Skip to contentSkip to conversation

qemu X3100 project

Qemu-devel Vincent Hanquez 4 participants 8 messages Mar 20, 2008 – Jul 20, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello QEMU ML,

I'm please to announce my qemu x3100 project. The ultimate goal is fully emulating an intel x3100 graphic card (also known as GMA965), to be able to hopefully support 3D in qemu guests (and any user of qemu code base).

However, the emulation is not complete yet; This is a long task, and lots of things need to be done, fixed and better integrated. I've started a month and a half, and at this point I think it would be useful to share it to the qemu mailing list, since it's got some basic features done, maybe people will be interested in helping ;)

So what does works ?
- VGA mode :)
- linux - intel drv 2.2.1 - non accelerated (32 bits depth only)
- linux - intel drv 2.2.1 - XAA acceleration (32 bits depth only)
- linux - intel drv 2.2.1 - partial EXA (32 bits only) (missing some text unfortunately see below)

So what doesn't works yet:
- Anything that's related to 3d.
- tiled surfaces.
- some text in EXA since driver is using 3d engine to do some 2d stuff.
- GART, only faked at the moment.
- Windows guests when using intel drivers.
- VESA emulation.
- better switch back to VGA mode (corrupted background color ATM).

if you want to try the card, just apply the patch in attachment, recompile, and start qemu using your usual command line and adding -x3100. make sure you are using a 32 bits color depth in your linux guest, and by default Xorg Intel driver will use EXA; to switch to XAA, add in your xorg.conf near the intel driver declaration:

Option "AccelMethod" "XAA"

There's a lots to be done, and the code need also cleanup (using correct types, remove some ugly macros, remove bugs, etc), hence I appreciate any encouragement, comments and/or patches ;)

Signature · 1 line
Vincent
Makefile.target +1 -0
index 9c83733..f813daa 100644
@@ -535,6 +535,7 @@ OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
 OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
 OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
 OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o
+OBJS+= x3100_debug.o x3100_vga.o x3100_gtt.o x3100_fb.o x3100_mi.o x3100_regs.o x3100.o
 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
 endif
 ifeq ($(TARGET_BASE_ARCH), ppc)
hw/pc.c +16 -1
index 2a569c7..03a6d1a 100644
@@ -706,6 +706,7 @@ static void pc_init1(int ram_size, int vga_ram_size,
     char buf[1024];
     int ret, linux_boot, i;
     ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
+    ram_addr_t x3100_ram_addr = 0;
     int bios_size, isa_bios_size, vga_bios_size;
     PCIBus *pci_bus;
     int piix3_devfn = -1;
@@ -753,7 +754,13 @@ static void pc_init1(int ram_size, int vga_ram_size,
     cpu_register_physical_memory(0, ram_size, ram_addr);
 
     /* allocate VGA RAM */
-    vga_ram_addr = qemu_ram_alloc(vga_ram_size);
+
+    if (x3100_enabled) {
+       vga_ram_addr = qemu_ram_alloc(vga_ram_size - X3100_RAM_SIZE);
+       x3100_ram_addr = qemu_ram_alloc(X3100_RAM_SIZE);
+    }
+    else
+       vga_ram_addr = qemu_ram_alloc(vga_ram_size);
 
     /* BIOS load */
     if (bios_name == NULL)
@@ -872,6 +879,14 @@ static void pc_init1(int ram_size, int vga_ram_size,
                             vga_ram_addr, vga_ram_size);
         else
             fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
+    } else if (x3100_enabled) {
+	if (pci_enabled)
+            pci_x3100_init(pci_bus, ds, phys_ram_base + vga_ram_addr,
+                           vga_ram_addr, vga_ram_size,
+                           phys_ram_base + x3100_ram_addr, x3100_ram_addr,
+	                   x3100_debug);
+        else
+            fprintf(stderr, "%s: x3100: no PCI bus\n", __FUNCTION__);
     } else {
         if (pci_enabled) {
             pci_vga_init(pci_bus, ds, phys_ram_base + vga_ram_addr,
hw/pc.h +7 -0
index 9f83050..d91407f 100644
@@ -113,6 +113,8 @@ int piix4_init(PCIBus *bus, int devfn);
 #define VGA_RAM_SIZE (9 * 1024 * 1024)
 #endif
 
+#define X3100_RAM_SIZE (128 * 1024 * 1024)
+
 int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
                  unsigned long vga_ram_offset, int vga_ram_size);
 int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
@@ -123,6 +125,11 @@ int isa_vga_mm_init(DisplayState *ds, uint8_t *vga_ram_base,
                     target_phys_addr_t vram_base, target_phys_addr_t ctrl_base,
                     int it_shift);
 
+int pci_x3100_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
+                   unsigned long vga_ram_offset, int vga_ram_size,
+                   uint8_t *x3100_ram_base, unsigned long x3100_ram_offset,
+                   int debug);
+
 /* cirrus_vga.c */
 void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
                          unsigned long vga_ram_offset, int vga_ram_size);
hw/pci.h +2 -0
index e870987..47a4e67 100644
@@ -17,7 +17,9 @@ typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
 
 #define PCI_ADDRESS_SPACE_MEM		0x00
 #define PCI_ADDRESS_SPACE_IO		0x01
+#define PCI_ADDRESS_SPACE_MEM64		0x04
 #define PCI_ADDRESS_SPACE_MEM_PREFETCH	0x08
+#define PCI_ADDRESS_SPACE_MEM64_PREFETCH 0x0c
 
 typedef struct PCIIORegion {
     uint32_t addr; /* current PCI mapping address. -1 means not mapped */
hw/x3100.c new file +295 -0

295 lines not on this page · raw message

hw/x3100.h new file +155 -0

155 lines not on this page · raw message

hw/x3100_debug.c new file +46 -0

46 lines not on this page · raw message

hw/x3100_fb.c new file +106 -0

106 lines not on this page · raw message

hw/x3100_gtt.c new file +63 -0

63 lines not on this page · raw message

hw/x3100_mi.c new file +766 -0

766 lines not on this page · raw message

hw/x3100_mi.h new file +116 -0

116 lines not on this page · raw message

hw/x3100_regs.c new file +647 -0

647 lines not on this page · raw message

hw/x3100_regs.h new file +206 -0

206 lines not on this page · raw message

hw/x3100_vga.c new file +228 -0

228 lines not on this page · raw message

sysemu.h +2 -0
index 0f18e04..fe6baf7 100644
@@ -76,6 +76,8 @@ void do_info_slirp(void);
 extern int ram_size;
 extern int bios_size;
 extern int cirrus_vga_enabled;
+extern int x3100_enabled;
+extern int x3100_debug;
 extern int vmsvga_enabled;
 extern int graphic_width;
 extern int graphic_height;
vl.c +15 -0
index 82f84db..b848873 100644
@@ -183,6 +183,8 @@ int vm_running;
 static int rtc_utc = 1;
 static int rtc_date_offset = -1; /* -1 means no change */
 int cirrus_vga_enabled = 1;
+int x3100_enabled = 0;
+int x3100_debug = 0;
 int vmsvga_enabled = 0;
 #ifdef TARGET_SPARC
 int graphic_width = 1024;
@@ -7713,6 +7715,7 @@ static void help(int exitcode)
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs Extensions\n"
            "                (default is CL-GD5446 PCI VGA)\n"
+           "-x3100          simulate a x3100 graphic card\n"
            "-no-acpi        disable ACPI\n"
 #endif
 #ifdef CONFIG_CURSES
@@ -7805,6 +7808,8 @@ enum {
     QEMU_OPTION_vmsvga,
     QEMU_OPTION_g,
     QEMU_OPTION_std_vga,
+    QEMU_OPTION_x3100,
+    QEMU_OPTION_x3100_debug,
     QEMU_OPTION_echr,
     QEMU_OPTION_monitor,
     QEMU_OPTION_serial,
@@ -7904,6 +7909,8 @@ const QEMUOption qemu_options[] = {
 #endif
     { "localtime", 0, QEMU_OPTION_localtime },
     { "std-vga", 0, QEMU_OPTION_std_vga },
+    { "x3100", 0, QEMU_OPTION_x3100 },
+    { "x3100-dbg", 0, QEMU_OPTION_x3100_debug },
     { "echr", HAS_ARG, QEMU_OPTION_echr },
     { "monitor", HAS_ARG, QEMU_OPTION_monitor },
     { "serial", HAS_ARG, QEMU_OPTION_serial },
@@ -8598,6 +8605,14 @@ int main(int argc, char **argv)
                 cirrus_vga_enabled = 0;
                 vmsvga_enabled = 0;
                 break;
+            case QEMU_OPTION_x3100:
+                cirrus_vga_enabled = 0;
+                x3100_enabled = 1;
+		vga_ram_size += X3100_RAM_SIZE;
+                break;
+	    case QEMU_OPTION_x3100_debug:
+	        x3100_debug = 1;
+		break;
             case QEMU_OPTION_g:
                 {
                     const char *p;
#1 lore raw

Hi Vincent,

did you continue on this great undertaking? Maybe you have a new version of the patch already implementing some more bits?

I specifically ask if you have a new version to avoid duplicate work, as I consider getting into this to get smoother graphic for my Qemu VM instances :-)

Yours,
René

Quoted 40 lines · Vincent Hanquez

Hello QEMU ML,

I'm please to announce my qemu x3100 project. The ultimate goal is fully emulating an intel x3100 graphic card (also known as GMA965), to be able to hopefully support 3D in qemu guests (and any user of qemu code base).

However, the emulation is not complete yet; This is a long task, and lots of things need to be done, fixed and better integrated. I've started a month and a half, and at this point I think it would be useful to share it to the qemu mailing list, since it's got some basic features done, maybe people will be interested in helping ;)

So what does works ?
- VGA mode :)
- linux - intel drv 2.2.1 - non accelerated (32 bits depth only)
- linux - intel drv 2.2.1 - XAA acceleration (32 bits depth only)
- linux - intel drv 2.2.1 - partial EXA (32 bits only) (missing some text unfortunately see below)

So what doesn't works yet:
- Anything that's related to 3d.
- tiled surfaces.
- some text in EXA since driver is using 3d engine to do some 2d stuff.
- GART, only faked at the moment.
- Windows guests when using intel drivers.
- VESA emulation.
- better switch back to VGA mode (corrupted background color ATM).

if you want to try the card, just apply the patch in attachment, recompile, and start qemu using your usual command line and adding -x3100. make sure you are using a 32 bits color depth in your linux guest, and by default Xorg Intel driver will use EXA; to switch to XAA, add in your xorg.conf near the intel driver declaration:

Option "AccelMethod" "XAA"

There's a lots to be done, and the code need also cleanup (using correct types, remove some ugly macros, remove bugs, etc), hence I appreciate any encouragement, comments and/or patches ;)

Signature · 2 lines
 René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
 http://exactcode.de | http://t2-project.org | http://rene.rebe.name
#2 lore raw
Quoted 8 lines · René Rebe

Hi Vincent,

did you continue on this great undertaking? Maybe you have a new version of the patch already implementing some more bits?

I specifically ask if you have a new version to avoid duplicate work, as I consider getting into this to get smoother graphic for my Qemu VM instances :-)

Hi René,

i've got a slightly newer version; mainly with few bugfixes around 2d mode, a stubbed 3d instruction decoder.

however the main problem which i'm kind of stuck on, is the programmed units (which is the most important 3d part), which involve having a x3100 assembly decoder & interpreter. i don't believe this part is hard, but the question is what to do with the instructions at this point :)

in the Intel driver, you can find thoses programs in file with extensions g4a (assembly mnemonics) and g4b (encoded version).

anyhow, I can send you an updated version if you're interested, and i'll be glad to discuss more about it (probably offlist to not bore qemu's people).

Cheers,

Signature · 1 line
Vincent
#3 lore raw

That's very interesting undertaking indeed.

I always dreamt of playing 3D games in VMs. And I hope, that with the help of your project, in may become a reality.

I don't know if it's possible to achieve good performance with emulated 3D hardware - to the point where 3D games would run.

Signature · 1 line
-Alexey Eromenko "Technologov"
#4 lore raw
Quoted 8 lines · Alexey Eremenko

That's very interesting undertaking indeed.

I always dreamt of playing 3D games in VMs. And I hope, that with the help of your project, in may become a reality.

I don't know if it's possible to achieve good performance with emulated 3D hardware - to the point where 3D games would run.

From the performance point of few I doubt it will yield performance to run 3D games. For such "high-performance" demands some dedicated "para-virtualized" direct 3D command passing would be required, there already where some attempts to do so.

I'd like some decent emulated hardware nonetheless, mostly for OS development, and probably for the nowadays common desktop 3D effects that I hope the Intel GMA emulation could reach useful performance.

Yours,

Signature · 2 lines
 René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
 http://exactcode.de | http://t2-project.org | http://rene.rebe.nam
#5 lore raw
In reply to Alexey Eremenko
Quoted 7 lines · Alexey Eremenko

That's very interesting undertaking indeed.

I always dreamt of playing 3D games in VMs. And I hope, that with the help of your project, in may become a reality.

I don't know if it's possible to achieve good performance with emulated 3D hardware - to the point where 3D games would run.

I can't predict about performance. I can't even predict about the total feasibility to be honest.

Performance depends on how the 3d operations can be offloaded to actual 3d chips. for example, having a "translator" from the intel 3d operation to OpenGL. or maybe something more feasible, to Gallium.

I'll open a public git repository based on my private one if people are interested in working on the card emulation. however people should not expect to be end-user (or testing) material anytime soon. not that i want to scare people off ;)

Cheers,

Signature · 1 line
Vincent
#6 lore raw
Quoted 12 lines · Vincent Hanquez
Quoted 7 lines · Alexey Eremenko

That's very interesting undertaking indeed.

I always dreamt of playing 3D games in VMs. And I hope, that with the help of your project, in may become a reality.

I don't know if it's possible to achieve good performance with emulated 3D hardware - to the point where 3D games would run.

I can't predict about performance. I can't even predict about the total feasibility to be honest.

Quoted 8 lines

Performance depends on how the 3d operations can be offloaded to actual 3d chips. for example, having a "translator" from the intel 3d operation to OpenGL. or maybe something more feasible, to Gallium.

I'll open a public git repository based on my private one if people are interested in working on the card emulation. however people should not expect to be end-user (or testing) material anytime soon. not that i want to scare people off ;)

Could you please do that? I'd be really interested in getting to work on that soon.

Thank you,

Alex

#7 lore raw
Quoted 4 lines · Alexander Graf

Could you please do that? I'd be really interested in getting to work on that soon.

Thank you,

it's finally available at git://git.snarc.org/x3100.git

it's totally rebased on top of today's head, on top of qemu at
git://git.kernel.dk/qemu.git, so the x3100 history is gone (not really interesting tho), but it's much easier for me to track newer versions.

sorry for the delay,

Signature · 1 line
Vincent