timer-r0drv-solaris.c revision 0dfc79e0666da4c8853deda18a14ebf5819d0d78
/* $Id$ */
/** @file
* IPRT - Timer, Ring-0 Driver, Solaris.
*/
/*
* Copyright (C) 2006-2007 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 *
*******************************************************************************/
#include "../the-solaris-kernel.h"
#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
# include <iprt/asm-amd64-x86.h>
#endif
#include <iprt/spinlock.h>
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* The internal representation of a Solaris timer handle.
*/
typedef struct RTTIMER
{
/** Magic.
* This is RTTIMER_MAGIC, but changes to something else before the timer
* is destroyed to indicate clearly that thread should exit. */
/** Flag indicating that the timer is suspended. */
uint8_t volatile fSuspended;
/** Run on all CPUs if set */
/** Whether the timer must run on a specific CPU or not. */
/** The CPU it must run on if fSpecificCpu is set. */
/** The nano second interval for repeating timers */
/** simple Solaris timer handle. */
/** global Solaris timer handle. */
/** The user callback. */
/** The argument for the user callback. */
void *pvUser;
} RTTIMER;
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** Validates that the timer is valid. */
#define RTTIMER_ASSERT_VALID_RET(pTimer) \
do \
{ \
} while (0)
/*
* Need a wrapper to get the PRTTIMER passed through
*/
{
}
RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, unsigned fFlags, PFNRTTIMER pfnTimer, void *pvUser)
{
/*
* Validate flags.
*/
if (!RTTIMER_FLAGS_ARE_VALID(fFlags))
return VERR_INVALID_PARAMETER;
if (vbi_revision_level < 2)
return VERR_NOT_SUPPORTED;
if ( (fFlags & RTTIMER_FLAGS_CPU_SPECIFIC)
return VERR_CPU_NOT_FOUND;
return VERR_NOT_SUPPORTED;
/*
* Allocate and initialize the timer handle.
*/
if (!pTimer)
return VERR_NO_MEMORY;
pTimer->fSuspended = true;
{
pTimer->fSpecificCpu = false;
}
else if (fFlags & RTTIMER_FLAGS_CPU_SPECIFIC)
{
pTimer->fSpecificCpu = true;
}
else
{
pTimer->fSpecificCpu = false;
}
return VINF_SUCCESS;
}
{
return VINF_SUCCESS;
/*
* Free the associated resources.
*/
return VINF_SUCCESS;
}
{
if (!pTimer->fSuspended)
return VERR_TIMER_ACTIVE;
pTimer->fSuspended = false;
{
pTimer->gtimer = vbi_gtimer_begin(rtTimerSolarisCallbackWrapper, pTimer, u64First, pTimer->interval);
return VERR_INVALID_PARAMETER;
}
else
{
int iCpu = VBI_ANY_CPU;
if (pTimer->fSpecificCpu)
pTimer->stimer = vbi_stimer_begin(rtTimerSolarisCallbackWrapper, pTimer, u64First, pTimer->interval, iCpu);
{
if (iCpu != VBI_ANY_CPU)
return VERR_CPU_OFFLINE;
return VERR_INVALID_PARAMETER;
}
}
return VINF_SUCCESS;
}
{
if (pTimer->fSuspended)
return VERR_TIMER_SUSPENDED;
pTimer->fSuspended = true;
{
}
{
}
return VINF_SUCCESS;
}
{
return vbi_timer_granularity();
}
{
return VERR_NOT_SUPPORTED;
}
{
return VERR_NOT_SUPPORTED;
}
RTDECL(bool) RTTimerCanDoHighResolution(void)
{
return true;
}