VirtualBox

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

Last change on this file since 101683 was 101683, checked in by vboxsync, 8 months ago

Main/Unattended|GuestOSType: Add an entry in the guest OS type to indicate the name of the additions install package instead of hardcoding it in the templates. Allows easy adaption if something changes and makes it possible to auto install guest additions for linux.arm64 guests, bugref:10542

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.4 KB
Line 
1/* $Id: Global.h 101683 2023-10-31 12:38:46Z 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 *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 platform architecture to a string.
206 *
207 * @returns Platform architecture as a string.
208 * @param aEnmArchitecture Platform architecture to convert.
209 */
210 static const char *stringifyPlatformArchitecture(PlatformArchitecture_T aEnmArchitecture);
211
212 /**
213 * Stringify a storage controller type.
214 *
215 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
216 * version of this method.
217 *
218 * @returns Pointer to a read only string.
219 * @param aType The storage controller type.
220 */
221 static const char *stringifyStorageControllerType(StorageControllerType_T aType);
222
223#if 0 /* unused */
224 /**
225 * Stringify a storage bus type.
226 *
227 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
228 * version of this method.
229 *
230 * @returns Pointer to a read only string.
231 * @param aBus The storage bus type.
232 */
233 static const char *stringifyStorageBus(StorageBus_T aBus);
234
235 /**
236 * Stringify a reason.
237 *
238 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
239 * version of this method.
240 *
241 * @returns Pointer to a read only string.
242 * @param aReason The reason code.
243 */
244 static const char *stringifyReason(Reason_T aReason);
245#endif
246
247 /**
248 * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
249 *
250 * @returns VBox status code.
251 * @param aComStatus COM status code.
252 */
253 static int vboxStatusCodeFromCOM(HRESULT aComStatus);
254
255 /**
256 * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
257 *
258 * This is mainly intended for dealing with vboxStatusCodeFromCOM() return
259 * values. If used on anything else, it won't be able to cope with most of the
260 * input!
261 *
262 * @returns COM status code.
263 * @param aVBoxStatus VBox status code.
264 */
265 static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
266};
267
268#endif /* !MAIN_INCLUDED_Global_h */
269/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use