Skip to contentSkip to conversation

Basic ATI VGA emulation

PATCH Superseded BALATON Zoltan 1 participant 4 messages Mar 6, 2019

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Basic ATI VGA emulation

Hello,

This is the latest version of the ati-vga patch, now also including the mips_fulong2e patch in a series so both can be merged together via the UI tree as agreed before to avoid needing to sync two maintainers.

That's probably all I can do before the freeze but the rest can be considered bugfixes (or given that there's nothing to regress from yet anything can be considered bugfix at this stage) so we may have some more chance to improve it before the release if it's merged now.

At least Linux console and fulong2e PMON firmware should work but I wasn't able to completely find out how 2D accel should work so it still gives some garbled output for guests using it but I won't have time to figure this out before the freeze. I could take some help in this from someone knowing this hardware and pixman better than me. (Pixman not having any documentation does not help.)

Please let me know if there's anything that needs to be fixed for it to be merged now. I can probably make another version before the freeze with those changes but not much more at the moment.

Regards,
BALATON Zoltan

BALATON Zoltan (2):
hw/display: Add basic ATI VGA emulation
mips_fulong2e: Add on-board graphics chip

 default-configs/pci.mak  |   1 +
 hw/display/Makefile.objs |   2 +
 hw/display/ati.c         | 786 +++++++++++++++++++++++++++++++++++++++++++++++
 hw/display/ati_2d.c      | 134 ++++++++
 hw/display/ati_dbg.c     | 259 ++++++++++++++++
 hw/display/ati_int.h     |  93 ++++++
 hw/display/ati_regs.h    | 461 +++++++++++++++++++++++++++
 hw/display/trace-events  |   4 +
 hw/mips/mips_fulong2e.c  |   6 +
 vl.c                     |   1 +
 10 files changed, 1747 insertions(+)
 create mode 100644 hw/display/ati.c
 create mode 100644 hw/display/ati_2d.c
 create mode 100644 hw/display/ati_dbg.c
 create mode 100644 hw/display/ati_int.h
 create mode 100644 hw/display/ati_regs.h
Signature · 1 line
2.13.7
#1 lore raw

PATCH v5 1/2 hw/display: Add basic ATI VGA emulation

At least two machines, the PPC mac99 and MIPS fulong2e, have an ATI gfx chip by default (Rage 128 Pro and M6/RV100 respectively) and guests running on these and the PMON2000 firmware of the fulong2e expect this to be available. Fortunately these are very similar chips so they can be mostly emulated in the same device model. This patch adds basic emulation of these ATI VGA chips.

While this is incomplete and currently only enough to run the MIPS firmware and get framebuffer output with Linux, it allows the fulong2e board to work more like the real hardware and having it in QEMU in this state provides a way to experiment with it and allows others to contribute to improve it. It is compiled for all archs but only the fulong2e (which currently has no display output at all) is set to use it by default (in a separate patch).

---
v5:
- review suggestions: add const to model aliases, \n to log, %u in trace
- implemented hardware cursor support

v4:
- fix mingw build (from Gerd)
- set dev_id in realize to allow pci_patch_ids to change bios rom
- add model aliases to select device variant by name instead of id
- misc mode switch and 2d fixes (better but still not quite right)

v3:
- add to default-configs/pci.mak instead of mips64el and ppc only
- rename device_id property to x-device-id
- use extract32/deposit32 in *_offs functions
- add ati-vga to vl.c default_list[]

v2:
- Extended debug logs
- Fix mode switching and some registers
- Fixes to 2D functions

 default-configs/pci.mak  |   1 +
 hw/display/Makefile.objs |   2 +
 hw/display/ati.c         | 786 +++++++++++++++++++++++++++++++++++++++++++++++
 hw/display/ati_2d.c      | 134 ++++++++
 hw/display/ati_dbg.c     | 259 ++++++++++++++++
 hw/display/ati_int.h     |  93 ++++++
 hw/display/ati_regs.h    | 461 +++++++++++++++++++++++++++
 hw/display/trace-events  |   4 +
 vl.c                     |   1 +
 9 files changed, 1741 insertions(+)
 create mode 100644 hw/display/ati.c
 create mode 100644 hw/display/ati_2d.c
 create mode 100644 hw/display/ati_dbg.c
 create mode 100644 hw/display/ati_int.h
 create mode 100644 hw/display/ati_regs.h
default-configs/pci.mak +1 -0
index 037636fa33..e59e2fa7b6 100644
@@ -49,3 +49,4 @@ CONFIG_IVSHMEM_DEVICE=$(CONFIG_IVSHMEM)
 CONFIG_ROCKER=y
 CONFIG_VFIO=$(CONFIG_LINUX)
 CONFIG_VFIO_PCI=y
+CONFIG_ATI_VGA=y
hw/display/Makefile.objs +2 -0
index 7c4ae9a0fd..963c23f3c8 100644
@@ -53,3 +53,5 @@ virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
 virtio-gpu-3d.o-libs += $(VIRGL_LIBS)
 obj-$(CONFIG_DPCD) += dpcd.o
 obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx_dp.o
+
+obj-$(CONFIG_ATI_VGA) += ati.o ati_2d.o ati_dbg.o
hw/display/ati.c new file +786 -0

786 lines not on this page · raw message

hw/display/ati_2d.c new file +134 -0

134 lines not on this page · raw message

hw/display/ati_dbg.c new file +259 -0

259 lines not on this page · raw message

hw/display/ati_int.h new file +93 -0

93 lines not on this page · raw message

hw/display/ati_regs.h new file +461 -0

461 lines not on this page · raw message

hw/display/trace-events +4 -0
index 37d3264bb2..80993cc4d9 100644
@@ -138,3 +138,7 @@ vga_cirrus_write_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x"
 sii9022_read_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
 sii9022_write_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
 sii9022_switch_mode(const char *mode) "mode: %s"
+
+# hw/display/ati*.c
+ati_mm_read(unsigned int size, uint64_t addr, const char *name, uint64_t val) "%u 0x%"HWADDR_PRIx " %s -> 0x%"PRIx64
+ati_mm_write(unsigned int size, uint64_t addr, const char *name, uint64_t val) "%u 0x%"HWADDR_PRIx " %s <- 0x%"PRIx64
vl.c +1 -0
index 4c5cc0d8ad..4ab7fb3753 100644
@@ -240,6 +240,7 @@ static struct {
     { .driver = "vmware-svga",          .flag = &default_vga       },
     { .driver = "qxl-vga",              .flag = &default_vga       },
     { .driver = "virtio-vga",           .flag = &default_vga       },
+    { .driver = "ati-vga",              .flag = &default_vga       },
 };
 
 static QemuOptsList qemu_rtc_opts = {
Signature · 1 line
2.13.7
#2 lore raw

PATCH v5 2/2 mips_fulong2e: Add on-board graphics chip

In reply to BALATON Zoltan

Add (partial) emulation of the on-board GPU of the machine. This allows the PMON2000 firmware to run and should also work with Linux console but probably not with X yet.

---
 hw/mips/mips_fulong2e.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/mips/mips_fulong2e.c +6 -0
index fbbc543eed..f877693766 100644
@@ -287,6 +287,7 @@ static void mips_fulong2e_init(MachineState *machine)
     I2CBus *smbus;
     MIPSCPU *cpu;
     CPUMIPSState *env;
+    DeviceState *dev;
 
     /* init CPUs */
     cpu = MIPS_CPU(cpu_create(machine->cpu_type));
@@ -347,6 +348,11 @@ static void mips_fulong2e_init(MachineState *machine)
     vt82c686b_southbridge_init(pci_bus, FULONG2E_VIA_SLOT, env->irq[5],
                                &smbus, &isa_bus);
 
+    /* GPU */
+    dev = DEVICE(pci_create(pci_bus, -1, "ati-vga"));
+    qdev_prop_set_uint16(dev, "x-device-id", 0x5159);
+    qdev_init_nofail(dev);
+
     /* Populate SPD eeprom data */
     spd_data = spd_data_generate(DDR, ram_size, &err);
     if (err) {
Signature · 1 line
2.13.7
#3 lore raw
In reply to BALATON Zoltan
Quoted 3 lines · BALATON Zoltan

Hello,

This is the latest version of the ati-vga patch, now also including

Sorry, looks like I messed it up and missing some changes in this. Please disregard this, I'll resend.

Quoted 44 lines

the mips_fulong2e patch in a series so both can be merged together via the UI tree as agreed before to avoid needing to sync two maintainers.

That's probably all I can do before the freeze but the rest can be considered bugfixes (or given that there's nothing to regress from yet anything can be considered bugfix at this stage) so we may have some more chance to improve it before the release if it's merged now.

At least Linux console and fulong2e PMON firmware should work but I wasn't able to completely find out how 2D accel should work so it still gives some garbled output for guests using it but I won't have time to figure this out before the freeze. I could take some help in this from someone knowing this hardware and pixman better than me. (Pixman not having any documentation does not help.)

Please let me know if there's anything that needs to be fixed for it to be merged now. I can probably make another version before the freeze with those changes but not much more at the moment.

Regards,
BALATON Zoltan

BALATON Zoltan (2):
hw/display: Add basic ATI VGA emulation
mips_fulong2e: Add on-board graphics chip

default-configs/pci.mak  |   1 +
hw/display/Makefile.objs |   2 +
hw/display/ati.c         | 786 +++++++++++++++++++++++++++++++++++++++++++++++
hw/display/ati_2d.c      | 134 ++++++++
hw/display/ati_dbg.c     | 259 ++++++++++++++++
hw/display/ati_int.h     |  93 ++++++
hw/display/ati_regs.h    | 461 +++++++++++++++++++++++++++
hw/display/trace-events  |   4 +
hw/mips/mips_fulong2e.c  |   6 +
vl.c                     |   1 +
10 files changed, 1747 insertions(+)

create mode 100644 hw/display/ati.c
create mode 100644 hw/display/ati_2d.c
create mode 100644 hw/display/ati_dbg.c
create mode 100644 hw/display/ati_int.h
create mode 100644 hw/display/ati_regs.h