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 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <sys/asi.h>
29 #include <sys/asm_linkage.h>
30 #include <sys/machthread.h>
31 #include <sys/privregs.h>
32 #include <sys/ontrap.h>
33 #include <sys/dditypes.h>
34
35 #ifndef lint
36 #include "assym.h"
37 #endif
38
39 #if defined(lint)
40 #include <sys/isa_defs.h>
41 #include <sys/types.h>
42 #include <sys/sunddi.h>
43 #endif /* lint */
44
45 /*
46 * This file implements the following ddi common access
47 * functions:
48 *
49 * ddi_get{8,16,32,64}
50 * ddi_put{8,16,32,64}
51 *
52 * and the underlying "trivial" implementations
53 *
54 * i_ddi_{get,put}{8,16,32,64}
55 *
56 * which assume that there is no need to check the access handle -
57 * byte swapping will be done by the mmu and the address is always
58 * accessible via ld/st instructions.
59 */
60
61 #if defined(lint)
62
63 /*ARGSUSED*/
64 uint8_t
65 ddi_get8(ddi_acc_handle_t handle, uint8_t *addr)
66 {
67 return (0);
68 }
69
70 /*ARGSUSED*/
71 uint8_t
72 ddi_mem_get8(ddi_acc_handle_t handle, uint8_t *addr)
73 {
74 return (0);
75 }
76
77 /*ARGSUSED*/
78 uint8_t
79 ddi_io_get8(ddi_acc_handle_t handle, uint8_t *dev_addr)
80 {
81 return (0);
82 }
83
84 /*ARGSUSED*/
85 uint16_t
86 ddi_get16(ddi_acc_handle_t handle, uint16_t *addr)
87 {
88 return (0);
89 }
90
91 /*ARGSUSED*/
92 uint16_t
93 ddi_mem_get16(ddi_acc_handle_t handle, uint16_t *addr)
94 {
95 return (0);
96 }
97
98 /*ARGSUSED*/
99 uint16_t
100 ddi_io_get16(ddi_acc_handle_t handle, uint16_t *dev_addr)
101 {
102 return (0);
103 }
104
105 /*ARGSUSED*/
106 uint32_t
107 ddi_get32(ddi_acc_handle_t handle, uint32_t *addr)
108 {
109 return (0);
110 }
111
112 /*ARGSUSED*/
113 uint32_t
114 ddi_mem_get32(ddi_acc_handle_t handle, uint32_t *addr)
115 {
116 return (0);
117 }
118
119 /*ARGSUSED*/
120 uint32_t
121 ddi_io_get32(ddi_acc_handle_t handle, uint32_t *dev_addr)
122 {
123 return (0);
124 }
125
126 /*ARGSUSED*/
127 uint64_t
128 ddi_get64(ddi_acc_handle_t handle, uint64_t *addr)
129 {
130 return (0);
131 }
132
133 /*ARGSUSED*/
134 uint64_t
135 ddi_mem_get64(ddi_acc_handle_t handle, uint64_t *addr)
136 {
137 return (0);
138 }
139
140 /*ARGSUSED*/
141 void
142 ddi_put8(ddi_acc_handle_t handle, uint8_t *addr, uint8_t value) {}
143
144 /*ARGSUSED*/
145 void
146 ddi_mem_put8(ddi_acc_handle_t handle, uint8_t *dev_addr, uint8_t value) {}
147
148 /*ARGSUSED*/
149 void
150 ddi_io_put8(ddi_acc_handle_t handle, uint8_t *dev_addr, uint8_t value) {}
151
152 /*ARGSUSED*/
153 void
154 ddi_put16(ddi_acc_handle_t handle, uint16_t *addr, uint16_t value) {}
155
156 /*ARGSUSED*/
157 void
158 ddi_mem_put16(ddi_acc_handle_t handle, uint16_t *dev_addr, uint16_t value) {}
159
160 /*ARGSUSED*/
161 void
162 ddi_io_put16(ddi_acc_handle_t handle, uint16_t *dev_addr, uint16_t value) {}
163
164 /*ARGSUSED*/
165 void
166 ddi_put32(ddi_acc_handle_t handle, uint32_t *addr, uint32_t value) {}
167
168 /*ARGSUSED*/
169 void
170 ddi_mem_put32(ddi_acc_handle_t handle, uint32_t *dev_addr, uint32_t value) {}
171
172 /*ARGSUSED*/
173 void
174 ddi_io_put32(ddi_acc_handle_t handle, uint32_t *dev_addr, uint32_t value) {}
175
176 /*ARGSUSED*/
177 void
178 ddi_put64(ddi_acc_handle_t handle, uint64_t *addr, uint64_t value) {}
179
180 /*ARGSUSED*/
181 void
182 ddi_mem_put64(ddi_acc_handle_t handle, uint64_t *dev_addr, uint64_t value) {}
183
184 /*ARGSUSED*/
185 void
186 ddi_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
187 size_t repcount, uint_t flags)
188 {
189 }
190
191 /*ARGSUSED*/
192 void
193 ddi_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
194 size_t repcount, uint_t flags)
195 {
196 }
197
198 /*ARGSUSED*/
199 void
200 ddi_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
201 size_t repcount, uint_t flags)
202 {
203 }
204
205 /*ARGSUSED*/
206 void
207 ddi_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
208 size_t repcount, uint_t flags)
209 {
210 }
211
212 /*ARGSUSED*/
213 void
214 ddi_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr, uint8_t *dev_addr,
215 size_t repcount, uint_t flags)
216 {
217 }
218
219 /*ARGSUSED*/
220 void
221 ddi_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr, uint16_t *dev_addr,
222 size_t repcount, uint_t flags)
223 {
224 }
225
226 /*ARGSUSED*/
227 void
228 ddi_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr, uint32_t *dev_addr,
229 size_t repcount, uint_t flags)
230 {
231 }
232
233 /*ARGSUSED*/
234 void
235 ddi_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr, uint64_t *dev_addr,
236 size_t repcount, uint_t flags)
237 {
238 }
239
240 /*ARGSUSED*/
241 void
242 ddi_mem_rep_get8(ddi_acc_handle_t handle, uint8_t *host_addr,
243 uint8_t *dev_addr, size_t repcount, uint_t flags)
244 {
245 }
246
247 /*ARGSUSED*/
248 void
249 ddi_mem_rep_get16(ddi_acc_handle_t handle, uint16_t *host_addr,
250 uint16_t *dev_addr, size_t repcount, uint_t flags)
251 {
252 }
253
254 /*ARGSUSED*/
255 void
256 ddi_mem_rep_get32(ddi_acc_handle_t handle, uint32_t *host_addr,
257 uint32_t *dev_addr, size_t repcount, uint_t flags)
258 {
259 }
260
261 /*ARGSUSED*/
262 void
263 ddi_mem_rep_get64(ddi_acc_handle_t handle, uint64_t *host_addr,
264 uint64_t *dev_addr, size_t repcount, uint_t flags)
265 {
266 }
267
268 /*ARGSUSED*/
269 void
270 ddi_mem_rep_put8(ddi_acc_handle_t handle, uint8_t *host_addr,
271 uint8_t *dev_addr, size_t repcount, uint_t flags)
272 {
273 }
274
275 /*ARGSUSED*/
276 void
277 ddi_mem_rep_put16(ddi_acc_handle_t handle, uint16_t *host_addr,
278 uint16_t *dev_addr, size_t repcount, uint_t flags)
279 {
280 }
281
282 /*ARGSUSED*/
283 void
284 ddi_mem_rep_put32(ddi_acc_handle_t handle, uint32_t *host_addr,
285 uint32_t *dev_addr, size_t repcount, uint_t flags)
286 {
287 }
288
289 /*ARGSUSED*/
290 void
291 ddi_mem_rep_put64(ddi_acc_handle_t handle, uint64_t *host_addr,
292 uint64_t *dev_addr, size_t repcount, uint_t flags)
293 {
294 }
295
296 /*ARGSUSED*/
297 void
298 ddi_io_rep_get8(ddi_acc_handle_t handle,
299 uint8_t *host_addr, uint8_t *dev_addr, size_t repcount) {}
300
301 /*ARGSUSED*/
302 void
303 ddi_io_rep_get16(ddi_acc_handle_t handle,
304 uint16_t *host_addr, uint16_t *dev_addr, size_t repcount) {}
305
306 /*ARGSUSED*/
307 void
308 ddi_io_rep_get32(ddi_acc_handle_t handle,
309 uint32_t *host_addr, uint32_t *dev_addr, size_t repcount) {}
310
311 /*ARGSUSED*/
312 void
313 ddi_io_rep_put8(ddi_acc_handle_t handle,
314 uint8_t *host_addr, uint8_t *dev_addr, size_t repcount) {}
315
316 /*ARGSUSED*/
317 void
318 ddi_io_rep_put16(ddi_acc_handle_t handle,
319 uint16_t *host_addr, uint16_t *dev_addr, size_t repcount) {}
320
321
322 /*ARGSUSED*/
323 void
324 ddi_io_rep_put32(ddi_acc_handle_t handle,
325 uint32_t *host_addr, uint32_t *dev_addr, size_t repcount) {}
326
327 /*ARGSUSED*/
328 uint8_t
329 i_ddi_get8(ddi_acc_impl_t *hdlp, uint8_t *addr)
330 {
331 return (0);
332 }
333
334 /*ARGSUSED*/
335 uint16_t
336 i_ddi_get16(ddi_acc_impl_t *hdlp, uint16_t *addr)
337 {
338 return (0);
339 }
340
341 /*ARGSUSED*/
342 uint32_t
343 i_ddi_get32(ddi_acc_impl_t *hdlp, uint32_t *addr)
344 {
345 return (0);
346 }
347
348 /*ARGSUSED*/
349 uint64_t
350 i_ddi_get64(ddi_acc_impl_t *hdlp, uint64_t *addr)
351 {
352 return (0);
353 }
354
355 /*ARGSUSED*/
356 void
357 i_ddi_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value) {}
358
359 /*ARGSUSED*/
360 void
361 i_ddi_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value) {}
362
363 /*ARGSUSED*/
364 void
365 i_ddi_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value) {}
366
367 /*ARGSUSED*/
368 void
369 i_ddi_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value) {}
370
371 /*ARGSUSED*/
372 void
373 i_ddi_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
374 size_t repcount, uint_t flags)
375 {
376 }
377
378 /*ARGSUSED*/
379 void
380 i_ddi_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
381 uint16_t *dev_addr, size_t repcount, uint_t flags)
382 {
383 }
384
385 /*ARGSUSED*/
386 void
387 i_ddi_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
388 uint32_t *dev_addr, size_t repcount, uint_t flags)
389 {
390 }
391
392 /*ARGSUSED*/
393 void
394 i_ddi_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
395 uint64_t *dev_addr, size_t repcount, uint_t flags)
396 {
397 }
398
399 /*ARGSUSED*/
400 void
401 i_ddi_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
402 size_t repcount, uint_t flags)
403 {
404 }
405
406 /*ARGSUSED*/
407 void
408 i_ddi_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
409 uint16_t *dev_addr, size_t repcount, uint_t flags)
410 {
411 }
412
413 /*ARGSUSED*/
414 void
415 i_ddi_rep_put32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
416 uint32_t *dev_addr, size_t repcount, uint_t flags)
417 {
418 }
419
420 /*ARGSUSED*/
421 void
422 i_ddi_rep_put64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
423 uint64_t *dev_addr, size_t repcount, uint_t flags)
424 {
425 }
426
427 /*ARGSUSED*/
428 uint8_t
429 i_ddi_prot_get8(ddi_acc_impl_t *hdlp, uint8_t *addr)
430 {
431 return (0);
432 }
433
434 /*ARGSUSED*/
435 uint16_t
436 i_ddi_prot_get16(ddi_acc_impl_t *hdlp, uint16_t *addr)
437 {
438 return (0);
439 }
440
441 /*ARGSUSED*/
442 uint32_t
443 i_ddi_prot_get32(ddi_acc_impl_t *hdlp, uint32_t *addr)
444 {
445 return (0);
446 }
447
448 /*ARGSUSED*/
449 uint64_t
450 i_ddi_prot_get64(ddi_acc_impl_t *hdlp, uint64_t *addr)
451 {
452 return (0);
453 }
454
455 /*ARGSUSED*/
456 void
457 i_ddi_prot_put8(ddi_acc_impl_t *hdlp, uint8_t *addr, uint8_t value) {}
458
459 /*ARGSUSED*/
460 void
461 i_ddi_prot_put16(ddi_acc_impl_t *hdlp, uint16_t *addr, uint16_t value) {}
462
463 /*ARGSUSED*/
464 void
465 i_ddi_prot_put32(ddi_acc_impl_t *hdlp, uint32_t *addr, uint32_t value) {}
466
467 /*ARGSUSED*/
468 void
469 i_ddi_prot_put64(ddi_acc_impl_t *hdlp, uint64_t *addr, uint64_t value) {}
470
471 /*ARGSUSED*/
472 void
473 i_ddi_prot_rep_get8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
474 size_t repcount, uint_t flags)
475 {
476 }
477
478 /*ARGSUSED*/
479 void
480 i_ddi_prot_rep_get16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
481 uint16_t *dev_addr, size_t repcount, uint_t flags)
482 {
483 }
484
485 /*ARGSUSED*/
486 void
487 i_ddi_prot_rep_get32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
488 uint32_t *dev_addr, size_t repcount, uint_t flags)
489 {
490 }
491
492 /*ARGSUSED*/
493 void
494 i_ddi_prot_rep_get64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
495 uint64_t *dev_addr, size_t repcount, uint_t flags)
496 {
497 }
498
499 /*ARGSUSED*/
500 void
501 i_ddi_prot_rep_put8(ddi_acc_impl_t *hdlp, uint8_t *host_addr, uint8_t *dev_addr,
502 size_t repcount, uint_t flags)
503 {
504 }
505
506 /*ARGSUSED*/
507 void
508 i_ddi_prot_rep_put16(ddi_acc_impl_t *hdlp, uint16_t *host_addr,
509 uint16_t *dev_addr, size_t repcount, uint_t flags)
510 {
511 }
512
513 /*ARGSUSED*/
514 void
515 i_ddi_prot_rep_put32(ddi_acc_impl_t *hdlp, uint32_t *host_addr,
516 uint32_t *dev_addr, size_t repcount, uint_t flags)
517 {
518 }
519
520 /*ARGSUSED*/
521 void
522 i_ddi_prot_rep_put64(ddi_acc_impl_t *hdlp, uint64_t *host_addr,
523 uint64_t *dev_addr, size_t repcount, uint_t flags)
524 {
525 }
526
527 /*ARGSUSED*/
528 int
529 i_ddi_ontrap(ddi_acc_handle_t handle)
530 {
531 return (0);
532 }
533
534 /*ARGSUSED*/
535 void
536 i_ddi_notrap(ddi_acc_handle_t handle)
537 {
538 }
539
540 /*ARGSUSED*/
541 void
542 i_ddi_caut_get(size_t getsz, void *addr, void *value)
543 {
544 }
545
546 #else
547
548 /*
549 * The functionality of each of the ddi_get/put routines is performed by
550 * the respective indirect function defined in the access handle. Use of
551 * the access handle functions provides compatibility across platforms for
552 * drivers.
553 *
554 * By default, the indirect access handle functions are initialized to the
555 * i_ddi_get/put routines to perform memory mapped IO. If memory mapped IO
556 * is not possible or desired, the access handle must be intialized to another
557 * valid routine to perform the sepcified IO operation.
558 *
559 * The alignment and placement of the following functions have been optimized
560 * such that the implementation specific versions, i_ddi*, fall within the
561 * same cache-line of the generic versions, ddi_*. This insures that an
562 * I-cache hit will occur thus minimizing the performance impact of using the
563 * access handle.
564 */
565
566 .align 32
567 ENTRY(ddi_get8)
1538 stuw %g1, [%o2]
1539 .get_half:
1540 bne,a .get_byte
1541 ldub [%o1], %g1 ! 8-bit!
1542 lduh [%o1], %g1
1543 ba .getdone
1544 stuh %g1, [%o2]
1545 .get_byte:
1546 stub %g1, [%o2]
1547 .getdone:
1548 rdpr %pstate, %o3 ! check&enable ints
1549 andcc %o3, PSTATE_IE, %g0
1550 bnz,a cautdone
1551 nop
1552 wrpr %o3, PSTATE_IE, %pstate
1553 cautdone:
1554 retl
1555 nop
1556 SET_SIZE(i_ddi_caut_get)
1557
1558 #endif /* lint */
|
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 #include <sys/asi.h>
27 #include <sys/asm_linkage.h>
28 #include <sys/machthread.h>
29 #include <sys/privregs.h>
30 #include <sys/ontrap.h>
31 #include <sys/dditypes.h>
32
33 #include "assym.h"
34
35 /*
36 * This file implements the following ddi common access
37 * functions:
38 *
39 * ddi_get{8,16,32,64}
40 * ddi_put{8,16,32,64}
41 *
42 * and the underlying "trivial" implementations
43 *
44 * i_ddi_{get,put}{8,16,32,64}
45 *
46 * which assume that there is no need to check the access handle -
47 * byte swapping will be done by the mmu and the address is always
48 * accessible via ld/st instructions.
49 */
50
51 /*
52 * The functionality of each of the ddi_get/put routines is performed by
53 * the respective indirect function defined in the access handle. Use of
54 * the access handle functions provides compatibility across platforms for
55 * drivers.
56 *
57 * By default, the indirect access handle functions are initialized to the
58 * i_ddi_get/put routines to perform memory mapped IO. If memory mapped IO
59 * is not possible or desired, the access handle must be intialized to another
60 * valid routine to perform the sepcified IO operation.
61 *
62 * The alignment and placement of the following functions have been optimized
63 * such that the implementation specific versions, i_ddi*, fall within the
64 * same cache-line of the generic versions, ddi_*. This insures that an
65 * I-cache hit will occur thus minimizing the performance impact of using the
66 * access handle.
67 */
68
69 .align 32
70 ENTRY(ddi_get8)
1041 stuw %g1, [%o2]
1042 .get_half:
1043 bne,a .get_byte
1044 ldub [%o1], %g1 ! 8-bit!
1045 lduh [%o1], %g1
1046 ba .getdone
1047 stuh %g1, [%o2]
1048 .get_byte:
1049 stub %g1, [%o2]
1050 .getdone:
1051 rdpr %pstate, %o3 ! check&enable ints
1052 andcc %o3, PSTATE_IE, %g0
1053 bnz,a cautdone
1054 nop
1055 wrpr %o3, PSTATE_IE, %pstate
1056 cautdone:
1057 retl
1058 nop
1059 SET_SIZE(i_ddi_caut_get)
1060
|