VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmcritsect.h@ 99956

Last change on this file since 99956 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 6.0 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Critical Sections.
3 */
4
5/*
6 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_pdmcritsect_h
37#define VBOX_INCLUDED_vmm_pdmcritsect_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/types.h>
43#include <iprt/critsect.h>
44
45
46RT_C_DECLS_BEGIN
47
48/** @defgroup grp_pdm_critsect The PDM Critical Section API
49 * @ingroup grp_pdm
50 * @{
51 */
52
53/**
54 * A PDM critical section.
55 * Initialize using PDMDRVHLP::pfnCritSectInit().
56 */
57typedef union PDMCRITSECT
58{
59 /** Padding. */
60 uint8_t padding[HC_ARCH_BITS == 32 ? 0xc0 : 0x100];
61#ifdef PDMCRITSECTINT_DECLARED
62 /** The internal structure (not normally visible). */
63 struct PDMCRITSECTINT s;
64#endif
65} PDMCRITSECT;
66
67VMMR3_INT_DECL(int) PDMR3CritSectBothTerm(PVM pVM);
68VMMR3_INT_DECL(void) PDMR3CritSectLeaveAll(PVM pVM);
69VMM_INT_DECL(void) PDMCritSectBothFF(PVMCC pVM, PVMCPUCC pVCpu);
70
71
72VMMR3DECL(uint32_t) PDMR3CritSectCountOwned(PVM pVM, char *pszNames, size_t cbNames);
73
74VMMR3DECL(int) PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
75 const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(6, 7);
76VMMR3DECL(int) PDMR3CritSectEnterEx(PVM pVM, PPDMCRITSECT pCritSect, bool fCallRing3);
77VMMR3DECL(bool) PDMR3CritSectYield(PVM pVM, PPDMCRITSECT pCritSect);
78VMMR3DECL(const char *) PDMR3CritSectName(PCPDMCRITSECT pCritSect);
79VMMR3DECL(int) PDMR3CritSectDelete(PVM pVM, PPDMCRITSECT pCritSect);
80#if defined(IN_RING0) || defined(IN_RING3)
81VMMDECL(int) PDMHCCritSectScheduleExitEvent(PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal);
82#endif
83
84VMMDECL(DECL_CHECK_RETURN_NOT_R3(int))
85 PDMCritSectEnter(PVMCC pVM, PPDMCRITSECT pCritSect, int rcBusy);
86VMMDECL(DECL_CHECK_RETURN_NOT_R3(int))
87 PDMCritSectEnterDebug(PVMCC pVM, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL);
88VMMDECL(DECL_CHECK_RETURN(int))
89 PDMCritSectTryEnter(PVMCC pVM, PPDMCRITSECT pCritSect);
90VMMDECL(DECL_CHECK_RETURN(int))
91 PDMCritSectTryEnterDebug(PVMCC pVM, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL);
92VMMDECL(int) PDMCritSectLeave(PVMCC pVM, PPDMCRITSECT pCritSect);
93
94VMMDECL(bool) PDMCritSectIsOwner(PVMCC pVM, PCPDMCRITSECT pCritSect);
95VMMDECL(bool) PDMCritSectIsOwnerEx(PVMCPUCC pVCpu, PCPDMCRITSECT pCritSect);
96VMMDECL(bool) PDMCritSectIsInitialized(PCPDMCRITSECT pCritSect);
97VMMDECL(bool) PDMCritSectHasWaiters(PVMCC pVM, PCPDMCRITSECT pCritSect);
98VMMDECL(uint32_t) PDMCritSectGetRecursion(PCPDMCRITSECT pCritSect);
99
100VMMR3DECL(PPDMCRITSECT) PDMR3CritSectGetNop(PVM pVM);
101
102/* Strict build: Remap the two enter calls to the debug versions. */
103#ifdef VBOX_STRICT
104# ifdef IPRT_INCLUDED_asm_h
105# define PDMCritSectEnter(a_pVM, pCritSect, rcBusy) PDMCritSectEnterDebug((a_pVM), (pCritSect), (rcBusy), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
106# define PDMCritSectTryEnter(a_pVM, pCritSect) PDMCritSectTryEnterDebug((a_pVM), (pCritSect), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
107# else
108# define PDMCritSectEnter(a_pVM, pCritSect, rcBusy) PDMCritSectEnterDebug((a_pVM), (pCritSect), (rcBusy), 0, RT_SRC_POS)
109# define PDMCritSectTryEnter(a_pVM, pCritSect) PDMCritSectTryEnterDebug((a_pVM), (pCritSect), 0, RT_SRC_POS)
110# endif
111#endif
112
113/** @def PDM_CRITSECT_RELEASE_ASSERT_RC
114 * Helper for PDMCritSectEnter w/ rcBusy VINF_SUCCESS when there is no way
115 * to forward failures to the caller. */
116#define PDM_CRITSECT_RELEASE_ASSERT_RC(a_pVM, a_pCritSect, a_rc) \
117 AssertReleaseMsg(RT_SUCCESS(a_rc), ("pVM=%p pCritSect=%p: %Rrc\n", (a_pVM), (a_pCritSect), (a_rc)))
118
119/** @def PDM_CRITSECT_RELEASE_ASSERT_RC_DEV
120 * Helper for PDMCritSectEnter w/ rcBusy VINF_SUCCESS when there is no way
121 * to forward failures to the caller, device edition. */
122#define PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(a_pDevIns, a_pCritSect, a_rc) \
123 AssertReleaseMsg(RT_SUCCESS(a_rc), ("pDevIns=%p pCritSect=%p: %Rrc\n", (a_pDevIns), (a_pCritSect), (a_rc)))
124
125/** @def PDM_CRITSECT_RELEASE_ASSERT_RC_DRV
126 * Helper for PDMCritSectEnter w/ rcBusy VINF_SUCCESS when there is no way
127 * to forward failures to the caller, driver edition. */
128#define PDM_CRITSECT_RELEASE_ASSERT_RC_DRV(a_pDrvIns, a_pCritSect, a_rc) \
129 AssertReleaseMsg(RT_SUCCESS(a_rc), ("pDrvIns=%p pCritSect=%p: %Rrc\n", (a_pDrvIns), (a_pCritSect), (a_rc)))
130
131/** @def PDM_CRITSECT_RELEASE_ASSERT_RC_USB
132 * Helper for PDMCritSectEnter w/ rcBusy VINF_SUCCESS when there is no way
133 * to forward failures to the caller, USB device edition. */
134#define PDM_CRITSECT_RELEASE_ASSERT_RC_USB(a_pUsbIns, a_pCritSect, a_rc) \
135 AssertReleaseMsg(RT_SUCCESS(a_rc), ("pUsbIns=%p pCritSect=%p: %Rrc\n", (a_pUsbIns), (a_pCritSect), (a_rc)))
136
137
138/** @} */
139
140RT_C_DECLS_END
141
142#endif /* !VBOX_INCLUDED_vmm_pdmcritsect_h */
143
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