VirtualBox

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

Last change on this file since 86115 was 85245, checked in by vboxsync, 4 years ago

Main/PCIDeviceAttachmentImpl.cpp: Signed/unsigned conversion issues. bugref:9790

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: PCIDeviceAttachmentImpl.cpp 85245 2020-07-11 23:07:43Z vboxsync $ */
2/** @file
3 * PCI attachment information implmentation.
4 */
5
6/*
7 * Copyright (C) 2010-2020 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 /** @todo r=bird: Inconsistent signed/unsigned crap. */
97 return init(aParent, hpda.strDeviceName, (LONG)hpda.uHostAddress, (LONG)hpda.uGuestAddress, TRUE);
98}
99
100
101HRESULT PCIDeviceAttachment::i_saveSettings(settings::HostPCIDeviceAttachment &data)
102{
103 Assert(m);
104 /** @todo r=bird: Inconsistent signed/unsigned crap. */
105 data.uHostAddress = (uint32_t)m->HostAddress;
106 data.uGuestAddress = (uint32_t)m->GuestAddress;
107 data.strDeviceName = m->DevName;
108
109 return S_OK;
110}
111
112/**
113 * Uninitializes the instance.
114 * Called from FinalRelease().
115 */
116void PCIDeviceAttachment::uninit()
117{
118 /* Enclose the state transition Ready->InUninit->NotReady */
119 AutoUninitSpan autoUninitSpan(this);
120 if (autoUninitSpan.uninitDone())
121 return;
122
123 delete m;
124 m = NULL;
125}
126
127// IPCIDeviceAttachment properties
128/////////////////////////////////////////////////////////////////////////////
129HRESULT PCIDeviceAttachment::getName(com::Utf8Str &aName)
130{
131 aName = m->DevName;
132 return S_OK;
133}
134
135HRESULT PCIDeviceAttachment::getIsPhysicalDevice(BOOL *aIsPhysicalDevice)
136{
137 *aIsPhysicalDevice = m->fPhysical;
138 return S_OK;
139}
140
141HRESULT PCIDeviceAttachment::getHostAddress(LONG *aHostAddress)
142{
143 *aHostAddress = m->HostAddress;
144 return S_OK;
145}
146HRESULT PCIDeviceAttachment::getGuestAddress(LONG *aGuestAddress)
147{
148 *aGuestAddress = m->GuestAddress;
149 return S_OK;
150}
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