1 | /* $Id: PCIDeviceAttachmentImpl.cpp 42551 2012-08-02 16:44:39Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * PCI attachment information implmentation.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2010-2012 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #include "PCIDeviceAttachmentImpl.h"
|
---|
21 | #include "AutoCaller.h"
|
---|
22 | #include "Global.h"
|
---|
23 | #include "Logging.h"
|
---|
24 |
|
---|
25 | struct PCIDeviceAttachment::Data
|
---|
26 | {
|
---|
27 | Data(const Bstr &aDevName,
|
---|
28 | LONG aHostAddress,
|
---|
29 | LONG aGuestAddress,
|
---|
30 | BOOL afPhysical)
|
---|
31 | : HostAddress(aHostAddress), GuestAddress(aGuestAddress),
|
---|
32 | fPhysical(afPhysical)
|
---|
33 | {
|
---|
34 | DevName = aDevName;
|
---|
35 | }
|
---|
36 |
|
---|
37 | Bstr DevName;
|
---|
38 | LONG HostAddress;
|
---|
39 | LONG GuestAddress;
|
---|
40 | BOOL fPhysical;
|
---|
41 | };
|
---|
42 |
|
---|
43 | // constructor / destructor
|
---|
44 | /////////////////////////////////////////////////////////////////////////////
|
---|
45 |
|
---|
46 | HRESULT PCIDeviceAttachment::FinalConstruct()
|
---|
47 | {
|
---|
48 | LogFlowThisFunc(("\n"));
|
---|
49 | return BaseFinalConstruct();
|
---|
50 | }
|
---|
51 |
|
---|
52 | void PCIDeviceAttachment::FinalRelease()
|
---|
53 | {
|
---|
54 | LogFlowThisFunc(("\n"));
|
---|
55 | uninit();
|
---|
56 | BaseFinalRelease();
|
---|
57 | }
|
---|
58 |
|
---|
59 | // public initializer/uninitializer for internal purposes only
|
---|
60 | /////////////////////////////////////////////////////////////////////////////
|
---|
61 | HRESULT PCIDeviceAttachment::init(IMachine *aParent,
|
---|
62 | const Bstr &aDevName,
|
---|
63 | LONG aHostAddress,
|
---|
64 | LONG aGuestAddress,
|
---|
65 | BOOL fPhysical)
|
---|
66 | {
|
---|
67 | (void)aParent;
|
---|
68 | m = new Data(aDevName, aHostAddress, aGuestAddress, fPhysical);
|
---|
69 |
|
---|
70 | return m != NULL ? S_OK : E_FAIL;
|
---|
71 | }
|
---|
72 |
|
---|
73 | HRESULT PCIDeviceAttachment::loadSettings(IMachine *aParent,
|
---|
74 | const settings::HostPCIDeviceAttachment &hpda)
|
---|
75 | {
|
---|
76 | Bstr bname(hpda.strDeviceName);
|
---|
77 | return init(aParent, bname, hpda.uHostAddress, hpda.uGuestAddress, TRUE);
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | HRESULT PCIDeviceAttachment::saveSettings(settings::HostPCIDeviceAttachment &data)
|
---|
82 | {
|
---|
83 | Assert(m);
|
---|
84 | data.uHostAddress = m->HostAddress;
|
---|
85 | data.uGuestAddress = m->GuestAddress;
|
---|
86 | data.strDeviceName = m->DevName;
|
---|
87 |
|
---|
88 | return S_OK;
|
---|
89 | }
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Uninitializes the instance.
|
---|
93 | * Called from FinalRelease().
|
---|
94 | */
|
---|
95 | void PCIDeviceAttachment::uninit()
|
---|
96 | {
|
---|
97 | if (m)
|
---|
98 | {
|
---|
99 | delete m;
|
---|
100 | m = NULL;
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 | // IPCIDeviceAttachment properties
|
---|
105 | /////////////////////////////////////////////////////////////////////////////
|
---|
106 |
|
---|
107 | STDMETHODIMP PCIDeviceAttachment::COMGETTER(Name)(BSTR * aName)
|
---|
108 | {
|
---|
109 | CheckComArgOutPointerValid(aName);
|
---|
110 | m->DevName.cloneTo(aName);
|
---|
111 | return S_OK;
|
---|
112 | }
|
---|
113 |
|
---|
114 | STDMETHODIMP PCIDeviceAttachment::COMGETTER(IsPhysicalDevice)(BOOL * aPhysical)
|
---|
115 | {
|
---|
116 | CheckComArgOutPointerValid(aPhysical);
|
---|
117 | *aPhysical = m->fPhysical;
|
---|
118 | return S_OK;
|
---|
119 | }
|
---|
120 |
|
---|
121 | STDMETHODIMP PCIDeviceAttachment::COMGETTER(HostAddress)(LONG * aHostAddress)
|
---|
122 | {
|
---|
123 | *aHostAddress = m->HostAddress;
|
---|
124 | return S_OK;
|
---|
125 | }
|
---|
126 |
|
---|
127 | STDMETHODIMP PCIDeviceAttachment::COMGETTER(GuestAddress)(LONG * aGuestAddress)
|
---|
128 | {
|
---|
129 | *aGuestAddress = m->GuestAddress;
|
---|
130 | return S_OK;
|
---|
131 | }
|
---|
132 |
|
---|
133 | #ifdef VBOX_WITH_XPCOM
|
---|
134 | NS_DECL_CLASSINFO(PCIDeviceAttachment)
|
---|
135 | NS_IMPL_THREADSAFE_ISUPPORTS1_CI(PCIDeviceAttachment, IPCIDeviceAttachment)
|
---|
136 | #endif
|
---|