hw/display: Add basic ATI VGA emulation
PATCH v3 1/1 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 patch sent separately).
---
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 | 623 +++++++++++++++++++++++++++++++++++++++++++++++ hw/display/ati_2d.c | 75 ++++++ hw/display/ati_dbg.c | 254 +++++++++++++++++++ hw/display/ati_int.h | 75 ++++++ hw/display/ati_regs.h | 454 ++++++++++++++++++++++++++++++++++ hw/display/trace-events | 4 + vl.c | 1 + 9 files changed, 1489 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
@@ -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
@@ -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 +623 -0
623 lines not on this page · raw message
hw/display/ati_2d.c new file +75 -0
75 lines not on this page · raw message
hw/display/ati_dbg.c new file +254 -0
254 lines not on this page · raw message
hw/display/ati_int.h new file +75 -0
75 lines not on this page · raw message
hw/display/ati_regs.h new file +454 -0
454 lines not on this page · raw message
hw/display/trace-events +4 -0
@@ -137,3 +137,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) "%d 0x%"HWADDR_PRIx " %s -> 0x%"PRIx64 +ati_mm_write(unsigned int size, uint64_t addr, const char *name, uint64_t val) "%d 0x%"HWADDR_PRIx " %s <- 0x%"PRIx64
vl.c +1 -0
@@ -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
Quoted 7 lines · BALATON Zoltan
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.
Quoted 7 lines
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 patch sent separately).
Attached patch creates two separate devices. It's just some QOM boilerplate, they still share 95% of the code. With that in place vgabios works just fine for both devices.
On x86 linux: Fedora live iso happily boots X on both devices, they both are running with the vesa xorg driver though so that doesn't say much.
With a self-compiled kernel:
aty128fb.ko seems to be able to handle the rage128pro.
Neither radeonfb.ko nor radeon.ko (drm driver) can handle the rv100. Loading radeonfb results in a kernel panic. radeon.ko prints an initialization error. Seems at least radeonfb tries to pull some info out of the bios image ...
cheers,
Gerd
Quoted 1 line
From
465dab28c40c6296065cb991c771e48882ba484cMon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Fri, 22 Feb 2019 11:15:03 +0100
Subject: [PATCH] ati-vga: add per model types
--- hw/display/ati_int.h | 3 +- hw/display/ati_regs.h | 1 + hw/display/ati.c | 80 +++++++++++++++++++++++++++++++++++---------------- vl.c | 3 +- 4 files changed, 59 insertions(+), 28 deletions(-)
hw/display/ati_int.h +1 -2
@@ -18,7 +18,7 @@#define DPRINTF (fmt, ...) do {} while (0)#endif -#define TYPE_ATI_VGA "ati-vga" +#define TYPE_ATI_VGA "ati-vga-base"#define ATI_VGA (obj) OBJECT_CHECK(ATIVGAState, (obj), TYPE_ATI_VGA) typedef struct ATIVGARegs {
@@ -63,7 +63,6 @@ typedef struct ATIVGARegs { typedef struct ATIVGAState { PCIDevice dev; VGACommonState vga; - uint16_t dev_id; uint16_t mode; MemoryRegion io; MemoryRegion mm;
hw/display/ati_regs.h +1 -0
@@ -212,6 +212,7 @@#define DP_WRITE_MASK 0x16cc#define DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0#define DEFAULT_OFFSET 0x16e0 +#undef DEFAULT_PITCH/* needed for mingw builds */ #define DEFAULT_PITCH 0x16e4#define DEFAULT_SC_BOTTOM_RIGHT 0x16e8#define SC_TOP_LEFT 0x16ec
hw/display/ati.c +55 -25
180 lines not on this page · raw message
vl.c +2 -1
@@ -240,7 +240,8 @@ 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 }, + { .driver = "ati-rage128pro", .flag = &default_vga }, + { .driver = "ati-rv100", .flag = &default_vga }, }; static QemuOptsList qemu_rtc_opts = {
Signature · 1 line
2.9.3
Quoted 16 lines · Gerd Hoffmann
Quoted 7 lines · BALATON Zoltan
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.
Quoted 7 lines
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 patch sent separately).
Quoted 2 lines
Attached patch creates two separate devices. It's just some QOM boilerplate, they still share 95% of the code.
Thanks. Do you want me to merge this and submit a new version or you want to fix up after merging my patch or what should we do with this? (I'm not a fan of adding a new function for every new model of these devices so I'd probably get rid of the is_ati_* functions and still compare to device id internally maybe via a single is_ati_device(id) function though. I also find ati-rage128pro a bit too long, I liked the ati-vga better with selecting variants via a property but if you think it's better with more QOM boilerplate and adding every variant to the default_list[] one by one then I can live with that. How about ati-r128pro at least instead?
Quoted 2 lines
With that in place
vgabios works just fine for both devices.
But I don't get why is the above needed for this. By the time the client runs (after device realize) both should look the same: your QOM subclasses and my ati-vga class that sets device_id based on property. Where's the difference that makes one work and other doesn't?
Quoted 5 lines
On x86 linux: Fedora live iso happily boots X on both devices, they both are running with the vesa xorg driver though so that doesn't say much.
With a self-compiled kernel:
aty128fb.ko seems to be able to handle the rage128pro.
Good, that's all that's expected to work at the moment anyway.
Quoted 4 lines
Neither radeonfb.ko nor radeon.ko (drm driver) can handle the rv100. Loading radeonfb results in a kernel panic. radeon.ko prints an initialization error. Seems at least radeonfb tries to pull some info out of the bios image ...
Is there a live cd iso or something simple to test this with?
I think the ATI option ROMs have some mode timings that are needed to program PLLs for setting modes and drivers extract this from the BIOS which has some predefined structure so if a driver relies on this it may have a problem when we don't have a BIOS with the data it expects. But if it does not check BIOS format and just pulls junk out of unexpected BIOS image and puts that in clock registers that should not matter as those are ignored anyway. I think rv100 will probably need a separate vgabios that looks more like what drivers expect but I don't have plans yet to implement that. It may also be interesting to try a BIOS from a real card if you can get one to see what it does.
I think I've seen some logs in dmesg from aty128fb driver saying that BIOS is unexpected, guessing PLL values or similar. Maybe the radoeon driver does not do that and exits if BIOS is not found?
Regards,
BALATON Zoltan
Quoted 12 lines
Quoted 2 lines
Attached patch creates two separate devices. It's just some QOM boilerplate, they still share 95% of the code.
Thanks. Do you want me to merge this and submit a new version or you want to fix up after merging my patch or what should we do with this? (I'm not a fan of adding a new function for every new model of these devices so I'd probably get rid of the is_ati_* functions and still compare to device id internally maybe via a single
is_ati_device(id)function though. I also find ati-rage128pro a bit too long, I liked the ati-vga better with selecting variants via a property but if you think it's better with more QOM boilerplate and adding every variant to the default_list[] one by one then I can live with that. How about ati-r128pro at least instead?
Just apply the patch to your branch and tidy up as you want. Shorten the rage name is fine with me.
I don't expect we'll add too many variants, getting the two work properly will be difficult enough, so the QOM boilerplate shouldn't be much of a problem. I think it'll be more user-friendly to just have two or three ati devices instead of expecting them to dig out the correct id.
Quoted 7 lines
Quoted 2 lines
With that in place
vgabios works just fine for both devices.But I don't get why is the above needed for this. By the time the client runs (after device realize) both should look the same: your QOM subclasses and my ati-vga class that sets
device_idbased on property. Where's the difference that makes one work and other doesn't?
See pci_patch_ids() in hw/pci/pci.c
That gets vgabios-stdvga going with the ati cards (as long as the bochs interface is available), by setting the vendor and device IDs so seabios accepts and loads the rom.
That requires the device ID being set at that point though. Specifically setting it in reset handler is too late, and I think doing it in realize() is too late too. With two QOM types it is already set, thats why this gets the vgabios work with the rv100.
Quoted 6 lines
Quoted 4 lines
Neither radeonfb.ko nor radeon.ko (drm driver) can handle the rv100. Loading radeonfb results in a kernel panic. radeon.ko prints an initialization error. Seems at least radeonfb tries to pull some info out of the bios image ...
Is there a live cd iso or something simple to test this with?
No. Problem is modern distros tend to not build these drivers any more.
I have a script which creates a big initrd with a small distro install plus a self-compiled kernel, for testing my kernel patches. This is what I have used here too.
Quoted 8 lines
I think the ATI option ROMs have some mode timings that are needed to program PLLs for setting modes and drivers extract this from the BIOS which has some predefined structure so if a driver relies on this it may have a problem when we don't have a BIOS with the data it expects. But if it does not check BIOS format and just pulls junk out of unexpected BIOS image and puts that in clock registers that should not matter as those are ignored anyway. I think rv100 will probably need a separate vgabios that looks more like what drivers expect but I don't have plans yet to implement that.
For radeonfb this might work.
The radeon drm driver error messaga was quite unspecific.
cheers,
Gerd
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
CC aarch64-softmmu/hw/intc/aspeed_vic.o
CC x86_64-softmmu/hw/virtio/virtio-input-pci.o
In file included from /tmp/qemu-test/src/hw/display/ati.c:19:/tmp/qemu-test/src/hw/display/ati_regs.h:215: error: "DEFAULT_PITCH" redefined [-Werror]
#define DEFAULT_PITCH 0x16e4
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/windows.h:71,
---
#define DEFAULT_PITCH 0
In file included from /tmp/qemu-test/src/hw/display/ati_2d.c:11:/tmp/qemu-test/src/hw/display/ati_regs.h:215: error: "DEFAULT_PITCH" redefined [-Werror]
#define DEFAULT_PITCH 0x16e4
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/windows.h:71,
---
CC aarch64-softmmu/hw/intc/arm_gicv3_cpuif.o
In file included from /tmp/qemu-test/src/hw/display/ati_2d.c:11:/tmp/qemu-test/src/hw/display/ati_regs.h:215: error: "DEFAULT_PITCH" redefined [-Werror]
#define DEFAULT_PITCH 0x16e4
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/windows.h:71,
---
cc1: all warnings being treated as errors
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: hw/display/ati.o] Error 1 In file included from /tmp/qemu-test/src/hw/display/ati.c:19:/tmp/qemu-test/src/hw/display/ati_regs.h:215: error: "DEFAULT_PITCH" redefined [-Werror]
#define DEFAULT_PITCH 0x16e4
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/windows.h:71,
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]