• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 1997,1998,2003 Doug Rabson
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 
31 #ifndef _SYS_BUS_H_
32 #define _SYS_BUS_H_
33 
34 #include <limits.h>
35 #include <sys/types.h>
36 #include <arm/include/_bus.h>
37 #include <sys/module.h>
38 #include <sys/queue.h>
39 #include <los_hwi.h>
40 
41 typedef struct device   *device_t;
42 
43 typedef uint32_t   u_int32_t;
44 
45 /**
46  * @brief State of the device.
47  */
48 typedef enum device_state {
49 	DS_NOTPRESENT = 10,             /**< @brief not probed or probe failed */
50 	DS_ALIVE = 20,                  /**< @brief probe succeeded */
51 	DS_ATTACHING = 25,              /**< @brief currently attaching */
52 	DS_ATTACHED = 30,               /**< @brief attach method called */
53 	DS_BUSY = 40                    /**< @brief device is open */
54 } device_state_t;
55 
56 /**
57  *  * @brief Device information exported to userspace.
58  *   */
59 struct u_device {
60 	uintptr_t       dv_handle;
61 	uintptr_t       dv_parent;
62 
63 	char            dv_name[32];            /**< @brief Name of device in tree. */
64 	char            dv_desc[32];            /**< @brief Driver description */
65 	char            dv_drivername[32];      /**< @brief Driver name */
66 	char            dv_pnpinfo[128];        /**< @brief Plug and play info */
67 	char            dv_location[128];       /**< @brief Where is the device? */
68 	uint32_t        dv_devflags;            /**< @brief API Flags for device */
69 	uint16_t        dv_flags;               /**< @brief flags for dev state */
70 	device_state_t  dv_state;               /**< @brief State of attachment */
71 	/* XXX more driver info? */
72 };
73 
74 /* Flags exported via dv_flags. */
75 #define DF_ENABLED      0x01            /* device should be probed/attached */
76 #define DF_FIXEDCLASS   0x02            /* devclass specified at create time */
77 #define DF_WILDCARD     0x04            /* unit was originally wildcard */
78 #define DF_DESCMALLOCED 0x08            /* description was malloced */
79 #define DF_QUIET        0x10            /* don't print verbose attach message */
80 #define DF_DONENOMATCH  0x20            /* don't execute DEVICE_NOMATCH again */
81 #define DF_EXTERNALSOFTC 0x40           /* softc not allocated by us */
82 #define DF_REBID        0x80            /* Can rebid after attach */
83 #define DF_SUSPENDED    0x100           /* Device is suspended. */
84 
85 #define	SYS_RES_IRQ	1	/* interrupt lines */
86 #define	SYS_RES_DRQ	2	/* isa dma lines */
87 #define	SYS_RES_MEMORY	3	/* i/o memory */
88 #define	SYS_RES_IOPORT	4	/* i/o ports */
89 
90 #include <sys/kobj.h>
91 
92 /**
93  * @brief A device driver (included mainly for compatibility with
94  * FreeBSD 4.x).
95  */
96 typedef struct kobj_class	driver_t;
97 
98 /**
99  * @brief A device class
100  *
101  * The devclass object has two main functions in the system. The first
102  * is to manage the allocation of unit numbers for device instances
103  * and the second is to hold the list of device drivers for a
104  * particular bus type. Each devclass has a name and there cannot be
105  * two devclasses with the same name. This ensures that unique unit
106  * numbers are allocated to device instances.
107  *
108  * Drivers that support several different bus attachments (e.g. isa,
109  * pci, pccard) should all use the same devclass to ensure that unit
110  * numbers do not conflict.
111  *
112  * Each devclass may also have a parent devclass. This is used when
113  * searching for device drivers to allow a form of inheritance. When
114  * matching drivers with devices, first the driver list of the parent
115  * device's devclass is searched. If no driver is found in that list,
116  * the search continues in the parent devclass (if any).
117  */
118 typedef struct devclass		*devclass_t;
119 
120 /**
121  * @brief A device method
122  */
123 #define device_method_t		kobj_method_t
124 
125 /**
126  * @brief Driver interrupt filter return values
127  *
128  * If a driver provides an interrupt filter routine it must return an
129  * integer consisting of oring together zero or more of the following
130  * flags:
131  *
132  *      FILTER_STRAY    - this device did not trigger the interrupt
133  *      FILTER_HANDLED  - the interrupt has been fully handled and can be EOId
134  *      FILTER_SCHEDULE_THREAD - the threaded interrupt handler should be
135  *                        scheduled to execute
136  *
137  * If the driver does not provide a filter, then the interrupt code will
138  * act is if the filter had returned FILTER_SCHEDULE_THREAD.  Note that it
139  * is illegal to specify any other flag with FILTER_STRAY and that it is
140  * illegal to not specify either of FILTER_HANDLED or FILTER_SCHEDULE_THREAD
141  * if FILTER_STRAY is not specified.
142  */
143 #define FILTER_STRAY            0x01
144 #define FILTER_HANDLED          0x02
145 #define FILTER_SCHEDULE_THREAD  0x04
146 
147 /**
148  * @brief Driver interrupt service routines
149  *
150  * The filter routine is run in primary interrupt context and may not
151  * block or use regular mutexes.  It may only use spin mutexes for
152  * synchronization.  The filter may either completely handle the
153  * interrupt or it may perform some of the work and defer more
154  * expensive work to the regular interrupt handler.  If a filter
155  * routine is not registered by the driver, then the regular interrupt
156  * handler is always used to handle interrupts from this device.
157  *
158  * The regular interrupt handler executes in its own thread context
159  * and may use regular mutexes.  However, it is prohibited from
160  * sleeping on a sleep queue.
161  */
162 typedef int driver_filter_t(void*);
163 typedef void driver_intr_t(int, void*);
164 
165 /**
166  * @brief This structure is deprecated.
167  *
168  * Use the kobj(9) macro DEFINE_CLASS to
169  * declare classes which implement device drivers.
170  */
171 struct driver {
172 	KOBJ_CLASS_FIELDS;
173 };
174 
175 
176 typedef   uint64_t      rman_res_t;
177 /*
178  * Definitions for drivers which need to keep simple lists of resources
179  * for their child devices.
180  */
181 /*
182  * The public (kernel) view of struct resource
183  *
184  * NB: Changing the offset/size/type of existing fields in struct resource
185  * NB: breaks the device driver ABI and is strongly FORBIDDEN.
186  * NB: Appending new fields is probably just misguided.
187  */
188 
189 struct resource {
190 	rman_res_t	start;		/**< @brief start of resource range */
191 	rman_res_t	end;		/**< @brief end of resource range */
192 	rman_res_t	count;			/**< @brief count within range */
193 };
194 
195 /**
196  * @brief An entry for a single resource in a resource list.
197  */
198 struct resource_list_entry {
199 	STAILQ_ENTRY(resource_list_entry) link;
200 	int	type;			/**< @brief type argument to alloc_resource */
201 	int	rid;			/**< @brief resource identifier */
202 	int	flags;			/**< @brief resource flags */
203 	struct	resource *res;		/**< @brief the real resource when allocated */
204 };
205 STAILQ_HEAD(resource_list, resource_list_entry);
206 
207 #define	RLE_RESERVED		0x0001	/* Reserved by the parent bus. */
208 #define	RLE_ALLOCATED		0x0002	/* Reserved resource is allocated. */
209 #define	RLE_PREFETCH		0x0004	/* Resource is a prefetch range. */
210 
211 void	resource_list_init(struct resource_list *rl);
212 void	resource_list_free(struct resource_list *rl);
213 struct resource_list_entry *
214 	resource_list_add(struct resource_list *rl,
215 			  int type, int rid,
216 			  rman_res_t start, rman_res_t end, rman_res_t count);
217 struct resource_list_entry*
218 	resource_list_find(struct resource_list *rl,
219 			   int type, int rid);
220 
221 typedef void (*add_res_callback_t)(const char *devclass_name, int type, int unit, rman_res_t start, rman_res_t end,
222 	rman_res_t count);
223 void machine_resource_init(add_res_callback_t callback);
224 
225 /*
226  * The root bus, to which all top-level busses are attached.
227  */
228 extern device_t root_bus;
229 extern devclass_t root_devclass;
230 void    root_bus_configure(void);
231 
232 extern device_t nexus;
233 
234 /*
235  * Useful functions for implementing busses.
236  */
237 
238 struct _cpuset;
239 
240 int     bus_generic_attach(device_t dev);
241 
242 device_t
243         bus_generic_add_child(device_t dev, u_int order, const char *name,
244                               int unit);
245 int     bus_generic_child_present(device_t dev, device_t child);
246 
247 int     bus_generic_detach(device_t dev);
248 void    bus_generic_driver_added(device_t dev, driver_t *driver);
249 int     bus_generic_get_domain(device_t dev, device_t child, int *domain);
250 
251 void    bus_generic_new_pass(device_t dev);
252 int     bus_print_child_header(device_t dev, device_t child);
253 int     bus_print_child_domain(device_t dev, device_t child);
254 int     bus_print_child_footer(device_t dev, device_t child);
255 int     bus_generic_print_child(device_t dev, device_t child);
256 int     bus_generic_probe(device_t dev);
257 int     bus_generic_read_ivar(device_t dev, device_t child, int which,
258                               uintptr_t *result);
259 int     bus_generic_resume(device_t dev);
260 int     bus_generic_resume_child(device_t dev, device_t child);
261 
262 int     bus_generic_shutdown(device_t dev);
263 int     bus_generic_suspend(device_t dev);
264 int     bus_generic_suspend_child(device_t dev, device_t child);
265 
266 int     bus_generic_write_ivar(device_t dev, device_t child, int which,
267                                uintptr_t value);
268 int     bus_helper_reset_post(device_t dev, int flags);
269 int     bus_helper_reset_prepare(device_t dev, int flags);
270 int     bus_null_rescan(device_t dev);
271 
272 struct	resource *bus_alloc_resource(device_t dev, int type, int *rid,
273 				     rman_res_t start, rman_res_t end,
274 				     rman_res_t count, u_int flags);
275 int     bus_generic_resume(device_t dev);
276 int     bus_generic_resume_child(device_t dev, device_t child);
277 
278 int   bus_child_location_str(device_t child, char *buf, size_t buflen);
279 
280 static __inline struct resource *
bus_alloc_resource_any(device_t dev,int type,int * rid,u_int flags)281 bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
282 {
283 	return (bus_alloc_resource(dev, type, rid, 0, ~0, 1, flags));
284 }
285 
286 /*
287  * Access functions for device.
288  */
289 device_t	device_add_child(device_t dev, const char *name, int unit);
290 device_t	device_add_child_ordered(device_t dev, u_int order,
291 					 const char *name, int unit);
292 void	device_busy(device_t dev);
293 int	device_delete_child(device_t dev, device_t child);
294 int	device_delete_children(device_t dev);
295 int	device_attach(device_t dev);
296 int	device_detach(device_t dev);
297 void	device_disable(device_t dev);
298 void	device_enable(device_t dev);
299 device_t	device_find_child(device_t dev, const char *classname,
300 				  int unit);
301 const char	*device_get_desc(device_t dev);
302 devclass_t	device_get_devclass(device_t dev);
303 driver_t	*device_get_driver(device_t dev);
304 u_int32_t	device_get_flags(device_t dev);
305 device_t	device_get_parent(device_t dev);
306 int	device_get_children(device_t dev, device_t **listp, int *countp);
307 void	*device_get_ivars(device_t dev);
308 void	device_set_ivars(device_t dev, void *ivars);
309 const	char *device_get_name(device_t dev);
310 const	char *device_get_nameunit(device_t dev);
311 void	*device_get_softc(device_t dev);
312 device_state_t	device_get_state(device_t dev);
313 int	device_get_unit(device_t dev);
314 struct sysctl_ctx_list *device_get_sysctl_ctx(device_t dev);
315 struct sysctl_oid *device_get_sysctl_tree(device_t dev);
316 int	device_is_alive(device_t dev);	/* did probe succeed? */
317 int	device_is_attached(device_t dev);	/* did attach succeed? */
318 int	device_is_enabled(device_t dev);
319 int	device_is_suspended(device_t dev);
320 int	device_is_quiet(device_t dev);
321 device_t device_lookup_by_name(const char *name);
322 int	device_print_prettyname(device_t dev);
323 int	device_printf(device_t dev, const char *, ...) __printflike(2, 3);
324 int	device_probe(device_t dev);
325 int	device_probe_and_attach(device_t dev);
326 int	device_probe_child(device_t bus, device_t dev);
327 int	device_quiesce(device_t dev);
328 void	device_quiet(device_t dev);
329 void	device_set_desc(device_t dev, const char* desc);
330 void	device_set_desc_copy(device_t dev, const char* desc);
331 int	device_set_devclass(device_t dev, const char *classname);
332 int	device_set_devclass_fixed(device_t dev, const char *classname);
333 bool	device_is_devclass_fixed(device_t dev);
334 int	device_set_driver(device_t dev, driver_t *driver);
335 void	device_set_flags(device_t dev, u_int32_t flags);
336 void	device_set_softc(device_t dev, void *softc);
337 void	device_free_softc(void *softc);
338 void	device_claim_softc(device_t dev);
339 int	device_set_unit(device_t dev, int unit);	/* XXX DONT USE XXX */
340 int	device_shutdown(device_t dev);
341 void	device_unbusy(device_t dev);
342 void	device_verbose(device_t dev);
343 
344 /* port for interrupt setup and teardown */
345 int bus_setup_intr(int irq, int flags, driver_intr_t *intr, void *arg);
346 int bus_teardown_intr(int irq, void *arg);
347 
348 /*
349  * Access functions for devclass.
350  */
351 int		devclass_add_driver(devclass_t dc, driver_t *driver,
352 				    int pass, devclass_t *dcp);
353 devclass_t	devclass_create(const char *classname);
354 int		devclass_delete_driver(devclass_t busclass, driver_t *driver);
355 devclass_t	devclass_find(const char *classname);
356 const char	*devclass_get_name(devclass_t dc);
357 device_t	devclass_get_device(devclass_t dc, int unit);
358 void	*devclass_get_softc(devclass_t dc, int unit);
359 int	devclass_get_devices(devclass_t dc, device_t **listp, int *countp);
360 int	devclass_get_drivers(devclass_t dc, driver_t ***listp, int *countp);
361 int	devclass_get_count(devclass_t dc);
362 int	devclass_get_maxunit(devclass_t dc);
363 int	devclass_find_free_unit(devclass_t dc, int unit);
364 void	devclass_set_parent(devclass_t dc, devclass_t pdc);
365 devclass_t	devclass_get_parent(devclass_t dc);
366 
367 /*
368  * Functions for maintaining and checking consistency of
369  * bus information exported to userspace.
370  */
371 int     bus_data_generation_check(int generation);
372 void    bus_data_generation_update(void);
373 
374 /**
375  * Some convenience defines for probe routines to return.  These are just
376  * suggested values, and there's nothing magical about them.
377  * BUS_PROBE_SPECIFIC is for devices that cannot be reprobed, and that no
378  * possible other driver may exist (typically legacy drivers who don't fallow
379  * all the rules, or special needs drivers).  BUS_PROBE_VENDOR is the
380  * suggested value that vendor supplied drivers use.  This is for source or
381  * binary drivers that are not yet integrated into the FreeBSD tree.  Its use
382  * in the base OS is prohibited.  BUS_PROBE_DEFAULT is the normal return value
383  * for drivers to use.  It is intended that nearly all of the drivers in the
384  * tree should return this value.  BUS_PROBE_LOW_PRIORITY are for drivers that
385  * have special requirements like when there are two drivers that support
386  * overlapping series of hardware devices.  In this case the one that supports
387  * the older part of the line would return this value, while the one that
388  * supports the newer ones would return BUS_PROBE_DEFAULT.  BUS_PROBE_GENERIC
389  * is for drivers that wish to have a generic form and a specialized form,
390  * like is done with the pci bus and the acpi pci bus.  BUS_PROBE_HOOVER is
391  * for those busses that implement a generic device place-holder for devices on
392  * the bus that have no more specific driver for them (aka ugen).
393  * BUS_PROBE_NOWILDCARD or lower means that the device isn't really bidding
394  * for a device node, but accepts only devices that its parent has told it
395  * use this driver.
396  */
397 #define BUS_PROBE_SPECIFIC	0	/* Only I can use this device */
398 #define BUS_PROBE_VENDOR	(-10)	/* Vendor supplied driver */
399 #define BUS_PROBE_DEFAULT	(-20)	/* Base OS default driver */
400 #define BUS_PROBE_LOW_PRIORITY	(-40)	/* Older, less desirable drivers */
401 #define BUS_PROBE_GENERIC	(-100)	/* generic driver for dev */
402 #define BUS_PROBE_HOOVER	(-1000000) /* Driver for any dev on bus */
403 #define BUS_PROBE_NOWILDCARD	(-2000000000) /* No wildcard device matches */
404 
405 /**
406  * During boot, the device tree is scanned multiple times.  Each scan,
407  * or pass, drivers may be attached to devices.  Each driver
408  * attachment is assigned a pass number.  Drivers may only probe and
409  * attach to devices if their pass number is less than or equal to the
410  * current system-wide pass number.  The default pass is the last pass
411  * and is used by most drivers.  Drivers needed by the scheduler are
412  * probed in earlier passes.
413  */
414 #define	BUS_PASS_ROOT		0	/* Used to attach root0. */
415 #define	BUS_PASS_BUS		10	/* Busses and bridges. */
416 #define	BUS_PASS_CPU		20	/* CPU devices. */
417 #define	BUS_PASS_RESOURCE	30	/* Resource discovery. */
418 #define	BUS_PASS_INTERRUPT	40	/* Interrupt controllers. */
419 #define	BUS_PASS_TIMER		50	/* Timers and clocks. */
420 #define	BUS_PASS_SCHEDULER	60	/* Start scheduler. */
421 #define	BUS_PASS_DEFAULT	INT_MAX /* Everything else. */
422 
423 #define	BUS_PASS_ORDER_FIRST	0
424 #define	BUS_PASS_ORDER_EARLY	2
425 #define	BUS_PASS_ORDER_MIDDLE	5
426 #define	BUS_PASS_ORDER_LATE	7
427 #define	BUS_PASS_ORDER_LAST	9
428 
429 extern int bus_current_pass;
430 
431 void	bus_set_pass(int pass);
432 
433 /**
434  * Shorthands for constructing method tables.
435  */
436 #define	DEVMETHOD	KOBJMETHOD
437 #define	DEVMETHOD_END	KOBJMETHOD_END
438 
439 /*
440  * Some common device interfaces.
441  */
442 #include "device_if.h"
443 #include "bus_if.h"
444 
445 struct	module;
446 
447 int	driver_module_handler(struct module *, int, void *);
448 
449 /**
450  * Module support for automatically adding drivers to busses.
451  */
452 struct driver_module_data {
453 	int		(*dmd_chainevh)(struct module *, int, void *);
454 	void		*dmd_chainarg;
455 	const char	*dmd_busname;
456 	kobj_class_t	dmd_driver;
457 	devclass_t	*dmd_devclass;
458 	int		dmd_pass;
459 };
460 
461 #define	EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass,	\
462     evh, arg, order, pass)						\
463 									\
464 /*static */struct driver_module_data name##_##busname##_driver_mod = {	\
465 	evh, arg,							\
466 	#busname,							\
467 	(kobj_class_t) &driver,						\
468 	&devclass,							\
469 	pass								\
470 };									\
471 									\
472 /*static */moduledata_t name##_##busname##_mod = {				\
473 	#busname "/" #name,						\
474 	driver_module_handler,						\
475 	&name##_##busname##_driver_mod					\
476 };									\
477 DECLARE_MODULE(name##_##busname, name##_##busname##_mod,		\
478 	       SI_SUB_DRIVERS, order)
479 
480 #define	EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg, pass) \
481 	EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass,	\
482 	    evh, arg, SI_ORDER_MIDDLE, pass)
483 
484 #define	DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg,\
485     order)								\
486 	EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass,	\
487 	    evh, arg, order, BUS_PASS_DEFAULT)
488 
489 #define	DRIVER_MODULE(name, busname, driver, devclass, evh, arg)	\
490 	EARLY_DRIVER_MODULE(name, busname, driver, devclass, evh, arg,	\
491 	    BUS_PASS_DEFAULT)
492 
493 /**
494  * Generic ivar accessor generation macros for bus drivers
495  */
496 #define __BUS_ACCESSOR(varp, var, ivarp, ivar, type)			\
497 									\
498 static __inline type varp ## _get_ ## var(device_t dev)			\
499 {									\
500 	uintptr_t v;							\
501 	int e;								\
502 	e = BUS_READ_IVAR(device_get_parent(dev), dev,			\
503 	    ivarp ## _IVAR_ ## ivar, &v);				\
504 	if (e != 0) {							\
505 		device_printf(dev, "failed to read ivar "		\
506 		    __XSTRING(ivarp ## _IVAR_ ## ivar) " on bus %s, "	\
507 		    "error = %d\n",					\
508 		    device_get_nameunit(device_get_parent(dev)), e);	\
509 	}								\
510 	return ((type) v);						\
511 }									\
512 									\
513 static __inline void varp ## _set_ ## var(device_t dev, type t)		\
514 {									\
515 	uintptr_t v = (uintptr_t) t;					\
516 	int e;								\
517 	e = BUS_WRITE_IVAR(device_get_parent(dev), dev,			\
518 	    ivarp ## _IVAR_ ## ivar, v);				\
519 	if (e != 0) {							\
520 		device_printf(dev, "failed to write ivar "		\
521 		    __XSTRING(ivarp ## _IVAR_ ## ivar) " on bus %s, "	\
522 		    "error = %d\n",					\
523 		    device_get_nameunit(device_get_parent(dev)), e);	\
524 	}								\
525 }
526 
527 /**
528  * Shorthand macros, taking resource argument
529  * Generated with sys/tools/bus_macro.sh
530  */
531 
532 #define bus_barrier(r, o, l, f) \
533 	bus_space_barrier((r)->r_bustag, (r)->r_bushandle, (o), (l), (f))
534 #define bus_poke_1(r, o, v) \
535 	bus_space_poke_1((r)->r_bustag, (r)->r_bushandle, (o), (v))
536 #define bus_peek_1(r, o, vp) \
537 	bus_space_peek_1((r)->r_bustag, (r)->r_bushandle, (o), (vp))
538 #define bus_read_1(r, o) \
539 	bus_space_read_1((r)->r_bustag, (r)->r_bushandle, (o))
540 #define bus_read_multi_1(r, o, d, c) \
541 	bus_space_read_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
542 #define bus_read_region_1(r, o, d, c) \
543 	bus_space_read_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
544 #define bus_set_multi_1(r, o, v, c) \
545 	bus_space_set_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
546 #define bus_set_region_1(r, o, v, c) \
547 	bus_space_set_region_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
548 #define bus_write_1(r, o, v) \
549 	bus_space_write_1((r)->r_bustag, (r)->r_bushandle, (o), (v))
550 #define bus_write_multi_1(r, o, d, c) \
551 	bus_space_write_multi_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
552 #define bus_write_region_1(r, o, d, c) \
553 	bus_space_write_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
554 #define bus_read_stream_1(r, o) \
555 	bus_space_read_stream_1((r)->r_bustag, (r)->r_bushandle, (o))
556 #define bus_read_multi_stream_1(r, o, d, c) \
557 	bus_space_read_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
558 #define bus_read_region_stream_1(r, o, d, c) \
559 	bus_space_read_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
560 #define bus_set_multi_stream_1(r, o, v, c) \
561 	bus_space_set_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
562 #define bus_set_region_stream_1(r, o, v, c) \
563 	bus_space_set_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
564 #define bus_write_stream_1(r, o, v) \
565 	bus_space_write_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (v))
566 #define bus_write_multi_stream_1(r, o, d, c) \
567 	bus_space_write_multi_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
568 #define bus_write_region_stream_1(r, o, d, c) \
569 	bus_space_write_region_stream_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
570 #define bus_poke_2(r, o, v) \
571 	bus_space_poke_2((r)->r_bustag, (r)->r_bushandle, (o), (v))
572 #define bus_peek_2(r, o, vp) \
573 	bus_space_peek_2((r)->r_bustag, (r)->r_bushandle, (o), (vp))
574 #define bus_read_2(r, o) \
575 	bus_space_read_2((r)->r_bustag, (r)->r_bushandle, (o))
576 #define bus_read_multi_2(r, o, d, c) \
577 	bus_space_read_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
578 #define bus_read_region_2(r, o, d, c) \
579 	bus_space_read_region_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
580 #define bus_set_multi_2(r, o, v, c) \
581 	bus_space_set_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
582 #define bus_set_region_2(r, o, v, c) \
583 	bus_space_set_region_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
584 #define bus_write_2(r, o, v) \
585 	bus_space_write_2((r)->r_bustag, (r)->r_bushandle, (o), (v))
586 #define bus_write_multi_2(r, o, d, c) \
587 	bus_space_write_multi_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
588 #define bus_write_region_2(r, o, d, c) \
589 	bus_space_write_region_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
590 #define bus_read_stream_2(r, o) \
591 	bus_space_read_stream_2((r)->r_bustag, (r)->r_bushandle, (o))
592 #define bus_read_multi_stream_2(r, o, d, c) \
593 	bus_space_read_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
594 #define bus_read_region_stream_2(r, o, d, c) \
595 	bus_space_read_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
596 #define bus_set_multi_stream_2(r, o, v, c) \
597 	bus_space_set_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
598 #define bus_set_region_stream_2(r, o, v, c) \
599 	bus_space_set_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
600 #define bus_write_stream_2(r, o, v) \
601 	bus_space_write_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (v))
602 #define bus_write_multi_stream_2(r, o, d, c) \
603 	bus_space_write_multi_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
604 #define bus_write_region_stream_2(r, o, d, c) \
605 	bus_space_write_region_stream_2((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
606 #define bus_poke_4(r, o, v) \
607 	bus_space_poke_4((r)->r_bustag, (r)->r_bushandle, (o), (v))
608 #define bus_peek_4(r, o, vp) \
609 	bus_space_peek_4((r)->r_bustag, (r)->r_bushandle, (o), (vp))
610 #define bus_read_4(r, o) \
611 	bus_space_read_4((r)->r_bustag, (r)->r_bushandle, (o))
612 #define bus_read_multi_4(r, o, d, c) \
613 	bus_space_read_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
614 #define bus_read_region_4(r, o, d, c) \
615 	bus_space_read_region_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
616 #define bus_set_multi_4(r, o, v, c) \
617 	bus_space_set_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
618 #define bus_set_region_4(r, o, v, c) \
619 	bus_space_set_region_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
620 #define bus_write_4(r, o, v) \
621 	bus_space_write_4((r)->r_bustag, (r)->r_bushandle, (o), (v))
622 #define bus_write_multi_4(r, o, d, c) \
623 	bus_space_write_multi_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
624 #define bus_write_region_4(r, o, d, c) \
625 	bus_space_write_region_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
626 #define bus_read_stream_4(r, o) \
627 	bus_space_read_stream_4((r)->r_bustag, (r)->r_bushandle, (o))
628 #define bus_read_multi_stream_4(r, o, d, c) \
629 	bus_space_read_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
630 #define bus_read_region_stream_4(r, o, d, c) \
631 	bus_space_read_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
632 #define bus_set_multi_stream_4(r, o, v, c) \
633 	bus_space_set_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
634 #define bus_set_region_stream_4(r, o, v, c) \
635 	bus_space_set_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
636 #define bus_write_stream_4(r, o, v) \
637 	bus_space_write_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (v))
638 #define bus_write_multi_stream_4(r, o, d, c) \
639 	bus_space_write_multi_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
640 #define bus_write_region_stream_4(r, o, d, c) \
641 	bus_space_write_region_stream_4((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
642 #define bus_poke_8(r, o, v) \
643 	bus_space_poke_8((r)->r_bustag, (r)->r_bushandle, (o), (v))
644 #define bus_peek_8(r, o, vp) \
645 	bus_space_peek_8((r)->r_bustag, (r)->r_bushandle, (o), (vp))
646 #define bus_read_8(r, o) \
647 	bus_space_read_8((r)->r_bustag, (r)->r_bushandle, (o))
648 #define bus_read_multi_8(r, o, d, c) \
649 	bus_space_read_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
650 #define bus_read_region_8(r, o, d, c) \
651 	bus_space_read_region_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
652 #define bus_set_multi_8(r, o, v, c) \
653 	bus_space_set_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
654 #define bus_set_region_8(r, o, v, c) \
655 	bus_space_set_region_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
656 #define bus_write_8(r, o, v) \
657 	bus_space_write_8((r)->r_bustag, (r)->r_bushandle, (o), (v))
658 #define bus_write_multi_8(r, o, d, c) \
659 	bus_space_write_multi_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
660 #define bus_write_region_8(r, o, d, c) \
661 	bus_space_write_region_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
662 #define bus_read_stream_8(r, o) \
663 	bus_space_read_stream_8((r)->r_bustag, (r)->r_bushandle, (o))
664 #define bus_read_multi_stream_8(r, o, d, c) \
665 	bus_space_read_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
666 #define bus_read_region_stream_8(r, o, d, c) \
667 	bus_space_read_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
668 #define bus_set_multi_stream_8(r, o, v, c) \
669 	bus_space_set_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
670 #define bus_set_region_stream_8(r, o, v, c) \
671 	bus_space_set_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v), (c))
672 #define bus_write_stream_8(r, o, v) \
673 	bus_space_write_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (v))
674 #define bus_write_multi_stream_8(r, o, d, c) \
675 	bus_space_write_multi_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
676 #define bus_write_region_stream_8(r, o, d, c) \
677 	bus_space_write_region_stream_8((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
678 
679 #endif /* !_SYS_BUS_H_ */
680