bus_defs.h revision 1.2 1 /* $NetBSD: bus_defs.h,v 1.2 2011/07/25 15:58:44 dyoung Exp $ */
2
3 /*
4 * Copyright (c) 1996 Leo Weppelman. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef _AMIGAPPC_BUS_DEFS_H_
28 #define _AMIGAPPC_BUS_DEFS_H_
29
30 #include <sys/types.h>
31
32 /* for public use: */
33
34 /*
35 * Memory addresses (in bus space)
36 */
37
38 typedef uint32_t bus_addr_t;
39 typedef uint32_t bus_size_t;
40
41 /*
42 * Access methods for bus resources and address space.
43 */
44 typedef struct bus_space_tag *bus_space_tag_t;
45 typedef u_long bus_space_handle_t;
46
47 /* unpublic, but needed by method implementors */
48
49 /*
50 * Lazyness macros for function declarations.
51 */
52
53 #define bsr(what, typ) \
54 typ (what)(bus_space_handle_t, bus_addr_t)
55
56 #define bsw(what, typ) \
57 void (what)(bus_space_handle_t, bus_addr_t, unsigned)
58
59 #define bsrm(what, typ) \
60 void (what)(bus_space_handle_t, bus_size_t, typ *, bus_size_t)
61
62 #define bswm(what, typ) \
63 void (what)(bus_space_handle_t, bus_size_t, const typ *, bus_size_t)
64
65 #define bssr(what, typ) \
66 void (what)(bus_space_handle_t, bus_size_t, unsigned, bus_size_t)
67
68 #define bscr(what, typ) \
69 void (what)(bus_space_handle_t, bus_size_t, \
70 bus_space_handle_t, bus_size_t, bus_size_t)
71
72 /*
73 * Implementation specific structures.
74 * XXX Don't use outside of bus_space definitions!
75 * XXX maybe this should be encapsuled in a non-global .h file?
76 */
77
78 struct bus_space_tag {
79 bus_addr_t base;
80 const struct amiga_bus_space_methods *absm;
81 };
82
83 struct amiga_bus_space_methods {
84
85 /* map, unmap, etc */
86
87 int (*bsm)(bus_space_tag_t,
88 bus_addr_t, bus_size_t, int, bus_space_handle_t *);
89
90 int (*bsms)(bus_space_handle_t,
91 bus_size_t, bus_size_t, bus_space_handle_t *);
92
93 void (*bsu)(bus_space_handle_t, bus_size_t);
94
95 /* placeholders for currently not implemented alloc and free */
96
97 void *bsa;
98 void *bsf;
99
100 /* 8 bit methods */
101
102 bsr(*bsr1, uint8_t);
103 bsw(*bsw1, uint8_t);
104 bsrm(*bsrm1, uint8_t);
105 bswm(*bswm1, uint8_t);
106 bsrm(*bsrr1, uint8_t);
107 bswm(*bswr1, uint8_t);
108 bssr(*bssr1, uint8_t);
109 bscr(*bscr1, uint8_t);
110
111 /* 16bit methods */
112
113 bsr(*bsr2, uint16_t);
114 bsw(*bsw2, uint16_t);
115 bsr(*bsrs2, uint16_t);
116 bsw(*bsws2, uint16_t);
117 bsrm(*bsrm2, uint16_t);
118 bswm(*bswm2, uint16_t);
119 bsrm(*bsrms2, uint16_t);
120 bswm(*bswms2, uint16_t);
121 bsrm(*bsrr2, uint16_t);
122 bswm(*bswr2, uint16_t);
123 bsrm(*bsrrs2, uint16_t);
124 bswm(*bswrs2, uint16_t);
125 bssr(*bssr2, uint16_t);
126 bscr(*bscr2, uint16_t);
127
128 /* add 32bit methods here */
129 };
130
131 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
132 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
133
134 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
135
136 #define __BUS_SPACE_HAS_STREAM_METHODS
137
138 extern const struct amiga_bus_space_methods amiga_bus_stride_1;
139 extern const struct amiga_bus_space_methods amiga_bus_stride_2;
140 extern const struct amiga_bus_space_methods amiga_bus_stride_4;
141 extern const struct amiga_bus_space_methods amiga_bus_stride_4swap;
142 extern const struct amiga_bus_space_methods amiga_bus_stride_16;
143
144 #endif /* _AMIGAPPC_BUS_DEFS_H_ */
145