Index: /trunk/include/VBox/cdefs.h
===================================================================
--- /trunk/include/VBox/cdefs.h	(revision 35854)
+++ /trunk/include/VBox/cdefs.h	(revision 35855)
@@ -60,4 +60,6 @@
 #define IN_INTNET_R0
 #define IN_INTNET_R3
+#define IN_PCIRAW_R0
+#define IN_PCIRAW_R3
 #define IN_REM_R3
 #define IN_SUP_R0
@@ -145,4 +147,31 @@
 #endif
 
+/** @def IN_PCIRAW_R3
+ * Used to indicate whether we're inside the same link module as the Ring-3
+ * PCI passthrough support.
+ */
+/** @def PCIRAWR3DECL(type)
+ * PCI passthrough export or import declaration.
+ * @param   type    The return type of the function declaration.
+ */
+#ifdef IN_PCIRAW_R3
+# define PCIRAWR3DECL(type) DECLEXPORT(type) VBOXCALL
+#else
+# define PCIRAWR3DECL(type) DECLIMPORT(type) VBOXCALL
+#endif
+
+/** @def IN_PCIRAW_R0
+ * Used to indicate whether we're inside the same link module as the R0
+ * PCI passthrough support.
+ */
+/** @def PCIRAWR0DECL(type)
+ * PCI passthroug export or import declaration.
+ * @param   type    The return type of the function declaration.
+ */
+#ifdef IN_PCIRAW_R0
+# define PCIRAWR0DECL(type) DECLEXPORT(type) VBOXCALL
+#else
+# define PCIRAWR0DECL(type) DECLIMPORT(type) VBOXCALL
+#endif
 
 
Index: /trunk/include/VBox/sup.h
===================================================================
--- /trunk/include/VBox/sup.h	(revision 35854)
+++ /trunk/include/VBox/sup.h	(revision 35855)
@@ -1117,4 +1117,6 @@
     /** Multiple release event semaphore. */
     SUPDRVOBJTYPE_SEM_EVENT_MULTI,
+    /** Raw PCI device. */
+    SUPDRVOBJTYPE_RAW_PCI_DEVICE,
     /** The first invalid object type in this end. */
     SUPDRVOBJTYPE_END,
Index: /trunk/include/VBox/vmm/vmm.h
===================================================================
--- /trunk/include/VBox/vmm/vmm.h	(revision 35854)
+++ /trunk/include/VBox/vmm/vmm.h	(revision 35855)
@@ -376,4 +376,8 @@
     /** Call IntNetR0IfAbortWait(). */
     VMMR0_DO_INTNET_IF_ABORT_WAIT,
+
+    /** Forward call to the PCI driver */
+    VMMR0_DO_PCIRAW_REQ,
+
     /** The end of the R0 service operations. */
     VMMR0_DO_SRV_END,
@@ -456,3 +460,2 @@
 
 #endif
-
Index: /trunk/src/VBox/Devices/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Devices/Makefile.kmk	(revision 35854)
+++ /trunk/src/VBox/Devices/Makefile.kmk	(revision 35855)
@@ -1120,8 +1120,8 @@
  #
  ServicesR0_TEMPLATE  = VBoxR0
- ServicesR0_DEFS      = IN_INTNET_R0 IN_RT_R0
+ ServicesR0_DEFS      = IN_INTNET_R0 IN_RT_R0 $(if $(VBOX_WITH_PCI_PASSTHROUGH),IN_PCIRAW_R0,)
  ServicesR0_SOURCES   = \
- 	Network/SrvIntNetR0.cpp
-
+ 	Network/SrvIntNetR0.cpp \
+        $(if $(VBOX_WITH_PCI_PASSTHROUGH),Bus/SrvPciRawR0.cpp,)
 
  #
Index: /trunk/src/VBox/VMM/Makefile.kmk
===================================================================
--- /trunk/src/VBox/VMM/Makefile.kmk	(revision 35854)
+++ /trunk/src/VBox/VMM/Makefile.kmk	(revision 35855)
@@ -437,4 +437,7 @@
   VMMR0_DEFS    += VBOX_WITH_VMMR0_DISABLE_PREEMPTION
  endif
+ ifdef VBOX_WITH_PCI_PASSTHROUGH
+  VMMR0_DEFS    += VBOX_WITH_PCI_PASSTHROUGH IN_PCIRAW_R0
+ endif
  VMMR0_DEFS.darwin = VMM_R0_SWITCH_STACK
  VMMR0_DEFS.darwin.x86 = \
Index: /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 35854)
+++ /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 35855)
@@ -30,4 +30,7 @@
 #include "VMMInternal.h"
 #include <VBox/vmm/vm.h>
+#ifdef VBOX_WITH_PCI_PASSTHROUGH
+#include <VBox/vmm/pdmpci.h>
+#endif
 
 #include <VBox/vmm/gvmm.h>
@@ -39,4 +42,5 @@
 #include <VBox/version.h>
 #include <VBox/log.h>
+
 
 #include <iprt/asm-amd64-x86.h>
@@ -127,17 +131,26 @@
                         if (RT_SUCCESS(rc))
                         {
-                            rc = CPUMR0ModuleInit();
+#ifdef VBOX_WITH_PCI_PASSTHROUGH
+                            rc = PciRawR0Init();
+#endif
                             if (RT_SUCCESS(rc))
                             {
-                                LogFlow(("ModuleInit: returns success.\n"));
-                                return VINF_SUCCESS;
+                                rc = CPUMR0ModuleInit();
+                                if (RT_SUCCESS(rc))
+                                {
+                                    LogFlow(("ModuleInit: returns success.\n"));
+                                    return VINF_SUCCESS;
+                                }
                             }
+                            
+                            /* bail out */
+                            LogFlow(("ModuleTerm: returns %Rrc\n", rc));
+#ifdef VBOX_WITH_PCI_PASSTHROUGH
+                            PciRawR0Term();
+#endif
+#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
+                            PGMR0DynMapTerm();
+#endif
                         }
-
-                        /* bail out */
-                        LogFlow(("ModuleTerm: returns %Rrc\n", rc));
-#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
-                        PGMR0DynMapTerm();
-#endif
                     }
                     PGMDeregisterStringFormatTypes();
@@ -178,4 +191,11 @@
 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     PGMR0DynMapTerm();
+#endif
+        
+#ifdef VBOX_WITH_PCI_PASSTHROUGH
+    /*
+     * Terminate PCI passthrough service.
+     */
+    PciRawR0Term();
 #endif
     PGMDeregisterStringFormatTypes();
@@ -1155,4 +1175,13 @@
             return IntNetR0IfAbortWaitReq(pSession, (PINTNETIFABORTWAITREQ)pReqHdr);
 
+#ifdef VBOX_WITH_PCI_PASSTHROUGH
+        /*
+         * Requests to host PCI driver service.
+         */
+        case VMMR0_DO_PCIRAW_REQ:
+            if (u64Arg || !pReqHdr || !vmmR0IsValidSession(pVM, ((PPCIRAWSENDREQ)pReqHdr)->pSession, pSession) || idCpu != NIL_VMCPUID)
+                return VERR_INVALID_PARAMETER;
+            return PciRawR0ProcessReq(pSession, (PPCIRAWSENDREQ)pReqHdr);
+#endif
         /*
          * For profiling.
@@ -1178,5 +1207,5 @@
         default:
             /*
-             * We're returning VERR_NOT_SUPPORT here so we've got something else
+             * We're returning VERR_NOT_SUPPORT here s we've got something else
              * than -1 which the interrupt gate glue code might return.
              */
@@ -1527,3 +1556,2 @@
     RTAssertMsg2V(pszFormat, va);
 }
-
