diff --git a/host/ivshmem.cpp b/host/ivshmem.cpp index 387db44b..b6d81724 100644 --- a/host/ivshmem.cpp +++ b/host/ivshmem.cpp @@ -189,4 +189,31 @@ void * IVSHMEM::GetMemory() m_vectors = static_cast(map.vectors); return m_memory; +} + +HANDLE IVSHMEM::CreateVectorEvent(UINT16 vector) +{ + if (!m_initialized) + return INVALID_HANDLE_VALUE; + + HANDLE event = CreateEvent(NULL, TRUE, FALSE, NULL); + if (event == INVALID_HANDLE_VALUE) + { + DEBUG_ERROR("CreateEvent Failed: %d", GetLastError()); + return INVALID_HANDLE_VALUE; + } + + IVSHMEM_EVENT msg; + msg.event = event; + msg.singleShot = false; + msg.vector = vector; + + if (!DeviceIoControl(m_handle, IOCTL_IVSHMEM_REGISTER_EVENT, &msg, sizeof(IVSHMEM_EVENT), NULL, 0, NULL, NULL)) + { + DEBUG_ERROR("DeviceIoControl Failed: %d", GetLastError()); + CloseHandle(event); + return INVALID_HANDLE_VALUE; + } + + return event; } \ No newline at end of file diff --git a/host/ivshmem.h b/host/ivshmem.h index 9aef697a..aa1e683a 100644 --- a/host/ivshmem.h +++ b/host/ivshmem.h @@ -22,6 +22,7 @@ public: UINT16 GetPeerID(); UINT16 GetVectors(); void * GetMemory(); + HANDLE CreateVectorEvent(UINT16 vector); protected: