Index: boot/arch/amd64/Makefile.inc
===================================================================
--- boot/arch/amd64/Makefile.inc	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ boot/arch/amd64/Makefile.inc	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -30,5 +30,7 @@
 
 RD_SRVS_ESSENTIAL += \
-	$(USPACE_PATH)/srv/hw/char/i8042/i8042
+	$(USPACE_PATH)/srv/hw/char/i8042/i8042 \
+	$(USPACE_PATH)/srv/hw/irc/apic/apic \
+	$(USPACE_PATH)/srv/hw/irc/i8259/i8259
 
 RD_SRVS_NON_ESSENTIAL += \
@@ -41,5 +43,5 @@
 	isa \
 	ns8250
-	
+
 RD_DRV_CFG += \
 	isa/isa.dev
Index: boot/arch/sparc64/Makefile.inc
===================================================================
--- boot/arch/sparc64/Makefile.inc	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ boot/arch/sparc64/Makefile.inc	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -43,6 +43,6 @@
 
 RD_SRVS_ESSENTIAL += \
-	$(USPACE_PATH)/srv/hw/cir/fhc/fhc \
-	$(USPACE_PATH)/srv/hw/cir/obio/obio
+	$(USPACE_PATH)/srv/hw/irc/fhc/fhc \
+	$(USPACE_PATH)/srv/hw/irc/obio/obio
 
 SOURCES = \
Index: kernel/arch/amd64/include/interrupt.h
===================================================================
--- kernel/arch/amd64/include/interrupt.h	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/amd64/include/interrupt.h	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -74,4 +74,5 @@
 extern void (* enable_irqs_function)(uint16_t);
 extern void (* eoi_function)(void);
+extern const char *irqs_info;
 
 extern void interrupt_init(void);
Index: kernel/arch/amd64/src/amd64.c
===================================================================
--- kernel/arch/amd64/src/amd64.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/amd64/src/amd64.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -235,8 +235,7 @@
 #endif
 	
-	/*
-	 * This nasty hack should also go away ASAP.
-	 */
-	trap_virtual_enable_irqs(1 << IRQ_DP8390);
+	if (irqs_info != NULL)
+		sysinfo_set_item_val(irqs_info, NULL, true);
+	
 	sysinfo_set_item_val("netif.dp8390.inr", NULL, IRQ_DP8390);
 }
Index: kernel/arch/amd64/src/interrupt.c
===================================================================
--- kernel/arch/amd64/src/interrupt.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/amd64/src/interrupt.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -62,4 +62,5 @@
 void (* enable_irqs_function)(uint16_t irqmask) = NULL;
 void (* eoi_function)(void) = NULL;
+const char *irqs_info = NULL;
 
 void istate_decode(istate_t *istate)
Index: kernel/arch/ia32/include/interrupt.h
===================================================================
--- kernel/arch/ia32/include/interrupt.h	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/ia32/include/interrupt.h	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -74,4 +74,5 @@
 extern void (* enable_irqs_function)(uint16_t);
 extern void (* eoi_function)(void);
+extern const char *irqs_info;
 
 extern void interrupt_init(void);
Index: kernel/arch/ia32/src/drivers/i8259.c
===================================================================
--- kernel/arch/ia32/src/drivers/i8259.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/ia32/src/drivers/i8259.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -86,4 +86,5 @@
 	disable_irqs_function = pic_disable_irqs;
 	eoi_function = pic_eoi;
+	irqs_info = "i8259";
 
 	pic_disable_irqs(0xffff);		/* disable all irq's */
Index: kernel/arch/ia32/src/ia32.c
===================================================================
--- kernel/arch/ia32/src/ia32.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/ia32/src/ia32.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -193,8 +193,7 @@
 #endif
 	
-	/*
-	 * This nasty hack should also go away ASAP.
-	 */
-	trap_virtual_enable_irqs(1 << IRQ_DP8390);
+	if (irqs_info != NULL)
+		sysinfo_set_item_val(irqs_info, NULL, true);
+	
 	sysinfo_set_item_val("netif.dp8390.inr", NULL, IRQ_DP8390);
 }
Index: kernel/arch/ia32/src/interrupt.c
===================================================================
--- kernel/arch/ia32/src/interrupt.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/ia32/src/interrupt.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -62,4 +62,5 @@
 void (* enable_irqs_function)(uint16_t irqmask) = NULL;
 void (* eoi_function)(void) = NULL;
+const char *irqs_info = NULL;
 
 void istate_decode(istate_t *istate)
Index: kernel/arch/ia32/src/smp/apic.c
===================================================================
--- kernel/arch/ia32/src/smp/apic.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ kernel/arch/ia32/src/smp/apic.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -178,4 +178,5 @@
 	disable_irqs_function = io_apic_disable_irqs;
 	eoi_function = l_apic_eoi;
+	irqs_info = "apic";
 	
 	/*
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ uspace/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -108,15 +108,21 @@
 
 ifeq ($(UARCH),amd64)
-	DIRS += drv/rootpc
-	DIRS += drv/pciintel
-	DIRS += drv/isa
-	DIRS += drv/ns8250
+	DIRS += \
+		drv/rootpc \
+		drv/pciintel \
+		drv/isa \
+		drv/ns8250 \
+		srv/hw/irc/apic \
+		srv/hw/irc/i8259
 endif
 
 ifeq ($(UARCH),ia32)
-	DIRS += drv/rootpc
-	DIRS += drv/pciintel
-	DIRS += drv/isa
-	DIRS += drv/ns8250
+	DIRS += \
+		drv/rootpc \
+		drv/pciintel \
+		drv/isa \
+		drv/ns8250 \
+		srv/hw/irc/apic \
+		srv/hw/irc/i8259
 endif
 
@@ -127,6 +133,6 @@
 ifeq ($(UARCH),sparc64)
 	DIRS += \
-		srv/hw/cir/fhc \
-		srv/hw/cir/obio
+		srv/hw/irc/fhc \
+		srv/hw/irc/obio
 endif
 
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ uspace/app/init/init.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -273,4 +273,6 @@
 	mount_tmpfs();
 	
+	spawn("/srv/apic");
+	spawn("/srv/i8259");
 	spawn("/srv/fhc");
 	spawn("/srv/obio");
Index: pace/lib/c/include/ipc/bus.h
===================================================================
--- uspace/lib/c/include/ipc/bus.h	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2009 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 libcipc
- * @{
- */
-/** @file
- */ 
-
-#ifndef LIBC_BUS_H_
-#define LIBC_BUS_H_
-
-#include <ipc/ipc.h>
-
-typedef enum {
-	BUS_CLEAR_INTERRUPT = IPC_FIRST_USER_METHOD
-} bus_request_t;
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/ipc/irc.h
===================================================================
--- uspace/lib/c/include/ipc/irc.h	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/lib/c/include/ipc/irc.h	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009 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 libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IRC_H_
+#define LIBC_IRC_H_
+
+#include <ipc/ipc.h>
+
+typedef enum {
+	IRC_ENABLE_INTERRUPT = IPC_FIRST_USER_METHOD,
+	IRC_CLEAR_INTERRUPT
+} irc_request_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ uspace/lib/c/include/ipc/services.h	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -49,4 +49,6 @@
 	SERVICE_FHC,
 	SERVICE_OBIO,
+	SERVICE_APIC,
+	SERVICE_I8259,
 	SERVICE_CLIPBOARD,
 	SERVICE_NETWORKING,
Index: uspace/srv/hid/kbd/port/ns16550.c
===================================================================
--- uspace/srv/hid/kbd/port/ns16550.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ uspace/srv/hid/kbd/port/ns16550.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -36,5 +36,5 @@
 
 #include <ipc/ipc.h>
-#include <ipc/bus.h>
+#include <ipc/irc.h>
 #include <async.h>
 #include <sysinfo.h>
@@ -122,5 +122,5 @@
 	
 	if (cir_service)
-		async_msg_1(cir_phone, BUS_CLEAR_INTERRUPT,
+		async_msg_1(cir_phone, IRC_CLEAR_INTERRUPT,
 		    IPC_GET_IMETHOD(*call));
 }
Index: uspace/srv/hid/kbd/port/z8530.c
===================================================================
--- uspace/srv/hid/kbd/port/z8530.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ uspace/srv/hid/kbd/port/z8530.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -36,5 +36,5 @@
 
 #include <ipc/ipc.h>
-#include <ipc/bus.h>
+#include <ipc/irc.h>
 #include <async.h>
 #include <sysinfo.h>
@@ -110,5 +110,5 @@
 	
 	if (cir_service)
-		async_msg_1(cir_phone, BUS_CLEAR_INTERRUPT,
+		async_msg_1(cir_phone, IRC_CLEAR_INTERRUPT,
 		    IPC_GET_IMETHOD(*call));
 }
Index: pace/srv/hw/cir/fhc/Makefile
===================================================================
--- uspace/srv/hw/cir/fhc/Makefile	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 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.
-#
-
-USPACE_PREFIX = ../../../..
-BINARY = fhc
-
-SOURCES = \
-	fhc.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/srv/hw/cir/fhc/fhc.c
===================================================================
--- uspace/srv/hw/cir/fhc/fhc.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ 	(revision )
@@ -1,157 +1,0 @@
-/*
- * Copyright (c) 2009 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 fhc
- * @{
- */ 
-
-/**
- * @file	fhc.c
- * @brief	FHC bus controller driver.
- */
-
-#include <ipc/ipc.h>
-#include <ipc/services.h>
-#include <ipc/bus.h>
-#include <ipc/ns.h>
-#include <sysinfo.h>
-#include <as.h>
-#include <ddi.h>
-#include <align.h>
-#include <bool.h>
-#include <errno.h>
-#include <async.h>
-#include <align.h>
-#include <async.h>
-#include <stdio.h>
-#include <ipc/devmap.h>
-
-#define NAME "fhc"
-
-#define FHC_UART_INR	0x39	
-
-#define FHC_UART_IMAP	0x0
-#define FHC_UART_ICLR	0x4
-
-static void *fhc_uart_phys;
-static volatile uint32_t *fhc_uart_virt;
-static size_t fhc_uart_size;
-
-/** Handle one connection to fhc.
- *
- * @param iid		Hash of the request that opened the connection.
- * @param icall		Call data of the request that opened the connection.
- */
-static void fhc_connection(ipc_callid_t iid, ipc_call_t *icall)
-{
-	ipc_callid_t callid;
-	ipc_call_t call;
-
-	/*
-	 * Answer the first IPC_M_CONNECT_ME_TO call.
-	 */
-	ipc_answer_0(iid, EOK);
-
-	while (1) {
-		int inr;
-	
-		callid = async_get_call(&call);
-		switch (IPC_GET_IMETHOD(call)) {
-		case BUS_CLEAR_INTERRUPT:
-			inr = IPC_GET_ARG1(call);
-			switch (inr) {
-			case FHC_UART_INR:
-				fhc_uart_virt[FHC_UART_ICLR] = 0;
-				ipc_answer_0(callid, EOK);
-				break;
-			default:
-				ipc_answer_0(callid, ENOTSUP);
-				break;
-			}
-			break;
-		default:
-			ipc_answer_0(callid, EINVAL);
-			break;
-		}
-	}
-}
-
-/** Initialize the FHC driver.
- *
- * So far, the driver heavily depends on information provided by the kernel via
- * sysinfo. In the future, there should be a standalone FHC driver.
- */
-static bool fhc_init(void)
-{
-	sysarg_t paddr;
-
-	if ((sysinfo_get_value("fhc.uart.physical", &paddr) != EOK)
-	    || (sysinfo_get_value("fhc.uart.size", &fhc_uart_size) != EOK)) {
-		printf(NAME ": no FHC UART registers found\n");
-		return false;
-	}
-	
-	fhc_uart_phys = (void *) paddr;
-	fhc_uart_virt = as_get_mappable_page(fhc_uart_size);
-	
-	int flags = AS_AREA_READ | AS_AREA_WRITE;
-	int retval = physmem_map(fhc_uart_phys, (void *) fhc_uart_virt,
-	    ALIGN_UP(fhc_uart_size, PAGE_SIZE) >> PAGE_WIDTH, flags);
-	
-	if (retval < 0) {
-		printf(NAME ": Error mapping FHC UART registers\n");
-		return false;
-	}
-	
-	printf(NAME ": FHC UART registers at %p, %zu bytes\n", fhc_uart_phys,
-	    fhc_uart_size);
-	
-	async_set_client_connection(fhc_connection);
-	sysarg_t phonead;
-	ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, &phonead);
-	
-	return true;
-}
-
-int main(int argc, char **argv)
-{
-	printf(NAME ": HelenOS FHC bus controller driver\n");
-	
-	if (!fhc_init())
-		return -1;
-	
-	printf(NAME ": Accepting connections\n");
-	async_manager();
-
-	/* Never reached */
-	return 0;
-}
-
-/**
- * @}
- */ 
Index: pace/srv/hw/cir/obio/Makefile
===================================================================
--- uspace/srv/hw/cir/obio/Makefile	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 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.
-#
-
-USPACE_PREFIX = ../../../..
-BINARY = obio
-
-SOURCES = \
-	obio.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/srv/hw/cir/obio/obio.c
===================================================================
--- uspace/srv/hw/cir/obio/obio.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ 	(revision )
@@ -1,158 +1,0 @@
-/*
- * Copyright (c) 2009 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 obio 
- * @{
- */ 
-
-/**
- * @file	obio.c
- * @brief	OBIO driver.
- *
- * OBIO is a short for on-board I/O. On UltraSPARC IIi and systems with U2P,
- * there is a piece of the root PCI bus controller address space, which
- * contains interrupt mapping and clear registers for all on-board devices.
- * Although UltraSPARC IIi and U2P are different in general, these registers can
- * be found at the same addresses.
- */
-
-#include <ipc/ipc.h>
-#include <ipc/services.h>
-#include <ipc/bus.h>
-#include <ipc/ns.h>
-#include <sysinfo.h>
-#include <as.h>
-#include <ddi.h>
-#include <align.h>
-#include <bool.h>
-#include <errno.h>
-#include <async.h>
-#include <align.h>
-#include <async.h>
-#include <stdio.h>
-#include <ipc/devmap.h>
-
-#define NAME "obio"
-
-#define OBIO_SIZE	0x1898	
-
-#define OBIO_IMR_BASE	0x200
-#define OBIO_IMR(ino)	(OBIO_IMR_BASE + ((ino) & INO_MASK))
-
-#define OBIO_CIR_BASE	0x300
-#define OBIO_CIR(ino)	(OBIO_CIR_BASE + ((ino) & INO_MASK))
-
-#define INO_MASK	0x1f
-
-static void *base_phys;
-static volatile uint64_t *base_virt;
-
-/** Handle one connection to obio.
- *
- * @param iid		Hash of the request that opened the connection.
- * @param icall		Call data of the request that opened the connection.
- */
-static void obio_connection(ipc_callid_t iid, ipc_call_t *icall)
-{
-	ipc_callid_t callid;
-	ipc_call_t call;
-
-	/*
-	 * Answer the first IPC_M_CONNECT_ME_TO call.
-	 */
-	ipc_answer_0(iid, EOK);
-
-	while (1) {
-		int inr;
-	
-		callid = async_get_call(&call);
-		switch (IPC_GET_IMETHOD(call)) {
-		case BUS_CLEAR_INTERRUPT:
-			inr = IPC_GET_ARG1(call);
-			base_virt[OBIO_CIR(inr & INO_MASK)] = 0;
-			ipc_answer_0(callid, EOK);
-			break;
-		default:
-			ipc_answer_0(callid, EINVAL);
-			break;
-		}
-	}
-}
-
-/** Initialize the OBIO driver.
- *
- * So far, the driver heavily depends on information provided by the kernel via
- * sysinfo. In the future, there should be a standalone OBIO driver.
- */
-static bool obio_init(void)
-{
-	sysarg_t paddr;
-	
-	if (sysinfo_get_value("obio.base.physical", &paddr) != EOK) {
-		printf(NAME ": no OBIO registers found\n");
-		return false;
-	}
-	
-	base_phys = (void *) paddr;
-	base_virt = as_get_mappable_page(OBIO_SIZE);
-	
-	int flags = AS_AREA_READ | AS_AREA_WRITE;
-	int retval = physmem_map(base_phys, (void *) base_virt,
-	    ALIGN_UP(OBIO_SIZE, PAGE_SIZE) >> PAGE_WIDTH, flags);
-	
-	if (retval < 0) {
-		printf(NAME ": Error mapping OBIO registers\n");
-		return false;
-	}
-	
-	printf(NAME ": OBIO registers with base at %p\n", base_phys);
-	
-	async_set_client_connection(obio_connection);
-	sysarg_t phonead;
-	ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, &phonead);
-	
-	return true;
-}
-
-int main(int argc, char **argv)
-{
-	printf(NAME ": HelenOS OBIO driver\n");
-	
-	if (!obio_init())
-		return -1;
-	
-	printf(NAME ": Accepting connections\n");
-	async_manager();
-
-	/* Never reached */
-	return 0;
-}
-
-/**
- * @}
- */ 
Index: uspace/srv/hw/irc/apic/Makefile
===================================================================
--- uspace/srv/hw/irc/apic/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/apic/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2011 Martin Decky
+# 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.
+#
+
+USPACE_PREFIX = ../../../..
+BINARY = apic
+
+SOURCES = \
+	apic.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/hw/irc/apic/apic.c
===================================================================
--- uspace/srv/hw/irc/apic/apic.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/apic/apic.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * 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 apic
+ * @{
+ */
+
+/**
+ * @file apic.c
+ * @brief APIC driver.
+ */
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <ipc/irc.h>
+#include <ipc/ns.h>
+#include <sysinfo.h>
+#include <as.h>
+#include <ddi.h>
+#include <libarch/ddi.h>
+#include <align.h>
+#include <bool.h>
+#include <errno.h>
+#include <async.h>
+#include <align.h>
+#include <async.h>
+#include <stdio.h>
+#include <ipc/devmap.h>
+
+#define NAME  "apic"
+
+static int apic_enable_irq(sysarg_t irq)
+{
+	// FIXME: TODO
+	return ENOTSUP;
+}
+
+/** Handle one connection to APIC.
+ *
+ * @param iid   Hash of the request that opened the connection.
+ * @param icall Call data of the request that opened the connection.
+ *
+ */
+static void apic_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	ipc_callid_t callid;
+	ipc_call_t call;
+	
+	/*
+	 * Answer the first IPC_M_CONNECT_ME_TO call.
+	 */
+	ipc_answer_0(iid, EOK);
+	
+	while (true) {
+		callid = async_get_call(&call);
+		
+		switch (IPC_GET_IMETHOD(call)) {
+		case IRC_ENABLE_INTERRUPT:
+			ipc_answer_0(callid, apic_enable_irq(IPC_GET_ARG1(call)));
+			break;
+		case IRC_CLEAR_INTERRUPT:
+			/* Noop */
+			ipc_answer_0(callid, EOK);
+			break;
+		default:
+			ipc_answer_0(callid, EINVAL);
+			break;
+		}
+	}
+}
+
+/** Initialize the APIC driver.
+ *
+ */
+static bool apic_init(void)
+{
+	sysarg_t apic;
+	
+	if ((sysinfo_get_value("apic", &apic) != EOK) || (!apic)) {
+		printf(NAME ": No APIC found\n");
+		return false;
+	}
+	
+	async_set_client_connection(apic_connection);
+	sysarg_t phonead;
+	ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, &phonead);
+	
+	return true;
+}
+
+int main(int argc, char **argv)
+{
+	printf(NAME ": HelenOS APIC driver\n");
+	
+	if (!apic_init())
+		return -1;
+	
+	printf(NAME ": Accepting connections\n");
+	async_manager();
+	
+	/* Never reached */
+	return 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/srv/hw/irc/fhc/Makefile
===================================================================
--- uspace/srv/hw/irc/fhc/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/fhc/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 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.
+#
+
+USPACE_PREFIX = ../../../..
+BINARY = fhc
+
+SOURCES = \
+	fhc.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/hw/irc/fhc/fhc.c
===================================================================
--- uspace/srv/hw/irc/fhc/fhc.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/fhc/fhc.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2009 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 fhc
+ * @{
+ */ 
+
+/**
+ * @file	fhc.c
+ * @brief	FHC bus controller driver.
+ */
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <ipc/irc.h>
+#include <ipc/ns.h>
+#include <sysinfo.h>
+#include <as.h>
+#include <ddi.h>
+#include <align.h>
+#include <bool.h>
+#include <errno.h>
+#include <async.h>
+#include <align.h>
+#include <async.h>
+#include <stdio.h>
+#include <ipc/devmap.h>
+
+#define NAME "fhc"
+
+#define FHC_UART_INR	0x39	
+
+#define FHC_UART_IMAP	0x0
+#define FHC_UART_ICLR	0x4
+
+static void *fhc_uart_phys;
+static volatile uint32_t *fhc_uart_virt;
+static size_t fhc_uart_size;
+
+/** Handle one connection to fhc.
+ *
+ * @param iid		Hash of the request that opened the connection.
+ * @param icall		Call data of the request that opened the connection.
+ */
+static void fhc_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	ipc_callid_t callid;
+	ipc_call_t call;
+
+	/*
+	 * Answer the first IPC_M_CONNECT_ME_TO call.
+	 */
+	ipc_answer_0(iid, EOK);
+
+	while (1) {
+		int inr;
+	
+		callid = async_get_call(&call);
+		switch (IPC_GET_IMETHOD(call)) {
+		case IRC_ENABLE_INTERRUPT:
+			/* Noop */
+			ipc_answer_0(callid, EOK);
+			break;
+		case IRC_CLEAR_INTERRUPT:
+			inr = IPC_GET_ARG1(call);
+			switch (inr) {
+			case FHC_UART_INR:
+				fhc_uart_virt[FHC_UART_ICLR] = 0;
+				ipc_answer_0(callid, EOK);
+				break;
+			default:
+				ipc_answer_0(callid, ENOTSUP);
+				break;
+			}
+			break;
+		default:
+			ipc_answer_0(callid, EINVAL);
+			break;
+		}
+	}
+}
+
+/** Initialize the FHC driver.
+ *
+ * So far, the driver heavily depends on information provided by the kernel via
+ * sysinfo. In the future, there should be a standalone FHC driver.
+ */
+static bool fhc_init(void)
+{
+	sysarg_t paddr;
+
+	if ((sysinfo_get_value("fhc.uart.physical", &paddr) != EOK)
+	    || (sysinfo_get_value("fhc.uart.size", &fhc_uart_size) != EOK)) {
+		printf(NAME ": no FHC UART registers found\n");
+		return false;
+	}
+	
+	fhc_uart_phys = (void *) paddr;
+	fhc_uart_virt = as_get_mappable_page(fhc_uart_size);
+	
+	int flags = AS_AREA_READ | AS_AREA_WRITE;
+	int retval = physmem_map(fhc_uart_phys, (void *) fhc_uart_virt,
+	    ALIGN_UP(fhc_uart_size, PAGE_SIZE) >> PAGE_WIDTH, flags);
+	
+	if (retval < 0) {
+		printf(NAME ": Error mapping FHC UART registers\n");
+		return false;
+	}
+	
+	printf(NAME ": FHC UART registers at %p, %zu bytes\n", fhc_uart_phys,
+	    fhc_uart_size);
+	
+	async_set_client_connection(fhc_connection);
+	sysarg_t phonead;
+	ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, &phonead);
+	
+	return true;
+}
+
+int main(int argc, char **argv)
+{
+	printf(NAME ": HelenOS FHC bus controller driver\n");
+	
+	if (!fhc_init())
+		return -1;
+	
+	printf(NAME ": Accepting connections\n");
+	async_manager();
+
+	/* Never reached */
+	return 0;
+}
+
+/**
+ * @}
+ */ 
Index: uspace/srv/hw/irc/i8259/Makefile
===================================================================
--- uspace/srv/hw/irc/i8259/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/i8259/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,35 @@
+#
+# Copyright (c) 2011 Martin Decky
+# 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.
+#
+
+USPACE_PREFIX = ../../../..
+BINARY = i8259
+
+SOURCES = \
+	i8259.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/hw/irc/i8259/i8259.c
===================================================================
--- uspace/srv/hw/irc/i8259/i8259.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/i8259/i8259.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * 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 i8259
+ * @{
+ */
+
+/**
+ * @file i8259.c
+ * @brief i8259 driver.
+ */
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <ipc/irc.h>
+#include <ipc/ns.h>
+#include <sysinfo.h>
+#include <as.h>
+#include <ddi.h>
+#include <libarch/ddi.h>
+#include <align.h>
+#include <bool.h>
+#include <errno.h>
+#include <async.h>
+#include <align.h>
+#include <async.h>
+#include <stdio.h>
+#include <ipc/devmap.h>
+
+#define NAME  "i8259"
+
+#define IO_RANGE0_START  ((ioport8_t *) 0x0020U)
+#define IO_RANGE0_SIZE   2
+
+#define IO_RANGE1_START  ((ioport8_t *) 0x00a0U)
+#define IO_RANGE1_SIZE   2
+
+static ioport8_t *io_range0;
+static ioport8_t *io_range1;
+
+#define PIC_PIC0PORT1  0
+#define PIC_PIC0PORT2  1
+
+#define PIC_PIC1PORT1  0
+#define PIC_PIC1PORT2  1
+
+#define PIC_MAX_IRQ  15
+
+static int pic_enable_irq(sysarg_t irq)
+{
+	if (irq > PIC_MAX_IRQ)
+		return ENOENT;
+	
+	uint16_t irqmask = 1 << irq;
+	uint8_t val;
+	
+	if (irqmask & 0xff) {
+		val = pio_read_8(io_range0 + PIC_PIC0PORT2);
+		pio_write_8(io_range0 + PIC_PIC0PORT2,
+		    (uint8_t) (val & (~(irqmask & 0xff))));
+	}
+	
+	if (irqmask >> 8) {
+		val = pio_read_8(io_range1 + PIC_PIC1PORT2);
+		pio_write_8(io_range1 + PIC_PIC1PORT2,
+		    (uint8_t) (val & (~(irqmask >> 8))));
+	}
+	
+	return EOK;
+}
+
+/** Handle one connection to i8259.
+ *
+ * @param iid   Hash of the request that opened the connection.
+ * @param icall Call data of the request that opened the connection.
+ *
+ */
+static void i8259_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	ipc_callid_t callid;
+	ipc_call_t call;
+	
+	/*
+	 * Answer the first IPC_M_CONNECT_ME_TO call.
+	 */
+	ipc_answer_0(iid, EOK);
+	
+	while (true) {
+		callid = async_get_call(&call);
+		
+		switch (IPC_GET_IMETHOD(call)) {
+		case IRC_ENABLE_INTERRUPT:
+			ipc_answer_0(callid, pic_enable_irq(IPC_GET_ARG1(call)));
+			break;
+		case IRC_CLEAR_INTERRUPT:
+			/* Noop */
+			ipc_answer_0(callid, EOK);
+			break;
+		default:
+			ipc_answer_0(callid, EINVAL);
+			break;
+		}
+	}
+}
+
+/** Initialize the i8259 driver.
+ *
+ */
+static bool i8259_init(void)
+{
+	sysarg_t i8259;
+	
+	if ((sysinfo_get_value("i8259", &i8259) != EOK) || (!i8259)) {
+		printf(NAME ": No i8259 found\n");
+		return false;
+	}
+	
+	if ((pio_enable((void *) IO_RANGE0_START, IO_RANGE0_SIZE,
+	    (void **) &io_range0) != EOK) ||
+	    (pio_enable((void *) IO_RANGE1_START, IO_RANGE1_SIZE,
+	    (void **) &io_range1) != EOK)) {
+		printf(NAME ": i8259 not accessible\n");
+		return false;
+	}
+	
+	async_set_client_connection(i8259_connection);
+	sysarg_t phonead;
+	ipc_connect_to_me(PHONE_NS, SERVICE_I8259, 0, 0, &phonead);
+	
+	return true;
+}
+
+int main(int argc, char **argv)
+{
+	printf(NAME ": HelenOS i8259 driver\n");
+	
+	if (!i8259_init())
+		return -1;
+	
+	printf(NAME ": Accepting connections\n");
+	async_manager();
+	
+	/* Never reached */
+	return 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/srv/hw/irc/obio/Makefile
===================================================================
--- uspace/srv/hw/irc/obio/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/obio/Makefile	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 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.
+#
+
+USPACE_PREFIX = ../../../..
+BINARY = obio
+
+SOURCES = \
+	obio.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/hw/irc/obio/obio.c
===================================================================
--- uspace/srv/hw/irc/obio/obio.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
+++ uspace/srv/hw/irc/obio/obio.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2009 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 obio 
+ * @{
+ */ 
+
+/**
+ * @file	obio.c
+ * @brief	OBIO driver.
+ *
+ * OBIO is a short for on-board I/O. On UltraSPARC IIi and systems with U2P,
+ * there is a piece of the root PCI bus controller address space, which
+ * contains interrupt mapping and clear registers for all on-board devices.
+ * Although UltraSPARC IIi and U2P are different in general, these registers can
+ * be found at the same addresses.
+ */
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <ipc/irc.h>
+#include <ipc/ns.h>
+#include <sysinfo.h>
+#include <as.h>
+#include <ddi.h>
+#include <align.h>
+#include <bool.h>
+#include <errno.h>
+#include <async.h>
+#include <align.h>
+#include <async.h>
+#include <stdio.h>
+#include <ipc/devmap.h>
+
+#define NAME "obio"
+
+#define OBIO_SIZE	0x1898	
+
+#define OBIO_IMR_BASE	0x200
+#define OBIO_IMR(ino)	(OBIO_IMR_BASE + ((ino) & INO_MASK))
+
+#define OBIO_CIR_BASE	0x300
+#define OBIO_CIR(ino)	(OBIO_CIR_BASE + ((ino) & INO_MASK))
+
+#define INO_MASK	0x1f
+
+static void *base_phys;
+static volatile uint64_t *base_virt;
+
+/** Handle one connection to obio.
+ *
+ * @param iid		Hash of the request that opened the connection.
+ * @param icall		Call data of the request that opened the connection.
+ */
+static void obio_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	ipc_callid_t callid;
+	ipc_call_t call;
+
+	/*
+	 * Answer the first IPC_M_CONNECT_ME_TO call.
+	 */
+	ipc_answer_0(iid, EOK);
+
+	while (1) {
+		int inr;
+	
+		callid = async_get_call(&call);
+		switch (IPC_GET_IMETHOD(call)) {
+		case IRC_ENABLE_INTERRUPT:
+			/* Noop */
+			ipc_answer_0(callid, EOK);
+			break;
+		case IRC_CLEAR_INTERRUPT:
+			inr = IPC_GET_ARG1(call);
+			base_virt[OBIO_CIR(inr & INO_MASK)] = 0;
+			ipc_answer_0(callid, EOK);
+			break;
+		default:
+			ipc_answer_0(callid, EINVAL);
+			break;
+		}
+	}
+}
+
+/** Initialize the OBIO driver.
+ *
+ * So far, the driver heavily depends on information provided by the kernel via
+ * sysinfo. In the future, there should be a standalone OBIO driver.
+ */
+static bool obio_init(void)
+{
+	sysarg_t paddr;
+	
+	if (sysinfo_get_value("obio.base.physical", &paddr) != EOK) {
+		printf(NAME ": no OBIO registers found\n");
+		return false;
+	}
+	
+	base_phys = (void *) paddr;
+	base_virt = as_get_mappable_page(OBIO_SIZE);
+	
+	int flags = AS_AREA_READ | AS_AREA_WRITE;
+	int retval = physmem_map(base_phys, (void *) base_virt,
+	    ALIGN_UP(OBIO_SIZE, PAGE_SIZE) >> PAGE_WIDTH, flags);
+	
+	if (retval < 0) {
+		printf(NAME ": Error mapping OBIO registers\n");
+		return false;
+	}
+	
+	printf(NAME ": OBIO registers with base at %p\n", base_phys);
+	
+	async_set_client_connection(obio_connection);
+	sysarg_t phonead;
+	ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, &phonead);
+	
+	return true;
+}
+
+int main(int argc, char **argv)
+{
+	printf(NAME ": HelenOS OBIO driver\n");
+	
+	if (!obio_init())
+		return -1;
+	
+	printf(NAME ": Accepting connections\n");
+	async_manager();
+
+	/* Never reached */
+	return 0;
+}
+
+/**
+ * @}
+ */ 
Index: uspace/srv/hw/netif/dp8390/dp8390_module.c
===================================================================
--- uspace/srv/hw/netif/dp8390/dp8390_module.c	(revision b404a98258ad59f7e2c9104938c667be48547dca)
+++ uspace/srv/hw/netif/dp8390/dp8390_module.c	(revision acc7ce4f9be635e9051884b563142089f38803c4)
@@ -41,6 +41,8 @@
 #include <err.h>
 #include <malloc.h>
+#include <sysinfo.h>
 #include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <ipc/irc.h>
 #include <net/modules.h>
 #include <packet_client.h>
@@ -71,4 +73,7 @@
  */
 #define IRQ_GET_ISR(call)  ((int) IPC_GET_ARG2(call))
+
+static int irc_service = 0;
+static int irc_phone = -1;
 
 /** DP8390 kernel interrupt command sequence.
@@ -136,8 +141,11 @@
 }
 
-/** Changes the network interface state.
+/** Change the network interface state.
+ *
  *  @param[in,out] device The network interface.
- *  @param[in] state The new state.
- *  @returns The new state.
+ *  @param[in]     state  The new state.
+ *
+ *  @return The new state.
+ *
  */
 static int change_state(netif_device_t *device, device_state_t state)
@@ -272,5 +280,5 @@
 		return rc;
 	
-	if (device->state != NETIF_ACTIVE){
+	if (device->state != NETIF_ACTIVE) {
 		netif_pq_release(packet_get_id(packet));
 		return EFORWARD;
@@ -312,5 +320,10 @@
 		}
 		
-		return change_state(device, NETIF_ACTIVE);
+		rc = change_state(device, NETIF_ACTIVE);
+		
+		if (irc_service)
+			async_msg_1(irc_phone, IRC_ENABLE_INTERRUPT, dep->de_irq);
+		
+		return rc;
 	}
 	
@@ -334,6 +347,22 @@
 int netif_initialize(void)
 {
+	sysarg_t apic;
+	sysarg_t i8259;
+	
+	if ((sysinfo_get_value("apic", &apic) == EOK) && (apic))
+		irc_service = SERVICE_APIC;
+	else if ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))
+		irc_service = SERVICE_I8259;
+	
+	if (irc_service) {
+		while (irc_phone < 0) {
+			irc_phone = ipc_connect_me_to_blocking(PHONE_NS, irc_service,
+			    0, 0);
+		}
+	}
+	
+	async_set_interrupt_received(irq_handler);
+	
 	sysarg_t phonehash;
-	async_set_interrupt_received(irq_handler);
 	return ipc_connect_to_me(PHONE_NS, SERVICE_DP8390, 0, 0, &phonehash);
 }
