1 /* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.2 1998/02/07 00:44:37 dawes Exp $ */
2 /*
3 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Thomas Roell not be used in
10 * advertising or publicity pertaining to distribution of the software without
11 * specific, written prior permission. Thomas Roell makes no representations
12 * about the suitability of this software for any purpose. It is provided
13 * "as is" without express or implied warranty.
14 *
15 * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
22 *
23 */
24 /* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */
25
26 #ifndef _COMPILER_H
27 #define _COMPILER_H
28
29 #ifndef __STDC__
30 # ifdef signed
31 # undef signed
32 # endif
33 # ifdef volatile
34 # undef volatile
35 # endif
36 # ifdef const
37 # undef const
38 # endif
39 # define signed /**/
40 # ifdef __GNUC__
41 # define volatile __volatile__
42 # define const __const__
43 # ifdef PC98
44 # undef NO_INLINE
45 # endif
46 # else
47 # define const /**/
48 # ifdef PC98
49 # define __inline__ /**/
50 # endif
51 # endif /* __GNUC__ */
52 #endif /* !__STDC__ */
53
54 #if defined(IODEBUG) && defined(__GNUC__)
55 #define outb RealOutb
56 #define outw RealOutw
57 #define outl RealOutl
58 #define inb RealInb
59 #define inw RealInw
60 #define inl RealInl
61 #endif
62
63 #ifdef NO_INLINE
64
65 extern void outb();
66 extern void outw();
67 extern void outl();
68 extern unsigned int inb();
69 extern unsigned int inw();
70 extern unsigned int inl();
71 #if NeedFunctionPrototypes
72 extern unsigned char rdinx(unsigned short int, unsigned char);
73 extern void wrinx(unsigned short int, unsigned char, unsigned char);
74 extern void modinx(unsigned short int, unsigned char, unsigned char, unsigned char);
75 extern int testrg(unsigned short int, unsigned char);
76 extern int testinx2(unsigned short int, unsigned char, unsigned char);
77 extern int testinx(unsigned short int, unsigned char);
78 #else /* NeedFunctionProtoypes */
79 extern unsigned char rdinx();
80 extern void wrinx();
81 extern void modinx();
82 extern int testrg();
83 extern int testinx2();
84 extern int testinx();
85 #endif /* NeedFunctionProtoypes */
86
87 #else /* NO_INLINE */
88
89 #ifdef __GNUC__
90
91 #if defined(linux) && defined(__alpha__)
92 /* for Linux on Alpha, we use the LIBC _inx/_outx routines */
93 /* note that the appropriate setup via "ioperm" needs to be done */
94 /* *before* any inx/outx is done. */
95
96 static __inline__ void
outb(port,val)97 outb(port, val)
98 unsigned short port;
99 char val;
100 {
101 extern void _outb(char val, unsigned short port);
102 _outb(val, port);
103 }
104
105 static __inline__ void
outw(port,val)106 outw(port, val)
107 unsigned short port;
108 short val;
109 {
110 extern void _outw(short val, unsigned short port);
111 _outw(val, port);
112 }
113
114 static __inline__ void
outl(port,val)115 outl(port, val)
116 unsigned short port;
117 int val;
118 {
119 extern void _outl(int val, unsigned short port);
120 _outl(val, port);
121 }
122
123 static __inline__ unsigned int
inb(port)124 inb(port)
125 unsigned short port;
126 {
127 extern unsigned int _inb(unsigned short port);
128 return _inb(port);
129 }
130
131 static __inline__ unsigned int
inw(port)132 inw(port)
133 unsigned short port;
134 {
135 extern unsigned int _inw(unsigned short port);
136 return _inw(port);
137 }
138
139 static __inline__ unsigned int
inl(port)140 inl(port)
141 unsigned short port;
142 {
143 extern unsigned int _inl(unsigned short port);
144 return _inl(port);
145 }
146
147
148 /*
149 * inline functions to do unaligned accesses
150 * from linux/include/asm-alpha/unaligned.h
151 */
152
ldq_u(unsigned long * r11)153 static __inline__ unsigned long ldq_u(unsigned long * r11)
154 {
155 unsigned long r1,r2;
156 __asm__("ldq_u %0,%3\n\t"
157 "ldq_u %1,%4\n\t"
158 "extql %0,%2,%0\n\t"
159 "extqh %1,%2,%1\n\t"
160 "bis %1,%0,%0"
161 :"=&r" (r1), "=&r" (r2)
162 :"r" (r11),
163 "m" (*r11),
164 "m" (*(unsigned long *)(7+(char *) r11)));
165 return r1;
166 }
167
ldl_u(unsigned int * r11)168 static __inline__ unsigned long ldl_u(unsigned int * r11)
169 {
170 unsigned long r1,r2;
171 __asm__("ldq_u %0,%3\n\t"
172 "ldq_u %1,%4\n\t"
173 "extll %0,%2,%0\n\t"
174 "extlh %1,%2,%1\n\t"
175 "bis %1,%0,%0"
176 :"=&r" (r1), "=&r" (r2)
177 :"r" (r11),
178 "m" (*r11),
179 "m" (*(unsigned long *)(3+(char *) r11)));
180 return r1;
181 }
182
ldw_u(unsigned short * r11)183 static __inline__ unsigned long ldw_u(unsigned short * r11)
184 {
185 unsigned long r1,r2;
186 __asm__("ldq_u %0,%3\n\t"
187 "ldq_u %1,%4\n\t"
188 "extwl %0,%2,%0\n\t"
189 "extwh %1,%2,%1\n\t"
190 "bis %1,%0,%0"
191 :"=&r" (r1), "=&r" (r2)
192 :"r" (r11),
193 "m" (*r11),
194 "m" (*(unsigned long *)(1+(char *) r11)));
195 return r1;
196 }
197
stq_u(unsigned long r5,unsigned long * r11)198 static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
199 {
200 unsigned long r1,r2,r3,r4;
201
202 __asm__("ldq_u %3,%1\n\t"
203 "ldq_u %2,%0\n\t"
204 "insqh %6,%7,%5\n\t"
205 "insql %6,%7,%4\n\t"
206 "mskqh %3,%7,%3\n\t"
207 "mskql %2,%7,%2\n\t"
208 "bis %3,%5,%3\n\t"
209 "bis %2,%4,%2\n\t"
210 "stq_u %3,%1\n\t"
211 "stq_u %2,%0"
212 :"=m" (*r11),
213 "=m" (*(unsigned long *)(7+(char *) r11)),
214 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
215 :"r" (r5), "r" (r11));
216 }
217
stl_u(unsigned long r5,unsigned int * r11)218 static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
219 {
220 unsigned long r1,r2,r3,r4;
221
222 __asm__("ldq_u %3,%1\n\t"
223 "ldq_u %2,%0\n\t"
224 "inslh %6,%7,%5\n\t"
225 "insll %6,%7,%4\n\t"
226 "msklh %3,%7,%3\n\t"
227 "mskll %2,%7,%2\n\t"
228 "bis %3,%5,%3\n\t"
229 "bis %2,%4,%2\n\t"
230 "stq_u %3,%1\n\t"
231 "stq_u %2,%0"
232 :"=m" (*r11),
233 "=m" (*(unsigned long *)(3+(char *) r11)),
234 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
235 :"r" (r5), "r" (r11));
236 }
237
stw_u(unsigned long r5,unsigned short * r11)238 static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
239 {
240 unsigned long r1,r2,r3,r4;
241
242 __asm__("ldq_u %3,%1\n\t"
243 "ldq_u %2,%0\n\t"
244 "inswh %6,%7,%5\n\t"
245 "inswl %6,%7,%4\n\t"
246 "mskwh %3,%7,%3\n\t"
247 "mskwl %2,%7,%2\n\t"
248 "bis %3,%5,%3\n\t"
249 "bis %2,%4,%2\n\t"
250 "stq_u %3,%1\n\t"
251 "stq_u %2,%0"
252 :"=m" (*r11),
253 "=m" (*(unsigned long *)(1+(char *) r11)),
254 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
255 :"r" (r5), "r" (r11));
256 }
257
258 #define mem_barrier() __asm__ __volatile__("mb" : : : "memory")
259 #ifdef __ELF__
260 #define write_mem_barrier() __asm__ __volatile__("wmb" : : : "memory")
261 #else /* ECOFF gas 2.6 doesn't know "wmb" :-( */
262 #define write_mem_barrier() mem_barrier()
263 #endif
264
265 #else /* defined(linux) && defined(__alpha__) */
266 #if defined(__mips__)
267
268 unsigned int IOPortBase; /* Memory mapped I/O port area */
269
270 static __inline__ void
outb(port,val)271 outb(port, val)
272 short port;
273 char val;
274 {
275 *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val;
276 }
277
278 static __inline__ void
outw(port,val)279 outw(port, val)
280 short port;
281 short val;
282 {
283 *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val;
284 }
285
286 static __inline__ void
outl(port,val)287 outl(port, val)
288 short port;
289 int val;
290 {
291 *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val;
292 }
293
294 static __inline__ unsigned int
inb(port)295 inb(port)
296 short port;
297 {
298 return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase));
299 }
300
301 static __inline__ unsigned int
inw(port)302 inw(port)
303 short port;
304 {
305 return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase));
306 }
307
308 static __inline__ unsigned int
inl(port)309 inl(port)
310 short port;
311 {
312 return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase));
313 }
314
315
ldq_u(unsigned long * r11)316 static __inline__ unsigned long ldq_u(unsigned long * r11)
317 {
318 unsigned long r1;
319 __asm__("lwr %0,%2\n\t"
320 "lwl %0,%3\n\t"
321 :"=&r" (r1)
322 :"r" (r11),
323 "m" (*r11),
324 "m" (*(unsigned long *)(3+(char *) r11)));
325 return r1;
326 }
327
ldl_u(unsigned int * r11)328 static __inline__ unsigned long ldl_u(unsigned int * r11)
329 {
330 unsigned long r1;
331 __asm__("lwr %0,%2\n\t"
332 "lwl %0,%3\n\t"
333 :"=&r" (r1)
334 :"r" (r11),
335 "m" (*r11),
336 "m" (*(unsigned long *)(3+(char *) r11)));
337 return r1;
338 }
339
ldw_u(unsigned short * r11)340 static __inline__ unsigned long ldw_u(unsigned short * r11)
341 {
342 unsigned long r1;
343 __asm__("lwr %0,%2\n\t"
344 "lwl %0,%3\n\t"
345 :"=&r" (r1)
346 :"r" (r11),
347 "m" (*r11),
348 "m" (*(unsigned long *)(1+(char *) r11)));
349 return r1;
350 }
351
352 #define stq_u(v,p) stl_u(v,p)
353 #define stl_u(v,p) ((unsigned char *)(p)) = (v); \
354 ((unsigned char *)(p)+1) = ((v) >> 8); \
355 ((unsigned char *)(p)+2) = ((v) >> 16); \
356 ((unsigned char *)(p)+3) = ((v) >> 24)
357
358 #define stw_u(v,p) ((unsigned char *)(p)) = (v); \
359 ((unsigned char *)(p)+1) = ((v) >> 8)
360
361 #define mem_barrier() /* NOP */
362
363 #else /* defined(mips) */
364
365 #define ldq_u(p) (*((unsigned long *)(p)))
366 #define ldl_u(p) (*((unsigned int *)(p)))
367 #define ldw_u(p) (*((unsigned short *)(p)))
368 #define stq_u(v,p) ((unsigned long *)(p)) = (v)
369 #define stl_u(v,p) ((unsigned int *)(p)) = (v)
370 #define stw_u(v,p) ((unsigned short *)(p)) = (v)
371 #define mem_barrier() /* NOP */
372 #define write_mem_barrier() /* NOP */
373
374 #if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__)
375 #ifdef GCCUSESGAS
376
377 /*
378 * If gcc uses gas rather than the native assembler, the syntax of these
379 * inlines has to be different. DHD
380 */
381 #ifndef PC98
382
383 static __inline__ void
384 #if NeedFunctionPrototypes
outb(unsigned short int port,unsigned char val)385 outb(
386 unsigned short int port,
387 unsigned char val)
388 #else
389 outb(port, val)
390 unsigned short int port;
391 unsigned char val;
392 #endif /* NeedFunctionPrototypes */
393 {
394 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
395 }
396
397
398 static __inline__ void
399 #if NeedFunctionPrototypes
outw(unsigned short int port,unsigned short int val)400 outw(
401 unsigned short int port,
402 unsigned short int val)
403 #else
404 outw(port, val)
405 unsigned short int port;
406 unsigned short int val;
407 #endif /* NeedFunctionPrototypes */
408 {
409 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
410 }
411
412 static __inline__ void
413 #if NeedFunctionPrototypes
outl(unsigned short int port,unsigned int val)414 outl(
415 unsigned short int port,
416 unsigned int val)
417 #else
418 outl(port, val)
419 unsigned short int port;
420 unsigned int val;
421 #endif /* NeedFunctionPrototypes */
422 {
423 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
424 }
425
426 static __inline__ unsigned int
427 #if NeedFunctionPrototypes
inb(unsigned short int port)428 inb(
429 unsigned short int port)
430 #else
431 inb(port)
432 unsigned short int port;
433 #endif /* NeedFunctionPrototypes */
434 {
435 unsigned char ret;
436 __asm__ __volatile__("inb %1,%0" :
437 "=a" (ret) :
438 "d" (port));
439 return ret;
440 }
441
442 static __inline__ unsigned int
443 #if NeedFunctionPrototypes
inw(unsigned short int port)444 inw(
445 unsigned short int port)
446 #else
447 inw(port)
448 unsigned short int port;
449 #endif /* NeedFunctionPrototypes */
450 {
451 unsigned short int ret;
452 __asm__ __volatile__("inw %1,%0" :
453 "=a" (ret) :
454 "d" (port));
455 return ret;
456 }
457
458 static __inline__ unsigned int
459 #if NeedFunctionPrototypes
inl(unsigned short int port)460 inl(
461 unsigned short int port)
462 #else
463 inl(port)
464 unsigned short int port;
465 #endif /* NeedFunctionPrototypes */
466 {
467 unsigned int ret;
468 __asm__ __volatile__("inl %1,%0" :
469 "=a" (ret) :
470 "d" (port));
471 return ret;
472 }
473
474 #else /* PC98 */
475
476 static __inline__ void
477 #if NeedFunctionPrototypes
_outb(unsigned short int port,unsigned char val)478 _outb(
479 unsigned short int port,
480 unsigned char val)
481 #else
482 _outb(port, val)
483 unsigned short int port;
484 unsigned char val;
485 #endif /* NeedFunctionPrototypes */
486 {
487 __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port));
488 }
489
490 static __inline__ void
491 #if NeedFunctionPrototypes
_outw(unsigned short int port,unsigned short int val)492 _outw(
493 unsigned short int port,
494 unsigned short int val)
495 #else
496 _outw(port, val)
497 unsigned short int port;
498 unsigned short int val;
499 #endif /* NeedFunctionPrototypes */
500 {
501 __asm__ __volatile__("outw %0,%1" ::"a" (val), "d" (port));
502 }
503
504 static __inline__ void
505 #if NeedFunctionPrototypes
_outl(unsigned short int port,unsigned int val)506 _outl(
507 unsigned short int port,
508 unsigned int val)
509 #else
510 _outl(port, val)
511 unsigned short int port;
512 unsigned int val;
513 #endif /* NeedFunctionPrototypes */
514 {
515 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
516 }
517
518
519 static __inline__ unsigned int
520 #if NeedFunctionPrototypes
_inb(unsigned short int port)521 _inb(
522 unsigned short int port)
523 #else
524 _inb(port)
525 unsigned short int port;
526 #endif /* NeedFunctionPrototypes */
527 {
528 unsigned char ret;
529 __asm__ __volatile__("inb %1,%0" :
530 "=a" (ret) :
531 "d" (port));
532 return ret;
533 }
534
535 static __inline__ unsigned int
536 #if NeedFunctionPrototypes
_inw(unsigned short int port)537 _inw(
538 unsigned short int port)
539 #else
540 _inw(port)
541 unsigned short int port;
542 #endif /* NeedFunctionPrototypes */
543 {
544 unsigned short ret;
545 __asm__ __volatile__("inw %1,%0" :
546 "=a" (ret) :
547 "d" (port));
548 return ret;
549 }
550
551 static __inline__ unsigned int
552 #if NeedFunctionPrototypes
_inl(unsigned short int port)553 _inl(
554 unsigned short int port)
555 #else
556 _inl(port)
557 unsigned short int port;
558 #endif /* NeedFunctionPrototypes */
559 {
560 unsigned int ret;
561 __asm__ __volatile__("inl %1,%0" :
562 "=a" (ret) :
563 "d" (port));
564 return ret;
565 }
566
567
568 #if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968)
569 #define PW_PORT 0x600
570 extern short chipID;
571 #if NeedFunctionPrototypes
572 extern void *mmioBase;
573 #else
574 extern unsigned char *mmioBase;
575 #endif
576 extern unsigned short _port_tbl[];
577 #define port_convert(x) _port_tbl[(unsigned short)x]
578 #endif
579
580 #if defined(PC98_WAB) || defined(PC98_GANB_WAP)
581 static __inline__ unsigned short
port_convert(unsigned short port)582 port_convert(unsigned short port)
583 {
584 port <<= 8;
585 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
586 port |= 0xE0;
587 return port;
588 }
589 #endif /* PC98_WAB || PC98_GANB_WAP */
590
591 #if defined(PC98_WABEP)
592 static __inline__ unsigned short
port_convert(unsigned short port)593 port_convert(unsigned short port)
594 {
595 port &= 0x7f; /* Mask 0000 0000 0111 1111 */
596 port |= 0x0f00;
597 return port;
598 }
599 #endif /* PC98_WABEP */
600
601 #ifdef PC98_WSNA
602 static __inline__ unsigned short
port_convert(unsigned short port)603 port_convert(unsigned short port)
604 {
605 port <<= 8;
606 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
607 port |= 0xE2;
608 return port;
609 }
610 #endif /* PC98_WSNA */
611
612 #ifdef PC98_NKVNEC
613 #ifdef PC98_NEC_CIRRUS2
614 static __inline__ unsigned short
port_convert(unsigned short port)615 port_convert(unsigned short port)
616 {
617 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
618 return port;
619 }
620 #else
621 static __inline__ unsigned short
port_convert(unsigned short port)622 port_convert(unsigned short port)
623 {
624 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
625 return port;
626 }
627 #endif /* PC98_NEC_CIRRUS2 */
628 #endif /* PC98_NKVNEC */
629
630 #if defined(PC98_TGUI) || defined(PC98_MGA)
631 #if NeedFunctionPrototypes
632 extern void *mmioBase;
633 #else
634 extern unsigned char *mmioBase;
635 #endif
636 #endif
637
638 static __inline__ void
639 #if NeedFunctionPrototypes
outb(unsigned short port,unsigned char val)640 outb(
641 unsigned short port,
642 unsigned char val)
643 #else
644 outb(port, val)
645 unsigned short port;
646 unsigned char val;
647 #endif /* NeedFunctionPrototypes */
648 {
649 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
650 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
651 defined(PC98_XKB) || defined(PC98_NEC)
652 unsigned short tmp;
653 tmp=port_convert(port);
654 port=tmp;
655 #endif
656
657 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
658 *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
659 #else
660 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
661 #endif
662 }
663
664 static __inline__ void
665 #if NeedFunctionPrototypes
outw(unsigned short port,unsigned short val)666 outw(
667 unsigned short port,
668 unsigned short val)
669 #else
670 outw(port, val)
671 unsigned short port;
672 unsigned short val;
673 #endif /* NeedFunctionPrototypes */
674 {
675 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
676 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
677 defined(PC98_XKB) || defined(PC98_NEC)
678 unsigned short tmp;
679 tmp=port_convert(port);
680 port=tmp;
681 #endif
682
683 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
684 *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
685 #else
686 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
687 #endif
688 }
689
690 static __inline__ void
691 #if NeedFunctionPrototypes
outl(unsigned short port,unsigned int val)692 outl(
693 unsigned short port,
694 unsigned int val)
695 #else
696 outl(port, val)
697 unsigned short port;
698 unsigned int val;
699 #endif /* NeedFunctionPrototypes */
700 {
701 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
702 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
703 defined(PC98_XKB) || defined(PC98_NEC)
704 unsigned short tmp;
705 tmp=port_convert(port);
706 port=tmp;
707 #endif
708
709 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
710 *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
711 #else
712 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
713 #endif
714 }
715
716 static __inline__ unsigned int
717 #if NeedFunctionPrototypes
inb(unsigned short port)718 inb(
719 unsigned short port)
720 #else
721 inb(port)
722 unsigned short port;
723 #endif /* NeedFunctionPrototypes */
724 {
725 unsigned char ret;
726
727 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
728 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
729 defined(PC98_XKB) || defined(PC98_NEC)
730 unsigned short tmp;
731 tmp=port_convert(port);
732 port=tmp;
733 #endif
734
735 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
736 ret =*(volatile unsigned char *)((char *)mmioBase+(port));
737 #else
738 __asm__ __volatile__("inb %1,%0" :
739 "=a" (ret) :
740 "d" (port));
741 #endif
742 return ret;
743 }
744
745 static __inline__ unsigned int
746 #if NeedFunctionPrototypes
inw(unsigned short port)747 inw(
748 unsigned short port)
749 #else
750 inw(port)
751 unsigned short port;
752 #endif /* NeedFunctionPrototypes */
753 {
754 unsigned short ret;
755
756 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
757 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
758 defined(PC98_XKB) || defined(PC98_NEC)
759 unsigned short tmp;
760 tmp=port_convert(port);
761 port=tmp;
762 #endif
763
764 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
765 ret =*(volatile unsigned short *)((char *)mmioBase+(port));
766 #else
767 __asm__ __volatile__("inw %1,%0" :
768 "=a" (ret) :
769 "d" (port));
770 #endif
771 return ret;
772 }
773
774 static __inline__ unsigned int
775 #if NeedFunctionPrototypes
inl(unsigned short port)776 inl(
777 unsigned short port)
778 #else
779 inl(port)
780 unsigned short port;
781 #endif /* NeedFunctionPrototypes */
782 {
783 unsigned int ret;
784
785 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
786 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
787 defined(PC98_XKB) || defined(PC98_NEC)
788 unsigned short tmp;
789 tmp=port_convert(port);
790 port=tmp;
791 #endif
792
793 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
794 ret =*(volatile unsigned int *)((char *)mmioBase+(port));
795 #else
796 __asm__ __volatile__("inl %1,%0" :
797 "=a" (ret) :
798 "d" (port));
799 #endif
800 return ret;
801 }
802
803 #endif /* PC98 */
804
805 #else /* GCCUSESGAS */
806
807 static __inline__ void
808 #if NeedFunctionPrototypes
outb(unsigned short int port,unsigned char val)809 outb(
810 unsigned short int port,
811 unsigned char val)
812 #else
813 outb(port, val)
814 unsigned short int port;
815 unsigned char val;
816 #endif /* NeedFunctionPrototypes */
817 {
818 __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
819 }
820
821 static __inline__ void
822 #if NeedFunctionPrototypes
outw(unsigned short int port,unsigned short int val)823 outw(
824 unsigned short int port,
825 unsigned short int val)
826 #else
827 outw(port, val)
828 unsigned short int port;
829 unsigned short int val;
830 #endif /* NeedFunctionPrototypes */
831 {
832 __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
833 }
834
835 static __inline__ void
836 #if NeedFunctionPrototypes
outl(unsigned short int port,unsigned int val)837 outl(
838 unsigned short int port,
839 unsigned int val)
840 #else
841 outl(port, val)
842 unsigned short int port;
843 unsigned int val;
844 #endif /* NeedFunctionPrototypes */
845 {
846 __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
847 }
848
849 static __inline__ unsigned int
850 #if NeedFunctionPrototypes
inb(unsigned short int port)851 inb(
852 unsigned short int port)
853 #else
854 inb(port)
855 unsigned short int port;
856 #endif /* NeedFunctionPrototypes */
857 {
858 unsigned char ret;
859 __asm__ __volatile__("in%B0 (%1)" :
860 "=a" (ret) :
861 "d" (port));
862 return ret;
863 }
864
865 static __inline__ unsigned int
866 #if NeedFunctionPrototypes
inw(unsigned short int port)867 inw(
868 unsigned short int port)
869 #else
870 inw(port)
871 unsigned short int port;
872 #endif /* NeedFunctionPrototypes */
873 {
874 unsigned short int ret;
875 __asm__ __volatile__("in%W0 (%1)" :
876 "=a" (ret) :
877 "d" (port));
878 return ret;
879 }
880
881 static __inline__ unsigned int
882 #if NeedFunctionPrototypes
inl(unsigned short int port)883 inl(
884 unsigned short int port)
885 #else
886 inl(port)
887 unsigned short int port;
888 #endif /* NeedFunctionPrototypes */
889 {
890 unsigned int ret;
891 __asm__ __volatile__("in%L0 (%1)" :
892 "=a" (ret) :
893 "d" (port));
894 return ret;
895 }
896
897 #endif /* GCCUSESGAS */
898
899 #else /* !defined(FAKEIT) && !defined(__mc68000__) */
900
901 static __inline__ void
902 #if NeedFunctionPrototypes
outb(unsigned short int port,unsigned char val)903 outb(
904 unsigned short int port,
905 unsigned char val)
906 #else
907 outb(port, val)
908 unsigned short int port;
909 unsigned char val;
910 #endif /* NeedFunctionPrototypes */
911 {
912 }
913
914 static __inline__ void
915 #if NeedFunctionPrototypes
outw(unsigned short int port,unsigned short int val)916 outw(
917 unsigned short int port,
918 unsigned short int val)
919 #else
920 outw(port, val)
921 unsigned short int port;
922 unsigned short int val;
923 #endif /* NeedFunctionPrototypes */
924 {
925 }
926
927 static __inline__ void
928 #if NeedFunctionPrototypes
outl(unsigned short int port,unsigned int val)929 outl(
930 unsigned short int port,
931 unsigned int val)
932 #else
933 outl(port, val)
934 unsigned short int port;
935 unsigned int val;
936 #endif /* NeedFunctionPrototypes */
937 {
938 }
939
940 static __inline__ unsigned int
941 #if NeedFunctionPrototypes
inb(unsigned short int port)942 inb(
943 unsigned short int port)
944 #else
945 inb(port)
946 unsigned short int port;
947 #endif /* NeedFunctionPrototypes */
948 {
949 return 0;
950 }
951
952 static __inline__ unsigned int
953 #if NeedFunctionPrototypes
inw(unsigned short int port)954 inw(
955 unsigned short int port)
956 #else
957 inw(port)
958 unsigned short int port;
959 #endif /* NeedFunctionPrototypes */
960 {
961 return 0;
962 }
963
964 static __inline__ unsigned int
965 #if NeedFunctionPrototypes
inl(unsigned short int port)966 inl(
967 unsigned short int port)
968 #else
969 inl(port)
970 unsigned short int port;
971 #endif /* NeedFunctionPrototypes */
972 {
973 return 0;
974 }
975
976 #endif /* FAKEIT */
977
978 #endif /* defined(mips) */
979 #endif /* defined(AlphaArchitecture) && defined(LinuxArchitecture) */
980
981 #else /* __GNUC__ */
982 #if !defined(AMOEBA) && !defined(MINIX)
983 # if defined(__STDC__) && (__STDC__ == 1)
984 # ifndef asm
985 # define asm __asm
986 # endif
987 # endif
988 # ifdef SVR4
989 # include <sys/types.h>
990 # ifndef __HIGHC__
991 # ifndef __USLC__
992 # define __USLC__
993 # endif
994 # endif
995 # endif
996 # ifndef PC98
997 # ifndef SCO325
998 # include <sys/inline.h>
999 # else
1000 # include "scoasm.h"
1001 # endif
1002 # else
1003 #if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968)
1004 #define PW_PORT 0x600
1005 extern short chipID;
1006 #if NeedFunctionPrototypes
1007 extern void *mmioBase;
1008 #else
1009 extern unsigned char *mmioBase;
1010 #endif
1011 extern unsigned short _port_tbl[];
1012 #define port_convert(x) _port_tbl[(unsigned short)x]
1013 #endif
1014
1015 #if defined(PC98_TGUI) || defined(PC98_MGA)
1016 #if NeedFunctionPrototypes
1017 extern void *mmioBase;
1018 #else
1019 extern unsigned char *mmioBase;
1020 #endif
1021 #endif
1022
_outl(port,val)1023 asm void _outl(port,val)
1024 {
1025 %reg port,val;
1026 movl port, %edx
1027 movl val, %eax
1028 outl (%dx)
1029 %reg port; mem val;
1030 movl port, %edx
1031 movl val, %eax
1032 outl (%dx)
1033 %mem port; reg val;
1034 movw port, %dx
1035 movl val, %eax
1036 outl (%dx)
1037 %mem port,val;
1038 movw port, %dx
1039 movl val, %eax
1040 outl (%dx)
1041 }
1042
_outw(port,val)1043 asm void _outw(port,val)
1044 {
1045 %reg port,val;
1046 movl port, %edx
1047 movl val, %eax
1048 data16
1049 outl (%dx)
1050 %reg port; mem val;
1051 movl port, %edx
1052 movw val, %ax
1053 data16
1054 outl (%dx)
1055 %mem port; reg val;
1056 movw port, %dx
1057 movl val, %eax
1058 data16
1059 outl (%dx)
1060 %mem port,val;
1061 movw port, %dx
1062 movw val, %ax
1063 data16
1064 outl (%dx)
1065 }
1066
_outb(port,val)1067 asm void _outb(port,val)
1068 {
1069 %reg port,val;
1070 movl port, %edx
1071 movl val, %eax
1072 outb (%dx)
1073 %reg port; mem val;
1074 movl port, %edx
1075 movb val, %al
1076 outb (%dx)
1077 %mem port; reg val;
1078 movw port, %dx
1079 movl val, %eax
1080 outb (%dx)
1081 %mem port,val;
1082 movw port, %dx
1083 movb val, %al
1084 outb (%dx)
1085 }
1086
_inl(port)1087 asm int _inl(port)
1088 {
1089 %reg port;
1090 movl port, %edx
1091 inl (%dx)
1092 %mem port;
1093 movw port, %dx
1094 inl (%dx)
1095 }
1096
_inw(port)1097 asm int _inw(port)
1098 {
1099 %reg port;
1100 subl %eax, %eax
1101 movl port, %edx
1102 data16
1103 inl (%dx)
1104 %mem port;
1105 subl %eax, %eax
1106 movw port, %dx
1107 data16
1108 inl (%dx)
1109 }
1110
_inb(port)1111 asm int _inb(port)
1112 {
1113 %reg port;
1114 subl %eax, %eax
1115 movl port, %edx
1116 inb (%dx)
1117 %mem port;
1118 subl %eax, %eax
1119 movw port, %dx
1120 inb (%dx)
1121 }
1122
1123 #if defined(PC98_WAB) || defined(PC98_GANB_WAP)
1124 static unsigned short
port_convert(unsigned short port)1125 port_convert(unsigned short port)
1126 {
1127 port <<= 8;
1128 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
1129 port |= 0xE0;
1130 return port;
1131 }
1132 #endif /* PC98_WAB || PC98_GANB_WAP */
1133
1134 #if defined(PC98_WABEP)
1135 static unsigned short
port_convert(unsigned short port)1136 port_convert(unsigned short port)
1137 {
1138 port &= 0x7f; /* Mask 0000 0000 0111 1111 */
1139 port |= 0x0f00;
1140 return port;
1141 }
1142 #endif /* PC98_WABEP */
1143
1144 #ifdef PC98_WSNA
1145 static unsigned short
port_convert(unsigned short port)1146 port_convert(unsigned short port)
1147 {
1148 port <<= 8;
1149 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
1150 port |= 0xE2;
1151 return port;
1152 }
1153 #endif /* PC98_WSNA */
1154
1155 #ifdef PC98_NKVNEC
1156 #ifdef PC98_NEC_CIRRUS2
1157 static unsigned short
port_convert(unsigned short port)1158 port_convert(unsigned short port)
1159 {
1160 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
1161 return port;
1162 }
1163 #else
1164 static unsigned short
port_convert(unsigned short port)1165 port_convert(unsigned short port)
1166 {
1167 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
1168 return port;
1169 }
1170 #endif /* PC98_NEC_CIRRUS2 */
1171 #endif /* PC98_NKVNEC */
1172
outl(port,val)1173 static void outl(port,val)
1174 {
1175 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
1176 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
1177 defined(PC98_XKB) || defined(PC98_NEC)
1178 unsigned short tmp;
1179 tmp=port_convert(port);
1180 port=tmp;
1181 #endif
1182
1183 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1184 *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
1185 #else
1186 _outl(port,val);
1187 #endif
1188 }
1189
outw(port,val)1190 static void outw(port,val)
1191 {
1192 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
1193 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
1194 defined(PC98_XKB) || defined(PC98_NEC)
1195 unsigned short tmp;
1196 tmp=port_convert(port);
1197 port=tmp;
1198 #endif
1199
1200 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1201 *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
1202 #else
1203 _outw(port,val);
1204 #endif
1205 }
1206
outb(port,val)1207 static void outb(port,val)
1208 {
1209 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
1210 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
1211 defined(PC98_XKB) || defined(PC98_NEC)
1212 unsigned short tmp;
1213 tmp=port_convert(port);
1214 port=tmp;
1215 #endif
1216
1217 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1218 *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
1219 #else
1220 _outb(port,val);
1221 #endif
1222 }
1223
inl(port)1224 static int inl(port)
1225 {
1226 unsigned int ret;
1227
1228 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
1229 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
1230 defined(PC98_XKB) || defined(PC98_NEC)
1231 unsigned short tmp;
1232 tmp=port_convert(port);
1233 port=tmp;
1234 #endif
1235
1236 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1237 ret =*(volatile unsigned int *)((char *)mmioBase+(port));
1238 #else
1239 ret = _inl(port);
1240 #endif
1241 return ret;
1242 }
1243
inw(port)1244 static int inw(port)
1245 {
1246 unsigned short ret;
1247
1248 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
1249 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
1250 defined(PC98_XKB) || defined(PC98_NEC)
1251 unsigned short tmp;
1252 tmp=port_convert(port);
1253 port=tmp;
1254 #endif
1255
1256 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1257 ret =*(volatile unsigned short *)((char *)mmioBase+(port));
1258 #else
1259 ret = _inw(port);
1260 #endif
1261 return ret;
1262 }
1263
inb(port)1264 static int inb(port)
1265 {
1266 unsigned char ret;
1267
1268 #if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
1269 defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
1270 defined(PC98_XKB) || defined(PC98_NEC)
1271 unsigned short tmp;
1272 tmp=port_convert(port);
1273 port=tmp;
1274 #endif
1275
1276 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1277 ret =*(volatile unsigned char *)((char *)mmioBase+(port));
1278 #else
1279 ret = _inb(port);
1280 #endif
1281 return ret;
1282 }
1283
1284
1285 # endif /* PC98 */
1286 # if !defined(__HIGHC__) && !defined(SCO325)
1287 # pragma asm partial_optimization outl
1288 # pragma asm partial_optimization outw
1289 # pragma asm partial_optimization outb
1290 # pragma asm partial_optimization inl
1291 # pragma asm partial_optimization inw
1292 # pragma asm partial_optimization inb
1293 # endif
1294 #endif
1295 #define ldq_u(p) (*((unsigned long *)(p)))
1296 #define ldl_u(p) (*((unsigned int *)(p)))
1297 #define ldw_u(p) (*((unsigned short *)(p)))
1298 #define stq_u(v,p) ((unsigned long *)(p)) = (v)
1299 #define stl_u(v,p) ((unsigned int *)(p)) = (v)
1300 #define stw_u(v,p) ((unsigned short *)(p)) = (v)
1301 #define mem_barrier() /* NOP */
1302 #define write_mem_barrier() /* NOP */
1303 #endif /* __GNUC__ */
1304
1305 #if defined(IODEBUG) && defined(__GNUC__)
1306 #undef inb
1307 #undef inw
1308 #undef inl
1309 #undef outb
1310 #undef outw
1311 #undef outl
1312 #define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
1313 #define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
1314 #define inl(a) __extension__ ({unsigned long __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
1315
1316 #define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b))
1317 #define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b))
1318 #define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b))
1319 #endif
1320
1321 /*
1322 * This header sometimes gets included where is isn't needed, and on some
1323 * OSs this causes problems because the following functions generate
1324 * references to inb() and outb() which can't be resolved. Defining
1325 * NO_COMPILER_H_EXTRAS avoids this problem.
1326 */
1327
1328 #ifndef NO_COMPILER_H_EXTRAS
1329 /*
1330 *-----------------------------------------------------------------------
1331 * Port manipulation convenience functions
1332 *-----------------------------------------------------------------------
1333 */
1334
1335 #ifndef __GNUC__
1336 #define __inline__ /**/
1337 #endif
1338
1339 /*
1340 * rdinx - read the indexed byte port 'port', index 'ind', and return its value
1341 */
1342 static __inline__ unsigned char
1343 #ifdef __STDC__
rdinx(unsigned short int port,unsigned char ind)1344 rdinx(unsigned short int port, unsigned char ind)
1345 #else
1346 rdinx(port, ind)
1347 unsigned short int port;
1348 unsigned char ind;
1349 #endif
1350 {
1351 if (port == 0x3C0) /* reset attribute flip-flop */
1352 (void) inb(0x3DA);
1353 outb(port, ind);
1354 return(inb(port+1));
1355 }
1356
1357 /*
1358 * wrinx - write 'val' to port 'port', index 'ind'
1359 */
1360 static __inline__ void
1361 #ifdef __STDC__
wrinx(unsigned short int port,unsigned char ind,unsigned char val)1362 wrinx(unsigned short int port, unsigned char ind, unsigned char val)
1363 #else
1364 wrinx(port, ind, val)
1365 unsigned short int port;
1366 unsigned char ind, val;
1367 #endif
1368 {
1369 outb(port, ind);
1370 outb(port+1, val);
1371 }
1372
1373 /*
1374 * modinx - in register 'port', index 'ind', set the bits in 'mask' as in 'new';
1375 * the other bits are unchanged.
1376 */
1377 static __inline__ void
1378 #ifdef __STDC__
modinx(unsigned short int port,unsigned char ind,unsigned char mask,unsigned char new)1379 modinx(unsigned short int port, unsigned char ind,
1380 unsigned char mask, unsigned char new)
1381 #else
1382 modinx(port, ind, mask, new)
1383 unsigned short int port;
1384 unsigned char ind, mask, new;
1385 #endif
1386 {
1387 unsigned char tmp;
1388
1389 tmp = (rdinx(port, ind) & ~mask) | (new & mask);
1390 wrinx(port, ind, tmp);
1391 }
1392
1393 /*
1394 * tstrg - returns true iff the bits in 'mask' of register 'port' are
1395 * readable & writable.
1396 */
1397
1398 static __inline__ int
1399 #ifdef __STDC__
testrg(unsigned short int port,unsigned char mask)1400 testrg(unsigned short int port, unsigned char mask)
1401 #else
1402 tstrg(port, mask)
1403 unsigned short int port;
1404 unsigned char mask;
1405 #endif
1406 {
1407 unsigned char old, new1, new2;
1408
1409 old = inb(port);
1410 outb(port, old & ~mask);
1411 new1 = inb(port) & mask;
1412 outb(port, old | mask);
1413 new2 = inb(port) & mask;
1414 outb(port, old);
1415 return((new1 == 0) && (new2 == mask));
1416 }
1417
1418 /*
1419 * testinx2 - returns true iff the bits in 'mask' of register 'port', index
1420 * 'ind' are readable & writable.
1421 */
1422 static __inline__ int
1423 #ifdef __STDC__
testinx2(unsigned short int port,unsigned char ind,unsigned char mask)1424 testinx2(unsigned short int port, unsigned char ind, unsigned char mask)
1425 #else
1426 testinx2(port, ind, mask)
1427 unsigned short int port;
1428 unsigned char ind, mask;
1429 #endif
1430 {
1431 unsigned char old, new1, new2;
1432
1433 old = rdinx(port, ind);
1434 wrinx(port, ind, old & ~mask);
1435 new1 = rdinx(port, ind) & mask;
1436 wrinx(port, ind, old | mask);
1437 new2 = rdinx(port, ind) & mask;
1438 wrinx(port, ind, old);
1439 return((new1 == 0) && (new2 == mask));
1440 }
1441
1442 /*
1443 * testinx - returns true iff all bits of register 'port', index 'ind' are
1444 * readable & writable.
1445 */
1446 static __inline__ int
1447 #ifdef __STDC__
testinx(unsigned short int port,unsigned char ind)1448 testinx(unsigned short int port, unsigned char ind)
1449 #else
1450 testinx(port, ind, mask)
1451 unsigned short int port;
1452 unsigned char ind;
1453 #endif
1454 {
1455 return(testinx2(port, ind, 0xFF));
1456 }
1457 #endif /* NO_COMPILER_H_EXTRAS */
1458
1459 #endif /* NO_INLINE */
1460 #endif /* _COMPILER_H */
1461