FreeBSD kernel kern code
|
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 int | rescan |
Rescan the bus. More... | |
METHOD struct resource * | alloc_resource |
Allocate a system resource. More... | |
int | _type |
int * | _rid |
rman_res_t | _start |
rman_res_t | _end |
rman_res_t | _count |
u_int | _flags |
DEFAULT | null_alloc_resource |
METHOD int | activate_resource |
Activate a resource. More... | |
struct resource * | _r |
METHOD int | map_resource |
Map a resource. More... | |
struct resource_map_request * | _args |
struct resource_map * | _map |
DEFAULT | bus_generic_map_resource |
METHOD int | unmap_resource |
Unmap a resource. More... | |
DEFAULT | bus_generic_unmap_resource |
METHOD int | deactivate_resource |
Deactivate a resource. More... | |
METHOD int | adjust_resource |
Adjust a resource. More... | |
struct resource * | _res |
METHOD int | translate_resource |
translate a resource value More... | |
rman_res_t * | _newstart |
DEFAULT | bus_generic_translate_resource |
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 | suspend_intr |
Suspend an interrupt handler. More... | |
DEFAULT | bus_generic_suspend_intr |
METHOD int | resume_intr |
Resume an interrupt handler. More... | |
DEFAULT | bus_generic_resume_intr |
METHOD int | set_resource |
Define a resource which can be allocated with BUS_ALLOC_RESOURCE(). More... | |
METHOD int | get_resource |
Describe a resource. More... | |
rman_res_t * | _startp |
rman_res_t * | _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 |
Returns the pnp info for this device. More... | |
struct sbuf * | _sb |
DEFAULT | bus_generic_child_pnpinfo |
METHOD int | child_location |
Returns the location for this device. More... | |
DEFAULT | bus_generic_child_location |
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 bus_space_tag_t | get_bus_tag |
Returns bus_space_tag_t for use w/ devices on the bus. More... | |
DEFAULT | bus_generic_get_bus_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 |
METHOD int | suspend_child |
Suspend a given child. More... | |
DEFAULT | bus_generic_suspend_child |
METHOD int | resume_child |
Resume a given child. More... | |
DEFAULT | bus_generic_resume_child |
METHOD int | get_domain |
Get the VM domain handle for the given bus and child. More... | |
int * | _domain |
DEFAULT | bus_generic_get_domain |
METHOD int | get_cpus |
Request a set of CPUs. More... | |
enum cpu_sets | _op |
size_t | _setsize |
struct _cpuset * | _cpuset |
DEFAULT | bus_generic_get_cpus |
METHOD int | reset_prepare |
Prepares the given child of the bus for reset. More... | |
DEFAULT | null_reset_prepare |
METHOD int | reset_post |
Restores the child operations after the reset. More... | |
DEFAULT | null_reset_post |
METHOD int | reset_child |
Performs reset of the child. More... | |
METHOD ssize_t | get_property |
Gets child's specific property. More... | |
const char * | _propname |
void * | _propvalue |
size_t | _size |
device_property_type_t | type |
DEFAULT | bus_generic_get_property |
METHOD int | get_device_path |
Gets a child's full path to the device. More... | |
const char * | _locator |
DEFAULT | bus_generic_get_device_path |
A set of methods required device drivers that support child devices.
int _flags |
Definition at line 294 of file bus_if.m.
Referenced by umtx_copyin_umtx_timei386().
METHOD int activate_resource |
Activate a resource.
Activate a resource previously allocated with BUS_ALLOC_RESOURCE(). This may enable decoding of this resource in a device for instance. It will also establish a mapping for the resource unless RF_UNMAPPED was set when allocating the resource.
_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 |
METHOD device_t add_child |
Create a new child device.
For buses 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. Implementations of bus_add_child call device_add_child_ordered to add the child and often add a suitable ivar to the device specific to that bus.
_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 |
METHOD int adjust_resource |
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.
_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 |
METHOD struct resource* alloc_resource |
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.
_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 0 for any start address |
_end | hint at the end of the resource range - pass ~0 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 |
NULL
if no resource could be allocated METHOD int bind_intr |
Allow drivers to request that an interrupt be bound to a specific CPU.
_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 |
INTERFACE bus |
Definition at line 39 of file bus_if.m.
Referenced by bus_enumerate_hinted_children(), bus_generic_get_device_path(), device_get_property(), driver_exists(), resource_list_alloc(), resource_list_release(), resource_list_release_active(), resource_list_reserve(), and resource_list_unreserve().
METHOD void child_deleted |
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.
_dev | the device whose child is being deleted |
_child | the child device which is being deleted |
METHOD void child_detached |
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.
_dev | the device whose child changed state |
_child | the child device which changed state |
METHOD int child_location |
Returns the location for this device.
Return it as a string, appended to _sb
The string must be formatted as a space-separated list of name=value pairs. Names may only contain alphanumeric characters, underscores ('_') and hyphens ('-'). Values can contain any non-whitespace characters. Values containing whitespace can be quoted with double quotes ('"'). Double quotes and backslashes in quoted values can be escaped with backslashes ('\').
_dev | the parent device of _child |
_child | the device which is being examined |
_sb | sbuf for results string |
METHOD int child_pnpinfo |
Returns the pnp info for this device.
Return it as a string, appended to _sb
The string must be formatted as a space-separated list of name=value pairs. Names may only contain alphanumeric characters, underscores ('_') and hyphens ('-'). Values can contain any non-whitespace characters. Values containing whitespace can be quoted with double quotes ('"'). Double quotes and backslashes in quoted values can be escaped with backslashes ('\').
_dev | the parent device of _child |
_child | the device which is being examined |
_sb | sbuf for results string |
METHOD int child_present |
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. Buses are to try to avoid returning errors, but newcard will return an error if the device fails to implement this method.
_dev | the parent device of _child |
_child | the device which is being examined |
METHOD int config_intr |
METHOD int deactivate_resource |
Deactivate a resource.
Deactivate a resource previously allocated with BUS_ALLOC_RESOURCE().
_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 |
METHOD void delete_resource |
Delete a resource.
Use this to delete a resource (possibly one previously added with BUS_SET_RESOURCE()).
_dev | the parent device of _child |
_child | the device which owns the resource |
_type | the type of resource |
_rid | the resource identifier |
METHOD int describe_intr |
Allow drivers to associate a description with an active interrupt handler.
_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 |
METHOD void driver_added |
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.
_dev | the device whose devclass had a new driver added to it |
_driver | the new driver which was added |
METHOD bus_space_tag_t get_bus_tag |
METHOD int get_cpus |
METHOD int get_device_path |
Gets a child's full path to the device.
The get_device_path method retrieves a device's full path to the device using one of several locators present in the system.
_bus | the bus device |
_child | the child device |
_locator | locator name |
_sb | buffer loaction string |
METHOD bus_dma_tag_t get_dma_tag |
METHOD int get_domain |
METHOD ssize_t get_property |
Gets child's specific property.
The bus_get_property can be used to access device specific properties stored on the bus. If _propvalue is NULL or _size is 0, then method only returns size of the property.
_dev | the bus device |
_child | the child device |
_propname | property name |
_propvalue | property value destination |
_size | property value size |
METHOD int get_resource |
Describe a resource.
This method allows a driver to examine the range used for a given resource without actually allocating it.
_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 receive the start index of the resource range |
_count | the address of a location to receive the size of the resource range |
METHOD struct resource_list* get_resource_list |
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.
_dev | the parent device of _child |
_child | the device which owns the resource list |
METHOD void hint_device_unit |
Allow the bus to determine the unit number of a device.
_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 |
METHOD void hinted_child |
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.
_dev | the bus device |
_dname | the name of the device w/o unit numbers |
_dunit | the unit number of the device |
METHOD int map_resource |
Map a resource.
Allocate a mapping for a range of an active resource. The mapping is described by a struct resource_map object. This may for instance map a memory region into the kernel's virtual address space.
_dev | the parent device of _child |
_child | the device which allocated the resource |
_type | the type of resource |
_r | the resource to map |
_args | optional attributes of the mapping |
_map | the mapping |
METHOD void new_pass |
METHOD int print_child |
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.
_dev | the device whose child is being printed |
_child | the child device to describe |
METHOD void probe_nomatch |
METHOD int read_ivar |
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
.
_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 location to receive the instance variable value |
0 | success |
ENOENT | no such instance variable is supported by _dev |
METHOD int release_resource |
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).
_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 |
METHOD int remap_intr |
METHOD int rescan |
METHOD int reset_child |
METHOD int reset_post |
Restores the child operations after the reset.
The bus_helper_reset_post() helper is provided to ease implementing bus reset methods.
_dev | the bus device |
_child | the child device |
METHOD int reset_prepare |
Prepares the given child of the bus for reset.
Typically bus detaches or suspends children' drivers, and then calls this method to save bus-specific information, for instance, PCI config space, which is damaged by reset.
The bus_helper_reset_prepare() helper is provided to ease implementing bus reset methods.
_dev | the bus device |
_child | the child device |
METHOD int resume_child |
METHOD int resume_intr |
Resume an interrupt handler.
This method is used to clear suspended state of a handler when the associated device is powered up and can be an interrupt source again. The value of _irq
must be the interrupt resource passed to a previous call to BUS_SETUP_INTR().
_dev | the parent device of _child |
_child | the device which allocated the resource |
_irq | the resource representing the interrupt |
METHOD int set_resource |
Define a resource which can be allocated with BUS_ALLOC_RESOURCE().
This method is used by some buses (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.
_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 |
METHOD int setup_intr |
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().
_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 receive a cookie value that may be used to remove the interrupt handler |
METHOD int suspend_child |
METHOD int suspend_intr |
Suspend an interrupt handler.
This method is used to mark a handler as suspended in the case that the associated device is powered down and cannot be a source for the, typically shared, interrupt. The value of _irq
must be the interrupt resource passed to a previous call to BUS_SETUP_INTR().
_dev | the parent device of _child |
_child | the device which allocated the resource |
_irq | the resource representing the interrupt |
METHOD int teardown_intr |
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().
_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 |
METHOD int translate_resource |
translate a resource value
Give a bus driver the opportunity to translate resource ranges. If successful, the host's view of the resource starting at _start
is returned in _newstart
, otherwise an error is returned.
_dev | the device associated with the resource |
_type | the type of resource |
_start | the starting address of the resource range |
_newstart | the new starting address of the resource range |
device_property_type_t type |
Definition at line 941 of file bus_if.m.
Referenced by __sanitizer_cov_trace_switch(), _mtx_init(), acl_copyin(), acl_copyout(), acl_type_unold(), aio_aqueue(), aiocb_copyin(), buf_ring_alloc(), buf_ring_free(), bus_activate_resource(), bus_adjust_resource(), bus_alloc_resource(), bus_alloc_resources(), bus_deactivate_resource(), bus_delete_resource(), bus_free_resource(), bus_generic_activate_resource(), bus_generic_adjust_resource(), bus_generic_alloc_resource(), bus_generic_deactivate_resource(), bus_generic_get_property(), bus_generic_map_resource(), bus_generic_release_resource(), bus_generic_rl_alloc_resource(), bus_generic_rl_delete_resource(), bus_generic_rl_get_resource(), bus_generic_rl_release_resource(), bus_generic_rl_set_resource(), bus_generic_translate_resource(), bus_generic_unmap_resource(), bus_get_resource(), bus_get_resource_count(), bus_get_resource_start(), bus_map_resource(), bus_release_resource(), bus_release_resources(), bus_set_resource(), bus_translate_resource(), bus_unmap_resource(), cf_get_method(), contigfree(), contigmalloc(), contigmalloc_domainset(), cpufreq_add_levels(), devaddq(), devctl_notify(), device_get_property(), do_osd_del(), do_wake2_umutex(), filt_timertouch(), filt_usertouch(), finit(), firmware_modevent(), get_proc_vector(), get_ps_strings(), hashdestroy(), hashinit(), hashinit_flags(), intr_alloc_map_data(), kdb_trap(), kern___acl_aclcheck_path(), kern___acl_delete_path(), kern___acl_get_path(), kern___acl_set_path(), kern_socket(), kern_socketpair(), kern_specialfd(), kmsan_orig(), kmsan_orig_name(), kmsan_report_hook(), kmsan_report_inline(), lf_findoverlap(), link_elf_link_preload(), linker_lookup_file(), lock_init(), m_extadd(), m_get2(), m_get3(), m_getjcl(), m_getm2(), m_tag_alloc(), m_tag_locate(), malloc_aligned(), mallocarray(), mallocarray_domainset(), mb_ctor_mbuf(), mb_ctor_pack(), mb_put_mem(), md_get_mem(), mount_devctl_event(), osd_call(), osd_del(), osd_deregister(), osd_exit(), osd_get(), osd_register(), osd_set(), osd_set_reserved(), parse_type(), pf_proto_unregister(), pffindproto(), pffindtype(), phashinit(), phashinit_flags(), populate_note(), preload_dump_internal(), preload_modinfo_type(), preload_modinfo_value(), preload_search_by_type(), preload_search_info(), proc_id_clear(), proc_id_set(), proc_id_set_cond(), register_note(), resource_list_add(), resource_list_add_next(), resource_list_alloc(), resource_list_busy(), resource_list_delete(), resource_list_find(), resource_list_print_type(), resource_list_release(), resource_list_release_active(), resource_list_reserve(), resource_list_reserved(), resource_list_unreserve(), sbcreatecontrol(), sbcreatecontrol_how(), sleepq_type(), sockargs(), socreate(), soreceive_generic(), sysctl_debug_tslog(), trace_cmp(), tslog(), umtx_key_get(), vaccess(), vaccess_acl_nfs4(), vaccess_acl_posix1e(), vacl_aclcheck(), vacl_delete(), vacl_get_acl(), vacl_set_acl(), vfs_modevent(), vmem_add1(), vn_fullpath_hardlink(), vn_open_vnode_advlock(), and witness_init().
METHOD int unmap_resource |
Unmap a resource.
Release a mapping previously allocated with BUS_MAP_RESOURCE(). This may for instance unmap a memory region from the kernel's virtual address space.
_dev | the parent device of _child |
_child | the device which allocated the resource |
_type | the type of resource |
_r | the resource |
_map | the mapping to release |
METHOD int write_ivar |
Write the value of a bus-specific attribute of a device.
This method sets the value of an instance variable to _value
.
_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 |
0 | success |
ENOENT | no such instance variable is supported by _dev |
EINVAL | the instance variable was recognised but contains a read-only value |