static void spapr_finalize_fdt(sPAPREnvironment *spapr,

                               target_phys_addr_t fdt_addr,

                               target_phys_addr_t rtas_addr,

                               target_phys_addr_t rtas_size)

{

    int ret;

    void *fdt;

    sPAPRPHBState *phb;



    fdt = g_malloc(FDT_MAX_SIZE);



    /* open out the base tree into a temp buffer for the final tweaks */

    _FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE)));



    ret = spapr_populate_vdevice(spapr->vio_bus, fdt);

    if (ret < 0) {

        fprintf(stderr, "couldn't setup vio devices in fdt\n");

        exit(1);

    }



    QLIST_FOREACH(phb, &spapr->phbs, list) {

        ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);

    }



    if (ret < 0) {

        fprintf(stderr, "couldn't setup PCI devices in fdt\n");

        exit(1);

    }



    /* RTAS */

    ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);

    if (ret < 0) {

        fprintf(stderr, "Couldn't set up RTAS device tree properties\n");

    }



    /* Advertise NUMA via ibm,associativity */

    if (nb_numa_nodes > 1) {

        ret = spapr_set_associativity(fdt, spapr);

        if (ret < 0) {

            fprintf(stderr, "Couldn't set up NUMA device tree properties\n");

        }

    }



    if (!spapr->has_graphics) {

        spapr_populate_chosen_stdout(fdt, spapr->vio_bus);

    }



    _FDT((fdt_pack(fdt)));



    if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {

        hw_error("FDT too big ! 0x%x bytes (max is 0x%x)\n",

                 fdt_totalsize(fdt), FDT_MAX_SIZE);

        exit(1);

    }



    cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));



    g_free(fdt);

}

static void spapr_finalize_fdt(sPAPREnvironment *spapr,

                               target_phys_addr_t fdt_addr,

                               target_phys_addr_t rtas_addr,

                               target_phys_addr_t rtas_size)

{

    int ret;

    void *fdt;

    sPAPRPHBState *phb;



    fdt = g_malloc(FDT_MAX_SIZE);



    

    _FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE)));



    ret = spapr_populate_vdevice(spapr->vio_bus, fdt);

    if (ret < 0) {

        fprintf(stderr, "couldn't setup vio devices in fdt\n");

        exit(1);

    }



    QLIST_FOREACH(phb, &spapr->phbs, list) {

        ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);

    }



    if (ret < 0) {

        fprintf(stderr, "couldn't setup PCI devices in fdt\n");

        exit(1);

    }



    

    ret = spapr_rtas_device_tree_setup(fdt, rtas_addr, rtas_size);

    if (ret < 0) {

        fprintf(stderr, "Couldn't set up RTAS device tree properties\n");

    }



    

    if (nb_numa_nodes > 1) {

        ret = spapr_set_associativity(fdt, spapr);

        if (ret < 0) {

            fprintf(stderr, "Couldn't set up NUMA device tree properties\n");

        }

    }



    if (!spapr->has_graphics) {

        spapr_populate_chosen_stdout(fdt, spapr->vio_bus);

    }



    _FDT((fdt_pack(fdt)));



    if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {

        hw_error("FDT too big ! 0x%x bytes (max is 0x%x)\n",

                 fdt_totalsize(fdt), FDT_MAX_SIZE);

        exit(1);

    }



    cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));



    g_free(fdt);

}

    if (nb_numa_nodes > 1) {         ret = spapr_set_associativity(fdt, spapr);         if (ret < 0) {             fprintf(stderr, "Couldn't set up NUMA device tree properties\n");
static void FUNC_0(sPAPREnvironment *VAR_0,

                               target_phys_addr_t VAR_1,

                               target_phys_addr_t VAR_2,

                               target_phys_addr_t VAR_3)

{

    int VAR_4;

    void *VAR_5;

    sPAPRPHBState *phb;



    VAR_5 = g_malloc(FDT_MAX_SIZE);



    

    _FDT((fdt_open_into(VAR_0->fdt_skel, VAR_5, FDT_MAX_SIZE)));



    VAR_4 = spapr_populate_vdevice(VAR_0->vio_bus, VAR_5);

    if (VAR_4 < 0) {

        fprintf(stderr, "couldn't setup vio devices in VAR_5\n");

        exit(1);

    }



    QLIST_FOREACH(phb, &VAR_0->phbs, list) {

        VAR_4 = spapr_populate_pci_dt(phb, PHANDLE_XICP, VAR_5);

    }



    if (VAR_4 < 0) {

        fprintf(stderr, "couldn't setup PCI devices in VAR_5\n");

        exit(1);

    }



    

    VAR_4 = spapr_rtas_device_tree_setup(VAR_5, VAR_2, VAR_3);

    if (VAR_4 < 0) {

        fprintf(stderr, "Couldn't set up RTAS device tree properties\n");

    }



    

    if (nb_numa_nodes > 1) {

        VAR_4 = spapr_set_associativity(VAR_5, VAR_0);

        if (VAR_4 < 0) {

            fprintf(stderr, "Couldn't set up NUMA device tree properties\n");

        }

    }



    if (!VAR_0->has_graphics) {

        spapr_populate_chosen_stdout(VAR_5, VAR_0->vio_bus);

    }



    _FDT((fdt_pack(VAR_5)));



    if (fdt_totalsize(VAR_5) > FDT_MAX_SIZE) {

        hw_error("FDT too big ! 0x%x bytes (max is 0x%x)\n",

                 fdt_totalsize(VAR_5), FDT_MAX_SIZE);

        exit(1);

    }



    cpu_physical_memory_write(VAR_1, VAR_5, fdt_totalsize(VAR_5));



    g_free(VAR_5);

}

static void FUNC_0(sPAPREnvironment *VAR_0,
target_phys_addr_t VAR_1,
target_phys_addr_t VAR_2,
target_phys_addr_t VAR_3)
{ int VAR_4; void *VAR_5; sPAPRPHBState *phb; VAR_5 = g_malloc(FDT_MAX_SIZE); _FDT((fdt_open_into(VAR_0->fdt_skel, VAR_5, FDT_MAX_SIZE))); VAR_4 = spapr_populate_vdevice(VAR_0->vio_bus, VAR_5); if (VAR_4 < 0) { fprintf(stderr, "couldn't setup vio devices in VAR_5\n"); exit(1); } QLIST_FOREACH(phb, &VAR_0->phbs, list) { VAR_4 = spapr_populate_pci_dt(phb, PHANDLE_XICP, VAR_5); } if (VAR_4 < 0) { fprintf(stderr, "couldn't setup PCI devices in VAR_5\n"); exit(1); } VAR_4 = spapr_rtas_device_tree_setup(VAR_5, VAR_2, VAR_3); if (VAR_4 < 0) { fprintf(stderr, "Couldn't set up RTAS device tree properties\n"); } if (nb_numa_nodes > 1) { VAR_4 = spapr_set_associativity(VAR_5, VAR_0); if (VAR_4 < 0) { fprintf(stderr, "Couldn't set up NUMA device tree properties\n"); } } if (!VAR_0->has_graphics) { spapr_populate_chosen_stdout(VAR_5, VAR_0->vio_bus); } _FDT((fdt_pack(VAR_5))); if (fdt_totalsize(VAR_5) > FDT_MAX_SIZE) { hw_error("FDT too big ! 0x%x bytes (max is 0x%x)\n",
fdt_totalsize(VAR_5), FDT_MAX_SIZE); exit(1); } cpu_physical_memory_write(VAR_1, VAR_5, fdt_totalsize(VAR_5)); g_free(VAR_5); }