1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Read/Write Critical Section.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___VBox_vmm_pdmcritsectrw_h
|
---|
27 | #define ___VBox_vmm_pdmcritsectrw_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 |
|
---|
31 |
|
---|
32 | RT_C_DECLS_BEGIN
|
---|
33 |
|
---|
34 | /** @defgroup grp_pdm_critsectrw The PDM Read/Write Critical Section API
|
---|
35 | * @ingroup grp_pdm
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * A PDM read/write critical section.
|
---|
41 | * Initialize using PDMDRVHLP::pfnCritSectRwInit().
|
---|
42 | */
|
---|
43 | typedef union PDMCRITSECTRW
|
---|
44 | {
|
---|
45 | /** Padding. */
|
---|
46 | uint8_t padding[HC_ARCH_BITS == 32 ? 0xc0 : 0x100];
|
---|
47 | #ifdef PDMCRITSECTRWINT_DECLARED
|
---|
48 | /** The internal structure (not normally visible). */
|
---|
49 | struct PDMCRITSECTRWINT s;
|
---|
50 | #endif
|
---|
51 | } PDMCRITSECTRW;
|
---|
52 |
|
---|
53 | VMMR3DECL(int) PDMR3CritSectRwInit(PVM pVM, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
|
---|
54 | const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(6, 7);
|
---|
55 | VMMR3DECL(int) PDMR3CritSectRwDelete(PPDMCRITSECTRW pCritSect);
|
---|
56 | VMMR3DECL(const char *) PDMR3CritSectRwName(PCPDMCRITSECTRW pCritSect);
|
---|
57 | VMMR3DECL(int) PDMR3CritSectRwEnterSharedEx(PPDMCRITSECTRW pThis, bool fCallRing3);
|
---|
58 | VMMR3DECL(int) PDMR3CritSectRwEnterExclEx(PPDMCRITSECTRW pThis, bool fCallRing3);
|
---|
59 |
|
---|
60 | VMMDECL(int) PDMCritSectRwEnterShared(PPDMCRITSECTRW pCritSect, int rcBusy);
|
---|
61 | VMMDECL(int) PDMCritSectRwEnterSharedDebug(PPDMCRITSECTRW pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL);
|
---|
62 | VMMDECL(int) PDMCritSectRwTryEnterShared(PPDMCRITSECTRW pCritSect);
|
---|
63 | VMMDECL(int) PDMCritSectRwTryEnterSharedDebug(PPDMCRITSECTRW pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL);
|
---|
64 | VMMDECL(int) PDMCritSectRwLeaveShared(PPDMCRITSECTRW pCritSect);
|
---|
65 | VMMDECL(int) PDMCritSectRwEnterExcl(PPDMCRITSECTRW pCritSect, int rcBusy);
|
---|
66 | VMMDECL(int) PDMCritSectRwEnterExclDebug(PPDMCRITSECTRW pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL);
|
---|
67 | VMMDECL(int) PDMCritSectRwTryEnterExcl(PPDMCRITSECTRW pCritSect);
|
---|
68 | VMMDECL(int) PDMCritSectRwTryEnterExclDebug(PPDMCRITSECTRW pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL);
|
---|
69 | VMMDECL(int) PDMCritSectRwLeaveExcl(PPDMCRITSECTRW pCritSect);
|
---|
70 |
|
---|
71 | VMMDECL(bool) PDMCritSectRwIsWriteOwner(PPDMCRITSECTRW pCritSect);
|
---|
72 | VMMDECL(bool) PDMCritSectRwIsReadOwner(PPDMCRITSECTRW pCritSect, bool fWannaHear);
|
---|
73 | VMMDECL(uint32_t) PDMCritSectRwGetWriteRecursion(PPDMCRITSECTRW pCritSect);
|
---|
74 | VMMDECL(uint32_t) PDMCritSectRwGetWriterReadRecursion(PPDMCRITSECTRW pCritSect);
|
---|
75 | VMMDECL(uint32_t) PDMCritSectRwGetReadCount(PPDMCRITSECTRW pCritSect);
|
---|
76 | VMMDECL(bool) PDMCritSectRwIsInitialized(PCPDMCRITSECTRW pCritSect);
|
---|
77 |
|
---|
78 | /* Lock strict build: Remap the three enter calls to the debug versions. */
|
---|
79 | #ifdef VBOX_STRICT
|
---|
80 | # ifdef ___iprt_asm_h
|
---|
81 | # define PDMCritSectRwEnterExcl(pCritSect, rcBusy) PDMCritSectRwEnterExclDebug(pCritSect, rcBusy, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
|
---|
82 | # define PDMCritSectRwTryEnterExcl(pCritSect) PDMCritSectRwTryEnterExclDebug(pCritSect, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
|
---|
83 | # define PDMCritSectRwEnterShared(pCritSect, rcBusy) PDMCritSectRwEnterSharedDebug(pCritSect, rcBusy, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
|
---|
84 | # define PDMCritSectRwTryEnterShared(pCritSect) PDMCritSectRwTryEnterSharedDebug(pCritSect, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
|
---|
85 | # else
|
---|
86 | # define PDMCritSectRwEnterExcl(pCritSect, rcBusy) PDMCritSectRwEnterExclDebug(pCritSect, rcBusy, 0, RT_SRC_POS)
|
---|
87 | # define PDMCritSectRwTryEnterExcl(pCritSect) PDMCritSectRwTryEnterExclDebug(pCritSect, 0, RT_SRC_POS)
|
---|
88 | # define PDMCritSectRwEnterShared(pCritSect, rcBusy) PDMCritSectRwEnterSharedDebug(pCritSect, rcBusy, 0, RT_SRC_POS)
|
---|
89 | # define PDMCritSectRwTryEnterShared(pCritSect) PDMCritSectRwTryEnterSharedDebug(pCritSect, 0, RT_SRC_POS)
|
---|
90 | # endif
|
---|
91 | #endif
|
---|
92 |
|
---|
93 | /** @} */
|
---|
94 |
|
---|
95 | RT_C_DECLS_END
|
---|
96 |
|
---|
97 | #endif
|
---|
98 |
|
---|