VirtualBox

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

Last change on this file since 101505 was 101460, checked in by vboxsync, 14 months ago

Main: Moved Platform::s_platformArchitectureToStr() to Global::stringifyPlatformArchitecture(), so that the client part of VBoxSVC also can make use of this. bugref:10384

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1/* $Id: Global.h 101460 2023-10-17 08:32:09Z vboxsync $ */
2/** @file
3 * VirtualBox COM API - Global Declarations and Definitions.
4 */
5
6/*
7 * Copyright (C) 2008-2023 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 *variant; /* 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 VBOXOSTYPE osType; /* enum, e.g. VBOXOSTYPE_Debian12_x64 */
103 const uint32_t osHint;
104 const uint32_t recommendedCPUCount;
105 const uint32_t recommendedRAM;
106 const uint32_t recommendedVRAM;
107 const uint64_t recommendedHDD;
108 const GraphicsControllerType_T graphicsControllerType;
109 const NetworkAdapterType_T networkAdapterType;
110 const uint32_t numSerialEnabled;
111 const StorageControllerType_T dvdStorageControllerType;
112 const StorageBus_T dvdStorageBusType;
113 const StorageControllerType_T hdStorageControllerType;
114 const StorageBus_T hdStorageBusType;
115 const ChipsetType_T chipsetType;
116 const IommuType_T iommuType;
117 const AudioControllerType_T audioControllerType;
118 const AudioCodecType_T audioCodecType;
119 };
120
121 static const OSType sOSTypes[];
122 static size_t cOSTypes;
123
124 /**
125 * Maps VBOXOSTYPE to the OS type which is used in VM configs.
126 */
127 static const char *OSTypeId(VBOXOSTYPE aOSType);
128
129 /**
130 * Maps an OS type ID string to index into sOSTypes.
131 * @returns index on success, UINT32_MAX if not found.
132 */
133 static uint32_t getOSTypeIndexFromId(const char *pszId);
134
135 /**
136 * Returns @c true if the given machine state is an online state. This is a
137 * recommended way to detect if the VM is online (being executed in a
138 * dedicated process) or not. Note that some online states are also
139 * transitional states (see #IsTransient()).
140 */
141 static bool IsOnline(MachineState_T aState)
142 {
143 return aState >= MachineState_FirstOnline &&
144 aState <= MachineState_LastOnline;
145 }
146
147 /**
148 * Returns @c true if the given machine state is a transient state. This is
149 * a recommended way to detect if the VM is performing some potentially
150 * lengthy operation (such as starting, stopping, saving, deleting
151 * snapshot, etc.). Note some (but not all) transitional states are also
152 * online states (see #IsOnline()).
153 */
154 static bool IsTransient(MachineState_T aState)
155 {
156 return aState >= MachineState_FirstTransient &&
157 aState <= MachineState_LastTransient;
158 }
159
160 /**
161 * Shortcut to <tt>IsOnline(aState) || IsTransient(aState)</tt>. When it returns
162 * @c false, the VM is turned off (no VM process) and not busy with
163 * another exclusive operation.
164 */
165 static bool IsOnlineOrTransient(MachineState_T aState)
166 {
167 return IsOnline(aState) || IsTransient(aState);
168 }
169
170 /**
171 * Stringify a machine state - translated.
172 *
173 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
174 * version of this method.
175 *
176 * @returns Pointer to a read only string.
177 * @param aState Valid machine state.
178 */
179 static const char *stringifyMachineState(MachineState_T aState);
180
181 /**
182 * Stringify a session state - translated.
183 *
184 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
185 * version of this method.
186 *
187 * @returns Pointer to a read only string.
188 * @param aState Valid session state.
189 */
190 static const char *stringifySessionState(SessionState_T aState);
191
192 /**
193 * Stringify a device type.
194 *
195 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
196 * version of this method.
197 *
198 * @returns Pointer to a read only string.
199 * @param aType The device type.
200 */
201 static const char *stringifyDeviceType(DeviceType_T aType);
202
203 /**
204 * Stringify a platform architecture to a string.
205 *
206 * @returns Platform architecture as a string.
207 * @param aEnmArchitecture Platform architecture to convert.
208 */
209 static const char *stringifyPlatformArchitecture(PlatformArchitecture_T aEnmArchitecture);
210
211 /**
212 * Stringify a storage controller type.
213 *
214 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
215 * version of this method.
216 *
217 * @returns Pointer to a read only string.
218 * @param aType The storage controller type.
219 */
220 static const char *stringifyStorageControllerType(StorageControllerType_T aType);
221
222#if 0 /* unused */
223 /**
224 * Stringify a storage bus type.
225 *
226 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
227 * version of this method.
228 *
229 * @returns Pointer to a read only string.
230 * @param aBus The storage bus type.
231 */
232 static const char *stringifyStorageBus(StorageBus_T aBus);
233
234 /**
235 * Stringify a reason.
236 *
237 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
238 * version of this method.
239 *
240 * @returns Pointer to a read only string.
241 * @param aReason The reason code.
242 */
243 static const char *stringifyReason(Reason_T aReason);
244#endif
245
246 /**
247 * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
248 *
249 * @returns VBox status code.
250 * @param aComStatus COM status code.
251 */
252 static int vboxStatusCodeFromCOM(HRESULT aComStatus);
253
254 /**
255 * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
256 *
257 * This is mainly intended for dealing with vboxStatusCodeFromCOM() return
258 * values. If used on anything else, it won't be able to cope with most of the
259 * input!
260 *
261 * @returns COM status code.
262 * @param aVBoxStatus VBox status code.
263 */
264 static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
265};
266
267#endif /* !MAIN_INCLUDED_Global_h */
268/* 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