SUPDrvSem.cpp revision 34281ca49352399191a51f929cc00801b370ee74
/* $Revision$ */
/** @file
* VBoxDrv - The VirtualBox Support Driver - Common OS agnostic.
*/
/*
* Copyright (C) 2006-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_SUP_DRV
#define SUPDRV_AGNOSTIC
#include "SUPDrvInternal.h"
/** @todo trim this down. */
#include <iprt/handletable.h>
#include <iprt/semaphore.h>
#include <iprt/spinlock.h>
/**
* Destructor for objects created by SUPSemEventCreate.
*
* @param pvObj The object handle.
* @param pvUser1 The IPRT event handle.
* @param pvUser2 NULL.
*/
{
}
{
int rc;
/*
* Input validation.
*/
/*
* Create the event semaphore object.
*/
if (RT_SUCCESS(rc))
{
void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT, supR0SemEventDestructor, hEventReal, NULL);
if (pvObj)
{
if (RT_SUCCESS(rc))
{
return VINF_SUCCESS;
}
}
else
}
return rc;
}
{
/*
* Input validation.
*/
if (hEvent == NIL_SUPSEMEVENT)
return VINF_SUCCESS;
return VERR_INVALID_HANDLE;
/*
* Do the job.
*/
if (!pObj)
return VERR_INVALID_HANDLE;
}
{
int rc;
/*
* Input validation.
*/
return VERR_INVALID_HANDLE;
pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
if (!pObj)
return VERR_INVALID_HANDLE;
/*
* Do the job.
*/
return rc;
}
static int supR0SemEventWaitEx(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t fFlags, uint64_t uTimeout)
{
int rc;
/*
* Input validation.
*/
return VERR_INVALID_HANDLE;
pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT);
if (!pObj)
return VERR_INVALID_HANDLE;
/*
* Do the job.
*/
return rc;
}
{
uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_UNINTERRUPTIBLE;
if (cMillies == RT_INDEFINITE_WAIT)
}
SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
{
uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
if (cMillies == RT_INDEFINITE_WAIT)
}
SUPDECL(int) SUPSemEventWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t uNsTimeout)
{
uint32_t fFlags = RTSEMWAIT_FLAGS_ABSOLUTE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
}
SUPDECL(int) SUPSemEventWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t cNsTimeout)
{
uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
}
{
return RTSemEventGetResolution();
}
/**
* Destructor for objects created by SUPSemEventMultiCreate.
*
* @param pvObj The object handle.
* @param pvUser1 The IPRT event handle.
* @param pvUser2 NULL.
*/
{
}
{
int rc;
/*
* Input validation.
*/
/*
* Create the event semaphore object.
*/
if (RT_SUCCESS(rc))
{
void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT_MULTI, supR0SemEventMultiDestructor, hEventMultReal, NULL);
if (pvObj)
{
if (RT_SUCCESS(rc))
{
return VINF_SUCCESS;
}
}
else
}
return rc;
}
{
/*
* Input validation.
*/
if (hEventMulti == NIL_SUPSEMEVENTMULTI)
return VINF_SUCCESS;
return VERR_INVALID_HANDLE;
/*
* Do the job.
*/
pObj = (PSUPDRVOBJ)RTHandleTableFreeWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
if (!pObj)
return VERR_INVALID_HANDLE;
}
{
int rc;
/*
* Input validation.
*/
return VERR_INVALID_HANDLE;
pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
if (!pObj)
return VERR_INVALID_HANDLE;
/*
* Do the job.
*/
return rc;
}
{
int rc;
/*
* Input validation.
*/
return VERR_INVALID_HANDLE;
pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
if (!pObj)
return VERR_INVALID_HANDLE;
/*
* Do the job.
*/
return rc;
}
static int supR0SemEventMultiWaitEx(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t fFlags, uint64_t uTimeout)
{
int rc;
/*
* Input validation.
*/
return VERR_INVALID_HANDLE;
pObj = (PSUPDRVOBJ)RTHandleTableLookupWithCtx(pSession->hHandleTable, h32, SUPDRV_HANDLE_CTX_EVENT_MULTI);
if (!pObj)
return VERR_INVALID_HANDLE;
/*
* Do the job.
*/
return rc;
}
SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
{
uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_UNINTERRUPTIBLE;
if (cMillies == RT_INDEFINITE_WAIT)
}
SUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
{
uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
if (cMillies == RT_INDEFINITE_WAIT)
}
SUPDECL(int) SUPSemEventMultiWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout)
{
uint32_t fFlags = RTSEMWAIT_FLAGS_ABSOLUTE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
}
SUPDECL(int) SUPSemEventMultiWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout)
{
uint32_t fFlags = RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_NANOSECS | RTSEMWAIT_FLAGS_INTERRUPTIBLE;
}
{
return RTSemEventMultiGetResolution();
}