VirtualBox

source: vbox/trunk/src/VBox/VMM/include/TMInline.h@ 87766

Last change on this file since 87766 was 87766, checked in by vboxsync, 4 years ago

VMM/TM,VMM/*: Refactored the TM timer APIs to use 'handles' and take a pVM parameter. Only internal callbacks have been updated with a hTimer parameter, so far. bugref:9943

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: TMInline.h 87766 2021-02-16 14:27:43Z 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 pQueue The timer queue.
29 * @param pTimer The timer that needs linking.
30 *
31 * @remarks Called while owning the relevant queue lock.
32 */
33DECL_FORCE_INLINE(void) tmTimerQueueUnlinkActive(PTMTIMERQUEUE pQueue, PTMTIMER pTimer)
34{
35#ifdef VBOX_STRICT
36 TMTIMERSTATE const enmState = pTimer->enmState;
37 Assert( pTimer->enmClock == TMCLOCK_VIRTUAL_SYNC
38 ? enmState == TMTIMERSTATE_ACTIVE
39 : enmState == TMTIMERSTATE_PENDING_SCHEDULE || enmState == TMTIMERSTATE_PENDING_STOP_SCHEDULE);
40#endif
41
42 const PTMTIMER pPrev = TMTIMER_GET_PREV(pTimer);
43 const PTMTIMER pNext = TMTIMER_GET_NEXT(pTimer);
44 if (pPrev)
45 TMTIMER_SET_NEXT(pPrev, pNext);
46 else
47 {
48 TMTIMER_SET_HEAD(pQueue, pNext);
49 pQueue->u64Expire = pNext ? pNext->u64Expire : INT64_MAX;
50 DBGFTRACE_U64_TAG(pTimer->CTX_SUFF(pVM), pQueue->u64Expire, "tmTimerQueueUnlinkActive");
51 }
52 if (pNext)
53 TMTIMER_SET_PREV(pNext, pPrev);
54 pTimer->offNext = 0;
55 pTimer->offPrev = 0;
56}
57
58
59/** @def TMTIMER_HANDLE_TO_PTR_RETURN_EX
60 * Converts a timer handle to a timer pointer, returning @a a_rcRet if the
61 * handle is invalid.
62 *
63 * @param a_pVM The cross context VM structure.
64 * @param a_hTimer The timer handle to translate.
65 * @param a_rcRet What to return on failure.
66 * @param a_pTimerVar The timer variable to assign the resulting pointer to.
67 */
68#ifdef IN_RING3
69# define TMTIMER_HANDLE_TO_PTR_RETURN_EX(a_pVM, a_hTimer, a_rcRet, a_pTimerVar) do { \
70 RT_NOREF(a_pVM); \
71 (a_pTimerVar) = (PTMTIMER)hTimer; \
72 AssertPtrReturn((a_pTimerVar), a_rcRet); \
73 AssertReturn((a_pTimerVar)->hSelf == a_hTimer, a_rcRet); \
74 } while (0)
75#else
76# define TMTIMER_HANDLE_TO_PTR_RETURN_EX(a_pVM, a_hTimer, a_rcRet, a_pTimerVar) do { \
77 (a_pTimerVar) = (PTMTIMER)MMHyperR3ToCC(pVM, (RTR3PTR)hTimer); \
78 AssertPtrReturn((a_pTimerVar), a_rcRet); \
79 AssertReturn((a_pTimerVar)->hSelf == a_hTimer, a_rcRet); \
80 Assert((a_pTimerVar)->fFlags & TMTIMER_FLAGS_RING0); \
81 } while (0)
82#endif
83
84/** @def TMTIMER_HANDLE_TO_PTR_RETURN
85 * Converts a timer handle to a timer pointer, returning VERR_INVALID_HANDLE if
86 * invalid.
87 *
88 * @param a_pVM The cross context VM structure.
89 * @param a_hTimer The timer handle to translate.
90 * @param a_pTimerVar The timer variable to assign the resulting pointer to.
91 */
92#define TMTIMER_HANDLE_TO_PTR_RETURN(a_pVM, a_hTimer, a_pTimerVar) \
93 TMTIMER_HANDLE_TO_PTR_RETURN_EX(a_pVM, a_hTimer, VERR_INVALID_HANDLE, a_pTimerVar)
94
95/** @def TMTIMER_HANDLE_TO_PTR_RETURN_VOID
96 * Converts a timer handle to a timer pointer, returning VERR_INVALID_HANDLE if
97 * invalid.
98 *
99 * @param a_pVM The cross context VM structure.
100 * @param a_hTimer The timer handle to translate.
101 * @param a_pTimerVar The timer variable to assign the resulting pointer to.
102 */
103#ifdef IN_RING3
104# define TMTIMER_HANDLE_TO_PTR_RETURN_VOID(a_pVM, a_hTimer, a_pTimerVar) do { \
105 RT_NOREF(a_pVM); \
106 (a_pTimerVar) = (PTMTIMER)hTimer; \
107 AssertPtrReturnVoid((a_pTimerVar)); \
108 AssertReturnVoid((a_pTimerVar)->hSelf == a_hTimer); \
109 } while (0)
110#else
111# define TMTIMER_HANDLE_TO_PTR_RETURN_VOID(a_pVM, a_hTimer, a_pTimerVar) do { \
112 (a_pTimerVar) = (PTMTIMER)MMHyperR3ToCC(pVM, (RTR3PTR)hTimer); \
113 AssertPtrReturnVoid((a_pTimerVar)); \
114 AssertReturnVoid((a_pTimerVar)->hSelf == a_hTimer); \
115 Assert((a_pTimerVar)->fFlags & TMTIMER_FLAGS_RING0); \
116 } while (0)
117#endif
118
119
120#endif /* !VMM_INCLUDED_SRC_include_TMInline_h */
121
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette