SUPDrvSem.c revision 36ebaddfec017eee7e82ee466c25de002cdc4231
/* $Revision$ */
/** @file
* VBoxDrv - The VirtualBox Support Driver - Common OS agnostic.
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* 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;
}
{
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;
}
SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
{
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;
}
/**
* 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;
}
SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
{
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) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
{
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;
}