VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/PDMAllCritSectBoth.cpp@ 90347

Last change on this file since 90347 was 90347, checked in by vboxsync, 3 years ago

VMM: Pass pVM to PDMCritSectRw APIs. bugref:9218 bugref:10074

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/* $Id: PDMAllCritSectBoth.cpp 90347 2021-07-26 20:36:28Z vboxsync $ */
2/** @file
3 * PDM - Code Common to Both Critical Section Types, All Contexts.
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
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/vmcc.h>
27#include <iprt/errcore.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 pVM The cross context VM structure.
39 * @param pVCpu The cross context virtual CPU structure.
40 */
41VMM_INT_DECL(void) PDMCritSectBothFF(PVMCC pVM, PVMCPUCC pVCpu)
42{
43 uint32_t i;
44 Assert( pVCpu->pdm.s.cQueuedCritSectLeaves > 0
45 || pVCpu->pdm.s.cQueuedCritSectRwShrdLeaves > 0
46 || pVCpu->pdm.s.cQueuedCritSectRwExclLeaves > 0);
47
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 pdmCritSectRwLeaveSharedQueued(pVM, 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 pdmCritSectRwLeaveExclQueued(pVM, pCritSectRw);
77 LogFlow(("PDMR3CritSectFF: %p (R/W)\n", pCritSectRw));
78 }
79
80 /* Normal leaves. */
81 i = pVCpu->pdm.s.cQueuedCritSectLeaves;
82 pVCpu->pdm.s.cQueuedCritSectLeaves = 0;
83 while (i-- > 0)
84 {
85# ifdef IN_RING3
86 PPDMCRITSECT pCritSect = pVCpu->pdm.s.apQueuedCritSectLeaves[i];
87# else
88 PPDMCRITSECT pCritSect = (PPDMCRITSECT)MMHyperR3ToCC(pVCpu->CTX_SUFF(pVM), pVCpu->pdm.s.apQueuedCritSectLeaves[i]);
89# endif
90
91 PDMCritSectLeave(pVM, pCritSect);
92 LogFlow(("PDMR3CritSectFF: %p\n", pCritSect));
93 }
94
95 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_PDM_CRITSECT);
96}
97#endif /* IN_RING3 || IN_RING0 */
98
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