bus.h revision 202175
1193326Sed/* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */ 2193326Sed 3193326Sed/*- 4193326Sed * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. 5193326Sed * All rights reserved. 6193326Sed * 7193326Sed * This code is derived from software contributed to The NetBSD Foundation 8193326Sed * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9193326Sed * NASA Ames Research Center. 10193326Sed * 11193326Sed * Redistribution and use in source and binary forms, with or without 12193326Sed * modification, are permitted provided that the following conditions 13193326Sed * are met: 14193326Sed * 1. Redistributions of source code must retain the above copyright 15193326Sed * notice, this list of conditions and the following disclaimer. 16193326Sed * 2. Redistributions in binary form must reproduce the above copyright 17198092Srdivacky * notice, this list of conditions and the following disclaimer in the 18193326Sed * documentation and/or other materials provided with the distribution. 19193326Sed * 3. All advertising materials mentioning features or use of this software 20234353Sdim * must display the following acknowledgement: 21193326Sed * This product includes software developed by the NetBSD 22193326Sed * Foundation, Inc. and its contributors. 23193326Sed * 4. Neither the name of The NetBSD Foundation nor the names of its 24193326Sed * contributors may be used to endorse or promote products derived 25219077Sdim * from this software without specific prior written permission. 26193326Sed * 27193326Sed * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28198092Srdivacky * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29193326Sed * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30219077Sdim * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31195341Sed * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32193326Sed * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33193326Sed * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34239462Sdim * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35193326Sed * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36193326Sed * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37193326Sed * POSSIBILITY OF SUCH DAMAGE. 38193326Sed */ 39193326Sed 40234353Sdim/*- 41234353Sdim * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 42234353Sdim * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 43193326Sed * 44219077Sdim * Redistribution and use in source and binary forms, with or without 45219077Sdim * modification, are permitted provided that the following conditions 46219077Sdim * are met: 47219077Sdim * 1. Redistributions of source code must retain the above copyright 48219077Sdim * notice, this list of conditions and the following disclaimer. 49219077Sdim * 2. Redistributions in binary form must reproduce the above copyright 50219077Sdim * notice, this list of conditions and the following disclaimer in the 51219077Sdim * documentation and/or other materials provided with the distribution. 52219077Sdim * 3. All advertising materials mentioning features or use of this software 53193326Sed * must display the following acknowledgement: 54193326Sed * This product includes software developed by Christopher G. Demetriou 55193326Sed * for the NetBSD Project. 56193326Sed * 4. The name of the author may not be used to endorse or promote products 57193326Sed * derived from this software without specific prior written permission 58193326Sed * 59219077Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 60193326Sed * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 61193326Sed * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 62193326Sed * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 63193326Sed * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 64193326Sed * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 65193326Sed * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 66193326Sed * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 67193326Sed * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 68193326Sed * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 69193326Sed * 70193326Sed * $FreeBSD: head/sys/mips/include/bus.h 202175 2010-01-12 21:36:08Z imp $ 71193326Sed */ 72193326Sed 73193326Sed#ifndef _MACHINE_BUS_H_ 74193326Sed#define _MACHINE_BUS_H_ 75219077Sdim 76219077Sdim#include <machine/_bus.h> 77219077Sdim 78219077Sdimstruct bus_space { 79219077Sdim /* cookie */ 80193326Sed void *bs_cookie; 81219077Sdim 82193326Sed /* mapping/unmapping */ 83193326Sed int (*bs_map) (void *, bus_addr_t, bus_size_t, 84219077Sdim int, bus_space_handle_t *); 85193326Sed void (*bs_unmap) (void *, bus_space_handle_t, bus_size_t); 86219077Sdim int (*bs_subregion) (void *, bus_space_handle_t, 87193326Sed bus_size_t, bus_size_t, bus_space_handle_t *); 88193326Sed 89193326Sed /* allocation/deallocation */ 90193326Sed int (*bs_alloc) (void *, bus_addr_t, bus_addr_t, 91219077Sdim bus_size_t, bus_size_t, bus_size_t, int, 92193326Sed bus_addr_t *, bus_space_handle_t *); 93193326Sed void (*bs_free) (void *, bus_space_handle_t, 94193326Sed bus_size_t); 95198092Srdivacky 96198092Srdivacky /* get kernel virtual address */ 97193326Sed /* barrier */ 98193326Sed void (*bs_barrier) (void *, bus_space_handle_t, 99193326Sed bus_size_t, bus_size_t, int); 100243830Sdim 101193326Sed /* read (single) */ 102193326Sed u_int8_t (*bs_r_1) (void *, bus_space_handle_t, bus_size_t); 103193326Sed u_int16_t (*bs_r_2) (void *, bus_space_handle_t, bus_size_t); 104218893Sdim u_int32_t (*bs_r_4) (void *, bus_space_handle_t, bus_size_t); 105193326Sed u_int64_t (*bs_r_8) (void *, bus_space_handle_t, bus_size_t); 106193326Sed 107193326Sed /* read multiple */ 108193326Sed void (*bs_rm_1) (void *, bus_space_handle_t, bus_size_t, 109193326Sed u_int8_t *, bus_size_t); 110193326Sed void (*bs_rm_2) (void *, bus_space_handle_t, bus_size_t, 111193326Sed u_int16_t *, bus_size_t); 112193326Sed void (*bs_rm_4) (void *, bus_space_handle_t, 113218893Sdim bus_size_t, u_int32_t *, bus_size_t); 114198092Srdivacky void (*bs_rm_8) (void *, bus_space_handle_t, 115193326Sed bus_size_t, u_int64_t *, bus_size_t); 116193326Sed 117193326Sed /* read region */ 118218893Sdim void (*bs_rr_1) (void *, bus_space_handle_t, 119198092Srdivacky bus_size_t, u_int8_t *, bus_size_t); 120249423Sdim void (*bs_rr_2) (void *, bus_space_handle_t, 121193326Sed bus_size_t, u_int16_t *, bus_size_t); 122219077Sdim void (*bs_rr_4) (void *, bus_space_handle_t, 123219077Sdim bus_size_t, u_int32_t *, bus_size_t); 124219077Sdim void (*bs_rr_8) (void *, bus_space_handle_t, 125219077Sdim bus_size_t, u_int64_t *, bus_size_t); 126219077Sdim 127193326Sed /* write (single) */ 128218893Sdim void (*bs_w_1) (void *, bus_space_handle_t, 129198092Srdivacky bus_size_t, u_int8_t); 130218893Sdim void (*bs_w_2) (void *, bus_space_handle_t, 131193326Sed bus_size_t, u_int16_t); 132198092Srdivacky void (*bs_w_4) (void *, bus_space_handle_t, 133198092Srdivacky bus_size_t, u_int32_t); 134198092Srdivacky void (*bs_w_8) (void *, bus_space_handle_t, 135198092Srdivacky bus_size_t, u_int64_t); 136198092Srdivacky 137198092Srdivacky /* write multiple */ 138218893Sdim void (*bs_wm_1) (void *, bus_space_handle_t, 139218893Sdim bus_size_t, const u_int8_t *, bus_size_t); 140198092Srdivacky void (*bs_wm_2) (void *, bus_space_handle_t, 141193326Sed bus_size_t, const u_int16_t *, bus_size_t); 142193326Sed void (*bs_wm_4) (void *, bus_space_handle_t, 143218893Sdim bus_size_t, const u_int32_t *, bus_size_t); 144193326Sed void (*bs_wm_8) (void *, bus_space_handle_t, 145193326Sed bus_size_t, const u_int64_t *, bus_size_t); 146193326Sed 147193326Sed /* write region */ 148193326Sed void (*bs_wr_1) (void *, bus_space_handle_t, 149193326Sed bus_size_t, const u_int8_t *, bus_size_t); 150193326Sed void (*bs_wr_2) (void *, bus_space_handle_t, 151193326Sed bus_size_t, const u_int16_t *, bus_size_t); 152193326Sed void (*bs_wr_4) (void *, bus_space_handle_t, 153193326Sed bus_size_t, const u_int32_t *, bus_size_t); 154193326Sed void (*bs_wr_8) (void *, bus_space_handle_t, 155219077Sdim bus_size_t, const u_int64_t *, bus_size_t); 156193326Sed 157193326Sed /* set multiple */ 158193326Sed void (*bs_sm_1) (void *, bus_space_handle_t, 159193326Sed bus_size_t, u_int8_t, bus_size_t); 160219077Sdim void (*bs_sm_2) (void *, bus_space_handle_t, 161193326Sed bus_size_t, u_int16_t, bus_size_t); 162193326Sed void (*bs_sm_4) (void *, bus_space_handle_t, 163193326Sed bus_size_t, u_int32_t, bus_size_t); 164193326Sed void (*bs_sm_8) (void *, bus_space_handle_t, 165198092Srdivacky bus_size_t, u_int64_t, bus_size_t); 166193326Sed 167193326Sed /* set region */ 168219077Sdim void (*bs_sr_1) (void *, bus_space_handle_t, 169193326Sed bus_size_t, u_int8_t, bus_size_t); 170219077Sdim void (*bs_sr_2) (void *, bus_space_handle_t, 171219077Sdim bus_size_t, u_int16_t, bus_size_t); 172219077Sdim void (*bs_sr_4) (void *, bus_space_handle_t, 173193326Sed bus_size_t, u_int32_t, bus_size_t); 174193326Sed void (*bs_sr_8) (void *, bus_space_handle_t, 175218893Sdim bus_size_t, u_int64_t, bus_size_t); 176219077Sdim 177219077Sdim /* copy */ 178218893Sdim void (*bs_c_1) (void *, bus_space_handle_t, bus_size_t, 179193326Sed bus_space_handle_t, bus_size_t, bus_size_t); 180193326Sed void (*bs_c_2) (void *, bus_space_handle_t, bus_size_t, 181193326Sed bus_space_handle_t, bus_size_t, bus_size_t); 182193326Sed void (*bs_c_4) (void *, bus_space_handle_t, bus_size_t, 183193326Sed bus_space_handle_t, bus_size_t, bus_size_t); 184193326Sed void (*bs_c_8) (void *, bus_space_handle_t, bus_size_t, 185193326Sed bus_space_handle_t, bus_size_t, bus_size_t); 186193326Sed 187224145Sdim /* read stream (single) */ 188224145Sdim u_int8_t (*bs_r_1_s) (void *, bus_space_handle_t, bus_size_t); 189224145Sdim u_int16_t (*bs_r_2_s) (void *, bus_space_handle_t, bus_size_t); 190224145Sdim u_int32_t (*bs_r_4_s) (void *, bus_space_handle_t, bus_size_t); 191218893Sdim u_int64_t (*bs_r_8_s) (void *, bus_space_handle_t, bus_size_t); 192239462Sdim 193218893Sdim /* read multiple stream */ 194218893Sdim void (*bs_rm_1_s) (void *, bus_space_handle_t, bus_size_t, 195193326Sed u_int8_t *, bus_size_t); 196193326Sed void (*bs_rm_2_s) (void *, bus_space_handle_t, bus_size_t, 197226633Sdim u_int16_t *, bus_size_t); 198193326Sed void (*bs_rm_4_s) (void *, bus_space_handle_t, 199193326Sed bus_size_t, u_int32_t *, bus_size_t); 200193326Sed void (*bs_rm_8_s) (void *, bus_space_handle_t, 201193326Sed bus_size_t, u_int64_t *, bus_size_t); 202193326Sed 203193326Sed /* read region stream */ 204193326Sed void (*bs_rr_1_s) (void *, bus_space_handle_t, 205193326Sed bus_size_t, u_int8_t *, bus_size_t); 206195341Sed void (*bs_rr_2_s) (void *, bus_space_handle_t, 207193326Sed bus_size_t, u_int16_t *, bus_size_t); 208193326Sed void (*bs_rr_4_s) (void *, bus_space_handle_t, 209219077Sdim bus_size_t, u_int32_t *, bus_size_t); 210219077Sdim void (*bs_rr_8_s) (void *, bus_space_handle_t, 211219077Sdim bus_size_t, u_int64_t *, bus_size_t); 212219077Sdim 213219077Sdim /* write stream (single) */ 214219077Sdim void (*bs_w_1_s) (void *, bus_space_handle_t, 215219077Sdim bus_size_t, u_int8_t); 216219077Sdim void (*bs_w_2_s) (void *, bus_space_handle_t, 217219077Sdim bus_size_t, u_int16_t); 218219077Sdim void (*bs_w_4_s) (void *, bus_space_handle_t, 219219077Sdim bus_size_t, u_int32_t); 220219077Sdim void (*bs_w_8_s) (void *, bus_space_handle_t, 221219077Sdim bus_size_t, u_int64_t); 222219077Sdim 223219077Sdim /* write multiple stream */ 224219077Sdim void (*bs_wm_1_s) (void *, bus_space_handle_t, 225219077Sdim bus_size_t, const u_int8_t *, bus_size_t); 226234353Sdim void (*bs_wm_2_s) (void *, bus_space_handle_t, 227219077Sdim bus_size_t, const u_int16_t *, bus_size_t); 228234353Sdim void (*bs_wm_4_s) (void *, bus_space_handle_t, 229219077Sdim bus_size_t, const u_int32_t *, bus_size_t); 230219077Sdim void (*bs_wm_8_s) (void *, bus_space_handle_t, 231234353Sdim bus_size_t, const u_int64_t *, bus_size_t); 232219077Sdim 233219077Sdim /* write region stream */ 234263508Sdim void (*bs_wr_1_s) (void *, bus_space_handle_t, 235219077Sdim bus_size_t, const u_int8_t *, bus_size_t); 236263508Sdim void (*bs_wr_2_s) (void *, bus_space_handle_t, 237263508Sdim bus_size_t, const u_int16_t *, bus_size_t); 238263508Sdim void (*bs_wr_4_s) (void *, bus_space_handle_t, 239263508Sdim bus_size_t, const u_int32_t *, bus_size_t); 240219077Sdim void (*bs_wr_8_s) (void *, bus_space_handle_t, 241219077Sdim bus_size_t, const u_int64_t *, bus_size_t); 242219077Sdim}; 243219077Sdim 244219077Sdim 245219077Sdim/* 246219077Sdim * Utility macros; INTERNAL USE ONLY. 247219077Sdim */ 248234353Sdim#define __bs_c(a,b) __CONCAT(a,b) 249219077Sdim#define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size) 250219077Sdim 251219077Sdim#define __bs_rs(sz, t, h, o) \ 252219077Sdim (*(t)->__bs_opname(r,sz))((t)->bs_cookie, h, o) 253239462Sdim#define __bs_ws(sz, t, h, o, v) \ 254219077Sdim (*(t)->__bs_opname(w,sz))((t)->bs_cookie, h, o, v) 255234353Sdim#define __bs_nonsingle(type, sz, t, h, o, a, c) \ 256219077Sdim (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, a, c) 257219077Sdim#define __bs_set(type, sz, t, h, o, v, c) \ 258219077Sdim (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, v, c) 259219077Sdim#define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \ 260219077Sdim (*(t)->__bs_opname(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt) 261239462Sdim 262219077Sdim#define __bs_opname_s(op,size) __bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s) 263219077Sdim#define __bs_rs_s(sz, t, h, o) \ 264219077Sdim (*(t)->__bs_opname_s(r,sz))((t)->bs_cookie, h, o) 265219077Sdim#define __bs_ws_s(sz, t, h, o, v) \ 266219077Sdim (*(t)->__bs_opname_s(w,sz))((t)->bs_cookie, h, o, v) 267234353Sdim#define __bs_nonsingle_s(type, sz, t, h, o, a, c) \ 268219077Sdim (*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, a, c) 269219077Sdim 270219077Sdim 271219077Sdim/* 272219077Sdim * Mapping and unmapping operations. 273234353Sdim */ 274219077Sdim#define bus_space_map(t, a, s, c, hp) \ 275219077Sdim (*(t)->bs_map)((t)->bs_cookie, (a), (s), (c), (hp)) 276219077Sdim#define bus_space_unmap(t, h, s) \ 277219077Sdim (*(t)->bs_unmap)((t)->bs_cookie, (h), (s)) 278219077Sdim#define bus_space_subregion(t, h, o, s, hp) \ 279234353Sdim (*(t)->bs_subregion)((t)->bs_cookie, (h), (o), (s), (hp)) 280219077Sdim 281219077Sdim 282234353Sdim/* 283219077Sdim * Allocation and deallocation operations. 284219077Sdim */ 285234353Sdim#define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \ 286219077Sdim (*(t)->bs_alloc)((t)->bs_cookie, (rs), (re), (s), (a), (b), \ 287219077Sdim (c), (ap), (hp)) 288219077Sdim#define bus_space_free(t, h, s) \ 289219077Sdim (*(t)->bs_free)((t)->bs_cookie, (h), (s)) 290219077Sdim 291219077Sdim/* 292239462Sdim * Bus barrier operations. 293219077Sdim */ 294219077Sdim#define bus_space_barrier(t, h, o, l, f) \ 295219077Sdim (*(t)->bs_barrier)((t)->bs_cookie, (h), (o), (l), (f)) 296219077Sdim 297219077Sdim#define BUS_SPACE_BARRIER_READ 0x01 298219077Sdim#define BUS_SPACE_BARRIER_WRITE 0x02 299219077Sdim 300219077Sdim/* 301219077Sdim * Bus read (single) operations. 302219077Sdim */ 303219077Sdim#define bus_space_read_1(t, h, o) __bs_rs(1,(t),(h),(o)) 304219077Sdim#define bus_space_read_2(t, h, o) __bs_rs(2,(t),(h),(o)) 305219077Sdim#define bus_space_read_4(t, h, o) __bs_rs(4,(t),(h),(o)) 306219077Sdim#define bus_space_read_8(t, h, o) __bs_rs(8,(t),(h),(o)) 307219077Sdim 308219077Sdim#define bus_space_read_stream_1(t, h, o) __bs_rs_s(1,(t), (h), (o)) 309234353Sdim#define bus_space_read_stream_2(t, h, o) __bs_rs_s(2,(t), (h), (o)) 310234353Sdim#define bus_space_read_stream_4(t, h, o) __bs_rs_s(4,(t), (h), (o)) 311219077Sdim#define bus_space_read_stream_8(t, h, o) __bs_rs_s(8,8,(t),(h),(o)) 312219077Sdim 313219077Sdim/* 314219077Sdim * Bus read multiple operations. 315234353Sdim */ 316219077Sdim#define bus_space_read_multi_1(t, h, o, a, c) \ 317219077Sdim __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) 318219077Sdim#define bus_space_read_multi_2(t, h, o, a, c) \ 319219077Sdim __bs_nonsingle(rm,2,(t),(h),(o),(a),(c)) 320219077Sdim#define bus_space_read_multi_4(t, h, o, a, c) \ 321221345Sdim __bs_nonsingle(rm,4,(t),(h),(o),(a),(c)) 322221345Sdim#define bus_space_read_multi_8(t, h, o, a, c) \ 323221345Sdim __bs_nonsingle(rm,8,(t),(h),(o),(a),(c)) 324221345Sdim 325234353Sdim#define bus_space_read_multi_stream_1(t, h, o, a, c) \ 326221345Sdim __bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c)) 327221345Sdim#define bus_space_read_multi_stream_2(t, h, o, a, c) \ 328234353Sdim __bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c)) 329221345Sdim#define bus_space_read_multi_stream_4(t, h, o, a, c) \ 330221345Sdim __bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c)) 331221345Sdim#define bus_space_read_multi_stream_8(t, h, o, a, c) \ 332234353Sdim __bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c)) 333221345Sdim 334221345Sdim 335221345Sdim/* 336234353Sdim * Bus read region operations. 337221345Sdim */ 338221345Sdim#define bus_space_read_region_1(t, h, o, a, c) \ 339221345Sdim __bs_nonsingle(rr,1,(t),(h),(o),(a),(c)) 340234353Sdim#define bus_space_read_region_2(t, h, o, a, c) \ 341234353Sdim __bs_nonsingle(rr,2,(t),(h),(o),(a),(c)) 342221345Sdim#define bus_space_read_region_4(t, h, o, a, c) \ 343221345Sdim __bs_nonsingle(rr,4,(t),(h),(o),(a),(c)) 344221345Sdim#define bus_space_read_region_8(t, h, o, a, c) \ 345221345Sdim __bs_nonsingle(rr,8,(t),(h),(o),(a),(c)) 346234353Sdim 347234353Sdim#define bus_space_read_region_stream_1(t, h, o, a, c) \ 348234353Sdim __bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c)) 349221345Sdim#define bus_space_read_region_stream_2(t, h, o, a, c) \ 350234353Sdim __bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c)) 351221345Sdim#define bus_space_read_region_stream_4(t, h, o, a, c) \ 352221345Sdim __bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c)) 353234353Sdim#define bus_space_read_region_stream_8(t, h, o, a, c) \ 354234353Sdim __bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c)) 355234353Sdim 356234353Sdim 357234353Sdim/* 358234353Sdim * Bus write (single) operations. 359221345Sdim */ 360221345Sdim#define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v)) 361234353Sdim#define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v)) 362221345Sdim#define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v)) 363221345Sdim#define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v)) 364221345Sdim 365221345Sdim#define bus_space_write_stream_1(t, h, o, v) __bs_ws_s(1,(t),(h),(o),(v)) 366221345Sdim#define bus_space_write_stream_2(t, h, o, v) __bs_ws_s(2,(t),(h),(o),(v)) 367221345Sdim#define bus_space_write_stream_4(t, h, o, v) __bs_ws_s(4,(t),(h),(o),(v)) 368221345Sdim#define bus_space_write_stream_8(t, h, o, v) __bs_ws_s(8,(t),(h),(o),(v)) 369221345Sdim 370221345Sdim 371221345Sdim/* 372221345Sdim * Bus write multiple operations. 373221345Sdim */ 374221345Sdim#define bus_space_write_multi_1(t, h, o, a, c) \ 375234353Sdim __bs_nonsingle(wm,1,(t),(h),(o),(a),(c)) 376234353Sdim#define bus_space_write_multi_2(t, h, o, a, c) \ 377221345Sdim __bs_nonsingle(wm,2,(t),(h),(o),(a),(c)) 378221345Sdim#define bus_space_write_multi_4(t, h, o, a, c) \ 379221345Sdim __bs_nonsingle(wm,4,(t),(h),(o),(a),(c)) 380221345Sdim#define bus_space_write_multi_8(t, h, o, a, c) \ 381221345Sdim __bs_nonsingle(wm,8,(t),(h),(o),(a),(c)) 382221345Sdim 383221345Sdim#define bus_space_write_multi_stream_1(t, h, o, a, c) \ 384221345Sdim __bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c)) 385221345Sdim#define bus_space_write_multi_stream_2(t, h, o, a, c) \ 386221345Sdim __bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c)) 387221345Sdim#define bus_space_write_multi_stream_4(t, h, o, a, c) \ 388221345Sdim __bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c)) 389234353Sdim#define bus_space_write_multi_stream_8(t, h, o, a, c) \ 390234353Sdim __bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c)) 391221345Sdim 392221345Sdim 393221345Sdim/* 394221345Sdim * Bus write region operations. 395221345Sdim */ 396221345Sdim#define bus_space_write_region_1(t, h, o, a, c) \ 397221345Sdim __bs_nonsingle(wr,1,(t),(h),(o),(a),(c)) 398221345Sdim#define bus_space_write_region_2(t, h, o, a, c) \ 399221345Sdim __bs_nonsingle(wr,2,(t),(h),(o),(a),(c)) 400221345Sdim#define bus_space_write_region_4(t, h, o, a, c) \ 401221345Sdim __bs_nonsingle(wr,4,(t),(h),(o),(a),(c)) 402221345Sdim#define bus_space_write_region_8(t, h, o, a, c) \ 403234353Sdim __bs_nonsingle(wr,8,(t),(h),(o),(a),(c)) 404234353Sdim 405221345Sdim#define bus_space_write_region_stream_1(t, h, o, a, c) \ 406221345Sdim __bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c)) 407221345Sdim#define bus_space_write_region_stream_2(t, h, o, a, c) \ 408221345Sdim __bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c)) 409221345Sdim#define bus_space_write_region_stream_4(t, h, o, a, c) \ 410221345Sdim __bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c)) 411221345Sdim#define bus_space_write_region_stream_8(t, h, o, a, c) \ 412234353Sdim __bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c)) 413221345Sdim 414221345Sdim 415221345Sdim/* 416221345Sdim * Set multiple operations. 417221345Sdim */ 418234353Sdim#define bus_space_set_multi_1(t, h, o, v, c) \ 419221345Sdim __bs_set(sm,1,(t),(h),(o),(v),(c)) 420221345Sdim#define bus_space_set_multi_2(t, h, o, v, c) \ 421221345Sdim __bs_set(sm,2,(t),(h),(o),(v),(c)) 422234353Sdim#define bus_space_set_multi_4(t, h, o, v, c) \ 423221345Sdim __bs_set(sm,4,(t),(h),(o),(v),(c)) 424221345Sdim#define bus_space_set_multi_8(t, h, o, v, c) \ 425221345Sdim __bs_set(sm,8,(t),(h),(o),(v),(c)) 426221345Sdim 427221345Sdim 428221345Sdim/* 429234353Sdim * Set region operations. 430221345Sdim */ 431234353Sdim#define bus_space_set_region_1(t, h, o, v, c) \ 432234353Sdim __bs_set(sr,1,(t),(h),(o),(v),(c)) 433221345Sdim#define bus_space_set_region_2(t, h, o, v, c) \ 434221345Sdim __bs_set(sr,2,(t),(h),(o),(v),(c)) 435234353Sdim#define bus_space_set_region_4(t, h, o, v, c) \ 436221345Sdim __bs_set(sr,4,(t),(h),(o),(v),(c)) 437234353Sdim#define bus_space_set_region_8(t, h, o, v, c) \ 438221345Sdim __bs_set(sr,8,(t),(h),(o),(v),(c)) 439221345Sdim 440234353Sdim 441221345Sdim/* 442221345Sdim * Copy operations. 443221345Sdim */ 444221345Sdim#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ 445221345Sdim __bs_copy(1, t, h1, o1, h2, o2, c) 446221345Sdim#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ 447221345Sdim __bs_copy(2, t, h1, o1, h2, o2, c) 448224145Sdim#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ 449239462Sdim __bs_copy(4, t, h1, o1, h2, o2, c) 450239462Sdim#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ 451239462Sdim __bs_copy(8, t, h1, o1, h2, o2, c) 452224145Sdim 453224145Sdim/* 454224145Sdim * Macros to provide prototypes for all the functions used in the 455224145Sdim * bus_space structure 456224145Sdim */ 457221345Sdim 458221345Sdim#define bs_map_proto(f) \ 459221345Sdimint __bs_c(f,_bs_map) (void *t, bus_addr_t addr, \ 460221345Sdim bus_size_t size, int cacheable, bus_space_handle_t *bshp); 461221345Sdim 462221345Sdim#define bs_unmap_proto(f) \ 463234353Sdimvoid __bs_c(f,_bs_unmap) (void *t, bus_space_handle_t bsh, \ 464221345Sdim bus_size_t size); 465221345Sdim 466221345Sdim#define bs_subregion_proto(f) \ 467221345Sdimint __bs_c(f,_bs_subregion) (void *t, bus_space_handle_t bsh, \ 468221345Sdim bus_size_t offset, bus_size_t size, \ 469221345Sdim bus_space_handle_t *nbshp); 470221345Sdim 471221345Sdim#define bs_alloc_proto(f) \ 472221345Sdimint __bs_c(f,_bs_alloc) (void *t, bus_addr_t rstart, \ 473234353Sdim bus_addr_t rend, bus_size_t size, bus_size_t align, \ 474234353Sdim bus_size_t boundary, int cacheable, bus_addr_t *addrp, \ 475234353Sdim bus_space_handle_t *bshp); 476198092Srdivacky 477198092Srdivacky#define bs_free_proto(f) \ 478198092Srdivackyvoid __bs_c(f,_bs_free) (void *t, bus_space_handle_t bsh, \ 479226633Sdim bus_size_t size); 480198092Srdivacky 481193326Sed#define bs_barrier_proto(f) \ 482193326Sedvoid __bs_c(f,_bs_barrier) (void *t, bus_space_handle_t bsh, \ 483198092Srdivacky bus_size_t offset, bus_size_t len, int flags); 484198092Srdivacky 485193326Sed#define bs_r_1_proto(f) \ 486u_int8_t __bs_c(f,_bs_r_1) (void *t, bus_space_handle_t bsh, \ 487 bus_size_t offset); 488 489#define bs_r_2_proto(f) \ 490u_int16_t __bs_c(f,_bs_r_2) (void *t, bus_space_handle_t bsh, \ 491 bus_size_t offset); 492 493#define bs_r_4_proto(f) \ 494u_int32_t __bs_c(f,_bs_r_4) (void *t, bus_space_handle_t bsh, \ 495 bus_size_t offset); 496 497#define bs_r_8_proto(f) \ 498u_int64_t __bs_c(f,_bs_r_8) (void *t, bus_space_handle_t bsh, \ 499 bus_size_t offset); 500 501#define bs_r_1_s_proto(f) \ 502u_int8_t __bs_c(f,_bs_r_1_s) (void *t, bus_space_handle_t bsh, \ 503 bus_size_t offset); 504 505#define bs_r_2_s_proto(f) \ 506u_int16_t __bs_c(f,_bs_r_2_s) (void *t, bus_space_handle_t bsh, \ 507 bus_size_t offset); 508 509#define bs_r_4_s_proto(f) \ 510u_int32_t __bs_c(f,_bs_r_4_s) (void *t, bus_space_handle_t bsh, \ 511 bus_size_t offset); 512 513#define bs_w_1_proto(f) \ 514void __bs_c(f,_bs_w_1) (void *t, bus_space_handle_t bsh, \ 515 bus_size_t offset, u_int8_t value); 516 517#define bs_w_2_proto(f) \ 518void __bs_c(f,_bs_w_2) (void *t, bus_space_handle_t bsh, \ 519 bus_size_t offset, u_int16_t value); 520 521#define bs_w_4_proto(f) \ 522void __bs_c(f,_bs_w_4) (void *t, bus_space_handle_t bsh, \ 523 bus_size_t offset, u_int32_t value); 524 525#define bs_w_8_proto(f) \ 526void __bs_c(f,_bs_w_8) (void *t, bus_space_handle_t bsh, \ 527 bus_size_t offset, u_int64_t value); 528 529#define bs_w_1_s_proto(f) \ 530void __bs_c(f,_bs_w_1_s) (void *t, bus_space_handle_t bsh, \ 531 bus_size_t offset, u_int8_t value); 532 533#define bs_w_2_s_proto(f) \ 534void __bs_c(f,_bs_w_2_s) (void *t, bus_space_handle_t bsh, \ 535 bus_size_t offset, u_int16_t value); 536 537#define bs_w_4_s_proto(f) \ 538void __bs_c(f,_bs_w_4_s) (void *t, bus_space_handle_t bsh, \ 539 bus_size_t offset, u_int32_t value); 540 541#define bs_rm_1_proto(f) \ 542void __bs_c(f,_bs_rm_1) (void *t, bus_space_handle_t bsh, \ 543 bus_size_t offset, u_int8_t *addr, bus_size_t count); 544 545#define bs_rm_2_proto(f) \ 546void __bs_c(f,_bs_rm_2) (void *t, bus_space_handle_t bsh, \ 547 bus_size_t offset, u_int16_t *addr, bus_size_t count); 548 549#define bs_rm_4_proto(f) \ 550void __bs_c(f,_bs_rm_4) (void *t, bus_space_handle_t bsh, \ 551 bus_size_t offset, u_int32_t *addr, bus_size_t count); 552 553#define bs_rm_8_proto(f) \ 554void __bs_c(f,_bs_rm_8) (void *t, bus_space_handle_t bsh, \ 555 bus_size_t offset, u_int64_t *addr, bus_size_t count); 556 557#define bs_wm_1_proto(f) \ 558void __bs_c(f,_bs_wm_1) (void *t, bus_space_handle_t bsh, \ 559 bus_size_t offset, const u_int8_t *addr, bus_size_t count); 560 561#define bs_wm_2_proto(f) \ 562void __bs_c(f,_bs_wm_2) (void *t, bus_space_handle_t bsh, \ 563 bus_size_t offset, const u_int16_t *addr, bus_size_t count); 564 565#define bs_wm_4_proto(f) \ 566void __bs_c(f,_bs_wm_4) (void *t, bus_space_handle_t bsh, \ 567 bus_size_t offset, const u_int32_t *addr, bus_size_t count); 568 569#define bs_wm_8_proto(f) \ 570void __bs_c(f,_bs_wm_8) (void *t, bus_space_handle_t bsh, \ 571 bus_size_t offset, const u_int64_t *addr, bus_size_t count); 572 573#define bs_rr_1_proto(f) \ 574void __bs_c(f, _bs_rr_1) (void *t, bus_space_handle_t bsh, \ 575 bus_size_t offset, u_int8_t *addr, bus_size_t count); 576 577#define bs_rr_2_proto(f) \ 578void __bs_c(f, _bs_rr_2) (void *t, bus_space_handle_t bsh, \ 579 bus_size_t offset, u_int16_t *addr, bus_size_t count); 580 581#define bs_rr_4_proto(f) \ 582void __bs_c(f, _bs_rr_4) (void *t, bus_space_handle_t bsh, \ 583 bus_size_t offset, u_int32_t *addr, bus_size_t count); 584 585#define bs_rr_8_proto(f) \ 586void __bs_c(f, _bs_rr_8) (void *t, bus_space_handle_t bsh, \ 587 bus_size_t offset, u_int64_t *addr, bus_size_t count); 588 589#define bs_wr_1_proto(f) \ 590void __bs_c(f, _bs_wr_1) (void *t, bus_space_handle_t bsh, \ 591 bus_size_t offset, const u_int8_t *addr, bus_size_t count); 592 593#define bs_wr_2_proto(f) \ 594void __bs_c(f, _bs_wr_2) (void *t, bus_space_handle_t bsh, \ 595 bus_size_t offset, const u_int16_t *addr, bus_size_t count); 596 597#define bs_wr_4_proto(f) \ 598void __bs_c(f, _bs_wr_4) (void *t, bus_space_handle_t bsh, \ 599 bus_size_t offset, const u_int32_t *addr, bus_size_t count); 600 601#define bs_wr_8_proto(f) \ 602void __bs_c(f, _bs_wr_8) (void *t, bus_space_handle_t bsh, \ 603 bus_size_t offset, const u_int64_t *addr, bus_size_t count); 604 605#define bs_sm_1_proto(f) \ 606void __bs_c(f,_bs_sm_1) (void *t, bus_space_handle_t bsh, \ 607 bus_size_t offset, u_int8_t value, bus_size_t count); 608 609#define bs_sm_2_proto(f) \ 610void __bs_c(f,_bs_sm_2) (void *t, bus_space_handle_t bsh, \ 611 bus_size_t offset, u_int16_t value, bus_size_t count); 612 613#define bs_sm_4_proto(f) \ 614void __bs_c(f,_bs_sm_4) (void *t, bus_space_handle_t bsh, \ 615 bus_size_t offset, u_int32_t value, bus_size_t count); 616 617#define bs_sm_8_proto(f) \ 618void __bs_c(f,_bs_sm_8) (void *t, bus_space_handle_t bsh, \ 619 bus_size_t offset, u_int64_t value, bus_size_t count); 620 621#define bs_sr_1_proto(f) \ 622void __bs_c(f,_bs_sr_1) (void *t, bus_space_handle_t bsh, \ 623 bus_size_t offset, u_int8_t value, bus_size_t count); 624 625#define bs_sr_2_proto(f) \ 626void __bs_c(f,_bs_sr_2) (void *t, bus_space_handle_t bsh, \ 627 bus_size_t offset, u_int16_t value, bus_size_t count); 628 629#define bs_sr_4_proto(f) \ 630void __bs_c(f,_bs_sr_4) (void *t, bus_space_handle_t bsh, \ 631 bus_size_t offset, u_int32_t value, bus_size_t count); 632 633#define bs_sr_8_proto(f) \ 634void __bs_c(f,_bs_sr_8) (void *t, bus_space_handle_t bsh, \ 635 bus_size_t offset, u_int64_t value, bus_size_t count); 636 637#define bs_c_1_proto(f) \ 638void __bs_c(f,_bs_c_1) (void *t, bus_space_handle_t bsh1, \ 639 bus_size_t offset1, bus_space_handle_t bsh2, \ 640 bus_size_t offset2, bus_size_t count); 641 642#define bs_c_2_proto(f) \ 643void __bs_c(f,_bs_c_2) (void *t, bus_space_handle_t bsh1, \ 644 bus_size_t offset1, bus_space_handle_t bsh2, \ 645 bus_size_t offset2, bus_size_t count); 646 647#define bs_c_4_proto(f) \ 648void __bs_c(f,_bs_c_4) (void *t, bus_space_handle_t bsh1, \ 649 bus_size_t offset1, bus_space_handle_t bsh2, \ 650 bus_size_t offset2, bus_size_t count); 651 652#define bs_c_8_proto(f) \ 653void __bs_c(f,_bs_c_8) (void *t, bus_space_handle_t bsh1, \ 654 bus_size_t offset1, bus_space_handle_t bsh2, \ 655 bus_size_t offset2, bus_size_t count); 656 657#define DECLARE_BUS_SPACE_PROTOTYPES(f) \ 658 bs_map_proto(f); \ 659 bs_unmap_proto(f); \ 660 bs_subregion_proto(f); \ 661 bs_alloc_proto(f); \ 662 bs_free_proto(f); \ 663 bs_barrier_proto(f); \ 664 bs_r_1_proto(f); \ 665 bs_r_2_proto(f); \ 666 bs_r_4_proto(f); \ 667 bs_r_8_proto(f); \ 668 bs_r_1_s_proto(f); \ 669 bs_r_2_s_proto(f); \ 670 bs_r_4_s_proto(f); \ 671 bs_w_1_proto(f); \ 672 bs_w_2_proto(f); \ 673 bs_w_4_proto(f); \ 674 bs_w_8_proto(f); \ 675 bs_w_1_s_proto(f); \ 676 bs_w_2_s_proto(f); \ 677 bs_w_4_s_proto(f); \ 678 bs_rm_1_proto(f); \ 679 bs_rm_2_proto(f); \ 680 bs_rm_4_proto(f); \ 681 bs_rm_8_proto(f); \ 682 bs_wm_1_proto(f); \ 683 bs_wm_2_proto(f); \ 684 bs_wm_4_proto(f); \ 685 bs_wm_8_proto(f); \ 686 bs_rr_1_proto(f); \ 687 bs_rr_2_proto(f); \ 688 bs_rr_4_proto(f); \ 689 bs_rr_8_proto(f); \ 690 bs_wr_1_proto(f); \ 691 bs_wr_2_proto(f); \ 692 bs_wr_4_proto(f); \ 693 bs_wr_8_proto(f); \ 694 bs_sm_1_proto(f); \ 695 bs_sm_2_proto(f); \ 696 bs_sm_4_proto(f); \ 697 bs_sm_8_proto(f); \ 698 bs_sr_1_proto(f); \ 699 bs_sr_2_proto(f); \ 700 bs_sr_4_proto(f); \ 701 bs_sr_8_proto(f); \ 702 bs_c_1_proto(f); \ 703 bs_c_2_proto(f); \ 704 bs_c_4_proto(f); \ 705 bs_c_8_proto(f); 706 707#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 708 709#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF 710#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF 711#define BUS_SPACE_MAXADDR 0xFFFFFFFF 712#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF 713#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF 714#define BUS_SPACE_MAXSIZE 0xFFFFFFFF 715 716/* 717 * declare generic bus space, it suits all needs in 718 */ 719DECLARE_BUS_SPACE_PROTOTYPES(generic); 720extern bus_space_tag_t mips_bus_space_generic; 721/* Special bus space for RMI processors */ 722#ifdef TARGET_XLR_XLS 723extern bus_space_tag_t rmi_bus_space; 724#endif 725 726#include <machine/bus_dma.h> 727 728#endif /* _MACHINE_BUS_H_ */ 729