[PATCH] Abstract calls to in/out with IN/OUT macros

Matt Turner mattst88 at gmail.com
Sun Nov 1 11:01:20 PST 2009


This will allow us to include sys/io.h and use libc's in/out when
available.

Also see http://lists.x.org/archives/xorg-devel/2009-October/002853.html

Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
 hw/xfree86/common/compiler.h            |  201 ++++++++++++-------------------
 hw/xfree86/common/xf86Helper.c          |   11 +-
 hw/xfree86/int10/helper_exec.c          |   36 +++---
 hw/xfree86/int10/xf86int10.c            |   44 ++++----
 hw/xfree86/os-support/linux/lnx_video.c |   12 +-
 hw/xfree86/os-support/misc/SlowBcopy.c  |    8 +-
 hw/xfree86/vgahw/vgaHW.c                |   72 ++++++------
 hw/xfree86/vgahw/vgaHW.h                |    8 +-
 8 files changed, 177 insertions(+), 215 deletions(-)

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index a450bd6..5fe35c7 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -309,78 +309,34 @@ static __inline__ void stw_u(uint16_t val, uint16_t *p)
 
 # ifndef NO_INLINE
 #  ifdef __GNUC__
-#   if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
+#   if defined __alpha__
 
 #    ifdef linux
-/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/*  *before* any inx/outx is done. */
+#     include <sys/io.h>
+#     define OUTB(port, val) outb((val), (port))
+#     define OUTW(port, val) outw((val), (port))
+#     define OUTL(port, val) outl((val), (port))
 
-extern _X_EXPORT void (*_alpha_outb)(char val, unsigned long port);
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
-    _alpha_outb(val, port);
-}
-
-extern _X_EXPORT void (*_alpha_outw)(short val, unsigned long port);
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
-    _alpha_outw(val, port);
-}
-
-extern _X_EXPORT void (*_alpha_outl)(int val, unsigned long port);
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
-    _alpha_outl(val, port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inb)(unsigned long port);
-static __inline__ unsigned int
-inb(unsigned long port)
-{
-  return _alpha_inb(port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inw)(unsigned long port);
-static __inline__ unsigned int
-inw(unsigned long port)
-{
-  return _alpha_inw(port);
-}
-
-extern _X_EXPORT unsigned int (*_alpha_inl)(unsigned long port);
-static __inline__ unsigned int
-inl(unsigned long port)
-{
-  return _alpha_inl(port);
-}
-
-#    endif /* linux */
-
-#    if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
+#    elif (defined(__FreeBSD__) || defined(__OpenBSD__)) \
       && !defined(DO_PROTOTYPES)
 
-/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
-/*  inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/*  *before* any inx/outx is done. */
-
-extern _X_EXPORT void outb(unsigned int port, unsigned char val);
-extern _X_EXPORT void outw(unsigned int port, unsigned short val);
-extern _X_EXPORT void outl(unsigned int port, unsigned int val);
-extern _X_EXPORT unsigned char inb(unsigned int port);
-extern _X_EXPORT unsigned short inw(unsigned int port);
-extern _X_EXPORT unsigned int inl(unsigned int port);
-
-#    endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
-
-
-#if defined(__NetBSD__)
-#include <machine/pio.h>
-#endif /* __NetBSD__ */
+/* FIXME: #include these instead of manual prototypes */
+extern void outb(unsigned int port, unsigned char val);
+extern void outw(unsigned int port, unsigned short val);
+extern void outl(unsigned int port, unsigned int val);
+extern unsigned char inb(unsigned int port);
+extern unsigned short inw(unsigned int port);
+extern unsigned int inl(unsigned int port);
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+
+#    elif defined(__NetBSD__)
+#     include <machine/pio.h>
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+#    endif
 
 #   elif defined(linux) && defined(__ia64__) 
  
@@ -388,6 +344,7 @@ extern _X_EXPORT unsigned int inl(unsigned int port);
 
 #    include <sys/io.h>
 
+/* FIXME: fix up, declared in hw/xfree86/os-support/shared/ia64Pci.c */
 #    undef outb
 #    undef outw
 #    undef outl
@@ -401,7 +358,13 @@ extern _X_EXPORT unsigned int inb(unsigned long port);
 extern _X_EXPORT unsigned int inw(unsigned long port);
 extern _X_EXPORT unsigned int inl(unsigned long port);
  
-#   elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
+#   elif defined __amd64__
+#    ifdef linux
+#     include <sys/io.h>
+#     define OUTB(port, val) outb((val), (port))
+#     define OUTW(port, val) outw((val), (port))
+#     define OUTL(port, val) outl((val), (port))
+#    elif  defined __FreeBSD__
  
 #    include <inttypes.h>
 
@@ -424,6 +387,10 @@ outl(unsigned short port, unsigned int val)
    __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
 }
 
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+
 static __inline__ unsigned int
 inb(unsigned short port)
 {
@@ -454,6 +421,8 @@ inl(unsigned short port)
    return ret;
 }
 
+#    endif /* linux/FreeBSD */
+
 #   elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
 
 #     ifndef ASI_PL
@@ -487,6 +456,10 @@ outl(unsigned long port, unsigned int val)
 	barrier();
 }
 
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+
 static __inline__ unsigned int
 inb(unsigned long port)
 {
@@ -719,6 +692,10 @@ outl(unsigned PORT_SIZE port, unsigned int val)
 	*(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
 }
 
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+
 static __inline__ unsigned int
 inb(unsigned PORT_SIZE port)
 {
@@ -737,7 +714,6 @@ inl(unsigned PORT_SIZE port)
 	return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
 }
 
-
 #    if defined(__mips__)
 #     ifdef linux	/* don't mess with other OSs */
 #       if X_BYTE_ORDER == X_BIG_ENDIAN
@@ -952,6 +928,10 @@ outl(unsigned short port, unsigned int value)
         xf86WriteMmio32Le((void *)ioBase, port, value);
 }
 
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+
 static __inline__ unsigned int
 inb(unsigned short port)
 {
@@ -973,41 +953,17 @@ inl(unsigned short port)
         return xf86ReadMmio32Le((void *)ioBase, port);
 }
 
-#elif defined(__arm__) && defined(__linux__)
-
-/* for Linux on ARM, we use the LIBC inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/*  *before* any inx/outx is done. */
-
-#include <sys/io.h>
-
-static __inline__ void
-xf_outb(unsigned short port, unsigned char val)
-{
-    outb(val, port);
-}
-
-static __inline__ void
-xf_outw(unsigned short port, unsigned short val)
-{
-    outw(val, port);
-}
-
-static __inline__ void
-xf_outl(unsigned short port, unsigned int val)
-{
-    outl(val, port);
-}
-
-#define outb xf_outb
-#define outw xf_outw
-#define outl xf_outl
+#   elif defined(__arm__) && defined(__linux__)
+#    include <sys/io.h>
+#    define OUTB(port, val) outb((val), (port))
+#    define OUTW(port, val) outw((val), (port))
+#    define OUTL(port, val) outl((val), (port))
 
 #   else /* ix86 */
 
 #    if !defined(__SUNPRO_C)
-#    if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
-#     ifdef GCCUSESGAS
+#     if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
+#      ifdef GCCUSESGAS
 
 /*
  * If gcc uses gas rather than the native assembler, the syntax of these
@@ -1033,6 +989,10 @@ outl(unsigned short port, unsigned int val)
    __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
 }
 
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+
 static __inline__ unsigned int
 inb(unsigned short port)
 {
@@ -1063,7 +1023,7 @@ inl(unsigned short port)
    return ret;
 }
 
-#     else	/* GCCUSESGAS */
+#      else /* GCCUSESGAS */
 
 static __inline__ void
 outb(unsigned short port, unsigned char val)
@@ -1077,6 +1037,10 @@ outw(unsigned short port, unsigned short val)
   __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
 }
 
+#     define OUTB(port, val) outb((port), (val))
+#     define OUTW(port, val) outw((port), (val))
+#     define OUTL(port, val) outl((port), (val))
+
 static __inline__ void
 outl(unsigned short port, unsigned int val)
 {
@@ -1113,24 +1077,12 @@ inl(unsigned short port)
   return ret;
 }
 
-#     endif /* GCCUSESGAS */
+#      endif /* GCCUSESGAS */
 
-#    else /* !defined(FAKEIT) && !defined(__mc68000__)  && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
-}
+#     else /* !defined(FAKEIT) && !defined(__mc68000__)  && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
+#      define OUTB(port, val) /* NOP */
+#      define OUTW(port, val) /* NOP */
+#      define OUTL(port, val) /* NOP */
 
 static __inline__ unsigned int
 inb(unsigned short port)
@@ -1150,11 +1102,19 @@ inl(unsigned short port)
   return 0;
 }
 
-#    endif /* FAKEIT */
+#     endif /* FAKEIT */
 #    endif /* __SUNPRO_C */
-
 #   endif /* ix86 */
 
+/*
+ * Since we don't have to worry about the order of arguments with in* like we
+ * do with out*, just define them once instead of in ever architecture's
+ * section.
+ */
+#   define INB(port) inb(port)
+#   define INW(port) inw(port)
+#   define INL(port) inl(port)
+
 #  else /* !GNUC */
 #    if defined(__STDC__) && (__STDC__ == 1)
 #     ifndef asm
@@ -1187,7 +1147,6 @@ inl(unsigned short port)
 #     pragma asm partial_optimization inb
 #    endif
 #  endif /* __GNUC__ */
-
 # endif /* NO_INLINE */
 
 # ifdef __alpha__
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 56ab266..d4139ed 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -59,6 +59,7 @@
 #include "mivalidate.h"
 #include "xf86Bus.h"
 #include "xf86Crtc.h"
+#include "compiler.h"
 
 /* For xf86GetClocks */
 #if defined(CSRG_BASED) || defined(__GNU__)
@@ -1957,22 +1958,22 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
     	cnt  = 0;
     	sync = 200000;
 
-	while ((inb(status) & maskval) == 0x00)
+	while ((INB(status) & maskval) == 0x00)
 	    if (sync-- == 0) goto finish;
 	/* Something appears to be happening, so reset sync count */
 	sync = 200000;
-	while ((inb(status) & maskval) == maskval)
+	while ((INB(status) & maskval) == maskval)
 	    if (sync-- == 0) goto finish;
 	/* Something appears to be happening, so reset sync count */
 	sync = 200000;
-	while ((inb(status) & maskval) == 0x00)
+	while ((INB(status) & maskval) == 0x00)
 	    if (sync-- == 0) goto finish;
 
 	for (rcnt = 0; rcnt < 5; rcnt++)
 	{
-	    while (!(inb(status) & maskval))
+	    while (!(INB(status) & maskval))
 		cnt++;
-	    while ((inb(status) & maskval))
+	    while ((INB(status) & maskval))
 		cnt++;
 	}
 
diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index 6ba647f..659bd89 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -330,7 +330,7 @@ x_inb(CARD16 port)
 	}
 #endif /* __NOT_YET__ */
     } else if (!pciCfg1inb(port, &val)) {
-	val = inb(Int10Current->ioBase + port);
+	val = INB(Int10Current->ioBase + port);
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" inb(%#x) = %2.2x\n", port, val);
     }
@@ -352,7 +352,7 @@ x_inw(CARD16 port)
 	X_GETTIMEOFDAY(&tv);
 	val = (CARD16)(tv.tv_usec / 3);
     } else if (!pciCfg1inw(port, &val)) {
-	val = inw(Int10Current->ioBase + port);
+	val = INW(Int10Current->ioBase + port);
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" inw(%#x) = %4.4x\n", port, val);
     }
@@ -386,7 +386,7 @@ x_outb(CARD16 port, CARD8 val)
     } else if (!pciCfg1outb(port, val)) {
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" outb(%#x, %2.2x)\n", port, val);
-	outb(Int10Current->ioBase + port, val);
+		OUTB(Int10Current->ioBase + port, val);
     }
 }
 
@@ -397,7 +397,7 @@ x_outw(CARD16 port, CARD16 val)
     if (!pciCfg1outw(port, val)) {
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" outw(%#x, %4.4x)\n", port, val);
-	outw(Int10Current->ioBase + port, val);
+		OUTW(Int10Current->ioBase + port, val);
     }
 }
 
@@ -407,7 +407,7 @@ x_inl(CARD16 port)
     CARD32 val;
 
     if (!pciCfg1in(port, &val)) {
-	val = inl(Int10Current->ioBase + port);
+	val = INL(Int10Current->ioBase + port);
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" inl(%#x) = %8.8lx\n", port, val);
     }
@@ -420,7 +420,7 @@ x_outl(CARD16 port, CARD32 val)
     if (!pciCfg1out(port, val)) {
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" outl(%#x, %8.8lx)\n", port, val);
-	outl(Int10Current->ioBase + port, val);
+		OUTL(Int10Current->ioBase + port, val);
     }
 }
 
@@ -644,29 +644,29 @@ bios_checksum(const CARD8 *start, int size)
 void
 LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
 {
-    vga->save_msr    = inb(pInt->ioBase + 0x03CC);
-    vga->save_vse    = inb(pInt->ioBase + 0x03C3);
+    vga->save_msr    = INB(pInt->ioBase + 0x03CC);
+    vga->save_vse    = INB(pInt->ioBase + 0x03C3);
 #ifndef __ia64__
-    vga->save_46e8   = inb(pInt->ioBase + 0x46E8);
+    vga->save_46e8   = INB(pInt->ioBase + 0x46E8);
 #endif
-    vga->save_pos102 = inb(pInt->ioBase + 0x0102);
-    outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr);
-    outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse);
+    vga->save_pos102 = INB(pInt->ioBase + 0x0102);
+    OUTB(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr);
+    OUTB(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse);
 #ifndef __ia64__
-    outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
+    OUTB(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
 #endif
-    outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
+    OUTB(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
 }
 
 void
 UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
 {
-    outb(pInt->ioBase + 0x0102, vga->save_pos102);
+    OUTB(pInt->ioBase + 0x0102, vga->save_pos102);
 #ifndef __ia64__
-    outb(pInt->ioBase + 0x46E8, vga->save_46e8);
+    OUTB(pInt->ioBase + 0x46E8, vga->save_46e8);
 #endif
-    outb(pInt->ioBase + 0x03C3, vga->save_vse);
-    outb(pInt->ioBase + 0x03C2, vga->save_msr);
+    OUTB(pInt->ioBase + 0x03C3, vga->save_vse);
+    OUTB(pInt->ioBase + 0x03C2, vga->save_msr);
 }
 
 #if defined (_PC)
diff --git a/hw/xfree86/int10/xf86int10.c b/hw/xfree86/int10/xf86int10.c
index 51eb91f..3a139ce 100644
--- a/hw/xfree86/int10/xf86int10.c
+++ b/hw/xfree86/int10/xf86int10.c
@@ -176,14 +176,14 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    ioport += pInt->ioBase;
 
 	    /* Programme the mode */
-	    outb(ioport + 4, cgamode & 0x37);   /* Turn off screen */
+	    OUTB(ioport + 4, cgamode & 0x37);   /* Turn off screen */
 	    for (i = 0; i < 0x10; i++) {
 		tmp = MEM_RB(pInt, regvals + i);
-		outb(ioport, i);
-		outb(ioport + 1, tmp);
+		OUTB(ioport, i);
+		OUTB(ioport + 1, tmp);
 	    }
-	    outb(ioport + 5, cgacolour);        /* Select colour mode */
-	    outb(ioport + 4, cgamode);          /* Turn on screen */
+	    OUTB(ioport + 5, cgacolour);        /* Select colour mode */
+	    OUTB(ioport + 4, cgamode);          /* Turn on screen */
 	}
 	break;
 
@@ -199,10 +199,10 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    MEM_WB(pInt, 0x0460, X86_CL);
 	    MEM_WB(pInt, 0x0461, X86_CH);
 
-	    outb(ioport, 0x0A);
-	    outb(ioport + 1, X86_CH);
-	    outb(ioport, 0x0B);
-	    outb(ioport + 1, X86_CL);
+	    OUTB(ioport, 0x0A);
+	    OUTB(ioport + 1, X86_CH);
+	    OUTB(ioport, 0x0B);
+	    OUTB(ioport + 1, X86_CL);
 	}
 	break;
 
@@ -227,10 +227,10 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    offset += MEM_RW(pInt, 0x044E) << 1;
 
 	    ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
-	    outb(ioport, 0x0E);
-	    outb(ioport + 1, offset >> 8);
-	    outb(ioport, 0x0F);
-	    outb(ioport + 1, offset & 0xFF);
+	    OUTB(ioport, 0x0E);
+	    OUTB(ioport + 1, offset >> 8);
+	    OUTB(ioport, 0x0F);
+	    OUTB(ioport + 1, offset & 0xFF);
 	}
 	break;
 
@@ -287,10 +287,10 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    start <<= 1;
 
 	    /* Update start address */
-	    outb(ioport, 0x0C);
-	    outb(ioport + 1, start >> 8);
-	    outb(ioport, 0x0D);
-	    outb(ioport + 1, start & 0xFF);
+	    OUTB(ioport, 0x0C);
+	    OUTB(ioport + 1, start >> 8);
+	    OUTB(ioport, 0x0D);
+	    OUTB(ioport + 1, start & 0xFF);
 
 	    /* Switch cursor position */
 	    y = MEM_RB(pInt, (X86_AL << 1) + 0x0450);
@@ -298,10 +298,10 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    start += (y * MEM_RW(pInt, 0x044A)) + x;
 
 	    /* Update cursor position */
-	    outb(ioport, 0x0E);
-	    outb(ioport + 1, start >> 8);
-	    outb(ioport, 0x0F);
-	    outb(ioport + 1, start & 0xFF);
+	    OUTB(ioport, 0x0E);
+	    OUTB(ioport + 1, start >> 8);
+	    OUTB(ioport, 0x0F);
+	    OUTB(ioport + 1, start & 0xFF);
 	}
 	break;
 
@@ -438,7 +438,7 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    }
 
 	    MEM_WB(pInt, 0x0466, cgacolour);
-	    outb(ioport, cgacolour);
+	    OUTB(ioport, cgacolour);
 	}
 	break;
 
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 09d1787..6327153 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -77,7 +77,7 @@ extern int iopl(int __level);
 
 extern void sethae(unsigned long hae);
 
-# define BUS_BASE bus_base
+# define BUS_BASE bus_base_addr
 
 #else 
 
@@ -99,7 +99,7 @@ static axpDevice axpSystem = -1;
 static Bool needSparse;
 static unsigned long hae_thresh;
 static unsigned long hae_mask;
-static unsigned long bus_base;
+static unsigned long bus_base_addr;
 static unsigned long sparse_size;
 #endif
 
@@ -373,12 +373,12 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 #ifdef __alpha__
 	if (axpSystem == -1) {
 	  axpSystem = lnxGetAXP();
-	  if ((needSparse = (_bus_base_sparse() > 0))) {
+	  if ((needSparse = (bus_base_sparse() > 0))) {
 	    hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
 	    hae_mask = xf86AXPParams[axpSystem].hae_mask;
 	    sparse_size = xf86AXPParams[axpSystem].size;
 	  }
-	  bus_base = _bus_base();
+	  bus_base_addr = bus_base();
 	}
 	if (needSparse) {
 	  xf86Msg(X_INFO,"Machine needs sparse mapping\n");
@@ -646,7 +646,7 @@ mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags
      */
     ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size,
 		   prot, MAP_SHARED, fd,
-		   (off_t) (bus_base + Base));
+		   (off_t) (bus_base_addr + Base));
 
     /*
      * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
@@ -660,7 +660,7 @@ mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags
     {
         rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)),
 				   Size << 5, prot, MAP_SHARED, fd,
-				   (off_t) _bus_base_sparse() + (Base << 5));
+				   (off_t) bus_base_sparse() + (Base << 5));
     }
 
     close(fd);
diff --git a/hw/xfree86/os-support/misc/SlowBcopy.c b/hw/xfree86/os-support/misc/SlowBcopy.c
index 0021b55..2627410 100644
--- a/hw/xfree86/os-support/misc/SlowBcopy.c
+++ b/hw/xfree86/os-support/misc/SlowBcopy.c
@@ -36,12 +36,12 @@ static void xf86_really_slow_bcopy(unsigned char *src, unsigned char *dst, int l
     while(len--)
     {
 	*dst++ = *src++;
-	outb(0x80, 0x00);
+	OUTB(0x80, 0x00);
     }
 }
 #endif
 
-/* The outb() isn't needed on my machine, but who knows ... -- ost */
+/* The OUTB() isn't needed on my machine, but who knows ... -- ost */
 void
 xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len)
 {
@@ -88,7 +88,7 @@ xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count)
 			*dst++ = (unsigned char) (0xffUL & result);
 			addr += 1<<SPARSE;
 			count--;
-			outb(0x80, 0x00);
+			OUTB(0x80, 0x00);
 		}
 	}
 	else
@@ -108,7 +108,7 @@ xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count)
 			src++;
 			addr += 1<<SPARSE;
 			count--;
-			outb(0x80, 0x00);
+			OUTB(0x80, 0x00);
 		}
 	}
 	else
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index 004376b..7712ed5 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -163,67 +163,67 @@ static CARD8 defaultDAC[768] =
 static void
 stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
 {
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET, value);
+    OUTB(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
+    OUTB(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET, value);
 }
 
 static CARD8
 stdReadCrtc(vgaHWPtr hwp, CARD8 index)
 {
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
-    return inb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET);
+    OUTB(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
+    return INB(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET);
 }
 
 static void
 stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
-    outb(hwp->PIOOffset + VGA_GRAPH_DATA, value);
+    OUTB(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
+    OUTB(hwp->PIOOffset + VGA_GRAPH_DATA, value);
 }
 
 static CARD8
 stdReadGr(vgaHWPtr hwp, CARD8 index)
 {
-    outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
-    return inb(hwp->PIOOffset + VGA_GRAPH_DATA);
+    OUTB(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
+    return INB(hwp->PIOOffset + VGA_GRAPH_DATA);
 }
 
 static void
 stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
-    outb(hwp->PIOOffset + VGA_SEQ_DATA, value);
+    OUTB(hwp->PIOOffset + VGA_SEQ_INDEX, index);
+    OUTB(hwp->PIOOffset + VGA_SEQ_DATA, value);
 }
 
 static CARD8
 stdReadSeq(vgaHWPtr hwp, CARD8 index)
 {
-    outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
-    return inb(hwp->PIOOffset + VGA_SEQ_DATA);
+    OUTB(hwp->PIOOffset + VGA_SEQ_INDEX, index);
+    return INB(hwp->PIOOffset + VGA_SEQ_DATA);
 }
 
 static CARD8
 stdReadST00(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_IN_STAT_0);
+    return INB(hwp->PIOOffset + VGA_IN_STAT_0);
 }
 
 static CARD8
 stdReadST01(vgaHWPtr hwp)
 {
-    return inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
+    return INB(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
 }
 
 static CARD8
 stdReadFCR(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_FEATURE_R);
+    return INB(hwp->PIOOffset + VGA_FEATURE_R);
 }
 
 static void
 stdWriteFCR(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_FEATURE_W_OFFSET,value);
+    OUTB(hwp->IOBase + hwp->PIOOffset + VGA_FEATURE_W_OFFSET,value);
 }
 
 static void
@@ -234,9 +234,9 @@ stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
     else
 	index |= 0x20;
 
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
-    outb(hwp->PIOOffset + VGA_ATTR_DATA_W, value);
+    (void) INB(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
+    OUTB(hwp->PIOOffset + VGA_ATTR_INDEX, index);
+    OUTB(hwp->PIOOffset + VGA_ATTR_DATA_W, value);
 }
 
 static CARD8
@@ -247,85 +247,85 @@ stdReadAttr(vgaHWPtr hwp, CARD8 index)
     else
 	index |= 0x20;
 
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
-    return inb(hwp->PIOOffset + VGA_ATTR_DATA_R);
+    (void) INB(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
+    OUTB(hwp->PIOOffset + VGA_ATTR_INDEX, index);
+    return INB(hwp->PIOOffset + VGA_ATTR_DATA_R);
 }
 
 static void
 stdWriteMiscOut(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_MISC_OUT_W, value);
+    OUTB(hwp->PIOOffset + VGA_MISC_OUT_W, value);
 }
 
 static CARD8
 stdReadMiscOut(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_MISC_OUT_R);
+    return INB(hwp->PIOOffset + VGA_MISC_OUT_R);
 }
 
 static void
 stdEnablePalette(vgaHWPtr hwp)
 {
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x00);
+    (void) INB(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
+    OUTB(hwp->PIOOffset + VGA_ATTR_INDEX, 0x00);
     hwp->paletteEnabled = TRUE;
 }
 
 static void
 stdDisablePalette(vgaHWPtr hwp)
 {
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x20);
+    (void) INB(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
+    OUTB(hwp->PIOOffset + VGA_ATTR_INDEX, 0x20);
     hwp->paletteEnabled = FALSE;
 }
 
 static void
 stdWriteDacMask(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_MASK, value);
+    OUTB(hwp->PIOOffset + VGA_DAC_MASK, value);
 }
 
 static CARD8
 stdReadDacMask(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_DAC_MASK);
+    return INB(hwp->PIOOffset + VGA_DAC_MASK);
 }
 
 static void
 stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_READ_ADDR, value);
+    OUTB(hwp->PIOOffset + VGA_DAC_READ_ADDR, value);
 }
 
 static void
 stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_WRITE_ADDR, value);
+    OUTB(hwp->PIOOffset + VGA_DAC_WRITE_ADDR, value);
 }
 
 static void
 stdWriteDacData(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_DATA, value);
+    OUTB(hwp->PIOOffset + VGA_DAC_DATA, value);
 }
 
 static CARD8
 stdReadDacData(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_DAC_DATA);
+    return INB(hwp->PIOOffset + VGA_DAC_DATA);
 }
 
 static CARD8
 stdReadEnable(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_ENABLE);
+    return INB(hwp->PIOOffset + VGA_ENABLE);
 }
 
 static void
 stdWriteEnable(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_ENABLE, value);
+    OUTB(hwp->PIOOffset + VGA_ENABLE, value);
 }
 
 void
diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h
index 7e63492..00f6793 100644
--- a/hw/xfree86/vgahw/vgaHW.h
+++ b/hw/xfree86/vgahw/vgaHW.h
@@ -27,6 +27,8 @@
 #include "globals.h"
 #include <X11/extensions/dpmsconst.h>
 
+#include "compiler.h"
+
 extern _X_EXPORT int vgaHWGetIndex(void);
 
 /*
@@ -159,7 +161,7 @@ typedef struct _vgaHWRec {
 } vgaHWRec;
 
 /* Some macros that VGA drivers can use in their ChipProbe() function */
-#define VGAHW_GET_IOBASE()	((inb(VGA_MISC_OUT_R) & 0x01) ?		      \
+#define VGAHW_GET_IOBASE()	((INB(VGA_MISC_OUT_R) & 0x01) ?		      \
 					 VGA_IOBASE_COLOR : VGA_IOBASE_MONO)
 
 #define OVERSCAN 0x11		/* Index of OverScan register */
@@ -179,8 +181,8 @@ typedef struct _vgaHWRec {
 #else
 #define DACDelay(hw)							      \
 	do {								      \
-	    (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
-	    (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+	    (void)INB((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+	    (void)INB((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
 	} while (0)
 #endif
 
-- 
1.6.4.4



More information about the xorg-devel mailing list