1 /*- 2 * Copyright (c) 2015 Landon Fuller <landon@landonf.org> 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 * without modification. 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 13 * redistribution must be conditioned upon including a substantially 14 * similar Disclaimer requirement for further binary redistribution. 15 * 16 * NO WARRANTY 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 * 29 * $FreeBSD$ 30 */ 31 32 #ifndef _BHND_BHND_H_ 33 #define _BHND_BHND_H_ 34 35 #include <sys/types.h> 36 #include <sys/bus.h> 37 38 #include <machine/bus.h> 39 40 #include "bhnd_ids.h" 41 #include "bhnd_types.h" 42 #include "bhnd_debug.h" 43 #include "bhnd_bus_if.h" 44 45 extern devclass_t bhnd_devclass; 46 extern devclass_t bhnd_hostb_devclass; 47 extern devclass_t bhnd_nvram_devclass; 48 49 /** 50 * bhnd child instance variables 51 */ 52 enum bhnd_device_vars { 53 BHND_IVAR_VENDOR, /**< Designer's JEP-106 manufacturer ID. */ 54 BHND_IVAR_DEVICE, /**< Part number */ 55 BHND_IVAR_HWREV, /**< Core revision */ 56 BHND_IVAR_DEVICE_CLASS, /**< Core class (@sa bhnd_devclass_t) */ 57 BHND_IVAR_VENDOR_NAME, /**< Core vendor name */ 58 BHND_IVAR_DEVICE_NAME, /**< Core name */ 59 BHND_IVAR_CORE_INDEX, /**< Bus-assigned core number */ 60 BHND_IVAR_CORE_UNIT, /**< Bus-assigned core unit number, 61 assigned sequentially (starting at 0) for 62 each vendor/device pair. */ 63 }; 64 65 /** 66 * bhnd device probe priority bands. 67 */ 68 enum { 69 BHND_PROBE_ROOT = 0, /**< Nexus or host bridge */ 70 BHND_PROBE_BUS = 1000, /**< Busses and bridges */ 71 BHND_PROBE_CPU = 2000, /**< CPU devices */ 72 BHND_PROBE_INTERRUPT = 3000, /**< Interrupt controllers. */ 73 BHND_PROBE_TIMER = 4000, /**< Timers and clocks. */ 74 BHND_PROBE_RESOURCE = 5000, /**< Resource discovery (including NVRAM/SPROM) */ 75 BHND_PROBE_DEFAULT = 6000, /**< Default device priority */ 76 }; 77 78 /** 79 * Constants defining fine grained ordering within a BHND_PROBE_* priority band. 80 * 81 * Example: 82 * @code 83 * BHND_PROBE_BUS + BHND_PROBE_ORDER_FIRST 84 * @endcode 85 */ 86 enum { 87 BHND_PROBE_ORDER_FIRST = 0, 88 BHND_PROBE_ORDER_EARLY = 25, 89 BHND_PROBE_ORDER_MIDDLE = 50, 90 BHND_PROBE_ORDER_LATE = 75, 91 BHND_PROBE_ORDER_LAST = 100 92 93 }; 94 95 /* 96 * Simplified accessors for bhnd device ivars 97 */ 98 #define BHND_ACCESSOR(var, ivar, type) \ 99 __BUS_ACCESSOR(bhnd, var, BHND, ivar, type) 100 101 BHND_ACCESSOR(vendor, VENDOR, uint16_t); 102 BHND_ACCESSOR(device, DEVICE, uint16_t); 103 BHND_ACCESSOR(hwrev, HWREV, uint8_t); 104 BHND_ACCESSOR(class, DEVICE_CLASS, bhnd_devclass_t); 105 BHND_ACCESSOR(vendor_name, VENDOR_NAME, const char *); 106 BHND_ACCESSOR(device_name, DEVICE_NAME, const char *); 107 BHND_ACCESSOR(core_index, CORE_INDEX, u_int); 108 BHND_ACCESSOR(core_unit, CORE_UNIT, int); 109 110 #undef BHND_ACCESSOR 111 112 /** 113 * A bhnd(4) board descriptor. 114 */ 115 struct bhnd_board_info { 116 uint16_t board_vendor; /**< PCI-SIG vendor ID (even on non-PCI 117 * devices). 118 * 119 * On PCI devices, this will generally 120 * be the subsystem vendor ID, but the 121 * value may be overridden in device 122 * NVRAM. 123 */ 124 uint16_t board_type; /**< Board type (See BHND_BOARD_*) 125 * 126 * On PCI devices, this will generally 127 * be the subsystem device ID, but the 128 * value may be overridden in device 129 * NVRAM. 130 */ 131 uint16_t board_rev; /**< Board revision. */ 132 uint8_t board_srom_rev; /**< Board SROM format revision */ 133 134 uint32_t board_flags; /**< Board flags (see BHND_BFL_*) */ 135 uint32_t board_flags2; /**< Board flags 2 (see BHND_BFL2_*) */ 136 uint32_t board_flags3; /**< Board flags 3 (see BHND_BFL3_*) */ 137 }; 138 139 140 /** 141 * Chip Identification 142 * 143 * This is read from the ChipCommon ID register; on earlier bhnd(4) devices 144 * where ChipCommon is unavailable, known values must be supplied. 145 */ 146 struct bhnd_chipid { 147 uint16_t chip_id; /**< chip id (BHND_CHIPID_*) */ 148 uint8_t chip_rev; /**< chip revision */ 149 uint8_t chip_pkg; /**< chip package (BHND_PKGID_*) */ 150 uint8_t chip_type; /**< chip type (BHND_CHIPTYPE_*) */ 151 152 bhnd_addr_t enum_addr; /**< chip_type-specific enumeration 153 * address; either the siba(4) base 154 * core register block, or the bcma(4) 155 * EROM core address. */ 156 157 uint8_t ncores; /**< number of cores, if known. 0 if 158 * not available. */ 159 }; 160 161 /** 162 * A bhnd(4) core descriptor. 163 */ 164 struct bhnd_core_info { 165 uint16_t vendor; /**< JEP-106 vendor (BHND_MFGID_*) */ 166 uint16_t device; /**< device */ 167 uint16_t hwrev; /**< hardware revision */ 168 u_int core_idx; /**< bus-assigned core index */ 169 int unit; /**< bus-assigned core unit */ 170 }; 171 172 173 /** 174 * A hardware revision match descriptor. 175 */ 176 struct bhnd_hwrev_match { 177 uint16_t start; /**< first revision, or BHND_HWREV_INVALID 178 to match on any revision. */ 179 uint16_t end; /**< last revision, or BHND_HWREV_INVALID 180 to match on any revision. */ 181 }; 182 183 /** 184 * A bhnd(4) bus resource. 185 * 186 * This provides an abstract interface to per-core resources that may require 187 * bus-level remapping of address windows prior to access. 188 */ 189 struct bhnd_resource { 190 struct resource *res; /**< the system resource. */ 191 bool direct; /**< false if the resource requires 192 * bus window remapping before it 193 * is MMIO accessible. */ 194 }; 195 196 /** 197 * Wildcard hardware revision match descriptor. 198 */ 199 #define BHND_HWREV_ANY { BHND_HWREV_INVALID, BHND_HWREV_INVALID } 200 #define BHND_HWREV_IS_ANY(_m) \ 201 ((_m)->start == BHND_HWREV_INVALID && (_m)->end == BHND_HWREV_INVALID) 202 203 /** 204 * Hardware revision match descriptor for an inclusive range. 205 * 206 * @param _start The first applicable hardware revision. 207 * @param _end The last applicable hardware revision, or BHND_HWREV_INVALID 208 * to match on any revision. 209 */ 210 #define BHND_HWREV_RANGE(_start, _end) { _start, _end } 211 212 /** 213 * Hardware revision match descriptor for a single revision. 214 * 215 * @param _hwrev The hardware revision to match on. 216 */ 217 #define BHND_HWREV_EQ(_hwrev) BHND_HWREV_RANGE(_hwrev, _hwrev) 218 219 /** 220 * Hardware revision match descriptor for any revision equal to or greater 221 * than @p _start. 222 * 223 * @param _start The first hardware revision to match on. 224 */ 225 #define BHND_HWREV_GTE(_start) BHND_HWREV_RANGE(_start, BHND_HWREV_INVALID) 226 227 /** 228 * Hardware revision match descriptor for any revision equal to or less 229 * than @p _end. 230 * 231 * @param _end The last hardware revision to match on. 232 */ 233 #define BHND_HWREV_LTE(_end) BHND_HWREV_RANGE(0, _end) 234 235 236 /** A core match descriptor. */ 237 struct bhnd_core_match { 238 uint16_t vendor; /**< required JEP106 device vendor or BHND_MFGID_INVALID. */ 239 uint16_t device; /**< required core ID or BHND_COREID_INVALID */ 240 struct bhnd_hwrev_match hwrev; /**< matching revisions. */ 241 bhnd_devclass_t class; /**< required class or BHND_DEVCLASS_INVALID */ 242 int unit; /**< required core unit, or -1 */ 243 }; 244 245 /** 246 * Core match descriptor matching against the given @p _vendor, @p _device, 247 * and @p _hwrev match descriptors. 248 */ 249 #define BHND_CORE_MATCH(_vendor, _device, _hwrev) \ 250 { _vendor, _device, _hwrev, BHND_DEVCLASS_INVALID, -1 } 251 252 /** 253 * Wildcard core match descriptor. 254 */ 255 #define BHND_CORE_MATCH_ANY \ 256 { \ 257 .vendor = BHND_MFGID_INVALID, \ 258 .device = BHND_COREID_INVALID, \ 259 .hwrev = BHND_HWREV_ANY, \ 260 .class = BHND_DEVCLASS_INVALID, \ 261 .unit = -1 \ 262 } 263 264 /** 265 * A chipset match descriptor. 266 * 267 * @warning Matching on board/nvram attributes relies on NVRAM access, and will 268 * fail if a valid NVRAM device cannot be found, or is not yet attached. 269 */ 270 struct bhnd_chip_match { 271 /** Select fields to be matched */ 272 uint16_t 273 match_id:1, 274 match_rev:1, 275 match_pkg:1, 276 match_bvendor:1, 277 match_btype:1, 278 match_brev:1, 279 match_srom_rev:1, 280 match_any:1, 281 match_flags_unused:8; 282 283 uint16_t chip_id; /**< required chip id */ 284 struct bhnd_hwrev_match chip_rev; /**< matching chip revisions */ 285 uint8_t chip_pkg; /**< required package */ 286 287 uint16_t board_vendor; /**< required board vendor */ 288 uint16_t board_type; /**< required board type */ 289 struct bhnd_hwrev_match board_rev; /**< matching board revisions */ 290 291 struct bhnd_hwrev_match board_srom_rev; /**< matching board srom revisions */ 292 }; 293 294 #define BHND_CHIP_MATCH_ANY \ 295 { .match_any = 1 } 296 297 #define BHND_CHIP_MATCH_IS_ANY(_m) \ 298 ((_m)->match_any == 1) 299 300 #define BHND_CHIP_MATCH_REQ_BOARD_INFO(_m) \ 301 ((_m)->match_srom_rev || (_m)->match_bvendor || \ 302 (_m)->match_btype || (_m)->match_brev) 303 304 /** Set the required chip ID within a bhnd_chip_match instance */ 305 #define BHND_CHIP_ID(_cid) \ 306 .match_id = 1, .chip_id = BHND_CHIPID_BCM ## _cid 307 308 /** Set the required chip revision range within a bhnd_chip_match instance */ 309 #define BHND_CHIP_REV(_rev) \ 310 .match_rev = 1, .chip_rev = BHND_ ## _rev 311 312 /** Set the required package ID within a bhnd_chip_match instance */ 313 #define BHND_CHIP_PKG(_pkg) \ 314 .match_pkg = 1, .chip_pkg = BHND_PKGID_BCM ## _pkg 315 316 /** Set the required board vendor within a bhnd_chip_match instance */ 317 #define BHND_CHIP_BVENDOR(_vend) \ 318 .match_bvendor = 1, .board_vendor = _vend 319 320 /** Set the required board type within a bhnd_chip_match instance */ 321 #define BHND_CHIP_BTYPE(_btype) \ 322 .match_btype = 1, .board_type = BHND_BOARD_ ## _btype 323 324 /** Set the required SROM revision range within a bhnd_chip_match instance */ 325 #define BHND_CHIP_SROMREV(_rev) \ 326 .match_srom_rev = 1, .board_srom_rev = BHND_ ## _rev 327 328 /** Set the required board revision range within a bhnd_chip_match instance */ 329 #define BHND_CHIP_BREV(_rev) \ 330 .match_brev = 1, .board_rev = BHND_ ## _rev 331 332 /** Set the required board vendor and type within a bhnd_chip_match instance */ 333 #define BHND_CHIP_BVT(_vend, _type) \ 334 BHND_CHIP_BVENDOR(_vend), BHND_CHIP_BTYPE(_type) 335 336 /** Set the required board vendor, type, and revision within a bhnd_chip_match 337 * instance */ 338 #define BHND_CHIP_BVTR(_vend, _type, _rev) \ 339 BHND_CHIP_BVT(_vend, _type), BHND_CHIP_BREV(_rev) 340 341 /** Set the required chip and package ID within a bhnd_chip_match instance */ 342 #define BHND_CHIP_IP(_cid, _pkg) \ 343 BHND_CHIP_ID(_cid), BHND_CHIP_PKG(_pkg) 344 345 /** Set the required chip ID, package ID, and revision within a bhnd_chip_match 346 * instance */ 347 #define BHND_CHIP_IPR(_cid, _pkg, _rev) \ 348 BHND_CHIP_ID(_cid), BHND_CHIP_PKG(_pkg), BHND_CHIP_REV(_rev) 349 350 /** Set the required chip ID and revision within a bhnd_chip_match 351 * instance */ 352 #define BHND_CHIP_IR(_cid, _rev) \ 353 BHND_CHIP_ID(_cid), BHND_CHIP_REV(_rev) 354 355 /** 356 * Chipset quirk table descriptor. 357 */ 358 struct bhnd_chip_quirk { 359 const struct bhnd_chip_match chip; /**< chip match descriptor */ 360 uint32_t quirks; /**< quirk flags */ 361 }; 362 363 #define BHND_CHIP_QUIRK_END { BHND_CHIP_MATCH_ANY, 0 } 364 365 #define BHND_CHIP_QUIRK_IS_END(_q) \ 366 (BHND_CHIP_MATCH_IS_ANY(&(_q)->chip) && (_q)->quirks == 0) 367 368 /** 369 * Device quirk table descriptor. 370 */ 371 struct bhnd_device_quirk { 372 struct bhnd_hwrev_match hwrev; /**< applicable hardware revisions */ 373 uint32_t quirks; /**< quirk flags */ 374 }; 375 #define BHND_DEVICE_QUIRK_END { BHND_HWREV_ANY, 0 } 376 #define BHND_DEVICE_QUIRK_IS_END(_q) \ 377 (BHND_HWREV_IS_ANY(&(_q)->hwrev) && (_q)->quirks == 0) 378 379 enum { 380 BHND_DF_ANY = 0, 381 BHND_DF_HOSTB = (1<<0) /**< core is serving as the bus' 382 * host bridge */ 383 }; 384 385 /** Device probe table descriptor */ 386 struct bhnd_device { 387 const struct bhnd_core_match core; /**< core match descriptor */ 388 const char *desc; /**< device description, or NULL. */ 389 const struct bhnd_device_quirk *quirks_table; /**< quirks table for this device, or NULL */ 390 const struct bhnd_chip_quirk *chip_quirks_table; /**< chipset-specific quirks for this device, or NULL */ 391 uint32_t device_flags; /**< required BHND_DF_* flags */ 392 }; 393 394 #define _BHND_DEVICE(_vendor, _device, _desc, _quirks, _chip_quirks, \ 395 _flags, ...) \ 396 { BHND_CORE_MATCH(BHND_MFGID_ ## _vendor, \ 397 BHND_COREID_ ## _device, BHND_HWREV_ANY), _desc, _quirks, \ 398 _chip_quirks, _flags } 399 400 #define BHND_MIPS_DEVICE(_device, _desc, _quirks, _chip_quirks, ...) \ 401 _BHND_DEVICE(MIPS, _device, _desc, _quirks, _chip_quirks, \ 402 ## __VA_ARGS__, 0) 403 404 #define BHND_ARM_DEVICE(_device, _desc, _quirks, _chip_quirks, ...) \ 405 _BHND_DEVICE(ARM, _device, _desc, _quirks, _chip_quirks, \ 406 ## __VA_ARGS__, 0) 407 408 #define BHND_DEVICE(_device, _desc, _quirks, _chip_quirks, ...) \ 409 _BHND_DEVICE(BCM, _device, _desc, _quirks, _chip_quirks, \ 410 ## __VA_ARGS__, 0) 411 412 #define BHND_DEVICE_END { BHND_CORE_MATCH_ANY, NULL, NULL, NULL, 0 } 413 414 const char *bhnd_vendor_name(uint16_t vendor); 415 const char *bhnd_port_type_name(bhnd_port_type port_type); 416 417 const char *bhnd_find_core_name(uint16_t vendor, 418 uint16_t device); 419 bhnd_devclass_t bhnd_find_core_class(uint16_t vendor, 420 uint16_t device); 421 422 const char *bhnd_core_name(const struct bhnd_core_info *ci); 423 bhnd_devclass_t bhnd_core_class(const struct bhnd_core_info *ci); 424 425 426 device_t bhnd_match_child(device_t dev, 427 const struct bhnd_core_match *desc); 428 429 device_t bhnd_find_child(device_t dev, 430 bhnd_devclass_t class, int unit); 431 432 device_t bhnd_find_bridge_root(device_t dev, 433 devclass_t bus_class); 434 435 const struct bhnd_core_info *bhnd_match_core( 436 const struct bhnd_core_info *cores, 437 u_int num_cores, 438 const struct bhnd_core_match *desc); 439 440 const struct bhnd_core_info *bhnd_find_core( 441 const struct bhnd_core_info *cores, 442 u_int num_cores, bhnd_devclass_t class); 443 444 bool bhnd_core_matches( 445 const struct bhnd_core_info *core, 446 const struct bhnd_core_match *desc); 447 448 bool bhnd_chip_matches( 449 const struct bhnd_chipid *chipid, 450 const struct bhnd_board_info *binfo, 451 const struct bhnd_chip_match *desc); 452 453 bool bhnd_hwrev_matches(uint16_t hwrev, 454 const struct bhnd_hwrev_match *desc); 455 456 uint32_t bhnd_chip_quirks(device_t dev, 457 const struct bhnd_chip_quirk *table); 458 459 bool bhnd_device_matches(device_t dev, 460 const struct bhnd_core_match *desc); 461 462 const struct bhnd_device *bhnd_device_lookup(device_t dev, 463 const struct bhnd_device *table, 464 size_t entry_size); 465 466 uint32_t bhnd_device_quirks(device_t dev, 467 const struct bhnd_device *table, 468 size_t entry_size); 469 470 struct bhnd_core_info bhnd_get_core_info(device_t dev); 471 472 473 int bhnd_alloc_resources(device_t dev, 474 struct resource_spec *rs, 475 struct bhnd_resource **res); 476 477 void bhnd_release_resources(device_t dev, 478 const struct resource_spec *rs, 479 struct bhnd_resource **res); 480 481 struct bhnd_chipid bhnd_parse_chipid(uint32_t idreg, 482 bhnd_addr_t enum_addr); 483 484 int bhnd_read_chipid(device_t dev, 485 struct resource_spec *rs, 486 bus_size_t chipc_offset, 487 struct bhnd_chipid *result); 488 489 void bhnd_set_custom_core_desc(device_t dev, 490 const char *name); 491 void bhnd_set_default_core_desc(device_t dev); 492 493 494 bool bhnd_bus_generic_is_hw_disabled(device_t dev, 495 device_t child); 496 bool bhnd_bus_generic_is_region_valid(device_t dev, 497 device_t child, bhnd_port_type type, 498 u_int port, u_int region); 499 int bhnd_bus_generic_read_nvram_var(device_t dev, 500 device_t child, const char *name, 501 void *buf, size_t *size); 502 const struct bhnd_chipid *bhnd_bus_generic_get_chipid(device_t dev, 503 device_t child); 504 int bhnd_bus_generic_read_board_info(device_t dev, 505 device_t child, 506 struct bhnd_board_info *info); 507 int bhnd_bus_generic_get_nvram_var(device_t dev, 508 device_t child, const char *name, 509 void *buf, size_t *size); 510 struct bhnd_resource *bhnd_bus_generic_alloc_resource (device_t dev, 511 device_t child, int type, int *rid, 512 rman_res_t start, rman_res_t end, 513 rman_res_t count, u_int flags); 514 int bhnd_bus_generic_release_resource (device_t dev, 515 device_t child, int type, int rid, 516 struct bhnd_resource *r); 517 int bhnd_bus_generic_activate_resource (device_t dev, 518 device_t child, int type, int rid, 519 struct bhnd_resource *r); 520 int bhnd_bus_generic_deactivate_resource (device_t dev, 521 device_t child, int type, int rid, 522 struct bhnd_resource *r); 523 524 525 526 /** 527 * Return the active host bridge core for the bhnd bus, if any, or NULL if 528 * not found. 529 * 530 * @param dev A bhnd bus device. 531 */ 532 static inline device_t 533 bhnd_find_hostb_device(device_t dev) { 534 return (BHND_BUS_FIND_HOSTB_DEVICE(dev)); 535 } 536 537 /** 538 * Return true if the hardware components required by @p dev are known to be 539 * unpopulated or otherwise unusable. 540 * 541 * In some cases, enumerated devices may have pins that are left floating, or 542 * the hardware may otherwise be non-functional; this method allows a parent 543 * device to explicitly specify if a successfully enumerated @p dev should 544 * be disabled. 545 * 546 * @param dev A bhnd bus child device. 547 */ 548 static inline bool 549 bhnd_is_hw_disabled(device_t dev) { 550 return (BHND_BUS_IS_HW_DISABLED(device_get_parent(dev), dev)); 551 } 552 553 /** 554 * Return the BHND chip identification info for the bhnd bus. 555 * 556 * @param dev A bhnd bus child device. 557 */ 558 static inline const struct bhnd_chipid * 559 bhnd_get_chipid(device_t dev) { 560 return (BHND_BUS_GET_CHIPID(device_get_parent(dev), dev)); 561 }; 562 563 /** 564 * Return the BHND attachment type of the parent bhnd bus. 565 * 566 * @param dev A bhnd bus child device. 567 * 568 * @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter, 569 * such as a WiFi chipset. 570 * @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock, 571 * CPU, etc) to a directly attached native host. 572 */ 573 static inline bhnd_attach_type 574 bhnd_get_attach_type (device_t dev) { 575 return (BHND_BUS_GET_ATTACH_TYPE(device_get_parent(dev), dev)); 576 } 577 578 /** 579 * Attempt to read the BHND board identification from the bhnd bus. 580 * 581 * This relies on NVRAM access, and will fail if a valid NVRAM device cannot 582 * be found, or is not yet attached. 583 * 584 * @param dev The parent of @p child. 585 * @param child The bhnd device requesting board info. 586 * @param[out] info On success, will be populated with the bhnd(4) device's 587 * board information. 588 * 589 * @retval 0 success 590 * @retval ENODEV No valid NVRAM source could be found. 591 * @retval non-zero If reading @p name otherwise fails, a regular unix 592 * error code will be returned. 593 */ 594 static inline int 595 bhnd_read_board_info(device_t dev, struct bhnd_board_info *info) 596 { 597 return (BHND_BUS_READ_BOARD_INFO(device_get_parent(dev), dev, info)); 598 } 599 600 /** 601 * Determine an NVRAM variable's expected size. 602 * 603 * @param dev A bhnd bus child device. 604 * @param name The variable name. 605 * @param[out] len On success, the variable's size, in bytes. 606 * 607 * @retval 0 success 608 * @retval ENOENT The requested variable was not found. 609 * @retval ENODEV No valid NVRAM source could be found. 610 * @retval non-zero If reading @p name otherwise fails, a regular unix 611 * error code will be returned. 612 */ 613 static inline int 614 bhnd_nvram_getvarlen(device_t dev, const char *name, size_t *len) 615 { 616 return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), dev, name, NULL, 617 len)); 618 } 619 620 /** 621 * Read an NVRAM variable. 622 * 623 * @param dev A bhnd bus child device. 624 * @param name The NVRAM variable name. 625 * @param buf A buffer large enough to hold @p len bytes. On success, 626 * the requested value will be written to this buffer. 627 * @param len The required variable length. 628 * 629 * @retval 0 success 630 * @retval ENOENT The requested variable was not found. 631 * @retval EINVAL If @p len does not match the actual variable size. 632 * @retval ENODEV No valid NVRAM source could be found. 633 * @retval non-zero If reading @p name otherwise fails, a regular unix 634 * error code will be returned. 635 */ 636 static inline int 637 bhnd_nvram_getvar(device_t dev, const char *name, void *buf, size_t len) 638 { 639 size_t var_len; 640 int error; 641 642 if ((error = bhnd_nvram_getvarlen(dev, name, &var_len))) 643 return (error); 644 645 if (len != var_len) 646 return (EINVAL); 647 648 return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), dev, name, buf, 649 &len)); 650 } 651 652 /** 653 * Allocate a resource from a device's parent bhnd(4) bus. 654 * 655 * @param dev The device requesting resource ownership. 656 * @param type The type of resource to allocate. This may be any type supported 657 * by the standard bus APIs. 658 * @param rid The bus-specific handle identifying the resource being allocated. 659 * @param start The start address of the resource. 660 * @param end The end address of the resource. 661 * @param count The size of the resource. 662 * @param flags The flags for the resource to be allocated. These may be any 663 * values supported by the standard bus APIs. 664 * 665 * To request the resource's default addresses, pass @p start and 666 * @p end values of @c 0 and @c ~0, respectively, and 667 * a @p count of @c 1. 668 * 669 * @retval NULL The resource could not be allocated. 670 * @retval resource The allocated resource. 671 */ 672 static inline struct bhnd_resource * 673 bhnd_alloc_resource(device_t dev, int type, int *rid, rman_res_t start, 674 rman_res_t end, rman_res_t count, u_int flags) 675 { 676 return BHND_BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, type, rid, 677 start, end, count, flags); 678 } 679 680 681 /** 682 * Allocate a resource from a device's parent bhnd(4) bus, using the 683 * resource's default start, end, and count values. 684 * 685 * @param dev The device requesting resource ownership. 686 * @param type The type of resource to allocate. This may be any type supported 687 * by the standard bus APIs. 688 * @param rid The bus-specific handle identifying the resource being allocated. 689 * @param flags The flags for the resource to be allocated. These may be any 690 * values supported by the standard bus APIs. 691 * 692 * @retval NULL The resource could not be allocated. 693 * @retval resource The allocated resource. 694 */ 695 static inline struct bhnd_resource * 696 bhnd_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) 697 { 698 return bhnd_alloc_resource(dev, type, rid, 0, ~0, 1, flags); 699 } 700 701 /** 702 * Activate a previously allocated bhnd resource. 703 * 704 * @param dev The device holding ownership of the allocated resource. 705 * @param type The type of the resource. 706 * @param rid The bus-specific handle identifying the resource. 707 * @param r A pointer to the resource returned by bhnd_alloc_resource or 708 * BHND_BUS_ALLOC_RESOURCE. 709 * 710 * @retval 0 success 711 * @retval non-zero an error occurred while activating the resource. 712 */ 713 static inline int 714 bhnd_activate_resource(device_t dev, int type, int rid, 715 struct bhnd_resource *r) 716 { 717 return BHND_BUS_ACTIVATE_RESOURCE(device_get_parent(dev), dev, type, 718 rid, r); 719 } 720 721 /** 722 * Deactivate a previously activated bhnd resource. 723 * 724 * @param dev The device holding ownership of the activated resource. 725 * @param type The type of the resource. 726 * @param rid The bus-specific handle identifying the resource. 727 * @param r A pointer to the resource returned by bhnd_alloc_resource or 728 * BHND_BUS_ALLOC_RESOURCE. 729 * 730 * @retval 0 success 731 * @retval non-zero an error occurred while activating the resource. 732 */ 733 static inline int 734 bhnd_deactivate_resource(device_t dev, int type, int rid, 735 struct bhnd_resource *r) 736 { 737 return BHND_BUS_DEACTIVATE_RESOURCE(device_get_parent(dev), dev, type, 738 rid, r); 739 } 740 741 /** 742 * Free a resource allocated by bhnd_alloc_resource(). 743 * 744 * @param dev The device holding ownership of the resource. 745 * @param type The type of the resource. 746 * @param rid The bus-specific handle identifying the resource. 747 * @param r A pointer to the resource returned by bhnd_alloc_resource or 748 * BHND_ALLOC_RESOURCE. 749 * 750 * @retval 0 success 751 * @retval non-zero an error occurred while activating the resource. 752 */ 753 static inline int 754 bhnd_release_resource(device_t dev, int type, int rid, 755 struct bhnd_resource *r) 756 { 757 return BHND_BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, type, 758 rid, r); 759 } 760 761 /** 762 * Return true if @p region_num is a valid region on @p port_num of 763 * @p type attached to @p dev. 764 * 765 * @param dev A bhnd bus child device. 766 * @param type The port type being queried. 767 * @param port_num The port number being queried. 768 * @param region_num The region number being queried. 769 */ 770 static inline bool 771 bhnd_is_region_valid(device_t dev, bhnd_port_type type, u_int port_num, 772 u_int region_num) 773 { 774 return (BHND_BUS_IS_REGION_VALID(device_get_parent(dev), dev, type, 775 port_num, region_num)); 776 } 777 778 /** 779 * Return the number of ports of type @p type attached to @p def. 780 * 781 * @param dev A bhnd bus child device. 782 * @param type The port type being queried. 783 */ 784 static inline u_int 785 bhnd_get_port_count(device_t dev, bhnd_port_type type) { 786 return (BHND_BUS_GET_PORT_COUNT(device_get_parent(dev), dev, type)); 787 } 788 789 /** 790 * Return the number of memory regions mapped to @p child @p port of 791 * type @p type. 792 * 793 * @param dev A bhnd bus child device. 794 * @param port The port number being queried. 795 * @param type The port type being queried. 796 */ 797 static inline u_int 798 bhnd_get_region_count(device_t dev, bhnd_port_type type, u_int port) { 799 return (BHND_BUS_GET_REGION_COUNT(device_get_parent(dev), dev, type, 800 port)); 801 } 802 803 /** 804 * Return the resource-ID for a memory region on the given device port. 805 * 806 * @param dev A bhnd bus child device. 807 * @param type The port type. 808 * @param port The port identifier. 809 * @param region The identifier of the memory region on @p port. 810 * 811 * @retval int The RID for the given @p port and @p region on @p device. 812 * @retval -1 No such port/region found. 813 */ 814 static inline int 815 bhnd_get_port_rid(device_t dev, bhnd_port_type type, u_int port, u_int region) 816 { 817 return BHND_BUS_GET_PORT_RID(device_get_parent(dev), dev, type, port, 818 region); 819 } 820 821 /** 822 * Decode a port / region pair on @p dev defined by @p rid. 823 * 824 * @param dev A bhnd bus child device. 825 * @param type The resource type. 826 * @param rid The resource identifier. 827 * @param[out] port_type The decoded port type. 828 * @param[out] port The decoded port identifier. 829 * @param[out] region The decoded region identifier. 830 * 831 * @retval 0 success 832 * @retval non-zero No matching port/region found. 833 */ 834 static inline int 835 bhnd_decode_port_rid(device_t dev, int type, int rid, bhnd_port_type *port_type, 836 u_int *port, u_int *region) 837 { 838 return BHND_BUS_DECODE_PORT_RID(device_get_parent(dev), dev, type, rid, 839 port_type, port, region); 840 } 841 842 /** 843 * Get the address and size of @p region on @p port. 844 * 845 * @param dev A bhnd bus child device. 846 * @param port_type The port type. 847 * @param port The port identifier. 848 * @param region The identifier of the memory region on @p port. 849 * @param[out] region_addr The region's base address. 850 * @param[out] region_size The region's size. 851 * 852 * @retval 0 success 853 * @retval non-zero No matching port/region found. 854 */ 855 static inline int 856 bhnd_get_region_addr(device_t dev, bhnd_port_type port_type, u_int port, 857 u_int region, bhnd_addr_t *region_addr, bhnd_size_t *region_size) 858 { 859 return BHND_BUS_GET_REGION_ADDR(device_get_parent(dev), dev, port_type, 860 port, region, region_addr, region_size); 861 } 862 863 /* 864 * bhnd bus-level equivalents of the bus_(read|write|set|barrier|...) 865 * macros (compatible with bhnd_resource). 866 * 867 * Generated with bhnd/tools/bus_macro.sh 868 */ 869 #define bhnd_bus_barrier(r, o, l, f) \ 870 ((r)->direct) ? \ 871 bus_barrier((r)->res, (o), (l), (f)) : \ 872 BHND_BUS_BARRIER( \ 873 device_get_parent(rman_get_device((r)->res)), \ 874 rman_get_device((r)->res), (r), (o), (l), (f)) 875 #define bhnd_bus_read_1(r, o) \ 876 ((r)->direct) ? \ 877 bus_read_1((r)->res, (o)) : \ 878 BHND_BUS_READ_1( \ 879 device_get_parent(rman_get_device((r)->res)), \ 880 rman_get_device((r)->res), (r), (o)) 881 #define bhnd_bus_read_multi_1(r, o, d, c) \ 882 ((r)->direct) ? \ 883 bus_read_multi_1((r)->res, (o), (d), (c)) : \ 884 BHND_BUS_READ_MULTI_1( \ 885 device_get_parent(rman_get_device((r)->res)), \ 886 rman_get_device((r)->res), (r), (o), (d), (c)) 887 #define bhnd_bus_read_region_1(r, o, d, c) \ 888 ((r)->direct) ? \ 889 bus_read_region_1((r)->res, (o), (d), (c)) : \ 890 BHND_BUS_READ_REGION_1( \ 891 device_get_parent(rman_get_device((r)->res)), \ 892 rman_get_device((r)->res), (r), (o), (d), (c)) 893 #define bhnd_bus_write_1(r, o, v) \ 894 ((r)->direct) ? \ 895 bus_write_1((r)->res, (o), (v)) : \ 896 BHND_BUS_WRITE_1( \ 897 device_get_parent(rman_get_device((r)->res)), \ 898 rman_get_device((r)->res), (r), (o), (v)) 899 #define bhnd_bus_write_multi_1(r, o, d, c) \ 900 ((r)->direct) ? \ 901 bus_write_multi_1((r)->res, (o), (d), (c)) : \ 902 BHND_BUS_WRITE_MULTI_1( \ 903 device_get_parent(rman_get_device((r)->res)), \ 904 rman_get_device((r)->res), (r), (o), (d), (c)) 905 #define bhnd_bus_write_region_1(r, o, d, c) \ 906 ((r)->direct) ? \ 907 bus_write_region_1((r)->res, (o), (d), (c)) : \ 908 BHND_BUS_WRITE_REGION_1( \ 909 device_get_parent(rman_get_device((r)->res)), \ 910 rman_get_device((r)->res), (r), (o), (d), (c)) 911 #define bhnd_bus_read_stream_1(r, o) \ 912 ((r)->direct) ? \ 913 bus_read_stream_1((r)->res, (o)) : \ 914 BHND_BUS_READ_STREAM_1( \ 915 device_get_parent(rman_get_device((r)->res)), \ 916 rman_get_device((r)->res), (r), (o)) 917 #define bhnd_bus_read_multi_stream_1(r, o, d, c) \ 918 ((r)->direct) ? \ 919 bus_read_multi_stream_1((r)->res, (o), (d), (c)) : \ 920 BHND_BUS_READ_MULTI_STREAM_1( \ 921 device_get_parent(rman_get_device((r)->res)), \ 922 rman_get_device((r)->res), (r), (o), (d), (c)) 923 #define bhnd_bus_read_region_stream_1(r, o, d, c) \ 924 ((r)->direct) ? \ 925 bus_read_region_stream_1((r)->res, (o), (d), (c)) : \ 926 BHND_BUS_READ_REGION_STREAM_1( \ 927 device_get_parent(rman_get_device((r)->res)), \ 928 rman_get_device((r)->res), (r), (o), (d), (c)) 929 #define bhnd_bus_write_stream_1(r, o, v) \ 930 ((r)->direct) ? \ 931 bus_write_stream_1((r)->res, (o), (v)) : \ 932 BHND_BUS_WRITE_STREAM_1( \ 933 device_get_parent(rman_get_device((r)->res)), \ 934 rman_get_device((r)->res), (r), (o), (v)) 935 #define bhnd_bus_write_multi_stream_1(r, o, d, c) \ 936 ((r)->direct) ? \ 937 bus_write_multi_stream_1((r)->res, (o), (d), (c)) : \ 938 BHND_BUS_WRITE_MULTI_STREAM_1( \ 939 device_get_parent(rman_get_device((r)->res)), \ 940 rman_get_device((r)->res), (r), (o), (d), (c)) 941 #define bhnd_bus_write_region_stream_1(r, o, d, c) \ 942 ((r)->direct) ? \ 943 bus_write_region_stream_1((r)->res, (o), (d), (c)) : \ 944 BHND_BUS_WRITE_REGION_STREAM_1( \ 945 device_get_parent(rman_get_device((r)->res)), \ 946 rman_get_device((r)->res), (r), (o), (d), (c)) 947 #define bhnd_bus_set_multi_1(r, o, v, c) \ 948 ((r)->direct) ? \ 949 bus_set_multi_1((r)->res, (o), (v), (c)) : \ 950 BHND_BUS_SET_MULTI_1( \ 951 device_get_parent(rman_get_device((r)->res)), \ 952 rman_get_device((r)->res), (r), (o), (v), (c)) 953 #define bhnd_bus_set_region_1(r, o, v, c) \ 954 ((r)->direct) ? \ 955 bus_set_region_1((r)->res, (o), (v), (c)) : \ 956 BHND_BUS_SET_REGION_1( \ 957 device_get_parent(rman_get_device((r)->res)), \ 958 rman_get_device((r)->res), (r), (o), (v), (c)) 959 #define bhnd_bus_read_2(r, o) \ 960 ((r)->direct) ? \ 961 bus_read_2((r)->res, (o)) : \ 962 BHND_BUS_READ_2( \ 963 device_get_parent(rman_get_device((r)->res)), \ 964 rman_get_device((r)->res), (r), (o)) 965 #define bhnd_bus_read_multi_2(r, o, d, c) \ 966 ((r)->direct) ? \ 967 bus_read_multi_2((r)->res, (o), (d), (c)) : \ 968 BHND_BUS_READ_MULTI_2( \ 969 device_get_parent(rman_get_device((r)->res)), \ 970 rman_get_device((r)->res), (r), (o), (d), (c)) 971 #define bhnd_bus_read_region_2(r, o, d, c) \ 972 ((r)->direct) ? \ 973 bus_read_region_2((r)->res, (o), (d), (c)) : \ 974 BHND_BUS_READ_REGION_2( \ 975 device_get_parent(rman_get_device((r)->res)), \ 976 rman_get_device((r)->res), (r), (o), (d), (c)) 977 #define bhnd_bus_write_2(r, o, v) \ 978 ((r)->direct) ? \ 979 bus_write_2((r)->res, (o), (v)) : \ 980 BHND_BUS_WRITE_2( \ 981 device_get_parent(rman_get_device((r)->res)), \ 982 rman_get_device((r)->res), (r), (o), (v)) 983 #define bhnd_bus_write_multi_2(r, o, d, c) \ 984 ((r)->direct) ? \ 985 bus_write_multi_2((r)->res, (o), (d), (c)) : \ 986 BHND_BUS_WRITE_MULTI_2( \ 987 device_get_parent(rman_get_device((r)->res)), \ 988 rman_get_device((r)->res), (r), (o), (d), (c)) 989 #define bhnd_bus_write_region_2(r, o, d, c) \ 990 ((r)->direct) ? \ 991 bus_write_region_2((r)->res, (o), (d), (c)) : \ 992 BHND_BUS_WRITE_REGION_2( \ 993 device_get_parent(rman_get_device((r)->res)), \ 994 rman_get_device((r)->res), (r), (o), (d), (c)) 995 #define bhnd_bus_read_stream_2(r, o) \ 996 ((r)->direct) ? \ 997 bus_read_stream_2((r)->res, (o)) : \ 998 BHND_BUS_READ_STREAM_2( \ 999 device_get_parent(rman_get_device((r)->res)), \ 1000 rman_get_device((r)->res), (r), (o)) 1001 #define bhnd_bus_read_multi_stream_2(r, o, d, c) \ 1002 ((r)->direct) ? \ 1003 bus_read_multi_stream_2((r)->res, (o), (d), (c)) : \ 1004 BHND_BUS_READ_MULTI_STREAM_2( \ 1005 device_get_parent(rman_get_device((r)->res)), \ 1006 rman_get_device((r)->res), (r), (o), (d), (c)) 1007 #define bhnd_bus_read_region_stream_2(r, o, d, c) \ 1008 ((r)->direct) ? \ 1009 bus_read_region_stream_2((r)->res, (o), (d), (c)) : \ 1010 BHND_BUS_READ_REGION_STREAM_2( \ 1011 device_get_parent(rman_get_device((r)->res)), \ 1012 rman_get_device((r)->res), (r), (o), (d), (c)) 1013 #define bhnd_bus_write_stream_2(r, o, v) \ 1014 ((r)->direct) ? \ 1015 bus_write_stream_2((r)->res, (o), (v)) : \ 1016 BHND_BUS_WRITE_STREAM_2( \ 1017 device_get_parent(rman_get_device((r)->res)), \ 1018 rman_get_device((r)->res), (r), (o), (v)) 1019 #define bhnd_bus_write_multi_stream_2(r, o, d, c) \ 1020 ((r)->direct) ? \ 1021 bus_write_multi_stream_2((r)->res, (o), (d), (c)) : \ 1022 BHND_BUS_WRITE_MULTI_STREAM_2( \ 1023 device_get_parent(rman_get_device((r)->res)), \ 1024 rman_get_device((r)->res), (r), (o), (d), (c)) 1025 #define bhnd_bus_write_region_stream_2(r, o, d, c) \ 1026 ((r)->direct) ? \ 1027 bus_write_region_stream_2((r)->res, (o), (d), (c)) : \ 1028 BHND_BUS_WRITE_REGION_STREAM_2( \ 1029 device_get_parent(rman_get_device((r)->res)), \ 1030 rman_get_device((r)->res), (r), (o), (d), (c)) 1031 #define bhnd_bus_set_multi_2(r, o, v, c) \ 1032 ((r)->direct) ? \ 1033 bus_set_multi_2((r)->res, (o), (v), (c)) : \ 1034 BHND_BUS_SET_MULTI_2( \ 1035 device_get_parent(rman_get_device((r)->res)), \ 1036 rman_get_device((r)->res), (r), (o), (v), (c)) 1037 #define bhnd_bus_set_region_2(r, o, v, c) \ 1038 ((r)->direct) ? \ 1039 bus_set_region_2((r)->res, (o), (v), (c)) : \ 1040 BHND_BUS_SET_REGION_2( \ 1041 device_get_parent(rman_get_device((r)->res)), \ 1042 rman_get_device((r)->res), (r), (o), (v), (c)) 1043 #define bhnd_bus_read_4(r, o) \ 1044 ((r)->direct) ? \ 1045 bus_read_4((r)->res, (o)) : \ 1046 BHND_BUS_READ_4( \ 1047 device_get_parent(rman_get_device((r)->res)), \ 1048 rman_get_device((r)->res), (r), (o)) 1049 #define bhnd_bus_read_multi_4(r, o, d, c) \ 1050 ((r)->direct) ? \ 1051 bus_read_multi_4((r)->res, (o), (d), (c)) : \ 1052 BHND_BUS_READ_MULTI_4( \ 1053 device_get_parent(rman_get_device((r)->res)), \ 1054 rman_get_device((r)->res), (r), (o), (d), (c)) 1055 #define bhnd_bus_read_region_4(r, o, d, c) \ 1056 ((r)->direct) ? \ 1057 bus_read_region_4((r)->res, (o), (d), (c)) : \ 1058 BHND_BUS_READ_REGION_4( \ 1059 device_get_parent(rman_get_device((r)->res)), \ 1060 rman_get_device((r)->res), (r), (o), (d), (c)) 1061 #define bhnd_bus_write_4(r, o, v) \ 1062 ((r)->direct) ? \ 1063 bus_write_4((r)->res, (o), (v)) : \ 1064 BHND_BUS_WRITE_4( \ 1065 device_get_parent(rman_get_device((r)->res)), \ 1066 rman_get_device((r)->res), (r), (o), (v)) 1067 #define bhnd_bus_write_multi_4(r, o, d, c) \ 1068 ((r)->direct) ? \ 1069 bus_write_multi_4((r)->res, (o), (d), (c)) : \ 1070 BHND_BUS_WRITE_MULTI_4( \ 1071 device_get_parent(rman_get_device((r)->res)), \ 1072 rman_get_device((r)->res), (r), (o), (d), (c)) 1073 #define bhnd_bus_write_region_4(r, o, d, c) \ 1074 ((r)->direct) ? \ 1075 bus_write_region_4((r)->res, (o), (d), (c)) : \ 1076 BHND_BUS_WRITE_REGION_4( \ 1077 device_get_parent(rman_get_device((r)->res)), \ 1078 rman_get_device((r)->res), (r), (o), (d), (c)) 1079 #define bhnd_bus_read_stream_4(r, o) \ 1080 ((r)->direct) ? \ 1081 bus_read_stream_4((r)->res, (o)) : \ 1082 BHND_BUS_READ_STREAM_4( \ 1083 device_get_parent(rman_get_device((r)->res)), \ 1084 rman_get_device((r)->res), (r), (o)) 1085 #define bhnd_bus_read_multi_stream_4(r, o, d, c) \ 1086 ((r)->direct) ? \ 1087 bus_read_multi_stream_4((r)->res, (o), (d), (c)) : \ 1088 BHND_BUS_READ_MULTI_STREAM_4( \ 1089 device_get_parent(rman_get_device((r)->res)), \ 1090 rman_get_device((r)->res), (r), (o), (d), (c)) 1091 #define bhnd_bus_read_region_stream_4(r, o, d, c) \ 1092 ((r)->direct) ? \ 1093 bus_read_region_stream_4((r)->res, (o), (d), (c)) : \ 1094 BHND_BUS_READ_REGION_STREAM_4( \ 1095 device_get_parent(rman_get_device((r)->res)), \ 1096 rman_get_device((r)->res), (r), (o), (d), (c)) 1097 #define bhnd_bus_write_stream_4(r, o, v) \ 1098 ((r)->direct) ? \ 1099 bus_write_stream_4((r)->res, (o), (v)) : \ 1100 BHND_BUS_WRITE_STREAM_4( \ 1101 device_get_parent(rman_get_device((r)->res)), \ 1102 rman_get_device((r)->res), (r), (o), (v)) 1103 #define bhnd_bus_write_multi_stream_4(r, o, d, c) \ 1104 ((r)->direct) ? \ 1105 bus_write_multi_stream_4((r)->res, (o), (d), (c)) : \ 1106 BHND_BUS_WRITE_MULTI_STREAM_4( \ 1107 device_get_parent(rman_get_device((r)->res)), \ 1108 rman_get_device((r)->res), (r), (o), (d), (c)) 1109 #define bhnd_bus_write_region_stream_4(r, o, d, c) \ 1110 ((r)->direct) ? \ 1111 bus_write_region_stream_4((r)->res, (o), (d), (c)) : \ 1112 BHND_BUS_WRITE_REGION_STREAM_4( \ 1113 device_get_parent(rman_get_device((r)->res)), \ 1114 rman_get_device((r)->res), (r), (o), (d), (c)) 1115 #define bhnd_bus_set_multi_4(r, o, v, c) \ 1116 ((r)->direct) ? \ 1117 bus_set_multi_4((r)->res, (o), (v), (c)) : \ 1118 BHND_BUS_SET_MULTI_4( \ 1119 device_get_parent(rman_get_device((r)->res)), \ 1120 rman_get_device((r)->res), (r), (o), (v), (c)) 1121 #define bhnd_bus_set_region_4(r, o, v, c) \ 1122 ((r)->direct) ? \ 1123 bus_set_region_4((r)->res, (o), (v), (c)) : \ 1124 BHND_BUS_SET_REGION_4( \ 1125 device_get_parent(rman_get_device((r)->res)), \ 1126 rman_get_device((r)->res), (r), (o), (v), (c)) 1127 1128 #endif /* _BHND_BHND_H_ */ 1129