void load_kernel (CPUState *env, int ram_size, const char *kernel_filename,

		  const char *kernel_cmdline,

		  const char *initrd_filename)

{

    int64_t entry = 0;

    long kernel_size, initrd_size;



    kernel_size = load_elf(kernel_filename, VIRT_TO_PHYS_ADDEND, &entry);

    if (kernel_size >= 0) {

        if ((entry & ~0x7fffffffULL) == 0x80000000)

            entry = (int32_t)entry;

        env->PC = entry;

    } else {

        kernel_size = load_image(kernel_filename,

                                 phys_ram_base + KERNEL_LOAD_ADDR + VIRT_TO_PHYS_ADDEND);

        if (kernel_size < 0) {

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

                    kernel_filename);

            exit(1);

        }

        env->PC = KERNEL_LOAD_ADDR;

    }



    /* load initrd */

    initrd_size = 0;

    if (initrd_filename) {

        initrd_size = load_image(initrd_filename,

                                 phys_ram_base + INITRD_LOAD_ADDR + VIRT_TO_PHYS_ADDEND);

        if (initrd_size == (target_ulong) -1) {

            fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",

                    initrd_filename);

            exit(1);

        }

    }



    /* Store command line.  */

    if (initrd_size > 0) {

        int ret;

        ret = sprintf(phys_ram_base + (16 << 20) - 256,

                      "rd_start=0x" TLSZ " rd_size=%li ",

                      INITRD_LOAD_ADDR,

                      initrd_size);

        strcpy (phys_ram_base + (16 << 20) - 256 + ret, kernel_cmdline);

    }

    else {

        strcpy (phys_ram_base + (16 << 20) - 256, kernel_cmdline);

    }



    *(int *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678);

    *(int *)(phys_ram_base + (16 << 20) - 264) = tswap32 (ram_size);

}

void load_kernel (CPUState *env, int ram_size, const char *kernel_filename,

		  const char *kernel_cmdline,

		  const char *initrd_filename)

{

    int64_t entry = 0;

    long kernel_size, initrd_size;



    kernel_size = load_elf(kernel_filename, VIRT_TO_PHYS_ADDEND, &entry);

    if (kernel_size >= 0) {

        if ((entry & ~0x7fffffffULL) == 0x80000000)

            entry = (int32_t)entry;

        env->PC = entry;

    } else {

        kernel_size = load_image(kernel_filename,

                                 phys_ram_base + KERNEL_LOAD_ADDR + VIRT_TO_PHYS_ADDEND);

        if (kernel_size < 0) {

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

                    kernel_filename);

            exit(1);

        }

        env->PC = KERNEL_LOAD_ADDR;

    }



    

    initrd_size = 0;

    if (initrd_filename) {

        initrd_size = load_image(initrd_filename,

                                 phys_ram_base + INITRD_LOAD_ADDR + VIRT_TO_PHYS_ADDEND);

        if (initrd_size == (target_ulong) -1) {

            fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",

                    initrd_filename);

            exit(1);

        }

    }



    

    if (initrd_size > 0) {

        int ret;

        ret = sprintf(phys_ram_base + (16 << 20) - 256,

                      "rd_start=0x" TLSZ " rd_size=%li ",

                      INITRD_LOAD_ADDR,

                      initrd_size);

        strcpy (phys_ram_base + (16 << 20) - 256 + ret, kernel_cmdline);

    }

    else {

        strcpy (phys_ram_base + (16 << 20) - 256, kernel_cmdline);

    }



    *(int *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678);

    *(int *)(phys_ram_base + (16 << 20) - 264) = tswap32 (ram_size);

}

void FUNC_0 (CPUState *VAR_0, int VAR_1, const char *VAR_2,

		  const char *VAR_3,

		  const char *VAR_4)

{

    int64_t entry = 0;

    long VAR_5, VAR_6;



    VAR_5 = load_elf(VAR_2, VIRT_TO_PHYS_ADDEND, &entry);

    if (VAR_5 >= 0) {

        if ((entry & ~0x7fffffffULL) == 0x80000000)

            entry = (int32_t)entry;

        VAR_0->PC = entry;

    } else {

        VAR_5 = load_image(VAR_2,

                                 phys_ram_base + KERNEL_LOAD_ADDR + VIRT_TO_PHYS_ADDEND);

        if (VAR_5 < 0) {

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

                    VAR_2);

            exit(1);

        }

        VAR_0->PC = KERNEL_LOAD_ADDR;

    }



    

    VAR_6 = 0;

    if (VAR_4) {

        VAR_6 = load_image(VAR_4,

                                 phys_ram_base + INITRD_LOAD_ADDR + VIRT_TO_PHYS_ADDEND);

        if (VAR_6 == (target_ulong) -1) {

            fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",

                    VAR_4);

            exit(1);

        }

    }



    

    if (VAR_6 > 0) {

        int VAR_7;

        VAR_7 = sprintf(phys_ram_base + (16 << 20) - 256,

                      "rd_start=0x" TLSZ " rd_size=%li ",

                      INITRD_LOAD_ADDR,

                      VAR_6);

        strcpy (phys_ram_base + (16 << 20) - 256 + VAR_7, VAR_3);

    }

    else {

        strcpy (phys_ram_base + (16 << 20) - 256, VAR_3);

    }



    *(int *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678);

    *(int *)(phys_ram_base + (16 << 20) - 264) = tswap32 (VAR_1);

}

void FUNC_0 (CPUState *VAR_0, int VAR_1, const char *VAR_2,
const char *VAR_3,
const char *VAR_4)
{ int64_t entry = 0; long VAR_5, VAR_6; VAR_5 = load_elf(VAR_2, VIRT_TO_PHYS_ADDEND, &entry); if (VAR_5 >= 0) { if ((entry & ~0x7fffffffULL) == 0x80000000)
entry = (int32_t)entry; VAR_0->PC = entry; } else { VAR_5 = load_image(VAR_2,
phys_ram_base + KERNEL_LOAD_ADDR + VIRT_TO_PHYS_ADDEND); if (VAR_5 < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n",
VAR_2); exit(1); } VAR_0->PC = KERNEL_LOAD_ADDR; } VAR_6 = 0; if (VAR_4) { VAR_6 = load_image(VAR_4,
phys_ram_base + INITRD_LOAD_ADDR + VIRT_TO_PHYS_ADDEND); if (VAR_6 == (target_ulong) -1) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
VAR_4); exit(1); } } if (VAR_6 > 0) { int VAR_7; VAR_7 = sprintf(phys_ram_base + (16 << 20) - 256,
"rd_start=0x" TLSZ " rd_size=%li ",
INITRD_LOAD_ADDR,
VAR_6); strcpy (phys_ram_base + (16 << 20) - 256 + VAR_7, VAR_3); } else { strcpy (phys_ram_base + (16 << 20) - 256, VAR_3); } *(int *)(phys_ram_base + (16 << 20) - 260) = tswap32 (0x12345678); *(int *)(phys_ram_base + (16 << 20) - 264) = tswap32 (VAR_1); }