1 | /* $Id: PDMAllCritSectBoth.cpp 58123 2015-10-08 18:09:45Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Code Common to Both Critical Section Types, All Contexts.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 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 The cross context virtual CPU structure.
|
---|
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 | /* Shared leaves. */
|
---|
48 | i = pVCpu->pdm.s.cQueuedCritSectRwShrdLeaves;
|
---|
49 | pVCpu->pdm.s.cQueuedCritSectRwShrdLeaves = 0;
|
---|
50 | while (i-- > 0)
|
---|
51 | {
|
---|
52 | # ifdef IN_RING3
|
---|
53 | PPDMCRITSECTRW pCritSectRw = pVCpu->pdm.s.apQueuedCritSectRwShrdLeaves[i];
|
---|
54 | # else
|
---|
55 | PPDMCRITSECTRW pCritSectRw = (PPDMCRITSECTRW)MMHyperR3ToCC(pVCpu->CTX_SUFF(pVM),
|
---|
56 | pVCpu->pdm.s.apQueuedCritSectRwShrdLeaves[i]);
|
---|
57 | # endif
|
---|
58 |
|
---|
59 | pdmCritSectRwLeaveSharedQueued(pCritSectRw);
|
---|
60 | LogFlow(("PDMR3CritSectFF: %p (R/W)\n", pCritSectRw));
|
---|
61 | }
|
---|
62 |
|
---|
63 | /* Last, exclusive leaves. */
|
---|
64 | i = pVCpu->pdm.s.cQueuedCritSectRwExclLeaves;
|
---|
65 | pVCpu->pdm.s.cQueuedCritSectRwExclLeaves = 0;
|
---|
66 | while (i-- > 0)
|
---|
67 | {
|
---|
68 | # ifdef IN_RING3
|
---|
69 | PPDMCRITSECTRW pCritSectRw = pVCpu->pdm.s.apQueuedCritSectRwExclLeaves[i];
|
---|
70 | # else
|
---|
71 | PPDMCRITSECTRW pCritSectRw = (PPDMCRITSECTRW)MMHyperR3ToCC(pVCpu->CTX_SUFF(pVM),
|
---|
72 | pVCpu->pdm.s.apQueuedCritSectRwExclLeaves[i]);
|
---|
73 | # endif
|
---|
74 |
|
---|
75 | pdmCritSectRwLeaveExclQueued(pCritSectRw);
|
---|
76 | LogFlow(("PDMR3CritSectFF: %p (R/W)\n", pCritSectRw));
|
---|
77 | }
|
---|
78 |
|
---|
79 | /* Normal leaves. */
|
---|
80 | i = pVCpu->pdm.s.cQueuedCritSectLeaves;
|
---|
81 | pVCpu->pdm.s.cQueuedCritSectLeaves = 0;
|
---|
82 | while (i-- > 0)
|
---|
83 | {
|
---|
84 | # ifdef IN_RING3
|
---|
85 | PPDMCRITSECT pCritSect = pVCpu->pdm.s.apQueuedCritSectLeaves[i];
|
---|
86 | # else
|
---|
87 | PPDMCRITSECT pCritSect = (PPDMCRITSECT)MMHyperR3ToCC(pVCpu->CTX_SUFF(pVM), pVCpu->pdm.s.apQueuedCritSectLeaves[i]);
|
---|
88 | # endif
|
---|
89 |
|
---|
90 | PDMCritSectLeave(pCritSect);
|
---|
91 | LogFlow(("PDMR3CritSectFF: %p\n", pCritSect));
|
---|
92 | }
|
---|
93 |
|
---|
94 | VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_PDM_CRITSECT);
|
---|
95 | }
|
---|
96 | #endif /* IN_RING3 || IN_RING0 */
|
---|
97 |
|
---|