1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "GuestOSTypeImpl.h"
|
---|
23 | #include "Logging.h"
|
---|
24 | #include <iprt/cpputils.h>
|
---|
25 |
|
---|
26 | // constructor / destructor
|
---|
27 | /////////////////////////////////////////////////////////////////////////////
|
---|
28 |
|
---|
29 | GuestOSType::GuestOSType()
|
---|
30 | : mOSType (VBOXOSTYPE_Unknown)
|
---|
31 | , mOSHint (VBOXOSHINT_NONE)
|
---|
32 | , mRAMSize (0), mVRAMSize (0)
|
---|
33 | , mHDDSize (0), mMonitorCount (0)
|
---|
34 | , mNetworkAdapterType (NetworkAdapterType_Am79C973)
|
---|
35 | , mNumSerialEnabled (0)
|
---|
36 | {
|
---|
37 | }
|
---|
38 |
|
---|
39 | GuestOSType::~GuestOSType()
|
---|
40 | {
|
---|
41 | }
|
---|
42 |
|
---|
43 | HRESULT GuestOSType::FinalConstruct()
|
---|
44 | {
|
---|
45 | return S_OK;
|
---|
46 | }
|
---|
47 |
|
---|
48 | void GuestOSType::FinalRelease()
|
---|
49 | {
|
---|
50 | uninit();
|
---|
51 | }
|
---|
52 |
|
---|
53 | // public initializer/uninitializer for internal purposes only
|
---|
54 | /////////////////////////////////////////////////////////////////////////////
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Initializes the guest OS type object.
|
---|
58 | *
|
---|
59 | * @returns COM result indicator
|
---|
60 | * @param aFamilyId os family short name string
|
---|
61 | * @param aFamilyDescription os family name string
|
---|
62 | * @param aId os short name string
|
---|
63 | * @param aDescription os name string
|
---|
64 | * @param aOSType global OS type ID
|
---|
65 | * @param aOSHint os configuration hint
|
---|
66 | * @param aRAMSize recommended RAM size in megabytes
|
---|
67 | * @param aVRAMSize recommended video memory size in megabytes
|
---|
68 | * @param aHDDSize recommended HDD size in megabytes
|
---|
69 | */
|
---|
70 | HRESULT GuestOSType::init (const char *aFamilyId, const char *aFamilyDescription,
|
---|
71 | const char *aId, const char *aDescription,
|
---|
72 | VBOXOSTYPE aOSType, uint32_t aOSHint,
|
---|
73 | uint32_t aRAMSize, uint32_t aVRAMSize, uint32_t aHDDSize,
|
---|
74 | NetworkAdapterType_T aNetworkAdapterType, uint32_t aNumSerialEnabled)
|
---|
75 | {
|
---|
76 | #if 0
|
---|
77 | LogFlowThisFunc(("aFamilyId='%s', aFamilyDescription='%s', "
|
---|
78 | "aId='%s', aDescription='%s', "
|
---|
79 | "aType=%d, aOSHint=%x, "
|
---|
80 | "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%d, "
|
---|
81 | "aNetworkAdapterType=%d, aNumSerialEnabled=%d\n",
|
---|
82 | aFamilyId, aFamilyDescription,
|
---|
83 | aId, aDescription,
|
---|
84 | aOSType, aOSHint,
|
---|
85 | aRAMSize, aVRAMSize, aHDDSize,
|
---|
86 | aNetworkAdapterType, aNumSerialEnabled));
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | ComAssertRet (aFamilyId && aFamilyDescription && aId && aDescription, E_INVALIDARG);
|
---|
90 |
|
---|
91 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
92 | AutoInitSpan autoInitSpan(this);
|
---|
93 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
94 |
|
---|
95 | unconst(mFamilyID) = aFamilyId;
|
---|
96 | unconst(mFamilyDescription) = aFamilyDescription;
|
---|
97 | unconst(mID) = aId;
|
---|
98 | unconst(mDescription) = aDescription;
|
---|
99 | unconst(mOSType) = aOSType;
|
---|
100 | unconst(mOSHint) = aOSHint;
|
---|
101 | unconst(mRAMSize) = aRAMSize;
|
---|
102 | unconst(mVRAMSize) = aVRAMSize;
|
---|
103 | unconst(mHDDSize) = aHDDSize;
|
---|
104 | unconst(mNetworkAdapterType) = aNetworkAdapterType;
|
---|
105 | unconst(mNumSerialEnabled) = aNumSerialEnabled;
|
---|
106 |
|
---|
107 | /* Confirm a successful initialization when it's the case */
|
---|
108 | autoInitSpan.setSucceeded();
|
---|
109 |
|
---|
110 | return S_OK;
|
---|
111 | }
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
115 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
116 | */
|
---|
117 | void GuestOSType::uninit()
|
---|
118 | {
|
---|
119 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
120 | AutoUninitSpan autoUninitSpan(this);
|
---|
121 | if (autoUninitSpan.uninitDone())
|
---|
122 | return;
|
---|
123 | }
|
---|
124 |
|
---|
125 | // IGuestOSType properties
|
---|
126 | /////////////////////////////////////////////////////////////////////////////
|
---|
127 |
|
---|
128 | STDMETHODIMP GuestOSType::COMGETTER(FamilyId) (BSTR *aFamilyId)
|
---|
129 | {
|
---|
130 | CheckComArgOutPointerValid(aFamilyId);
|
---|
131 |
|
---|
132 | AutoCaller autoCaller(this);
|
---|
133 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
134 |
|
---|
135 | /* mFamilyID is constant during life time, no need to lock */
|
---|
136 | mFamilyID.cloneTo(aFamilyId);
|
---|
137 |
|
---|
138 | return S_OK;
|
---|
139 | }
|
---|
140 |
|
---|
141 | STDMETHODIMP GuestOSType::COMGETTER(FamilyDescription) (BSTR *aFamilyDescription)
|
---|
142 | {
|
---|
143 | CheckComArgOutPointerValid(aFamilyDescription);
|
---|
144 |
|
---|
145 | AutoCaller autoCaller(this);
|
---|
146 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
147 |
|
---|
148 | /* mFamilyDescription is constant during life time, no need to lock */
|
---|
149 | mFamilyDescription.cloneTo(aFamilyDescription);
|
---|
150 |
|
---|
151 | return S_OK;
|
---|
152 | }
|
---|
153 |
|
---|
154 | STDMETHODIMP GuestOSType::COMGETTER(Id) (BSTR *aId)
|
---|
155 | {
|
---|
156 | CheckComArgOutPointerValid(aId);
|
---|
157 |
|
---|
158 | AutoCaller autoCaller(this);
|
---|
159 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
160 |
|
---|
161 | /* mID is constant during life time, no need to lock */
|
---|
162 | mID.cloneTo(aId);
|
---|
163 |
|
---|
164 | return S_OK;
|
---|
165 | }
|
---|
166 |
|
---|
167 | STDMETHODIMP GuestOSType::COMGETTER(Description) (BSTR *aDescription)
|
---|
168 | {
|
---|
169 | CheckComArgOutPointerValid(aDescription);
|
---|
170 |
|
---|
171 | AutoCaller autoCaller(this);
|
---|
172 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
173 |
|
---|
174 | /* mDescription is constant during life time, no need to lock */
|
---|
175 | mDescription.cloneTo(aDescription);
|
---|
176 |
|
---|
177 | return S_OK;
|
---|
178 | }
|
---|
179 |
|
---|
180 | STDMETHODIMP GuestOSType::COMGETTER(Is64Bit) (BOOL *aIs64Bit)
|
---|
181 | {
|
---|
182 | CheckComArgOutPointerValid(aIs64Bit);
|
---|
183 |
|
---|
184 | AutoCaller autoCaller(this);
|
---|
185 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
186 |
|
---|
187 | /* mIs64Bit is constant during life time, no need to lock */
|
---|
188 | *aIs64Bit = !!(mOSHint & VBOXOSHINT_64BIT);
|
---|
189 |
|
---|
190 | return S_OK;
|
---|
191 | }
|
---|
192 |
|
---|
193 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedIOAPIC) (BOOL *aRecommendedIOAPIC)
|
---|
194 | {
|
---|
195 | CheckComArgOutPointerValid(aRecommendedIOAPIC);
|
---|
196 |
|
---|
197 | AutoCaller autoCaller(this);
|
---|
198 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
199 |
|
---|
200 | /* mRecommendedIOAPIC is constant during life time, no need to lock */
|
---|
201 | *aRecommendedIOAPIC = !!(mOSHint & VBOXOSHINT_IOAPIC);
|
---|
202 |
|
---|
203 | return S_OK;
|
---|
204 | }
|
---|
205 |
|
---|
206 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedVirtEx) (BOOL *aRecommendedVirtEx)
|
---|
207 | {
|
---|
208 | CheckComArgOutPointerValid(aRecommendedVirtEx);
|
---|
209 |
|
---|
210 | AutoCaller autoCaller(this);
|
---|
211 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
212 |
|
---|
213 | /* mRecommendedVirtEx is constant during life time, no need to lock */
|
---|
214 | *aRecommendedVirtEx = !!(mOSHint & VBOXOSHINT_HWVIRTEX);
|
---|
215 |
|
---|
216 | return S_OK;
|
---|
217 | }
|
---|
218 |
|
---|
219 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedRAM) (ULONG *aRAMSize)
|
---|
220 | {
|
---|
221 | CheckComArgOutPointerValid(aRAMSize);
|
---|
222 |
|
---|
223 | AutoCaller autoCaller(this);
|
---|
224 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
225 |
|
---|
226 | /* mRAMSize is constant during life time, no need to lock */
|
---|
227 | *aRAMSize = mRAMSize;
|
---|
228 |
|
---|
229 | return S_OK;
|
---|
230 | }
|
---|
231 |
|
---|
232 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedVRAM) (ULONG *aVRAMSize)
|
---|
233 | {
|
---|
234 | CheckComArgOutPointerValid(aVRAMSize);
|
---|
235 |
|
---|
236 | AutoCaller autoCaller(this);
|
---|
237 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
238 |
|
---|
239 | /* mVRAMSize is constant during life time, no need to lock */
|
---|
240 | *aVRAMSize = mVRAMSize;
|
---|
241 |
|
---|
242 | return S_OK;
|
---|
243 | }
|
---|
244 |
|
---|
245 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedHDD) (ULONG *aHDDSize)
|
---|
246 | {
|
---|
247 | CheckComArgOutPointerValid(aHDDSize);
|
---|
248 |
|
---|
249 | AutoCaller autoCaller(this);
|
---|
250 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
251 |
|
---|
252 | /* mHDDSize is constant during life time, no need to lock */
|
---|
253 | *aHDDSize = mHDDSize;
|
---|
254 |
|
---|
255 | return S_OK;
|
---|
256 | }
|
---|
257 |
|
---|
258 | STDMETHODIMP GuestOSType::COMGETTER(AdapterType) (NetworkAdapterType_T *aNetworkAdapterType)
|
---|
259 | {
|
---|
260 | CheckComArgOutPointerValid(aNetworkAdapterType);
|
---|
261 |
|
---|
262 | AutoCaller autoCaller(this);
|
---|
263 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
264 |
|
---|
265 | /* mNetworkAdapterType is constant during life time, no need to lock */
|
---|
266 | *aNetworkAdapterType = mNetworkAdapterType;
|
---|
267 |
|
---|
268 | return S_OK;
|
---|
269 | }
|
---|
270 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|