1139804Simp#- 2133588Simp# Copyright (c) 1998-2004 Doug Rabson 336973Sdfr# All rights reserved. 436973Sdfr# 536973Sdfr# Redistribution and use in source and binary forms, with or without 636973Sdfr# modification, are permitted provided that the following conditions 736973Sdfr# are met: 836973Sdfr# 1. Redistributions of source code must retain the above copyright 936973Sdfr# notice, this list of conditions and the following disclaimer. 1036973Sdfr# 2. Redistributions in binary form must reproduce the above copyright 1136973Sdfr# notice, this list of conditions and the following disclaimer in the 1236973Sdfr# documentation and/or other materials provided with the distribution. 1336973Sdfr# 1436973Sdfr# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1536973Sdfr# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1636973Sdfr# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1736973Sdfr# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1836973Sdfr# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1936973Sdfr# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2036973Sdfr# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2136973Sdfr# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2236973Sdfr# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2336973Sdfr# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2436973Sdfr# SUCH DAMAGE. 2536973Sdfr# 2650477Speter# $FreeBSD$ 2736973Sdfr# 2836973Sdfr 29212544Savg#include <sys/types.h> 30212544Savg#include <sys/systm.h> 3159093Sdfr#include <sys/bus.h> 3259093Sdfr 33132354Sdfr/** 34132354Sdfr * @defgroup BUS bus - KObj methods for drivers of devices with children 35132354Sdfr * @brief A set of methods required device drivers that support 36132354Sdfr * child devices. 37132354Sdfr * @{ 38132354Sdfr */ 3941017SnsouchINTERFACE bus; 4036973Sdfr 4136973Sdfr# 4246913Sdfr# Default implementations of some methods. 4346913Sdfr# 4446913SdfrCODE { 4546913Sdfr static struct resource * 4646913Sdfr null_alloc_resource(device_t dev, device_t child, 47100421Simp int type, int *rid, u_long start, u_long end, 48100421Simp u_long count, u_int flags) 4946913Sdfr { 50100421Simp return (0); 5146913Sdfr } 52209154Smav 53209154Smav static int 54209154Smav null_remap_intr(device_t bus, device_t dev, u_int irq) 55209154Smav { 56209154Smav 57209154Smav if (dev != NULL) 58209154Smav return (BUS_REMAP_INTR(dev, NULL, irq)); 59209154Smav return (ENXIO); 60209154Smav } 61212544Savg 62212544Savg static device_t 63212544Savg null_add_child(device_t bus, int order, const char *name, 64212544Savg int unit) 65212544Savg { 66212544Savg 67212544Savg panic("bus_add_child is not implemented"); 68212544Savg } 6946913Sdfr}; 7046913Sdfr 71132354Sdfr/** 72132354Sdfr * @brief Print a description of a child device 73132354Sdfr * 74132354Sdfr * This is called from system code which prints out a description of a 75132354Sdfr * device. It should describe the attachment that the child has with 76132354Sdfr * the parent. For instance the TurboLaser bus prints which node the 77132354Sdfr * device is attached to. See bus_generic_print_child() for more 78132354Sdfr * information. 79132354Sdfr * 80132354Sdfr * @param _dev the device whose child is being printed 81132354Sdfr * @param _child the child device to describe 82132354Sdfr * 83132354Sdfr * @returns the number of characters output. 84132354Sdfr */ 8549195SmdoddMETHOD int print_child { 86132354Sdfr device_t _dev; 87132354Sdfr device_t _child; 88112588Smdodd} DEFAULT bus_generic_print_child; 8936973Sdfr 90132354Sdfr/** 91132354Sdfr * @brief Print a notification about an unprobed child device. 92132354Sdfr * 93132354Sdfr * Called for each child device that did not succeed in probing for a 94132354Sdfr * driver. 95132354Sdfr * 96132354Sdfr * @param _dev the device whose child was being probed 97132354Sdfr * @param _child the child device which failed to probe 98132354Sdfr */ 9948754SdfrMETHOD void probe_nomatch { 100132354Sdfr device_t _dev; 101132354Sdfr device_t _child; 10248754Sdfr}; 10348754Sdfr 104132354Sdfr/** 105132354Sdfr * @brief Read the value of a bus-specific attribute of a device 106132354Sdfr * 107132354Sdfr * This method, along with BUS_WRITE_IVAR() manages a bus-specific set 108132354Sdfr * of instance variables of a child device. The intention is that 109132354Sdfr * each different type of bus defines a set of appropriate instance 110132354Sdfr * variables (such as ports and irqs for ISA bus etc.) 111132354Sdfr * 112132354Sdfr * This information could be given to the child device as a struct but 113132354Sdfr * that makes it hard for a bus to add or remove variables without 114132354Sdfr * forcing an edit and recompile for all drivers which may not be 115132354Sdfr * possible for vendor supplied binary drivers. 116132354Sdfr * 117132354Sdfr * This method copies the value of an instance variable to the 118132354Sdfr * location specified by @p *_result. 119132354Sdfr * 120132354Sdfr * @param _dev the device whose child was being examined 121132354Sdfr * @param _child the child device whose instance variable is 122132354Sdfr * being read 123132354Sdfr * @param _index the instance variable to read 124132354Sdfr * @param _result a loction to recieve the instance variable 125132354Sdfr * value 126132354Sdfr * 127132354Sdfr * @retval 0 success 128132354Sdfr * @retval ENOENT no such instance variable is supported by @p 129132354Sdfr * _dev 130132354Sdfr */ 13136973SdfrMETHOD int read_ivar { 13295201Smarkm device_t _dev; 13395201Smarkm device_t _child; 134132354Sdfr int _index; 13595201Smarkm uintptr_t *_result; 13636973Sdfr}; 13736973Sdfr 138132354Sdfr/** 139132354Sdfr * @brief Write the value of a bus-specific attribute of a device 140132354Sdfr * 141132354Sdfr * This method sets the value of an instance variable to @p _value. 142132354Sdfr * 143132354Sdfr * @param _dev the device whose child was being updated 144132354Sdfr * @param _child the child device whose instance variable is 145132354Sdfr * being written 146132354Sdfr * @param _index the instance variable to write 147132354Sdfr * @param _value the value to write to that instance variable 148132354Sdfr * 149132354Sdfr * @retval 0 success 150132354Sdfr * @retval ENOENT no such instance variable is supported by @p 151132354Sdfr * _dev 152132354Sdfr * @retval EINVAL the instance variable was recognised but 153132354Sdfr * contains a read-only value 154132354Sdfr */ 15536973SdfrMETHOD int write_ivar { 15695201Smarkm device_t _dev; 15795201Smarkm device_t _child; 15895201Smarkm int _indx; 15995201Smarkm uintptr_t _value; 16036973Sdfr}; 16136973Sdfr 162132354Sdfr/** 163239512Sjhb * @brief Notify a bus that a child was deleted 164239512Sjhb * 165239512Sjhb * Called at the beginning of device_delete_child() to allow the parent 166239512Sjhb * to teardown any bus-specific state for the child. 167239512Sjhb * 168239512Sjhb * @param _dev the device whose child is being deleted 169239512Sjhb * @param _child the child device which is being deleted 170239512Sjhb */ 171239512SjhbMETHOD void child_deleted { 172239512Sjhb device_t _dev; 173239512Sjhb device_t _child; 174239512Sjhb}; 175239512Sjhb 176239512Sjhb/** 177132354Sdfr * @brief Notify a bus that a child was detached 178132354Sdfr * 179132354Sdfr * Called after the child's DEVICE_DETACH() method to allow the parent 180132354Sdfr * to reclaim any resources allocated on behalf of the child. 181132354Sdfr * 182132354Sdfr * @param _dev the device whose child changed state 183132354Sdfr * @param _child the child device which changed state 184132354Sdfr */ 18545107SdfrMETHOD void child_detached { 18695201Smarkm device_t _dev; 18795201Smarkm device_t _child; 18845107Sdfr}; 18945107Sdfr 190132354Sdfr/** 191132354Sdfr * @brief Notify a bus that a new driver was added 192132354Sdfr * 193132354Sdfr * Called when a new driver is added to the devclass which owns this 194132354Sdfr * bus. The generic implementation of this method attempts to probe and 195132354Sdfr * attach any un-matched children of the bus. 196132354Sdfr * 197132354Sdfr * @param _dev the device whose devclass had a new driver 198132354Sdfr * added to it 199132354Sdfr * @param _driver the new driver which was added 200132354Sdfr */ 20145720SpeterMETHOD void driver_added { 20295201Smarkm device_t _dev; 20395201Smarkm driver_t *_driver; 20452045Simp} DEFAULT bus_generic_driver_added; 20545720Speter 206132354Sdfr/** 207132354Sdfr * @brief Create a new child device 208132354Sdfr * 209132354Sdfr * For busses which use use drivers supporting DEVICE_IDENTIFY() to 210132354Sdfr * enumerate their devices, this method is used to create new 211132354Sdfr * device instances. The new device will be added after the last 212132354Sdfr * existing child with the same order. 213132354Sdfr * 214132354Sdfr * @param _dev the bus device which will be the parent of the 215132354Sdfr * new child device 216132354Sdfr * @param _order a value which is used to partially sort the 217132354Sdfr * children of @p _dev - devices created using 218132354Sdfr * lower values of @p _order appear first in @p 219132354Sdfr * _dev's list of children 220132354Sdfr * @param _name devclass name for new device or @c NULL if not 221132354Sdfr * specified 222132354Sdfr * @param _unit unit number for new device or @c -1 if not 223132354Sdfr * specified 224132354Sdfr */ 22547178SdfrMETHOD device_t add_child { 22695201Smarkm device_t _dev; 227212413Savg u_int _order; 22895201Smarkm const char *_name; 22995201Smarkm int _unit; 230212544Savg} DEFAULT null_add_child; 23147178Sdfr 232132354Sdfr/** 233132354Sdfr * @brief Allocate a system resource 234132354Sdfr * 235132354Sdfr * This method is called by child devices of a bus to allocate resources. 236132354Sdfr * The types are defined in <machine/resource.h>; the meaning of the 237132354Sdfr * resource-ID field varies from bus to bus (but @p *rid == 0 is always 238132354Sdfr * valid if the resource type is). If a resource was allocated and the 239132354Sdfr * caller did not use the RF_ACTIVE to specify that it should be 240132354Sdfr * activated immediately, the caller is responsible for calling 241132354Sdfr * BUS_ACTIVATE_RESOURCE() when it actually uses the resource. 242132354Sdfr * 243132354Sdfr * @param _dev the parent device of @p _child 244132354Sdfr * @param _child the device which is requesting an allocation 245132354Sdfr * @param _type the type of resource to allocate 246132354Sdfr * @param _rid a pointer to the resource identifier 247132354Sdfr * @param _start hint at the start of the resource range - pass 248132354Sdfr * @c 0UL for any start address 249132354Sdfr * @param _end hint at the end of the resource range - pass 250132354Sdfr * @c ~0UL for any end address 251132354Sdfr * @param _count hint at the size of range required - pass @c 1 252132354Sdfr * for any size 253132354Sdfr * @param _flags any extra flags to control the resource 254132354Sdfr * allocation - see @c RF_XXX flags in 255132354Sdfr * <sys/rman.h> for details 256132354Sdfr * 257132354Sdfr * @returns the resource which was allocated or @c NULL if no 258132354Sdfr * resource could be allocated 259132354Sdfr */ 26041153SwollmanMETHOD struct resource * alloc_resource { 26195201Smarkm device_t _dev; 26295201Smarkm device_t _child; 26395201Smarkm int _type; 26495201Smarkm int *_rid; 26595201Smarkm u_long _start; 26695201Smarkm u_long _end; 26795201Smarkm u_long _count; 26895201Smarkm u_int _flags; 26946913Sdfr} DEFAULT null_alloc_resource; 27037592Sdfr 271132354Sdfr/** 272132354Sdfr * @brief Activate a resource 273132354Sdfr * 274132354Sdfr * Activate a resource previously allocated with 275132354Sdfr * BUS_ALLOC_RESOURCE(). This may for instance map a memory region 276132354Sdfr * into the kernel's virtual address space. 277132354Sdfr * 278132354Sdfr * @param _dev the parent device of @p _child 279132354Sdfr * @param _child the device which allocated the resource 280132354Sdfr * @param _type the type of resource 281132354Sdfr * @param _rid the resource identifier 282132354Sdfr * @param _r the resource to activate 283132354Sdfr */ 28441153SwollmanMETHOD int activate_resource { 28595201Smarkm device_t _dev; 28695201Smarkm device_t _child; 28795201Smarkm int _type; 28895201Smarkm int _rid; 28995201Smarkm struct resource *_r; 29041153Swollman}; 29141153Swollman 292132354Sdfr/** 293132354Sdfr * @brief Deactivate a resource 294132354Sdfr * 295132354Sdfr * Deactivate a resource previously allocated with 296132354Sdfr * BUS_ALLOC_RESOURCE(). This may for instance unmap a memory region 297132354Sdfr * from the kernel's virtual address space. 298132354Sdfr * 299132354Sdfr * @param _dev the parent device of @p _child 300132354Sdfr * @param _child the device which allocated the resource 301132354Sdfr * @param _type the type of resource 302132354Sdfr * @param _rid the resource identifier 303132354Sdfr * @param _r the resource to deactivate 304132354Sdfr */ 30541153SwollmanMETHOD int deactivate_resource { 30695201Smarkm device_t _dev; 30795201Smarkm device_t _child; 30895201Smarkm int _type; 30995201Smarkm int _rid; 31095201Smarkm struct resource *_r; 31141153Swollman}; 31241153Swollman 313132354Sdfr/** 314221231Sjhb * @brief Adjust a resource 315221231Sjhb * 316221231Sjhb * Adjust the start and/or end of a resource allocated by 317221231Sjhb * BUS_ALLOC_RESOURCE. At least part of the new address range must overlap 318221231Sjhb * with the existing address range. If the successful, the resource's range 319221231Sjhb * will be adjusted to [start, end] on return. 320221231Sjhb * 321221231Sjhb * @param _dev the parent device of @p _child 322221231Sjhb * @param _child the device which allocated the resource 323221231Sjhb * @param _type the type of resource 324221231Sjhb * @param _res the resource to adjust 325221231Sjhb * @param _start the new starting address of the resource range 326221231Sjhb * @param _end the new ending address of the resource range 327221231Sjhb */ 328221231SjhbMETHOD int adjust_resource { 329221231Sjhb device_t _dev; 330221231Sjhb device_t _child; 331221231Sjhb int _type; 332221231Sjhb struct resource *_res; 333221231Sjhb u_long _start; 334221231Sjhb u_long _end; 335221231Sjhb}; 336221231Sjhb 337221231Sjhb/** 338132354Sdfr * @brief Release a resource 339132354Sdfr * 340132354Sdfr * Free a resource allocated by the BUS_ALLOC_RESOURCE. The @p _rid 341132354Sdfr * value must be the same as the one returned by BUS_ALLOC_RESOURCE() 342132354Sdfr * (which is not necessarily the same as the one the client passed). 343132354Sdfr * 344132354Sdfr * @param _dev the parent device of @p _child 345132354Sdfr * @param _child the device which allocated the resource 346132354Sdfr * @param _type the type of resource 347132354Sdfr * @param _rid the resource identifier 348132354Sdfr * @param _r the resource to release 349132354Sdfr */ 35041153SwollmanMETHOD int release_resource { 35195201Smarkm device_t _dev; 35295201Smarkm device_t _child; 35395201Smarkm int _type; 35495201Smarkm int _rid; 35595201Smarkm struct resource *_res; 35637592Sdfr}; 35741153Swollman 358132354Sdfr/** 359132354Sdfr * @brief Install an interrupt handler 360132354Sdfr * 361132354Sdfr * This method is used to associate an interrupt handler function with 362132354Sdfr * an irq resource. When the interrupt triggers, the function @p _intr 363132354Sdfr * will be called with the value of @p _arg as its single 364132354Sdfr * argument. The value returned in @p *_cookiep is used to cancel the 365132354Sdfr * interrupt handler - the caller should save this value to use in a 366132354Sdfr * future call to BUS_TEARDOWN_INTR(). 367132354Sdfr * 368132354Sdfr * @param _dev the parent device of @p _child 369132354Sdfr * @param _child the device which allocated the resource 370132354Sdfr * @param _irq the resource representing the interrupt 371132354Sdfr * @param _flags a set of bits from enum intr_type specifying 372132354Sdfr * the class of interrupt 373132354Sdfr * @param _intr the function to call when the interrupt 374132354Sdfr * triggers 375132354Sdfr * @param _arg a value to use as the single argument in calls 376132354Sdfr * to @p _intr 377132354Sdfr * @param _cookiep a pointer to a location to recieve a cookie 378132354Sdfr * value that may be used to remove the interrupt 379132354Sdfr * handler 380132354Sdfr */ 38141153SwollmanMETHOD int setup_intr { 38295201Smarkm device_t _dev; 38395201Smarkm device_t _child; 38495201Smarkm struct resource *_irq; 38595201Smarkm int _flags; 386166901Spiso driver_filter_t *_filter; 38795201Smarkm driver_intr_t *_intr; 38895201Smarkm void *_arg; 38995201Smarkm void **_cookiep; 39041153Swollman}; 39141153Swollman 392132354Sdfr/** 393132354Sdfr * @brief Uninstall an interrupt handler 394132354Sdfr * 395132354Sdfr * This method is used to disassociate an interrupt handler function 396132354Sdfr * with an irq resource. The value of @p _cookie must be the value 397132354Sdfr * returned from a previous call to BUS_SETUP_INTR(). 398132354Sdfr * 399132354Sdfr * @param _dev the parent device of @p _child 400132354Sdfr * @param _child the device which allocated the resource 401132354Sdfr * @param _irq the resource representing the interrupt 402132354Sdfr * @param _cookie the cookie value returned when the interrupt 403132354Sdfr * was originally registered 404132354Sdfr */ 40541153SwollmanMETHOD int teardown_intr { 40695201Smarkm device_t _dev; 40795201Smarkm device_t _child; 40895201Smarkm struct resource *_irq; 40995201Smarkm void *_cookie; 41041153Swollman}; 41152174Sdfr 412132354Sdfr/** 413132354Sdfr * @brief Define a resource which can be allocated with 414132354Sdfr * BUS_ALLOC_RESOURCE(). 415132354Sdfr * 416132354Sdfr * This method is used by some busses (typically ISA) to allow a 417132354Sdfr * driver to describe a resource range that it would like to 418132354Sdfr * allocate. The resource defined by @p _type and @p _rid is defined 419132354Sdfr * to start at @p _start and to include @p _count indices in its 420132354Sdfr * range. 421132354Sdfr * 422132354Sdfr * @param _dev the parent device of @p _child 423132354Sdfr * @param _child the device which owns the resource 424132354Sdfr * @param _type the type of resource 425132354Sdfr * @param _rid the resource identifier 426132354Sdfr * @param _start the start of the resource range 427132354Sdfr * @param _count the size of the resource range 428132354Sdfr */ 42952174SdfrMETHOD int set_resource { 43095201Smarkm device_t _dev; 43195201Smarkm device_t _child; 43295201Smarkm int _type; 43395201Smarkm int _rid; 43495201Smarkm u_long _start; 43595201Smarkm u_long _count; 43652174Sdfr}; 43752174Sdfr 438132354Sdfr/** 439132354Sdfr * @brief Describe a resource 440132354Sdfr * 441132354Sdfr * This method allows a driver to examine the range used for a given 442132354Sdfr * resource without actually allocating it. 443132354Sdfr * 444132354Sdfr * @param _dev the parent device of @p _child 445132354Sdfr * @param _child the device which owns the resource 446132354Sdfr * @param _type the type of resource 447132354Sdfr * @param _rid the resource identifier 448132354Sdfr * @param _start the address of a location to recieve the start 449132354Sdfr * index of the resource range 450132354Sdfr * @param _count the address of a location to recieve the size 451132354Sdfr * of the resource range 452132354Sdfr */ 45352174SdfrMETHOD int get_resource { 45495201Smarkm device_t _dev; 45595201Smarkm device_t _child; 45695201Smarkm int _type; 45795201Smarkm int _rid; 45895201Smarkm u_long *_startp; 45995201Smarkm u_long *_countp; 46052174Sdfr}; 46152174Sdfr 462132354Sdfr/** 463132354Sdfr * @brief Delete a resource. 464132354Sdfr * 465132354Sdfr * Use this to delete a resource (possibly one previously added with 466132354Sdfr * BUS_SET_RESOURCE()). 467132354Sdfr * 468132354Sdfr * @param _dev the parent device of @p _child 469132354Sdfr * @param _child the device which owns the resource 470132354Sdfr * @param _type the type of resource 471132354Sdfr * @param _rid the resource identifier 472132354Sdfr */ 47352174SdfrMETHOD void delete_resource { 47495201Smarkm device_t _dev; 47595201Smarkm device_t _child; 47695201Smarkm int _type; 47795201Smarkm int _rid; 47852174Sdfr}; 47967278Smdodd 480132354Sdfr/** 481132354Sdfr * @brief Return a struct resource_list. 482132354Sdfr * 483132354Sdfr * Used by drivers which use bus_generic_rl_alloc_resource() etc. to 484132354Sdfr * implement their resource handling. It should return the resource 485132354Sdfr * list of the given child device. 486132354Sdfr * 487132354Sdfr * @param _dev the parent device of @p _child 488132354Sdfr * @param _child the device which owns the resource list 489132354Sdfr */ 49069294SmdoddMETHOD struct resource_list * get_resource_list { 49195201Smarkm device_t _dev; 49295201Smarkm device_t _child; 49367278Smdodd} DEFAULT bus_generic_get_resource_list; 494100421Simp 495132354Sdfr/** 496132354Sdfr * @brief Is the hardware described by @p _child still attached to the 497132354Sdfr * system? 498132354Sdfr * 499133588Simp * This method should return 0 if the device is not present. It 500133588Simp * should return -1 if it is present. Any errors in determining 501133588Simp * should be returned as a normal errno value. Client drivers are to 502133588Simp * assume that the device is present, even if there is an error 503133588Simp * determining if it is there. Busses are to try to avoid returning 504133588Simp * errors, but newcard will return an error if the device fails to 505133588Simp * implement this method. 506132354Sdfr * 507132354Sdfr * @param _dev the parent device of @p _child 508132354Sdfr * @param _child the device which is being examined 509132354Sdfr */ 510100421SimpMETHOD int child_present { 511100421Simp device_t _dev; 512100421Simp device_t _child; 513100421Simp} DEFAULT bus_generic_child_present; 514104597Simp 515132354Sdfr/** 516132354Sdfr * @brief Returns the pnp info for this device. 517132354Sdfr * 518132354Sdfr * Return it as a string. If the string is insufficient for the 519132354Sdfr * storage, then return EOVERFLOW. 520132354Sdfr * 521132354Sdfr * @param _dev the parent device of @p _child 522132354Sdfr * @param _child the device which is being examined 523132354Sdfr * @param _buf the address of a buffer to receive the pnp 524132354Sdfr * string 525132354Sdfr * @param _buflen the size of the buffer pointed to by @p _buf 526132354Sdfr */ 527104597SimpMETHOD int child_pnpinfo_str { 528104597Simp device_t _dev; 529104597Simp device_t _child; 530104597Simp char *_buf; 531104597Simp size_t _buflen; 532104597Simp}; 533104597Simp 534132354Sdfr/** 535132354Sdfr * @brief Returns the location for this device. 536132354Sdfr * 537132354Sdfr * Return it as a string. If the string is insufficient for the 538132354Sdfr * storage, then return EOVERFLOW. 539132354Sdfr * 540132354Sdfr * @param _dev the parent device of @p _child 541132354Sdfr * @param _child the device which is being examined 542132354Sdfr * @param _buf the address of a buffer to receive the location 543132354Sdfr * string 544132354Sdfr * @param _buflen the size of the buffer pointed to by @p _buf 545132354Sdfr */ 546104597SimpMETHOD int child_location_str { 547104597Simp device_t _dev; 548104597Simp device_t _child; 549104597Simp char *_buf; 550104597Simp size_t _buflen; 551104597Simp}; 552119967Smarcel 553132354Sdfr/** 554177467Sjhb * @brief Allow drivers to request that an interrupt be bound to a specific 555177467Sjhb * CPU. 556177467Sjhb * 557177467Sjhb * @param _dev the parent device of @p _child 558177467Sjhb * @param _child the device which allocated the resource 559177467Sjhb * @param _irq the resource representing the interrupt 560177467Sjhb * @param _cpu the CPU to bind the interrupt to 561177467Sjhb */ 562177467SjhbMETHOD int bind_intr { 563177467Sjhb device_t _dev; 564177467Sjhb device_t _child; 565177467Sjhb struct resource *_irq; 566177467Sjhb int _cpu; 567177467Sjhb} DEFAULT bus_generic_bind_intr; 568177467Sjhb 569177467Sjhb/** 570132354Sdfr * @brief Allow (bus) drivers to specify the trigger mode and polarity 571132354Sdfr * of the specified interrupt. 572132354Sdfr * 573132354Sdfr * @param _dev the bus device 574132354Sdfr * @param _irq the interrupt number to modify 575132354Sdfr * @param _trig the trigger mode required 576132354Sdfr * @param _pol the interrupt polarity required 577132354Sdfr */ 578119967SmarcelMETHOD int config_intr { 579119967Smarcel device_t _dev; 580119967Smarcel int _irq; 581119967Smarcel enum intr_trigger _trig; 582119967Smarcel enum intr_polarity _pol; 583119967Smarcel} DEFAULT bus_generic_config_intr; 584160186Simp 585160186Simp/** 586198134Sjhb * @brief Allow drivers to associate a description with an active 587198134Sjhb * interrupt handler. 588198134Sjhb * 589198134Sjhb * @param _dev the parent device of @p _child 590198134Sjhb * @param _child the device which allocated the resource 591198134Sjhb * @param _irq the resource representing the interrupt 592198134Sjhb * @param _cookie the cookie value returned when the interrupt 593198134Sjhb * was originally registered 594198134Sjhb * @param _descr the description to associate with the interrupt 595198134Sjhb */ 596198134SjhbMETHOD int describe_intr { 597198134Sjhb device_t _dev; 598198134Sjhb device_t _child; 599198134Sjhb struct resource *_irq; 600198134Sjhb void *_cookie; 601198134Sjhb const char *_descr; 602198134Sjhb} DEFAULT bus_generic_describe_intr; 603198134Sjhb 604198134Sjhb/** 605160186Simp * @brief Notify a (bus) driver about a child that the hints mechanism 606160186Simp * believes it has discovered. 607160186Simp * 608160186Simp * The bus is responsible for then adding the child in the right order 609160186Simp * and discovering other things about the child. The bus driver is 610160186Simp * free to ignore this hint, to do special things, etc. It is all up 611160186Simp * to the bus driver to interpret. 612160186Simp * 613160186Simp * This method is only called in response to the parent bus asking for 614160186Simp * hinted devices to be enumerated. 615160186Simp * 616160186Simp * @param _dev the bus device 617160186Simp * @param _dname the name of the device w/o unit numbers 618160186Simp * @param _dunit the unit number of the device 619160186Simp */ 620160186SimpMETHOD void hinted_child { 621160186Simp device_t _dev; 622185059Sjhb const char *_dname; 623160186Simp int _dunit; 624160186Simp}; 625161928Sjmg 626161928Sjmg/** 627161928Sjmg * @brief Returns bus_dma_tag_t for use w/ devices on the bus. 628161928Sjmg * 629161928Sjmg * @param _dev the parent device of @p _child 630161928Sjmg * @param _child the device to which the tag will belong 631161928Sjmg */ 632161928SjmgMETHOD bus_dma_tag_t get_dma_tag { 633161928Sjmg device_t _dev; 634161928Sjmg device_t _child; 635161928Sjmg} DEFAULT bus_generic_get_dma_tag; 636185059Sjhb 637185059Sjhb/** 638185059Sjhb * @brief Allow the bus to determine the unit number of a device. 639185059Sjhb * 640185059Sjhb * @param _dev the parent device of @p _child 641185059Sjhb * @param _child the device whose unit is to be wired 642185059Sjhb * @param _name the name of the device's new devclass 643185059Sjhb * @param _unitp a pointer to the device's new unit value 644185059Sjhb */ 645185059SjhbMETHOD void hint_device_unit { 646185059Sjhb device_t _dev; 647185059Sjhb device_t _child; 648185059Sjhb const char *_name; 649185059Sjhb int *_unitp; 650185059Sjhb}; 651185059Sjhb 652193833Sjhb/** 653193833Sjhb * @brief Notify a bus that the bus pass level has been changed 654193833Sjhb * 655193833Sjhb * @param _dev the bus device 656193833Sjhb */ 657193833SjhbMETHOD void new_pass { 658193833Sjhb device_t _dev; 659193833Sjhb} DEFAULT bus_generic_new_pass; 660209154Smav 661209154Smav/** 662209154Smav * @brief Notify a bus that specified child's IRQ should be remapped. 663209154Smav * 664209154Smav * @param _dev the bus device 665209154Smav * @param _child the child device 666209154Smav * @param _irq the irq number 667209154Smav */ 668209154SmavMETHOD int remap_intr { 669209154Smav device_t _dev; 670209154Smav device_t _child; 671209154Smav u_int _irq; 672209154Smav} DEFAULT null_remap_intr; 673