Skip to contentSkip to conversation

: PCI Host/Proxy version 2.

PATCH In review Gianni Tedesco 2 participants 3 messages Jun 3, 2004 – Jun 4, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : PCI Host/Proxy version 2.

Hi,

Attached is the latest version of my PCI Host/Proxy patch. It allows you to use *real* PCI devices in qemu. Improvements over the last version include:

o Bugfixes
o Support for memory resources
o Support for ROM resources

Still to do:
o Support IRQ delivery (I need to dig up a kernel patch for this and get everything together).
o Test fully on real hardware
o Documentation (thats already a WIP)
o Logging support
o AGP support
o Support for PCI-DMA with patched guest OS (any win2k hackers out there wanna help on this?). Until this is done the code won't be ready for normal users
o Lock the PCI device

Right now this code is able to get my 3Com 905C running under Linux and win98, the interface can be configured and link status monitered, tho no tx/rx. You can see in this new screenshot:

	http://www.scaramanga.co.uk/stuff/qemu-pciproxy-0.2.png

Happy hacking kids ;)

Signature · 3 lines
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D
Makefile.target +1 -1
diff -urN qemu.orig/Makefile.target qemu/Makefile.target
@@ -232,7 +232,7 @@
 endif
 
 # must use static linking to avoid leaving stuff in virtual address space
-VL_OBJS=vl.o osdep.o block.o monitor.o pci.o
+VL_OBJS=vl.o osdep.o block.o monitor.o pci.o pciproxy.o
 
 ifeq ($(TARGET_ARCH), i386)
 # Hardware support
configure +5 -0
diff -urN qemu.orig/configure qemu/configure
@@ -390,6 +390,11 @@
 elif test -f "/usr/include/byteswap.h" ; then
   echo "#define HAVE_BYTESWAP_H 1" >> $config_h
 fi
+if test -f "/usr/include/sys/io.h"; then
+  echo "#define HAVE_SYS_IO_H 1" >> $config_h
+  echo "#define HAVE_IOPL 1" >> $config_h
+  echo "#define HAVE_IOPERM 1" >> $config_h
+fi
 if test "$gdbstub" = "yes" ; then
   echo "CONFIG_GDBSTUB=yes" >> $config_mak
   echo "#define CONFIG_GDBSTUB 1" >> $config_h
hw/pc.c +2 -0
diff -urN qemu.orig/hw/pc.c qemu/hw/pc.c
@@ -389,6 +389,8 @@
     if (pci_enabled) {
         i440fx_init();
         piix3_init();
+        if ( pciproxy_devpath )
+	    pciproxy_add_device(pciproxy_devpath);
     }
 
     /* init basic PC hardware */
hw/pciproxy.c +675 -0

675 lines not on this page · raw message

vl.c +6 -0
diff -urN qemu.orig/vl.c qemu/vl.c
@@ -130,6 +130,7 @@
 int pci_enabled = 0;
 int prep_enabled = 0;
 int rtc_utc = 1;
+char *pciproxy_devpath = NULL;
 
 /***********************************************************/
 /* x86 ISA bus support */
@@ -2018,6 +2019,7 @@
     QEMU_OPTION_pci,
     QEMU_OPTION_prep,
     QEMU_OPTION_localtime,
+    QEMU_OPTION_pciproxy,
 };
 
 typedef struct QEMUOption {
@@ -2068,6 +2070,7 @@
 #ifdef TARGET_PPC
     { "prep", 0, QEMU_OPTION_prep },
 #endif
+    { "pciproxy", HAS_ARG, QEMU_OPTION_pciproxy },
     { "localtime", 0, QEMU_OPTION_localtime },
     { NULL },
 };
@@ -2348,6 +2351,9 @@
             case QEMU_OPTION_localtime:
                 rtc_utc = 0;
                 break;
+            case QEMU_OPTION_pciproxy:
+		pciproxy_devpath = (char *)optarg;
+                break;
             }
         }
     }
vl.h +4 -0
diff -urN qemu.orig/vl.h qemu/vl.h
@@ -437,6 +437,10 @@
 void pci_pmac_init(void);
 void pci_ppc_bios_init(void);
 
+/* pciproxy.c */
+extern char *pciproxy_devpath;
+void pciproxy_add_device(char *devpath);
+
 /* vga.c */
 
 #define VGA_RAM_SIZE (4096 * 1024)
#1 lore raw

Hi,
Out of curiousity, will one be able to use this to get SD cards to work in linux? Ie fire up a win98 vm with the sd driver & access it over smbfs from linux?

Taras

#2 lore raw
Quoted 4 lines · Taras

Hi,
Out of curiousity, will one be able to use this to get SD cards to work in linux? Ie fire up a win98 vm with the sd driver & access it over smbfs from linux?

If the card doesn't use PCI-DMA (which seems unlikely) then yes. Although you may be lucky...

Until we can make patched OS kernels which notify qemu of PCI-DMA setup, then pciproxy will not work in all cases. I can do this for Linux, but someone with windows kernel skills needs to step forward in order to make this truly useful ;)

Signature · 3 lines
// Gianni Tedesco (gianni at scaramanga dot co dot uk)
lynx --source www.scaramanga.co.uk/scaramanga.asc | gpg --import
8646BE7D: 6D9F 2287 870E A2C9 8F60 3A3C 91B5 7669 8646 BE7D