Commit 2d069bab6ad7f8c74e49715f7c534e8e799c9855

Authored by blueswir1
1 parent 52da07d1

Use qemu_irq for a reset signal between DMA and ESP/Lance


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3120 c046a42c-6fe2-441c-8c8c-71466251a162
hw/esp.c
... ... @@ -344,6 +344,12 @@ static void esp_reset(void *opaque)
344 344 s->do_cmd = 0;
345 345 }
346 346  
  347 +static void parent_esp_reset(void *opaque, int irq, int level)
  348 +{
  349 + if (level)
  350 + esp_reset(opaque);
  351 +}
  352 +
347 353 static uint32_t esp_mem_readb(void *opaque, target_phys_addr_t addr)
348 354 {
349 355 ESPState *s = opaque;
... ... @@ -569,7 +575,7 @@ void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id)
569 575 }
570 576  
571 577 void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr,
572   - void *dma_opaque, qemu_irq irq)
  578 + void *dma_opaque, qemu_irq irq, qemu_irq *reset)
573 579 {
574 580 ESPState *s;
575 581 int esp_io_memory;
... ... @@ -581,7 +587,6 @@ void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr,
581 587 s->bd = bd;
582 588 s->irq = irq;
583 589 s->dma_opaque = dma_opaque;
584   - sparc32_dma_set_reset_data(dma_opaque, esp_reset, s);
585 590  
586 591 esp_io_memory = cpu_register_io_memory(0, esp_mem_read, esp_mem_write, s);
587 592 cpu_register_physical_memory(espaddr, ESP_SIZE, esp_io_memory);
... ... @@ -591,5 +596,7 @@ void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr,
591 596 register_savevm("esp", espaddr, 3, esp_save, esp_load, s);
592 597 qemu_register_reset(esp_reset, s);
593 598  
  599 + *reset = *qemu_allocate_irqs(parent_esp_reset, s, 1);
  600 +
594 601 return s;
595 602 }
... ...
hw/pcnet.c
... ... @@ -2011,6 +2011,12 @@ void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
2011 2011  
2012 2012 #if defined (TARGET_SPARC) && !defined(TARGET_SPARC64) // Avoid compile failure
2013 2013  
  2014 +static void parent_lance_reset(void *opaque, int irq, int level)
  2015 +{
  2016 + if (level)
  2017 + pcnet_h_reset(opaque);
  2018 +}
  2019 +
2014 2020 static void lance_mem_writew(void *opaque, target_phys_addr_t addr,
2015 2021 uint32_t val)
2016 2022 {
... ... @@ -2047,7 +2053,7 @@ static CPUWriteMemoryFunc *lance_mem_write[3] = {
2047 2053 };
2048 2054  
2049 2055 void lance_init(NICInfo *nd, target_phys_addr_t leaddr, void *dma_opaque,
2050   - qemu_irq irq)
  2056 + qemu_irq irq, qemu_irq *reset)
2051 2057 {
2052 2058 PCNetState *d;
2053 2059 int lance_io_memory;
... ... @@ -2060,7 +2066,8 @@ void lance_init(NICInfo *nd, target_phys_addr_t leaddr, void *dma_opaque,
2060 2066 cpu_register_io_memory(0, lance_mem_read, lance_mem_write, d);
2061 2067  
2062 2068 d->dma_opaque = dma_opaque;
2063   - sparc32_dma_set_reset_data(dma_opaque, pcnet_h_reset, d);
  2069 +
  2070 + *reset = *qemu_allocate_irqs(parent_lance_reset, d, 1);
2064 2071  
2065 2072 cpu_register_physical_memory(leaddr, 4, lance_io_memory);
2066 2073  
... ...
hw/sparc32_dma.c
... ... @@ -58,9 +58,9 @@ typedef struct DMAState DMAState;
58 58 struct DMAState {
59 59 uint32_t dmaregs[DMA_REGS];
60 60 qemu_irq irq;
61   - void *iommu, *dev_opaque;
62   - void (*dev_reset)(void *dev_opaque);
  61 + void *iommu;
63 62 qemu_irq *pic;
  63 + qemu_irq dev_reset;
64 64 };
65 65  
66 66 /* Note: on sparc, the lance 16 bit bus is swapped */
... ... @@ -178,7 +178,8 @@ static void dma_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
178 178 qemu_irq_lower(s->irq);
179 179 }
180 180 if (val & DMA_RESET) {
181   - s->dev_reset(s->dev_opaque);
  181 + qemu_irq_raise(s->dev_reset);
  182 + qemu_irq_lower(s->dev_reset);
182 183 } else if (val & DMA_DRAIN_FIFO) {
183 184 val &= ~DMA_DRAIN_FIFO;
184 185 } else if (val == 0)
... ... @@ -238,7 +239,7 @@ static int dma_load(QEMUFile *f, void *opaque, int version_id)
238 239 }
239 240  
240 241 void *sparc32_dma_init(target_phys_addr_t daddr, qemu_irq parent_irq,
241   - void *iommu, qemu_irq **dev_irq)
  242 + void *iommu, qemu_irq **dev_irq, qemu_irq **reset)
242 243 {
243 244 DMAState *s;
244 245 int dma_io_memory;
... ... @@ -257,14 +258,7 @@ void *sparc32_dma_init(target_phys_addr_t daddr, qemu_irq parent_irq,
257 258 qemu_register_reset(dma_reset, s);
258 259 *dev_irq = qemu_allocate_irqs(dma_set_irq, s, 1);
259 260  
260   - return s;
261   -}
262   -
263   -void sparc32_dma_set_reset_data(void *opaque, void (*dev_reset)(void *opaque),
264   - void *dev_opaque)
265   -{
266   - DMAState *s = opaque;
  261 + *reset = &s->dev_reset;
267 262  
268   - s->dev_reset = dev_reset;
269   - s->dev_opaque = dev_opaque;
  263 + return s;
270 264 }
... ...
hw/sun4m.c
... ... @@ -315,6 +315,7 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
315 315 const sparc_def_t *def;
316 316 qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq,
317 317 *espdma_irq, *ledma_irq;
  318 + qemu_irq *esp_reset, *le_reset;
318 319  
319 320 /* init CPUs */
320 321 sparc_find_by_name(cpu_model, &def);
... ... @@ -352,9 +353,11 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
352 353 hwdef->clock_irq);
353 354  
354 355 espdma = sparc32_dma_init(hwdef->dma_base, slavio_irq[hwdef->esp_irq],
355   - iommu, &espdma_irq);
  356 + iommu, &espdma_irq, &esp_reset);
  357 +
356 358 ledma = sparc32_dma_init(hwdef->dma_base + 16ULL,
357   - slavio_irq[hwdef->le_irq], iommu, &ledma_irq);
  359 + slavio_irq[hwdef->le_irq], iommu, &ledma_irq,
  360 + &le_reset);
358 361  
359 362 if (graphic_depth != 8 && graphic_depth != 24) {
360 363 fprintf(stderr, "qemu: Unsupported depth: %d\n", graphic_depth);
... ... @@ -365,7 +368,7 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
365 368  
366 369 if (nd_table[0].model == NULL
367 370 || strcmp(nd_table[0].model, "lance") == 0) {
368   - lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq);
  371 + lance_init(&nd_table[0], hwdef->le_base, ledma, *ledma_irq, le_reset);
369 372 } else if (strcmp(nd_table[0].model, "?") == 0) {
370 373 fprintf(stderr, "qemu: Supported NICs: lance\n");
371 374 exit (1);
... ... @@ -389,7 +392,9 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size,
389 392 slavio_serial_init(hwdef->serial_base, slavio_irq[hwdef->ser_irq],
390 393 serial_hds[1], serial_hds[0]);
391 394 fdctrl_init(slavio_irq[hwdef->fd_irq], 0, 1, hwdef->fd_base, fd_table);
392   - main_esp = esp_init(bs_table, hwdef->esp_base, espdma, *espdma_irq);
  395 +
  396 + main_esp = esp_init(bs_table, hwdef->esp_base, espdma, *espdma_irq,
  397 + esp_reset);
393 398  
394 399 for (i = 0; i < MAX_DISKS; i++) {
395 400 if (bs_table[i]) {
... ...
... ... @@ -1054,7 +1054,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
1054 1054  
1055 1055 void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
1056 1056 void lance_init(NICInfo *nd, target_phys_addr_t leaddr, void *dma_opaque,
1057   - qemu_irq irq);
  1057 + qemu_irq irq, qemu_irq *reset);
1058 1058  
1059 1059 /* vmmouse.c */
1060 1060 void *vmmouse_init(void *m);
... ... @@ -1273,19 +1273,17 @@ void slavio_set_power_fail(void *opaque, int power_failing);
1273 1273 /* esp.c */
1274 1274 void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id);
1275 1275 void *esp_init(BlockDriverState **bd, target_phys_addr_t espaddr,
1276   - void *dma_opaque, qemu_irq irq);
  1276 + void *dma_opaque, qemu_irq irq, qemu_irq *reset);
1277 1277  
1278 1278 /* sparc32_dma.c */
1279 1279 void *sparc32_dma_init(target_phys_addr_t daddr, qemu_irq parent_irq,
1280   - void *iommu, qemu_irq **dev_irq);
  1280 + void *iommu, qemu_irq **dev_irq, qemu_irq **reset);
1281 1281 void ledma_memory_read(void *opaque, target_phys_addr_t addr,
1282 1282 uint8_t *buf, int len, int do_bswap);
1283 1283 void ledma_memory_write(void *opaque, target_phys_addr_t addr,
1284 1284 uint8_t *buf, int len, int do_bswap);
1285 1285 void espdma_memory_read(void *opaque, uint8_t *buf, int len);
1286 1286 void espdma_memory_write(void *opaque, uint8_t *buf, int len);
1287   -void sparc32_dma_set_reset_data(void *opaque, void (*dev_reset)(void *opaque),
1288   - void *dev_opaque);
1289 1287  
1290 1288 /* cs4231.c */
1291 1289 void cs_init(target_phys_addr_t base, int irq, void *intctl);
... ...