Index: kernel/generic/src/ddi/ddi.c
===================================================================
--- kernel/generic/src/ddi/ddi.c	(revision a422bc5449e8b4f17cb18f04d134a8bcaf373a4d)
+++ kernel/generic/src/ddi/ddi.c	(revision da1bafb8cf9a3b3be8ef21bc114daaa476a85190)
@@ -59,5 +59,7 @@
 static btree_t parea_btree;
 
-/** Initialize DDI. */
+/** Initialize DDI.
+ *
+ */
 void ddi_init(void)
 {
@@ -97,5 +99,6 @@
  *
  */
-static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, size_t pages, int flags)
+static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, size_t pages,
+    unsigned int flags)
 {
 	ASSERT(TASK);
@@ -114,8 +117,6 @@
 	backend_data.frames = pages;
 	
-	ipl_t ipl = interrupts_disable();
-	
 	/* Find the zone of the physical memory */
-	spinlock_lock(&zones.lock);
+	irq_spinlock_lock(&zones.lock, true);
 	size_t znum = find_zone(ADDR2PFN(pf), pages, 0);
 	
@@ -124,5 +125,5 @@
 		 * -> assume it is hardware device and allow mapping
 		 */
-		spinlock_unlock(&zones.lock);
+		irq_spinlock_unlock(&zones.lock, true);
 		goto map;
 	}
@@ -130,13 +131,14 @@
 	if (zones.info[znum].flags & ZONE_FIRMWARE) {
 		/* Frames are part of firmware */
-		spinlock_unlock(&zones.lock);
+		irq_spinlock_unlock(&zones.lock, true);
 		goto map;
 	}
 	
 	if (zone_flags_available(zones.info[znum].flags)) {
-		/* Frames are part of physical memory, check if the memory
+		/*
+		 * Frames are part of physical memory, check if the memory
 		 * region is enabled for mapping.
 		 */
-		spinlock_unlock(&zones.lock);
+		irq_spinlock_unlock(&zones.lock, true);
 		
 		mutex_lock(&parea_lock);
@@ -154,12 +156,10 @@
 	}
 	
-	spinlock_unlock(&zones.lock);
+	irq_spinlock_unlock(&zones.lock, true);
+	
 err:
-	interrupts_restore(ipl);
 	return ENOENT;
 	
 map:
-	interrupts_restore(ipl);
-
 	if (!as_area_create(TASK->as, flags, pages * PAGE_SIZE, vp,
 	    AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) {
@@ -196,6 +196,5 @@
 		return EPERM;
 	
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&tasks_lock);
+	irq_spinlock_lock(&tasks_lock, true);
 	
 	task_t *task = task_find_by_id(id);
@@ -207,17 +206,14 @@
 		 * context.
 		 */
-		spinlock_unlock(&tasks_lock);
-		interrupts_restore(ipl);
+		irq_spinlock_unlock(&tasks_lock, true);
 		return ENOENT;
 	}
 	
 	/* Lock the task and release the lock protecting tasks_btree. */
-	spinlock_lock(&task->lock);
-	spinlock_unlock(&tasks_lock);
+	irq_spinlock_exchange(&tasks_lock, &task->lock);
 	
 	int rc = ddi_iospace_enable_arch(task, ioaddr, size);
 	
-	spinlock_unlock(&task->lock);
-	interrupts_restore(ipl);
+	irq_spinlock_unlock(&task->lock, true);
 	
 	return rc;
Index: kernel/generic/src/ddi/irq.c
===================================================================
--- kernel/generic/src/ddi/irq.c	(revision a422bc5449e8b4f17cb18f04d134a8bcaf373a4d)
+++ kernel/generic/src/ddi/irq.c	(revision da1bafb8cf9a3b3be8ef21bc114daaa476a85190)
@@ -32,5 +32,5 @@
 /**
  * @file
- * @brief	IRQ dispatcher.
+ * @brief IRQ dispatcher.
  *
  * This file provides means of connecting IRQs with particular
@@ -78,20 +78,24 @@
 #include <arch.h>
 
-#define KEY_INR		0
-#define KEY_DEVNO	1
-
-/**
- * Spinlock protecting the kernel IRQ hash table.
+#define KEY_INR    0
+#define KEY_DEVNO  1
+
+/** Spinlock protecting the kernel IRQ hash table.
+ *
  * This lock must be taken only when interrupts are disabled.
- */
-SPINLOCK_INITIALIZE(irq_kernel_hash_table_lock);
+ *
+ */
+IRQ_SPINLOCK_STATIC_INITIALIZE(irq_kernel_hash_table_lock);
+
 /** The kernel IRQ hash table. */
 static hash_table_t irq_kernel_hash_table;
 
-/**
- * Spinlock protecting the uspace IRQ hash table.
+/** Spinlock protecting the uspace IRQ hash table.
+ *
  * This lock must be taken only when interrupts are disabled.
- */
-SPINLOCK_INITIALIZE(irq_uspace_hash_table_lock);
+ *
+ */
+IRQ_SPINLOCK_INITIALIZE(irq_uspace_hash_table_lock);
+
 /** The uspace IRQ hash table. */
 hash_table_t irq_uspace_hash_table;
@@ -100,4 +104,5 @@
  * Hash table operations for cases when we know that
  * there will be collisions between different keys.
+ *
  */
 static size_t irq_ht_hash(unative_t *key);
@@ -116,4 +121,5 @@
  * However, there might be still collisions among
  * elements with single key (sharing of one IRQ).
+ *
  */
 static size_t irq_lin_hash(unative_t *key);
@@ -132,6 +138,7 @@
 /** Initialize IRQ subsystem.
  *
- * @param inrs Numbers of unique IRQ numbers or INRs.
+ * @param inrs   Numbers of unique IRQ numbers or INRs.
  * @param chains Number of chains in the hash table.
+ *
  */
 void irq_init(size_t inrs, size_t chains)
@@ -166,9 +173,9 @@
 	memsetb(irq, sizeof(irq_t), 0);
 	link_initialize(&irq->link);
-	spinlock_initialize(&irq->lock, "irq.lock");
+	irq_spinlock_initialize(&irq->lock, "irq.lock");
 	link_initialize(&irq->notif_cfg.link);
 	irq->inr = -1;
 	irq->devno = -1;
-
+	
 	irq_initialize_arch(irq);
 }
@@ -180,10 +187,11 @@
  * function pointer and handler() function pointer.
  *
- * @param irq		IRQ structure belonging to a device.
- * @return		True on success, false on failure.
+ * @param irq IRQ structure belonging to a device.
+ *
+ * @return True on success, false on failure.
+ *
  */
 void irq_register(irq_t *irq)
 {
-	ipl_t ipl;
 	unative_t key[] = {
 		(unative_t) irq->inr,
@@ -191,11 +199,9 @@
 	};
 	
-	ipl = interrupts_disable();
-	spinlock_lock(&irq_kernel_hash_table_lock);
-	spinlock_lock(&irq->lock);
+	irq_spinlock_lock(&irq_kernel_hash_table_lock, true);
+	irq_spinlock_lock(&irq->lock, false);
 	hash_table_insert(&irq_kernel_hash_table, key, &irq->link);
-	spinlock_unlock(&irq->lock);	
-	spinlock_unlock(&irq_kernel_hash_table_lock);
-	interrupts_restore(ipl);
+	irq_spinlock_unlock(&irq->lock, false);
+	irq_spinlock_unlock(&irq_kernel_hash_table_lock, true);
 }
 
@@ -208,17 +214,15 @@
 	unative_t key[] = {
 		(unative_t) inr,
-		(unative_t) -1    /* search will use claim() instead of devno */
+		(unative_t) -1    /* Search will use claim() instead of devno */
 	};
 	
-	spinlock_lock(&irq_uspace_hash_table_lock);
+	irq_spinlock_lock(&irq_uspace_hash_table_lock, false);
 	lnk = hash_table_find(&irq_uspace_hash_table, key);
 	if (lnk) {
-		irq_t *irq;
-		
-		irq = hash_table_get_instance(lnk, irq_t, link);
-		spinlock_unlock(&irq_uspace_hash_table_lock);
+		irq_t *irq = hash_table_get_instance(lnk, irq_t, link);
+		irq_spinlock_unlock(&irq_uspace_hash_table_lock, false);
 		return irq;
 	}
-	spinlock_unlock(&irq_uspace_hash_table_lock);
+	irq_spinlock_unlock(&irq_uspace_hash_table_lock, false);
 	
 	return NULL;
@@ -233,17 +237,15 @@
 	unative_t key[] = {
 		(unative_t) inr,
-		(unative_t) -1    /* search will use claim() instead of devno */
+		(unative_t) -1    /* Search will use claim() instead of devno */
 	};
 	
-	spinlock_lock(&irq_kernel_hash_table_lock);
+	irq_spinlock_lock(&irq_kernel_hash_table_lock, false);
 	lnk = hash_table_find(&irq_kernel_hash_table, key);
 	if (lnk) {
-		irq_t *irq;
-		
-		irq = hash_table_get_instance(lnk, irq_t, link);
-		spinlock_unlock(&irq_kernel_hash_table_lock);
+		irq_t *irq = hash_table_get_instance(lnk, irq_t, link);
+		irq_spinlock_unlock(&irq_kernel_hash_table_lock, false);
 		return irq;
 	}
-	spinlock_unlock(&irq_kernel_hash_table_lock);
+	irq_spinlock_unlock(&irq_kernel_hash_table_lock, false);
 	
 	return NULL;
@@ -263,9 +265,8 @@
  *
  * @return IRQ structure of the respective device or NULL.
+ *
  */
 irq_t *irq_dispatch_and_lock(inr_t inr)
 {
-	irq_t *irq;
-	
 	/*
 	 * If the kernel console is silenced,
@@ -277,13 +278,15 @@
 	 */
 	if (silent) {
-		irq = irq_dispatch_and_lock_uspace(inr);
+		irq_t *irq = irq_dispatch_and_lock_uspace(inr);
 		if (irq)
 			return irq;
+		
 		return irq_dispatch_and_lock_kernel(inr);
 	}
 	
-	irq = irq_dispatch_and_lock_kernel(inr);
+	irq_t *irq = irq_dispatch_and_lock_kernel(inr);
 	if (irq)
 		return irq;
+	
 	return irq_dispatch_and_lock_uspace(inr);
 }
@@ -301,4 +304,5 @@
  *
  * @return Index into the hash table.
+ *
  */
 size_t irq_ht_hash(unative_t key[])
@@ -322,9 +326,10 @@
  * This function assumes interrupts are already disabled.
  *
- * @param key Keys (i.e. inr and devno).
+ * @param key  Keys (i.e. inr and devno).
  * @param keys This is 2.
  * @param item The item to compare the key with.
  *
  * @return True on match or false otherwise.
+ *
  */
 bool irq_ht_compare(unative_t key[], size_t keys, link_t *item)
@@ -333,8 +338,8 @@
 	inr_t inr = (inr_t) key[KEY_INR];
 	devno_t devno = (devno_t) key[KEY_DEVNO];
-
+	
 	bool rv;
 	
-	spinlock_lock(&irq->lock);
+	irq_spinlock_lock(&irq->lock, false);
 	if (devno == -1) {
 		/* Invoked by irq_dispatch_and_lock(). */
@@ -348,6 +353,6 @@
 	/* unlock only on non-match */
 	if (!rv)
-		spinlock_unlock(&irq->lock);
-
+		irq_spinlock_unlock(&irq->lock, false);
+	
 	return rv;
 }
@@ -361,5 +366,5 @@
 	irq_t *irq __attribute__((unused))
 	    = hash_table_get_instance(lnk, irq_t, link);
-	spinlock_unlock(&irq->lock);
+	irq_spinlock_unlock(&irq->lock, false);
 }
 
@@ -374,4 +379,5 @@
  *
  * @return Index into the hash table.
+ *
  */
 size_t irq_lin_hash(unative_t key[])
@@ -395,9 +401,10 @@
  * This function assumes interrupts are already disabled.
  *
- * @param key Keys (i.e. inr and devno).
+ * @param key  Keys (i.e. inr and devno).
  * @param keys This is 2.
  * @param item The item to compare the key with.
  *
  * @return True on match or false otherwise.
+ *
  */
 bool irq_lin_compare(unative_t key[], size_t keys, link_t *item)
@@ -407,5 +414,5 @@
 	bool rv;
 	
-	spinlock_lock(&irq->lock);
+	irq_spinlock_lock(&irq->lock, false);
 	if (devno == -1) {
 		/* Invoked by irq_dispatch_and_lock() */
@@ -418,5 +425,5 @@
 	/* unlock only on non-match */
 	if (!rv)
-		spinlock_unlock(&irq->lock);
+		irq_spinlock_unlock(&irq->lock, false);
 	
 	return rv;
@@ -425,5 +432,6 @@
 /** Unlock IRQ structure after hash_table_remove().
  *
- * @param lnk		Link in the removed and locked IRQ structure.
+ * @param lnk Link in the removed and locked IRQ structure.
+ *
  */
 void irq_lin_remove(link_t *lnk)
@@ -431,5 +439,5 @@
 	irq_t *irq __attribute__((unused))
 	    = hash_table_get_instance(lnk, irq_t, link);
-	spinlock_unlock(&irq->lock);
+	irq_spinlock_unlock(&irq->lock, false);
 }
 
