A set of methods required device drivers that support child devices.
More...
A set of methods required device drivers that support child devices.
METHOD int activate_resource |
Initial value:
Activate a resource.
Activate a resource previously allocated with BUS_ALLOC_RESOURCE(). This may for instance map a memory region into the kernel's virtual address space.
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_type | the type of resource |
_rid | the resource identifier |
_r | the resource to activate |
Definition at line 284 of file bus_if.m.
METHOD device_t add_child |
Initial value:
Create a new child device.
For busses which use use drivers supporting DEVICE_IDENTIFY() to enumerate their devices, this method is used to create new device instances. The new device will be added after the last existing child with the same order.
- Parameters
-
_dev | the bus device which will be the parent of the new child device |
_order | a value which is used to partially sort the children of _dev - devices created using lower values of _order appear first in _dev's list of children |
_name | devclass name for new device or NULL if not specified |
_unit | unit number for new device or -1 if not specified |
Definition at line 225 of file bus_if.m.
METHOD int adjust_resource |
Initial value:
Adjust a resource.
Adjust the start and/or end of a resource allocated by BUS_ALLOC_RESOURCE. At least part of the new address range must overlap with the existing address range. If the successful, the resource's range will be adjusted to [start, end] on return.
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_type | the type of resource |
_res | the resource to adjust |
_start | the new starting address of the resource range |
_end | the new ending address of the resource range |
Definition at line 328 of file bus_if.m.
METHOD struct resource* alloc_resource |
Initial value:
Allocate a system resource.
This method is called by child devices of a bus to allocate resources. The types are defined in <machine/resource.h>; the meaning of the resource-ID field varies from bus to bus (but *rid
== 0 is always valid if the resource type is). If a resource was allocated and the caller did not use the RF_ACTIVE to specify that it should be activated immediately, the caller is responsible for calling BUS_ACTIVATE_RESOURCE() when it actually uses the resource.
- Parameters
-
_dev | the parent device of _child |
_child | the device which is requesting an allocation |
_type | the type of resource to allocate |
_rid | a pointer to the resource identifier |
_start | hint at the start of the resource range - pass 0UL for any start address |
_end | hint at the end of the resource range - pass ~0UL for any end address |
_count | hint at the size of range required - pass 1 for any size |
_flags | any extra flags to control the resource allocation - see RF_XXX flags in <sys/rman.h> for details |
- Returns
- the resource which was allocated or
NULL
if no resource could be allocated
Definition at line 260 of file bus_if.m.
Initial value:
Allow drivers to request that an interrupt be bound to a specific CPU.
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_irq | the resource representing the interrupt |
_cpu | the CPU to bind the interrupt to |
Definition at line 562 of file bus_if.m.
DEFAULT bus_generic_get_resource_list |
METHOD void child_deleted |
Initial value:
Notify a bus that a child was deleted.
Called at the beginning of device_delete_child() to allow the parent to teardown any bus-specific state for the child.
- Parameters
-
_dev | the device whose child is being deleted |
_child | the child device which is being deleted |
Definition at line 171 of file bus_if.m.
METHOD void child_detached |
Initial value:
Notify a bus that a child was detached.
Called after the child's DEVICE_DETACH() method to allow the parent to reclaim any resources allocated on behalf of the child.
- Parameters
-
_dev | the device whose child changed state |
_child | the child device which changed state |
Definition at line 185 of file bus_if.m.
METHOD int child_location_str |
Initial value:
Returns the location for this device.
Return it as a string. If the string is insufficient for the storage, then return EOVERFLOW.
- Parameters
-
_dev | the parent device of _child |
_child | the device which is being examined |
_buf | the address of a buffer to receive the location string |
_buflen | the size of the buffer pointed to by _buf |
Definition at line 546 of file bus_if.m.
METHOD int child_pnpinfo_str |
Initial value:
Returns the pnp info for this device.
Return it as a string. If the string is insufficient for the storage, then return EOVERFLOW.
- Parameters
-
_dev | the parent device of _child |
_child | the device which is being examined |
_buf | the address of a buffer to receive the pnp string |
_buflen | the size of the buffer pointed to by _buf |
Definition at line 527 of file bus_if.m.
Initial value:
Is the hardware described by _child
still attached to the system?
This method should return 0 if the device is not present. It should return -1 if it is present. Any errors in determining should be returned as a normal errno value. Client drivers are to assume that the device is present, even if there is an error determining if it is there. Busses are to try to avoid returning errors, but newcard will return an error if the device fails to implement this method.
- Parameters
-
_dev | the parent device of _child |
_child | the device which is being examined |
Definition at line 510 of file bus_if.m.
Initial value:{
static struct resource *
int type,
int *rid, u_long
start, u_long end,
u_long
count, u_int flags)
{
return (0);
}
static int
{
if (dev != NULL)
return (BUS_REMAP_INTR(dev, NULL, irq));
return (ENXIO);
}
static device_t
int unit)
{
panic(
"bus_add_child is not implemented");
}
}
void panic(const char *fmt,...)
DEFAULT null_alloc_resource
Definition at line 44 of file bus_if.m.
Initial value:
Allow (bus) drivers to specify the trigger mode and polarity of the specified interrupt.
- Parameters
-
_dev | the bus device |
_irq | the interrupt number to modify |
_trig | the trigger mode required |
_pol | the interrupt polarity required |
Definition at line 578 of file bus_if.m.
METHOD int deactivate_resource |
Initial value:
Deactivate a resource.
Deactivate a resource previously allocated with BUS_ALLOC_RESOURCE(). This may for instance unmap a memory region from the kernel's virtual address space.
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_type | the type of resource |
_rid | the resource identifier |
_r | the resource to deactivate |
Definition at line 305 of file bus_if.m.
METHOD void delete_resource |
Initial value:
Delete a resource.
Use this to delete a resource (possibly one previously added with BUS_SET_RESOURCE()).
- Parameters
-
_dev | the parent device of _child |
_child | the device which owns the resource |
_type | the type of resource |
_rid | the resource identifier |
Definition at line 473 of file bus_if.m.
Initial value:
Allow drivers to associate a description with an active interrupt handler.
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_irq | the resource representing the interrupt |
_cookie | the cookie value returned when the interrupt was originally registered |
_descr | the description to associate with the interrupt |
Definition at line 596 of file bus_if.m.
Initial value:
Notify a bus that a new driver was added.
Called when a new driver is added to the devclass which owns this bus. The generic implementation of this method attempts to probe and attach any un-matched children of the bus.
- Parameters
-
_dev | the device whose devclass had a new driver added to it |
_driver | the new driver which was added |
Definition at line 201 of file bus_if.m.
METHOD bus_dma_tag_t get_dma_tag |
Initial value:
Returns bus_dma_tag_t for use w/ devices on the bus.
- Parameters
-
_dev | the parent device of _child |
_child | the device to which the tag will belong |
Definition at line 632 of file bus_if.m.
Initial value:
Describe a resource.
This method allows a driver to examine the range used for a given resource without actually allocating it.
- Parameters
-
_dev | the parent device of _child |
_child | the device which owns the resource |
_type | the type of resource |
_rid | the resource identifier |
_start | the address of a location to recieve the start index of the resource range |
_count | the address of a location to recieve the size of the resource range |
Definition at line 453 of file bus_if.m.
METHOD struct resource_list* get_resource_list |
Initial value:
Return a struct resource_list.
Used by drivers which use bus_generic_rl_alloc_resource() etc. to implement their resource handling. It should return the resource list of the given child device.
- Parameters
-
_dev | the parent device of _child |
_child | the device which owns the resource list |
Definition at line 490 of file bus_if.m.
METHOD void hint_device_unit |
Initial value:
Allow the bus to determine the unit number of a device.
- Parameters
-
_dev | the parent device of _child |
_child | the device whose unit is to be wired |
_name | the name of the device's new devclass |
_unitp | a pointer to the device's new unit value |
Definition at line 645 of file bus_if.m.
Initial value:
Notify a (bus) driver about a child that the hints mechanism believes it has discovered.
The bus is responsible for then adding the child in the right order and discovering other things about the child. The bus driver is free to ignore this hint, to do special things, etc. It is all up to the bus driver to interpret.
This method is only called in response to the parent bus asking for hinted devices to be enumerated.
- Parameters
-
_dev | the bus device |
_dname | the name of the device w/o unit numbers |
_dunit | the unit number of the device |
Definition at line 620 of file bus_if.m.
Initial value:
Notify a bus that the bus pass level has been changed.
- Parameters
-
Definition at line 657 of file bus_if.m.
Initial value:
Print a description of a child device.
This is called from system code which prints out a description of a device. It should describe the attachment that the child has with the parent. For instance the TurboLaser bus prints which node the device is attached to. See bus_generic_print_child() for more information.
- Parameters
-
_dev | the device whose child is being printed |
_child | the child device to describe |
- Returns
- the number of characters output.
Definition at line 85 of file bus_if.m.
METHOD void probe_nomatch |
Initial value:
Print a notification about an unprobed child device.
Called for each child device that did not succeed in probing for a driver.
- Parameters
-
_dev | the device whose child was being probed |
_child | the child device which failed to probe |
Definition at line 99 of file bus_if.m.
Initial value:
Read the value of a bus-specific attribute of a device.
This method, along with BUS_WRITE_IVAR() manages a bus-specific set of instance variables of a child device. The intention is that each different type of bus defines a set of appropriate instance variables (such as ports and irqs for ISA bus etc.)
This information could be given to the child device as a struct but that makes it hard for a bus to add or remove variables without forcing an edit and recompile for all drivers which may not be possible for vendor supplied binary drivers.
This method copies the value of an instance variable to the location specified by *_result
.
- Parameters
-
_dev | the device whose child was being examined |
_child | the child device whose instance variable is being read |
_index | the instance variable to read |
_result | a loction to recieve the instance variable value |
- Return values
-
0 | success |
ENOENT | no such instance variable is supported by _dev |
Definition at line 131 of file bus_if.m.
METHOD int release_resource |
Initial value:
Release a resource.
Free a resource allocated by the BUS_ALLOC_RESOURCE. The _rid
value must be the same as the one returned by BUS_ALLOC_RESOURCE() (which is not necessarily the same as the one the client passed).
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_type | the type of resource |
_rid | the resource identifier |
_r | the resource to release |
Definition at line 350 of file bus_if.m.
Initial value:
Notify a bus that specified child's IRQ should be remapped.
- Parameters
-
_dev | the bus device |
_child | the child device |
_irq | the irq number |
Definition at line 668 of file bus_if.m.
Initial value:
Define a resource which can be allocated with BUS_ALLOC_RESOURCE().
This method is used by some busses (typically ISA) to allow a driver to describe a resource range that it would like to allocate. The resource defined by _type
and _rid
is defined to start at _start
and to include _count
indices in its range.
- Parameters
-
_dev | the parent device of _child |
_child | the device which owns the resource |
_type | the type of resource |
_rid | the resource identifier |
_start | the start of the resource range |
_count | the size of the resource range |
Definition at line 429 of file bus_if.m.
Initial value:
Install an interrupt handler.
This method is used to associate an interrupt handler function with an irq resource. When the interrupt triggers, the function _intr
will be called with the value of _arg
as its single argument. The value returned in *_cookiep
is used to cancel the interrupt handler - the caller should save this value to use in a future call to BUS_TEARDOWN_INTR().
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_irq | the resource representing the interrupt |
_flags | a set of bits from enum intr_type specifying the class of interrupt |
_intr | the function to call when the interrupt triggers |
_arg | a value to use as the single argument in calls to _intr |
_cookiep | a pointer to a location to recieve a cookie value that may be used to remove the interrupt handler |
Definition at line 381 of file bus_if.m.
Initial value:
Uninstall an interrupt handler.
This method is used to disassociate an interrupt handler function with an irq resource. The value of _cookie
must be the value returned from a previous call to BUS_SETUP_INTR().
- Parameters
-
_dev | the parent device of _child |
_child | the device which allocated the resource |
_irq | the resource representing the interrupt |
_cookie | the cookie value returned when the interrupt was originally registered |
Definition at line 405 of file bus_if.m.
Initial value:
Write the value of a bus-specific attribute of a device.
This method sets the value of an instance variable to _value
.
- Parameters
-
_dev | the device whose child was being updated |
_child | the child device whose instance variable is being written |
_index | the instance variable to write |
_value | the value to write to that instance variable |
- Return values
-
0 | success |
ENOENT | no such instance variable is supported by _dev |
EINVAL | the instance variable was recognised but contains a read-only value |
Definition at line 155 of file bus_if.m.