VirtualBox

source: vbox/trunk/include/VBox/pdmcritsect.h@ 3880

Last change on this file since 3880 was 3854, checked in by vboxsync, 18 years ago

Splitting up pdm.h - export the fragments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Critical Sections.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef ___VBox_pdm_h
22# include <VBox/pdm.h>
23#endif
24
25#ifndef ___VBox_pdmcritsect_h
26#define ___VBox_pdmcritsect_h
27
28__BEGIN_DECLS
29
30/** @defgroup grp_pdm_critsect The PDM Critical Section
31 * @ingroup grp_pdm
32 * @{
33 */
34
35/**
36 * A PDM critical section.
37 * Initialize using PDMDRVHLP::pfnCritSectInit().
38 */
39typedef union PDMCRITSECT
40{
41 /** Padding. */
42 uint8_t padding[HC_ARCH_BITS == 64 ? 0xb8 : 0x80];
43#ifdef PDMCRITSECTINT_DECLARED
44 /** The internal structure (not normally visible). */
45 struct PDMCRITSECTINT s;
46#endif
47} PDMCRITSECT;
48/** Pointer to a PDM critical section. */
49typedef PDMCRITSECT *PPDMCRITSECT;
50/** Pointer to a const PDM critical section. */
51typedef const PDMCRITSECT *PCPDMCRITSECT;
52
53/**
54 * Initializes a PDM critical section for internal use.
55 *
56 * The PDM critical sections are derived from the IPRT critical sections, but
57 * works in GC as well.
58 *
59 * @returns VBox status code.
60 * @param pVM The VM handle.
61 * @param pDevIns Device instance.
62 * @param pCritSect Pointer to the critical section.
63 * @param pszName The name of the critical section (for statistics).
64 */
65PDMR3DECL(int) PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, const char *pszName);
66
67/**
68 * Leaves a critical section entered with PDMCritSectEnter().
69 *
70 * @returns VINF_SUCCESS if entered successfully.
71 * @returns rcBusy when encountering a busy critical section in GC/R0.
72 * @returns VERR_SEM_DESTROYED if the critical section is dead.
73 *
74 * @param pCritSect The PDM critical section to enter.
75 * @param rcBusy The status code to return when we're in GC or R0
76 * and the section is busy.
77 */
78PDMDECL(int) PDMCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy);
79
80/**
81 * Leaves a critical section entered with PDMCritSectEnter().
82 *
83 * @param pCritSect The PDM critical section to leave.
84 */
85PDMDECL(void) PDMCritSectLeave(PPDMCRITSECT pCritSect);
86
87/**
88 * Checks the caller is the owner of the critical section.
89 *
90 * @returns true if owner.
91 * @returns false if not owner.
92 * @param pCritSect The critical section.
93 */
94PDMDECL(bool) PDMCritSectIsOwner(PCPDMCRITSECT pCritSect);
95
96/**
97 * Try enter a critical section.
98 *
99 * @returns VINF_SUCCESS on success.
100 * @returns VERR_SEM_BUSY if the critsect was owned.
101 * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
102 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
103 * @param pCritSect The critical section.
104 */
105PDMR3DECL(int) PDMR3CritSectTryEnter(PPDMCRITSECT pCritSect);
106
107/**
108 * Schedule a event semaphore for signalling upon critsect exit.
109 *
110 * @returns VINF_SUCCESS on success.
111 * @returns VERR_TOO_MANY_SEMAPHORES if an event was already scheduled.
112 * @returns VERR_NOT_OWNER if we're not the critsect owner.
113 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
114 * @param pCritSect The critical section.
115 * @param EventToSignal The semapore that should be signalled.
116 */
117PDMR3DECL(int) PDMR3CritSectScheduleExitEvent(PPDMCRITSECT pCritSect, RTSEMEVENT EventToSignal);
118
119/**
120 * Deletes the critical section.
121 *
122 * @returns VBox status code.
123 * @param pCritSect The PDM critical section to destroy.
124 */
125PDMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect);
126
127/**
128 * Deletes all remaining critical sections.
129 *
130 * This is called at the end of the termination process.
131 *
132 * @returns VBox status.
133 * First error code, rest is lost.
134 * @param pVM The VM handle.
135 * @remark Don't confuse this with PDMR3CritSectDelete.
136 */
137PDMDECL(int) PDMR3CritSectTerm(PVM pVM);
138
139/**
140 * Process the critical sections queued for ring-3 'leave'.
141 *
142 * @param pVM The VM handle.
143 */
144PDMR3DECL(void) PDMR3CritSectFF(PVM pVM);
145
146/** @} */
147
148__END_DECLS
149
150#endif
151
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette