Index: kernel/genarch/src/ofw/ebus.c
===================================================================
--- kernel/genarch/src/ofw/ebus.c	(revision 98000fb4ea6015506f059c9b121e417ce991ecfd)
+++ kernel/genarch/src/ofw/ebus.c	(revision 771599490c9c1e7f468c40fc138f10e8ac0282dc)
@@ -37,6 +37,7 @@
 
 #include <genarch/ofw/ofw_tree.h>
+#include <genarch/ofw/ebus.h>
+#include <genarch/ofw/pci.h>
 #include <arch/memstr.h>
-#include <arch/trap/interrupt.h>
 #include <string.h>
 #include <panic.h>
Index: kernel/genarch/src/ofw/fhc.c
===================================================================
--- kernel/genarch/src/ofw/fhc.c	(revision 98000fb4ea6015506f059c9b121e417ce991ecfd)
+++ kernel/genarch/src/ofw/fhc.c	(revision 771599490c9c1e7f468c40fc138f10e8ac0282dc)
@@ -37,4 +37,5 @@
 
 #include <genarch/ofw/ofw_tree.h>
+#include <genarch/ofw/fhc.h>
 #include <arch/drivers/fhc.h>
 #include <arch/memstr.h>
Index: kernel/genarch/src/ofw/ofw_tree.c
===================================================================
--- kernel/genarch/src/ofw/ofw_tree.c	(revision 98000fb4ea6015506f059c9b121e417ce991ecfd)
+++ kernel/genarch/src/ofw/ofw_tree.c	(revision 771599490c9c1e7f468c40fc138f10e8ac0282dc)
@@ -32,5 +32,5 @@
 /**
  * @file
- * @brief	OpenFirmware device tree navigation.
+ * @brief OpenFirmware device tree navigation.
  *
  */
@@ -40,9 +40,9 @@
 #include <mm/slab.h>
 #include <string.h>
+#include <panic.h>
 #include <print.h>
-#include <panic.h>
-
-#define PATH_MAX_LEN	80
-#define NAME_BUF_LEN	50
+
+#define PATH_MAX_LEN  256
+#define NAME_BUF_LEN  50
 
 static ofw_tree_node_t *ofw_root;
@@ -55,12 +55,13 @@
 /** Get OpenFirmware node property.
  *
- * @param node		Node in which to lookup the property.
- * @param name		Name of the property.
- *
- * @return		Pointer to the property structure or NULL if no such
- * 			property.
- */
-ofw_tree_property_t *
-ofw_tree_getprop(const ofw_tree_node_t *node, const char *name)
+ * @param node Node in which to lookup the property.
+ * @param name Name of the property.
+ *
+ * @return Pointer to the property structure or NULL if no such
+ *         property.
+ *
+ */
+ofw_tree_property_t *ofw_tree_getprop(const ofw_tree_node_t *node,
+    const char *name)
 {
 	unsigned int i;
@@ -70,5 +71,5 @@
 			return &node->property[i];
 	}
-
+	
 	return NULL;
 }
@@ -76,18 +77,15 @@
 /** Return value of the 'name' property.
  *
- * @param node		Node of interest.
- *
- * @return		Value of the 'name' property belonging to the node.
+ * @param node Node of interest.
+ *
+ * @return Value of the 'name' property belonging to the node
+ *         or NULL if the property is invalid.
+ *
  */
 const char *ofw_tree_node_name(const ofw_tree_node_t *node)
 {
-	ofw_tree_property_t *prop;
-	
-	prop = ofw_tree_getprop(node, "name");
-	if (!prop)
-		panic("Node without name property.");
-		
-	if (prop->size < 2)
-		panic("Invalid name property.");
+	ofw_tree_property_t *prop = ofw_tree_getprop(node, "name");
+	if ((!prop) || (prop->size < 2))
+		return NULL;
 	
 	return prop->value;
@@ -96,11 +94,13 @@
 /** Lookup child of given name.
  *
- * @param node		Node whose child is being looked up.
- * @param name		Name of the child being looked up.
- *
- * @return		NULL if there is no such child or pointer to the
- * 			matching child node.
- */
-ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node, const char *name)
+ * @param node Node whose child is being looked up.
+ * @param name Name of the child being looked up.
+ *
+ * @return NULL if there is no such child or pointer to the
+ *         matching child node.
+ *
+ */
+ofw_tree_node_t *ofw_tree_find_child(ofw_tree_node_t *node,
+    const char *name)
 {
 	ofw_tree_node_t *cur;
@@ -125,5 +125,5 @@
 			return cur;
 	}
-		
+	
 	return NULL;
 }
@@ -131,24 +131,27 @@
 /** Lookup first child of given device type.
  *
- * @param node		Node whose child is being looked up.
- * @param name		Device type of the child being looked up.
- *
- * @return		NULL if there is no such child or pointer to the
- * 			matching child node.
- */
-ofw_tree_node_t *
-ofw_tree_find_child_by_device_type(ofw_tree_node_t *node, const char *name)
-{
-	ofw_tree_node_t *cur;
-	ofw_tree_property_t *prop;
+ * @param node  Node whose child is being looked up.
+ * @param dtype Device type of the child being looked up.
+ *
+ * @return NULL if there is no such child or pointer to the
+ *         matching child node.
+ *
+ */
+ofw_tree_node_t *ofw_tree_find_child_by_device_type(ofw_tree_node_t *node,
+    const char *dtype)
+{
+	ofw_tree_node_t *cur;
 	
 	for (cur = node->child; cur; cur = cur->peer) {
-		prop = ofw_tree_getprop(cur, "device_type");
-		if (!prop || !prop->value)
+		ofw_tree_property_t *prop =
+		    ofw_tree_getprop(cur, "device_type");
+		
+		if ((!prop) || (!prop->value))
 			continue;
-		if (str_cmp(prop->value, name) == 0)
-			return cur;
-	}
-			
+		
+		if (str_cmp(prop->value, dtype) == 0)
+			return cur;
+	}
+	
 	return NULL;
 }
@@ -159,23 +162,23 @@
  * are looked up iteratively to avoid stack overflow.
  *
- * @param root		Root of the searched subtree.
- * @param handle	OpenFirmware handle.
- *
- * @return		NULL if there is no such node or pointer to the matching
- * 			node.
- */
-ofw_tree_node_t *
-ofw_tree_find_node_by_handle(ofw_tree_node_t *root, uint32_t handle)
-{
-	ofw_tree_node_t *cur;
-
-	for (cur = root; cur; cur = cur->peer) {		
+ * @param root   Root of the searched subtree.
+ * @param handle OpenFirmware handle.
+ *
+ * @return NULL if there is no such node or pointer to the matching
+ *         node.
+ *
+ */
+ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *root,
+    uint32_t handle)
+{
+	ofw_tree_node_t *cur;
+	
+	for (cur = root; cur; cur = cur->peer) {
 		if (cur->node_handle == handle)
 			return cur;
-
+		
 		if (cur->child) {
-			ofw_tree_node_t *node;
-			
-			node = ofw_tree_find_node_by_handle(cur->child, handle);
+			ofw_tree_node_t *node
+			    = ofw_tree_find_node_by_handle(cur->child, handle);
 			if (node)
 				return node;
@@ -183,55 +186,60 @@
 	}
 	
-	return NULL;	
+	return NULL;
 }
 
 /** Lookup first peer of given device type.
  *
- * @param node		Node whose peer is being looked up.
- * @param name		Device type of the child being looked up.
- *
- * @return		NULL if there is no such child or pointer to the
- * 			matching child node.
- */
-ofw_tree_node_t *
-ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node, const char *name)
-{
-	ofw_tree_node_t *cur;
-	ofw_tree_property_t *prop;
+ * @param node  Node whose peer is being looked up.
+ * @param dtype Device type of the child being looked up.
+ *
+ * @return NULL if there is no such child or pointer to the
+ *         matching child node.
+ *
+ */
+ofw_tree_node_t *ofw_tree_find_peer_by_device_type(ofw_tree_node_t *node,
+    const char *dtype)
+{
+	ofw_tree_node_t *cur;
 	
 	for (cur = node->peer; cur; cur = cur->peer) {
-		prop = ofw_tree_getprop(cur, "device_type");
-		if (!prop || !prop->value)
+		ofw_tree_property_t *prop =
+		    ofw_tree_getprop(cur, "device_type");
+		
+		if ((!prop) || (!prop->value))
 			continue;
+		
+		if (str_cmp(prop->value, dtype) == 0)
+			return cur;
+	}
+	
+	return NULL;
+}
+
+/** Lookup first peer of given name.
+ *
+ * @param node Node whose peer is being looked up.
+ * @param name Name of the child being looked up.
+ *
+ * @return NULL if there is no such peer or pointer to the matching
+ *         peer node.
+ *
+ */
+ofw_tree_node_t *ofw_tree_find_peer_by_name(ofw_tree_node_t *node,
+    const char *name)
+{
+	ofw_tree_node_t *cur;
+	
+	for (cur = node->peer; cur; cur = cur->peer) {
+		ofw_tree_property_t *prop
+		    = ofw_tree_getprop(cur, "name");
+		
+		if ((!prop) || (!prop->value))
+			continue;
+		
 		if (str_cmp(prop->value, name) == 0)
 			return cur;
 	}
-			
-	return NULL;
-}
-
-
-/** Lookup first peer of given name.
- *
- * @param node		Node whose peer is being looked up.
- * @param name		Name of the child being looked up.
- *
- * @return		NULL if there is no such peer or pointer to the matching
- * 			peer node.
- */
-ofw_tree_node_t *
-ofw_tree_find_peer_by_name(ofw_tree_node_t *node, const char *name)
-{
-	ofw_tree_node_t *cur;
-	ofw_tree_property_t *prop;
-	
-	for (cur = node->peer; cur; cur = cur->peer) {
-		prop = ofw_tree_getprop(cur, "name");
-		if (!prop || !prop->value)
-			continue;
-		if (str_cmp(prop->value, name) == 0)
-			return cur;
-	}
-			
+	
 	return NULL;
 }
@@ -239,19 +247,19 @@
 /** Lookup OpenFirmware node by its path.
  *
- * @param path		Path to the node.
- *
- * @return		NULL if there is no such node or pointer to the leaf
- * 			node.
+ * @param path Path to the node.
+ *
+ * @return NULL if there is no such node or pointer to the leaf
+ *         node.
+ *
  */
 ofw_tree_node_t *ofw_tree_lookup(const char *path)
 {
-	char buf[NAME_BUF_LEN + 1];
+	if (path[0] != '/')
+		return NULL;
+	
 	ofw_tree_node_t *node = ofw_root;
 	size_t i;
 	size_t j;
 	
-	if (path[0] != '/')
-		return NULL;
-	
 	for (i = 1; (i < str_size(path)) && (node); i = j + 1) {
 		for (j = i; (j < str_size(path)) && (path[j] != '/'); j++);
@@ -261,4 +269,5 @@
 			continue;
 		
+		char buf[NAME_BUF_LEN + 1];
 		memcpy(buf, &path[i], j - i);
 		buf[j - i] = 0;
@@ -269,33 +278,88 @@
 }
 
-/** Print OpenFirmware device subtree rooted in a node.
+/** Walk the OpenFirmware device subtree rooted in a node.
  *
  * Child nodes are processed recursively and peer nodes are processed
  * iteratively in order to avoid stack overflow.
  *
- * @param node		Root of the subtree.
- * @param path		Current path, NULL for the very root of the entire tree.
- */
-static void ofw_tree_node_print(const ofw_tree_node_t *node, const char *path)
-{
-	char *p;
-	const ofw_tree_node_t *cur;
-
-	p = (char *) malloc(PATH_MAX_LEN, 0);
-
+ * @param node   Root of the subtree.
+ * @param dtype  Device type to look for.
+ * @param walker Routine to be invoked on found device.
+ * @param arg    User argument to the walker.
+ *
+ * @return True if the walk should continue.
+ *
+ */
+static bool ofw_tree_walk_by_device_type_internal(ofw_tree_node_t *node,
+    const char *dtype, ofw_tree_walker_t walker, void *arg)
+{
+	ofw_tree_node_t *cur;
+	
 	for (cur = node; cur; cur = cur->peer) {
-		if (cur->parent) {
-			snprintf(p, PATH_MAX_LEN, "%s/%s", path, cur->da_name);
-			printf("%s\n", p);
+		ofw_tree_property_t *prop =
+		    ofw_tree_getprop(cur, "device_type");
+		
+		if ((prop) && (prop->value) && (str_cmp(prop->value, dtype) == 0)) {
+			bool ret = walker(cur, arg);
+			if (!ret)
+				return false;
+		}
+		
+		if (cur->child) {
+			bool ret =
+			    ofw_tree_walk_by_device_type_internal(cur->child, dtype, walker, arg);
+			if (!ret)
+				return false;
+		}
+	}
+	
+	return true;
+}
+
+/** Walk the OpenFirmware device tree and find devices by type.
+ *
+ * Walk the whole OpenFirmware device tree and if any node has
+ * the property "device_type" equal to dtype, run a walker on it.
+ * If the walker returns false, the walk does not continue.
+ *
+ * @param dtype  Device type to look for.
+ * @param walker Routine to be invoked on found device.
+ * @param arg    User argument to the walker.
+ *
+ */
+void ofw_tree_walk_by_device_type(const char *dtype, ofw_tree_walker_t walker,
+    void *arg)
+{
+	(void) ofw_tree_walk_by_device_type_internal(ofw_root, dtype, walker, arg);
+}
+
+/** Print OpenFirmware device subtree rooted in a node.
+ *
+ * Child nodes are processed recursively and peer nodes are processed
+ * iteratively in order to avoid stack overflow.
+ *
+ * @param node Root of the subtree.
+ * @param path Current path, NULL for the very root of the entire tree.
+ *
+ */
+static void ofw_tree_node_print(ofw_tree_node_t *node, const char *path)
+{
+	char *cur_path = (char *) malloc(PATH_MAX_LEN, 0);
+	ofw_tree_node_t *cur;
+	
+	for (cur = node; cur; cur = cur->peer) {
+		if ((cur->parent) && (path)) {
+			snprintf(cur_path, PATH_MAX_LEN, "%s/%s", path, cur->da_name);
+			printf("%s\n", cur_path);
 		} else {
-			snprintf(p, PATH_MAX_LEN, "%s", cur->da_name);
+			snprintf(cur_path, PATH_MAX_LEN, "%s", cur->da_name);
 			printf("/\n");
 		}
-
+		
 		if (cur->child)
-			ofw_tree_node_print(cur->child, p);
-	}
-
-	free(p);
+			ofw_tree_node_print(cur->child, cur_path);
+	}
+	
+	free(cur_path);
 }
 
Index: kernel/genarch/src/ofw/pci.c
===================================================================
--- kernel/genarch/src/ofw/pci.c	(revision 98000fb4ea6015506f059c9b121e417ce991ecfd)
+++ kernel/genarch/src/ofw/pci.c	(revision 771599490c9c1e7f468c40fc138f10e8ac0282dc)
@@ -37,4 +37,5 @@
 
 #include <genarch/ofw/ofw_tree.h>
+#include <genarch/ofw/pci.h>
 #include <arch/drivers/pci.h>
 #include <arch/trap/interrupt.h>
Index: kernel/genarch/src/ofw/sbus.c
===================================================================
--- kernel/genarch/src/ofw/sbus.c	(revision 98000fb4ea6015506f059c9b121e417ce991ecfd)
+++ kernel/genarch/src/ofw/sbus.c	(revision 771599490c9c1e7f468c40fc138f10e8ac0282dc)
@@ -37,4 +37,5 @@
 
 #include <genarch/ofw/ofw_tree.h>
+#include <genarch/ofw/sbus.h>
 #include <macros.h>
 
Index: kernel/genarch/src/ofw/upa.c
===================================================================
--- kernel/genarch/src/ofw/upa.c	(revision 98000fb4ea6015506f059c9b121e417ce991ecfd)
+++ kernel/genarch/src/ofw/upa.c	(revision 771599490c9c1e7f468c40fc138f10e8ac0282dc)
@@ -37,4 +37,5 @@
 
 #include <genarch/ofw/ofw_tree.h>
+#include <genarch/ofw/upa.h>
 #include <arch/memstr.h>
 #include <func.h>
