summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2015-01-16 18:47:20 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2015-01-16 18:47:20 +0000
commit0988dad56d7c9cb98e70d7e8a6a8a232b4cbc777 (patch)
treefdb15f50f7fbfca6c39f4955810bf9c38042f285
parent590f3ce30a5c5caabef87bd4f9b5157920bb9cff (diff)
downloadFreeBSD-src-0988dad56d7c9cb98e70d7e8a6a8a232b4cbc777.zip
FreeBSD-src-0988dad56d7c9cb98e70d7e8a6a8a232b4cbc777.tar.gz
Add two fake properties ("fdtbootcpu" and "fdtmemreserv") to the device
tree's /chosen node to provide out-of-band header fields of the FDT. This emulation is not perfect without corresponding changes to ofw_fdt_nextprop(), but is enough to enable lookup by memory-map-parsing code. MFC after: 1 week
-rw-r--r--sys/dev/ofw/ofw_fdt.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/dev/ofw/ofw_fdt.c b/sys/dev/ofw/ofw_fdt.c
index f4072a3..01f82c4 100644
--- a/sys/dev/ofw/ofw_fdt.c
+++ b/sys/dev/ofw/ofw_fdt.c
@@ -231,6 +231,13 @@ ofw_fdt_getproplen(ofw_t ofw, phandle_t package, const char *propname)
return (len + 1);
}
+ if (prop == NULL && offset == fdt_path_offset(fdtp, "/chosen")) {
+ if (strcmp(propname, "fdtbootcpu") == 0)
+ return (sizeof(cell_t));
+ if (strcmp(propname, "fdtmemreserv") == 0)
+ return (sizeof(uint64_t)*2*fdt_num_mem_rsv(fdtp));
+ }
+
return (len);
}
@@ -242,6 +249,7 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const char *propname, void *buf,
const void *prop;
const char *name;
int len, offset;
+ uint32_t cpuid;
offset = fdt_phandle_offset(package);
if (offset < 0)
@@ -258,6 +266,18 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const char *propname, void *buf,
return (len + 1);
}
+ if (prop == NULL && offset == fdt_path_offset(fdtp, "/chosen")) {
+ if (strcmp(propname, "fdtbootcpu") == 0) {
+ cpuid = cpu_to_fdt32(fdt_boot_cpuid_phys(fdtp));
+ len = sizeof(cpuid);
+ prop = &cpuid;
+ }
+ if (strcmp(propname, "fdtmemreserv") == 0) {
+ prop = (char *)fdtp + fdt_off_mem_rsvmap(fdtp);
+ len = sizeof(uint64_t)*2*fdt_num_mem_rsv(fdtp);
+ }
+ }
+
if (prop == NULL)
return (-1);
OpenPOWER on IntegriCloud