Index: kernel/arch/ia64/include/arch.h
===================================================================
--- kernel/arch/ia64/include/arch.h	(revision 0fd9b3513b2c0cfce8b0c99e0acbaf3470c1bc80)
+++ kernel/arch/ia64/include/arch.h	(revision 32817cc7228ed0a4db98be9cb5f00757af3d7e2c)
@@ -36,6 +36,4 @@
 #define KERN_ia64_ARCH_H_
 
-#include <arch/drivers/ski.h>
-
 extern void arch_pre_main(void);
 
Index: kernel/arch/ia64/include/asm.h
===================================================================
--- kernel/arch/ia64/include/asm.h	(revision 0fd9b3513b2c0cfce8b0c99e0acbaf3470c1bc80)
+++ kernel/arch/ia64/include/asm.h	(revision 32817cc7228ed0a4db98be9cb5f00757af3d7e2c)
@@ -39,20 +39,23 @@
 #include <typedefs.h>
 #include <arch/register.h>
+#include <arch/legacyio.h>
 #include <trace.h>
 
-#define IA64_IOSPACE_ADDRESS  0xE001000000000000ULL
-
 #define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
 
+/** Map the I/O port address to a legacy I/O address. */
+NO_TRACE static inline uintptr_t p2a(volatile void *p)
+{
+	uintptr_t prt = (uintptr_t) p;
+
+	return legacyio_virt_base + (((prt >> 2) << 12) | (prt & 0xfff));
+}
+	
 NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
 {
-	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
-		uintptr_t prt = (uintptr_t) port;
-	
-		*((ioport8_t *) (IA64_IOSPACE_ADDRESS +
-		    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
-	} else {
+	if (port < (ioport8_t *) IO_SPACE_BOUNDARY)
+		*((ioport8_t *) p2a(port)) = v;
+	else
 		*port = v;
-	}
 	
 	asm volatile (
@@ -64,12 +67,8 @@
 NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t v)
 {
-	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
-		uintptr_t prt = (uintptr_t) port;
-	
-		*((ioport16_t *) (IA64_IOSPACE_ADDRESS +
-		    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
-	} else {
+	if (port < (ioport16_t *) IO_SPACE_BOUNDARY)
+		*((ioport16_t *) p2a(port)) = v;
+	else
 		*port = v;
-	}
 	
 	asm volatile (
@@ -81,12 +80,8 @@
 NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t v)
 {
-	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
-		uintptr_t prt = (uintptr_t) port;
-	
-		*((ioport32_t *) (IA64_IOSPACE_ADDRESS +
-		    ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
-	} else {
+	if (port < (ioport32_t *) IO_SPACE_BOUNDARY)
+		*((ioport32_t *) p2a(port)) = v;
+	else
 		*port = v;
-	}
 	
 	asm volatile (
@@ -105,12 +100,8 @@
 	);
 
-	if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
-		uintptr_t prt = (uintptr_t) port;
-
-		v = *((ioport8_t *) (IA64_IOSPACE_ADDRESS +
-		    ((prt & 0xfff) | ((prt >> 2) << 12))));
-	} else {
+	if (port < (ioport8_t *) IO_SPACE_BOUNDARY)
+		v = *((ioport8_t *) p2a(port));
+	else
 		v = *port;
-	}
 	
 	return v;
@@ -126,12 +117,8 @@
 	);
 
-	if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
-		uintptr_t prt = (uintptr_t) port;
-
-		v = *((ioport16_t *) (IA64_IOSPACE_ADDRESS +
-		    ((prt & 0xfff) | ((prt >> 2) << 12))));
-	} else {
+	if (port < (ioport16_t *) IO_SPACE_BOUNDARY)
+		v = *((ioport16_t *) p2a(port));
+	else
 		v = *port;
-	}
 	
 	return v;
@@ -147,12 +134,8 @@
 	);
 	
-	if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
-		uintptr_t prt = (uintptr_t) port;
-		
-		v = *((ioport32_t *) (IA64_IOSPACE_ADDRESS +
-		    ((prt & 0xfff) | ((prt >> 2) << 12))));
-	} else {
+	if (port < (ioport32_t *) IO_SPACE_BOUNDARY)
+		v = *((ioport32_t *) p2a(port));
+	else
 		v = *port;
-	}
 
 	return v;
Index: kernel/arch/ia64/include/legacyio.h
===================================================================
--- kernel/arch/ia64/include/legacyio.h	(revision 32817cc7228ed0a4db98be9cb5f00757af3d7e2c)
+++ kernel/arch/ia64/include/legacyio.h	(revision 32817cc7228ed0a4db98be9cb5f00757af3d7e2c)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup ia64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_ia64_LEGACYIO_H_
+#define KERN_ia64_LEGACYIO_H_
+
+#include <typedefs.h>
+
+#define LEGACYIO_PHYS_BASE	0x00000FFFFC000000ULL
+
+/* Legacy I/O space - static uspace address, FIXME */
+#define LEGACYIO_USER_BASE	0x0001000000000000ULL 
+
+#define LEGACYIO_PAGE_WIDTH		26	/* 64M */
+#define LEGACYIO_SINGLE_PAGE_WIDTH 	12 	/* 4K */
+
+#define LEGACYIO_SIZE	(1ULL << LEGACYIO_PAGE_WIDTH)
+
+extern uintptr_t legacyio_virt_base;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/ia64/include/mm/page.h
===================================================================
--- kernel/arch/ia64/include/mm/page.h	(revision 0fd9b3513b2c0cfce8b0c99e0acbaf3470c1bc80)
+++ kernel/arch/ia64/include/mm/page.h	(revision 32817cc7228ed0a4db98be9cb5f00757af3d7e2c)
@@ -43,24 +43,5 @@
 
 /** Bit width of the TLB-locked portion of kernel address space. */
-#define KERNEL_PAGE_WIDTH  28  /* 256M */
-#define IO_PAGE_WIDTH      26  /* 64M */
-#define FW_PAGE_WIDTH      28  /* 256M */
-
-#define USPACE_IO_PAGE_WIDTH  12  /* 4K */
-
-
-/*
- * Statically mapped IO spaces - offsets to 0xe...00 of virtual addresses
- * because of "minimal virtual bits implemented is 51" it is possible to
- * have values up to 0x0007000000000000
- */
-
-/* Firmware area (bellow 4GB in phys mem) */
-#define FW_OFFSET   0x00000000F0000000	// FIXME: [non-ident]
-/* Legacy IO space */
-#define IO_OFFSET   0x0001000000000000	// FIXME: [non-ident]
-/* Videoram - now mapped to 0 as VGA text mode vram on 0xb8000 */
-#define VIO_OFFSET  0x0002000000000000	// FIXME: [non-ident]
-
+#define KERNEL_PAGE_WIDTH 	28	/* 256M */
 
 #define PPN_SHIFT  12
