xref: /illumos-gate/usr/src/uts/sparc/sys/ddi_isa.h (revision c160bf3613805cfb4a89a0433ae896d3594f551f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_DDI_ISA_H
27 #define	_SYS_DDI_ISA_H
28 
29 #include <sys/isa_defs.h>
30 #include <sys/ndifm.h>
31 #include <sys/dditypes.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #ifdef	_KERNEL
38 
39 /*
40  * These are the data access functions which the platform
41  * can choose to define as functions or macro's.
42  */
43 
44 /*
45  * DDI interfaces defined as macro's
46  */
47 
48 /*
49  * DDI interfaces defined as functions
50  */
51 
52 /*
53  * The implementation specific ddi access handle is the same for
54  * all sparc v7 platforms.
55  */
56 
57 typedef struct ddi_acc_impl {
58 	ddi_acc_hdl_t	ahi_common;
59 	uint8_t
60 		(*ahi_get8)(struct ddi_acc_impl *handle, uint8_t *addr);
61 	uint16_t
62 		(*ahi_get16)(struct ddi_acc_impl *handle, uint16_t *addr);
63 	uint32_t
64 		(*ahi_get32)(struct ddi_acc_impl *handle, uint32_t *addr);
65 	uint64_t
66 		(*ahi_get64)(struct ddi_acc_impl *handle, uint64_t *addr);
67 	void	(*ahi_put8)(struct ddi_acc_impl *handle, uint8_t *addr,
68 			uint8_t value);
69 	void	(*ahi_put16)(struct ddi_acc_impl *handle, uint16_t *addr,
70 			uint16_t value);
71 	void	(*ahi_put32)(struct ddi_acc_impl *handle, uint32_t *addr,
72 			uint32_t value);
73 	void	(*ahi_put64)(struct ddi_acc_impl *handle, uint64_t *addr,
74 			uint64_t value);
75 
76 	void	(*ahi_rep_get8)(struct ddi_acc_impl *handle,
77 			uint8_t *host_addr, uint8_t *dev_addr,
78 			size_t repcount, uint_t flags);
79 	void	(*ahi_rep_get16)(struct ddi_acc_impl *handle,
80 			uint16_t *host_addr, uint16_t *dev_addr,
81 			size_t repcount, uint_t flags);
82 	void	(*ahi_rep_get32)(struct ddi_acc_impl *handle,
83 			uint32_t *host_addr, uint32_t *dev_addr,
84 			size_t repcount, uint_t flags);
85 	void	(*ahi_rep_get64)(struct ddi_acc_impl *handle,
86 			uint64_t *host_addr, uint64_t *dev_addr,
87 			size_t repcount, uint_t flags);
88 
89 	void	(*ahi_rep_put8)(struct ddi_acc_impl *handle,
90 			uint8_t *host_addr, uint8_t *dev_addr,
91 			size_t repcount, uint_t flags);
92 	void	(*ahi_rep_put16)(struct ddi_acc_impl *handle,
93 			uint16_t *host_addr, uint16_t *dev_addr,
94 			size_t repcount, uint_t flags);
95 	void	(*ahi_rep_put32)(struct ddi_acc_impl *handle,
96 			uint32_t *host_addr, uint32_t *dev_addr,
97 			size_t repcount, uint_t flags);
98 	void	(*ahi_rep_put64)(struct ddi_acc_impl *handle,
99 			uint64_t *host_addr, uint64_t *dev_addr,
100 			size_t repcount, uint_t flags);
101 
102 	int	(*ahi_fault_check)(struct ddi_acc_impl *handle);
103 	void	(*ahi_fault_notify)(struct ddi_acc_impl *handle);
104 	uint32_t	ahi_fault;
105 	ndi_err_t *ahi_err;	/* Access error data */
106 } ddi_acc_impl_t;
107 
108 /*
109  * Input functions to memory mapped IO
110  */
111 uint8_t
112 i_ddi_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
113 
114 uint16_t
115 i_ddi_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
116 
117 uint32_t
118 i_ddi_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
119 
120 uint64_t
121 i_ddi_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
122 
123 uint16_t
124 i_ddi_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
125 
126 uint32_t
127 i_ddi_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
128 
129 uint64_t
130 i_ddi_swap_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
131 
132 /*
133  * Output functions to memory mapped IO
134  */
135 void
136 i_ddi_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
137 
138 void
139 i_ddi_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
140 
141 void
142 i_ddi_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
143 
144 void
145 i_ddi_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
146 
147 void
148 i_ddi_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
149 
150 void
151 i_ddi_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
152 
153 void
154 i_ddi_swap_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
155 
156 /*
157  * Repeated input functions for memory mapped IO
158  */
159 void
160 i_ddi_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
161     size_t repcount, uint_t flags);
162 
163 void
164 i_ddi_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, uint16_t *dev_addr,
165     size_t repcount, uint_t flags);
166 
167 void
168 i_ddi_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, uint32_t *dev_addr,
169     size_t repcount, uint_t flags);
170 
171 void
172 i_ddi_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, uint64_t *dev_addr,
173     size_t repcount, uint_t flags);
174 
175 void
176 i_ddi_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
177     uint16_t *dev_addr, size_t repcount, uint_t flags);
178 
179 void
180 i_ddi_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
181     uint32_t *dev_addr, size_t repcount, uint_t flags);
182 
183 void
184 i_ddi_swap_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
185     uint64_t *dev_addr, size_t repcount, uint_t flags);
186 
187 /*
188  * Repeated output functions for memory mapped IO
189  */
190 void
191 i_ddi_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
192     size_t repcount, uint_t flags);
193 
194 void
195 i_ddi_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, uint16_t *dev_addr,
196     size_t repcount, uint_t flags);
197 
198 void
199 i_ddi_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, uint32_t *dev_addr,
200     size_t repcount, uint_t flags);
201 
202 void
203 i_ddi_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, uint64_t *dev_addr,
204     size_t repcount, uint_t flags);
205 
206 void
207 i_ddi_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
208     uint16_t *dev_addr, size_t repcount, uint_t flags);
209 
210 void
211 i_ddi_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
212     uint32_t *dev_addr, size_t repcount, uint_t flags);
213 
214 void
215 i_ddi_swap_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
216     uint64_t *dev_addr, size_t repcount, uint_t flags);
217 
218 /*
219  * Default fault-checking and notification functions
220  */
221 int
222 i_ddi_acc_fault_check(ddi_acc_impl_t *hdlp);
223 
224 void
225 i_ddi_acc_fault_notify(ddi_acc_impl_t *hdlp);
226 
227 /* DDI Fault Services functions */
228 
229 void i_ddi_caut_get(size_t size, void *addr, void *val);
230 
231 uint8_t i_ddi_prot_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
232 uint16_t i_ddi_prot_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
233 uint32_t i_ddi_prot_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
234 uint64_t i_ddi_prot_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
235 
236 void i_ddi_prot_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
237 void i_ddi_prot_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
238 void i_ddi_prot_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
239 void i_ddi_prot_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
240 
241 void i_ddi_prot_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
242     uint8_t *dev_addr, size_t repcount, uint_t flags);
243 void i_ddi_prot_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
244     uint16_t *dev_addr, size_t repcount, uint_t flags);
245 void i_ddi_prot_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
246     uint32_t *dev_addr, size_t repcount, uint_t flags);
247 void i_ddi_prot_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
248     uint64_t *dev_addr, size_t repcount, uint_t flags);
249 
250 void i_ddi_prot_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
251     uint8_t *dev_addr, size_t repcount, uint_t flags);
252 void i_ddi_prot_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
253     uint16_t *dev_addr, size_t repcount, uint_t flags);
254 void i_ddi_prot_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
255     uint32_t *dev_addr, size_t repcount, uint_t flags);
256 void i_ddi_prot_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
257     uint64_t *dev_addr, size_t repcount, uint_t flags);
258 
259 uint8_t i_ddi_caut_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
260 uint16_t i_ddi_caut_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
261 uint32_t i_ddi_caut_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
262 uint64_t i_ddi_caut_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
263 
264 void i_ddi_caut_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
265 void i_ddi_caut_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
266 void i_ddi_caut_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
267 void i_ddi_caut_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
268 
269 void i_ddi_caut_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
270     uint8_t *dev_addr, size_t repcount, uint_t flags);
271 void i_ddi_caut_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
272     uint16_t *dev_addr, size_t repcount, uint_t flags);
273 void i_ddi_caut_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
274     uint32_t *dev_addr, size_t repcount, uint_t flags);
275 void i_ddi_caut_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
276     uint64_t *dev_addr, size_t repcount, uint_t flags);
277 
278 void i_ddi_caut_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
279     uint8_t *dev_addr, size_t repcount, uint_t flags);
280 void i_ddi_caut_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
281     uint16_t *dev_addr, size_t repcount, uint_t flags);
282 void i_ddi_caut_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
283     uint32_t *dev_addr, size_t repcount, uint_t flags);
284 void i_ddi_caut_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
285     uint64_t *dev_addr, size_t repcount, uint_t flags);
286 
287 #endif	/* _KERNEL */
288 
289 #ifdef	__cplusplus
290 }
291 #endif
292 
293 #endif	/* _SYS_DDI_ISA_H */
294