5 IPortTopologyVtbl
*lpVtbl
;
6 ISubdeviceVtbl
*lpVtblSubDevice
;
11 PMINIPORTTOPOLOGY pMiniport
;
12 PDEVICE_OBJECT pDeviceObject
;
14 PPOWERNOTIFY pPowerNotify
;
16 PPCFILTER_DESCRIPTOR pDescriptor
;
17 PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor
;
21 static GUID InterfaceGuids
[2] =
24 /// KS_CATEGORY_TOPOLOGY
25 0xDDA54A40, 0x1E4C, 0x11D1, {0xA0, 0x50, 0x40, 0x57, 0x05, 0xC1, 0x00, 0x00}
29 0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}
35 KSPROPERTY_SET PinPropertySet
=
45 KSPROPERTY_SET TopologyPropertySet
=
47 &KSPROPSETID_Topology
,
56 //---------------------------------------------------------------
57 // IUnknown interface functions
62 IPortTopology_fnQueryInterface(
68 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
70 DPRINT1("IPortTopology_fnQueryInterface\n");
72 if (IsEqualGUIDAligned(refiid
, &IID_IPortTopology
) ||
73 IsEqualGUIDAligned(refiid
, &IID_IPort
) ||
74 IsEqualGUIDAligned(refiid
, &IID_IUnknown
))
76 *Output
= &This
->lpVtbl
;
77 InterlockedIncrement(&This
->ref
);
78 return STATUS_SUCCESS
;
80 else if (IsEqualGUIDAligned(refiid
, &IID_ISubdevice
))
82 *Output
= &This
->lpVtblSubDevice
;
83 InterlockedIncrement(&This
->ref
);
84 return STATUS_SUCCESS
;
86 else if (IsEqualGUIDAligned(refiid
, &IID_IPortClsVersion
))
88 return NewPortClsVersion((PPORTCLSVERSION
*)Output
);
91 StringFromCLSID(refiid
, Buffer
);
92 DPRINT1("IPortTopology_fnQueryInterface no iface %S\n", Buffer
);
93 KeBugCheckEx(0, 0, 0, 0, 0);
94 return STATUS_UNSUCCESSFUL
;
99 IPortTopology_fnAddRef(
100 IPortTopology
* iface
)
102 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
104 return InterlockedIncrement(&This
->ref
);
109 IPortTopology_fnRelease(
110 IPortTopology
* iface
)
112 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
114 InterlockedDecrement(&This
->ref
);
118 FreeItem(This
, TAG_PORTCLASS
);
121 /* Return new reference count */
126 //---------------------------------------------------------------
127 // IPort interface functions
132 IPortTopology_fnGetDeviceProperty(
133 IN IPortTopology
* iface
,
134 IN DEVICE_REGISTRY_PROPERTY DeviceRegistryProperty
,
135 IN ULONG BufferLength
,
136 OUT PVOID PropertyBuffer
,
137 OUT PULONG ReturnLength
)
139 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
141 if (!This
->bInitialized
)
143 DPRINT("IPortTopology_fnNewRegistryKey called w/o initiazed\n");
144 return STATUS_UNSUCCESSFUL
;
147 return IoGetDeviceProperty(This
->pDeviceObject
, DeviceRegistryProperty
, BufferLength
, PropertyBuffer
, ReturnLength
);
152 IPortTopology_fnInit(
153 IN IPortTopology
* iface
,
154 IN PDEVICE_OBJECT DeviceObject
,
156 IN PUNKNOWN UnknownMiniport
,
157 IN PUNKNOWN UnknownAdapter OPTIONAL
,
158 IN PRESOURCELIST ResourceList
)
160 IMiniportTopology
* Miniport
;
162 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
164 DPRINT1("IPortTopology_fnInit entered This %p DeviceObject %p Irp %p UnknownMiniport %p UnknownAdapter %p ResourceList %p\n",
165 This
, DeviceObject
, Irp
, UnknownMiniport
, UnknownAdapter
, ResourceList
);
167 if (This
->bInitialized
)
169 DPRINT1("IPortTopology_Init called again\n");
170 return STATUS_SUCCESS
;
173 Status
= UnknownMiniport
->lpVtbl
->QueryInterface(UnknownMiniport
, &IID_IMiniportTopology
, (PVOID
*)&Miniport
);
174 if (!NT_SUCCESS(Status
))
176 DPRINT1("IPortTopology_Init called with invalid IMiniport adapter\n");
177 return STATUS_INVALID_PARAMETER
;
180 /* Initialize port object */
181 This
->pMiniport
= Miniport
;
182 This
->pDeviceObject
= DeviceObject
;
183 This
->bInitialized
= TRUE
;
185 /* increment reference on miniport adapter */
186 Miniport
->lpVtbl
->AddRef(Miniport
);
188 Status
= Miniport
->lpVtbl
->Init(Miniport
, UnknownAdapter
, ResourceList
, iface
);
189 if (!NT_SUCCESS(Status
))
191 DPRINT1("IPortTopology_Init failed with %x\n", Status
);
192 This
->bInitialized
= FALSE
;
193 Miniport
->lpVtbl
->Release(Miniport
);
197 /* get the miniport device descriptor */
198 Status
= Miniport
->lpVtbl
->GetDescription(Miniport
, &This
->pDescriptor
);
199 if (!NT_SUCCESS(Status
))
201 DPRINT1("failed to get description\n");
202 Miniport
->lpVtbl
->Release(Miniport
);
203 This
->bInitialized
= FALSE
;
207 /* create the subdevice descriptor */
208 Status
= PcCreateSubdeviceDescriptor(&This
->SubDeviceDescriptor
,
224 DPRINT1("IPortTopology_fnInit success\n");
225 return STATUS_SUCCESS
;
231 IPortTopology_fnNewRegistryKey(
232 IN IPortTopology
* iface
,
233 OUT PREGISTRYKEY
*OutRegistryKey
,
234 IN PUNKNOWN OuterUnknown OPTIONAL
,
235 IN ULONG RegistryKeyType
,
236 IN ACCESS_MASK DesiredAccess
,
237 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
,
238 IN ULONG CreateOptions OPTIONAL
,
239 OUT PULONG Disposition OPTIONAL
)
241 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)iface
;
243 if (!This
->bInitialized
)
245 DPRINT("IPortTopology_fnNewRegistryKey called w/o initialized\n");
246 return STATUS_UNSUCCESSFUL
;
248 return PcNewRegistryKey(OutRegistryKey
,
259 static IPortTopologyVtbl vt_IPortTopology
=
261 /* IUnknown methods */
262 IPortTopology_fnQueryInterface
,
263 IPortTopology_fnAddRef
,
264 IPortTopology_fnRelease
,
266 IPortTopology_fnInit
,
267 IPortTopology_fnGetDeviceProperty
,
268 IPortTopology_fnNewRegistryKey
271 //---------------------------------------------------------------
272 // ISubdevice interface
278 ISubDevice_fnQueryInterface(
279 IN ISubdevice
*iface
,
280 IN REFIID InterfaceId
,
283 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
285 return IPortTopology_fnQueryInterface((IPortTopology
*)This
, InterfaceId
, Interface
);
292 IN ISubdevice
*iface
)
294 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
296 return IPortTopology_fnAddRef((IPortTopology
*)This
);
302 ISubDevice_fnRelease(
303 IN ISubdevice
*iface
)
305 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
307 return IPortTopology_fnRelease((IPortTopology
*)This
);
313 ISubDevice_fnNewIrpTarget(
314 IN ISubdevice
*iface
,
315 OUT
struct IIrpTarget
**OutTarget
,
318 IN POOL_TYPE PoolType
,
319 IN PDEVICE_OBJECT
* DeviceObject
,
321 IN KSOBJECT_CREATE
*CreateObject
)
323 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
325 DPRINT1("ISubDevice_NewIrpTarget this %p\n", This
);
326 return STATUS_UNSUCCESSFUL
;
332 ISubDevice_fnReleaseChildren(
333 IN ISubdevice
*iface
)
335 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
337 DPRINT1("ISubDevice_ReleaseChildren this %p\n", This
);
338 return STATUS_UNSUCCESSFUL
;
344 ISubDevice_fnGetDescriptor(
345 IN ISubdevice
*iface
,
346 IN SUBDEVICE_DESCRIPTOR
** Descriptor
)
348 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
350 DPRINT1("ISubDevice_GetDescriptor this %p\n", This
);
351 *Descriptor
= This
->SubDeviceDescriptor
;
352 return STATUS_SUCCESS
;
358 ISubDevice_fnDataRangeIntersection(
359 IN ISubdevice
*iface
,
361 IN PKSDATARANGE DataRange
,
362 IN PKSDATARANGE MatchingDataRange
,
363 IN ULONG OutputBufferLength
,
364 OUT PVOID ResultantFormat OPTIONAL
,
365 OUT PULONG ResultantFormatLength
)
367 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
369 DPRINT("ISubDevice_DataRangeIntersection this %p\n", This
);
373 return This
->pMiniport
->lpVtbl
->DataRangeIntersection (This
->pMiniport
, PinId
, DataRange
, MatchingDataRange
, OutputBufferLength
, ResultantFormat
, ResultantFormatLength
);
376 return STATUS_UNSUCCESSFUL
;
382 ISubDevice_fnPowerChangeNotify(
383 IN ISubdevice
*iface
,
384 IN POWER_STATE PowerState
)
386 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
388 if (This
->pPowerNotify
)
390 This
->pPowerNotify
->lpVtbl
->PowerChangeNotify(This
->pPowerNotify
, PowerState
);
393 return STATUS_SUCCESS
;
399 ISubDevice_fnPinCount(
400 IN ISubdevice
*iface
,
402 IN OUT PULONG FilterNecessary
,
403 IN OUT PULONG FilterCurrent
,
404 IN OUT PULONG FilterPossible
,
405 IN OUT PULONG GlobalCurrent
,
406 IN OUT PULONG GlobalPossible
)
408 IPortTopologyImpl
* This
= (IPortTopologyImpl
*)CONTAINING_RECORD(iface
, IPortTopologyImpl
, lpVtblSubDevice
);
412 This
->pPinCount
->lpVtbl
->PinCount(This
->pPinCount
, PinId
, FilterNecessary
, FilterCurrent
, FilterPossible
, GlobalCurrent
, GlobalPossible
);
413 return STATUS_SUCCESS
;
417 * scan filter descriptor
419 return STATUS_UNSUCCESSFUL
;
422 static ISubdeviceVtbl vt_ISubdeviceVtbl
=
424 ISubDevice_fnQueryInterface
,
426 ISubDevice_fnRelease
,
427 ISubDevice_fnNewIrpTarget
,
428 ISubDevice_fnReleaseChildren
,
429 ISubDevice_fnGetDescriptor
,
430 ISubDevice_fnDataRangeIntersection
,
431 ISubDevice_fnPowerChangeNotify
,
432 ISubDevice_fnPinCount
440 IPortTopologyImpl
* This
;
442 This
= AllocateItem(NonPagedPool
, sizeof(IPortTopologyImpl
), TAG_PORTCLASS
);
444 return STATUS_INSUFFICIENT_RESOURCES
;
446 This
->lpVtbl
= &vt_IPortTopology
;
447 This
->lpVtblSubDevice
= &vt_ISubdeviceVtbl
;
449 *OutPort
= (PPORT
)(&This
->lpVtbl
);
450 DPRINT1("NewPortTopology result %p\n", *OutPort
);
452 return STATUS_SUCCESS
;