* [Qemu-devel] [PATCH 1/3] isa bus irq changes and fixes.
2009-08-26 13:35 [Qemu-devel] [PATCH 0/3] isa bus irq patches Gerd Hoffmann
@ 2009-08-26 13:35 ` Gerd Hoffmann
2009-08-26 13:35 ` [Qemu-devel] [PATCH 2/3] Add isa_reserve_irq() Gerd Hoffmann
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2009-08-26 13:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Changes:
(1) make isa-bus maintain isa irqs, complain when allocating
already taken irqs.
(2) note that (1) works only for isa devices converted to qdev
already (floppy and ps2/kbd/mouse right now), so more work
is needed to make this really useful.
(3) split floppy init into isa and sysbus versions.
(4) add sysbus->isa bridge & fix -M isapc breakage.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/fdc.c | 47 ++++++++++++++++++++++++----------------
hw/fdc.h | 9 +++++--
hw/isa-bus.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++---
hw/isa.h | 4 ++-
hw/mips_jazz.c | 2 +-
hw/mips_malta.c | 2 +-
hw/pc.c | 8 ++++--
hw/ppc_prep.c | 2 +-
hw/sun4u.c | 2 +-
9 files changed, 106 insertions(+), 34 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index dabbf3a..0ece6db 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1871,33 +1871,42 @@ static void fdctrl_connect_drives(fdctrl_t *fdctrl, BlockDriverState **fds)
}
}
-fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
- target_phys_addr_t io_base,
- BlockDriverState **fds)
+fdctrl_t *fdctrl_init_isa(int isairq, int dma_chann,
+ uint32_t io_base,
+ BlockDriverState **fds)
{
fdctrl_t *fdctrl;
+ ISADevice *dev;
- if (mem_mapped) {
- DeviceState *dev;
- fdctrl_sysbus_t *sys;
+ dev = isa_create_simple("isa-fdc", io_base, 0);
+ fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
+ isa_connect_irq(dev, 0, isairq);
- dev = qdev_create(NULL, "sysbus-fdc");
- qdev_init(dev);
- sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
- fdctrl = &sys->state;
- sysbus_connect_irq(&sys->busdev, 0, irq);
- sysbus_mmio_map(&sys->busdev, 0, io_base);
- } else {
- ISADevice *dev;
+ fdctrl->dma_chann = dma_chann;
+ DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl);
- dev = isa_create_simple("isa-fdc", io_base, 0);
- fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
- isa_connect_irq(dev, 0, irq);
- }
+ fdctrl_connect_drives(fdctrl, fds);
+
+ return fdctrl;
+}
+
+fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
+ target_phys_addr_t mmio_base,
+ BlockDriverState **fds)
+{
+ fdctrl_t *fdctrl;
+ DeviceState *dev;
+ fdctrl_sysbus_t *sys;
+
+ dev = qdev_create(NULL, "sysbus-fdc");
+ qdev_init(dev);
+ sys = DO_UPCAST(fdctrl_sysbus_t, busdev.qdev, dev);
+ fdctrl = &sys->state;
+ sysbus_connect_irq(&sys->busdev, 0, irq);
+ sysbus_mmio_map(&sys->busdev, 0, mmio_base);
fdctrl->dma_chann = dma_chann;
DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl);
-
fdctrl_connect_drives(fdctrl, fds);
return fdctrl;
diff --git a/hw/fdc.h b/hw/fdc.h
index 7b6a9de..04d64ea 100644
--- a/hw/fdc.h
+++ b/hw/fdc.h
@@ -3,9 +3,12 @@
typedef struct fdctrl_t fdctrl_t;
-fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped,
- target_phys_addr_t io_base,
- BlockDriverState **fds);
+fdctrl_t *fdctrl_init_isa(int isairq, int dma_chann,
+ uint32_t io_base,
+ BlockDriverState **fds);
+fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
+ target_phys_addr_t mmio_base,
+ BlockDriverState **fds);
fdctrl_t *sun4m_fdctrl_init (qemu_irq irq, target_phys_addr_t io_base,
BlockDriverState **fds, qemu_irq *fdc_tc);
int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 315efbb..f8ba7c0 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -18,16 +18,23 @@
*/
#include "hw.h"
#include "sysemu.h"
+#include "monitor.h"
+#include "sysbus.h"
#include "isa.h"
struct ISABus {
BusState qbus;
+ qemu_irq *irqs;
+ uint32_t assigned;
};
static ISABus *isabus;
+static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent);
+
static struct BusInfo isa_bus_info = {
.name = "ISA",
.size = sizeof(ISABus),
+ .print_dev = isabus_dev_print,
.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISADevice, iobase[0], -1),
DEFINE_PROP_HEX32("iobase2", ISADevice, iobase[1], -1),
@@ -41,16 +48,32 @@ ISABus *isa_bus_new(DeviceState *dev)
fprintf(stderr, "Can't create a second ISA bus\n");
return NULL;
}
+ if (NULL == dev) {
+ dev = qdev_create(NULL, "isabus-bridge");
+ qdev_init(dev);
+ }
isabus = FROM_QBUS(ISABus, qbus_create(&isa_bus_info, dev, NULL));
return isabus;
}
-void isa_connect_irq(ISADevice *dev, int n, qemu_irq irq)
+void isa_bus_irqs(qemu_irq *irqs)
{
- assert(n >= 0 && n < dev->nirqs);
- if (dev->irqs[n])
- *dev->irqs[n] = irq;
+ isabus->irqs = irqs;
+}
+
+void isa_connect_irq(ISADevice *dev, int devnr, int isairq)
+{
+ assert(devnr >= 0 && devnr < dev->nirqs);
+ if (isabus->assigned & (1 << isairq)) {
+ fprintf(stderr, "isa irq %d already assigned\n", isairq);
+ exit(1);
+ }
+ if (dev->irqs[devnr]) {
+ isabus->assigned |= (1 << isairq);
+ dev->isairq[devnr] = isairq;
+ *dev->irqs[devnr] = isabus->irqs[isairq];
+ }
}
void isa_init_irq(ISADevice *dev, qemu_irq *p)
@@ -65,6 +88,8 @@ static void isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);
ISADeviceInfo *info = DO_UPCAST(ISADeviceInfo, qdev, base);
+ dev->isairq[0] = -1;
+ dev->isairq[1] = -1;
info->init(dev);
}
@@ -91,3 +116,34 @@ ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2
qdev_init(dev);
return isa;
}
+
+static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
+{
+ ISADevice *d = DO_UPCAST(ISADevice, qdev, dev);
+
+ if (d->isairq[1] != -1) {
+ monitor_printf(mon, "%*sisa irqs %d,%d\n", indent, "",
+ d->isairq[0], d->isairq[1]);
+ } else if (d->isairq[0] != -1) {
+ monitor_printf(mon, "%*sisa irq %d\n", indent, "",
+ d->isairq[0]);
+ }
+}
+
+static void isabus_bridge_init(SysBusDevice *dev)
+{
+ /* nothing */
+}
+
+static SysBusDeviceInfo isabus_bridge_info = {
+ .init = isabus_bridge_init,
+ .qdev.name = "isabus-bridge",
+ .qdev.size = sizeof(SysBusDevice),
+};
+
+static void isabus_register_devices(void)
+{
+ sysbus_register_withprop(&isabus_bridge_info);
+}
+
+device_init(isabus_register_devices)
diff --git a/hw/isa.h b/hw/isa.h
index 49c58f8..1a3bb5b 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -13,6 +13,7 @@ typedef struct ISADeviceInfo ISADeviceInfo;
struct ISADevice {
DeviceState qdev;
uint32_t iobase[2];
+ uint32_t isairq[2];
qemu_irq *irqs[2];
int nirqs;
};
@@ -24,7 +25,8 @@ struct ISADeviceInfo {
};
ISABus *isa_bus_new(DeviceState *dev);
-void isa_connect_irq(ISADevice *dev, int n, qemu_irq irq);
+void isa_bus_irqs(qemu_irq *irqs);
+void isa_connect_irq(ISADevice *dev, int devirq, int isairq);
void isa_init_irq(ISADevice *dev, qemu_irq *p);
void isa_qdev_register(ISADeviceInfo *info);
ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2);
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 9740d72..1cbd947 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -238,7 +238,7 @@ void mips_jazz_init (ram_addr_t ram_size,
DriveInfo *dinfo = drive_get(IF_FLOPPY, 0, n);
fds[n] = dinfo ? dinfo->bdrv : NULL;
}
- fdctrl_init(rc4030[1], 0, 1, 0x80003000, fds);
+ fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);
/* Real time clock */
rtc_init(0x70, i8259[8], 1980);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index d8fa264..6d41450 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -929,7 +929,7 @@ void mips_malta_init (ram_addr_t ram_size,
dinfo = drive_get(IF_FLOPPY, 0, i);
fd[i] = dinfo ? dinfo->bdrv : NULL;
}
- floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd);
+ floppy_controller = fdctrl_init_isa(6, 2, 0x3f0, fd);
/* Sound card */
#ifdef HAS_AUDIO
diff --git a/hw/pc.c b/hw/pc.c
index 11b8618..abb7356 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1283,7 +1283,9 @@ static void pc_init1(ram_addr_t ram_size,
piix3_devfn = piix3_init(pci_bus, -1);
} else {
pci_bus = NULL;
+ isa_bus_new(NULL);
}
+ isa_bus_irqs(isa_irq);
/* init basic PC hardware */
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
@@ -1372,8 +1374,8 @@ static void pc_init1(ram_addr_t ram_size,
}
isa_dev = isa_create_simple("i8042", 0x60, 0x64);
- isa_connect_irq(isa_dev, 0, isa_irq[1]);
- isa_connect_irq(isa_dev, 1, isa_irq[12]);
+ isa_connect_irq(isa_dev, 0, 1);
+ isa_connect_irq(isa_dev, 1, 12);
DMA_init(0);
#ifdef HAS_AUDIO
audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
@@ -1383,7 +1385,7 @@ static void pc_init1(ram_addr_t ram_size,
dinfo = drive_get(IF_FLOPPY, 0, i);
fd[i] = dinfo ? dinfo->bdrv : NULL;
}
- floppy_controller = fdctrl_init(isa_irq[6], 2, 0, 0x3f0, fd);
+ floppy_controller = fdctrl_init_isa(6, 2, 0x3f0, fd);
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 223ca61..7665cb7 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -719,7 +719,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
dinfo = drive_get(IF_FLOPPY, 0, i);
fd[i] = dinfo ? dinfo->bdrv : NULL;
}
- fdctrl_init(i8259[6], 2, 0, 0x3f0, fd);
+ fdctrl_init_isa(6, 2, 0x3f0, fd);
/* Register speaker port */
register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
diff --git a/hw/sun4u.c b/hw/sun4u.c
index bc83255..09027e2 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -618,7 +618,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
dinfo = drive_get(IF_FLOPPY, 0, i);
fd[i] = dinfo ? dinfo->bdrv : NULL;
}
- floppy_controller = fdctrl_init(NULL/*6*/, 2, 0, 0x3f0, fd);
+ floppy_controller = fdctrl_init_isa(6, 2, 0x3f0, fd);
nvram = m48t59_init(NULL/*8*/, 0, 0x0074, NVRAM_SIZE, 59);
initrd_size = 0;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/3] Add isa_reserve_irq().
2009-08-26 13:35 [Qemu-devel] [PATCH 0/3] isa bus irq patches Gerd Hoffmann
2009-08-26 13:35 ` [Qemu-devel] [PATCH 1/3] isa bus irq changes and fixes Gerd Hoffmann
@ 2009-08-26 13:35 ` Gerd Hoffmann
2009-08-26 13:35 ` [Qemu-devel] [PATCH 3/3] Move isa_connect_irq calls into isa_create_simple Gerd Hoffmann
2009-08-28 0:47 ` [Qemu-devel] [PATCH 0/3] isa bus irq patches Anthony Liguori
3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2009-08-26 13:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Jes Sorensen, Gerd Hoffmann
From: Jes Sorensen <jes@sgi.com>
Introduce isa_reserve_irq() which marks an irq reserved and returns
the appropriate qemu_irq entry from the i8259 table.
isa_reserve_irq() is a temporary interface to be used to allocate ISA
IRQs for devices which have not yet been converted to qdev, and for
special cases which are not suited for qdev conversions, such as the
'ferr'.
This patch goes on top of Gerd Hoffmann's which makes isa-bus.c own
the ISA irq table.
[ added isa-bus.o to some targets to fix build failures -- kraxel ]
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
Makefile.target | 4 ++--
hw/cs4231a.c | 12 +++++-------
hw/ide.c | 7 +++++--
hw/isa-bus.c | 21 +++++++++++++++++++++
hw/isa.h | 1 +
hw/pc.c | 23 +++++++++++++----------
hw/sb16.c | 25 ++++++++++++-------------
7 files changed, 59 insertions(+), 34 deletions(-)
diff --git a/Makefile.target b/Makefile.target
index 690f30b..415046b 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -265,7 +265,7 @@ obj-arm-y += arm-semi.o
obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
obj-arm-y += pflash_cfi01.o gumstix.o
-obj-arm-y += zaurus.o ide.o serial.o spitz.o tosa.o tc6393xb.o
+obj-arm-y += zaurus.o ide.o isa-bus.o serial.o spitz.o tosa.o tc6393xb.o
obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
obj-arm-y += omap2.o omap_dss.o soc_dma.o
obj-arm-y += omap_sx1.o palm.o tsc210x.o
@@ -279,7 +279,7 @@ obj-arm-y += syborg_virtio.o
obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o
-obj-sh4-y += ide.o
+obj-sh4-y += ide.o isa-bus.o
obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
obj-m68k-y += m68k-semi.o dummy_m68k.o
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index 5516867..d482e04 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -60,10 +60,9 @@ static struct {
typedef struct CSState {
QEMUSoundCard card;
- qemu_irq *pic;
+ qemu_irq pic;
uint32_t regs[CS_REGS];
uint8_t dregs[CS_DREGS];
- int irq;
int dma;
int port;
int shift;
@@ -483,7 +482,7 @@ IO_WRITE_PROTO (cs_write)
case Alternate_Feature_Status:
if ((s->dregs[iaddr] & PI) && !(val & PI)) {
/* XXX: TI CI */
- qemu_irq_lower (s->pic[s->irq]);
+ qemu_irq_lower (s->pic);
s->regs[Status] &= ~INT;
}
s->dregs[iaddr] = val;
@@ -503,7 +502,7 @@ IO_WRITE_PROTO (cs_write)
case Status:
if (s->regs[Status] & INT) {
- qemu_irq_lower (s->pic[s->irq]);
+ qemu_irq_lower (s->pic);
}
s->regs[Status] &= ~INT;
s->dregs[Alternate_Feature_Status] &= ~(PI | CI | TI);
@@ -588,7 +587,7 @@ static int cs_dma_read (void *opaque, int nchan, int dma_pos, int dma_len)
s->regs[Status] |= INT;
s->dregs[Alternate_Feature_Status] |= PI;
s->transferred = 0;
- qemu_irq_raise (s->pic[s->irq]);
+ qemu_irq_raise (s->pic);
}
else {
s->transferred += written;
@@ -643,8 +642,7 @@ int cs4231a_init (qemu_irq *pic)
s = qemu_mallocz (sizeof (*s));
- s->pic = pic;
- s->irq = conf.irq;
+ s->pic = isa_reserve_irq(conf.irq);
s->dma = conf.dma;
s->port = conf.port;
diff --git a/hw/ide.c b/hw/ide.c
index 0bde632..28b93f4 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -3610,8 +3610,8 @@ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
pci_register_bar((PCIDevice *)d, 4, 0x10,
PCI_ADDRESS_SPACE_IO, bmdma_map);
- ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], pic[14]);
- ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], pic[15]);
+ ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], isa_reserve_irq(14));
+ ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], isa_reserve_irq(15));
ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
@@ -3650,6 +3650,9 @@ void pci_piix4_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn,
pci_register_bar((PCIDevice *)d, 4, 0x10,
PCI_ADDRESS_SPACE_IO, bmdma_map);
+ /*
+ * These should call isa_reserve_irq() instead when MIPS supports it
+ */
ide_init2(&d->ide_if[0], hd_table[0], hd_table[1], pic[14]);
ide_init2(&d->ide_if[2], hd_table[2], hd_table[3], pic[15]);
ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index f8ba7c0..4ac4fad 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -76,6 +76,27 @@ void isa_connect_irq(ISADevice *dev, int devnr, int isairq)
}
}
+/*
+ * isa_reserve_irq() reserves the ISA irq and returns the corresponding
+ * qemu_irq entry for the i8259.
+ *
+ * This function is only for special cases such as the 'ferr', and
+ * temporary use for normal devices until they are converted to qdev.
+ */
+qemu_irq isa_reserve_irq(int isairq)
+{
+ if (isairq < 0 || isairq > 15) {
+ fprintf(stderr, "isa irq %d invalid\n", isairq);
+ exit(1);
+ }
+ if (isabus->assigned & (1 << isairq)) {
+ fprintf(stderr, "isa irq %d already assigned\n", isairq);
+ exit(1);
+ }
+ isabus->assigned |= (1 << isairq);
+ return isabus->irqs[isairq];
+}
+
void isa_init_irq(ISADevice *dev, qemu_irq *p)
{
assert(dev->nirqs < ARRAY_SIZE(dev->irqs));
diff --git a/hw/isa.h b/hw/isa.h
index 1a3bb5b..31853a0 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -27,6 +27,7 @@ struct ISADeviceInfo {
ISABus *isa_bus_new(DeviceState *dev);
void isa_bus_irqs(qemu_irq *irqs);
void isa_connect_irq(ISADevice *dev, int devirq, int isairq);
+qemu_irq isa_reserve_irq(int isairq);
void isa_init_irq(ISADevice *dev, qemu_irq *p);
void isa_qdev_register(ISADeviceInfo *info);
ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2);
diff --git a/hw/pc.c b/hw/pc.c
index abb7356..fc6a925 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1043,13 +1043,14 @@ static void audio_init (PCIBus *pci_bus, qemu_irq *pic)
}
#endif
-static void pc_init_ne2k_isa(NICInfo *nd, qemu_irq *pic)
+static void pc_init_ne2k_isa(NICInfo *nd)
{
static int nb_ne2k = 0;
if (nb_ne2k == NE2000_NB_MAX)
return;
- isa_ne2000_init(ne2000_io[nb_ne2k], pic[ne2000_irq[nb_ne2k]], nd);
+ isa_ne2000_init(ne2000_io[nb_ne2k],
+ isa_reserve_irq(ne2000_irq[nb_ne2k]), nd);
nb_ne2k++;
}
@@ -1276,7 +1277,6 @@ static void pc_init1(ram_addr_t ram_size,
isa_irq_state = qemu_mallocz(sizeof(*isa_irq_state));
isa_irq_state->i8259 = i8259;
isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24);
- ferr_irq = isa_irq[13];
if (pci_enabled) {
pci_bus = i440fx_init(&i440fx_state, isa_irq);
@@ -1286,6 +1286,7 @@ static void pc_init1(ram_addr_t ram_size,
isa_bus_new(NULL);
}
isa_bus_irqs(isa_irq);
+ ferr_irq = isa_reserve_irq(13);
/* init basic PC hardware */
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
@@ -1311,7 +1312,7 @@ static void pc_init1(ram_addr_t ram_size,
}
}
- rtc_state = rtc_init(0x70, isa_irq[8], 2000);
+ rtc_state = rtc_init(0x70, isa_reserve_irq(8), 2000);
qemu_register_boot_set(pc_boot_set, rtc_state);
@@ -1321,7 +1322,7 @@ static void pc_init1(ram_addr_t ram_size,
if (pci_enabled) {
isa_irq_state->ioapic = ioapic_init();
}
- pit = pit_init(0x40, isa_irq[0]);
+ pit = pit_init(0x40, isa_reserve_irq(0));
pcspk_init(pit);
if (!no_hpet) {
hpet_init(isa_irq);
@@ -1329,14 +1330,14 @@ static void pc_init1(ram_addr_t ram_size,
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
if (serial_hds[i]) {
- serial_init(serial_io[i], isa_irq[serial_irq[i]], 115200,
+ serial_init(serial_io[i], isa_reserve_irq(serial_irq[i]), 115200,
serial_hds[i]);
}
}
for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
if (parallel_hds[i]) {
- parallel_init(parallel_io[i], isa_irq[parallel_irq[i]],
+ parallel_init(parallel_io[i], isa_reserve_irq(parallel_irq[i]),
parallel_hds[i]);
}
}
@@ -1347,7 +1348,7 @@ static void pc_init1(ram_addr_t ram_size,
NICInfo *nd = &nd_table[i];
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
- pc_init_ne2k_isa(nd, isa_irq);
+ pc_init_ne2k_isa(nd);
else
pci_nic_init(nd, "e1000", NULL);
}
@@ -1368,7 +1369,8 @@ static void pc_init1(ram_addr_t ram_size,
pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1, isa_irq);
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
- isa_ide_init(ide_iobase[i], ide_iobase2[i], isa_irq[ide_irq[i]],
+ isa_ide_init(ide_iobase[i], ide_iobase2[i],
+ isa_reserve_irq(ide_irq[i]),
hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
}
}
@@ -1398,7 +1400,8 @@ static void pc_init1(ram_addr_t ram_size,
i2c_bus *smbus;
/* TODO: Populate SPD eeprom data. */
- smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, isa_irq[9]);
+ smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
+ isa_reserve_irq(9));
for (i = 0; i < 8; i++) {
DeviceState *eeprom;
eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
diff --git a/hw/sb16.c b/hw/sb16.c
index 2506d98..9f7680d 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -56,7 +56,7 @@ static struct {
typedef struct SB16State {
QEMUSoundCard card;
- qemu_irq *pic;
+ qemu_irq pic;
int irq;
int dma;
int hdma;
@@ -190,7 +190,7 @@ static void aux_timer (void *opaque)
{
SB16State *s = opaque;
s->can_write = 1;
- qemu_irq_raise (s->pic[s->irq]);
+ qemu_irq_raise (s->pic);
}
#define DMA8_AUTO 1
@@ -598,7 +598,7 @@ static void command (SB16State *s, uint8_t cmd)
case 0xf3:
dsp_out_data (s, 0xaa);
s->mixer_regs[0x82] |= (cmd == 0xf2) ? 1 : 2;
- qemu_irq_raise (s->pic[s->irq]);
+ qemu_irq_raise (s->pic);
break;
case 0xf9:
@@ -766,7 +766,7 @@ static void complete (SB16State *s)
bytes = samples << s->fmt_stereo << (s->fmt_bits == 16);
ticks = (bytes * ticks_per_sec) / freq;
if (ticks < ticks_per_sec / 1024) {
- qemu_irq_raise (s->pic[s->irq]);
+ qemu_irq_raise (s->pic);
}
else {
if (s->aux_ts) {
@@ -858,10 +858,10 @@ static void legacy_reset (SB16State *s)
static void reset (SB16State *s)
{
- qemu_irq_lower (s->pic[s->irq]);
+ qemu_irq_lower (s->pic);
if (s->dma_auto) {
- qemu_irq_raise (s->pic[s->irq]);
- qemu_irq_lower (s->pic[s->irq]);
+ qemu_irq_raise (s->pic);
+ qemu_irq_lower (s->pic);
}
s->mixer_regs[0x82] = 0;
@@ -897,7 +897,7 @@ static IO_WRITE_PROTO (dsp_write)
if (s->v2x6 == 1) {
if (0 && s->highspeed) {
s->highspeed = 0;
- qemu_irq_lower (s->pic[s->irq]);
+ qemu_irq_lower (s->pic);
control (s, 0);
}
else {
@@ -1008,7 +1008,7 @@ static IO_READ_PROTO (dsp_read)
if (s->mixer_regs[0x82] & 1) {
ack = 1;
s->mixer_regs[0x82] &= 1;
- qemu_irq_lower (s->pic[s->irq]);
+ qemu_irq_lower (s->pic);
}
break;
@@ -1017,7 +1017,7 @@ static IO_READ_PROTO (dsp_read)
if (s->mixer_regs[0x82] & 2) {
ack = 1;
s->mixer_regs[0x82] &= 2;
- qemu_irq_lower (s->pic[s->irq]);
+ qemu_irq_lower (s->pic);
}
break;
@@ -1231,7 +1231,7 @@ static int SB_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
if (s->left_till_irq <= 0) {
s->mixer_regs[0x82] |= (nchan & 4) ? 2 : 1;
- qemu_irq_raise (s->pic[s->irq]);
+ qemu_irq_raise (s->pic);
if (0 == s->dma_auto) {
control (s, 0);
speaker (s, 0);
@@ -1408,8 +1408,7 @@ int SB16_init (qemu_irq *pic)
s = qemu_mallocz (sizeof (*s));
s->cmd = -1;
- s->pic = pic;
- s->irq = conf.irq;
+ s->pic = isa_reserve_irq(conf.irq);
s->dma = conf.dma;
s->hdma = conf.hdma;
s->port = conf.port;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 3/3] Move isa_connect_irq calls into isa_create_simple
2009-08-26 13:35 [Qemu-devel] [PATCH 0/3] isa bus irq patches Gerd Hoffmann
2009-08-26 13:35 ` [Qemu-devel] [PATCH 1/3] isa bus irq changes and fixes Gerd Hoffmann
2009-08-26 13:35 ` [Qemu-devel] [PATCH 2/3] Add isa_reserve_irq() Gerd Hoffmann
@ 2009-08-26 13:35 ` Gerd Hoffmann
2009-08-26 17:19 ` Blue Swirl
2009-08-28 0:47 ` [Qemu-devel] [PATCH 0/3] isa bus irq patches Anthony Liguori
3 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2009-08-26 13:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Now with isa-bus maintaining the isa irqs we can move the
isa_connect_irq() calls into isa_create_simple().
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/fdc.c | 3 +--
hw/isa-bus.c | 7 ++++++-
hw/isa.h | 3 ++-
hw/pc.c | 4 +---
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 0ece6db..e5a650a 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1878,9 +1878,8 @@ fdctrl_t *fdctrl_init_isa(int isairq, int dma_chann,
fdctrl_t *fdctrl;
ISADevice *dev;
- dev = isa_create_simple("isa-fdc", io_base, 0);
+ dev = isa_create_simple("isa-fdc", io_base, 0, isairq, -1);
fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
- isa_connect_irq(dev, 0, isairq);
fdctrl->dma_chann = dma_chann;
DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 4ac4fad..1ad5e40 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -121,7 +121,8 @@ void isa_qdev_register(ISADeviceInfo *info)
qdev_register(&info->qdev);
}
-ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2)
+ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2,
+ uint32_t irq, uint32 irq2)
{
DeviceState *dev;
ISADevice *isa;
@@ -135,6 +136,10 @@ ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2
isa->iobase[0] = iobase;
isa->iobase[1] = iobase2;
qdev_init(dev);
+ if (-1 != irq)
+ isa_connect_irq(isa, 0, irq);
+ if (-1 != irq2)
+ isa_connect_irq(isa, 1, irq2);
return isa;
}
diff --git a/hw/isa.h b/hw/isa.h
index 31853a0..872e3ef 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -30,7 +30,8 @@ void isa_connect_irq(ISADevice *dev, int devirq, int isairq);
qemu_irq isa_reserve_irq(int isairq);
void isa_init_irq(ISADevice *dev, qemu_irq *p);
void isa_qdev_register(ISADeviceInfo *info);
-ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2);
+ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2,
+ uint32_t irq, uint32_t irq2);
extern target_phys_addr_t isa_mem_base;
diff --git a/hw/pc.c b/hw/pc.c
index fc6a925..ab7ce20 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1375,9 +1375,7 @@ static void pc_init1(ram_addr_t ram_size,
}
}
- isa_dev = isa_create_simple("i8042", 0x60, 0x64);
- isa_connect_irq(isa_dev, 0, 1);
- isa_connect_irq(isa_dev, 1, 12);
+ isa_dev = isa_create_simple("i8042", 0x60, 0x64, 1, 12);
DMA_init(0);
#ifdef HAS_AUDIO
audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Move isa_connect_irq calls into isa_create_simple
2009-08-26 13:35 ` [Qemu-devel] [PATCH 3/3] Move isa_connect_irq calls into isa_create_simple Gerd Hoffmann
@ 2009-08-26 17:19 ` Blue Swirl
2009-08-27 11:51 ` Gerd Hoffmann
0 siblings, 1 reply; 7+ messages in thread
From: Blue Swirl @ 2009-08-26 17:19 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
On Wed, Aug 26, 2009 at 4:35 PM, Gerd Hoffmann<kraxel@redhat.com> wrote:
> Now with isa-bus maintaining the isa irqs we can move the
> isa_connect_irq() calls into isa_create_simple().
> + if (-1 != irq)
> + if (-1 != irq2)
Not again.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Move isa_connect_irq calls into isa_create_simple
2009-08-26 17:19 ` Blue Swirl
@ 2009-08-27 11:51 ` Gerd Hoffmann
0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2009-08-27 11:51 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 411 bytes --]
On 08/26/09 19:19, Blue Swirl wrote:
> On Wed, Aug 26, 2009 at 4:35 PM, Gerd Hoffmann<kraxel@redhat.com> wrote:
>> Now with isa-bus maintaining the isa irqs we can move the
>> isa_connect_irq() calls into isa_create_simple().
>
>> + if (-1 != irq)
>> + if (-1 != irq2)
>
> Not again.
Oh well. Probably needs some time to teach my fingers to stop doing
that ...
Fixed patch attached.
cheers,
Gerd
[-- Attachment #2: 0001-Move-isa_connect_irq-calls-into-isa_create_simple.patch --]
[-- Type: text/plain, Size: 2888 bytes --]
>From cb189da691cd3bf62a846c1e94e74b28ee9f3f40 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Fri, 14 Aug 2009 10:50:49 +0200
Subject: [PATCH] Move isa_connect_irq calls into isa_create_simple
Now with isa-bus maintaining the isa irqs we can move the
isa_connect_irq() calls into isa_create_simple().
---
hw/fdc.c | 3 +--
hw/isa-bus.c | 7 ++++++-
hw/isa.h | 3 ++-
hw/pc.c | 4 +---
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 0ece6db..e5a650a 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1878,9 +1878,8 @@ fdctrl_t *fdctrl_init_isa(int isairq, int dma_chann,
fdctrl_t *fdctrl;
ISADevice *dev;
- dev = isa_create_simple("isa-fdc", io_base, 0);
+ dev = isa_create_simple("isa-fdc", io_base, 0, isairq, -1);
fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
- isa_connect_irq(dev, 0, isairq);
fdctrl->dma_chann = dma_chann;
DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 4ac4fad..1b12676 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -121,7 +121,8 @@ void isa_qdev_register(ISADeviceInfo *info)
qdev_register(&info->qdev);
}
-ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2)
+ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2,
+ uint32_t irq, uint32 irq2)
{
DeviceState *dev;
ISADevice *isa;
@@ -135,6 +136,10 @@ ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2
isa->iobase[0] = iobase;
isa->iobase[1] = iobase2;
qdev_init(dev);
+ if (irq != -1)
+ isa_connect_irq(isa, 0, irq);
+ if (irq2 != -1)
+ isa_connect_irq(isa, 1, irq2);
return isa;
}
diff --git a/hw/isa.h b/hw/isa.h
index 31853a0..872e3ef 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -30,7 +30,8 @@ void isa_connect_irq(ISADevice *dev, int devirq, int isairq);
qemu_irq isa_reserve_irq(int isairq);
void isa_init_irq(ISADevice *dev, qemu_irq *p);
void isa_qdev_register(ISADeviceInfo *info);
-ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2);
+ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2,
+ uint32_t irq, uint32_t irq2);
extern target_phys_addr_t isa_mem_base;
diff --git a/hw/pc.c b/hw/pc.c
index fc6a925..ab7ce20 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1375,9 +1375,7 @@ static void pc_init1(ram_addr_t ram_size,
}
}
- isa_dev = isa_create_simple("i8042", 0x60, 0x64);
- isa_connect_irq(isa_dev, 0, 1);
- isa_connect_irq(isa_dev, 1, 12);
+ isa_dev = isa_create_simple("i8042", 0x60, 0x64, 1, 12);
DMA_init(0);
#ifdef HAS_AUDIO
audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] isa bus irq patches
2009-08-26 13:35 [Qemu-devel] [PATCH 0/3] isa bus irq patches Gerd Hoffmann
` (2 preceding siblings ...)
2009-08-26 13:35 ` [Qemu-devel] [PATCH 3/3] Move isa_connect_irq calls into isa_create_simple Gerd Hoffmann
@ 2009-08-28 0:47 ` Anthony Liguori
3 siblings, 0 replies; 7+ messages in thread
From: Anthony Liguori @ 2009-08-28 0:47 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
Gerd Hoffmann wrote:
> Hi,
>
> Yet another patch series respin. Rebased to todays master.
> Adapted to irq changes in pc.c. No other changes.
>
Got this in staging too. Will be pushing in a couple hours.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 7+ messages in thread