FreeBSD kernel kern code
bus - KObj methods for drivers of devices with children

A set of methods required device drivers that support child devices. More...

Variables

INTERFACE bus
 
 CODE
 
METHOD int print_child
 Print a description of a child device. More...
 
device_t _child
 
DEFAULT bus_generic_print_child
 
METHOD void probe_nomatch
 Print a notification about an unprobed child device. More...
 
METHOD int read_ivar
 Read the value of a bus-specific attribute of a device. More...
 
int _index
 
uintptr_t * _result
 
METHOD int write_ivar
 Write the value of a bus-specific attribute of a device. More...
 
int _indx
 
uintptr_t _value
 
METHOD void child_deleted
 Notify a bus that a child was deleted. More...
 
METHOD void child_detached
 Notify a bus that a child was detached. More...
 
METHOD void driver_added
 Notify a bus that a new driver was added. More...
 
driver_t * _driver
 
DEFAULT bus_generic_driver_added
 
METHOD device_t add_child
 Create a new child device. More...
 
u_int _order
 
const char * _name
 
int _unit
 
DEFAULT null_add_child
 
METHOD struct resource * alloc_resource
 Allocate a system resource. More...
 
int _type
 
int * _rid
 
u_long _start
 
u_long _end
 
u_long _count
 
u_int _flags
 
DEFAULT null_alloc_resource
 
METHOD int activate_resource
 Activate a resource. More...
 
struct resource * _r
 
METHOD int deactivate_resource
 Deactivate a resource. More...
 
METHOD int adjust_resource
 Adjust a resource. More...
 
struct resource * _res
 
METHOD int release_resource
 Release a resource. More...
 
METHOD int setup_intr
 Install an interrupt handler. More...
 
struct resource * _irq
 
driver_filter_t * _filter
 
driver_intr_t * _intr
 
void * _arg
 
void ** _cookiep
 
METHOD int teardown_intr
 Uninstall an interrupt handler. More...
 
void * _cookie
 
METHOD int set_resource
 Define a resource which can be allocated with BUS_ALLOC_RESOURCE(). More...
 
METHOD int get_resource
 Describe a resource. More...
 
u_long * _startp
 
u_long * _countp
 
METHOD void delete_resource
 Delete a resource. More...
 
METHOD struct resource_list * get_resource_list
 Return a struct resource_list. More...
 
DEFAULT bus_generic_get_resource_list
 
METHOD int child_present
 Is the hardware described by _child still attached to the system? More...
 
DEFAULT bus_generic_child_present
 
METHOD int child_pnpinfo_str
 Returns the pnp info for this device. More...
 
char * _buf
 
size_t _buflen
 
METHOD int child_location_str
 Returns the location for this device. More...
 
METHOD int bind_intr
 Allow drivers to request that an interrupt be bound to a specific CPU. More...
 
int _cpu
 
DEFAULT bus_generic_bind_intr
 
METHOD int config_intr
 Allow (bus) drivers to specify the trigger mode and polarity of the specified interrupt. More...
 
enum intr_trigger _trig
 
enum intr_polarity _pol
 
DEFAULT bus_generic_config_intr
 
METHOD int describe_intr
 Allow drivers to associate a description with an active interrupt handler. More...
 
const char * _descr
 
DEFAULT bus_generic_describe_intr
 
METHOD void hinted_child
 Notify a (bus) driver about a child that the hints mechanism believes it has discovered. More...
 
const char * _dname
 
int _dunit
 
METHOD bus_dma_tag_t get_dma_tag
 Returns bus_dma_tag_t for use w/ devices on the bus. More...
 
DEFAULT bus_generic_get_dma_tag
 
METHOD void hint_device_unit
 Allow the bus to determine the unit number of a device. More...
 
int * _unitp
 
METHOD void new_pass
 Notify a bus that the bus pass level has been changed. More...
 
DEFAULT bus_generic_new_pass
 
METHOD int remap_intr
 Notify a bus that specified child's IRQ should be remapped. More...
 
DEFAULT null_remap_intr
 

Detailed Description

A set of methods required device drivers that support child devices.

Variable Documentation

void* _arg

Definition at line 388 of file bus_if.m.

char * _buf

Definition at line 530 of file bus_if.m.

size_t _buflen

Definition at line 531 of file bus_if.m.

device_t _child

Definition at line 87 of file bus_if.m.

void * _cookie

Definition at line 409 of file bus_if.m.

void** _cookiep

Definition at line 389 of file bus_if.m.

u_long _count

Definition at line 267 of file bus_if.m.

u_long* _countp

Definition at line 459 of file bus_if.m.

int _cpu

Definition at line 566 of file bus_if.m.

const char* _descr

Definition at line 601 of file bus_if.m.

const char* _dname

Definition at line 622 of file bus_if.m.

driver_t* _driver

Definition at line 203 of file bus_if.m.

int _dunit

Definition at line 623 of file bus_if.m.

u_long _end

Definition at line 266 of file bus_if.m.

driver_filter_t* _filter

Definition at line 386 of file bus_if.m.

int _flags

Definition at line 268 of file bus_if.m.

int _index

Definition at line 134 of file bus_if.m.

int _indx

Definition at line 158 of file bus_if.m.

driver_intr_t* _intr

Definition at line 387 of file bus_if.m.

u_int _irq

Definition at line 384 of file bus_if.m.

const char * _name

Definition at line 228 of file bus_if.m.

u_int _order

Definition at line 227 of file bus_if.m.

enum intr_polarity _pol

Definition at line 582 of file bus_if.m.

struct resource * _r

Definition at line 289 of file bus_if.m.

struct resource * _res

Definition at line 332 of file bus_if.m.

uintptr_t* _result

Definition at line 135 of file bus_if.m.

int _rid

Definition at line 264 of file bus_if.m.

u_long _start

Definition at line 265 of file bus_if.m.

u_long* _startp

Definition at line 458 of file bus_if.m.

enum intr_trigger _trig

Definition at line 581 of file bus_if.m.

int _type

Definition at line 263 of file bus_if.m.

int _unit

Definition at line 229 of file bus_if.m.

int* _unitp

Definition at line 649 of file bus_if.m.

uintptr_t _value

Definition at line 159 of file bus_if.m.

METHOD int activate_resource
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which allocated the resource
_typethe type of resource
_ridthe resource identifier
_rthe resource to activate

Definition at line 284 of file bus_if.m.

METHOD device_t add_child
Initial value:
{
device_t _dev

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
_devthe bus device which will be the parent of the new child device
_ordera 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
_namedevclass name for new device or NULL if not specified
_unitunit number for new device or -1 if not specified

Definition at line 225 of file bus_if.m.

METHOD int adjust_resource
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which allocated the resource
_typethe type of resource
_resthe resource to adjust
_startthe new starting address of the resource range
_endthe new ending address of the resource range

Definition at line 328 of file bus_if.m.

METHOD struct resource* alloc_resource
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which is requesting an allocation
_typethe type of resource to allocate
_rida pointer to the resource identifier
_starthint at the start of the resource range - pass 0UL for any start address
_endhint at the end of the resource range - pass ~0UL for any end address
_counthint at the size of range required - pass 1 for any size
_flagsany 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.

METHOD int bind_intr
Initial value:
{
device_t _dev

Allow drivers to request that an interrupt be bound to a specific CPU.

Parameters
_devthe parent device of _child
_childthe device which allocated the resource
_irqthe resource representing the interrupt
_cputhe CPU to bind the interrupt to

Definition at line 562 of file bus_if.m.

INTERFACE bus
DEFAULT bus_generic_bind_intr

Definition at line 567 of file bus_if.m.

DEFAULT bus_generic_child_present

Definition at line 513 of file bus_if.m.

DEFAULT bus_generic_config_intr

Definition at line 583 of file bus_if.m.

DEFAULT bus_generic_describe_intr

Definition at line 602 of file bus_if.m.

DEFAULT bus_generic_driver_added

Definition at line 204 of file bus_if.m.

DEFAULT bus_generic_get_dma_tag

Definition at line 635 of file bus_if.m.

DEFAULT bus_generic_get_resource_list

Definition at line 493 of file bus_if.m.

DEFAULT bus_generic_new_pass

Definition at line 659 of file bus_if.m.

DEFAULT bus_generic_print_child

Definition at line 88 of file bus_if.m.

METHOD void child_deleted
Initial value:
{
device_t _dev

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
_devthe device whose child is being deleted
_childthe child device which is being deleted

Definition at line 171 of file bus_if.m.

METHOD void child_detached
Initial value:
{
device_t _dev

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
_devthe device whose child changed state
_childthe child device which changed state

Definition at line 185 of file bus_if.m.

METHOD int child_location_str
Initial value:
{
device_t _dev

Returns the location for this device.

Return it as a string. If the string is insufficient for the storage, then return EOVERFLOW.

Parameters
_devthe parent device of _child
_childthe device which is being examined
_bufthe address of a buffer to receive the location string
_buflenthe size of the buffer pointed to by _buf

Definition at line 546 of file bus_if.m.

METHOD int child_pnpinfo_str
Initial value:
{
device_t _dev

Returns the pnp info for this device.

Return it as a string. If the string is insufficient for the storage, then return EOVERFLOW.

Parameters
_devthe parent device of _child
_childthe device which is being examined
_bufthe address of a buffer to receive the pnp string
_buflenthe size of the buffer pointed to by _buf

Definition at line 527 of file bus_if.m.

METHOD int child_present
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which is being examined

Definition at line 510 of file bus_if.m.

CODE
Initial value:
{
static struct resource *
null_alloc_resource(device_t dev, device_t child,
int type, int *rid, u_long start, u_long end,
u_long count, u_int flags)
{
return (0);
}
static int
null_remap_intr(device_t bus, device_t dev, u_int irq)
{
if (dev != NULL)
return (BUS_REMAP_INTR(dev, NULL, irq));
return (ENXIO);
}
static device_t
null_add_child(device_t bus, int order, const char *name,
int unit)
{
panic("bus_add_child is not implemented");
}
}
INTERFACE bus
Definition: bus_if.m:39
void *** start
Definition: linker_if.m:86
void panic(const char *fmt,...)
const char * name
Definition: kern_fail.c:97
DEFAULT null_add_child
Definition: bus_if.m:230
int * type
Definition: cpufreq_if.m:98
DEFAULT null_alloc_resource
Definition: bus_if.m:269
DEFAULT null_remap_intr
Definition: bus_if.m:672
int * count
Definition: cpufreq_if.m:63

Definition at line 44 of file bus_if.m.

METHOD int config_intr
Initial value:
{
device_t _dev

Allow (bus) drivers to specify the trigger mode and polarity of the specified interrupt.

Parameters
_devthe bus device
_irqthe interrupt number to modify
_trigthe trigger mode required
_polthe interrupt polarity required

Definition at line 578 of file bus_if.m.

METHOD int deactivate_resource
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which allocated the resource
_typethe type of resource
_ridthe resource identifier
_rthe resource to deactivate

Definition at line 305 of file bus_if.m.

METHOD void delete_resource
Initial value:
{
device_t _dev

Delete a resource.

Use this to delete a resource (possibly one previously added with BUS_SET_RESOURCE()).

Parameters
_devthe parent device of _child
_childthe device which owns the resource
_typethe type of resource
_ridthe resource identifier

Definition at line 473 of file bus_if.m.

METHOD int describe_intr
Initial value:
{
device_t _dev

Allow drivers to associate a description with an active interrupt handler.

Parameters
_devthe parent device of _child
_childthe device which allocated the resource
_irqthe resource representing the interrupt
_cookiethe cookie value returned when the interrupt was originally registered
_descrthe description to associate with the interrupt

Definition at line 596 of file bus_if.m.

METHOD void driver_added
Initial value:
{
device_t _dev

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
_devthe device whose devclass had a new driver added to it
_driverthe new driver which was added

Definition at line 201 of file bus_if.m.

METHOD bus_dma_tag_t get_dma_tag
Initial value:
{
device_t _dev

Returns bus_dma_tag_t for use w/ devices on the bus.

Parameters
_devthe parent device of _child
_childthe device to which the tag will belong

Definition at line 632 of file bus_if.m.

METHOD int get_resource
Initial value:
{
device_t _dev

Describe a resource.

This method allows a driver to examine the range used for a given resource without actually allocating it.

Parameters
_devthe parent device of _child
_childthe device which owns the resource
_typethe type of resource
_ridthe resource identifier
_startthe address of a location to recieve the start index of the resource range
_countthe 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:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which owns the resource list

Definition at line 490 of file bus_if.m.

METHOD void hint_device_unit
Initial value:
{
device_t _dev

Allow the bus to determine the unit number of a device.

Parameters
_devthe parent device of _child
_childthe device whose unit is to be wired
_namethe name of the device's new devclass
_unitpa pointer to the device's new unit value

Definition at line 645 of file bus_if.m.

METHOD void hinted_child
Initial value:
{
device_t _dev

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
_devthe bus device
_dnamethe name of the device w/o unit numbers
_dunitthe unit number of the device

Definition at line 620 of file bus_if.m.

METHOD void new_pass
Initial value:
{
device_t _dev

Notify a bus that the bus pass level has been changed.

Parameters
_devthe bus device

Definition at line 657 of file bus_if.m.

DEFAULT null_add_child

Definition at line 230 of file bus_if.m.

DEFAULT null_alloc_resource

Definition at line 269 of file bus_if.m.

DEFAULT null_remap_intr

Definition at line 672 of file bus_if.m.

METHOD int print_child
Initial value:
{
device_t _dev

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
_devthe device whose child is being printed
_childthe 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:
{
device_t _dev

Print a notification about an unprobed child device.

Called for each child device that did not succeed in probing for a driver.

Parameters
_devthe device whose child was being probed
_childthe child device which failed to probe

Definition at line 99 of file bus_if.m.

METHOD int read_ivar
Initial value:
{
device_t _dev

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
_devthe device whose child was being examined
_childthe child device whose instance variable is being read
_indexthe instance variable to read
_resulta loction to recieve the instance variable value
Return values
0success
ENOENTno such instance variable is supported by _dev

Definition at line 131 of file bus_if.m.

METHOD int release_resource
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which allocated the resource
_typethe type of resource
_ridthe resource identifier
_rthe resource to release

Definition at line 350 of file bus_if.m.

METHOD int remap_intr
Initial value:
{
device_t _dev

Notify a bus that specified child's IRQ should be remapped.

Parameters
_devthe bus device
_childthe child device
_irqthe irq number

Definition at line 668 of file bus_if.m.

METHOD int set_resource
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which owns the resource
_typethe type of resource
_ridthe resource identifier
_startthe start of the resource range
_countthe size of the resource range

Definition at line 429 of file bus_if.m.

METHOD int setup_intr
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which allocated the resource
_irqthe resource representing the interrupt
_flagsa set of bits from enum intr_type specifying the class of interrupt
_intrthe function to call when the interrupt triggers
_arga value to use as the single argument in calls to _intr
_cookiepa 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.

METHOD int teardown_intr
Initial value:
{
device_t _dev

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
_devthe parent device of _child
_childthe device which allocated the resource
_irqthe resource representing the interrupt
_cookiethe cookie value returned when the interrupt was originally registered

Definition at line 405 of file bus_if.m.

METHOD int write_ivar
Initial value:
{
device_t _dev

Write the value of a bus-specific attribute of a device.

This method sets the value of an instance variable to _value.

Parameters
_devthe device whose child was being updated
_childthe child device whose instance variable is being written
_indexthe instance variable to write
_valuethe value to write to that instance variable
Return values
0success
ENOENTno such instance variable is supported by _dev
EINVALthe instance variable was recognised but contains a read-only value

Definition at line 155 of file bus_if.m.