136849Sdfr/*- 2121129Sdfr * Copyright (c) 1997,1998,2003 Doug Rabson 336849Sdfr * All rights reserved. 436849Sdfr * 536849Sdfr * Redistribution and use in source and binary forms, with or without 636849Sdfr * modification, are permitted provided that the following conditions 736849Sdfr * are met: 836849Sdfr * 1. Redistributions of source code must retain the above copyright 936849Sdfr * notice, this list of conditions and the following disclaimer. 1036849Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1136849Sdfr * notice, this list of conditions and the following disclaimer in the 1236849Sdfr * documentation and/or other materials provided with the distribution. 1336849Sdfr * 1436849Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1536849Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1636849Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1736849Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1836849Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1936849Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2036849Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2136849Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2236849Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2336849Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2436849Sdfr * SUCH DAMAGE. 2536849Sdfr * 2650477Speter * $FreeBSD: stable/10/sys/sys/bus.h 308318 2016-11-04 21:43:10Z jhb $ 2736849Sdfr */ 2836849Sdfr 2936849Sdfr#ifndef _SYS_BUS_H_ 3036849Sdfr#define _SYS_BUS_H_ 3136849Sdfr 32193833Sjhb#include <machine/_limits.h> 33161928Sjmg#include <sys/_bus_dma.h> 34295131Sjhb#include <sys/ioccom.h> 35161928Sjmg 36132354Sdfr/** 37132354Sdfr * @defgroup NEWBUS newbus - a generic framework for managing devices 38132354Sdfr * @{ 3968522Smsmith */ 40132354Sdfr 41132354Sdfr/** 42132354Sdfr * @brief Interface information structure. 43132354Sdfr */ 4468522Smsmithstruct u_businfo { 45132354Sdfr int ub_version; /**< @brief interface version */ 4668522Smsmith#define BUS_USER_VERSION 1 47132354Sdfr int ub_generation; /**< @brief generation count */ 4868522Smsmith}; 4968522Smsmith 50132354Sdfr/** 51132354Sdfr * @brief State of the device. 52103329Simp */ 53103329Simptypedef enum device_state { 54197224Sattilio DS_NOTPRESENT = 10, /**< @brief not probed or probe failed */ 55197224Sattilio DS_ALIVE = 20, /**< @brief probe succeeded */ 56234152Sjhb DS_ATTACHING = 25, /**< @brief currently attaching */ 57197224Sattilio DS_ATTACHED = 30, /**< @brief attach method called */ 58197224Sattilio DS_BUSY = 40 /**< @brief device is open */ 59103329Simp} device_state_t; 60103329Simp 61132354Sdfr/** 62132354Sdfr * @brief Device information exported to userspace. 6368522Smsmith */ 6468522Smsmithstruct u_device { 6575718Sobrien uintptr_t dv_handle; 6675718Sobrien uintptr_t dv_parent; 6768522Smsmith 68132354Sdfr char dv_name[32]; /**< @brief Name of device in tree. */ 69132354Sdfr char dv_desc[32]; /**< @brief Driver description */ 70132354Sdfr char dv_drivername[32]; /**< @brief Driver name */ 71132354Sdfr char dv_pnpinfo[128]; /**< @brief Plug and play info */ 72132354Sdfr char dv_location[128]; /**< @brief Where is the device? */ 73132354Sdfr uint32_t dv_devflags; /**< @brief API Flags for device */ 74132354Sdfr uint16_t dv_flags; /**< @brief flags for dev date */ 75132354Sdfr device_state_t dv_state; /**< @brief State of attachment */ 7675718Sobrien /* XXX more driver info? */ 7768522Smsmith}; 7868522Smsmith 79295131Sjhb/** 80295131Sjhb * @brief Device request structure used for ioctl's. 81295131Sjhb * 82295131Sjhb * Used for ioctl's on /dev/devctl2. All device ioctl's 83295131Sjhb * must have parameter definitions which begin with dr_name. 84295131Sjhb */ 85295131Sjhbstruct devreq_buffer { 86295131Sjhb void *buffer; 87295131Sjhb size_t length; 88295131Sjhb}; 89295131Sjhb 90295131Sjhbstruct devreq { 91295131Sjhb char dr_name[128]; 92295131Sjhb int dr_flags; /* request-specific flags */ 93295131Sjhb union { 94295131Sjhb struct devreq_buffer dru_buffer; 95295131Sjhb void *dru_data; 96295131Sjhb } dr_dru; 97295131Sjhb#define dr_buffer dr_dru.dru_buffer /* variable-sized buffer */ 98295131Sjhb#define dr_data dr_dru.dru_data /* fixed-size buffer */ 99295131Sjhb}; 100295131Sjhb 101295131Sjhb#define DEV_ATTACH _IOW('D', 1, struct devreq) 102295131Sjhb#define DEV_DETACH _IOW('D', 2, struct devreq) 103295131Sjhb#define DEV_ENABLE _IOW('D', 3, struct devreq) 104295131Sjhb#define DEV_DISABLE _IOW('D', 4, struct devreq) 105295131Sjhb#define DEV_SET_DRIVER _IOW('D', 7, struct devreq) 106306533Sjhb#define DEV_CLEAR_DRIVER _IOW('D', 8, struct devreq) 107295131Sjhb 108295131Sjhb/* Flags for DEV_DETACH and DEV_DISABLE. */ 109295131Sjhb#define DEVF_FORCE_DETACH 0x0000001 110295131Sjhb 111295131Sjhb/* Flags for DEV_SET_DRIVER. */ 112295131Sjhb#define DEVF_SET_DRIVER_DETACH 0x0000001 /* Detach existing driver. */ 113295131Sjhb 114306533Sjhb/* Flags for DEV_CLEAR_DRIVER. */ 115306533Sjhb#define DEVF_CLEAR_DRIVER_DETACH 0x0000001 /* Detach existing driver. */ 116306533Sjhb 11755205Speter#ifdef _KERNEL 11836849Sdfr 119295131Sjhb#include <sys/eventhandler.h> 12059093Sdfr#include <sys/kobj.h> 12144515Sbde 122132354Sdfr/** 123121489Simp * devctl hooks. Typically one should use the devctl_notify 124121489Simp * hook to send the message. However, devctl_queue_data is also 125121489Simp * included in case devctl_notify isn't sufficiently general. 126121489Simp */ 127175726Siwasakiboolean_t devctl_process_running(void); 128209104Skibvoid devctl_notify_f(const char *__system, const char *__subsystem, 129209104Skib const char *__type, const char *__data, int __flags); 130121489Simpvoid devctl_notify(const char *__system, const char *__subsystem, 131121489Simp const char *__type, const char *__data); 132209104Skibvoid devctl_queue_data_f(char *__data, int __flags); 133121489Simpvoid devctl_queue_data(char *__data); 134121489Simp 135132354Sdfr/** 136295131Sjhb * Device name parsers. Hook to allow device enumerators to map 137295131Sjhb * scheme-specific names to a device. 138295131Sjhb */ 139295131Sjhbtypedef void (*dev_lookup_fn)(void *arg, const char *name, 140295131Sjhb device_t *result); 141295131SjhbEVENTHANDLER_DECLARE(dev_lookup, dev_lookup_fn); 142295131Sjhb 143295131Sjhb/** 144132354Sdfr * @brief A device driver (included mainly for compatibility with 145132354Sdfr * FreeBSD 4.x). 146132354Sdfr */ 147121129Sdfrtypedef struct kobj_class driver_t; 148132354Sdfr 149132354Sdfr/** 150132354Sdfr * @brief A device class 151132354Sdfr * 152132354Sdfr * The devclass object has two main functions in the system. The first 153132354Sdfr * is to manage the allocation of unit numbers for device instances 154132354Sdfr * and the second is to hold the list of device drivers for a 155132354Sdfr * particular bus type. Each devclass has a name and there cannot be 156132354Sdfr * two devclasses with the same name. This ensures that unique unit 157132354Sdfr * numbers are allocated to device instances. 158132354Sdfr * 159132354Sdfr * Drivers that support several different bus attachments (e.g. isa, 160132354Sdfr * pci, pccard) should all use the same devclass to ensure that unit 161132354Sdfr * numbers do not conflict. 162132354Sdfr * 163132354Sdfr * Each devclass may also have a parent devclass. This is used when 164132354Sdfr * searching for device drivers to allow a form of inheritance. When 165132354Sdfr * matching drivers with devices, first the driver list of the parent 166132354Sdfr * device's devclass is searched. If no driver is found in that list, 167132354Sdfr * the search continues in the parent devclass (if any). 168132354Sdfr */ 16936972Sdfrtypedef struct devclass *devclass_t; 170132354Sdfr 171132354Sdfr/** 172132354Sdfr * @brief A device method (included mainly for compatibility with 173132354Sdfr * FreeBSD 4.x). 174132354Sdfr */ 17559093Sdfr#define device_method_t kobj_method_t 17636849Sdfr 177132354Sdfr/** 178166901Spiso * @brief Driver interrupt filter return values 179166901Spiso * 180166901Spiso * If a driver provides an interrupt filter routine it must return an 181166901Spiso * integer consisting of oring together zero or more of the following 182166901Spiso * flags: 183166901Spiso * 184166901Spiso * FILTER_STRAY - this device did not trigger the interrupt 185166901Spiso * FILTER_HANDLED - the interrupt has been fully handled and can be EOId 186166901Spiso * FILTER_SCHEDULE_THREAD - the threaded interrupt handler should be 187166901Spiso * scheduled to execute 188166901Spiso * 189166901Spiso * If the driver does not provide a filter, then the interrupt code will 190166901Spiso * act is if the filter had returned FILTER_SCHEDULE_THREAD. Note that it 191166901Spiso * is illegal to specify any other flag with FILTER_STRAY and that it is 192166901Spiso * illegal to not specify either of FILTER_HANDLED or FILTER_SCHEDULE_THREAD 193166901Spiso * if FILTER_STRAY is not specified. 194132354Sdfr */ 195166901Spiso#define FILTER_STRAY 0x01 196166901Spiso#define FILTER_HANDLED 0x02 197166901Spiso#define FILTER_SCHEDULE_THREAD 0x04 198166901Spiso 199166901Spiso/** 200166901Spiso * @brief Driver interrupt service routines 201166901Spiso * 202166901Spiso * The filter routine is run in primary interrupt context and may not 203166901Spiso * block or use regular mutexes. It may only use spin mutexes for 204166901Spiso * synchronization. The filter may either completely handle the 205166901Spiso * interrupt or it may perform some of the work and defer more 206166901Spiso * expensive work to the regular interrupt handler. If a filter 207166901Spiso * routine is not registered by the driver, then the regular interrupt 208166901Spiso * handler is always used to handle interrupts from this device. 209166901Spiso * 210166901Spiso * The regular interrupt handler executes in its own thread context 211166901Spiso * and may use regular mutexes. However, it is prohibited from 212166901Spiso * sleeping on a sleep queue. 213166901Spiso */ 214166901Spisotypedef int driver_filter_t(void*); 21536849Sdfrtypedef void driver_intr_t(void*); 21636849Sdfr 217132354Sdfr/** 218132354Sdfr * @brief Interrupt type bits. 219132354Sdfr * 220132354Sdfr * These flags are used both by newbus interrupt 22165557Sjasone * registration (nexus.c) and also in struct intrec, which defines 22265557Sjasone * interrupt properties. 22365557Sjasone * 22465557Sjasone * XXX We should probably revisit this and remove the vestiges of the 225132354Sdfr * spls implicit in names like INTR_TYPE_TTY. In the meantime, don't 22665557Sjasone * confuse things by renaming them (Grog, 18 July 2000). 22765557Sjasone * 228249097Srpaulo * Buses which do interrupt remapping will want to change their type 229249097Srpaulo * to reflect what sort of devices are underneath. 23041153Swollman */ 23146743Sdfrenum intr_type { 23275718Sobrien INTR_TYPE_TTY = 1, 23375718Sobrien INTR_TYPE_BIO = 2, 23475718Sobrien INTR_TYPE_NET = 4, 23575718Sobrien INTR_TYPE_CAM = 8, 23675718Sobrien INTR_TYPE_MISC = 16, 23775718Sobrien INTR_TYPE_CLK = 32, 23878365Speter INTR_TYPE_AV = 64, 23975718Sobrien INTR_EXCL = 256, /* exclusive interrupt */ 24075718Sobrien INTR_MPSAFE = 512, /* this interrupt is SMP safe */ 241216961Smarius INTR_ENTROPY = 1024, /* this interrupt provides entropy */ 242216961Smarius INTR_MD1 = 4096, /* flag reserved for MD use */ 243216961Smarius INTR_MD2 = 8192, /* flag reserved for MD use */ 244216961Smarius INTR_MD3 = 16384, /* flag reserved for MD use */ 245216961Smarius INTR_MD4 = 32768 /* flag reserved for MD use */ 24646743Sdfr}; 24736849Sdfr 248119967Smarcelenum intr_trigger { 249119967Smarcel INTR_TRIGGER_CONFORM = 0, 250119967Smarcel INTR_TRIGGER_EDGE = 1, 251119967Smarcel INTR_TRIGGER_LEVEL = 2 252119967Smarcel}; 253119967Smarcel 254119967Smarcelenum intr_polarity { 255119967Smarcel INTR_POLARITY_CONFORM = 0, 256119967Smarcel INTR_POLARITY_HIGH = 1, 257119967Smarcel INTR_POLARITY_LOW = 2 258119967Smarcel}; 259119967Smarcel 26036972Sdfrtypedef int (*devop_t)(void); 26136972Sdfr 262132354Sdfr/** 263132354Sdfr * @brief This structure is deprecated. 264132354Sdfr * 265132354Sdfr * Use the kobj(9) macro DEFINE_CLASS to 266121129Sdfr * declare classes which implement device drivers. 267121129Sdfr */ 26836849Sdfrstruct driver { 26975718Sobrien KOBJ_CLASS_FIELDS; 27036849Sdfr}; 27136849Sdfr 27236849Sdfr/* 27347397Sdfr * Definitions for drivers which need to keep simple lists of resources 27447397Sdfr * for their child devices. 27547397Sdfr */ 27647397Sdfrstruct resource; 27747397Sdfr 278132354Sdfr/** 279132354Sdfr * @brief An entry for a single resource in a resource list. 280132354Sdfr */ 28147397Sdfrstruct resource_list_entry { 282143785Simp STAILQ_ENTRY(resource_list_entry) link; 283132354Sdfr int type; /**< @brief type argument to alloc_resource */ 284132354Sdfr int rid; /**< @brief resource identifier */ 285200315Sjhb int flags; /**< @brief resource flags */ 286132354Sdfr struct resource *res; /**< @brief the real resource when allocated */ 287132354Sdfr u_long start; /**< @brief start of resource range */ 288132354Sdfr u_long end; /**< @brief end of resource range */ 289132354Sdfr u_long count; /**< @brief count within range */ 29047397Sdfr}; 291143785SimpSTAILQ_HEAD(resource_list, resource_list_entry); 29247397Sdfr 293200315Sjhb#define RLE_RESERVED 0x0001 /* Reserved by the parent bus. */ 294200315Sjhb#define RLE_ALLOCATED 0x0002 /* Reserved resource is allocated. */ 295224069Sjhb#define RLE_PREFETCH 0x0004 /* Resource is a prefetch range. */ 296200315Sjhb 29747397Sdfrvoid resource_list_init(struct resource_list *rl); 29847397Sdfrvoid resource_list_free(struct resource_list *rl); 299144926Simpstruct resource_list_entry * 300144926Simp resource_list_add(struct resource_list *rl, 30147397Sdfr int type, int rid, 30247397Sdfr u_long start, u_long end, u_long count); 30393365Smdoddint resource_list_add_next(struct resource_list *rl, 30493365Smdodd int type, 30593365Smdodd u_long start, u_long end, u_long count); 306200315Sjhbint resource_list_busy(struct resource_list *rl, 307200315Sjhb int type, int rid); 308215443Sjhbint resource_list_reserved(struct resource_list *rl, int type, int rid); 30947397Sdfrstruct resource_list_entry* 31047397Sdfr resource_list_find(struct resource_list *rl, 31147397Sdfr int type, int rid); 31247608Sdfrvoid resource_list_delete(struct resource_list *rl, 31347397Sdfr int type, int rid); 31447397Sdfrstruct resource * 31552174Sdfr resource_list_alloc(struct resource_list *rl, 31652174Sdfr device_t bus, device_t child, 31747397Sdfr int type, int *rid, 31847397Sdfr u_long start, u_long end, 31947397Sdfr u_long count, u_int flags); 32052174Sdfrint resource_list_release(struct resource_list *rl, 32152174Sdfr device_t bus, device_t child, 32247397Sdfr int type, int rid, struct resource *res); 323252315Sjhbint resource_list_release_active(struct resource_list *rl, 324252315Sjhb device_t bus, device_t child, 325252315Sjhb int type); 326200315Sjhbstruct resource * 327200315Sjhb resource_list_reserve(struct resource_list *rl, 328200315Sjhb device_t bus, device_t child, 329200315Sjhb int type, int *rid, 330200315Sjhb u_long start, u_long end, 331200315Sjhb u_long count, u_int flags); 332200315Sjhbint resource_list_unreserve(struct resource_list *rl, 333200315Sjhb device_t bus, device_t child, 334200315Sjhb int type, int rid); 335144952Simpvoid resource_list_purge(struct resource_list *rl); 33688373Stmmint resource_list_print_type(struct resource_list *rl, 33788373Stmm const char *name, int type, 33888373Stmm const char *format); 339103266Sjhb 34088373Stmm/* 34136849Sdfr * The root bus, to which all top-level busses are attached. 34236849Sdfr */ 34336972Sdfrextern device_t root_bus; 34436849Sdfrextern devclass_t root_devclass; 34541153Swollmanvoid root_bus_configure(void); 34636849Sdfr 34736849Sdfr/* 34836849Sdfr * Useful functions for implementing busses. 34936849Sdfr */ 35036849Sdfr 35141153Swollmanint bus_generic_activate_resource(device_t dev, device_t child, int type, 35241153Swollman int rid, struct resource *r); 353162228Sjhbdevice_t 354212413Savg bus_generic_add_child(device_t dev, u_int order, const char *name, 355162228Sjhb int unit); 356221231Sjhbint bus_generic_adjust_resource(device_t bus, device_t child, int type, 357221231Sjhb struct resource *r, u_long start, 358221231Sjhb u_long end); 35969294Smdoddstruct resource * 36075718Sobrien bus_generic_alloc_resource(device_t bus, device_t child, int type, 36175718Sobrien int *rid, u_long start, u_long end, 36269294Smdodd u_long count, u_int flags); 36341153Swollmanint bus_generic_attach(device_t dev); 364177467Sjhbint bus_generic_bind_intr(device_t dev, device_t child, 365177467Sjhb struct resource *irq, int cpu); 366100421Simpint bus_generic_child_present(device_t dev, device_t child); 367119967Smarcelint bus_generic_config_intr(device_t, int, enum intr_trigger, 368119967Smarcel enum intr_polarity); 369198134Sjhbint bus_generic_describe_intr(device_t dev, device_t child, 370198134Sjhb struct resource *irq, void *cookie, 371198134Sjhb const char *descr); 37241153Swollmanint bus_generic_deactivate_resource(device_t dev, device_t child, int type, 37341153Swollman int rid, struct resource *r); 37441153Swollmanint bus_generic_detach(device_t dev); 37545720Spetervoid bus_generic_driver_added(device_t dev, driver_t *driver); 376161928Sjmgbus_dma_tag_t 377161928Sjmg bus_generic_get_dma_tag(device_t dev, device_t child); 37869294Smdoddstruct resource_list * 37969294Smdodd bus_generic_get_resource_list (device_t, device_t); 380193833Sjhbvoid bus_generic_new_pass(device_t dev); 38149195Smdoddint bus_print_child_header(device_t dev, device_t child); 382279904Sscottlint bus_print_child_domain(device_t dev, device_t child); 38349195Smdoddint bus_print_child_footer(device_t dev, device_t child); 38449195Smdoddint bus_generic_print_child(device_t dev, device_t child); 38547178Sdfrint bus_generic_probe(device_t dev); 38641153Swollmanint bus_generic_read_ivar(device_t dev, device_t child, int which, 38741153Swollman uintptr_t *result); 38842734Sdfrint bus_generic_release_resource(device_t bus, device_t child, 38942734Sdfr int type, int rid, struct resource *r); 39041153Swollmanint bus_generic_resume(device_t dev); 39141153Swollmanint bus_generic_setup_intr(device_t dev, device_t child, 39246743Sdfr struct resource *irq, int flags, 393166901Spiso driver_filter_t *filter, driver_intr_t *intr, 394166901Spiso void *arg, void **cookiep); 39567278Smdodd 39669294Smdoddstruct resource * 39769294Smdodd bus_generic_rl_alloc_resource (device_t, device_t, int, int *, 39869294Smdodd u_long, u_long, u_long, u_int); 39967278Smdoddvoid bus_generic_rl_delete_resource (device_t, device_t, int, int); 40069294Smdoddint bus_generic_rl_get_resource (device_t, device_t, int, int, u_long *, 40169294Smdodd u_long *); 40269294Smdoddint bus_generic_rl_set_resource (device_t, device_t, int, int, u_long, 40369294Smdodd u_long); 40469294Smdoddint bus_generic_rl_release_resource (device_t, device_t, int, int, 40569294Smdodd struct resource *); 40667278Smdodd 40741153Swollmanint bus_generic_shutdown(device_t dev); 40841153Swollmanint bus_generic_suspend(device_t dev); 40941153Swollmanint bus_generic_teardown_intr(device_t dev, device_t child, 41041153Swollman struct resource *irq, void *cookie); 41141153Swollmanint bus_generic_write_ivar(device_t dev, device_t child, int which, 41241153Swollman uintptr_t value); 41341153Swollman 414279904Sscottlint bus_generic_get_domain(device_t dev, device_t child, int *domain); 415279904Sscottl 41636849Sdfr/* 41741153Swollman * Wrapper functions for the BUS_*_RESOURCE methods to make client code 41841153Swollman * a little simpler. 41941153Swollman */ 420150521Sphk 421150521Sphkstruct resource_spec { 422150521Sphk int type; 423150521Sphk int rid; 424150521Sphk int flags; 425150521Sphk}; 426150521Sphk 427198135Sjhbint bus_alloc_resources(device_t dev, struct resource_spec *rs, 428198135Sjhb struct resource **res); 429198135Sjhbvoid bus_release_resources(device_t dev, const struct resource_spec *rs, 430198135Sjhb struct resource **res); 431150521Sphk 432221231Sjhbint bus_adjust_resource(device_t child, int type, struct resource *r, 433221231Sjhb u_long start, u_long end); 43441153Swollmanstruct resource *bus_alloc_resource(device_t dev, int type, int *rid, 43541153Swollman u_long start, u_long end, u_long count, 43641153Swollman u_int flags); 437130061Sdesint bus_activate_resource(device_t dev, int type, int rid, 43841153Swollman struct resource *r); 43941153Swollmanint bus_deactivate_resource(device_t dev, int type, int rid, 44041153Swollman struct resource *r); 441161928Sjmgbus_dma_tag_t bus_get_dma_tag(device_t dev); 442279904Sscottlint bus_get_domain(device_t dev, int *domain); 443130061Sdesint bus_release_resource(device_t dev, int type, int rid, 44441153Swollman struct resource *r); 445140466Simpint bus_free_resource(device_t dev, int type, struct resource *r); 44646743Sdfrint bus_setup_intr(device_t dev, struct resource *r, int flags, 447166901Spiso driver_filter_t filter, driver_intr_t handler, 448166901Spiso void *arg, void **cookiep); 44945107Sdfrint bus_teardown_intr(device_t dev, struct resource *r, void *cookie); 450177467Sjhbint bus_bind_intr(device_t dev, struct resource *r, int cpu); 451198134Sjhbint bus_describe_intr(device_t dev, struct resource *irq, void *cookie, 452198134Sjhb const char *fmt, ...); 45352174Sdfrint bus_set_resource(device_t dev, int type, int rid, 45452174Sdfr u_long start, u_long count); 45552174Sdfrint bus_get_resource(device_t dev, int type, int rid, 45652174Sdfr u_long *startp, u_long *countp); 45752174Sdfru_long bus_get_resource_start(device_t dev, int type, int rid); 45852174Sdfru_long bus_get_resource_count(device_t dev, int type, int rid); 45952174Sdfrvoid bus_delete_resource(device_t dev, int type, int rid); 460104608Simpint bus_child_present(device_t child); 461104608Simpint bus_child_pnpinfo_str(device_t child, char *buf, size_t buflen); 462104608Simpint bus_child_location_str(device_t child, char *buf, size_t buflen); 463160186Simpvoid bus_enumerate_hinted_children(device_t bus); 46441153Swollman 465127133Snjlstatic __inline struct resource * 466127133Snjlbus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) 467127133Snjl{ 468127133Snjl return (bus_alloc_resource(dev, type, rid, 0ul, ~0ul, 1, flags)); 469127133Snjl} 470127133Snjl 47141153Swollman/* 47236849Sdfr * Access functions for device. 47336849Sdfr */ 47454073Smdodddevice_t device_add_child(device_t dev, const char *name, int unit); 475212213Savgdevice_t device_add_child_ordered(device_t dev, u_int order, 47654073Smdodd const char *name, int unit); 47741153Swollmanvoid device_busy(device_t dev); 47841153Swollmanint device_delete_child(device_t dev, device_t child); 479227849Shselaskyint device_delete_children(device_t dev); 480129711Sdesint device_attach(device_t dev); 48141153Swollmanint device_detach(device_t dev); 48241153Swollmanvoid device_disable(device_t dev); 48341153Swollmanvoid device_enable(device_t dev); 48441153Swollmandevice_t device_find_child(device_t dev, const char *classname, 48541153Swollman int unit); 486130061Sdesconst char *device_get_desc(device_t dev); 48741153Swollmandevclass_t device_get_devclass(device_t dev); 48841153Swollmandriver_t *device_get_driver(device_t dev); 48951052Sdfru_int32_t device_get_flags(device_t dev); 49041153Swollmandevice_t device_get_parent(device_t dev); 49142734Sdfrint device_get_children(device_t dev, device_t **listp, int *countp); 49241153Swollmanvoid *device_get_ivars(device_t dev); 49354073Smdoddvoid device_set_ivars(device_t dev, void *ivars); 49441153Swollmanconst char *device_get_name(device_t dev); 49545107Sdfrconst char *device_get_nameunit(device_t dev); 49641153Swollmanvoid *device_get_softc(device_t dev); 49741153Swollmandevice_state_t device_get_state(device_t dev); 49841153Swollmanint device_get_unit(device_t dev); 499129711Sdesstruct sysctl_ctx_list *device_get_sysctl_ctx(device_t dev); 500129711Sdesstruct sysctl_oid *device_get_sysctl_tree(device_t dev); 50175718Sobrienint device_is_alive(device_t dev); /* did probe succeed? */ 502113808Simpint device_is_attached(device_t dev); /* did attach succeed? */ 50341153Swollmanint device_is_enabled(device_t dev); 504295131Sjhbint device_is_suspended(device_t dev); 50545107Sdfrint device_is_quiet(device_t dev); 506308318Sjhbdevice_t device_lookup_by_name(const char *name); 50749047Sdfrint device_print_prettyname(device_t dev); 50849047Sdfrint device_printf(device_t dev, const char *, ...) __printflike(2, 3); 509179893Simpint device_probe(device_t dev); 51041153Swollmanint device_probe_and_attach(device_t dev); 511150265Simpint device_probe_child(device_t bus, device_t dev); 512139507Simpint device_quiesce(device_t dev); 51345107Sdfrvoid device_quiet(device_t dev); 51441153Swollmanvoid device_set_desc(device_t dev, const char* desc); 51545107Sdfrvoid device_set_desc_copy(device_t dev, const char* desc); 51641153Swollmanint device_set_devclass(device_t dev, const char *classname); 51741153Swollmanint device_set_driver(device_t dev, driver_t *driver); 51851052Sdfrvoid device_set_flags(device_t dev, u_int32_t flags); 51962466Sphkvoid device_set_softc(device_t dev, void *softc); 520239299Shselaskyvoid device_free_softc(void *softc); 521239299Shselaskyvoid device_claim_softc(device_t dev); 52258884Simpint device_set_unit(device_t dev, int unit); /* XXX DONT USE XXX */ 52341153Swollmanint device_shutdown(device_t dev); 52441153Swollmanvoid device_unbusy(device_t dev); 52545107Sdfrvoid device_verbose(device_t dev); 52636849Sdfr 52736849Sdfr/* 52836849Sdfr * Access functions for devclass. 52936849Sdfr */ 530219819Sjeffint devclass_add_driver(devclass_t dc, driver_t *driver, 531219819Sjeff int pass, devclass_t *dcp); 53247608Sdfrdevclass_t devclass_create(const char *classname); 533219819Sjeffint devclass_delete_driver(devclass_t busclass, driver_t *driver); 53441153Swollmandevclass_t devclass_find(const char *classname); 535130061Sdesconst char *devclass_get_name(devclass_t dc); 53641153Swollmandevice_t devclass_get_device(devclass_t dc, int unit); 53741153Swollmanvoid *devclass_get_softc(devclass_t dc, int unit); 53841153Swollmanint devclass_get_devices(devclass_t dc, device_t **listp, int *countp); 539144626Snjlint devclass_get_drivers(devclass_t dc, driver_t ***listp, int *countp); 540138533Snjlint devclass_get_count(devclass_t dc); 54141153Swollmanint devclass_get_maxunit(devclass_t dc); 54285801Sacheint devclass_find_free_unit(devclass_t dc, int unit); 543121129Sdfrvoid devclass_set_parent(devclass_t dc, devclass_t pdc); 544121129Sdfrdevclass_t devclass_get_parent(devclass_t dc); 545130063Sdesstruct sysctl_ctx_list *devclass_get_sysctl_ctx(devclass_t dc); 546130063Sdesstruct sysctl_oid *devclass_get_sysctl_tree(devclass_t dc); 54736849Sdfr 54836972Sdfr/* 54937840Sdfr * Access functions for device resources. 55037840Sdfr */ 55145720Speter 55253331Speterint resource_int_value(const char *name, int unit, const char *resname, 55341153Swollman int *result); 55453331Speterint resource_long_value(const char *name, int unit, const char *resname, 55541153Swollman long *result); 55653331Speterint resource_string_value(const char *name, int unit, const char *resname, 55778135Speter const char **result); 558117166Sjhbint resource_disabled(const char *name, int unit); 55978135Speterint resource_find_match(int *anchor, const char **name, int *unit, 56078135Speter const char *resname, const char *value); 56178135Speterint resource_find_dev(int *anchor, const char *name, int *unit, 56278135Speter const char *resname, const char *value); 56353331Speterint resource_set_int(const char *name, int unit, const char *resname, 56453331Speter int value); 56553331Speterint resource_set_long(const char *name, int unit, const char *resname, 56653331Speter long value); 56753331Speterint resource_set_string(const char *name, int unit, const char *resname, 56853331Speter const char *value); 569295131Sjhbint resource_unset_value(const char *name, int unit, const char *resname); 570295131Sjhb 57137840Sdfr/* 57268522Smsmith * Functions for maintaining and checking consistency of 57368522Smsmith * bus information exported to userspace. 57468522Smsmith */ 57575718Sobrienint bus_data_generation_check(int generation); 57675718Sobrienvoid bus_data_generation_update(void); 57768522Smsmith 578132354Sdfr/** 579142392Simp * Some convenience defines for probe routines to return. These are just 580142392Simp * suggested values, and there's nothing magical about them. 581142392Simp * BUS_PROBE_SPECIFIC is for devices that cannot be reprobed, and that no 582142392Simp * possible other driver may exist (typically legacy drivers who don't fallow 583142392Simp * all the rules, or special needs drivers). BUS_PROBE_VENDOR is the 584142392Simp * suggested value that vendor supplied drivers use. This is for source or 585142392Simp * binary drivers that are not yet integrated into the FreeBSD tree. Its use 586142392Simp * in the base OS is prohibited. BUS_PROBE_DEFAULT is the normal return value 587142392Simp * for drivers to use. It is intended that nearly all of the drivers in the 588142392Simp * tree should return this value. BUS_PROBE_LOW_PRIORITY are for drivers that 589142392Simp * have special requirements like when there are two drivers that support 590142392Simp * overlapping series of hardware devices. In this case the one that supports 591142392Simp * the older part of the line would return this value, while the one that 592142392Simp * supports the newer ones would return BUS_PROBE_DEFAULT. BUS_PROBE_GENERIC 593142392Simp * is for drivers that wish to have a generic form and a specialized form, 594142392Simp * like is done with the pci bus and the acpi pci bus. BUS_PROBE_HOOVER is 595142392Simp * for those busses that implement a generic device place-holder for devices on 596239046Sandreast * the bus that have no more specific driver for them (aka ugen). 597176965Simp * BUS_PROBE_NOWILDCARD or lower means that the device isn't really bidding 598176965Simp * for a device node, but accepts only devices that its parent has told it 599176965Simp * use this driver. 600142392Simp */ 601142392Simp#define BUS_PROBE_SPECIFIC 0 /* Only I can use this device */ 602142392Simp#define BUS_PROBE_VENDOR (-10) /* Vendor supplied driver */ 603142392Simp#define BUS_PROBE_DEFAULT (-20) /* Base OS default driver */ 604142392Simp#define BUS_PROBE_LOW_PRIORITY (-40) /* Older, less desirable drivers */ 605142392Simp#define BUS_PROBE_GENERIC (-100) /* generic driver for dev */ 606142392Simp#define BUS_PROBE_HOOVER (-500) /* Generic dev for all devs on bus */ 607176965Simp#define BUS_PROBE_NOWILDCARD (-2000000000) /* No wildcard device matches */ 608142392Simp 609142392Simp/** 610193833Sjhb * During boot, the device tree is scanned multiple times. Each scan, 611193833Sjhb * or pass, drivers may be attached to devices. Each driver 612193833Sjhb * attachment is assigned a pass number. Drivers may only probe and 613193833Sjhb * attach to devices if their pass number is less than or equal to the 614193833Sjhb * current system-wide pass number. The default pass is the last pass 615193833Sjhb * and is used by most drivers. Drivers needed by the scheduler are 616193833Sjhb * probed in earlier passes. 617193833Sjhb */ 618193833Sjhb#define BUS_PASS_ROOT 0 /* Used to attach root0. */ 619193833Sjhb#define BUS_PASS_BUS 10 /* Busses and bridges. */ 620193833Sjhb#define BUS_PASS_CPU 20 /* CPU devices. */ 621193833Sjhb#define BUS_PASS_RESOURCE 30 /* Resource discovery. */ 622193833Sjhb#define BUS_PASS_INTERRUPT 40 /* Interrupt controllers. */ 623193833Sjhb#define BUS_PASS_TIMER 50 /* Timers and clocks. */ 624193833Sjhb#define BUS_PASS_SCHEDULER 60 /* Start scheduler. */ 625193833Sjhb#define BUS_PASS_DEFAULT __INT_MAX /* Everything else. */ 626193833Sjhb 627270075Sian#define BUS_PASS_ORDER_FIRST 0 628270075Sian#define BUS_PASS_ORDER_EARLY 2 629270075Sian#define BUS_PASS_ORDER_MIDDLE 5 630270075Sian#define BUS_PASS_ORDER_LATE 7 631270075Sian#define BUS_PASS_ORDER_LAST 9 632270075Sian 633193833Sjhbextern int bus_current_pass; 634193833Sjhb 635193833Sjhbvoid bus_set_pass(int pass); 636193833Sjhb 637193833Sjhb/** 638227829Smarius * Shorthands for constructing method tables. 63936972Sdfr */ 64075718Sobrien#define DEVMETHOD KOBJMETHOD 641227829Smarius#define DEVMETHOD_END KOBJMETHOD_END 64236972Sdfr 64336972Sdfr/* 64436972Sdfr * Some common device interfaces. 64536972Sdfr */ 64636972Sdfr#include "device_if.h" 64736972Sdfr#include "bus_if.h" 64836972Sdfr 64941153Swollmanstruct module; 65036849Sdfr 65141153Swollmanint driver_module_handler(struct module *, int, void *); 65241153Swollman 653132354Sdfr/** 65436849Sdfr * Module support for automatically adding drivers to busses. 65536849Sdfr */ 65636849Sdfrstruct driver_module_data { 65741153Swollman int (*dmd_chainevh)(struct module *, int, void *); 65841153Swollman void *dmd_chainarg; 65941153Swollman const char *dmd_busname; 660121129Sdfr kobj_class_t dmd_driver; 66141153Swollman devclass_t *dmd_devclass; 662193833Sjhb int dmd_pass; 66336849Sdfr}; 66436849Sdfr 665225079Sjhb#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ 666225079Sjhb evh, arg, order, pass) \ 66736849Sdfr \ 66837990Sdfrstatic struct driver_module_data name##_##busname##_driver_mod = { \ 66936849Sdfr evh, arg, \ 67036849Sdfr #busname, \ 671121129Sdfr (kobj_class_t) &driver, \ 672193833Sjhb &devclass, \ 673193833Sjhb pass \ 67436849Sdfr}; \ 67536849Sdfr \ 67637990Sdfrstatic moduledata_t name##_##busname##_mod = { \ 67737990Sdfr #busname "/" #name, \ 67836849Sdfr driver_module_handler, \ 67937990Sdfr &name##_##busname##_driver_mod \ 68036849Sdfr}; \ 68137990SdfrDECLARE_MODULE(name##_##busname, name##_##busname##_mod, \ 682225079Sjhb SI_SUB_DRIVERS, order) 68336849Sdfr 684225079Sjhb#define EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \ 685225079Sjhb EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ 686225079Sjhb evh, arg, SI_ORDER_MIDDLE, pass) 687225079Sjhb 688225079Sjhb#define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg,\ 689225079Sjhb order) \ 690225079Sjhb EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ 691225079Sjhb evh, arg, order, BUS_PASS_DEFAULT) 692225079Sjhb 693193833Sjhb#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \ 694193833Sjhb EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, \ 695193833Sjhb BUS_PASS_DEFAULT) 696193833Sjhb 697132354Sdfr/** 69888373Stmm * Generic ivar accessor generation macros for bus drivers 69988373Stmm */ 70088373Stmm#define __BUS_ACCESSOR(varp, var, ivarp, ivar, type) \ 70188373Stmm \ 70288373Stmmstatic __inline type varp ## _get_ ## var(device_t dev) \ 70388373Stmm{ \ 70488373Stmm uintptr_t v; \ 70588373Stmm BUS_READ_IVAR(device_get_parent(dev), dev, \ 70688373Stmm ivarp ## _IVAR_ ## ivar, &v); \ 70788373Stmm return ((type) v); \ 70888373Stmm} \ 70988373Stmm \ 71088373Stmmstatic __inline void varp ## _set_ ## var(device_t dev, type t) \ 71188373Stmm{ \ 71288373Stmm uintptr_t v = (uintptr_t) t; \ 71388373Stmm BUS_WRITE_IVAR(device_get_parent(dev), dev, \ 71488373Stmm ivarp ## _IVAR_ ## ivar, v); \ 71588373Stmm} 71688373Stmm 717150524Sphk/** 718150524Sphk * Shorthand macros, taking resource argument 719150524Sphk * Generated with sys/tools/bus_macro.sh 720150524Sphk */ 721150524Sphk 722150524Sphk#define bus_barrier(r, o, l, f) \ 723150524Sphk bus_space_barrier((r)->r_bustag, (r)->r_bushandle, (o), (l), (f)) 724150524Sphk#define bus_read_1(r, o) \ 725150524Sphk bus_space_read_1((r)->r_bustag, (r)->r_bushandle, (o)) 726150524Sphk#define bus_read_multi_1(r, o, d, c) \ 727150524Sphk bus_space_read_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 728150524Sphk#define bus_read_region_1(r, o, d, c) \ 729150524Sphk bus_space_read_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 730150524Sphk#define bus_set_multi_1(r, o, v, c) \ 731150524Sphk bus_space_set_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 732150524Sphk#define bus_set_region_1(r, o, v, c) \ 733150524Sphk bus_space_set_region_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 734150524Sphk#define bus_write_1(r, o, v) \ 735150524Sphk bus_space_write_1((r)->r_bustag, (r)->r_bushandle, (o), (v)) 736150524Sphk#define bus_write_multi_1(r, o, d, c) \ 737150524Sphk bus_space_write_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 738150524Sphk#define bus_write_region_1(r, o, d, c) \ 739150524Sphk bus_space_write_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 740150524Sphk#define bus_read_stream_1(r, o) \ 741150524Sphk bus_space_read_stream_1((r)->r_bustag, (r)->r_bushandle, (o)) 742150524Sphk#define bus_read_multi_stream_1(r, o, d, c) \ 743150524Sphk bus_space_read_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 744150524Sphk#define bus_read_region_stream_1(r, o, d, c) \ 745150524Sphk bus_space_read_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 746150524Sphk#define bus_set_multi_stream_1(r, o, v, c) \ 747150524Sphk bus_space_set_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 748150524Sphk#define bus_set_region_stream_1(r, o, v, c) \ 749150524Sphk bus_space_set_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 750150524Sphk#define bus_write_stream_1(r, o, v) \ 751150524Sphk bus_space_write_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v)) 752150524Sphk#define bus_write_multi_stream_1(r, o, d, c) \ 753150524Sphk bus_space_write_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 754150524Sphk#define bus_write_region_stream_1(r, o, d, c) \ 755150524Sphk bus_space_write_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 756150524Sphk#define bus_read_2(r, o) \ 757150524Sphk bus_space_read_2((r)->r_bustag, (r)->r_bushandle, (o)) 758150524Sphk#define bus_read_multi_2(r, o, d, c) \ 759150524Sphk bus_space_read_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 760150524Sphk#define bus_read_region_2(r, o, d, c) \ 761150524Sphk bus_space_read_region_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 762150524Sphk#define bus_set_multi_2(r, o, v, c) \ 763150524Sphk bus_space_set_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 764150524Sphk#define bus_set_region_2(r, o, v, c) \ 765150524Sphk bus_space_set_region_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 766150524Sphk#define bus_write_2(r, o, v) \ 767150524Sphk bus_space_write_2((r)->r_bustag, (r)->r_bushandle, (o), (v)) 768150524Sphk#define bus_write_multi_2(r, o, d, c) \ 769150524Sphk bus_space_write_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 770150524Sphk#define bus_write_region_2(r, o, d, c) \ 771150524Sphk bus_space_write_region_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 772150524Sphk#define bus_read_stream_2(r, o) \ 773150524Sphk bus_space_read_stream_2((r)->r_bustag, (r)->r_bushandle, (o)) 774150524Sphk#define bus_read_multi_stream_2(r, o, d, c) \ 775150524Sphk bus_space_read_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 776150524Sphk#define bus_read_region_stream_2(r, o, d, c) \ 777150524Sphk bus_space_read_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 778150524Sphk#define bus_set_multi_stream_2(r, o, v, c) \ 779150524Sphk bus_space_set_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 780150524Sphk#define bus_set_region_stream_2(r, o, v, c) \ 781150524Sphk bus_space_set_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 782150524Sphk#define bus_write_stream_2(r, o, v) \ 783150524Sphk bus_space_write_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v)) 784150524Sphk#define bus_write_multi_stream_2(r, o, d, c) \ 785150524Sphk bus_space_write_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 786150524Sphk#define bus_write_region_stream_2(r, o, d, c) \ 787150524Sphk bus_space_write_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 788150524Sphk#define bus_read_4(r, o) \ 789150524Sphk bus_space_read_4((r)->r_bustag, (r)->r_bushandle, (o)) 790150524Sphk#define bus_read_multi_4(r, o, d, c) \ 791150524Sphk bus_space_read_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 792150524Sphk#define bus_read_region_4(r, o, d, c) \ 793150524Sphk bus_space_read_region_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 794150524Sphk#define bus_set_multi_4(r, o, v, c) \ 795150524Sphk bus_space_set_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 796150524Sphk#define bus_set_region_4(r, o, v, c) \ 797150524Sphk bus_space_set_region_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 798150524Sphk#define bus_write_4(r, o, v) \ 799150524Sphk bus_space_write_4((r)->r_bustag, (r)->r_bushandle, (o), (v)) 800150524Sphk#define bus_write_multi_4(r, o, d, c) \ 801150524Sphk bus_space_write_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 802150524Sphk#define bus_write_region_4(r, o, d, c) \ 803150524Sphk bus_space_write_region_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 804150524Sphk#define bus_read_stream_4(r, o) \ 805150524Sphk bus_space_read_stream_4((r)->r_bustag, (r)->r_bushandle, (o)) 806150524Sphk#define bus_read_multi_stream_4(r, o, d, c) \ 807150524Sphk bus_space_read_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 808150524Sphk#define bus_read_region_stream_4(r, o, d, c) \ 809150524Sphk bus_space_read_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 810150524Sphk#define bus_set_multi_stream_4(r, o, v, c) \ 811150524Sphk bus_space_set_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 812150524Sphk#define bus_set_region_stream_4(r, o, v, c) \ 813150524Sphk bus_space_set_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 814150524Sphk#define bus_write_stream_4(r, o, v) \ 815150524Sphk bus_space_write_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v)) 816150524Sphk#define bus_write_multi_stream_4(r, o, d, c) \ 817150524Sphk bus_space_write_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 818150524Sphk#define bus_write_region_stream_4(r, o, d, c) \ 819150524Sphk bus_space_write_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 820150524Sphk#define bus_read_8(r, o) \ 821150524Sphk bus_space_read_8((r)->r_bustag, (r)->r_bushandle, (o)) 822150524Sphk#define bus_read_multi_8(r, o, d, c) \ 823150524Sphk bus_space_read_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 824150524Sphk#define bus_read_region_8(r, o, d, c) \ 825150524Sphk bus_space_read_region_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 826150524Sphk#define bus_set_multi_8(r, o, v, c) \ 827150524Sphk bus_space_set_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 828150524Sphk#define bus_set_region_8(r, o, v, c) \ 829150524Sphk bus_space_set_region_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 830150524Sphk#define bus_write_8(r, o, v) \ 831150524Sphk bus_space_write_8((r)->r_bustag, (r)->r_bushandle, (o), (v)) 832150524Sphk#define bus_write_multi_8(r, o, d, c) \ 833150524Sphk bus_space_write_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 834150524Sphk#define bus_write_region_8(r, o, d, c) \ 835150524Sphk bus_space_write_region_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 836150524Sphk#define bus_read_stream_8(r, o) \ 837150524Sphk bus_space_read_stream_8((r)->r_bustag, (r)->r_bushandle, (o)) 838150524Sphk#define bus_read_multi_stream_8(r, o, d, c) \ 839150524Sphk bus_space_read_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 840150524Sphk#define bus_read_region_stream_8(r, o, d, c) \ 841150524Sphk bus_space_read_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 842150524Sphk#define bus_set_multi_stream_8(r, o, v, c) \ 843150524Sphk bus_space_set_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 844150524Sphk#define bus_set_region_stream_8(r, o, v, c) \ 845150524Sphk bus_space_set_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 846150524Sphk#define bus_write_stream_8(r, o, v) \ 847150524Sphk bus_space_write_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v)) 848150524Sphk#define bus_write_multi_stream_8(r, o, d, c) \ 849150524Sphk bus_space_write_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 850150524Sphk#define bus_write_region_stream_8(r, o, d, c) \ 851150524Sphk bus_space_write_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 85255205Speter#endif /* _KERNEL */ 85336849Sdfr 85436849Sdfr#endif /* !_SYS_BUS_H_ */ 855