mirror of https://gitlab.com/qemu-project/qemu
hw/arm/boot: Allow boards to provide an fdt blob
If no fdt is provided on command line and the new field get_dtb in struct arm_boot_info is set then call it to get a device tree blob. Signed-off-by: John Rigby <john.rigby@linaro.org> Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Message-id: 1385140638-10444-4-git-send-email-peter.maydell@linaro.org [PMM: minor tweaks and cleanup] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
ef6de70ea8
commit
0fb79851c3
|
@ -228,23 +228,31 @@ static void set_kernel_args_old(const struct arm_boot_info *info)
|
||||||
static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
|
static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
|
||||||
{
|
{
|
||||||
void *fdt = NULL;
|
void *fdt = NULL;
|
||||||
char *filename;
|
|
||||||
int size, rc;
|
int size, rc;
|
||||||
uint32_t acells, scells;
|
uint32_t acells, scells;
|
||||||
|
|
||||||
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
|
if (binfo->dtb_filename) {
|
||||||
if (!filename) {
|
char *filename;
|
||||||
fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
|
||||||
goto fail;
|
if (!filename) {
|
||||||
}
|
fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
fdt = load_device_tree(filename, &size);
|
fdt = load_device_tree(filename, &size);
|
||||||
if (!fdt) {
|
if (!fdt) {
|
||||||
fprintf(stderr, "Couldn't open dtb file %s\n", filename);
|
fprintf(stderr, "Couldn't open dtb file %s\n", filename);
|
||||||
|
g_free(filename);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
goto fail;
|
} else if (binfo->get_dtb) {
|
||||||
|
fdt = binfo->get_dtb(binfo, &size);
|
||||||
|
if (!fdt) {
|
||||||
|
fprintf(stderr, "Board was unable to create a dtb blob\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g_free(filename);
|
|
||||||
|
|
||||||
acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells");
|
acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells");
|
||||||
scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells");
|
scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells");
|
||||||
|
@ -438,7 +446,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
|
||||||
/* for device tree boot, we pass the DTB directly in r2. Otherwise
|
/* for device tree boot, we pass the DTB directly in r2. Otherwise
|
||||||
* we point to the kernel args.
|
* we point to the kernel args.
|
||||||
*/
|
*/
|
||||||
if (info->dtb_filename) {
|
if (info->dtb_filename || info->get_dtb) {
|
||||||
/* Place the DTB after the initrd in memory. Note that some
|
/* Place the DTB after the initrd in memory. Note that some
|
||||||
* kernels will trash anything in the 4K page the initrd
|
* kernels will trash anything in the 4K page the initrd
|
||||||
* ends in, so make sure the DTB isn't caught up in that.
|
* ends in, so make sure the DTB isn't caught up in that.
|
||||||
|
|
|
@ -50,6 +50,13 @@ struct arm_boot_info {
|
||||||
const struct arm_boot_info *info);
|
const struct arm_boot_info *info);
|
||||||
void (*secondary_cpu_reset_hook)(ARMCPU *cpu,
|
void (*secondary_cpu_reset_hook)(ARMCPU *cpu,
|
||||||
const struct arm_boot_info *info);
|
const struct arm_boot_info *info);
|
||||||
|
/* if a board is able to create a dtb without a dtb file then it
|
||||||
|
* sets get_dtb. This will only be used if no dtb file is provided
|
||||||
|
* by the user. On success, sets *size to the length of the created
|
||||||
|
* dtb, and returns a pointer to it. (The caller must free this memory
|
||||||
|
* with g_free() when it has finished with it.) On failure, returns NULL.
|
||||||
|
*/
|
||||||
|
void *(*get_dtb)(const struct arm_boot_info *info, int *size);
|
||||||
/* if a board needs to be able to modify a device tree provided by
|
/* if a board needs to be able to modify a device tree provided by
|
||||||
* the user it should implement this hook.
|
* the user it should implement this hook.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue