bus.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */
  2. /*-
  3. * SPDX-License-Identifier: BSD-2-Clause-NetBSD AND BSD-4-Clause
  4. *
  5. * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
  6. * All rights reserved.
  7. *
  8. * This code is derived from software contributed to The NetBSD Foundation
  9. * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
  10. * NASA Ames Research Center.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in the
  19. * documentation and/or other materials provided with the distribution.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  23. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  24. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  25. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. * POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. /*-
  34. * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
  35. * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
  36. *
  37. * Redistribution and use in source and binary forms, with or without
  38. * modification, are permitted provided that the following conditions
  39. * are met:
  40. * 1. Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * 2. Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in the
  44. * documentation and/or other materials provided with the distribution.
  45. * 3. All advertising materials mentioning features or use of this software
  46. * must display the following acknowledgement:
  47. * This product includes software developed by Christopher G. Demetriou
  48. * for the NetBSD Project.
  49. * 4. The name of the author may not be used to endorse or promote products
  50. * derived from this software without specific prior written permission
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  53. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  54. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  55. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  56. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  57. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  58. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  59. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  60. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  61. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  62. *
  63. * $FreeBSD$
  64. */
  65. #ifndef _MACHINE_BUS_H_
  66. #define _MACHINE_BUS_H_
  67. #include <machine/_bus.h>
  68. #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
  69. #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL
  70. #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL
  71. #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL
  72. #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL
  73. #ifdef __powerpc64__
  74. #define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFFUL
  75. #define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFFUL
  76. #else
  77. #ifdef BOOKE
  78. #define BUS_SPACE_MAXADDR 0xFFFFFFFFFULL
  79. #define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL
  80. #else
  81. #define BUS_SPACE_MAXADDR 0xFFFFFFFFUL
  82. #define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL
  83. #endif
  84. #endif
  85. #define BUS_SPACE_MAP_CACHEABLE 0x01
  86. #define BUS_SPACE_MAP_LINEAR 0x02
  87. #define BUS_SPACE_MAP_PREFETCHABLE 0x04
  88. #define BUS_SPACE_UNRESTRICTED (~0)
  89. #define BUS_SPACE_BARRIER_READ 0x01
  90. #define BUS_SPACE_BARRIER_WRITE 0x02
  91. struct bus_space_access;
  92. struct bus_space {
  93. /* mapping/unmapping */
  94. int (*bs_map)(bus_addr_t, bus_size_t, int,
  95. bus_space_handle_t *);
  96. void (*bs_unmap)(bus_size_t);
  97. int (*bs_subregion)(bus_space_handle_t, bus_size_t,
  98. bus_size_t, bus_space_handle_t *);
  99. /* allocation/deallocation */
  100. int (*bs_alloc)(bus_addr_t, bus_addr_t, bus_size_t,
  101. bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
  102. void (*bs_free)(bus_space_handle_t, bus_size_t);
  103. void (*bs_barrier)(bus_space_handle_t, bus_size_t,
  104. bus_size_t, int);
  105. /* Read single. */
  106. uint8_t (*bs_r_1)(bus_space_handle_t, bus_size_t);
  107. uint16_t (*bs_r_2)(bus_space_handle_t, bus_size_t);
  108. uint32_t (*bs_r_4)(bus_space_handle_t, bus_size_t);
  109. uint64_t (*bs_r_8)(bus_space_handle_t, bus_size_t);
  110. uint16_t (*bs_r_s_2)(bus_space_handle_t, bus_size_t);
  111. uint32_t (*bs_r_s_4)(bus_space_handle_t, bus_size_t);
  112. uint64_t (*bs_r_s_8)(bus_space_handle_t, bus_size_t);
  113. /* read multiple */
  114. void (*bs_rm_1)(bus_space_handle_t, bus_size_t, uint8_t *,
  115. bus_size_t);
  116. void (*bs_rm_2)(bus_space_handle_t, bus_size_t, uint16_t *,
  117. bus_size_t);
  118. void (*bs_rm_4)(bus_space_handle_t, bus_size_t, uint32_t *,
  119. bus_size_t);
  120. void (*bs_rm_8)(bus_space_handle_t, bus_size_t, uint64_t *,
  121. bus_size_t);
  122. void (*bs_rm_s_2)(bus_space_handle_t, bus_size_t, uint16_t *,
  123. bus_size_t);
  124. void (*bs_rm_s_4)(bus_space_handle_t, bus_size_t, uint32_t *,
  125. bus_size_t);
  126. void (*bs_rm_s_8)(bus_space_handle_t, bus_size_t, uint64_t *,
  127. bus_size_t);
  128. /* read region */
  129. void (*bs_rr_1)(bus_space_handle_t, bus_size_t, uint8_t *,
  130. bus_size_t);
  131. void (*bs_rr_2)(bus_space_handle_t, bus_size_t, uint16_t *,
  132. bus_size_t);
  133. void (*bs_rr_4)(bus_space_handle_t, bus_size_t, uint32_t *,
  134. bus_size_t);
  135. void (*bs_rr_8)(bus_space_handle_t, bus_size_t, uint64_t *,
  136. bus_size_t);
  137. void (*bs_rr_s_2)(bus_space_handle_t, bus_size_t, uint16_t *,
  138. bus_size_t);
  139. void (*bs_rr_s_4)(bus_space_handle_t, bus_size_t, uint32_t *,
  140. bus_size_t);
  141. void (*bs_rr_s_8)(bus_space_handle_t, bus_size_t, uint64_t *,
  142. bus_size_t);
  143. /* write */
  144. void (*bs_w_1)(bus_space_handle_t, bus_size_t, uint8_t);
  145. void (*bs_w_2)(bus_space_handle_t, bus_size_t, uint16_t);
  146. void (*bs_w_4)(bus_space_handle_t, bus_size_t, uint32_t);
  147. void (*bs_w_8)(bus_space_handle_t, bus_size_t, uint64_t);
  148. void (*bs_w_s_2)(bus_space_handle_t, bus_size_t, uint16_t);
  149. void (*bs_w_s_4)(bus_space_handle_t, bus_size_t, uint32_t);
  150. void (*bs_w_s_8)(bus_space_handle_t, bus_size_t, uint64_t);
  151. /* write multiple */
  152. void (*bs_wm_1)(bus_space_handle_t, bus_size_t,
  153. const uint8_t *, bus_size_t);
  154. void (*bs_wm_2)(bus_space_handle_t, bus_size_t,
  155. const uint16_t *, bus_size_t);
  156. void (*bs_wm_4)(bus_space_handle_t, bus_size_t,
  157. const uint32_t *, bus_size_t);
  158. void (*bs_wm_8)(bus_space_handle_t, bus_size_t,
  159. const uint64_t *, bus_size_t);
  160. void (*bs_wm_s_2)(bus_space_handle_t, bus_size_t,
  161. const uint16_t *, bus_size_t);
  162. void (*bs_wm_s_4)(bus_space_handle_t, bus_size_t,
  163. const uint32_t *, bus_size_t);
  164. void (*bs_wm_s_8)(bus_space_handle_t, bus_size_t,
  165. const uint64_t *, bus_size_t);
  166. /* write region */
  167. void (*bs_wr_1)(bus_space_handle_t, bus_size_t,
  168. const uint8_t *, bus_size_t);
  169. void (*bs_wr_2)(bus_space_handle_t, bus_size_t,
  170. const uint16_t *, bus_size_t);
  171. void (*bs_wr_4)(bus_space_handle_t, bus_size_t,
  172. const uint32_t *, bus_size_t);
  173. void (*bs_wr_8)(bus_space_handle_t, bus_size_t,
  174. const uint64_t *, bus_size_t);
  175. void (*bs_wr_s_2)(bus_space_handle_t, bus_size_t,
  176. const uint16_t *, bus_size_t);
  177. void (*bs_wr_s_4)(bus_space_handle_t, bus_size_t,
  178. const uint32_t *, bus_size_t);
  179. void (*bs_wr_s_8)(bus_space_handle_t, bus_size_t,
  180. const uint64_t *, bus_size_t);
  181. /* set multiple */
  182. void (*bs_sm_1)(bus_space_handle_t, bus_size_t, uint8_t,
  183. bus_size_t);
  184. void (*bs_sm_2)(bus_space_handle_t, bus_size_t, uint16_t,
  185. bus_size_t);
  186. void (*bs_sm_4)(bus_space_handle_t, bus_size_t, uint32_t,
  187. bus_size_t);
  188. void (*bs_sm_8)(bus_space_handle_t, bus_size_t, uint64_t,
  189. bus_size_t);
  190. void (*bs_sm_s_2)(bus_space_handle_t, bus_size_t, uint16_t,
  191. bus_size_t);
  192. void (*bs_sm_s_4)(bus_space_handle_t, bus_size_t, uint32_t,
  193. bus_size_t);
  194. void (*bs_sm_s_8)(bus_space_handle_t, bus_size_t, uint64_t,
  195. bus_size_t);
  196. /* set region */
  197. void (*bs_sr_1)(bus_space_handle_t, bus_size_t, uint8_t,
  198. bus_size_t);
  199. void (*bs_sr_2)(bus_space_handle_t, bus_size_t, uint16_t,
  200. bus_size_t);
  201. void (*bs_sr_4)(bus_space_handle_t, bus_size_t, uint32_t,
  202. bus_size_t);
  203. void (*bs_sr_8)(bus_space_handle_t, bus_size_t, uint64_t,
  204. bus_size_t);
  205. void (*bs_sr_s_2)(bus_space_handle_t, bus_size_t, uint16_t,
  206. bus_size_t);
  207. void (*bs_sr_s_4)(bus_space_handle_t, bus_size_t, uint32_t,
  208. bus_size_t);
  209. void (*bs_sr_s_8)(bus_space_handle_t, bus_size_t, uint64_t,
  210. bus_size_t);
  211. /* copy region */
  212. void (*bs_cr_1)(bus_space_handle_t, bus_size_t,
  213. bus_space_handle_t, bus_size_t, bus_size_t);
  214. void (*bs_cr_2)(bus_space_handle_t, bus_size_t,
  215. bus_space_handle_t, bus_size_t, bus_size_t);
  216. void (*bs_cr_4)(bus_space_handle_t, bus_size_t,
  217. bus_space_handle_t, bus_size_t, bus_size_t);
  218. void (*bs_cr_8)(bus_space_handle_t, bus_size_t,
  219. bus_space_handle_t, bus_size_t, bus_size_t);
  220. void (*bs_cr_s_2)(bus_space_handle_t, bus_size_t,
  221. bus_space_handle_t, bus_size_t, bus_size_t);
  222. void (*bs_cr_s_4)(bus_space_handle_t, bus_size_t,
  223. bus_space_handle_t, bus_size_t, bus_size_t);
  224. void (*bs_cr_s_8)(bus_space_handle_t, bus_size_t,
  225. bus_space_handle_t, bus_size_t, bus_size_t);
  226. };
  227. extern struct bus_space bs_be_tag;
  228. extern struct bus_space bs_le_tag;
  229. #define __bs_c(a,b) __CONCAT(a,b)
  230. #define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size)
  231. #define __bs_rs(sz, t, h, o) \
  232. (*(t)->__bs_opname(r,sz))(h, o)
  233. #define __bs_ws(sz, t, h, o, v) \
  234. (*(t)->__bs_opname(w,sz))(h, o, v)
  235. #define __bs_nonsingle(type, sz, t, h, o, a, c) \
  236. (*(t)->__bs_opname(type,sz))(h, o, a, c)
  237. #define __bs_set(type, sz, t, h, o, v, c) \
  238. (*(t)->__bs_opname(type,sz))(h, o, v, c)
  239. #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \
  240. (*(t)->__bs_opname(c,sz))(h1, o1, h2, o2, cnt)
  241. /*
  242. * Mapping and unmapping operations.
  243. */
  244. #define bus_space_map(t, a, s, c, hp) (*(t)->bs_map)(a, s, c, hp)
  245. #define bus_space_unmap(t, h, s) (*(t)->bs_unmap)(h, s)
  246. #define bus_space_subregion(t, h, o, s, hp) (*(t)->bs_subregion)(h, o, s, hp)
  247. /*
  248. * Allocation and deallocation operations.
  249. */
  250. #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \
  251. (*(t)->bs_alloc)(rs, re, s, a, b, c, ap, hp)
  252. #define bus_space_free(t, h, s) \
  253. (*(t)->bs_free)(h, s)
  254. /*
  255. * Bus barrier operations.
  256. */
  257. #define bus_space_barrier(t, h, o, l, f) (*(t)->bs_barrier)(h, o, l, f)
  258. /*
  259. * Bus read (single) operations.
  260. */
  261. #define bus_space_read_1(t, h, o) __bs_rs(1,t,h,o)
  262. #define bus_space_read_2(t, h, o) __bs_rs(2,t,h,o)
  263. #define bus_space_read_4(t, h, o) __bs_rs(4,t,h,o)
  264. #define bus_space_read_8(t, h, o) __bs_rs(8,t,h,o)
  265. #define bus_space_read_stream_1 bus_space_read_1
  266. #define bus_space_read_stream_2(t, h, o) __bs_rs(s_2,t,h,o)
  267. #define bus_space_read_stream_4(t, h, o) __bs_rs(s_4,t,h,o)
  268. #define bus_space_read_stream_8(t, h, o) __bs_rs(s_8,t,h,o)
  269. /*
  270. * Bus read multiple operations.
  271. */
  272. #define bus_space_read_multi_1(t, h, o, a, c) \
  273. __bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
  274. #define bus_space_read_multi_2(t, h, o, a, c) \
  275. __bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
  276. #define bus_space_read_multi_4(t, h, o, a, c) \
  277. __bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
  278. #define bus_space_read_multi_8(t, h, o, a, c) \
  279. __bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
  280. #define bus_space_read_multi_stream_1 bus_space_read_multi_1
  281. #define bus_space_read_multi_stream_2(t, h, o, a, c) \
  282. __bs_nonsingle(rm,s_2,(t),(h),(o),(a),(c))
  283. #define bus_space_read_multi_stream_4(t, h, o, a, c) \
  284. __bs_nonsingle(rm,s_4,(t),(h),(o),(a),(c))
  285. #define bus_space_read_multi_stream_8(t, h, o, a, c) \
  286. __bs_nonsingle(rm,s_8,(t),(h),(o),(a),(c))
  287. /*
  288. * Bus read region operations.
  289. */
  290. #define bus_space_read_region_1(t, h, o, a, c) \
  291. __bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
  292. #define bus_space_read_region_2(t, h, o, a, c) \
  293. __bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
  294. #define bus_space_read_region_4(t, h, o, a, c) \
  295. __bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
  296. #define bus_space_read_region_8(t, h, o, a, c) \
  297. __bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
  298. #define bus_space_read_region_stream_1 bus_space_read_region_1
  299. #define bus_space_read_region_stream_2(t, h, o, a, c) \
  300. __bs_nonsingle(rr,s_2,(t),(h),(o),(a),(c))
  301. #define bus_space_read_region_stream_4(t, h, o, a, c) \
  302. __bs_nonsingle(rr,s_4,(t),(h),(o),(a),(c))
  303. #define bus_space_read_region_stream_8(t, h, o, a, c) \
  304. __bs_nonsingle(rr,s_8,(t),(h),(o),(a),(c))
  305. /*
  306. * Bus write (single) operations.
  307. */
  308. #define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v))
  309. #define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v))
  310. #define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v))
  311. #define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v))
  312. #define bus_space_write_stream_1 bus_space_write_1
  313. #define bus_space_write_stream_2(t, h, o, v) __bs_ws(s_2,(t),(h),(o),(v))
  314. #define bus_space_write_stream_4(t, h, o, v) __bs_ws(s_4,(t),(h),(o),(v))
  315. #define bus_space_write_stream_8(t, h, o, v) __bs_ws(s_8,(t),(h),(o),(v))
  316. /*
  317. * Bus write multiple operations.
  318. */
  319. #define bus_space_write_multi_1(t, h, o, a, c) \
  320. __bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
  321. #define bus_space_write_multi_2(t, h, o, a, c) \
  322. __bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
  323. #define bus_space_write_multi_4(t, h, o, a, c) \
  324. __bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
  325. #define bus_space_write_multi_8(t, h, o, a, c) \
  326. __bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
  327. #define bus_space_write_multi_stream_1 bus_space_write_multi_1
  328. #define bus_space_write_multi_stream_2(t, h, o, a, c) \
  329. __bs_nonsingle(wm,s_2,(t),(h),(o),(a),(c))
  330. #define bus_space_write_multi_stream_4(t, h, o, a, c) \
  331. __bs_nonsingle(wm,s_4,(t),(h),(o),(a),(c))
  332. #define bus_space_write_multi_stream_8(t, h, o, a, c) \
  333. __bs_nonsingle(wm,s_8,(t),(h),(o),(a),(c))
  334. /*
  335. * Bus write region operations.
  336. */
  337. #define bus_space_write_region_1(t, h, o, a, c) \
  338. __bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
  339. #define bus_space_write_region_2(t, h, o, a, c) \
  340. __bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
  341. #define bus_space_write_region_4(t, h, o, a, c) \
  342. __bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
  343. #define bus_space_write_region_8(t, h, o, a, c) \
  344. __bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
  345. #define bus_space_write_region_stream_1 bus_space_write_region_1
  346. #define bus_space_write_region_stream_2(t, h, o, a, c) \
  347. __bs_nonsingle(wr,s_2,(t),(h),(o),(a),(c))
  348. #define bus_space_write_region_stream_4(t, h, o, a, c) \
  349. __bs_nonsingle(wr,s_4,(t),(h),(o),(a),(c))
  350. #define bus_space_write_region_stream_8(t, h, o, a, c) \
  351. __bs_nonsingle(wr,s_8,(t),(h),(o),(a),(c))
  352. /*
  353. * Set multiple operations.
  354. */
  355. #define bus_space_set_multi_1(t, h, o, v, c) \
  356. __bs_set(sm,1,(t),(h),(o),(v),(c))
  357. #define bus_space_set_multi_2(t, h, o, v, c) \
  358. __bs_set(sm,2,(t),(h),(o),(v),(c))
  359. #define bus_space_set_multi_4(t, h, o, v, c) \
  360. __bs_set(sm,4,(t),(h),(o),(v),(c))
  361. #define bus_space_set_multi_8(t, h, o, v, c) \
  362. __bs_set(sm,8,(t),(h),(o),(v),(c))
  363. #define bus_space_set_multi_stream_1 bus_space_set_multi_1
  364. #define bus_space_set_multi_stream_2(t, h, o, v, c) \
  365. __bs_set(sm,s_2,(t),(h),(o),(v),(c))
  366. #define bus_space_set_multi_stream_4(t, h, o, v, c) \
  367. __bs_set(sm,s_4,(t),(h),(o),(v),(c))
  368. #define bus_space_set_multi_stream_8(t, h, o, v, c) \
  369. __bs_set(sm,s_8,(t),(h),(o),(v),(c))
  370. /*
  371. * Set region operations.
  372. */
  373. #define bus_space_set_region_1(t, h, o, v, c) \
  374. __bs_set(sr,1,(t),(h),(o),(v),(c))
  375. #define bus_space_set_region_2(t, h, o, v, c) \
  376. __bs_set(sr,2,(t),(h),(o),(v),(c))
  377. #define bus_space_set_region_4(t, h, o, v, c) \
  378. __bs_set(sr,4,(t),(h),(o),(v),(c))
  379. #define bus_space_set_region_8(t, h, o, v, c) \
  380. __bs_set(sr,8,(t),(h),(o),(v),(c))
  381. #define bus_space_set_region_stream_1 bus_space_set_region_1
  382. #define bus_space_set_region_stream_2(t, h, o, v, c) \
  383. __bs_set(sr,s_2,(t),(h),(o),(v),(c))
  384. #define bus_space_set_region_stream_4(t, h, o, v, c) \
  385. __bs_set(sr,s_4,(t),(h),(o),(v),(c))
  386. #define bus_space_set_region_stream_8(t, h, o, v, c) \
  387. __bs_set(sr,s_8,(t),(h),(o),(v),(c))
  388. #if 0
  389. /*
  390. * Copy operations.
  391. */
  392. #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
  393. __bs_copy(1, t, h1, o1, h2, o2, c)
  394. #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
  395. __bs_copy(2, t, h1, o1, h2, o2, c)
  396. #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
  397. __bs_copy(4, t, h1, o1, h2, o2, c)
  398. #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
  399. __bs_copy(8, t, h1, o1, h2, o2, c)
  400. #define bus_space_copy_region_stream_1 bus_space_copy_region_1
  401. #define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
  402. __bs_copy(s_2, t, h1, o1, h2, o2, c)
  403. #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
  404. __bs_copy(s_4, t, h1, o1, h2, o2, c)
  405. #define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c) \
  406. __bs_copy(s_8, t, h1, o1, h2, o2, c)
  407. #endif
  408. #define BUS_PEEK_FUNC(width, type) \
  409. static inline int \
  410. bus_space_peek_##width(bus_space_tag_t tag, \
  411. bus_space_handle_t hnd, bus_size_t offset, type *value) \
  412. { \
  413. type tmp; \
  414. tmp = bus_space_read_##width(tag, hnd, offset); \
  415. *value = (type)tmp; \
  416. return (0); \
  417. }
  418. BUS_PEEK_FUNC(1, uint8_t)
  419. BUS_PEEK_FUNC(2, uint16_t)
  420. BUS_PEEK_FUNC(4, uint32_t)
  421. BUS_PEEK_FUNC(8, uint64_t)
  422. #define BUS_POKE_FUNC(width, type) \
  423. static inline int \
  424. bus_space_poke_##width(bus_space_tag_t tag, \
  425. bus_space_handle_t hnd, bus_size_t offset, type value) \
  426. { \
  427. bus_space_write_##width(tag, hnd, offset, value); \
  428. return (0); \
  429. }
  430. BUS_POKE_FUNC(1, uint8_t)
  431. BUS_POKE_FUNC(2, uint16_t)
  432. BUS_POKE_FUNC(4, uint32_t)
  433. BUS_POKE_FUNC(8, uint64_t)
  434. #include <machine/bus_dma.h>
  435. #endif /* _MACHINE_BUS_H_ */