Index: kernel/arch/ia64/src/ddi/ddi.c
===================================================================
--- kernel/arch/ia64/src/ddi/ddi.c	(revision 7782030a5944566e96b3a1307067dc1993fd1a64)
+++ kernel/arch/ia64/src/ddi/ddi.c	(revision e55571317c3b62308d58f97fb8f2aa78c6fd7aa4)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2006 Jakub Jermar
+ * Copyright (c) 2006 Jakub Jermar, Jakub vana
  * All rights reserved.
  *
@@ -36,4 +36,9 @@
 #include <proc/task.h>
 #include <arch/types.h>
+#include <mm/slab.h>
+#include <errno.h>
+
+#define IO_MEMMAP_PAGES 16384
+#define PORTS_PER_PAGE 4
 
 /** Enable I/O space range for task.
@@ -49,4 +54,21 @@
 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
 {
+
+	if(!task->arch.iomap)
+	{
+		uint8_t *map;
+		task->arch.iomap=malloc(sizeof(bitmap_t),0);
+		map=malloc(BITS2BYTES(IO_MEMMAP_PAGES),0);
+		if(!map)
+			return ENOMEM;
+		bitmap_initialize(task->arch.iomap,map,IO_MEMMAP_PAGES);	
+		bitmap_clear_range(task->arch.iomap,0,IO_MEMMAP_PAGES);
+	}
+	
+	uintptr_t iopage = ioaddr / PORTS_PER_PAGE;
+	size = ALIGN_UP (size+ioaddr-4*iopage,PORTS_PER_PAGE);
+	bitmap_set_range(task->arch.iomap,iopage,size/4);
+
+
 	return 0;
 }
Index: kernel/arch/ia64/src/drivers/ega.c
===================================================================
--- kernel/arch/ia64/src/drivers/ega.c	(revision 7782030a5944566e96b3a1307067dc1993fd1a64)
+++ kernel/arch/ia64/src/drivers/ega.c	(revision e55571317c3b62308d58f97fb8f2aa78c6fd7aa4)
@@ -47,4 +47,6 @@
 #include <sysinfo/sysinfo.h>
 #include <arch/drivers/ega.h>
+#include <ddi/ddi.h>
+
 
 /*
@@ -52,4 +54,8 @@
  * Simple and short. Function for displaying characters and "scrolling".
  */
+
+
+static parea_t ega_parea;	/**< Physical memory area for EGA video RAM. */
+
 
 SPINLOCK_INITIALIZE(egalock);
@@ -76,4 +82,12 @@
 	chardev_initialize("ega_out", &ega_console, &ega_ops);
 	stdout = &ega_console;
+
+
+	ega_parea.pbase = VIDEORAM & 0xffffffff;
+	ega_parea.vbase = (uintptr_t) videoram;
+	ega_parea.frames = 1;
+	ega_parea.cacheable = false;
+	ddi_parea_register(&ega_parea);
+
 	
 	sysinfo_set_item_val("fb", NULL, true);
@@ -81,5 +95,5 @@
 	sysinfo_set_item_val("fb.width", NULL, ROW);
 	sysinfo_set_item_val("fb.height", NULL, ROWS);
-	sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM);
+	sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM & 0xffffffff);
 	
 #ifndef CONFIG_FB
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision 7782030a5944566e96b3a1307067dc1993fd1a64)
+++ kernel/arch/ia64/src/ia64.c	(revision e55571317c3b62308d58f97fb8f2aa78c6fd7aa4)
@@ -61,4 +61,5 @@
 #include <panic.h>
 #include <print.h>
+#include <sysinfo/sysinfo.h>
 
 /*NS16550 as a COM 1*/
@@ -183,4 +184,9 @@
 
 	}
+	
+	sysinfo_set_item_val("ia64_iospace", NULL, true);
+	sysinfo_set_item_val("ia64_iospace.address", NULL, true);
+	sysinfo_set_item_val("ia64_iospace.address.virtual", NULL, IO_OFFSET);
+
 }
 
Index: kernel/arch/ia64/src/mm/tlb.c
===================================================================
--- kernel/arch/ia64/src/mm/tlb.c	(revision 7782030a5944566e96b3a1307067dc1993fd1a64)
+++ kernel/arch/ia64/src/mm/tlb.c	(revision e55571317c3b62308d58f97fb8f2aa78c6fd7aa4)
@@ -476,4 +476,71 @@
 }
 
+
+
+static int is_io_page_accessible(int page)
+{
+	if(TASK->arch.iomap) return bitmap_get(TASK->arch.iomap,page);
+	else return 0;
+}
+
+#define IO_FRAME_BASE 0xFFFFC000000
+
+/** There is special handling of memmaped lagacy io, because
+ * of 4KB sized access
+ * only for userspace
+ *
+ * @param va virtual address of page fault
+ * @param istate Structure with saved interruption state.
+ *
+ *
+ * @return 1 on success, 0 on fail
+ */
+static int try_memmap_io_insertion(uintptr_t va, istate_t *istate)
+{
+	if((va >= IO_OFFSET ) && (va < IO_OFFSET + (1<<IO_PAGE_WIDTH)))
+		if(TASK){
+			
+			uint64_t io_page=(va &  ((1<<IO_PAGE_WIDTH)-1)) >> (USPACE_IO_PAGE_WIDTH);
+			if(is_io_page_accessible(io_page)){
+				//printf("Insert %llX\n",va);
+
+				uint64_t page,frame;
+
+				page = IO_OFFSET + (1 << USPACE_IO_PAGE_WIDTH) * io_page;
+				frame = IO_FRAME_BASE + (1 << USPACE_IO_PAGE_WIDTH) * io_page;
+
+
+				tlb_entry_t entry;
+	
+				entry.word[0] = 0;
+				entry.word[1] = 0;
+	
+				entry.p = true;			/* present */
+				entry.ma = MA_UNCACHEABLE;		
+				entry.a = true;			/* already accessed */
+				entry.d = true;			/* already dirty */
+				entry.pl = PL_USER;
+				entry.ar = AR_READ | AR_WRITE;
+				entry.ppn = frame >> PPN_SHIFT;    //MUSIM spocitat frame
+				entry.ps = USPACE_IO_PAGE_WIDTH;
+	
+				dtc_mapping_insert(page, TASK->as->asid, entry); //Musim zjistit ASID
+				return 1;
+			}else {
+				fault_if_from_uspace(istate,"IO access fault at %p",va);
+				return 0;
+			}		
+		} else 
+			return 0;
+	else 
+		return 0;
+		
+	return 0;
+
+}
+
+
+
+
 /** Data TLB fault handler for faults with VHPT turned off.
  *
@@ -512,8 +579,9 @@
 		page_table_unlock(AS, true);
 	} else {
+		page_table_unlock(AS, true);
+		if (try_memmap_io_insertion(va,istate)) return;
 		/*
 		 * Forward the page fault to the address space page fault handler.
 		 */
-		page_table_unlock(AS, true);
 		if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
 			fault_if_from_uspace(istate,"Page fault at %p",va);
