]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/pc98/include/bus.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / pc98 / include / bus.h
1 /*-
2  * Copyright (c) KATO Takenori, 1999.
3  *
4  * All rights reserved.  Unpublished rights reserved under the copyright
5  * laws of Japan.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer as
13  *    the first lines of this file unmodified.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  * 
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * $FreeBSD$
32  */
33
34 /*      $NecBSD: busio.h,v 3.25.4.2.2.1 2000/06/12 03:53:08 honda Exp $ */
35 /*      $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $    */
36
37 /*-
38  * [NetBSD for NEC PC-98 series]
39  *  Copyright (c) 1997, 1998
40  *      NetBSD/pc98 porting staff. All rights reserved.
41  *
42  * [Ported for FreeBSD]
43  *  Copyright (c) 2001
44  *      TAKAHASHI Yoshihiro. All rights reserved.
45  *
46  *  Redistribution and use in source and binary forms, with or without
47  *  modification, are permitted provided that the following conditions
48  *  are met:
49  *  1. Redistributions of source code must retain the above copyright
50  *     notice, this list of conditions and the following disclaimer.
51  *  2. Redistributions in binary form must reproduce the above copyright
52  *     notice, this list of conditions and the following disclaimer in the
53  *     documentation and/or other materials provided with the distribution.
54  *  3. The name of the author may not be used to endorse or promote products
55  *     derived from this software without specific prior written permission.
56  * 
57  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
59  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
60  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
61  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
62  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
63  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
66  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
67  * POSSIBILITY OF SUCH DAMAGE.
68  */
69
70 /*
71  * Copyright (c) 1997, 1998
72  *      Naofumi HONDA.  All rights reserved.
73  *
74  * This module support generic bus address relocation mechanism.
75  * To reduce a function call overhead, we employ pascal call methods.
76  */
77
78 #ifndef _PC98_BUS_H_
79 #define _PC98_BUS_H_
80
81 #include <sys/systm.h>
82
83 #include <machine/_bus.h>
84 #include <machine/cpufunc.h>
85
86 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
87 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
88 #define BUS_SPACE_MAXSIZE       0xFFFFFFFF
89 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
90 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
91 #define BUS_SPACE_MAXADDR       0xFFFFFFFF
92
93 #define BUS_SPACE_UNRESTRICTED  (~0)
94
95 #define BUS_SPACE_IAT_MAXSIZE   33
96
97 /*
98  * Access methods for bus resources and address space.
99  */
100 struct resource;
101
102 /*
103  * bus space tag
104  */
105 #define _PASCAL_CALL    (void)
106
107 #define _BUS_SPACE_CALL_FUNCS_TAB(NAME,TYPE,BWN) \
108         NAME##_space_read_##BWN,                                \
109         NAME##_space_read_multi_##BWN,                          \
110         NAME##_space_read_region_##BWN,                         \
111         NAME##_space_write_##BWN,                               \
112         NAME##_space_write_multi_##BWN,                         \
113         NAME##_space_write_region_##BWN,                        \
114         NAME##_space_set_multi_##BWN,                           \
115         NAME##_space_set_region_##BWN,                          \
116         NAME##_space_copy_region_##BWN
117
118 #define _BUS_SPACE_CALL_FUNCS_PROTO(NAME,TYPE,BWN) \
119         TYPE NAME##_space_read_##BWN _PASCAL_CALL;              \
120         void NAME##_space_read_multi_##BWN _PASCAL_CALL;        \
121         void NAME##_space_read_region_##BWN _PASCAL_CALL;       \
122         void NAME##_space_write_##BWN _PASCAL_CALL;             \
123         void NAME##_space_write_multi_##BWN _PASCAL_CALL;       \
124         void NAME##_space_write_region_##BWN _PASCAL_CALL;      \
125         void NAME##_space_set_multi_##BWN _PASCAL_CALL;         \
126         void NAME##_space_set_region_##BWN _PASCAL_CALL;        \
127         void NAME##_space_copy_region_##BWN _PASCAL_CALL;
128
129 #define _BUS_SPACE_CALL_FUNCS(NAME,TYPE,BWN) \
130         TYPE (* NAME##_read_##BWN) _PASCAL_CALL;                \
131         void (* NAME##_read_multi_##BWN) _PASCAL_CALL;          \
132         void (* NAME##_read_region_##BWN) _PASCAL_CALL;         \
133         void (* NAME##_write_##BWN) _PASCAL_CALL;               \
134         void (* NAME##_write_multi_##BWN) _PASCAL_CALL;         \
135         void (* NAME##_write_region_##BWN) _PASCAL_CALL;        \
136         void (* NAME##_set_multi_##BWN) _PASCAL_CALL;           \
137         void (* NAME##_set_region_##BWN) _PASCAL_CALL;          \
138         void (* NAME##_copy_region_##BWN) _PASCAL_CALL; 
139
140 struct bus_space_access_methods {
141         /* 8 bits access methods */
142         _BUS_SPACE_CALL_FUNCS(bs,u_int8_t,1)
143
144         /* 16 bits access methods */
145         _BUS_SPACE_CALL_FUNCS(bs,u_int16_t,2)
146
147         /* 32 bits access methods */
148         _BUS_SPACE_CALL_FUNCS(bs,u_int32_t,4)
149 };
150
151 /*
152  * Access methods for bus resources and address space.
153  */
154 struct bus_space_tag {
155 #define BUS_SPACE_IO    0
156 #define BUS_SPACE_MEM   1
157         u_int   bs_tag;                 /* bus space flags */
158
159         struct bus_space_access_methods bs_da;  /* direct access */
160         struct bus_space_access_methods bs_ra;  /* relocate access */
161 #if     0
162         struct bus_space_access_methods bs_ida; /* indexed direct access */
163 #endif
164 };
165
166 /*
167  * bus space handle
168  */
169 struct bus_space_handle {
170         bus_addr_t      bsh_base;
171         size_t          bsh_sz;
172
173         bus_addr_t      bsh_iat[BUS_SPACE_IAT_MAXSIZE];
174         size_t          bsh_maxiatsz;
175         size_t          bsh_iatsz;
176
177         struct resource **bsh_res;
178         size_t          bsh_ressz;
179
180         struct bus_space_access_methods bsh_bam;
181 };
182
183 /*
184  * Values for the pc98 bus space tag, not to be used directly by MI code.
185  */
186 extern struct bus_space_tag SBUS_io_space_tag;
187 extern struct bus_space_tag SBUS_mem_space_tag;
188
189 #define I386_BUS_SPACE_IO       (&SBUS_io_space_tag)
190 #define I386_BUS_SPACE_MEM      (&SBUS_mem_space_tag)
191
192 /*
193  * Allocate/Free bus_space_handle
194  */
195 int i386_bus_space_handle_alloc(bus_space_tag_t t, bus_addr_t bpa,
196                                 bus_size_t size, bus_space_handle_t *bshp);
197 void i386_bus_space_handle_free(bus_space_tag_t t, bus_space_handle_t bsh,
198                                 size_t size);
199
200 /*
201  *      int bus_space_map (bus_space_tag_t t, bus_addr_t addr,
202  *          bus_size_t size, int flag, bus_space_handle_t *bshp);
203  *
204  * Map a region of bus space.
205  */
206
207 int i386_memio_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
208                    int flag, bus_space_handle_t *bshp);
209
210 #define bus_space_map(t, a, s, f, hp)                                   \
211         i386_memio_map((t), (a), (s), (f), (hp))
212
213 /*
214  *      int bus_space_unmap (bus_space_tag_t t,
215  *          bus_space_handle_t bsh, bus_size_t size);
216  *
217  * Unmap a region of bus space.
218  */
219
220 void i386_memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
221                        bus_size_t size);
222
223 #define bus_space_unmap(t, h, s)                                        \
224         i386_memio_unmap((t), (h), (s))
225
226 /*
227  *      int bus_space_subregion (bus_space_tag_t t,
228  *          bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
229  *          bus_space_handle_t *nbshp);
230  *
231  * Get a new handle for a subregion of an already-mapped area of bus space.
232  */
233
234 int i386_memio_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
235                          bus_size_t offset, bus_size_t size,
236                          bus_space_handle_t *nbshp);
237
238 #define bus_space_subregion(t, h, o, s, nhp)                            \
239         i386_memio_subregion((t), (h), (o), (s), (nhp))
240
241 /*
242  *      int bus_space_free (bus_space_tag_t t,
243  *          bus_space_handle_t bsh, bus_size_t size);
244  *
245  * Free a region of bus space.
246  */
247
248 void i386_memio_free(bus_space_tag_t t, bus_space_handle_t bsh,
249                      bus_size_t size);
250
251 #define bus_space_free(t, h, s)                                         \
252         i386_memio_free((t), (h), (s))
253
254 /*
255  * Access methods for bus resources and address space.
256  */
257 #define _BUS_ACCESS_METHODS_PROTO(TYPE,BWN) \
258         static __inline TYPE bus_space_read_##BWN                       \
259         (bus_space_tag_t, bus_space_handle_t, bus_size_t offset);       \
260         static __inline void bus_space_read_multi_##BWN                 \
261         (bus_space_tag_t, bus_space_handle_t,                           \
262              bus_size_t, TYPE *, size_t);                               \
263         static __inline void bus_space_read_region_##BWN                \
264         (bus_space_tag_t, bus_space_handle_t,                           \
265              bus_size_t, TYPE *, size_t);                               \
266         static __inline void bus_space_write_##BWN                      \
267         (bus_space_tag_t, bus_space_handle_t, bus_size_t, TYPE);        \
268         static __inline void bus_space_write_multi_##BWN                \
269         (bus_space_tag_t, bus_space_handle_t,                           \
270              bus_size_t, const TYPE *, size_t);                         \
271         static __inline void bus_space_write_region_##BWN               \
272         (bus_space_tag_t, bus_space_handle_t,                           \
273              bus_size_t, const TYPE *, size_t);                         \
274         static __inline void bus_space_set_multi_##BWN                  \
275         (bus_space_tag_t, bus_space_handle_t, bus_size_t, TYPE, size_t);\
276         static __inline void bus_space_set_region_##BWN                 \
277         (bus_space_tag_t, bus_space_handle_t, bus_size_t, TYPE, size_t);\
278         static __inline void bus_space_copy_region_##BWN                \
279         (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
280              bus_space_handle_t, bus_size_t, size_t);
281
282 _BUS_ACCESS_METHODS_PROTO(u_int8_t,1)
283 _BUS_ACCESS_METHODS_PROTO(u_int16_t,2)
284 _BUS_ACCESS_METHODS_PROTO(u_int32_t,4)
285
286 /*
287  * read methods
288  */
289 #define _BUS_SPACE_READ(TYPE,BWN)                               \
290 static __inline TYPE                                            \
291 bus_space_read_##BWN (tag, bsh, offset)                         \
292         bus_space_tag_t tag;                                    \
293         bus_space_handle_t bsh;                                 \
294         bus_size_t offset;                                      \
295 {                                                               \
296         register TYPE result;                                   \
297                                                                 \
298         __asm __volatile("call *%2"                             \
299                         :"=a" (result),                         \
300                          "=d" (offset)                          \
301                         :"o" (bsh->bsh_bam.bs_read_##BWN),      \
302                          "b" (bsh),                             \
303                          "1" (offset)                           \
304                         );                                      \
305                                                                 \
306         return result;                                          \
307 }
308
309 _BUS_SPACE_READ(u_int8_t,1)
310 _BUS_SPACE_READ(u_int16_t,2)
311 _BUS_SPACE_READ(u_int32_t,4)
312
313 /*
314  * write methods
315  */
316 #define _BUS_SPACE_WRITE(TYPE,BWN)                              \
317 static __inline void                                            \
318 bus_space_write_##BWN (tag, bsh, offset, val)                   \
319         bus_space_tag_t tag;                                    \
320         bus_space_handle_t bsh;                                 \
321         bus_size_t offset;                                      \
322         TYPE val;                                               \
323 {                                                               \
324                                                                 \
325         __asm __volatile("call *%1"                             \
326                         :"=d" (offset)                          \
327                         :"o" (bsh->bsh_bam.bs_write_##BWN),     \
328                          "a" (val),                             \
329                          "b" (bsh),                             \
330                          "0" (offset)                           \
331                         );                                      \
332 }                                                               
333
334 _BUS_SPACE_WRITE(u_int8_t,1)
335 _BUS_SPACE_WRITE(u_int16_t,2)
336 _BUS_SPACE_WRITE(u_int32_t,4)
337
338 /*
339  * multi read
340  */
341 #define _BUS_SPACE_READ_MULTI(TYPE,BWN)                                 \
342 static __inline void                                                    \
343 bus_space_read_multi_##BWN (tag, bsh, offset, buf, cnt)                 \
344         bus_space_tag_t tag;                                            \
345         bus_space_handle_t bsh;                                         \
346         bus_size_t offset;                                              \
347         TYPE *buf;                                                      \
348         size_t cnt;                                                     \
349 {                                                                       \
350                                                                         \
351         __asm __volatile("call *%3"                                     \
352                         :"=c" (cnt),                                    \
353                          "=d" (offset),                                 \
354                          "=D" (buf)                                     \
355                         :"o" (bsh->bsh_bam.bs_read_multi_##BWN),        \
356                          "b" (bsh),                                     \
357                          "0" (cnt),                                     \
358                          "1" (offset),                                  \
359                          "2" (buf)                                      \
360                         :"memory");                                     \
361 }
362
363 _BUS_SPACE_READ_MULTI(u_int8_t,1)
364 _BUS_SPACE_READ_MULTI(u_int16_t,2)
365 _BUS_SPACE_READ_MULTI(u_int32_t,4)
366
367 /*
368  * multi write
369  */
370 #define _BUS_SPACE_WRITE_MULTI(TYPE,BWN)                                \
371 static __inline void                                                    \
372 bus_space_write_multi_##BWN (tag, bsh, offset, buf, cnt)                \
373         bus_space_tag_t tag;                                            \
374         bus_space_handle_t bsh;                                         \
375         bus_size_t offset;                                              \
376         const TYPE *buf;                                                \
377         size_t cnt;                                                     \
378 {                                                                       \
379                                                                         \
380         __asm __volatile("call *%3"                                     \
381                         :"=c" (cnt),                                    \
382                          "=d" (offset),                                 \
383                          "=S" (buf)                                     \
384                         :"o" (bsh->bsh_bam.bs_write_multi_##BWN),       \
385                          "b" (bsh),                                     \
386                          "0" (cnt),                                     \
387                          "1" (offset),                                  \
388                          "2" (buf)                                      \
389                         );                                              \
390 }
391
392 _BUS_SPACE_WRITE_MULTI(u_int8_t,1)
393 _BUS_SPACE_WRITE_MULTI(u_int16_t,2)
394 _BUS_SPACE_WRITE_MULTI(u_int32_t,4)
395
396 /*
397  * region read
398  */
399 #define _BUS_SPACE_READ_REGION(TYPE,BWN)                                \
400 static __inline void                                                    \
401 bus_space_read_region_##BWN (tag, bsh, offset, buf, cnt)                \
402         bus_space_tag_t tag;                                            \
403         bus_space_handle_t bsh;                                         \
404         bus_size_t offset;                                              \
405         TYPE *buf;                                              \
406         size_t cnt;                                                     \
407 {                                                                       \
408                                                                         \
409         __asm __volatile("call *%3"                                     \
410                         :"=c" (cnt),                                    \
411                          "=d" (offset),                                 \
412                          "=D" (buf)                                     \
413                         :"o" (bsh->bsh_bam.bs_read_region_##BWN),       \
414                          "b" (bsh),                                     \
415                          "0" (cnt),                                     \
416                          "1" (offset),                                  \
417                          "2" (buf)                                      \
418                         :"memory");                                     \
419 }
420
421 _BUS_SPACE_READ_REGION(u_int8_t,1)
422 _BUS_SPACE_READ_REGION(u_int16_t,2)
423 _BUS_SPACE_READ_REGION(u_int32_t,4)
424
425 /*
426  * region write
427  */
428 #define _BUS_SPACE_WRITE_REGION(TYPE,BWN)                               \
429 static __inline void                                                    \
430 bus_space_write_region_##BWN (tag, bsh, offset, buf, cnt)               \
431         bus_space_tag_t tag;                                            \
432         bus_space_handle_t bsh;                                         \
433         bus_size_t offset;                                              \
434         const TYPE *buf;                                                \
435         size_t cnt;                                                     \
436 {                                                                       \
437                                                                         \
438         __asm __volatile("call *%3"                                     \
439                         :"=c" (cnt),                                    \
440                          "=d" (offset),                                 \
441                          "=S" (buf)                                     \
442                         :"o" (bsh->bsh_bam.bs_write_region_##BWN),      \
443                          "b" (bsh),                                     \
444                          "0" (cnt),                                     \
445                          "1" (offset),                                  \
446                          "2" (buf)                                      \
447                         );                                              \
448 }
449
450 _BUS_SPACE_WRITE_REGION(u_int8_t,1)
451 _BUS_SPACE_WRITE_REGION(u_int16_t,2)
452 _BUS_SPACE_WRITE_REGION(u_int32_t,4)
453
454 /*
455  * multi set
456  */
457 #define _BUS_SPACE_SET_MULTI(TYPE,BWN)                                  \
458 static __inline void                                                    \
459 bus_space_set_multi_##BWN (tag, bsh, offset, val, cnt)                  \
460         bus_space_tag_t tag;                                            \
461         bus_space_handle_t bsh;                                         \
462         bus_size_t offset;                                              \
463         TYPE val;                                                       \
464         size_t cnt;                                                     \
465 {                                                                       \
466                                                                         \
467         __asm __volatile("call *%2"                                     \
468                         :"=c" (cnt),                                    \
469                          "=d" (offset)                                  \
470                         :"o" (bsh->bsh_bam.bs_set_multi_##BWN),         \
471                          "a" (val),                                     \
472                          "b" (bsh),                                     \
473                          "0" (cnt),                                     \
474                          "1" (offset)                                   \
475                         );                                              \
476 }
477
478 _BUS_SPACE_SET_MULTI(u_int8_t,1)
479 _BUS_SPACE_SET_MULTI(u_int16_t,2)
480 _BUS_SPACE_SET_MULTI(u_int32_t,4)
481
482 /*
483  * region set
484  */
485 #define _BUS_SPACE_SET_REGION(TYPE,BWN)                                 \
486 static __inline void                                                    \
487 bus_space_set_region_##BWN (tag, bsh, offset, val, cnt)                 \
488         bus_space_tag_t tag;                                            \
489         bus_space_handle_t bsh;                                         \
490         bus_size_t offset;                                              \
491         TYPE val;                                                       \
492         size_t cnt;                                                     \
493 {                                                                       \
494                                                                         \
495         __asm __volatile("call *%2"                                     \
496                         :"=c" (cnt),                                    \
497                          "=d" (offset)                                  \
498                         :"o" (bsh->bsh_bam.bs_set_region_##BWN),        \
499                          "a" (val),                                     \
500                          "b" (bsh),                                     \
501                          "0" (cnt),                                     \
502                          "1" (offset)                                   \
503                         );                                              \
504 }
505
506 _BUS_SPACE_SET_REGION(u_int8_t,1)
507 _BUS_SPACE_SET_REGION(u_int16_t,2)
508 _BUS_SPACE_SET_REGION(u_int32_t,4)
509
510 /*
511  * copy
512  */
513 #define _BUS_SPACE_COPY_REGION(BWN)                                     \
514 static __inline void                                                    \
515 bus_space_copy_region_##BWN (tag, sbsh, src, dbsh, dst, cnt)            \
516         bus_space_tag_t tag;                                            \
517         bus_space_handle_t sbsh;                                        \
518         bus_size_t src;                                                 \
519         bus_space_handle_t dbsh;                                        \
520         bus_size_t dst;                                                 \
521         size_t cnt;                                                     \
522 {                                                                       \
523                                                                         \
524         if (dbsh->bsh_bam.bs_copy_region_1 != sbsh->bsh_bam.bs_copy_region_1) \
525                 panic("bus_space_copy_region: funcs mismatch (ENOSUPPORT)");\
526                                                                         \
527         __asm __volatile("call *%3"                                     \
528                         :"=c" (cnt),                                    \
529                          "=S" (src),                                    \
530                          "=D" (dst)                                     \
531                         :"o" (dbsh->bsh_bam.bs_copy_region_##BWN),      \
532                          "a" (sbsh),                                    \
533                          "b" (dbsh),                                    \
534                          "0" (cnt),                                     \
535                          "1" (src),                                     \
536                          "2" (dst)                                      \
537                         );                                              \
538 }
539
540 _BUS_SPACE_COPY_REGION(1)
541 _BUS_SPACE_COPY_REGION(2)
542 _BUS_SPACE_COPY_REGION(4)
543
544 /*
545  * Bus read/write barrier methods.
546  *
547  *      void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
548  *                             bus_size_t offset, bus_size_t len, int flags);
549  *
550  *
551  * Note that BUS_SPACE_BARRIER_WRITE doesn't do anything other than
552  * prevent reordering by the compiler; all Intel x86 processors currently
553  * retire operations outside the CPU in program order.
554  */
555 #define BUS_SPACE_BARRIER_READ  0x01            /* force read barrier */
556 #define BUS_SPACE_BARRIER_WRITE 0x02            /* force write barrier */
557
558 static __inline void
559 bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
560                   bus_size_t offset, bus_size_t len, int flags)
561 {
562         if (flags & BUS_SPACE_BARRIER_READ)
563                 __asm __volatile("lock; addl $0,0(%%esp)" : : : "memory");
564         else
565                 __asm __volatile("" : : : "memory");
566 }
567
568 #ifdef BUS_SPACE_NO_LEGACY
569 #undef inb
570 #undef outb
571 #define inb(a) compiler_error
572 #define inw(a) compiler_error
573 #define inl(a) compiler_error
574 #define outb(a, b) compiler_error
575 #define outw(a, b) compiler_error
576 #define outl(a, b) compiler_error
577 #endif
578
579 #include <machine/bus_dma.h>
580
581 /*
582  * Stream accesses are the same as normal accesses on i386/pc98; there are no
583  * supported bus systems with an endianess different from the host one.
584  */
585 #define bus_space_read_stream_1(t, h, o)        bus_space_read_1((t), (h), (o))
586 #define bus_space_read_stream_2(t, h, o)        bus_space_read_2((t), (h), (o))
587 #define bus_space_read_stream_4(t, h, o)        bus_space_read_4((t), (h), (o))
588
589 #define bus_space_read_multi_stream_1(t, h, o, a, c) \
590         bus_space_read_multi_1((t), (h), (o), (a), (c))
591 #define bus_space_read_multi_stream_2(t, h, o, a, c) \
592         bus_space_read_multi_2((t), (h), (o), (a), (c))
593 #define bus_space_read_multi_stream_4(t, h, o, a, c) \
594         bus_space_read_multi_4((t), (h), (o), (a), (c))
595
596 #define bus_space_write_stream_1(t, h, o, v) \
597         bus_space_write_1((t), (h), (o), (v))
598 #define bus_space_write_stream_2(t, h, o, v) \
599         bus_space_write_2((t), (h), (o), (v))
600 #define bus_space_write_stream_4(t, h, o, v) \
601         bus_space_write_4((t), (h), (o), (v))
602
603 #define bus_space_write_multi_stream_1(t, h, o, a, c) \
604         bus_space_write_multi_1((t), (h), (o), (a), (c))
605 #define bus_space_write_multi_stream_2(t, h, o, a, c) \
606         bus_space_write_multi_2((t), (h), (o), (a), (c))
607 #define bus_space_write_multi_stream_4(t, h, o, a, c) \
608         bus_space_write_multi_4((t), (h), (o), (a), (c))
609
610 #define bus_space_set_multi_stream_1(t, h, o, v, c) \
611         bus_space_set_multi_1((t), (h), (o), (v), (c))
612 #define bus_space_set_multi_stream_2(t, h, o, v, c) \
613         bus_space_set_multi_2((t), (h), (o), (v), (c))
614 #define bus_space_set_multi_stream_4(t, h, o, v, c) \
615         bus_space_set_multi_4((t), (h), (o), (v), (c))
616
617 #define bus_space_read_region_stream_1(t, h, o, a, c) \
618         bus_space_read_region_1((t), (h), (o), (a), (c))
619 #define bus_space_read_region_stream_2(t, h, o, a, c) \
620         bus_space_read_region_2((t), (h), (o), (a), (c))
621 #define bus_space_read_region_stream_4(t, h, o, a, c) \
622         bus_space_read_region_4((t), (h), (o), (a), (c))
623
624 #define bus_space_write_region_stream_1(t, h, o, a, c) \
625         bus_space_write_region_1((t), (h), (o), (a), (c))
626 #define bus_space_write_region_stream_2(t, h, o, a, c) \
627         bus_space_write_region_2((t), (h), (o), (a), (c))
628 #define bus_space_write_region_stream_4(t, h, o, a, c) \
629         bus_space_write_region_4((t), (h), (o), (a), (c))
630
631 #define bus_space_set_region_stream_1(t, h, o, v, c) \
632         bus_space_set_region_1((t), (h), (o), (v), (c))
633 #define bus_space_set_region_stream_2(t, h, o, v, c) \
634         bus_space_set_region_2((t), (h), (o), (v), (c))
635 #define bus_space_set_region_stream_4(t, h, o, v, c) \
636         bus_space_set_region_4((t), (h), (o), (v), (c))
637
638 #define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
639         bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
640 #define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
641         bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
642 #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
643         bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
644
645 #endif /* _PC98_BUS_H_ */