Index: kernel/arch/amd64/src/amd64.c
===================================================================
--- kernel/arch/amd64/src/amd64.c	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ kernel/arch/amd64/src/amd64.c	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -200,4 +200,8 @@
 	sysinfo_set_item_val("kbd.devno", NULL, devno);
 	sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    (uintptr_t) I8042_BASE);
+	sysinfo_set_item_val("kbd.address.kernel", NULL,
+	    (uintptr_t) I8042_BASE);
 }
 
Index: kernel/arch/ia32/src/ia32.c
===================================================================
--- kernel/arch/ia32/src/ia32.c	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ kernel/arch/ia32/src/ia32.c	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -158,4 +158,8 @@
 	sysinfo_set_item_val("kbd.devno", NULL, devno);
 	sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    (uintptr_t) I8042_BASE);
+	sysinfo_set_item_val("kbd.address.kernel", NULL,
+	    (uintptr_t) I8042_BASE);
 }
 
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ kernel/arch/ia64/src/ia64.c	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -169,9 +169,16 @@
 	(void) ns16550_init((ns16550_t *)NS16550_BASE, devno, inr, NULL, NULL);
 	sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550);
-	sysinfo_set_item_val("kbd.port", NULL, (uintptr_t)NS16550_BASE);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    (uintptr_t) NS16550_BASE);
+	sysinfo_set_item_val("kbd.address.kernel", NULL,
+	    (uintptr_t) NS16550_BASE);
 #else
 	inr = IRQ_KBD;
 	(void) i8042_init((i8042_t *)I8042_BASE, devno, inr);
 	sysinfo_set_item_val("kbd.type", NULL, KBD_LEGACY);
+	sysinfo_set_item_val("kbd.address.physical", NULL,
+	    (uintptr_t) I8042_BASE);
+	sysinfo_set_item_val("kbd.address.kernel", NULL,
+	    (uintptr_t) I8042_BASE);
 #endif
 	sysinfo_set_item_val("kbd", NULL, true);
Index: kernel/arch/sparc64/src/drivers/kbd.c
===================================================================
--- kernel/arch/sparc64/src/drivers/kbd.c	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ kernel/arch/sparc64/src/drivers/kbd.c	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -170,5 +170,5 @@
 		sysinfo_set_item_val("kbd.devno", NULL, devno);
 		sysinfo_set_item_val("kbd.inr", NULL, inr);
-		sysinfo_set_item_val("kbd.address.virtual", NULL,
+		sysinfo_set_item_val("kbd.address.kernel", NULL,
 		    (uintptr_t) z8530);
 		sysinfo_set_item_val("kbd.address.physical", NULL, pa);
@@ -190,5 +190,5 @@
 		sysinfo_set_item_val("kbd.devno", NULL, devno);
 		sysinfo_set_item_val("kbd.inr", NULL, inr);
-		sysinfo_set_item_val("kbd.address.virtual", NULL,
+		sysinfo_set_item_val("kbd.address.kernel", NULL,
 		    (uintptr_t) ns16550);
 		sysinfo_set_item_val("kbd.address.physical", NULL, pa);
Index: uspace/srv/kbd/port/i8042.c
===================================================================
--- uspace/srv/kbd/port/i8042.c	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ uspace/srv/kbd/port/i8042.c	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -36,4 +36,6 @@
  */
 
+#include <ddi.h>
+#include <libarch/ddi.h>
 #include <ipc/ipc.h>
 #include <async.h>
@@ -67,5 +69,5 @@
 	{
 		.cmd = CMD_PIO_READ_8,
-		.addr = (void *) 0x64,
+		.addr = NULL,	/* will be patched in run-time */
 		.dstarg = 1
 	},
@@ -83,5 +85,5 @@
 	{
 		.cmd = CMD_PIO_READ_8,
-		.addr = (void *) 0x60,
+		.addr = NULL,	/* will be patched in run-time */
 		.dstarg = 2
 	},
@@ -96,7 +98,11 @@
 };
 
+static uintptr_t i8042_physical;
+static uintptr_t i8042_kernel;
+static i8042_t * i8042;
+
 static void wait_ready(void) {
-	while (i8042_status_read() & i8042_INPUT_FULL)
-	    ;
+	while (pio_read_8(&i8042->status) & i8042_INPUT_FULL)
+		;
 }
 
@@ -105,48 +111,30 @@
 int kbd_port_init(void)
 {
-//	int i;
 	int mouseenabled = 0;
+	void *vaddr;
+
+	i8042_physical = sysinfo_value("kbd.address.physical");
+	i8042_kernel = sysinfo_value("kbd.address.kernel");
+	if (pio_enable((void *) i8042_physical, sizeof(i8042_t), &vaddr) != 0)
+		return -1;
+	i8042 = vaddr;
 
 	async_set_interrupt_received(i8042_irq_handler);
-	iospace_enable(task_get_id(), (void *) i8042_DATA, 5);
 
 	/* Disable kbd, enable mouse */
-	i8042_command_write(i8042_CMD_KBD);
+	pio_write_8(&i8042->status, i8042_CMD_KBD);
 	wait_ready();
-	i8042_command_write(i8042_CMD_KBD);
+	pio_write_8(&i8042->status, i8042_CMD_KBD);
 	wait_ready();
-	i8042_data_write(i8042_KBD_DISABLE);
+	pio_write_8(&i8042->data, i8042_KBD_DISABLE);
 	wait_ready();
 
 	/* Flush all current IO */
-	while (i8042_status_read() & i8042_OUTPUT_FULL)
-		i8042_data_read();
+	while (pio_read_8(&i8042->status) & i8042_OUTPUT_FULL)
+		(void) pio_read_8(&i8042->data);
 	
-	/* Initialize mouse */
-/*	i8042_command_write(i8042_CMD_MOUSE);
-	wait_ready();
-	i8042_data_write(MOUSE_OUT_INIT);
-	wait_ready();
-	
-	int mouseanswer = 0;
-	for (i=0;i < 1000; i++) {
-		int status = i8042_status_read();
-		if (status & i8042_OUTPUT_FULL) {
-			int data = i8042_data_read();
-			if (status & i8042_MOUSE_DATA) {
-				mouseanswer = data;
-				break;
-			}
-		}
-		usleep(1000);
-	}*/
-//	if (mouseanswer == MOUSE_ACK) {
-//		/* enable mouse */
-//		mouseenabled = 1;
-//		
-//		ipc_register_irq(sysinfo_value("mouse.inr"), sysinfo_value("mouse.devno"), 0, &i8042_kbd);
-//	}
-
 	/* Enable kbd */
+	i8042_kbd.cmds[0].addr = &((i8042_t *) i8042_kernel)->status;
+	i8042_kbd.cmds[3].addr = &((i8042_t *) i8042_kernel)->data;
 	ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &i8042_kbd);
 
@@ -155,7 +143,7 @@
 		newcontrol |= i8042_MOUSE_IE;
 	
-	i8042_command_write(i8042_CMD_KBD);
+	pio_write_8(&i8042->status, i8042_CMD_KBD);
 	wait_ready();
-	i8042_data_write(newcontrol);
+	pio_write_8(&i8042->data, newcontrol);
 	wait_ready();
 	
@@ -168,10 +156,10 @@
 
 	if ((status & i8042_MOUSE_DATA))
-		return 0;
+		return;
 
 	int scan_code = IPC_GET_ARG2(*call);
 
 	kbd_push_scancode(scan_code);
-	return 1;
+	return;
 }
 
Index: uspace/srv/kbd/port/i8042.h
===================================================================
--- uspace/srv/kbd/port/i8042.h	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ uspace/srv/kbd/port/i8042.h	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -39,33 +39,13 @@
 #define KBD_PORT_i8042_H_
 
-#include <ddi.h>
 #include <libarch/ddi.h>
+#include <libarch/types.h>
 
-#define i8042_DATA      0x60
-#define i8042_STATUS    0X64
-
-
-typedef unsigned char u8;
-typedef short u16;
-
-static inline void i8042_data_write(u8 data)
-{
-	outb(i8042_DATA, data);
-}
-
-static inline u8 i8042_data_read(void)
-{
-	return inb(i8042_DATA);
-}
-
-static inline u8 i8042_status_read(void)
-{
-	return inb(i8042_STATUS);
-}
-
-static inline void i8042_command_write(u8 command)
-{
-	outb(i8042_STATUS, command);
-}
+struct i8042 {
+	ioport8_t data;
+	uint8_t pad[3];
+	ioport8_t status;
+} __attribute__ ((packed));
+typedef struct i8042 i8042_t;
 
 #endif
Index: uspace/srv/kbd/port/ns16550.c
===================================================================
--- uspace/srv/kbd/port/ns16550.c	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ uspace/srv/kbd/port/ns16550.c	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -87,18 +87,20 @@
 static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call);
 
-uint16_t ns16550_port;
+static uintptr_t ns16550_physical;
+static uintptr_t ns16550_kernel; 
 
 int kbd_port_init(void)
 {
+	void *vaddr;
+
 	async_set_interrupt_received(ns16550_irq_handler);
 
-	ns16550_port = sysinfo_value("kbd.port");
-	ns16550_kbd.cmds[0].addr = (void *) (ns16550_port + LSR_REG);
-	ns16550_kbd.cmds[3].addr = (void *) (ns16550_port + RBR_REG);
+	ns16550_physical = sysinfo_value("kbd.address.physical");
+	ns16550_kernel = sysinfo_value("kbd.address.kernel");
+	ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG);
+	ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG);
 	ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
 	    0, &ns16550_kbd);
-	iospace_enable(task_get_id(), ns16550_port, 8);
-
-	return 0;
+	return pio_enable((void *) ns16550_physical, 8, &vaddr);
 }
 
Index: uspace/srv/kbd/port/z8530.c
===================================================================
--- uspace/srv/kbd/port/z8530.c	(revision 9cd98796ce2b79a13dae8d49fe37ce6be500f3b8)
+++ uspace/srv/kbd/port/z8530.c	(revision ff685c93ca4666ba47a3b747bd9da4268cc5aa47)
@@ -42,4 +42,5 @@
 #include <kbd_port.h>
 #include <sys/types.h>
+#include <ddi.h>
 
 #define CHAN_A_STATUS	4
@@ -85,7 +86,7 @@
 {
 	async_set_interrupt_received(z8530_irq_handler);
-	z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") +
+	z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.kernel") +
 	    CHAN_A_STATUS;
-	z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.virtual") +
+	z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.kernel") +
 	    CHAN_A_DATA;
 	ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
