qdev: add isa bus support
cover qdev: add isa bus support
Hi,
This series adds isa bus support to qdev and converts one device (pc kbd controller).
cheers,
Gerd
PATCH 1/4 qdev/isa: add isa bus support to qdev.
Wrong mmio stuff from previous version ripped out. Pretty simple and straigt forward now. IRQs modeled simliar to sysbus.
--- Makefile.target | 8 +++--- hw/isa-bus.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/isa.h | 25 +++++++++++++++++ 3 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 hw/isa-bus.c
Makefile.target +4 -4
@@ -563,7 +563,7 @@ obj-y += wdt_ib700.o wdt_i6300esb.o ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support -obj-y += ide.o pckbd.o vga.o $(sound-obj-y) dma.o +obj-y += ide.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o obj-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o obj-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o obj-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
@@ -573,7 +573,7 @@ endif ifeq ($(TARGET_BASE_ARCH), ppc) CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE # shared objects -obj-y += ppc.o ide.o vga.o $(sound-obj-y) dma.o openpic.o +obj-y += ppc.o ide.o vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o # PREP target obj-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o obj-y += prep_pci.o ppc_prep.o
@@ -599,7 +599,7 @@ obj-y += mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o obj-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o obj-y += g364fb.o jazz_led.o dp8393x.o obj-y += ide.o gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o -obj-y += piix_pci.o parallel.o cirrus_vga.o pcspk.o $(sound-obj-y) +obj-y += piix_pci.o parallel.o cirrus_vga.o isa-bus.o pcspk.o $(sound-obj-y) obj-y += mipsnet.o obj-y += pflash_cfi01.o obj-y += vmware_vga.o
@@ -635,7 +635,7 @@ obj-y += pflash_cfi02.o endif ifeq ($(TARGET_BASE_ARCH), sparc) ifeq ($(TARGET_ARCH), sparc64) -obj-y += sun4u.o ide.o pckbd.o vga.o apb_pci.o +obj-y += sun4u.o ide.o isa-bus.o pckbd.o vga.o apb_pci.o obj-y += fdc.o mc146818rtc.o serial.o obj-y += cirrus_vga.o parallel.o else
hw/isa-bus.c new file +82 -0
82 lines not on this page · raw message
hw/isa.h +25 -0
@@ -1,8 +1,33 @@#ifndef HW_ISA_H #define HW_ISA_H +/* ISA bus */ #include "ioport.h" +#include "qdev.h" + +typedef struct ISABus ISABus ; +typedef struct ISADevice ISADevice ; +typedef struct ISADeviceInfo ISADeviceInfo ; + +struct ISADevice { +DeviceState qdev; +uint32_t iobase[2 ]; +qemu_irq *irqs[2 ]; +int nirqs; +}; + +typedef void (*isa_qdev_initfn )(ISADevice *dev); +struct ISADeviceInfo { +DeviceInfo qdev; +isa_qdev_initfn init; +}; + +ISABus *isa_bus_new (DeviceState *dev); +void isa_connect_irq (ISADevice *dev,int n,qemu_irq irq); +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);extern target_phys_addr_t isa_mem_base;
Signature · 1 line
1.6.2.5
Re: [Qemu-devel] [PATCH 1/4] qdev/isa: add isa bus support to qdev.
2009/7/15 Gerd Hoffmann <[email protected]>:
Quoted 8 lines
hw/isa-bus.c new file +8
-0+static struct BusInfo isa_bus_info = { + .name = "ISA", + .size = sizeof(ISABus), + .props = (Property[]) { + { + .name = "iobase", + .info = &qdev_prop_hex32, + .offset = offsetof(ISADevice, iobase[0]),
hw/isa-bus.c line 27
Quoted 10 lines
hw/isa-bus.c new file +10
-0+ .defval = (uint32_t[]) { -1 }, + },{ + .name = "iobase2", + .info = &qdev_prop_hex32, + .offset = offsetof(ISADevice, iobase[1]), + .defval = (uint32_t[]) { -1 }, + }, + {/* end of list */} + } +};
Why exactly two IO bases? That sounds like bad design to me. IMHO it should be handled more like sysbus_init_mmio (or sysbus_init_mmio_cb) and sysbus_mmio_map and the number of IO bases should be virtually unlimited (something like QDEV_MAX_MMIO is acceptable).
Best regards,
Filip Navara
Re: [Qemu-devel] [PATCH 1/4] qdev/isa: add isa bus support to qdev.
Quoted 9 lines · Filip Navara
2009/7/15 Gerd Hoffmann<[email protected]>:
hw/isa-bus.c line 20
Quoted 7 lines
hw/isa-bus.c new file +7
-0+static struct BusInfo isa_bus_info = { + .name ="ISA" , + .size =sizeof (ISABus), + .props = (Property []) { + { + .name ="iobase" , + .name ="iobase2" ,
Quoted 4 lines
Why exactly two IO bases? That sounds like bad design to me. IMHO it should be handled more like
sysbus_init_mmio(orsysbus_init_mmio_cb) andsysbus_mmio_mapand the number of IO bases should be virtually unlimited (something likeQDEV_MAX_MMIOis acceptable).
Do we really need that? As new isa devices most likely wouldn't show up looking at the existing ones should give us a pretty complete picture ;)
Most devices use one iobase. A few (ide, ps/2) need two. Any devices which need more?
cheers,
Gerd
PATCH 2/4 qdev/isa: add qdev support to i8042 (aka ps/2 kbd+mouse).
In reply to Gerd Hoffmann--- hw/pckbd.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)
hw/pckbd.c +40 -0
@@ -440,3 +440,43 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,#endif qemu_register_reset (kbd_reset, s); } + +typedef struct ISAKBDState { +ISADevice dev; +KBDState kbd; +}ISAKBDState ; + +static void i8042_initfn (ISADevice *dev) +{ +KBDState *s = &(DO_UPCAST (ISAKBDState, dev, dev)->kbd); + +isa_init_irq (dev, &s->irq_kbd); +isa_init_irq (dev, &s->irq_mouse); + +kbd_reset (s); +register_savevm ("pckbd" ,0 ,3 , kbd_save, kbd_load, s); +register_ioport_read (dev->iobase[0 ],1 ,1 , kbd_read_data, s); +register_ioport_write (dev->iobase[0 ],1 ,1 , kbd_write_data, s); +register_ioport_read (dev->iobase[1 ],1 ,1 , kbd_read_status, s); +register_ioport_write (dev->iobase[1 ],1 ,1 , kbd_write_command, s); + + s->kbd =ps2_kbd_init (kbd_update_kbd_irq, s); + s->mouse =ps2_mouse_init (kbd_update_aux_irq, s); +#ifdef TARGET_I386 +vmmouse_init (s->mouse); +#endif +qemu_register_reset (kbd_reset, s); +} + +static ISADeviceInfo i8042_info = { + .qdev.name ="i8042" , + .qdev.size =sizeof (ISAKBDState), + .qdev.no_user =1 , + .init = i8042_initfn, +}; + +static void i8042_register (void ) +{ +isa_qdev_register (&i8042_info); +} +device_init (i8042_register)
Signature · 1 line
1.6.2.5
PATCH 3/4 qdev/isa: make the piix isa bridge register an isa bus.
In reply to Gerd Hoffmann--- hw/piix_pci.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
hw/piix_pci.c +2 -0
@@ -25,6 +25,7 @@#include "hw.h" #include "pc.h" #include "pci.h" +#include "isa.h" #include "sysbus.h" typedef uint32_t pci_addr_t ;
@@ -342,6 +343,7 @@ static void piix3_initfn(PCIDevice *d) {uint8_t *pci_conf; +isa_bus_new (&d->qdev);register_savevm ("PIIX3" ,0 ,2 , piix_save, piix_load, d); pci_conf = d->config;
Signature · 1 line
1.6.2.5
PATCH 4/4 qdev/isa: make pc use qdev for i8042 setup.
In reply to Gerd Hoffmann--- hw/pc.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
hw/pc.c +4 -1
@@ -1095,6 +1095,7 @@ static void pc_init1(ram_addr_t ram_size,int bios_size, isa_bios_size, oprom_area_size;PCIBus *pci_bus;PCIDevice *pci_dev; +ISADevice *isa_dev;int piix3_devfn =-1 ;CPUState *env;qemu_irq *cpu_irq;
@@ -1344,7 +1345,9 @@ static void pc_init1(ram_addr_t ram_size, } } -i8042_init (i8259[1 ], i8259[12 ],0x60 ); + isa_dev =isa_create_simple ("i8042" ,0x60 ,0x64 ); +isa_connect_irq (isa_dev,0 , i8259[1 ]); +isa_connect_irq (isa_dev,1 , i8259[12 ]);DMA_init (0 );#ifdef HAS_AUDIO audio_init (pci_enabled ? pci_bus :NULL , i8259);
Signature · 1 line
1.6.2.5