--- ../common/boilerplate.mk.orig	2004-07-14 02:23:21.000000000 +0900
+++ ../common/boilerplate.mk	2007-09-09 22:12:55.000000000 +0900
@@ -12,10 +12,10 @@
 top_srcdir = @top_srcdir@
 @SET_MAKE@
 CC = @CC@
-CFLAGS = @CFLAGS@ $(DIR_CFLAGS)
+CFLAGS = @CFLAGS@ -fPIC $(DIR_CFLAGS)
 CCLD = $(CC)
 CXX = @CXX@
-CXXFLAGS = @CXXFLAGS@
+CXXFLAGS = @CXXFLAGS@ -fPIC
 CXXLD = $(CXX)
 CPPFLAGS = @CPPFLAGS@
 DEFS = @DEFS@
--- xc/config/cf/Imake.cf.orig	2003-02-19 01:51:45.000000000 +0900
+++ xc/config/cf/Imake.cf	2007-09-09 20:16:12.000000000 +0900
@@ -223,6 +223,19 @@
 #  define i386Architecture
 #  undef i386
 # endif
+# if defined(__x86_64__) || defined(x86_64)
+#  ifndef __x86_64__
+#   define __x86_64__
+#  endif
+#  ifndef x86_64Architecture
+#   define x86_64Architecture
+#  endif
+#  define x86_64BsdArchitecture
+#  undef x86_64
+#  undef i386
+#  undef i386Architecture
+#  undef i386BsdArchitecture
+# endif
 # ifdef __alpha__
 #  define AlphaBsdArchitecture
 #  define AlphaArchitecture
@@ -232,6 +245,10 @@
 #  define Sparc64Architecture
 #  undef __sparc64__
 # endif
+# ifdef __ia64__
+#  define ia64Architecture
+#  undef __ia64__
+# endif
 #endif /* __FreeBSD__ */
  
 #ifdef AMOEBA
--- xc/config/cf/xfree86.cf.orig	2003-02-27 05:07:59.000000000 +0900
+++ xc/config/cf/xfree86.cf	2007-09-09 20:40:56.000000000 +0900
@@ -1167,7 +1167,7 @@
  * The default is to install the X servers setuid-root on most OSs.
  * It the servers are only started by xdm, they should not be setuid-root.
  */
-#if !defined(i386MachArchitecture) && !defined(OS2Architecture)
+#if !defined(i386MachArchitecture) && !defined(OS2Architecture) && !defined(x86_64Architecture)
 # ifndef InstallXserverSetUID
 #  define InstallXserverSetUID	YES
 # endif
@@ -1688,7 +1688,8 @@
 # if SystemV || SystemV4 || \
     (defined(LinuxArchitecture) && !defined(Mc68020Architecture)) || \
     defined(i386BsdArchitecture) || defined(LynxOSArchitecture) || \
-    defined(OS2Architecture) || defined(GNUMachArchitecture)
+    defined(OS2Architecture) || defined(GNUMachArchitecture) || \
+    defined(x86_64Architecture)
 #   define BuildScanpci		YES
 # else
 #   define BuildScanpci		NO
@@ -1801,7 +1802,7 @@
 #endif
 
 #ifndef XFree86ConsoleDefines
-# if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture)
+# if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) || defined(x86_64BsdArchitecture)
 #  define XFree86ConsoleDefines	-DPCCONS_SUPPORT -DSYSCONS_SUPPORT -DPCVT_SUPPORT
 # else
 #  define XFree86ConsoleDefines	/**/
@@ -1995,7 +1996,7 @@
 
 #ifndef Egcs112Bug
   /* Not exactly precise, but it'll do for now... */
-# if HasGcc2 && defined(i386Architecture) && \
+# if HasGcc2 && (defined(i386Architecture) || defined(x86_64Architecture)) && \
      (GccMajorVersion == 2) && (GccMinorVersion > 8)
 #  define Egcs112Bug YES
 # else
@@ -2012,7 +2013,7 @@
 #define HasGlibc21Sigsetjmp NO
 #endif
 
-#ifdef i386Architecture
+#if defined(i386Architecture) || defined(x86_64Architecture)
 # ifndef HasX86Support
 #  define HasX86Support YES
 # endif
--- xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile.orig	2003-02-18 01:37:19.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile	2007-09-07 06:38:14.000000000 +0900
@@ -150,6 +150,10 @@
 #elif defined(Sparc64Architecture)
 VIDEO_SRC = sparc64_video.c
 VIDEO_OBJ = sparc64_video.o
+#elif defined(x86_64Architecture)
+VIDEO_SRC = i386_video.c
+VIDEO_OBJ = i386_video.o
+#elif defined(ia64Architecture)
 #else
 #error Unknown architecture !
 #endif
--- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c.orig	2002-05-23 06:38:29.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c	2007-09-08 20:35:51.000000000 +0900
@@ -18,7 +18,7 @@
 
 #ifdef INCLUDE_XF86_NO_DOMAIN
 
-#if defined(__alpha__) || defined(__sparc64__)
+#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__)
 
 resPtr
 xf86BusAccWindowsFromOS(void)
--- xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h.orig	2002-10-11 10:40:34.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h	2007-09-09 11:44:01.000000000 +0900
@@ -2,4 +2,5 @@
 
 extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
 				CARD8 *pModMap);
-
+#include <sys/kbio.h>
+#include <sys/consio.h>
--- xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile.orig	2003-02-24 05:26:49.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile	2007-09-09 22:21:16.000000000 +0900
@@ -80,7 +80,7 @@
 PCIDRVRSRC = ix86Pci.c linuxPci.c
 PCIDRVROBJ = ix86Pci.o linuxPci.o
 
-#elif defined(FreeBSDArchitecture) && defined(AlphaArchitecture)
+#elif defined(FreeBSDArchitecture) && (defined(AlphaArchitecture) || defined(x86_64Architecture))
 
 
 XCOMM generic FreeBSD PCI driver (using /dev/pci)
--- xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h.orig	2002-12-24 00:37:26.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h	2007-09-09 22:21:25.000000000 +0900
@@ -230,6 +230,10 @@
 #  define ARCH_PCI_INIT linuxPciInit
 #  define INCLUDE_XF86_MAP_PCI_MEM
 #  define INCLUDE_XF86_NO_DOMAIN
+# elif defined(FreeBSD)
+#  define ARCH_PCI_INIT freebsdPciInit
+#  define INCLUDE_XF86_MAP_PCI_MEM
+#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 # define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
 #elif defined(__i386__)
@@ -291,14 +295,20 @@
 # elif defined(sun)
 #  define ARCH_PCI_INIT sparcPciInit
 #  define INCLUDE_XF86_MAP_PCI_MEM
-# elif defined(__OpenBSD__) && defined(__sparc64__)
+# elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__)
 #  define  ARCH_PCI_INIT freebsdPciInit
 #  define INCLUDE_XF86_MAP_PCI_MEM
 #  define INCLUDE_XF86_NO_DOMAIN
 # endif
-# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
+# if !defined(__FreeBSD__)
+#  define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
+# endif
 #elif defined(__x86_64__)
-# define ARCH_PCI_INIT ix86PciInit
+# if defined(__FreeBSD__)
+#  define ARCH_PCI_INIT freebsdPciInit
+# else
+#  define ARCH_PCI_INIT ix86PciInit
+# endif
 # define INCLUDE_XF86_MAP_PCI_MEM
 # define INCLUDE_XF86_NO_DOMAIN
 # if defined(linux)
--- xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c.orig	2002-08-28 07:07:07.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c	2007-09-09 22:21:33.000000000 +0900
@@ -84,7 +84,7 @@
 /* bridge      */	NULL
 };
 
-#if !defined(__OpenBSD__)
+#if !defined(__OpenBSD__) && !defined(__FreeBSD__)
 #if X_BYTE_ORDER == X_BIG_ENDIAN
 #ifdef __sparc__
 #ifndef ASI_PL
--- xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h.orig	2002-05-23 06:38:30.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h	2007-09-09 22:21:43.000000000 +0900
@@ -35,7 +35,13 @@
 #elif defined(__OpenBSD__) && defined(__sparc64__)
 /* XXX */
 #elif defined(CSRG_BASED)
+#if defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/fbio.h>
+#include <dev/ofw/openpromio.h>
+#else
 #include <machine/fbio.h>
+#endif
 #else
 #include <sun/fbio.h>
 #endif
--- xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c.orig	2003-02-22 15:00:39.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c	2007-09-09 22:23:14.000000000 +0900
@@ -480,7 +480,7 @@
     if (flags & XF86_MAP_FIXED)		f |= MAP_FIXED;
     if (flags & XF86_MAP_SHARED)	f |= MAP_SHARED;
     if (flags & XF86_MAP_PRIVATE)	f |= MAP_PRIVATE;
-#ifdef __x86_64__
+#if defined(__x86_64__) && defined(linux)
     if (flags & XF86_MAP_32BIT)	        f |= MAP_32BIT;
 #endif
     if (prot  & XF86_PROT_EXEC)		p |= PROT_EXEC;
--- xc/programs/Xserver/hw/xfree86/common/Imakefile.orig	2003-02-18 02:06:41.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/common/Imakefile	2007-09-09 22:24:34.000000000 +0900
@@ -18,7 +18,8 @@
 #endif /* GNUMachArchitecture */
 #else
 # if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) \
-	|| defined(OpenBSDArchitecture) || defined(NetBSDArchitecture)
+	|| defined(OpenBSDArchitecture) || defined(NetBSDArchitecture) \
+	|| defined(FreeBSDArchitecture)
         KBD = xf86KbdBSD
 # else
 #  ifdef LinuxArchitecture
--- xc/programs/Xserver/hw/xfree86/common/xf86Events.c.orig	2003-02-20 13:20:52.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/common/xf86Events.c	2007-09-09 22:24:56.000000000 +0900
@@ -315,7 +315,7 @@
 	    CloseDownClient(server);
 	}
 	break;
-#if !defined(__SOL8__) && (!defined(sun) || defined(i386))
+#if !defined(__SOL8__) && (!defined(sun) || defined(i386)) && defined(VT_ACTIVATE)
     case ACTION_SWITCHSCREEN:
 	if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
 	    int vtno = *((int *) arg);
--- xc/programs/Xserver/hw/xfree86/loader/Imakefile.orig	2003-02-27 08:32:12.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/loader/Imakefile	2007-09-09 22:27:05.000000000 +0900
@@ -34,7 +34,7 @@
   SETJMPDEFINES = -DHAS_GLIBC_SIGSETJMP=1
 #endif
 
-#if defined (x86_64Architecture)
+#if defined (x86_64Architecture) && defined(linux)
 ARCHDEFINES = -DDoMMAPedMerge -DMmapPageAlign
 #endif
 
--- xc/programs/Xserver/hw/xfree86/loader/elfloader.c.orig	2003-01-25 02:26:35.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/loader/elfloader.c	2007-09-09 22:27:13.000000000 +0900
@@ -73,7 +73,7 @@
 # if !defined(linux)
 #  error    No MAP_ANON?
 # endif
-# if !defined (__x86_64__)
+# if !defined (__x86_64__) || !defined(__linux__)
 # define MMAP_FLAGS     (MAP_PRIVATE | MAP_ANON)
 # else
 # define MMAP_FLAGS     (MAP_PRIVATE | MAP_ANON | MAP_32BIT)
--- xc/config/cf/bsdLib.rules.orig	2007-09-10 08:00:14.000000000 +0900
+++ xc/config/cf/bsdLib.rules	2007-09-10 08:00:38.000000000 +0900
@@ -450,4 +450,14 @@
 #endif
 
 
+#ifdef FreeBSDArchitecture YES
+#define NormalLibraryObjectRule()                                       @@\
+.c.Osuf:                                                                @@\
+	NormalSharedLibObjCompile($(_NOOP_))
+
+#define NormalCplusplusObjectRule()                                     @@\
+.CCsuf.Osuf:                                                            @@\
+	NormalSharedLibObjCplusplusCompile($(_NOOP_))
+#endif
+
 #endif /* UseElfFormat */
--- xc/lib/font/FreeType/ftfuncs.c.orig	2003-02-13 12:01:45.000000000 +0900
+++ xc/lib/font/FreeType/ftfuncs.c	2007-09-10 09:30:44.000000000 +0900
@@ -959,11 +959,11 @@
         int underlinePosition, underlineThickness;
 
         if(post) {
-            underlinePosition = TRANSFORM_FUNITS_Y(post->underlinePosition);
+            underlinePosition = TRANSFORM_FUNITS_Y(-post->underlinePosition);
             underlineThickness = TRANSFORM_FUNITS_Y(post->underlineThickness);
         } else {
             underlinePosition = 
-                TRANSFORM_FUNITS_Y(t1info->underline_position);
+                TRANSFORM_FUNITS_Y(-t1info->underline_position);
             underlineThickness = 
                 TRANSFORM_FUNITS_Y(t1info->underline_thickness);
         }
--- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c.orig	2003-02-09 06:26:58.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c	2007-09-10 09:39:58.000000000 +0900
@@ -1359,6 +1359,7 @@
    if (pMga->irq) {
       drmCtlUninstHandler(pMga->drmFD);
       pMga->irq = 0;
+      pMga->reg_ien = 0;
    }
 
    /* Cleanup DMA */
--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c.orig	2003-02-11 08:42:51.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	2007-09-10 09:42:07.000000000 +0900
@@ -178,6 +178,7 @@
  */
 
 static const char *vgahwSymbols[] = {
+    "vgaHWUnmapMem",
     "vgaHWDPMSSet",
     "vgaHWFreeHWRec",
     "vgaHWGetHWRec",
--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c.orig	2003-02-11 08:42:51.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	2007-09-10 09:45:41.000000000 +0900
@@ -24,7 +24,7 @@
 /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen
    <jpaana@s2.org> */
 
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.27 2003/02/10 23:42:51 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.28 2003/03/12 21:27:18 mvojkovi Exp $ */
 
 #include "nv_include.h"
 
@@ -416,6 +416,9 @@
         break;
     }
 
+    if(pNv->riva.Architecture == 3)
+       pNv->riva.PCRTC0 = pNv->riva.PGRAPH;
+
     if(pNv->SecondCRTC) {
        pNv->riva.PCIO = pNv->riva.PCIO0 + 0x2000;
        pNv->riva.PCRTC = pNv->riva.PCRTC0 + 0x800;
@@ -484,7 +487,6 @@
                                      frameBase+0x00C00000, 0x00008000);
             
     NVCommonSetup(pScrn);
-    pNv->riva.PCRTC = pNv->riva.PCRTC0 = pNv->riva.PGRAPH;
 }
 
 void
--- xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c.orig	2003-02-19 10:19:41.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c	2007-09-10 09:48:30.000000000 +0900
@@ -275,6 +275,7 @@
     "drmAddMap",
     "drmAgpAcquire",
     "drmAgpAlloc",
+    "drmAgpBase",
     "drmAgpBind",
     "drmAgpDeviceId",
     "drmAgpEnable",
@@ -288,8 +289,11 @@
     "drmCommandRead",
     "drmCommandWrite",
     "drmCommandWriteRead",
+    "drmCtlInstHandler",
+    "drmCtlUninstHandler",
     "drmFreeBufs",
     "drmFreeVersion",
+    "drmGetInterruptFromBusID",
     "drmGetLibVersion",
     "drmGetVersion",
     "drmMap",
@@ -307,6 +311,7 @@
     "DRICreateInfoRec",
     "DRIDestroyInfoRec",
     "DRIFinishScreenInit",
+    "DRIGetDeviceInfo",
     "DRIGetSAREAPrivate",
     "DRILock",
     "DRIQueryVersion",
--- xc/lib/GL/mesa/src/drv/r200/r200_vtxtmp_x86.S.orig	2002-11-08 03:31:59.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/r200/r200_vtxtmp_x86.S	2007-09-10 09:57:23.000000000 +0900
@@ -28,7 +28,7 @@
 
 #define GLOBL( x )	\
 .globl x;		\
-x##:
+x:
 
 .data
 .align 4
--- xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c.orig	2003-02-25 05:34:55.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c	2007-09-10 09:59:44.000000000 +0900
@@ -370,7 +370,7 @@
     }
 
     if (info->IsSecondary || info->Clone) {
-	save2 = INREG(RADEON_CRTC_GEN_CNTL) & ~(CARD32) (3 << 20);
+	save2 = INREG(RADEON_CRTC2_GEN_CNTL) & ~(CARD32) (3 << 20);
 	save2 |= (CARD32) (2 << 20);
 	OUTREG(RADEON_CRTC2_GEN_CNTL, save2 & (CARD32)~RADEON_CRTC2_CUR_EN);
     }
--- xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c.orig	2003-02-19 18:17:30.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c	2007-09-10 10:01:06.000000000 +0900
@@ -1585,6 +1585,7 @@
     if (info->irq) {
 	drmCtlUninstHandler(info->drmFD);
 	info->irq = 0;
+	info->ModeReg.gen_int_cntl = 0;
     }
 
 				/* De-allocate vertex buffers */
--- xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h.orig	2003-02-08 03:08:59.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h	2007-09-10 10:02:33.000000000 +0900
@@ -879,7 +879,7 @@
 #       define RADEON_P2PLL_REF_DIV_MASK    0x03ff
 #       define RADEON_P2PLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
 #       define RADEON_P2PLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
-#       define R300_PPLL_REF_DIV_ACC_MASK   (0x3ff < 18)
+#       define R300_PPLL_REF_DIV_ACC_MASK   (0x3ff << 18)
 #       define R300_PPLL_REF_DIV_ACC_SHIFT  18
 #define RADEON_PALETTE_DATA                 0x00b4
 #define RADEON_PALETTE_30_DATA              0x00b8
--- xc/lib/GL/mesa/src/drv/radeon/radeon_vtxtmp_x86.S.orig	2002-11-08 03:32:00.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/radeon/radeon_vtxtmp_x86.S	2007-09-10 10:03:57.000000000 +0900
@@ -28,7 +28,7 @@
 
 #define GLOBL( x )	\
 .globl x;		\
-x##:
+x:
 
 .data
 .align 4
--- xc/lib/GL/mesa/src/drv/r200/r200_context.c.orig	2002-12-17 01:18:53.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/r200/r200_context.c	2007-09-10 10:05:57.000000000 +0900
@@ -391,6 +391,7 @@
     */
    _tnl_destroy_pipeline( ctx );
    _tnl_install_pipeline( ctx, r200_pipeline );
+   ctx->Driver.FlushVertices = r200FlushVertices;
 
    /* Try and keep materials and vertices separate:
     */
--- xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c.orig	2002-12-24 00:29:26.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c	2007-09-10 10:08:12.000000000 +0900
@@ -46,6 +46,7 @@
 #include "math/m_translate.h"
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
+#include "tnl/t_imm_exec.h"
 #include "tnl/t_pipeline.h"
 
 #include "r200_context.h"
@@ -1223,6 +1224,14 @@
 }
 
 
+void r200FlushVertices( GLcontext *ctx, GLuint flags )
+{
+   _tnl_flush_vertices( ctx, flags );
+
+   if (flags & FLUSH_STORED_VERTICES) 
+      R200_FIREVERTICES( R200_CONTEXT( ctx ) );
+}
+
 /**********************************************************************/
 /*                            Initialization.                         */
 /**********************************************************************/
--- xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h.orig	2002-12-17 01:18:55.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h	2007-09-10 10:09:23.000000000 +0900
@@ -42,6 +42,7 @@
 extern void r200InitSwtcl( GLcontext *ctx );
 extern void r200DestroySwtcl( GLcontext *ctx );
 
+extern void r200FlushVertices( GLcontext *ctx, GLuint flags );
 extern void r200ChooseRenderState( GLcontext *ctx );
 extern void r200ChooseVertexState( GLcontext *ctx );
 
--- xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt.c.orig	2002-12-17 01:18:55.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt.c	2007-09-10 10:13:18.000000000 +0900
@@ -38,6 +38,7 @@
 #include "r200_ioctl.h"
 #include "r200_tex.h"
 #include "r200_tcl.h"
+#include "r200_swtcl.h"
 #include "r200_vtxfmt.h"
 
 #include "api_noop.h"
@@ -59,7 +60,7 @@
 
 struct r200_vb vb;
 
-static void r200FlushVertices( GLcontext *, GLuint );
+static void r200VtxFmtFlushVertices( GLcontext *, GLuint );
 
 static void count_func( const char *name,  struct dynfn *l )
 {
@@ -357,12 +358,13 @@
       fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
 
    if (ctx->Driver.NeedFlush) 
-      r200FlushVertices( ctx, ctx->Driver.NeedFlush );
+      r200VtxFmtFlushVertices( ctx, ctx->Driver.NeedFlush );
 
    if (ctx->NewState)
       _mesa_update_state( ctx ); /* clear state so fell_back sticks */
 
    _tnl_wakeup_exec( ctx );
+   ctx->Driver.FlushVertices = r200FlushVertices;
 
    assert( rmesa->dma.flush == 0 );
    rmesa->vb.fell_back = GL_TRUE;
@@ -404,6 +406,7 @@
    prim = rmesa->vb.prim[0];
    ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
    _tnl_wakeup_exec( ctx );
+   ctx->Driver.FlushVertices = r200FlushVertices;
 
    assert(rmesa->dma.flush == 0);
    rmesa->vb.fell_back = GL_TRUE;
@@ -756,7 +759,7 @@
 	    fprintf(stderr, "reinstall (new install)\n");
 
 	 _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
-	 ctx->Driver.FlushVertices = r200FlushVertices;
+	 ctx->Driver.FlushVertices = r200VtxFmtFlushVertices;
 	 ctx->Driver.NewList = r200NewList;
 	 rmesa->vb.installed = GL_TRUE;
 	 vb.context = ctx;
@@ -772,6 +775,7 @@
 	 if (rmesa->dma.flush)
 	    rmesa->dma.flush( rmesa );
 	 _tnl_wakeup_exec( ctx );
+	 ctx->Driver.FlushVertices = r200FlushVertices;
 	 rmesa->vb.installed = GL_FALSE;
 	 vb.context = 0;
       }
@@ -931,7 +935,7 @@
    return GL_TRUE;
 }
 
-static void r200FlushVertices( GLcontext *ctx, GLuint flags )
+static void r200VtxFmtFlushVertices( GLcontext *ctx, GLuint flags )
 {
    r200ContextPtr rmesa = R200_CONTEXT( ctx );
 
--- xc/lib/GL/mesa/src/drv/radeon/radeon_context.c.orig	2003-02-09 06:26:45.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/radeon/radeon_context.c	2007-09-10 10:14:38.000000000 +0900
@@ -382,6 +382,7 @@
     */
    _tnl_destroy_pipeline( ctx );
    _tnl_install_pipeline( ctx, radeon_pipeline );
+   ctx->Driver.FlushVertices = radeonFlushVertices;
 
    /* Try and keep materials and vertices separate:
     */
--- xc/lib/GL/mesa/src/drv/radeon/radeon_swtcl.c.orig	2003-02-16 07:18:48.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/radeon/radeon_swtcl.c	2007-09-10 10:17:15.000000000 +0900
@@ -45,6 +45,7 @@
 #include "math/m_translate.h"
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
+#include "tnl/t_imm_exec.h"
 #include "tnl/t_pipeline.h"
 
 #include "radeon_context.h"
@@ -1134,6 +1135,14 @@
 }
 
 
+void radeonFlushVertices( GLcontext *ctx, GLuint flags )
+{
+   _tnl_flush_vertices( ctx, flags );
+
+   if (flags & FLUSH_STORED_VERTICES) 
+      RADEON_FIREVERTICES( RADEON_CONTEXT( ctx ) );
+}
+
 /**********************************************************************/
 /*                            Initialization.                         */
 /**********************************************************************/
--- xc/lib/GL/mesa/src/drv/radeon/radeon_swtcl.h.orig	2002-10-30 21:51:57.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/radeon/radeon_swtcl.h	2007-09-10 10:18:31.000000000 +0900
@@ -43,6 +43,7 @@
 extern void radeonInitSwtcl( GLcontext *ctx );
 extern void radeonDestroySwtcl( GLcontext *ctx );
 
+extern void radeonFlushVertices( GLcontext *ctx, GLuint flags );
 extern void radeonChooseRenderState( GLcontext *ctx );
 extern void radeonChooseVertexState( GLcontext *ctx );
 
--- xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c.orig	2002-12-17 01:18:59.000000000 +0900
+++ xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c	2007-09-10 10:22:20.000000000 +0900
@@ -38,6 +38,7 @@
 #include "radeon_ioctl.h"
 #include "radeon_tex.h"
 #include "radeon_tcl.h"
+#include "radeon_swtcl.h"
 #include "radeon_vtxfmt.h"
 
 #include "api_noop.h"
@@ -59,7 +60,7 @@
 
 struct radeon_vb vb;
 
-static void radeonFlushVertices( GLcontext *, GLuint );
+static void radeonVtxfmtFlushVertices( GLcontext *, GLuint );
 
 static void count_func( const char *name,  struct dynfn *l )
 {
@@ -336,12 +337,13 @@
       fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
 
    if (ctx->Driver.NeedFlush) 
-      radeonFlushVertices( ctx, ctx->Driver.NeedFlush );
+      radeonVtxfmtFlushVertices( ctx, ctx->Driver.NeedFlush );
 
    if (ctx->NewState)
       _mesa_update_state( ctx ); /* clear state so fell_back sticks */
 
    _tnl_wakeup_exec( ctx );
+   ctx->Driver.FlushVertices = radeonFlushVertices;
 
    assert( rmesa->dma.flush == 0 );
    rmesa->vb.fell_back = GL_TRUE;
@@ -382,6 +384,7 @@
    prim = rmesa->vb.prim[0];
    ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
    _tnl_wakeup_exec( ctx );
+   ctx->Driver.FlushVertices = radeonFlushVertices;
 
    assert(rmesa->dma.flush == 0);
    rmesa->vb.fell_back = GL_TRUE;
@@ -731,7 +734,7 @@
 	    fprintf(stderr, "reinstall (new install)\n");
 
 	 _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
-	 ctx->Driver.FlushVertices = radeonFlushVertices;
+	 ctx->Driver.FlushVertices = radeonVtxfmtFlushVertices;
 	 ctx->Driver.NewList = radeonNewList;
 	 rmesa->vb.installed = GL_TRUE;
 	 vb.context = ctx;
@@ -747,6 +750,7 @@
 	 if (rmesa->dma.flush)
 	    rmesa->dma.flush( rmesa );
 	 _tnl_wakeup_exec( ctx );
+	 ctx->Driver.FlushVertices = radeonFlushVertices;
 	 rmesa->vb.installed = GL_FALSE;
 	 vb.context = 0;
       }
@@ -905,7 +909,7 @@
    return GL_TRUE;
 }
 
-static void radeonFlushVertices( GLcontext *ctx, GLuint flags )
+static void radeonVtxfmtFlushVertices( GLcontext *ctx, GLuint flags )
 {
    radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
 
--- xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h.orig	2003-02-08 05:41:11.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h	2007-09-10 10:25:56.000000000 +0900
@@ -498,21 +498,34 @@
 #define PCI_CHIP_TRIO64V2_DXGX		0x8901
 #define PCI_CHIP_PLATO_PX		0x8902
 #define PCI_CHIP_Trio3D			0x8904
-#define PCI_CHIP_Trio3D_2X		0x8A13
 #define PCI_CHIP_VIRGE_DXGX		0x8A01
 #define PCI_CHIP_VIRGE_GX2		0x8A10
+#define PCI_CHIP_Trio3D_2X		0x8A13
 #define PCI_CHIP_SAVAGE3D		0x8A20
 #define PCI_CHIP_SAVAGE3D_MV		0x8A21
 #define PCI_CHIP_SAVAGE4		0x8A22
-#define PCI_CHIP_VIRGE_MX		0x8C01
-#define PCI_CHIP_VIRGE_MXPLUS		0x8C01
-#define PCI_CHIP_VIRGE_MXP		0x8C03
 #define PCI_CHIP_PROSAVAGE_PM		0x8A25
 #define PCI_CHIP_PROSAVAGE_KM		0x8A26
+#define PCI_CHIP_VIRGE_MX		0x8C01
+#define PCI_CHIP_VIRGE_MXPLUS		0x8C02
+#define PCI_CHIP_VIRGE_MXP		0x8C03
 #define PCI_CHIP_SAVAGE_MX_MV		0x8C10
 #define PCI_CHIP_SAVAGE_MX		0x8C11
 #define PCI_CHIP_SAVAGE_IX_MV		0x8C12
 #define PCI_CHIP_SAVAGE_IX		0x8C13
+#define PCI_CHIP_SUPSAV_MX128		0x8C22
+#define PCI_CHIP_SUPSAV_MX64		0x8C24
+#define PCI_CHIP_SUPSAV_MX64C		0x8C26
+#define PCI_CHIP_SUPSAV_IX128SDR	0x8C2A
+#define PCI_CHIP_SUPSAV_IX128DDR	0x8C2B
+#define PCI_CHIP_SUPSAV_IX64SDR		0x8C2C
+#define PCI_CHIP_SUPSAV_IX64DDR		0x8C2D
+#define PCI_CHIP_SUPSAV_IXCSDR		0x8C2E
+#define PCI_CHIP_SUPSAV_IXCDDR		0x8C2F
+#define PCI_CHIP_S3TWISTER_P		0x8D01
+#define PCI_CHIP_S3TWISTER_K		0x8D02
+#define PCI_CHIP_PROSAVAGE_DDR		0x8D03
+#define PCI_CHIP_PROSAVAGE_DDRK		0x8D04
 #define PCI_CHIP_SAVAGE2000		0x9102
 
 /* ARK Logic */
--- xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h.orig	2002-10-03 05:39:55.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h	2007-09-10 10:27:32.000000000 +0900
@@ -3,30 +3,6 @@
 #ifndef _SAVAGE_REGS_H
 #define _SAVAGE_REGS_H
 
-/* These are here until xf86PciInfo.h is updated. */
-
-#ifndef PCI_CHIP_S3TWISTER_P
-#define PCI_CHIP_S3TWISTER_P	0x8d01
-#endif
-#ifndef PCI_CHIP_S3TWISTER_K
-#define PCI_CHIP_S3TWISTER_K	0x8d02
-#endif
-#ifndef PCI_CHIP_SUPSAV_MX128
-#define PCI_CHIP_SUPSAV_MX128		0x8c22
-#define PCI_CHIP_SUPSAV_MX64		0x8c24
-#define PCI_CHIP_SUPSAV_MX64C		0x8c26
-#define PCI_CHIP_SUPSAV_IX128SDR	0x8c2a
-#define PCI_CHIP_SUPSAV_IX128DDR	0x8c2b
-#define PCI_CHIP_SUPSAV_IX64SDR		0x8c2c
-#define PCI_CHIP_SUPSAV_IX64DDR		0x8c2d
-#define PCI_CHIP_SUPSAV_IXCSDR		0x8c2e
-#define PCI_CHIP_SUPSAV_IXCDDR		0x8c2f
-#endif
-#ifndef PCI_CHIP_PROSAVAGE_DDR
-#define PCI_CHIP_PROSAVAGE_DDR	0x8d03
-#define PCI_CHIP_PROSAVAGE_DDRK	0x8d04
-#endif
-
 #define S3_SAVAGE3D_SERIES(chip)  ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
 
 #define S3_SAVAGE4_SERIES(chip)   ((chip==S3_SAVAGE4) || (chip==S3_PROSAVAGE))
--- xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.c.orig	2003-02-25 13:08:21.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.c	2007-09-10 10:28:45.000000000 +0900
@@ -123,8 +123,8 @@
     { PCI_CHIP_SAVAGE_IX,	"Savage/IX" },
     { PCI_CHIP_PROSAVAGE_PM,	"ProSavage PM133" },
     { PCI_CHIP_PROSAVAGE_KM,	"ProSavage KM133" },
-    { PCI_CHIP_S3TWISTER_P,	"ProSavage PN133" },
-    { PCI_CHIP_S3TWISTER_K,	"ProSavage KN133" },
+    { PCI_CHIP_S3TWISTER_P,	"Twister PN133" },
+    { PCI_CHIP_S3TWISTER_K,	"Twister KN133" },
     { PCI_CHIP_SUPSAV_MX128,	"SuperSavage/MX 128" },
     { PCI_CHIP_SUPSAV_MX64,	"SuperSavage/MX 64" },
     { PCI_CHIP_SUPSAV_MX64C,	"SuperSavage/MX 64C" },
--- xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c.orig	2003-02-06 02:45:29.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c	2007-09-10 10:30:31.000000000 +0900
@@ -1410,7 +1410,7 @@
 	ENTER_PROC("SMI_Save");
 
 	/* Save the standard VGA registers */
-	vgaHWSave(pScrn, vgaSavePtr, VGA_SR_MODE);
+	vgaHWSave(pScrn, vgaSavePtr, VGA_SR_ALL);
 	save->smiDACMask = VGAIN8(pSmi, VGA_DAC_MASK);
 	VGAOUT8(pSmi, VGA_DAC_READ_ADDR, 0);
 	for (i = 0; i < 256; i++)
@@ -1601,7 +1601,7 @@
 		VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0, restore->SRA0);
 
 		/* Restore the standard VGA registers */
-		vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_MODE);
+		vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_ALL);
 		if (restore->smiDACMask)
 		{
 			VGAOUT8(pSmi, VGA_DAC_MASK, restore->smiDACMask);
@@ -1672,7 +1672,7 @@
 		} 
 
 		if (restore->modeInit)
-		    vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_MODE);
+		    vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_ALL);
 
 		if (!SMI_LYNXM_SERIES(pSmi->Chipset))
 		{
--- xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c.orig	2003-01-12 12:55:49.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c	2007-09-10 10:31:51.000000000 +0900
@@ -277,7 +277,7 @@
     {XvSettable | XvGettable,        0,             1, XV_INTERLACED_NAME},
 };
 
-static XF86AttributeRec SMI_VideoAttributes[N_ATTRS] = {
+static XF86AttributeRec SMI_VideoAttributes[2] = {
     {XvSettable | XvGettable,        0,           255, XV_BRIGHTNESS_NAME},
     {XvSettable | XvGettable, 0x000000,      0xFFFFFF, XV_COLORKEY_NAME},
 };
--- xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile.orig	2002-09-17 03:06:01.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile	2007-09-10 10:34:37.000000000 +0900
@@ -49,7 +49,7 @@
 #define FFBsObjectRule(name)						@@\
 name.o: name.s								@@\
 	$(RM) $@							@@\
-	$(CPP) $*.s | $(AS) $(GCCVISOPTION) -o $@ -
+	$(CC) -c -x assembler-with-cpp $(GCCVISOPTION) $*.s -o $@
 #endif
 #else
 VISOBJS =
--- xc/programs/Xserver/xkb/xkbInit.c.orig	2003-02-09 15:29:20.000000000 +0900
+++ xc/programs/Xserver/xkb/xkbInit.c	2007-09-10 10:42:15.000000000 +0900
@@ -713,7 +713,7 @@
     if (names->types) names->types = _XkbDupString(names->types);
     if (names->compat) names->compat = _XkbDupString(names->compat);
     if (names->geometry) names->geometry = _XkbDupString(names->geometry);
-    if (names->symbols) names->geometry = _XkbDupString(names->symbols);
+    if (names->symbols) names->symbols = _XkbDupString(names->symbols);
 
     if (defs.model && defs.layout && rules) {
 	XkbComponentNamesRec	rNames;
--- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c.orig	2003-01-30 04:29:49.000000000 +0900
+++ xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c	2007-09-10 10:43:51.000000000 +0900
@@ -304,7 +304,10 @@
     "drmAgpVendorId",
     "drmCommandNone",
     "drmCommandWrite",
+    "drmCtlInstHandler",
+    "drmCtlUninstHandler",
     "drmFreeVersion",
+    "drmGetInterruptFromBusID",
     "drmGetLibVersion",
     "drmGetVersion",
     "drmMap",
