FDTMachineInfo *fdt_generic_create_machine(void *fdt, qemu_irq *cpu_irq) { char node_path[DT_PATH_LENGTH]; FDTMachineInfo *fdti = fdt_init_new_fdti(fdt); fdti->irq_base = cpu_irq; /* parse the device tree */ if (!qemu_devtree_get_root_node(fdt, node_path)) { memory_region_transaction_begin(); fdt_init_set_opaque(fdti, node_path, NULL); simple_bus_fdt_init(node_path, fdti); while (qemu_co_enter_next(fdti->cq)); fdt_init_all_irqs(fdti); memory_region_transaction_commit(); } else { fprintf(stderr, "FDT: ERROR: cannot get root node from device tree %s\n" , node_path); } DB_PRINT(0, "FDT: Device tree scan complete\n"); FDTMachineInfo *ret = g_malloc0(sizeof(*ret)); return fdti; }
FDTMachineInfo *fdt_generic_create_machine(void *fdt, qemu_irq cpu_irq) { char node_path[DT_PATH_LENGTH]; FDTMachineInfo *fdti = fdt_init_new_fdti(fdt); fdti->irq_base = cpu_irq; /* bind any force bound instances */ fdt_force_bind_all(fdti); /* parse the device tree */ if (!qemu_fdt_get_root_node(fdt, node_path)) { simple_bus_fdt_init(node_path, fdti, NULL); while (qemu_co_enter_next(fdti->cq)); } else { fprintf(stderr, "FDT: ERROR: cannot get root node from device tree %s\n" , node_path); } DB_PRINT("FDT: Device tree scan complete\n"); FDTMachineInfo *ret = g_malloc0(sizeof(*ret)); return fdti; }
static void fdt_init_node(void *args) { struct FDTInitNodeArgs *a = args; char *node_path = a->node_path; FDTMachineInfo *fdti = a->fdti; g_free(a); simple_bus_fdt_init(node_path, fdti); char *all_compats = NULL, *compat, *node_name, *next_compat, *device_type; int compat_len; DB_PRINT_NP(1, "enter\n"); /* try instance binding first */ node_name = qemu_devtree_get_node_name(fdti->fdt, node_path); DB_PRINT_NP(1, "node with name: %s\n", node_name ? node_name : "(none)"); if (!node_name) { printf("FDT: ERROR: nameless node: %s\n", node_path); } if (!fdt_init_inst_bind(node_path, fdti, node_name)) { DB_PRINT_NP(0, "instance bind successful\n"); goto exit; } /* fallback to compatibility binding */ all_compats = qemu_fdt_getprop(fdti->fdt, node_path, "compatible", &compat_len, false, NULL); if (!all_compats) { DB_PRINT_NP(0, "no compatibility found\n"); } for (compat = all_compats; compat && compat_len; compat = next_compat+1) { char *compat_prefixed = g_strdup_printf("compatible:%s", compat); if (!fdt_init_compat(node_path, fdti, compat_prefixed)) { goto exit; } g_free(compat_prefixed); if (!fdt_init_qdev(node_path, fdti, compat)) { goto exit; } next_compat = rawmemchr(compat, '\0'); compat_len -= (next_compat + 1 - compat); if (compat_len > 0) { *next_compat = ' '; } } device_type = qemu_fdt_getprop(fdti->fdt, node_path, "device_type", NULL, false, NULL); device_type = g_strdup_printf("device_type:%s", device_type); if (!fdt_init_compat(node_path, fdti, device_type)) { goto exit; } if (!all_compats) { goto exit; } DB_PRINT_NP(0, "FDT: Unsupported peripheral invalidated - " "compatibilities %s\n", all_compats); qemu_fdt_setprop_string(fdti->fdt, node_path, "compatible", "invalidated"); exit: DB_PRINT_NP(1, "exit\n"); if (!fdt_init_has_opaque(fdti, node_path)) { fdt_init_set_opaque(fdti, node_path, NULL); } g_free(node_path); g_free(all_compats); return; }