summaryrefslogtreecommitdiffstats
path: root/sys/dev/ofw/openfirm.c
diff options
context:
space:
mode:
authorraj <raj@FreeBSD.org>2010-05-28 10:43:56 +0000
committerraj <raj@FreeBSD.org>2010-05-28 10:43:56 +0000
commitef99eb110e7dc8e312597e69d22a462e881a05d0 (patch)
tree8ab64de3265e079ec3e830ced915bbb9259ecf0e /sys/dev/ofw/openfirm.c
parent9e7f7d81de0fced89e8d5f752d141ddd0046d9f2 (diff)
downloadFreeBSD-src-ef99eb110e7dc8e312597e69d22a462e881a05d0.zip
FreeBSD-src-ef99eb110e7dc8e312597e69d22a462e881a05d0.tar.gz
Prepare and extend OFW layer for FDT support.
o Let OFW_INIT() and OF_init() return status value. o Provide helper routines for 'compatible' property handling. o Only compile OF and OFW code, which is relevant in FDT scenario. o Other minor cosmetics Reviewed by: imp Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/dev/ofw/openfirm.c')
-rw-r--r--sys/dev/ofw/openfirm.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c
index 17cda68..414b402 100644
--- a/sys/dev/ofw/openfirm.c
+++ b/sys/dev/ofw/openfirm.c
@@ -58,6 +58,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_platform.h"
+
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@@ -110,10 +112,11 @@ OF_install(char *name, int prio)
}
/* Initializer */
-void
+int
OF_init(void *cookie)
{
phandle_t chosen;
+ int rv;
ofw_obj = &ofw_kernel_obj;
/*
@@ -123,14 +126,16 @@ OF_init(void *cookie)
kobj_class_compile_static(ofw_def_impl, &ofw_kernel_kops);
kobj_init((kobj_t)ofw_obj, ofw_def_impl);
- OFW_INIT(ofw_obj, cookie);
+ rv = OFW_INIT(ofw_obj, cookie);
+
+ if ((chosen = OF_finddevice("/chosen")) > 0)
+ if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
+ stdout = -1;
- if ((chosen = OF_finddevice("/chosen")) == -1)
- OF_exit();
- if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
- stdout = -1;
+ return (rv);
}
+#ifndef FDT
void
OF_printf(const char *fmt, ...)
{
@@ -154,6 +159,7 @@ OF_test(const char *name)
return (OFW_TEST(ofw_obj, name));
}
+#endif
int
OF_interpret(const char *cmd, int nreturns, ...)
@@ -228,7 +234,7 @@ OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
}
/*
- * Resursively search the node and its parent for the given property, working
+ * Recursively search the node and its parent for the given property, working
* downward from the node to the device tree root. Returns the value of the
* first match.
*/
@@ -315,6 +321,7 @@ OF_package_to_path(phandle_t package, char *buf, size_t len)
return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len));
}
+#ifndef FDT
/* Call the method in the scope of a given instance. */
int
OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
@@ -428,3 +435,4 @@ OF_exit()
for (;;) /* just in case */
;
}
+#endif
OpenPOWER on IntegriCloud