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