5 IPortTopologyVtbl
*lpVtbl
;
6 ISubdeviceVtbl
*lpVtblSubDevice
;
11 PMINIPORTTOPOLOGY pMiniport
;
12 PDEVICE_OBJECT pDeviceObject
;
14 PPOWERNOTIFY pPowerNotify
;
21 KSPROPERTY_SET PinPropertySet
=
31 KSPROPERTY_SET TopologyPropertySet
=
33 &KSPROPSETID_Topology
,
42 //---------------------------------------------------------------
43 // IUnknown interface functions
48 IPortTopology_fnQueryInterface(
54 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
56 DPRINT1("IPortTopology_fnQueryInterface\n");
58 if (IsEqualGUIDAligned(refiid
, &IID_IPortTopology
) ||
59 IsEqualGUIDAligned(refiid
, &IID_IUnknown
))
61 *Output
= &This
->lpVtbl
;
62 InterlockedIncrement(&This
->ref
);
63 return STATUS_SUCCESS
;
65 else if (IsEqualGUIDAligned(refiid
, &IID_ISubdevice
))
67 *Output
= &This
->lpVtblSubDevice
;
68 InterlockedIncrement(&This
->ref
);
69 return STATUS_SUCCESS
;
71 else if (IsEqualGUIDAligned(refiid
, &IID_IPortClsVersion
))
73 return NewPortClsVersion((PPORTCLSVERSION
*)Output
);
75 StringFromCLSID(refiid
, Buffer
);
76 DPRINT1("IPortTopology_fnQueryInterface no iface %S\n", Buffer
);
77 StringFromCLSID(&IID_IUnknown
, Buffer
);
78 DPRINT1("IPortTopology_fnQueryInterface IUnknown %S\n", Buffer
);
80 return STATUS_UNSUCCESSFUL
;
85 IPortTopology_fnAddRef(
88 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
90 return InterlockedIncrement(&This
->ref
);
95 IPortTopology_fnRelease(
98 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
100 InterlockedDecrement(&This
->ref
);
104 FreeItem(This
, TAG_PORTCLASS
);
107 /* Return new reference count */
112 //---------------------------------------------------------------
113 // IPort interface functions
118 IPortTopology_fnGetDeviceProperty(
119 IN IPortTopology
* iface
,
120 IN DEVICE_REGISTRY_PROPERTY DeviceRegistryProperty
,
121 IN ULONG BufferLength
,
122 OUT PVOID PropertyBuffer
,
123 OUT PULONG ReturnLength
)
125 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
127 if (!This
->bInitialized
)
129 DPRINT("IPortTopology_fnNewRegistryKey called w/o initiazed\n");
130 return STATUS_UNSUCCESSFUL
;
133 return IoGetDeviceProperty(This
->pDeviceObject
, DeviceRegistryProperty
, BufferLength
, PropertyBuffer
, ReturnLength
);
138 IPortTopology_fnInit(
139 IN IPortTopology
* iface
,
140 IN PDEVICE_OBJECT DeviceObject
,
142 IN PUNKNOWN UnknownMiniport
,
143 IN PUNKNOWN UnknownAdapter OPTIONAL
,
144 IN PRESOURCELIST ResourceList
)
146 IMiniportTopology
* Miniport
;
148 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
150 DPRINT1("IPortTopology_fnInit entered This %p DeviceObject %p Irp %p UnknownMiniport %p UnknownAdapter %p ResourceList %p\n",
151 This
, DeviceObject
, Irp
, UnknownMiniport
, UnknownAdapter
, ResourceList
);
153 if (This
->bInitialized
)
155 DPRINT1("IPortTopology_Init called again\n");
156 return STATUS_SUCCESS
;
159 Status
= UnknownMiniport
->lpVtbl
->QueryInterface(UnknownMiniport
, &IID_IMiniportTopology
, (PVOID
*)&Miniport
);
160 if (!NT_SUCCESS(Status
))
162 DPRINT1("IPortTopology_Init called with invalid IMiniport adapter\n");
163 return STATUS_INVALID_PARAMETER
;
166 /* Initialize port object */
167 This
->pMiniport
= Miniport
;
168 This
->pDeviceObject
= DeviceObject
;
169 This
->bInitialized
= TRUE
;
171 Status
= Miniport
->lpVtbl
->Init(Miniport
, UnknownAdapter
, ResourceList
, iface
);
172 if (!NT_SUCCESS(Status
))
174 DPRINT1("IPortTopology_Init failed with %x\n", Status
);
175 This
->bInitialized
= FALSE
;
179 /* increment reference on miniport adapter */
180 Miniport
->lpVtbl
->AddRef(Miniport
);
183 DPRINT1("IPortTopology_fnInit success\n");
184 return STATUS_SUCCESS
;
190 IPortTopology_fnNewRegistryKey(
191 IN IPortTopology
* iface
,
192 OUT PREGISTRYKEY
*OutRegistryKey
,
193 IN PUNKNOWN OuterUnknown OPTIONAL
,
194 IN ULONG RegistryKeyType
,
195 IN ACCESS_MASK DesiredAccess
,
196 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
,
197 IN ULONG CreateOptions OPTIONAL
,
198 OUT PULONG Disposition OPTIONAL
)
200 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
202 if (!This
->bInitialized
)
204 DPRINT("IPortTopology_fnNewRegistryKey called w/o initialized\n");
205 return STATUS_UNSUCCESSFUL
;
207 return PcNewRegistryKey(OutRegistryKey
,
218 static IPortTopologyVtbl vt_IPortTopology
=
220 /* IUnknown methods */
221 IPortTopology_fnQueryInterface
,
222 IPortTopology_fnAddRef
,
223 IPortTopology_fnRelease
,
225 IPortTopology_fnInit
,
226 IPortTopology_fnGetDeviceProperty
,
227 IPortTopology_fnNewRegistryKey
230 //---------------------------------------------------------------
231 // ISubdevice interface
237 ISubDevice_fnQueryInterface(
238 IN ISubdevice
*iface
,
239 IN REFIID InterfaceId
,
242 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
244 return IPortTopology_fnQueryInterface((IPortTopology
*)This
, InterfaceId
, Interface
);
251 IN ISubdevice
*iface
)
253 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
255 return IPortTopology_fnAddRef((IPortTopology
*)This
);
261 ISubDevice_fnRelease(
262 IN ISubdevice
*iface
)
264 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
266 return IPortTopology_fnRelease((IPortTopology
*)This
);
272 ISubDevice_fnNewIrpTarget(
273 IN ISubdevice
*iface
,
274 OUT
struct IIrpTarget
**OutTarget
,
277 IN POOL_TYPE PoolType
,
278 IN PDEVICE_OBJECT
* DeviceObject
,
280 IN KSOBJECT_CREATE
*CreateObject
)
282 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
284 DPRINT1("ISubDevice_NewIrpTarget this %p\n", This
);
285 return STATUS_UNSUCCESSFUL
;
291 ISubDevice_fnReleaseChildren(
292 IN ISubdevice
*iface
)
294 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
296 DPRINT1("ISubDevice_ReleaseChildren this %p\n", This
);
297 return STATUS_UNSUCCESSFUL
;
303 ISubDevice_fnGetDescriptor(
304 IN ISubdevice
*iface
,
305 IN
struct SUBDEVICE_DESCRIPTOR
** Descriptor
)
307 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
309 DPRINT1("ISubDevice_GetDescriptor this %p\n", This
);
310 return STATUS_UNSUCCESSFUL
;
316 ISubDevice_fnDataRangeIntersection(
317 IN ISubdevice
*iface
,
319 IN PKSDATARANGE DataRange
,
320 IN PKSDATARANGE MatchingDataRange
,
321 IN ULONG OutputBufferLength
,
322 OUT PVOID ResultantFormat OPTIONAL
,
323 OUT PULONG ResultantFormatLength
)
325 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
327 DPRINT("ISubDevice_DataRangeIntersection this %p\n", This
);
331 return This
->pMiniport
->lpVtbl
->DataRangeIntersection (This
->pMiniport
, PinId
, DataRange
, MatchingDataRange
, OutputBufferLength
, ResultantFormat
, ResultantFormatLength
);
334 return STATUS_UNSUCCESSFUL
;
340 ISubDevice_fnPowerChangeNotify(
341 IN ISubdevice
*iface
,
342 IN POWER_STATE PowerState
)
344 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
346 if (This
->pPowerNotify
)
348 This
->pPowerNotify
->lpVtbl
->PowerChangeNotify(This
->pPowerNotify
, PowerState
);
351 return STATUS_SUCCESS
;
357 ISubDevice_fnPinCount(
358 IN ISubdevice
*iface
,
360 IN OUT PULONG FilterNecessary
,
361 IN OUT PULONG FilterCurrent
,
362 IN OUT PULONG FilterPossible
,
363 IN OUT PULONG GlobalCurrent
,
364 IN OUT PULONG GlobalPossible
)
366 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
370 This
->pPinCount
->lpVtbl
->PinCount(This
->pPinCount
, PinId
, FilterNecessary
, FilterCurrent
, FilterPossible
, GlobalCurrent
, GlobalPossible
);
371 return STATUS_SUCCESS
;
375 * scan filter descriptor
377 return STATUS_UNSUCCESSFUL
;
380 static ISubdeviceVtbl vt_ISubdeviceVtbl
=
382 ISubDevice_fnQueryInterface
,
384 ISubDevice_fnRelease
,
385 ISubDevice_fnNewIrpTarget
,
386 ISubDevice_fnReleaseChildren
,
387 ISubDevice_fnGetDescriptor
,
388 ISubDevice_fnDataRangeIntersection
,
389 ISubDevice_fnPowerChangeNotify
,
390 ISubDevice_fnPinCount
398 IPortTopologyImpl
* This
;
400 This
= AllocateItem(NonPagedPool
, sizeof(IPortTopologyImpl
), TAG_PORTCLASS
);
402 return STATUS_INSUFFICIENT_RESOURCES
;
404 This
->lpVtbl
= &vt_IPortTopology
;
405 This
->lpVtblSubDevice
= &vt_ISubdeviceVtbl
;
407 *OutPort
= (PPORT
)(&This
->lpVtbl
);
408 DPRINT1("NewPortTopology result %p\n", *OutPort
);
410 return STATUS_SUCCESS
;