xref: /freebsd/sys/arm/include/bus.h (revision 2737497b8398ee7f0a3de051b5b0ffac8995fdfe)
16fc729afSOlivier Houchard /*	$NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $	*/
26fc729afSOlivier Houchard 
36fc729afSOlivier Houchard /*-
46fc729afSOlivier Houchard  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
56fc729afSOlivier Houchard  * All rights reserved.
66fc729afSOlivier Houchard  *
76fc729afSOlivier Houchard  * This code is derived from software contributed to The NetBSD Foundation
86fc729afSOlivier Houchard  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
96fc729afSOlivier Houchard  * NASA Ames Research Center.
106fc729afSOlivier Houchard  *
116fc729afSOlivier Houchard  * Redistribution and use in source and binary forms, with or without
126fc729afSOlivier Houchard  * modification, are permitted provided that the following conditions
136fc729afSOlivier Houchard  * are met:
146fc729afSOlivier Houchard  * 1. Redistributions of source code must retain the above copyright
156fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer.
166fc729afSOlivier Houchard  * 2. Redistributions in binary form must reproduce the above copyright
176fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer in the
186fc729afSOlivier Houchard  *    documentation and/or other materials provided with the distribution.
196fc729afSOlivier Houchard  *
206fc729afSOlivier Houchard  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
216fc729afSOlivier Houchard  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
226fc729afSOlivier Houchard  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
236fc729afSOlivier Houchard  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
246fc729afSOlivier Houchard  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
256fc729afSOlivier Houchard  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
266fc729afSOlivier Houchard  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
276fc729afSOlivier Houchard  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
286fc729afSOlivier Houchard  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
296fc729afSOlivier Houchard  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
306fc729afSOlivier Houchard  * POSSIBILITY OF SUCH DAMAGE.
316fc729afSOlivier Houchard  */
326fc729afSOlivier Houchard 
33d8315c79SWarner Losh /*-
346fc729afSOlivier Houchard  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
356fc729afSOlivier Houchard  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
366fc729afSOlivier Houchard  *
376fc729afSOlivier Houchard  * Redistribution and use in source and binary forms, with or without
386fc729afSOlivier Houchard  * modification, are permitted provided that the following conditions
396fc729afSOlivier Houchard  * are met:
406fc729afSOlivier Houchard  * 1. Redistributions of source code must retain the above copyright
416fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer.
426fc729afSOlivier Houchard  * 2. Redistributions in binary form must reproduce the above copyright
436fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer in the
446fc729afSOlivier Houchard  *    documentation and/or other materials provided with the distribution.
456fc729afSOlivier Houchard  * 3. All advertising materials mentioning features or use of this software
466fc729afSOlivier Houchard  *    must display the following acknowledgement:
476fc729afSOlivier Houchard  *      This product includes software developed by Christopher G. Demetriou
486fc729afSOlivier Houchard  *	for the NetBSD Project.
496fc729afSOlivier Houchard  * 4. The name of the author may not be used to endorse or promote products
506fc729afSOlivier Houchard  *    derived from this software without specific prior written permission
516fc729afSOlivier Houchard  *
526fc729afSOlivier Houchard  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
536fc729afSOlivier Houchard  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
546fc729afSOlivier Houchard  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
556fc729afSOlivier Houchard  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
566fc729afSOlivier Houchard  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
576fc729afSOlivier Houchard  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
586fc729afSOlivier Houchard  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
596fc729afSOlivier Houchard  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
606fc729afSOlivier Houchard  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
616fc729afSOlivier Houchard  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
626fc729afSOlivier Houchard  *
636fc729afSOlivier Houchard  * $FreeBSD$
646fc729afSOlivier Houchard  */
656fc729afSOlivier Houchard 
666fc729afSOlivier Houchard #ifndef _MACHINE_BUS_H_
676fc729afSOlivier Houchard #define _MACHINE_BUS_H_
686fc729afSOlivier Houchard 
6906db52b6SWarner Losh #include <machine/_bus.h>
706fc729afSOlivier Houchard 
716fc729afSOlivier Houchard /*
726fc729afSOlivier Houchard  *	int bus_space_map  (bus_space_tag_t t, bus_addr_t addr,
736fc729afSOlivier Houchard  *	    bus_size_t size, int flags, bus_space_handle_t *bshp);
746fc729afSOlivier Houchard  *
756fc729afSOlivier Houchard  * Map a region of bus space.
766fc729afSOlivier Houchard  */
776fc729afSOlivier Houchard 
786fc729afSOlivier Houchard #define	BUS_SPACE_MAP_CACHEABLE		0x01
796fc729afSOlivier Houchard #define	BUS_SPACE_MAP_LINEAR		0x02
806fc729afSOlivier Houchard #define	BUS_SPACE_MAP_PREFETCHABLE     	0x04
816fc729afSOlivier Houchard 
826fc729afSOlivier Houchard struct bus_space {
836fc729afSOlivier Houchard 	/* cookie */
844098ccafSIan Lepore 	void		*bs_privdata;
856fc729afSOlivier Houchard 
866fc729afSOlivier Houchard 	/* mapping/unmapping */
874098ccafSIan Lepore 	int		(*bs_map) (bus_space_tag_t, bus_addr_t, bus_size_t,
886fc729afSOlivier Houchard 			    int, bus_space_handle_t *);
894098ccafSIan Lepore 	void		(*bs_unmap) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
904098ccafSIan Lepore 	int		(*bs_subregion) (bus_space_tag_t, bus_space_handle_t,
916fc729afSOlivier Houchard 			    bus_size_t, bus_size_t, bus_space_handle_t *);
926fc729afSOlivier Houchard 
936fc729afSOlivier Houchard 	/* allocation/deallocation */
944098ccafSIan Lepore 	int		(*bs_alloc) (bus_space_tag_t, bus_addr_t, bus_addr_t,
956fc729afSOlivier Houchard 			    bus_size_t, bus_size_t, bus_size_t, int,
966fc729afSOlivier Houchard 			    bus_addr_t *, bus_space_handle_t *);
974098ccafSIan Lepore 	void		(*bs_free) (bus_space_tag_t, bus_space_handle_t,
986fc729afSOlivier Houchard 			    bus_size_t);
996fc729afSOlivier Houchard 
1006fc729afSOlivier Houchard 	/* get kernel virtual address */
1016fc729afSOlivier Houchard 	/* barrier */
1024098ccafSIan Lepore 	void		(*bs_barrier) (bus_space_tag_t, bus_space_handle_t,
1036fc729afSOlivier Houchard 			    bus_size_t, bus_size_t, int);
1046fc729afSOlivier Houchard 
1056fc729afSOlivier Houchard 	/* read (single) */
1064098ccafSIan Lepore 	uint8_t		(*bs_r_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
1074098ccafSIan Lepore 	uint16_t	(*bs_r_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
1084098ccafSIan Lepore 	uint32_t	(*bs_r_4) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
1094098ccafSIan Lepore 	uint64_t	(*bs_r_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
1106fc729afSOlivier Houchard 
1116fc729afSOlivier Houchard 	/* read multiple */
1124098ccafSIan Lepore 	void		(*bs_rm_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
1134098ccafSIan Lepore 	    uint8_t *, bus_size_t);
1144098ccafSIan Lepore 	void		(*bs_rm_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
1154098ccafSIan Lepore 	    uint16_t *, bus_size_t);
1164098ccafSIan Lepore 	void		(*bs_rm_4) (bus_space_tag_t, bus_space_handle_t,
1174098ccafSIan Lepore 			    bus_size_t, uint32_t *, bus_size_t);
1184098ccafSIan Lepore 	void		(*bs_rm_8) (bus_space_tag_t, bus_space_handle_t,
1194098ccafSIan Lepore 			    bus_size_t, uint64_t *, bus_size_t);
1206fc729afSOlivier Houchard 
1216fc729afSOlivier Houchard 	/* read region */
1224098ccafSIan Lepore 	void		(*bs_rr_1) (bus_space_tag_t, bus_space_handle_t,
1234098ccafSIan Lepore 			    bus_size_t, uint8_t *, bus_size_t);
1244098ccafSIan Lepore 	void		(*bs_rr_2) (bus_space_tag_t, bus_space_handle_t,
1254098ccafSIan Lepore 			    bus_size_t, uint16_t *, bus_size_t);
1264098ccafSIan Lepore 	void		(*bs_rr_4) (bus_space_tag_t, bus_space_handle_t,
1274098ccafSIan Lepore 			    bus_size_t, uint32_t *, bus_size_t);
1284098ccafSIan Lepore 	void		(*bs_rr_8) (bus_space_tag_t, bus_space_handle_t,
1294098ccafSIan Lepore 			    bus_size_t, uint64_t *, bus_size_t);
1306fc729afSOlivier Houchard 
1316fc729afSOlivier Houchard 	/* write (single) */
1324098ccafSIan Lepore 	void		(*bs_w_1) (bus_space_tag_t, bus_space_handle_t,
1334098ccafSIan Lepore 			    bus_size_t, uint8_t);
1344098ccafSIan Lepore 	void		(*bs_w_2) (bus_space_tag_t, bus_space_handle_t,
1354098ccafSIan Lepore 			    bus_size_t, uint16_t);
1364098ccafSIan Lepore 	void		(*bs_w_4) (bus_space_tag_t, bus_space_handle_t,
1374098ccafSIan Lepore 			    bus_size_t, uint32_t);
1384098ccafSIan Lepore 	void		(*bs_w_8) (bus_space_tag_t, bus_space_handle_t,
1394098ccafSIan Lepore 			    bus_size_t, uint64_t);
1406fc729afSOlivier Houchard 
1416fc729afSOlivier Houchard 	/* write multiple */
1424098ccafSIan Lepore 	void		(*bs_wm_1) (bus_space_tag_t, bus_space_handle_t,
1434098ccafSIan Lepore 			    bus_size_t, const uint8_t *, bus_size_t);
1444098ccafSIan Lepore 	void		(*bs_wm_2) (bus_space_tag_t, bus_space_handle_t,
1454098ccafSIan Lepore 			    bus_size_t, const uint16_t *, bus_size_t);
1464098ccafSIan Lepore 	void		(*bs_wm_4) (bus_space_tag_t, bus_space_handle_t,
1474098ccafSIan Lepore 			    bus_size_t, const uint32_t *, bus_size_t);
1484098ccafSIan Lepore 	void		(*bs_wm_8) (bus_space_tag_t, bus_space_handle_t,
1494098ccafSIan Lepore 			    bus_size_t, const uint64_t *, bus_size_t);
1506fc729afSOlivier Houchard 
1516fc729afSOlivier Houchard 	/* write region */
1524098ccafSIan Lepore 	void		(*bs_wr_1) (bus_space_tag_t, bus_space_handle_t,
1534098ccafSIan Lepore 			    bus_size_t, const uint8_t *, bus_size_t);
1544098ccafSIan Lepore 	void		(*bs_wr_2) (bus_space_tag_t, bus_space_handle_t,
1554098ccafSIan Lepore 			    bus_size_t, const uint16_t *, bus_size_t);
1564098ccafSIan Lepore 	void		(*bs_wr_4) (bus_space_tag_t, bus_space_handle_t,
1574098ccafSIan Lepore 			    bus_size_t, const uint32_t *, bus_size_t);
1584098ccafSIan Lepore 	void		(*bs_wr_8) (bus_space_tag_t, bus_space_handle_t,
1594098ccafSIan Lepore 			    bus_size_t, const uint64_t *, bus_size_t);
1606fc729afSOlivier Houchard 
1616fc729afSOlivier Houchard 	/* set multiple */
1624098ccafSIan Lepore 	void		(*bs_sm_1) (bus_space_tag_t, bus_space_handle_t,
1634098ccafSIan Lepore 			    bus_size_t, uint8_t, bus_size_t);
1644098ccafSIan Lepore 	void		(*bs_sm_2) (bus_space_tag_t, bus_space_handle_t,
1654098ccafSIan Lepore 			    bus_size_t, uint16_t, bus_size_t);
1664098ccafSIan Lepore 	void		(*bs_sm_4) (bus_space_tag_t, bus_space_handle_t,
1674098ccafSIan Lepore 			    bus_size_t, uint32_t, bus_size_t);
1684098ccafSIan Lepore 	void		(*bs_sm_8) (bus_space_tag_t, bus_space_handle_t,
1694098ccafSIan Lepore 			    bus_size_t, uint64_t, bus_size_t);
1706fc729afSOlivier Houchard 
1716fc729afSOlivier Houchard 	/* set region */
1724098ccafSIan Lepore 	void		(*bs_sr_1) (bus_space_tag_t, bus_space_handle_t,
1734098ccafSIan Lepore 			    bus_size_t, uint8_t, bus_size_t);
1744098ccafSIan Lepore 	void		(*bs_sr_2) (bus_space_tag_t, bus_space_handle_t,
1754098ccafSIan Lepore 			    bus_size_t, uint16_t, bus_size_t);
1764098ccafSIan Lepore 	void		(*bs_sr_4) (bus_space_tag_t, bus_space_handle_t,
1774098ccafSIan Lepore 			    bus_size_t, uint32_t, bus_size_t);
1784098ccafSIan Lepore 	void		(*bs_sr_8) (bus_space_tag_t, bus_space_handle_t,
1794098ccafSIan Lepore 			    bus_size_t, uint64_t, bus_size_t);
1806fc729afSOlivier Houchard 
1816fc729afSOlivier Houchard 	/* copy */
1824098ccafSIan Lepore 	void		(*bs_c_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
1836fc729afSOlivier Houchard 			    bus_space_handle_t, bus_size_t, bus_size_t);
1844098ccafSIan Lepore 	void		(*bs_c_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
1856fc729afSOlivier Houchard 			    bus_space_handle_t, bus_size_t, bus_size_t);
1864098ccafSIan Lepore 	void		(*bs_c_4) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
1876fc729afSOlivier Houchard 			    bus_space_handle_t, bus_size_t, bus_size_t);
1884098ccafSIan Lepore 	void		(*bs_c_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
1896fc729afSOlivier Houchard 			    bus_space_handle_t, bus_size_t, bus_size_t);
1906fc729afSOlivier Houchard 
191588a2322SSam Leffler 	/* read stream (single) */
1924098ccafSIan Lepore 	uint8_t	(*bs_r_1_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
1934098ccafSIan Lepore 	uint16_t	(*bs_r_2_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
1944098ccafSIan Lepore 	uint32_t	(*bs_r_4_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
1954098ccafSIan Lepore 	uint64_t	(*bs_r_8_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
196588a2322SSam Leffler 
197588a2322SSam Leffler 	/* read multiple stream */
1984098ccafSIan Lepore 	void		(*bs_rm_1_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
1994098ccafSIan Lepore 	    uint8_t *, bus_size_t);
2004098ccafSIan Lepore 	void		(*bs_rm_2_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
2014098ccafSIan Lepore 	    uint16_t *, bus_size_t);
2024098ccafSIan Lepore 	void		(*bs_rm_4_s) (bus_space_tag_t, bus_space_handle_t,
2034098ccafSIan Lepore 			    bus_size_t, uint32_t *, bus_size_t);
2044098ccafSIan Lepore 	void		(*bs_rm_8_s) (bus_space_tag_t, bus_space_handle_t,
2054098ccafSIan Lepore 			    bus_size_t, uint64_t *, bus_size_t);
206588a2322SSam Leffler 
207588a2322SSam Leffler 	/* read region stream */
2084098ccafSIan Lepore 	void		(*bs_rr_1_s) (bus_space_tag_t, bus_space_handle_t,
2094098ccafSIan Lepore 			    bus_size_t, uint8_t *, bus_size_t);
2104098ccafSIan Lepore 	void		(*bs_rr_2_s) (bus_space_tag_t, bus_space_handle_t,
2114098ccafSIan Lepore 			    bus_size_t, uint16_t *, bus_size_t);
2124098ccafSIan Lepore 	void		(*bs_rr_4_s) (bus_space_tag_t, bus_space_handle_t,
2134098ccafSIan Lepore 			    bus_size_t, uint32_t *, bus_size_t);
2144098ccafSIan Lepore 	void		(*bs_rr_8_s) (bus_space_tag_t, bus_space_handle_t,
2154098ccafSIan Lepore 			    bus_size_t, uint64_t *, bus_size_t);
216588a2322SSam Leffler 
217588a2322SSam Leffler 	/* write stream (single) */
2184098ccafSIan Lepore 	void		(*bs_w_1_s) (bus_space_tag_t, bus_space_handle_t,
2194098ccafSIan Lepore 			    bus_size_t, uint8_t);
2204098ccafSIan Lepore 	void		(*bs_w_2_s) (bus_space_tag_t, bus_space_handle_t,
2214098ccafSIan Lepore 			    bus_size_t, uint16_t);
2224098ccafSIan Lepore 	void		(*bs_w_4_s) (bus_space_tag_t, bus_space_handle_t,
2234098ccafSIan Lepore 			    bus_size_t, uint32_t);
2244098ccafSIan Lepore 	void		(*bs_w_8_s) (bus_space_tag_t, bus_space_handle_t,
2254098ccafSIan Lepore 			    bus_size_t, uint64_t);
226588a2322SSam Leffler 
227588a2322SSam Leffler 	/* write multiple stream */
2284098ccafSIan Lepore 	void		(*bs_wm_1_s) (bus_space_tag_t, bus_space_handle_t,
2294098ccafSIan Lepore 			    bus_size_t, const uint8_t *, bus_size_t);
2304098ccafSIan Lepore 	void		(*bs_wm_2_s) (bus_space_tag_t, bus_space_handle_t,
2314098ccafSIan Lepore 			    bus_size_t, const uint16_t *, bus_size_t);
2324098ccafSIan Lepore 	void		(*bs_wm_4_s) (bus_space_tag_t, bus_space_handle_t,
2334098ccafSIan Lepore 			    bus_size_t, const uint32_t *, bus_size_t);
2344098ccafSIan Lepore 	void		(*bs_wm_8_s) (bus_space_tag_t, bus_space_handle_t,
2354098ccafSIan Lepore 			    bus_size_t, const uint64_t *, bus_size_t);
236588a2322SSam Leffler 
237588a2322SSam Leffler 	/* write region stream */
2384098ccafSIan Lepore 	void		(*bs_wr_1_s) (bus_space_tag_t, bus_space_handle_t,
2394098ccafSIan Lepore 			    bus_size_t, const uint8_t *, bus_size_t);
2404098ccafSIan Lepore 	void		(*bs_wr_2_s) (bus_space_tag_t, bus_space_handle_t,
2414098ccafSIan Lepore 			    bus_size_t, const uint16_t *, bus_size_t);
2424098ccafSIan Lepore 	void		(*bs_wr_4_s) (bus_space_tag_t, bus_space_handle_t,
2434098ccafSIan Lepore 			    bus_size_t, const uint32_t *, bus_size_t);
2444098ccafSIan Lepore 	void		(*bs_wr_8_s) (bus_space_tag_t, bus_space_handle_t,
2454098ccafSIan Lepore 			    bus_size_t, const uint64_t *, bus_size_t);
2466fc729afSOlivier Houchard };
2476fc729afSOlivier Houchard 
2486fc729afSOlivier Houchard 
2496fc729afSOlivier Houchard /*
2506fc729afSOlivier Houchard  * Utility macros; INTERNAL USE ONLY.
2516fc729afSOlivier Houchard  */
2526fc729afSOlivier Houchard #define	__bs_c(a,b)		__CONCAT(a,b)
2536fc729afSOlivier Houchard #define	__bs_opname(op,size)	__bs_c(__bs_c(__bs_c(bs_,op),_),size)
2546fc729afSOlivier Houchard 
2556fc729afSOlivier Houchard #define	__bs_nonsingle(type, sz, t, h, o, a, c)				\
2564098ccafSIan Lepore 	(*(t)->__bs_opname(type,sz))((t), h, o, a, c)
2576fc729afSOlivier Houchard #define	__bs_set(type, sz, t, h, o, v, c)				\
2584098ccafSIan Lepore 	(*(t)->__bs_opname(type,sz))((t), h, o, v, c)
2596fc729afSOlivier Houchard #define	__bs_copy(sz, t, h1, o1, h2, o2, cnt)				\
2604098ccafSIan Lepore 	(*(t)->__bs_opname(c,sz))((t), h1, o1, h2, o2, cnt)
2616fc729afSOlivier Houchard 
262588a2322SSam Leffler #define	__bs_opname_s(op,size)	__bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s)
263588a2322SSam Leffler #define	__bs_rs_s(sz, t, h, o)						\
2644098ccafSIan Lepore 	(*(t)->__bs_opname_s(r,sz))((t), h, o)
265588a2322SSam Leffler #define	__bs_ws_s(sz, t, h, o, v)					\
2664098ccafSIan Lepore 	(*(t)->__bs_opname_s(w,sz))((t), h, o, v)
267588a2322SSam Leffler #define	__bs_nonsingle_s(type, sz, t, h, o, a, c)			\
2684098ccafSIan Lepore 	(*(t)->__bs_opname_s(type,sz))((t), h, o, a, c)
269588a2322SSam Leffler 
2706fc729afSOlivier Houchard 
27116e2dc66SIan Lepore #define __generate_inline_bs_rs(IFN, MBR, TYP)					\
27216e2dc66SIan Lepore 	static inline TYP						\
27316e2dc66SIan Lepore 	IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)	\
27416e2dc66SIan Lepore 	{								\
27516e2dc66SIan Lepore 									\
27616e2dc66SIan Lepore 		if (__predict_true(t->MBR == NULL))			\
27716e2dc66SIan Lepore 			return (*(volatile TYP *)(h + o));		\
27816e2dc66SIan Lepore 		else							\
2794098ccafSIan Lepore 			return (t->MBR(t, h, o));		\
28016e2dc66SIan Lepore 	}
28116e2dc66SIan Lepore 
28216e2dc66SIan Lepore #define __generate_inline_bs_ws(IFN, MBR, TYP)					\
28316e2dc66SIan Lepore 	static inline void						\
28416e2dc66SIan Lepore 	IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, TYP v)\
28516e2dc66SIan Lepore 	{								\
28616e2dc66SIan Lepore 									\
28716e2dc66SIan Lepore 		if (__predict_true(t->MBR == NULL))			\
28816e2dc66SIan Lepore 			*(volatile TYP *)(h + o) = v;			\
28916e2dc66SIan Lepore 		else							\
2904098ccafSIan Lepore 			t->MBR(t, h, o, v);			\
29116e2dc66SIan Lepore 	}
29216e2dc66SIan Lepore 
2936fc729afSOlivier Houchard /*
2946fc729afSOlivier Houchard  * Mapping and unmapping operations.
2956fc729afSOlivier Houchard  */
2966fc729afSOlivier Houchard #define	bus_space_map(t, a, s, c, hp)					\
2974098ccafSIan Lepore 	(*(t)->bs_map)((t), (a), (s), (c), (hp))
2986fc729afSOlivier Houchard #define	bus_space_unmap(t, h, s)					\
2994098ccafSIan Lepore 	(*(t)->bs_unmap)((t), (h), (s))
3006fc729afSOlivier Houchard #define	bus_space_subregion(t, h, o, s, hp)				\
3014098ccafSIan Lepore 	(*(t)->bs_subregion)((t), (h), (o), (s), (hp))
3026fc729afSOlivier Houchard 
3036fc729afSOlivier Houchard 
3046fc729afSOlivier Houchard /*
3056fc729afSOlivier Houchard  * Allocation and deallocation operations.
3066fc729afSOlivier Houchard  */
3076fc729afSOlivier Houchard #define	bus_space_alloc(t, rs, re, s, a, b, c, ap, hp)			\
3084098ccafSIan Lepore 	(*(t)->bs_alloc)((t), (rs), (re), (s), (a), (b),	\
3096fc729afSOlivier Houchard 	    (c), (ap), (hp))
3106fc729afSOlivier Houchard #define	bus_space_free(t, h, s)						\
3114098ccafSIan Lepore 	(*(t)->bs_free)((t), (h), (s))
3126fc729afSOlivier Houchard 
3136fc729afSOlivier Houchard /*
3146fc729afSOlivier Houchard  * Bus barrier operations.
3156fc729afSOlivier Houchard  */
3166fc729afSOlivier Houchard #define	bus_space_barrier(t, h, o, l, f)				\
3174098ccafSIan Lepore 	(*(t)->bs_barrier)((t), (h), (o), (l), (f))
3186fc729afSOlivier Houchard 
3196fc729afSOlivier Houchard #define	BUS_SPACE_BARRIER_READ	0x01
3206fc729afSOlivier Houchard #define	BUS_SPACE_BARRIER_WRITE	0x02
3216fc729afSOlivier Houchard 
3226fc729afSOlivier Houchard /*
3236fc729afSOlivier Houchard  * Bus read (single) operations.
3246fc729afSOlivier Houchard  */
32516e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_1, bs_r_1, uint8_t);
32616e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_2, bs_r_2, uint16_t);
32716e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_4, bs_r_4, uint32_t);
32816e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_8, bs_r_8, uint64_t);
3296fc729afSOlivier Houchard 
33016e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_1, bs_r_1_s, uint8_t);
33116e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_2, bs_r_2_s, uint16_t);
33216e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_4, bs_r_4_s, uint32_t);
33316e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_8, bs_r_8_s, uint64_t);
3346fc729afSOlivier Houchard 
3356fc729afSOlivier Houchard /*
3366fc729afSOlivier Houchard  * Bus read multiple operations.
3376fc729afSOlivier Houchard  */
3386fc729afSOlivier Houchard #define	bus_space_read_multi_1(t, h, o, a, c)				\
3396fc729afSOlivier Houchard 	__bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
3406fc729afSOlivier Houchard #define	bus_space_read_multi_2(t, h, o, a, c)				\
3416fc729afSOlivier Houchard 	__bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
3426fc729afSOlivier Houchard #define	bus_space_read_multi_4(t, h, o, a, c)				\
3436fc729afSOlivier Houchard 	__bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
3446fc729afSOlivier Houchard #define	bus_space_read_multi_8(t, h, o, a, c)				\
3456fc729afSOlivier Houchard 	__bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
3466fc729afSOlivier Houchard 
347588a2322SSam Leffler #define	bus_space_read_multi_stream_1(t, h, o, a, c)			\
348588a2322SSam Leffler 	__bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c))
349588a2322SSam Leffler #define	bus_space_read_multi_stream_2(t, h, o, a, c)			\
350588a2322SSam Leffler 	__bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c))
351588a2322SSam Leffler #define	bus_space_read_multi_stream_4(t, h, o, a, c)			\
352588a2322SSam Leffler 	__bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c))
353588a2322SSam Leffler #define	bus_space_read_multi_stream_8(t, h, o, a, c)			\
354588a2322SSam Leffler 	__bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c))
355588a2322SSam Leffler 
3566fc729afSOlivier Houchard 
3576fc729afSOlivier Houchard /*
3586fc729afSOlivier Houchard  * Bus read region operations.
3596fc729afSOlivier Houchard  */
3606fc729afSOlivier Houchard #define	bus_space_read_region_1(t, h, o, a, c)				\
3616fc729afSOlivier Houchard 	__bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
3626fc729afSOlivier Houchard #define	bus_space_read_region_2(t, h, o, a, c)				\
3636fc729afSOlivier Houchard 	__bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
3646fc729afSOlivier Houchard #define	bus_space_read_region_4(t, h, o, a, c)				\
3656fc729afSOlivier Houchard 	__bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
3666fc729afSOlivier Houchard #define	bus_space_read_region_8(t, h, o, a, c)				\
3676fc729afSOlivier Houchard 	__bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
3686fc729afSOlivier Houchard 
369588a2322SSam Leffler #define	bus_space_read_region_stream_1(t, h, o, a, c)			\
370588a2322SSam Leffler 	__bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c))
371588a2322SSam Leffler #define	bus_space_read_region_stream_2(t, h, o, a, c)			\
372588a2322SSam Leffler 	__bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c))
373588a2322SSam Leffler #define	bus_space_read_region_stream_4(t, h, o, a, c)			\
374588a2322SSam Leffler 	__bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c))
375588a2322SSam Leffler #define	bus_space_read_region_stream_8(t, h, o, a, c)			\
376588a2322SSam Leffler 	__bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c))
377588a2322SSam Leffler 
3786fc729afSOlivier Houchard 
3796fc729afSOlivier Houchard /*
3806fc729afSOlivier Houchard  * Bus write (single) operations.
3816fc729afSOlivier Houchard  */
38216e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_1, bs_w_1, uint8_t);
38316e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_2, bs_w_2, uint16_t);
38416e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_4, bs_w_4, uint32_t);
38516e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_8, bs_w_8, uint64_t);
3866fc729afSOlivier Houchard 
38716e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_1, bs_w_1_s, uint8_t);
38816e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_2, bs_w_2_s, uint16_t);
38916e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_4, bs_w_4_s, uint32_t);
39016e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_8, bs_w_8_s, uint64_t);
391588a2322SSam Leffler 
3926fc729afSOlivier Houchard 
3936fc729afSOlivier Houchard /*
3946fc729afSOlivier Houchard  * Bus write multiple operations.
3956fc729afSOlivier Houchard  */
3966fc729afSOlivier Houchard #define	bus_space_write_multi_1(t, h, o, a, c)				\
3976fc729afSOlivier Houchard 	__bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
3986fc729afSOlivier Houchard #define	bus_space_write_multi_2(t, h, o, a, c)				\
3996fc729afSOlivier Houchard 	__bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
4006fc729afSOlivier Houchard #define	bus_space_write_multi_4(t, h, o, a, c)				\
4016fc729afSOlivier Houchard 	__bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
4026fc729afSOlivier Houchard #define	bus_space_write_multi_8(t, h, o, a, c)				\
4036fc729afSOlivier Houchard 	__bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
4046fc729afSOlivier Houchard 
405588a2322SSam Leffler #define	bus_space_write_multi_stream_1(t, h, o, a, c)			\
406588a2322SSam Leffler 	__bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c))
407588a2322SSam Leffler #define	bus_space_write_multi_stream_2(t, h, o, a, c)			\
408588a2322SSam Leffler 	__bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c))
409588a2322SSam Leffler #define	bus_space_write_multi_stream_4(t, h, o, a, c)			\
410588a2322SSam Leffler 	__bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c))
411588a2322SSam Leffler #define	bus_space_write_multi_stream_8(t, h, o, a, c)			\
412588a2322SSam Leffler 	__bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c))
413588a2322SSam Leffler 
4146fc729afSOlivier Houchard 
4156fc729afSOlivier Houchard /*
4166fc729afSOlivier Houchard  * Bus write region operations.
4176fc729afSOlivier Houchard  */
4186fc729afSOlivier Houchard #define	bus_space_write_region_1(t, h, o, a, c)				\
4196fc729afSOlivier Houchard 	__bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
4206fc729afSOlivier Houchard #define	bus_space_write_region_2(t, h, o, a, c)				\
4216fc729afSOlivier Houchard 	__bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
4226fc729afSOlivier Houchard #define	bus_space_write_region_4(t, h, o, a, c)				\
4236fc729afSOlivier Houchard 	__bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
4246fc729afSOlivier Houchard #define	bus_space_write_region_8(t, h, o, a, c)				\
4256fc729afSOlivier Houchard 	__bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
4266fc729afSOlivier Houchard 
427588a2322SSam Leffler #define	bus_space_write_region_stream_1(t, h, o, a, c)			\
428588a2322SSam Leffler 	__bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c))
429588a2322SSam Leffler #define	bus_space_write_region_stream_2(t, h, o, a, c)			\
430588a2322SSam Leffler 	__bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c))
431588a2322SSam Leffler #define	bus_space_write_region_stream_4(t, h, o, a, c)			\
432588a2322SSam Leffler 	__bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c))
433588a2322SSam Leffler #define	bus_space_write_region_stream_8(t, h, o, a, c)			\
434588a2322SSam Leffler 	__bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c))
435588a2322SSam Leffler 
4366fc729afSOlivier Houchard 
4376fc729afSOlivier Houchard /*
4386fc729afSOlivier Houchard  * Set multiple operations.
4396fc729afSOlivier Houchard  */
4406fc729afSOlivier Houchard #define	bus_space_set_multi_1(t, h, o, v, c)				\
4416fc729afSOlivier Houchard 	__bs_set(sm,1,(t),(h),(o),(v),(c))
4426fc729afSOlivier Houchard #define	bus_space_set_multi_2(t, h, o, v, c)				\
4436fc729afSOlivier Houchard 	__bs_set(sm,2,(t),(h),(o),(v),(c))
4446fc729afSOlivier Houchard #define	bus_space_set_multi_4(t, h, o, v, c)				\
4456fc729afSOlivier Houchard 	__bs_set(sm,4,(t),(h),(o),(v),(c))
4466fc729afSOlivier Houchard #define	bus_space_set_multi_8(t, h, o, v, c)				\
4476fc729afSOlivier Houchard 	__bs_set(sm,8,(t),(h),(o),(v),(c))
4486fc729afSOlivier Houchard 
4496fc729afSOlivier Houchard 
4506fc729afSOlivier Houchard /*
4516fc729afSOlivier Houchard  * Set region operations.
4526fc729afSOlivier Houchard  */
4536fc729afSOlivier Houchard #define	bus_space_set_region_1(t, h, o, v, c)				\
4546fc729afSOlivier Houchard 	__bs_set(sr,1,(t),(h),(o),(v),(c))
4556fc729afSOlivier Houchard #define	bus_space_set_region_2(t, h, o, v, c)				\
4566fc729afSOlivier Houchard 	__bs_set(sr,2,(t),(h),(o),(v),(c))
4576fc729afSOlivier Houchard #define	bus_space_set_region_4(t, h, o, v, c)				\
4586fc729afSOlivier Houchard 	__bs_set(sr,4,(t),(h),(o),(v),(c))
4596fc729afSOlivier Houchard #define	bus_space_set_region_8(t, h, o, v, c)				\
4606fc729afSOlivier Houchard 	__bs_set(sr,8,(t),(h),(o),(v),(c))
4616fc729afSOlivier Houchard 
4626fc729afSOlivier Houchard 
4636fc729afSOlivier Houchard /*
4646fc729afSOlivier Houchard  * Copy operations.
4656fc729afSOlivier Houchard  */
4666fc729afSOlivier Houchard #define	bus_space_copy_region_1(t, h1, o1, h2, o2, c)				\
4676fc729afSOlivier Houchard 	__bs_copy(1, t, h1, o1, h2, o2, c)
4686fc729afSOlivier Houchard #define	bus_space_copy_region_2(t, h1, o1, h2, o2, c)				\
4696fc729afSOlivier Houchard 	__bs_copy(2, t, h1, o1, h2, o2, c)
4706fc729afSOlivier Houchard #define	bus_space_copy_region_4(t, h1, o1, h2, o2, c)				\
4716fc729afSOlivier Houchard 	__bs_copy(4, t, h1, o1, h2, o2, c)
4726fc729afSOlivier Houchard #define	bus_space_copy_region_8(t, h1, o1, h2, o2, c)				\
4736fc729afSOlivier Houchard 	__bs_copy(8, t, h1, o1, h2, o2, c)
4746fc729afSOlivier Houchard 
4756fc729afSOlivier Houchard /*
4766fc729afSOlivier Houchard  * Macros to provide prototypes for all the functions used in the
4776fc729afSOlivier Houchard  * bus_space structure
4786fc729afSOlivier Houchard  */
4796fc729afSOlivier Houchard 
4806fc729afSOlivier Houchard #define bs_map_proto(f)							\
4814098ccafSIan Lepore int	__bs_c(f,_bs_map) (bus_space_tag_t t, bus_addr_t addr,		\
4826fc729afSOlivier Houchard 	    bus_size_t size, int cacheable, bus_space_handle_t *bshp);
4836fc729afSOlivier Houchard 
4846fc729afSOlivier Houchard #define bs_unmap_proto(f)						\
4854098ccafSIan Lepore void	__bs_c(f,_bs_unmap) (bus_space_tag_t t, bus_space_handle_t bsh,		\
486588a2322SSam Leffler 	    bus_size_t size);
4876fc729afSOlivier Houchard 
4886fc729afSOlivier Houchard #define bs_subregion_proto(f)						\
4894098ccafSIan Lepore int	__bs_c(f,_bs_subregion) (bus_space_tag_t t, bus_space_handle_t bsh,	\
4906fc729afSOlivier Houchard 	    bus_size_t offset, bus_size_t size, 			\
4916fc729afSOlivier Houchard 	    bus_space_handle_t *nbshp);
4926fc729afSOlivier Houchard 
4936fc729afSOlivier Houchard #define bs_alloc_proto(f)						\
4944098ccafSIan Lepore int	__bs_c(f,_bs_alloc) (bus_space_tag_t t, bus_addr_t rstart,		\
4956fc729afSOlivier Houchard 	    bus_addr_t rend, bus_size_t size, bus_size_t align,		\
4966fc729afSOlivier Houchard 	    bus_size_t boundary, int cacheable, bus_addr_t *addrp,	\
4976fc729afSOlivier Houchard 	    bus_space_handle_t *bshp);
4986fc729afSOlivier Houchard 
4996fc729afSOlivier Houchard #define bs_free_proto(f)						\
5004098ccafSIan Lepore void	__bs_c(f,_bs_free) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5016fc729afSOlivier Houchard 	    bus_size_t size);
5026fc729afSOlivier Houchard 
5036fc729afSOlivier Houchard #define bs_mmap_proto(f)						\
50489c9c53dSPoul-Henning Kamp int	__bs_c(f,_bs_mmap) (struct cdev *, vm_offset_t, vm_paddr_t *, int);
5056fc729afSOlivier Houchard 
5066fc729afSOlivier Houchard #define bs_barrier_proto(f)						\
5074098ccafSIan Lepore void	__bs_c(f,_bs_barrier) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5086fc729afSOlivier Houchard 	    bus_size_t offset, bus_size_t len, int flags);
5096fc729afSOlivier Houchard 
5106fc729afSOlivier Houchard #define	bs_r_1_proto(f)							\
5114098ccafSIan Lepore uint8_t	__bs_c(f,_bs_r_1) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5126fc729afSOlivier Houchard 		    bus_size_t offset);
5136fc729afSOlivier Houchard 
5146fc729afSOlivier Houchard #define	bs_r_2_proto(f)							\
5154098ccafSIan Lepore uint16_t	__bs_c(f,_bs_r_2) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5166fc729afSOlivier Houchard 		    bus_size_t offset);
5176fc729afSOlivier Houchard 
5186fc729afSOlivier Houchard #define	bs_r_4_proto(f)							\
5194098ccafSIan Lepore uint32_t	__bs_c(f,_bs_r_4) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5206fc729afSOlivier Houchard 		    bus_size_t offset);
5216fc729afSOlivier Houchard 
5226fc729afSOlivier Houchard #define	bs_r_8_proto(f)							\
5234098ccafSIan Lepore uint64_t	__bs_c(f,_bs_r_8) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5246fc729afSOlivier Houchard 		    bus_size_t offset);
5256fc729afSOlivier Houchard 
526588a2322SSam Leffler #define	bs_r_1_s_proto(f)						\
5274098ccafSIan Lepore uint8_t	__bs_c(f,_bs_r_1_s) (bus_space_tag_t t, bus_space_handle_t bsh,	\
528588a2322SSam Leffler 		    bus_size_t offset);
529588a2322SSam Leffler 
530588a2322SSam Leffler #define	bs_r_2_s_proto(f)						\
5314098ccafSIan Lepore uint16_t	__bs_c(f,_bs_r_2_s) (bus_space_tag_t t, bus_space_handle_t bsh,	\
532588a2322SSam Leffler 		    bus_size_t offset);
533588a2322SSam Leffler 
534588a2322SSam Leffler #define	bs_r_4_s_proto(f)						\
5354098ccafSIan Lepore uint32_t	__bs_c(f,_bs_r_4_s) (bus_space_tag_t t, bus_space_handle_t bsh,	\
536588a2322SSam Leffler 		    bus_size_t offset);
537588a2322SSam Leffler 
5386fc729afSOlivier Houchard #define	bs_w_1_proto(f)							\
5394098ccafSIan Lepore void	__bs_c(f,_bs_w_1) (bus_space_tag_t t, bus_space_handle_t bsh,		\
5404098ccafSIan Lepore 	    bus_size_t offset, uint8_t value);
5416fc729afSOlivier Houchard 
5426fc729afSOlivier Houchard #define	bs_w_2_proto(f)							\
5434098ccafSIan Lepore void	__bs_c(f,_bs_w_2) (bus_space_tag_t t, bus_space_handle_t bsh,		\
5444098ccafSIan Lepore 	    bus_size_t offset, uint16_t value);
5456fc729afSOlivier Houchard 
5466fc729afSOlivier Houchard #define	bs_w_4_proto(f)							\
5474098ccafSIan Lepore void	__bs_c(f,_bs_w_4) (bus_space_tag_t t, bus_space_handle_t bsh,		\
5484098ccafSIan Lepore 	    bus_size_t offset, uint32_t value);
5496fc729afSOlivier Houchard 
5506fc729afSOlivier Houchard #define	bs_w_8_proto(f)							\
5514098ccafSIan Lepore void	__bs_c(f,_bs_w_8) (bus_space_tag_t t, bus_space_handle_t bsh,		\
5524098ccafSIan Lepore 	    bus_size_t offset, uint64_t value);
5536fc729afSOlivier Houchard 
554588a2322SSam Leffler #define	bs_w_1_s_proto(f)						\
5554098ccafSIan Lepore void	__bs_c(f,_bs_w_1_s) (bus_space_tag_t t, bus_space_handle_t bsh,		\
5564098ccafSIan Lepore 	    bus_size_t offset, uint8_t value);
557588a2322SSam Leffler 
558588a2322SSam Leffler #define	bs_w_2_s_proto(f)						\
5594098ccafSIan Lepore void	__bs_c(f,_bs_w_2_s) (bus_space_tag_t t, bus_space_handle_t bsh,		\
5604098ccafSIan Lepore 	    bus_size_t offset, uint16_t value);
561588a2322SSam Leffler 
562588a2322SSam Leffler #define	bs_w_4_s_proto(f)						\
5634098ccafSIan Lepore void	__bs_c(f,_bs_w_4_s) (bus_space_tag_t t, bus_space_handle_t bsh,		\
5644098ccafSIan Lepore 	    bus_size_t offset, uint32_t value);
565588a2322SSam Leffler 
5666fc729afSOlivier Houchard #define	bs_rm_1_proto(f)						\
5674098ccafSIan Lepore void	__bs_c(f,_bs_rm_1) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5684098ccafSIan Lepore 	    bus_size_t offset, uint8_t *addr, bus_size_t count);
5696fc729afSOlivier Houchard 
5706fc729afSOlivier Houchard #define	bs_rm_2_proto(f)						\
5714098ccafSIan Lepore void	__bs_c(f,_bs_rm_2) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5724098ccafSIan Lepore 	    bus_size_t offset, uint16_t *addr, bus_size_t count);
5736fc729afSOlivier Houchard 
5746fc729afSOlivier Houchard #define	bs_rm_4_proto(f)						\
5754098ccafSIan Lepore void	__bs_c(f,_bs_rm_4) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5764098ccafSIan Lepore 	    bus_size_t offset, uint32_t *addr, bus_size_t count);
5776fc729afSOlivier Houchard 
5786fc729afSOlivier Houchard #define	bs_rm_8_proto(f)						\
5794098ccafSIan Lepore void	__bs_c(f,_bs_rm_8) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5804098ccafSIan Lepore 	    bus_size_t offset, uint64_t *addr, bus_size_t count);
5816fc729afSOlivier Houchard 
5826fc729afSOlivier Houchard #define	bs_wm_1_proto(f)						\
5834098ccafSIan Lepore void	__bs_c(f,_bs_wm_1) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5844098ccafSIan Lepore 	    bus_size_t offset, const uint8_t *addr, bus_size_t count);
5856fc729afSOlivier Houchard 
5866fc729afSOlivier Houchard #define	bs_wm_2_proto(f)						\
5874098ccafSIan Lepore void	__bs_c(f,_bs_wm_2) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5884098ccafSIan Lepore 	    bus_size_t offset, const uint16_t *addr, bus_size_t count);
5896fc729afSOlivier Houchard 
5906fc729afSOlivier Houchard #define	bs_wm_4_proto(f)						\
5914098ccafSIan Lepore void	__bs_c(f,_bs_wm_4) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5924098ccafSIan Lepore 	    bus_size_t offset, const uint32_t *addr, bus_size_t count);
5936fc729afSOlivier Houchard 
5946fc729afSOlivier Houchard #define	bs_wm_8_proto(f)						\
5954098ccafSIan Lepore void	__bs_c(f,_bs_wm_8) (bus_space_tag_t t, bus_space_handle_t bsh,	\
5964098ccafSIan Lepore 	    bus_size_t offset, const uint64_t *addr, bus_size_t count);
5976fc729afSOlivier Houchard 
5986fc729afSOlivier Houchard #define	bs_rr_1_proto(f)						\
5994098ccafSIan Lepore void	__bs_c(f, _bs_rr_1) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6004098ccafSIan Lepore 	    bus_size_t offset, uint8_t *addr, bus_size_t count);
6016fc729afSOlivier Houchard 
6026fc729afSOlivier Houchard #define	bs_rr_2_proto(f)						\
6034098ccafSIan Lepore void	__bs_c(f, _bs_rr_2) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6044098ccafSIan Lepore 	    bus_size_t offset, uint16_t *addr, bus_size_t count);
6056fc729afSOlivier Houchard 
6066fc729afSOlivier Houchard #define	bs_rr_4_proto(f)						\
6074098ccafSIan Lepore void	__bs_c(f, _bs_rr_4) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6084098ccafSIan Lepore 	    bus_size_t offset, uint32_t *addr, bus_size_t count);
6096fc729afSOlivier Houchard 
6106fc729afSOlivier Houchard #define	bs_rr_8_proto(f)						\
6114098ccafSIan Lepore void	__bs_c(f, _bs_rr_8) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6124098ccafSIan Lepore 	    bus_size_t offset, uint64_t *addr, bus_size_t count);
6136fc729afSOlivier Houchard 
6146fc729afSOlivier Houchard #define	bs_wr_1_proto(f)						\
6154098ccafSIan Lepore void	__bs_c(f, _bs_wr_1) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6164098ccafSIan Lepore 	    bus_size_t offset, const uint8_t *addr, bus_size_t count);
6176fc729afSOlivier Houchard 
6186fc729afSOlivier Houchard #define	bs_wr_2_proto(f)						\
6194098ccafSIan Lepore void	__bs_c(f, _bs_wr_2) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6204098ccafSIan Lepore 	    bus_size_t offset, const uint16_t *addr, bus_size_t count);
6216fc729afSOlivier Houchard 
6226fc729afSOlivier Houchard #define	bs_wr_4_proto(f)						\
6234098ccafSIan Lepore void	__bs_c(f, _bs_wr_4) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6244098ccafSIan Lepore 	    bus_size_t offset, const uint32_t *addr, bus_size_t count);
6256fc729afSOlivier Houchard 
6266fc729afSOlivier Houchard #define	bs_wr_8_proto(f)						\
6274098ccafSIan Lepore void	__bs_c(f, _bs_wr_8) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6284098ccafSIan Lepore 	    bus_size_t offset, const uint64_t *addr, bus_size_t count);
6296fc729afSOlivier Houchard 
6306fc729afSOlivier Houchard #define	bs_sm_1_proto(f)						\
6314098ccafSIan Lepore void	__bs_c(f,_bs_sm_1) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6324098ccafSIan Lepore 	    bus_size_t offset, uint8_t value, bus_size_t count);
6336fc729afSOlivier Houchard 
6346fc729afSOlivier Houchard #define	bs_sm_2_proto(f)						\
6354098ccafSIan Lepore void	__bs_c(f,_bs_sm_2) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6364098ccafSIan Lepore 	    bus_size_t offset, uint16_t value, bus_size_t count);
6376fc729afSOlivier Houchard 
6386fc729afSOlivier Houchard #define	bs_sm_4_proto(f)						\
6394098ccafSIan Lepore void	__bs_c(f,_bs_sm_4) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6404098ccafSIan Lepore 	    bus_size_t offset, uint32_t value, bus_size_t count);
6416fc729afSOlivier Houchard 
6426fc729afSOlivier Houchard #define	bs_sm_8_proto(f)						\
6434098ccafSIan Lepore void	__bs_c(f,_bs_sm_8) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6444098ccafSIan Lepore 	    bus_size_t offset, uint64_t value, bus_size_t count);
6456fc729afSOlivier Houchard 
6466fc729afSOlivier Houchard #define	bs_sr_1_proto(f)						\
6474098ccafSIan Lepore void	__bs_c(f,_bs_sr_1) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6484098ccafSIan Lepore 	    bus_size_t offset, uint8_t value, bus_size_t count);
6496fc729afSOlivier Houchard 
6506fc729afSOlivier Houchard #define	bs_sr_2_proto(f)						\
6514098ccafSIan Lepore void	__bs_c(f,_bs_sr_2) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6524098ccafSIan Lepore 	    bus_size_t offset, uint16_t value, bus_size_t count);
6536fc729afSOlivier Houchard 
6546fc729afSOlivier Houchard #define	bs_sr_4_proto(f)						\
6554098ccafSIan Lepore void	__bs_c(f,_bs_sr_4) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6564098ccafSIan Lepore 	    bus_size_t offset, uint32_t value, bus_size_t count);
6576fc729afSOlivier Houchard 
6586fc729afSOlivier Houchard #define	bs_sr_8_proto(f)						\
6594098ccafSIan Lepore void	__bs_c(f,_bs_sr_8) (bus_space_tag_t t, bus_space_handle_t bsh,	\
6604098ccafSIan Lepore 	    bus_size_t offset, uint64_t value, bus_size_t count);
6616fc729afSOlivier Houchard 
6626fc729afSOlivier Houchard #define	bs_c_1_proto(f)							\
6634098ccafSIan Lepore void	__bs_c(f,_bs_c_1) (bus_space_tag_t t, bus_space_handle_t bsh1,	\
6646fc729afSOlivier Houchard 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
6656fc729afSOlivier Houchard 	    bus_size_t offset2, bus_size_t count);
6666fc729afSOlivier Houchard 
6676fc729afSOlivier Houchard #define	bs_c_2_proto(f)							\
6684098ccafSIan Lepore void	__bs_c(f,_bs_c_2) (bus_space_tag_t t, bus_space_handle_t bsh1,	\
6696fc729afSOlivier Houchard 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
6706fc729afSOlivier Houchard 	    bus_size_t offset2, bus_size_t count);
6716fc729afSOlivier Houchard 
6726fc729afSOlivier Houchard #define	bs_c_4_proto(f)							\
6734098ccafSIan Lepore void	__bs_c(f,_bs_c_4) (bus_space_tag_t t, bus_space_handle_t bsh1,	\
6746fc729afSOlivier Houchard 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
6756fc729afSOlivier Houchard 	    bus_size_t offset2, bus_size_t count);
6766fc729afSOlivier Houchard 
6776fc729afSOlivier Houchard #define	bs_c_8_proto(f)							\
6784098ccafSIan Lepore void	__bs_c(f,_bs_c_8) (bus_space_tag_t t, bus_space_handle_t bsh1,	\
6796fc729afSOlivier Houchard 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
6806fc729afSOlivier Houchard 	    bus_size_t offset2, bus_size_t count);
6816fc729afSOlivier Houchard 
6826fc729afSOlivier Houchard #define bs_protos(f)		\
6836fc729afSOlivier Houchard bs_map_proto(f);		\
6846fc729afSOlivier Houchard bs_unmap_proto(f);		\
6856fc729afSOlivier Houchard bs_subregion_proto(f);		\
6866fc729afSOlivier Houchard bs_alloc_proto(f);		\
6876fc729afSOlivier Houchard bs_free_proto(f);		\
6886fc729afSOlivier Houchard bs_mmap_proto(f);		\
6896fc729afSOlivier Houchard bs_barrier_proto(f);		\
6906fc729afSOlivier Houchard bs_r_1_proto(f);		\
6916fc729afSOlivier Houchard bs_r_2_proto(f);		\
6926fc729afSOlivier Houchard bs_r_4_proto(f);		\
6936fc729afSOlivier Houchard bs_r_8_proto(f);		\
694588a2322SSam Leffler bs_r_1_s_proto(f);		\
695588a2322SSam Leffler bs_r_2_s_proto(f);		\
696588a2322SSam Leffler bs_r_4_s_proto(f);		\
6976fc729afSOlivier Houchard bs_w_1_proto(f);		\
6986fc729afSOlivier Houchard bs_w_2_proto(f);		\
6996fc729afSOlivier Houchard bs_w_4_proto(f);		\
7006fc729afSOlivier Houchard bs_w_8_proto(f);		\
701588a2322SSam Leffler bs_w_1_s_proto(f);		\
702588a2322SSam Leffler bs_w_2_s_proto(f);		\
703588a2322SSam Leffler bs_w_4_s_proto(f);		\
7046fc729afSOlivier Houchard bs_rm_1_proto(f);		\
7056fc729afSOlivier Houchard bs_rm_2_proto(f);		\
7066fc729afSOlivier Houchard bs_rm_4_proto(f);		\
7076fc729afSOlivier Houchard bs_rm_8_proto(f);		\
7086fc729afSOlivier Houchard bs_wm_1_proto(f);		\
7096fc729afSOlivier Houchard bs_wm_2_proto(f);		\
7106fc729afSOlivier Houchard bs_wm_4_proto(f);		\
7116fc729afSOlivier Houchard bs_wm_8_proto(f);		\
7126fc729afSOlivier Houchard bs_rr_1_proto(f);		\
7136fc729afSOlivier Houchard bs_rr_2_proto(f);		\
7146fc729afSOlivier Houchard bs_rr_4_proto(f);		\
7156fc729afSOlivier Houchard bs_rr_8_proto(f);		\
7166fc729afSOlivier Houchard bs_wr_1_proto(f);		\
7176fc729afSOlivier Houchard bs_wr_2_proto(f);		\
7186fc729afSOlivier Houchard bs_wr_4_proto(f);		\
7196fc729afSOlivier Houchard bs_wr_8_proto(f);		\
7206fc729afSOlivier Houchard bs_sm_1_proto(f);		\
7216fc729afSOlivier Houchard bs_sm_2_proto(f);		\
7226fc729afSOlivier Houchard bs_sm_4_proto(f);		\
7236fc729afSOlivier Houchard bs_sm_8_proto(f);		\
7246fc729afSOlivier Houchard bs_sr_1_proto(f);		\
7256fc729afSOlivier Houchard bs_sr_2_proto(f);		\
7266fc729afSOlivier Houchard bs_sr_4_proto(f);		\
7276fc729afSOlivier Houchard bs_sr_8_proto(f);		\
7286fc729afSOlivier Houchard bs_c_1_proto(f);		\
7296fc729afSOlivier Houchard bs_c_2_proto(f);		\
7306fc729afSOlivier Houchard bs_c_4_proto(f);		\
7316fc729afSOlivier Houchard bs_c_8_proto(f);
7326fc729afSOlivier Houchard 
733*2737497bSIan Lepore void generic_bs_unimplemented(void);
734*2737497bSIan Lepore #define	BS_UNIMPLEMENTED	(void *)generic_bs_unimplemented
735*2737497bSIan Lepore 
7366fc729afSOlivier Houchard #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
7376fc729afSOlivier Houchard 
738a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXADDR_24BIT	0xFFFFFF
739a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
740a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXADDR 	0xFFFFFFFF
741a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXSIZE_24BIT	0xFFFFFF
742a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXSIZE_32BIT	0xFFFFFFFF
743a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXSIZE 	0xFFFFFFFF
744a5bb1c85SOlivier Houchard 
745b938b7a3SWarner Losh #define BUS_SPACE_UNRESTRICTED	(~0)
746b938b7a3SWarner Losh 
7475974e5c7SScott Long #include <machine/bus_dma.h>
7485974e5c7SScott Long 
74933ff10eaSIan Lepore /*
75033ff10eaSIan Lepore  * Get the physical address of a bus space memory-mapped resource.
75133ff10eaSIan Lepore  * Doing this as a macro is a temporary solution until a more robust fix is
75233ff10eaSIan Lepore  * designed.  It also serves to mark the locations needing that fix.
75333ff10eaSIan Lepore  */
75433ff10eaSIan Lepore #define BUS_SPACE_PHYSADDR(res, offs) \
7554117c1dbSAleksandr Rybalko 	((u_int)(rman_get_start(res)+(offs)))
75633ff10eaSIan Lepore 
7576fc729afSOlivier Houchard #endif /* _MACHINE_BUS_H_ */
758