diff options
author | kientzle <kientzle@FreeBSD.org> | 2013-02-20 16:32:38 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2013-02-20 16:32:38 +0000 |
commit | e341f5a9677635311ada483476d10b467dc091d9 (patch) | |
tree | bf040d75cb8ba1a9f752b3ce034d77f618509614 /sys/boot | |
parent | 5be772ca1074c8bc1ed5c72a2a840f704b127ade (diff) | |
download | FreeBSD-src-e341f5a9677635311ada483476d10b467dc091d9.zip FreeBSD-src-e341f5a9677635311ada483476d10b467dc091d9.tar.gz |
Fix "fdt addr" to accept literal addresses rather than va offsets.
When initializing the fdt, query U-Boot as well.
With this change, it is now feasible to have U-Boot load
the FDT, ubldr will pull it from U-Boot and hand it to the
kernel.
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/fdt/fdt_loader_cmd.c | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/sys/boot/fdt/fdt_loader_cmd.c b/sys/boot/fdt/fdt_loader_cmd.c index c7297f4..37cf75d 100644 --- a/sys/boot/fdt/fdt_loader_cmd.c +++ b/sys/boot/fdt/fdt_loader_cmd.c @@ -235,26 +235,47 @@ fdt_load_dtb(vm_offset_t va) } static int -fdt_setup_fdtp() +fdt_load_dtb_addr(struct fdt_header *header) { struct preloaded_file *bfp; - vm_offset_t va; - bfp = file_findfile(NULL, "dtb"); + bfp = mem_load_raw("dtb", "memory.dtb", header, fdt_totalsize(header)); if (bfp == NULL) { - if ((va = fdt_find_static_dtb()) == 0) { - command_errmsg = "no device tree blob found!"; - return (1); - } - } else { - /* Dynamic blob has precedence over static. */ - va = bfp->f_addr; + command_errmsg = "unable to copy DTB into module directory"; + return (1); } + return fdt_load_dtb(bfp->f_addr); +} - if (fdt_load_dtb(va) != 0) - return (1); - - return (0); +static int +fdt_setup_fdtp() +{ + struct preloaded_file *bfp; + struct fdt_header *hdr; + const char *s, *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); + } + + s = ub_env_get("fdtaddr"); + if (s != NULL && *s != '\0') { + hdr = (struct fdt_header *)strtoul(s, &p, 16); + if (*p == '\0') { + printf("Using DTB provided by U-Boot.\n"); + return fdt_load_dtb_addr(hdr); + } + } + + if ((va = fdt_find_static_dtb()) != 0) { + printf("Using DTB compiled into kernel.\n"); + return (fdt_load_dtb(va)); + } + + command_errmsg = "no device tree blob found!"; + return (1); } #define fdt_strtovect(str, cellbuf, lim, cellsize) _fdt_strtovect((str), \ @@ -789,8 +810,8 @@ command_fdt_internal(int argc, char *argv[]) static int fdt_cmd_addr(int argc, char *argv[]) { - vm_offset_t va; - char *addr, *cp; + struct fdt_header *hdr; + const char *addr, *cp; if (argc > 2) addr = argv[2]; @@ -799,13 +820,13 @@ fdt_cmd_addr(int argc, char *argv[]) return (CMD_ERROR); } - va = strtol(addr, &cp, 0); + hdr = (struct fdt_header *)strtoul(addr, &cp, 0); if (cp == addr) { sprintf(command_errbuf, "Invalid address: %s", addr); return (CMD_ERROR); } - if (fdt_load_dtb(va) != 0) + if (fdt_load_dtb_addr(hdr) != 0) return (CMD_ERROR); return (CMD_OK); @@ -1484,6 +1505,7 @@ fdt_cmd_mkprop(int argc, char *argv[]) if (fdt_modprop(o, propname, value, 1)) return (CMD_ERROR); + COPYIN(fdtp, fdtp_va, fdtp_size); return (CMD_OK); } |