1 | /* $Id: TMInline.h 87774 2021-02-16 23:40:35Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * TM - Common Inlined functions.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VMM_INCLUDED_SRC_include_TMInline_h
|
---|
19 | #define VMM_INCLUDED_SRC_include_TMInline_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Used to unlink a timer from the active list.
|
---|
27 | *
|
---|
28 | * @param pVM The cross context VM structure.
|
---|
29 | * @param pQueue The timer queue.
|
---|
30 | * @param pTimer The timer that needs linking.
|
---|
31 | *
|
---|
32 | * @remarks Called while owning the relevant queue lock.
|
---|
33 | */
|
---|
34 | DECL_FORCE_INLINE(void) tmTimerQueueUnlinkActive(PVMCC pVM, PTMTIMERQUEUE pQueue, PTMTIMER pTimer)
|
---|
35 | {
|
---|
36 | #ifdef VBOX_STRICT
|
---|
37 | TMTIMERSTATE const enmState = pTimer->enmState;
|
---|
38 | Assert( pTimer->enmClock == TMCLOCK_VIRTUAL_SYNC
|
---|
39 | ? enmState == TMTIMERSTATE_ACTIVE
|
---|
40 | : enmState == TMTIMERSTATE_PENDING_SCHEDULE || enmState == TMTIMERSTATE_PENDING_STOP_SCHEDULE);
|
---|
41 | #endif
|
---|
42 | RT_NOREF(pVM);
|
---|
43 |
|
---|
44 | const PTMTIMER pPrev = TMTIMER_GET_PREV(pTimer);
|
---|
45 | const PTMTIMER pNext = TMTIMER_GET_NEXT(pTimer);
|
---|
46 | if (pPrev)
|
---|
47 | TMTIMER_SET_NEXT(pPrev, pNext);
|
---|
48 | else
|
---|
49 | {
|
---|
50 | TMTIMER_SET_HEAD(pQueue, pNext);
|
---|
51 | pQueue->u64Expire = pNext ? pNext->u64Expire : INT64_MAX;
|
---|
52 | DBGFTRACE_U64_TAG(pVM, pQueue->u64Expire, "tmTimerQueueUnlinkActive");
|
---|
53 | }
|
---|
54 | if (pNext)
|
---|
55 | TMTIMER_SET_PREV(pNext, pPrev);
|
---|
56 | pTimer->offNext = 0;
|
---|
57 | pTimer->offPrev = 0;
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | /** @def TMTIMER_HANDLE_TO_PTR_RETURN_EX
|
---|
62 | * Converts a timer handle to a timer pointer, returning @a a_rcRet if the
|
---|
63 | * handle is invalid.
|
---|
64 | *
|
---|
65 | * @param a_pVM The cross context VM structure.
|
---|
66 | * @param a_hTimer The timer handle to translate.
|
---|
67 | * @param a_rcRet What to return on failure.
|
---|
68 | * @param a_pTimerVar The timer variable to assign the resulting pointer to.
|
---|
69 | */
|
---|
70 | #ifdef IN_RING3
|
---|
71 | # define TMTIMER_HANDLE_TO_PTR_RETURN_EX(a_pVM, a_hTimer, a_rcRet, a_pTimerVar) do { \
|
---|
72 | RT_NOREF(a_pVM); \
|
---|
73 | (a_pTimerVar) = (PTMTIMER)hTimer; \
|
---|
74 | AssertPtrReturn((a_pTimerVar), a_rcRet); \
|
---|
75 | AssertReturn((a_pTimerVar)->hSelf == a_hTimer, a_rcRet); \
|
---|
76 | } while (0)
|
---|
77 | #else
|
---|
78 | # define TMTIMER_HANDLE_TO_PTR_RETURN_EX(a_pVM, a_hTimer, a_rcRet, a_pTimerVar) do { \
|
---|
79 | (a_pTimerVar) = (PTMTIMER)MMHyperR3ToCC(pVM, (RTR3PTR)hTimer); \
|
---|
80 | AssertPtrReturn((a_pTimerVar), a_rcRet); \
|
---|
81 | AssertReturn((a_pTimerVar)->hSelf == a_hTimer, a_rcRet); \
|
---|
82 | Assert((a_pTimerVar)->fFlags & TMTIMER_FLAGS_RING0); \
|
---|
83 | } while (0)
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | /** @def TMTIMER_HANDLE_TO_PTR_RETURN
|
---|
87 | * Converts a timer handle to a timer pointer, returning VERR_INVALID_HANDLE if
|
---|
88 | * invalid.
|
---|
89 | *
|
---|
90 | * @param a_pVM The cross context VM structure.
|
---|
91 | * @param a_hTimer The timer handle to translate.
|
---|
92 | * @param a_pTimerVar The timer variable to assign the resulting pointer to.
|
---|
93 | */
|
---|
94 | #define TMTIMER_HANDLE_TO_PTR_RETURN(a_pVM, a_hTimer, a_pTimerVar) \
|
---|
95 | TMTIMER_HANDLE_TO_PTR_RETURN_EX(a_pVM, a_hTimer, VERR_INVALID_HANDLE, a_pTimerVar)
|
---|
96 |
|
---|
97 | /** @def TMTIMER_HANDLE_TO_PTR_RETURN_VOID
|
---|
98 | * Converts a timer handle to a timer pointer, returning VERR_INVALID_HANDLE if
|
---|
99 | * invalid.
|
---|
100 | *
|
---|
101 | * @param a_pVM The cross context VM structure.
|
---|
102 | * @param a_hTimer The timer handle to translate.
|
---|
103 | * @param a_pTimerVar The timer variable to assign the resulting pointer to.
|
---|
104 | */
|
---|
105 | #ifdef IN_RING3
|
---|
106 | # define TMTIMER_HANDLE_TO_PTR_RETURN_VOID(a_pVM, a_hTimer, a_pTimerVar) do { \
|
---|
107 | RT_NOREF(a_pVM); \
|
---|
108 | (a_pTimerVar) = (PTMTIMER)hTimer; \
|
---|
109 | AssertPtrReturnVoid((a_pTimerVar)); \
|
---|
110 | AssertReturnVoid((a_pTimerVar)->hSelf == a_hTimer); \
|
---|
111 | } while (0)
|
---|
112 | #else
|
---|
113 | # define TMTIMER_HANDLE_TO_PTR_RETURN_VOID(a_pVM, a_hTimer, a_pTimerVar) do { \
|
---|
114 | (a_pTimerVar) = (PTMTIMER)MMHyperR3ToCC(pVM, (RTR3PTR)hTimer); \
|
---|
115 | AssertPtrReturnVoid((a_pTimerVar)); \
|
---|
116 | AssertReturnVoid((a_pTimerVar)->hSelf == a_hTimer); \
|
---|
117 | Assert((a_pTimerVar)->fFlags & TMTIMER_FLAGS_RING0); \
|
---|
118 | } while (0)
|
---|
119 | #endif
|
---|
120 |
|
---|
121 |
|
---|
122 | #endif /* !VMM_INCLUDED_SRC_include_TMInline_h */
|
---|
123 |
|
---|