diff options
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/common/compiler.h')
-rw-r--r-- | xc/programs/Xserver/hw/xfree86/common/compiler.h | 561 |
1 files changed, 24 insertions, 537 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/common/compiler.h b/xc/programs/Xserver/hw/xfree86/common/compiler.h index b8d8123a4..1b177aaf8 100644 --- a/xc/programs/Xserver/hw/xfree86/common/compiler.h +++ b/xc/programs/Xserver/hw/xfree86/common/compiler.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.62 2000/06/25 12:35:53 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.65 2000/08/11 17:27:13 dawes Exp $ */ /* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * @@ -24,6 +24,11 @@ /* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */ #ifndef _COMPILER_H + +#if !defined(_XF86_ANSIC_H) && defined(XFree86Module) +# error missing #include "xf86_ansic.h" before #include "compiler.h" +#endif + #define _COMPILER_H #ifndef __STDC__ @@ -40,14 +45,8 @@ # ifdef __GNUC__ # define volatile __volatile__ # define const __const__ -# ifdef PC98 -# undef NO_INLINE -# endif # else # define const /**/ -# ifdef PC98 -# define __inline__ /**/ -# endif # ifdef __HIGHC__ # define __inline__ _Inline # endif @@ -546,7 +545,7 @@ outw(unsigned short port, unsigned short val) static __inline__ void outl(unsigned short port, unsigned int val) { - *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; + *(volatile unsigned int*)(((unsigned short)(port))+IOPortBase) = val; } static __inline__ unsigned int @@ -564,7 +563,7 @@ inw(unsigned short port) static __inline__ unsigned int inl(unsigned short port) { - return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); + return(*(volatile unsigned int*)(((unsigned short)(port))+IOPortBase)); } @@ -705,7 +704,7 @@ xf86ReadMmio32Le(void *base, const unsigned long offset) static __inline__ void xf86WriteMmioNB8(void *base, const unsigned long offset, - const unsigned int val) + const unsigned char val) { __asm__ __volatile__( "stbx %1,%2,%3\n\t" @@ -715,7 +714,7 @@ xf86WriteMmioNB8(void *base, const unsigned long offset, static __inline__ void xf86WriteMmioNB16Le(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { __asm__ __volatile__( "sthbrx %1,%2,%3\n\t" @@ -725,7 +724,7 @@ xf86WriteMmioNB16Le(void *base, const unsigned long offset, static __inline__ void xf86WriteMmioNB16Be(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { __asm__ __volatile__( "sthx %1,%2,%3\n\t" @@ -735,7 +734,7 @@ xf86WriteMmioNB16Be(void *base, const unsigned long offset, static __inline__ void xf86WriteMmioNB32Le(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { __asm__ __volatile__( "stwbrx %1,%2,%3\n\t" @@ -745,7 +744,7 @@ xf86WriteMmioNB32Le(void *base, const unsigned long offset, static __inline__ void xf86WriteMmioNB32Be(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { __asm__ __volatile__( "stwx %1,%2,%3\n\t" @@ -755,7 +754,7 @@ xf86WriteMmioNB32Be(void *base, const unsigned long offset, static __inline__ void xf86WriteMmio8(void *base, const unsigned long offset, - const unsigned int val) + const unsigned char val) { xf86WriteMmioNB8(base,offset,val); eieio(); @@ -763,7 +762,7 @@ xf86WriteMmio8(void *base, const unsigned long offset, static __inline__ void xf86WriteMmio16Le(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { xf86WriteMmioNB16Le(base,offset,val); eieio(); @@ -771,7 +770,7 @@ xf86WriteMmio16Le(void *base, const unsigned long offset, static __inline__ void xf86WriteMmio16Be(void *base, const unsigned long offset, - const unsigned int val) + const unsigned short val) { xf86WriteMmioNB16Be(base,offset,val); eieio(); @@ -779,7 +778,7 @@ xf86WriteMmio16Be(void *base, const unsigned long offset, static __inline__ void xf86WriteMmio32Le(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { xf86WriteMmioNB32Le(base,offset,val); eieio(); @@ -787,7 +786,7 @@ xf86WriteMmio32Le(void *base, const unsigned long offset, static __inline__ void xf86WriteMmio32Be(void *base, const unsigned long offset, - const unsigned long val) + const unsigned int val) { xf86WriteMmioNB32Be(base,offset,val); eieio(); @@ -873,7 +872,6 @@ inl(unsigned short port) * If gcc uses gas rather than the native assembler, the syntax of these * inlines has to be different. DHD */ -#ifndef PC98 static __inline__ void outb(unsigned short port, unsigned char val) @@ -924,245 +922,6 @@ inl(unsigned short port) return ret; } -#else /* PC98 */ - -static __inline__ void -_outb(unsigned short port, unsigned char val) -{ - __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port)); -} - -static __inline__ void -_outw(unsigned short port, unsigned short val) -{ - __asm__ __volatile__("outw %0,%1" ::"a" (val), "d" (port)); -} - -static __inline__ void -_outl(unsigned short port, unsigned int val) -{ - __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); -} - - -static __inline__ unsigned int -_inb(unsigned short port) -{ - unsigned char ret; - __asm__ __volatile__("inb %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -_inw(unsigned short port) -{ - unsigned char ret; - __asm__ __volatile__("inw %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - -static __inline__ unsigned int -_inl(unsigned short port) -{ - unsigned int ret; - __asm__ __volatile__("inl %1,%0" : - "=a" (ret) : - "d" (port)); - return ret; -} - - -#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968) -#define PW_PORT 0x600 -extern short chipID; -extern void *mmioBase; -extern unsigned short _port_tbl[]; -#define port_convert(x) _port_tbl[(unsigned short)x] -#endif - -#if defined(PC98_WAB) || defined(PC98_GANB_WAP) -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE0; - return port; -} -#endif /* PC98_WAB || PC98_GANB_WAP */ - -#if defined(PC98_WABEP) -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port &= 0x7f; /* Mask 0000 0000 0111 1111 */ - port |= 0x0f00; - return port; -} -#endif /* PC98_WABEP */ - -#ifdef PC98_WSNA -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE2; - return port; -} -#endif /* PC98_WSNA */ - -#ifdef PC98_NKVNEC -#ifdef PC98_NEC_CIRRUS2 -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050; - return port; -} -#else -static __inline__ unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0; - return port; -} -#endif /* PC98_NEC_CIRRUS2 */ -#endif /* PC98_NKVNEC */ - -#if defined(PC98_TGUI) -extern void *mmioBase; -#endif - -static __inline__ void -outb(unsigned short port, unsigned char val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val); -#else - __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); -#endif -} - -static __inline__ void -outw(unsigned short port, unsigned short val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val); -#else - __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); -#endif -} - -static __inline__ void -outl(unsigned short port, unsigned int val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val); -#else - __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); -#endif -} - -static __inline__ unsigned int -inb(unsigned short port) -{ - unsigned char ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - ret =*(volatile unsigned char *)((char *)mmioBase+(port)); -#else - __asm__ __volatile__("inb %1,%0" : - "=a" (ret) : - "d" (port)); -#endif - return ret; -} - -static __inline__ unsigned int -inw(unsigned short port) -{ - unsigned short ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - ret =*(volatile unsigned short *)((char *)mmioBase+(port)); -#else - __asm__ __volatile__("inw %1,%0" : - "=a" (ret) : - "d" (port)); -#endif - return ret; -} - -static __inline__ unsigned int -inl(unsigned short port) -{ - unsigned int ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI) - ret =*(volatile unsigned int *)((char *)mmioBase+(port)); -#else - __asm__ __volatile__("inl %1,%0" : - "=a" (ret) : - "d" (port)); -#endif - return ret; -} - -#endif /* PC98 */ - #else /* GCCUSESGAS */ static __inline__ void @@ -1300,10 +1059,10 @@ extern volatile unsigned char *ioBase; extern void debug_outb(unsigned int a, unsigned char b, int line, char *file); extern void debug_outw(unsigned int a, unsigned short w, int line, char *file); -extern void debug_outl(unsigned int a, unsigned long l, int line, char *file); +extern void debug_outl(unsigned int a, unsigned int l, int line, char *file); extern unsigned char debug_inb(unsigned int a, int line, char *file); extern unsigned short debug_inw(unsigned int a, int line, char *file); -extern unsigned long debug_inl(unsigned int a, int line, char *file); +extern unsigned int debug_inl(unsigned int a, int line, char *file); #define outb(a,b) debug_outb(a,b, __LINE__, __FILE__) #define outw(a,w) debug_outw(a,w, __LINE__, __FILE__) @@ -1316,7 +1075,7 @@ extern unsigned long debug_inl(unsigned int a, int line, char *file); extern unsigned char inb(unsigned int a); extern unsigned short inw(unsigned int a); -extern unsigned long inl(unsigned int a); +extern unsigned int inl(unsigned int a); # if PPCIO_INLINE @@ -1327,8 +1086,8 @@ extern unsigned long inl(unsigned int a); # else /* !PPCIO_INLINE */ extern void outb(unsigned int a, unsigned char b); -extern void outw(unsigned int a, unsigned char w); -extern void outl(unsigned int a, unsigned char l); +extern void outw(unsigned int a, unsigned short w); +extern void outl(unsigned int a, unsigned int l); # endif /* PPCIO_INLINE */ @@ -1351,7 +1110,6 @@ extern void outl(unsigned int a, unsigned char l); # endif # endif # endif -# ifndef PC98 # ifndef SCO325 # if defined(USL) # if defined(IN_MODULE) @@ -1370,278 +1128,7 @@ extern void outl(unsigned int a, unsigned char l); # else # include "scoasm.h" # endif -# else -#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968) -#define PW_PORT 0x600 -extern short chipID; -extern void *mmioBase; -extern unsigned short _port_tbl[]; -#define port_convert(x) _port_tbl[(unsigned short)x] -#endif - -asm void _outl(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - outl (%dx) -%reg port; mem val; - movl port, %edx - movl val, %eax - outl (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - outl (%dx) -%mem port,val; - movw port, %dx - movl val, %eax - outl (%dx) -} - -asm void _outw(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - data16 - outl (%dx) -%reg port; mem val; - movl port, %edx - movw val, %ax - data16 - outl (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - data16 - outl (%dx) -%mem port,val; - movw port, %dx - movw val, %ax - data16 - outl (%dx) -} - -asm void _outb(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - outb (%dx) -%reg port; mem val; - movl port, %edx - movb val, %al - outb (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - outb (%dx) -%mem port,val; - movw port, %dx - movb val, %al - outb (%dx) -} - -asm int _inl(port) -{ -%reg port; - movl port, %edx - inl (%dx) -%mem port; - movw port, %dx - inl (%dx) -} - -asm int _inw(port) -{ -%reg port; - subl %eax, %eax - movl port, %edx - data16 - inl (%dx) -%mem port; - subl %eax, %eax - movw port, %dx - data16 - inl (%dx) -} - -asm int _inb(port) -{ -%reg port; - subl %eax, %eax - movl port, %edx - inb (%dx) -%mem port; - subl %eax, %eax - movw port, %dx - inb (%dx) -} - -#if defined(PC98_WAB) || defined(PC98_GANB_WAP) -static unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE0; - return port; -} -#endif /* PC98_WAB || PC98_GANB_WAP */ - -#if defined(PC98_WABEP) -static unsigned short -port_convert(unsigned short port) -{ - port &= 0x7f; /* Mask 0000 0000 0111 1111 */ - port |= 0x0f00; - return port; -} -#endif /* PC98_WABEP */ - -#ifdef PC98_WSNA -static unsigned short -port_convert(unsigned short port) -{ - port <<= 8; - port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ - port |= 0xE2; - return port; -} -#endif /* PC98_WSNA */ - -#ifdef PC98_NKVNEC -#ifdef PC98_NEC_CIRRUS2 -static unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050; - return port; -} -#else -static unsigned short -port_convert(unsigned short port) -{ - port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0; - return port; -} -#endif /* PC98_NEC_CIRRUS2 */ -#endif /* PC98_NKVNEC */ - -static void outl(port,val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val); -#else - _outl(port,val); -#endif -} - -static void outw(port,val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val); -#else - _outw(port,val); -#endif -} - -static void outb(port,val) -{ -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val); -#else - _outb(port,val); -#endif -} - -static int inl(port) -{ - unsigned int ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - ret =*(volatile unsigned int *)((char *)mmioBase+(port)); -#else - ret = _inl(port); -#endif - return ret; -} - -static int inw(port) -{ - unsigned short ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - ret =*(volatile unsigned short *)((char *)mmioBase+(port)); -#else - ret = _inw(port); -#endif - return ret; -} - -static int inb(port) -{ - unsigned char ret; - -#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ - defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ - defined(PC98_XKB) || defined(PC98_NEC) - unsigned short tmp; - tmp=port_convert(port); - port=tmp; -#endif - -#if defined(PC98_NEC)||defined(PC98_PWLB) - ret =*(volatile unsigned char *)((char *)mmioBase+(port)); -#else - ret = _inb(port); -#endif - return ret; -} - -# endif /* PC98 */ # if !defined(__HIGHC__) && !defined(SCO325) # pragma asm partial_optimization outl # pragma asm partial_optimization outw @@ -1691,7 +1178,7 @@ extern void outl(unsigned port, unsigned val); #undef outl #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;}) #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;}) -#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;}) +#define inl(a) __extension__ ({unsigned int __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) #define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b)) #define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b)) |