Pegasos2 emulation
PATCH v11 2/7 vt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO
In reply to BALATON ZoltanThe VT8231 south bridge is very similar to VT82C686B but there are some differences in register addresses and functionality, e.g. the VT8231 only has one serial port. This commit adds VT8231_SUPERIO subclass based on the abstract VIA_SUPERIO class to emulate the superio part of VT8231.
--- hw/isa/vt82c686.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
hw/isa/vt82c686.c +102 -0
@@ -417,6 +417,107 @@ static const TypeInfo vt82c686b_superio_info = { }; +#define TYPE_VT8231_SUPERIO "vt8231-superio" + +static void vt8231_superio_cfg_write (void *opaque,hwaddr addr, +uint64_t data,unsigned size) +{ +ViaSuperIOState *sc = opaque; +uint8_t idx = sc->regs[0 ]; + +if (addr ==0 ) {/* config index register */ + sc->regs[0 ] = data; +return ; + } + +/* config data register */ +trace_via_superio_write (idx, data); +switch (idx) { + case 0x00 ... 0xdf: + case 0xe7 ... 0xef: + case 0xf0 ... 0xf1: +case 0xf5 : +case 0xf8 : +case 0xfd : +/* ignore write to read only registers */ +return ; +default : +qemu_log_mask (LOG_UNIMP , +"via_superio_cfg: unimplemented register 0x%x\n" , idx); +break ; + } + sc->regs[idx] = data; +} + +static const MemoryRegionOps vt8231_superio_cfg_ops = { + .read = via_superio_cfg_read, + .write = vt8231_superio_cfg_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { + .min_access_size =1 , + .max_access_size =1 , + }, +}; + +static void vt8231_superio_reset (DeviceState *dev) +{ +ViaSuperIOState *s =VIA_SUPERIO (dev); + +memset (s->regs,0 ,sizeof (s->regs)); +/* Device ID */ + s->regs[0xf0 ] =0x3c ; +/* Device revision */ + s->regs[0xf1 ] =0x01 ; +/* Function select - all disabled */ +vt8231_superio_cfg_write (s,0 ,0xf2 ,1 ); +vt8231_superio_cfg_write (s,1 ,0x03 ,1 ); +/* Serial port base addr */ +vt8231_superio_cfg_write (s,0 ,0xf4 ,1 ); +vt8231_superio_cfg_write (s,1 ,0xfe ,1 ); +/* Parallel port base addr */ +vt8231_superio_cfg_write (s,0 ,0xf6 ,1 ); +vt8231_superio_cfg_write (s,1 ,0xde ,1 ); +/* Floppy ctrl base addr */ +vt8231_superio_cfg_write (s,0 ,0xf7 ,1 ); +vt8231_superio_cfg_write (s,1 ,0xfc ,1 ); + +vt8231_superio_cfg_write (s,0 ,0 ,1 ); +} + +static void vt8231_superio_init (Object *obj) +{ +VIA_SUPERIO (obj)->io_ops = &vt8231_superio_cfg_ops; +} + +static uint16_t vt8231_superio_serial_iobase (ISASuperIODevice *sio, +uint8_t index) +{ +return 0x2f8 ;/* FIXME: This should be settable via registers f2-f4 */ +} + +static void vt8231_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + dc->reset = vt8231_superio_reset; + sc->serial.count =1 ; + sc->serial.get_iobase = vt8231_superio_serial_iobase; + sc->parallel.count =1 ; + sc->ide.count =0 ;/* emulated by via-ide */ + sc->floppy.count =1 ; +} + +static const TypeInfo vt8231_superio_info = { + .name =TYPE_VT8231_SUPERIO , + .parent =TYPE_VIA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .instance_init = vt8231_superio_init, + .class_size =sizeof (ISASuperIOClass), + .class_init = vt8231_superio_class_init, +}; + + OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA)struct VT82C686BISAState {
@@ -540,6 +641,7 @@ static void vt82c686b_register_types(void)type_register_static (&vt8231_pm_info);type_register_static (&via_superio_info);type_register_static (&vt82c686b_superio_info); +type_register_static (&vt8231_superio_info);type_register_static (&via_info); }
Signature · 1 line
2.21.4
PATCH v11 7/7 hw/ppc: Add emulation of Genesi/bPlan Pegasos II
In reply to BALATON ZoltanAdd new machine called pegasos2 emulating the Genesi/bPlan Pegasos II, a PowerPC board based on the Marvell MV64361 system controller and the VIA VT8231 integrated south bridge/superio chips. It can run Linux, AmigaOS and a wide range of MorphOS versions. Currently a firmware ROM image is needed to boot and only MorphOS has a video driver to produce graphics output. Linux could work too but distros that supported this machine don't include usual video drivers so those only run with serial console for now.
--- MAINTAINERS | 10 ++ default-configs/devices/ppc-softmmu.mak | 2 + hw/ppc/Kconfig | 9 ++ hw/ppc/meson.build | 2 + hw/ppc/pegasos2.c | 144 ++++++++++++++++++++++++ 5 files changed, 167 insertions(+) create mode 100644 hw/ppc/pegasos2.c
MAINTAINERS +10 -0
@@ -1368,6 +1368,16 @@ F: pc-bios/canyonlands.dt[sb] F: pc-bios/u-boot-sam460ex-20100605.bin F: roms/u-boot-sam460ex +pegasos2 +M: BALATON Zoltan <[email protected]> +R: David Gibson <[email protected]> +L: [email protected] +S: Maintained +F: hw/ppc/pegasos2.c +F: hw/pci-host/mv64361.c +F: hw/pci-host/mv643xx.h +F: include/hw/pci-host/mv64361.h + RISC-V Machines --------------- OpenTitan
default-configs/devices/ppc-softmmu.mak +2 -0
@@ -14,5 +14,7 @@ CONFIG_SAM460EX=y CONFIG_MAC_OLDWORLD=y CONFIG_MAC_NEWWORLD=y +CONFIG_PEGASOS2=n + # For PReP CONFIG_PREP=y
hw/ppc/Kconfig +9 -0
@@ -68,6 +68,15 @@ config SAM460EX select USB_OHCI select FDT_PPC +config PEGASOS2 + bool + select MV64361 + select VT82C686 + select IDE_VIA + select SMBUS_EEPROM +# This should come with VT82C686 + select ACPI_X86 + config PREP bool imply PCI_DEVICES
hw/ppc/meson.build +2 -0
@@ -78,5 +78,7 @@ ppc_ss.add(when: 'CONFIG_E500', if_true: files( )) # PowerPC 440 Xilinx ML507 reference board. ppc_ss.add(when: 'CONFIG_VIRTEX', if_true: files('virtex_ml507.c')) +# Pegasos2 +ppc_ss.add(when: 'CONFIG_PEGASOS2', if_true: files('pegasos2.c')) hw_arch += {'ppc': ppc_ss}
hw/ppc/pegasos2.c new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
2.21.4
PATCH v11 6/7 hw/pci-host: Add emulation of Marvell MV64361 PPC system controller
In reply to BALATON ZoltanThe Marvell Discovery II aka. MV64361 is a PowerPC system controller chip that is used on the pegasos2 PPC board. This adds emulation of it that models the device enough to boot guests on this board. The mv643xx.h header with register definitions is taken from Linux 4.15.10 only fixing white space errors, removing not needed parts and changing formatting for QEMU coding style.
--- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 951 ++++++++++++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 ++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 6 + include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 1 + 7 files changed, 1890 insertions(+) create mode 100644 hw/pci-host/mv64361.c create mode 100644 hw/pci-host/mv643xx.h create mode 100644 include/hw/pci-host/mv64361.h
hw/pci-host/Kconfig +4 -0
@@ -72,3 +72,7 @@ config REMOTE_PCIHOST config SH_PCI bool select PCI + +config MV64361 + bool + select PCI
hw/pci-host/meson.build +2 -0
@@ -19,6 +19,8 @@ pci_ss.add(when: 'CONFIG_GRACKLE_PCI', if_true: files('grackle.c')) pci_ss.add(when: 'CONFIG_UNIN_PCI', if_true: files('uninorth.c')) # PowerPC E500 boards pci_ss.add(when: 'CONFIG_PPCE500_PCI', if_true: files('ppce500.c')) +# Pegasos2 +pci_ss.add(when: 'CONFIG_MV64361', if_true: files('mv64361.c')) # ARM devices pci_ss.add(when: 'CONFIG_VERSATILE_PCI', if_true: files('versatile.c'))
hw/pci-host/mv64361.c new file +951 -0
951 lines not on this page · raw message
hw/pci-host/mv643xx.h new file +918 -0
918 lines not on this page · raw message
hw/pci-host/trace-events +6 -0
@@ -3,6 +3,12 @@ # grackle.c grackle_set_irq(int irq_num, int level) "set_irq num %d level %d" +# mv64361.c +mv64361_region_map(const char *name, uint64_t poffs, uint64_t size, uint64_t moffs) "Mapping %s 0x%"PRIx64"+0x%"PRIx64" @ 0x%"PRIx64 +mv64361_region_enable(const char *op, int num) "Should %s region %d" +mv64361_reg_read(uint64_t addr, uint32_t val) "0x%"PRIx64" -> 0x%x" +mv64361_reg_write(uint64_t addr, uint64_t val) "0x%"PRIx64" <- 0x%"PRIx64 + # sabre.c sabre_set_request(int irq_num) "request irq %d" sabre_clear_request(int irq_num) "clear request irq %d"
include/hw/pci-host/mv64361.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef MV64361_H +#define MV64361_H + +#define TYPE_MV64361 "mv64361" + +PCIBus *mv64361_get_pci_bus (DeviceState *dev,int n); + +#endif
include/hw/pci/pci_ids.h +1 -0
@@ -214,6 +214,7 @@#define PCI_DEVICE_ID_VIA_8231_PM 0x8235#define PCI_VENDOR_ID_MARVELL 0x11ab +#define PCI_DEVICE_ID_MARVELL_MV6436X 0x6460#define PCI_VENDOR_ID_SILICON_MOTION 0x126f#define PCI_DEVICE_ID_SM501 0x0501
Signature · 1 line
2.21.4
PATCH v11 4/7 vt82c686: Add emulation of VT8231 south bridge
In reply to BALATON ZoltanAdd emulation of VT8231 south bridge ISA part based on the similar VT82C686B but implemented in a separate subclass that holds the differences while reusing parts that can be shared.
--- hw/isa/vt82c686.c | 84 +++++++++++++++++++++++++++++++++++++++ include/hw/isa/vt82c686.h | 1 + include/hw/pci/pci_ids.h | 1 + 3 files changed, 86 insertions(+)
hw/isa/vt82c686.c +84 -0
@@ -8,6 +8,9 @@* * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. +* +* VT8231 south bridge support and general clean up to allow it +* Copyright (c) 2018-2020 BALATON Zoltan */ #include "qemu/osdep.h"
@@ -640,6 +643,86 @@ static const TypeInfo vt82c686b_isa_info = { .class_init = vt82c686b_class_init, }; +/* TYPE_VT8231_ISA */ + +static void vt8231_write_config (PCIDevice *d,uint32_t addr, +uint32_t val,int len) +{ +ViaISAState *s =VIA_ISA (d); + +trace_via_isa_write (addr, val, len); +pci_default_write_config (d, addr, val, len); +if (addr ==0x50 ) { +/* BIT(2): enable or disable superio config io ports */ +via_superio_io_enable (s->via_sio, val &BIT (2 )); + } +} + +static void vt8231_isa_reset (DeviceState *dev) +{ +ViaISAState *s =VIA_ISA (dev); +uint8_t *pci_conf = s->dev.config; + +pci_set_long (pci_conf +PCI_CAPABILITY_LIST ,0x000000c0 ); +pci_set_word (pci_conf +PCI_COMMAND ,PCI_COMMAND_IO |PCI_COMMAND_MEMORY | +PCI_COMMAND_MASTER |PCI_COMMAND_SPECIAL ); +pci_set_word (pci_conf +PCI_STATUS ,PCI_STATUS_DEVSEL_MEDIUM ); + + pci_conf[0x58 ] =0x40 ;/* Miscellaneous Control 0 */ + pci_conf[0x67 ] =0x08 ;/* Fast IR Config */ + pci_conf[0x6b ] =0x01 ;/* Fast IR I/O Base */ +} + +static void vt8231_realize (PCIDevice *d,Error **errp) +{ +ViaISAState *s =VIA_ISA (d); +DeviceState *dev =DEVICE (d); +ISABus *isa_bus; +qemu_irq *isa_irq; +int i; + +qdev_init_gpio_out (dev, &s->cpu_intr,1 ); + isa_irq =qemu_allocate_irqs (via_isa_request_i8259_irq, s,1 ); + isa_bus =isa_bus_new (dev,get_system_memory (),pci_address_space_io (d), + &error_fatal); +isa_bus_irqs (isa_bus,i8259_init (isa_bus, *isa_irq)); +i8254_pit_init (isa_bus,0x40 ,0 ,NULL ); +i8257_dma_init (isa_bus,0 ); + s->via_sio =VIA_SUPERIO (isa_create_simple (isa_bus,TYPE_VT8231_SUPERIO )); +mc146818_rtc_init (isa_bus,2000 ,NULL ); + +for (i =0 ; i <PCI_CONFIG_HEADER_SIZE ; i++) { +if (i <PCI_COMMAND || i >=PCI_REVISION_ID ) { + d->wmask[i] =0 ; + } + } +} + +static void vt8231_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); + + k->realize = vt8231_realize; + k->config_write = vt8231_write_config; + k->vendor_id =PCI_VENDOR_ID_VIA ; + k->device_id =PCI_DEVICE_ID_VIA_8231_ISA ; + k->class_id =PCI_CLASS_BRIDGE_ISA ; + k->revision =0x10 ; + dc->reset = vt8231_isa_reset; + dc->desc ="ISA bridge" ; + dc->vmsd = &vmstate_via; +/* Reason: part of VIA VT8231 southbridge, needs to be wired up */ + dc->user_creatable = false; +} + +static const TypeInfo vt8231_isa_info = { + .name =TYPE_VT8231_ISA , + .parent =TYPE_VIA_ISA , + .instance_size =sizeof (ViaISAState), + .class_init = vt8231_class_init, +}; +static void vt82c686b_register_types (void ) {
@@ -651,6 +734,7 @@ static void vt82c686b_register_types(void)type_register_static (&vt8231_superio_info);type_register_static (&via_isa_info);type_register_static (&vt82c686b_isa_info); +type_register_static (&vt8231_isa_info); }type_init (vt82c686b_register_types)
include/hw/isa/vt82c686.h +1 -0
@@ -3,6 +3,7 @@#define TYPE_VT82C686B_ISA "vt82c686b-isa"#define TYPE_VT82C686B_PM "vt82c686b-pm" +#define TYPE_VT8231_ISA "vt8231-isa"#define TYPE_VT8231_PM "vt8231-pm"#define TYPE_VIA_AC97 "via-ac97"#define TYPE_VIA_MC97 "via-mc97"
include/hw/pci/pci_ids.h +1 -0
@@ -210,6 +210,7 @@#define PCI_DEVICE_ID_VIA_82C686B_PM 0x3057#define PCI_DEVICE_ID_VIA_AC97 0x3058#define PCI_DEVICE_ID_VIA_MC97 0x3068 +#define PCI_DEVICE_ID_VIA_8231_ISA 0x8231#define PCI_DEVICE_ID_VIA_8231_PM 0x8235#define PCI_VENDOR_ID_MARVELL 0x11ab
Signature · 1 line
2.21.4
v11 cover Pegasos2 emulation
Hello,
This is adding a new PPC board called pegasos2. More info on it can be found at:
https://osdn.net/projects/qmiga/wiki/SubprojectPegasos2
Currently it needs a firmware ROM image that I cannot include due to original copyright holder (bPlan) did not release it under a free licence but I have plans to write a replacement in the future. With the original board firmware it can boot MorphOS now as:
qemu-system-ppc -M pegasos2 -cdrom morphos.iso -device ati-vga,romfile="" -serial stdio
then enter "boot cd boot.img" at the firmware "ok" prompt as described in the MorphOS.readme. To boot Linux use same command line with e.g. -cdrom debian-8.11.0-powerpc-netinst.iso then enter
"boot cd install/pegasos"
The last patch adds the actual board code after previous patches adding VT8231 and MV64361 system controller chip emulation.
Regards,
BALATON Zoltan
v11: Changes to last two patches David asked for during review
v10: Updated comments and added R-b from Mark
v9: Rebased to master
v8: Do not emulate setting of serial port address via register, just
hard code a default address instead
v7: Fix errp usage in patch 2
v6: Rebased on master, updated commit message about migration change
v5: Changes for review comments from David and Philippe
V4: Rename pegasos2_reset to pegasos2_cpu_reset
Add new files to MAINTAINERS
BALATON Zoltan (6):
vt82c686: QOM-ify superio related functionality
vt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO
vt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it
vt82c686: Add emulation of VT8231 south bridge hw/pci-host: Add emulation of Marvell MV64361 PPC system controller hw/ppc: Add emulation of Genesi/bPlan Pegasos II
Philippe Mathieu-Daudé (1):
hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APM
MAINTAINERS | 10 + default-configs/devices/ppc-softmmu.mak | 2 + hw/isa/Kconfig | 1 + hw/isa/vt82c686.c | 422 +++++++++-- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 951 ++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 +++++++++++++++++++++++ hw/pci-host/trace-events | 6 + hw/ppc/Kconfig | 9 + hw/ppc/meson.build | 2 + hw/ppc/pegasos2.c | 144 ++++ include/hw/isa/vt82c686.h | 2 +- include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 4 +- 15 files changed, 2403 insertions(+), 82 deletions(-) create mode 100644 hw/pci-host/mv64361.c create mode 100644 hw/pci-host/mv643xx.h create mode 100644 hw/ppc/pegasos2.c create mode 100644 include/hw/pci-host/mv64361.h
Signature · 1 line
2.21.4
PATCH v11 3/7 vt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it
To allow reusing ISA bridge emulation for vt8231_isa move the device state of vt82c686b_isa emulation in an abstract via_isa class. This change breaks migration back compatibility but this is not an issue for Fuloong2E machine which is not versioned or migration supported.
--- hw/isa/vt82c686.c | 70 ++++++++++++++++++++++------------------ include/hw/pci/pci_ids.h | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-)
hw/isa/vt82c686.c +39 -31
@@ -518,24 +518,48 @@ static const TypeInfo vt8231_superio_info = { }; -OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) +#define TYPE_VIA_ISA "via-isa" +OBJECT_DECLARE_SIMPLE_TYPE(ViaISAState, VIA_ISA) -struct VT82C686BISAState { +struct ViaISAState {PCIDevice dev;qemu_irq cpu_intr;ViaSuperIOState *via_sio; }; +static const VMStateDescription vmstate_via = { + .name ="via-isa" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, ViaISAState), +VMSTATE_END_OF_LIST () + } +}; + +static const TypeInfo via_isa_info = { + .name =TYPE_VIA_ISA , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (ViaISAState), + .abstract = true, + .interfaces = (InterfaceInfo []) { + {INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; +static void via_isa_request_i8259_irq (void *opaque,int irq,int level) { -VT82C686BISAState *s = opaque; +ViaISAState *s = opaque;qemu_set_irq (s->cpu_intr, level); } +/* TYPE_VT82C686B_ISA */ +static void vt82c686b_write_config (PCIDevice *d,uint32_t addr,uint32_t val,int len) { -VT82C686BISAState *s =VT82C686B_ISA (d); +ViaISAState *s =VIA_ISA (d);trace_via_isa_write (addr, val, len);pci_default_write_config (d, addr, val, len);
@@ -545,19 +569,9 @@ static void vt82c686b_write_config(PCIDevice *d, uint32_t addr, } } -static const VMStateDescription vmstate_via = { - .name ="vt82c686b" , - .version_id =1 , - .minimum_version_id =1 , - .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, VT82C686BISAState), -VMSTATE_END_OF_LIST () - } -}; -static void vt82c686b_isa_reset (DeviceState *dev) { -VT82C686BISAState *s =VT82C686B_ISA (dev); +ViaISAState *s =VIA_ISA (dev);uint8_t *pci_conf = s->dev.config;pci_set_long (pci_conf +PCI_CAPABILITY_LIST ,0x000000c0 );
@@ -577,7 +591,7 @@ static void vt82c686b_isa_reset(DeviceState *dev)static void vt82c686b_realize (PCIDevice *d,Error **errp) { -VT82C686BISAState *s =VT82C686B_ISA (d); +ViaISAState *s =VIA_ISA (d);DeviceState *dev =DEVICE (d);ISABus *isa_bus;qemu_irq *isa_irq;
@@ -601,7 +615,7 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp) } } -static void via_class_init (ObjectClass *klass,void *data) +static void vt82c686b_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass);
@@ -609,28 +623,21 @@ static void via_class_init(ObjectClass *klass, void *data) k->realize = vt82c686b_realize; k->config_write = vt82c686b_write_config; k->vendor_id =PCI_VENDOR_ID_VIA ; - k->device_id =PCI_DEVICE_ID_VIA_ISA_BRIDGE ; + k->device_id =PCI_DEVICE_ID_VIA_82C686B_ISA ; k->class_id =PCI_CLASS_BRIDGE_ISA ; k->revision =0x40 ; dc->reset = vt82c686b_isa_reset; dc->desc ="ISA bridge" ; dc->vmsd = &vmstate_via; -/* -* Reason: part of VIA VT82C686 southbridge, needs to be wired up, -* e.g. by mips_fuloong2e_init() -*/ +/* Reason: part of VIA VT82C686 southbridge, needs to be wired up */ dc->user_creatable = false; } -static const TypeInfo via_info = { +static const TypeInfo vt82c686b_isa_info = { .name =TYPE_VT82C686B_ISA , - .parent =TYPE_PCI_DEVICE , - .instance_size =sizeof (VT82C686BISAState), - .class_init = via_class_init, - .interfaces = (InterfaceInfo []) { - {INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, + .parent =TYPE_VIA_ISA , + .instance_size =sizeof (ViaISAState), + .class_init = vt82c686b_class_init, };
@@ -642,7 +649,8 @@ static void vt82c686b_register_types(void)type_register_static (&via_superio_info);type_register_static (&vt82c686b_superio_info);type_register_static (&vt8231_superio_info); -type_register_static (&via_info); +type_register_static (&via_isa_info); +type_register_static (&vt82c686b_isa_info); }type_init (vt82c686b_register_types)
include/hw/pci/pci_ids.h +1 -1
@@ -204,7 +204,7 @@#define PCI_VENDOR_ID_XILINX 0x10ee#define PCI_VENDOR_ID_VIA 0x1106 -#define PCI_DEVICE_ID_VIA_ISA_BRIDGE 0x0686 +#define PCI_DEVICE_ID_VIA_82C686B_ISA 0x0686#define PCI_DEVICE_ID_VIA_IDE 0x0571#define PCI_DEVICE_ID_VIA_UHCI 0x3038#define PCI_DEVICE_ID_VIA_82C686B_PM 0x3057
Signature · 1 line
2.21.4
PATCH v11 1/7 vt82c686: QOM-ify superio related functionality
In reply to BALATON ZoltanCollect superio functionality and its controlling config registers handling in an abstract VIA_SUPERIO class that is a subclass of ISA_SUPERIO and put vt82c686b specific parts in a subclass of this abstract class.
--- hw/isa/vt82c686.c | 196 +++++++++++++++++++++++++------------- include/hw/isa/vt82c686.h | 1 - 2 files changed, 132 insertions(+), 65 deletions(-)
hw/isa/vt82c686.c +132 -64
@@ -249,15 +249,80 @@ static const TypeInfo vt8231_pm_info = { }; -typedef struct SuperIOConfig { +#define TYPE_VIA_SUPERIO "via-superio" +OBJECT_DECLARE_SIMPLE_TYPE(ViaSuperIOState, VIA_SUPERIO) + +struct ViaSuperIOState { +ISASuperIODevice superio;uint8_t regs[0x100 ]; +const MemoryRegionOps *io_ops;MemoryRegion io; -}SuperIOConfig ; +}; + +static inline void via_superio_io_enable (ViaSuperIOState *s,bool enable) +{ +memory_region_set_enabled (&s->io, enable); +} + +static void via_superio_realize (DeviceState *d,Error **errp) +{ +ViaSuperIOState *s =VIA_SUPERIO (d); +ISASuperIOClass *ic =ISA_SUPERIO_GET_CLASS (s); +Error *local_err =NULL ; + +assert (s->io_ops); + ic->parent_realize (d, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } +memory_region_init_io (&s->io,OBJECT (d), s->io_ops, s,"via-superio" ,2 ); +memory_region_set_enabled (&s->io, false); +/* The floppy also uses 0x3f0 and 0x3f1 but this seems to work anyway */ +memory_region_add_subregion (isa_address_space_io (ISA_DEVICE (s)),0x3f0 , + &s->io); +} + +static uint64_t via_superio_cfg_read (void *opaque,hwaddr addr,unsigned size) +{ +ViaSuperIOState *sc = opaque; +uint8_t idx = sc->regs[0 ]; +uint8_t val = sc->regs[idx]; + +if (addr ==0 ) { +return idx; + } +if (addr ==1 && idx ==0 ) { + val =0 ;/* reading reg 0 where we store index value */ + } +trace_via_superio_read (idx, val); +return val; +} + +static void via_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + sc->parent_realize = dc->realize; + dc->realize = via_superio_realize; +} + +static const TypeInfo via_superio_info = { + .name =TYPE_VIA_SUPERIO , + .parent =TYPE_ISA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .class_size =sizeof (ISASuperIOClass), + .class_init = via_superio_class_init, + .abstract = true, +}; + +#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio" -static void superio_cfg_write (void *opaque,hwaddr addr,uint64_t data, -unsigned size) +static void vt82c686b_superio_cfg_write (void *opaque,hwaddr addr, +uint64_t data,unsigned size) { -SuperIOConfig *sc = opaque; +ViaSuperIOState *sc = opaque;uint8_t idx = sc->regs[0 ];if (addr ==0 ) {/* config index register */
@@ -288,25 +353,9 @@ static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, sc->regs[idx] = data; } -static uint64_t superio_cfg_read (void *opaque,hwaddr addr,unsigned size) -{ -SuperIOConfig *sc = opaque; -uint8_t idx = sc->regs[0 ]; -uint8_t val = sc->regs[idx]; - -if (addr ==0 ) { -return idx; - } -if (addr ==1 && idx ==0 ) { - val =0 ;/* reading reg 0 where we store index value */ - } -trace_via_superio_read (idx, val); -return val; -} - -static const MemoryRegionOps superio_cfg_ops = { - .read = superio_cfg_read, - .write = superio_cfg_write, +static const MemoryRegionOps vt82c686b_superio_cfg_ops = { + .read = via_superio_cfg_read, + .write = vt82c686b_superio_cfg_write, .endianness =DEVICE_NATIVE_ENDIAN , .impl = { .min_access_size =1 ,
@@ -314,13 +363,66 @@ static const MemoryRegionOps superio_cfg_ops = { }, }; +static void vt82c686b_superio_reset (DeviceState *dev) +{ +ViaSuperIOState *s =VIA_SUPERIO (dev); + +memset (s->regs,0 ,sizeof (s->regs)); +/* Device ID */ +vt82c686b_superio_cfg_write (s,0 ,0xe0 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0x3c ,1 ); +/* Function select - all disabled */ +vt82c686b_superio_cfg_write (s,0 ,0xe2 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0x03 ,1 ); +/* Floppy ctrl base addr 0x3f0-7 */ +vt82c686b_superio_cfg_write (s,0 ,0xe3 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xfc ,1 ); +/* Parallel port base addr 0x378-f */ +vt82c686b_superio_cfg_write (s,0 ,0xe6 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xde ,1 ); +/* Serial port 1 base addr 0x3f8-f */ +vt82c686b_superio_cfg_write (s,0 ,0xe7 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xfe ,1 ); +/* Serial port 2 base addr 0x2f8-f */ +vt82c686b_superio_cfg_write (s,0 ,0xe8 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xbe ,1 ); + +vt82c686b_superio_cfg_write (s,0 ,0 ,1 ); +} + +static void vt82c686b_superio_init (Object *obj) +{ +VIA_SUPERIO (obj)->io_ops = &vt82c686b_superio_cfg_ops; +} + +static void vt82c686b_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + dc->reset = vt82c686b_superio_reset; + sc->serial.count =2 ; + sc->parallel.count =1 ; + sc->ide.count =0 ;/* emulated by via-ide */ + sc->floppy.count =1 ; +} + +static const TypeInfo vt82c686b_superio_info = { + .name =TYPE_VT82C686B_SUPERIO , + .parent =TYPE_VIA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .instance_init = vt82c686b_superio_init, + .class_size =sizeof (ISASuperIOClass), + .class_init = vt82c686b_superio_class_init, +}; + OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA)struct VT82C686BISAState {PCIDevice dev;qemu_irq cpu_intr; -SuperIOConfig superio_cfg; +ViaSuperIOState *via_sio; };static void via_isa_request_i8259_irq (void *opaque,int irq,int level)
@@ -338,7 +440,7 @@ static void vt82c686b_write_config(PCIDevice *d, uint32_t addr,pci_default_write_config (d, addr, val, len);if (addr ==0x85 ) {/* BIT(1): enable or disable superio config io ports */ -memory_region_set_enabled (&s->superio_cfg.io, val &BIT (1 )); +via_superio_io_enable (s->via_sio, val &BIT (1 )); } }
@@ -370,13 +472,6 @@ static void vt82c686b_isa_reset(DeviceState *dev) pci_conf[0x5a ] =0x04 ;/* KBC/RTC Control*/ pci_conf[0x5f ] =0x04 ; pci_conf[0x77 ] =0x10 ;/* GPIO Control 1/2/3/4 */ - - s->superio_cfg.regs[0xe0 ] =0x3c ;/* Device ID */ - s->superio_cfg.regs[0xe2 ] =0x03 ;/* Function select */ - s->superio_cfg.regs[0xe3 ] =0xfc ;/* Floppy ctrl base addr */ - s->superio_cfg.regs[0xe6 ] =0xde ;/* Parallel port base addr */ - s->superio_cfg.regs[0xe7 ] =0xfe ;/* Serial port 1 base addr */ - s->superio_cfg.regs[0xe8 ] =0xbe ;/* Serial port 2 base addr */ }static void vt82c686b_realize (PCIDevice *d,Error **errp)
@@ -394,7 +489,8 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp)isa_bus_irqs (isa_bus,i8259_init (isa_bus, *isa_irq));i8254_pit_init (isa_bus,0x40 ,0 ,NULL );i8257_dma_init (isa_bus,0 ); -isa_create_simple (isa_bus,TYPE_VT82C686B_SUPERIO ); + s->via_sio =VIA_SUPERIO (isa_create_simple (isa_bus, +TYPE_VT82C686B_SUPERIO ));mc146818_rtc_init (isa_bus,2000 ,NULL );for (i =0 ; i <PCI_CONFIG_HEADER_SIZE ; i++) {
@@ -402,16 +498,6 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp) d->wmask[i] =0 ; } } - -memory_region_init_io (&s->superio_cfg.io,OBJECT (d), &superio_cfg_ops, - &s->superio_cfg,"superio_cfg" ,2 ); -memory_region_set_enabled (&s->superio_cfg.io, false); -/* -* The floppy also uses 0x3f0 and 0x3f1. -* But we do not emulate a floppy, so just set it here. -*/ -memory_region_add_subregion (isa_bus->address_space_io,0x3f0 , - &s->superio_cfg.io); }static void via_class_init (ObjectClass *klass,void *data)
@@ -447,32 +533,14 @@ static const TypeInfo via_info = { }; -static void vt82c686b_superio_class_init (ObjectClass *klass,void *data) -{ -ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); - - sc->serial.count =2 ; - sc->parallel.count =1 ; - sc->ide.count =0 ; - sc->floppy.count =1 ; -} - -static const TypeInfo via_superio_info = { - .name =TYPE_VT82C686B_SUPERIO , - .parent =TYPE_ISA_SUPERIO , - .instance_size =sizeof (ISASuperIODevice), - .class_size =sizeof (ISASuperIOClass), - .class_init = vt82c686b_superio_class_init, -}; - -static void vt82c686b_register_types (void ) {type_register_static (&via_pm_info);type_register_static (&vt82c686b_pm_info);type_register_static (&vt8231_pm_info); -type_register_static (&via_info);type_register_static (&via_superio_info); +type_register_static (&vt82c686b_superio_info); +type_register_static (&via_info); }type_init (vt82c686b_register_types)
include/hw/isa/vt82c686.h +0 -1
@@ -2,7 +2,6 @@#define HW_VT82C686_H #define TYPE_VT82C686B_ISA "vt82c686b-isa" -#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio"#define TYPE_VT82C686B_PM "vt82c686b-pm"#define TYPE_VT8231_PM "vt8231-pm"#define TYPE_VIA_AC97 "via-ac97"
Signature · 1 line
2.21.4
PATCH v11 5/7 hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APM
In reply to BALATON ZoltanFrom: Philippe Mathieu-Daudé <[email protected]>
TYPE_VIA_PM calls apm_init() in via_pm_realize(), so requires APM to be selected.
--- hw/isa/Kconfig | 1 + 1 file changed, 1 insertion(+)
hw/isa/Kconfig +1 -0
@@ -48,6 +48,7 @@ config VT82C686 select SERIAL_ISA select FDC select USB_UHCI + select APM config SMC37C669 bool
Signature · 1 line
2.21.4
David Gibson
AppliedQuoted 14 lines · BALATON Zoltan
Hello,
This is adding a new PPC board called pegasos2. More info on it can be found at:
https://osdn.net/projects/qmiga/wiki/SubprojectPegasos2
Currently it needs a firmware ROM image that I cannot include due to original copyright holder (bPlan) did not release it under a free licence but I have plans to write a replacement in the future. With the original board firmware it can boot MorphOS now as:
qemu-system-ppc -M pegasos2 -cdrom morphos.iso -device ati-vga,romfile="" -serial stdio
Quoted 7 lines
then enter "boot cd boot.img" at the firmware "ok" prompt as described in the MorphOS.readme. To boot Linux use same command line with e.g. -cdrom debian-8.11.0-powerpc-netinst.iso then enter
"boot cd install/pegasos"The last patch adds the actual board code after previous patches adding VT8231 and MV64361 system controller chip emulation.
Applied to ppc-for-6.1, thanks.
Quoted 54 lines
Regards,
BALATON Zoltanv11: Changes to last two patches David asked for during review
v10: Updated comments and added R-b from Mark
v9: Rebased to master
v8: Do not emulate setting of serial port address via register, just
hard code a default address insteadv7: Fix errp usage in patch 2
v6: Rebased on master, updated commit message about migration change
v5: Changes for review comments from David and Philippe
V4: Rename
pegasos2_resettopegasos2_cpu_reset
Add new files toMAINTAINERSBALATON Zoltan (6):
vt82c686: QOM-ify superio related functionality
vt82c686: AddVT8231_SUPERIObased onVIA_SUPERIO
vt82c686: Introduce abstractTYPE_VIA_ISAand basevt82c686b_isaon it
vt82c686: Add emulation of VT8231 south bridge hw/pci-host: Add emulation of Marvell MV64361 PPC system controller hw/ppc: Add emulation of Genesi/bPlan Pegasos IIPhilippe Mathieu-Daudé (1):
hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APMMAINTAINERS | 10 + default-configs/devices/ppc-softmmu.mak | 2 + hw/isa/Kconfig | 1 + hw/isa/vt82c686.c | 422 +++++++++-- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 951 ++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 +++++++++++++++++++++++ hw/pci-host/trace-events | 6 + hw/ppc/Kconfig | 9 + hw/ppc/meson.build | 2 + hw/ppc/pegasos2.c | 144 ++++ include/hw/isa/vt82c686.h | 2 +- include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 4 +- 15 files changed, 2403 insertions(+), 82 deletions(-) create mode 100644 hw/pci-host/mv64361.c create mode 100644 hw/pci-host/mv643xx.h create mode 100644 hw/ppc/pegasos2.c create mode 100644 include/hw/pci-host/mv64361.h
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson