1 /* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.2 1998/02/07 00:44:37 dawes Exp $ */
3 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
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.
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.
24 /* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */
41 # define volatile __volatile__
42 # define const __const__
49 # define __inline__ /**/
51 # endif /* __GNUC__ */
52 #endif /* !__STDC__ */
54 #if defined(IODEBUG) && defined(__GNUC__)
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();
83 extern int testinx2();
85 #endif /* NeedFunctionProtoypes */
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. */
96 static __inline__ void
101 extern void _outb(char val, unsigned short port);
105 static __inline__ void
110 extern void _outw(short val, unsigned short port);
114 static __inline__ void
119 extern void _outl(int val, unsigned short port);
123 static __inline__ unsigned int
127 extern unsigned int _inb(unsigned short port);
131 static __inline__ unsigned int
135 extern unsigned int _inw(unsigned short port);
139 static __inline__ unsigned int
143 extern unsigned int _inl(unsigned short port);
149 * inline functions to do unaligned accesses
150 * from linux/include/asm-alpha/unaligned.h
153 static __inline__ unsigned long ldq_u(unsigned long * r11)
156 __asm__("ldq_u %0,%3\n\t"
161 :"=&r" (r1), "=&r" (r2)
164 "m" (*(unsigned long *)(7+(char *) r11)));
168 static __inline__ unsigned long ldl_u(unsigned int * r11)
171 __asm__("ldq_u %0,%3\n\t"
176 :"=&r" (r1), "=&r" (r2)
179 "m" (*(unsigned long *)(3+(char *) r11)));
183 static __inline__ unsigned long ldw_u(unsigned short * r11)
186 __asm__("ldq_u %0,%3\n\t"
191 :"=&r" (r1), "=&r" (r2)
194 "m" (*(unsigned long *)(1+(char *) r11)));
198 static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
200 unsigned long r1,r2,r3,r4;
202 __asm__("ldq_u %3,%1\n\t"
213 "=m" (*(unsigned long *)(7+(char *) r11)),
214 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
215 :"r" (r5), "r" (r11));
218 static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
220 unsigned long r1,r2,r3,r4;
222 __asm__("ldq_u %3,%1\n\t"
233 "=m" (*(unsigned long *)(3+(char *) r11)),
234 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
235 :"r" (r5), "r" (r11));
238 static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
240 unsigned long r1,r2,r3,r4;
242 __asm__("ldq_u %3,%1\n\t"
253 "=m" (*(unsigned long *)(1+(char *) r11)),
254 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
255 :"r" (r5), "r" (r11));
258 #define mem_barrier() __asm__ __volatile__("mb" : : : "memory")
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()
265 #else /* defined(linux) && defined(__alpha__) */
266 #if defined(__mips__)
268 unsigned int IOPortBase; /* Memory mapped I/O port area */
270 static __inline__ void
275 *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val;
278 static __inline__ void
283 *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val;
286 static __inline__ void
291 *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val;
294 static __inline__ unsigned int
298 return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase));
301 static __inline__ unsigned int
305 return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase));
308 static __inline__ unsigned int
312 return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase));
316 static __inline__ unsigned long ldq_u(unsigned long * r11)
319 __asm__("lwr %0,%2\n\t"
324 "m" (*(unsigned long *)(3+(char *) r11)));
328 static __inline__ unsigned long ldl_u(unsigned int * r11)
331 __asm__("lwr %0,%2\n\t"
336 "m" (*(unsigned long *)(3+(char *) r11)));
340 static __inline__ unsigned long ldw_u(unsigned short * r11)
343 __asm__("lwr %0,%2\n\t"
348 "m" (*(unsigned long *)(1+(char *) r11)));
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)
358 #define stw_u(v,p) ((unsigned char *)(p)) = (v); \
359 ((unsigned char *)(p)+1) = ((v) >> 8)
361 #define mem_barrier() /* NOP */
363 #else /* defined(mips) */
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 */
374 #if !defined(FAKEIT) && !defined(__mc68000__)
378 * If gcc uses gas rather than the native assembler, the syntax of these
379 * inlines has to be different. DHD
383 static __inline__ void
384 #if NeedFunctionPrototypes
386 unsigned short int port,
390 unsigned short int port;
392 #endif /* NeedFunctionPrototypes */
394 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
398 static __inline__ void
399 #if NeedFunctionPrototypes
401 unsigned short int port,
402 unsigned short int val)
405 unsigned short int port;
406 unsigned short int val;
407 #endif /* NeedFunctionPrototypes */
409 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
412 static __inline__ void
413 #if NeedFunctionPrototypes
415 unsigned short int port,
419 unsigned short int port;
421 #endif /* NeedFunctionPrototypes */
423 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
426 static __inline__ unsigned int
427 #if NeedFunctionPrototypes
429 unsigned short int port)
432 unsigned short int port;
433 #endif /* NeedFunctionPrototypes */
436 __asm__ __volatile__("inb %1,%0" :
442 static __inline__ unsigned int
443 #if NeedFunctionPrototypes
445 unsigned short int port)
448 unsigned short int port;
449 #endif /* NeedFunctionPrototypes */
451 unsigned short int ret;
452 __asm__ __volatile__("inw %1,%0" :
458 static __inline__ unsigned int
459 #if NeedFunctionPrototypes
461 unsigned short int port)
464 unsigned short int port;
465 #endif /* NeedFunctionPrototypes */
468 __asm__ __volatile__("inl %1,%0" :
476 static __inline__ void
477 #if NeedFunctionPrototypes
479 unsigned short int port,
483 unsigned short int port;
485 #endif /* NeedFunctionPrototypes */
487 __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port));
490 static __inline__ void
491 #if NeedFunctionPrototypes
493 unsigned short int port,
494 unsigned short int val)
497 unsigned short int port;
498 unsigned short int val;
499 #endif /* NeedFunctionPrototypes */
501 __asm__ __volatile__("outw %0,%1" ::"a" (val), "d" (port));
504 static __inline__ void
505 #if NeedFunctionPrototypes
507 unsigned short int port,
511 unsigned short int port;
513 #endif /* NeedFunctionPrototypes */
515 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
519 static __inline__ unsigned int
520 #if NeedFunctionPrototypes
522 unsigned short int port)
525 unsigned short int port;
526 #endif /* NeedFunctionPrototypes */
529 __asm__ __volatile__("inb %1,%0" :
535 static __inline__ unsigned int
536 #if NeedFunctionPrototypes
538 unsigned short int port)
541 unsigned short int port;
542 #endif /* NeedFunctionPrototypes */
545 __asm__ __volatile__("inw %1,%0" :
551 static __inline__ unsigned int
552 #if NeedFunctionPrototypes
554 unsigned short int port)
557 unsigned short int port;
558 #endif /* NeedFunctionPrototypes */
561 __asm__ __volatile__("inl %1,%0" :
568 #if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968)
569 #define PW_PORT 0x600
571 #if NeedFunctionPrototypes
572 extern void *mmioBase;
574 extern unsigned char *mmioBase;
576 extern unsigned short _port_tbl[];
577 #define port_convert(x) _port_tbl[(unsigned short)x]
580 #if defined(PC98_WAB) || defined(PC98_GANB_WAP)
581 static __inline__ unsigned short
582 port_convert(unsigned short port)
585 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
589 #endif /* PC98_WAB || PC98_GANB_WAP */
591 #if defined(PC98_WABEP)
592 static __inline__ unsigned short
593 port_convert(unsigned short port)
595 port &= 0x7f; /* Mask 0000 0000 0111 1111 */
599 #endif /* PC98_WABEP */
602 static __inline__ unsigned short
603 port_convert(unsigned short port)
606 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
610 #endif /* PC98_WSNA */
613 #ifdef PC98_NEC_CIRRUS2
614 static __inline__ unsigned short
615 port_convert(unsigned short port)
617 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
621 static __inline__ unsigned short
622 port_convert(unsigned short port)
624 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
627 #endif /* PC98_NEC_CIRRUS2 */
628 #endif /* PC98_NKVNEC */
630 #if defined(PC98_TGUI) || defined(PC98_MGA)
631 #if NeedFunctionPrototypes
632 extern void *mmioBase;
634 extern unsigned char *mmioBase;
638 static __inline__ void
639 #if NeedFunctionPrototypes
647 #endif /* NeedFunctionPrototypes */
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)
653 tmp=port_convert(port);
657 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
658 *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
660 __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
664 static __inline__ void
665 #if NeedFunctionPrototypes
673 #endif /* NeedFunctionPrototypes */
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)
679 tmp=port_convert(port);
683 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
684 *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
686 __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
690 static __inline__ void
691 #if NeedFunctionPrototypes
699 #endif /* NeedFunctionPrototypes */
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)
705 tmp=port_convert(port);
709 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
710 *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
712 __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
716 static __inline__ unsigned int
717 #if NeedFunctionPrototypes
723 #endif /* NeedFunctionPrototypes */
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)
731 tmp=port_convert(port);
735 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
736 ret =*(volatile unsigned char *)((char *)mmioBase+(port));
738 __asm__ __volatile__("inb %1,%0" :
745 static __inline__ unsigned int
746 #if NeedFunctionPrototypes
752 #endif /* NeedFunctionPrototypes */
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)
760 tmp=port_convert(port);
764 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
765 ret =*(volatile unsigned short *)((char *)mmioBase+(port));
767 __asm__ __volatile__("inw %1,%0" :
774 static __inline__ unsigned int
775 #if NeedFunctionPrototypes
781 #endif /* NeedFunctionPrototypes */
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)
789 tmp=port_convert(port);
793 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
794 ret =*(volatile unsigned int *)((char *)mmioBase+(port));
796 __asm__ __volatile__("inl %1,%0" :
805 #else /* GCCUSESGAS */
807 static __inline__ void
808 #if NeedFunctionPrototypes
810 unsigned short int port,
814 unsigned short int port;
816 #endif /* NeedFunctionPrototypes */
818 __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
821 static __inline__ void
822 #if NeedFunctionPrototypes
824 unsigned short int port,
825 unsigned short int val)
828 unsigned short int port;
829 unsigned short int val;
830 #endif /* NeedFunctionPrototypes */
832 __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
835 static __inline__ void
836 #if NeedFunctionPrototypes
838 unsigned short int port,
842 unsigned short int port;
844 #endif /* NeedFunctionPrototypes */
846 __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
849 static __inline__ unsigned int
850 #if NeedFunctionPrototypes
852 unsigned short int port)
855 unsigned short int port;
856 #endif /* NeedFunctionPrototypes */
859 __asm__ __volatile__("in%B0 (%1)" :
865 static __inline__ unsigned int
866 #if NeedFunctionPrototypes
868 unsigned short int port)
871 unsigned short int port;
872 #endif /* NeedFunctionPrototypes */
874 unsigned short int ret;
875 __asm__ __volatile__("in%W0 (%1)" :
881 static __inline__ unsigned int
882 #if NeedFunctionPrototypes
884 unsigned short int port)
887 unsigned short int port;
888 #endif /* NeedFunctionPrototypes */
891 __asm__ __volatile__("in%L0 (%1)" :
897 #endif /* GCCUSESGAS */
899 #else /* !defined(FAKEIT) && !defined(__mc68000__) */
901 static __inline__ void
902 #if NeedFunctionPrototypes
904 unsigned short int port,
908 unsigned short int port;
910 #endif /* NeedFunctionPrototypes */
914 static __inline__ void
915 #if NeedFunctionPrototypes
917 unsigned short int port,
918 unsigned short int val)
921 unsigned short int port;
922 unsigned short int val;
923 #endif /* NeedFunctionPrototypes */
927 static __inline__ void
928 #if NeedFunctionPrototypes
930 unsigned short int port,
934 unsigned short int port;
936 #endif /* NeedFunctionPrototypes */
940 static __inline__ unsigned int
941 #if NeedFunctionPrototypes
943 unsigned short int port)
946 unsigned short int port;
947 #endif /* NeedFunctionPrototypes */
952 static __inline__ unsigned int
953 #if NeedFunctionPrototypes
955 unsigned short int port)
958 unsigned short int port;
959 #endif /* NeedFunctionPrototypes */
964 static __inline__ unsigned int
965 #if NeedFunctionPrototypes
967 unsigned short int port)
970 unsigned short int port;
971 #endif /* NeedFunctionPrototypes */
978 #endif /* defined(mips) */
979 #endif /* defined(AlphaArchitecture) && defined(LinuxArchitecture) */
982 #if !defined(AMOEBA) && !defined(MINIX)
983 # if defined(__STDC__) && (__STDC__ == 1)
989 # include <sys/types.h>
998 # include <sys/inline.h>
1000 # include "scoasm.h"
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;
1009 extern unsigned char *mmioBase;
1011 extern unsigned short _port_tbl[];
1012 #define port_convert(x) _port_tbl[(unsigned short)x]
1015 #if defined(PC98_TGUI) || defined(PC98_MGA)
1016 #if NeedFunctionPrototypes
1017 extern void *mmioBase;
1019 extern unsigned char *mmioBase;
1023 asm void _outl(port,val)
1043 asm void _outw(port,val)
1067 asm void _outb(port,val)
1123 #if defined(PC98_WAB) || defined(PC98_GANB_WAP)
1124 static unsigned short
1125 port_convert(unsigned short port)
1128 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
1132 #endif /* PC98_WAB || PC98_GANB_WAP */
1134 #if defined(PC98_WABEP)
1135 static unsigned short
1136 port_convert(unsigned short port)
1138 port &= 0x7f; /* Mask 0000 0000 0111 1111 */
1142 #endif /* PC98_WABEP */
1145 static unsigned short
1146 port_convert(unsigned short port)
1149 port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
1153 #endif /* PC98_WSNA */
1156 #ifdef PC98_NEC_CIRRUS2
1157 static unsigned short
1158 port_convert(unsigned short port)
1160 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
1164 static unsigned short
1165 port_convert(unsigned short port)
1167 port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
1170 #endif /* PC98_NEC_CIRRUS2 */
1171 #endif /* PC98_NKVNEC */
1173 static void outl(port,val)
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)
1179 tmp=port_convert(port);
1183 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1184 *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
1190 static void outw(port,val)
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)
1196 tmp=port_convert(port);
1200 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1201 *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
1207 static void outb(port,val)
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)
1213 tmp=port_convert(port);
1217 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1218 *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
1224 static int inl(port)
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)
1232 tmp=port_convert(port);
1236 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1237 ret =*(volatile unsigned int *)((char *)mmioBase+(port));
1244 static int inw(port)
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)
1252 tmp=port_convert(port);
1256 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1257 ret =*(volatile unsigned short *)((char *)mmioBase+(port));
1264 static int inb(port)
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)
1272 tmp=port_convert(port);
1276 #if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
1277 ret =*(volatile unsigned char *)((char *)mmioBase+(port));
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
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__ */
1305 #if defined(IODEBUG) && defined(__GNUC__)
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;})
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))
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.
1328 #ifndef NO_COMPILER_H_EXTRAS
1330 *-----------------------------------------------------------------------
1331 * Port manipulation convenience functions
1332 *-----------------------------------------------------------------------
1336 #define __inline__ /**/
1340 * rdinx - read the indexed byte port 'port', index 'ind', and return its value
1342 static __inline__ unsigned char
1344 rdinx(unsigned short int port, unsigned char ind)
1347 unsigned short int port;
1351 if (port == 0x3C0) /* reset attribute flip-flop */
1354 return(inb(port+1));
1358 * wrinx - write 'val' to port 'port', index 'ind'
1360 static __inline__ void
1362 wrinx(unsigned short int port, unsigned char ind, unsigned char val)
1364 wrinx(port, ind, val)
1365 unsigned short int port;
1366 unsigned char ind, val;
1374 * modinx - in register 'port', index 'ind', set the bits in 'mask' as in 'new';
1375 * the other bits are unchanged.
1377 static __inline__ void
1379 modinx(unsigned short int port, unsigned char ind,
1380 unsigned char mask, unsigned char new)
1382 modinx(port, ind, mask, new)
1383 unsigned short int port;
1384 unsigned char ind, mask, new;
1389 tmp = (rdinx(port, ind) & ~mask) | (new & mask);
1390 wrinx(port, ind, tmp);
1394 * tstrg - returns true iff the bits in 'mask' of register 'port' are
1395 * readable & writable.
1398 static __inline__ int
1400 testrg(unsigned short int port, unsigned char mask)
1403 unsigned short int port;
1407 unsigned char old, new1, new2;
1410 outb(port, old & ~mask);
1411 new1 = inb(port) & mask;
1412 outb(port, old | mask);
1413 new2 = inb(port) & mask;
1415 return((new1 == 0) && (new2 == mask));
1419 * testinx2 - returns true iff the bits in 'mask' of register 'port', index
1420 * 'ind' are readable & writable.
1422 static __inline__ int
1424 testinx2(unsigned short int port, unsigned char ind, unsigned char mask)
1426 testinx2(port, ind, mask)
1427 unsigned short int port;
1428 unsigned char ind, mask;
1431 unsigned char old, new1, new2;
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));
1443 * testinx - returns true iff all bits of register 'port', index 'ind' are
1444 * readable & writable.
1446 static __inline__ int
1448 testinx(unsigned short int port, unsigned char ind)
1450 testinx(port, ind, mask)
1451 unsigned short int port;
1455 return(testinx2(port, ind, 0xFF));
1457 #endif /* NO_COMPILER_H_EXTRAS */
1459 #endif /* NO_INLINE */
1460 #endif /* _COMPILER_H */