Handle tap fds with IFF_VNET_HDR
[qemu-kvm/fedora.git] / hw / tosa.c
blobf67d67e19936c263664bb08f3277874852bdaa2a
1 /* vim:set shiftwidth=4 ts=4 et: */
2 /*
3 * PXA255 Sharp Zaurus SL-6000 PDA platform
5 * Copyright (c) 2008 Dmitry Baryshkov
7 * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
8 * This code is licensed under the GNU GPL v2.
9 */
11 #include "hw.h"
12 #include "pxa.h"
13 #include "arm-misc.h"
14 #include "sysemu.h"
15 #include "devices.h"
16 #include "sharpsl.h"
17 #include "pcmcia.h"
18 #include "block.h"
19 #include "boards.h"
21 #define TOSA_RAM 0x04000000
22 #define TOSA_ROM 0x00800000
24 #define TOSA_GPIO_nSD_DETECT (9)
25 #define TOSA_GPIO_ON_RESET (19)
26 #define TOSA_GPIO_CF_IRQ (21) /* CF slot0 Ready */
27 #define TOSA_GPIO_CF_CD (13)
28 #define TOSA_GPIO_JC_CF_IRQ (36) /* CF slot1 Ready */
30 #define TOSA_SCOOP_GPIO_BASE 0
31 #define TOSA_GPIO_IR_POWERDWN (TOSA_SCOOP_GPIO_BASE + 2)
32 #define TOSA_GPIO_SD_WP (TOSA_SCOOP_GPIO_BASE + 3)
33 #define TOSA_GPIO_PWR_ON (TOSA_SCOOP_GPIO_BASE + 4)
35 static void tosa_microdrive_attach(struct pxa2xx_state_s *cpu)
37 struct pcmcia_card_s *md;
38 int index;
39 BlockDriverState *bs;
41 index = drive_get_index(IF_IDE, 0, 0);
42 if (index == -1)
43 return;
44 bs = drives_table[index].bdrv;
45 if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) {
46 md = dscm1xxxx_init(bs);
47 pxa2xx_pcmcia_attach(cpu->pcmcia[0], md);
51 static void tosa_gpio_setup(struct pxa2xx_state_s *cpu,
52 struct scoop_info_s *scp0,
53 struct scoop_info_s *scp1)
55 /* MMC/SD host */
56 pxa2xx_mmci_handlers(cpu->mmc,
57 scoop_gpio_in_get(scp0)[TOSA_GPIO_SD_WP],
58 qemu_irq_invert(pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_nSD_DETECT]));
60 /* Handle reset */
61 pxa2xx_gpio_out_set(cpu->gpio, TOSA_GPIO_ON_RESET, cpu->reset);
63 /* PCMCIA signals: card's IRQ and Card-Detect */
64 pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
65 pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_CF_IRQ],
66 pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_CF_CD]);
68 pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
69 pxa2xx_gpio_in_get(cpu->gpio)[TOSA_GPIO_JC_CF_IRQ],
70 NULL);
74 static struct arm_boot_info tosa_binfo = {
75 .loader_start = PXA2XX_SDRAM_BASE,
76 .ram_size = 0x04000000,
79 static void tosa_init(ram_addr_t ram_size, int vga_ram_size,
80 const char *boot_device, DisplayState *ds,
81 const char *kernel_filename, const char *kernel_cmdline,
82 const char *initrd_filename, const char *cpu_model)
84 struct pxa2xx_state_s *cpu;
85 struct scoop_info_s *scp0, *scp1;
87 if (ram_size < (TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE)) {
88 fprintf(stderr, "This platform requires %i bytes of memory\n",
89 TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE);
90 exit(1);
93 if (!cpu_model)
94 cpu_model = "pxa255";
96 cpu = pxa255_init(tosa_binfo.ram_size, ds);
98 cpu_register_physical_memory(0, TOSA_ROM,
99 qemu_ram_alloc(TOSA_ROM) | IO_MEM_ROM);
101 tc6393xb_init(0x10000000, NULL);
103 scp0 = scoop_init(cpu, 0, 0x08800000);
104 scp1 = scoop_init(cpu, 1, 0x14800040);
106 tosa_gpio_setup(cpu, scp0, scp1);
108 tosa_microdrive_attach(cpu);
110 /* Setup initial (reset) machine state */
111 cpu->env->regs[15] = tosa_binfo.loader_start;
113 tosa_binfo.kernel_filename = kernel_filename;
114 tosa_binfo.kernel_cmdline = kernel_cmdline;
115 tosa_binfo.initrd_filename = initrd_filename;
116 tosa_binfo.board_id = 0x208;
117 arm_load_kernel(cpu->env, &tosa_binfo);
118 sl_bootparam_write(SL_PXA_PARAM_BASE - PXA2XX_SDRAM_BASE);
121 QEMUMachine tosapda_machine = {
122 "tosa",
123 "Tosa PDA (PXA255)",
124 tosa_init,
125 TOSA_RAM + TOSA_ROM + PXA2XX_INTERNAL_SIZE + RAMSIZE_FIXED,