VirtualBox

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

Last change on this file since 78582 was 76592, checked in by vboxsync, 6 years ago

Main: Don't use Logging.h.

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

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