1#- 2# Copyright (c) 1998-2004 Doug Rabson 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26# 27 28#include <sys/types.h> 29#include <sys/systm.h> 30#include <sys/bus.h> 31 32/** 33 * @defgroup BUS bus - KObj methods for drivers of devices with children 34 * @brief A set of methods required device drivers that support 35 * child devices. 36 * @{ 37 */ 38INTERFACE bus; 39 40# 41# Default implementations of some methods. 42# 43CODE { 44 static struct resource * 45 null_alloc_resource(device_t dev, device_t child, 46 int type, int *rid, rman_res_t start, rman_res_t end, 47 rman_res_t count, u_int flags) 48 { 49 return (0); 50 } 51 52 static int 53 null_remap_intr(device_t bus, device_t dev, u_int irq) 54 { 55 56 if (dev != NULL) 57 return (BUS_REMAP_INTR(dev, NULL, irq)); 58 return (ENXIO); 59 } 60 61 static device_t 62 null_add_child(device_t bus, int order, const char *name, 63 int unit) 64 { 65 66 panic("%s: bus_add_child is not implemented, name '%s', " 67 "unit %d", device_get_nameunit(bus), name, unit); 68 } 69 70 static int 71 null_reset_post(device_t bus, device_t dev) 72 { 73 return (0); 74 } 75 76 static int 77 null_reset_prepare(device_t bus, device_t dev) 78 { 79 return (0); 80 } 81 82 static struct rman * 83 null_get_rman(device_t bus, int type, u_int flags) 84 { 85 return (NULL); 86 } 87 88 static struct resource_list * 89 null_get_resource_list(device_t bus, device_t dev) 90 { 91 return (NULL); 92 } 93}; 94 95/** 96 * @brief Print a description of a child device 97 * 98 * This is called from system code which prints out a description of a 99 * device. It should describe the attachment that the child has with 100 * the parent. For instance the TurboLaser bus prints which node the 101 * device is attached to. See bus_generic_print_child() for more 102 * information. 103 * 104 * @param _dev the device whose child is being printed 105 * @param _child the child device to describe 106 * 107 * @returns the number of characters output. 108 */ 109METHOD int print_child { 110 device_t _dev; 111 device_t _child; 112} DEFAULT bus_generic_print_child; 113 114/** 115 * @brief Print a notification about an unprobed child device. 116 * 117 * Called for each child device that did not succeed in probing for a 118 * driver. 119 * 120 * @param _dev the device whose child was being probed 121 * @param _child the child device which failed to probe 122 */ 123METHOD void probe_nomatch { 124 device_t _dev; 125 device_t _child; 126}; 127 128/** 129 * @brief Read the value of a bus-specific attribute of a device 130 * 131 * This method, along with BUS_WRITE_IVAR() manages a bus-specific set 132 * of instance variables of a child device. The intention is that 133 * each different type of bus defines a set of appropriate instance 134 * variables (such as ports and irqs for ISA bus etc.) 135 * 136 * This information could be given to the child device as a struct but 137 * that makes it hard for a bus to add or remove variables without 138 * forcing an edit and recompile for all drivers which may not be 139 * possible for vendor supplied binary drivers. 140 * 141 * This method copies the value of an instance variable to the 142 * location specified by @p *_result. 143 * 144 * @param _dev the device whose child was being examined 145 * @param _child the child device whose instance variable is 146 * being read 147 * @param _index the instance variable to read 148 * @param _result a location to receive the instance variable 149 * value 150 * 151 * @retval 0 success 152 * @retval ENOENT no such instance variable is supported by @p 153 * _dev 154 */ 155METHOD int read_ivar { 156 device_t _dev; 157 device_t _child; 158 int _index; 159 uintptr_t *_result; 160}; 161 162/** 163 * @brief Write the value of a bus-specific attribute of a device 164 * 165 * This method sets the value of an instance variable to @p _value. 166 * 167 * @param _dev the device whose child was being updated 168 * @param _child the child device whose instance variable is 169 * being written 170 * @param _index the instance variable to write 171 * @param _value the value to write to that instance variable 172 * 173 * @retval 0 success 174 * @retval ENOENT no such instance variable is supported by @p 175 * _dev 176 * @retval EINVAL the instance variable was recognised but 177 * contains a read-only value 178 */ 179METHOD int write_ivar { 180 device_t _dev; 181 device_t _child; 182 int _indx; 183 uintptr_t _value; 184}; 185 186/** 187 * @brief Notify a bus that a child was deleted 188 * 189 * Called at the beginning of device_delete_child() to allow the parent 190 * to teardown any bus-specific state for the child. 191 * 192 * @param _dev the device whose child is being deleted 193 * @param _child the child device which is being deleted 194 */ 195METHOD void child_deleted { 196 device_t _dev; 197 device_t _child; 198}; 199 200/** 201 * @brief Notify a bus that a child was detached 202 * 203 * Called after the child's DEVICE_DETACH() method to allow the parent 204 * to reclaim any resources allocated on behalf of the child. 205 * 206 * @param _dev the device whose child changed state 207 * @param _child the child device which changed state 208 */ 209METHOD void child_detached { 210 device_t _dev; 211 device_t _child; 212}; 213 214/** 215 * @brief Notify a bus that a new driver was added 216 * 217 * Called when a new driver is added to the devclass which owns this 218 * bus. The generic implementation of this method attempts to probe and 219 * attach any un-matched children of the bus. 220 * 221 * @param _dev the device whose devclass had a new driver 222 * added to it 223 * @param _driver the new driver which was added 224 */ 225METHOD void driver_added { 226 device_t _dev; 227 driver_t *_driver; 228} DEFAULT bus_generic_driver_added; 229 230/** 231 * @brief Create a new child device 232 * 233 * For buses which use use drivers supporting DEVICE_IDENTIFY() to 234 * enumerate their devices, this method is used to create new 235 * device instances. The new device will be added after the last 236 * existing child with the same order. Implementations of bus_add_child 237 * call device_add_child_ordered to add the child and often add 238 * a suitable ivar to the device specific to that bus. 239 * 240 * @param _dev the bus device which will be the parent of the 241 * new child device 242 * @param _order a value which is used to partially sort the 243 * children of @p _dev - devices created using 244 * lower values of @p _order appear first in @p 245 * _dev's list of children 246 * @param _name devclass name for new device or @c NULL if not 247 * specified 248 * @param _unit unit number for new device or @c -1 if not 249 * specified 250 */ 251METHOD device_t add_child { 252 device_t _dev; 253 u_int _order; 254 const char *_name; 255 int _unit; 256} DEFAULT null_add_child; 257 258/** 259 * @brief Rescan the bus 260 * 261 * This method is called by a parent bridge or devctl to trigger a bus 262 * rescan. The rescan should delete devices no longer present and 263 * enumerate devices that have newly arrived. 264 * 265 * @param _dev the bus device 266 */ 267METHOD int rescan { 268 device_t _dev; 269} DEFAULT bus_null_rescan; 270 271/** 272 * @brief Allocate a system resource 273 * 274 * This method is called by child devices of a bus to allocate resources. 275 * The types are defined in <machine/resource.h>; the meaning of the 276 * resource-ID field varies from bus to bus (but @p *rid == 0 is always 277 * valid if the resource type is). If a resource was allocated and the 278 * caller did not use the RF_ACTIVE to specify that it should be 279 * activated immediately, the caller is responsible for calling 280 * BUS_ACTIVATE_RESOURCE() when it actually uses the resource. 281 * 282 * @param _dev the parent device of @p _child 283 * @param _child the device which is requesting an allocation 284 * @param _type the type of resource to allocate 285 * @param _rid a pointer to the resource identifier 286 * @param _start hint at the start of the resource range - pass 287 * @c 0 for any start address 288 * @param _end hint at the end of the resource range - pass 289 * @c ~0 for any end address 290 * @param _count hint at the size of range required - pass @c 1 291 * for any size 292 * @param _flags any extra flags to control the resource 293 * allocation - see @c RF_XXX flags in 294 * <sys/rman.h> for details 295 * 296 * @returns the resource which was allocated or @c NULL if no 297 * resource could be allocated 298 */ 299METHOD struct resource * alloc_resource { 300 device_t _dev; 301 device_t _child; 302 int _type; 303 int *_rid; 304 rman_res_t _start; 305 rman_res_t _end; 306 rman_res_t _count; 307 u_int _flags; 308} DEFAULT null_alloc_resource; 309 310/** 311 * @brief Activate a resource 312 * 313 * Activate a resource previously allocated with 314 * BUS_ALLOC_RESOURCE(). This may enable decoding of this resource in a 315 * device for instance. It will also establish a mapping for the resource 316 * unless RF_UNMAPPED was set when allocating the resource. 317 * 318 * @param _dev the parent device of @p _child 319 * @param _child the device which allocated the resource 320 * @param _r the resource to activate 321 */ 322METHOD int activate_resource { 323 device_t _dev; 324 device_t _child; 325 struct resource *_r; 326}; 327 328 329/** 330 * @brief Map a resource 331 * 332 * Allocate a mapping for a range of an active resource. The mapping 333 * is described by a struct resource_map object. This may for instance 334 * map a memory region into the kernel's virtual address space. 335 * 336 * @param _dev the parent device of @p _child 337 * @param _child the device which allocated the resource 338 * @param _r the resource to map 339 * @param _args optional attributes of the mapping 340 * @param _map the mapping 341 */ 342METHOD int map_resource { 343 device_t _dev; 344 device_t _child; 345 struct resource *_r; 346 struct resource_map_request *_args; 347 struct resource_map *_map; 348} DEFAULT bus_generic_map_resource; 349 350 351/** 352 * @brief Unmap a resource 353 * 354 * Release a mapping previously allocated with 355 * BUS_MAP_RESOURCE(). This may for instance unmap a memory region 356 * from the kernel's virtual address space. 357 * 358 * @param _dev the parent device of @p _child 359 * @param _child the device which allocated the resource 360 * @param _r the resource 361 * @param _map the mapping to release 362 */ 363METHOD int unmap_resource { 364 device_t _dev; 365 device_t _child; 366 struct resource *_r; 367 struct resource_map *_map; 368} DEFAULT bus_generic_unmap_resource; 369 370 371/** 372 * @brief Deactivate a resource 373 * 374 * Deactivate a resource previously allocated with 375 * BUS_ALLOC_RESOURCE(). 376 * 377 * @param _dev the parent device of @p _child 378 * @param _child the device which allocated the resource 379 * @param _r the resource to deactivate 380 */ 381METHOD int deactivate_resource { 382 device_t _dev; 383 device_t _child; 384 struct resource *_r; 385}; 386 387/** 388 * @brief Adjust a resource 389 * 390 * Adjust the start and/or end of a resource allocated by 391 * BUS_ALLOC_RESOURCE. At least part of the new address range must overlap 392 * with the existing address range. If the successful, the resource's range 393 * will be adjusted to [start, end] on return. 394 * 395 * @param _dev the parent device of @p _child 396 * @param _child the device which allocated the resource 397 * @param _res the resource to adjust 398 * @param _start the new starting address of the resource range 399 * @param _end the new ending address of the resource range 400 */ 401METHOD int adjust_resource { 402 device_t _dev; 403 device_t _child; 404 struct resource *_res; 405 rman_res_t _start; 406 rman_res_t _end; 407}; 408 409/** 410 * @brief translate a resource value 411 * 412 * Give a bus driver the opportunity to translate resource ranges. If 413 * successful, the host's view of the resource starting at @p _start is 414 * returned in @p _newstart, otherwise an error is returned. 415 * 416 * @param _dev the device associated with the resource 417 * @param _type the type of resource 418 * @param _start the starting address of the resource range 419 * @param _newstart the new starting address of the resource range 420 */ 421METHOD int translate_resource { 422 device_t _dev; 423 int _type; 424 rman_res_t _start; 425 rman_res_t *_newstart; 426} DEFAULT bus_generic_translate_resource; 427 428/** 429 * @brief Release a resource 430 * 431 * Free a resource allocated by the BUS_ALLOC_RESOURCE. The @p _rid 432 * value must be the same as the one returned by BUS_ALLOC_RESOURCE() 433 * (which is not necessarily the same as the one the client passed). 434 * 435 * @param _dev the parent device of @p _child 436 * @param _child the device which allocated the resource 437 * @param _r the resource to release 438 */ 439METHOD int release_resource { 440 device_t _dev; 441 device_t _child; 442 struct resource *_res; 443}; 444 445/** 446 * @brief Install an interrupt handler 447 * 448 * This method is used to associate an interrupt handler function with 449 * an irq resource. When the interrupt triggers, the function @p _intr 450 * will be called with the value of @p _arg as its single 451 * argument. The value returned in @p *_cookiep is used to cancel the 452 * interrupt handler - the caller should save this value to use in a 453 * future call to BUS_TEARDOWN_INTR(). 454 * 455 * @param _dev the parent device of @p _child 456 * @param _child the device which allocated the resource 457 * @param _irq the resource representing the interrupt 458 * @param _flags a set of bits from enum intr_type specifying 459 * the class of interrupt 460 * @param _intr the function to call when the interrupt 461 * triggers 462 * @param _arg a value to use as the single argument in calls 463 * to @p _intr 464 * @param _cookiep a pointer to a location to receive a cookie 465 * value that may be used to remove the interrupt 466 * handler 467 */ 468METHOD int setup_intr { 469 device_t _dev; 470 device_t _child; 471 struct resource *_irq; 472 int _flags; 473 driver_filter_t *_filter; 474 driver_intr_t *_intr; 475 void *_arg; 476 void **_cookiep; 477}; 478 479/** 480 * @brief Uninstall an interrupt handler 481 * 482 * This method is used to disassociate an interrupt handler function 483 * with an irq resource. The value of @p _cookie must be the value 484 * returned from a previous call to BUS_SETUP_INTR(). 485 * 486 * @param _dev the parent device of @p _child 487 * @param _child the device which allocated the resource 488 * @param _irq the resource representing the interrupt 489 * @param _cookie the cookie value returned when the interrupt 490 * was originally registered 491 */ 492METHOD int teardown_intr { 493 device_t _dev; 494 device_t _child; 495 struct resource *_irq; 496 void *_cookie; 497}; 498 499/** 500 * @brief Suspend an interrupt handler 501 * 502 * This method is used to mark a handler as suspended in the case 503 * that the associated device is powered down and cannot be a source 504 * for the, typically shared, interrupt. 505 * The value of @p _irq must be the interrupt resource passed 506 * to a previous call to BUS_SETUP_INTR(). 507 * 508 * @param _dev the parent device of @p _child 509 * @param _child the device which allocated the resource 510 * @param _irq the resource representing the interrupt 511 */ 512METHOD int suspend_intr { 513 device_t _dev; 514 device_t _child; 515 struct resource *_irq; 516} DEFAULT bus_generic_suspend_intr; 517 518/** 519 * @brief Resume an interrupt handler 520 * 521 * This method is used to clear suspended state of a handler when 522 * the associated device is powered up and can be an interrupt source 523 * again. 524 * The value of @p _irq must be the interrupt resource passed 525 * to a previous call to BUS_SETUP_INTR(). 526 * 527 * @param _dev the parent device of @p _child 528 * @param _child the device which allocated the resource 529 * @param _irq the resource representing the interrupt 530 */ 531METHOD int resume_intr { 532 device_t _dev; 533 device_t _child; 534 struct resource *_irq; 535} DEFAULT bus_generic_resume_intr; 536 537/** 538 * @brief Define a resource which can be allocated with 539 * BUS_ALLOC_RESOURCE(). 540 * 541 * This method is used by some buses (typically ISA) to allow a 542 * driver to describe a resource range that it would like to 543 * allocate. The resource defined by @p _type and @p _rid is defined 544 * to start at @p _start and to include @p _count indices in its 545 * range. 546 * 547 * @param _dev the parent device of @p _child 548 * @param _child the device which owns the resource 549 * @param _type the type of resource 550 * @param _rid the resource identifier 551 * @param _start the start of the resource range 552 * @param _count the size of the resource range 553 */ 554METHOD int set_resource { 555 device_t _dev; 556 device_t _child; 557 int _type; 558 int _rid; 559 rman_res_t _start; 560 rman_res_t _count; 561}; 562 563/** 564 * @brief Describe a resource 565 * 566 * This method allows a driver to examine the range used for a given 567 * resource without actually allocating it. 568 * 569 * @param _dev the parent device of @p _child 570 * @param _child the device which owns the resource 571 * @param _type the type of resource 572 * @param _rid the resource identifier 573 * @param _start the address of a location to receive the start 574 * index of the resource range 575 * @param _count the address of a location to receive the size 576 * of the resource range 577 */ 578METHOD int get_resource { 579 device_t _dev; 580 device_t _child; 581 int _type; 582 int _rid; 583 rman_res_t *_startp; 584 rman_res_t *_countp; 585}; 586 587/** 588 * @brief Delete a resource. 589 * 590 * Use this to delete a resource (possibly one previously added with 591 * BUS_SET_RESOURCE()). 592 * 593 * @param _dev the parent device of @p _child 594 * @param _child the device which owns the resource 595 * @param _type the type of resource 596 * @param _rid the resource identifier 597 */ 598METHOD void delete_resource { 599 device_t _dev; 600 device_t _child; 601 int _type; 602 int _rid; 603}; 604 605/** 606 * @brief Return a struct resource_list. 607 * 608 * Used by drivers which use bus_generic_rl_alloc_resource() etc. to 609 * implement their resource handling. It should return the resource 610 * list of the given child device. 611 * 612 * @param _dev the parent device of @p _child 613 * @param _child the device which owns the resource list 614 */ 615METHOD struct resource_list * get_resource_list { 616 device_t _dev; 617 device_t _child; 618} DEFAULT null_get_resource_list; 619 620/** 621 * @brief Return a struct rman. 622 * 623 * Used by drivers which use bus_generic_rman_alloc_resource() etc. to 624 * implement their resource handling. It should return the resource 625 * manager used for the given resource type. 626 * 627 * @param _dev the bus device 628 * @param _type the resource type 629 * @param _flags resource flags (@c RF_XXX flags in 630 * <sys/rman.h>) 631 */ 632METHOD struct rman * get_rman { 633 device_t _dev; 634 int _type; 635 u_int _flags; 636} DEFAULT null_get_rman; 637 638/** 639 * @brief Is the hardware described by @p _child still attached to the 640 * system? 641 * 642 * This method should return 0 if the device is not present. It 643 * should return -1 if it is present. Any errors in determining 644 * should be returned as a normal errno value. Client drivers are to 645 * assume that the device is present, even if there is an error 646 * determining if it is there. Buses are to try to avoid returning 647 * errors, but newcard will return an error if the device fails to 648 * implement this method. 649 * 650 * @param _dev the parent device of @p _child 651 * @param _child the device which is being examined 652 */ 653METHOD int child_present { 654 device_t _dev; 655 device_t _child; 656} DEFAULT bus_generic_child_present; 657 658/** 659 * @brief Returns the pnp info for this device. 660 * 661 * Return it as a string, appended to @p _sb 662 * 663 * The string must be formatted as a space-separated list of 664 * name=value pairs. Names may only contain alphanumeric characters, 665 * underscores ('_') and hyphens ('-'). Values can contain any 666 * non-whitespace characters. Values containing whitespace can be 667 * quoted with double quotes ('"'). Double quotes and backslashes in 668 * quoted values can be escaped with backslashes ('\'). 669 * 670 * @param _dev the parent device of @p _child 671 * @param _child the device which is being examined 672 * @param _sb sbuf for results string 673 */ 674METHOD int child_pnpinfo { 675 device_t _dev; 676 device_t _child; 677 struct sbuf *_sb; 678} DEFAULT bus_generic_child_pnpinfo; 679 680/** 681 * @brief Returns the location for this device. 682 * 683 * Return it as a string, appended to @p _sb 684 * 685 * The string must be formatted as a space-separated list of 686 * name=value pairs. Names may only contain alphanumeric characters, 687 * underscores ('_') and hyphens ('-'). Values can contain any 688 * non-whitespace characters. Values containing whitespace can be 689 * quoted with double quotes ('"'). Double quotes and backslashes in 690 * quoted values can be escaped with backslashes ('\'). 691 * 692 * @param _dev the parent device of @p _child 693 * @param _child the device which is being examined 694 * @param _sb sbuf for results string 695 */ 696METHOD int child_location { 697 device_t _dev; 698 device_t _child; 699 struct sbuf *_sb; 700} DEFAULT bus_generic_child_location; 701 702/** 703 * @brief Allow drivers to request that an interrupt be bound to a specific 704 * CPU. 705 * 706 * @param _dev the parent device of @p _child 707 * @param _child the device which allocated the resource 708 * @param _irq the resource representing the interrupt 709 * @param _cpu the CPU to bind the interrupt to 710 */ 711METHOD int bind_intr { 712 device_t _dev; 713 device_t _child; 714 struct resource *_irq; 715 int _cpu; 716} DEFAULT bus_generic_bind_intr; 717 718/** 719 * @brief Allow (bus) drivers to specify the trigger mode and polarity 720 * of the specified interrupt. 721 * 722 * @param _dev the bus device 723 * @param _irq the interrupt number to modify 724 * @param _trig the trigger mode required 725 * @param _pol the interrupt polarity required 726 */ 727METHOD int config_intr { 728 device_t _dev; 729 int _irq; 730 enum intr_trigger _trig; 731 enum intr_polarity _pol; 732} DEFAULT bus_generic_config_intr; 733 734/** 735 * @brief Allow drivers to associate a description with an active 736 * interrupt handler. 737 * 738 * @param _dev the parent device of @p _child 739 * @param _child the device which allocated the resource 740 * @param _irq the resource representing the interrupt 741 * @param _cookie the cookie value returned when the interrupt 742 * was originally registered 743 * @param _descr the description to associate with the interrupt 744 */ 745METHOD int describe_intr { 746 device_t _dev; 747 device_t _child; 748 struct resource *_irq; 749 void *_cookie; 750 const char *_descr; 751} DEFAULT bus_generic_describe_intr; 752 753/** 754 * @brief Notify a (bus) driver about a child that the hints mechanism 755 * believes it has discovered. 756 * 757 * The bus is responsible for then adding the child in the right order 758 * and discovering other things about the child. The bus driver is 759 * free to ignore this hint, to do special things, etc. It is all up 760 * to the bus driver to interpret. 761 * 762 * This method is only called in response to the parent bus asking for 763 * hinted devices to be enumerated. 764 * 765 * @param _dev the bus device 766 * @param _dname the name of the device w/o unit numbers 767 * @param _dunit the unit number of the device 768 */ 769METHOD void hinted_child { 770 device_t _dev; 771 const char *_dname; 772 int _dunit; 773}; 774 775/** 776 * @brief Returns bus_dma_tag_t for use w/ devices on the bus. 777 * 778 * @param _dev the parent device of @p _child 779 * @param _child the device to which the tag will belong 780 */ 781METHOD bus_dma_tag_t get_dma_tag { 782 device_t _dev; 783 device_t _child; 784} DEFAULT bus_generic_get_dma_tag; 785 786/** 787 * @brief Returns bus_space_tag_t for use w/ devices on the bus. 788 * 789 * @param _dev the parent device of @p _child 790 * @param _child the device to which the tag will belong 791 */ 792METHOD bus_space_tag_t get_bus_tag { 793 device_t _dev; 794 device_t _child; 795} DEFAULT bus_generic_get_bus_tag; 796 797/** 798 * @brief Allow the bus to determine the unit number of a device. 799 * 800 * @param _dev the parent device of @p _child 801 * @param _child the device whose unit is to be wired 802 * @param _name the name of the device's new devclass 803 * @param _unitp a pointer to the device's new unit value 804 */ 805METHOD void hint_device_unit { 806 device_t _dev; 807 device_t _child; 808 const char *_name; 809 int *_unitp; 810}; 811 812/** 813 * @brief Notify a bus that the bus pass level has been changed 814 * 815 * @param _dev the bus device 816 */ 817METHOD void new_pass { 818 device_t _dev; 819} DEFAULT bus_generic_new_pass; 820 821/** 822 * @brief Notify a bus that specified child's IRQ should be remapped. 823 * 824 * @param _dev the bus device 825 * @param _child the child device 826 * @param _irq the irq number 827 */ 828METHOD int remap_intr { 829 device_t _dev; 830 device_t _child; 831 u_int _irq; 832} DEFAULT null_remap_intr; 833 834/** 835 * @brief Suspend a given child 836 * 837 * @param _dev the parent device of @p _child 838 * @param _child the device to suspend 839 */ 840METHOD int suspend_child { 841 device_t _dev; 842 device_t _child; 843} DEFAULT bus_generic_suspend_child; 844 845/** 846 * @brief Resume a given child 847 * 848 * @param _dev the parent device of @p _child 849 * @param _child the device to resume 850 */ 851METHOD int resume_child { 852 device_t _dev; 853 device_t _child; 854} DEFAULT bus_generic_resume_child; 855 856/** 857 * @brief Get the VM domain handle for the given bus and child. 858 * 859 * @param _dev the bus device 860 * @param _child the child device 861 * @param _domain a pointer to the bus's domain handle identifier 862 */ 863METHOD int get_domain { 864 device_t _dev; 865 device_t _child; 866 int *_domain; 867} DEFAULT bus_generic_get_domain; 868 869/** 870 * @brief Request a set of CPUs 871 * 872 * @param _dev the bus device 873 * @param _child the child device 874 * @param _op type of CPUs to request 875 * @param _setsize the size of the set passed in _cpuset 876 * @param _cpuset a pointer to a cpuset to receive the requested 877 * set of CPUs 878 */ 879METHOD int get_cpus { 880 device_t _dev; 881 device_t _child; 882 enum cpu_sets _op; 883 size_t _setsize; 884 struct _cpuset *_cpuset; 885} DEFAULT bus_generic_get_cpus; 886 887/** 888 * @brief Prepares the given child of the bus for reset 889 * 890 * Typically bus detaches or suspends children' drivers, and then 891 * calls this method to save bus-specific information, for instance, 892 * PCI config space, which is damaged by reset. 893 * 894 * The bus_helper_reset_prepare() helper is provided to ease 895 * implementing bus reset methods. 896 * 897 * @param _dev the bus device 898 * @param _child the child device 899 */ 900METHOD int reset_prepare { 901 device_t _dev; 902 device_t _child; 903} DEFAULT null_reset_prepare; 904 905/** 906 * @brief Restores the child operations after the reset 907 * 908 * The bus_helper_reset_post() helper is provided to ease 909 * implementing bus reset methods. 910 * 911 * @param _dev the bus device 912 * @param _child the child device 913 */ 914METHOD int reset_post { 915 device_t _dev; 916 device_t _child; 917} DEFAULT null_reset_post; 918 919/** 920 * @brief Performs reset of the child 921 * 922 * @param _dev the bus device 923 * @param _child the child device 924 * @param _flags DEVF_RESET_ flags 925 */ 926METHOD int reset_child { 927 device_t _dev; 928 device_t _child; 929 int _flags; 930}; 931 932/** 933 * @brief Gets child's specific property 934 * 935 * The bus_get_property can be used to access device 936 * specific properties stored on the bus. If _propvalue 937 * is NULL or _size is 0, then method only returns size 938 * of the property. 939 * 940 * @param _dev the bus device 941 * @param _child the child device 942 * @param _propname property name 943 * @param _propvalue property value destination 944 * @param _size property value size 945 * 946 * @returns size of property if successful otherwise -1 947 */ 948METHOD ssize_t get_property { 949 device_t _dev; 950 device_t _child; 951 const char *_propname; 952 void *_propvalue; 953 size_t _size; 954 device_property_type_t type; 955} DEFAULT bus_generic_get_property; 956 957/** 958 * @brief Gets a child's full path to the device 959 * 960 * The get_device_path method retrieves a device's 961 * full path to the device using one of several 962 * locators present in the system. 963 * 964 * @param _bus the bus device 965 * @param _child the child device 966 * @param _locator locator name 967 * @param _sb buffer loaction string 968 */ 969METHOD int get_device_path { 970 device_t _bus; 971 device_t _child; 972 const char *_locator; 973 struct sbuf *_sb; 974} DEFAULT bus_generic_get_device_path; 975