qdev'ify PReP PCI host bridge
v2 cover qdev'ify PReP PCI host bridge
Hello Anthony and Hervé,
Here's my rebased qdev'ification of PReP PCI host.
It is tested not to make things worse than they are already.
I've split up my original patch and did some renaming to make it better readable. Please compare it to yours; it is intended to go in before the second QOM series.
Some not immediately needed changes, such as adding the IRQs as state to the SysBus device (Hervé's patch) and dropping pci_prep_init() in favor of sysbus_create_simple() are deferred to the 40P machine series.
Regards,
Andreas
Changes since v1:
* Use the new .vendor_id etc. in PCIDeviceInfo
* Rename from PRePPCI to Raven, adopt naming scheme from i440FX
* Rebase onto multiple Memory API conversions
* Split into PCIDevice and SysBus patches, leave out PREPPCIState changes
http://patchwork.ozlabs.org/patch/100268/
Andreas Färber (3):
prep: qdev'ify Raven host bridge
prep: Add Raven PCI host SysBus device
MAINTAINERS: Add PCI host bridge files to PReP machine
MAINTAINERS | 1 + hw/prep_pci.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 74 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.7
PATCH v2 1/3 prep: qdev'ify Raven host bridge
Move initialization of vendor ID, etc. to PCIDeviceInfo. Add VMState.
--- hw/prep_pci.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-)
hw/prep_pci.c +46 -9
@@ -29,6 +29,10 @@typedef PCIHostState PREPPCIState ; +typedef struct RavenPCIState { +PCIDevice dev; +}RavenPCIState ; +static inline uint32_t PPC_PCIIO_config (target_phys_addr_t addr) {int i;
@@ -111,7 +115,6 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_io) {PREPPCIState *s; -PCIDevice *d; s =g_malloc0 (sizeof (PREPPCIState)); s->bus = pci_register_bus(NULL, "pci",
@@ -133,16 +136,50 @@ PCIBus *pci_prep_init(qemu_irq *pic,memory_region_init_io (&s->mmcfg, &PPC_PCIIO_ops, s,"pciio" ,0x00400000 );memory_region_add_subregion (address_space_mem,0x80800000 , &s->mmcfg); -/* PCI host bridge */ - d =pci_register_device (s->bus,"PREP Host Bridge - Motorola Raven" , -sizeof (PCIDevice),0 ,NULL ,NULL ); -pci_config_set_vendor_id (d->config,PCI_VENDOR_ID_MOTOROLA ); -pci_config_set_device_id (d->config,PCI_DEVICE_ID_MOTOROLA_RAVEN ); - d->config[0x08 ] =0x00 ;// revision -pci_config_set_class (d->config,PCI_CLASS_BRIDGE_HOST ); +pci_create_simple (s->bus,0 ,"raven" ); + +return s->bus; +} + +static int raven_init (PCIDevice *d) +{ d->config[0x0C ] =0x08 ;// cache_line_size d->config[0x0D ] =0x10 ;// latency_timer d->config[0x34 ] =0x00 ;// capabilities_pointer -return s->bus; +return 0 ; } + +static const VMStateDescription vmstate_raven = { + .name ="raven" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, RavenPCIState), +VMSTATE_END_OF_LIST () + }, +}; + +static PCIDeviceInfo raven_info = { + .qdev.name ="raven" , + .qdev.desc ="PReP Host Bridge - Motorola Raven" , + .qdev.size =sizeof (RavenPCIState), + .qdev.vmsd = &vmstate_raven, + .qdev.no_user =1 , + .no_hotplug =1 , + .init = raven_init, + .vendor_id =PCI_VENDOR_ID_MOTOROLA , + .device_id =PCI_DEVICE_ID_MOTOROLA_RAVEN , + .revision =0x00 , + .class_id =PCI_CLASS_BRIDGE_HOST , + .qdev.props = (Property []) { +DEFINE_PROP_END_OF_LIST () + }, +}; + +static void raven_register_devices (void ) +{ +pci_qdev_register (&raven_info); +} + +device_init (raven_register_devices)
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH v2 1/3] prep: qdev'ify Raven host bridge
Quoted 83 lines · Andreas Färber
Move initialization of vendor ID, etc. to PCIDeviceInfo. Add VMState.
Signed-off-by Andreas Färber<[email protected]>Cc Hervé Poussineau<[email protected]>Cc Michael S. Tsirkin<[email protected]>Cc Anthony Liguori<[email protected]>--- hw/prep_pci.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-)hw/prep_pci.c +36
-9@@ -29,6 +29,10 @@typedef PCIHostState PREPPCIState ; +typedef struct RavenPCIState { +PCIDevice dev; +}RavenPCIState ; +static inline uint32_t PPC_PCIIO_config (target_phys_addr_t addr) {int i;@@ -111,7 +115,6 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_io) {PREPPCIState *s; -PCIDevice *d; s =g_malloc0 (sizeof (PREPPCIState)); s->bus = pci_register_bus(NULL, "pci",@@ -133,16 +136,50 @@ PCIBus *pci_prep_init(qemu_irq *pic,memory_region_init_io (&s->mmcfg,&PPC_PCIIO_ops, s,"pciio" ,0x00400000 );memory_region_add_subregion (address_space_mem,0x80800000 ,&s->mmcfg); -/* PCI host bridge */ - d =pci_register_device (s->bus,"PREP Host Bridge - Motorola Raven" , -sizeof (PCIDevice),0 ,NULL ,NULL ); -pci_config_set_vendor_id (d->config,PCI_VENDOR_ID_MOTOROLA ); -pci_config_set_device_id (d->config,PCI_DEVICE_ID_MOTOROLA_RAVEN ); - d->config[0x08 ] =0x00 ;// revision -pci_config_set_class (d->config,PCI_CLASS_BRIDGE_HOST ); +pci_create_simple (s->bus,0 ,"raven" ); + +return s->bus; +} + +static int raven_init (PCIDevice *d) +{ d->config[0x0C ] =0x08 ;// cache_line_size d->config[0x0D ] =0x10 ;// latency_timer d->config[0x34 ] =0x00 ;// capabilities_pointer -return s->bus; +return 0 ; } + +static const VMStateDescription vmstate_raven = { + .name ="raven" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, RavenPCIState), +VMSTATE_END_OF_LIST () + }, +}; + +static PCIDeviceInfo raven_info = { + .qdev.name ="raven" , + .qdev.desc ="PReP Host Bridge - Motorola Raven" , + .qdev.size =sizeof (RavenPCIState), + .qdev.vmsd =&vmstate_raven, + .qdev.no_user =1 , + .no_hotplug =1 , + .init = raven_init, + .vendor_id =PCI_VENDOR_ID_MOTOROLA , + .device_id =PCI_DEVICE_ID_MOTOROLA_RAVEN , + .revision =0x00 , + .class_id =PCI_CLASS_BRIDGE_HOST , + .qdev.props = (Property []) {
hw/prep_pci.c PCIBus *pci_prep_init(qemu_irq *pic, · line 185
Quoted 10 lines
hw/prep_pci.c +10
-0+DEFINE_PROP_END_OF_LIST () + }, +}; + +static void raven_register_devices (void ) +{ +pci_qdev_register (&raven_info); +} + +device_init (raven_register_devices)
How can the host bridge itself be a PCI device? What we do for the i440fx is have a i440fx-pcihost device which is a SysBusDevice and then a create a separate PCIDevice (i440fx) which acts as the host device config space.
Regards,
Anthony Liguori
PATCH v2 2/3 prep: Add Raven PCI host SysBus device
In reply to Andreas FärberFor now, focus on qdev'ification and leave PIC IRQs unchanged.
--- hw/prep_pci.c | 41 +++++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 10 deletions(-)
hw/prep_pci.c +31 -10
@@ -114,31 +114,43 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io) { +DeviceState *dev;PREPPCIState *s; - s =g_malloc0 (sizeof (PREPPCIState)); - s->bus =pci_register_bus (NULL ,"pci" , + dev =qdev_create (NULL ,"raven-pcihost" ); + s =FROM_SYSBUS (PREPPCIState,sysbus_from_qdev (dev)); + s->address_space = address_space_mem; + s->bus =pci_register_bus (&s->busdev.qdev,"pci" , prep_set_irq, prep_map_irq, pic, address_space_mem, address_space_io,0 ,4 ); +qdev_init_nofail (dev); +qdev_property_add_child (qdev_get_root (),"raven" , dev,NULL ); + +memory_region_init_io (&s->mmcfg, &PPC_PCIIO_ops, s,"pciio" ,0x00400000 ); +memory_region_add_subregion (address_space_mem,0x80800000 , &s->mmcfg); + +pci_create_simple (s->bus,0 ,"raven" ); + +return s->bus; +} + +static int raven_pcihost_init (SysBusDevice *dev) +{ +PREPPCIState *s =FROM_SYSBUS (PREPPCIState, dev);memory_region_init_io (&s->conf_mem, &pci_host_conf_be_ops, s,"pci-conf-idx" ,1 ); -memory_region_add_subregion (address_space_io,0xcf8 , &s->conf_mem); +sysbus_add_io (dev,0xcf8 , &s->conf_mem);sysbus_init_ioports (&s->busdev,0xcf8 ,1 );memory_region_init_io (&s->data_mem, &pci_host_data_be_ops, s,"pci-conf-data" ,1 ); -memory_region_add_subregion (address_space_io,0xcfc , &s->data_mem); +sysbus_add_io (dev,0xcfc , &s->data_mem);sysbus_init_ioports (&s->busdev,0xcfc ,1 ); -memory_region_init_io (&s->mmcfg, &PPC_PCIIO_ops, s,"pciio" ,0x00400000 ); -memory_region_add_subregion (address_space_mem,0x80800000 , &s->mmcfg); - -pci_create_simple (s->bus,0 ,"raven" ); - -return s->bus; +return 0 ; }static int raven_init (PCIDevice *d)
@@ -177,8 +189,17 @@ static PCIDeviceInfo raven_info = { }, }; +static SysBusDeviceInfo raven_pcihost_info = { + .qdev.name ="raven-pcihost" , + .qdev.fw_name ="pci" , + .qdev.size =sizeof (PREPPCIState), + .qdev.no_user =1 , + .init = raven_pcihost_init, +}; +static void raven_register_devices (void ) { +sysbus_register_withprop (&raven_pcihost_info);pci_qdev_register (&raven_info); }
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH v2 2/3] prep: Add Raven PCI host SysBus device
Quoted 74 lines · Andreas Färber
For now, focus on qdev'ification and leave PIC IRQs unchanged.
Signed-off-by Andreas Färber<[email protected]>Cc Hervé Poussineau<[email protected]>Cc Michael S. Tsirkin<[email protected]>Cc Anthony Liguori<[email protected]>--- hw/prep_pci.c | 41 +++++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 10 deletions(-)hw/prep_pci.c +24
-10@@ -114,31 +114,43 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io) { +DeviceState *dev;PREPPCIState *s; - s =g_malloc0 (sizeof (PREPPCIState)); - s->bus =pci_register_bus (NULL ,"pci" , + dev =qdev_create (NULL ,"raven-pcihost" ); + s =FROM_SYSBUS (PREPPCIState,sysbus_from_qdev (dev)); + s->address_space = address_space_mem; + s->bus =pci_register_bus (&s->busdev.qdev,"pci" , prep_set_irq, prep_map_irq, pic, address_space_mem, address_space_io,0 ,4 ); +qdev_init_nofail (dev); +qdev_property_add_child (qdev_get_root (),"raven" , dev,NULL ); + +memory_region_init_io (&s->mmcfg,&PPC_PCIIO_ops, s,"pciio" ,0x00400000 ); +memory_region_add_subregion (address_space_mem,0x80800000 ,&s->mmcfg); + +pci_create_simple (s->bus,0 ,"raven" ); + +return s->bus; +} + +static int raven_pcihost_init (SysBusDevice *dev) +{ +PREPPCIState *s =FROM_SYSBUS (PREPPCIState, dev);memory_region_init_io (&s->conf_mem,&pci_host_conf_be_ops, s,"pci-conf-idx" ,1 ); -memory_region_add_subregion (address_space_io,0xcf8 ,&s->conf_mem); +sysbus_add_io (dev,0xcf8 ,&s->conf_mem);sysbus_init_ioports (&s->busdev,0xcf8 ,1 );memory_region_init_io (&s->data_mem,&pci_host_data_be_ops, s,"pci-conf-data" ,1 ); -memory_region_add_subregion (address_space_io,0xcfc ,&s->data_mem); +sysbus_add_io (dev,0xcfc ,&s->data_mem);sysbus_init_ioports (&s->busdev,0xcfc ,1 ); -memory_region_init_io (&s->mmcfg,&PPC_PCIIO_ops, s,"pciio" ,0x00400000 ); -memory_region_add_subregion (address_space_mem,0x80800000 ,&s->mmcfg); - -pci_create_simple (s->bus,0 ,"raven" ); - -return s->bus; +return 0 ; }static int raven_init (PCIDevice *d)@@ -177,8 +189,17 @@ static PCIDeviceInfo raven_info = { }, }; +static SysBusDeviceInfo raven_pcihost_info = { + .qdev.name ="raven-pcihost" ,
hw/prep_pci.c static PCIDeviceInfo raven_info = { · line 203
Quoted 10 lines
hw/prep_pci.c +7
-0+ .qdev.fw_name = "pci", + .qdev.size = sizeof(PREPPCIState), + .qdev.no_user = 1, + .init = raven_pcihost_init, +}; +static void raven_register_devices (void ) { +sysbus_register_withprop (&raven_pcihost_info);pci_qdev_register (&raven_info);
I see now :-) Ignore previous message.
Regards,
Anthony Liguori
Quoted 2 lines
hw/prep_pci.c +0
-0}
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] prep: Add Raven PCI host SysBus device
In reply to Andreas FärberQuoted 15 lines · Andreas Färber
For now, focus on qdev'ification and leave PIC IRQs unchanged.
Signed-off-by Andreas Färber <[email protected]>Cc Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Anthony Liguori <[email protected]>---
hw/prep_pci.c| 41 +++++++++++++++++++++++++++++++----------1 files changed, 31 insertions(+), 10 deletions(-)hw/prep_pci.c +0
-0
hw/prep_pci.c PCIBus *pci_prep_init(qemu_irq *pic, · line 116
Quoted 3 lines
hw/prep_pci.c +0
-0@@ -114,31 +114,43 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io) {
I'm not sure this is the best way to do this. For e500, we just create the host bridge explicitly in the board file:
/* PCI */
dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE,
mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]],
mpic[pci_irq_nrs[2]], mpic[pci_irq_nrs[3]],
NULL);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
if (!pci_bus)
printf("couldn't create PCI controller!\n");and that's all the interaction there is between the pci host code and the board code. No calling into functions. The way you're doing it now, the board still needs to call into prep_pci.c which doesn't sound too appealing to me :).
hw/prep_pci.c PCIBus *pci_prep_init(qemu_irq *pic, · line 127
Quoted 13 lines
hw/prep_pci.c +5
-2+DeviceState *dev;PREPPCIState *s; - s =g_malloc0 (sizeof (PREPPCIState)); - s->bus =pci_register_bus (NULL ,"pci" , + dev =qdev_create (NULL ,"raven-pcihost" ); + s =FROM_SYSBUS (PREPPCIState,sysbus_from_qdev (dev)); + s->address_space = address_space_mem; + s->bus =pci_register_bus (&s->busdev.qdev,"pci" , prep_set_irq, prep_map_irq, pic, address_space_mem, address_space_io,0 ,4 );
This should be happening in the host bridge init code. Take a look at e500_pcihost_initfn() in hw/ppce500_pci.c.
Alex
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 2/3] prep: Add Raven PCI host SysBus device
Am 11.01.2012 23:12, schrieb Alexander Graf:
Quoted 33 lines · Andreas Färber
Quoted 16 lines
For now, focus on qdev'ification and leave PIC IRQs unchanged.
Signed-off-by Andreas Färber <[email protected]>Cc Hervé Poussineau <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Anthony Liguori <[email protected]>---
hw/prep_pci.c| 41 +++++++++++++++++++++++++++++++----------1 files changed, 31 insertions(+), 10 deletions(-)hw/prep_pci.c +0
-0hw/prep_pci.c PCIBus *pci_prep_init(qemu_irq *pic, · line 116
Quoted 3 lines
hw/prep_pci.c +0
-0@@ -114,31 +114,43 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_mem, MemoryRegion *address_space_io) {I'm not sure this is the best way to do this. For e500, we just create the host bridge explicitly in the board file:
/* PCI */ dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE, mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]], mpic[pci_irq_nrs[2]], mpic[pci_irq_nrs[3]], NULL); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (!pci_bus) printf("couldn't create PCI controller!\n");
Quoted 1 line
and that's all the interaction there is between the pci host code and the board code. No calling into functions. The way you're doing it now, the board still needs to call into
prep_pci.cwhich doesn't sound too appealing to me :).
That's a TODO for a later patch. As you can see, those lines were not introduced in this series. For the PCI-ISA bridge, we need to get rid of qemu_irq *pic anyway - that's what the commit message refers to. Should clarify that, thanks.
Quoted 14 lines
hw/prep_pci.c PCIBus *pci_prep_init(qemu_irq *pic, · line 127
Quoted 13 lines
hw/prep_pci.c +5
-2+DeviceState *dev;PREPPCIState *s; - s =g_malloc0 (sizeof (PREPPCIState)); - s->bus =pci_register_bus (NULL ,"pci" , + dev =qdev_create (NULL ,"raven-pcihost" ); + s =FROM_SYSBUS (PREPPCIState,sysbus_from_qdev (dev)); + s->address_space = address_space_mem; + s->bus =pci_register_bus (&s->busdev.qdev,"pci" , prep_set_irq, prep_map_irq, pic, address_space_mem, address_space_io,0 ,4 );
Quoted 1 line
This should be happening in the host bridge init code. Take a look at
e500_pcihost_initfn()inhw/ppce500_pci.c.
I don't see how that could work for PReP: prep_set_irq and prep_map_irq need the IRQs allocated by the i8259 on the upcoming i82378 PCI-ISA bridge, which as a PCIDevice needs the PCI host bridge set up already...
To allow for board-specific setup (prep vs. 40p) v2 uses pci_bus_new() there and uses pci_bus_irqs() on the board. :)
Andreas
PATCH v2 3/3 MAINTAINERS: Add PCI host bridge files to PReP machine
In reply to Andreas Färber--- MAINTAINERS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
MAINTAINERS +1 -0
@@ -307,6 +307,7 @@ PReP M: Andreas Färber <[email protected]> S: Odd Fixes F: hw/ppc_prep.c +F: hw/prep_pci.[hc] SH4 Machines ------------
Signature · 1 line
1.7.7
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 3/3] MAINTAINERS: Add PCI host bridge files to PReP machine
Quoted 1 line · Andreas Färber
Signed-off-by Andreas Färber <[email protected]>
Alex
Quoted 20 lines
---
MAINTAINERS| 1 +1 files changed, 1 insertions(+), 0 deletions(-)MAINTAINERS +0
-0@@ -307,6 +307,7 @@ PRePM: Andreas Färber <[email protected]>
S: Odd Fixes
F:hw/ppc_prep.c
+F: hw/prep_pci.[hc]SH4 Machines
------------Signature · 1 line
1.7.7
v3 cover qdev'ify PReP PCI host bridge and add PCI-to-ISA bridge
In reply to Andreas FärberHello,
Here's an updated initial qdev'ification series for PReP, as prerequisite for Anthony's second QOM series.
As stated before, this is NOT a complete conversion of all PReP devices and of all those shared with x86. Please comment on what's there, not on what may be done, too. I'm sitting on these patches for over a year now, so let's start getting some of it merged so that we can move on with QOM and get some of the design issues fixed that kept the pc87312 Super I/O and 40P machine from getting merged in the first place!
Regards,
Andreas
Changes since v2:
* Simplify I/O byte swaps.
* Convert I/O from old_mmio to MemoryRegion ops.
* Drop pci_prep_init() and instantiate the PCI host bridge in the machine, reintroducing PREPPCIState extension.
* Connect IRQs via qdev after instantiating. Suggested by Alex.
* Add a rebased PCI-to-ISA-bridge from the 40P series on top, to show why some suggestions from v2 and IRC don't work out.
* Merge fix-up by Hervé: Add indirection for late-connected out[0] IRQ.
* Add VMState for i82374 and i82378.
* From i82378 drop the I/O address translation duplicated from the board.
* Rebase i82378 onto Memory API.
http://patchwork.ozlabs.org/patch/100250/
http://patchwork.ozlabs.org/patch/100272/
* Add new patch from Hervé to wire up the PCI-to-ISA bridge for 'prep'.
Changes since v1:
* Use the new .vendor_id etc. in PCIDeviceInfo
* Rename from PRePPCI to Raven, adopt naming scheme from i440FX
* Rebase onto multiple Memory API conversions
* Split into PCIDevice and SysBus patches, leave out PREPPCIState changes
http://patchwork.ozlabs.org/patch/100268/
Andreas Färber (8):
prep: qdev'ify Raven host bridge (PCIDevice)
prep_pci: Simplify I/O endianness
prep_pci: Update I/O to MemoryRegion ops
prep: qdev'ify Raven host bridge (SysBus)
MAINTAINERS: Add PCI host bridge files to PReP machine
prep: Add i82374 DMA emulation
prep: Add i82378 PCI-to-ISA bridge emulation
prep: Use i82378 PCI->ISA bridge for 'prep' machine
MAINTAINERS | 1 + Makefile.objs | 2 + default-configs/ppc-softmmu.mak | 3 + hw/i82374.c | 154 ++++++++++++++++++++++++ hw/i82378.c | 252 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + hw/ppc_prep.c | 77 +++++------- hw/prep_pci.c | 181 +++++++++++++++++----------- hw/prep_pci.h | 11 -- 9 files changed, 553 insertions(+), 129 deletions(-) create mode 100644 hw/i82374.c create mode 100644 hw/i82378.c delete mode 100644 hw/prep_pci.h
Signature · 1 line
1.7.7
PATCH v3 1/8 prep: qdev'ify Raven host bridge (PCIDevice)
Move initialization of vendor ID, etc. to PCIDeviceInfo. Introduce VMState.
--- hw/prep_pci.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-)
hw/prep_pci.c +46 -9
@@ -29,6 +29,10 @@typedef PCIHostState PREPPCIState ; +typedef struct RavenPCIState { +PCIDevice dev; +}RavenPCIState ; +static inline uint32_t PPC_PCIIO_config (target_phys_addr_t addr) {int i;
@@ -111,7 +115,6 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_io) {PREPPCIState *s; -PCIDevice *d; s =g_malloc0 (sizeof (PREPPCIState)); s->bus = pci_register_bus(NULL, "pci",
@@ -133,16 +136,50 @@ PCIBus *pci_prep_init(qemu_irq *pic,memory_region_init_io (&s->mmcfg, &PPC_PCIIO_ops, s,"pciio" ,0x00400000 );memory_region_add_subregion (address_space_mem,0x80800000 , &s->mmcfg); -/* PCI host bridge */ - d =pci_register_device (s->bus,"PREP Host Bridge - Motorola Raven" , -sizeof (PCIDevice),0 ,NULL ,NULL ); -pci_config_set_vendor_id (d->config,PCI_VENDOR_ID_MOTOROLA ); -pci_config_set_device_id (d->config,PCI_DEVICE_ID_MOTOROLA_RAVEN ); - d->config[0x08 ] =0x00 ;// revision -pci_config_set_class (d->config,PCI_CLASS_BRIDGE_HOST ); +pci_create_simple (s->bus,0 ,"raven" ); + +return s->bus; +} + +static int raven_init (PCIDevice *d) +{ d->config[0x0C ] =0x08 ;// cache_line_size d->config[0x0D ] =0x10 ;// latency_timer d->config[0x34 ] =0x00 ;// capabilities_pointer -return s->bus; +return 0 ; } + +static const VMStateDescription vmstate_raven = { + .name ="raven" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, RavenPCIState), +VMSTATE_END_OF_LIST () + }, +}; + +static PCIDeviceInfo raven_info = { + .qdev.name ="raven" , + .qdev.desc ="PReP Host Bridge - Motorola Raven" , + .qdev.size =sizeof (RavenPCIState), + .qdev.vmsd = &vmstate_raven, + .qdev.no_user =1 , + .no_hotplug =1 , + .init = raven_init, + .vendor_id =PCI_VENDOR_ID_MOTOROLA , + .device_id =PCI_DEVICE_ID_MOTOROLA_RAVEN , + .revision =0x00 , + .class_id =PCI_CLASS_BRIDGE_HOST , + .qdev.props = (Property []) { +DEFINE_PROP_END_OF_LIST () + }, +}; + +static void raven_register_devices (void ) +{ +pci_qdev_register (&raven_info); +} + +device_init (raven_register_devices)
Signature · 1 line
1.7.7
PATCH v3 2/8 prep_pci: Simplify I/O endianness
In reply to Andreas FärberThe prep PowerPC CPU is Big Endian. An explicit byte swap therefore effectively becomes Little Endian.
Remove explicit byte swaps and mark as Little Endian.
--- hw/prep_pci.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
hw/prep_pci.c +1 -5
@@ -53,14 +53,12 @@ static void PPC_PCIIO_writeb (void *opaque, target_phys_addr_t addr, uint32_t vastatic void PPC_PCIIO_writew (void *opaque,target_phys_addr_t addr,uint32_t val) {PREPPCIState *s = opaque; - val =bswap16 (val);pci_data_write (s->bus,PPC_PCIIO_config (addr), val,2 ); }static void PPC_PCIIO_writel (void *opaque,target_phys_addr_t addr,uint32_t val) {PREPPCIState *s = opaque; - val =bswap32 (val);pci_data_write (s->bus,PPC_PCIIO_config (addr), val,4 ); }
@@ -77,7 +75,6 @@ static uint32_t PPC_PCIIO_readw (void *opaque, target_phys_addr_t addr)PREPPCIState *s = opaque;uint32_t val; val =pci_data_read (s->bus,PPC_PCIIO_config (addr),2 ); - val =bswap16 (val);return val; }
@@ -86,7 +83,6 @@ static uint32_t PPC_PCIIO_readl (void *opaque, target_phys_addr_t addr)PREPPCIState *s = opaque;uint32_t val; val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 ); - val =bswap32 (val);return val; }
@@ -95,7 +91,7 @@ static const MemoryRegionOps PPC_PCIIO_ops = { .read = { PPC_PCIIO_readb, PPC_PCIIO_readw, PPC_PCIIO_readl, }, .write = { PPC_PCIIO_writeb, PPC_PCIIO_writew, PPC_PCIIO_writel, }, }, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, };static int prep_map_irq (PCIDevice *pci_dev,int irq_num)
Signature · 1 line
1.7.7
PATCH v3 3/8 prep_pci: Update I/O to MemoryRegion ops
In reply to Andreas FärberConvert to new-style read/write callbacks.
--- hw/prep_pci.c | 61 +++++++++++++++++++++----------------------------------- 1 files changed, 23 insertions(+), 38 deletions(-)
hw/prep_pci.c +23 -38
@@ -44,53 +44,38 @@ static inline uint32_t PPC_PCIIO_config(target_phys_addr_t addr)return (addr &0x7ff ) | (i <<11 ); } -static void PPC_PCIIO_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) +static void ppc_pci_io_write (void *opaque,target_phys_addr_t addr, +uint64_t val,unsigned int size) {PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,1 ); -} - -static void PPC_PCIIO_writew (void *opaque,target_phys_addr_t addr,uint32_t val) -{ -PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,2 ); -} - -static void PPC_PCIIO_writel (void *opaque,target_phys_addr_t addr,uint32_t val) -{ -PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,4 ); -} - -static uint32_t PPC_PCIIO_readb (void *opaque,target_phys_addr_t addr) -{ -PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),1 ); -return val; -} - -static uint32_t PPC_PCIIO_readw (void *opaque,target_phys_addr_t addr) -{ -PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),2 ); -return val; +switch (size) { +case 1 : +case 2 : +case 4 : +pci_data_write (s->bus,PPC_PCIIO_config (addr), val, size); +break ; +default : +abort (); + } } -static uint32_t PPC_PCIIO_readl (void *opaque,target_phys_addr_t addr) +static uint64_t ppc_pci_io_read (void *opaque,target_phys_addr_t addr, +unsigned int size) {PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 ); -return val; +switch (size) { +case 1 : +case 2 : +case 4 : +return pci_data_read (s->bus,PPC_PCIIO_config (addr), size); +default : +abort (); + } }static const MemoryRegionOps PPC_PCIIO_ops = { - .old_mmio = { - .read = { PPC_PCIIO_readb, PPC_PCIIO_readw, PPC_PCIIO_readl, }, - .write = { PPC_PCIIO_writeb, PPC_PCIIO_writew, PPC_PCIIO_writel, }, - }, + .read = ppc_pci_io_read, + .write = ppc_pci_io_write, .endianness =DEVICE_LITTLE_ENDIAN , };
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH v3 3/8] prep_pci: Update I/O to MemoryRegion ops
Quoted 10 lines · Andreas Färber
Convert to new-style read/write callbacks.
hw/prep_pci.c +2
-3-static uint32_t PPC_PCIIO_readl (void *opaque,target_phys_addr_t addr) +static uint64_t ppc_pci_io_read (void *opaque,target_phys_addr_t addr, +unsigned int size) {PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 );
hw/prep_pci.c static inline uint32_t PPC_PCIIO_config(target_phys_addr_t addr) · line 74
Quoted 10 lines
hw/prep_pci.c +8
-1-return val; +switch (size) { +case 1 : +case 2 : +case 4 : +return pci_data_read (s->bus,PPC_PCIIO_config (addr), size); +default : +abort (); + } }
Huh? just call pci_data_read() unconditionally.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH v3 3/8] prep_pci: Update I/O to MemoryRegion ops
Am 15.01.2012 10:19, schrieb Avi Kivity:
Quoted 15 lines · Andreas Färber
Quoted 14 lines
Convert to new-style read/write callbacks.
hw/prep_pci.c +5
-4-static uint32_t PPC_PCIIO_readl (void *opaque,target_phys_addr_t addr) +static uint64_t ppc_pci_io_read (void *opaque,target_phys_addr_t addr, +unsigned int size) {PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 ); -return val; +switch (size) { +case 1 : +case 2 :
Quoted 8 lines
hw/prep_pci.c static inline uint32_t PPC_PCIIO_config(target_phys_addr_t addr) · line 74
Quoted 6 lines
hw/prep_pci.c +5
-0+case 4 : +return pci_data_read (s->bus,PPC_PCIIO_config (addr), size); +default : +abort (); + } }Huh? just call
pci_data_read()unconditionally.
Just so that I understand, is that because PReP is 32-bit ppc? In the above mechanical conversion, size 8 would abort.
BTW did we agree on an indentation style for switch?
Andreas
Re: [Qemu-devel] [PATCH v3 3/8] prep_pci: Update I/O to MemoryRegion ops
Quoted 25 lines · Andreas Färber
Am 15.01.2012 10:19, schrieb Avi Kivity:
Quoted 15 lines · Andreas Färber
Quoted 14 lines
Convert to new-style read/write callbacks.
hw/prep_pci.c +5
-4-static uint32_t PPC_PCIIO_readl (void *opaque,target_phys_addr_t addr) +static uint64_t ppc_pci_io_read (void *opaque,target_phys_addr_t addr, +unsigned int size) {PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 ); -return val; +switch (size) { +case 1 : +case 2 :Quoted 8 lines
hw/prep_pci.c static inline uint32_t PPC_PCIIO_config(target_phys_addr_t addr) · line 74
Quoted 6 lines
hw/prep_pci.c +5
-0+case 4 : +return pci_data_read (s->bus,PPC_PCIIO_config (addr), size); +default : +abort (); + } }Huh? just call
pci_data_read()unconditionally.
Quoted 2 lines
Just so that I understand, is that because PReP is 32-bit ppc? In the above mechanical conversion, size 8 would abort.
The memory core never issues size 8 transactions, since the code is unprepared for it. When we will support it, you'll have to explicitly declare it with .impl.max_access_size = 8 or something.
Quoted 1 line
BTW did we agree on an indentation style for switch?
What you wrote conforms to the de facto standard.
Signature · 1 line
error compiling committee.c: too many arguments to function
PATCH v3 4/8 prep: qdev'ify Raven host bridge (SysBus)
In reply to Andreas FärberDrop pci_prep_init() in favor of extended device state. Inspired by patches from Hervé and Alex.
Assign the 4 IRQs from the board after device instantiation. This moves the knowledge out of prep_pci and allows for future machines with different IRQ wiring (IBM 40P). Suggested by Alex.
--- hw/ppc_prep.c | 23 +++++++++++++++++- hw/prep_pci.c | 67 +++++++++++++++++++++++++++++++++++--------------------- hw/prep_pci.h | 11 --------- 3 files changed, 63 insertions(+), 38 deletions(-) delete mode 100644 hw/prep_pci.h
hw/ppc_prep.c +21 -2
@@ -29,7 +29,7 @@#include "sysemu.h" #include "isa.h" #include "pci.h" -#include "prep_pci.h" +#include "pci_host.h" #include "usb-ohci.h" #include "ppc.h" #include "boards.h"
@@ -522,6 +522,9 @@ static void ppc_prep_init (ram_addr_t ram_size,MemoryRegion *bios =g_new (MemoryRegion,1 );uint32_t kernel_base, initrd_base;long kernel_size, initrd_size; +DeviceState *dev; +SysBusDevice *sys; +PCIHostState *pcihost;PCIBus *pci_bus;ISABus *isa_bus;qemu_irq *i8259;
@@ -633,7 +636,23 @@ static void ppc_prep_init (ram_addr_t ram_size,/* Hmm, prep has no pci-isa bridge ??? */ isa_bus =isa_bus_new (NULL ,get_system_io ()); i8259 =i8259_init (isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); - pci_bus =pci_prep_init (i8259,get_system_memory (),get_system_io ()); + + dev =qdev_create (NULL ,"raven-pcihost" ); + sys =sysbus_from_qdev (dev); + pcihost =DO_UPCAST (PCIHostState, busdev, sys); + pcihost->address_space =get_system_memory (); +qdev_init_nofail (dev); +qdev_property_add_child (qdev_get_root (),"raven" , dev,NULL ); + pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci.0" ); +if (pci_bus ==NULL ) { +fprintf (stderr,"Couldn't create PCI host controller.\n" ); +exit (1 ); + } +sysbus_connect_irq (&pcihost->busdev,0 , i8259[9 ]); +sysbus_connect_irq (&pcihost->busdev,1 , i8259[11 ]); +sysbus_connect_irq (&pcihost->busdev,2 , i8259[9 ]); +sysbus_connect_irq (&pcihost->busdev,3 , i8259[11 ]); +isa_bus_irqs (isa_bus, i8259);// pci_bus = i440fx_init(); /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
hw/prep_pci.c +42 -25
111 lines not on this page · raw message
hw/prep_pci.h deleted +0 -11
@@ -1,11 +0,0 @@ -#ifndef QEMU_PREP_PCI_H -#define QEMU_PREP_PCI_H - -#include "qemu-common.h" -#include "memory.h" - -PCIBus *pci_prep_init (qemu_irq *pic, -MemoryRegion *address_space_mem, -MemoryRegion *address_space_io); - -#endif
Signature · 1 line
1.7.7
PATCH v3 5/8 MAINTAINERS: Add PCI host bridge files to PReP machine
In reply to Andreas Färber--- MAINTAINERS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
MAINTAINERS +1 -0
@@ -307,6 +307,7 @@ PReP M: Andreas Färber <[email protected]> S: Odd Fixes F: hw/ppc_prep.c +F: hw/prep_pci.[hc] SH4 Machines ------------
Signature · 1 line
1.7.7
PATCH v3 6/8 prep: Add i82374 DMA emulation
In reply to Andreas FärberPrepare Intel 82374 emulation for use by Intel 82378 PCI->ISA bridge.
Confine to CONFIG_I82374. Add VMState.
--- Makefile.objs | 1 + default-configs/ppc-softmmu.mak | 1 + hw/i82374.c | 154 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 0 deletions(-) create mode 100644 hw/i82374.c
Makefile.objs +1 -0
@@ -215,6 +215,7 @@ hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o +hw-obj-$(CONFIG_I82374) += i82374.o hw-obj-$(CONFIG_HPET) += hpet.o hw-obj-$(CONFIG_APPLESMC) += applesmc.o hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o
default-configs/ppc-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_I8254=y CONFIG_PCKBD=y CONFIG_FDC=y CONFIG_DMA=y +CONFIG_I82374=y CONFIG_OPENPIC=y CONFIG_PREP_PCI=y CONFIG_MACIO=y
hw/i82374.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v3 7/8 prep: Add i82378 PCI-to-ISA bridge emulation
In reply to Andreas FärberPrepare Intel 82378 emulation for use by PReP platforms.
Create ISA bus in this device (suggested by Markus). Rebase onto Memory API, mark memory ops as Little Endian. Add VMState.
--- Makefile.objs | 1 + default-configs/ppc-softmmu.mak | 2 + hw/i82378.c | 252 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + 4 files changed, 256 insertions(+), 0 deletions(-) create mode 100644 hw/i82378.c
Makefile.objs +1 -0
@@ -225,6 +225,7 @@ hw-obj-$(CONFIG_I8259) += i8259.o # PPC devices hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o +hw-obj-$(CONFIG_I82378) += i82378.o # Mac shared devices hw-obj-$(CONFIG_MACIO) += macio.o hw-obj-$(CONFIG_CUDA) += cuda.o
default-configs/ppc-softmmu.mak +2 -0
@@ -14,7 +14,9 @@ CONFIG_DMA=y CONFIG_I82374=y CONFIG_OPENPIC=y CONFIG_PREP_PCI=y +CONFIG_I82378=y CONFIG_MACIO=y +CONFIG_PCSPK=y CONFIG_CUDA=y CONFIG_ADB=y CONFIG_MAC_NVRAM=y
hw/i82378.c new file +252 -0
252 lines not on this page · raw message
hw/pci_ids.h +1 -0
@@ -98,6 +98,7 @@#define PCI_DEVICE_ID_MPC8533E 0x0030#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_82378 0x0484#define PCI_DEVICE_ID_INTEL_82441 0x1237#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415#define PCI_DEVICE_ID_INTEL_82801D 0x24CD
Signature · 1 line
1.7.7
PATCH v3 8/8 prep: Use i82378 PCI->ISA bridge for 'prep' machine
In reply to Andreas FärberSpeaker I/O, ISA bus, i8259 PIC, RTC and DMA are no longer set up individually by the machine. Effectively, no-op speaker I/O is replaced by pcspk; PIT and i82374 DMA are introduced.
Remove related dead, alternative code.
Access i8259 IRQs via ISA bus to resolve cyclic dependency with PCI host bridge.
--- hw/ppc_prep.c | 54 +++++++++++------------------------------------------- 1 files changed, 11 insertions(+), 43 deletions(-)
hw/ppc_prep.c +11 -43
@@ -83,37 +83,9 @@ static const int ide_irq[2] = { 13, 13 };static uint32_t ne2000_io[NE2000_NB_MAX ] = {0x300 ,0x320 ,0x340 ,0x360 ,0x280 ,0x380 };static int ne2000_irq[NE2000_NB_MAX ] = {9 ,10 ,11 ,3 ,4 ,5 }; -//static ISADevice *pit; -/* ISA IO ports bridge */ #define PPC_IO_BASE 0x80000000 -#if 0 -/* Speaker port 0x61 */ -static int speaker_data_on; -static int dummy_refresh_clock; -#endif - -static void speaker_ioport_write (void *opaque,uint32_t addr,uint32_t val) -{ -#if 0 - speaker_data_on = (val >>1 ) &1 ; -pit_set_gate (pit,2 , val &1 ); -#endif -} - -static uint32_t speaker_ioport_read (void *opaque,uint32_t addr) -{ -#if 0 -int out; - out =pit_get_out (pit,2 ,qemu_get_clock_ns (vm_clock)); - dummy_refresh_clock ^=1 ; -return (speaker_data_on <<1 ) |pit_get_gate (pit,2 ) | (out <<5 ) | - (dummy_refresh_clock <<4 ); -#endif -return 0 ; -} -/* PCI intack register */ /* Read-only register (?) */ static void PPC_intack_write (void *opaque, target_phys_addr_t addr,
@@ -526,6 +498,7 @@ static void ppc_prep_init (ram_addr_t ram_size,SysBusDevice *sys;PCIHostState *pcihost;PCIBus *pci_bus; +PCIDevice *pci;ISABus *isa_bus;qemu_irq *i8259;qemu_irq *cpu_exit_irq;
@@ -629,13 +602,9 @@ static void ppc_prep_init (ram_addr_t ram_size, } } - isa_mem_base =0xc0000000 ;if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {hw_error ("Only 6xx bus is supported on PREP machine\n" ); } -/* Hmm, prep has no pci-isa bridge ??? */ - isa_bus =isa_bus_new (NULL ,get_system_io ()); - i8259 =i8259_init (isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); dev =qdev_create (NULL ,"raven-pcihost" ); sys =sysbus_from_qdev (dev);
@@ -648,13 +617,21 @@ static void ppc_prep_init (ram_addr_t ram_size,fprintf (stderr,"Couldn't create PCI host controller.\n" );exit (1 ); } + +/* PCI -> ISA bridge */ + pci =pci_create_simple (pci_bus,PCI_DEVFN (1 ,0 ),"i82378" ); + cpu_exit_irq =qemu_allocate_irqs (cpu_request_exit,NULL ,1 ); +qdev_connect_gpio_out (&pci->qdev,0 , + first_cpu->irq_inputs[PPC6xx_INPUT_INT]); +qdev_connect_gpio_out (&pci->qdev,1 , *cpu_exit_irq); + isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); + + i8259 = isa_bus->irqs;sysbus_connect_irq (&pcihost->busdev,0 , i8259[9 ]);sysbus_connect_irq (&pcihost->busdev,1 , i8259[11 ]);sysbus_connect_irq (&pcihost->busdev,2 , i8259[9 ]);sysbus_connect_irq (&pcihost->busdev,3 , i8259[11 ]); -isa_bus_irqs (isa_bus, i8259); -// pci_bus = i440fx_init(); /* Register 8 MB of ISA IO space (needed for non-contiguous map) */ memory_region_init_io (PPC_io_memory, &PPC_prep_io_ops, sysctrl,"ppc-io" ,0x00800000 );
@@ -662,9 +639,6 @@ static void ppc_prep_init (ram_addr_t ram_size,/* init basic PC hardware */ pci_vga_init (pci_bus); -// openpic = openpic_init(0x00000000, 0xF0000000, 1); -// pit = pit_init(0x40, 0); -rtc_init (isa_bus,2000 ,NULL );if (serial_hds[0 ])serial_isa_init (isa_bus,0 , serial_hds[0 ]);
@@ -691,9 +665,6 @@ static void ppc_prep_init (ram_addr_t ram_size, }isa_create_simple (isa_bus,"i8042" ); - cpu_exit_irq =qemu_allocate_irqs (cpu_request_exit,NULL ,1 ); -DMA_init (1 , cpu_exit_irq); -// SB16_init(); for (i =0 ; i <MAX_FD ; i++) {
@@ -701,9 +672,6 @@ static void ppc_prep_init (ram_addr_t ram_size, }fdctrl_init_isa (isa_bus, fd); -/* Register speaker port */ -register_ioport_read (0x61 ,1 ,1 , speaker_ioport_read,NULL ); -register_ioport_write (0x61 ,1 ,1 , speaker_ioport_write,NULL );/* Register fake IO ports for PREP */ sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];register_ioport_read (0x398 ,2 ,1 , &PREP_io_read, sysctrl);
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH v3 8/8] prep: Use i82378 PCI->ISA bridge for 'prep' machine
Quoted 85 lines · Andreas Färber
Speaker I/O, ISA bus, i8259 PIC, RTC and DMA are no longer set up individually by the machine. Effectively, no-op speaker I/O is replaced by pcspk; PIT and i82374 DMA are introduced.
Signed-off-by Hervé Poussineau <[email protected]>Remove related dead, alternative code.
Access i8259 IRQs via ISA bus to resolve cyclic dependency with PCI host bridge.Signed-off-by Andreas Färber <[email protected]>Cc Alexander Graf <[email protected]>Cc Jan Kiszka <[email protected]>--- hw/ppc_prep.c | 54 +++++++++++------------------------------------------- 1 files changed, 11 insertions(+), 43 deletions(-)hw/ppc_prep.c +1
-32@@ -83,37 +83,9 @@ static const int ide_irq[2] = { 13, 13 };static uint32_t ne2000_io[NE2000_NB_MAX ] = {0x300 ,0x320 ,0x340 ,0x360 ,0x280 ,0x380 };static int ne2000_irq[NE2000_NB_MAX ] = {9 ,10 ,11 ,3 ,4 ,5 }; -//static ISADevice *pit; -/* ISA IO ports bridge */ #define PPC_IO_BASE 0x80000000 -#if 0 -/* Speaker port 0x61 */ -static int speaker_data_on; -static int dummy_refresh_clock; -#endif - -static void speaker_ioport_write (void *opaque,uint32_t addr,uint32_t val) -{ -#if 0 - speaker_data_on = (val >>1 ) &1 ; -pit_set_gate (pit,2 , val &1 ); -#endif -} - -static uint32_t speaker_ioport_read (void *opaque,uint32_t addr) -{ -#if 0 -int out; - out =pit_get_out (pit,2 ,qemu_get_clock_ns (vm_clock)); - dummy_refresh_clock ^=1 ; -return (speaker_data_on <<1 ) |pit_get_gate (pit,2 ) | (out <<5 ) | - (dummy_refresh_clock <<4 ); -#endif -return 0 ; -} -/* PCI intack register */ /* Read-only register (?) */ static void PPC_intack_write (void *opaque, target_phys_addr_t addr,@@ -526,6 +498,7 @@ static void ppc_prep_init (ram_addr_t ram_size,SysBusDevice *sys;PCIHostState *pcihost;PCIBus *pci_bus; +PCIDevice *pci;ISABus *isa_bus;qemu_irq *i8259;qemu_irq *cpu_exit_irq;@@ -629,13 +602,9 @@ static void ppc_prep_init (ram_addr_t ram_size, } } - isa_mem_base =0xc0000000 ;if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {hw_error ("Only 6xx bus is supported on PREP machine\n" ); } -/* Hmm, prep has no pci-isa bridge ??? */ - isa_bus =isa_bus_new (NULL ,get_system_io ()); - i8259 =i8259_init (isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); dev =qdev_create (NULL ,"raven-pcihost" ); sys =sysbus_from_qdev (dev);@@ -648,13 +617,21 @@ static void ppc_prep_init (ram_addr_t ram_size,fprintf (stderr,"Couldn't create PCI host controller.\n" );exit (1 ); }
hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 629
Quoted 10 lines
hw/ppc_prep.c +10
-0+ +/* PCI -> ISA bridge */ + pci =pci_create_simple (pci_bus,PCI_DEVFN (1 ,0 ),"i82378" ); + cpu_exit_irq =qemu_allocate_irqs (cpu_request_exit,NULL ,1 ); +qdev_connect_gpio_out (&pci->qdev,0 , + first_cpu->irq_inputs[PPC6xx_INPUT_INT]); +qdev_connect_gpio_out (&pci->qdev,1 , *cpu_exit_irq); + isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); + + i8259 = isa_bus->irqs;
I think this is unneeded. You only access i8259[8] later on for initializing the m48t59. But that one should be creatable as ISA device now (m48t59_init_isa), no? Please check.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH v3 8/8] prep: Use i82378 PCI->ISA bridge for 'prep' machine
Am 13.01.2012 10:21, schrieb Jan Kiszka:
Quoted 6 lines · Andreas Färber
hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 629
Quoted 3 lines
hw/ppc_prep.c +3
-0+ isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); + + i8259 = isa_bus->irqs;I think this is unneeded.
The problem here was that isa_get_irq() needs an ISADevice*, not just the ISABus*, so I had to access ->irqs directly at this point.
Some of the later ISA devices are optional, others will be moved to the pc87312. The i8042 might be an option if we really have to.
Quoted 2 lines
You only access i8259[8] later on for
initializing the m48t59.
And immediately following your quote i8259[9] and i8259[11] for the host bridge.
The alternative would be to access the i8259's IRQs (initialized in the PCI-ISA bridge needing the PCI host bridge) via a QOM property from here. Or access the PCI host bridge from the PCI-ISA bridge init.
Quoted 2 lines
But that one should be creatable as ISA device
now (m48t59_init_isa), no? Please check.
Ah, that matches a patch by Hervé confusingly named "fix compilation". Using the ISA version even resolves the m48t59 io_base issue I reported earlier. I'll send a separate patch and rebase onto that.
Andreas
Re: [Qemu-devel] [PATCH v3 8/8] prep: Use i82378 PCI->ISA bridge for 'prep' machine
Quoted 10 lines · Andreas Färber
Am 13.01.2012 10:21, schrieb Jan Kiszka:
Quoted 6 lines · Andreas Färber
hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 629
Quoted 3 lines
hw/ppc_prep.c +3
-0+ isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); + + i8259 = isa_bus->irqs;I think this is unneeded.
The problem here was that
isa_get_irq()needs an ISADevice*, not just the ISABus*, so I had to access ->irqs directly at this point.
Which is a hack that should not be merged.
Quoted 9 lines
Some of the later ISA devices are optional, others will be moved to the pc87312. The i8042 might be an option if we really have to.
Quoted 2 lines
You only access i8259[8] later on for
initializing the m48t59.And immediately following your quote i8259[9] and i8259[11] for the host bridge.
I was looking at upstream. Which patch is this?
Quoted 11 lines
The alternative would be to access the i8259's IRQs (initialized in the PCI-ISA bridge needing the PCI host bridge) via a QOM property from here. Or access the PCI host bridge from the PCI-ISA bridge init.
Quoted 2 lines
But that one should be creatable as ISA device
now (m48t59_init_isa), no? Please check.Ah, that matches a patch by Hervé confusingly named "fix compilation". Using the ISA version even resolves the m48t59
io_baseissue I reported earlier. I'll send a separate patch and rebase onto that.
What about the other IRQs? Can they be associated with ISADevices as well?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH v3 8/8] prep: Use i82378 PCI->ISA bridge for 'prep' machine
Quoted 18 lines · Jan Kiszka
Quoted 10 lines · Andreas Färber
Am 13.01.2012 10:21, schrieb Jan Kiszka:
Quoted 6 lines · Andreas Färber
hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 629
Quoted 3 lines
hw/ppc_prep.c +3
-0+ isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); + + i8259 = isa_bus->irqs;I think this is unneeded.
The problem here was that
isa_get_irq()needs an ISADevice*, not just the ISABus*, so I had to access ->irqs directly at this point.Which is a hack that should not be merged.
Quoted 4 lines
Some of the later ISA devices are optional, others will be moved to the pc87312. The i8042 might be an option if we really have to.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
You only access i8259[8] later on for
initializing the m48t59.And immediately following your quote i8259[9] and i8259[11] for the host bridge.
I was looking at upstream. Which patch is this?
The patch you were commenting on :)
Alex
Re: [Qemu-devel] [PATCH v3 8/8] prep: Use i82378 PCI->ISA bridge for 'prep' machine
Quoted 24 lines · Alexander Graf
Quoted 21 lines · Jan Kiszka
Quoted 10 lines · Andreas Färber
Am 13.01.2012 10:21, schrieb Jan Kiszka:
Quoted 6 lines · Andreas Färber
hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 629
Quoted 3 lines
hw/ppc_prep.c +3
-0+ isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); + + i8259 = isa_bus->irqs;I think this is unneeded.
The problem here was that
isa_get_irq()needs an ISADevice*, not just the ISABus*, so I had to access ->irqs directly at this point.Which is a hack that should not be merged.
Quoted 7 lines
Some of the later ISA devices are optional, others will be moved to the pc87312. The i8042 might be an option if we really have to.
Quoted 2 lines
You only access i8259[8] later on for
initializing the m48t59.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
And immediately following your quote i8259[9] and i8259[11] for the host bridge.
I was looking at upstream. Which patch is this?
The patch you were commenting on :)
I see now. It just doesn't introduce it. :)
OK, so the problem is that the creator of the PIC does not export the input IRQs in a way that they can be used by non-ISA chipset-external devices as well. It's that fixable? Via GPIO pins of the chipset e.g.?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH v3 0/8] qdev'ify PReP PCI host bridge and add PCI-to-ISA bridge
In reply to Andreas FärberAm 13.01.2012 04:09, schrieb Andreas Färber:
Quoted 4 lines
Hello,
Here's an updated initial qdev'ification series for PReP, as prerequisite for Anthony's second QOM series.
Available from
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/prep-queue
on top of all patches needed for testing.
Quoted 23 lines
Andreas Färber (8):
prep: qdev'ify Raven host bridge (PCIDevice)
prep_pci: Simplify I/O endianness
prep_pci: Update I/O to MemoryRegion ops
prep: qdev'ify Raven host bridge (SysBus)
MAINTAINERS: Add PCI host bridge files to PReP machine
prep: Add i82374 DMA emulation
prep: Add i82378 PCI-to-ISA bridge emulation
prep: Use i82378PCI->ISAbridge for 'prep' machineMAINTAINERS | 1 + Makefile.objs | 2 + default-configs/ppc-softmmu.mak | 3 + hw/i82374.c | 154 ++++++++++++++++++++++++ hw/i82378.c | 252 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + hw/ppc_prep.c | 77 +++++------- hw/prep_pci.c | 181 +++++++++++++++++----------- hw/prep_pci.h | 11 -- 9 files changed, 553 insertions(+), 129 deletions(-) create mode 100644 hw/i82374.c create mode 100644 hw/i82378.c delete mode 100644 hw/prep_pci.h
Re: [Qemu-devel] [PATCH v3 0/8] qdev'ify PReP PCI host bridge and add PCI-to-ISA bridge
In reply to Andreas FärberQuoted 12 lines · Andreas Färber
Hello,
Here's an updated initial qdev'ification series for PReP, as prerequisite for Anthony's second QOM series.
As stated before, this is NOT a complete conversion of all PReP devices and of all those shared with x86. Please comment on what's there, not on what may be done, too. I'm sitting on these patches for over a year now, so let's start getting some of it merged so that we can move on with QOM and get some of the design issues fixed that kept the pc87312 Super I/O and 40P machine from getting merged in the first place!
Quoted 2 lines
Regards,
Andreas
Looks good to me.
Alex
Quoted 55 lines
Changes since v2:
* Simplify I/O byte swaps.
* Convert I/O fromold_mmioto MemoryRegion ops.
* Droppci_prep_init()and instantiate the PCI host bridge in the machine, reintroducing PREPPCIState extension.
* Connect IRQs via qdev after instantiating. Suggested by Alex.
* Add a rebased PCI-to-ISA-bridge from the 40P series on top, to show why some suggestions from v2 and IRC don't work out.
* Merge fix-up by Hervé: Add indirection for late-connected out[0] IRQ.
* Add VMState for i82374 and i82378.
* From i82378 drop the I/O address translation duplicated from the board.
* Rebase i82378 onto Memory API.
http://patchwork.ozlabs.org/patch/100250/
http://patchwork.ozlabs.org/patch/100272/
* Add new patch from Hervé to wire up the PCI-to-ISA bridge for 'prep'.Changes since v1:
* Use the new .vendor_id etc. in PCIDeviceInfo
* Rename from PRePPCI to Raven, adopt naming scheme from i440FX
* Rebase onto multiple Memory API conversions
* Split into PCIDevice and SysBus patches, leave out PREPPCIState changes
http://patchwork.ozlabs.org/patch/100268/Cc Hervé Poussineau <[email protected]>Cc Anthony Liguori <[email protected]>Cc Alexander Graf <[email protected]>Andreas Färber (8):
prep: qdev'ify Raven host bridge (PCIDevice)
prep_pci: Simplify I/O endianness
prep_pci: Update I/O to MemoryRegion ops
prep: qdev'ify Raven host bridge (SysBus)
MAINTAINERS: Add PCI host bridge files to PReP machine
prep: Add i82374 DMA emulation
prep: Add i82378 PCI-to-ISA bridge emulation
prep: Use i82378PCI->ISAbridge for 'prep' machineMAINTAINERS | 1 + Makefile.objs | 2 + default-configs/ppc-softmmu.mak | 3 + hw/i82374.c | 154 ++++++++++++++++++++++++ hw/i82378.c | 252 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + hw/ppc_prep.c | 77 +++++------- hw/prep_pci.c | 181 +++++++++++++++++----------- hw/prep_pci.h | 11 -- 9 files changed, 553 insertions(+), 129 deletions(-)create mode 100644
hw/i82374.c
create mode 100644hw/i82378.c
delete mode 100644hw/prep_pci.hSignature · 1 line
1.7.7
v4 cover qdev'ify PReP PCI host bridge and add PCI-to-ISA bridge
In reply to Andreas FärberHello,
Here's an improved initial qdev'ification series for PReP, as prerequisite for Anthony's second QOM series.
On Jan's suggestion, the i8259 IRQs are exposed through qdev GPIO-in IRQs on the i82378 PCI->ISA bridge
Regards,
Andreas
Changes since v3:
* i82378: Add i8259 IRQs as state and provide qdev GPIO-in access to them.
* prep: Update wiring of IRQs. Both suggested by Jan.
Changes since v2:
* Simplify I/O byte swaps.
* Convert I/O from old_mmio to MemoryRegion ops.
* Drop pci_prep_init() and instantiate the PCI host bridge in the machine, reintroducing PREPPCIState extension.
* Connect IRQs via qdev after instantiating. Suggested by Alex.
* Add a rebased PCI-to-ISA-bridge from the 40P series on top, to show why some suggestions from v2 and IRC don't work out.
* Merge fix-up by Hervé: Add indirection for late-connected out[0] IRQ.
* Add VMState for i82374 and i82378.
* From i82378 drop the I/O address translation duplicated from the board.
* Rebase i82378 onto Memory API.
http://patchwork.ozlabs.org/patch/100250/
http://patchwork.ozlabs.org/patch/100272/
* Add new patch from Hervé to wire up the PCI-to-ISA bridge for 'prep'.
Changes since v1:
* Use the new .vendor_id etc. in PCIDeviceInfo
* Rename from PRePPCI to Raven, adopt naming scheme from i440FX
* Rebase onto multiple Memory API conversions
* Split into PCIDevice and SysBus patches, leave out PREPPCIState changes
http://patchwork.ozlabs.org/patch/100268/
Andreas Färber (8):
prep: qdev'ify Raven host bridge (PCIDevice)
prep_pci: Simplify I/O endianness
prep_pci: Update I/O to MemoryRegion ops
prep: qdev'ify Raven host bridge (SysBus)
MAINTAINERS: Add PCI host bridge files to PReP machine
prep: Add i82374 DMA emulation
prep: Add i82378 PCI-to-ISA bridge emulation
prep: Use i82378 PCI->ISA bridge for 'prep' machine
MAINTAINERS | 1 + Makefile.objs | 2 + default-configs/ppc-softmmu.mak | 3 + hw/i82374.c | 154 +++++++++++++++++++++++ hw/i82378.c | 264 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + hw/ppc_prep.c | 76 +++++------- hw/prep_pci.c | 181 ++++++++++++++++----------- hw/prep_pci.h | 11 -- 9 files changed, 563 insertions(+), 130 deletions(-) create mode 100644 hw/i82374.c create mode 100644 hw/i82378.c delete mode 100644 hw/prep_pci.h
Signature · 1 line
1.7.7
PATCH v4 1/8 prep: qdev'ify Raven host bridge (PCIDevice)
Move initialization of vendor ID, etc. to PCIDeviceInfo. Introduce VMState.
--- hw/prep_pci.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 46 insertions(+), 9 deletions(-)
hw/prep_pci.c +46 -9
@@ -29,6 +29,10 @@typedef PCIHostState PREPPCIState ; +typedef struct RavenPCIState { +PCIDevice dev; +}RavenPCIState ; +static inline uint32_t PPC_PCIIO_config (target_phys_addr_t addr) {int i;
@@ -111,7 +115,6 @@ PCIBus *pci_prep_init(qemu_irq *pic, MemoryRegion *address_space_io) {PREPPCIState *s; -PCIDevice *d; s =g_malloc0 (sizeof (PREPPCIState)); s->bus = pci_register_bus(NULL, "pci",
@@ -133,16 +136,50 @@ PCIBus *pci_prep_init(qemu_irq *pic,memory_region_init_io (&s->mmcfg, &PPC_PCIIO_ops, s,"pciio" ,0x00400000 );memory_region_add_subregion (address_space_mem,0x80800000 , &s->mmcfg); -/* PCI host bridge */ - d =pci_register_device (s->bus,"PREP Host Bridge - Motorola Raven" , -sizeof (PCIDevice),0 ,NULL ,NULL ); -pci_config_set_vendor_id (d->config,PCI_VENDOR_ID_MOTOROLA ); -pci_config_set_device_id (d->config,PCI_DEVICE_ID_MOTOROLA_RAVEN ); - d->config[0x08 ] =0x00 ;// revision -pci_config_set_class (d->config,PCI_CLASS_BRIDGE_HOST ); +pci_create_simple (s->bus,0 ,"raven" ); + +return s->bus; +} + +static int raven_init (PCIDevice *d) +{ d->config[0x0C ] =0x08 ;// cache_line_size d->config[0x0D ] =0x10 ;// latency_timer d->config[0x34 ] =0x00 ;// capabilities_pointer -return s->bus; +return 0 ; } + +static const VMStateDescription vmstate_raven = { + .name ="raven" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, RavenPCIState), +VMSTATE_END_OF_LIST () + }, +}; + +static PCIDeviceInfo raven_info = { + .qdev.name ="raven" , + .qdev.desc ="PReP Host Bridge - Motorola Raven" , + .qdev.size =sizeof (RavenPCIState), + .qdev.vmsd = &vmstate_raven, + .qdev.no_user =1 , + .no_hotplug =1 , + .init = raven_init, + .vendor_id =PCI_VENDOR_ID_MOTOROLA , + .device_id =PCI_DEVICE_ID_MOTOROLA_RAVEN , + .revision =0x00 , + .class_id =PCI_CLASS_BRIDGE_HOST , + .qdev.props = (Property []) { +DEFINE_PROP_END_OF_LIST () + }, +}; + +static void raven_register_devices (void ) +{ +pci_qdev_register (&raven_info); +} + +device_init (raven_register_devices)
Signature · 1 line
1.7.7
PATCH v4 2/8 prep_pci: Simplify I/O endianness
In reply to Andreas FärberThe prep PowerPC CPU is Big Endian. An explicit byte swap therefore effectively becomes Little Endian.
Remove explicit byte swaps and mark as Little Endian.
--- hw/prep_pci.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
hw/prep_pci.c +1 -5
@@ -53,14 +53,12 @@ static void PPC_PCIIO_writeb (void *opaque, target_phys_addr_t addr, uint32_t vastatic void PPC_PCIIO_writew (void *opaque,target_phys_addr_t addr,uint32_t val) {PREPPCIState *s = opaque; - val =bswap16 (val);pci_data_write (s->bus,PPC_PCIIO_config (addr), val,2 ); }static void PPC_PCIIO_writel (void *opaque,target_phys_addr_t addr,uint32_t val) {PREPPCIState *s = opaque; - val =bswap32 (val);pci_data_write (s->bus,PPC_PCIIO_config (addr), val,4 ); }
@@ -77,7 +75,6 @@ static uint32_t PPC_PCIIO_readw (void *opaque, target_phys_addr_t addr)PREPPCIState *s = opaque;uint32_t val; val =pci_data_read (s->bus,PPC_PCIIO_config (addr),2 ); - val =bswap16 (val);return val; }
@@ -86,7 +83,6 @@ static uint32_t PPC_PCIIO_readl (void *opaque, target_phys_addr_t addr)PREPPCIState *s = opaque;uint32_t val; val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 ); - val =bswap32 (val);return val; }
@@ -95,7 +91,7 @@ static const MemoryRegionOps PPC_PCIIO_ops = { .read = { PPC_PCIIO_readb, PPC_PCIIO_readw, PPC_PCIIO_readl, }, .write = { PPC_PCIIO_writeb, PPC_PCIIO_writew, PPC_PCIIO_writel, }, }, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, };static int prep_map_irq (PCIDevice *pci_dev,int irq_num)
Signature · 1 line
1.7.7
PATCH v4 3/8 prep_pci: Update I/O to MemoryRegion ops
In reply to Andreas FärberConvert to new-style read/write callbacks.
--- hw/prep_pci.c | 61 +++++++++++++++++++++----------------------------------- 1 files changed, 23 insertions(+), 38 deletions(-)
hw/prep_pci.c +23 -38
@@ -44,53 +44,38 @@ static inline uint32_t PPC_PCIIO_config(target_phys_addr_t addr)return (addr &0x7ff ) | (i <<11 ); } -static void PPC_PCIIO_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) +static void ppc_pci_io_write (void *opaque,target_phys_addr_t addr, +uint64_t val,unsigned int size) {PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,1 ); -} - -static void PPC_PCIIO_writew (void *opaque,target_phys_addr_t addr,uint32_t val) -{ -PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,2 ); -} - -static void PPC_PCIIO_writel (void *opaque,target_phys_addr_t addr,uint32_t val) -{ -PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,4 ); -} - -static uint32_t PPC_PCIIO_readb (void *opaque,target_phys_addr_t addr) -{ -PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),1 ); -return val; -} - -static uint32_t PPC_PCIIO_readw (void *opaque,target_phys_addr_t addr) -{ -PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),2 ); -return val; +switch (size) { +case 1 : +case 2 : +case 4 : +pci_data_write (s->bus,PPC_PCIIO_config (addr), val, size); +break ; +default : +abort (); + } } -static uint32_t PPC_PCIIO_readl (void *opaque,target_phys_addr_t addr) +static uint64_t ppc_pci_io_read (void *opaque,target_phys_addr_t addr, +unsigned int size) {PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 ); -return val; +switch (size) { +case 1 : +case 2 : +case 4 : +return pci_data_read (s->bus,PPC_PCIIO_config (addr), size); +default : +abort (); + } }static const MemoryRegionOps PPC_PCIIO_ops = { - .old_mmio = { - .read = { PPC_PCIIO_readb, PPC_PCIIO_readw, PPC_PCIIO_readl, }, - .write = { PPC_PCIIO_writeb, PPC_PCIIO_writew, PPC_PCIIO_writel, }, - }, + .read = ppc_pci_io_read, + .write = ppc_pci_io_write, .endianness =DEVICE_LITTLE_ENDIAN , };
Signature · 1 line
1.7.7
PATCH v4 4/8 prep: qdev'ify Raven host bridge (SysBus)
In reply to Andreas FärberDrop pci_prep_init() in favor of extended device state. Inspired by patches from Hervé and Alex.
Assign the 4 IRQs from the board after device instantiation. This moves the knowledge out of prep_pci and allows for future machines with different IRQ wiring (IBM 40P). Suggested by Alex.
--- hw/ppc_prep.c | 23 +++++++++++++++++- hw/prep_pci.c | 67 +++++++++++++++++++++++++++++++++++--------------------- hw/prep_pci.h | 11 --------- 3 files changed, 63 insertions(+), 38 deletions(-) delete mode 100644 hw/prep_pci.h
hw/ppc_prep.c +21 -2
@@ -29,7 +29,7 @@#include "sysemu.h" #include "isa.h" #include "pci.h" -#include "prep_pci.h" +#include "pci_host.h" #include "usb-ohci.h" #include "ppc.h" #include "boards.h"
@@ -522,6 +522,9 @@ static void ppc_prep_init (ram_addr_t ram_size,MemoryRegion *bios =g_new (MemoryRegion,1 );uint32_t kernel_base, initrd_base;long kernel_size, initrd_size; +DeviceState *dev; +SysBusDevice *sys; +PCIHostState *pcihost;PCIBus *pci_bus;ISABus *isa_bus;qemu_irq *i8259;
@@ -633,7 +636,23 @@ static void ppc_prep_init (ram_addr_t ram_size,/* Hmm, prep has no pci-isa bridge ??? */ isa_bus =isa_bus_new (NULL ,get_system_io ()); i8259 =i8259_init (isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); - pci_bus =pci_prep_init (i8259,get_system_memory (),get_system_io ()); + + dev =qdev_create (NULL ,"raven-pcihost" ); + sys =sysbus_from_qdev (dev); + pcihost =DO_UPCAST (PCIHostState, busdev, sys); + pcihost->address_space =get_system_memory (); +qdev_init_nofail (dev); +qdev_property_add_child (qdev_get_root (),"raven" , dev,NULL ); + pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci.0" ); +if (pci_bus ==NULL ) { +fprintf (stderr,"Couldn't create PCI host controller.\n" ); +exit (1 ); + } +sysbus_connect_irq (&pcihost->busdev,0 , i8259[9 ]); +sysbus_connect_irq (&pcihost->busdev,1 , i8259[11 ]); +sysbus_connect_irq (&pcihost->busdev,2 , i8259[9 ]); +sysbus_connect_irq (&pcihost->busdev,3 , i8259[11 ]); +isa_bus_irqs (isa_bus, i8259);// pci_bus = i440fx_init(); /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
hw/prep_pci.c +42 -25
111 lines not on this page · raw message
hw/prep_pci.h deleted +0 -11
@@ -1,11 +0,0 @@ -#ifndef QEMU_PREP_PCI_H -#define QEMU_PREP_PCI_H - -#include "qemu-common.h" -#include "memory.h" - -PCIBus *pci_prep_init (qemu_irq *pic, -MemoryRegion *address_space_mem, -MemoryRegion *address_space_io); - -#endif
Signature · 1 line
1.7.7
PATCH v4 5/8 MAINTAINERS: Add PCI host bridge files to PReP machine
In reply to Andreas Färber--- MAINTAINERS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
MAINTAINERS +1 -0
@@ -307,6 +307,7 @@ PReP M: Andreas Färber <[email protected]> S: Odd Fixes F: hw/ppc_prep.c +F: hw/prep_pci.[hc] SH4 Machines ------------
Signature · 1 line
1.7.7
PATCH v4 6/8 prep: Add i82374 DMA emulation
In reply to Andreas FärberPrepare Intel 82374 emulation for use by Intel 82378 PCI->ISA bridge.
Confine to CONFIG_I82374. Add VMState.
--- Makefile.objs | 1 + default-configs/ppc-softmmu.mak | 1 + hw/i82374.c | 154 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 0 deletions(-) create mode 100644 hw/i82374.c
Makefile.objs +1 -0
@@ -215,6 +215,7 @@ hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o +hw-obj-$(CONFIG_I82374) += i82374.o hw-obj-$(CONFIG_HPET) += hpet.o hw-obj-$(CONFIG_APPLESMC) += applesmc.o hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o
default-configs/ppc-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_I8254=y CONFIG_PCKBD=y CONFIG_FDC=y CONFIG_DMA=y +CONFIG_I82374=y CONFIG_OPENPIC=y CONFIG_PREP_PCI=y CONFIG_MACIO=y
hw/i82374.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v4 7/8 prep: Add i82378 PCI-to-ISA bridge emulation
In reply to Andreas FärberPrepare Intel 82378 emulation for use by PReP platforms.
Create ISA bus in this device (suggested by Markus). Rebase onto Memory API, mark memory ops as Little Endian. Add VMState. Provide access to i8259 IRQs via qdev GPIOs.
--- Makefile.objs | 1 + default-configs/ppc-softmmu.mak | 2 + hw/i82378.c | 264 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + 4 files changed, 268 insertions(+), 0 deletions(-) create mode 100644 hw/i82378.c
Makefile.objs +1 -0
@@ -225,6 +225,7 @@ hw-obj-$(CONFIG_I8259) += i8259.o # PPC devices hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o +hw-obj-$(CONFIG_I82378) += i82378.o # Mac shared devices hw-obj-$(CONFIG_MACIO) += macio.o hw-obj-$(CONFIG_CUDA) += cuda.o
default-configs/ppc-softmmu.mak +2 -0
@@ -14,7 +14,9 @@ CONFIG_DMA=y CONFIG_I82374=y CONFIG_OPENPIC=y CONFIG_PREP_PCI=y +CONFIG_I82378=y CONFIG_MACIO=y +CONFIG_PCSPK=y CONFIG_CUDA=y CONFIG_ADB=y CONFIG_MAC_NVRAM=y
hw/i82378.c new file +264 -0
264 lines not on this page · raw message
hw/pci_ids.h +1 -0
@@ -98,6 +98,7 @@#define PCI_DEVICE_ID_MPC8533E 0x0030#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_82378 0x0484#define PCI_DEVICE_ID_INTEL_82441 0x1237#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415#define PCI_DEVICE_ID_INTEL_82801D 0x24CD
Signature · 1 line
1.7.7
PATCH v4 8/8 prep: Use i82378 PCI->ISA bridge for 'prep' machine
In reply to Andreas FärberSpeaker I/O, ISA bus, i8259 PIC, RTC and DMA are no longer set up individually by the machine. Effectively, no-op speaker I/O is replaced by pcspk; PIT and i82374 DMA are introduced.
Remove related dead, alternative code.
Wire up PCI host bridge IRQs via GPIO-in IRQs of PCI->ISA bridge.
--- hw/ppc_prep.c | 61 ++++++++++++-------------------------------------------- 1 files changed, 13 insertions(+), 48 deletions(-)
hw/ppc_prep.c +13 -48
@@ -83,37 +83,9 @@ static const int ide_irq[2] = { 13, 13 };static uint32_t ne2000_io[NE2000_NB_MAX ] = {0x300 ,0x320 ,0x340 ,0x360 ,0x280 ,0x380 };static int ne2000_irq[NE2000_NB_MAX ] = {9 ,10 ,11 ,3 ,4 ,5 }; -//static ISADevice *pit; -/* ISA IO ports bridge */ #define PPC_IO_BASE 0x80000000 -#if 0 -/* Speaker port 0x61 */ -static int speaker_data_on; -static int dummy_refresh_clock; -#endif - -static void speaker_ioport_write (void *opaque,uint32_t addr,uint32_t val) -{ -#if 0 - speaker_data_on = (val >>1 ) &1 ; -pit_set_gate (pit,2 , val &1 ); -#endif -} - -static uint32_t speaker_ioport_read (void *opaque,uint32_t addr) -{ -#if 0 -int out; - out =pit_get_out (pit,2 ,qemu_get_clock_ns (vm_clock)); - dummy_refresh_clock ^=1 ; -return (speaker_data_on <<1 ) |pit_get_gate (pit,2 ) | (out <<5 ) | - (dummy_refresh_clock <<4 ); -#endif -return 0 ; -} -/* PCI intack register */ /* Read-only register (?) */ static void PPC_intack_write (void *opaque, target_phys_addr_t addr,
@@ -526,8 +498,8 @@ static void ppc_prep_init (ram_addr_t ram_size,SysBusDevice *sys;PCIHostState *pcihost;PCIBus *pci_bus; +PCIDevice *pci;ISABus *isa_bus; -qemu_irq *i8259;qemu_irq *cpu_exit_irq;int ppc_boot_device;DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];
@@ -629,13 +601,9 @@ static void ppc_prep_init (ram_addr_t ram_size, } } - isa_mem_base =0xc0000000 ;if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {hw_error ("Only 6xx bus is supported on PREP machine\n" ); } -/* Hmm, prep has no pci-isa bridge ??? */ - isa_bus =isa_bus_new (NULL ,get_system_io ()); - i8259 =i8259_init (isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); dev =qdev_create (NULL ,"raven-pcihost" ); sys =sysbus_from_qdev (dev);
@@ -648,13 +616,19 @@ static void ppc_prep_init (ram_addr_t ram_size,fprintf (stderr,"Couldn't create PCI host controller.\n" );exit (1 ); } -sysbus_connect_irq (&pcihost->busdev,0 , i8259[9 ]); -sysbus_connect_irq (&pcihost->busdev,1 , i8259[11 ]); -sysbus_connect_irq (&pcihost->busdev,2 , i8259[9 ]); -sysbus_connect_irq (&pcihost->busdev,3 , i8259[11 ]); -isa_bus_irqs (isa_bus, i8259); -// pci_bus = i440fx_init(); +/* PCI -> ISA bridge */ + pci =pci_create_simple (pci_bus,PCI_DEVFN (1 ,0 ),"i82378" ); + cpu_exit_irq =qemu_allocate_irqs (cpu_request_exit,NULL ,1 ); +qdev_connect_gpio_out (&pci->qdev,0 , + first_cpu->irq_inputs[PPC6xx_INPUT_INT]); +qdev_connect_gpio_out (&pci->qdev,1 , *cpu_exit_irq); +sysbus_connect_irq (&pcihost->busdev,0 ,qdev_get_gpio_in (&pci->qdev,9 )); +sysbus_connect_irq (&pcihost->busdev,1 ,qdev_get_gpio_in (&pci->qdev,11 )); +sysbus_connect_irq (&pcihost->busdev,2 ,qdev_get_gpio_in (&pci->qdev,9 )); +sysbus_connect_irq (&pcihost->busdev,3 ,qdev_get_gpio_in (&pci->qdev,11 )); + isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); +/* Register 8 MB of ISA IO space (needed for non-contiguous map) */ memory_region_init_io (PPC_io_memory, &PPC_prep_io_ops, sysctrl,"ppc-io" ,0x00800000 );
@@ -662,9 +636,6 @@ static void ppc_prep_init (ram_addr_t ram_size,/* init basic PC hardware */ pci_vga_init (pci_bus); -// openpic = openpic_init(0x00000000, 0xF0000000, 1); -// pit = pit_init(0x40, 0); -rtc_init (isa_bus,2000 ,NULL );if (serial_hds[0 ])serial_isa_init (isa_bus,0 , serial_hds[0 ]);
@@ -691,9 +662,6 @@ static void ppc_prep_init (ram_addr_t ram_size, }isa_create_simple (isa_bus,"i8042" ); - cpu_exit_irq =qemu_allocate_irqs (cpu_request_exit,NULL ,1 ); -DMA_init (1 , cpu_exit_irq); -// SB16_init(); for (i =0 ; i <MAX_FD ; i++) {
@@ -701,9 +669,6 @@ static void ppc_prep_init (ram_addr_t ram_size, }fdctrl_init_isa (isa_bus, fd); -/* Register speaker port */ -register_ioport_read (0x61 ,1 ,1 , speaker_ioport_read,NULL ); -register_ioport_write (0x61 ,1 ,1 , speaker_ioport_write,NULL );/* Register fake IO ports for PREP */ sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];register_ioport_read (0x398 ,2 ,1 , &PREP_io_read, sysctrl);
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH v4 0/8] qdev'ify PReP PCI host bridge and add PCI-to-ISA bridge
In reply to Andreas FärberAm 13.01.2012 20:03, schrieb Andreas Färber:
Quoted 3 lines
Andreas Färber (8):
prep: qdev'ify Raven host bridge (PCIDevice)
prep_pci: Simplify I/O endianness
Applied 1-2 to prep-up branch:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/prep-up
/-F
Quoted 6 lines
prep_pci: Update I/O to MemoryRegion ops
prep: qdev'ify Raven host bridge (SysBus)
MAINTAINERS: Add PCI host bridge files to PReP machine
prep: Add i82374 DMA emulation
prep: Add i82378 PCI-to-ISA bridge emulation
prep: Use i82378PCI->ISAbridge for 'prep' machine
v5 cover qdev'ify PReP PCI host bridge and add PCI-to-ISA bridge
In reply to Andreas FärberHello,
Here's a slightly simplified qdev'ification series for PReP.
Sizes other than 1/2/4 are currently not supported, so no need to abort().
Regards,
Andreas
Changes since v4:
* Patches 1-2 were applied to prep-up, thus drop.
* Drop switch statements for prep_pci_io_{read,write}(). Suggested by Avi.
Changes since v3:
* i82378: Add i8259 IRQs as state and provide qdev GPIO-in access to them.
* prep: Update wiring of IRQs. Both suggested by Jan.
Changes since v2:
* Simplify I/O byte swaps.
* Convert I/O from old_mmio to MemoryRegion ops.
* Drop pci_prep_init() and instantiate the PCI host bridge in the machine, reintroducing PREPPCIState extension.
* Connect IRQs via qdev after instantiating. Suggested by Alex.
* Add a rebased PCI-to-ISA-bridge from the 40P series on top, to show why some suggestions from v2 and IRC don't work out.
* Merge fix-up by Hervé: Add indirection for late-connected out[0] IRQ.
* Add VMState for i82374 and i82378.
* From i82378 drop the I/O address translation duplicated from the board.
* Rebase i82378 onto Memory API.
http://patchwork.ozlabs.org/patch/100250/
http://patchwork.ozlabs.org/patch/100272/
* Add new patch from Hervé to wire up the PCI-to-ISA bridge for 'prep'.
Changes since v1:
* Use the new .vendor_id etc. in PCIDeviceInfo
* Rename from PRePPCI to Raven, adopt naming scheme from i440FX
* Rebase onto multiple Memory API conversions
* Split into PCIDevice and SysBus patches, leave out PREPPCIState changes
http://patchwork.ozlabs.org/patch/100268/
Andreas Färber (6):
prep_pci: Update I/O to MemoryRegion ops
prep: qdev'ify Raven host bridge (SysBus)
MAINTAINERS: Add PCI host bridge files to PReP machine
prep: Add i82374 DMA emulation
prep: Add i82378 PCI-to-ISA bridge emulation
prep: Use i82378 PCI->ISA bridge for 'prep' machine
MAINTAINERS | 1 + Makefile.objs | 2 + default-configs/ppc-softmmu.mak | 3 + hw/i82374.c | 154 +++++++++++++++++++++++ hw/i82378.c | 264 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + hw/ppc_prep.c | 76 +++++------- hw/prep_pci.c | 109 +++++++--------- hw/prep_pci.h | 11 -- 9 files changed, 503 insertions(+), 118 deletions(-) create mode 100644 hw/i82374.c create mode 100644 hw/i82378.c delete mode 100644 hw/prep_pci.h
Signature · 1 line
1.7.7
PATCH v5 1/6 prep_pci: Update I/O to MemoryRegion ops
Convert to new-style read/write callbacks.
--- hw/prep_pci.c | 46 ++++++++-------------------------------------- 1 files changed, 8 insertions(+), 38 deletions(-)
hw/prep_pci.c +8 -38
@@ -44,53 +44,23 @@ static inline uint32_t PPC_PCIIO_config(target_phys_addr_t addr)return (addr &0x7ff ) | (i <<11 ); } -static void PPC_PCIIO_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) +static void ppc_pci_io_write (void *opaque,target_phys_addr_t addr, +uint64_t val,unsigned int size) {PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,1 ); +pci_data_write (s->bus,PPC_PCIIO_config (addr), val, size); } -static void PPC_PCIIO_writew (void *opaque,target_phys_addr_t addr,uint32_t val) +static uint64_t ppc_pci_io_read (void *opaque,target_phys_addr_t addr, +unsigned int size) {PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,2 ); -} - -static void PPC_PCIIO_writel (void *opaque,target_phys_addr_t addr,uint32_t val) -{ -PREPPCIState *s = opaque; -pci_data_write (s->bus,PPC_PCIIO_config (addr), val,4 ); -} - -static uint32_t PPC_PCIIO_readb (void *opaque,target_phys_addr_t addr) -{ -PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),1 ); -return val; -} - -static uint32_t PPC_PCIIO_readw (void *opaque,target_phys_addr_t addr) -{ -PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),2 ); -return val; -} - -static uint32_t PPC_PCIIO_readl (void *opaque,target_phys_addr_t addr) -{ -PREPPCIState *s = opaque; -uint32_t val; - val =pci_data_read (s->bus,PPC_PCIIO_config (addr),4 ); -return val; +return pci_data_read (s->bus,PPC_PCIIO_config (addr), size); }static const MemoryRegionOps PPC_PCIIO_ops = { - .old_mmio = { - .read = { PPC_PCIIO_readb, PPC_PCIIO_readw, PPC_PCIIO_readl, }, - .write = { PPC_PCIIO_writeb, PPC_PCIIO_writew, PPC_PCIIO_writel, }, - }, + .read = ppc_pci_io_read, + .write = ppc_pci_io_write, .endianness =DEVICE_LITTLE_ENDIAN , };
Signature · 1 line
1.7.7
PATCH v5 2/6 prep: qdev'ify Raven host bridge (SysBus)
In reply to Andreas FärberDrop pci_prep_init() in favor of extended device state. Inspired by patches from Hervé and Alex.
Assign the 4 IRQs from the board after device instantiation. This moves the knowledge out of prep_pci and allows for future machines with different IRQ wiring (IBM 40P). Suggested by Alex.
--- hw/ppc_prep.c | 23 +++++++++++++++++- hw/prep_pci.c | 67 +++++++++++++++++++++++++++++++++++--------------------- hw/prep_pci.h | 11 --------- 3 files changed, 63 insertions(+), 38 deletions(-) delete mode 100644 hw/prep_pci.h
hw/ppc_prep.c +21 -2
@@ -29,7 +29,7 @@#include "sysemu.h" #include "isa.h" #include "pci.h" -#include "prep_pci.h" +#include "pci_host.h" #include "usb-ohci.h" #include "ppc.h" #include "boards.h"
@@ -522,6 +522,9 @@ static void ppc_prep_init (ram_addr_t ram_size,MemoryRegion *bios =g_new (MemoryRegion,1 );uint32_t kernel_base, initrd_base;long kernel_size, initrd_size; +DeviceState *dev; +SysBusDevice *sys; +PCIHostState *pcihost;PCIBus *pci_bus;ISABus *isa_bus;qemu_irq *i8259;
@@ -633,7 +636,23 @@ static void ppc_prep_init (ram_addr_t ram_size,/* Hmm, prep has no pci-isa bridge ??? */ isa_bus =isa_bus_new (NULL ,get_system_io ()); i8259 =i8259_init (isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); - pci_bus =pci_prep_init (i8259,get_system_memory (),get_system_io ()); + + dev =qdev_create (NULL ,"raven-pcihost" ); + sys =sysbus_from_qdev (dev); + pcihost =DO_UPCAST (PCIHostState, busdev, sys); + pcihost->address_space =get_system_memory (); +qdev_init_nofail (dev); +qdev_property_add_child (qdev_get_root (),"raven" , dev,NULL ); + pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci.0" ); +if (pci_bus ==NULL ) { +fprintf (stderr,"Couldn't create PCI host controller.\n" ); +exit (1 ); + } +sysbus_connect_irq (&pcihost->busdev,0 , i8259[9 ]); +sysbus_connect_irq (&pcihost->busdev,1 , i8259[11 ]); +sysbus_connect_irq (&pcihost->busdev,2 , i8259[9 ]); +sysbus_connect_irq (&pcihost->busdev,3 , i8259[11 ]); +isa_bus_irqs (isa_bus, i8259);// pci_bus = i440fx_init(); /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
hw/prep_pci.c +42 -25
111 lines not on this page · raw message
hw/prep_pci.h deleted +0 -11
@@ -1,11 +0,0 @@ -#ifndef QEMU_PREP_PCI_H -#define QEMU_PREP_PCI_H - -#include "qemu-common.h" -#include "memory.h" - -PCIBus *pci_prep_init (qemu_irq *pic, -MemoryRegion *address_space_mem, -MemoryRegion *address_space_io); - -#endif
Signature · 1 line
1.7.7
PATCH v5 3/6 MAINTAINERS: Add PCI host bridge files to PReP machine
In reply to Andreas Färber--- MAINTAINERS | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
MAINTAINERS +1 -0
@@ -307,6 +307,7 @@ PReP M: Andreas Färber <[email protected]> S: Odd Fixes F: hw/ppc_prep.c +F: hw/prep_pci.[hc] SH4 Machines ------------
Signature · 1 line
1.7.7
PATCH v5 4/6 prep: Add i82374 DMA emulation
In reply to Andreas FärberPrepare Intel 82374 emulation for use by Intel 82378 PCI->ISA bridge.
Confine to CONFIG_I82374. Add VMState.
--- Makefile.objs | 1 + default-configs/ppc-softmmu.mak | 1 + hw/i82374.c | 154 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 0 deletions(-) create mode 100644 hw/i82374.c
Makefile.objs +1 -0
@@ -215,6 +215,7 @@ hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o +hw-obj-$(CONFIG_I82374) += i82374.o hw-obj-$(CONFIG_HPET) += hpet.o hw-obj-$(CONFIG_APPLESMC) += applesmc.o hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o
default-configs/ppc-softmmu.mak +1 -0
@@ -11,6 +11,7 @@ CONFIG_I8254=y CONFIG_PCKBD=y CONFIG_FDC=y CONFIG_DMA=y +CONFIG_I82374=y CONFIG_OPENPIC=y CONFIG_PREP_PCI=y CONFIG_MACIO=y
hw/i82374.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
1.7.7
PATCH v5 5/6 prep: Add i82378 PCI-to-ISA bridge emulation
In reply to Andreas FärberPrepare Intel 82378 emulation for use by PReP platforms.
Create ISA bus in this device (suggested by Markus). Rebase onto Memory API, mark memory ops as Little Endian. Add VMState. Provide access to i8259 IRQs via qdev GPIOs.
--- Makefile.objs | 1 + default-configs/ppc-softmmu.mak | 2 + hw/i82378.c | 264 +++++++++++++++++++++++++++++++++++++++ hw/pci_ids.h | 1 + 4 files changed, 268 insertions(+), 0 deletions(-) create mode 100644 hw/i82378.c
Makefile.objs +1 -0
@@ -225,6 +225,7 @@ hw-obj-$(CONFIG_I8259) += i8259.o # PPC devices hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o +hw-obj-$(CONFIG_I82378) += i82378.o # Mac shared devices hw-obj-$(CONFIG_MACIO) += macio.o hw-obj-$(CONFIG_CUDA) += cuda.o
default-configs/ppc-softmmu.mak +2 -0
@@ -14,7 +14,9 @@ CONFIG_DMA=y CONFIG_I82374=y CONFIG_OPENPIC=y CONFIG_PREP_PCI=y +CONFIG_I82378=y CONFIG_MACIO=y +CONFIG_PCSPK=y CONFIG_CUDA=y CONFIG_ADB=y CONFIG_MAC_NVRAM=y
hw/i82378.c new file +264 -0
264 lines not on this page · raw message
hw/pci_ids.h +1 -0
@@ -98,6 +98,7 @@#define PCI_DEVICE_ID_MPC8533E 0x0030#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_82378 0x0484#define PCI_DEVICE_ID_INTEL_82441 0x1237#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415#define PCI_DEVICE_ID_INTEL_82801D 0x24CD
Signature · 1 line
1.7.7
PATCH v5 6/6 prep: Use i82378 PCI->ISA bridge for 'prep' machine
In reply to Andreas FärberSpeaker I/O, ISA bus, i8259 PIC, RTC and DMA are no longer set up individually by the machine. Effectively, no-op speaker I/O is replaced by pcspk; PIT and i82374 DMA are introduced.
Remove related dead, alternative code.
Wire up PCI host bridge IRQs via GPIO-in IRQs of PCI->ISA bridge.
--- hw/ppc_prep.c | 61 ++++++++++++-------------------------------------------- 1 files changed, 13 insertions(+), 48 deletions(-)
hw/ppc_prep.c +13 -48
@@ -83,37 +83,9 @@ static const int ide_irq[2] = { 13, 13 };static uint32_t ne2000_io[NE2000_NB_MAX ] = {0x300 ,0x320 ,0x340 ,0x360 ,0x280 ,0x380 };static int ne2000_irq[NE2000_NB_MAX ] = {9 ,10 ,11 ,3 ,4 ,5 }; -//static ISADevice *pit; -/* ISA IO ports bridge */ #define PPC_IO_BASE 0x80000000 -#if 0 -/* Speaker port 0x61 */ -static int speaker_data_on; -static int dummy_refresh_clock; -#endif - -static void speaker_ioport_write (void *opaque,uint32_t addr,uint32_t val) -{ -#if 0 - speaker_data_on = (val >>1 ) &1 ; -pit_set_gate (pit,2 , val &1 ); -#endif -} - -static uint32_t speaker_ioport_read (void *opaque,uint32_t addr) -{ -#if 0 -int out; - out =pit_get_out (pit,2 ,qemu_get_clock_ns (vm_clock)); - dummy_refresh_clock ^=1 ; -return (speaker_data_on <<1 ) |pit_get_gate (pit,2 ) | (out <<5 ) | - (dummy_refresh_clock <<4 ); -#endif -return 0 ; -} -/* PCI intack register */ /* Read-only register (?) */ static void PPC_intack_write (void *opaque, target_phys_addr_t addr,
@@ -526,8 +498,8 @@ static void ppc_prep_init (ram_addr_t ram_size,SysBusDevice *sys;PCIHostState *pcihost;PCIBus *pci_bus; +PCIDevice *pci;ISABus *isa_bus; -qemu_irq *i8259;qemu_irq *cpu_exit_irq;int ppc_boot_device;DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];
@@ -629,13 +601,9 @@ static void ppc_prep_init (ram_addr_t ram_size, } } - isa_mem_base =0xc0000000 ;if (PPC_INPUT (env) != PPC_FLAGS_INPUT_6xx) {hw_error ("Only 6xx bus is supported on PREP machine\n" ); } -/* Hmm, prep has no pci-isa bridge ??? */ - isa_bus =isa_bus_new (NULL ,get_system_io ()); - i8259 =i8259_init (isa_bus, first_cpu->irq_inputs[PPC6xx_INPUT_INT]); dev =qdev_create (NULL ,"raven-pcihost" ); sys =sysbus_from_qdev (dev);
@@ -648,13 +616,19 @@ static void ppc_prep_init (ram_addr_t ram_size,fprintf (stderr,"Couldn't create PCI host controller.\n" );exit (1 ); } -sysbus_connect_irq (&pcihost->busdev,0 , i8259[9 ]); -sysbus_connect_irq (&pcihost->busdev,1 , i8259[11 ]); -sysbus_connect_irq (&pcihost->busdev,2 , i8259[9 ]); -sysbus_connect_irq (&pcihost->busdev,3 , i8259[11 ]); -isa_bus_irqs (isa_bus, i8259); -// pci_bus = i440fx_init(); +/* PCI -> ISA bridge */ + pci =pci_create_simple (pci_bus,PCI_DEVFN (1 ,0 ),"i82378" ); + cpu_exit_irq =qemu_allocate_irqs (cpu_request_exit,NULL ,1 ); +qdev_connect_gpio_out (&pci->qdev,0 , + first_cpu->irq_inputs[PPC6xx_INPUT_INT]); +qdev_connect_gpio_out (&pci->qdev,1 , *cpu_exit_irq); +sysbus_connect_irq (&pcihost->busdev,0 ,qdev_get_gpio_in (&pci->qdev,9 )); +sysbus_connect_irq (&pcihost->busdev,1 ,qdev_get_gpio_in (&pci->qdev,11 )); +sysbus_connect_irq (&pcihost->busdev,2 ,qdev_get_gpio_in (&pci->qdev,9 )); +sysbus_connect_irq (&pcihost->busdev,3 ,qdev_get_gpio_in (&pci->qdev,11 )); + isa_bus =DO_UPCAST (ISABus, qbus,qdev_get_child_bus (&pci->qdev,"isa.0" )); +/* Register 8 MB of ISA IO space (needed for non-contiguous map) */ memory_region_init_io (PPC_io_memory, &PPC_prep_io_ops, sysctrl,"ppc-io" ,0x00800000 );
@@ -662,9 +636,6 @@ static void ppc_prep_init (ram_addr_t ram_size,/* init basic PC hardware */ pci_vga_init (pci_bus); -// openpic = openpic_init(0x00000000, 0xF0000000, 1); -// pit = pit_init(0x40, 0); -rtc_init (isa_bus,2000 ,NULL );if (serial_hds[0 ])serial_isa_init (isa_bus,0 , serial_hds[0 ]);
@@ -691,9 +662,6 @@ static void ppc_prep_init (ram_addr_t ram_size, }isa_create_simple (isa_bus,"i8042" ); - cpu_exit_irq =qemu_allocate_irqs (cpu_request_exit,NULL ,1 ); -DMA_init (1 , cpu_exit_irq); -// SB16_init(); for (i =0 ; i <MAX_FD ; i++) {
@@ -701,9 +669,6 @@ static void ppc_prep_init (ram_addr_t ram_size, }fdctrl_init_isa (isa_bus, fd); -/* Register speaker port */ -register_ioport_read (0x61 ,1 ,1 , speaker_ioport_read,NULL ); -register_ioport_write (0x61 ,1 ,1 , speaker_ioport_write,NULL );/* Register fake IO ports for PREP */ sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];register_ioport_read (0x398 ,2 ,1 , &PREP_io_read, sysctrl);
Signature · 1 line
1.7.7
Re: [Qemu-devel] [PATCH v5 0/6] qdev'ify PReP PCI host bridge and add PCI-to-ISA bridge
In reply to Andreas FärberAm 16.01.2012 17:18, schrieb Andreas Färber:
Quoted 7 lines
Andreas Färber (6):
prep_pci: Update I/O to MemoryRegion ops
prep: qdev'ify Raven host bridge (SysBus)
MAINTAINERS: Add PCI host bridge files to PReP machine
prep: Add i82374 DMA emulation
prep: Add i82378 PCI-to-ISA bridge emulation
prep: Use i82378PCI->ISAbridge for 'prep' machine
All applied to the prep-up branch:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/prep-up
Andreas