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 /*- 34af3dc4a7SPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 35af3dc4a7SPedro F. Giffuni * 366fc729afSOlivier Houchard * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 376fc729afSOlivier Houchard * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 386fc729afSOlivier Houchard * 396fc729afSOlivier Houchard * Redistribution and use in source and binary forms, with or without 406fc729afSOlivier Houchard * modification, are permitted provided that the following conditions 416fc729afSOlivier Houchard * are met: 426fc729afSOlivier Houchard * 1. Redistributions of source code must retain the above copyright 436fc729afSOlivier Houchard * notice, this list of conditions and the following disclaimer. 446fc729afSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright 456fc729afSOlivier Houchard * notice, this list of conditions and the following disclaimer in the 466fc729afSOlivier Houchard * documentation and/or other materials provided with the distribution. 476fc729afSOlivier Houchard * 3. All advertising materials mentioning features or use of this software 486fc729afSOlivier Houchard * must display the following acknowledgement: 496fc729afSOlivier Houchard * This product includes software developed by Christopher G. Demetriou 506fc729afSOlivier Houchard * for the NetBSD Project. 516fc729afSOlivier Houchard * 4. The name of the author may not be used to endorse or promote products 526fc729afSOlivier Houchard * derived from this software without specific prior written permission 536fc729afSOlivier Houchard * 546fc729afSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 556fc729afSOlivier Houchard * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 566fc729afSOlivier Houchard * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 576fc729afSOlivier Houchard * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 586fc729afSOlivier Houchard * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 596fc729afSOlivier Houchard * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 606fc729afSOlivier Houchard * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 616fc729afSOlivier Houchard * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 626fc729afSOlivier Houchard * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 636fc729afSOlivier Houchard * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 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 82ede35faeSIan Lepore /* 83ede35faeSIan Lepore * Bus space for ARM. 84ede35faeSIan Lepore * 85ede35faeSIan Lepore * The functions used most often are grouped together at the beginning to ensure 86ede35faeSIan Lepore * that all the data fits into a single cache line. The inline implementations 87ede35faeSIan Lepore * of single read/write access these values a lot. 88ede35faeSIan Lepore */ 896fc729afSOlivier Houchard struct bus_space { 90ede35faeSIan Lepore /* Read/write single and barrier: the most commonly used functions. */ 91ede35faeSIan Lepore uint8_t (*bs_r_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t); 92ede35faeSIan Lepore uint32_t (*bs_r_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t); 93ede35faeSIan Lepore void (*bs_w_1)(bus_space_tag_t, bus_space_handle_t, 94ede35faeSIan Lepore bus_size_t, uint8_t); 95ede35faeSIan Lepore void (*bs_w_4)(bus_space_tag_t, bus_space_handle_t, 96ede35faeSIan Lepore bus_size_t, uint32_t); 97ede35faeSIan Lepore void (*bs_barrier)(bus_space_tag_t, bus_space_handle_t, 98ede35faeSIan Lepore bus_size_t, bus_size_t, int); 99ede35faeSIan Lepore 100ede35faeSIan Lepore /* Backlink to parent (if copied), and implementation private data. */ 101ede35faeSIan Lepore struct bus_space *bs_parent; 1024098ccafSIan Lepore void *bs_privdata; 1036fc729afSOlivier Houchard 1046fc729afSOlivier Houchard /* mapping/unmapping */ 1054098ccafSIan Lepore int (*bs_map) (bus_space_tag_t, bus_addr_t, bus_size_t, 1066fc729afSOlivier Houchard int, bus_space_handle_t *); 1074098ccafSIan Lepore void (*bs_unmap) (bus_space_tag_t, bus_space_handle_t, bus_size_t); 1084098ccafSIan Lepore int (*bs_subregion) (bus_space_tag_t, bus_space_handle_t, 1096fc729afSOlivier Houchard bus_size_t, bus_size_t, bus_space_handle_t *); 1106fc729afSOlivier Houchard 1116fc729afSOlivier Houchard /* allocation/deallocation */ 1124098ccafSIan Lepore int (*bs_alloc) (bus_space_tag_t, bus_addr_t, bus_addr_t, 1136fc729afSOlivier Houchard bus_size_t, bus_size_t, bus_size_t, int, 1146fc729afSOlivier Houchard bus_addr_t *, bus_space_handle_t *); 1154098ccafSIan Lepore void (*bs_free) (bus_space_tag_t, bus_space_handle_t, 1166fc729afSOlivier Houchard bus_size_t); 1176fc729afSOlivier Houchard 118ede35faeSIan Lepore /* Read single, the less commonly used functions. */ 1194098ccafSIan Lepore uint16_t (*bs_r_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t); 1204098ccafSIan Lepore uint64_t (*bs_r_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t); 1216fc729afSOlivier Houchard 1226fc729afSOlivier Houchard /* read multiple */ 1234098ccafSIan Lepore void (*bs_rm_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 1244098ccafSIan Lepore uint8_t *, bus_size_t); 1254098ccafSIan Lepore void (*bs_rm_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 1264098ccafSIan Lepore uint16_t *, bus_size_t); 1274098ccafSIan Lepore void (*bs_rm_4) (bus_space_tag_t, bus_space_handle_t, 1284098ccafSIan Lepore bus_size_t, uint32_t *, bus_size_t); 1294098ccafSIan Lepore void (*bs_rm_8) (bus_space_tag_t, bus_space_handle_t, 1304098ccafSIan Lepore bus_size_t, uint64_t *, bus_size_t); 1316fc729afSOlivier Houchard 1326fc729afSOlivier Houchard /* read region */ 1334098ccafSIan Lepore void (*bs_rr_1) (bus_space_tag_t, bus_space_handle_t, 1344098ccafSIan Lepore bus_size_t, uint8_t *, bus_size_t); 1354098ccafSIan Lepore void (*bs_rr_2) (bus_space_tag_t, bus_space_handle_t, 1364098ccafSIan Lepore bus_size_t, uint16_t *, bus_size_t); 1374098ccafSIan Lepore void (*bs_rr_4) (bus_space_tag_t, bus_space_handle_t, 1384098ccafSIan Lepore bus_size_t, uint32_t *, bus_size_t); 1394098ccafSIan Lepore void (*bs_rr_8) (bus_space_tag_t, bus_space_handle_t, 1404098ccafSIan Lepore bus_size_t, uint64_t *, bus_size_t); 1416fc729afSOlivier Houchard 142ede35faeSIan Lepore /* Write single, the less commonly used functions. */ 1434098ccafSIan Lepore void (*bs_w_2) (bus_space_tag_t, bus_space_handle_t, 1444098ccafSIan Lepore bus_size_t, uint16_t); 1454098ccafSIan Lepore void (*bs_w_8) (bus_space_tag_t, bus_space_handle_t, 1464098ccafSIan Lepore bus_size_t, uint64_t); 1476fc729afSOlivier Houchard 1486fc729afSOlivier Houchard /* write multiple */ 1494098ccafSIan Lepore void (*bs_wm_1) (bus_space_tag_t, bus_space_handle_t, 1504098ccafSIan Lepore bus_size_t, const uint8_t *, bus_size_t); 1514098ccafSIan Lepore void (*bs_wm_2) (bus_space_tag_t, bus_space_handle_t, 1524098ccafSIan Lepore bus_size_t, const uint16_t *, bus_size_t); 1534098ccafSIan Lepore void (*bs_wm_4) (bus_space_tag_t, bus_space_handle_t, 1544098ccafSIan Lepore bus_size_t, const uint32_t *, bus_size_t); 1554098ccafSIan Lepore void (*bs_wm_8) (bus_space_tag_t, bus_space_handle_t, 1564098ccafSIan Lepore bus_size_t, const uint64_t *, bus_size_t); 1576fc729afSOlivier Houchard 1586fc729afSOlivier Houchard /* write region */ 1594098ccafSIan Lepore void (*bs_wr_1) (bus_space_tag_t, bus_space_handle_t, 1604098ccafSIan Lepore bus_size_t, const uint8_t *, bus_size_t); 1614098ccafSIan Lepore void (*bs_wr_2) (bus_space_tag_t, bus_space_handle_t, 1624098ccafSIan Lepore bus_size_t, const uint16_t *, bus_size_t); 1634098ccafSIan Lepore void (*bs_wr_4) (bus_space_tag_t, bus_space_handle_t, 1644098ccafSIan Lepore bus_size_t, const uint32_t *, bus_size_t); 1654098ccafSIan Lepore void (*bs_wr_8) (bus_space_tag_t, bus_space_handle_t, 1664098ccafSIan Lepore bus_size_t, const uint64_t *, bus_size_t); 1676fc729afSOlivier Houchard 1686fc729afSOlivier Houchard /* set multiple */ 1694098ccafSIan Lepore void (*bs_sm_1) (bus_space_tag_t, bus_space_handle_t, 1704098ccafSIan Lepore bus_size_t, uint8_t, bus_size_t); 1714098ccafSIan Lepore void (*bs_sm_2) (bus_space_tag_t, bus_space_handle_t, 1724098ccafSIan Lepore bus_size_t, uint16_t, bus_size_t); 1734098ccafSIan Lepore void (*bs_sm_4) (bus_space_tag_t, bus_space_handle_t, 1744098ccafSIan Lepore bus_size_t, uint32_t, bus_size_t); 1754098ccafSIan Lepore void (*bs_sm_8) (bus_space_tag_t, bus_space_handle_t, 1764098ccafSIan Lepore bus_size_t, uint64_t, bus_size_t); 1776fc729afSOlivier Houchard 1786fc729afSOlivier Houchard /* set region */ 1794098ccafSIan Lepore void (*bs_sr_1) (bus_space_tag_t, bus_space_handle_t, 1804098ccafSIan Lepore bus_size_t, uint8_t, bus_size_t); 1814098ccafSIan Lepore void (*bs_sr_2) (bus_space_tag_t, bus_space_handle_t, 1824098ccafSIan Lepore bus_size_t, uint16_t, bus_size_t); 1834098ccafSIan Lepore void (*bs_sr_4) (bus_space_tag_t, bus_space_handle_t, 1844098ccafSIan Lepore bus_size_t, uint32_t, bus_size_t); 1854098ccafSIan Lepore void (*bs_sr_8) (bus_space_tag_t, bus_space_handle_t, 1864098ccafSIan Lepore bus_size_t, uint64_t, bus_size_t); 1876fc729afSOlivier Houchard 1886fc729afSOlivier Houchard /* copy */ 1894098ccafSIan Lepore void (*bs_c_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 1906fc729afSOlivier Houchard bus_space_handle_t, bus_size_t, bus_size_t); 1914098ccafSIan Lepore void (*bs_c_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 1926fc729afSOlivier Houchard bus_space_handle_t, bus_size_t, bus_size_t); 1934098ccafSIan Lepore void (*bs_c_4) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 1946fc729afSOlivier Houchard bus_space_handle_t, bus_size_t, bus_size_t); 1954098ccafSIan Lepore void (*bs_c_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 1966fc729afSOlivier Houchard bus_space_handle_t, bus_size_t, bus_size_t); 1976fc729afSOlivier Houchard 198588a2322SSam Leffler /* read stream (single) */ 1994098ccafSIan Lepore uint8_t (*bs_r_1_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t); 2004098ccafSIan Lepore uint16_t (*bs_r_2_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t); 2014098ccafSIan Lepore uint32_t (*bs_r_4_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t); 2024098ccafSIan Lepore uint64_t (*bs_r_8_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t); 203588a2322SSam Leffler 204588a2322SSam Leffler /* read multiple stream */ 2054098ccafSIan Lepore void (*bs_rm_1_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 2064098ccafSIan Lepore uint8_t *, bus_size_t); 2074098ccafSIan Lepore void (*bs_rm_2_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t, 2084098ccafSIan Lepore uint16_t *, bus_size_t); 2094098ccafSIan Lepore void (*bs_rm_4_s) (bus_space_tag_t, bus_space_handle_t, 2104098ccafSIan Lepore bus_size_t, uint32_t *, bus_size_t); 2114098ccafSIan Lepore void (*bs_rm_8_s) (bus_space_tag_t, bus_space_handle_t, 2124098ccafSIan Lepore bus_size_t, uint64_t *, bus_size_t); 213588a2322SSam Leffler 214588a2322SSam Leffler /* read region stream */ 2154098ccafSIan Lepore void (*bs_rr_1_s) (bus_space_tag_t, bus_space_handle_t, 2164098ccafSIan Lepore bus_size_t, uint8_t *, bus_size_t); 2174098ccafSIan Lepore void (*bs_rr_2_s) (bus_space_tag_t, bus_space_handle_t, 2184098ccafSIan Lepore bus_size_t, uint16_t *, bus_size_t); 2194098ccafSIan Lepore void (*bs_rr_4_s) (bus_space_tag_t, bus_space_handle_t, 2204098ccafSIan Lepore bus_size_t, uint32_t *, bus_size_t); 2214098ccafSIan Lepore void (*bs_rr_8_s) (bus_space_tag_t, bus_space_handle_t, 2224098ccafSIan Lepore bus_size_t, uint64_t *, bus_size_t); 223588a2322SSam Leffler 224588a2322SSam Leffler /* write stream (single) */ 2254098ccafSIan Lepore void (*bs_w_1_s) (bus_space_tag_t, bus_space_handle_t, 2264098ccafSIan Lepore bus_size_t, uint8_t); 2274098ccafSIan Lepore void (*bs_w_2_s) (bus_space_tag_t, bus_space_handle_t, 2284098ccafSIan Lepore bus_size_t, uint16_t); 2294098ccafSIan Lepore void (*bs_w_4_s) (bus_space_tag_t, bus_space_handle_t, 2304098ccafSIan Lepore bus_size_t, uint32_t); 2314098ccafSIan Lepore void (*bs_w_8_s) (bus_space_tag_t, bus_space_handle_t, 2324098ccafSIan Lepore bus_size_t, uint64_t); 233588a2322SSam Leffler 234588a2322SSam Leffler /* write multiple stream */ 2354098ccafSIan Lepore void (*bs_wm_1_s) (bus_space_tag_t, bus_space_handle_t, 2364098ccafSIan Lepore bus_size_t, const uint8_t *, bus_size_t); 2374098ccafSIan Lepore void (*bs_wm_2_s) (bus_space_tag_t, bus_space_handle_t, 2384098ccafSIan Lepore bus_size_t, const uint16_t *, bus_size_t); 2394098ccafSIan Lepore void (*bs_wm_4_s) (bus_space_tag_t, bus_space_handle_t, 2404098ccafSIan Lepore bus_size_t, const uint32_t *, bus_size_t); 2414098ccafSIan Lepore void (*bs_wm_8_s) (bus_space_tag_t, bus_space_handle_t, 2424098ccafSIan Lepore bus_size_t, const uint64_t *, bus_size_t); 243588a2322SSam Leffler 244588a2322SSam Leffler /* write region stream */ 2454098ccafSIan Lepore void (*bs_wr_1_s) (bus_space_tag_t, bus_space_handle_t, 2464098ccafSIan Lepore bus_size_t, const uint8_t *, bus_size_t); 2474098ccafSIan Lepore void (*bs_wr_2_s) (bus_space_tag_t, bus_space_handle_t, 2484098ccafSIan Lepore bus_size_t, const uint16_t *, bus_size_t); 2494098ccafSIan Lepore void (*bs_wr_4_s) (bus_space_tag_t, bus_space_handle_t, 2504098ccafSIan Lepore bus_size_t, const uint32_t *, bus_size_t); 2514098ccafSIan Lepore void (*bs_wr_8_s) (bus_space_tag_t, bus_space_handle_t, 2524098ccafSIan Lepore bus_size_t, const uint64_t *, bus_size_t); 2536fc729afSOlivier Houchard }; 2546fc729afSOlivier Houchard 2556fc729afSOlivier Houchard /* 2566fc729afSOlivier Houchard * Utility macros; INTERNAL USE ONLY. 2576fc729afSOlivier Houchard */ 2586fc729afSOlivier Houchard #define __bs_c(a,b) __CONCAT(a,b) 2596fc729afSOlivier Houchard #define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size) 2606fc729afSOlivier Houchard 2616fc729afSOlivier Houchard #define __bs_nonsingle(type, sz, t, h, o, a, c) \ 2624098ccafSIan Lepore (*(t)->__bs_opname(type,sz))((t), h, o, a, c) 2636fc729afSOlivier Houchard #define __bs_set(type, sz, t, h, o, v, c) \ 2644098ccafSIan Lepore (*(t)->__bs_opname(type,sz))((t), h, o, v, c) 2656fc729afSOlivier Houchard #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \ 2664098ccafSIan Lepore (*(t)->__bs_opname(c,sz))((t), h1, o1, h2, o2, cnt) 2676fc729afSOlivier Houchard 268588a2322SSam Leffler #define __bs_opname_s(op,size) __bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s) 269588a2322SSam Leffler #define __bs_rs_s(sz, t, h, o) \ 2704098ccafSIan Lepore (*(t)->__bs_opname_s(r,sz))((t), h, o) 271588a2322SSam Leffler #define __bs_ws_s(sz, t, h, o, v) \ 2724098ccafSIan Lepore (*(t)->__bs_opname_s(w,sz))((t), h, o, v) 273588a2322SSam Leffler #define __bs_nonsingle_s(type, sz, t, h, o, a, c) \ 2744098ccafSIan Lepore (*(t)->__bs_opname_s(type,sz))((t), h, o, a, c) 275588a2322SSam Leffler 27616e2dc66SIan Lepore #define __generate_inline_bs_rs(IFN, MBR, TYP) \ 27716e2dc66SIan Lepore static inline TYP \ 27816e2dc66SIan Lepore IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) \ 27916e2dc66SIan Lepore { \ 28016e2dc66SIan Lepore \ 28116e2dc66SIan Lepore if (__predict_true(t->MBR == NULL)) \ 28216e2dc66SIan Lepore return (*(volatile TYP *)(h + o)); \ 28316e2dc66SIan Lepore else \ 2844098ccafSIan Lepore return (t->MBR(t, h, o)); \ 28516e2dc66SIan Lepore } 28616e2dc66SIan Lepore 28716e2dc66SIan Lepore #define __generate_inline_bs_ws(IFN, MBR, TYP) \ 28816e2dc66SIan Lepore static inline void \ 28916e2dc66SIan Lepore IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, TYP v)\ 29016e2dc66SIan Lepore { \ 29116e2dc66SIan Lepore \ 29216e2dc66SIan Lepore if (__predict_true(t->MBR == NULL)) \ 29316e2dc66SIan Lepore *(volatile TYP *)(h + o) = v; \ 29416e2dc66SIan Lepore else \ 2954098ccafSIan Lepore t->MBR(t, h, o, v); \ 29616e2dc66SIan Lepore } 29716e2dc66SIan Lepore 2986fc729afSOlivier Houchard /* 2996fc729afSOlivier Houchard * Mapping and unmapping operations. 3006fc729afSOlivier Houchard */ 3016fc729afSOlivier Houchard #define bus_space_map(t, a, s, c, hp) \ 3024098ccafSIan Lepore (*(t)->bs_map)((t), (a), (s), (c), (hp)) 3036fc729afSOlivier Houchard #define bus_space_unmap(t, h, s) \ 3044098ccafSIan Lepore (*(t)->bs_unmap)((t), (h), (s)) 3056fc729afSOlivier Houchard #define bus_space_subregion(t, h, o, s, hp) \ 3064098ccafSIan Lepore (*(t)->bs_subregion)((t), (h), (o), (s), (hp)) 3076fc729afSOlivier Houchard 3086fc729afSOlivier Houchard /* 3096fc729afSOlivier Houchard * Allocation and deallocation operations. 3106fc729afSOlivier Houchard */ 3116fc729afSOlivier Houchard #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \ 3124098ccafSIan Lepore (*(t)->bs_alloc)((t), (rs), (re), (s), (a), (b), \ 3136fc729afSOlivier Houchard (c), (ap), (hp)) 3146fc729afSOlivier Houchard #define bus_space_free(t, h, s) \ 3154098ccafSIan Lepore (*(t)->bs_free)((t), (h), (s)) 3166fc729afSOlivier Houchard 3176fc729afSOlivier Houchard /* 3186fc729afSOlivier Houchard * Bus barrier operations. 3196fc729afSOlivier Houchard */ 3206fc729afSOlivier Houchard #define bus_space_barrier(t, h, o, l, f) \ 3214098ccafSIan Lepore (*(t)->bs_barrier)((t), (h), (o), (l), (f)) 3226fc729afSOlivier Houchard 3236fc729afSOlivier Houchard #define BUS_SPACE_BARRIER_READ 0x01 3246fc729afSOlivier Houchard #define BUS_SPACE_BARRIER_WRITE 0x02 3256fc729afSOlivier Houchard 3266fc729afSOlivier Houchard /* 3276fc729afSOlivier Houchard * Bus read (single) operations. 3286fc729afSOlivier Houchard */ 32916e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_1, bs_r_1, uint8_t); 33016e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_2, bs_r_2, uint16_t); 33116e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_4, bs_r_4, uint32_t); 33216e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_8, bs_r_8, uint64_t); 3336fc729afSOlivier Houchard 33416e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_1, bs_r_1_s, uint8_t); 33516e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_2, bs_r_2_s, uint16_t); 33616e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_4, bs_r_4_s, uint32_t); 33716e2dc66SIan Lepore __generate_inline_bs_rs(bus_space_read_stream_8, bs_r_8_s, uint64_t); 3386fc729afSOlivier Houchard 3396fc729afSOlivier Houchard /* 3406fc729afSOlivier Houchard * Bus read multiple operations. 3416fc729afSOlivier Houchard */ 3426fc729afSOlivier Houchard #define bus_space_read_multi_1(t, h, o, a, c) \ 3436fc729afSOlivier Houchard __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) 3446fc729afSOlivier Houchard #define bus_space_read_multi_2(t, h, o, a, c) \ 3456fc729afSOlivier Houchard __bs_nonsingle(rm,2,(t),(h),(o),(a),(c)) 3466fc729afSOlivier Houchard #define bus_space_read_multi_4(t, h, o, a, c) \ 3476fc729afSOlivier Houchard __bs_nonsingle(rm,4,(t),(h),(o),(a),(c)) 3486fc729afSOlivier Houchard #define bus_space_read_multi_8(t, h, o, a, c) \ 3496fc729afSOlivier Houchard __bs_nonsingle(rm,8,(t),(h),(o),(a),(c)) 3506fc729afSOlivier Houchard 351588a2322SSam Leffler #define bus_space_read_multi_stream_1(t, h, o, a, c) \ 352588a2322SSam Leffler __bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c)) 353588a2322SSam Leffler #define bus_space_read_multi_stream_2(t, h, o, a, c) \ 354588a2322SSam Leffler __bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c)) 355588a2322SSam Leffler #define bus_space_read_multi_stream_4(t, h, o, a, c) \ 356588a2322SSam Leffler __bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c)) 357588a2322SSam Leffler #define bus_space_read_multi_stream_8(t, h, o, a, c) \ 358588a2322SSam Leffler __bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c)) 359588a2322SSam Leffler 3606fc729afSOlivier Houchard /* 3616fc729afSOlivier Houchard * Bus read region operations. 3626fc729afSOlivier Houchard */ 3636fc729afSOlivier Houchard #define bus_space_read_region_1(t, h, o, a, c) \ 3646fc729afSOlivier Houchard __bs_nonsingle(rr,1,(t),(h),(o),(a),(c)) 3656fc729afSOlivier Houchard #define bus_space_read_region_2(t, h, o, a, c) \ 3666fc729afSOlivier Houchard __bs_nonsingle(rr,2,(t),(h),(o),(a),(c)) 3676fc729afSOlivier Houchard #define bus_space_read_region_4(t, h, o, a, c) \ 3686fc729afSOlivier Houchard __bs_nonsingle(rr,4,(t),(h),(o),(a),(c)) 3696fc729afSOlivier Houchard #define bus_space_read_region_8(t, h, o, a, c) \ 3706fc729afSOlivier Houchard __bs_nonsingle(rr,8,(t),(h),(o),(a),(c)) 3716fc729afSOlivier Houchard 372588a2322SSam Leffler #define bus_space_read_region_stream_1(t, h, o, a, c) \ 373588a2322SSam Leffler __bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c)) 374588a2322SSam Leffler #define bus_space_read_region_stream_2(t, h, o, a, c) \ 375588a2322SSam Leffler __bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c)) 376588a2322SSam Leffler #define bus_space_read_region_stream_4(t, h, o, a, c) \ 377588a2322SSam Leffler __bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c)) 378588a2322SSam Leffler #define bus_space_read_region_stream_8(t, h, o, a, c) \ 379588a2322SSam Leffler __bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c)) 380588a2322SSam Leffler 3816fc729afSOlivier Houchard /* 3826fc729afSOlivier Houchard * Bus write (single) operations. 3836fc729afSOlivier Houchard */ 38416e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_1, bs_w_1, uint8_t); 38516e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_2, bs_w_2, uint16_t); 38616e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_4, bs_w_4, uint32_t); 38716e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_8, bs_w_8, uint64_t); 3886fc729afSOlivier Houchard 38916e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_1, bs_w_1_s, uint8_t); 39016e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_2, bs_w_2_s, uint16_t); 39116e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_4, bs_w_4_s, uint32_t); 39216e2dc66SIan Lepore __generate_inline_bs_ws(bus_space_write_stream_8, bs_w_8_s, uint64_t); 393588a2322SSam Leffler 3946fc729afSOlivier Houchard /* 3956fc729afSOlivier Houchard * Bus write multiple operations. 3966fc729afSOlivier Houchard */ 3976fc729afSOlivier Houchard #define bus_space_write_multi_1(t, h, o, a, c) \ 3986fc729afSOlivier Houchard __bs_nonsingle(wm,1,(t),(h),(o),(a),(c)) 3996fc729afSOlivier Houchard #define bus_space_write_multi_2(t, h, o, a, c) \ 4006fc729afSOlivier Houchard __bs_nonsingle(wm,2,(t),(h),(o),(a),(c)) 4016fc729afSOlivier Houchard #define bus_space_write_multi_4(t, h, o, a, c) \ 4026fc729afSOlivier Houchard __bs_nonsingle(wm,4,(t),(h),(o),(a),(c)) 4036fc729afSOlivier Houchard #define bus_space_write_multi_8(t, h, o, a, c) \ 4046fc729afSOlivier Houchard __bs_nonsingle(wm,8,(t),(h),(o),(a),(c)) 4056fc729afSOlivier Houchard 406588a2322SSam Leffler #define bus_space_write_multi_stream_1(t, h, o, a, c) \ 407588a2322SSam Leffler __bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c)) 408588a2322SSam Leffler #define bus_space_write_multi_stream_2(t, h, o, a, c) \ 409588a2322SSam Leffler __bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c)) 410588a2322SSam Leffler #define bus_space_write_multi_stream_4(t, h, o, a, c) \ 411588a2322SSam Leffler __bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c)) 412588a2322SSam Leffler #define bus_space_write_multi_stream_8(t, h, o, a, c) \ 413588a2322SSam Leffler __bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c)) 414588a2322SSam Leffler 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 * Set multiple operations. 4386fc729afSOlivier Houchard */ 4396fc729afSOlivier Houchard #define bus_space_set_multi_1(t, h, o, v, c) \ 4406fc729afSOlivier Houchard __bs_set(sm,1,(t),(h),(o),(v),(c)) 4416fc729afSOlivier Houchard #define bus_space_set_multi_2(t, h, o, v, c) \ 4426fc729afSOlivier Houchard __bs_set(sm,2,(t),(h),(o),(v),(c)) 4436fc729afSOlivier Houchard #define bus_space_set_multi_4(t, h, o, v, c) \ 4446fc729afSOlivier Houchard __bs_set(sm,4,(t),(h),(o),(v),(c)) 4456fc729afSOlivier Houchard #define bus_space_set_multi_8(t, h, o, v, c) \ 4466fc729afSOlivier Houchard __bs_set(sm,8,(t),(h),(o),(v),(c)) 4476fc729afSOlivier Houchard 4486fc729afSOlivier Houchard /* 4496fc729afSOlivier Houchard * Set region operations. 4506fc729afSOlivier Houchard */ 4516fc729afSOlivier Houchard #define bus_space_set_region_1(t, h, o, v, c) \ 4526fc729afSOlivier Houchard __bs_set(sr,1,(t),(h),(o),(v),(c)) 4536fc729afSOlivier Houchard #define bus_space_set_region_2(t, h, o, v, c) \ 4546fc729afSOlivier Houchard __bs_set(sr,2,(t),(h),(o),(v),(c)) 4556fc729afSOlivier Houchard #define bus_space_set_region_4(t, h, o, v, c) \ 4566fc729afSOlivier Houchard __bs_set(sr,4,(t),(h),(o),(v),(c)) 4576fc729afSOlivier Houchard #define bus_space_set_region_8(t, h, o, v, c) \ 4586fc729afSOlivier Houchard __bs_set(sr,8,(t),(h),(o),(v),(c)) 4596fc729afSOlivier Houchard 4606fc729afSOlivier Houchard /* 4616fc729afSOlivier Houchard * Copy operations. 4626fc729afSOlivier Houchard */ 4636fc729afSOlivier Houchard #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ 4646fc729afSOlivier Houchard __bs_copy(1, t, h1, o1, h2, o2, c) 4656fc729afSOlivier Houchard #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ 4666fc729afSOlivier Houchard __bs_copy(2, t, h1, o1, h2, o2, c) 4676fc729afSOlivier Houchard #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ 4686fc729afSOlivier Houchard __bs_copy(4, t, h1, o1, h2, o2, c) 4696fc729afSOlivier Houchard #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ 4706fc729afSOlivier Houchard __bs_copy(8, t, h1, o1, h2, o2, c) 4716fc729afSOlivier Houchard 4726fc729afSOlivier Houchard /* 4736fc729afSOlivier Houchard * Macros to provide prototypes for all the functions used in the 4746fc729afSOlivier Houchard * bus_space structure 4756fc729afSOlivier Houchard */ 4766fc729afSOlivier Houchard 4776fc729afSOlivier Houchard #define bs_map_proto(f) \ 4784098ccafSIan Lepore int __bs_c(f,_bs_map) (bus_space_tag_t t, bus_addr_t addr, \ 4796fc729afSOlivier Houchard bus_size_t size, int cacheable, bus_space_handle_t *bshp); 4806fc729afSOlivier Houchard 4816fc729afSOlivier Houchard #define bs_unmap_proto(f) \ 4824098ccafSIan Lepore void __bs_c(f,_bs_unmap) (bus_space_tag_t t, bus_space_handle_t bsh, \ 483588a2322SSam Leffler bus_size_t size); 4846fc729afSOlivier Houchard 4856fc729afSOlivier Houchard #define bs_subregion_proto(f) \ 4864098ccafSIan Lepore int __bs_c(f,_bs_subregion) (bus_space_tag_t t, bus_space_handle_t bsh, \ 4876fc729afSOlivier Houchard bus_size_t offset, bus_size_t size, \ 4886fc729afSOlivier Houchard bus_space_handle_t *nbshp); 4896fc729afSOlivier Houchard 4906fc729afSOlivier Houchard #define bs_alloc_proto(f) \ 4914098ccafSIan Lepore int __bs_c(f,_bs_alloc) (bus_space_tag_t t, bus_addr_t rstart, \ 4926fc729afSOlivier Houchard bus_addr_t rend, bus_size_t size, bus_size_t align, \ 4936fc729afSOlivier Houchard bus_size_t boundary, int cacheable, bus_addr_t *addrp, \ 4946fc729afSOlivier Houchard bus_space_handle_t *bshp); 4956fc729afSOlivier Houchard 4966fc729afSOlivier Houchard #define bs_free_proto(f) \ 4974098ccafSIan Lepore void __bs_c(f,_bs_free) (bus_space_tag_t t, bus_space_handle_t bsh, \ 4986fc729afSOlivier Houchard bus_size_t size); 4996fc729afSOlivier Houchard 5006fc729afSOlivier Houchard #define bs_mmap_proto(f) \ 50189c9c53dSPoul-Henning Kamp int __bs_c(f,_bs_mmap) (struct cdev *, vm_offset_t, vm_paddr_t *, int); 5026fc729afSOlivier Houchard 5036fc729afSOlivier Houchard #define bs_barrier_proto(f) \ 5044098ccafSIan Lepore void __bs_c(f,_bs_barrier) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5056fc729afSOlivier Houchard bus_size_t offset, bus_size_t len, int flags); 5066fc729afSOlivier Houchard 5076fc729afSOlivier Houchard #define bs_r_1_proto(f) \ 5084098ccafSIan Lepore uint8_t __bs_c(f,_bs_r_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5096fc729afSOlivier Houchard bus_size_t offset); 5106fc729afSOlivier Houchard 5116fc729afSOlivier Houchard #define bs_r_2_proto(f) \ 5124098ccafSIan Lepore uint16_t __bs_c(f,_bs_r_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5136fc729afSOlivier Houchard bus_size_t offset); 5146fc729afSOlivier Houchard 5156fc729afSOlivier Houchard #define bs_r_4_proto(f) \ 5164098ccafSIan Lepore uint32_t __bs_c(f,_bs_r_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5176fc729afSOlivier Houchard bus_size_t offset); 5186fc729afSOlivier Houchard 5196fc729afSOlivier Houchard #define bs_r_8_proto(f) \ 5204098ccafSIan Lepore uint64_t __bs_c(f,_bs_r_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5216fc729afSOlivier Houchard bus_size_t offset); 5226fc729afSOlivier Houchard 523588a2322SSam Leffler #define bs_r_1_s_proto(f) \ 5244098ccafSIan Lepore uint8_t __bs_c(f,_bs_r_1_s) (bus_space_tag_t t, bus_space_handle_t bsh, \ 525588a2322SSam Leffler bus_size_t offset); 526588a2322SSam Leffler 527588a2322SSam Leffler #define bs_r_2_s_proto(f) \ 5284098ccafSIan Lepore uint16_t __bs_c(f,_bs_r_2_s) (bus_space_tag_t t, bus_space_handle_t bsh, \ 529588a2322SSam Leffler bus_size_t offset); 530588a2322SSam Leffler 531588a2322SSam Leffler #define bs_r_4_s_proto(f) \ 5324098ccafSIan Lepore uint32_t __bs_c(f,_bs_r_4_s) (bus_space_tag_t t, bus_space_handle_t bsh, \ 533588a2322SSam Leffler bus_size_t offset); 534588a2322SSam Leffler 5356fc729afSOlivier Houchard #define bs_w_1_proto(f) \ 5364098ccafSIan Lepore void __bs_c(f,_bs_w_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5374098ccafSIan Lepore bus_size_t offset, uint8_t value); 5386fc729afSOlivier Houchard 5396fc729afSOlivier Houchard #define bs_w_2_proto(f) \ 5404098ccafSIan Lepore void __bs_c(f,_bs_w_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5414098ccafSIan Lepore bus_size_t offset, uint16_t value); 5426fc729afSOlivier Houchard 5436fc729afSOlivier Houchard #define bs_w_4_proto(f) \ 5444098ccafSIan Lepore void __bs_c(f,_bs_w_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5454098ccafSIan Lepore bus_size_t offset, uint32_t value); 5466fc729afSOlivier Houchard 5476fc729afSOlivier Houchard #define bs_w_8_proto(f) \ 5484098ccafSIan Lepore void __bs_c(f,_bs_w_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5494098ccafSIan Lepore bus_size_t offset, uint64_t value); 5506fc729afSOlivier Houchard 551588a2322SSam Leffler #define bs_w_1_s_proto(f) \ 5524098ccafSIan Lepore void __bs_c(f,_bs_w_1_s) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5534098ccafSIan Lepore bus_size_t offset, uint8_t value); 554588a2322SSam Leffler 555588a2322SSam Leffler #define bs_w_2_s_proto(f) \ 5564098ccafSIan Lepore void __bs_c(f,_bs_w_2_s) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5574098ccafSIan Lepore bus_size_t offset, uint16_t value); 558588a2322SSam Leffler 559588a2322SSam Leffler #define bs_w_4_s_proto(f) \ 5604098ccafSIan Lepore void __bs_c(f,_bs_w_4_s) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5614098ccafSIan Lepore bus_size_t offset, uint32_t value); 562588a2322SSam Leffler 5636fc729afSOlivier Houchard #define bs_rm_1_proto(f) \ 5644098ccafSIan Lepore void __bs_c(f,_bs_rm_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5654098ccafSIan Lepore bus_size_t offset, uint8_t *addr, bus_size_t count); 5666fc729afSOlivier Houchard 5676fc729afSOlivier Houchard #define bs_rm_2_proto(f) \ 5684098ccafSIan Lepore void __bs_c(f,_bs_rm_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5694098ccafSIan Lepore bus_size_t offset, uint16_t *addr, bus_size_t count); 5706fc729afSOlivier Houchard 5716fc729afSOlivier Houchard #define bs_rm_4_proto(f) \ 5724098ccafSIan Lepore void __bs_c(f,_bs_rm_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5734098ccafSIan Lepore bus_size_t offset, uint32_t *addr, bus_size_t count); 5746fc729afSOlivier Houchard 5756fc729afSOlivier Houchard #define bs_rm_8_proto(f) \ 5764098ccafSIan Lepore void __bs_c(f,_bs_rm_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5774098ccafSIan Lepore bus_size_t offset, uint64_t *addr, bus_size_t count); 5786fc729afSOlivier Houchard 5796fc729afSOlivier Houchard #define bs_wm_1_proto(f) \ 5804098ccafSIan Lepore void __bs_c(f,_bs_wm_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5814098ccafSIan Lepore bus_size_t offset, const uint8_t *addr, bus_size_t count); 5826fc729afSOlivier Houchard 5836fc729afSOlivier Houchard #define bs_wm_2_proto(f) \ 5844098ccafSIan Lepore void __bs_c(f,_bs_wm_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5854098ccafSIan Lepore bus_size_t offset, const uint16_t *addr, bus_size_t count); 5866fc729afSOlivier Houchard 5876fc729afSOlivier Houchard #define bs_wm_4_proto(f) \ 5884098ccafSIan Lepore void __bs_c(f,_bs_wm_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5894098ccafSIan Lepore bus_size_t offset, const uint32_t *addr, bus_size_t count); 5906fc729afSOlivier Houchard 5916fc729afSOlivier Houchard #define bs_wm_8_proto(f) \ 5924098ccafSIan Lepore void __bs_c(f,_bs_wm_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5934098ccafSIan Lepore bus_size_t offset, const uint64_t *addr, bus_size_t count); 5946fc729afSOlivier Houchard 5956fc729afSOlivier Houchard #define bs_rr_1_proto(f) \ 5964098ccafSIan Lepore void __bs_c(f, _bs_rr_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 5974098ccafSIan Lepore bus_size_t offset, uint8_t *addr, bus_size_t count); 5986fc729afSOlivier Houchard 5996fc729afSOlivier Houchard #define bs_rr_2_proto(f) \ 6004098ccafSIan Lepore void __bs_c(f, _bs_rr_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6014098ccafSIan Lepore bus_size_t offset, uint16_t *addr, bus_size_t count); 6026fc729afSOlivier Houchard 6036fc729afSOlivier Houchard #define bs_rr_4_proto(f) \ 6044098ccafSIan Lepore void __bs_c(f, _bs_rr_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6054098ccafSIan Lepore bus_size_t offset, uint32_t *addr, bus_size_t count); 6066fc729afSOlivier Houchard 6076fc729afSOlivier Houchard #define bs_rr_8_proto(f) \ 6084098ccafSIan Lepore void __bs_c(f, _bs_rr_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6094098ccafSIan Lepore bus_size_t offset, uint64_t *addr, bus_size_t count); 6106fc729afSOlivier Houchard 6116fc729afSOlivier Houchard #define bs_wr_1_proto(f) \ 6124098ccafSIan Lepore void __bs_c(f, _bs_wr_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6134098ccafSIan Lepore bus_size_t offset, const uint8_t *addr, bus_size_t count); 6146fc729afSOlivier Houchard 6156fc729afSOlivier Houchard #define bs_wr_2_proto(f) \ 6164098ccafSIan Lepore void __bs_c(f, _bs_wr_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6174098ccafSIan Lepore bus_size_t offset, const uint16_t *addr, bus_size_t count); 6186fc729afSOlivier Houchard 6196fc729afSOlivier Houchard #define bs_wr_4_proto(f) \ 6204098ccafSIan Lepore void __bs_c(f, _bs_wr_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6214098ccafSIan Lepore bus_size_t offset, const uint32_t *addr, bus_size_t count); 6226fc729afSOlivier Houchard 6236fc729afSOlivier Houchard #define bs_wr_8_proto(f) \ 6244098ccafSIan Lepore void __bs_c(f, _bs_wr_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6254098ccafSIan Lepore bus_size_t offset, const uint64_t *addr, bus_size_t count); 6266fc729afSOlivier Houchard 6276fc729afSOlivier Houchard #define bs_sm_1_proto(f) \ 6284098ccafSIan Lepore void __bs_c(f,_bs_sm_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6294098ccafSIan Lepore bus_size_t offset, uint8_t value, bus_size_t count); 6306fc729afSOlivier Houchard 6316fc729afSOlivier Houchard #define bs_sm_2_proto(f) \ 6324098ccafSIan Lepore void __bs_c(f,_bs_sm_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6334098ccafSIan Lepore bus_size_t offset, uint16_t value, bus_size_t count); 6346fc729afSOlivier Houchard 6356fc729afSOlivier Houchard #define bs_sm_4_proto(f) \ 6364098ccafSIan Lepore void __bs_c(f,_bs_sm_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6374098ccafSIan Lepore bus_size_t offset, uint32_t value, bus_size_t count); 6386fc729afSOlivier Houchard 6396fc729afSOlivier Houchard #define bs_sm_8_proto(f) \ 6404098ccafSIan Lepore void __bs_c(f,_bs_sm_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6414098ccafSIan Lepore bus_size_t offset, uint64_t value, bus_size_t count); 6426fc729afSOlivier Houchard 6436fc729afSOlivier Houchard #define bs_sr_1_proto(f) \ 6444098ccafSIan Lepore void __bs_c(f,_bs_sr_1) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6454098ccafSIan Lepore bus_size_t offset, uint8_t value, bus_size_t count); 6466fc729afSOlivier Houchard 6476fc729afSOlivier Houchard #define bs_sr_2_proto(f) \ 6484098ccafSIan Lepore void __bs_c(f,_bs_sr_2) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6494098ccafSIan Lepore bus_size_t offset, uint16_t value, bus_size_t count); 6506fc729afSOlivier Houchard 6516fc729afSOlivier Houchard #define bs_sr_4_proto(f) \ 6524098ccafSIan Lepore void __bs_c(f,_bs_sr_4) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6534098ccafSIan Lepore bus_size_t offset, uint32_t value, bus_size_t count); 6546fc729afSOlivier Houchard 6556fc729afSOlivier Houchard #define bs_sr_8_proto(f) \ 6564098ccafSIan Lepore void __bs_c(f,_bs_sr_8) (bus_space_tag_t t, bus_space_handle_t bsh, \ 6574098ccafSIan Lepore bus_size_t offset, uint64_t value, bus_size_t count); 6586fc729afSOlivier Houchard 6596fc729afSOlivier Houchard #define bs_c_1_proto(f) \ 6604098ccafSIan Lepore void __bs_c(f,_bs_c_1) (bus_space_tag_t t, bus_space_handle_t bsh1, \ 6616fc729afSOlivier Houchard bus_size_t offset1, bus_space_handle_t bsh2, \ 6626fc729afSOlivier Houchard bus_size_t offset2, bus_size_t count); 6636fc729afSOlivier Houchard 6646fc729afSOlivier Houchard #define bs_c_2_proto(f) \ 6654098ccafSIan Lepore void __bs_c(f,_bs_c_2) (bus_space_tag_t t, bus_space_handle_t bsh1, \ 6666fc729afSOlivier Houchard bus_size_t offset1, bus_space_handle_t bsh2, \ 6676fc729afSOlivier Houchard bus_size_t offset2, bus_size_t count); 6686fc729afSOlivier Houchard 6696fc729afSOlivier Houchard #define bs_c_4_proto(f) \ 6704098ccafSIan Lepore void __bs_c(f,_bs_c_4) (bus_space_tag_t t, bus_space_handle_t bsh1, \ 6716fc729afSOlivier Houchard bus_size_t offset1, bus_space_handle_t bsh2, \ 6726fc729afSOlivier Houchard bus_size_t offset2, bus_size_t count); 6736fc729afSOlivier Houchard 6746fc729afSOlivier Houchard #define bs_c_8_proto(f) \ 6754098ccafSIan Lepore void __bs_c(f,_bs_c_8) (bus_space_tag_t t, bus_space_handle_t bsh1, \ 6766fc729afSOlivier Houchard bus_size_t offset1, bus_space_handle_t bsh2, \ 6776fc729afSOlivier Houchard bus_size_t offset2, bus_size_t count); 6786fc729afSOlivier Houchard 6796fc729afSOlivier Houchard #define bs_protos(f) \ 6806fc729afSOlivier Houchard bs_map_proto(f); \ 6816fc729afSOlivier Houchard bs_unmap_proto(f); \ 6826fc729afSOlivier Houchard bs_subregion_proto(f); \ 6836fc729afSOlivier Houchard bs_alloc_proto(f); \ 6846fc729afSOlivier Houchard bs_free_proto(f); \ 6856fc729afSOlivier Houchard bs_mmap_proto(f); \ 6866fc729afSOlivier Houchard bs_barrier_proto(f); \ 6876fc729afSOlivier Houchard bs_r_1_proto(f); \ 6886fc729afSOlivier Houchard bs_r_2_proto(f); \ 6896fc729afSOlivier Houchard bs_r_4_proto(f); \ 6906fc729afSOlivier Houchard bs_r_8_proto(f); \ 691588a2322SSam Leffler bs_r_1_s_proto(f); \ 692588a2322SSam Leffler bs_r_2_s_proto(f); \ 693588a2322SSam Leffler bs_r_4_s_proto(f); \ 6946fc729afSOlivier Houchard bs_w_1_proto(f); \ 6956fc729afSOlivier Houchard bs_w_2_proto(f); \ 6966fc729afSOlivier Houchard bs_w_4_proto(f); \ 6976fc729afSOlivier Houchard bs_w_8_proto(f); \ 698588a2322SSam Leffler bs_w_1_s_proto(f); \ 699588a2322SSam Leffler bs_w_2_s_proto(f); \ 700588a2322SSam Leffler bs_w_4_s_proto(f); \ 7016fc729afSOlivier Houchard bs_rm_1_proto(f); \ 7026fc729afSOlivier Houchard bs_rm_2_proto(f); \ 7036fc729afSOlivier Houchard bs_rm_4_proto(f); \ 7046fc729afSOlivier Houchard bs_rm_8_proto(f); \ 7056fc729afSOlivier Houchard bs_wm_1_proto(f); \ 7066fc729afSOlivier Houchard bs_wm_2_proto(f); \ 7076fc729afSOlivier Houchard bs_wm_4_proto(f); \ 7086fc729afSOlivier Houchard bs_wm_8_proto(f); \ 7096fc729afSOlivier Houchard bs_rr_1_proto(f); \ 7106fc729afSOlivier Houchard bs_rr_2_proto(f); \ 7116fc729afSOlivier Houchard bs_rr_4_proto(f); \ 7126fc729afSOlivier Houchard bs_rr_8_proto(f); \ 7136fc729afSOlivier Houchard bs_wr_1_proto(f); \ 7146fc729afSOlivier Houchard bs_wr_2_proto(f); \ 7156fc729afSOlivier Houchard bs_wr_4_proto(f); \ 7166fc729afSOlivier Houchard bs_wr_8_proto(f); \ 7176fc729afSOlivier Houchard bs_sm_1_proto(f); \ 7186fc729afSOlivier Houchard bs_sm_2_proto(f); \ 7196fc729afSOlivier Houchard bs_sm_4_proto(f); \ 7206fc729afSOlivier Houchard bs_sm_8_proto(f); \ 7216fc729afSOlivier Houchard bs_sr_1_proto(f); \ 7226fc729afSOlivier Houchard bs_sr_2_proto(f); \ 7236fc729afSOlivier Houchard bs_sr_4_proto(f); \ 7246fc729afSOlivier Houchard bs_sr_8_proto(f); \ 7256fc729afSOlivier Houchard bs_c_1_proto(f); \ 7266fc729afSOlivier Houchard bs_c_2_proto(f); \ 7276fc729afSOlivier Houchard bs_c_4_proto(f); \ 7286fc729afSOlivier Houchard bs_c_8_proto(f); 7296fc729afSOlivier Houchard 7302737497bSIan Lepore void generic_bs_unimplemented(void); 7312737497bSIan Lepore #define BS_UNIMPLEMENTED (void *)generic_bs_unimplemented 7322737497bSIan Lepore 7336fc729afSOlivier Houchard #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 7346fc729afSOlivier Houchard 735a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF 736a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF 737a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXADDR 0xFFFFFFFF 738a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF 739a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF 740a5bb1c85SOlivier Houchard #define BUS_SPACE_MAXSIZE 0xFFFFFFFF 741a5bb1c85SOlivier Houchard 742b938b7a3SWarner Losh #define BUS_SPACE_UNRESTRICTED (~0) 743b938b7a3SWarner Losh 74495a85c12SMichal Meloun #define BUS_PEEK_FUNC(width, type) \ 74595a85c12SMichal Meloun static inline int \ 74695a85c12SMichal Meloun bus_space_peek_##width(bus_space_tag_t tag, \ 74795a85c12SMichal Meloun bus_space_handle_t hnd, bus_size_t offset, type *value) \ 74895a85c12SMichal Meloun { \ 74995a85c12SMichal Meloun type tmp; \ 75095a85c12SMichal Meloun tmp = bus_space_read_##width(tag, hnd, offset); \ 751*31820621SMichal Meloun *value = (type)tmp; \ 75295a85c12SMichal Meloun return (0); \ 75395a85c12SMichal Meloun } 75495a85c12SMichal Meloun BUS_PEEK_FUNC(1, uint8_t) 75595a85c12SMichal Meloun BUS_PEEK_FUNC(2, uint16_t) 75695a85c12SMichal Meloun BUS_PEEK_FUNC(4, uint32_t) 75795a85c12SMichal Meloun BUS_PEEK_FUNC(8, uint64_t) 75895a85c12SMichal Meloun 75995a85c12SMichal Meloun #define BUS_POKE_FUNC(width, type) \ 76095a85c12SMichal Meloun static inline int \ 76195a85c12SMichal Meloun bus_space_poke_##width(bus_space_tag_t tag, \ 76295a85c12SMichal Meloun bus_space_handle_t hnd, bus_size_t offset, type value) \ 76395a85c12SMichal Meloun { \ 76495a85c12SMichal Meloun bus_space_write_##width(tag, hnd, offset, value); \ 76595a85c12SMichal Meloun return (0); \ 76695a85c12SMichal Meloun } 76795a85c12SMichal Meloun BUS_POKE_FUNC(1, uint8_t) 76895a85c12SMichal Meloun BUS_POKE_FUNC(2, uint16_t) 76995a85c12SMichal Meloun BUS_POKE_FUNC(4, uint32_t) 77095a85c12SMichal Meloun BUS_POKE_FUNC(8, uint64_t) 77195a85c12SMichal Meloun 7725974e5c7SScott Long #include <machine/bus_dma.h> 7735974e5c7SScott Long 77433ff10eaSIan Lepore /* 77533ff10eaSIan Lepore * Get the physical address of a bus space memory-mapped resource. 77633ff10eaSIan Lepore * Doing this as a macro is a temporary solution until a more robust fix is 77733ff10eaSIan Lepore * designed. It also serves to mark the locations needing that fix. 77833ff10eaSIan Lepore */ 77933ff10eaSIan Lepore #define BUS_SPACE_PHYSADDR(res, offs) \ 7804117c1dbSAleksandr Rybalko ((u_int)(rman_get_start(res)+(offs))) 78133ff10eaSIan Lepore 7826fc729afSOlivier Houchard #endif /* _MACHINE_BUS_H_ */ 783