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