--- configure.dist	2009-06-18 17:05:59.000000000 -0700
+++ configure	2009-06-18 17:08:47.000000000 -0700
@@ -1097,6 +1097,8 @@
 SPARC64_VIDEO_TRUE
 PPC_VIDEO_FALSE
 PPC_VIDEO_TRUE
+IA64_VIDEO_FALSE
+IA64_VIDEO_TRUE
 I386_VIDEO_FALSE
 I386_VIDEO_TRUE
 ARM_VIDEO_FALSE
@@ -19134,6 +19136,7 @@
 	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
 	;;
   ia64*)
+	IA64_VIDEO=yes
   	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
 	;;
   s390*)
@@ -19166,6 +19169,14 @@
   I386_VIDEO_FALSE=
 fi
 
+ if test "x$IA64_VIDEO" = xyes; then
+  IA64_VIDEO_TRUE=
+  IA64_VIDEO_FALSE='#'
+else
+  IA64_VIDEO_TRUE='#'
+  IA64_VIDEO_FALSE=
+fi
+
  if test "x$PPC_VIDEO" = xyes; then
   PPC_VIDEO_TRUE=
   PPC_VIDEO_FALSE='#'
--- hw/xfree86/common/compiler.h.dist	2009-04-14 10:14:57.000000000 -0700
+++ hw/xfree86/common/compiler.h	2009-06-18 16:22:46.000000000 -0700
@@ -363,12 +363,10 @@
 #    endif
 
 
-#   elif defined(linux) && defined(__ia64__) 
+#   elif (defined(linux) || defined(__FreeBSD__)) && defined(__ia64__) 
  
 #    include <inttypes.h>
 
-#    include <sys/io.h>
-
 struct __una_u64 { uint64_t x __attribute__((packed)); };
 struct __una_u32 { uint32_t x __attribute__((packed)); };
 struct __una_u16 { uint16_t x __attribute__((packed)); };
--- hw/xfree86/os-support/bsd/Makefile.in.dist	2009-06-18 17:45:13.000000000 -0700
+++ hw/xfree86/os-support/bsd/Makefile.in	2009-06-18 17:45:19.000000000 -0700
@@ -63,6 +63,7 @@
 @ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@am__objects_1 = sparc64_video.lo \
 @ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@	ioperm_noop.lo
 @ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_TRUE@am__objects_1 = ppc_video.lo
+@IA64_VIDEO_TRUE@am__objects_1 = ia64_video.lo
 @ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_TRUE@am__objects_1 = i386_video.lo
 @ALPHA_VIDEO_FALSE@@ARM_VIDEO_TRUE@am__objects_1 = arm_video.lo
 @ALPHA_VIDEO_TRUE@am__objects_1 = alpha_video.lo bsd_ev56.lo \
@@ -393,6 +394,7 @@
 
 @ARM_VIDEO_TRUE@ARCH_SOURCES = arm_video.c
 @I386_VIDEO_TRUE@ARCH_SOURCES = i386_video.c
+@IA64_VIDEO_TRUE@ARCH_SOURCES = ia64_video.c
 @PPC_VIDEO_TRUE@ARCH_SOURCES = ppc_video.c
 
 # Cheat here and piggyback other sparc64 bits on SPARC64_VIDEO.
--- /dev/null	2009-06-18 18:27:23.000000000 -0700
+++ hw/xfree86/os-support/bsd/ia64_video.c	2009-06-18 18:26:02.000000000 -0700
@@ -0,0 +1,150 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#include "bus/Pci.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+
+/***************************************************************************/
+/* Video Memory Mapping section                                            */
+/***************************************************************************/
+
+#define DEV_MEM "/dev/mem"
+
+static pointer ia64MapVidMem(int, unsigned long, unsigned long, int flags);
+static void ia64UnmapVidMem(int, pointer, unsigned long);
+
+Bool xf86EnableIO(void);
+void xf86DisableIO(void);
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+	pVidMem->linearSupported = TRUE;
+	pVidMem->mapMem = ia64MapVidMem;
+	pVidMem->unmapMem = ia64UnmapVidMem;
+	pVidMem->initialised = TRUE;
+	xf86EnableIO();
+}
+
+
+_X_EXPORT volatile unsigned char *ioBase = MAP_FAILED;
+
+static pointer
+ia64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+	int fd = xf86Info.screenFd;
+	pointer base;
+#ifdef DEBUG
+	xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", 
+		    Base, Size, fd);
+#endif
+
+	base = mmap(0, Size,
+		    (flags & VIDMEM_READONLY) ?
+		     PROT_READ : (PROT_READ | PROT_WRITE),
+		    MAP_SHARED, fd, Base);
+	if (base == MAP_FAILED)
+		FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)",
+			   "xf86MapVidMem", Size, Base, strerror(errno));
+
+	return base;
+}
+
+static void
+ia64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+	munmap(Base, Size);
+}
+
+_X_EXPORT int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+	     int Len)
+{
+	int rv;
+	static int kmem = -1;
+
+	if (kmem == -1) {
+		kmem = open(DEV_MEM, 2);
+		if (kmem == -1) {
+			FatalError("xf86ReadBIOS: open %s", DEV_MEM);
+		}
+	}
+
+#ifdef DEBUG
+	xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", 
+		    Base, Offset, Len);
+#endif
+
+
+	lseek(kmem, Base + Offset, 0);
+	rv = read(kmem, Buf, Len);
+
+	return rv;
+}
+
+Bool xf86EnableIO()
+{
+        int fd = xf86Info.screenFd;
+
+        xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd);
+        if (ioBase == MAP_FAILED)
+        {
+                ioBase=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
+                    0);
+                xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %p\n", ioBase);
+                if (ioBase == MAP_FAILED) {
+                        xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n");
+			return FALSE;
+		}
+        }
+	return TRUE;
+}
+
+void xf86DisableIO()
+{
+
+        if (ioBase != MAP_FAILED)
+        {
+                munmap((void *)(uintptr_t)(void *)ioBase, 0x10000);
+                ioBase = MAP_FAILED;
+        }
+}
+
+void outb(unsigned long port, unsigned char val)
+{
+}
+
+void outw(unsigned long port, unsigned short val)
+{
+}
+
+void outl(unsigned long port, unsigned int val)
+{
+}
+
+unsigned int inb(unsigned long port)
+{
+	return 0xff;
+}
+
+unsigned int inw(unsigned long port)
+{
+	return 0xffff;
+}
+
+unsigned int inl(unsigned long port)
+{
+	return 0xffffffff;
+}
