#ifndef __VMCI_GUESTKERNELAPI_H__
#define __VMCI_GUESTKERNELAPI_H__
-/* VMCI guest kernel API version number. */
-#define VMCI_GUEST_KERNEL_API_VERSION 1
-
/* Macros to operate on the driver version number. */
#define VMCI_MAJOR_VERSION(v) (((v) >> 16) & 0xffff)
-#define VMCI_MINOT_VERSION(v) ((v) & 0xffff)
+#define VMCI_MINOR_VERSION(v) ((v) & 0xffff)
#define INCLUDE_ALLOW_MODULE
#include "includeCheck.h"
#include "vmci_defs.h"
#include "vmci_call_defs.h"
-#include "vmciQueue.h"
/*
* Note: APIs marked as compat are provided for compatibility with the host
VMCIId VMCI_GetContextID(void);
uint32 VMCI_Version(void);
+int VMCI_ContextID2HostVmID(VMCIId contextID, void *hostVmID,
+ size_t hostVmIDLen);
/* VMCI Event API. */
/* VMCI Doorbell API. */
-#if !defined(SOLARIS) && !defined(__APPLE__)
-
#define VMCI_FLAG_DELAYED_CB 0x01
typedef void (*VMCICallback)(void *clientData);
int VMCIDoorbell_Notify(VMCIHandle handle,
VMCIPrivilegeFlags privFlags);
-#endif // !defined(SOLARIS) && !defined(__APPLE__)
-
#endif /* !__VMCI_GUESTKERNELAPI_H__ */
#include "vmciUtil.h"
#include "circList.h"
+#if !defined(SOLARIS) && !defined(__APPLE__)
+
/*
* The VMCI Notify hash table provides two mappings:
* 1) one maps a given notification index in the bitmap to the
#if defined(__linux__)
EXPORT_SYMBOL(VMCIDoorbell_Notify);
#endif
+
+#else // defined(SOLARIS) || defined(__APPLE__)
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMCIDoorbell_Create/VMCIDoorbell_Destroy/VMCIDoorbell_Notify --
+ *
+ * The doorbell functions have yet to be implemented for Solaris
+ * and Mac OS X guest drivers.
+ *
+ * Results:
+ * VMCI_ERROR_UNAVAILABLE.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+int
+VMCIDoorbell_Create(VMCIHandle *handle, // IN
+ uint32 flags, // IN
+ VMCIPrivilegeFlags privFlags, // IN
+ VMCICallback notifyCB, // IN
+ void *clientData) // IN
+{
+ return VMCI_ERROR_UNAVAILABLE;
+}
+
+
+int
+VMCIDoorbell_Destroy(VMCIHandle handle) // IN
+{
+ return VMCI_ERROR_UNAVAILABLE;
+}
+
+
+int
+VMCIDoorbell_Notify(VMCIHandle handle, // IN
+ VMCIPrivilegeFlags privFlags) // IN
+{
+ return VMCI_ERROR_UNAVAILABLE;
+}
+
+#endif
#ifdef __linux__
# include "driver-config.h"
-# define EXPORT_SYMTAB
# include <asm/page.h>
# include <linux/module.h>
#elif defined(_WIN32)
detachMsg.hdr.src = VMCI_ANON_SRC_HANDLE;
detachMsg.hdr.payloadSize = sizeof entry->handle;
detachMsg.handle = entry->handle;
-
+
(void)VMCI_SendDatagram((VMCIDatagram *)&detachMsg);
}
/*
*-----------------------------------------------------------------------------
*/
-#ifdef __linux__
-EXPORT_SYMBOL(VMCIQueuePair_Alloc);
-#endif
-
int
VMCIQueuePair_Alloc(VMCIHandle *handle, // IN/OUT:
VMCIQueue **produceQ, // OUT:
*-----------------------------------------------------------------------------
*/
-#ifdef __linux__
-EXPORT_SYMBOL(VMCIQueuePair_AllocPriv);
-#endif
-
int
VMCIQueuePair_AllocPriv(VMCIHandle *handle, // IN/OUT:
VMCIQueue **produceQ, // OUT:
*-----------------------------------------------------------------------------
*/
-#ifdef __linux__
-EXPORT_SYMBOL(VMCIQueuePair_Detach);
-#endif
-
int
VMCIQueuePair_Detach(VMCIHandle handle) // IN:
{
2; /* One page each for the queue headers. */
ASSERT((produceSize || consumeSize) && produceQ && consumeQ);
-
+
if (VMCI_HANDLE_INVALID(handle)) {
VMCIId contextID = VMCI_GetContextID();
VMCIId oldRID = queuePairRID;
/* If we didn't remove the entry, this could change once we unlock. */
refCount = entry ? entry->refCount :
- 0xffffffff; /*
+ 0xffffffff; /*
* Value does not matter, silence the
* compiler.
*/
-
QueuePairList_Unlock();
# include "compat_interrupt.h"
#elif defined(_WIN32)
# ifndef WINNT_DDK
-# error This file only works with the NT ddk
+# error This file only works with the NT ddk
# endif // WINNT_DDK
# include <ntddk.h>
#elif defined(SOLARIS)
# include <sys/disp.h>
#elif defined(__APPLE__)
# include <IOKit/IOLib.h>
-#else
+#else
#error "platform not supported."
#endif //linux
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_LOG(("VMCIUtil: Failed to subscribe to event %d.\n",
+ VMCI_LOG(("VMCIUtil: Failed to subscribe to event %d.\n",
VMCI_EVENT_CTX_ID_UPDATE));
}
}
*
* VMCIUtil_Exit --
*
- * Cleanup
+ * Cleanup
*
* Results:
* None.
{
int result;
VMCIResourcesQueryMsg *msg;
- uint32 msgSize = sizeof(VMCIResourcesQueryHdr) +
+ uint32 msgSize = sizeof(VMCIResourcesQueryHdr) +
VMCI_UTIL_NUM_RESOURCES * sizeof(VMCI_Resource);
VMCIDatagram *checkMsg = VMCI_AllocKernelMem(msgSize, VMCI_MEMORY_NONPAGED);
return FALSE;
}
- checkMsg->dst = VMCI_MAKE_HANDLE(VMCI_HYPERVISOR_CONTEXT_ID,
+ checkMsg->dst = VMCI_MAKE_HANDLE(VMCI_HYPERVISOR_CONTEXT_ID,
VMCI_RESOURCES_QUERY);
checkMsg->src = VMCI_ANON_SRC_HANDLE;
checkMsg->payloadSize = msgSize - VMCI_DG_HEADERSIZE;
*
* VMCI_GetContextID --
*
- * Returns the context id.
+ * Returns the context id.
*
* Results:
* Context id.
*
* Returns the version of the VMCI guest driver.
*
- * Results:
+ * Results:
* Returns a version number.
*
* Side effects:
*
* Determines if we are running in tasklet/dispatch level or above.
*
- * Results:
+ * Results:
* TRUE if tasklet/dispatch or above, FALSE otherwise.
*
* Side effects:
* the callers intention to use the device until it calls
* VMCI_DeviceRelease().
*
- * Results:
+ * Results:
* TRUE if a valid VMCI device is present, FALSE otherwise.
*
* Side effects:
*
* Indicates that the caller is done using the VMCI device.
*
- * Results:
+ * Results:
* None.
*
* Side effects:
ASSERT(dgInBufferSize >= PAGE_SIZE);
VMCI_ReadPortBytes(ioHandle, dgInPort, dgInBuffer, currentDgInBufferSize);
- dg = (VMCIDatagram *)dgInBuffer;
+ dg = (VMCIDatagram *)dgInBuffer;
remainingBytes = currentDgInBufferSize;
-
+
while (dg->dst.resource != VMCI_INVALID_ID || remainingBytes > PAGE_SIZE) {
unsigned dgInSize;
-
+
/*
* When the input buffer spans multiple pages, a datagram can
- * start on any page boundary in the buffer.
+ * start on any page boundary in the buffer.
*/
if (dg->dst.resource == VMCI_INVALID_ID) {
}
dgInSize = VMCI_DG_SIZE_ALIGNED(dg);
-
+
if (dgInSize <= dgInBufferSize) {
int result;
* enough room for it and then we read the reminder of the
* datagram and possibly any following datagrams.
*/
-
+
if (dgInSize > remainingBytes) {
if (remainingBytes != currentDgInBufferSize) {
* the reminder of the datagram and possibly following
* calls into the following bytes.
*/
-
+
memmove(dgInBuffer, dgInBuffer + currentDgInBufferSize - remainingBytes,
remainingBytes);
- dg = (VMCIDatagram *)dgInBuffer;
+ dg = (VMCIDatagram *)dgInBuffer;
}
if (currentDgInBufferSize != dgInBufferSize) {
VMCI_ReadPortBytes(ioHandle, dgInPort, dgInBuffer + remainingBytes,
currentDgInBufferSize - remainingBytes);
}
-
+
/* We special case event datagrams from the hypervisor. */
- if (dg->src.context == VMCI_HYPERVISOR_CONTEXT_ID &&
+ if (dg->src.context == VMCI_HYPERVISOR_CONTEXT_ID &&
dg->dst.resource == VMCI_EVENT_HANDLER) {
result = VMCIEvent_Dispatch(dg);
} else {
VMCI_LOG(("Datagram with resource %d failed with err %x.\n",
dg->dst.resource, result));
}
-
+
/* On to the next datagram. */
dg = (VMCIDatagram *)((uint8 *)dg + dgInSize);
} else {
size_t bytesToSkip;
-
+
/*
* Datagram doesn't fit in datagram buffer of maximal size. We drop it.
*/
VMCI_LOG(("Failed to receive datagram of size %u.\n",
dgInSize));
-
+
bytesToSkip = dgInSize - remainingBytes;
if (currentDgInBufferSize != dgInBufferSize) {
currentDgInBufferSize = dgInBufferSize;
}
dg = (VMCIDatagram *)(dgInBuffer + bytesToSkip);
}
-
+
remainingBytes = (size_t) (dgInBuffer + currentDgInBufferSize - (uint8 *)dg);
-
+
if (remainingBytes < VMCI_DG_HEADERSIZE) {
/* Get the next batch of datagrams. */
-
+
VMCI_ReadPortBytes(ioHandle, dgInPort, dgInBuffer, currentDgInBufferSize);
dg = (VMCIDatagram *)dgInBuffer;
remainingBytes = currentDgInBufferSize;
{
return VMCI_NO_PRIVILEGE_FLAGS;
}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCI_ContextID2HostVmID --
+ *
+ * Provided for compatibility with the host VMCI API.
+ *
+ * Results:
+ * Returns VMCI_ERROR_UNAVAILABLE.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#ifdef __linux__
+EXPORT_SYMBOL(VMCI_ContextID2HostVmID);
+#endif
+
+int
+VMCI_ContextID2HostVmID(VMCIId contextID, // IN
+ void *hostVmID, // OUT
+ size_t hostVmIDLen) // IN
+{
+ return VMCI_ERROR_UNAVAILABLE;
+}