void arm_load_kernel(CPUState *env, struct arm_boot_info *info)

{

    int kernel_size;

    int initrd_size;

    int n;

    int is_linux = 0;

    uint64_t elf_entry;

    target_phys_addr_t entry;

    int big_endian;



    /* Load the kernel.  */

    if (!info->kernel_filename) {

        fprintf(stderr, "Kernel image must be specified\n");

        exit(1);

    }



    if (!info->secondary_cpu_reset_hook) {

        info->secondary_cpu_reset_hook = default_reset_secondary;

    }

    if (!info->write_secondary_boot) {

        info->write_secondary_boot = default_write_secondary;

    }



    if (info->nb_cpus == 0)

        info->nb_cpus = 1;



#ifdef TARGET_WORDS_BIGENDIAN

    big_endian = 1;

#else

    big_endian = 0;

#endif



    /* Assume that raw images are linux kernels, and ELF images are not.  */

    kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,

                           NULL, NULL, big_endian, ELF_MACHINE, 1);

    entry = elf_entry;

    if (kernel_size < 0) {

        kernel_size = load_uimage(info->kernel_filename, &entry, NULL,

                                  &is_linux);

    }

    if (kernel_size < 0) {

        entry = info->loader_start + KERNEL_LOAD_ADDR;

        kernel_size = load_image_targphys(info->kernel_filename, entry,

                                          ram_size - KERNEL_LOAD_ADDR);

        is_linux = 1;

    }

    if (kernel_size < 0) {

        fprintf(stderr, "qemu: could not load kernel '%s'\n",

                info->kernel_filename);

        exit(1);

    }

    info->entry = entry;

    if (is_linux) {

        if (info->initrd_filename) {

            initrd_size = load_image_targphys(info->initrd_filename,

                                              info->loader_start

                                              + INITRD_LOAD_ADDR,

                                              ram_size - INITRD_LOAD_ADDR);

            if (initrd_size < 0) {

                fprintf(stderr, "qemu: could not load initrd '%s'\n",

                        info->initrd_filename);

                exit(1);

            }

        } else {

            initrd_size = 0;

        }

        bootloader[1] |= info->board_id & 0xff;

        bootloader[2] |= (info->board_id >> 8) & 0xff;

        bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;

        bootloader[6] = entry;

        for (n = 0; n < sizeof(bootloader) / 4; n++) {

            bootloader[n] = tswap32(bootloader[n]);

        }

        rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),

                           info->loader_start);

        if (info->nb_cpus > 1) {

            info->write_secondary_boot(env, info);

        }

        info->initrd_size = initrd_size;

    }

    info->is_linux = is_linux;



    for (; env; env = env->next_cpu) {

        env->boot_info = info;

        qemu_register_reset(do_cpu_reset, env);

    }

}

void arm_load_kernel(CPUState *env, struct arm_boot_info *info)

{

    int kernel_size;

    int initrd_size;

    int n;

    int is_linux = 0;

    uint64_t elf_entry;

    target_phys_addr_t entry;

    int big_endian;



    

    if (!info->kernel_filename) {

        fprintf(stderr, "Kernel image must be specified\n");

        exit(1);

    }



    if (!info->secondary_cpu_reset_hook) {

        info->secondary_cpu_reset_hook = default_reset_secondary;

    }

    if (!info->write_secondary_boot) {

        info->write_secondary_boot = default_write_secondary;

    }



    if (info->nb_cpus == 0)

        info->nb_cpus = 1;



#ifdef TARGET_WORDS_BIGENDIAN

    big_endian = 1;

#else

    big_endian = 0;

#endif



    

    kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,

                           NULL, NULL, big_endian, ELF_MACHINE, 1);

    entry = elf_entry;

    if (kernel_size < 0) {

        kernel_size = load_uimage(info->kernel_filename, &entry, NULL,

                                  &is_linux);

    }

    if (kernel_size < 0) {

        entry = info->loader_start + KERNEL_LOAD_ADDR;

        kernel_size = load_image_targphys(info->kernel_filename, entry,

                                          ram_size - KERNEL_LOAD_ADDR);

        is_linux = 1;

    }

    if (kernel_size < 0) {

        fprintf(stderr, "qemu: could not load kernel '%s'\n",

                info->kernel_filename);

        exit(1);

    }

    info->entry = entry;

    if (is_linux) {

        if (info->initrd_filename) {

            initrd_size = load_image_targphys(info->initrd_filename,

                                              info->loader_start

                                              + INITRD_LOAD_ADDR,

                                              ram_size - INITRD_LOAD_ADDR);

            if (initrd_size < 0) {

                fprintf(stderr, "qemu: could not load initrd '%s'\n",

                        info->initrd_filename);

                exit(1);

            }

        } else {

            initrd_size = 0;

        }

        bootloader[1] |= info->board_id & 0xff;

        bootloader[2] |= (info->board_id >> 8) & 0xff;

        bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;

        bootloader[6] = entry;

        for (n = 0; n < sizeof(bootloader) / 4; n++) {

            bootloader[n] = tswap32(bootloader[n]);

        }

        rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),

                           info->loader_start);

        if (info->nb_cpus > 1) {

            info->write_secondary_boot(env, info);

        }

        info->initrd_size = initrd_size;

    }

    info->is_linux = is_linux;



    for (; env; env = env->next_cpu) {

        env->boot_info = info;

        qemu_register_reset(do_cpu_reset, env);

    }

}

void FUNC_0(CPUState *VAR_0, struct arm_boot_info *VAR_1)

{

    int VAR_2;

    int VAR_3;

    int VAR_4;

    int VAR_5 = 0;

    uint64_t elf_entry;

    target_phys_addr_t entry;

    int VAR_6;



    

    if (!VAR_1->kernel_filename) {

        fprintf(stderr, "Kernel image must be specified\VAR_4");

        exit(1);

    }



    if (!VAR_1->secondary_cpu_reset_hook) {

        VAR_1->secondary_cpu_reset_hook = default_reset_secondary;

    }

    if (!VAR_1->write_secondary_boot) {

        VAR_1->write_secondary_boot = default_write_secondary;

    }



    if (VAR_1->nb_cpus == 0)

        VAR_1->nb_cpus = 1;



#ifdef TARGET_WORDS_BIGENDIAN

    VAR_6 = 1;

#else

    VAR_6 = 0;

#endif



    

    VAR_2 = load_elf(VAR_1->kernel_filename, NULL, NULL, &elf_entry,

                           NULL, NULL, VAR_6, ELF_MACHINE, 1);

    entry = elf_entry;

    if (VAR_2 < 0) {

        VAR_2 = load_uimage(VAR_1->kernel_filename, &entry, NULL,

                                  &VAR_5);

    }

    if (VAR_2 < 0) {

        entry = VAR_1->loader_start + KERNEL_LOAD_ADDR;

        VAR_2 = load_image_targphys(VAR_1->kernel_filename, entry,

                                          ram_size - KERNEL_LOAD_ADDR);

        VAR_5 = 1;

    }

    if (VAR_2 < 0) {

        fprintf(stderr, "qemu: could not load kernel '%s'\VAR_4",

                VAR_1->kernel_filename);

        exit(1);

    }

    VAR_1->entry = entry;

    if (VAR_5) {

        if (VAR_1->initrd_filename) {

            VAR_3 = load_image_targphys(VAR_1->initrd_filename,

                                              VAR_1->loader_start

                                              + INITRD_LOAD_ADDR,

                                              ram_size - INITRD_LOAD_ADDR);

            if (VAR_3 < 0) {

                fprintf(stderr, "qemu: could not load initrd '%s'\VAR_4",

                        VAR_1->initrd_filename);

                exit(1);

            }

        } else {

            VAR_3 = 0;

        }

        bootloader[1] |= VAR_1->board_id & 0xff;

        bootloader[2] |= (VAR_1->board_id >> 8) & 0xff;

        bootloader[5] = VAR_1->loader_start + KERNEL_ARGS_ADDR;

        bootloader[6] = entry;

        for (VAR_4 = 0; VAR_4 < sizeof(bootloader) / 4; VAR_4++) {

            bootloader[VAR_4] = tswap32(bootloader[VAR_4]);

        }

        rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),

                           VAR_1->loader_start);

        if (VAR_1->nb_cpus > 1) {

            VAR_1->write_secondary_boot(VAR_0, VAR_1);

        }

        VAR_1->VAR_3 = VAR_3;

    }

    VAR_1->VAR_5 = VAR_5;



    for (; VAR_0; VAR_0 = VAR_0->next_cpu) {

        VAR_0->boot_info = VAR_1;

        qemu_register_reset(do_cpu_reset, VAR_0);

    }

}

void FUNC_0(CPUState *VAR_0, struct arm_boot_info *VAR_1)
{ int VAR_2; int VAR_3; int VAR_4; int VAR_5 = 0; uint64_t elf_entry; target_phys_addr_t entry; int VAR_6; if (!VAR_1->kernel_filename) { fprintf(stderr, "Kernel image must be specified\VAR_4"); exit(1); } if (!VAR_1->secondary_cpu_reset_hook) { VAR_1->secondary_cpu_reset_hook = default_reset_secondary; } if (!VAR_1->write_secondary_boot) { VAR_1->write_secondary_boot = default_write_secondary; } if (VAR_1->nb_cpus == 0)
VAR_1->nb_cpus = 1; #ifdef TARGET_WORDS_BIGENDIAN
VAR_6 = 1; #else
VAR_6 = 0; #endif
VAR_2 = load_elf(VAR_1->kernel_filename, NULL, NULL, &elf_entry,
NULL, NULL, VAR_6, ELF_MACHINE, 1); entry = elf_entry; if (VAR_2 < 0) { VAR_2 = load_uimage(VAR_1->kernel_filename, &entry, NULL,
&VAR_5); } if (VAR_2 < 0) { entry = VAR_1->loader_start + KERNEL_LOAD_ADDR; VAR_2 = load_image_targphys(VAR_1->kernel_filename, entry,
ram_size - KERNEL_LOAD_ADDR); VAR_5 = 1; } if (VAR_2 < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\VAR_4",
VAR_1->kernel_filename); exit(1); } VAR_1->entry = entry; if (VAR_5) { if (VAR_1->initrd_filename) { VAR_3 = load_image_targphys(VAR_1->initrd_filename,
VAR_1->loader_start
+ INITRD_LOAD_ADDR,
ram_size - INITRD_LOAD_ADDR); if (VAR_3 < 0) { fprintf(stderr, "qemu: could not load initrd '%s'\VAR_4",
VAR_1->initrd_filename); exit(1); } } else { VAR_3 = 0; } bootloader[1] |= VAR_1->board_id & 0xff; bootloader[2] |= (VAR_1->board_id >> 8) & 0xff; bootloader[5] = VAR_1->loader_start + KERNEL_ARGS_ADDR; bootloader[6] = entry; for (VAR_4 = 0; VAR_4 < sizeof(bootloader) / 4; VAR_4++) { bootloader[VAR_4] = tswap32(bootloader[VAR_4]); } rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader),
VAR_1->loader_start); if (VAR_1->nb_cpus > 1) { VAR_1->write_secondary_boot(VAR_0, VAR_1); } VAR_1->VAR_3 = VAR_3; } VAR_1->VAR_5 = VAR_5; for (; VAR_0; VAR_0 = VAR_0->next_cpu) { VAR_0->boot_info = VAR_1; qemu_register_reset(do_cpu_reset, VAR_0); } }