#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"
#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);
+++ /dev/null
-/*********************************************************
- * 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)
-{
-}
* 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"
*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;
}
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;
}
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;
}
* 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"
#else // VMKERNEL
int retval;
VMCIResource *resource;
- extern int VMCI_SendDatagram(VMCIDatagram *);
ASSERT(VMCI_HasGuestDevice());
* 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"
static void VMCIDoorbellFreeCB(void *clientData);
static int VMCIDoorbellReleaseCB(void *clientData);
static void VMCIDoorbellDelayedDispatchCB(void *data);
-extern int VMCI_SendDatagram(VMCIDatagram *);
/*
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
*********************************************************/
/*
- * 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.
* 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;
+
+
/*
*-----------------------------------------------------------------------------
*
}
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * 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));
+ }
+}
+
/*
*-----------------------------------------------------------------------------
#define VMCI_UTIL_NUM_RESOURCES 1
-Bool
-VMCIUtil_CheckHostCapabilities(void)
+static Bool
+VMCIUtilCheckHostCapabilities(void)
{
int result;
VMCIResourcesQueryMsg *msg;
}
-/*
- *-----------------------------------------------------------------------------
- *
- * 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);
-}
-
-
/*
*-----------------------------------------------------------------------------
*
{
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 //
-}
-
/*
*----------------------------------------------------------------------
}
}
}
+
+#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;
+}
#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_
* 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"
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];
#include "compat_version.h"
#include "compat_pci.h"
#include "vm_basic_types.h"
-#include "vmciGuestKernelIf.h"
+#include "vmciDriver.h"
/*
+++ /dev/null
-/*********************************************************
- * 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_
-
* 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"
+++ /dev/null
-/*********************************************************
- * 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__ */
* 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"
* 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"
* 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"
+++ /dev/null
-/*********************************************************
- * 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__
#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
}
+/*
+ *------------------------------------------------------------------------------
+ *
+ * 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);
#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_ */