xref: /titanic_51/usr/src/uts/sparc/sys/ddi_isa.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_DDI_ISA_H
28 #define	_SYS_DDI_ISA_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/isa_defs.h>
33 #include <sys/ndifm.h>
34 #include <sys/dditypes.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #ifdef	_KERNEL
41 
42 /*
43  * These are the data access functions which the platform
44  * can choose to define as functions or macro's.
45  */
46 
47 /*
48  * DDI interfaces defined as macro's
49  */
50 
51 /*
52  * DDI interfaces defined as functions
53  */
54 
55 #ifdef	__STDC__
56 
57 uint8_t
58 ddi_mem_get8(ddi_acc_handle_t handle, uint8_t *host_addr);
59 
60 uint16_t
61 ddi_mem_get16(ddi_acc_handle_t handle, uint16_t *host_addr);
62 
63 uint32_t
64 ddi_mem_get32(ddi_acc_handle_t handle, uint32_t *host_addr);
65 
66 uint64_t
67 ddi_mem_get64(ddi_acc_handle_t handle, uint64_t *host_addr);
68 
69 void
70 ddi_mem_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr,
71 	uint8_t *dev_addr, size_t repcount, uint_t flags);
72 
73 void
74 ddi_mem_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr,
75 	uint16_t *dev_addr, size_t repcount, uint_t flags);
76 
77 void
78 ddi_mem_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr,
79 	uint32_t *dev_addr, size_t repcount, uint_t flags);
80 
81 void
82 ddi_mem_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr,
83 	uint64_t *dev_addr, size_t repcount, uint_t flags);
84 
85 void
86 ddi_mem_put8(ddi_acc_handle_t handle, uint8_t *dev_addr, uint8_t value);
87 
88 void
89 ddi_mem_put16(ddi_acc_handle_t handle, uint16_t *dev_addr, uint16_t value);
90 
91 void
92 ddi_mem_put32(ddi_acc_handle_t handle, uint32_t *dev_addr, uint32_t value);
93 
94 void
95 ddi_mem_put64(ddi_acc_handle_t handle, uint64_t *dev_addr, uint64_t value);
96 
97 void
98 ddi_mem_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr,
99 	uint8_t *dev_addr, size_t repcount, uint_t flags);
100 
101 void
102 ddi_mem_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr,
103 	uint16_t *dev_addr, size_t repcount, uint_t flags);
104 
105 void
106 ddi_mem_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr,
107 	uint32_t *dev_addr, size_t repcount, uint_t flags);
108 
109 void
110 ddi_mem_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr,
111 	uint64_t *dev_addr, size_t repcount, uint_t flags);
112 
113 uint8_t
114 ddi_io_get8(ddi_acc_handle_t handle, uint8_t *dev_addr);
115 
116 uint16_t
117 ddi_io_get16(ddi_acc_handle_t handle, uint16_t *dev_addr);
118 
119 uint32_t
120 ddi_io_get32(ddi_acc_handle_t handle, uint32_t *dev_addr);
121 
122 void
123 ddi_io_rep_get8(ddi_acc_handle_t handle,
124 	uint8_t *host_addr, uint8_t *dev_addr, size_t repcount);
125 
126 void
127 ddi_io_rep_get16(ddi_acc_handle_t handle,
128 	uint16_t *host_addr, uint16_t *dev_addr, size_t repcount);
129 
130 void
131 ddi_io_rep_get32(ddi_acc_handle_t handle,
132 	uint32_t *host_addr, uint32_t *dev_addr, size_t repcount);
133 
134 void
135 ddi_io_put8(ddi_acc_handle_t handle, uint8_t *dev_addr, uint8_t value);
136 
137 void
138 ddi_io_put16(ddi_acc_handle_t handle, uint16_t *dev_addr, uint16_t value);
139 
140 void
141 ddi_io_put32(ddi_acc_handle_t handle, uint32_t *dev_addr, uint32_t value);
142 
143 void
144 ddi_io_rep_put8(ddi_acc_handle_t handle,
145 	uint8_t *host_addr, uint8_t *dev_addr, size_t repcount);
146 
147 void
148 ddi_io_rep_put16(ddi_acc_handle_t handle,
149 	uint16_t *host_addr, uint16_t *dev_addr, size_t repcount);
150 
151 void
152 ddi_io_rep_put32(ddi_acc_handle_t handle,
153 	uint32_t *host_addr, uint32_t *dev_addr, size_t repcount);
154 
155 #endif	/* __STDC__ */
156 
157 /*
158  * The implementation specific ddi access handle is the same for
159  * all sparc v7 platforms.
160  */
161 
162 typedef struct ddi_acc_impl {
163 	ddi_acc_hdl_t	ahi_common;
164 	uint8_t
165 		(*ahi_get8)(struct ddi_acc_impl *handle, uint8_t *addr);
166 	uint16_t
167 		(*ahi_get16)(struct ddi_acc_impl *handle, uint16_t *addr);
168 	uint32_t
169 		(*ahi_get32)(struct ddi_acc_impl *handle, uint32_t *addr);
170 	uint64_t
171 		(*ahi_get64)(struct ddi_acc_impl *handle, uint64_t *addr);
172 	void	(*ahi_put8)(struct ddi_acc_impl *handle, uint8_t *addr,
173 			uint8_t value);
174 	void	(*ahi_put16)(struct ddi_acc_impl *handle, uint16_t *addr,
175 			uint16_t value);
176 	void	(*ahi_put32)(struct ddi_acc_impl *handle, uint32_t *addr,
177 			uint32_t value);
178 	void	(*ahi_put64)(struct ddi_acc_impl *handle, uint64_t *addr,
179 			uint64_t value);
180 
181 	void	(*ahi_rep_get8)(struct ddi_acc_impl *handle,
182 			uint8_t *host_addr, uint8_t *dev_addr,
183 			size_t repcount, uint_t flags);
184 	void	(*ahi_rep_get16)(struct ddi_acc_impl *handle,
185 			uint16_t *host_addr, uint16_t *dev_addr,
186 			size_t repcount, uint_t flags);
187 	void	(*ahi_rep_get32)(struct ddi_acc_impl *handle,
188 			uint32_t *host_addr, uint32_t *dev_addr,
189 			size_t repcount, uint_t flags);
190 	void	(*ahi_rep_get64)(struct ddi_acc_impl *handle,
191 			uint64_t *host_addr, uint64_t *dev_addr,
192 			size_t repcount, uint_t flags);
193 
194 	void	(*ahi_rep_put8)(struct ddi_acc_impl *handle,
195 			uint8_t *host_addr, uint8_t *dev_addr,
196 			size_t repcount, uint_t flags);
197 	void	(*ahi_rep_put16)(struct ddi_acc_impl *handle,
198 			uint16_t *host_addr, uint16_t *dev_addr,
199 			size_t repcount, uint_t flags);
200 	void	(*ahi_rep_put32)(struct ddi_acc_impl *handle,
201 			uint32_t *host_addr, uint32_t *dev_addr,
202 			size_t repcount, uint_t flags);
203 	void	(*ahi_rep_put64)(struct ddi_acc_impl *handle,
204 			uint64_t *host_addr, uint64_t *dev_addr,
205 			size_t repcount, uint_t flags);
206 
207 	int	(*ahi_fault_check)(struct ddi_acc_impl *handle);
208 	void	(*ahi_fault_notify)(struct ddi_acc_impl *handle);
209 	uint32_t	ahi_fault;
210 	ndi_err_t *ahi_err;	/* Access error data */
211 } ddi_acc_impl_t;
212 
213 /*
214  * Input functions to memory mapped IO
215  */
216 uint8_t
217 i_ddi_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
218 
219 uint16_t
220 i_ddi_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
221 
222 uint32_t
223 i_ddi_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
224 
225 uint64_t
226 i_ddi_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
227 
228 uint16_t
229 i_ddi_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
230 
231 uint32_t
232 i_ddi_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
233 
234 uint64_t
235 i_ddi_swap_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
236 
237 /*
238  * Output functions to memory mapped IO
239  */
240 void
241 i_ddi_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
242 
243 void
244 i_ddi_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
245 
246 void
247 i_ddi_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
248 
249 void
250 i_ddi_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
251 
252 void
253 i_ddi_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
254 
255 void
256 i_ddi_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
257 
258 void
259 i_ddi_swap_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
260 
261 /*
262  * Repeated input functions for memory mapped IO
263  */
264 void
265 i_ddi_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
266 	size_t repcount, uint_t flags);
267 
268 void
269 i_ddi_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, uint16_t *dev_addr,
270 	size_t repcount, uint_t flags);
271 
272 void
273 i_ddi_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr, uint32_t *dev_addr,
274 	size_t repcount, uint_t flags);
275 
276 void
277 i_ddi_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr, uint64_t *dev_addr,
278 	size_t repcount, uint_t flags);
279 
280 void
281 i_ddi_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
282 	uint16_t *dev_addr, size_t repcount, uint_t flags);
283 
284 void
285 i_ddi_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
286 	uint32_t *dev_addr, size_t repcount, uint_t flags);
287 
288 void
289 i_ddi_swap_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
290 	uint64_t *dev_addr, size_t repcount, uint_t flags);
291 
292 /*
293  * Repeated output functions for memory mapped IO
294  */
295 void
296 i_ddi_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
297 	size_t repcount, uint_t flags);
298 
299 void
300 i_ddi_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr, uint16_t *dev_addr,
301 	size_t repcount, uint_t flags);
302 
303 void
304 i_ddi_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, uint32_t *dev_addr,
305 	size_t repcount, uint_t flags);
306 
307 void
308 i_ddi_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, uint64_t *dev_addr,
309 	size_t repcount, uint_t flags);
310 
311 void
312 i_ddi_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
313 	uint16_t *dev_addr, size_t repcount, uint_t flags);
314 
315 void
316 i_ddi_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
317 	uint32_t *dev_addr, size_t repcount, uint_t flags);
318 
319 void
320 i_ddi_swap_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
321 	uint64_t *dev_addr, size_t repcount, uint_t flags);
322 
323 /*
324  * Default fault-checking and notification functions
325  */
326 int
327 i_ddi_acc_fault_check(ddi_acc_impl_t *hdlp);
328 
329 void
330 i_ddi_acc_fault_notify(ddi_acc_impl_t *hdlp);
331 
332 /* DDI Fault Services functions */
333 
334 void i_ddi_caut_get(size_t size, void *addr, void *val);
335 
336 uint8_t i_ddi_prot_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
337 uint16_t i_ddi_prot_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
338 uint32_t i_ddi_prot_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
339 uint64_t i_ddi_prot_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
340 
341 void i_ddi_prot_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
342 void i_ddi_prot_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
343 void i_ddi_prot_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
344 void i_ddi_prot_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
345 
346 void i_ddi_prot_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
347     uint8_t *dev_addr, size_t repcount, uint_t flags);
348 void i_ddi_prot_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
349     uint16_t *dev_addr, size_t repcount, uint_t flags);
350 void i_ddi_prot_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
351     uint32_t *dev_addr, size_t repcount, uint_t flags);
352 void i_ddi_prot_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
353     uint64_t *dev_addr, size_t repcount, uint_t flags);
354 
355 void i_ddi_prot_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
356     uint8_t *dev_addr, size_t repcount, uint_t flags);
357 void i_ddi_prot_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
358     uint16_t *dev_addr, size_t repcount, uint_t flags);
359 void i_ddi_prot_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
360     uint32_t *dev_addr, size_t repcount, uint_t flags);
361 void i_ddi_prot_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
362     uint64_t *dev_addr, size_t repcount, uint_t flags);
363 
364 uint8_t i_ddi_caut_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
365 uint16_t i_ddi_caut_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
366 uint32_t i_ddi_caut_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
367 uint64_t i_ddi_caut_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
368 
369 void i_ddi_caut_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
370 void i_ddi_caut_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
371 void i_ddi_caut_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
372 void i_ddi_caut_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
373 
374 void i_ddi_caut_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
375     uint8_t *dev_addr, size_t repcount, uint_t flags);
376 void i_ddi_caut_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
377     uint16_t *dev_addr, size_t repcount, uint_t flags);
378 void i_ddi_caut_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
379     uint32_t *dev_addr, size_t repcount, uint_t flags);
380 void i_ddi_caut_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
381     uint64_t *dev_addr, size_t repcount, uint_t flags);
382 
383 void i_ddi_caut_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
384     uint8_t *dev_addr, size_t repcount, uint_t flags);
385 void i_ddi_caut_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
386     uint16_t *dev_addr, size_t repcount, uint_t flags);
387 void i_ddi_caut_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
388     uint32_t *dev_addr, size_t repcount, uint_t flags);
389 void i_ddi_caut_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
390     uint64_t *dev_addr, size_t repcount, uint_t flags);
391 
392 #endif	/* _KERNEL */
393 
394 #ifdef	__cplusplus
395 }
396 #endif
397 
398 #endif	/* _SYS_DDI_ISA_H */
399