Revision 0fb79851

b/hw/arm/boot.c
228 228
static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
229 229
{
230 230
    void *fdt = NULL;
231
    char *filename;
232 231
    int size, rc;
233 232
    uint32_t acells, scells;
234 233

  
235
    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
236
    if (!filename) {
237
        fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
238
        goto fail;
239
    }
234
    if (binfo->dtb_filename) {
235
        char *filename;
236
        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, binfo->dtb_filename);
237
        if (!filename) {
238
            fprintf(stderr, "Couldn't open dtb file %s\n", binfo->dtb_filename);
239
            goto fail;
240
        }
240 241

  
241
    fdt = load_device_tree(filename, &size);
242
    if (!fdt) {
243
        fprintf(stderr, "Couldn't open dtb file %s\n", filename);
242
        fdt = load_device_tree(filename, &size);
243
        if (!fdt) {
244
            fprintf(stderr, "Couldn't open dtb file %s\n", filename);
245
            g_free(filename);
246
            goto fail;
247
        }
244 248
        g_free(filename);
245
        goto fail;
249
    } else if (binfo->get_dtb) {
250
        fdt = binfo->get_dtb(binfo, &size);
251
        if (!fdt) {
252
            fprintf(stderr, "Board was unable to create a dtb blob\n");
253
            goto fail;
254
        }
246 255
    }
247
    g_free(filename);
248 256

  
249 257
    acells = qemu_devtree_getprop_cell(fdt, "/", "#address-cells");
250 258
    scells = qemu_devtree_getprop_cell(fdt, "/", "#size-cells");
......
438 446
        /* for device tree boot, we pass the DTB directly in r2. Otherwise
439 447
         * we point to the kernel args.
440 448
         */
441
        if (info->dtb_filename) {
449
        if (info->dtb_filename || info->get_dtb) {
442 450
            /* Place the DTB after the initrd in memory. Note that some
443 451
             * kernels will trash anything in the 4K page the initrd
444 452
             * ends in, so make sure the DTB isn't caught up in that.
b/include/hw/arm/arm.h
50 50
                                 const struct arm_boot_info *info);
51 51
    void (*secondary_cpu_reset_hook)(ARMCPU *cpu,
52 52
                                     const struct arm_boot_info *info);
53
    /* if a board is able to create a dtb without a dtb file then it
54
     * sets get_dtb. This will only be used if no dtb file is provided
55
     * by the user. On success, sets *size to the length of the created
56
     * dtb, and returns a pointer to it. (The caller must free this memory
57
     * with g_free() when it has finished with it.) On failure, returns NULL.
58
     */
59
    void *(*get_dtb)(const struct arm_boot_info *info, int *size);
53 60
    /* if a board needs to be able to modify a device tree provided by
54 61
     * the user it should implement this hook.
55 62
     */

Also available in: Unified diff