19454b2d8SWarner Losh#- 29f7f340aSWarner Losh# Copyright (c) 1998-2004 Doug Rabson 3b1bf6610SDoug Rabson# All rights reserved. 4b1bf6610SDoug Rabson# 5b1bf6610SDoug Rabson# Redistribution and use in source and binary forms, with or without 6b1bf6610SDoug Rabson# modification, are permitted provided that the following conditions 7b1bf6610SDoug Rabson# are met: 8b1bf6610SDoug Rabson# 1. Redistributions of source code must retain the above copyright 9b1bf6610SDoug Rabson# notice, this list of conditions and the following disclaimer. 10b1bf6610SDoug Rabson# 2. Redistributions in binary form must reproduce the above copyright 11b1bf6610SDoug Rabson# notice, this list of conditions and the following disclaimer in the 12b1bf6610SDoug Rabson# documentation and/or other materials provided with the distribution. 13b1bf6610SDoug Rabson# 14b1bf6610SDoug Rabson# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15b1bf6610SDoug Rabson# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16b1bf6610SDoug Rabson# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17b1bf6610SDoug Rabson# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18b1bf6610SDoug Rabson# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19b1bf6610SDoug Rabson# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20b1bf6610SDoug Rabson# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21b1bf6610SDoug Rabson# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22b1bf6610SDoug Rabson# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23b1bf6610SDoug Rabson# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24b1bf6610SDoug Rabson# SUCH DAMAGE. 25b1bf6610SDoug Rabson# 26c3aac50fSPeter Wemm# $FreeBSD$ 27b1bf6610SDoug Rabson# 28b1bf6610SDoug Rabson 29b7d28b2eSAndriy Gapon#include <sys/types.h> 30b7d28b2eSAndriy Gapon#include <sys/systm.h> 31f7b77691SDoug Rabson#include <sys/bus.h> 32f7b77691SDoug Rabson 334c4392e7SDoug Rabson/** 344c4392e7SDoug Rabson * @defgroup BUS bus - KObj methods for drivers of devices with children 354c4392e7SDoug Rabson * @brief A set of methods required device drivers that support 364c4392e7SDoug Rabson * child devices. 374c4392e7SDoug Rabson * @{ 384c4392e7SDoug Rabson */ 3931a7daaeSNicolas SouchuINTERFACE bus; 40b1bf6610SDoug Rabson 41b1bf6610SDoug Rabson# 428b2970bbSDoug Rabson# Default implementations of some methods. 438b2970bbSDoug Rabson# 448b2970bbSDoug RabsonCODE { 458b2970bbSDoug Rabson static struct resource * 468b2970bbSDoug Rabson null_alloc_resource(device_t dev, device_t child, 472dd1bdf1SJustin Hibbits int type, int *rid, rman_res_t start, rman_res_t end, 482dd1bdf1SJustin Hibbits rman_res_t count, u_int flags) 498b2970bbSDoug Rabson { 505878eb3fSWarner Losh return (0); 518b2970bbSDoug Rabson } 5293fc07b4SAlexander Motin 5393fc07b4SAlexander Motin static int 5493fc07b4SAlexander Motin null_remap_intr(device_t bus, device_t dev, u_int irq) 5593fc07b4SAlexander Motin { 5693fc07b4SAlexander Motin 5793fc07b4SAlexander Motin if (dev != NULL) 5893fc07b4SAlexander Motin return (BUS_REMAP_INTR(dev, NULL, irq)); 5993fc07b4SAlexander Motin return (ENXIO); 6093fc07b4SAlexander Motin } 61b7d28b2eSAndriy Gapon 62b7d28b2eSAndriy Gapon static device_t 63b7d28b2eSAndriy Gapon null_add_child(device_t bus, int order, const char *name, 64b7d28b2eSAndriy Gapon int unit) 65b7d28b2eSAndriy Gapon { 66b7d28b2eSAndriy Gapon 67b7d28b2eSAndriy Gapon panic("bus_add_child is not implemented"); 68b7d28b2eSAndriy Gapon } 69c53df6daSKonstantin Belousov 70c53df6daSKonstantin Belousov static int null_reset_post(device_t bus, device_t dev) 71c53df6daSKonstantin Belousov { 72c53df6daSKonstantin Belousov return (0); 73c53df6daSKonstantin Belousov } 74c53df6daSKonstantin Belousov 75c53df6daSKonstantin Belousov static int null_reset_prepare(device_t bus, device_t dev) 76c53df6daSKonstantin Belousov { 77c53df6daSKonstantin Belousov return (0); 78c53df6daSKonstantin Belousov } 79*937a05baSJustin Hibbits 80*937a05baSJustin Hibbits static int 81*937a05baSJustin Hibbits null_translate_resource(device_t bus, int type, rman_res_t start, 82*937a05baSJustin Hibbits rman_res_t *newstart) 83*937a05baSJustin Hibbits { 84*937a05baSJustin Hibbits if (device_get_parent(bus) != NULL) 85*937a05baSJustin Hibbits return (BUS_TRANSLATE_RESOURCE(device_get_parent(bus), 86*937a05baSJustin Hibbits type, start, newstart)); 87*937a05baSJustin Hibbits 88*937a05baSJustin Hibbits *newstart = start; 89*937a05baSJustin Hibbits return (0); 90*937a05baSJustin Hibbits } 918b2970bbSDoug Rabson}; 928b2970bbSDoug Rabson 934c4392e7SDoug Rabson/** 944c4392e7SDoug Rabson * @brief Print a description of a child device 954c4392e7SDoug Rabson * 964c4392e7SDoug Rabson * This is called from system code which prints out a description of a 974c4392e7SDoug Rabson * device. It should describe the attachment that the child has with 984c4392e7SDoug Rabson * the parent. For instance the TurboLaser bus prints which node the 994c4392e7SDoug Rabson * device is attached to. See bus_generic_print_child() for more 1004c4392e7SDoug Rabson * information. 1014c4392e7SDoug Rabson * 1024c4392e7SDoug Rabson * @param _dev the device whose child is being printed 1034c4392e7SDoug Rabson * @param _child the child device to describe 1044c4392e7SDoug Rabson * 1054c4392e7SDoug Rabson * @returns the number of characters output. 1064c4392e7SDoug Rabson */ 10715317dd8SMatthew N. DoddMETHOD int print_child { 1084c4392e7SDoug Rabson device_t _dev; 1094c4392e7SDoug Rabson device_t _child; 110c8440669SMatthew N. Dodd} DEFAULT bus_generic_print_child; 111b1bf6610SDoug Rabson 1124c4392e7SDoug Rabson/** 1134c4392e7SDoug Rabson * @brief Print a notification about an unprobed child device. 1144c4392e7SDoug Rabson * 1154c4392e7SDoug Rabson * Called for each child device that did not succeed in probing for a 1164c4392e7SDoug Rabson * driver. 1174c4392e7SDoug Rabson * 1184c4392e7SDoug Rabson * @param _dev the device whose child was being probed 1194c4392e7SDoug Rabson * @param _child the child device which failed to probe 1204c4392e7SDoug Rabson */ 121ca7036d8SDoug RabsonMETHOD void probe_nomatch { 1224c4392e7SDoug Rabson device_t _dev; 1234c4392e7SDoug Rabson device_t _child; 124ca7036d8SDoug Rabson}; 125ca7036d8SDoug Rabson 1264c4392e7SDoug Rabson/** 1274c4392e7SDoug Rabson * @brief Read the value of a bus-specific attribute of a device 1284c4392e7SDoug Rabson * 1294c4392e7SDoug Rabson * This method, along with BUS_WRITE_IVAR() manages a bus-specific set 1304c4392e7SDoug Rabson * of instance variables of a child device. The intention is that 1314c4392e7SDoug Rabson * each different type of bus defines a set of appropriate instance 1324c4392e7SDoug Rabson * variables (such as ports and irqs for ISA bus etc.) 1334c4392e7SDoug Rabson * 1344c4392e7SDoug Rabson * This information could be given to the child device as a struct but 1354c4392e7SDoug Rabson * that makes it hard for a bus to add or remove variables without 1364c4392e7SDoug Rabson * forcing an edit and recompile for all drivers which may not be 1374c4392e7SDoug Rabson * possible for vendor supplied binary drivers. 1384c4392e7SDoug Rabson * 1394c4392e7SDoug Rabson * This method copies the value of an instance variable to the 1404c4392e7SDoug Rabson * location specified by @p *_result. 1414c4392e7SDoug Rabson * 1424c4392e7SDoug Rabson * @param _dev the device whose child was being examined 1434c4392e7SDoug Rabson * @param _child the child device whose instance variable is 1444c4392e7SDoug Rabson * being read 1454c4392e7SDoug Rabson * @param _index the instance variable to read 146e3043798SPedro F. Giffuni * @param _result a location to receive the instance variable 1474c4392e7SDoug Rabson * value 1484c4392e7SDoug Rabson * 1494c4392e7SDoug Rabson * @retval 0 success 1504c4392e7SDoug Rabson * @retval ENOENT no such instance variable is supported by @p 1514c4392e7SDoug Rabson * _dev 1524c4392e7SDoug Rabson */ 153b1bf6610SDoug RabsonMETHOD int read_ivar { 154bd418641SMark Murray device_t _dev; 155bd418641SMark Murray device_t _child; 1564c4392e7SDoug Rabson int _index; 157bd418641SMark Murray uintptr_t *_result; 158b1bf6610SDoug Rabson}; 159b1bf6610SDoug Rabson 1604c4392e7SDoug Rabson/** 1614c4392e7SDoug Rabson * @brief Write the value of a bus-specific attribute of a device 1624c4392e7SDoug Rabson * 1634c4392e7SDoug Rabson * This method sets the value of an instance variable to @p _value. 1644c4392e7SDoug Rabson * 1654c4392e7SDoug Rabson * @param _dev the device whose child was being updated 1664c4392e7SDoug Rabson * @param _child the child device whose instance variable is 1674c4392e7SDoug Rabson * being written 1684c4392e7SDoug Rabson * @param _index the instance variable to write 1694c4392e7SDoug Rabson * @param _value the value to write to that instance variable 1704c4392e7SDoug Rabson * 1714c4392e7SDoug Rabson * @retval 0 success 1724c4392e7SDoug Rabson * @retval ENOENT no such instance variable is supported by @p 1734c4392e7SDoug Rabson * _dev 1744c4392e7SDoug Rabson * @retval EINVAL the instance variable was recognised but 1754c4392e7SDoug Rabson * contains a read-only value 1764c4392e7SDoug Rabson */ 177b1bf6610SDoug RabsonMETHOD int write_ivar { 178bd418641SMark Murray device_t _dev; 179bd418641SMark Murray device_t _child; 180bd418641SMark Murray int _indx; 181bd418641SMark Murray uintptr_t _value; 182b1bf6610SDoug Rabson}; 183b1bf6610SDoug Rabson 1844c4392e7SDoug Rabson/** 1856f7d0018SJohn Baldwin * @brief Notify a bus that a child was deleted 1866f7d0018SJohn Baldwin * 1876f7d0018SJohn Baldwin * Called at the beginning of device_delete_child() to allow the parent 1886f7d0018SJohn Baldwin * to teardown any bus-specific state for the child. 1896f7d0018SJohn Baldwin * 1906f7d0018SJohn Baldwin * @param _dev the device whose child is being deleted 1916f7d0018SJohn Baldwin * @param _child the child device which is being deleted 1926f7d0018SJohn Baldwin */ 1936f7d0018SJohn BaldwinMETHOD void child_deleted { 1946f7d0018SJohn Baldwin device_t _dev; 1956f7d0018SJohn Baldwin device_t _child; 1966f7d0018SJohn Baldwin}; 1976f7d0018SJohn Baldwin 1986f7d0018SJohn Baldwin/** 1994c4392e7SDoug Rabson * @brief Notify a bus that a child was detached 2004c4392e7SDoug Rabson * 2014c4392e7SDoug Rabson * Called after the child's DEVICE_DETACH() method to allow the parent 2024c4392e7SDoug Rabson * to reclaim any resources allocated on behalf of the child. 2034c4392e7SDoug Rabson * 2044c4392e7SDoug Rabson * @param _dev the device whose child changed state 2054c4392e7SDoug Rabson * @param _child the child device which changed state 2064c4392e7SDoug Rabson */ 2076350e58aSDoug RabsonMETHOD void child_detached { 208bd418641SMark Murray device_t _dev; 209bd418641SMark Murray device_t _child; 2106350e58aSDoug Rabson}; 2116350e58aSDoug Rabson 2124c4392e7SDoug Rabson/** 2134c4392e7SDoug Rabson * @brief Notify a bus that a new driver was added 2144c4392e7SDoug Rabson * 2154c4392e7SDoug Rabson * Called when a new driver is added to the devclass which owns this 2164c4392e7SDoug Rabson * bus. The generic implementation of this method attempts to probe and 2174c4392e7SDoug Rabson * attach any un-matched children of the bus. 2184c4392e7SDoug Rabson * 2194c4392e7SDoug Rabson * @param _dev the device whose devclass had a new driver 2204c4392e7SDoug Rabson * added to it 2214c4392e7SDoug Rabson * @param _driver the new driver which was added 2224c4392e7SDoug Rabson */ 2236182fdbdSPeter WemmMETHOD void driver_added { 224bd418641SMark Murray device_t _dev; 225bd418641SMark Murray driver_t *_driver; 2266d4d0ac9SWarner Losh} DEFAULT bus_generic_driver_added; 2276182fdbdSPeter Wemm 2284c4392e7SDoug Rabson/** 2294c4392e7SDoug Rabson * @brief Create a new child device 2304c4392e7SDoug Rabson * 231db4fcadfSConrad Meyer * For buses which use use drivers supporting DEVICE_IDENTIFY() to 2324c4392e7SDoug Rabson * enumerate their devices, this method is used to create new 2334c4392e7SDoug Rabson * device instances. The new device will be added after the last 23483a283cfSWarner Losh * existing child with the same order. Implementations of bus_add_child 23583a283cfSWarner Losh * call device_add_child_ordered to add the child and often add 23683a283cfSWarner Losh * a suitable ivar to the device specific to that bus. 2374c4392e7SDoug Rabson * 2384c4392e7SDoug Rabson * @param _dev the bus device which will be the parent of the 2394c4392e7SDoug Rabson * new child device 2404c4392e7SDoug Rabson * @param _order a value which is used to partially sort the 2414c4392e7SDoug Rabson * children of @p _dev - devices created using 2424c4392e7SDoug Rabson * lower values of @p _order appear first in @p 2434c4392e7SDoug Rabson * _dev's list of children 2444c4392e7SDoug Rabson * @param _name devclass name for new device or @c NULL if not 2454c4392e7SDoug Rabson * specified 2464c4392e7SDoug Rabson * @param _unit unit number for new device or @c -1 if not 2474c4392e7SDoug Rabson * specified 2484c4392e7SDoug Rabson */ 2496c2e3ddeSDoug RabsonMETHOD device_t add_child { 250bd418641SMark Murray device_t _dev; 2513d844eddSAndriy Gapon u_int _order; 252bd418641SMark Murray const char *_name; 253bd418641SMark Murray int _unit; 254b7d28b2eSAndriy Gapon} DEFAULT null_add_child; 2556c2e3ddeSDoug Rabson 2564c4392e7SDoug Rabson/** 257a907c691SJohn Baldwin * @brief Rescan the bus 258a907c691SJohn Baldwin * 259a907c691SJohn Baldwin * This method is called by a parent bridge or devctl to trigger a bus 260a907c691SJohn Baldwin * rescan. The rescan should delete devices no longer present and 261a907c691SJohn Baldwin * enumerate devices that have newly arrived. 262a907c691SJohn Baldwin * 263a907c691SJohn Baldwin * @param _dev the bus device 264a907c691SJohn Baldwin */ 265a907c691SJohn BaldwinMETHOD int rescan { 266a907c691SJohn Baldwin device_t _dev; 267a907c691SJohn Baldwin} 268a907c691SJohn Baldwin 269a907c691SJohn Baldwin/** 2704c4392e7SDoug Rabson * @brief Allocate a system resource 2714c4392e7SDoug Rabson * 2724c4392e7SDoug Rabson * This method is called by child devices of a bus to allocate resources. 2734c4392e7SDoug Rabson * The types are defined in <machine/resource.h>; the meaning of the 2744c4392e7SDoug Rabson * resource-ID field varies from bus to bus (but @p *rid == 0 is always 2754c4392e7SDoug Rabson * valid if the resource type is). If a resource was allocated and the 2764c4392e7SDoug Rabson * caller did not use the RF_ACTIVE to specify that it should be 2774c4392e7SDoug Rabson * activated immediately, the caller is responsible for calling 2784c4392e7SDoug Rabson * BUS_ACTIVATE_RESOURCE() when it actually uses the resource. 2794c4392e7SDoug Rabson * 2804c4392e7SDoug Rabson * @param _dev the parent device of @p _child 2814c4392e7SDoug Rabson * @param _child the device which is requesting an allocation 2824c4392e7SDoug Rabson * @param _type the type of resource to allocate 2834c4392e7SDoug Rabson * @param _rid a pointer to the resource identifier 2844c4392e7SDoug Rabson * @param _start hint at the start of the resource range - pass 285534ccd7bSJustin Hibbits * @c 0 for any start address 2864c4392e7SDoug Rabson * @param _end hint at the end of the resource range - pass 287534ccd7bSJustin Hibbits * @c ~0 for any end address 2884c4392e7SDoug Rabson * @param _count hint at the size of range required - pass @c 1 2894c4392e7SDoug Rabson * for any size 2904c4392e7SDoug Rabson * @param _flags any extra flags to control the resource 2914c4392e7SDoug Rabson * allocation - see @c RF_XXX flags in 2924c4392e7SDoug Rabson * <sys/rman.h> for details 2934c4392e7SDoug Rabson * 2944c4392e7SDoug Rabson * @returns the resource which was allocated or @c NULL if no 2954c4392e7SDoug Rabson * resource could be allocated 2964c4392e7SDoug Rabson */ 29714177d72SGarrett WollmanMETHOD struct resource * alloc_resource { 298bd418641SMark Murray device_t _dev; 299bd418641SMark Murray device_t _child; 300bd418641SMark Murray int _type; 301bd418641SMark Murray int *_rid; 3022dd1bdf1SJustin Hibbits rman_res_t _start; 3032dd1bdf1SJustin Hibbits rman_res_t _end; 3042dd1bdf1SJustin Hibbits rman_res_t _count; 305bd418641SMark Murray u_int _flags; 3068b2970bbSDoug Rabson} DEFAULT null_alloc_resource; 30714177d72SGarrett Wollman 3084c4392e7SDoug Rabson/** 3094c4392e7SDoug Rabson * @brief Activate a resource 3104c4392e7SDoug Rabson * 3114c4392e7SDoug Rabson * Activate a resource previously allocated with 312cc981af2SJohn Baldwin * BUS_ALLOC_RESOURCE(). This may enable decoding of this resource in a 313cc981af2SJohn Baldwin * device for instance. It will also establish a mapping for the resource 314cc981af2SJohn Baldwin * unless RF_UNMAPPED was set when allocating the resource. 3154c4392e7SDoug Rabson * 3164c4392e7SDoug Rabson * @param _dev the parent device of @p _child 3174c4392e7SDoug Rabson * @param _child the device which allocated the resource 3184c4392e7SDoug Rabson * @param _type the type of resource 3194c4392e7SDoug Rabson * @param _rid the resource identifier 3204c4392e7SDoug Rabson * @param _r the resource to activate 3214c4392e7SDoug Rabson */ 32214177d72SGarrett WollmanMETHOD int activate_resource { 323bd418641SMark Murray device_t _dev; 324bd418641SMark Murray device_t _child; 325bd418641SMark Murray int _type; 326bd418641SMark Murray int _rid; 327bd418641SMark Murray struct resource *_r; 32814177d72SGarrett Wollman}; 32914177d72SGarrett Wollman 330cc981af2SJohn Baldwin 331cc981af2SJohn Baldwin/** 332cc981af2SJohn Baldwin * @brief Map a resource 333cc981af2SJohn Baldwin * 334cc981af2SJohn Baldwin * Allocate a mapping for a range of an active resource. The mapping 335cc981af2SJohn Baldwin * is described by a struct resource_map object. This may for instance 336cc981af2SJohn Baldwin * map a memory region into the kernel's virtual address space. 337cc981af2SJohn Baldwin * 338cc981af2SJohn Baldwin * @param _dev the parent device of @p _child 339cc981af2SJohn Baldwin * @param _child the device which allocated the resource 340cc981af2SJohn Baldwin * @param _type the type of resource 341cc981af2SJohn Baldwin * @param _r the resource to map 342cc981af2SJohn Baldwin * @param _args optional attributes of the mapping 343cc981af2SJohn Baldwin * @param _map the mapping 344cc981af2SJohn Baldwin */ 345cc981af2SJohn BaldwinMETHOD int map_resource { 346cc981af2SJohn Baldwin device_t _dev; 347cc981af2SJohn Baldwin device_t _child; 348cc981af2SJohn Baldwin int _type; 349cc981af2SJohn Baldwin struct resource *_r; 350cc981af2SJohn Baldwin struct resource_map_request *_args; 351cc981af2SJohn Baldwin struct resource_map *_map; 352cc981af2SJohn Baldwin} DEFAULT bus_generic_map_resource; 353cc981af2SJohn Baldwin 354cc981af2SJohn Baldwin 355cc981af2SJohn Baldwin/** 356cc981af2SJohn Baldwin * @brief Unmap a resource 357cc981af2SJohn Baldwin * 358cc981af2SJohn Baldwin * Release a mapping previously allocated with 359cc981af2SJohn Baldwin * BUS_MAP_RESOURCE(). This may for instance unmap a memory region 360cc981af2SJohn Baldwin * from the kernel's virtual address space. 361cc981af2SJohn Baldwin * 362cc981af2SJohn Baldwin * @param _dev the parent device of @p _child 363cc981af2SJohn Baldwin * @param _child the device which allocated the resource 364cc981af2SJohn Baldwin * @param _type the type of resource 365cc981af2SJohn Baldwin * @param _r the resource 366cc981af2SJohn Baldwin * @param _map the mapping to release 367cc981af2SJohn Baldwin */ 368cc981af2SJohn BaldwinMETHOD int unmap_resource { 369cc981af2SJohn Baldwin device_t _dev; 370cc981af2SJohn Baldwin device_t _child; 371cc981af2SJohn Baldwin int _type; 372cc981af2SJohn Baldwin struct resource *_r; 373cc981af2SJohn Baldwin struct resource_map *_map; 374cc981af2SJohn Baldwin} DEFAULT bus_generic_unmap_resource; 375cc981af2SJohn Baldwin 376cc981af2SJohn Baldwin 3774c4392e7SDoug Rabson/** 3784c4392e7SDoug Rabson * @brief Deactivate a resource 3794c4392e7SDoug Rabson * 3804c4392e7SDoug Rabson * Deactivate a resource previously allocated with 381cc981af2SJohn Baldwin * BUS_ALLOC_RESOURCE(). 3824c4392e7SDoug Rabson * 3834c4392e7SDoug Rabson * @param _dev the parent device of @p _child 3844c4392e7SDoug Rabson * @param _child the device which allocated the resource 3854c4392e7SDoug Rabson * @param _type the type of resource 3864c4392e7SDoug Rabson * @param _rid the resource identifier 3874c4392e7SDoug Rabson * @param _r the resource to deactivate 3884c4392e7SDoug Rabson */ 38914177d72SGarrett WollmanMETHOD int deactivate_resource { 390bd418641SMark Murray device_t _dev; 391bd418641SMark Murray device_t _child; 392bd418641SMark Murray int _type; 393bd418641SMark Murray int _rid; 394bd418641SMark Murray struct resource *_r; 395b1bf6610SDoug Rabson}; 39645c95fa1SDoug Rabson 3974c4392e7SDoug Rabson/** 39885ee63c9SJohn Baldwin * @brief Adjust a resource 39985ee63c9SJohn Baldwin * 40085ee63c9SJohn Baldwin * Adjust the start and/or end of a resource allocated by 40185ee63c9SJohn Baldwin * BUS_ALLOC_RESOURCE. At least part of the new address range must overlap 40285ee63c9SJohn Baldwin * with the existing address range. If the successful, the resource's range 40385ee63c9SJohn Baldwin * will be adjusted to [start, end] on return. 40485ee63c9SJohn Baldwin * 40585ee63c9SJohn Baldwin * @param _dev the parent device of @p _child 40685ee63c9SJohn Baldwin * @param _child the device which allocated the resource 40785ee63c9SJohn Baldwin * @param _type the type of resource 40885ee63c9SJohn Baldwin * @param _res the resource to adjust 40985ee63c9SJohn Baldwin * @param _start the new starting address of the resource range 41085ee63c9SJohn Baldwin * @param _end the new ending address of the resource range 41185ee63c9SJohn Baldwin */ 41285ee63c9SJohn BaldwinMETHOD int adjust_resource { 41385ee63c9SJohn Baldwin device_t _dev; 41485ee63c9SJohn Baldwin device_t _child; 41585ee63c9SJohn Baldwin int _type; 41685ee63c9SJohn Baldwin struct resource *_res; 4172dd1bdf1SJustin Hibbits rman_res_t _start; 4182dd1bdf1SJustin Hibbits rman_res_t _end; 41985ee63c9SJohn Baldwin}; 42085ee63c9SJohn Baldwin 421*937a05baSJustin Hibbits 422*937a05baSJustin Hibbits/** 423*937a05baSJustin Hibbits * @brief translate a resource value 424*937a05baSJustin Hibbits * 425*937a05baSJustin Hibbits * 426*937a05baSJustin Hibbits * @param _dev the device associated with the resource 427*937a05baSJustin Hibbits * @param _type the type of resource 428*937a05baSJustin Hibbits * @param _start the starting address of the resource range 429*937a05baSJustin Hibbits * @param _newstart the new starting address of the resource range 430*937a05baSJustin Hibbits */ 431*937a05baSJustin HibbitsMETHOD int translate_resource { 432*937a05baSJustin Hibbits device_t _dev; 433*937a05baSJustin Hibbits int _type; 434*937a05baSJustin Hibbits rman_res_t _start; 435*937a05baSJustin Hibbits rman_res_t *_newstart; 436*937a05baSJustin Hibbits} DEFAULT null_translate_resource; 437*937a05baSJustin Hibbits 43885ee63c9SJohn Baldwin/** 4394c4392e7SDoug Rabson * @brief Release a resource 4404c4392e7SDoug Rabson * 4414c4392e7SDoug Rabson * Free a resource allocated by the BUS_ALLOC_RESOURCE. The @p _rid 4424c4392e7SDoug Rabson * value must be the same as the one returned by BUS_ALLOC_RESOURCE() 4434c4392e7SDoug Rabson * (which is not necessarily the same as the one the client passed). 4444c4392e7SDoug Rabson * 4454c4392e7SDoug Rabson * @param _dev the parent device of @p _child 4464c4392e7SDoug Rabson * @param _child the device which allocated the resource 4474c4392e7SDoug Rabson * @param _type the type of resource 4484c4392e7SDoug Rabson * @param _rid the resource identifier 4494c4392e7SDoug Rabson * @param _r the resource to release 4504c4392e7SDoug Rabson */ 45114177d72SGarrett WollmanMETHOD int release_resource { 452bd418641SMark Murray device_t _dev; 453bd418641SMark Murray device_t _child; 454bd418641SMark Murray int _type; 455bd418641SMark Murray int _rid; 456bd418641SMark Murray struct resource *_res; 45714177d72SGarrett Wollman}; 45814177d72SGarrett Wollman 4594c4392e7SDoug Rabson/** 4604c4392e7SDoug Rabson * @brief Install an interrupt handler 4614c4392e7SDoug Rabson * 4624c4392e7SDoug Rabson * This method is used to associate an interrupt handler function with 4634c4392e7SDoug Rabson * an irq resource. When the interrupt triggers, the function @p _intr 4644c4392e7SDoug Rabson * will be called with the value of @p _arg as its single 4654c4392e7SDoug Rabson * argument. The value returned in @p *_cookiep is used to cancel the 4664c4392e7SDoug Rabson * interrupt handler - the caller should save this value to use in a 4674c4392e7SDoug Rabson * future call to BUS_TEARDOWN_INTR(). 4684c4392e7SDoug Rabson * 4694c4392e7SDoug Rabson * @param _dev the parent device of @p _child 4704c4392e7SDoug Rabson * @param _child the device which allocated the resource 4714c4392e7SDoug Rabson * @param _irq the resource representing the interrupt 4724c4392e7SDoug Rabson * @param _flags a set of bits from enum intr_type specifying 4734c4392e7SDoug Rabson * the class of interrupt 4744c4392e7SDoug Rabson * @param _intr the function to call when the interrupt 4754c4392e7SDoug Rabson * triggers 4764c4392e7SDoug Rabson * @param _arg a value to use as the single argument in calls 4774c4392e7SDoug Rabson * to @p _intr 478e3043798SPedro F. Giffuni * @param _cookiep a pointer to a location to receive a cookie 4794c4392e7SDoug Rabson * value that may be used to remove the interrupt 4804c4392e7SDoug Rabson * handler 4814c4392e7SDoug Rabson */ 48214177d72SGarrett WollmanMETHOD int setup_intr { 483bd418641SMark Murray device_t _dev; 484bd418641SMark Murray device_t _child; 485bd418641SMark Murray struct resource *_irq; 486bd418641SMark Murray int _flags; 487ef544f63SPaolo Pisati driver_filter_t *_filter; 488bd418641SMark Murray driver_intr_t *_intr; 489bd418641SMark Murray void *_arg; 490bd418641SMark Murray void **_cookiep; 49114177d72SGarrett Wollman}; 49214177d72SGarrett Wollman 4934c4392e7SDoug Rabson/** 4944c4392e7SDoug Rabson * @brief Uninstall an interrupt handler 4954c4392e7SDoug Rabson * 4964c4392e7SDoug Rabson * This method is used to disassociate an interrupt handler function 4974c4392e7SDoug Rabson * with an irq resource. The value of @p _cookie must be the value 4984c4392e7SDoug Rabson * returned from a previous call to BUS_SETUP_INTR(). 4994c4392e7SDoug Rabson * 5004c4392e7SDoug Rabson * @param _dev the parent device of @p _child 5014c4392e7SDoug Rabson * @param _child the device which allocated the resource 5024c4392e7SDoug Rabson * @param _irq the resource representing the interrupt 5034c4392e7SDoug Rabson * @param _cookie the cookie value returned when the interrupt 5044c4392e7SDoug Rabson * was originally registered 5054c4392e7SDoug Rabson */ 50614177d72SGarrett WollmanMETHOD int teardown_intr { 507bd418641SMark Murray device_t _dev; 508bd418641SMark Murray device_t _child; 509bd418641SMark Murray struct resource *_irq; 510bd418641SMark Murray void *_cookie; 51145c95fa1SDoug Rabson}; 51225afb89bSDoug Rabson 5134c4392e7SDoug Rabson/** 51482a5a275SAndriy Gapon * @brief Suspend an interrupt handler 51582a5a275SAndriy Gapon * 51682a5a275SAndriy Gapon * This method is used to mark a handler as suspended in the case 51782a5a275SAndriy Gapon * that the associated device is powered down and cannot be a source 51882a5a275SAndriy Gapon * for the, typically shared, interrupt. 51982a5a275SAndriy Gapon * The value of @p _irq must be the interrupt resource passed 52082a5a275SAndriy Gapon * to a previous call to BUS_SETUP_INTR(). 52182a5a275SAndriy Gapon * 52282a5a275SAndriy Gapon * @param _dev the parent device of @p _child 52382a5a275SAndriy Gapon * @param _child the device which allocated the resource 52482a5a275SAndriy Gapon * @param _irq the resource representing the interrupt 52582a5a275SAndriy Gapon */ 52682a5a275SAndriy GaponMETHOD int suspend_intr { 52782a5a275SAndriy Gapon device_t _dev; 52882a5a275SAndriy Gapon device_t _child; 52982a5a275SAndriy Gapon struct resource *_irq; 53082a5a275SAndriy Gapon} DEFAULT bus_generic_suspend_intr; 53182a5a275SAndriy Gapon 53282a5a275SAndriy Gapon/** 53382a5a275SAndriy Gapon * @brief Resume an interrupt handler 53482a5a275SAndriy Gapon * 53582a5a275SAndriy Gapon * This method is used to clear suspended state of a handler when 53682a5a275SAndriy Gapon * the associated device is powered up and can be an interrupt source 53782a5a275SAndriy Gapon * again. 53882a5a275SAndriy Gapon * The value of @p _irq must be the interrupt resource passed 53982a5a275SAndriy Gapon * to a previous call to BUS_SETUP_INTR(). 54082a5a275SAndriy Gapon * 54182a5a275SAndriy Gapon * @param _dev the parent device of @p _child 54282a5a275SAndriy Gapon * @param _child the device which allocated the resource 54382a5a275SAndriy Gapon * @param _irq the resource representing the interrupt 54482a5a275SAndriy Gapon */ 54582a5a275SAndriy GaponMETHOD int resume_intr { 54682a5a275SAndriy Gapon device_t _dev; 54782a5a275SAndriy Gapon device_t _child; 54882a5a275SAndriy Gapon struct resource *_irq; 54982a5a275SAndriy Gapon} DEFAULT bus_generic_resume_intr; 55082a5a275SAndriy Gapon 55182a5a275SAndriy Gapon/** 5524c4392e7SDoug Rabson * @brief Define a resource which can be allocated with 5534c4392e7SDoug Rabson * BUS_ALLOC_RESOURCE(). 5544c4392e7SDoug Rabson * 555db4fcadfSConrad Meyer * This method is used by some buses (typically ISA) to allow a 5564c4392e7SDoug Rabson * driver to describe a resource range that it would like to 5574c4392e7SDoug Rabson * allocate. The resource defined by @p _type and @p _rid is defined 5584c4392e7SDoug Rabson * to start at @p _start and to include @p _count indices in its 5594c4392e7SDoug Rabson * range. 5604c4392e7SDoug Rabson * 5614c4392e7SDoug Rabson * @param _dev the parent device of @p _child 5624c4392e7SDoug Rabson * @param _child the device which owns the resource 5634c4392e7SDoug Rabson * @param _type the type of resource 5644c4392e7SDoug Rabson * @param _rid the resource identifier 5654c4392e7SDoug Rabson * @param _start the start of the resource range 5664c4392e7SDoug Rabson * @param _count the size of the resource range 5674c4392e7SDoug Rabson */ 56825afb89bSDoug RabsonMETHOD int set_resource { 569bd418641SMark Murray device_t _dev; 570bd418641SMark Murray device_t _child; 571bd418641SMark Murray int _type; 572bd418641SMark Murray int _rid; 5732dd1bdf1SJustin Hibbits rman_res_t _start; 5742dd1bdf1SJustin Hibbits rman_res_t _count; 57525afb89bSDoug Rabson}; 57625afb89bSDoug Rabson 5774c4392e7SDoug Rabson/** 5784c4392e7SDoug Rabson * @brief Describe a resource 5794c4392e7SDoug Rabson * 5804c4392e7SDoug Rabson * This method allows a driver to examine the range used for a given 5814c4392e7SDoug Rabson * resource without actually allocating it. 5824c4392e7SDoug Rabson * 5834c4392e7SDoug Rabson * @param _dev the parent device of @p _child 5844c4392e7SDoug Rabson * @param _child the device which owns the resource 5854c4392e7SDoug Rabson * @param _type the type of resource 5864c4392e7SDoug Rabson * @param _rid the resource identifier 587e3043798SPedro F. Giffuni * @param _start the address of a location to receive the start 5884c4392e7SDoug Rabson * index of the resource range 589e3043798SPedro F. Giffuni * @param _count the address of a location to receive the size 5904c4392e7SDoug Rabson * of the resource range 5914c4392e7SDoug Rabson */ 59225afb89bSDoug RabsonMETHOD int get_resource { 593bd418641SMark Murray device_t _dev; 594bd418641SMark Murray device_t _child; 595bd418641SMark Murray int _type; 596bd418641SMark Murray int _rid; 5972dd1bdf1SJustin Hibbits rman_res_t *_startp; 5982dd1bdf1SJustin Hibbits rman_res_t *_countp; 59925afb89bSDoug Rabson}; 60025afb89bSDoug Rabson 6014c4392e7SDoug Rabson/** 6024c4392e7SDoug Rabson * @brief Delete a resource. 6034c4392e7SDoug Rabson * 6044c4392e7SDoug Rabson * Use this to delete a resource (possibly one previously added with 6054c4392e7SDoug Rabson * BUS_SET_RESOURCE()). 6064c4392e7SDoug Rabson * 6074c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6084c4392e7SDoug Rabson * @param _child the device which owns the resource 6094c4392e7SDoug Rabson * @param _type the type of resource 6104c4392e7SDoug Rabson * @param _rid the resource identifier 6114c4392e7SDoug Rabson */ 61225afb89bSDoug RabsonMETHOD void delete_resource { 613bd418641SMark Murray device_t _dev; 614bd418641SMark Murray device_t _child; 615bd418641SMark Murray int _type; 616bd418641SMark Murray int _rid; 61725afb89bSDoug Rabson}; 6180cb53e24SMatthew N. Dodd 6194c4392e7SDoug Rabson/** 6204c4392e7SDoug Rabson * @brief Return a struct resource_list. 6214c4392e7SDoug Rabson * 6224c4392e7SDoug Rabson * Used by drivers which use bus_generic_rl_alloc_resource() etc. to 6234c4392e7SDoug Rabson * implement their resource handling. It should return the resource 6244c4392e7SDoug Rabson * list of the given child device. 6254c4392e7SDoug Rabson * 6264c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6274c4392e7SDoug Rabson * @param _child the device which owns the resource list 6284c4392e7SDoug Rabson */ 62946aa504eSMatthew N. DoddMETHOD struct resource_list * get_resource_list { 630bd418641SMark Murray device_t _dev; 631bd418641SMark Murray device_t _child; 6320cb53e24SMatthew N. Dodd} DEFAULT bus_generic_get_resource_list; 6335878eb3fSWarner Losh 6344c4392e7SDoug Rabson/** 6354c4392e7SDoug Rabson * @brief Is the hardware described by @p _child still attached to the 6364c4392e7SDoug Rabson * system? 6374c4392e7SDoug Rabson * 6389f7f340aSWarner Losh * This method should return 0 if the device is not present. It 6399f7f340aSWarner Losh * should return -1 if it is present. Any errors in determining 6409f7f340aSWarner Losh * should be returned as a normal errno value. Client drivers are to 6419f7f340aSWarner Losh * assume that the device is present, even if there is an error 642db4fcadfSConrad Meyer * determining if it is there. Buses are to try to avoid returning 6439f7f340aSWarner Losh * errors, but newcard will return an error if the device fails to 6449f7f340aSWarner Losh * implement this method. 6454c4392e7SDoug Rabson * 6464c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6474c4392e7SDoug Rabson * @param _child the device which is being examined 6484c4392e7SDoug Rabson */ 6495878eb3fSWarner LoshMETHOD int child_present { 6505878eb3fSWarner Losh device_t _dev; 6515878eb3fSWarner Losh device_t _child; 6525878eb3fSWarner Losh} DEFAULT bus_generic_child_present; 6533d9841b4SWarner Losh 6544c4392e7SDoug Rabson/** 6554c4392e7SDoug Rabson * @brief Returns the pnp info for this device. 6564c4392e7SDoug Rabson * 65708907ec3SRavi Pokala * Return it as a string. If the storage is insufficient for the 65808907ec3SRavi Pokala * string, then return EOVERFLOW. 6594c4392e7SDoug Rabson * 660ed7ed7f0SJohn Baldwin * The string must be formatted as a space-separated list of 661ed7ed7f0SJohn Baldwin * name=value pairs. Names may only contain alphanumeric characters, 662ed7ed7f0SJohn Baldwin * underscores ('_') and hyphens ('-'). Values can contain any 663ed7ed7f0SJohn Baldwin * non-whitespace characters. Values containing whitespace can be 664ed7ed7f0SJohn Baldwin * quoted with double quotes ('"'). Double quotes and backslashes in 665ed7ed7f0SJohn Baldwin * quoted values can be escaped with backslashes ('\'). 666ed7ed7f0SJohn Baldwin * 6674c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6684c4392e7SDoug Rabson * @param _child the device which is being examined 6694c4392e7SDoug Rabson * @param _buf the address of a buffer to receive the pnp 6704c4392e7SDoug Rabson * string 6714c4392e7SDoug Rabson * @param _buflen the size of the buffer pointed to by @p _buf 6724c4392e7SDoug Rabson */ 6733d9841b4SWarner LoshMETHOD int child_pnpinfo_str { 6743d9841b4SWarner Losh device_t _dev; 6753d9841b4SWarner Losh device_t _child; 6763d9841b4SWarner Losh char *_buf; 6773d9841b4SWarner Losh size_t _buflen; 6783d9841b4SWarner Losh}; 6793d9841b4SWarner Losh 6804c4392e7SDoug Rabson/** 6814c4392e7SDoug Rabson * @brief Returns the location for this device. 6824c4392e7SDoug Rabson * 68308907ec3SRavi Pokala * Return it as a string. If the storage is insufficient for the 68408907ec3SRavi Pokala * string, then return EOVERFLOW. 6854c4392e7SDoug Rabson * 686ed7ed7f0SJohn Baldwin * The string must be formatted as a space-separated list of 687ed7ed7f0SJohn Baldwin * name=value pairs. Names may only contain alphanumeric characters, 688ed7ed7f0SJohn Baldwin * underscores ('_') and hyphens ('-'). Values can contain any 689ed7ed7f0SJohn Baldwin * non-whitespace characters. Values containing whitespace can be 690ed7ed7f0SJohn Baldwin * quoted with double quotes ('"'). Double quotes and backslashes in 691ed7ed7f0SJohn Baldwin * quoted values can be escaped with backslashes ('\'). 692ed7ed7f0SJohn Baldwin * 6934c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6944c4392e7SDoug Rabson * @param _child the device which is being examined 6954c4392e7SDoug Rabson * @param _buf the address of a buffer to receive the location 6964c4392e7SDoug Rabson * string 6974c4392e7SDoug Rabson * @param _buflen the size of the buffer pointed to by @p _buf 6984c4392e7SDoug Rabson */ 6993d9841b4SWarner LoshMETHOD int child_location_str { 7003d9841b4SWarner Losh device_t _dev; 7013d9841b4SWarner Losh device_t _child; 7023d9841b4SWarner Losh char *_buf; 7033d9841b4SWarner Losh size_t _buflen; 7043d9841b4SWarner Losh}; 705da13b8f9SMarcel Moolenaar 7064c4392e7SDoug Rabson/** 707dcc81068SJohn Baldwin * @brief Allow drivers to request that an interrupt be bound to a specific 708dcc81068SJohn Baldwin * CPU. 709dcc81068SJohn Baldwin * 710dcc81068SJohn Baldwin * @param _dev the parent device of @p _child 711dcc81068SJohn Baldwin * @param _child the device which allocated the resource 712dcc81068SJohn Baldwin * @param _irq the resource representing the interrupt 713dcc81068SJohn Baldwin * @param _cpu the CPU to bind the interrupt to 714dcc81068SJohn Baldwin */ 715dcc81068SJohn BaldwinMETHOD int bind_intr { 716dcc81068SJohn Baldwin device_t _dev; 717dcc81068SJohn Baldwin device_t _child; 718dcc81068SJohn Baldwin struct resource *_irq; 719dcc81068SJohn Baldwin int _cpu; 720dcc81068SJohn Baldwin} DEFAULT bus_generic_bind_intr; 721dcc81068SJohn Baldwin 722dcc81068SJohn Baldwin/** 7234c4392e7SDoug Rabson * @brief Allow (bus) drivers to specify the trigger mode and polarity 7244c4392e7SDoug Rabson * of the specified interrupt. 7254c4392e7SDoug Rabson * 7264c4392e7SDoug Rabson * @param _dev the bus device 7274c4392e7SDoug Rabson * @param _irq the interrupt number to modify 7284c4392e7SDoug Rabson * @param _trig the trigger mode required 7294c4392e7SDoug Rabson * @param _pol the interrupt polarity required 7304c4392e7SDoug Rabson */ 731da13b8f9SMarcel MoolenaarMETHOD int config_intr { 732da13b8f9SMarcel Moolenaar device_t _dev; 733da13b8f9SMarcel Moolenaar int _irq; 734da13b8f9SMarcel Moolenaar enum intr_trigger _trig; 735da13b8f9SMarcel Moolenaar enum intr_polarity _pol; 736da13b8f9SMarcel Moolenaar} DEFAULT bus_generic_config_intr; 737db2bc1bbSWarner Losh 738db2bc1bbSWarner Losh/** 73937b8ef16SJohn Baldwin * @brief Allow drivers to associate a description with an active 74037b8ef16SJohn Baldwin * interrupt handler. 74137b8ef16SJohn Baldwin * 74237b8ef16SJohn Baldwin * @param _dev the parent device of @p _child 74337b8ef16SJohn Baldwin * @param _child the device which allocated the resource 74437b8ef16SJohn Baldwin * @param _irq the resource representing the interrupt 74537b8ef16SJohn Baldwin * @param _cookie the cookie value returned when the interrupt 74637b8ef16SJohn Baldwin * was originally registered 74737b8ef16SJohn Baldwin * @param _descr the description to associate with the interrupt 74837b8ef16SJohn Baldwin */ 74937b8ef16SJohn BaldwinMETHOD int describe_intr { 75037b8ef16SJohn Baldwin device_t _dev; 75137b8ef16SJohn Baldwin device_t _child; 75237b8ef16SJohn Baldwin struct resource *_irq; 75337b8ef16SJohn Baldwin void *_cookie; 75437b8ef16SJohn Baldwin const char *_descr; 75537b8ef16SJohn Baldwin} DEFAULT bus_generic_describe_intr; 75637b8ef16SJohn Baldwin 75737b8ef16SJohn Baldwin/** 758db2bc1bbSWarner Losh * @brief Notify a (bus) driver about a child that the hints mechanism 759db2bc1bbSWarner Losh * believes it has discovered. 760db2bc1bbSWarner Losh * 761db2bc1bbSWarner Losh * The bus is responsible for then adding the child in the right order 762db2bc1bbSWarner Losh * and discovering other things about the child. The bus driver is 763db2bc1bbSWarner Losh * free to ignore this hint, to do special things, etc. It is all up 764db2bc1bbSWarner Losh * to the bus driver to interpret. 765db2bc1bbSWarner Losh * 766db2bc1bbSWarner Losh * This method is only called in response to the parent bus asking for 767db2bc1bbSWarner Losh * hinted devices to be enumerated. 768db2bc1bbSWarner Losh * 769db2bc1bbSWarner Losh * @param _dev the bus device 770db2bc1bbSWarner Losh * @param _dname the name of the device w/o unit numbers 771db2bc1bbSWarner Losh * @param _dunit the unit number of the device 772db2bc1bbSWarner Losh */ 773db2bc1bbSWarner LoshMETHOD void hinted_child { 774db2bc1bbSWarner Losh device_t _dev; 775db2bc1bbSWarner Losh const char *_dname; 776db2bc1bbSWarner Losh int _dunit; 777db2bc1bbSWarner Losh}; 778378f231eSJohn-Mark Gurney 779378f231eSJohn-Mark Gurney/** 780378f231eSJohn-Mark Gurney * @brief Returns bus_dma_tag_t for use w/ devices on the bus. 781378f231eSJohn-Mark Gurney * 782378f231eSJohn-Mark Gurney * @param _dev the parent device of @p _child 783378f231eSJohn-Mark Gurney * @param _child the device to which the tag will belong 784378f231eSJohn-Mark Gurney */ 785378f231eSJohn-Mark GurneyMETHOD bus_dma_tag_t get_dma_tag { 786378f231eSJohn-Mark Gurney device_t _dev; 787378f231eSJohn-Mark Gurney device_t _child; 788378f231eSJohn-Mark Gurney} DEFAULT bus_generic_get_dma_tag; 7890d484d24SJohn Baldwin 7900d484d24SJohn Baldwin/** 791b998c965SZbigniew Bodek * @brief Returns bus_space_tag_t for use w/ devices on the bus. 792b998c965SZbigniew Bodek * 793b998c965SZbigniew Bodek * @param _dev the parent device of @p _child 794b998c965SZbigniew Bodek * @param _child the device to which the tag will belong 795b998c965SZbigniew Bodek */ 796b998c965SZbigniew BodekMETHOD bus_space_tag_t get_bus_tag { 797b998c965SZbigniew Bodek device_t _dev; 798b998c965SZbigniew Bodek device_t _child; 799b998c965SZbigniew Bodek} DEFAULT bus_generic_get_bus_tag; 800b998c965SZbigniew Bodek 801b998c965SZbigniew Bodek/** 8020d484d24SJohn Baldwin * @brief Allow the bus to determine the unit number of a device. 8030d484d24SJohn Baldwin * 8040d484d24SJohn Baldwin * @param _dev the parent device of @p _child 8050d484d24SJohn Baldwin * @param _child the device whose unit is to be wired 8060d484d24SJohn Baldwin * @param _name the name of the device's new devclass 8070d484d24SJohn Baldwin * @param _unitp a pointer to the device's new unit value 8080d484d24SJohn Baldwin */ 8090d484d24SJohn BaldwinMETHOD void hint_device_unit { 8100d484d24SJohn Baldwin device_t _dev; 8110d484d24SJohn Baldwin device_t _child; 8120d484d24SJohn Baldwin const char *_name; 8130d484d24SJohn Baldwin int *_unitp; 8140d484d24SJohn Baldwin}; 8150d484d24SJohn Baldwin 8164ef60d26SJohn Baldwin/** 8174ef60d26SJohn Baldwin * @brief Notify a bus that the bus pass level has been changed 8184ef60d26SJohn Baldwin * 8194ef60d26SJohn Baldwin * @param _dev the bus device 8204ef60d26SJohn Baldwin */ 8214ef60d26SJohn BaldwinMETHOD void new_pass { 8224ef60d26SJohn Baldwin device_t _dev; 8234ef60d26SJohn Baldwin} DEFAULT bus_generic_new_pass; 82493fc07b4SAlexander Motin 82593fc07b4SAlexander Motin/** 82693fc07b4SAlexander Motin * @brief Notify a bus that specified child's IRQ should be remapped. 82793fc07b4SAlexander Motin * 82893fc07b4SAlexander Motin * @param _dev the bus device 82993fc07b4SAlexander Motin * @param _child the child device 83093fc07b4SAlexander Motin * @param _irq the irq number 83193fc07b4SAlexander Motin */ 83293fc07b4SAlexander MotinMETHOD int remap_intr { 83393fc07b4SAlexander Motin device_t _dev; 83493fc07b4SAlexander Motin device_t _child; 83593fc07b4SAlexander Motin u_int _irq; 83693fc07b4SAlexander Motin} DEFAULT null_remap_intr; 837a1c16348SJustin Hibbits 838a1c16348SJustin Hibbits/** 839a1c16348SJustin Hibbits * @brief Suspend a given child 840a1c16348SJustin Hibbits * 841a1c16348SJustin Hibbits * @param _dev the parent device of @p _child 842a1c16348SJustin Hibbits * @param _child the device to suspend 843a1c16348SJustin Hibbits */ 844a1c16348SJustin HibbitsMETHOD int suspend_child { 845a1c16348SJustin Hibbits device_t _dev; 846a1c16348SJustin Hibbits device_t _child; 847a1c16348SJustin Hibbits} DEFAULT bus_generic_suspend_child; 848a1c16348SJustin Hibbits 849a1c16348SJustin Hibbits/** 850a1c16348SJustin Hibbits * @brief Resume a given child 851a1c16348SJustin Hibbits * 852a1c16348SJustin Hibbits * @param _dev the parent device of @p _child 853a1c16348SJustin Hibbits * @param _child the device to resume 854a1c16348SJustin Hibbits */ 855a1c16348SJustin HibbitsMETHOD int resume_child { 856a1c16348SJustin Hibbits device_t _dev; 857a1c16348SJustin Hibbits device_t _child; 858a1c16348SJustin Hibbits} DEFAULT bus_generic_resume_child; 859ffcf962dSAdrian Chadd 860ffcf962dSAdrian Chadd/** 861ffcf962dSAdrian Chadd * @brief Get the VM domain handle for the given bus and child. 862ffcf962dSAdrian Chadd * 863ffcf962dSAdrian Chadd * @param _dev the bus device 864ffcf962dSAdrian Chadd * @param _child the child device 865ffcf962dSAdrian Chadd * @param _domain a pointer to the bus's domain handle identifier 866ffcf962dSAdrian Chadd */ 867ffcf962dSAdrian ChaddMETHOD int get_domain { 868ffcf962dSAdrian Chadd device_t _dev; 869ffcf962dSAdrian Chadd device_t _child; 870ffcf962dSAdrian Chadd int *_domain; 871ffcf962dSAdrian Chadd} DEFAULT bus_generic_get_domain; 8728d791e5aSJohn Baldwin 8738d791e5aSJohn Baldwin/** 8748d791e5aSJohn Baldwin * @brief Request a set of CPUs 8758d791e5aSJohn Baldwin * 8768d791e5aSJohn Baldwin * @param _dev the bus device 8778d791e5aSJohn Baldwin * @param _child the child device 8788d791e5aSJohn Baldwin * @param _op type of CPUs to request 8798d791e5aSJohn Baldwin * @param _setsize the size of the set passed in _cpuset 8808d791e5aSJohn Baldwin * @param _cpuset a pointer to a cpuset to receive the requested 8818d791e5aSJohn Baldwin * set of CPUs 8828d791e5aSJohn Baldwin */ 8838d791e5aSJohn BaldwinMETHOD int get_cpus { 8848d791e5aSJohn Baldwin device_t _dev; 8858d791e5aSJohn Baldwin device_t _child; 8868d791e5aSJohn Baldwin enum cpu_sets _op; 8878d791e5aSJohn Baldwin size_t _setsize; 888e2e050c8SConrad Meyer struct _cpuset *_cpuset; 8898d791e5aSJohn Baldwin} DEFAULT bus_generic_get_cpus; 890c53df6daSKonstantin Belousov 891c53df6daSKonstantin Belousov/** 892c53df6daSKonstantin Belousov * @brief Prepares the given child of the bus for reset 893c53df6daSKonstantin Belousov * 894c53df6daSKonstantin Belousov * Typically bus detaches or suspends children' drivers, and then 895c53df6daSKonstantin Belousov * calls this method to save bus-specific information, for instance, 896c53df6daSKonstantin Belousov * PCI config space, which is damaged by reset. 897c53df6daSKonstantin Belousov * 898c53df6daSKonstantin Belousov * The bus_helper_reset_prepare() helper is provided to ease 899c53df6daSKonstantin Belousov * implementing bus reset methods. 900c53df6daSKonstantin Belousov * 901c53df6daSKonstantin Belousov * @param _dev the bus device 902c53df6daSKonstantin Belousov * @param _child the child device 903c53df6daSKonstantin Belousov */ 904c53df6daSKonstantin BelousovMETHOD int reset_prepare { 905c53df6daSKonstantin Belousov device_t _dev; 906c53df6daSKonstantin Belousov device_t _child; 907c53df6daSKonstantin Belousov} DEFAULT null_reset_prepare; 908c53df6daSKonstantin Belousov 909c53df6daSKonstantin Belousov/** 910c53df6daSKonstantin Belousov * @brief Restores the child operations after the reset 911c53df6daSKonstantin Belousov * 912c53df6daSKonstantin Belousov * The bus_helper_reset_post() helper is provided to ease 913c53df6daSKonstantin Belousov * implementing bus reset methods. 914c53df6daSKonstantin Belousov * 915c53df6daSKonstantin Belousov * @param _dev the bus device 916c53df6daSKonstantin Belousov * @param _child the child device 917c53df6daSKonstantin Belousov */ 918c53df6daSKonstantin BelousovMETHOD int reset_post { 919c53df6daSKonstantin Belousov device_t _dev; 920c53df6daSKonstantin Belousov device_t _child; 921c53df6daSKonstantin Belousov} DEFAULT null_reset_post; 922c53df6daSKonstantin Belousov 923c53df6daSKonstantin Belousov/** 924c53df6daSKonstantin Belousov * @brief Performs reset of the child 925c53df6daSKonstantin Belousov * 926c53df6daSKonstantin Belousov * @param _dev the bus device 927c53df6daSKonstantin Belousov * @param _child the child device 928c53df6daSKonstantin Belousov * @param _flags DEVF_RESET_ flags 929c53df6daSKonstantin Belousov */ 930c53df6daSKonstantin BelousovMETHOD int reset_child { 931c53df6daSKonstantin Belousov device_t _dev; 932c53df6daSKonstantin Belousov device_t _child; 933c53df6daSKonstantin Belousov int _flags; 934c53df6daSKonstantin Belousov}; 935