~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/r0drv/solaris/vbi/timer-r0drv-solaris.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/** $Id: timer-r0drv-solaris.c $ */
 
1
/* $Id: timer-r0drv-solaris.c $ */
2
2
/** @file
3
3
 * IPRT - Timer, Ring-0 Driver, Solaris.
4
4
 */
32
32
/*******************************************************************************
33
33
*   Header Files                                                               *
34
34
*******************************************************************************/
35
 
#include "the-solaris-kernel.h"
36
 
 
 
35
#include "../the-solaris-kernel.h"
 
36
#include "internal/iprt.h"
37
37
#include <iprt/timer.h>
38
 
#include <iprt/time.h>
 
38
 
 
39
#include <iprt/asm.h>
 
40
#include <iprt/assert.h>
 
41
#include <iprt/err.h>
 
42
#include <iprt/mem.h>
39
43
#include <iprt/mp.h>
40
44
#include <iprt/spinlock.h>
41
 
#include <iprt/err.h>
42
 
#include <iprt/asm.h>
43
 
#include <iprt/assert.h>
44
 
#include <iprt/alloc.h>
45
 
 
 
45
#include <iprt/time.h>
 
46
#include <iprt/thread.h>
46
47
#include "internal/magics.h"
47
48
 
48
49
 
69
70
    /** The nano second interval for repeating timers */
70
71
    uint64_t                interval;
71
72
    /** simple Solaris timer handle. */
72
 
    vbi_stimer_t            *stimer;
 
73
    vbi_stimer_t           *stimer;
73
74
    /** global Solaris timer handle. */
74
 
    vbi_gtimer_t            *gtimer;
 
75
    vbi_gtimer_t           *gtimer;
75
76
    /** The user callback. */
76
77
    PFNRTTIMER              pfnTimer;
77
78
    /** The argument for the user callback. */
78
 
    void                    *pvUser;
 
79
    void                   *pvUser;
79
80
} RTTIMER;
80
81
 
81
82
 
 
83
/*******************************************************************************
 
84
*   Defined Constants And Macros                                               *
 
85
*******************************************************************************/
 
86
/** Validates that the timer is valid. */
 
87
#define RTTIMER_ASSERT_VALID_RET(pTimer) \
 
88
    do \
 
89
    { \
 
90
        AssertPtrReturn(pTimer, VERR_INVALID_HANDLE); \
 
91
        AssertReturn((pTimer)->u32Magic == RTTIMER_MAGIC, VERR_INVALID_HANDLE); \
 
92
    } while (0)
 
93
 
 
94
 
82
95
/*
83
96
 * Need a wrapper to get the PRTTIMER passed through
84
97
 */
92
105
 
93
106
RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, unsigned fFlags, PFNRTTIMER pfnTimer, void *pvUser)
94
107
{
 
108
    RT_ASSERT_PREEMPTIBLE();
95
109
    *ppTimer = NULL;
96
110
 
97
111
    /*
148
162
}
149
163
 
150
164
 
151
 
/**
152
 
 * Validates the timer handle.
153
 
 *
154
 
 * @returns true if valid, false if invalid.
155
 
 * @param   pTimer  The handle.
156
 
 */
157
 
DECLINLINE(bool) rtTimerIsValid(PRTTIMER pTimer)
158
 
{
159
 
    AssertReturn(VALID_PTR(pTimer), false);
160
 
    AssertReturn(pTimer->u32Magic == RTTIMER_MAGIC, false);
161
 
    return true;
162
 
}
163
 
 
164
 
 
165
165
RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
166
166
{
167
167
    if (pTimer == NULL)
168
168
        return VINF_SUCCESS;
169
 
    if (!rtTimerIsValid(pTimer))
170
 
        return VERR_INVALID_HANDLE;
 
169
    RTTIMER_ASSERT_VALID_RET(pTimer);
 
170
    RT_ASSERT_INTS_ON();
171
171
 
172
172
    /*
173
173
     * Free the associated resources.
174
174
     */
175
175
    RTTimerStop(pTimer);
176
 
    pTimer->u32Magic++;
 
176
    ASMAtomicWriteU32(pTimer, ~RTTIMER_MAGIC);
177
177
    RTMemFree(pTimer);
178
178
    return VINF_SUCCESS;
179
179
}
181
181
 
182
182
RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First)
183
183
{
184
 
    int cpu = VBI_ANY_CPU;
 
184
    RTTIMER_ASSERT_VALID_RET(pTimer);
 
185
    RT_ASSERT_INTS_ON();
185
186
 
186
 
    if (!rtTimerIsValid(pTimer))
187
 
        return VERR_INVALID_HANDLE;
188
187
    if (!pTimer->fSuspended)
189
188
        return VERR_TIMER_ACTIVE;
190
189
 
197
196
    }
198
197
    else
199
198
    {
 
199
        int cpu = VBI_ANY_CPU;
200
200
        if (pTimer->fSpecificCpu)
201
201
            cpu = pTimer->iCpu;
202
202
        pTimer->stimer = vbi_stimer_begin(rtTimerSolarisCallbackWrapper, pTimer, u64First, pTimer->interval, cpu);
214
214
 
215
215
RTDECL(int) RTTimerStop(PRTTIMER pTimer)
216
216
{
217
 
    if (!rtTimerIsValid(pTimer))
218
 
        return VERR_INVALID_HANDLE;
 
217
    RTTIMER_ASSERT_VALID_RET(pTimer);
 
218
    RT_ASSERT_INTS_ON();
 
219
 
219
220
    if (pTimer->fSuspended)
220
221
        return VERR_TIMER_SUSPENDED;
221
222