]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
This is part 12 of a change to support Nested VMs.
authorVMware, Inc <>
Tue, 29 Mar 2011 18:49:42 +0000 (11:49 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 18:49:42 +0000 (11:49 -0700)
This part removes vmciUtil.* and vmciInt.h from the
guest driver and uses vmciDriver.* instead.  I'm
cheating here, by copying some of the old vmciUtil
code into vmciDriver.  The change after this will
unify more of the code.

Everything under common/guest is gone with this change.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
18 files changed:
open-vm-tools/modules/linux/shared/vmci_kernel_if.h
open-vm-tools/modules/linux/vmci/stubs.c [deleted file]
open-vm-tools/modules/linux/vmci/vmciContext.c
open-vm-tools/modules/linux/vmci/vmciDatagram.c
open-vm-tools/modules/linux/vmci/vmciDoorbell.c
open-vm-tools/modules/linux/vmci/vmciDriver.c [moved from open-vm-tools/modules/linux/vmci/vmciUtil.c with 71% similarity]
open-vm-tools/modules/linux/vmci/vmciDriver.h
open-vm-tools/modules/linux/vmci/vmciEvent.c
open-vm-tools/modules/linux/vmci/vmciGuestKernelIf.c
open-vm-tools/modules/linux/vmci/vmciGuestKernelIf.h [deleted file]
open-vm-tools/modules/linux/vmci/vmciHashtable.c
open-vm-tools/modules/linux/vmci/vmciInt.h [deleted file]
open-vm-tools/modules/linux/vmci/vmciQueuePair.c
open-vm-tools/modules/linux/vmci/vmciResource.c
open-vm-tools/modules/linux/vmci/vmciRoute.c
open-vm-tools/modules/linux/vmci/vmciUtil.h [deleted file]
open-vm-tools/modules/linux/vmci/vmci_drv.c
open-vm-tools/modules/linux/vmci/vmci_version.h

index eff077aefdc14b28ba97ca166eaece44d95caa7c..a7a64746e0eeb9e36d67b738d4071163c1517251 100644 (file)
 #endif
 
 #ifdef SOLARIS
+#  include <sys/ddi.h>
+#  include <sys/kmem.h>
 #  include <sys/mutex.h>
 #  include <sys/poll.h>
 #  include <sys/semaphore.h>
-#  include <sys/kmem.h>
+#  include <sys/sunddi.h>
+#  include <sys/types.h>
 #endif
 
 #include "vm_basic_types.h"
 #include "vmci_defs.h"
+#include "vmci_infrastructure.h"
 
 #if defined(VMKERNEL)
 #  include "list.h"
@@ -230,6 +234,39 @@ typedef struct VMCIHost {
 #endif
 } VMCIHost;
 
+/*
+ * Guest device port I/O.
+ */
+
+#if defined(linux)
+   typedef unsigned short int VMCIIoPort;
+   typedef int VMCIIoHandle;
+#elif defined(_WIN32)
+   typedef PUCHAR VMCIIoPort;
+   typedef int VMCIIoHandle;
+#elif defined(SOLARIS)
+   typedef uint8_t * VMCIIoPort;
+   typedef ddi_acc_handle_t VMCIIoHandle;
+#elif defined(__APPLE__)
+   typedef unsigned short int VMCIIoPort;
+   typedef void *VMCIIoHandle;
+#endif // __APPLE__
+
+void VMCI_ReadPortBytes(VMCIIoHandle handle, VMCIIoPort port, uint8 *buffer,
+                        size_t bufferLength);
+
+/*
+ * Guest device handle (FsCtx).  Not used on VMK, but we use an empty type to
+ * keep offsetchecker happy.
+ */
+
+typedef struct VMCIGuestDeviceHandle {
+#if !defined(VMKERNEL)
+   void *obj;
+   VMCIObjType objType;
+#endif // VMKERNEL
+} VMCIGuestDeviceHandle;
+
 
 void VMCI_InitLock(VMCILock *lock, char *name, VMCILockRank rank);
 void VMCI_CleanupLock(VMCILock *lock);
diff --git a/open-vm-tools/modules/linux/vmci/stubs.c b/open-vm-tools/modules/linux/vmci/stubs.c
deleted file mode 100644 (file)
index 304cff5..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*********************************************************
- * Copyright (C) 2011 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- *
- *********************************************************/
-
-/*
- * stubs.c
- *
- * Stubs for host functions still missing from the guest driver.
- *
- */
-
-#ifdef __linux__
-#  include "driver-config.h"
-#endif
-
-#include "vmci_kernel_if.h"
-#include "vmci_defs.h"
-#include "vmciContext.h"
-#include "vmciDoorbell.h"
-
-
-/*
- *------------------------------------------------------------------------------
- *
- *  VMCIUnsetNotify --
- *
- *     Stub.  Not called in the guest driver (yet).
- *
- *  Result:
- *     Always VMCI_ERROR_GENERIC.
- *
- *------------------------------------------------------------------------------
- */
-
-void
-VMCIUnsetNotify(VMCIContext *context)
-{
-}
index 40f216e9fe5d16824c1ff9c8ceefe4751610a39e..e91fbe90adc1c5af20afcc3b934ad64753bdd25e 100644 (file)
  *     Platform independent routines for VMCI calls.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
 #include "vmciKernelAPI.h"
 #include "vmciQueuePair.h"
 #include "vmciResource.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
@@ -929,7 +921,7 @@ VMCIContext_DequeueDatagram(VMCIContext *context, // IN
       *maxSize = dqEntry->dgSize;
       VMCI_ReleaseLock(&context->lock, flags);
       VMCI_DEBUG_LOG(4, (LGPFX"Caller's buffer should be at least "
-                         "(size=%"FMTSZ"d bytes).\n", *maxSize));
+                         "(size=%u bytes).\n", (uint32)*maxSize));
       return VMCI_ERROR_NO_MEM;
    }
 
@@ -1300,20 +1292,19 @@ VMCI_EXPORT_SYMBOL(VMCIContext_GetPrivFlags)
 VMCIPrivilegeFlags
 VMCIContext_GetPrivFlags(VMCIId contextID)  // IN
 {
-#if defined(VMX86_TOOLS)
-   return VMCI_NO_PRIVILEGE_FLAGS;
-#else // VMX86_TOOLS
-   VMCIPrivilegeFlags flags;
-   VMCIContext *context;
+   if (VMCI_HasHostDevice()) {
+      VMCIPrivilegeFlags flags;
+      VMCIContext *context;
 
-   context = VMCIContext_Get(contextID);
-   if (!context) {
-      return VMCI_LEAST_PRIVILEGE_FLAGS;
+      context = VMCIContext_Get(contextID);
+      if (!context) {
+         return VMCI_LEAST_PRIVILEGE_FLAGS;
+      }
+      flags = context->privFlags;
+      VMCIContext_Release(context);
+      return flags;
    }
-   flags = context->privFlags;
-   VMCIContext_Release(context);
-   return flags;
-#endif // VMX86_TOOLS
+   return VMCI_NO_PRIVILEGE_FLAGS;
 }
 
 
@@ -2329,35 +2320,34 @@ int
 VMCI_IsContextOwner(VMCIId contextID,   // IN
                     void *hostUser)     // IN
 {
-#if defined(VMX86_TOOLS)
-   return VMCI_ERROR_UNAVAILABLE;
-#else // VMX86_TOOLS
-   VMCIContext *context;
-   VMCIHostUser *user = (VMCIHostUser *)hostUser;
-   int retval;
+   if (VMCI_HasHostDevice()) {
+      VMCIContext *context;
+      VMCIHostUser *user = (VMCIHostUser *)hostUser;
+      int retval;
 
-   if (vmkernel) {
-      return VMCI_ERROR_UNAVAILABLE;
-   }
+      if (vmkernel) {
+         return VMCI_ERROR_UNAVAILABLE;
+      }
 
-   if (!hostUser) {
-      return VMCI_ERROR_INVALID_ARGS;
-   }
+      if (!hostUser) {
+         return VMCI_ERROR_INVALID_ARGS;
+      }
 
-   context = VMCIContext_Get(contextID);
-   if (!context) {
-      return VMCI_ERROR_NOT_FOUND;
-   }
+      context = VMCIContext_Get(contextID);
+      if (!context) {
+         return VMCI_ERROR_NOT_FOUND;
+      }
 
-   if (context->validUser) {
-      retval = VMCIHost_CompareUser(user, &context->user);
-   } else {
-      retval = VMCI_ERROR_UNAVAILABLE;
-   }
-   VMCIContext_Release(context);
+      if (context->validUser) {
+         retval = VMCIHost_CompareUser(user, &context->user);
+      } else {
+         retval = VMCI_ERROR_UNAVAILABLE;
+      }
+      VMCIContext_Release(context);
 
-   return retval;
-#endif // VMX86_TOOLS
+      return retval;
+   }
+   return VMCI_ERROR_UNAVAILABLE;
 }
 
 
index 641e4476bd2ad78ba3a01bf875080eea0fb34a5d..3fbfae9ba415505805f537537a4ca2b10778cff1 100644 (file)
  *    This file implements the VMCI Simple Datagram API on the host.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
 #include "vmciKernelAPI.h"
 #include "vmciResource.h"
 #include "vmciRoute.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
@@ -828,7 +820,6 @@ VMCIDatagramDispatchAsGuest(VMCIDatagram *dg)
 #else // VMKERNEL
    int retval;
    VMCIResource *resource;
-   extern int VMCI_SendDatagram(VMCIDatagram *);
 
    ASSERT(VMCI_HasGuestDevice());
 
index 5f6aacd835a74cc7b9fefa0c2f1432848ad40007..ca4cc4c1f8ab6a16d3999cfe5547142c9ea1c9bf 100644 (file)
  *    This file implements the VMCI doorbell API on the host.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
 #include "vmciKernelAPI.h"
 #include "vmciResource.h"
 #include "vmciRoute.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
@@ -127,7 +119,6 @@ static uint32 lastNotifyIdxReleased = PAGE_SIZE;
 static void VMCIDoorbellFreeCB(void *clientData);
 static int VMCIDoorbellReleaseCB(void *clientData);
 static void VMCIDoorbellDelayedDispatchCB(void *data);
-extern int VMCI_SendDatagram(VMCIDatagram *);
 
 
 /*
@@ -1189,7 +1180,7 @@ VMCI_ScanNotificationBitmap(uint8 *bitmap)
 VMCI_EXPORT_SYMBOL(VMCIDoorbell_Create)
 int
 VMCIDoorbell_Create(VMCIHandle *handle,            // IN
-                    uint32 flags,                  // I
+                    uint32 flags,                  // IN
                     VMCIPrivilegeFlags privFlags,  // IN
                     VMCICallback notifyCB,         // IN
                     void *clientData)              // IN
similarity index 71%
rename from open-vm-tools/modules/linux/vmci/vmciUtil.c
rename to open-vm-tools/modules/linux/vmci/vmciDriver.c
index 2ade9348cc5364fcabafc9f3ff1dea7a6c578cd5..9b980392292b30255832352d62afafcccb2c9ad6 100644 (file)
  *********************************************************/
 
 /*
- * vmciUtil.c
- *
- * Small utility function for allocating kernel memory and copying data.
+ * vmciDriver.c --
  *
+ *     VMCI initialization and ioctl handling.
  */
 
-#ifdef __linux__
-#  include "driver-config.h"
-#  define EXPORT_SYMTAB
-#  include <linux/module.h>
-#  include "compat_kernel.h"
-#  include "compat_slab.h"
-#  include "compat_interrupt.h"
-#endif
-
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
-#include "vm_atomic.h"
 #include "vmci_defs.h"
-#include "vmci_kernel_if.h"
-#include "vmciGuestKernelIf.h"
-#include "vmciInt.h"
+#include "vmci_infrastructure.h"
+#include "vmciCommonInt.h"
+#include "vmciContext.h"
 #include "vmciDatagram.h"
-#include "vmciUtil.h"
+#include "vmciDoorbell.h"
 #include "vmciEvent.h"
+#include "vmciHashtable.h"
 #include "vmciKernelAPI.h"
+#include "vmciQueuePair.h"
+#include "vmciResource.h"
+#if defined(VMKERNEL)
+#  include "vmciVmkInt.h"
+#  include "vm_libc.h"
+#  include "helper_ext.h"
+#  include "vmciDriver.h"
+#else
+#  include "vmciDriver.h"
+#endif
 
-#define LGPFX "VMCIUtil: "
-
-static void VMCIUtilCidUpdate(VMCIId subID, VMCI_EventData *eventData,
-                              void *clientData);
+#define LGPFX "VMCI: "
 
-static VMCIId ctxUpdateSubID = VMCI_INVALID_ID;
 static Atomic_uint32 vmContextID = { VMCI_INVALID_ID };
-static Atomic_uint32 vmciClientCount;
+
+#if !defined(VMX86_TOOLS)
+
+static VMCIContext *hostContext;
 
 
 /*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
  *
- * VMCIUtil_Init --
+ * VMCI_Init --
  *
- *      Subscribe to context id update event.
+ *      Initializes VMCI. This registers core hypercalls.
  *
  * Results:
- *      None.
+ *      VMCI_SUCCESS if successful, appropriate error code otherwise.
  *
  * Side effects:
  *      None.
  *
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
  */
 
-void
-VMCIUtil_Init(void)
+int
+VMCI_Init(void)
 {
+   int result;
+
+   result = VMCIResource_Init();
+   if (result < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to initialize VMCIResource (result=%d)",
+                    result));
+      goto errorExit;
+   }
+
+   result = VMCIContext_Init();
+   if (result < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to initialize VMCIContext (result=%d)",
+                    result));
+      goto resourceExit;
+   }
+
+   result = VMCIDatagram_Init();
+   if (result < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to initialize VMCIDatagram (result=%d)",
+                    result));
+      goto contextExit;
+   }
+
    /*
-    * We subscribe to the VMCI_EVENT_CTX_ID_UPDATE here so we can update the
-    * internal context id when needed.
+    * In theory, it is unsafe to pass an eventHnd of -1 to platforms which use
+    * it (VMKernel/Windows/Mac OS at the time of this writing). In practice we
+    * are fine though, because the event is never used in the case of the host
+    * context.
     */
-   if (VMCIEvent_Subscribe(VMCI_EVENT_CTX_ID_UPDATE, VMCI_FLAG_EVENT_NONE,
-                           VMCIUtilCidUpdate, NULL,
-                           &ctxUpdateSubID) < VMCI_SUCCESS) {
-      VMCI_WARNING((LGPFX"Failed to subscribe to event (type=%d).\n",
-                    VMCI_EVENT_CTX_ID_UPDATE));
+   result = VMCIContext_InitContext(VMCI_HOST_CONTEXT_ID,
+                                    VMCI_DEFAULT_PROC_PRIVILEGE_FLAGS,
+                                    -1, VMCI_VERSION, NULL, &hostContext);
+   if (result < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to initialize VMCIContext (result=%d)",
+                    result));
+      goto datagramExit;
    }
+
+   VMCIEvent_Init();
+   VMCIDoorbell_Init();
+
+   result = VMCIQPBroker_Init();
+   if (result < VMCI_SUCCESS) {
+      goto hostContextExit;
+   }
+
+   VMCI_LOG((LGPFX"Driver initialized."));
+   return VMCI_SUCCESS;
+
+  hostContextExit:
+   VMCIDoorbell_Exit();
+   VMCIEvent_Exit();
+   VMCIContext_ReleaseContext(hostContext);
+  datagramExit:
+   VMCIDatagram_Exit();
+  contextExit:
+   VMCIContext_Exit();
+  resourceExit:
+   VMCIResource_Exit();
+  errorExit:
+   return result;
 }
 
 
 /*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
  *
- * VMCIUtil_Exit --
+ * VMCI_Cleanup --
  *
- *      Cleanup
+ *      Cleanup the  VMCI module.
  *
  * Results:
  *      None.
@@ -99,20 +149,104 @@ VMCIUtil_Init(void)
  * Side effects:
  *      None.
  *
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------
  */
 
 void
-VMCIUtil_Exit(void)
+VMCI_Cleanup(void)
 {
-   if (VMCIEvent_Unsubscribe(ctxUpdateSubID) < VMCI_SUCCESS) {
-      VMCI_WARNING((LGPFX"Failed to unsubscribe to event (type=%d) with "
-                    "subscriber (ID=0x%x).\n", VMCI_EVENT_CTX_ID_UPDATE,
-                    ctxUpdateSubID));
+   VMCIDoorbell_Exit();
+   VMCIEvent_Exit();
+   VMCIContext_ReleaseContext(hostContext);
+   VMCIDatagram_Exit();
+   VMCIContext_Exit();
+   VMCIResource_Exit();
+   VMCIQPBroker_Exit();
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCI_DeviceGet --
+ *
+ *      API provided for compatibility with the guest vmci
+ *      API. Indicates the callers intention to use the device until
+ *      it calls VMCI_DeviceRelease().
+ *
+ * Results:
+ *      TRUE.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+VMCI_EXPORT_SYMBOL(VMCI_DeviceGet)
+Bool
+VMCI_DeviceGet(uint32 *apiVersion)
+{
+   if (*apiVersion > VMCI_KERNEL_API_VERSION) {
+      *apiVersion = VMCI_KERNEL_API_VERSION;
+      return FALSE;
    }
+   return TRUE;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCI_DeviceRelease --
+ *
+ *      API provided for compatibility with the guest vmci
+ *      API. Indicates that the caller is done using the VMCI device.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+VMCI_EXPORT_SYMBOL(VMCI_DeviceRelease)
+void
+VMCI_DeviceRelease(void)
+{
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMCI_SendDatagram --
+ *
+ *      Stub for guest VM to hypervisor call mechanism.
+ *
+ * Results:
+ *      Always VMCI_ERROR_GENERIC.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int
+VMCI_SendDatagram(VMCIDatagram *dg)
+{
+   return VMCI_ERROR_UNAVAILABLE;
+}
+
+#else // VMX86_TOOLS
+
+static Atomic_uint32 vmciClientCount;
+static VMCIId ctxUpdateSubID = VMCI_INVALID_ID;
+
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -151,6 +285,64 @@ VMCIUtilCidUpdate(VMCIId subID,               // IN:
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMCIUtil_Init --
+ *
+ *      Subscribe to context id update event.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+VMCIUtil_Init(void)
+{
+   /*
+    * We subscribe to the VMCI_EVENT_CTX_ID_UPDATE here so we can update the
+    * internal context id when needed.
+    */
+   if (VMCIEvent_Subscribe(VMCI_EVENT_CTX_ID_UPDATE, VMCI_FLAG_EVENT_NONE,
+                           VMCIUtilCidUpdate, NULL,
+                           &ctxUpdateSubID) < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to subscribe to event (type=%d).\n",
+                    VMCI_EVENT_CTX_ID_UPDATE));
+   }
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMCIUtil_Exit --
+ *
+ *      Cleanup
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+VMCIUtil_Exit(void)
+{
+   if (VMCIEvent_Unsubscribe(ctxUpdateSubID) < VMCI_SUCCESS) {
+      VMCI_WARNING((LGPFX"Failed to unsubscribe to event (type=%d) with "
+                    "subscriber (ID=0x%x).\n", VMCI_EVENT_CTX_ID_UPDATE,
+                    ctxUpdateSubID));
+   }
+}
+
 
 /*
  *-----------------------------------------------------------------------------
@@ -172,8 +364,8 @@ VMCIUtilCidUpdate(VMCIId subID,               // IN:
 
 #define VMCI_UTIL_NUM_RESOURCES 1
 
-Bool
-VMCIUtil_CheckHostCapabilities(void)
+static Bool
+VMCIUtilCheckHostCapabilities(void)
 {
    int result;
    VMCIResourcesQueryMsg *msg;
@@ -203,40 +395,6 @@ VMCIUtil_CheckHostCapabilities(void)
 }
 
 
-/*
- *-----------------------------------------------------------------------------
- *
- * VMCI_GetContextID --
- *
- *      Returns the context id.
- *
- * Results:
- *      Context id.
- *
- * Side effects:
- *      None.
- *
- *-----------------------------------------------------------------------------
- */
-
-VMCI_EXPORT_SYMBOL(VMCI_GetContextID)
-VMCIId
-VMCI_GetContextID(void)
-{
-   if (Atomic_Read(&vmContextID) == VMCI_INVALID_ID) {
-      uint32 result;
-      VMCIDatagram getCidMsg;
-      getCidMsg.dst =  VMCI_MAKE_HANDLE(VMCI_HYPERVISOR_CONTEXT_ID,
-                                        VMCI_GET_CONTEXT_ID);
-      getCidMsg.src = VMCI_ANON_SRC_HANDLE;
-      getCidMsg.payloadSize = 0;
-      result = VMCI_SendDatagram(&getCidMsg);
-      Atomic_Write(&vmContextID, result);
-   }
-   return Atomic_Read(&vmContextID);
-}
-
-
 /*
  *-----------------------------------------------------------------------------
  *
@@ -261,71 +419,13 @@ VMCI_CheckHostCapabilities(void)
 {
    Bool result = VMCIEvent_CheckHostCapabilities();
    result &= VMCIDatagram_CheckHostCapabilities();
-   result &= VMCIUtil_CheckHostCapabilities();
+   result &= VMCIUtilCheckHostCapabilities();
 
    VMCI_LOG((LGPFX"Host capability check: %s\n", result ? "PASSED" : "FAILED"));
 
    return result;
 }
 
-/*
- *----------------------------------------------------------------------
- *
- * VMCI_Version --
- *
- *     Returns the version of the VMCI guest driver.
- *
- * Results:
- *      Returns a version number.
- *
- * Side effects:
- *      None.
- *
- *----------------------------------------------------------------------
- */
-
-VMCI_EXPORT_SYMBOL(VMCI_Version)
-uint32
-VMCI_Version()
-{
-   return VMCI_VERSION_NUMBER;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * VMCI_InInterrupt --
- *
- *     Determines if we are running in tasklet/dispatch level or above.
- *
- * Results:
- *      TRUE if tasklet/dispatch or above, FALSE otherwise.
- *
- * Side effects:
- *      None.
- *
- *----------------------------------------------------------------------
- */
-
-Bool
-VMCI_InInterrupt()
-{
-#if defined(_WIN32)
-   return KeGetCurrentIrql() >= DISPATCH_LEVEL;
-#elif defined(__linux__)
-   return in_interrupt();
-#elif defined(SOLARIS)
-   return servicing_interrupt();   /* servicing_interrupt is not part of DDI. */
-#elif defined(__APPLE__)
-   /*
-    * All interrupt servicing is handled by IOKit functions, by the time the IOService
-    * interrupt handler is called we're no longer in an interrupt dispatch level.
-    */
-   return false;
-#endif //
-}
-
 
 /*
  *----------------------------------------------------------------------
@@ -561,3 +661,68 @@ VMCI_ReadDatagramsFromPort(VMCIIoHandle ioHandle,  // IN
       }
    }
 }
+
+#endif // VMX86_TOOLS
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * VMCI_GetContextID --
+ *
+ *    Returns the current context ID.  Note that since this is accessed only
+ *    from code running in the host, this always returns the host context ID.
+ *
+ * Results:
+ *    Context ID.
+ *
+ * Side effects:
+ *    None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+VMCI_EXPORT_SYMBOL(VMCI_GetContextID)
+VMCIId
+VMCI_GetContextID(void)
+{
+   if (VMCI_HasGuestDevice()) {
+      if (Atomic_Read(&vmContextID) == VMCI_INVALID_ID) {
+         uint32 result;
+         VMCIDatagram getCidMsg;
+         getCidMsg.dst =  VMCI_MAKE_HANDLE(VMCI_HYPERVISOR_CONTEXT_ID,
+                                           VMCI_GET_CONTEXT_ID);
+         getCidMsg.src = VMCI_ANON_SRC_HANDLE;
+         getCidMsg.payloadSize = 0;
+         result = VMCI_SendDatagram(&getCidMsg);
+         Atomic_Write(&vmContextID, result);
+      }
+      return Atomic_Read(&vmContextID);
+   } else if (VMCI_HasHostDevice()) {
+      return VMCI_HOST_CONTEXT_ID;
+   }
+   return VMCI_INVALID_ID;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCI_Version --
+ *
+ *     Returns the version of the VMCI driver.
+ *
+ * Results:
+ *      Returns a version number.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+VMCI_EXPORT_SYMBOL(VMCI_Version)
+uint32
+VMCI_Version()
+{
+   return VMCI_VERSION;
+}
index 731258d5a03d10fb041e3121f0d53b3b67ac08f1..cf18e9eac4f251bc8fe2c02d8459308759452eba 100644 (file)
 #ifdef _WIN32
 #  include "vmciLog.h"
 #else // _WIN32
-#ifdef VMKERNEL
+#if defined(VMKERNEL) && !defined(VMKERNEL_OFFSET_CHECKER)
+   /*
+    * LOGLEVEL_MODULE is defined in another header that gets included into the
+    * dummy file used by the offsetchecker, which causes it to barf on the
+    * redefinition.
+    */
 #  define LOGLEVEL_MODULE_LEN 0
 #  define LOGLEVEL_MODULE VMCIVMK
 #  include "log.h"
         int i = _level;                   \
         _VMCILOG _args ;                  \
      } while(FALSE)
-#  else
+#  else // VMX86_LOG
 #    define VMCI_DEBUG_LOG(_level, _args)
-#  endif
-#else
+#  endif // VMX86_LOG
+#else // VMKERNEL
 #  define VMCI_DEBUG_LEVEL 4
 #  define VMCI_DEBUG_LOG(_level, _args) \
    do {                                 \
          Log _args ;                    \
       }                                 \
    } while(FALSE)
-#endif
+#endif // VMKERNEL
 #define VMCI_LOG(_args) Log _args
 #define VMCI_WARNING(_args) Warning _args
 #endif // _WIN32
 
+
 int VMCI_Init(void);
 void VMCI_Cleanup(void);
 VMCIId VMCI_GetContextID(void);
+int VMCI_SendDatagram(VMCIDatagram *dg);
+
+#if defined(VMX86_TOOLS)
+void VMCIUtil_Init(void);
+void VMCIUtil_Exit(void);
+Bool VMCI_CheckHostCapabilities(void);
+void VMCI_ReadDatagramsFromPort(VMCIIoHandle ioHandle, VMCIIoPort dgInPort,
+                                uint8 *dgInBuffer, size_t dgInBufferSize);
+Bool VMCI_DeviceInUse(void);
+Bool VMCI_DeviceEnabled(void);
+#if defined(_WIN64)
+int VMCIDoSendDatagram(unsigned int dgSize, ULONG *dataPort, ULONG *resultPort,
+                       VMCIDatagram *dg);
+#endif // _WIN64
+#endif // VMX86_TOOLS
+
 
 #endif // _VMCI_DRIVER_H_
index 84e1952443b8d44738f51bbf8e2a999cd1f851c8..3319d159070ba9e80188c82711f5afbf534a424f 100644 (file)
  *     VMCI Event code for host and guests.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vmci_defs.h"
 #include "vmci_infrastructure.h"
 #include "vmciEvent.h"
 #include "vmciKernelAPI.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
@@ -69,21 +61,19 @@ static int VMCIEventRegisterSubscription(VMCISubscription *sub,
                                          void *callbackData);
 static VMCISubscription *VMCIEventUnregisterSubscription(VMCIId subID);
 
-/*
- * In the guest, VMCI events are dispatched from interrupt context, so
- * the locks need to be bottom half safe. In the host kernel, this
- * isn't so, and regular locks are used instead.
- */
 
-#ifdef VMX86_TOOLS
-#define VMCIEventInitLock(_lock, _name) VMCI_InitLock(_lock, _name, VMCI_LOCK_RANK_HIGHER_BH)
-#define VMCIEventGrabLock(_lock, _flags) VMCI_GrabLock_BH(_lock, _flags)
-#define VMCIEventReleaseLock(_lock, _flags) VMCI_ReleaseLock_BH(_lock, _flags)
-#else
-#define VMCIEventInitLock(_lock, _name) VMCI_InitLock(_lock, _name, VMCI_LOCK_RANK_HIGHER)
-#define VMCIEventGrabLock(_lock, _flags) VMCI_GrabLock(_lock, _flags)
-#define VMCIEventReleaseLock(_lock, _flags) VMCI_ReleaseLock(_lock, _flags)
-#endif
+#if defined(VMKERNEL)
+   /* VMK doesn't need BH locks, so use lower ranks. */
+#  define VMCIEventInitLock(_lock, _name) \
+   VMCI_InitLock(_lock, _name, VMCI_LOCK_RANK_HIGHER)
+#  define VMCIEventGrabLock(_lock, _flags)    VMCI_GrabLock(_lock, _flags)
+#  define VMCIEventReleaseLock(_lock, _flags) VMCI_ReleaseLock(_lock, _flags)
+#else // VMKERNEL
+#  define VMCIEventInitLock(_lock, _name) \
+   VMCI_InitLock(_lock, _name, VMCI_LOCK_RANK_HIGHER_BH)
+#  define VMCIEventGrabLock(_lock, _flags)    VMCI_GrabLock_BH(_lock, _flags)
+#  define VMCIEventReleaseLock(_lock, _flags) VMCI_ReleaseLock_BH(_lock, _flags)
+#endif // VMKERNEL
 
 
 static VMCIList subscriberArray[VMCI_EVENT_MAX];
index f57b0eb8032159b7a8c7b479f4e385fa89a087c7..6b3da469eb5cb004e2f3e312407894367ccaf686 100644 (file)
@@ -35,7 +35,7 @@
 #include "compat_version.h"
 #include "compat_pci.h"
 #include "vm_basic_types.h"
-#include "vmciGuestKernelIf.h"
+#include "vmciDriver.h"
 
 
 /*
diff --git a/open-vm-tools/modules/linux/vmci/vmciGuestKernelIf.h b/open-vm-tools/modules/linux/vmci/vmciGuestKernelIf.h
deleted file mode 100644 (file)
index 737008d..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*********************************************************
- * Copyright (C) 2007 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- *
- *********************************************************/
-
-/*
- * vmciGuestKernelIf.h -- 
- * 
- *      This file defines OS encapsulation helper functions that are
- *      needed only in VMCI guest kernel code. It must work for
- *      windows, solaris and linux kernel, ie. using defines
- *      where necessary.
- */ 
-#ifndef _VMCI_GUEST_KERNEL_IF_H_
-#define _VMCI_GUEST_KERNEL_IF_H_
-
-#if defined(_WIN32)
-#include <ntddk.h>
-#endif 
-
-#ifdef SOLARIS
-#  include <sys/ddi.h>
-#  include <sys/sunddi.h> 
-#  include <sys/types.h>
-#endif
-
-#include "vm_basic_types.h"
-#include "vmci_defs.h"
-
-#if defined(linux)
-  typedef unsigned short int VMCIIoPort;
-  typedef int VMCIIoHandle;
-#elif defined(_WIN32)
-  typedef PUCHAR VMCIIoPort;
-  typedef int VMCIIoHandle;
-#elif defined(SOLARIS)
-  typedef uint8_t * VMCIIoPort;
-  typedef ddi_acc_handle_t VMCIIoHandle;
-#elif defined(__APPLE__)
-  typedef unsigned short int VMCIIoPort;
-  typedef void *VMCIIoHandle;
-#endif // VMKERNEL
-
-void VMCI_ReadPortBytes(VMCIIoHandle handle, VMCIIoPort port, uint8 *buffer,
-                       size_t bufferLength);
-
-#endif // _VMCI_GUEST_KERNEL_IF_H_
-
index cdea16b8c0ba650b3c93cdd13a576c6c5cf64e73..46fa43e3ae554f0249fd9fbbf7bb0e34c7a24e78 100644 (file)
  *     our own implementation.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
 #include "vmci_infrastructure.h"
 #include "vmciCommonInt.h"
 #include "vmciHashtable.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
diff --git a/open-vm-tools/modules/linux/vmci/vmciInt.h b/open-vm-tools/modules/linux/vmci/vmciInt.h
deleted file mode 100644 (file)
index ce03fda..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********************************************************
- * Copyright (C) 2006 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- *
- *********************************************************/
-
-#ifndef __VMCI_INT_H__
-#define __VMCI_INT_H__
-
-#define INCLUDE_ALLOW_MODULE
-#include "includeCheck.h"
-
-#include "vm_basic_types.h"
-#include "vmci_call_defs.h"
-
-#define DODEBUGLOG(...) printk(KERN_DEBUG __VA_ARGS__)
-#define DOLOG(...) printk(KERN_INFO __VA_ARGS__)
-#define DOWARNING(...) printk(KERN_WARNING __VA_ARGS__)
-
-#ifdef VMCI_DEBUG
-#  define VMCI_DEBUG_LOG(_level, _args) DODEBUGLOG _args
-#else
-#  define VMCI_DEBUG_LOG(_level, _args)
-#endif // VMCI_DEBUG
-#define VMCI_LOG(_args) DOLOG _args
-#define VMCI_WARNING(_args) DOWARNING _args
-
-/*
- * Called by common code, hence the different naming convention.
- * XXX Should be in vmci.h.
- */
-int VMCI_SendDatagram(VMCIDatagram *dg);
-Bool VMCI_DeviceEnabled(void);
-
-#endif /* __VMCIINT_H__ */
index 99b6eaed587cc2488cd506485ecf46655a6cc3f4..1fa4ce35258161f31e3983fd2f349fc4f0bf150f 100644 (file)
  *    VMCI QueuePair API implementation in the host driver.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
 #include "vmciQueuePair.h"
 #include "vmciResource.h"
 #include "vmciRoute.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
index 2034b78cd1b9273fd2dd084a9efbc91f747d7e57..6192073cbc121dd589433d455c12b6af44cc980c 100644 (file)
  *     Implementation of the VMCI Resource Access Control API.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
 #include "vmciCommonInt.h"
 #include "vmciHashtable.h"
 #include "vmciResource.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
index 112337ee7eac05a8bb5b121580d0fae106871455..84d9c377a72bb690a615107cd642798042671179 100644 (file)
  *     Implementation of VMCI routing rules.
  */
 
-#if defined(__linux__) && !defined(VMKERNEL)
-#  include "driver-config.h"
-#  include "compat_kernel.h"
-#  include "compat_module.h"
-#endif // __linux__
 #include "vmci_kernel_if.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
 #include "vmciContext.h"
 #include "vmciKernelAPI.h"
 #include "vmciRoute.h"
-#ifdef VMX86_TOOLS
-#  include "vmciInt.h"
-#  include "vmciUtil.h"
-#elif defined(VMKERNEL)
+#if defined(VMKERNEL)
 #  include "vmciVmkInt.h"
 #  include "vm_libc.h"
 #  include "helper_ext.h"
diff --git a/open-vm-tools/modules/linux/vmci/vmciUtil.h b/open-vm-tools/modules/linux/vmci/vmciUtil.h
deleted file mode 100644 (file)
index 62dccbf..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*********************************************************
- * Copyright (C) 2006 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- *
- *********************************************************/
-
-/*
- * vmciUtil.h --
- *
- *      Helper functions.
- */
-
-#ifndef __VMCI_UTIL_H__
-#define __VMCI_UTIL_H__
-
-#define INCLUDE_ALLOW_MODULE
-#include "includeCheck.h"
-
-#include "vmciGuestKernelIf.h"
-#include "vmci_infrastructure.h"
-
-#define VMCI_MAJOR_VERSION_NUMBER   1
-#define VMCI_MINOR_VERSION_NUMBER   0
-#define VMCI_VERSION_NUMBER         \
-         ((VMCI_MAJOR_VERSION_NUMBER << 16) | (VMCI_MINOR_VERSION_NUMBER))
-
-typedef struct VMCIGuestDeviceHandle {
-   void *obj;
-   VMCIObjType objType;
-} VMCIGuestDeviceHandle;
-
-void VMCIUtil_Init(void);
-void VMCIUtil_Exit(void);
-Bool VMCIUtil_CheckHostCapabilities(void);
-Bool VMCI_CheckHostCapabilities(void);
-Bool VMCI_InInterrupt(void);
-void VMCI_ReadDatagramsFromPort(VMCIIoHandle ioHandle, VMCIIoPort dgInPort,
-                                uint8 *dgInBuffer, size_t dgInBufferSize);
-Bool VMCI_DeviceInUse(void);
-
-#endif //__VMCI_UTIL_H__
index 9a55afb65dad5586697464e48c67b544588b4d28..a0e24a1d1c3691accf475bd993582310b0fad785 100644 (file)
 #include "vmciContext.h"
 #include "vmciDatagram.h"
 #include "vmciDoorbell.h"
+#include "vmciDriver.h"
 #include "vmciEvent.h"
-#include "vmciInt.h"
 #include "vmciQueuePair.h"
 #include "vmciResource.h"
-#include "vmciUtil.h"
 
 #define LGPFX "VMCI: "
 #define VMCI_DEVICE_MINOR_NUM 0
@@ -1025,6 +1024,25 @@ process_bitmap(unsigned long data)
 }
 
 
+/*
+ *------------------------------------------------------------------------------
+ *
+ *  VMCIUnsetNotify --
+ *
+ *     Stub.  Not called in the guest driver (yet).
+ *
+ *  Result:
+ *     Always VMCI_ERROR_GENERIC.
+ *
+ *------------------------------------------------------------------------------
+ */
+
+void
+VMCIUnsetNotify(VMCIContext *context)
+{
+}
+
+
 module_init(vmci_init);
 module_exit(vmci_exit);
 MODULE_DEVICE_TABLE(pci, vmci_ids);
index 0f5aad60fced62d8686d449f41c562f017d700bf..68fac7e46fbe98eabfc9f3873209f2a96f5c5d60 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef _VMCI_VERSION_H_
 #define _VMCI_VERSION_H_
 
-#define VMCI_DRIVER_VERSION          9.1.9.0
-#define VMCI_DRIVER_VERSION_COMMAS   9,1,9,0
-#define VMCI_DRIVER_VERSION_STRING   "9.1.9.0"
+#define VMCI_DRIVER_VERSION          9.1.10.0
+#define VMCI_DRIVER_VERSION_COMMAS   9,1,10,0
+#define VMCI_DRIVER_VERSION_STRING   "9.1.10.0"
 
 #endif /* _VMCI_VERSION_H_ */