semeventmulti-r0drv-nt.cpp revision 67c26773eca4a576449ffa8f289fa344fc7b8176
/* $Id$ */
/** @file
* innotek Portable Runtime - Semaphores, Ring-0 Driver, NT.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "the-nt-kernel.h"
#include <iprt/semaphore.h>
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* NT event semaphore.
*/
typedef struct RTSEMEVENTINTERNAL
{
/** Magic value (RTSEMEVENT_MAGIC). */
/** The NT Event object. */
/**
* NT mutex semaphore.
*/
typedef struct RTSEMMUTEXINTERNAL
{
/** Magic value (RTSEMMUTEX_MAGIC). */
#ifdef RT_USE_FAST_MUTEX
/** The fast mutex object. */
#else
/** The NT Mutex object. */
#endif
/**
* Wrapper for the linux semaphore structure.
*/
typedef struct RTSEMFASTMUTEXINTERNAL
{
/** Magic value (RTSEMFASTMUTEX_MAGIC). */
/** the NT fast mutex. */
{
Assert(sizeof(RTSEMEVENTINTERNAL) > sizeof(void *));
if (pEventInt)
{
return VINF_SUCCESS;
}
return VERR_NO_MEMORY;
}
{
/*
* Validate input.
*/
if (!pEventInt)
return VERR_INVALID_PARAMETER;
{
return VERR_INVALID_PARAMETER;
}
/*
* Invalidate it and signal the object just in case.
*/
return VINF_SUCCESS;
}
{
/*
* Validate input.
*/
if (!pEventInt)
return VERR_INVALID_PARAMETER;
if ( !pEventInt
{
AssertMsgFailed(("pEventInt->u32Magic=%RX32 pEventInt=%p\n", pEventInt ? pEventInt->u32Magic : 0, pEventInt));
return VERR_INVALID_PARAMETER;
}
/*
* Signal the event object.
*/
return VINF_SUCCESS;
}
{
/*
* Validate input.
*/
if (!pEventInt)
return VERR_INVALID_PARAMETER;
if ( !pEventInt
{
AssertMsgFailed(("pEventInt->u32Magic=%RX32 pEventInt=%p\n", pEventInt ? pEventInt->u32Magic : 0, pEventInt));
return VERR_INVALID_PARAMETER;
}
/*
* Wait for it.
*/
if (cMillies == RT_INDEFINITE_WAIT)
else
{
}
switch (rcNt)
{
case STATUS_SUCCESS:
return VINF_SUCCESS;
return VERR_SEM_DESTROYED;
case STATUS_ALERTED:
return VERR_INTERRUPTED;
case STATUS_USER_APC:
return VERR_INTERRUPTED;
case STATUS_TIMEOUT:
return VERR_TIMEOUT;
default:
AssertMsgFailed(("pEventInt->u32Magic=%RX32 pEventInt=%p: wait returned %lx!\n",
return VERR_INTERNAL_ERROR;
}
}
{
}
{
}
{
Assert(sizeof(RTSEMMUTEXINTERNAL) > sizeof(void *));
if (pMutexInt)
{
#ifdef RT_USE_FAST_MUTEX
#else
#endif
return VINF_SUCCESS;
}
return VERR_NO_MEMORY;
}
{
/*
* Validate input.
*/
if (!pMutexInt)
return VERR_INVALID_PARAMETER;
{
return VERR_INVALID_PARAMETER;
}
/*
* Invalidate it and signal the object just in case.
*/
return VINF_SUCCESS;
}
{
/*
* Validate input.
*/
if (!pMutexInt)
return VERR_INVALID_PARAMETER;
if ( !pMutexInt
{
AssertMsgFailed(("pMutexInt->u32Magic=%RX32 pMutexInt=%p\n", pMutexInt ? pMutexInt->u32Magic : 0, pMutexInt));
return VERR_INVALID_PARAMETER;
}
/*
* Get the mutex.
*/
#ifdef RT_USE_FAST_MUTEX
AssertMsg(cMillies == RT_INDEFINITE_WAIT, ("timeouts are not supported when using fast mutexes!\n"));
#else
if (cMillies == RT_INDEFINITE_WAIT)
else
{
}
switch (rcNt)
{
case STATUS_SUCCESS:
return VINF_SUCCESS;
return VERR_SEM_DESTROYED;
case STATUS_ALERTED:
return VERR_INTERRUPTED; /** @todo VERR_INTERRUPTED isn't correct anylonger. please fix r0drv stuff! */
case STATUS_USER_APC:
return VERR_INTERRUPTED; /** @todo VERR_INTERRUPTED isn't correct anylonger. please fix r0drv stuff! */
case STATUS_TIMEOUT:
return VERR_TIMEOUT;
default:
AssertMsgFailed(("pMutexInt->u32Magic=%RX32 pMutexInt=%p: wait returned %lx!\n",
return VERR_INTERNAL_ERROR;
}
#endif
return VINF_SUCCESS;
}
{
/*
* Validate input.
*/
if (!pMutexInt)
return VERR_INVALID_PARAMETER;
if ( !pMutexInt
{
AssertMsgFailed(("pMutexInt->u32Magic=%RX32 pMutexInt=%p\n", pMutexInt ? pMutexInt->u32Magic : 0, pMutexInt));
return VERR_INVALID_PARAMETER;
}
/*
* Release the mutex.
*/
#ifdef RT_USE_FAST_MUTEX
#else
#endif
return VINF_SUCCESS;
}
{
/*
* Allocate.
*/
if (!pFastInt)
return VERR_NO_MEMORY;
/*
* Initialize.
*/
return VINF_SUCCESS;
}
{
/*
* Validate.
*/
if (!pFastInt)
return VERR_INVALID_PARAMETER;
{
return VERR_INVALID_PARAMETER;
}
return VINF_SUCCESS;
}
{
/*
* Validate.
*/
if ( !pFastInt
{
AssertMsgFailed(("pFastInt->u32Magic=%RX32 pMutexInt=%p\n", pFastInt ? pFastInt->u32Magic : 0, pFastInt));
return VERR_INVALID_PARAMETER;
}
return VINF_SUCCESS;
}
{
/*
* Validate.
*/
if ( !pFastInt
{
AssertMsgFailed(("pFastInt->u32Magic=%RX32 pMutexInt=%p\n", pFastInt ? pFastInt->u32Magic : 0, pFastInt));
return VERR_INVALID_PARAMETER;
}
return VINF_SUCCESS;
}