summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2013-02-23 20:34:47 +0000
committerkientzle <kientzle@FreeBSD.org>2013-02-23 20:34:47 +0000
commit02ee4992361228dcb913b2881260ee680a2c3e39 (patch)
tree93b834f8bbcffbdc1050c5c293266967e2ecf17e /sys/boot
parent8321b23854f25073208a8aeca26e8b79db948390 (diff)
downloadFreeBSD-src-02ee4992361228dcb913b2881260ee680a2c3e39.zip
FreeBSD-src-02ee4992361228dcb913b2881260ee680a2c3e39.tar.gz
"fdt addr" gets run from loader.rc before the kernel is loaded.
This was broken by r247045 which tried to copy the FDT into the module directory immediately. Instead, store the address and arrange for the FDT to get copied into the module directory later when the usual FDT initialization runs.
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/fdt/fdt_loader_cmd.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/boot/fdt/fdt_loader_cmd.c b/sys/boot/fdt/fdt_loader_cmd.c
index 37cf75d..0417c52 100644
--- a/sys/boot/fdt/fdt_loader_cmd.c
+++ b/sys/boot/fdt/fdt_loader_cmd.c
@@ -62,7 +62,9 @@ __FBSDID("$FreeBSD$");
#define CMD_REQUIRES_BLOB 0x01
-/* Local copy of FDT */
+/* Location of FDT yet to be loaded. */
+static struct fdt_header *fdt_to_load = NULL;
+/* Local copy of FDT on heap. */
static struct fdt_header *fdtp = NULL;
/* Size of FDT blob */
static size_t fdtp_size = 0;
@@ -252,13 +254,20 @@ fdt_setup_fdtp()
{
struct preloaded_file *bfp;
struct fdt_header *hdr;
- const char *s, *p;
+ const char *s;
+ char *p;
vm_offset_t va;
if ((bfp = file_findfile(NULL, "dtb")) != NULL) {
printf("Using DTB from loaded file.\n");
return fdt_load_dtb(bfp->f_addr);
- }
+ }
+
+ if (fdt_to_load != NULL) {
+ printf("Using DTB from memory address 0x%08X.\n",
+ (unsigned int)fdt_to_load);
+ return fdt_load_dtb_addr(fdt_to_load);
+ }
s = ub_env_get("fdtaddr");
if (s != NULL && *s != '\0') {
@@ -810,8 +819,12 @@ command_fdt_internal(int argc, char *argv[])
static int
fdt_cmd_addr(int argc, char *argv[])
{
+ struct preloaded_file *fp;
struct fdt_header *hdr;
- const char *addr, *cp;
+ const char *addr;
+ char *cp;
+
+ fdt_to_load = NULL;
if (argc > 2)
addr = argv[2];
@@ -820,15 +833,17 @@ fdt_cmd_addr(int argc, char *argv[])
return (CMD_ERROR);
}
- hdr = (struct fdt_header *)strtoul(addr, &cp, 0);
+ hdr = (struct fdt_header *)strtoul(addr, &cp, 16);
if (cp == addr) {
sprintf(command_errbuf, "Invalid address: %s", addr);
return (CMD_ERROR);
}
- if (fdt_load_dtb_addr(hdr) != 0)
- return (CMD_ERROR);
+ while ((fp = file_findfile(NULL, "dtb")) != NULL) {
+ file_discard(fp);
+ }
+ fdt_to_load = hdr;
return (CMD_OK);
}
OpenPOWER on IntegriCloud