VirtualBox

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

Last change on this file since 100609 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1/* $Id: Global.h 98103 2023-01-17 14:15: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#define VBOXOSHINT_NONE 0
42#define VBOXOSHINT_64BIT RT_BIT(0)
43#define VBOXOSHINT_HWVIRTEX RT_BIT(1)
44#define VBOXOSHINT_IOAPIC RT_BIT(2)
45#define VBOXOSHINT_EFI RT_BIT(3)
46#define VBOXOSHINT_PAE RT_BIT(4)
47#define VBOXOSHINT_USBHID RT_BIT(5)
48#define VBOXOSHINT_HPET RT_BIT(6)
49#define VBOXOSHINT_USBTABLET RT_BIT(7)
50#define VBOXOSHINT_RTCUTC RT_BIT(8)
51#define VBOXOSHINT_ACCEL2D RT_BIT(9)
52#define VBOXOSHINT_ACCEL3D RT_BIT(10)
53#define VBOXOSHINT_FLOPPY RT_BIT(11)
54#define VBOXOSHINT_NOUSB RT_BIT(12)
55#define VBOXOSHINT_TFRESET RT_BIT(13)
56#define VBOXOSHINT_USB3 RT_BIT(14)
57#define VBOXOSHINT_X2APIC RT_BIT(15)
58#define VBOXOSHINT_EFI_SECUREBOOT RT_BIT(16)
59#define VBOXOSHINT_TPM RT_BIT(17)
60#define VBOXOSHINT_TPM2 RT_BIT(18)
61#define VBOXOSHINT_WDDM_GRAPHICS RT_BIT(19)
62
63/** The VBoxVRDP kludge extension pack name.
64 *
65 * This is not a valid extension pack name (dashes are not allowed), and
66 * hence will not conflict with real extension packs.
67 */
68#define VBOXVRDP_KLUDGE_EXTPACK_NAME "Built-in-VBoxVRDP"
69
70/** The VBoxPuelCrypto kludge extension pack name.
71 *
72 * This is not a valid extension pack name (dashes are not allowed), and
73 * hence will not conflict with real extension packs.
74 */
75#define VBOXPUELCRYPTO_KLUDGE_EXTPACK_NAME "Built-in-VBoxPuelCrypto"
76
77/**
78 * Contains global static definitions that can be referenced by all COM classes
79 * regardless of the apartment.
80 */
81class Global
82{
83public:
84
85 /** Represents OS Type <-> string mappings. */
86 struct OSType
87 {
88 const char *familyId; /* utf-8 */
89 const char *familyDescription; /* utf-8 */
90 const char *id; /* utf-8, VM config file value */
91 const char *description; /* utf-8 */
92 const VBOXOSTYPE osType;
93 const uint32_t osHint;
94 const uint32_t recommendedCPUCount;
95 const uint32_t recommendedRAM;
96 const uint32_t recommendedVRAM;
97 const uint64_t recommendedHDD;
98 const GraphicsControllerType_T graphicsControllerType;
99 const NetworkAdapterType_T networkAdapterType;
100 const uint32_t numSerialEnabled;
101 const StorageControllerType_T dvdStorageControllerType;
102 const StorageBus_T dvdStorageBusType;
103 const StorageControllerType_T hdStorageControllerType;
104 const StorageBus_T hdStorageBusType;
105 const ChipsetType_T chipsetType;
106 const IommuType_T iommuType;
107 const AudioControllerType_T audioControllerType;
108 const AudioCodecType_T audioCodecType;
109 };
110
111 static const OSType sOSTypes[];
112 static size_t cOSTypes;
113
114 /**
115 * Maps VBOXOSTYPE to the OS type which is used in VM configs.
116 */
117 static const char *OSTypeId(VBOXOSTYPE aOSType);
118
119 /**
120 * Maps an OS type ID string to index into sOSTypes.
121 * @returns index on success, UINT32_MAX if not found.
122 */
123 static uint32_t getOSTypeIndexFromId(const char *pszId);
124
125 /**
126 * Get the network adapter limit for each chipset type.
127 */
128 static uint32_t getMaxNetworkAdapters(ChipsetType_T aChipsetType);
129
130 /**
131 * Returns @c true if the given machine state is an online state. This is a
132 * recommended way to detect if the VM is online (being executed in a
133 * dedicated process) or not. Note that some online states are also
134 * transitional states (see #IsTransient()).
135 */
136 static bool IsOnline(MachineState_T aState)
137 {
138 return aState >= MachineState_FirstOnline &&
139 aState <= MachineState_LastOnline;
140 }
141
142 /**
143 * Returns @c true if the given machine state is a transient state. This is
144 * a recommended way to detect if the VM is performing some potentially
145 * lengthy operation (such as starting, stopping, saving, deleting
146 * snapshot, etc.). Note some (but not all) transitional states are also
147 * online states (see #IsOnline()).
148 */
149 static bool IsTransient(MachineState_T aState)
150 {
151 return aState >= MachineState_FirstTransient &&
152 aState <= MachineState_LastTransient;
153 }
154
155 /**
156 * Shortcut to <tt>IsOnline(aState) || IsTransient(aState)</tt>. When it returns
157 * @c false, the VM is turned off (no VM process) and not busy with
158 * another exclusive operation.
159 */
160 static bool IsOnlineOrTransient(MachineState_T aState)
161 {
162 return IsOnline(aState) || IsTransient(aState);
163 }
164
165 /**
166 * Stringify a machine state - translated.
167 *
168 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
169 * version of this method.
170 *
171 * @returns Pointer to a read only string.
172 * @param aState Valid machine state.
173 */
174 static const char *stringifyMachineState(MachineState_T aState);
175
176 /**
177 * Stringify a session state - translated.
178 *
179 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
180 * version of this method.
181 *
182 * @returns Pointer to a read only string.
183 * @param aState Valid session state.
184 */
185 static const char *stringifySessionState(SessionState_T aState);
186
187 /**
188 * Stringify a device type.
189 *
190 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
191 * version of this method.
192 *
193 * @returns Pointer to a read only string.
194 * @param aType The device type.
195 */
196 static const char *stringifyDeviceType(DeviceType_T aType);
197
198 /**
199 * Stringify a storage controller type.
200 *
201 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
202 * version of this method.
203 *
204 * @returns Pointer to a read only string.
205 * @param aType The storage controller type.
206 */
207 static const char *stringifyStorageControllerType(StorageControllerType_T aType);
208
209#if 0 /* unused */
210 /**
211 * Stringify a storage bus type.
212 *
213 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
214 * version of this method.
215 *
216 * @returns Pointer to a read only string.
217 * @param aBus The storage bus type.
218 */
219 static const char *stringifyStorageBus(StorageBus_T aBus);
220
221 /**
222 * Stringify a reason.
223 *
224 * Drop the Global:: prefix and include StringifyEnums.h for an untranslated
225 * version of this method.
226 *
227 * @returns Pointer to a read only string.
228 * @param aReason The reason code.
229 */
230 static const char *stringifyReason(Reason_T aReason);
231#endif
232
233 /**
234 * Try convert a COM status code to a VirtualBox status code (VBox/err.h).
235 *
236 * @returns VBox status code.
237 * @param aComStatus COM status code.
238 */
239 static int vboxStatusCodeFromCOM(HRESULT aComStatus);
240
241 /**
242 * Try convert a VirtualBox status code (VBox/err.h) to a COM status code.
243 *
244 * This is mainly intended for dealing with vboxStatusCodeFromCOM() return
245 * values. If used on anything else, it won't be able to cope with most of the
246 * input!
247 *
248 * @returns COM status code.
249 * @param aVBoxStatus VBox status code.
250 */
251 static HRESULT vboxStatusCodeToCOM(int aVBoxStatus);
252};
253
254#endif /* !MAIN_INCLUDED_Global_h */
255/* 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