timer-r0drv-solaris.c revision 291970486c0aa5b533b1a507f34cb292f414ba68
ece9652d971886b99a269656ea4782319637e75avboxsync * IPRT - Timer, Ring-0 Driver, Solaris.
ece9652d971886b99a269656ea4782319637e75avboxsync * Copyright (C) 2006-2012 Oracle Corporation
ece9652d971886b99a269656ea4782319637e75avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
ece9652d971886b99a269656ea4782319637e75avboxsync * available from http://www.virtualbox.org. This file is free software;
ece9652d971886b99a269656ea4782319637e75avboxsync * you can redistribute it and/or modify it under the terms of the GNU
ece9652d971886b99a269656ea4782319637e75avboxsync * General Public License (GPL) as published by the Free Software
ece9652d971886b99a269656ea4782319637e75avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
ece9652d971886b99a269656ea4782319637e75avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
ece9652d971886b99a269656ea4782319637e75avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ece9652d971886b99a269656ea4782319637e75avboxsync * The contents of this file may alternatively be used under the terms
ece9652d971886b99a269656ea4782319637e75avboxsync * of the Common Development and Distribution License Version 1.0
ece9652d971886b99a269656ea4782319637e75avboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
ece9652d971886b99a269656ea4782319637e75avboxsync * VirtualBox OSE distribution, in which case the provisions of the
ece9652d971886b99a269656ea4782319637e75avboxsync * CDDL are applicable instead of those of the GPL.
ece9652d971886b99a269656ea4782319637e75avboxsync * You may elect to license modified versions of this file under the
ece9652d971886b99a269656ea4782319637e75avboxsync * terms and conditions of either the GPL or the CDDL or both.
e7f5b62e52275099a4d14501306063e23876b771vboxsync/*******************************************************************************
e7f5b62e52275099a4d14501306063e23876b771vboxsync* Header Files *
ece9652d971886b99a269656ea4782319637e75avboxsync*******************************************************************************/
ece9652d971886b99a269656ea4782319637e75avboxsync/*******************************************************************************
e7f5b62e52275099a4d14501306063e23876b771vboxsync* Structures and Typedefs *
e7f5b62e52275099a4d14501306063e23876b771vboxsync*******************************************************************************/
e7f5b62e52275099a4d14501306063e23876b771vboxsync * Single-CPU timer handle.
ece9652d971886b99a269656ea4782319637e75avboxsync /** Cyclic handler. */
ece9652d971886b99a269656ea4782319637e75avboxsync /** Cyclic time and interval representation. */
ece9652d971886b99a269656ea4782319637e75avboxsync /** Timer ticks. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync * Omni-CPU timer handle.
ece9652d971886b99a269656ea4782319637e75avboxsync /** Absolute timestamp of when the timer should fire next. */
ece9652d971886b99a269656ea4782319637e75avboxsync /** Array of timer ticks per CPU. Reinitialized when a CPU is online'd. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync * The internal representation of a Solaris timer handle.
e7f5b62e52275099a4d14501306063e23876b771vboxsynctypedef struct RTTIMER
e7f5b62e52275099a4d14501306063e23876b771vboxsync * This is RTTIMER_MAGIC, but changes to something else before the timer
e7f5b62e52275099a4d14501306063e23876b771vboxsync * is destroyed to indicate clearly that thread should exit. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** Flag indicating that the timer is suspended. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** Whether the timer must run on all CPUs or not. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** Whether the timer must run on a specific CPU or not. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** The CPU it must run on if fSpecificCpu is set. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** The nano second interval for repeating timers. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** Cyclic timer Id. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** @todo Make this a union unless we intend to support omni<=>single timers
e7f5b62e52275099a4d14501306063e23876b771vboxsync * conversions. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** Single-CPU timer handle. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** Omni-CPU timer handle. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** The user callback. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync /** The argument for the user callback. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync/*******************************************************************************
e7f5b62e52275099a4d14501306063e23876b771vboxsync* Defined Constants And Macros *
e7f5b62e52275099a4d14501306063e23876b771vboxsync*******************************************************************************/
e7f5b62e52275099a4d14501306063e23876b771vboxsync/** Validates that the timer is valid. */
1cc6d0ca9b70d90116a4fb8f7e60869cc98ad57cvboxsync AssertMsgReturn((pTimer)->u32Magic == RTTIMER_MAGIC, ("pTimer=%p u32Magic=%x expected %x\n", (pTimer), (pTimer)->u32Magic, RTTIMER_MAGIC), \
1cc6d0ca9b70d90116a4fb8f7e60869cc98ad57cvboxsync } while (0)
ece9652d971886b99a269656ea4782319637e75avboxsync * Callback wrapper for Omni-CPU and single-CPU timers.
ece9652d971886b99a269656ea4782319637e75avboxsync * @param pvArg Opaque pointer to the timer.
ece9652d971886b99a269656ea4782319637e75avboxsync * @remarks This will be executed in interrupt context but only at the specified
ece9652d971886b99a269656ea4782319637e75avboxsync * level i.e. CY_LOCK_LEVEL in our case. We -CANNOT- call into the
ece9652d971886b99a269656ea4782319637e75avboxsync * cyclic subsystem here, neither should pfnTimer().
e7f5b62e52275099a4d14501306063e23876b771vboxsync /* For specific periodic timers, we might fire on the wrong CPU between cyclic_add() and cyclic_bind().
e7f5b62e52275099a4d14501306063e23876b771vboxsync Ignore these shots while we are temporarily rebinding to the right CPU. */
e7f5b62e52275099a4d14501306063e23876b771vboxsync && pTimer->iCpu != RTMpCpuId()) /* ASSUMES: index == cpuid */
ece9652d971886b99a269656ea4782319637e75avboxsync /* Allow RTTimer to be restarted for one-shot timers. */
ece9652d971886b99a269656ea4782319637e75avboxsync uint64_t u64Tick = ++pTimer->pSingleTimer->u64Tick;
ece9652d971886b99a269656ea4782319637e75avboxsync uint64_t u64Tick = ++pTimer->pOmniTimer->au64Ticks[CPU->cpu_id];
e7f5b62e52275099a4d14501306063e23876b771vboxsync * Omni-CPU cyclic online event. This is called before the omni cycle begins to
e7f5b62e52275099a4d14501306063e23876b771vboxsync * fire on the specified CPU.
e7f5b62e52275099a4d14501306063e23876b771vboxsync * @param pvArg Opaque pointer to the timer.
e7f5b62e52275099a4d14501306063e23876b771vboxsync * @param pCpu Pointer to the CPU on which it will fire.
e7f5b62e52275099a4d14501306063e23876b771vboxsync * @param pCyclicHandler Pointer to a cyclic handler to add to the CPU
e7f5b62e52275099a4d14501306063e23876b771vboxsync * specified in @a pCpu.
e7f5b62e52275099a4d14501306063e23876b771vboxsync * @param pCyclicTime Pointer to the cyclic time and interval object.
e7f5b62e52275099a4d14501306063e23876b771vboxsync * @remarks We -CANNOT- call back into the cyclic subsystem here, we can however
e7f5b62e52275099a4d14501306063e23876b771vboxsync * block (sleep).
e7f5b62e52275099a4d14501306063e23876b771vboxsyncstatic void rtTimerSolOmniCpuOnline(void *pvArg, cpu_t *pCpu, cyc_handler_t *pCyclicHandler, cyc_time_t *pCyclicTime)
RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_t fFlags, PFNRTTIMER pfnTimer, void *pvUser)
return VERR_INVALID_PARAMETER;
return VERR_CPU_NOT_FOUND;
&& u64NanoInterval == 0)
return VERR_NOT_SUPPORTED;
&& u64NanoInterval == 0)
return VERR_NOT_SUPPORTED;
if (!pTimer)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VERR_TIMER_ACTIVE;
return VERR_NO_MEMORY;
return VERR_NO_MEMORY;
return VERR_CPU_OFFLINE;
return VERR_NO_MEMORY;
return VERR_CPU_OFFLINE;
/* cylic_add() comment: "The caller is responsible for assuring that cyt_when + cyt_interval <= INT64_MAX" */
return VINF_SUCCESS;
return VERR_TIMER_SUSPENDED;
return VINF_SUCCESS;
return VERR_NOT_SUPPORTED;
return nsec_per_tick;
return VERR_NOT_SUPPORTED;
return VERR_NOT_SUPPORTED;