VirtualBox

source: vbox/trunk/src/VBox/Main/src-all/PCIDeviceAttachmentImpl.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* $Id: PCIDeviceAttachmentImpl.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * PCI attachment information implmentation.
4 */
5
6/*
7 * Copyright (C) 2010-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_PCIDEVICEATTACHMENT
29#include "PCIDeviceAttachmentImpl.h"
30#include "AutoCaller.h"
31#include "Global.h"
32#include "LoggingNew.h"
33
34#include <VBox/settings.h>
35
36struct PCIDeviceAttachment::Data
37{
38 Data(const Utf8Str &aDevName,
39 LONG aHostAddress,
40 LONG aGuestAddress,
41 BOOL afPhysical) :
42 DevName(aDevName),
43 HostAddress(aHostAddress),
44 GuestAddress(aGuestAddress),
45 fPhysical(afPhysical)
46 {
47 }
48
49 Utf8Str DevName;
50 LONG HostAddress;
51 LONG GuestAddress;
52 BOOL fPhysical;
53};
54
55// constructor / destructor
56/////////////////////////////////////////////////////////////////////////////
57DEFINE_EMPTY_CTOR_DTOR(PCIDeviceAttachment)
58
59HRESULT PCIDeviceAttachment::FinalConstruct()
60{
61 LogFlowThisFunc(("\n"));
62 return BaseFinalConstruct();
63}
64
65void PCIDeviceAttachment::FinalRelease()
66{
67 LogFlowThisFunc(("\n"));
68 uninit();
69 BaseFinalRelease();
70}
71
72// public initializer/uninitializer for internal purposes only
73/////////////////////////////////////////////////////////////////////////////
74HRESULT PCIDeviceAttachment::init(IMachine *aParent,
75 const Utf8Str &aDevName,
76 LONG aHostAddress,
77 LONG aGuestAddress,
78 BOOL fPhysical)
79{
80 NOREF(aParent);
81
82 /* Enclose the state transition NotReady->InInit->Ready */
83 AutoInitSpan autoInitSpan(this);
84 AssertReturn(autoInitSpan.isOk(), E_FAIL);
85
86 m = new Data(aDevName, aHostAddress, aGuestAddress, fPhysical);
87
88 /* Confirm a successful initialization */
89 autoInitSpan.setSucceeded();
90
91 return S_OK;
92}
93
94HRESULT PCIDeviceAttachment::initCopy(IMachine *aParent, PCIDeviceAttachment *aThat)
95{
96 LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
97
98 ComAssertRet(aParent && aThat, E_INVALIDARG);
99
100 return init(aParent, aThat->m->DevName, aThat->m->HostAddress, aThat->m->GuestAddress, aThat->m->fPhysical);
101}
102
103HRESULT PCIDeviceAttachment::i_loadSettings(IMachine *aParent,
104 const settings::HostPCIDeviceAttachment &hpda)
105{
106 /** @todo r=bird: Inconsistent signed/unsigned crap. */
107 return init(aParent, hpda.strDeviceName, (LONG)hpda.uHostAddress, (LONG)hpda.uGuestAddress, TRUE);
108}
109
110
111HRESULT PCIDeviceAttachment::i_saveSettings(settings::HostPCIDeviceAttachment &data)
112{
113 Assert(m);
114 /** @todo r=bird: Inconsistent signed/unsigned crap. */
115 data.uHostAddress = (uint32_t)m->HostAddress;
116 data.uGuestAddress = (uint32_t)m->GuestAddress;
117 data.strDeviceName = m->DevName;
118
119 return S_OK;
120}
121
122/**
123 * Uninitializes the instance.
124 * Called from FinalRelease().
125 */
126void PCIDeviceAttachment::uninit()
127{
128 /* Enclose the state transition Ready->InUninit->NotReady */
129 AutoUninitSpan autoUninitSpan(this);
130 if (autoUninitSpan.uninitDone())
131 return;
132
133 delete m;
134 m = NULL;
135}
136
137// IPCIDeviceAttachment properties
138/////////////////////////////////////////////////////////////////////////////
139HRESULT PCIDeviceAttachment::getName(com::Utf8Str &aName)
140{
141 aName = m->DevName;
142 return S_OK;
143}
144
145HRESULT PCIDeviceAttachment::getIsPhysicalDevice(BOOL *aIsPhysicalDevice)
146{
147 *aIsPhysicalDevice = m->fPhysical;
148 return S_OK;
149}
150
151HRESULT PCIDeviceAttachment::getHostAddress(LONG *aHostAddress)
152{
153 *aHostAddress = m->HostAddress;
154 return S_OK;
155}
156HRESULT PCIDeviceAttachment::getGuestAddress(LONG *aGuestAddress)
157{
158 *aGuestAddress = m->GuestAddress;
159 return S_OK;
160}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use