VirtualBox

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

Last change on this file was 102455, checked in by vboxsync, 5 months ago

Main: Removed some more BUGBUG entries and documented empty / non-implemented code areas where needed. bugref:10384

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
1/* $Id: PlatformARMImpl.cpp 102455 2023-12-04 15:53:11Z 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.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#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 /* share the parent + machine weakly */
89 unconst(mParent) = aParent;
90 unconst(mMachine) = aMachine;
91
92 m = new Data;
93 m->bd.allocate();
94
95 autoInitSpan.setSucceeded();
96
97 return S_OK;
98}
99
100/**
101 * Initializes the platform object given another platform object
102 * (a kind of copy constructor). This object shares data with
103 * the object passed as an argument.
104 *
105 * @note This object must be destroyed before the original object
106 * it shares data with is destroyed.
107 */
108HRESULT PlatformARM::init(Platform *aParent, Machine *aMachine, PlatformARM *aThat)
109{
110 /* Enclose the state transition NotReady->InInit->Ready */
111 AutoInitSpan autoInitSpan(this);
112 AssertReturn(autoInitSpan.isOk(), E_FAIL);
113
114 ComAssertRet(aParent && aParent, E_INVALIDARG);
115
116 unconst(mParent) = aParent;
117 unconst(mMachine) = aMachine;
118
119 m = new Data();
120 m->pPeer = aThat;
121
122 AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
123 m->bd.share(aThat->m->bd);
124
125 autoInitSpan.setSucceeded();
126
127 return S_OK;
128}
129
130/**
131 * Initializes the guest object given another guest object
132 * (a kind of copy constructor). This object makes a private copy of data
133 * of the original object passed as an argument.
134 */
135HRESULT PlatformARM::initCopy(Platform *aParent, Machine *aMachine, PlatformARM *aThat)
136{
137 ComAssertRet(aParent && aParent, E_INVALIDARG);
138
139 /* Enclose the state transition NotReady->InInit->Ready */
140 AutoInitSpan autoInitSpan(this);
141 AssertReturn(autoInitSpan.isOk(), E_FAIL);
142
143 unconst(mParent) = aParent;
144 unconst(mMachine) = aMachine;
145
146 m = new Data();
147 // m->pPeer is left null
148
149 AutoWriteLock thatlock(aThat COMMA_LOCKVAL_SRC_POS); /** @todo r=andy Shouldn't a read lock be sufficient here? */
150 m->bd.attachCopy(aThat->m->bd);
151
152 autoInitSpan.setSucceeded();
153
154 return S_OK;
155}
156
157void PlatformARM::uninit()
158{
159 /* Enclose the state transition Ready->InUninit->NotReady */
160 AutoUninitSpan autoUninitSpan(this);
161 if (autoUninitSpan.uninitDone())
162 return;
163
164 unconst(mMachine) = NULL;
165
166 if (m)
167 {
168 m->bd.free();
169 unconst(m->pPeer) = NULL;
170
171 delete m;
172 m = NULL;
173 }
174}
175
176void PlatformARM::i_rollback()
177{
178 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
179 if (m)
180 m->bd.rollback();
181}
182
183void PlatformARM::i_commit()
184{
185 /* sanity */
186 AutoCaller autoCaller(this);
187 AssertComRCReturnVoid(autoCaller.hrc());
188
189 /* sanity too */
190 AutoCaller peerCaller(m->pPeer);
191 AssertComRCReturnVoid(peerCaller.hrc());
192
193 /* lock both for writing since we modify both (mPeer is "master" so locked
194 * first) */
195 AutoMultiWriteLock2 alock(m->pPeer, this COMMA_LOCKVAL_SRC_POS);
196
197 if (m->bd.isBackedUp())
198 {
199 m->bd.commit();
200 if (m->pPeer)
201 {
202 /* attach new data to the peer and reshare it */
203 AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS);
204 m->pPeer->m->bd.attach(m->bd);
205 }
206 }
207}
208
209void PlatformARM::i_copyFrom(PlatformARM *aThat)
210{
211 AssertReturnVoid(aThat != NULL);
212
213 /* sanity */
214 AutoCaller autoCaller(this);
215 AssertComRCReturnVoid(autoCaller.hrc());
216
217 /* sanity too */
218 AutoCaller thatCaller(aThat);
219 AssertComRCReturnVoid(thatCaller.hrc());
220
221 /* peer is not modified, lock it for reading (aThat is "master" so locked
222 * first) */
223 AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS);
224 AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
225
226 /* this will back up current data */
227 m->bd.assignCopy(aThat->m->bd);
228}
229
230/**
231 * Loads settings from the given platform ARM node.
232 * May be called once right after this object creation.
233 *
234 * @returns HRESULT
235 * @param data Configuration settings.
236 *
237 * @note Locks this object for writing.
238 */
239HRESULT PlatformARM::i_loadSettings(const settings::PlatformARM &data)
240{
241 RT_NOREF(data);
242
243 /* Nothing here yet. */
244 return S_OK;
245}
246
247/**
248 * Saves settings to the given platform ARM node.
249 *
250 * @returns HRESULT
251 * @param data Configuration settings.
252 *
253 * @note Locks this object for reading.
254 */
255HRESULT PlatformARM::i_saveSettings(settings::PlatformARM &data)
256{
257 RT_NOREF(data);
258
259 /* Nothing here yet. */
260 return S_OK;
261}
262
263HRESULT PlatformARM::i_applyDefaults(GuestOSType *aOsType)
264{
265 RT_NOREF(aOsType);
266
267 /* Nothing here yet. */
268 return S_OK;
269}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use