PERFORCE change 219948 for review
Robert Watson
rwatson at FreeBSD.org
Fri Jan 4 09:10:21 UTC 2013
http://p4web.freebsd.org/@@219948?ac=10
Change 219948 by rwatson at rwatson_zenith_cl_cam_ac_uk on 2013/01/04 09:09:35
Add code so that the BERI boot process can ask the kernel linker for
DTB blobs that may have been left for it by the boot loader, as done
on PowerPC and ARM. This will require both a more mature boot
loader, and more mature boot loader argument passing mechanism,
than currently supported on BERI.
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/sys/mips/beri/beri_machdep.c#8 edit
.. //depot/projects/ctsrd/beribsd/src/sys/mips/include/metadata.h#2 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/sys/mips/beri/beri_machdep.c#8 (text+ko) ====
@@ -45,6 +45,7 @@
#include <sys/cpu.h>
#include <sys/cons.h>
#include <sys/exec.h>
+#include <sys/linker.h>
#include <sys/ucontext.h>
#include <sys/proc.h>
#include <sys/kdb.h>
@@ -70,6 +71,7 @@
#include <machine/cpuregs.h>
#include <machine/hwfunc.h>
#include <machine/md_var.h>
+#include <machine/metadata.h>
#include <machine/pmap.h>
#include <machine/trap.h>
@@ -135,6 +137,10 @@
char **argv = (char **)a1;
char **envp = (char **)a2;
unsigned int memsize = a3;
+#ifdef FDT
+ vm_offset_t dtbp;
+ void *kmdp;
+#endif
int i;
/* clear the BSS and SBSS segments */
@@ -146,8 +152,24 @@
mips_pcpu0_init();
#ifdef FDT
-#ifndef FDT_DTB_STATIC
-#error "mips_init with FDT requires FDT_DTB_STATIC"
+ /*
+ * Find the dtb passed in by the boot loader (currently fictional).
+ */
+ kmdp = preload_search_by_type("elf kernel");
+ if (kmdp != NULL)
+ dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
+ else
+ dtbp = (vm_offset_t)NULL;
+
+#if defined(FDT_DTB_STATIC)
+ /*
+ * In case the device tree blob was not retrieved (from metadata) try
+ * to use the statically embedded one.
+ */
+ if (dtbp == (vm_offset_t)NULL)
+ dtbp = (vm_offset_t)&fdt_static_dtb;
+#else
+#error "Non-static FDT not yet supported on BERI"
#endif
if (OF_install(OFW_FDT, 0) == FALSE)
==== //depot/projects/ctsrd/beribsd/src/sys/mips/include/metadata.h#2 (text+ko) ====
@@ -30,5 +30,6 @@
#define _MACHINE_METADATA_H_
#define MODINFOMD_SMAP 0x1001
+#define MODINFOMD_DTBP 0x1002
#endif /* !_MACHINE_METADATA_H_ */
More information about the p4-projects
mailing list