static void stellaris_init(const char *kernel_filename, const char *cpu_model,

                           DisplayState *ds, stellaris_board_info *board)

{

    static const int uart_irq[] = {5, 6, 33, 34};

    static const int timer_irq[] = {19, 21, 23, 35};

    static const uint32_t gpio_addr[7] =

      { 0x40004000, 0x40005000, 0x40006000, 0x40007000,

        0x40024000, 0x40025000, 0x40026000};

    static const int gpio_irq[7] = {0, 1, 2, 3, 4, 30, 31};



    qemu_irq *pic;

    qemu_irq *gpio_in[7];

    qemu_irq *gpio_out[7];

    qemu_irq adc;

    int sram_size;

    int flash_size;

    i2c_bus *i2c;

    int i;



    flash_size = ((board->dc0 & 0xffff) + 1) << 1;

    sram_size = (board->dc0 >> 18) + 1;

    pic = armv7m_init(flash_size, sram_size, kernel_filename, cpu_model);



    if (board->dc1 & (1 << 16)) {

        adc = stellaris_adc_init(0x40038000, pic[14]);

    } else {

        adc = NULL;

    }

    for (i = 0; i < 4; i++) {

        if (board->dc2 & (0x10000 << i)) {

            stellaris_gptm_init(0x40030000 + i * 0x1000,

                                pic[timer_irq[i]], adc);

        }

    }



    stellaris_sys_init(0x400fe000, pic[28], board, nd_table[0].macaddr);



    for (i = 0; i < 7; i++) {

        if (board->dc4 & (1 << i)) {

            gpio_in[i] = pl061_init(gpio_addr[i], pic[gpio_irq[i]],

                                    &gpio_out[i]);

        }

    }



    if (board->dc2 & (1 << 12)) {

        i2c = i2c_init_bus();

        stellaris_i2c_init(0x40020000, pic[8], i2c);

        if (board->peripherals & BP_OLED_I2C) {

            ssd0303_init(ds, i2c, 0x3d);

        }

    }



    for (i = 0; i < 4; i++) {

        if (board->dc2 & (1 << i)) {

            pl011_init(0x4000c000 + i * 0x1000, pic[uart_irq[i]],

                       serial_hds[i], PL011_LUMINARY);

        }

    }

    if (board->dc2 & (1 << 4)) {

        if (board->peripherals & BP_OLED_SSI) {

            void * oled;

            void * sd;

            void *ssi_bus;

            int index;



            oled = ssd0323_init(ds, &gpio_out[GPIO_C][7]);

            index = drive_get_index(IF_SD, 0, 0);

            sd = ssi_sd_init(drives_table[index].bdrv);



            ssi_bus = stellaris_ssi_bus_init(&gpio_out[GPIO_D][0],

                                             ssi_sd_xfer, sd,

                                             ssd0323_xfer_ssi, oled);



            pl022_init(0x40008000, pic[7], stellaris_ssi_bus_xfer, ssi_bus);

            /* Make sure the select pin is high.  */

            qemu_irq_raise(gpio_out[GPIO_D][0]);

        } else {

            pl022_init(0x40008000, pic[7], NULL, NULL);

        }

    }

    if (board->dc4 & (1 << 28)) {

        /* FIXME: Obey network model.  */

        stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]);

    }

    if (board->peripherals & BP_GAMEPAD) {

        qemu_irq gpad_irq[5];

        static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };



        gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]); /* up */

        gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]); /* down */

        gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]); /* left */

        gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]); /* right */

        gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]); /* select */



        stellaris_gamepad_init(5, gpad_irq, gpad_keycode);

    }

}

static void stellaris_init(const char *kernel_filename, const char *cpu_model,

                           DisplayState *ds, stellaris_board_info *board)

{

    static const int uart_irq[] = {5, 6, 33, 34};

    static const int timer_irq[] = {19, 21, 23, 35};

    static const uint32_t gpio_addr[7] =

      { 0x40004000, 0x40005000, 0x40006000, 0x40007000,

        0x40024000, 0x40025000, 0x40026000};

    static const int gpio_irq[7] = {0, 1, 2, 3, 4, 30, 31};



    qemu_irq *pic;

    qemu_irq *gpio_in[7];

    qemu_irq *gpio_out[7];

    qemu_irq adc;

    int sram_size;

    int flash_size;

    i2c_bus *i2c;

    int i;



    flash_size = ((board->dc0 & 0xffff) + 1) << 1;

    sram_size = (board->dc0 >> 18) + 1;

    pic = armv7m_init(flash_size, sram_size, kernel_filename, cpu_model);



    if (board->dc1 & (1 << 16)) {

        adc = stellaris_adc_init(0x40038000, pic[14]);

    } else {

        adc = NULL;

    }

    for (i = 0; i < 4; i++) {

        if (board->dc2 & (0x10000 << i)) {

            stellaris_gptm_init(0x40030000 + i * 0x1000,

                                pic[timer_irq[i]], adc);

        }

    }



    stellaris_sys_init(0x400fe000, pic[28], board, nd_table[0].macaddr);



    for (i = 0; i < 7; i++) {

        if (board->dc4 & (1 << i)) {

            gpio_in[i] = pl061_init(gpio_addr[i], pic[gpio_irq[i]],

                                    &gpio_out[i]);

        }

    }



    if (board->dc2 & (1 << 12)) {

        i2c = i2c_init_bus();

        stellaris_i2c_init(0x40020000, pic[8], i2c);

        if (board->peripherals & BP_OLED_I2C) {

            ssd0303_init(ds, i2c, 0x3d);

        }

    }



    for (i = 0; i < 4; i++) {

        if (board->dc2 & (1 << i)) {

            pl011_init(0x4000c000 + i * 0x1000, pic[uart_irq[i]],

                       serial_hds[i], PL011_LUMINARY);

        }

    }

    if (board->dc2 & (1 << 4)) {

        if (board->peripherals & BP_OLED_SSI) {

            void * oled;

            void * sd;

            void *ssi_bus;

            int index;



            oled = ssd0323_init(ds, &gpio_out[GPIO_C][7]);

            index = drive_get_index(IF_SD, 0, 0);

            sd = ssi_sd_init(drives_table[index].bdrv);



            ssi_bus = stellaris_ssi_bus_init(&gpio_out[GPIO_D][0],

                                             ssi_sd_xfer, sd,

                                             ssd0323_xfer_ssi, oled);



            pl022_init(0x40008000, pic[7], stellaris_ssi_bus_xfer, ssi_bus);

            

            qemu_irq_raise(gpio_out[GPIO_D][0]);

        } else {

            pl022_init(0x40008000, pic[7], NULL, NULL);

        }

    }

    if (board->dc4 & (1 << 28)) {

        

        stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]);

    }

    if (board->peripherals & BP_GAMEPAD) {

        qemu_irq gpad_irq[5];

        static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };



        gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]); 

        gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]); 

        gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]); 

        gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]); 

        gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]); 



        stellaris_gamepad_init(5, gpad_irq, gpad_keycode);

    }

}

static void FUNC_0(const char *VAR_0, const char *VAR_1,

                           DisplayState *VAR_2, stellaris_board_info *VAR_3)

{

    static const int VAR_4[] = {5, 6, 33, 34};

    static const int VAR_5[] = {19, 21, 23, 35};

    static const uint32_t VAR_6[7] =

      { 0x40004000, 0x40005000, 0x40006000, 0x40007000,

        0x40024000, 0x40025000, 0x40026000};

    static const int VAR_7[7] = {0, 1, 2, 3, 4, 30, 31};



    qemu_irq *pic;

    qemu_irq *gpio_in[7];

    qemu_irq *gpio_out[7];

    qemu_irq adc;

    int VAR_8;

    int VAR_9;

    i2c_bus *i2c;

    int VAR_10;



    VAR_9 = ((VAR_3->dc0 & 0xffff) + 1) << 1;

    VAR_8 = (VAR_3->dc0 >> 18) + 1;

    pic = armv7m_init(VAR_9, VAR_8, VAR_0, VAR_1);



    if (VAR_3->dc1 & (1 << 16)) {

        adc = stellaris_adc_init(0x40038000, pic[14]);

    } else {

        adc = NULL;

    }

    for (VAR_10 = 0; VAR_10 < 4; VAR_10++) {

        if (VAR_3->dc2 & (0x10000 << VAR_10)) {

            stellaris_gptm_init(0x40030000 + VAR_10 * 0x1000,

                                pic[VAR_5[VAR_10]], adc);

        }

    }



    stellaris_sys_init(0x400fe000, pic[28], VAR_3, nd_table[0].macaddr);



    for (VAR_10 = 0; VAR_10 < 7; VAR_10++) {

        if (VAR_3->dc4 & (1 << VAR_10)) {

            gpio_in[VAR_10] = pl061_init(VAR_6[VAR_10], pic[VAR_7[VAR_10]],

                                    &gpio_out[VAR_10]);

        }

    }



    if (VAR_3->dc2 & (1 << 12)) {

        i2c = i2c_init_bus();

        stellaris_i2c_init(0x40020000, pic[8], i2c);

        if (VAR_3->peripherals & BP_OLED_I2C) {

            ssd0303_init(VAR_2, i2c, 0x3d);

        }

    }



    for (VAR_10 = 0; VAR_10 < 4; VAR_10++) {

        if (VAR_3->dc2 & (1 << VAR_10)) {

            pl011_init(0x4000c000 + VAR_10 * 0x1000, pic[VAR_4[VAR_10]],

                       serial_hds[VAR_10], PL011_LUMINARY);

        }

    }

    if (VAR_3->dc2 & (1 << 4)) {

        if (VAR_3->peripherals & BP_OLED_SSI) {

            void * VAR_11;

            void * VAR_12;

            void *VAR_13;

            int VAR_14;



            VAR_11 = ssd0323_init(VAR_2, &gpio_out[GPIO_C][7]);

            VAR_14 = drive_get_index(IF_SD, 0, 0);

            VAR_12 = ssi_sd_init(drives_table[VAR_14].bdrv);



            VAR_13 = stellaris_ssi_bus_init(&gpio_out[GPIO_D][0],

                                             ssi_sd_xfer, VAR_12,

                                             ssd0323_xfer_ssi, VAR_11);



            pl022_init(0x40008000, pic[7], stellaris_ssi_bus_xfer, VAR_13);

            

            qemu_irq_raise(gpio_out[GPIO_D][0]);

        } else {

            pl022_init(0x40008000, pic[7], NULL, NULL);

        }

    }

    if (VAR_3->dc4 & (1 << 28)) {

        

        stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]);

    }

    if (VAR_3->peripherals & BP_GAMEPAD) {

        qemu_irq gpad_irq[5];

        static const int VAR_15[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d };



        gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]); 

        gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]); 

        gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]); 

        gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]); 

        gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]); 



        stellaris_gamepad_init(5, gpad_irq, VAR_15);

    }

}

static void FUNC_0(const char *VAR_0, const char *VAR_1,
DisplayState *VAR_2, stellaris_board_info *VAR_3)
{ static const int VAR_4[] = {5, 6, 33, 34}; static const int VAR_5[] = {19, 21, 23, 35}; static const uint32_t VAR_6[7] =
{ 0x40004000, 0x40005000, 0x40006000, 0x40007000, 0x40024000, 0x40025000, 0x40026000}; static const int VAR_7[7] = {0, 1, 2, 3, 4, 30, 31}; qemu_irq *pic; qemu_irq *gpio_in[7]; qemu_irq *gpio_out[7]; qemu_irq adc; int VAR_8; int VAR_9; i2c_bus *i2c; int VAR_10; VAR_9 = ((VAR_3->dc0 & 0xffff) + 1) << 1; VAR_8 = (VAR_3->dc0 >> 18) + 1; pic = armv7m_init(VAR_9, VAR_8, VAR_0, VAR_1); if (VAR_3->dc1 & (1 << 16)) { adc = stellaris_adc_init(0x40038000, pic[14]); } else { adc = NULL; } for (VAR_10 = 0; VAR_10 < 4; VAR_10++) { if (VAR_3->dc2 & (0x10000 << VAR_10)) { stellaris_gptm_init(0x40030000 + VAR_10 * 0x1000,
pic[VAR_5[VAR_10]], adc); } } stellaris_sys_init(0x400fe000, pic[28], VAR_3, nd_table[0].macaddr); for (VAR_10 = 0; VAR_10 < 7; VAR_10++) { if (VAR_3->dc4 & (1 << VAR_10)) { gpio_in[VAR_10] = pl061_init(VAR_6[VAR_10], pic[VAR_7[VAR_10]],
&gpio_out[VAR_10]); } } if (VAR_3->dc2 & (1 << 12)) { i2c = i2c_init_bus(); stellaris_i2c_init(0x40020000, pic[8], i2c); if (VAR_3->peripherals & BP_OLED_I2C) { ssd0303_init(VAR_2, i2c, 0x3d); } } for (VAR_10 = 0; VAR_10 < 4; VAR_10++) { if (VAR_3->dc2 & (1 << VAR_10)) { pl011_init(0x4000c000 + VAR_10 * 0x1000, pic[VAR_4[VAR_10]],
serial_hds[VAR_10], PL011_LUMINARY); } } if (VAR_3->dc2 & (1 << 4)) { if (VAR_3->peripherals & BP_OLED_SSI) { void * VAR_11; void * VAR_12; void *VAR_13; int VAR_14; VAR_11 = ssd0323_init(VAR_2, &gpio_out[GPIO_C][7]); VAR_14 = drive_get_index(IF_SD, 0, 0); VAR_12 = ssi_sd_init(drives_table[VAR_14].bdrv); VAR_13 = stellaris_ssi_bus_init(&gpio_out[GPIO_D][0],
ssi_sd_xfer, VAR_12,
ssd0323_xfer_ssi, VAR_11); pl022_init(0x40008000, pic[7], stellaris_ssi_bus_xfer, VAR_13); qemu_irq_raise(gpio_out[GPIO_D][0]); } else { pl022_init(0x40008000, pic[7], NULL, NULL); } } if (VAR_3->dc4 & (1 << 28)) { stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]); } if (VAR_3->peripherals & BP_GAMEPAD) { qemu_irq gpad_irq[5]; static const int VAR_15[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d }; gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]); gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]); gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]); gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]); gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]); stellaris_gamepad_init(5, gpad_irq, VAR_15); } }