1
commit d572248c13788feeac12f46f2c1b17255619af3a
2
Author: John Rigby <john.rigby@linaro.org>
3
Date: Fri Aug 9 17:07:20 2013 +0100
5
hw/arm/boot: Allow boards to provide an fdt blob
7
If no fdt is provided on command line and the new field
8
get_dtb in struct arm_boot_info is set then call it to
9
get a device tree blob.
11
Signed-off-by: John Rigby <john.rigby@linaro.org>
12
[PMM: minor tweaks and cleanup]
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
16
index 2cbeefd..9d790b7 100644
19
@@ -228,23 +228,31 @@ static void set_kernel_args_old(const struct arm_boot_info *info)
20
static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
25
uint32_t acells, scells;
27
- filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
29
- fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
32
+ if (binfo->dtb_filename) {
34
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
36
+ fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
40
- fdt = load_device_tree(filename, &size);
42
- fprintf(stderr, "Couldn't open dtb file %s\n", filename);
43
+ fdt = load_device_tree(filename, &size);
45
+ fprintf(stderr, "Couldn't open dtb file %s\n", filename);
51
+ } else if (binfo->get_dtb) {
52
+ fdt = binfo->get_dtb(binfo, &size);
54
+ fprintf(stderr, "Board was unable to create a dtb blob\n");
60
acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells");
61
scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells");
62
@@ -436,7 +444,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
63
/* for device tree boot, we pass the DTB directly in r2. Otherwise
64
* we point to the kernel args.
66
- if (info->dtb_filename) {
67
+ if (info->dtb_filename || info->get_dtb) {
68
/* Place the DTB after the initrd in memory. Note that some
69
* kernels will trash anything in the 4K page the initrd
70
* ends in, so make sure the DTB isn't caught up in that.
71
diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h
72
index bae87c6..4e51a9e 100644
73
--- a/include/hw/arm/arm.h
74
+++ b/include/hw/arm/arm.h
75
@@ -55,6 +55,13 @@ struct arm_boot_info {
76
const struct arm_boot_info *info);
77
void (*secondary_cpu_reset_hook)(ARMCPU *cpu,
78
const struct arm_boot_info *info);
79
+ /* if a board is able to create a dtb without a dtb file then it
80
+ * sets get_dtb. This will only be used if no dtb file is provided
81
+ * by the user. On success, sets *size to the length of the created
82
+ * dtb, and returns a pointer to it. (The caller must free this memory
83
+ * with g_free() when it has finished with it.) On failure, returns NULL.
85
+ void *(*get_dtb)(const struct arm_boot_info *info, int *size);
86
/* if a board needs to be able to modify a device tree provided by
87
* the user it should implement this hook.