Index: boot/genarch/ofw_tree.c
===================================================================
--- boot/genarch/ofw_tree.c	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ boot/genarch/ofw_tree.c	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -97,4 +97,5 @@
 	current_node->properties = 0;
 	current_node->property = NULL;
+	current_node->device = NULL;
 	
 	/*
Index: boot/genarch/ofw_tree.h
===================================================================
--- boot/genarch/ofw_tree.h	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ boot/genarch/ofw_tree.h	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -50,4 +50,6 @@
 	unsigned properties;			/**< Number of properties. */
 	ofw_tree_property_t *property;
+	
+	void *device;				/**< Member used solely by the kernel. */
 };
 
Index: kernel/arch/sparc64/include/drivers/fhc.h
===================================================================
--- kernel/arch/sparc64/include/drivers/fhc.h	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/arch/sparc64/include/drivers/fhc.h	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -37,9 +37,15 @@
 
 #include <arch/types.h>
+#include <genarch/ofw/ofw_tree.h>
 
-extern volatile uint32_t *fhc;
+typedef struct {
+	volatile uint32_t *uart_imap;
+} fhc_t;
 
-extern void fhc_init(void);
-extern void fhc_uart_reset(void);
+extern fhc_t *central_fhc;
+
+extern fhc_t *fhc_init(ofw_tree_node_t *node);
+extern void fhc_enable_interrupt(fhc_t *fhc, int ino);
+extern void fhc_clear_interrupt(fhc_t *fhc, int ino);
 
 #endif
Index: kernel/arch/sparc64/src/drivers/fhc.c
===================================================================
--- kernel/arch/sparc64/src/drivers/fhc.c	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/arch/sparc64/src/drivers/fhc.c	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -42,27 +42,78 @@
 #include <arch/drivers/fhc.h>
 #include <arch/mm/page.h>
+#include <mm/slab.h>
 #include <arch/types.h>
 #include <typedefs.h>
-
+#include <genarch/ofw/ofw_tree.h>
 #include <genarch/kbd/z8530.h>
 
-volatile uint32_t *fhc = NULL;
+fhc_t *central_fhc = NULL;
 
-#define FHC_UART_ADDR	0x1fff8808000ULL		/* hardcoded for Simics simulation */
+/**
+ * I suspect this must be hardcoded in the FHC.
+ * If it is not, than we can read all IMAP registers
+ * and get the complete mapping.
+ */
+#define FHC_UART_INO	0x39	
 
 #define FHC_UART_IMAP	0x0
 #define FHC_UART_ICLR	0x4
 
-void fhc_init(void)
+#define UART_IMAP_REG	4
+
+fhc_t *fhc_init(ofw_tree_node_t *node)
 {
-	fhc = (void *) hw_map(FHC_UART_ADDR, PAGE_SIZE);
+	fhc_t *fhc;
+	ofw_tree_property_t *prop;
 
-	fhc[FHC_UART_ICLR] = 0;
-	fhc[FHC_UART_IMAP] = 0x80000000;
+	prop = ofw_tree_getprop(node, "reg");
+	
+	if (!prop || !prop->value)
+		return NULL;
+		
+	count_t regs = prop->size / sizeof(ofw_central_reg_t);
+	if (regs + 1 < UART_IMAP_REG)
+		return NULL;
+
+	ofw_central_reg_t *reg = &((ofw_central_reg_t *) prop->value)[UART_IMAP_REG];
+
+	uintptr_t paddr;
+	if (!ofw_central_apply_ranges(node->parent, reg, &paddr))
+		return NULL;
+
+	fhc = (fhc_t *) malloc(sizeof(fhc_t), FRAME_ATOMIC);
+	if (!fhc)
+		return NULL;
+
+	fhc->uart_imap = (uint32_t *) hw_map(paddr, reg->size);
+	
+	return fhc;
 }
 
-void fhc_uart_reset(void)
+void fhc_enable_interrupt(fhc_t *fhc, int ino)
 {
-	fhc[FHC_UART_ICLR] = 0;
+	switch (ino) {
+	case FHC_UART_INO:
+		fhc->uart_imap[FHC_UART_ICLR] = 0x0;
+		fhc->uart_imap[FHC_UART_IMAP] = 0x80000000;
+		break;
+	default:
+		panic("Unexpected INO (%d)\n", ino);
+		break;
+	}
+}
+
+void fhc_clear_interrupt(fhc_t *fhc, int ino)
+{
+	ASSERT(fhc->uart_imap);
+
+	switch (ino) {
+	case FHC_UART_INO:
+		fhc->uart_imap[FHC_UART_ICLR] = 0;
+		break;
+	default:
+		panic("Unexpected INO (%d)\n", ino);
+		break;
+	}
 }
 
Index: kernel/arch/sparc64/src/drivers/kbd.c
===================================================================
--- kernel/arch/sparc64/src/drivers/kbd.c	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/arch/sparc64/src/drivers/kbd.c	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -69,4 +69,7 @@
 	name = ofw_tree_node_name(node);
 	
+	/*
+	 * Determine keyboard serial controller type.
+	 */
 	if (strcmp(name, "zs") == 0)
 		kbd_type = KBD_Z8530;
@@ -79,10 +82,23 @@
 	}
 	
+	/*
+	 * Read 'interrupts' property.
+	 */
+	uint32_t interrupts;
+	prop = ofw_tree_getprop(node, "interrupts");
+	if (!prop || !prop->value)
+		panic("Can't find \"interrupts\" property.\n");
+	interrupts = *((uint32_t *) prop->value);
+
+	/*
+	 * Read 'reg' property.
+	 */
 	prop = ofw_tree_getprop(node, "reg");
-	if (!prop)
+	if (!prop || !prop->value)
 		panic("Can't find \"reg\" property.\n");
 	
 	uintptr_t pa;
 	size_t size;
+	int ino;
 	
 	switch (kbd_type) {
@@ -93,4 +109,8 @@
 			return;
 		}
+		if (!ofw_fhc_map_interrupts(node->parent, ((ofw_fhc_reg_t *) prop->value), interrupts, &ino)) {
+			printf("Failed to determine keyboard interrupts.\n");
+			return;
+		}
 		break;
 	case KBD_NS16550:
@@ -98,4 +118,8 @@
 		if (!ofw_ebus_apply_ranges(node->parent, ((ofw_ebus_reg_t *) prop->value) , &pa)) {
 			printf("Failed to determine keyboard address.\n");
+			return;
+		}
+		if (!ofw_ebus_map_interrupts(node->parent, ((ofw_ebus_reg_t *) prop->value), interrupts, &ino)) {
+			printf("Failed to determine keyboard interrupts.\n");
 			return;
 		}
Index: kernel/arch/sparc64/src/trap/interrupt.c
===================================================================
--- kernel/arch/sparc64/src/trap/interrupt.c	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/arch/sparc64/src/trap/interrupt.c	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -97,5 +97,5 @@
 		else
 			ipc_irq_send_notif(0);
-		fhc_uart_reset();
+		fhc_clear_interrupt(central_fhc, data0);
 		break;
 
Index: kernel/genarch/include/ofw/ofw_tree.h
===================================================================
--- kernel/genarch/include/ofw/ofw_tree.h	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/genarch/include/ofw/ofw_tree.h	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -50,4 +50,10 @@
 	unsigned properties;			/**< Number of properties. */
 	ofw_tree_property_t *property;
+	
+	/**
+	 * Pointer to a structure representing respective device.
+	 * Its semantics is device dependent.
+	 */
+	void *device;
 };
 
@@ -105,6 +111,22 @@
 typedef struct ofw_ebus_range ofw_ebus_range_t;
 
+struct ofw_ebus_intr_map {
+	uint32_t space;
+	uint32_t addr;
+	uint32_t intr;
+	uint32_t controller_handle;
+	uint32_t controller_ino;
+} __attribute__ ((packed));
+typedef struct ofw_ebus_intr_map ofw_ebus_intr_map_t;
+
+struct ofw_ebus_intr_mask {
+	uint32_t space_mask;
+	uint32_t addr_mask;
+	uint32_t intr_mask;
+} __attribute__ ((packed));
+typedef struct ofw_ebus_intr_mask ofw_ebus_intr_mask_t;
+
 struct ofw_pci_reg {
-	uint32_t space;			/* needs to masked to obtain pure space id */
+	uint32_t space;			/* needs to be masked to obtain pure space id */
 	uint64_t addr;			/* group phys.mid and phys.lo together */
 	uint64_t size;
@@ -144,3 +166,6 @@
 extern bool ofw_pci_reg_absolutize(ofw_tree_node_t *node, ofw_pci_reg_t *reg, ofw_pci_reg_t *out);
 
+extern bool ofw_fhc_map_interrupts(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uint32_t interrupt, int *ino);
+extern bool ofw_ebus_map_interrupts(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uint32_t interrupt, int *ino);
+
 #endif
Index: kernel/genarch/src/kbd/z8530.c
===================================================================
--- kernel/genarch/src/kbd/z8530.c	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/genarch/src/kbd/z8530.c	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -39,5 +39,4 @@
 #include <genarch/kbd/scanc.h>
 #include <genarch/kbd/scanc_sun.h>
-#include <arch/drivers/fhc.h>
 #include <arch/drivers/z8530.h>
 #include <arch/interrupt.h>
@@ -107,12 +106,4 @@
 	
 	z8530_write_a(WR9, WR9_MIE);		/* Master Interrupt Enable. */
-	
-	/*
-	 * We need to initialize the FireHose Controller,
-	 * to which is this z8530 attached. Otherwise
-	 * interrupts generated by the z8530 would not
-	 * be forwarded to the CPU.
-	 */
-	fhc_init();
 }
 
Index: kernel/genarch/src/ofw/ebus.c
===================================================================
--- kernel/genarch/src/ofw/ebus.c	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/genarch/src/ofw/ebus.c	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -40,4 +40,5 @@
 #include <func.h>
 #include <panic.h>
+#include <debug.h>
 #include <macros.h>
 
@@ -74,4 +75,50 @@
 }
 
+bool ofw_ebus_map_interrupts(ofw_tree_node_t *node, ofw_ebus_reg_t *reg, uint32_t interrupt, int *ino)
+{
+	ofw_tree_property_t *prop;
+	ofw_tree_node_t *controller;
+	
+	prop = ofw_tree_getprop(node, "interrupt-map");
+	if (!prop || !prop->value)
+		return false;
+
+	ofw_ebus_intr_map_t *intr_map = prop->value;
+	count_t count = prop->size / sizeof(ofw_ebus_intr_map_t);
+	
+	ASSERT(count);
+	
+	prop = ofw_tree_getprop(node, "interrupt-map-mask");
+	if (!prop || !prop->value)
+		return false;
+	
+	ofw_ebus_intr_mask_t *intr_mask = prop->value;
+	
+	ASSERT(prop->size == sizeof(ofw_ebus_intr_mask_t));
+	
+	uint32_t space = reg->space & intr_mask->space_mask;
+	uint32_t addr = reg->addr & intr_mask->addr_mask;
+	uint32_t intr = interrupt & intr_mask->intr_mask;
+	
+	int i;
+	for (i = 0; i < count; i++) {
+		if ((intr_map[i].space == space) && (intr_map[i].addr == addr)
+			&& (intr_map[i].intr == intr))
+			goto found;
+	}
+	return false;
+
+found:
+	/*
+	 * We found the device that functions as an interrupt controller
+	 * for the interrupt. We also found mapping from interrupt to INO.
+	 */
+
+	controller = ofw_tree_find_node_by_handle(ofw_tree_lookup("/"), intr_map[i].controller_handle);
+	
+	*ino = intr_map[i].controller_ino;
+	return true;
+}
+
 /** @}
  */
Index: kernel/genarch/src/ofw/fhc.c
===================================================================
--- kernel/genarch/src/ofw/fhc.c	(revision 36db5ac1d5864f5e63a519565d7d97f7fc18c184)
+++ kernel/genarch/src/ofw/fhc.c	(revision 0b414b5bfb083f200dcb33bd41d7b8a75f79142e)
@@ -37,4 +37,5 @@
 
 #include <genarch/ofw/ofw_tree.h>
+#include <arch/drivers/fhc.h>
 #include <arch/memstr.h>
 #include <func.h>
@@ -109,4 +110,24 @@
 }
 
+bool ofw_fhc_map_interrupts(ofw_tree_node_t *node, ofw_fhc_reg_t *reg, uint32_t interrupt, int *ino)
+{
+	fhc_t *fhc = NULL;
+	if (!node->device) {
+		fhc = fhc_init(node);
+		if (!fhc)
+			return false;
+		node->device = fhc;
+		central_fhc = fhc;
+	}
+	
+	/*
+	 * The interrupt controller for the interrupt is the FHC itself.
+	 */
+	fhc_enable_interrupt(fhc, interrupt);
+	
+	*ino = interrupt;
+	return true;
+}
+
 /** @}
  */
