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$ 2736849Sdfr */ 2836849Sdfr 2936849Sdfr#ifndef _SYS_BUS_H_ 3036849Sdfr#define _SYS_BUS_H_ 3136849Sdfr 32193833Sjhb#include <machine/_limits.h> 33161928Sjmg#include <sys/_bus_dma.h> 34161928Sjmg 35132354Sdfr/** 36132354Sdfr * @defgroup NEWBUS newbus - a generic framework for managing devices 37132354Sdfr * @{ 3868522Smsmith */ 39132354Sdfr 40132354Sdfr/** 41132354Sdfr * @brief Interface information structure. 42132354Sdfr */ 4368522Smsmithstruct u_businfo { 44132354Sdfr int ub_version; /**< @brief interface version */ 4568522Smsmith#define BUS_USER_VERSION 1 46132354Sdfr int ub_generation; /**< @brief generation count */ 4768522Smsmith}; 4868522Smsmith 49132354Sdfr/** 50132354Sdfr * @brief State of the device. 51103329Simp */ 52103329Simptypedef enum device_state { 53197224Sattilio DS_NOTPRESENT = 10, /**< @brief not probed or probe failed */ 54197224Sattilio DS_ALIVE = 20, /**< @brief probe succeeded */ 55234152Sjhb DS_ATTACHING = 25, /**< @brief currently attaching */ 56197224Sattilio DS_ATTACHED = 30, /**< @brief attach method called */ 57197224Sattilio DS_BUSY = 40 /**< @brief device is open */ 58103329Simp} device_state_t; 59103329Simp 60132354Sdfr/** 61132354Sdfr * @brief Device information exported to userspace. 6268522Smsmith */ 6368522Smsmithstruct u_device { 6475718Sobrien uintptr_t dv_handle; 6575718Sobrien uintptr_t dv_parent; 6668522Smsmith 67132354Sdfr char dv_name[32]; /**< @brief Name of device in tree. */ 68132354Sdfr char dv_desc[32]; /**< @brief Driver description */ 69132354Sdfr char dv_drivername[32]; /**< @brief Driver name */ 70132354Sdfr char dv_pnpinfo[128]; /**< @brief Plug and play info */ 71132354Sdfr char dv_location[128]; /**< @brief Where is the device? */ 72132354Sdfr uint32_t dv_devflags; /**< @brief API Flags for device */ 73132354Sdfr uint16_t dv_flags; /**< @brief flags for dev date */ 74132354Sdfr device_state_t dv_state; /**< @brief State of attachment */ 7575718Sobrien /* XXX more driver info? */ 7668522Smsmith}; 7768522Smsmith 7855205Speter#ifdef _KERNEL 7936849Sdfr 8044515Sbde#include <sys/queue.h> 8159093Sdfr#include <sys/kobj.h> 8244515Sbde 83132354Sdfr/** 84121489Simp * devctl hooks. Typically one should use the devctl_notify 85121489Simp * hook to send the message. However, devctl_queue_data is also 86121489Simp * included in case devctl_notify isn't sufficiently general. 87121489Simp */ 88175726Siwasakiboolean_t devctl_process_running(void); 89209104Skibvoid devctl_notify_f(const char *__system, const char *__subsystem, 90209104Skib const char *__type, const char *__data, int __flags); 91121489Simpvoid devctl_notify(const char *__system, const char *__subsystem, 92121489Simp const char *__type, const char *__data); 93209104Skibvoid devctl_queue_data_f(char *__data, int __flags); 94121489Simpvoid devctl_queue_data(char *__data); 95121489Simp 96132354Sdfr/** 97132354Sdfr * @brief A device driver (included mainly for compatibility with 98132354Sdfr * FreeBSD 4.x). 99132354Sdfr */ 100121129Sdfrtypedef struct kobj_class driver_t; 101132354Sdfr 102132354Sdfr/** 103132354Sdfr * @brief A device class 104132354Sdfr * 105132354Sdfr * The devclass object has two main functions in the system. The first 106132354Sdfr * is to manage the allocation of unit numbers for device instances 107132354Sdfr * and the second is to hold the list of device drivers for a 108132354Sdfr * particular bus type. Each devclass has a name and there cannot be 109132354Sdfr * two devclasses with the same name. This ensures that unique unit 110132354Sdfr * numbers are allocated to device instances. 111132354Sdfr * 112132354Sdfr * Drivers that support several different bus attachments (e.g. isa, 113132354Sdfr * pci, pccard) should all use the same devclass to ensure that unit 114132354Sdfr * numbers do not conflict. 115132354Sdfr * 116132354Sdfr * Each devclass may also have a parent devclass. This is used when 117132354Sdfr * searching for device drivers to allow a form of inheritance. When 118132354Sdfr * matching drivers with devices, first the driver list of the parent 119132354Sdfr * device's devclass is searched. If no driver is found in that list, 120132354Sdfr * the search continues in the parent devclass (if any). 121132354Sdfr */ 12236972Sdfrtypedef struct devclass *devclass_t; 123132354Sdfr 124132354Sdfr/** 125132354Sdfr * @brief A device method (included mainly for compatibility with 126132354Sdfr * FreeBSD 4.x). 127132354Sdfr */ 12859093Sdfr#define device_method_t kobj_method_t 12936849Sdfr 130132354Sdfr/** 131166901Spiso * @brief Driver interrupt filter return values 132166901Spiso * 133166901Spiso * If a driver provides an interrupt filter routine it must return an 134166901Spiso * integer consisting of oring together zero or more of the following 135166901Spiso * flags: 136166901Spiso * 137166901Spiso * FILTER_STRAY - this device did not trigger the interrupt 138166901Spiso * FILTER_HANDLED - the interrupt has been fully handled and can be EOId 139166901Spiso * FILTER_SCHEDULE_THREAD - the threaded interrupt handler should be 140166901Spiso * scheduled to execute 141166901Spiso * 142166901Spiso * If the driver does not provide a filter, then the interrupt code will 143166901Spiso * act is if the filter had returned FILTER_SCHEDULE_THREAD. Note that it 144166901Spiso * is illegal to specify any other flag with FILTER_STRAY and that it is 145166901Spiso * illegal to not specify either of FILTER_HANDLED or FILTER_SCHEDULE_THREAD 146166901Spiso * if FILTER_STRAY is not specified. 147132354Sdfr */ 148166901Spiso#define FILTER_STRAY 0x01 149166901Spiso#define FILTER_HANDLED 0x02 150166901Spiso#define FILTER_SCHEDULE_THREAD 0x04 151166901Spiso 152166901Spiso/** 153166901Spiso * @brief Driver interrupt service routines 154166901Spiso * 155166901Spiso * The filter routine is run in primary interrupt context and may not 156166901Spiso * block or use regular mutexes. It may only use spin mutexes for 157166901Spiso * synchronization. The filter may either completely handle the 158166901Spiso * interrupt or it may perform some of the work and defer more 159166901Spiso * expensive work to the regular interrupt handler. If a filter 160166901Spiso * routine is not registered by the driver, then the regular interrupt 161166901Spiso * handler is always used to handle interrupts from this device. 162166901Spiso * 163166901Spiso * The regular interrupt handler executes in its own thread context 164166901Spiso * and may use regular mutexes. However, it is prohibited from 165166901Spiso * sleeping on a sleep queue. 166166901Spiso */ 167166901Spisotypedef int driver_filter_t(void*); 16836849Sdfrtypedef void driver_intr_t(void*); 16936849Sdfr 170132354Sdfr/** 171132354Sdfr * @brief Interrupt type bits. 172132354Sdfr * 173132354Sdfr * These flags are used both by newbus interrupt 17465557Sjasone * registration (nexus.c) and also in struct intrec, which defines 17565557Sjasone * interrupt properties. 17665557Sjasone * 17765557Sjasone * XXX We should probably revisit this and remove the vestiges of the 178132354Sdfr * spls implicit in names like INTR_TYPE_TTY. In the meantime, don't 17965557Sjasone * confuse things by renaming them (Grog, 18 July 2000). 18065557Sjasone * 181249097Srpaulo * Buses which do interrupt remapping will want to change their type 182249097Srpaulo * to reflect what sort of devices are underneath. 18341153Swollman */ 18446743Sdfrenum intr_type { 18575718Sobrien INTR_TYPE_TTY = 1, 18675718Sobrien INTR_TYPE_BIO = 2, 18775718Sobrien INTR_TYPE_NET = 4, 18875718Sobrien INTR_TYPE_CAM = 8, 18975718Sobrien INTR_TYPE_MISC = 16, 19075718Sobrien INTR_TYPE_CLK = 32, 19178365Speter INTR_TYPE_AV = 64, 19275718Sobrien INTR_EXCL = 256, /* exclusive interrupt */ 19375718Sobrien INTR_MPSAFE = 512, /* this interrupt is SMP safe */ 194216961Smarius INTR_ENTROPY = 1024, /* this interrupt provides entropy */ 195216961Smarius INTR_MD1 = 4096, /* flag reserved for MD use */ 196216961Smarius INTR_MD2 = 8192, /* flag reserved for MD use */ 197216961Smarius INTR_MD3 = 16384, /* flag reserved for MD use */ 198216961Smarius INTR_MD4 = 32768 /* flag reserved for MD use */ 19946743Sdfr}; 20036849Sdfr 201119967Smarcelenum intr_trigger { 202119967Smarcel INTR_TRIGGER_CONFORM = 0, 203119967Smarcel INTR_TRIGGER_EDGE = 1, 204119967Smarcel INTR_TRIGGER_LEVEL = 2 205119967Smarcel}; 206119967Smarcel 207119967Smarcelenum intr_polarity { 208119967Smarcel INTR_POLARITY_CONFORM = 0, 209119967Smarcel INTR_POLARITY_HIGH = 1, 210119967Smarcel INTR_POLARITY_LOW = 2 211119967Smarcel}; 212119967Smarcel 21336972Sdfrtypedef int (*devop_t)(void); 21436972Sdfr 215132354Sdfr/** 216132354Sdfr * @brief This structure is deprecated. 217132354Sdfr * 218132354Sdfr * Use the kobj(9) macro DEFINE_CLASS to 219121129Sdfr * declare classes which implement device drivers. 220121129Sdfr */ 22136849Sdfrstruct driver { 22275718Sobrien KOBJ_CLASS_FIELDS; 22336849Sdfr}; 22436849Sdfr 22536849Sdfr/* 22647397Sdfr * Definitions for drivers which need to keep simple lists of resources 22747397Sdfr * for their child devices. 22847397Sdfr */ 22947397Sdfrstruct resource; 23047397Sdfr 231132354Sdfr/** 232132354Sdfr * @brief An entry for a single resource in a resource list. 233132354Sdfr */ 23447397Sdfrstruct resource_list_entry { 235143785Simp STAILQ_ENTRY(resource_list_entry) link; 236132354Sdfr int type; /**< @brief type argument to alloc_resource */ 237132354Sdfr int rid; /**< @brief resource identifier */ 238200315Sjhb int flags; /**< @brief resource flags */ 239132354Sdfr struct resource *res; /**< @brief the real resource when allocated */ 240132354Sdfr u_long start; /**< @brief start of resource range */ 241132354Sdfr u_long end; /**< @brief end of resource range */ 242132354Sdfr u_long count; /**< @brief count within range */ 24347397Sdfr}; 244143785SimpSTAILQ_HEAD(resource_list, resource_list_entry); 24547397Sdfr 246200315Sjhb#define RLE_RESERVED 0x0001 /* Reserved by the parent bus. */ 247200315Sjhb#define RLE_ALLOCATED 0x0002 /* Reserved resource is allocated. */ 248224069Sjhb#define RLE_PREFETCH 0x0004 /* Resource is a prefetch range. */ 249200315Sjhb 25047397Sdfrvoid resource_list_init(struct resource_list *rl); 25147397Sdfrvoid resource_list_free(struct resource_list *rl); 252144926Simpstruct resource_list_entry * 253144926Simp resource_list_add(struct resource_list *rl, 25447397Sdfr int type, int rid, 25547397Sdfr u_long start, u_long end, u_long count); 25693365Smdoddint resource_list_add_next(struct resource_list *rl, 25793365Smdodd int type, 25893365Smdodd u_long start, u_long end, u_long count); 259200315Sjhbint resource_list_busy(struct resource_list *rl, 260200315Sjhb int type, int rid); 261215443Sjhbint resource_list_reserved(struct resource_list *rl, int type, int rid); 26247397Sdfrstruct resource_list_entry* 26347397Sdfr resource_list_find(struct resource_list *rl, 26447397Sdfr int type, int rid); 26547608Sdfrvoid resource_list_delete(struct resource_list *rl, 26647397Sdfr int type, int rid); 26747397Sdfrstruct resource * 26852174Sdfr resource_list_alloc(struct resource_list *rl, 26952174Sdfr device_t bus, device_t child, 27047397Sdfr int type, int *rid, 27147397Sdfr u_long start, u_long end, 27247397Sdfr u_long count, u_int flags); 27352174Sdfrint resource_list_release(struct resource_list *rl, 27452174Sdfr device_t bus, device_t child, 27547397Sdfr int type, int rid, struct resource *res); 276252315Sjhbint resource_list_release_active(struct resource_list *rl, 277252315Sjhb device_t bus, device_t child, 278252315Sjhb int type); 279200315Sjhbstruct resource * 280200315Sjhb resource_list_reserve(struct resource_list *rl, 281200315Sjhb device_t bus, device_t child, 282200315Sjhb int type, int *rid, 283200315Sjhb u_long start, u_long end, 284200315Sjhb u_long count, u_int flags); 285200315Sjhbint resource_list_unreserve(struct resource_list *rl, 286200315Sjhb device_t bus, device_t child, 287200315Sjhb int type, int rid); 288144952Simpvoid resource_list_purge(struct resource_list *rl); 28988373Stmmint resource_list_print_type(struct resource_list *rl, 29088373Stmm const char *name, int type, 29188373Stmm const char *format); 292103266Sjhb 29388373Stmm/* 29436849Sdfr * The root bus, to which all top-level busses are attached. 29536849Sdfr */ 29636972Sdfrextern device_t root_bus; 29736849Sdfrextern devclass_t root_devclass; 29841153Swollmanvoid root_bus_configure(void); 29936849Sdfr 30036849Sdfr/* 30136849Sdfr * Useful functions for implementing busses. 30236849Sdfr */ 30336849Sdfr 30441153Swollmanint bus_generic_activate_resource(device_t dev, device_t child, int type, 30541153Swollman int rid, struct resource *r); 306162228Sjhbdevice_t 307212413Savg bus_generic_add_child(device_t dev, u_int order, const char *name, 308162228Sjhb int unit); 309221231Sjhbint bus_generic_adjust_resource(device_t bus, device_t child, int type, 310221231Sjhb struct resource *r, u_long start, 311221231Sjhb u_long end); 31269294Smdoddstruct resource * 31375718Sobrien bus_generic_alloc_resource(device_t bus, device_t child, int type, 31475718Sobrien int *rid, u_long start, u_long end, 31569294Smdodd u_long count, u_int flags); 31641153Swollmanint bus_generic_attach(device_t dev); 317177467Sjhbint bus_generic_bind_intr(device_t dev, device_t child, 318177467Sjhb struct resource *irq, int cpu); 319100421Simpint bus_generic_child_present(device_t dev, device_t child); 320119967Smarcelint bus_generic_config_intr(device_t, int, enum intr_trigger, 321119967Smarcel enum intr_polarity); 322198134Sjhbint bus_generic_describe_intr(device_t dev, device_t child, 323198134Sjhb struct resource *irq, void *cookie, 324198134Sjhb const char *descr); 32541153Swollmanint bus_generic_deactivate_resource(device_t dev, device_t child, int type, 32641153Swollman int rid, struct resource *r); 32741153Swollmanint bus_generic_detach(device_t dev); 32845720Spetervoid bus_generic_driver_added(device_t dev, driver_t *driver); 329161928Sjmgbus_dma_tag_t 330161928Sjmg bus_generic_get_dma_tag(device_t dev, device_t child); 33169294Smdoddstruct resource_list * 33269294Smdodd bus_generic_get_resource_list (device_t, device_t); 333193833Sjhbvoid bus_generic_new_pass(device_t dev); 33449195Smdoddint bus_print_child_header(device_t dev, device_t child); 33549195Smdoddint bus_print_child_footer(device_t dev, device_t child); 33649195Smdoddint bus_generic_print_child(device_t dev, device_t child); 33747178Sdfrint bus_generic_probe(device_t dev); 33841153Swollmanint bus_generic_read_ivar(device_t dev, device_t child, int which, 33941153Swollman uintptr_t *result); 34042734Sdfrint bus_generic_release_resource(device_t bus, device_t child, 34142734Sdfr int type, int rid, struct resource *r); 34241153Swollmanint bus_generic_resume(device_t dev); 34341153Swollmanint bus_generic_setup_intr(device_t dev, device_t child, 34446743Sdfr struct resource *irq, int flags, 345166901Spiso driver_filter_t *filter, driver_intr_t *intr, 346166901Spiso void *arg, void **cookiep); 34767278Smdodd 34869294Smdoddstruct resource * 34969294Smdodd bus_generic_rl_alloc_resource (device_t, device_t, int, int *, 35069294Smdodd u_long, u_long, u_long, u_int); 35167278Smdoddvoid bus_generic_rl_delete_resource (device_t, device_t, int, int); 35269294Smdoddint bus_generic_rl_get_resource (device_t, device_t, int, int, u_long *, 35369294Smdodd u_long *); 35469294Smdoddint bus_generic_rl_set_resource (device_t, device_t, int, int, u_long, 35569294Smdodd u_long); 35669294Smdoddint bus_generic_rl_release_resource (device_t, device_t, int, int, 35769294Smdodd struct resource *); 35867278Smdodd 35941153Swollmanint bus_generic_shutdown(device_t dev); 36041153Swollmanint bus_generic_suspend(device_t dev); 36141153Swollmanint bus_generic_teardown_intr(device_t dev, device_t child, 36241153Swollman struct resource *irq, void *cookie); 36341153Swollmanint bus_generic_write_ivar(device_t dev, device_t child, int which, 36441153Swollman uintptr_t value); 36541153Swollman 36636849Sdfr/* 36741153Swollman * Wrapper functions for the BUS_*_RESOURCE methods to make client code 36841153Swollman * a little simpler. 36941153Swollman */ 370150521Sphk 371150521Sphkstruct resource_spec { 372150521Sphk int type; 373150521Sphk int rid; 374150521Sphk int flags; 375150521Sphk}; 376150521Sphk 377198135Sjhbint bus_alloc_resources(device_t dev, struct resource_spec *rs, 378198135Sjhb struct resource **res); 379198135Sjhbvoid bus_release_resources(device_t dev, const struct resource_spec *rs, 380198135Sjhb struct resource **res); 381150521Sphk 382221231Sjhbint bus_adjust_resource(device_t child, int type, struct resource *r, 383221231Sjhb u_long start, u_long end); 38441153Swollmanstruct resource *bus_alloc_resource(device_t dev, int type, int *rid, 38541153Swollman u_long start, u_long end, u_long count, 38641153Swollman u_int flags); 387130061Sdesint bus_activate_resource(device_t dev, int type, int rid, 38841153Swollman struct resource *r); 38941153Swollmanint bus_deactivate_resource(device_t dev, int type, int rid, 39041153Swollman struct resource *r); 391161928Sjmgbus_dma_tag_t bus_get_dma_tag(device_t dev); 392130061Sdesint bus_release_resource(device_t dev, int type, int rid, 39341153Swollman struct resource *r); 394140466Simpint bus_free_resource(device_t dev, int type, struct resource *r); 39546743Sdfrint bus_setup_intr(device_t dev, struct resource *r, int flags, 396166901Spiso driver_filter_t filter, driver_intr_t handler, 397166901Spiso void *arg, void **cookiep); 39845107Sdfrint bus_teardown_intr(device_t dev, struct resource *r, void *cookie); 399177467Sjhbint bus_bind_intr(device_t dev, struct resource *r, int cpu); 400198134Sjhbint bus_describe_intr(device_t dev, struct resource *irq, void *cookie, 401198134Sjhb const char *fmt, ...); 40252174Sdfrint bus_set_resource(device_t dev, int type, int rid, 40352174Sdfr u_long start, u_long count); 40452174Sdfrint bus_get_resource(device_t dev, int type, int rid, 40552174Sdfr u_long *startp, u_long *countp); 40652174Sdfru_long bus_get_resource_start(device_t dev, int type, int rid); 40752174Sdfru_long bus_get_resource_count(device_t dev, int type, int rid); 40852174Sdfrvoid bus_delete_resource(device_t dev, int type, int rid); 409104608Simpint bus_child_present(device_t child); 410104608Simpint bus_child_pnpinfo_str(device_t child, char *buf, size_t buflen); 411104608Simpint bus_child_location_str(device_t child, char *buf, size_t buflen); 412160186Simpvoid bus_enumerate_hinted_children(device_t bus); 41341153Swollman 414127133Snjlstatic __inline struct resource * 415127133Snjlbus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) 416127133Snjl{ 417127133Snjl return (bus_alloc_resource(dev, type, rid, 0ul, ~0ul, 1, flags)); 418127133Snjl} 419127133Snjl 42041153Swollman/* 42136849Sdfr * Access functions for device. 42236849Sdfr */ 42354073Smdodddevice_t device_add_child(device_t dev, const char *name, int unit); 424212213Savgdevice_t device_add_child_ordered(device_t dev, u_int order, 42554073Smdodd const char *name, int unit); 42641153Swollmanvoid device_busy(device_t dev); 42741153Swollmanint device_delete_child(device_t dev, device_t child); 428227849Shselaskyint device_delete_children(device_t dev); 429129711Sdesint device_attach(device_t dev); 43041153Swollmanint device_detach(device_t dev); 43141153Swollmanvoid device_disable(device_t dev); 43241153Swollmanvoid device_enable(device_t dev); 43341153Swollmandevice_t device_find_child(device_t dev, const char *classname, 43441153Swollman int unit); 435130061Sdesconst char *device_get_desc(device_t dev); 43641153Swollmandevclass_t device_get_devclass(device_t dev); 43741153Swollmandriver_t *device_get_driver(device_t dev); 43851052Sdfru_int32_t device_get_flags(device_t dev); 43941153Swollmandevice_t device_get_parent(device_t dev); 44042734Sdfrint device_get_children(device_t dev, device_t **listp, int *countp); 44141153Swollmanvoid *device_get_ivars(device_t dev); 44254073Smdoddvoid device_set_ivars(device_t dev, void *ivars); 44341153Swollmanconst char *device_get_name(device_t dev); 44445107Sdfrconst char *device_get_nameunit(device_t dev); 44541153Swollmanvoid *device_get_softc(device_t dev); 44641153Swollmandevice_state_t device_get_state(device_t dev); 44741153Swollmanint device_get_unit(device_t dev); 448129711Sdesstruct sysctl_ctx_list *device_get_sysctl_ctx(device_t dev); 449129711Sdesstruct sysctl_oid *device_get_sysctl_tree(device_t dev); 45075718Sobrienint device_is_alive(device_t dev); /* did probe succeed? */ 451113808Simpint device_is_attached(device_t dev); /* did attach succeed? */ 45241153Swollmanint device_is_enabled(device_t dev); 45345107Sdfrint device_is_quiet(device_t dev); 45449047Sdfrint device_print_prettyname(device_t dev); 45549047Sdfrint device_printf(device_t dev, const char *, ...) __printflike(2, 3); 456179893Simpint device_probe(device_t dev); 45741153Swollmanint device_probe_and_attach(device_t dev); 458150265Simpint device_probe_child(device_t bus, device_t dev); 459139507Simpint device_quiesce(device_t dev); 46045107Sdfrvoid device_quiet(device_t dev); 46141153Swollmanvoid device_set_desc(device_t dev, const char* desc); 46245107Sdfrvoid device_set_desc_copy(device_t dev, const char* desc); 46341153Swollmanint device_set_devclass(device_t dev, const char *classname); 46441153Swollmanint device_set_driver(device_t dev, driver_t *driver); 46551052Sdfrvoid device_set_flags(device_t dev, u_int32_t flags); 46662466Sphkvoid device_set_softc(device_t dev, void *softc); 467239299Shselaskyvoid device_free_softc(void *softc); 468239299Shselaskyvoid device_claim_softc(device_t dev); 46958884Simpint device_set_unit(device_t dev, int unit); /* XXX DONT USE XXX */ 47041153Swollmanint device_shutdown(device_t dev); 47141153Swollmanvoid device_unbusy(device_t dev); 47245107Sdfrvoid device_verbose(device_t dev); 47336849Sdfr 47436849Sdfr/* 47536849Sdfr * Access functions for devclass. 47636849Sdfr */ 477219819Sjeffint devclass_add_driver(devclass_t dc, driver_t *driver, 478219819Sjeff int pass, devclass_t *dcp); 47947608Sdfrdevclass_t devclass_create(const char *classname); 480219819Sjeffint devclass_delete_driver(devclass_t busclass, driver_t *driver); 48141153Swollmandevclass_t devclass_find(const char *classname); 482130061Sdesconst char *devclass_get_name(devclass_t dc); 48341153Swollmandevice_t devclass_get_device(devclass_t dc, int unit); 48441153Swollmanvoid *devclass_get_softc(devclass_t dc, int unit); 48541153Swollmanint devclass_get_devices(devclass_t dc, device_t **listp, int *countp); 486144626Snjlint devclass_get_drivers(devclass_t dc, driver_t ***listp, int *countp); 487138533Snjlint devclass_get_count(devclass_t dc); 48841153Swollmanint devclass_get_maxunit(devclass_t dc); 48985801Sacheint devclass_find_free_unit(devclass_t dc, int unit); 490121129Sdfrvoid devclass_set_parent(devclass_t dc, devclass_t pdc); 491121129Sdfrdevclass_t devclass_get_parent(devclass_t dc); 492130063Sdesstruct sysctl_ctx_list *devclass_get_sysctl_ctx(devclass_t dc); 493130063Sdesstruct sysctl_oid *devclass_get_sysctl_tree(devclass_t dc); 49436849Sdfr 49536972Sdfr/* 49637840Sdfr * Access functions for device resources. 49737840Sdfr */ 49845720Speter 49953331Speterint resource_int_value(const char *name, int unit, const char *resname, 50041153Swollman int *result); 50153331Speterint resource_long_value(const char *name, int unit, const char *resname, 50241153Swollman long *result); 50353331Speterint resource_string_value(const char *name, int unit, const char *resname, 50478135Speter const char **result); 505117166Sjhbint resource_disabled(const char *name, int unit); 50678135Speterint resource_find_match(int *anchor, const char **name, int *unit, 50778135Speter const char *resname, const char *value); 50878135Speterint resource_find_dev(int *anchor, const char *name, int *unit, 50978135Speter const char *resname, const char *value); 51053331Speterint resource_set_int(const char *name, int unit, const char *resname, 51153331Speter int value); 51253331Speterint resource_set_long(const char *name, int unit, const char *resname, 51353331Speter long value); 51453331Speterint resource_set_string(const char *name, int unit, const char *resname, 51553331Speter const char *value); 51637840Sdfr/* 51768522Smsmith * Functions for maintaining and checking consistency of 51868522Smsmith * bus information exported to userspace. 51968522Smsmith */ 52075718Sobrienint bus_data_generation_check(int generation); 52175718Sobrienvoid bus_data_generation_update(void); 52268522Smsmith 523132354Sdfr/** 524142392Simp * Some convenience defines for probe routines to return. These are just 525142392Simp * suggested values, and there's nothing magical about them. 526142392Simp * BUS_PROBE_SPECIFIC is for devices that cannot be reprobed, and that no 527142392Simp * possible other driver may exist (typically legacy drivers who don't fallow 528142392Simp * all the rules, or special needs drivers). BUS_PROBE_VENDOR is the 529142392Simp * suggested value that vendor supplied drivers use. This is for source or 530142392Simp * binary drivers that are not yet integrated into the FreeBSD tree. Its use 531142392Simp * in the base OS is prohibited. BUS_PROBE_DEFAULT is the normal return value 532142392Simp * for drivers to use. It is intended that nearly all of the drivers in the 533142392Simp * tree should return this value. BUS_PROBE_LOW_PRIORITY are for drivers that 534142392Simp * have special requirements like when there are two drivers that support 535142392Simp * overlapping series of hardware devices. In this case the one that supports 536142392Simp * the older part of the line would return this value, while the one that 537142392Simp * supports the newer ones would return BUS_PROBE_DEFAULT. BUS_PROBE_GENERIC 538142392Simp * is for drivers that wish to have a generic form and a specialized form, 539142392Simp * like is done with the pci bus and the acpi pci bus. BUS_PROBE_HOOVER is 540142392Simp * for those busses that implement a generic device place-holder for devices on 541239046Sandreast * the bus that have no more specific driver for them (aka ugen). 542176965Simp * BUS_PROBE_NOWILDCARD or lower means that the device isn't really bidding 543176965Simp * for a device node, but accepts only devices that its parent has told it 544176965Simp * use this driver. 545142392Simp */ 546142392Simp#define BUS_PROBE_SPECIFIC 0 /* Only I can use this device */ 547142392Simp#define BUS_PROBE_VENDOR (-10) /* Vendor supplied driver */ 548142392Simp#define BUS_PROBE_DEFAULT (-20) /* Base OS default driver */ 549142392Simp#define BUS_PROBE_LOW_PRIORITY (-40) /* Older, less desirable drivers */ 550142392Simp#define BUS_PROBE_GENERIC (-100) /* generic driver for dev */ 551142392Simp#define BUS_PROBE_HOOVER (-500) /* Generic dev for all devs on bus */ 552176965Simp#define BUS_PROBE_NOWILDCARD (-2000000000) /* No wildcard device matches */ 553142392Simp 554142392Simp/** 555193833Sjhb * During boot, the device tree is scanned multiple times. Each scan, 556193833Sjhb * or pass, drivers may be attached to devices. Each driver 557193833Sjhb * attachment is assigned a pass number. Drivers may only probe and 558193833Sjhb * attach to devices if their pass number is less than or equal to the 559193833Sjhb * current system-wide pass number. The default pass is the last pass 560193833Sjhb * and is used by most drivers. Drivers needed by the scheduler are 561193833Sjhb * probed in earlier passes. 562193833Sjhb */ 563193833Sjhb#define BUS_PASS_ROOT 0 /* Used to attach root0. */ 564193833Sjhb#define BUS_PASS_BUS 10 /* Busses and bridges. */ 565193833Sjhb#define BUS_PASS_CPU 20 /* CPU devices. */ 566193833Sjhb#define BUS_PASS_RESOURCE 30 /* Resource discovery. */ 567193833Sjhb#define BUS_PASS_INTERRUPT 40 /* Interrupt controllers. */ 568193833Sjhb#define BUS_PASS_TIMER 50 /* Timers and clocks. */ 569193833Sjhb#define BUS_PASS_SCHEDULER 60 /* Start scheduler. */ 570193833Sjhb#define BUS_PASS_DEFAULT __INT_MAX /* Everything else. */ 571193833Sjhb 572270075Sian#define BUS_PASS_ORDER_FIRST 0 573270075Sian#define BUS_PASS_ORDER_EARLY 2 574270075Sian#define BUS_PASS_ORDER_MIDDLE 5 575270075Sian#define BUS_PASS_ORDER_LATE 7 576270075Sian#define BUS_PASS_ORDER_LAST 9 577270075Sian 578193833Sjhbextern int bus_current_pass; 579193833Sjhb 580193833Sjhbvoid bus_set_pass(int pass); 581193833Sjhb 582193833Sjhb/** 583227829Smarius * Shorthands for constructing method tables. 58436972Sdfr */ 58575718Sobrien#define DEVMETHOD KOBJMETHOD 586227829Smarius#define DEVMETHOD_END KOBJMETHOD_END 58736972Sdfr 58836972Sdfr/* 58936972Sdfr * Some common device interfaces. 59036972Sdfr */ 59136972Sdfr#include "device_if.h" 59236972Sdfr#include "bus_if.h" 59336972Sdfr 59441153Swollmanstruct module; 59536849Sdfr 59641153Swollmanint driver_module_handler(struct module *, int, void *); 59741153Swollman 598132354Sdfr/** 59936849Sdfr * Module support for automatically adding drivers to busses. 60036849Sdfr */ 60136849Sdfrstruct driver_module_data { 60241153Swollman int (*dmd_chainevh)(struct module *, int, void *); 60341153Swollman void *dmd_chainarg; 60441153Swollman const char *dmd_busname; 605121129Sdfr kobj_class_t dmd_driver; 60641153Swollman devclass_t *dmd_devclass; 607193833Sjhb int dmd_pass; 60836849Sdfr}; 60936849Sdfr 610225079Sjhb#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ 611225079Sjhb evh, arg, order, pass) \ 61236849Sdfr \ 61337990Sdfrstatic struct driver_module_data name##_##busname##_driver_mod = { \ 61436849Sdfr evh, arg, \ 61536849Sdfr #busname, \ 616121129Sdfr (kobj_class_t) &driver, \ 617193833Sjhb &devclass, \ 618193833Sjhb pass \ 61936849Sdfr}; \ 62036849Sdfr \ 62137990Sdfrstatic moduledata_t name##_##busname##_mod = { \ 62237990Sdfr #busname "/" #name, \ 62336849Sdfr driver_module_handler, \ 62437990Sdfr &name##_##busname##_driver_mod \ 62536849Sdfr}; \ 62637990SdfrDECLARE_MODULE(name##_##busname, name##_##busname##_mod, \ 627225079Sjhb SI_SUB_DRIVERS, order) 62836849Sdfr 629225079Sjhb#define EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \ 630225079Sjhb EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ 631225079Sjhb evh, arg, SI_ORDER_MIDDLE, pass) 632225079Sjhb 633225079Sjhb#define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg,\ 634225079Sjhb order) \ 635225079Sjhb EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \ 636225079Sjhb evh, arg, order, BUS_PASS_DEFAULT) 637225079Sjhb 638193833Sjhb#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \ 639193833Sjhb EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, \ 640193833Sjhb BUS_PASS_DEFAULT) 641193833Sjhb 642132354Sdfr/** 64388373Stmm * Generic ivar accessor generation macros for bus drivers 64488373Stmm */ 64588373Stmm#define __BUS_ACCESSOR(varp, var, ivarp, ivar, type) \ 64688373Stmm \ 64788373Stmmstatic __inline type varp ## _get_ ## var(device_t dev) \ 64888373Stmm{ \ 64988373Stmm uintptr_t v; \ 65088373Stmm BUS_READ_IVAR(device_get_parent(dev), dev, \ 65188373Stmm ivarp ## _IVAR_ ## ivar, &v); \ 65288373Stmm return ((type) v); \ 65388373Stmm} \ 65488373Stmm \ 65588373Stmmstatic __inline void varp ## _set_ ## var(device_t dev, type t) \ 65688373Stmm{ \ 65788373Stmm uintptr_t v = (uintptr_t) t; \ 65888373Stmm BUS_WRITE_IVAR(device_get_parent(dev), dev, \ 65988373Stmm ivarp ## _IVAR_ ## ivar, v); \ 66088373Stmm} 66188373Stmm 662150524Sphk/** 663150524Sphk * Shorthand macros, taking resource argument 664150524Sphk * Generated with sys/tools/bus_macro.sh 665150524Sphk */ 666150524Sphk 667150524Sphk#define bus_barrier(r, o, l, f) \ 668150524Sphk bus_space_barrier((r)->r_bustag, (r)->r_bushandle, (o), (l), (f)) 669150524Sphk#define bus_read_1(r, o) \ 670150524Sphk bus_space_read_1((r)->r_bustag, (r)->r_bushandle, (o)) 671150524Sphk#define bus_read_multi_1(r, o, d, c) \ 672150524Sphk bus_space_read_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 673150524Sphk#define bus_read_region_1(r, o, d, c) \ 674150524Sphk bus_space_read_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 675150524Sphk#define bus_set_multi_1(r, o, v, c) \ 676150524Sphk bus_space_set_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 677150524Sphk#define bus_set_region_1(r, o, v, c) \ 678150524Sphk bus_space_set_region_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 679150524Sphk#define bus_write_1(r, o, v) \ 680150524Sphk bus_space_write_1((r)->r_bustag, (r)->r_bushandle, (o), (v)) 681150524Sphk#define bus_write_multi_1(r, o, d, c) \ 682150524Sphk bus_space_write_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 683150524Sphk#define bus_write_region_1(r, o, d, c) \ 684150524Sphk bus_space_write_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 685150524Sphk#define bus_read_stream_1(r, o) \ 686150524Sphk bus_space_read_stream_1((r)->r_bustag, (r)->r_bushandle, (o)) 687150524Sphk#define bus_read_multi_stream_1(r, o, d, c) \ 688150524Sphk bus_space_read_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 689150524Sphk#define bus_read_region_stream_1(r, o, d, c) \ 690150524Sphk bus_space_read_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 691150524Sphk#define bus_set_multi_stream_1(r, o, v, c) \ 692150524Sphk bus_space_set_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 693150524Sphk#define bus_set_region_stream_1(r, o, v, c) \ 694150524Sphk bus_space_set_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 695150524Sphk#define bus_write_stream_1(r, o, v) \ 696150524Sphk bus_space_write_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v)) 697150524Sphk#define bus_write_multi_stream_1(r, o, d, c) \ 698150524Sphk bus_space_write_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 699150524Sphk#define bus_write_region_stream_1(r, o, d, c) \ 700150524Sphk bus_space_write_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 701150524Sphk#define bus_read_2(r, o) \ 702150524Sphk bus_space_read_2((r)->r_bustag, (r)->r_bushandle, (o)) 703150524Sphk#define bus_read_multi_2(r, o, d, c) \ 704150524Sphk bus_space_read_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 705150524Sphk#define bus_read_region_2(r, o, d, c) \ 706150524Sphk bus_space_read_region_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 707150524Sphk#define bus_set_multi_2(r, o, v, c) \ 708150524Sphk bus_space_set_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 709150524Sphk#define bus_set_region_2(r, o, v, c) \ 710150524Sphk bus_space_set_region_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 711150524Sphk#define bus_write_2(r, o, v) \ 712150524Sphk bus_space_write_2((r)->r_bustag, (r)->r_bushandle, (o), (v)) 713150524Sphk#define bus_write_multi_2(r, o, d, c) \ 714150524Sphk bus_space_write_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 715150524Sphk#define bus_write_region_2(r, o, d, c) \ 716150524Sphk bus_space_write_region_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 717150524Sphk#define bus_read_stream_2(r, o) \ 718150524Sphk bus_space_read_stream_2((r)->r_bustag, (r)->r_bushandle, (o)) 719150524Sphk#define bus_read_multi_stream_2(r, o, d, c) \ 720150524Sphk bus_space_read_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 721150524Sphk#define bus_read_region_stream_2(r, o, d, c) \ 722150524Sphk bus_space_read_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 723150524Sphk#define bus_set_multi_stream_2(r, o, v, c) \ 724150524Sphk bus_space_set_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 725150524Sphk#define bus_set_region_stream_2(r, o, v, c) \ 726150524Sphk bus_space_set_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 727150524Sphk#define bus_write_stream_2(r, o, v) \ 728150524Sphk bus_space_write_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v)) 729150524Sphk#define bus_write_multi_stream_2(r, o, d, c) \ 730150524Sphk bus_space_write_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 731150524Sphk#define bus_write_region_stream_2(r, o, d, c) \ 732150524Sphk bus_space_write_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 733150524Sphk#define bus_read_4(r, o) \ 734150524Sphk bus_space_read_4((r)->r_bustag, (r)->r_bushandle, (o)) 735150524Sphk#define bus_read_multi_4(r, o, d, c) \ 736150524Sphk bus_space_read_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 737150524Sphk#define bus_read_region_4(r, o, d, c) \ 738150524Sphk bus_space_read_region_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 739150524Sphk#define bus_set_multi_4(r, o, v, c) \ 740150524Sphk bus_space_set_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 741150524Sphk#define bus_set_region_4(r, o, v, c) \ 742150524Sphk bus_space_set_region_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 743150524Sphk#define bus_write_4(r, o, v) \ 744150524Sphk bus_space_write_4((r)->r_bustag, (r)->r_bushandle, (o), (v)) 745150524Sphk#define bus_write_multi_4(r, o, d, c) \ 746150524Sphk bus_space_write_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 747150524Sphk#define bus_write_region_4(r, o, d, c) \ 748150524Sphk bus_space_write_region_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 749150524Sphk#define bus_read_stream_4(r, o) \ 750150524Sphk bus_space_read_stream_4((r)->r_bustag, (r)->r_bushandle, (o)) 751150524Sphk#define bus_read_multi_stream_4(r, o, d, c) \ 752150524Sphk bus_space_read_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 753150524Sphk#define bus_read_region_stream_4(r, o, d, c) \ 754150524Sphk bus_space_read_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 755150524Sphk#define bus_set_multi_stream_4(r, o, v, c) \ 756150524Sphk bus_space_set_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 757150524Sphk#define bus_set_region_stream_4(r, o, v, c) \ 758150524Sphk bus_space_set_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 759150524Sphk#define bus_write_stream_4(r, o, v) \ 760150524Sphk bus_space_write_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v)) 761150524Sphk#define bus_write_multi_stream_4(r, o, d, c) \ 762150524Sphk bus_space_write_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 763150524Sphk#define bus_write_region_stream_4(r, o, d, c) \ 764150524Sphk bus_space_write_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 765150524Sphk#define bus_read_8(r, o) \ 766150524Sphk bus_space_read_8((r)->r_bustag, (r)->r_bushandle, (o)) 767150524Sphk#define bus_read_multi_8(r, o, d, c) \ 768150524Sphk bus_space_read_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 769150524Sphk#define bus_read_region_8(r, o, d, c) \ 770150524Sphk bus_space_read_region_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 771150524Sphk#define bus_set_multi_8(r, o, v, c) \ 772150524Sphk bus_space_set_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 773150524Sphk#define bus_set_region_8(r, o, v, c) \ 774150524Sphk bus_space_set_region_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 775150524Sphk#define bus_write_8(r, o, v) \ 776150524Sphk bus_space_write_8((r)->r_bustag, (r)->r_bushandle, (o), (v)) 777150524Sphk#define bus_write_multi_8(r, o, d, c) \ 778150524Sphk bus_space_write_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 779150524Sphk#define bus_write_region_8(r, o, d, c) \ 780150524Sphk bus_space_write_region_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 781150524Sphk#define bus_read_stream_8(r, o) \ 782150524Sphk bus_space_read_stream_8((r)->r_bustag, (r)->r_bushandle, (o)) 783150524Sphk#define bus_read_multi_stream_8(r, o, d, c) \ 784150524Sphk bus_space_read_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 785150524Sphk#define bus_read_region_stream_8(r, o, d, c) \ 786150524Sphk bus_space_read_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 787150524Sphk#define bus_set_multi_stream_8(r, o, v, c) \ 788150524Sphk bus_space_set_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 789150524Sphk#define bus_set_region_stream_8(r, o, v, c) \ 790150524Sphk bus_space_set_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c)) 791150524Sphk#define bus_write_stream_8(r, o, v) \ 792150524Sphk bus_space_write_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v)) 793150524Sphk#define bus_write_multi_stream_8(r, o, d, c) \ 794150524Sphk bus_space_write_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 795150524Sphk#define bus_write_region_stream_8(r, o, d, c) \ 796150524Sphk bus_space_write_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c)) 79755205Speter#endif /* _KERNEL */ 79836849Sdfr 79936849Sdfr#endif /* !_SYS_BUS_H_ */ 800