xref: /netbsd-src/sys/arch/hppa/include/bus_funcs.h (revision dbeed5211bb070f13a01c576c13ceba139116a04)
1*dbeed521Smacallan /*	$NetBSD: bus_funcs.h,v 1.2 2024/01/28 09:03:22 macallan Exp $	*/
26d3ceb1dSskrll 
36d3ceb1dSskrll /*	$OpenBSD: bus.h,v 1.13 2001/07/30 14:15:59 art Exp $	*/
46d3ceb1dSskrll 
56d3ceb1dSskrll /*
66d3ceb1dSskrll  * Copyright (c) 1998-2004 Michael Shalayeff
76d3ceb1dSskrll  * All rights reserved.
86d3ceb1dSskrll  *
96d3ceb1dSskrll  * Redistribution and use in source and binary forms, with or without
106d3ceb1dSskrll  * modification, are permitted provided that the following conditions
116d3ceb1dSskrll  * are met:
126d3ceb1dSskrll  * 1. Redistributions of source code must retain the above copyright
136d3ceb1dSskrll  *    notice, this list of conditions and the following disclaimer.
146d3ceb1dSskrll  * 2. Redistributions in binary form must reproduce the above copyright
156d3ceb1dSskrll  *    notice, this list of conditions and the following disclaimer in the
166d3ceb1dSskrll  *    documentation and/or other materials provided with the distribution.
176d3ceb1dSskrll  *
186d3ceb1dSskrll  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
196d3ceb1dSskrll  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
206d3ceb1dSskrll  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
216d3ceb1dSskrll  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
226d3ceb1dSskrll  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
236d3ceb1dSskrll  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
246d3ceb1dSskrll  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
256d3ceb1dSskrll  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
266d3ceb1dSskrll  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
276d3ceb1dSskrll  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
286d3ceb1dSskrll  * THE POSSIBILITY OF SUCH DAMAGE.
296d3ceb1dSskrll  */
306d3ceb1dSskrll 
316d3ceb1dSskrll 
326d3ceb1dSskrll #ifndef _MACHINE_BUS_FUNCS_H_
336d3ceb1dSskrll #define _MACHINE_BUS_FUNCS_H_
346d3ceb1dSskrll 
356d3ceb1dSskrll extern const struct hppa_bus_space_tag hppa_bustag;
366d3ceb1dSskrll 
376d3ceb1dSskrll #define	bus_space_map(t,a,c,ca,hp) \
386d3ceb1dSskrll 	(((t)->hbt_map)((t)->hbt_cookie,(a),(c),(ca),(hp)))
396d3ceb1dSskrll #define	bus_space_unmap(t,h,c) \
406d3ceb1dSskrll 	(((t)->hbt_unmap)((t)->hbt_cookie,(h),(c)))
416d3ceb1dSskrll #define	bus_space_subregion(t,h,o,c,hp) \
426d3ceb1dSskrll 	(((t)->hbt_subregion)((t)->hbt_cookie,(h),(o),(c),(hp)))
436d3ceb1dSskrll #define	bus_space_alloc(t,b,e,c,al,bn,ca,ap,hp) \
446d3ceb1dSskrll 	(((t)->hbt_alloc)((t)->hbt_cookie,(b),(e),(c),(al),(bn),(ca),(ap),(hp)))
456d3ceb1dSskrll #define	bus_space_free(t,h,c) \
466d3ceb1dSskrll 	(((t)->hbt_free)((t)->hbt_cookie,(h),(c)))
476d3ceb1dSskrll #define	bus_space_barrier(t,h,o,l,op) \
486d3ceb1dSskrll 	((t)->hbt_barrier((t)->hbt_cookie, (h), (o), (l), (op)))
496d3ceb1dSskrll #define	bus_space_vaddr(t,h) \
506d3ceb1dSskrll 	(((t)->hbt_vaddr)((t)->hbt_cookie,(h)))
516d3ceb1dSskrll #define bus_space_mmap(t, a, o, p, f) \
526d3ceb1dSskrll 	(*(t)->hbt_mmap)((t)->hbt_cookie, (a), (o), (p), (f))
536d3ceb1dSskrll 
546d3ceb1dSskrll #define	bus_space_read_1(t,h,o) (((t)->hbt_r1)((t)->hbt_cookie,(h),(o)))
556d3ceb1dSskrll #define	bus_space_read_2(t,h,o) (((t)->hbt_r2)((t)->hbt_cookie,(h),(o)))
566d3ceb1dSskrll #define	bus_space_read_4(t,h,o) (((t)->hbt_r4)((t)->hbt_cookie,(h),(o)))
576d3ceb1dSskrll #define	bus_space_read_8(t,h,o) (((t)->hbt_r8)((t)->hbt_cookie,(h),(o)))
586d3ceb1dSskrll 
59*dbeed521Smacallan #define	bus_space_read_stream_1(t,h,o) (bus_space_read_1(t,h,o))
60*dbeed521Smacallan #define	bus_space_read_stream_2(t,h,o) (((t)->hbt_rs2)((t)->hbt_cookie,(h),(o)))
61*dbeed521Smacallan #define	bus_space_read_stream_4(t,h,o) (((t)->hbt_rs4)((t)->hbt_cookie,(h),(o)))
62*dbeed521Smacallan #define	bus_space_read_stream_8(t,h,o) (((t)->hbt_rs8)((t)->hbt_cookie,(h),(o)))
63*dbeed521Smacallan 
646d3ceb1dSskrll #define	bus_space_write_1(t,h,o,v) (((t)->hbt_w1)((t)->hbt_cookie,(h),(o),(v)))
656d3ceb1dSskrll #define	bus_space_write_2(t,h,o,v) (((t)->hbt_w2)((t)->hbt_cookie,(h),(o),(v)))
666d3ceb1dSskrll #define	bus_space_write_4(t,h,o,v) (((t)->hbt_w4)((t)->hbt_cookie,(h),(o),(v)))
676d3ceb1dSskrll #define	bus_space_write_8(t,h,o,v) (((t)->hbt_w8)((t)->hbt_cookie,(h),(o),(v)))
686d3ceb1dSskrll 
69*dbeed521Smacallan #define	bus_space_write_stream_1(t,h,o,v) (bus_space_write_1(t,h,o,v))
70*dbeed521Smacallan #define	bus_space_write_stream_2(t,h,o,v) (((t)->hbt_ws2)((t)->hbt_cookie,(h),(o),(v)))
71*dbeed521Smacallan #define	bus_space_write_stream_4(t,h,o,v) (((t)->hbt_ws4)((t)->hbt_cookie,(h),(o),(v)))
72*dbeed521Smacallan #define	bus_space_write_stream_8(t,h,o,v) (((t)->hbt_ws8)((t)->hbt_cookie,(h),(o),(v)))
736d3ceb1dSskrll 
746d3ceb1dSskrll #define	bus_space_read_multi_1(t,h,o,a,c) \
756d3ceb1dSskrll 	(((t)->hbt_rm_1)((t)->hbt_cookie, (h), (o), (a), (c)))
766d3ceb1dSskrll #define	bus_space_read_multi_2(t,h,o,a,c) \
776d3ceb1dSskrll 	(((t)->hbt_rm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
786d3ceb1dSskrll #define	bus_space_read_multi_4(t,h,o,a,c) \
796d3ceb1dSskrll 	(((t)->hbt_rm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
806d3ceb1dSskrll #define	bus_space_read_multi_8(t,h,o,a,c) \
816d3ceb1dSskrll 	(((t)->hbt_rm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
826d3ceb1dSskrll 
836d3ceb1dSskrll #define	bus_space_write_multi_1(t,h,o,a,c) \
846d3ceb1dSskrll 	(((t)->hbt_wm_1)((t)->hbt_cookie, (h), (o), (a), (c)))
856d3ceb1dSskrll #define	bus_space_write_multi_2(t,h,o,a,c) \
866d3ceb1dSskrll 	(((t)->hbt_wm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
876d3ceb1dSskrll #define	bus_space_write_multi_4(t,h,o,a,c) \
886d3ceb1dSskrll 	(((t)->hbt_wm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
896d3ceb1dSskrll #define	bus_space_write_multi_8(t,h,o,a,c) \
906d3ceb1dSskrll 	(((t)->hbt_wm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
916d3ceb1dSskrll 
926d3ceb1dSskrll #define	bus_space_set_multi_1(t,h,o,v,c) \
936d3ceb1dSskrll 	(((t)->hbt_sm_1)((t)->hbt_cookie, (h), (o), (v), (c)))
946d3ceb1dSskrll #define	bus_space_set_multi_2(t,h,o,v,c) \
956d3ceb1dSskrll 	(((t)->hbt_sm_2)((t)->hbt_cookie, (h), (o), (v), (c)))
966d3ceb1dSskrll #define	bus_space_set_multi_4(t,h,o,v,c) \
976d3ceb1dSskrll 	(((t)->hbt_sm_4)((t)->hbt_cookie, (h), (o), (v), (c)))
986d3ceb1dSskrll #define	bus_space_set_multi_8(t,h,o,v,c) \
996d3ceb1dSskrll 	(((t)->hbt_sm_8)((t)->hbt_cookie, (h), (o), (v), (c)))
1006d3ceb1dSskrll 
1016d3ceb1dSskrll #define	bus_space_read_multi_stream_2(t, h, o, a, c) \
1026d3ceb1dSskrll 	(((t)->hbt_rrm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
1036d3ceb1dSskrll #define	bus_space_read_multi_stream_4(t, h, o, a, c) \
1046d3ceb1dSskrll 	(((t)->hbt_rrm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
1056d3ceb1dSskrll #define	bus_space_read_multi_stream_8(t, h, o, a, c) \
1066d3ceb1dSskrll 	(((t)->hbt_rrm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
1076d3ceb1dSskrll 
1086d3ceb1dSskrll #define	bus_space_write_multi_stream_2(t, h, o, a, c) \
1096d3ceb1dSskrll 	(((t)->hbt_wrm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
1106d3ceb1dSskrll #define	bus_space_write_multi_stream_4(t, h, o, a, c) \
1116d3ceb1dSskrll 	(((t)->hbt_wrm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
1126d3ceb1dSskrll #define	bus_space_write_multi_stream_8(t, h, o, a, c) \
1136d3ceb1dSskrll 	(((t)->hbt_wrm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
1146d3ceb1dSskrll 
1156d3ceb1dSskrll #define	bus_space_read_region_1(t, h, o, a, c) \
1166d3ceb1dSskrll 	(((t)->hbt_rr_1)((t)->hbt_cookie, (h), (o), (a), (c)))
1176d3ceb1dSskrll #define	bus_space_read_region_2(t, h, o, a, c) \
1186d3ceb1dSskrll 	(((t)->hbt_rr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
1196d3ceb1dSskrll #define	bus_space_read_region_4(t, h, o, a, c) \
1206d3ceb1dSskrll 	(((t)->hbt_rr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
1216d3ceb1dSskrll #define	bus_space_read_region_8(t, h, o, a, c) \
1226d3ceb1dSskrll 	(((t)->hbt_rr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
1236d3ceb1dSskrll 
1246d3ceb1dSskrll #define	bus_space_write_region_1(t, h, o, a, c) \
1256d3ceb1dSskrll 	(((t)->hbt_wr_1)((t)->hbt_cookie, (h), (o), (a), (c)))
1266d3ceb1dSskrll #define	bus_space_write_region_2(t, h, o, a, c) \
1276d3ceb1dSskrll 	(((t)->hbt_wr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
1286d3ceb1dSskrll #define	bus_space_write_region_4(t, h, o, a, c) \
1296d3ceb1dSskrll 	(((t)->hbt_wr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
1306d3ceb1dSskrll #define	bus_space_write_region_8(t, h, o, a, c) \
1316d3ceb1dSskrll 	(((t)->hbt_wr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
1326d3ceb1dSskrll 
1336d3ceb1dSskrll #define	bus_space_read_region_stream_2(t, h, o, a, c) \
1346d3ceb1dSskrll 	(((t)->hbt_rrr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
1356d3ceb1dSskrll #define	bus_space_read_region_stream_4(t, h, o, a, c) \
1366d3ceb1dSskrll 	(((t)->hbt_rrr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
1376d3ceb1dSskrll #define	bus_space_read_region_stream_8(t, h, o, a, c) \
1386d3ceb1dSskrll 	(((t)->hbt_rrr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
1396d3ceb1dSskrll 
1406d3ceb1dSskrll #define	bus_space_write_region_stream_2(t, h, o, a, c) \
1416d3ceb1dSskrll 	(((t)->hbt_wrr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
1426d3ceb1dSskrll #define	bus_space_write_region_stream_4(t, h, o, a, c) \
1436d3ceb1dSskrll 	(((t)->hbt_wrr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
1446d3ceb1dSskrll #define	bus_space_write_region_stream_8(t, h, o, a, c) \
1456d3ceb1dSskrll 	(((t)->hbt_wrr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
1466d3ceb1dSskrll 
1476d3ceb1dSskrll #define	bus_space_set_region_1(t, h, o, v, c) \
1486d3ceb1dSskrll 	(((t)->hbt_sr_1)((t)->hbt_cookie, (h), (o), (v), (c)))
1496d3ceb1dSskrll #define	bus_space_set_region_2(t, h, o, v, c) \
1506d3ceb1dSskrll 	(((t)->hbt_sr_2)((t)->hbt_cookie, (h), (o), (v), (c)))
1516d3ceb1dSskrll #define	bus_space_set_region_4(t, h, o, v, c) \
1526d3ceb1dSskrll 	(((t)->hbt_sr_4)((t)->hbt_cookie, (h), (o), (v), (c)))
1536d3ceb1dSskrll #define	bus_space_set_region_8(t, h, o, v, c) \
1546d3ceb1dSskrll 	(((t)->hbt_sr_8)((t)->hbt_cookie, (h), (o), (v), (c)))
1556d3ceb1dSskrll 
1566d3ceb1dSskrll #define	bus_space_copy_1(t, h1, o1, h2, o2, c) \
1576d3ceb1dSskrll 	(((t)->hbt_cp_1)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
1586d3ceb1dSskrll #define	bus_space_copy_2(t, h1, o1, h2, o2, c) \
1596d3ceb1dSskrll 	(((t)->hbt_cp_2)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
1606d3ceb1dSskrll #define	bus_space_copy_4(t, h1, o1, h2, o2, c) \
1616d3ceb1dSskrll 	(((t)->hbt_cp_4)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
1626d3ceb1dSskrll #define	bus_space_copy_8(t, h1, o1, h2, o2, c) \
1636d3ceb1dSskrll 	(((t)->hbt_cp_8)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
1646d3ceb1dSskrll 
1656d3ceb1dSskrll /* Forwards needed by prototypes below. */
1666d3ceb1dSskrll struct mbuf;
1676d3ceb1dSskrll struct proc;
1686d3ceb1dSskrll struct uio;
1696d3ceb1dSskrll 
1706d3ceb1dSskrll #define	bus_dmamap_create(t, s, n, m, b, f, p)			\
1716d3ceb1dSskrll 	(*(t)->_dmamap_create)((t)->_cookie, (s), (n), (m), (b), (f), (p))
1726d3ceb1dSskrll #define	bus_dmamap_destroy(t, p)				\
1736d3ceb1dSskrll 	(*(t)->_dmamap_destroy)((t)->_cookie, (p))
1746d3ceb1dSskrll #define	bus_dmamap_load(t, m, b, s, p, f)			\
1756d3ceb1dSskrll 	(*(t)->_dmamap_load)((t)->_cookie, (m), (b), (s), (p), (f))
1766d3ceb1dSskrll #define	bus_dmamap_load_mbuf(t, m, b, f)			\
1776d3ceb1dSskrll 	(*(t)->_dmamap_load_mbuf)((t)->_cookie, (m), (b), (f))
1786d3ceb1dSskrll #define	bus_dmamap_load_uio(t, m, u, f)				\
1796d3ceb1dSskrll 	(*(t)->_dmamap_load_uio)((t)->_cookie, (m), (u), (f))
1806d3ceb1dSskrll #define	bus_dmamap_load_raw(t, m, sg, n, s, f)			\
1816d3ceb1dSskrll 	(*(t)->_dmamap_load_raw)((t)->_cookie, (m), (sg), (n), (s), (f))
1826d3ceb1dSskrll #define	bus_dmamap_unload(t, p)					\
1836d3ceb1dSskrll 	(*(t)->_dmamap_unload)((t)->_cookie, (p))
1846d3ceb1dSskrll #define	bus_dmamap_sync(t, p, o, l, ops)				\
1856d3ceb1dSskrll 	(void)((t)->_dmamap_sync ?				\
1866d3ceb1dSskrll 	    (*(t)->_dmamap_sync)((t)->_cookie, (p), (o), (l), (ops)) : (void)0)
1876d3ceb1dSskrll 
1886d3ceb1dSskrll #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
1896d3ceb1dSskrll 	(*(t)->_dmamem_alloc)((t)->_cookie, (s), (a), (b), (sg), (n), (r), (f))
1906d3ceb1dSskrll #define	bus_dmamem_free(t, sg, n)				\
1916d3ceb1dSskrll 	(*(t)->_dmamem_free)((t)->_cookie, (sg), (n))
1926d3ceb1dSskrll #define	bus_dmamem_map(t, sg, n, s, k, f)			\
1936d3ceb1dSskrll 	(*(t)->_dmamem_map)((t)->_cookie, (sg), (n), (s), (k), (f))
1946d3ceb1dSskrll #define	bus_dmamem_unmap(t, k, s)				\
1956d3ceb1dSskrll 	(*(t)->_dmamem_unmap)((t)->_cookie, (k), (s))
1966d3ceb1dSskrll #define	bus_dmamem_mmap(t, sg, n, o, p, f)			\
1976d3ceb1dSskrll 	(*(t)->_dmamem_mmap)((t)->_cookie, (sg), (n), (o), (p), (f))
1986d3ceb1dSskrll 
1996d3ceb1dSskrll #define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP
2006d3ceb1dSskrll #define bus_dmatag_destroy(t)
2016d3ceb1dSskrll 
2026d3ceb1dSskrll #endif /* _MACHINE_BUS_FUNCS_H_ */
203