static void palmte_init(ram_addr_t ram_size, int vga_ram_size,

                const char *boot_device,

                const char *kernel_filename, const char *kernel_cmdline,

                const char *initrd_filename, const char *cpu_model)

{

    struct omap_mpu_state_s *cpu;

    int flash_size = 0x00800000;

    int sdram_size = palmte_binfo.ram_size;

    int io;

    static uint32_t cs0val = 0xffffffff;

    static uint32_t cs1val = 0x0000e1a0;

    static uint32_t cs2val = 0x0000e1a0;

    static uint32_t cs3val = 0xe1a0e1a0;

    ram_addr_t phys_flash;

    int rom_size, rom_loaded = 0;

    DisplayState *ds = get_displaystate();



    if (ram_size < flash_size + sdram_size + OMAP15XX_SRAM_SIZE) {

        fprintf(stderr, "This architecture uses %i bytes of memory\n",

                        flash_size + sdram_size + OMAP15XX_SRAM_SIZE);

        exit(1);

    }



    cpu = omap310_mpu_init(sdram_size, cpu_model);



    /* External Flash (EMIFS) */

    cpu_register_physical_memory(OMAP_CS0_BASE, flash_size,

                    (phys_flash = qemu_ram_alloc(flash_size)) | IO_MEM_ROM);



    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs0val);

    cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,

                    OMAP_CS0_SIZE - flash_size, io);

    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs1val);

    cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, io);

    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs2val);

    cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, io);

    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs3val);

    cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, io);



    palmte_microwire_setup(cpu);



    qemu_add_kbd_event_handler(palmte_button_event, cpu);



    palmte_gpio_setup(cpu);



    /* Setup initial (reset) machine state */

    if (nb_option_roms) {

        rom_size = get_image_size(option_rom[0]);

        if (rom_size > flash_size) {

            fprintf(stderr, "%s: ROM image too big (%x > %x)\n",

                            __FUNCTION__, rom_size, flash_size);

            rom_size = 0;

        }

        if (rom_size > 0) {

            rom_size = load_image_targphys(option_rom[0], OMAP_CS0_BASE,

                                           flash_size);

            rom_loaded = 1;

            cpu->env->regs[15] = 0x00000000;

        }

        if (rom_size < 0) {

            fprintf(stderr, "%s: error loading '%s'\n",

                            __FUNCTION__, option_rom[0]);

        }

    }



    if (!rom_loaded && !kernel_filename) {

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

        exit(1);

    }



    /* Load the kernel.  */

    if (kernel_filename) {

        /* Start at bootloader.  */

        cpu->env->regs[15] = palmte_binfo.loader_start;



        palmte_binfo.kernel_filename = kernel_filename;

        palmte_binfo.kernel_cmdline = kernel_cmdline;

        palmte_binfo.initrd_filename = initrd_filename;

        arm_load_kernel(cpu->env, &palmte_binfo);

    }



    /* FIXME: We shouldn't really be doing this here.  The LCD controller

       will set the size once configured, so this just sets an initial

       size until the guest activates the display.  */

    ds->surface = qemu_resize_displaysurface(ds, 320, 320);

    dpy_resize(ds);

}

static void palmte_init(ram_addr_t ram_size, int vga_ram_size,

                const char *boot_device,

                const char *kernel_filename, const char *kernel_cmdline,

                const char *initrd_filename, const char *cpu_model)

{

    struct omap_mpu_state_s *cpu;

    int flash_size = 0x00800000;

    int sdram_size = palmte_binfo.ram_size;

    int io;

    static uint32_t cs0val = 0xffffffff;

    static uint32_t cs1val = 0x0000e1a0;

    static uint32_t cs2val = 0x0000e1a0;

    static uint32_t cs3val = 0xe1a0e1a0;

    ram_addr_t phys_flash;

    int rom_size, rom_loaded = 0;

    DisplayState *ds = get_displaystate();



    if (ram_size < flash_size + sdram_size + OMAP15XX_SRAM_SIZE) {

        fprintf(stderr, "This architecture uses %i bytes of memory\n",

                        flash_size + sdram_size + OMAP15XX_SRAM_SIZE);

        exit(1);

    }



    cpu = omap310_mpu_init(sdram_size, cpu_model);



    

    cpu_register_physical_memory(OMAP_CS0_BASE, flash_size,

                    (phys_flash = qemu_ram_alloc(flash_size)) | IO_MEM_ROM);



    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs0val);

    cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,

                    OMAP_CS0_SIZE - flash_size, io);

    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs1val);

    cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, io);

    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs2val);

    cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, io);

    io = cpu_register_io_memory(0, static_readfn, static_writefn, &cs3val);

    cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, io);



    palmte_microwire_setup(cpu);



    qemu_add_kbd_event_handler(palmte_button_event, cpu);



    palmte_gpio_setup(cpu);



    

    if (nb_option_roms) {

        rom_size = get_image_size(option_rom[0]);

        if (rom_size > flash_size) {

            fprintf(stderr, "%s: ROM image too big (%x > %x)\n",

                            __FUNCTION__, rom_size, flash_size);

            rom_size = 0;

        }

        if (rom_size > 0) {

            rom_size = load_image_targphys(option_rom[0], OMAP_CS0_BASE,

                                           flash_size);

            rom_loaded = 1;

            cpu->env->regs[15] = 0x00000000;

        }

        if (rom_size < 0) {

            fprintf(stderr, "%s: error loading '%s'\n",

                            __FUNCTION__, option_rom[0]);

        }

    }



    if (!rom_loaded && !kernel_filename) {

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

        exit(1);

    }



    

    if (kernel_filename) {

        

        cpu->env->regs[15] = palmte_binfo.loader_start;



        palmte_binfo.kernel_filename = kernel_filename;

        palmte_binfo.kernel_cmdline = kernel_cmdline;

        palmte_binfo.initrd_filename = initrd_filename;

        arm_load_kernel(cpu->env, &palmte_binfo);

    }



    





    ds->surface = qemu_resize_displaysurface(ds, 320, 320);

    dpy_resize(ds);

}

static void FUNC_0(ram_addr_t VAR_0, int VAR_1,

                const char *VAR_2,

                const char *VAR_3, const char *VAR_4,

                const char *VAR_5, const char *VAR_6)

{

    struct omap_mpu_state_s *VAR_7;

    int VAR_8 = 0x00800000;

    int VAR_9 = palmte_binfo.VAR_0;

    int VAR_10;

    static uint32_t VAR_11 = 0xffffffff;

    static uint32_t VAR_12 = 0x0000e1a0;

    static uint32_t VAR_13 = 0x0000e1a0;

    static uint32_t VAR_14 = 0xe1a0e1a0;

    ram_addr_t phys_flash;

    int VAR_15, VAR_16 = 0;

    DisplayState *ds = get_displaystate();



    if (VAR_0 < VAR_8 + VAR_9 + OMAP15XX_SRAM_SIZE) {

        fprintf(stderr, "This architecture uses %i bytes of memory\n",

                        VAR_8 + VAR_9 + OMAP15XX_SRAM_SIZE);

        exit(1);

    }



    VAR_7 = omap310_mpu_init(VAR_9, VAR_6);



    

    cpu_register_physical_memory(OMAP_CS0_BASE, VAR_8,

                    (phys_flash = qemu_ram_alloc(VAR_8)) | IO_MEM_ROM);



    VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_11);

    cpu_register_physical_memory(OMAP_CS0_BASE + VAR_8,

                    OMAP_CS0_SIZE - VAR_8, VAR_10);

    VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_12);

    cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, VAR_10);

    VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_13);

    cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, VAR_10);

    VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_14);

    cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, VAR_10);



    palmte_microwire_setup(VAR_7);



    qemu_add_kbd_event_handler(palmte_button_event, VAR_7);



    palmte_gpio_setup(VAR_7);



    

    if (nb_option_roms) {

        VAR_15 = get_image_size(option_rom[0]);

        if (VAR_15 > VAR_8) {

            fprintf(stderr, "%s: ROM image too big (%x > %x)\n",

                            __FUNCTION__, VAR_15, VAR_8);

            VAR_15 = 0;

        }

        if (VAR_15 > 0) {

            VAR_15 = load_image_targphys(option_rom[0], OMAP_CS0_BASE,

                                           VAR_8);

            VAR_16 = 1;

            VAR_7->env->regs[15] = 0x00000000;

        }

        if (VAR_15 < 0) {

            fprintf(stderr, "%s: error loading '%s'\n",

                            __FUNCTION__, option_rom[0]);

        }

    }



    if (!VAR_16 && !VAR_3) {

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

        exit(1);

    }



    

    if (VAR_3) {

        

        VAR_7->env->regs[15] = palmte_binfo.loader_start;



        palmte_binfo.VAR_3 = VAR_3;

        palmte_binfo.VAR_4 = VAR_4;

        palmte_binfo.VAR_5 = VAR_5;

        arm_load_kernel(VAR_7->env, &palmte_binfo);

    }



    





    ds->surface = qemu_resize_displaysurface(ds, 320, 320);

    dpy_resize(ds);

}

static void FUNC_0(ram_addr_t VAR_0, int VAR_1,
const char *VAR_2,
const char *VAR_3, const char *VAR_4,
const char *VAR_5, const char *VAR_6)
{ struct omap_mpu_state_s *VAR_7; int VAR_8 = 0x00800000; int VAR_9 = palmte_binfo.VAR_0; int VAR_10; static uint32_t VAR_11 = 0xffffffff; static uint32_t VAR_12 = 0x0000e1a0; static uint32_t VAR_13 = 0x0000e1a0; static uint32_t VAR_14 = 0xe1a0e1a0; ram_addr_t phys_flash; int VAR_15, VAR_16 = 0; DisplayState *ds = get_displaystate(); if (VAR_0 < VAR_8 + VAR_9 + OMAP15XX_SRAM_SIZE) { fprintf(stderr, "This architecture uses %i bytes of memory\n",
VAR_8 + VAR_9 + OMAP15XX_SRAM_SIZE); exit(1); } VAR_7 = omap310_mpu_init(VAR_9, VAR_6); cpu_register_physical_memory(OMAP_CS0_BASE, VAR_8,
(phys_flash = qemu_ram_alloc(VAR_8)) | IO_MEM_ROM); VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_11); cpu_register_physical_memory(OMAP_CS0_BASE + VAR_8,
OMAP_CS0_SIZE - VAR_8, VAR_10); VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_12); cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, VAR_10); VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_13); cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, VAR_10); VAR_10 = cpu_register_io_memory(0, static_readfn, static_writefn, &VAR_14); cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, VAR_10); palmte_microwire_setup(VAR_7); qemu_add_kbd_event_handler(palmte_button_event, VAR_7); palmte_gpio_setup(VAR_7); if (nb_option_roms) { VAR_15 = get_image_size(option_rom[0]); if (VAR_15 > VAR_8) { fprintf(stderr, "%s: ROM image too big (%x > %x)\n",
__FUNCTION__, VAR_15, VAR_8); VAR_15 = 0; } if (VAR_15 > 0) { VAR_15 = load_image_targphys(option_rom[0], OMAP_CS0_BASE,
VAR_8); VAR_16 = 1; VAR_7->env->regs[15] = 0x00000000; } if (VAR_15 < 0) { fprintf(stderr, "%s: error loading '%s'\n",
__FUNCTION__, option_rom[0]); } } if (!VAR_16 && !VAR_3) { fprintf(stderr, "Kernel or ROM image must be specified\n"); exit(1); } if (VAR_3) { VAR_7->env->regs[15] = palmte_binfo.loader_start; palmte_binfo.VAR_3 = VAR_3; palmte_binfo.VAR_4 = VAR_4; palmte_binfo.VAR_5 = VAR_5; arm_load_kernel(VAR_7->env, &palmte_binfo); } ds->surface = qemu_resize_displaysurface(ds, 320, 320); dpy_resize(ds); }