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 } 79937a05baSJustin Hibbits 80937a05baSJustin Hibbits static int 81937a05baSJustin Hibbits null_translate_resource(device_t bus, int type, rman_res_t start, 82937a05baSJustin Hibbits rman_res_t *newstart) 83937a05baSJustin Hibbits { 84937a05baSJustin Hibbits if (device_get_parent(bus) != NULL) 85937a05baSJustin Hibbits return (BUS_TRANSLATE_RESOURCE(device_get_parent(bus), 86937a05baSJustin Hibbits type, start, newstart)); 87937a05baSJustin Hibbits 88937a05baSJustin Hibbits *newstart = start; 89937a05baSJustin Hibbits return (0); 90937a05baSJustin Hibbits } 91*3f9a00e3SBartlomiej Grzesik 92*3f9a00e3SBartlomiej Grzesik static ssize_t 93*3f9a00e3SBartlomiej Grzesik null_get_property(device_t dev, device_t child, const char *propname, 94*3f9a00e3SBartlomiej Grzesik void *propvalue, size_t size) 95*3f9a00e3SBartlomiej Grzesik { 96*3f9a00e3SBartlomiej Grzesik return (-1); 97*3f9a00e3SBartlomiej Grzesik } 988b2970bbSDoug Rabson}; 998b2970bbSDoug Rabson 1004c4392e7SDoug Rabson/** 1014c4392e7SDoug Rabson * @brief Print a description of a child device 1024c4392e7SDoug Rabson * 1034c4392e7SDoug Rabson * This is called from system code which prints out a description of a 1044c4392e7SDoug Rabson * device. It should describe the attachment that the child has with 1054c4392e7SDoug Rabson * the parent. For instance the TurboLaser bus prints which node the 1064c4392e7SDoug Rabson * device is attached to. See bus_generic_print_child() for more 1074c4392e7SDoug Rabson * information. 1084c4392e7SDoug Rabson * 1094c4392e7SDoug Rabson * @param _dev the device whose child is being printed 1104c4392e7SDoug Rabson * @param _child the child device to describe 1114c4392e7SDoug Rabson * 1124c4392e7SDoug Rabson * @returns the number of characters output. 1134c4392e7SDoug Rabson */ 11415317dd8SMatthew N. DoddMETHOD int print_child { 1154c4392e7SDoug Rabson device_t _dev; 1164c4392e7SDoug Rabson device_t _child; 117c8440669SMatthew N. Dodd} DEFAULT bus_generic_print_child; 118b1bf6610SDoug Rabson 1194c4392e7SDoug Rabson/** 1204c4392e7SDoug Rabson * @brief Print a notification about an unprobed child device. 1214c4392e7SDoug Rabson * 1224c4392e7SDoug Rabson * Called for each child device that did not succeed in probing for a 1234c4392e7SDoug Rabson * driver. 1244c4392e7SDoug Rabson * 1254c4392e7SDoug Rabson * @param _dev the device whose child was being probed 1264c4392e7SDoug Rabson * @param _child the child device which failed to probe 1274c4392e7SDoug Rabson */ 128ca7036d8SDoug RabsonMETHOD void probe_nomatch { 1294c4392e7SDoug Rabson device_t _dev; 1304c4392e7SDoug Rabson device_t _child; 131ca7036d8SDoug Rabson}; 132ca7036d8SDoug Rabson 1334c4392e7SDoug Rabson/** 1344c4392e7SDoug Rabson * @brief Read the value of a bus-specific attribute of a device 1354c4392e7SDoug Rabson * 1364c4392e7SDoug Rabson * This method, along with BUS_WRITE_IVAR() manages a bus-specific set 1374c4392e7SDoug Rabson * of instance variables of a child device. The intention is that 1384c4392e7SDoug Rabson * each different type of bus defines a set of appropriate instance 1394c4392e7SDoug Rabson * variables (such as ports and irqs for ISA bus etc.) 1404c4392e7SDoug Rabson * 1414c4392e7SDoug Rabson * This information could be given to the child device as a struct but 1424c4392e7SDoug Rabson * that makes it hard for a bus to add or remove variables without 1434c4392e7SDoug Rabson * forcing an edit and recompile for all drivers which may not be 1444c4392e7SDoug Rabson * possible for vendor supplied binary drivers. 1454c4392e7SDoug Rabson * 1464c4392e7SDoug Rabson * This method copies the value of an instance variable to the 1474c4392e7SDoug Rabson * location specified by @p *_result. 1484c4392e7SDoug Rabson * 1494c4392e7SDoug Rabson * @param _dev the device whose child was being examined 1504c4392e7SDoug Rabson * @param _child the child device whose instance variable is 1514c4392e7SDoug Rabson * being read 1524c4392e7SDoug Rabson * @param _index the instance variable to read 153e3043798SPedro F. Giffuni * @param _result a location to receive the instance variable 1544c4392e7SDoug Rabson * value 1554c4392e7SDoug Rabson * 1564c4392e7SDoug Rabson * @retval 0 success 1574c4392e7SDoug Rabson * @retval ENOENT no such instance variable is supported by @p 1584c4392e7SDoug Rabson * _dev 1594c4392e7SDoug Rabson */ 160b1bf6610SDoug RabsonMETHOD int read_ivar { 161bd418641SMark Murray device_t _dev; 162bd418641SMark Murray device_t _child; 1634c4392e7SDoug Rabson int _index; 164bd418641SMark Murray uintptr_t *_result; 165b1bf6610SDoug Rabson}; 166b1bf6610SDoug Rabson 1674c4392e7SDoug Rabson/** 1684c4392e7SDoug Rabson * @brief Write the value of a bus-specific attribute of a device 1694c4392e7SDoug Rabson * 1704c4392e7SDoug Rabson * This method sets the value of an instance variable to @p _value. 1714c4392e7SDoug Rabson * 1724c4392e7SDoug Rabson * @param _dev the device whose child was being updated 1734c4392e7SDoug Rabson * @param _child the child device whose instance variable is 1744c4392e7SDoug Rabson * being written 1754c4392e7SDoug Rabson * @param _index the instance variable to write 1764c4392e7SDoug Rabson * @param _value the value to write to that instance variable 1774c4392e7SDoug Rabson * 1784c4392e7SDoug Rabson * @retval 0 success 1794c4392e7SDoug Rabson * @retval ENOENT no such instance variable is supported by @p 1804c4392e7SDoug Rabson * _dev 1814c4392e7SDoug Rabson * @retval EINVAL the instance variable was recognised but 1824c4392e7SDoug Rabson * contains a read-only value 1834c4392e7SDoug Rabson */ 184b1bf6610SDoug RabsonMETHOD int write_ivar { 185bd418641SMark Murray device_t _dev; 186bd418641SMark Murray device_t _child; 187bd418641SMark Murray int _indx; 188bd418641SMark Murray uintptr_t _value; 189b1bf6610SDoug Rabson}; 190b1bf6610SDoug Rabson 1914c4392e7SDoug Rabson/** 1926f7d0018SJohn Baldwin * @brief Notify a bus that a child was deleted 1936f7d0018SJohn Baldwin * 1946f7d0018SJohn Baldwin * Called at the beginning of device_delete_child() to allow the parent 1956f7d0018SJohn Baldwin * to teardown any bus-specific state for the child. 1966f7d0018SJohn Baldwin * 1976f7d0018SJohn Baldwin * @param _dev the device whose child is being deleted 1986f7d0018SJohn Baldwin * @param _child the child device which is being deleted 1996f7d0018SJohn Baldwin */ 2006f7d0018SJohn BaldwinMETHOD void child_deleted { 2016f7d0018SJohn Baldwin device_t _dev; 2026f7d0018SJohn Baldwin device_t _child; 2036f7d0018SJohn Baldwin}; 2046f7d0018SJohn Baldwin 2056f7d0018SJohn Baldwin/** 2064c4392e7SDoug Rabson * @brief Notify a bus that a child was detached 2074c4392e7SDoug Rabson * 2084c4392e7SDoug Rabson * Called after the child's DEVICE_DETACH() method to allow the parent 2094c4392e7SDoug Rabson * to reclaim any resources allocated on behalf of the child. 2104c4392e7SDoug Rabson * 2114c4392e7SDoug Rabson * @param _dev the device whose child changed state 2124c4392e7SDoug Rabson * @param _child the child device which changed state 2134c4392e7SDoug Rabson */ 2146350e58aSDoug RabsonMETHOD void child_detached { 215bd418641SMark Murray device_t _dev; 216bd418641SMark Murray device_t _child; 2176350e58aSDoug Rabson}; 2186350e58aSDoug Rabson 2194c4392e7SDoug Rabson/** 2204c4392e7SDoug Rabson * @brief Notify a bus that a new driver was added 2214c4392e7SDoug Rabson * 2224c4392e7SDoug Rabson * Called when a new driver is added to the devclass which owns this 2234c4392e7SDoug Rabson * bus. The generic implementation of this method attempts to probe and 2244c4392e7SDoug Rabson * attach any un-matched children of the bus. 2254c4392e7SDoug Rabson * 2264c4392e7SDoug Rabson * @param _dev the device whose devclass had a new driver 2274c4392e7SDoug Rabson * added to it 2284c4392e7SDoug Rabson * @param _driver the new driver which was added 2294c4392e7SDoug Rabson */ 2306182fdbdSPeter WemmMETHOD void driver_added { 231bd418641SMark Murray device_t _dev; 232bd418641SMark Murray driver_t *_driver; 2336d4d0ac9SWarner Losh} DEFAULT bus_generic_driver_added; 2346182fdbdSPeter Wemm 2354c4392e7SDoug Rabson/** 2364c4392e7SDoug Rabson * @brief Create a new child device 2374c4392e7SDoug Rabson * 238db4fcadfSConrad Meyer * For buses which use use drivers supporting DEVICE_IDENTIFY() to 2394c4392e7SDoug Rabson * enumerate their devices, this method is used to create new 2404c4392e7SDoug Rabson * device instances. The new device will be added after the last 24183a283cfSWarner Losh * existing child with the same order. Implementations of bus_add_child 24283a283cfSWarner Losh * call device_add_child_ordered to add the child and often add 24383a283cfSWarner Losh * a suitable ivar to the device specific to that bus. 2444c4392e7SDoug Rabson * 2454c4392e7SDoug Rabson * @param _dev the bus device which will be the parent of the 2464c4392e7SDoug Rabson * new child device 2474c4392e7SDoug Rabson * @param _order a value which is used to partially sort the 2484c4392e7SDoug Rabson * children of @p _dev - devices created using 2494c4392e7SDoug Rabson * lower values of @p _order appear first in @p 2504c4392e7SDoug Rabson * _dev's list of children 2514c4392e7SDoug Rabson * @param _name devclass name for new device or @c NULL if not 2524c4392e7SDoug Rabson * specified 2534c4392e7SDoug Rabson * @param _unit unit number for new device or @c -1 if not 2544c4392e7SDoug Rabson * specified 2554c4392e7SDoug Rabson */ 2566c2e3ddeSDoug RabsonMETHOD device_t add_child { 257bd418641SMark Murray device_t _dev; 2583d844eddSAndriy Gapon u_int _order; 259bd418641SMark Murray const char *_name; 260bd418641SMark Murray int _unit; 261b7d28b2eSAndriy Gapon} DEFAULT null_add_child; 2626c2e3ddeSDoug Rabson 2634c4392e7SDoug Rabson/** 264a907c691SJohn Baldwin * @brief Rescan the bus 265a907c691SJohn Baldwin * 266a907c691SJohn Baldwin * This method is called by a parent bridge or devctl to trigger a bus 267a907c691SJohn Baldwin * rescan. The rescan should delete devices no longer present and 268a907c691SJohn Baldwin * enumerate devices that have newly arrived. 269a907c691SJohn Baldwin * 270a907c691SJohn Baldwin * @param _dev the bus device 271a907c691SJohn Baldwin */ 272a907c691SJohn BaldwinMETHOD int rescan { 273a907c691SJohn Baldwin device_t _dev; 274a907c691SJohn Baldwin} 275a907c691SJohn Baldwin 276a907c691SJohn Baldwin/** 2774c4392e7SDoug Rabson * @brief Allocate a system resource 2784c4392e7SDoug Rabson * 2794c4392e7SDoug Rabson * This method is called by child devices of a bus to allocate resources. 2804c4392e7SDoug Rabson * The types are defined in <machine/resource.h>; the meaning of the 2814c4392e7SDoug Rabson * resource-ID field varies from bus to bus (but @p *rid == 0 is always 2824c4392e7SDoug Rabson * valid if the resource type is). If a resource was allocated and the 2834c4392e7SDoug Rabson * caller did not use the RF_ACTIVE to specify that it should be 2844c4392e7SDoug Rabson * activated immediately, the caller is responsible for calling 2854c4392e7SDoug Rabson * BUS_ACTIVATE_RESOURCE() when it actually uses the resource. 2864c4392e7SDoug Rabson * 2874c4392e7SDoug Rabson * @param _dev the parent device of @p _child 2884c4392e7SDoug Rabson * @param _child the device which is requesting an allocation 2894c4392e7SDoug Rabson * @param _type the type of resource to allocate 2904c4392e7SDoug Rabson * @param _rid a pointer to the resource identifier 2914c4392e7SDoug Rabson * @param _start hint at the start of the resource range - pass 292534ccd7bSJustin Hibbits * @c 0 for any start address 2934c4392e7SDoug Rabson * @param _end hint at the end of the resource range - pass 294534ccd7bSJustin Hibbits * @c ~0 for any end address 2954c4392e7SDoug Rabson * @param _count hint at the size of range required - pass @c 1 2964c4392e7SDoug Rabson * for any size 2974c4392e7SDoug Rabson * @param _flags any extra flags to control the resource 2984c4392e7SDoug Rabson * allocation - see @c RF_XXX flags in 2994c4392e7SDoug Rabson * <sys/rman.h> for details 3004c4392e7SDoug Rabson * 3014c4392e7SDoug Rabson * @returns the resource which was allocated or @c NULL if no 3024c4392e7SDoug Rabson * resource could be allocated 3034c4392e7SDoug Rabson */ 30414177d72SGarrett WollmanMETHOD struct resource * alloc_resource { 305bd418641SMark Murray device_t _dev; 306bd418641SMark Murray device_t _child; 307bd418641SMark Murray int _type; 308bd418641SMark Murray int *_rid; 3092dd1bdf1SJustin Hibbits rman_res_t _start; 3102dd1bdf1SJustin Hibbits rman_res_t _end; 3112dd1bdf1SJustin Hibbits rman_res_t _count; 312bd418641SMark Murray u_int _flags; 3138b2970bbSDoug Rabson} DEFAULT null_alloc_resource; 31414177d72SGarrett Wollman 3154c4392e7SDoug Rabson/** 3164c4392e7SDoug Rabson * @brief Activate a resource 3174c4392e7SDoug Rabson * 3184c4392e7SDoug Rabson * Activate a resource previously allocated with 319cc981af2SJohn Baldwin * BUS_ALLOC_RESOURCE(). This may enable decoding of this resource in a 320cc981af2SJohn Baldwin * device for instance. It will also establish a mapping for the resource 321cc981af2SJohn Baldwin * unless RF_UNMAPPED was set when allocating the resource. 3224c4392e7SDoug Rabson * 3234c4392e7SDoug Rabson * @param _dev the parent device of @p _child 3244c4392e7SDoug Rabson * @param _child the device which allocated the resource 3254c4392e7SDoug Rabson * @param _type the type of resource 3264c4392e7SDoug Rabson * @param _rid the resource identifier 3274c4392e7SDoug Rabson * @param _r the resource to activate 3284c4392e7SDoug Rabson */ 32914177d72SGarrett WollmanMETHOD int activate_resource { 330bd418641SMark Murray device_t _dev; 331bd418641SMark Murray device_t _child; 332bd418641SMark Murray int _type; 333bd418641SMark Murray int _rid; 334bd418641SMark Murray struct resource *_r; 33514177d72SGarrett Wollman}; 33614177d72SGarrett Wollman 337cc981af2SJohn Baldwin 338cc981af2SJohn Baldwin/** 339cc981af2SJohn Baldwin * @brief Map a resource 340cc981af2SJohn Baldwin * 341cc981af2SJohn Baldwin * Allocate a mapping for a range of an active resource. The mapping 342cc981af2SJohn Baldwin * is described by a struct resource_map object. This may for instance 343cc981af2SJohn Baldwin * map a memory region into the kernel's virtual address space. 344cc981af2SJohn Baldwin * 345cc981af2SJohn Baldwin * @param _dev the parent device of @p _child 346cc981af2SJohn Baldwin * @param _child the device which allocated the resource 347cc981af2SJohn Baldwin * @param _type the type of resource 348cc981af2SJohn Baldwin * @param _r the resource to map 349cc981af2SJohn Baldwin * @param _args optional attributes of the mapping 350cc981af2SJohn Baldwin * @param _map the mapping 351cc981af2SJohn Baldwin */ 352cc981af2SJohn BaldwinMETHOD int map_resource { 353cc981af2SJohn Baldwin device_t _dev; 354cc981af2SJohn Baldwin device_t _child; 355cc981af2SJohn Baldwin int _type; 356cc981af2SJohn Baldwin struct resource *_r; 357cc981af2SJohn Baldwin struct resource_map_request *_args; 358cc981af2SJohn Baldwin struct resource_map *_map; 359cc981af2SJohn Baldwin} DEFAULT bus_generic_map_resource; 360cc981af2SJohn Baldwin 361cc981af2SJohn Baldwin 362cc981af2SJohn Baldwin/** 363cc981af2SJohn Baldwin * @brief Unmap a resource 364cc981af2SJohn Baldwin * 365cc981af2SJohn Baldwin * Release a mapping previously allocated with 366cc981af2SJohn Baldwin * BUS_MAP_RESOURCE(). This may for instance unmap a memory region 367cc981af2SJohn Baldwin * from the kernel's virtual address space. 368cc981af2SJohn Baldwin * 369cc981af2SJohn Baldwin * @param _dev the parent device of @p _child 370cc981af2SJohn Baldwin * @param _child the device which allocated the resource 371cc981af2SJohn Baldwin * @param _type the type of resource 372cc981af2SJohn Baldwin * @param _r the resource 373cc981af2SJohn Baldwin * @param _map the mapping to release 374cc981af2SJohn Baldwin */ 375cc981af2SJohn BaldwinMETHOD int unmap_resource { 376cc981af2SJohn Baldwin device_t _dev; 377cc981af2SJohn Baldwin device_t _child; 378cc981af2SJohn Baldwin int _type; 379cc981af2SJohn Baldwin struct resource *_r; 380cc981af2SJohn Baldwin struct resource_map *_map; 381cc981af2SJohn Baldwin} DEFAULT bus_generic_unmap_resource; 382cc981af2SJohn Baldwin 383cc981af2SJohn Baldwin 3844c4392e7SDoug Rabson/** 3854c4392e7SDoug Rabson * @brief Deactivate a resource 3864c4392e7SDoug Rabson * 3874c4392e7SDoug Rabson * Deactivate a resource previously allocated with 388cc981af2SJohn Baldwin * BUS_ALLOC_RESOURCE(). 3894c4392e7SDoug Rabson * 3904c4392e7SDoug Rabson * @param _dev the parent device of @p _child 3914c4392e7SDoug Rabson * @param _child the device which allocated the resource 3924c4392e7SDoug Rabson * @param _type the type of resource 3934c4392e7SDoug Rabson * @param _rid the resource identifier 3944c4392e7SDoug Rabson * @param _r the resource to deactivate 3954c4392e7SDoug Rabson */ 39614177d72SGarrett WollmanMETHOD int deactivate_resource { 397bd418641SMark Murray device_t _dev; 398bd418641SMark Murray device_t _child; 399bd418641SMark Murray int _type; 400bd418641SMark Murray int _rid; 401bd418641SMark Murray struct resource *_r; 402b1bf6610SDoug Rabson}; 40345c95fa1SDoug Rabson 4044c4392e7SDoug Rabson/** 40585ee63c9SJohn Baldwin * @brief Adjust a resource 40685ee63c9SJohn Baldwin * 40785ee63c9SJohn Baldwin * Adjust the start and/or end of a resource allocated by 40885ee63c9SJohn Baldwin * BUS_ALLOC_RESOURCE. At least part of the new address range must overlap 40985ee63c9SJohn Baldwin * with the existing address range. If the successful, the resource's range 41085ee63c9SJohn Baldwin * will be adjusted to [start, end] on return. 41185ee63c9SJohn Baldwin * 41285ee63c9SJohn Baldwin * @param _dev the parent device of @p _child 41385ee63c9SJohn Baldwin * @param _child the device which allocated the resource 41485ee63c9SJohn Baldwin * @param _type the type of resource 41585ee63c9SJohn Baldwin * @param _res the resource to adjust 41685ee63c9SJohn Baldwin * @param _start the new starting address of the resource range 41785ee63c9SJohn Baldwin * @param _end the new ending address of the resource range 41885ee63c9SJohn Baldwin */ 41985ee63c9SJohn BaldwinMETHOD int adjust_resource { 42085ee63c9SJohn Baldwin device_t _dev; 42185ee63c9SJohn Baldwin device_t _child; 42285ee63c9SJohn Baldwin int _type; 42385ee63c9SJohn Baldwin struct resource *_res; 4242dd1bdf1SJustin Hibbits rman_res_t _start; 4252dd1bdf1SJustin Hibbits rman_res_t _end; 42685ee63c9SJohn Baldwin}; 42785ee63c9SJohn Baldwin 428937a05baSJustin Hibbits 429937a05baSJustin Hibbits/** 430937a05baSJustin Hibbits * @brief translate a resource value 431937a05baSJustin Hibbits * 432937a05baSJustin Hibbits * 433937a05baSJustin Hibbits * @param _dev the device associated with the resource 434937a05baSJustin Hibbits * @param _type the type of resource 435937a05baSJustin Hibbits * @param _start the starting address of the resource range 436937a05baSJustin Hibbits * @param _newstart the new starting address of the resource range 437937a05baSJustin Hibbits */ 438937a05baSJustin HibbitsMETHOD int translate_resource { 439937a05baSJustin Hibbits device_t _dev; 440937a05baSJustin Hibbits int _type; 441937a05baSJustin Hibbits rman_res_t _start; 442937a05baSJustin Hibbits rman_res_t *_newstart; 443937a05baSJustin Hibbits} DEFAULT null_translate_resource; 444937a05baSJustin Hibbits 44585ee63c9SJohn Baldwin/** 4464c4392e7SDoug Rabson * @brief Release a resource 4474c4392e7SDoug Rabson * 4484c4392e7SDoug Rabson * Free a resource allocated by the BUS_ALLOC_RESOURCE. The @p _rid 4494c4392e7SDoug Rabson * value must be the same as the one returned by BUS_ALLOC_RESOURCE() 4504c4392e7SDoug Rabson * (which is not necessarily the same as the one the client passed). 4514c4392e7SDoug Rabson * 4524c4392e7SDoug Rabson * @param _dev the parent device of @p _child 4534c4392e7SDoug Rabson * @param _child the device which allocated the resource 4544c4392e7SDoug Rabson * @param _type the type of resource 4554c4392e7SDoug Rabson * @param _rid the resource identifier 4564c4392e7SDoug Rabson * @param _r the resource to release 4574c4392e7SDoug Rabson */ 45814177d72SGarrett WollmanMETHOD int release_resource { 459bd418641SMark Murray device_t _dev; 460bd418641SMark Murray device_t _child; 461bd418641SMark Murray int _type; 462bd418641SMark Murray int _rid; 463bd418641SMark Murray struct resource *_res; 46414177d72SGarrett Wollman}; 46514177d72SGarrett Wollman 4664c4392e7SDoug Rabson/** 4674c4392e7SDoug Rabson * @brief Install an interrupt handler 4684c4392e7SDoug Rabson * 4694c4392e7SDoug Rabson * This method is used to associate an interrupt handler function with 4704c4392e7SDoug Rabson * an irq resource. When the interrupt triggers, the function @p _intr 4714c4392e7SDoug Rabson * will be called with the value of @p _arg as its single 4724c4392e7SDoug Rabson * argument. The value returned in @p *_cookiep is used to cancel the 4734c4392e7SDoug Rabson * interrupt handler - the caller should save this value to use in a 4744c4392e7SDoug Rabson * future call to BUS_TEARDOWN_INTR(). 4754c4392e7SDoug Rabson * 4764c4392e7SDoug Rabson * @param _dev the parent device of @p _child 4774c4392e7SDoug Rabson * @param _child the device which allocated the resource 4784c4392e7SDoug Rabson * @param _irq the resource representing the interrupt 4794c4392e7SDoug Rabson * @param _flags a set of bits from enum intr_type specifying 4804c4392e7SDoug Rabson * the class of interrupt 4814c4392e7SDoug Rabson * @param _intr the function to call when the interrupt 4824c4392e7SDoug Rabson * triggers 4834c4392e7SDoug Rabson * @param _arg a value to use as the single argument in calls 4844c4392e7SDoug Rabson * to @p _intr 485e3043798SPedro F. Giffuni * @param _cookiep a pointer to a location to receive a cookie 4864c4392e7SDoug Rabson * value that may be used to remove the interrupt 4874c4392e7SDoug Rabson * handler 4884c4392e7SDoug Rabson */ 48914177d72SGarrett WollmanMETHOD int setup_intr { 490bd418641SMark Murray device_t _dev; 491bd418641SMark Murray device_t _child; 492bd418641SMark Murray struct resource *_irq; 493bd418641SMark Murray int _flags; 494ef544f63SPaolo Pisati driver_filter_t *_filter; 495bd418641SMark Murray driver_intr_t *_intr; 496bd418641SMark Murray void *_arg; 497bd418641SMark Murray void **_cookiep; 49814177d72SGarrett Wollman}; 49914177d72SGarrett Wollman 5004c4392e7SDoug Rabson/** 5014c4392e7SDoug Rabson * @brief Uninstall an interrupt handler 5024c4392e7SDoug Rabson * 5034c4392e7SDoug Rabson * This method is used to disassociate an interrupt handler function 5044c4392e7SDoug Rabson * with an irq resource. The value of @p _cookie must be the value 5054c4392e7SDoug Rabson * returned from a previous call to BUS_SETUP_INTR(). 5064c4392e7SDoug Rabson * 5074c4392e7SDoug Rabson * @param _dev the parent device of @p _child 5084c4392e7SDoug Rabson * @param _child the device which allocated the resource 5094c4392e7SDoug Rabson * @param _irq the resource representing the interrupt 5104c4392e7SDoug Rabson * @param _cookie the cookie value returned when the interrupt 5114c4392e7SDoug Rabson * was originally registered 5124c4392e7SDoug Rabson */ 51314177d72SGarrett WollmanMETHOD int teardown_intr { 514bd418641SMark Murray device_t _dev; 515bd418641SMark Murray device_t _child; 516bd418641SMark Murray struct resource *_irq; 517bd418641SMark Murray void *_cookie; 51845c95fa1SDoug Rabson}; 51925afb89bSDoug Rabson 5204c4392e7SDoug Rabson/** 52182a5a275SAndriy Gapon * @brief Suspend an interrupt handler 52282a5a275SAndriy Gapon * 52382a5a275SAndriy Gapon * This method is used to mark a handler as suspended in the case 52482a5a275SAndriy Gapon * that the associated device is powered down and cannot be a source 52582a5a275SAndriy Gapon * for the, typically shared, interrupt. 52682a5a275SAndriy Gapon * The value of @p _irq must be the interrupt resource passed 52782a5a275SAndriy Gapon * to a previous call to BUS_SETUP_INTR(). 52882a5a275SAndriy Gapon * 52982a5a275SAndriy Gapon * @param _dev the parent device of @p _child 53082a5a275SAndriy Gapon * @param _child the device which allocated the resource 53182a5a275SAndriy Gapon * @param _irq the resource representing the interrupt 53282a5a275SAndriy Gapon */ 53382a5a275SAndriy GaponMETHOD int suspend_intr { 53482a5a275SAndriy Gapon device_t _dev; 53582a5a275SAndriy Gapon device_t _child; 53682a5a275SAndriy Gapon struct resource *_irq; 53782a5a275SAndriy Gapon} DEFAULT bus_generic_suspend_intr; 53882a5a275SAndriy Gapon 53982a5a275SAndriy Gapon/** 54082a5a275SAndriy Gapon * @brief Resume an interrupt handler 54182a5a275SAndriy Gapon * 54282a5a275SAndriy Gapon * This method is used to clear suspended state of a handler when 54382a5a275SAndriy Gapon * the associated device is powered up and can be an interrupt source 54482a5a275SAndriy Gapon * again. 54582a5a275SAndriy Gapon * The value of @p _irq must be the interrupt resource passed 54682a5a275SAndriy Gapon * to a previous call to BUS_SETUP_INTR(). 54782a5a275SAndriy Gapon * 54882a5a275SAndriy Gapon * @param _dev the parent device of @p _child 54982a5a275SAndriy Gapon * @param _child the device which allocated the resource 55082a5a275SAndriy Gapon * @param _irq the resource representing the interrupt 55182a5a275SAndriy Gapon */ 55282a5a275SAndriy GaponMETHOD int resume_intr { 55382a5a275SAndriy Gapon device_t _dev; 55482a5a275SAndriy Gapon device_t _child; 55582a5a275SAndriy Gapon struct resource *_irq; 55682a5a275SAndriy Gapon} DEFAULT bus_generic_resume_intr; 55782a5a275SAndriy Gapon 55882a5a275SAndriy Gapon/** 5594c4392e7SDoug Rabson * @brief Define a resource which can be allocated with 5604c4392e7SDoug Rabson * BUS_ALLOC_RESOURCE(). 5614c4392e7SDoug Rabson * 562db4fcadfSConrad Meyer * This method is used by some buses (typically ISA) to allow a 5634c4392e7SDoug Rabson * driver to describe a resource range that it would like to 5644c4392e7SDoug Rabson * allocate. The resource defined by @p _type and @p _rid is defined 5654c4392e7SDoug Rabson * to start at @p _start and to include @p _count indices in its 5664c4392e7SDoug Rabson * range. 5674c4392e7SDoug Rabson * 5684c4392e7SDoug Rabson * @param _dev the parent device of @p _child 5694c4392e7SDoug Rabson * @param _child the device which owns the resource 5704c4392e7SDoug Rabson * @param _type the type of resource 5714c4392e7SDoug Rabson * @param _rid the resource identifier 5724c4392e7SDoug Rabson * @param _start the start of the resource range 5734c4392e7SDoug Rabson * @param _count the size of the resource range 5744c4392e7SDoug Rabson */ 57525afb89bSDoug RabsonMETHOD int set_resource { 576bd418641SMark Murray device_t _dev; 577bd418641SMark Murray device_t _child; 578bd418641SMark Murray int _type; 579bd418641SMark Murray int _rid; 5802dd1bdf1SJustin Hibbits rman_res_t _start; 5812dd1bdf1SJustin Hibbits rman_res_t _count; 58225afb89bSDoug Rabson}; 58325afb89bSDoug Rabson 5844c4392e7SDoug Rabson/** 5854c4392e7SDoug Rabson * @brief Describe a resource 5864c4392e7SDoug Rabson * 5874c4392e7SDoug Rabson * This method allows a driver to examine the range used for a given 5884c4392e7SDoug Rabson * resource without actually allocating it. 5894c4392e7SDoug Rabson * 5904c4392e7SDoug Rabson * @param _dev the parent device of @p _child 5914c4392e7SDoug Rabson * @param _child the device which owns the resource 5924c4392e7SDoug Rabson * @param _type the type of resource 5934c4392e7SDoug Rabson * @param _rid the resource identifier 594e3043798SPedro F. Giffuni * @param _start the address of a location to receive the start 5954c4392e7SDoug Rabson * index of the resource range 596e3043798SPedro F. Giffuni * @param _count the address of a location to receive the size 5974c4392e7SDoug Rabson * of the resource range 5984c4392e7SDoug Rabson */ 59925afb89bSDoug RabsonMETHOD int get_resource { 600bd418641SMark Murray device_t _dev; 601bd418641SMark Murray device_t _child; 602bd418641SMark Murray int _type; 603bd418641SMark Murray int _rid; 6042dd1bdf1SJustin Hibbits rman_res_t *_startp; 6052dd1bdf1SJustin Hibbits rman_res_t *_countp; 60625afb89bSDoug Rabson}; 60725afb89bSDoug Rabson 6084c4392e7SDoug Rabson/** 6094c4392e7SDoug Rabson * @brief Delete a resource. 6104c4392e7SDoug Rabson * 6114c4392e7SDoug Rabson * Use this to delete a resource (possibly one previously added with 6124c4392e7SDoug Rabson * BUS_SET_RESOURCE()). 6134c4392e7SDoug Rabson * 6144c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6154c4392e7SDoug Rabson * @param _child the device which owns the resource 6164c4392e7SDoug Rabson * @param _type the type of resource 6174c4392e7SDoug Rabson * @param _rid the resource identifier 6184c4392e7SDoug Rabson */ 61925afb89bSDoug RabsonMETHOD void delete_resource { 620bd418641SMark Murray device_t _dev; 621bd418641SMark Murray device_t _child; 622bd418641SMark Murray int _type; 623bd418641SMark Murray int _rid; 62425afb89bSDoug Rabson}; 6250cb53e24SMatthew N. Dodd 6264c4392e7SDoug Rabson/** 6274c4392e7SDoug Rabson * @brief Return a struct resource_list. 6284c4392e7SDoug Rabson * 6294c4392e7SDoug Rabson * Used by drivers which use bus_generic_rl_alloc_resource() etc. to 6304c4392e7SDoug Rabson * implement their resource handling. It should return the resource 6314c4392e7SDoug Rabson * list of the given child device. 6324c4392e7SDoug Rabson * 6334c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6344c4392e7SDoug Rabson * @param _child the device which owns the resource list 6354c4392e7SDoug Rabson */ 63646aa504eSMatthew N. DoddMETHOD struct resource_list * get_resource_list { 637bd418641SMark Murray device_t _dev; 638bd418641SMark Murray device_t _child; 6390cb53e24SMatthew N. Dodd} DEFAULT bus_generic_get_resource_list; 6405878eb3fSWarner Losh 6414c4392e7SDoug Rabson/** 6424c4392e7SDoug Rabson * @brief Is the hardware described by @p _child still attached to the 6434c4392e7SDoug Rabson * system? 6444c4392e7SDoug Rabson * 6459f7f340aSWarner Losh * This method should return 0 if the device is not present. It 6469f7f340aSWarner Losh * should return -1 if it is present. Any errors in determining 6479f7f340aSWarner Losh * should be returned as a normal errno value. Client drivers are to 6489f7f340aSWarner Losh * assume that the device is present, even if there is an error 649db4fcadfSConrad Meyer * determining if it is there. Buses are to try to avoid returning 6509f7f340aSWarner Losh * errors, but newcard will return an error if the device fails to 6519f7f340aSWarner Losh * implement this method. 6524c4392e7SDoug Rabson * 6534c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6544c4392e7SDoug Rabson * @param _child the device which is being examined 6554c4392e7SDoug Rabson */ 6565878eb3fSWarner LoshMETHOD int child_present { 6575878eb3fSWarner Losh device_t _dev; 6585878eb3fSWarner Losh device_t _child; 6595878eb3fSWarner Losh} DEFAULT bus_generic_child_present; 6603d9841b4SWarner Losh 6614c4392e7SDoug Rabson/** 6624c4392e7SDoug Rabson * @brief Returns the pnp info for this device. 6634c4392e7SDoug Rabson * 664ddfc9c4cSWarner Losh * Return it as a string, appended to @p _sb 6654c4392e7SDoug Rabson * 666ed7ed7f0SJohn Baldwin * The string must be formatted as a space-separated list of 667ed7ed7f0SJohn Baldwin * name=value pairs. Names may only contain alphanumeric characters, 668ed7ed7f0SJohn Baldwin * underscores ('_') and hyphens ('-'). Values can contain any 669ed7ed7f0SJohn Baldwin * non-whitespace characters. Values containing whitespace can be 670ed7ed7f0SJohn Baldwin * quoted with double quotes ('"'). Double quotes and backslashes in 671ed7ed7f0SJohn Baldwin * quoted values can be escaped with backslashes ('\'). 672ed7ed7f0SJohn Baldwin * 6734c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6744c4392e7SDoug Rabson * @param _child the device which is being examined 675ddfc9c4cSWarner Losh * @param _sb sbuf for results string 6764c4392e7SDoug Rabson */ 677ddfc9c4cSWarner LoshMETHOD int child_pnpinfo { 6783d9841b4SWarner Losh device_t _dev; 6793d9841b4SWarner Losh device_t _child; 680ddfc9c4cSWarner Losh struct sbuf *_sb; 681ddfc9c4cSWarner Losh} DEFAULT bus_generic_child_pnpinfo; 6823d9841b4SWarner Losh 6834c4392e7SDoug Rabson/** 6844c4392e7SDoug Rabson * @brief Returns the location for this device. 6854c4392e7SDoug Rabson * 686ddfc9c4cSWarner Losh * Return it as a string, appended to @p _sb 6874c4392e7SDoug Rabson * 688ed7ed7f0SJohn Baldwin * The string must be formatted as a space-separated list of 689ed7ed7f0SJohn Baldwin * name=value pairs. Names may only contain alphanumeric characters, 690ed7ed7f0SJohn Baldwin * underscores ('_') and hyphens ('-'). Values can contain any 691ed7ed7f0SJohn Baldwin * non-whitespace characters. Values containing whitespace can be 692ed7ed7f0SJohn Baldwin * quoted with double quotes ('"'). Double quotes and backslashes in 693ed7ed7f0SJohn Baldwin * quoted values can be escaped with backslashes ('\'). 694ed7ed7f0SJohn Baldwin * 6954c4392e7SDoug Rabson * @param _dev the parent device of @p _child 6964c4392e7SDoug Rabson * @param _child the device which is being examined 697ddfc9c4cSWarner Losh * @param _sb sbuf for results string 6984c4392e7SDoug Rabson */ 699ddfc9c4cSWarner LoshMETHOD int child_location { 7003d9841b4SWarner Losh device_t _dev; 7013d9841b4SWarner Losh device_t _child; 702ddfc9c4cSWarner Losh struct sbuf *_sb; 703ddfc9c4cSWarner Losh} DEFAULT bus_generic_child_location; 704da13b8f9SMarcel Moolenaar 7054c4392e7SDoug Rabson/** 706dcc81068SJohn Baldwin * @brief Allow drivers to request that an interrupt be bound to a specific 707dcc81068SJohn Baldwin * CPU. 708dcc81068SJohn Baldwin * 709dcc81068SJohn Baldwin * @param _dev the parent device of @p _child 710dcc81068SJohn Baldwin * @param _child the device which allocated the resource 711dcc81068SJohn Baldwin * @param _irq the resource representing the interrupt 712dcc81068SJohn Baldwin * @param _cpu the CPU to bind the interrupt to 713dcc81068SJohn Baldwin */ 714dcc81068SJohn BaldwinMETHOD int bind_intr { 715dcc81068SJohn Baldwin device_t _dev; 716dcc81068SJohn Baldwin device_t _child; 717dcc81068SJohn Baldwin struct resource *_irq; 718dcc81068SJohn Baldwin int _cpu; 719dcc81068SJohn Baldwin} DEFAULT bus_generic_bind_intr; 720dcc81068SJohn Baldwin 721dcc81068SJohn Baldwin/** 7224c4392e7SDoug Rabson * @brief Allow (bus) drivers to specify the trigger mode and polarity 7234c4392e7SDoug Rabson * of the specified interrupt. 7244c4392e7SDoug Rabson * 7254c4392e7SDoug Rabson * @param _dev the bus device 7264c4392e7SDoug Rabson * @param _irq the interrupt number to modify 7274c4392e7SDoug Rabson * @param _trig the trigger mode required 7284c4392e7SDoug Rabson * @param _pol the interrupt polarity required 7294c4392e7SDoug Rabson */ 730da13b8f9SMarcel MoolenaarMETHOD int config_intr { 731da13b8f9SMarcel Moolenaar device_t _dev; 732da13b8f9SMarcel Moolenaar int _irq; 733da13b8f9SMarcel Moolenaar enum intr_trigger _trig; 734da13b8f9SMarcel Moolenaar enum intr_polarity _pol; 735da13b8f9SMarcel Moolenaar} DEFAULT bus_generic_config_intr; 736db2bc1bbSWarner Losh 737db2bc1bbSWarner Losh/** 73837b8ef16SJohn Baldwin * @brief Allow drivers to associate a description with an active 73937b8ef16SJohn Baldwin * interrupt handler. 74037b8ef16SJohn Baldwin * 74137b8ef16SJohn Baldwin * @param _dev the parent device of @p _child 74237b8ef16SJohn Baldwin * @param _child the device which allocated the resource 74337b8ef16SJohn Baldwin * @param _irq the resource representing the interrupt 74437b8ef16SJohn Baldwin * @param _cookie the cookie value returned when the interrupt 74537b8ef16SJohn Baldwin * was originally registered 74637b8ef16SJohn Baldwin * @param _descr the description to associate with the interrupt 74737b8ef16SJohn Baldwin */ 74837b8ef16SJohn BaldwinMETHOD int describe_intr { 74937b8ef16SJohn Baldwin device_t _dev; 75037b8ef16SJohn Baldwin device_t _child; 75137b8ef16SJohn Baldwin struct resource *_irq; 75237b8ef16SJohn Baldwin void *_cookie; 75337b8ef16SJohn Baldwin const char *_descr; 75437b8ef16SJohn Baldwin} DEFAULT bus_generic_describe_intr; 75537b8ef16SJohn Baldwin 75637b8ef16SJohn Baldwin/** 757db2bc1bbSWarner Losh * @brief Notify a (bus) driver about a child that the hints mechanism 758db2bc1bbSWarner Losh * believes it has discovered. 759db2bc1bbSWarner Losh * 760db2bc1bbSWarner Losh * The bus is responsible for then adding the child in the right order 761db2bc1bbSWarner Losh * and discovering other things about the child. The bus driver is 762db2bc1bbSWarner Losh * free to ignore this hint, to do special things, etc. It is all up 763db2bc1bbSWarner Losh * to the bus driver to interpret. 764db2bc1bbSWarner Losh * 765db2bc1bbSWarner Losh * This method is only called in response to the parent bus asking for 766db2bc1bbSWarner Losh * hinted devices to be enumerated. 767db2bc1bbSWarner Losh * 768db2bc1bbSWarner Losh * @param _dev the bus device 769db2bc1bbSWarner Losh * @param _dname the name of the device w/o unit numbers 770db2bc1bbSWarner Losh * @param _dunit the unit number of the device 771db2bc1bbSWarner Losh */ 772db2bc1bbSWarner LoshMETHOD void hinted_child { 773db2bc1bbSWarner Losh device_t _dev; 774db2bc1bbSWarner Losh const char *_dname; 775db2bc1bbSWarner Losh int _dunit; 776db2bc1bbSWarner Losh}; 777378f231eSJohn-Mark Gurney 778378f231eSJohn-Mark Gurney/** 779378f231eSJohn-Mark Gurney * @brief Returns bus_dma_tag_t for use w/ devices on the bus. 780378f231eSJohn-Mark Gurney * 781378f231eSJohn-Mark Gurney * @param _dev the parent device of @p _child 782378f231eSJohn-Mark Gurney * @param _child the device to which the tag will belong 783378f231eSJohn-Mark Gurney */ 784378f231eSJohn-Mark GurneyMETHOD bus_dma_tag_t get_dma_tag { 785378f231eSJohn-Mark Gurney device_t _dev; 786378f231eSJohn-Mark Gurney device_t _child; 787378f231eSJohn-Mark Gurney} DEFAULT bus_generic_get_dma_tag; 7880d484d24SJohn Baldwin 7890d484d24SJohn Baldwin/** 790b998c965SZbigniew Bodek * @brief Returns bus_space_tag_t for use w/ devices on the bus. 791b998c965SZbigniew Bodek * 792b998c965SZbigniew Bodek * @param _dev the parent device of @p _child 793b998c965SZbigniew Bodek * @param _child the device to which the tag will belong 794b998c965SZbigniew Bodek */ 795b998c965SZbigniew BodekMETHOD bus_space_tag_t get_bus_tag { 796b998c965SZbigniew Bodek device_t _dev; 797b998c965SZbigniew Bodek device_t _child; 798b998c965SZbigniew Bodek} DEFAULT bus_generic_get_bus_tag; 799b998c965SZbigniew Bodek 800b998c965SZbigniew Bodek/** 8010d484d24SJohn Baldwin * @brief Allow the bus to determine the unit number of a device. 8020d484d24SJohn Baldwin * 8030d484d24SJohn Baldwin * @param _dev the parent device of @p _child 8040d484d24SJohn Baldwin * @param _child the device whose unit is to be wired 8050d484d24SJohn Baldwin * @param _name the name of the device's new devclass 8060d484d24SJohn Baldwin * @param _unitp a pointer to the device's new unit value 8070d484d24SJohn Baldwin */ 8080d484d24SJohn BaldwinMETHOD void hint_device_unit { 8090d484d24SJohn Baldwin device_t _dev; 8100d484d24SJohn Baldwin device_t _child; 8110d484d24SJohn Baldwin const char *_name; 8120d484d24SJohn Baldwin int *_unitp; 8130d484d24SJohn Baldwin}; 8140d484d24SJohn Baldwin 8154ef60d26SJohn Baldwin/** 8164ef60d26SJohn Baldwin * @brief Notify a bus that the bus pass level has been changed 8174ef60d26SJohn Baldwin * 8184ef60d26SJohn Baldwin * @param _dev the bus device 8194ef60d26SJohn Baldwin */ 8204ef60d26SJohn BaldwinMETHOD void new_pass { 8214ef60d26SJohn Baldwin device_t _dev; 8224ef60d26SJohn Baldwin} DEFAULT bus_generic_new_pass; 82393fc07b4SAlexander Motin 82493fc07b4SAlexander Motin/** 82593fc07b4SAlexander Motin * @brief Notify a bus that specified child's IRQ should be remapped. 82693fc07b4SAlexander Motin * 82793fc07b4SAlexander Motin * @param _dev the bus device 82893fc07b4SAlexander Motin * @param _child the child device 82993fc07b4SAlexander Motin * @param _irq the irq number 83093fc07b4SAlexander Motin */ 83193fc07b4SAlexander MotinMETHOD int remap_intr { 83293fc07b4SAlexander Motin device_t _dev; 83393fc07b4SAlexander Motin device_t _child; 83493fc07b4SAlexander Motin u_int _irq; 83593fc07b4SAlexander Motin} DEFAULT null_remap_intr; 836a1c16348SJustin Hibbits 837a1c16348SJustin Hibbits/** 838a1c16348SJustin Hibbits * @brief Suspend a given child 839a1c16348SJustin Hibbits * 840a1c16348SJustin Hibbits * @param _dev the parent device of @p _child 841a1c16348SJustin Hibbits * @param _child the device to suspend 842a1c16348SJustin Hibbits */ 843a1c16348SJustin HibbitsMETHOD int suspend_child { 844a1c16348SJustin Hibbits device_t _dev; 845a1c16348SJustin Hibbits device_t _child; 846a1c16348SJustin Hibbits} DEFAULT bus_generic_suspend_child; 847a1c16348SJustin Hibbits 848a1c16348SJustin Hibbits/** 849a1c16348SJustin Hibbits * @brief Resume a given child 850a1c16348SJustin Hibbits * 851a1c16348SJustin Hibbits * @param _dev the parent device of @p _child 852a1c16348SJustin Hibbits * @param _child the device to resume 853a1c16348SJustin Hibbits */ 854a1c16348SJustin HibbitsMETHOD int resume_child { 855a1c16348SJustin Hibbits device_t _dev; 856a1c16348SJustin Hibbits device_t _child; 857a1c16348SJustin Hibbits} DEFAULT bus_generic_resume_child; 858ffcf962dSAdrian Chadd 859ffcf962dSAdrian Chadd/** 860ffcf962dSAdrian Chadd * @brief Get the VM domain handle for the given bus and child. 861ffcf962dSAdrian Chadd * 862ffcf962dSAdrian Chadd * @param _dev the bus device 863ffcf962dSAdrian Chadd * @param _child the child device 864ffcf962dSAdrian Chadd * @param _domain a pointer to the bus's domain handle identifier 865ffcf962dSAdrian Chadd */ 866ffcf962dSAdrian ChaddMETHOD int get_domain { 867ffcf962dSAdrian Chadd device_t _dev; 868ffcf962dSAdrian Chadd device_t _child; 869ffcf962dSAdrian Chadd int *_domain; 870ffcf962dSAdrian Chadd} DEFAULT bus_generic_get_domain; 8718d791e5aSJohn Baldwin 8728d791e5aSJohn Baldwin/** 8738d791e5aSJohn Baldwin * @brief Request a set of CPUs 8748d791e5aSJohn Baldwin * 8758d791e5aSJohn Baldwin * @param _dev the bus device 8768d791e5aSJohn Baldwin * @param _child the child device 8778d791e5aSJohn Baldwin * @param _op type of CPUs to request 8788d791e5aSJohn Baldwin * @param _setsize the size of the set passed in _cpuset 8798d791e5aSJohn Baldwin * @param _cpuset a pointer to a cpuset to receive the requested 8808d791e5aSJohn Baldwin * set of CPUs 8818d791e5aSJohn Baldwin */ 8828d791e5aSJohn BaldwinMETHOD int get_cpus { 8838d791e5aSJohn Baldwin device_t _dev; 8848d791e5aSJohn Baldwin device_t _child; 8858d791e5aSJohn Baldwin enum cpu_sets _op; 8868d791e5aSJohn Baldwin size_t _setsize; 887e2e050c8SConrad Meyer struct _cpuset *_cpuset; 8888d791e5aSJohn Baldwin} DEFAULT bus_generic_get_cpus; 889c53df6daSKonstantin Belousov 890c53df6daSKonstantin Belousov/** 891c53df6daSKonstantin Belousov * @brief Prepares the given child of the bus for reset 892c53df6daSKonstantin Belousov * 893c53df6daSKonstantin Belousov * Typically bus detaches or suspends children' drivers, and then 894c53df6daSKonstantin Belousov * calls this method to save bus-specific information, for instance, 895c53df6daSKonstantin Belousov * PCI config space, which is damaged by reset. 896c53df6daSKonstantin Belousov * 897c53df6daSKonstantin Belousov * The bus_helper_reset_prepare() helper is provided to ease 898c53df6daSKonstantin Belousov * implementing bus reset methods. 899c53df6daSKonstantin Belousov * 900c53df6daSKonstantin Belousov * @param _dev the bus device 901c53df6daSKonstantin Belousov * @param _child the child device 902c53df6daSKonstantin Belousov */ 903c53df6daSKonstantin BelousovMETHOD int reset_prepare { 904c53df6daSKonstantin Belousov device_t _dev; 905c53df6daSKonstantin Belousov device_t _child; 906c53df6daSKonstantin Belousov} DEFAULT null_reset_prepare; 907c53df6daSKonstantin Belousov 908c53df6daSKonstantin Belousov/** 909c53df6daSKonstantin Belousov * @brief Restores the child operations after the reset 910c53df6daSKonstantin Belousov * 911c53df6daSKonstantin Belousov * The bus_helper_reset_post() helper is provided to ease 912c53df6daSKonstantin Belousov * implementing bus reset methods. 913c53df6daSKonstantin Belousov * 914c53df6daSKonstantin Belousov * @param _dev the bus device 915c53df6daSKonstantin Belousov * @param _child the child device 916c53df6daSKonstantin Belousov */ 917c53df6daSKonstantin BelousovMETHOD int reset_post { 918c53df6daSKonstantin Belousov device_t _dev; 919c53df6daSKonstantin Belousov device_t _child; 920c53df6daSKonstantin Belousov} DEFAULT null_reset_post; 921c53df6daSKonstantin Belousov 922c53df6daSKonstantin Belousov/** 923c53df6daSKonstantin Belousov * @brief Performs reset of the child 924c53df6daSKonstantin Belousov * 925c53df6daSKonstantin Belousov * @param _dev the bus device 926c53df6daSKonstantin Belousov * @param _child the child device 927c53df6daSKonstantin Belousov * @param _flags DEVF_RESET_ flags 928c53df6daSKonstantin Belousov */ 929c53df6daSKonstantin BelousovMETHOD int reset_child { 930c53df6daSKonstantin Belousov device_t _dev; 931c53df6daSKonstantin Belousov device_t _child; 932c53df6daSKonstantin Belousov int _flags; 933c53df6daSKonstantin Belousov}; 934*3f9a00e3SBartlomiej Grzesik 935*3f9a00e3SBartlomiej Grzesik/** 936*3f9a00e3SBartlomiej Grzesik * @brief Gets child's specific property 937*3f9a00e3SBartlomiej Grzesik * 938*3f9a00e3SBartlomiej Grzesik * The bus_get_property can be used to access device 939*3f9a00e3SBartlomiej Grzesik * specific properties stored on the bus. If _propvalue 940*3f9a00e3SBartlomiej Grzesik * is NULL or _size is 0, then method only returns size 941*3f9a00e3SBartlomiej Grzesik * of the property. 942*3f9a00e3SBartlomiej Grzesik * 943*3f9a00e3SBartlomiej Grzesik * @param _dev the bus device 944*3f9a00e3SBartlomiej Grzesik * @param _child the child device 945*3f9a00e3SBartlomiej Grzesik * @param _propname property name 946*3f9a00e3SBartlomiej Grzesik * @param _propvalue property value destination 947*3f9a00e3SBartlomiej Grzesik * @param _size property value size 948*3f9a00e3SBartlomiej Grzesik * 949*3f9a00e3SBartlomiej Grzesik * @returns size of property if successful otherwise -1 950*3f9a00e3SBartlomiej Grzesik */ 951*3f9a00e3SBartlomiej GrzesikMETHOD ssize_t get_property { 952*3f9a00e3SBartlomiej Grzesik device_t _dev; 953*3f9a00e3SBartlomiej Grzesik device_t _child; 954*3f9a00e3SBartlomiej Grzesik const char *_propname; 955*3f9a00e3SBartlomiej Grzesik void *_propvalue; 956*3f9a00e3SBartlomiej Grzesik size_t _size; 957*3f9a00e3SBartlomiej Grzesik} DEFAULT null_get_property; 958