VirtualBox

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

Last change on this file since 95753 was 94714, checked in by vboxsync, 3 years ago

Main,Settings: Integrate the extension pack cryptographic module in the ExtPack manager etc., bugref:9955

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