xref: /titanic_44/usr/src/uts/intel/sys/ddi_isa.h (revision 1ae0874509b6811fdde1dfd46f0d93fd09867a3f)
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 2006 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/isa_defs.h>
32 #include <sys/dditypes.h>
33 #include <sys/ndifm.h>
34 #ifdef	_KERNEL
35 #include <sys/ddi_obsolete.h>
36 #endif
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #ifdef	_KERNEL
43 
44 /*
45  * These are the data access functions which the platform
46  * can choose to define as functions or macro's.
47  */
48 
49 /*
50  * DDI interfaces defined as macro's
51  */
52 
53 /*
54  * DDI interfaces defined as functions
55  */
56 
57 #ifdef	__STDC__
58 
59 /*
60  * ahi_acc_attr flags
61  */
62 #define	DDI_ACCATTR_CONFIG_SPACE	0x1
63 #define	DDI_ACCATTR_IO_SPACE		0x2
64 #define	DDI_ACCATTR_CPU_VADDR		0x4
65 #define	DDI_ACCATTR_DIRECT		0x8
66 
67 typedef struct ddi_acc_impl {
68 	ddi_acc_hdl_t	ahi_common;
69 	uint_t		ahi_acc_attr;
70 	ulong_t		ahi_io_port_base;
71 
72 	uint8_t
73 		(*ahi_get8)(struct ddi_acc_impl *handle, uint8_t *addr);
74 	uint16_t
75 		(*ahi_get16)(struct ddi_acc_impl *handle, uint16_t *addr);
76 	uint32_t
77 		(*ahi_get32)(struct ddi_acc_impl *handle, uint32_t *addr);
78 	uint64_t
79 		(*ahi_get64)(struct ddi_acc_impl *handle, uint64_t *addr);
80 
81 	void	(*ahi_put8)(struct ddi_acc_impl *handle, uint8_t *addr,
82 			uint8_t value);
83 	void	(*ahi_put16)(struct ddi_acc_impl *handle, uint16_t *addr,
84 			uint16_t value);
85 	void	(*ahi_put32)(struct ddi_acc_impl *handle, uint32_t *addr,
86 			uint32_t value);
87 	void	(*ahi_put64)(struct ddi_acc_impl *handle, uint64_t *addr,
88 			uint64_t value);
89 
90 	void	(*ahi_rep_get8)(struct ddi_acc_impl *handle,
91 			uint8_t *host_addr, uint8_t *dev_addr,
92 			size_t repcount, uint_t flags);
93 	void	(*ahi_rep_get16)(struct ddi_acc_impl *handle,
94 			uint16_t *host_addr, uint16_t *dev_addr,
95 			size_t repcount, uint_t flags);
96 	void	(*ahi_rep_get32)(struct ddi_acc_impl *handle,
97 			uint32_t *host_addr, uint32_t *dev_addr,
98 			size_t repcount, uint_t flags);
99 	void	(*ahi_rep_get64)(struct ddi_acc_impl *handle,
100 			uint64_t *host_addr, uint64_t *dev_addr,
101 			size_t repcount, uint_t flags);
102 
103 	void	(*ahi_rep_put8)(struct ddi_acc_impl *handle,
104 			uint8_t *host_addr, uint8_t *dev_addr,
105 			size_t repcount, uint_t flags);
106 	void	(*ahi_rep_put16)(struct ddi_acc_impl *handle,
107 			uint16_t *host_addr, uint16_t *dev_addr,
108 			size_t repcount, uint_t flags);
109 	void	(*ahi_rep_put32)(struct ddi_acc_impl *handle,
110 			uint32_t *host_addr, uint32_t *dev_addr,
111 			size_t repcount, uint_t flags);
112 	void	(*ahi_rep_put64)(struct ddi_acc_impl *handle,
113 			uint64_t *host_addr, uint64_t *dev_addr,
114 			size_t repcount, uint_t flags);
115 
116 	int	(*ahi_fault_check)(struct ddi_acc_impl *handle);
117 	void	(*ahi_fault_notify)(struct ddi_acc_impl *handle);
118 	uint32_t	ahi_fault;
119 	ndi_err_t *ahi_err;
120 } ddi_acc_impl_t;
121 
122 
123 /*
124  * Input functions to memory mapped IO
125  */
126 uint8_t
127 i_ddi_vaddr_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
128 
129 uint16_t
130 i_ddi_vaddr_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
131 
132 uint32_t
133 i_ddi_vaddr_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
134 
135 uint64_t
136 i_ddi_vaddr_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
137 
138 uint16_t
139 i_ddi_vaddr_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
140 
141 uint32_t
142 i_ddi_vaddr_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
143 
144 uint64_t
145 i_ddi_vaddr_swap_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
146 
147 /*
148  * Output functions to memory mapped IO
149  */
150 void
151 i_ddi_vaddr_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
152 
153 void
154 i_ddi_vaddr_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
155 
156 void
157 i_ddi_vaddr_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
158 
159 void
160 i_ddi_vaddr_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
161 
162 void
163 i_ddi_vaddr_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
164 
165 void
166 i_ddi_vaddr_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
167 
168 void
169 i_ddi_vaddr_swap_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
170 
171 /*
172  * Repeated input functions for memory mapped IO
173  */
174 void
175 i_ddi_vaddr_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
176 	uint8_t *dev_addr, size_t repcount, uint_t flags);
177 
178 void
179 i_ddi_vaddr_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
180 	uint16_t *dev_addr, size_t repcount, uint_t flags);
181 
182 void
183 i_ddi_vaddr_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
184 	uint32_t *dev_addr, size_t repcount, uint_t flags);
185 
186 void
187 i_ddi_vaddr_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
188 	uint64_t *dev_addr, size_t repcount, uint_t flags);
189 
190 void
191 i_ddi_vaddr_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
192 	uint16_t *dev_addr, size_t repcount, uint_t flags);
193 
194 void
195 i_ddi_vaddr_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
196 	uint32_t *dev_addr, size_t repcount, uint_t flags);
197 
198 void
199 i_ddi_vaddr_swap_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
200 	uint64_t *dev_addr, size_t repcount, uint_t flags);
201 
202 /*
203  * Repeated output functions for memory mapped IO
204  */
205 void
206 i_ddi_vaddr_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
207 	uint8_t *dev_addr, size_t repcount, uint_t flags);
208 
209 void
210 i_ddi_vaddr_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
211 	uint16_t *dev_addr, size_t repcount, uint_t flags);
212 
213 void
214 i_ddi_vaddr_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
215 	uint32_t *dev_addr, size_t repcount, uint_t flags);
216 
217 void
218 i_ddi_vaddr_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
219 	uint64_t *dev_addr, size_t repcount, uint_t flags);
220 
221 void
222 i_ddi_vaddr_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
223 	uint16_t *dev_addr, size_t repcount, uint_t flags);
224 
225 void
226 i_ddi_vaddr_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
227 	uint32_t *dev_addr, size_t repcount, uint_t flags);
228 
229 void
230 i_ddi_vaddr_swap_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
231 	uint64_t *dev_addr, size_t repcount, uint_t flags);
232 
233 /*
234  * Input functions to IO space
235  */
236 uint8_t
237 i_ddi_io_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
238 
239 uint16_t
240 i_ddi_io_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
241 
242 uint32_t
243 i_ddi_io_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
244 
245 uint64_t
246 i_ddi_io_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
247 
248 uint16_t
249 i_ddi_io_swap_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
250 
251 uint32_t
252 i_ddi_io_swap_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
253 
254 /*
255  * Output functions to IO space
256  */
257 void
258 i_ddi_io_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
259 
260 void
261 i_ddi_io_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
262 
263 void
264 i_ddi_io_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
265 
266 void
267 i_ddi_io_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
268 
269 void
270 i_ddi_io_swap_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
271 
272 void
273 i_ddi_io_swap_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
274 
275 /*
276  * Repeated input functions for IO space
277  */
278 void
279 i_ddi_io_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
280 	size_t repcount, uint_t flags);
281 
282 void
283 i_ddi_io_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
284 	uint16_t *dev_addr, size_t repcount, uint_t flags);
285 
286 void
287 i_ddi_io_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
288 	uint32_t *dev_addr, size_t repcount, uint_t flags);
289 
290 void
291 i_ddi_io_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
292 	uint64_t *dev_addr, size_t repcount, uint_t flags);
293 
294 void
295 i_ddi_io_swap_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
296 	uint16_t *dev_addr, size_t repcount, uint_t flags);
297 
298 void
299 i_ddi_io_swap_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
300 	uint32_t *dev_addr, size_t repcount, uint_t flags);
301 
302 /*
303  * Repeated output functions for IO space
304  */
305 void
306 i_ddi_io_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
307 	size_t repcount, uint_t flags);
308 
309 void
310 i_ddi_io_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
311 	uint16_t *dev_addr, size_t repcount, uint_t flags);
312 
313 void
314 i_ddi_io_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr, uint32_t *dev_addr,
315 	size_t repcount, uint_t flags);
316 
317 void
318 i_ddi_io_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr, uint64_t *dev_addr,
319 	size_t repcount, uint_t flags);
320 void
321 i_ddi_io_swap_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
322 	uint16_t *dev_addr, size_t repcount, uint_t flags);
323 
324 void
325 i_ddi_io_swap_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
326 	uint32_t *dev_addr, size_t repcount, uint_t flags);
327 
328 /*
329  * Default fault-checking and notification functions
330  */
331 int
332 i_ddi_acc_fault_check(ddi_acc_impl_t *hdlp);
333 
334 void
335 i_ddi_acc_fault_notify(ddi_acc_impl_t *hdlp);
336 
337 /* DDI Fault Services functions */
338 void i_ddi_caut_get(size_t size, void *addr, void *val);
339 
340 uint8_t i_ddi_caut_get8(ddi_acc_impl_t *hdlp, uint8_t *addr);
341 uint16_t i_ddi_caut_get16(ddi_acc_impl_t *hdlp, uint16_t *addr);
342 uint32_t i_ddi_caut_get32(ddi_acc_impl_t *hdlp, uint32_t *addr);
343 uint64_t i_ddi_caut_get64(ddi_acc_impl_t *hdlp, uint64_t *addr);
344 
345 void i_ddi_caut_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value);
346 void i_ddi_caut_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value);
347 void i_ddi_caut_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value);
348 void i_ddi_caut_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value);
349 
350 void i_ddi_caut_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
351     uint8_t *dev_addr, size_t repcount, uint_t flags);
352 void i_ddi_caut_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
353     uint16_t *dev_addr, size_t repcount, uint_t flags);
354 void i_ddi_caut_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
355     uint32_t *dev_addr, size_t repcount, uint_t flags);
356 void i_ddi_caut_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
357     uint64_t *dev_addr, size_t repcount, uint_t flags);
358 
359 void i_ddi_caut_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr,
360     uint8_t *dev_addr, size_t repcount, uint_t flags);
361 void i_ddi_caut_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
362     uint16_t *dev_addr, size_t repcount, uint_t flags);
363 void i_ddi_caut_rep_put32(ddi_acc_impl_t *hdl, uint32_t *host_addr,
364     uint32_t *dev_addr, size_t repcount, uint_t flags);
365 void i_ddi_caut_rep_put64(ddi_acc_impl_t *hdl, uint64_t *host_addr,
366     uint64_t *dev_addr, size_t repcount, uint_t flags);
367 
368 #endif	/* __STDC__ */
369 
370 #endif	/* _KERNEL */
371 
372 #ifdef	__cplusplus
373 }
374 #endif
375 
376 #endif	/* _SYS_DDI_ISA_H */
377