1 | /* $Id: PDMAllCritSectBoth.cpp 45152 2013-03-23 20:36:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Code Common to Both Critical Section Types, All Contexts.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 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 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_PDM//_CRITSECT
|
---|
23 | #include "PDMInternal.h"
|
---|
24 | #include <VBox/vmm/pdmcritsect.h>
|
---|
25 | #include <VBox/vmm/pdmcritsectrw.h>
|
---|
26 | #include <VBox/vmm/vm.h>
|
---|
27 | #include <VBox/err.h>
|
---|
28 |
|
---|
29 | #include <VBox/log.h>
|
---|
30 | #include <iprt/assert.h>
|
---|
31 | #include <iprt/asm.h>
|
---|
32 |
|
---|
33 |
|
---|
34 | #if defined(IN_RING3) || defined(IN_RING0)
|
---|
35 | /**
|
---|
36 | * Process the critical sections (both types) queued for ring-3 'leave'.
|
---|
37 | *
|
---|
38 | * @param pVCpu Pointer to the VMCPU.
|
---|
39 | */
|
---|
40 | VMM_INT_DECL(void) PDMCritSectBothFF(PVMCPU pVCpu)
|
---|
41 | {
|
---|
42 | uint32_t i;
|
---|
43 | Assert( pVCpu->pdm.s.cQueuedCritSectLeaves > 0
|
---|
44 | || pVCpu->pdm.s.cQueuedCritSectRwShrdLeaves > 0
|
---|
45 | || pVCpu->pdm.s.cQueuedCritSectRwExclLeaves > 0);
|
---|
46 |
|
---|
47 | #if 0 /* Later... */
|
---|
48 | /* Shared leaves. */
|
---|
49 | i = pVCpu->pdm.s.cQueuedCritSectRwShrdLeaves;
|
---|
50 | pVCpu->pdm.s.cQueuedCritSectRwShrdLeaves = 0;
|
---|
51 | while (i-- > 0)
|
---|
52 | {
|
---|
53 | # ifdef IN_RING3
|
---|
54 | PPDMCRITSECTRW pCritSectRw = pVCpu->pdm.s.apQueuedCritSectRwShrdLeaves[i];
|
---|
55 | # else
|
---|
56 | PPDMCRITSECTRW pCritSectRw = (PPDMCRITSECTRW)MMHyperR3ToCC(pVCpu->CTX_SUFF(pVM),
|
---|
57 | pVCpu->pdm.s.apQueuedCritSectRwShrdLeaves[i]);
|
---|
58 | # endif
|
---|
59 |
|
---|
60 | PDMCritSectRwLeaveShared(pCritSectRw);
|
---|
61 | LogFlow(("PDMR3CritSectFF: %p (R/W)\n", pCritSectRw));
|
---|
62 | }
|
---|
63 |
|
---|
64 | /* Last, exclusive leaves. */
|
---|
65 | i = pVCpu->pdm.s.cQueuedCritSectRwExclLeaves;
|
---|
66 | pVCpu->pdm.s.cQueuedCritSectRwExclLeaves = 0;
|
---|
67 | while (i-- > 0)
|
---|
68 | {
|
---|
69 | # ifdef IN_RING3
|
---|
70 | PPDMCRITSECTRW pCritSectRw = pVCpu->pdm.s.apQueuedCritSectRwExclLeaves[i];
|
---|
71 | # else
|
---|
72 | PPDMCRITSECTRW pCritSectRw = (PPDMCRITSECTRW)MMHyperR3ToCC(pVCpu->CTX_SUFF(pVM),
|
---|
73 | pVCpu->pdm.s.apQueuedCritSectRwExclLeaves[i]);
|
---|
74 | # endif
|
---|
75 |
|
---|
76 | PDMCritSectRwLeaveExcl(pCritSectRw);
|
---|
77 | LogFlow(("PDMR3CritSectFF: %p (R/W)\n", pCritSectRw));
|
---|
78 | }
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | /* Normal leaves. */
|
---|
82 | i = pVCpu->pdm.s.cQueuedCritSectLeaves;
|
---|
83 | pVCpu->pdm.s.cQueuedCritSectLeaves = 0;
|
---|
84 | while (i-- > 0)
|
---|
85 | {
|
---|
86 | # ifdef IN_RING3
|
---|
87 | PPDMCRITSECT pCritSect = pVCpu->pdm.s.apQueuedCritSectLeaves[i];
|
---|
88 | # else
|
---|
89 | PPDMCRITSECT pCritSect = (PPDMCRITSECT)MMHyperR3ToCC(pVCpu->CTX_SUFF(pVM), pVCpu->pdm.s.apQueuedCritSectLeaves[i]);
|
---|
90 | # endif
|
---|
91 |
|
---|
92 | PDMCritSectLeave(pCritSect);
|
---|
93 | LogFlow(("PDMR3CritSectFF: %p\n", pCritSect));
|
---|
94 | }
|
---|
95 |
|
---|
96 | VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_PDM_CRITSECT);
|
---|
97 | }
|
---|
98 | #endif /* IN_RING3 || IN_RING0 */
|
---|
99 |
|
---|