VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/PlatformARMImpl.cpp@ 101057

最後變更 在這個檔案從101057是 101054,由 vboxsync 提交於 19 月 前

Main: More checks for (un)supported platforms. See comments for details. bugref:10384

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.1 KB
 
1/* $Id: PlatformARMImpl.cpp 101054 2023-09-07 13:59:53Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation - ARM platform settings.
4 */
5
6/*
7 * Copyright (C) 2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.alldomusa.eu.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#define LOG_GROUP LOG_GROUP_MAIN_PLATFORMARM
29#include "MachineImpl.h"
30#include "PlatformARMImpl.h"
31#include "PlatformImpl.h"
32#include "LoggingNew.h"
33
34#include <VBox/settings.h>
35
36#include <iprt/cpp/utils.h>
37
38
39/**
40 * ARM-specific platform data.
41 *
42 * This data is unique for a machine and for every machine snapshot.
43 * Stored using the util::Backupable template in the |mPlatformARMData| variable.
44 *
45 * SessionMachine instances can alter this data and discard changes.
46 */
47struct Data
48{
49 Data() { }
50
51 ComObjPtr<PlatformARM> pPeer;
52
53 // use the XML settings structure in the members for simplicity
54 Backupable<settings::PlatformARM> bd;
55};
56
57
58/*
59 * PlatformARM implementation.
60 */
61PlatformARM::PlatformARM()
62{
63}
64
65PlatformARM::~PlatformARM()
66{
67 uninit();
68}
69
70HRESULT PlatformARM::FinalConstruct()
71{
72 return BaseFinalConstruct();
73}
74
75void PlatformARM::FinalRelease()
76{
77 uninit();
78
79 BaseFinalRelease();
80}
81
82HRESULT PlatformARM::init(Platform *aParent, Machine *aMachine)
83{
84 /* Enclose the state transition NotReady->InInit->Ready */
85 AutoInitSpan autoInitSpan(this);
86 AssertReturn(autoInitSpan.isOk(), E_FAIL);
87
88 RT_NOREF(aParent, aMachine);
89
90 autoInitSpan.setSucceeded();
91
92 return S_OK;
93}
94
95/**
96 * Initializes the platform object given another platform object
97 * (a kind of copy constructor). This object shares data with
98 * the object passed as an argument.
99 *
100 * @note This object must be destroyed before the original object
101 * it shares data with is destroyed.
102 */
103HRESULT PlatformARM::init(Platform *aParent, Machine *aMachine, PlatformARM *aThat)
104{
105 /* Enclose the state transition NotReady->InInit->Ready */
106 AutoInitSpan autoInitSpan(this);
107 AssertReturn(autoInitSpan.isOk(), E_FAIL);
108
109 ComAssertRet(aParent && aParent, E_INVALIDARG);
110
111 unconst(mParent) = aParent;
112 unconst(mMachine) = aMachine;
113
114 m = new Data();
115 m->pPeer = aThat;
116
117 AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
118 m->bd.share(aThat->m->bd);
119
120 autoInitSpan.setSucceeded();
121
122 return S_OK;
123}
124
125/**
126 * Initializes the guest object given another guest object
127 * (a kind of copy constructor). This object makes a private copy of data
128 * of the original object passed as an argument.
129 */
130HRESULT PlatformARM::initCopy(Platform *aParent, Machine *aMachine, PlatformARM *aThat)
131{
132 ComAssertRet(aParent && aParent, E_INVALIDARG);
133
134 /* Enclose the state transition NotReady->InInit->Ready */
135 AutoInitSpan autoInitSpan(this);
136 AssertReturn(autoInitSpan.isOk(), E_FAIL);
137
138 unconst(mParent) = aParent;
139 unconst(mMachine) = aMachine;
140
141 m = new Data();
142 // m->pPeer is left null
143
144 AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS); /** @todo r=andy Shouldn't a read lock be sufficient here? */
145 m->bd.attachCopy(aThat->m->bd);
146
147 autoInitSpan.setSucceeded();
148
149 return S_OK;
150}
151
152void PlatformARM::uninit()
153{
154 /* Enclose the state transition Ready->InUninit->NotReady */
155 AutoUninitSpan autoUninitSpan(this);
156 if (autoUninitSpan.uninitDone())
157 return;
158
159 unconst(mMachine) = NULL;
160
161 if (m)
162 {
163 m->bd.free();
164 unconst(m->pPeer) = NULL;
165
166 delete m;
167 m = NULL;
168 }
169}
170
171void PlatformARM::i_rollback()
172{
173 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
174 if (m)
175 m->bd.rollback();
176}
177
178void PlatformARM::i_commit()
179{
180 /* sanity */
181 AutoCaller autoCaller(this);
182 AssertComRCReturnVoid(autoCaller.hrc());
183
184 /* sanity too */
185 AutoCaller peerCaller(m->pPeer);
186 AssertComRCReturnVoid(peerCaller.hrc());
187
188 /* lock both for writing since we modify both (mPeer is "master" so locked
189 * first) */
190 AutoMultiWriteLock2 alock(m->pPeer, this COMMA_LOCKVAL_SRC_POS);
191
192 if (m->bd.isBackedUp())
193 {
194 m->bd.commit();
195 if (m->pPeer)
196 {
197 /* attach new data to the peer and reshare it */
198 AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS);
199 m->pPeer->m->bd.attach(m->bd);
200 }
201 }
202}
203
204void PlatformARM::i_copyFrom(PlatformARM *aThat)
205{
206 AssertReturnVoid(aThat != NULL);
207
208 /* sanity */
209 AutoCaller autoCaller(this);
210 AssertComRCReturnVoid(autoCaller.hrc());
211
212 /* sanity too */
213 AutoCaller thatCaller(aThat);
214 AssertComRCReturnVoid(thatCaller.hrc());
215
216 /* peer is not modified, lock it for reading (aThat is "master" so locked
217 * first) */
218 AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS);
219 AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
220
221 /* this will back up current data */
222 m->bd.assignCopy(aThat->m->bd);
223}
224
225/**
226 * Loads settings from the given platform ARM node.
227 * May be called once right after this object creation.
228 *
229 * @returns HRESULT
230 * @param data Configuration settings.
231 *
232 * @note Locks this object for writing.
233 */
234HRESULT PlatformARM::i_loadSettings(const settings::PlatformARM &data)
235{
236 RT_NOREF(data);
237
238 /** @todo BUGBUG Implement this form ARM! */
239 return E_NOTIMPL;
240}
241
242/**
243 * Saves settings to the given platform ARM node.
244 *
245 * @returns HRESULT
246 * @param data Configuration settings.
247 *
248 * @note Locks this object for reading.
249 */
250HRESULT PlatformARM::i_saveSettings(settings::PlatformARM &data)
251{
252 RT_NOREF(data);
253
254 /** @todo BUGBUG Implement this form ARM! */
255 return E_NOTIMPL;
256}
257
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette