static void sun4m_load_kernel(long vram_size, int ram_size, int boot_device,

                              const char *kernel_filename,

                              const char *kernel_cmdline,

                              const char *initrd_filename,

                              int machine_id)

{

    int ret, linux_boot;

    char buf[1024];

    unsigned int i;

    long prom_offset, initrd_size, kernel_size;



    linux_boot = (kernel_filename != NULL);



    prom_offset = ram_size + vram_size;

    cpu_register_physical_memory(PROM_ADDR, 

                                 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK, 

                                 prom_offset | IO_MEM_ROM);



    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME);

    ret = load_elf(buf, 0, NULL, NULL, NULL);

    if (ret < 0) {

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

		buf);

	exit(1);

    }



    kernel_size = 0;

    if (linux_boot) {

        kernel_size = load_elf(kernel_filename, -0xf0000000, NULL, NULL, NULL);

        if (kernel_size < 0)

	    kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);

	if (kernel_size < 0)

	    kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);

        if (kernel_size < 0) {

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

                    kernel_filename);

	    exit(1);

        }



        /* load initrd */

        initrd_size = 0;

        if (initrd_filename) {

            initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);

            if (initrd_size < 0) {

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

                        initrd_filename);

                exit(1);

            }

        }

        if (initrd_size > 0) {

	    for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {

		if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)

		    == 0x48647253) { // HdrS

		    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);

		    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);

		    break;

		}

	    }

        }

    }

    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,

               boot_device, ram_size, kernel_size, graphic_width,

               graphic_height, graphic_depth, machine_id);

}

static void sun4m_load_kernel(long vram_size, int ram_size, int boot_device,

                              const char *kernel_filename,

                              const char *kernel_cmdline,

                              const char *initrd_filename,

                              int machine_id)

{

    int ret, linux_boot;

    char buf[1024];

    unsigned int i;

    long prom_offset, initrd_size, kernel_size;



    linux_boot = (kernel_filename != NULL);



    prom_offset = ram_size + vram_size;

    cpu_register_physical_memory(PROM_ADDR, 

                                 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK, 

                                 prom_offset | IO_MEM_ROM);



    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME);

    ret = load_elf(buf, 0, NULL, NULL, NULL);

    if (ret < 0) {

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

		buf);

	exit(1);

    }



    kernel_size = 0;

    if (linux_boot) {

        kernel_size = load_elf(kernel_filename, -0xf0000000, NULL, NULL, NULL);

        if (kernel_size < 0)

	    kernel_size = load_aout(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);

	if (kernel_size < 0)

	    kernel_size = load_image(kernel_filename, phys_ram_base + KERNEL_LOAD_ADDR);

        if (kernel_size < 0) {

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

                    kernel_filename);

	    exit(1);

        }



        

        initrd_size = 0;

        if (initrd_filename) {

            initrd_size = load_image(initrd_filename, phys_ram_base + INITRD_LOAD_ADDR);

            if (initrd_size < 0) {

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

                        initrd_filename);

                exit(1);

            }

        }

        if (initrd_size > 0) {

	    for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {

		if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i)

		    == 0x48647253) { 

		    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 16, INITRD_LOAD_ADDR);

		    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + i + 20, initrd_size);

		    break;

		}

	    }

        }

    }

    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,

               boot_device, ram_size, kernel_size, graphic_width,

               graphic_height, graphic_depth, machine_id);

}

static void FUNC_0(long VAR_0, int VAR_1, int VAR_2,

                              const char *VAR_3,

                              const char *VAR_4,

                              const char *VAR_5,

                              int VAR_6)

{

    int VAR_7, VAR_8;

    char VAR_9[1024];

    unsigned int VAR_10;

    long VAR_11, VAR_12, VAR_13;



    VAR_8 = (VAR_3 != NULL);



    VAR_11 = VAR_1 + VAR_0;

    cpu_register_physical_memory(PROM_ADDR, 

                                 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK, 

                                 VAR_11 | IO_MEM_ROM);



    snprintf(VAR_9, sizeof(VAR_9), "%s/%s", bios_dir, PROM_FILENAME);

    VAR_7 = load_elf(VAR_9, 0, NULL, NULL, NULL);

    if (VAR_7 < 0) {

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

		VAR_9);

	exit(1);

    }



    VAR_13 = 0;

    if (VAR_8) {

        VAR_13 = load_elf(VAR_3, -0xf0000000, NULL, NULL, NULL);

        if (VAR_13 < 0)

	    VAR_13 = load_aout(VAR_3, phys_ram_base + KERNEL_LOAD_ADDR);

	if (VAR_13 < 0)

	    VAR_13 = load_image(VAR_3, phys_ram_base + KERNEL_LOAD_ADDR);

        if (VAR_13 < 0) {

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

                    VAR_3);

	    exit(1);

        }



        

        VAR_12 = 0;

        if (VAR_5) {

            VAR_12 = load_image(VAR_5, phys_ram_base + INITRD_LOAD_ADDR);

            if (VAR_12 < 0) {

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

                        VAR_5);

                exit(1);

            }

        }

        if (VAR_12 > 0) {

	    for (VAR_10 = 0; VAR_10 < 64 * TARGET_PAGE_SIZE; VAR_10 += TARGET_PAGE_SIZE) {

		if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + VAR_10)

		    == 0x48647253) { 

		    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + VAR_10 + 16, INITRD_LOAD_ADDR);

		    stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + VAR_10 + 20, VAR_12);

		    break;

		}

	    }

        }

    }

    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, VAR_4,

               VAR_2, VAR_1, VAR_13, graphic_width,

               graphic_height, graphic_depth, VAR_6);

}

static void FUNC_0(long VAR_0, int VAR_1, int VAR_2,
const char *VAR_3,
const char *VAR_4,
const char *VAR_5,
int VAR_6)
{ int VAR_7, VAR_8; char VAR_9[1024]; unsigned int VAR_10; long VAR_11, VAR_12, VAR_13; VAR_8 = (VAR_3 != NULL); VAR_11 = VAR_1 + VAR_0; cpu_register_physical_memory(PROM_ADDR,
(PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK,
VAR_11 | IO_MEM_ROM); snprintf(VAR_9, sizeof(VAR_9), "%s/%s", bios_dir, PROM_FILENAME); VAR_7 = load_elf(VAR_9, 0, NULL, NULL, NULL); if (VAR_7 < 0) { fprintf(stderr, "qemu: could not load prom '%s'\n",
VAR_9); exit(1); } VAR_13 = 0; if (VAR_8) { VAR_13 = load_elf(VAR_3, -0xf0000000, NULL, NULL, NULL); if (VAR_13 < 0)
VAR_13 = load_aout(VAR_3, phys_ram_base + KERNEL_LOAD_ADDR); if (VAR_13 < 0)
VAR_13 = load_image(VAR_3, phys_ram_base + KERNEL_LOAD_ADDR); if (VAR_13 < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n",
VAR_3); exit(1); } VAR_12 = 0; if (VAR_5) { VAR_12 = load_image(VAR_5, phys_ram_base + INITRD_LOAD_ADDR); if (VAR_12 < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
VAR_5); exit(1); } } if (VAR_12 > 0) { for (VAR_10 = 0; VAR_10 < 64 * TARGET_PAGE_SIZE; VAR_10 += TARGET_PAGE_SIZE) { if (ldl_raw(phys_ram_base + KERNEL_LOAD_ADDR + VAR_10)
== 0x48647253) { stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + VAR_10 + 16, INITRD_LOAD_ADDR); stl_raw(phys_ram_base + KERNEL_LOAD_ADDR + VAR_10 + 20, VAR_12); break; } } } } nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, VAR_4,
VAR_2, VAR_1, VAR_13, graphic_width,
graphic_height, graphic_depth, VAR_6); }