summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-08-25 21:18:21 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-08-25 21:18:21 +0000
commitcfbbc0d2953469d053b4058d7960d1672b5258c9 (patch)
tree13f3e65cfcba489c48aee22c82f1c76faec6964d /sys/arch
parenta3081dda3e377516db0867023ed4aa03089f04d9 (diff)
Initialize flattened device tree support if a tree was passed by the firmware.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/socppc/socppc/machdep.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c
index e6001152602..dc4c103a0f7 100644
--- a/sys/arch/socppc/socppc/machdep.c
+++ b/sys/arch/socppc/socppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.18 2009/08/11 19:17:17 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.19 2009/08/25 21:18:20 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -52,6 +52,7 @@
#include <machine/bat.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <machine/pio.h>
#include <machine/powerpc.h>
#include <machine/trap.h>
@@ -112,6 +113,7 @@ struct bd_info {
} bootinfo;
extern struct bd_info **fwargsave;
+extern struct fdt_head *fwfdtsave;
void uboot_mem_regions(struct mem_region **, struct mem_region **);
void uboot_vmon(void);
@@ -179,7 +181,48 @@ initppc(u_int startkernel, u_int endkernel, char *args)
/* Make a copy of the args! */
strlcpy(bootpathbuf, args ? args : "wd0a", sizeof bootpathbuf);
- memcpy(&bootinfo, *fwargsave, sizeof bootinfo);
+
+ if (fwfdtsave) {
+ /*
+ * We were loaded by a newer U-boot or RouterBOOT.
+ * Both provide a flattened device tree.
+ *
+ * XXX We only support RouterBOOT and fake a bootinfo
+ * structure.
+ */
+ bootinfo.bi_memstart = 0x00000000;
+ bootinfo.bi_memsize = 0x07ffffff;
+ bootinfo.bi_immr_base = 0xe0000000;
+ bootinfo.bi_enetaddr[0] = 0x00;
+ bootinfo.bi_enetaddr[1] = 0x0c;
+ bootinfo.bi_enetaddr[2] = 0x42;
+ bootinfo.bi_enetaddr[3] = 0x20;
+ bootinfo.bi_enetaddr[4] = 0xc6;
+ bootinfo.bi_enetaddr[5] = 0xe5;
+ } else {
+ /*
+ * We were loaded by an old U-Boot that didn't provide
+ * a flattened device tree. It should have provided a
+ * valid bootinfo structure which we'll use to build
+ * such a device tree ourselves.
+ *
+ * XXX We don't build a flattened device tree yet.
+ */
+ memcpy(&bootinfo, *fwargsave, sizeof bootinfo);
+ }
+
+ if (fwfdtsave && fwfdtsave->fh_magic == FDT_MAGIC) {
+ /*
+ * Save the FDT firmware blob passed by the bootloader
+ * before we zero all memory.
+ *
+ */
+ void *fdt = (void *)endkernel;
+ memcpy(fdt, fwfdtsave, fwfdtsave->fh_size);
+ endkernel += fwfdtsave->fh_size;
+
+ fdt_init(fdt);
+ }
proc0.p_cpu = &cpu_info[0];
proc0.p_addr = proc0paddr;