VirtualBox

source: vbox/trunk/src/VBox/Main/include/Global.h@ 106384

Last change on this file since 106384 was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.1 KB
Line 
1/* $Id: Global.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VirtualBox COM API - Global Declarations and Definitions.
4 */
5
6/*
7 * Copyright (C) 2008-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_Global_h
29#define MAIN_INCLUDED_Global_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* interface definitions */
35#include "VBox/com/VirtualBox.h"
36
37#include <VBox/ostypes.h>
38
39#include <iprt/types.h>
40
41/** @name Generic OS hint bits.
42 * @{
43 */
44#define VBOXOSHINT_NONE 0
45#define VBOXOSHINT_64BIT RT_BIT(0)
46#define VBOXOSHINT_EFI RT_BIT(1)
47#define VBOXOSHINT_USBHID RT_BIT(2)
48#define VBOXOSHINT_USBTABLET RT_BIT(3)
49#define VBOXOSHINT_RTCUTC RT_BIT(4)
50#define VBOXOSHINT_ACCEL2D RT_BIT(5)
51#define VBOXOSHINT_ACCEL3D RT_BIT(6)
52#define VBOXOSHINT_FLOPPY RT_BIT(7)
53#define VBOXOSHINT_NOUSB RT_BIT(8)
54#define VBOXOSHINT_TFRESET RT_BIT(9)
55#define VBOXOSHINT_USB3 RT_BIT(10)
56#define VBOXOSHINT_EFI_SECUREBOOT RT_BIT(11)
57#define VBOXOSHINT_TPM RT_BIT(12)
58#define VBOXOSHINT_TPM2 RT_BIT(13)
59#define VBOXOSHINT_WDDM_GRAPHICS RT_BIT(14)
60/** @} */
61
62/** @name x86-specific OS hint bits.
63 * @{
64 */
65#define VBOXOSHINT_X86_HWVIRTEX RT_BIT(15)
66#define VBOXOSHINT_X86_IOAPIC RT_BIT(16)
67#define VBOXOSHINT_X86_HPET RT_BIT(17)
68#define VBOXOSHINT_X86_PAE RT_BIT(18)
69#define VBOXOSHINT_X86_X2APIC RT_BIT(19)
70/** @} */
71
72/** The VBoxVRDP kludge extension pack name.
73 *
74 * This is not a valid extension pack name (dashes are not allowed), and
75 * hence will not conflict with real extension packs.
76 */
77#define VBOXVRDP_KLUDGE_EXTPACK_NAME "Built-in-VBoxVRDP"
78
79/** The VBoxPuelCrypto kludge extension pack name.
80 *
81 * This is not a valid extension pack name (dashes are not allowed), and
82 * hence will not conflict with real extension packs.
83 */
84#define VBOXPUELCRYPTO_KLUDGE_EXTPACK_NAME "Built-in-VBoxPuelCrypto"
85
86/**
87 * Contains global static definitions that can be referenced by all COM classes
88 * regardless of the apartment.
89 */
90class Global
91{
92public:
93
94 /** Represents OS Type <-> string mappings. */
95 struct OSType
96 {
97 const char *familyId; /* utf-8, e.g. Linux or MacOS */
98 const char *familyDescription; /* utf-8, e.g. Linux or Mac OS X */
99 const char *subtype; /* utf-8, the subtype of the family e.g. Debian or FreeBSD */
100 const char *id; /* utf-8, VM config file value e.g. Debian12_64 */
101 const char *description; /* utf-8, e.g. "Debian 12 Bookworm (64-bit)" */
102 const char *guestAdditionsInstallPkgName; /* utf-8, e.g. "VBoxLinuxAdditions.run" */
103 const VBOXOSTYPE osType; /* enum, e.g. VBOXOSTYPE_Debian12_x64 */
104 const uint32_t osHint;
105 const uint32_t recommendedCPUCount;
106 const uint32_t recommendedRAM;
107 const uint32_t recommendedVRAM;
108 const uint64_t recommendedHDD;
109 const GraphicsControllerType_T graphicsControllerType;
110 const NetworkAdapterType_T networkAdapterType;
111 const uint32_t numSerialEnabled;
112 const StorageControllerType_T dvdStorageControllerType;
113 const StorageBus_T dvdStorageBusType;
114 const StorageControllerType_T hdStorageControllerType;
115 const StorageBus_T hdStorageBusType;
116 const ChipsetType_T chipsetType;
117 const IommuType_T iommuType;
118 const AudioControllerType_T audioControllerType;
119 const AudioCodecType_T audioCodecType;
120 };
121
122 static const OSType sOSTypes[];
123 static size_t cOSTypes;
124
125 /**
126 * Maps VBOXOSTYPE to the OS type which is used in VM configs.
127 */
128 static const char *OSTypeId(VBOXOSTYPE aOSType);
129
130 /**
131 * Maps an OS type ID string to index into sOSTypes.
132 * @returns index on success, UINT32_MAX if not found.
133 */
134 static uint32_t getOSTypeIndexFromId(const char *pszId);
135
136 /**
137 * Returns @c true if the given machine state is an online state. This is a
138 * recommended way to detect if the VM is online (being executed in a
139 * dedicated process) or not. Note that some online states are also
140 * transitional states (see #IsTransient()).
141 */
142 static bool IsOnline(MachineState_T aState)
143 {
144 return aState >= MachineState_FirstOnline &&
145 aState <= MachineState_LastOnline;
146 }
147
148 /**
149 * Returns @c true if the given machine state is a transient state. This is
150 * a recommended way to detect if the VM is performing some potentially
151 * lengthy operation (such as starting, stopping, saving, deleting
152 * snapshot, etc.). Note some (but not all) transitional states are also
153 * online states (see #IsOnline()).
154 */
155 static bool IsTransient(MachineState_T aState)
156 {
157 return aState >= MachineState_FirstTransient &&
158 aState <= MachineState_LastTransient;
159 }
160
161 /**
162 * Shortcut to <tt>IsOnline(aState) || IsTransient(aState)</tt>. When it returns
163 * @c false, the VM is turned off (no VM process) and not busy with
164 * another exclusive operation.
165 */
166 static bool IsOnlineOrTransient(MachineState_T aState)
167 {
168 return IsOnline(aState) || IsTransient(aState);
169 }
170
171 /**
172 * Stringify a machine state - translated.
173 *
174 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
175 * version of this method.
176 *
177 * @returns Pointer to a read only string.
178 * @param aState Valid machine state.
179 */
180 static const char *stringifyMachineState(MachineState_T aState);
181
182 /**
183 * Stringify a session state - translated.
184 *
185 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
186 * version of this method.
187 *
188 * @returns Pointer to a read only string.
189 * @param aState Valid session state.
190 */
191 static const char *stringifySessionState(SessionState_T aState);
192
193 /**
194 * Stringify a device type.
195 *
196 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
197 * version of this method.
198 *
199 * @returns Pointer to a read only string.
200 * @param aType The device type.
201 */
202 static const char *stringifyDeviceType(DeviceType_T aType);
203
204 /**
205 * Stringify a guest session status.
206 *
207 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
208 * version of this method.
209 *
210 * @returns Pointer to a read only string.
211 * @param aStatus The guest session status.
212 */
213 static const char *stringifyGuestSessionStatus(GuestSessionStatus_T aStatus);
214
215 /**
216 * Stringify a process status.
217 *
218 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
219 * version of this method.
220 *
221 * @returns Pointer to a read only string.
222 * @param aStatus The process status.
223 */
224 static const char *stringifyProcessStatus(ProcessStatus_T aStatus);
225
226 /**
227 * Stringify a process wait result.
228 *
229 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
230 * version of this method.
231 *
232 * @returns Pointer to a read only string.
233 * @param aWaitResult The process wait result.
234 */
235 static const char *stringifyProcessWaitResult(ProcessWaitResult_T aWaitResult);
236
237 /**
238 * Stringify a file status.
239 *
240 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
241 * version of this method.
242 *
243 * @returns Pointer to a read only string.
244 * @param aStatus The file status.
245 */
246 static const char *stringifyFileStatus(FileStatus_T aStatus);
247
248 /**
249 * Stringify a filesystem object type.
250 *
251 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
252 * version of this method.
253 *
254 * @returns Pointer to a read only string.
255 * @param aType The filesystem object type.
256 */
257 static const char *stringifyFsObjType(FsObjType_T aType);
258
259 /**
260 * Stringify a platform architecture to a string.
261 *
262 * @returns Platform architecture as a string.
263 * @param aEnmArchitecture Platform architecture to convert.
264 */
265 static const char *stringifyPlatformArchitecture(PlatformArchitecture_T aEnmArchitecture);
266
267 /**
268 * Stringify a storage controller type.
269 *
270 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
271 * version of this method.
272 *
273 * @returns Pointer to a read only string.
274 * @param aType The storage controller type.
275 */
276 static const char *stringifyStorageControllerType(StorageControllerType_T aType);
277
278#if 0 /* unused */
279 /**
280 * Stringify a storage bus type.
281 *
282 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
283 * version of this method.
284 *
285 * @returns Pointer to a read only string.
286 * @param aBus The storage bus type.
287 */
288 static const char *stringifyStorageBus(StorageBus_T aBus);
289
290 /**
291 * Stringify a reason.
292 *
293 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
294 * version of this method.
295 *
296 * @returns Pointer to a read only string.
297 * @param aReason The reason code.
298 */
299 static const char *stringifyReason(Reason_T aReason);
300#endif
301
302 /**
303 * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
304 *
305 * @returns VBox status code.
306 * @param aComStatus COM status code.
307 */
308 static int vboxStatusCodeFromCOM(HRESULT aComStatus);
309
310 /**
311 * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
312 *
313 * This is mainly intended for dealing with vboxStatusCodeFromCOM() return
314 * values. If used on anything else, it won't be able to cope with most of the
315 * input!
316 *
317 * @returns COM status code.
318 * @param aVBoxStatus VBox status code.
319 */
320 static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
321};
322
323#endif /* !MAIN_INCLUDED_Global_h */
324/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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