Index: uspace/drv/char/i8042/i8042.c
===================================================================
--- uspace/drv/char/i8042/i8042.c	(revision ee163b3f91b170b746f3137b84e988e62e4bc0bc)
+++ uspace/drv/char/i8042/i8042.c	(revision b1f44b425eeb53e21337e0364e53668b960b8a5b)
@@ -38,4 +38,6 @@
 
 #include <ddi.h>
+#include <devman.h>
+#include <device/hw_res.h>
 #include <libarch/ddi.h>
 #include <loc.h>
@@ -52,5 +54,4 @@
 
 #define NAME       "i8042"
-#define NAMESPACE  "char"
 
 /* Interesting bits for status register */
@@ -97,6 +98,4 @@
 };
 
-static i8042_t device;
-
 static void wait_ready(i8042_t *dev)
 {
@@ -105,9 +104,30 @@
 }
 
-static void i8042_irq_handler(ddf_dev_t *dev,
-    ipc_callid_t iid, ipc_call_t *call);
-static void i8042_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
-static void i8042_port_write(i8042_t *dev, int devid, uint8_t data);
-
+static void i8042_irq_handler(
+    ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
+{
+
+	const int status = IPC_GET_ARG1(*call);
+	const int data = IPC_GET_ARG2(*call);
+	const int devid = (status & i8042_AUX_DATA) ? DEVID_AUX : DEVID_PRI;
+	ddf_msg(LVL_WARN, "Unhandled %s data: %x , status: %x.",
+	    (devid == DEVID_AUX) ? "AUX" : "PRIMARY", data, status);
+#if 0
+	if (!dev || !dev->driver_data)
+		return;
+
+	if (device.port[devid].client_sess != NULL) {
+		async_exch_t *exch =
+		    async_exchange_begin(device.port[devid].client_sess);
+		if (exch) {
+			async_msg_1(exch, IPC_FIRST_USER_METHOD, data);
+			async_exchange_end(exch);
+		}
+	} else {
+		ddf_msg(LVL_WARN, "No client session.\n");
+	}
+#endif
+}
+/*----------------------------------------------------------------------------*/
 int i8042_init(i8042_t *dev, void *regs, size_t reg_size, int irq_kbd,
     int irq_mouse, ddf_dev_t *ddf_dev)
@@ -177,4 +197,5 @@
 	} \
 } else (void)0
+
 	const size_t cmd_count = sizeof(i8042_cmds) / sizeof(irq_cmd_t);
 	irq_cmd_t cmds[cmd_count];
@@ -184,7 +205,4 @@
 
 	irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = cmds };
-	ddf_msg(LVL_DEBUG,
-	    "Registering interrupt handler for device %s on irq %d.\n",
-	    ddf_dev->name, irq_kbd);
 	ret = register_interrupt_handler(ddf_dev, irq_kbd, i8042_irq_handler,
 	    &irq_code);
@@ -192,7 +210,4 @@
 	    "Failed set handler for kbd: %s.\n", str_error(ret));
 
-	ddf_msg(LVL_DEBUG,
-	    "Registering interrupt handler for device %s on irq %d.\n",
-	    ddf_dev->name, irq_mouse);
 	ret = register_interrupt_handler(ddf_dev, irq_mouse, i8042_irq_handler,
 	    &irq_code);
@@ -200,4 +215,5 @@
 	    "Failed set handler for mouse: %s.\n", str_error(ret));
 
+#if 0
 	ret = ddf_fun_add_to_category(dev->kbd_fun, "keyboard");
 	if (ret != EOK)
@@ -206,6 +222,16 @@
 	if (ret != EOK)
 		ddf_msg(LVL_WARN, "Failed to register mouse fun to category.\n");
-
-	// TODO: Don't rely on kernel enabling interrupts do it yourself.
+#endif
+	/* Enable interrupts */
+	async_sess_t *parent_sess =
+	    devman_parent_device_connect(EXCHANGE_SERIALIZE, ddf_dev->handle,
+	    IPC_FLAG_BLOCKING);
+	ret = parent_sess ? EOK : ENOMEM;
+	CHECK_RET_UNBIND_DESTROY(ret, "Failed to create parent connection.\n");
+	const bool enabled = hw_res_enable_interrupt(parent_sess);
+	async_hangup(parent_sess);
+	ret = enabled ? EOK : EIO;
+	CHECK_RET_UNBIND_DESTROY(ret, "Failed to enable interrupts: %s.\n");
+
 
 	wait_ready(dev);
@@ -215,11 +241,9 @@
 	    i8042_AUX_IE);
 
-	// TODO: Plug in connection.
-
-	return ret;
-	(void)i8042_connection;
+	return EOK;
 }
 
 /** Character device connection handler */
+#if 0
 static void i8042_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
 {
@@ -288,5 +312,4 @@
 	}
 }
-
 void i8042_port_write(i8042_t *dev, int devid, uint8_t data)
 {
@@ -300,26 +323,5 @@
 	pio_write_8(&dev->regs->data, data);
 }
-
-void i8042_irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
-{
-	ddf_msg(LVL_FATAL, "IRQ!!!.\n");
-	if (!dev || !dev->driver_data)
-		return;
-
-	const int status = IPC_GET_ARG1(*call);
-	const int data = IPC_GET_ARG2(*call);
-	const int devid = (status & i8042_AUX_DATA) ? DEVID_AUX : DEVID_PRI;
-
-	if (device.port[devid].client_sess != NULL) {
-		async_exch_t *exch =
-		    async_exchange_begin(device.port[devid].client_sess);
-		if (exch) {
-			async_msg_1(exch, IPC_FIRST_USER_METHOD, data);
-			async_exchange_end(exch);
-		}
-	} else {
-		ddf_msg(LVL_WARN, "No client session.\n");
-	}
-}
+#endif
 
 /**
