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.
This commit is contained in:
parent
46f2df9c13
commit
f87223581e
@ -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;
|
||||
}
|
||||
|
||||
if (fdt_load_dtb(va) != 0)
|
||||
command_errmsg = "unable to copy DTB into module directory";
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
return fdt_load_dtb(bfp->f_addr);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user