diff --git a/reactos/drivers/wdm/audio/backpln/portcls/adapter.c b/reactos/drivers/wdm/audio/backpln/portcls/adapter.c index e53a56e5880..4232d4a030a 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/adapter.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/adapter.c @@ -13,8 +13,6 @@ #include #include -const GUID IID_ISubdevice; - /* This is called from DriverEntry so that PortCls can take care of some IRPs and map some others to the main KS driver. In most cases this will @@ -49,7 +47,7 @@ PcInitializeAdapterDriver( //NTSTATUS status; //ULONG i; - DPRINT("PcInitializeAdapterDriver\n"); + DPRINT1("PcInitializeAdapterDriver\n"); #if 0 /* Set default stub - is this a good idea? */ @@ -101,59 +99,41 @@ PcAddAdapterDevice( IN ULONG MaxObjects, IN ULONG DeviceExtensionSize) { - /* - Note - after this has been called, we can - handle IRP_MN_START_DEVICE by calling StartDevice - - TODO: - Validate DeviceExtensionSize!! (et al...) - */ - NTSTATUS status = STATUS_UNSUCCESSFUL; PDEVICE_OBJECT fdo = NULL; + PDEVICE_OBJECT PrevDeviceObject; PCExtension* portcls_ext; DPRINT1("PcAddAdapterDevice called\n"); - if ( ! DriverObject) + if (!DriverObject || !PhysicalDeviceObject || !StartDevice) { - DPRINT("DriverObject is NULL!\n"); return STATUS_INVALID_PARAMETER; } - if ( ! PhysicalDeviceObject ) - { - DPRINT("PhysicalDeviceObject is NULL!\n"); - return STATUS_INVALID_PARAMETER; - } - - if ( ! StartDevice ) - { - DPRINT("No StartDevice parameter!\n"); - return STATUS_INVALID_PARAMETER; - } - - /* TODO: Make sure this is right */ + /* check if the DeviceExtensionSize is provided */ if ( DeviceExtensionSize < PORT_CLASS_DEVICE_EXTENSION_SIZE ) { + /* driver does not need a device extension */ if ( DeviceExtensionSize != 0 ) { - /* TODO: Error */ - DPRINT("DeviceExtensionSize is invalid\n"); + /* DeviceExtensionSize must be zero*/ return STATUS_INVALID_PARAMETER; } + /* set size to our extension size */ + DeviceExtensionSize = PORT_CLASS_DEVICE_EXTENSION_SIZE; } - DPRINT("portcls is creating a device\n"); + /* create the device */ status = IoCreateDevice(DriverObject, DeviceExtensionSize, NULL, FILE_DEVICE_KS, - PhysicalDeviceObject->Characteristics, /* TODO: Check */ + FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN, FALSE, &fdo); - if ( ! NT_SUCCESS(status) ) + if (!NT_SUCCESS(status)) { DPRINT("IoCreateDevice() failed with status 0x%08lx\n", status); return status; @@ -161,24 +141,60 @@ PcAddAdapterDevice( /* Obtain the new device extension */ portcls_ext = (PCExtension*) fdo->DeviceExtension; + /* initialize the device extension */ + RtlZeroMemory(portcls_ext, DeviceExtensionSize); + /* allocate create item */ + portcls_ext->CreateItems = AllocateItem(NonPagedPool, MaxObjects * sizeof(KSOBJECT_CREATE_ITEM), TAG_PORTCLASS); - ASSERT(portcls_ext); - - /* Initialize */ - RtlZeroMemory(portcls_ext, sizeof(PCExtension)); + /* store the physical device object */ portcls_ext->PhysicalDeviceObject = PhysicalDeviceObject; + /* set up the start device function */ portcls_ext->StartDevice = StartDevice; + /* prepare the subdevice list */ InitializeListHead(&portcls_ext->SubDeviceList); + /* prepare the physical connection list */ InitializeListHead(&portcls_ext->PhysicalConnectionList); - status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, 0, NULL); + /* set io flags */ + fdo->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE; + /* clear initializing flag */ + fdo->Flags &= ~ DO_DEVICE_INITIALIZING; + + /* allocate the device header */ + status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, MaxObjects, portcls_ext->CreateItems); + /* did we succeed */ if (!NT_SUCCESS(status)) { + /* free previously allocated create items */ + FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS); + /* delete created fdo */ IoDeleteDevice(fdo); + /* return error code */ return status; } - DPRINT("PcAddAdapterDriver succeeded\n"); + /* attach device to device stack */ + PrevDeviceObject = IoAttachDeviceToDeviceStack(fdo, PhysicalDeviceObject); + /* did we succeed */ + if (PrevDeviceObject) + { + /* store the device object in the device header */ + //KsSetDevicePnpBaseObject(portcls_ext->KsDeviceHeader, PrevDeviceObject, fdo); + portcls_ext->PrevDeviceObject = PrevDeviceObject; + } + else + { + /* free the device header */ + KsFreeDeviceHeader(portcls_ext->KsDeviceHeader); + /* free previously allocated create items */ + FreeItem(portcls_ext->CreateItems, TAG_PORTCLASS); + /* delete created fdo */ + IoDeleteDevice(fdo); + /* return error code */ + return STATUS_UNSUCCESSFUL; + } + + return status; } @@ -206,7 +222,7 @@ PciDriverDispatch( return STATUS_UNSUCCESSFUL; } - Entry = ExAllocatePoolWithTag(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS); + Entry = AllocateItem(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS); if (!Entry) return STATUS_INSUFFICIENT_RESOURCES; @@ -221,7 +237,7 @@ PciDriverDispatch( Status = KsAllocateObjectHeader(&Entry->ObjectHeader, 1, NULL, Irp, &DispatchTable); if (!NT_SUCCESS(Status)) { - ExFreePoolWithTag(Entry, TAG_PORTCLASS); + FreeItem(Entry, TAG_PORTCLASS); return Status; } @@ -247,9 +263,13 @@ PcRegisterSubdevice( UNICODE_STRING ReferenceString; UNICODE_STRING SymbolicLinkName; + DPRINT1("PcRegisterSubdevice DeviceObject %p Name %S Unknown %p\n", DeviceObject, Name, Unknown); if (!DeviceObject || !Name || !Unknown) + { + DPRINT("PcRegisterSubdevice invalid parameter\n"); return STATUS_INVALID_PARAMETER; + } DeviceExt = (PCExtension*)DeviceObject->DeviceExtension; if (!DeviceExt) @@ -258,17 +278,20 @@ PcRegisterSubdevice( Status = Unknown->lpVtbl->QueryInterface(Unknown, &IID_ISubdevice, (LPVOID)&SubDevice); if (!NT_SUCCESS(Status)) { + DPRINT1("No ISubdevice interface\n"); /* the provided port driver doesnt support ISubdevice */ return STATUS_INVALID_PARAMETER; } - +#if KS_IMPLEMENTED Status = KsAddObjectCreateItemToDeviceHeader(DeviceExt->KsDeviceHeader, PciDriverDispatch, (PVOID)SubDevice, Name, NULL); if (!NT_SUCCESS(Status)) { /* failed to attach */ SubDevice->lpVtbl->Release(SubDevice); + DPRINT1("KsAddObjectCreateItemToDeviceHeader failed with %x\n", Status); return Status; } +#endif /* FIXME retrieve guid from subdescriptor */ @@ -284,6 +307,11 @@ PcRegisterSubdevice( RtlFreeUnicodeString(&SymbolicLinkName); } + DPRINT1("PcRegisterSubdevice Status %x\n", Status); - return Status; + /// HACK + /// IoRegisterDeviceInterface fails with + /// STATUS_OBJECT_PATH_NOT_FOUND + /// return Status; + return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/connection.c b/reactos/drivers/wdm/audio/backpln/portcls/connection.c index 8731b9b049f..225f77f0829 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/connection.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/connection.c @@ -59,7 +59,7 @@ RegisterConnection( goto cleanup; } - NewConnection = ExAllocatePoolWithTag(NonPagedPool, sizeof(PHYSICAL_CONNECTION), TAG_PORTCLASS); + NewConnection = AllocateItem(NonPagedPool, sizeof(PHYSICAL_CONNECTION), TAG_PORTCLASS); if (!NewConnection) { Status = STATUS_INSUFFICIENT_RESOURCES; @@ -107,6 +107,9 @@ PcRegisterPhysicalConnection( IN PUNKNOWN ToUnknown, IN ULONG ToPin) { + + DPRINT1("PcRegisterPhysicalConnection\n"); + if (!DeviceObject || !FromUnknown || !ToUnknown) return STATUS_INVALID_PARAMETER; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c b/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c index 9d68b6911ef..95efdf09bdd 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c @@ -85,7 +85,7 @@ IDmaChannelSlave_fnRelease( if (This->ref == 0) { This->pAdapter->DmaOperations->PutDmaAdapter(This->pAdapter); - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -487,7 +487,7 @@ PcNewDmaChannel( IDmaChannelSlaveImpl * This; - This = ExAllocatePoolWithTag(PoolType, sizeof(IDmaChannelSlaveImpl), TAG_PORTCLASS); + This = AllocateItem(PoolType, sizeof(IDmaChannelSlaveImpl), TAG_PORTCLASS); if (!This) { return STATUS_INSUFFICIENT_RESOURCES; @@ -503,12 +503,11 @@ PcNewDmaChannel( Adapter = IoGetDmaAdapter(DeviceObject, DeviceDescription, &MapRegisters); if (!Adapter) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return STATUS_DEVICE_CONFIGURATION_ERROR; } - RtlZeroMemory(This, sizeof(IDmaChannelSlaveImpl)); - + /* initialize object */ This->ref = 1; This->lpVtbl = &vt_IDmaChannelSlaveVtbl; This->pAdapter = Adapter; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c b/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c index 20ad65c628f..ef3232cca25 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c @@ -1,8 +1,7 @@ #include "private.h" -const GUID IID_IDrmPort; -const GUID IID_IDrmPort2; + typedef struct { @@ -33,7 +32,7 @@ IDrmPort2_fnRelease( if (This->ref == 0) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -154,7 +153,7 @@ NTSTATUS NewIDrmPort( OUT PDRMPORT2 *OutPort) { - IDrmPort2Impl * This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IDrmPort2Impl), TAG_PORTCLASS); + IDrmPort2Impl * This = AllocateItem(NonPagedPool, sizeof(IDrmPort2Impl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c b/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c index 3e9b09ceca7..50586c06a1a 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c @@ -59,7 +59,7 @@ IPortFilterWaveCyclic_fnRelease( if (This->ref == 0) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } return This->ref; @@ -260,7 +260,7 @@ NTSTATUS NewPortFilterWaveCyclic( { IPortFilterWaveCyclicImpl * This; - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortFilterWaveCyclicImpl), TAG_PORTCLASS); + This = AllocateItem(NonPagedPool, sizeof(IPortFilterWaveCyclicImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/guids.c b/reactos/drivers/wdm/audio/backpln/portcls/guids.c new file mode 100644 index 00000000000..1626095939e --- /dev/null +++ b/reactos/drivers/wdm/audio/backpln/portcls/guids.c @@ -0,0 +1,49 @@ +#include "private.h" + + + + +const GUID CLSID_PortTopology = {0xb4c90a32L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID CLSID_PortMidi = {0xb4c90a43L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID CLSID_PortWaveCyclic = {0xb4c90a2aL, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID CLSID_PortWavePci = {0xb4c90a54L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID CLSID_PortDMus; +const GUID IID_IMiniportDMus; + +const GUID IID_IMiniportTopology = {0xb4c90a31L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID IID_IPortTopology = {0xb4c90a30L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; + +const GUID CLSID_MiniportDriverDMusUART; +const GUID CLSID_MiniportDriverUart; +const GUID CLSID_MiniportDriverDMusUARTCapture; +const GUID CLSID_MiniportDriverFmSynth; +const GUID CLSID_MiniportDriverFmSynthWithVol; + +const GUID IID_IDrmPort = {0x286D3DF8L, 0xCA22, 0x4E2E, {0xB9, 0xBC, 0x20, 0xB4, 0xF0, 0xE2, 0x01, 0xCE}}; +const GUID IID_IDrmPort2 = {0x1ACCE59CL, 0x7311, 0x4B6B, {0x9F, 0xBA, 0xCC, 0x3B, 0xA5, 0x9A, 0xCD, 0xCE}}; +const GUID IID_IInterruptSync = {0x22C6AC63L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; +const GUID IID_IPortWavePci = {0xb4c90a50L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID IID_IMiniportWavePci = {0xb4c90a52L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID IID_IAdapterPowerManagement = {0x793417D0L, 0x35FE, 0x11D1, {0xAD, 0x08, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0xB0}}; + + +const GUID IID_IMiniportWaveCyclic = {0xb4c90a27L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID IID_IPortWaveCyclic = {0xb4c90a26L, 0x5791, 0x11d0, {0x86, 0xf9, 0x00, 0xa0, 0xc9, 0x11, 0xb5, 0x44}}; +const GUID IID_IResourceList = {0x22C6AC60L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; +const GUID IID_IServiceGroup = {0x22C6AC65L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; +const GUID IID_IPinCount = {0x5dadb7dcL, 0xa2cb, 0x4540, {0xa4, 0xa8, 0x42, 0x5e, 0xe4, 0xae, 0x90, 0x51}}; +const GUID IID_IPowerNotify = {0x3DD648B8L, 0x969F, 0x11D1, {0x95, 0xA9, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}}; +const GUID IID_IDmaChannelSlave = {0x22C6AC62L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; +const GUID IID_IDmaChannel = {0x22C6AC61L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; +const GUID IID_IRegistryKey = {0xE8DA4302l, 0xF304, 0x11D0, {0x95, 0x8B, 0x00, 0xC0, 0x4F, 0xB9, 0x25, 0xD3}}; +const GUID IID_IServiceSink = {0x22C6AC64L, 0x851B, 0x11D0, {0x9A, 0x7F, 0x00, 0xAA, 0x00, 0x38, 0xAC, 0xFE}}; +const GUID IID_IPortClsVersion = {0x7D89A7BBL, 0x869B, 0x4567, {0x8D, 0xBE, 0x1E, 0x16, 0x8C, 0xC8, 0x53, 0xDE}}; +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x46}}; + +/// +/// undocumented guids + +const GUID IID_ISubdevice = {0xB4C90A61, 0x5791, 0x11D0, {0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}}; +const GUID IID_IIrpTarget = {0xB4C90A60, 0x5791, 0x11D0, {0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}}; +const GUID IID_IIrpTargetFactory = {0xB4C90A62, 0x5791, 0x11D0, {0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44}}; + diff --git a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h index e42eab01f83..0cbe4070e4a 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h +++ b/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h @@ -1,9 +1,9 @@ #ifndef INTERFACES_H__ #define INTERFACES_H__ -DEFINE_GUID(IID_IIrpTarget, 0xB4C90A60, 0x5791, 0x11D0, 0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); -DEFINE_GUID(IID_ISubdevice, 0xB4C90A61, 0x5791, 0x11D0, 0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); -DEFINE_GUID(IID_IIrpTargetFactory, 0xB4C90A62, 0x5791, 0x11D0, 0x86, 0xF9, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); +DEFINE_GUID(IID_IIrpTarget, 0xB4C90A60, 0x5791, 0x11D0, 0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); +DEFINE_GUID(IID_ISubdevice, 0xB4C90A61, 0x5791, 0x11D0, 0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); +DEFINE_GUID(IID_IIrpTargetFactory, 0xB4C90A62, 0x5791, 0x11D0, 0xF9, 0x86, 0x00, 0xA0, 0xC9, 0x11, 0xB5, 0x44); /***************************************************************************** diff --git a/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c b/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c index 310e53f3e4f..eb2032b58bd 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c @@ -28,7 +28,7 @@ typedef struct // IUnknown methods // -const GUID IID_IInterruptSync; + NTSTATUS NTAPI @@ -39,13 +39,15 @@ IInterruptSync_fnQueryInterface( { IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; + DPRINT1("IInterruptSync_fnQueryInterface: This %p\n", This); + if (IsEqualGUIDAligned(refiid, &IID_IInterruptSync)) { *Output = &This->lpVtbl; _InterlockedIncrement(&This->ref); return STATUS_SUCCESS; } - + DPRINT1("IInterruptSync_fnQueryInterface: This %p UNKNOWN interface requested\n", This); return STATUS_UNSUCCESSFUL; } @@ -56,7 +58,7 @@ IInterruptSync_fnAddRef( { IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; - DPRINT("IInterruptSync_AddRef: This %p\n", This); + DPRINT1("IInterruptSync_AddRef: This %p\n", This); return _InterlockedIncrement(&This->ref); } @@ -72,24 +74,20 @@ IInterruptSync_fnRelease( _InterlockedDecrement(&This->ref); - DPRINT("IInterruptSync_Release: This %p new ref %u\n", This, This->ref); + DPRINT1("IInterruptSync_Release: This %p new ref %u\n", This, This->ref); if (This->ref == 0) { - if (This->Interrupt) - { - DPRINT1("Interrupt not disconnected! %p\n", This->Interrupt); - IoDisconnectInterrupt(This->Interrupt); - } while(!IsListEmpty(&This->ServiceRoutines)) { CurEntry = RemoveHeadList(&This->ServiceRoutines); Entry = CONTAINING_RECORD(CurEntry, SYNC_ENTRY, ListEntry); - ExFreePoolWithTag(Entry, TAG_PORTCLASS); + FreeItem(Entry, TAG_PORTCLASS); } - This->ResourceList->lpVtbl->Release(This->ResourceList); - ExFreePoolWithTag(This, TAG_PORTCLASS); + //This->ResourceList->lpVtbl->Release(This->ResourceList); + //FreeItem(This, TAG_PORTCLASS); +DPRINT1("IInterruptSync_Release: complete\n"); return 0; } /* Return new reference count */ @@ -107,8 +105,8 @@ IInterruptSynchronizedRoutine( IN PVOID ServiceContext) { IInterruptSyncImpl * This = (IInterruptSyncImpl*)ServiceContext; - - return This->SyncRoutine((IInterruptSync*)This, This->DynamicContext); + DPRINT1("IInterruptSynchronizedRoutine This %p SyncRoutine%p\n", This, This->SyncRoutine); + return This->SyncRoutine((IInterruptSync*)&This->lpVtbl, This->DynamicContext); } NTSTATUS @@ -118,12 +116,24 @@ IInterruptSync_fnCallSynchronizedRoutine( IN PINTERRUPTSYNCROUTINE Routine, IN PVOID DynamicContext) { + KIRQL OldIrql; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; + DPRINT1("IInterruptSync_fnCallSynchronizedRoutine This %p Routine %p DynamicContext %p\n", This, Routine, DynamicContext); + if (!This->Interrupt) { DPRINT("IInterruptSync_CallSynchronizedRoutine %p no interrupt connected\n", This); - return STATUS_UNSUCCESSFUL; + if (KeGetCurrentIrql() > DISPATCH_LEVEL) + return STATUS_UNSUCCESSFUL; + + KeAcquireSpinLock(&This->Lock, &OldIrql); + This->SyncRoutine = Routine; + This->DynamicContext = DynamicContext; + IInterruptSynchronizedRoutine((PVOID)This); + KeReleaseSpinLock(&This->Lock, OldIrql); + + return STATUS_SUCCESS; } This->SyncRoutine = Routine; @@ -138,6 +148,7 @@ IInterruptSync_fnGetKInterrupt( IN IInterruptSync * iface) { IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; + DPRINT1("IInterruptSynchronizedRoutine\n"); return This->Interrupt; } @@ -154,6 +165,8 @@ IInterruptServiceRoutine( BOOL Success; IInterruptSyncImpl * This = (IInterruptSyncImpl*)ServiceContext; + DPRINT1("IInterruptServiceRoutine\n"); + if (This->Mode == InterruptSyncModeNormal) { CurEntry = This->ServiceRoutines.Flink; @@ -216,6 +229,8 @@ IInterruptSync_fnConnect( NTSTATUS Status; PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor; + DPRINT1("IInterruptSync_fnConnect\n"); + Descriptor = This->ResourceList->lpVtbl->FindTranslatedEntry(This->ResourceList, CmResourceTypeInterrupt, This->ResourceIndex); if (!Descriptor) return STATUS_UNSUCCESSFUL; @@ -244,6 +259,7 @@ IInterruptSync_fnDisconnect( IN IInterruptSync * iface) { IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; + DPRINT1("IInterruptSync_fnDisconnect\n"); if (!This->Interrupt) { @@ -266,7 +282,9 @@ IInterruptSync_fnRegisterServiceRoutine( PSYNC_ENTRY NewEntry; IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface; - NewEntry = ExAllocatePoolWithTag(NonPagedPool, sizeof(SYNC_ENTRY), TAG_PORTCLASS); +DPRINT1("IInterruptSync_fnRegisterServiceRoutine\n"); + + NewEntry = AllocateItem(NonPagedPool, sizeof(SYNC_ENTRY), TAG_PORTCLASS); if (!NewEntry) return STATUS_INSUFFICIENT_RESOURCES; @@ -308,6 +326,7 @@ PcNewInterruptSync( { IInterruptSyncImpl * This; + DPRINT1("PcNewInterruptSync entered\n"); if (!OutInterruptSync || !ResourceList || Mode > InterruptSyncModeRepeat || Mode < 0) return STATUS_INVALID_PARAMETER; @@ -315,22 +334,24 @@ PcNewInterruptSync( if (ResourceIndex > ResourceList->lpVtbl->NumberOfEntriesOfType(ResourceList, CmResourceTypeInterrupt)) return STATUS_INVALID_PARAMETER; + ResourceList->lpVtbl->AddRef(ResourceList); - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IInterruptSyncImpl), TAG_PORTCLASS); + This = AllocateItem(NonPagedPool, sizeof(IInterruptSyncImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; + /* initialize object */ This->lpVtbl = &vt_IInterruptSyncVtbl; This->ref = 1; This->Mode = Mode; - This->Interrupt = NULL; This->ResourceIndex = ResourceIndex; This->ResourceList = ResourceList; InitializeListHead(&This->ServiceRoutines); KeInitializeSpinLock(&This->Lock); *OutInterruptSync = (PINTERRUPTSYNC)&This->lpVtbl; - return STATUS_UNSUCCESSFUL; + DPRINT1("PcNewInterruptSync success %p\n", *OutInterruptSync); + return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/irp.c b/reactos/drivers/wdm/audio/backpln/portcls/irp.c index b08d5796542..a1885e94018 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/irp.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/irp.c @@ -205,7 +205,7 @@ PcDispatchIrp( { PIO_STACK_LOCATION irp_stack; - DPRINT("PcDispatchIrp called - handling IRP in PortCls\n"); + DPRINT1("PcDispatchIrp called - handling IRP in PortCls\n"); irp_stack = IoGetCurrentIrpStackLocation(Irp); @@ -289,10 +289,13 @@ PcForwardIrpSynchronous( DPRINT1("PcForwardIrpSynchronous\n"); DeviceExt = (PCExtension*)DeviceObject->DeviceExtension; - +return STATUS_SUCCESS; /* initialize the notification event */ KeInitializeEvent(&Event, NotificationEvent, FALSE); + /* copy the current stack location */ + IoCopyCurrentIrpStackLocationToNext(Irp); + /* setup a completion routine */ IoSetCompletionRoutine(Irp, IrpCompletionRoutine, (PVOID)&Event, TRUE, FALSE, FALSE); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/miniport.c b/reactos/drivers/wdm/audio/backpln/portcls/miniport.c index 92d6970238d..2b204d5aeb4 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/miniport.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/miniport.c @@ -12,11 +12,7 @@ #include "private.h" -const GUID CLSID_MiniportDriverDMusUART; -const GUID CLSID_MiniportDriverUart; -const GUID CLSID_MiniportDriverDMusUARTCapture; -const GUID CLSID_MiniportDriverFmSynth; -const GUID CLSID_MiniportDriverFmSynthWithVol; + /* * @implemented @@ -28,6 +24,8 @@ PcNewMiniport( { NTSTATUS Status = STATUS_INVALID_PARAMETER; + DPRINT1("PcNewMiniport entered\n"); + if (!OutMiniport) { DPRINT("PcNewMiniport was supplied a NULL OutPort parameter\n"); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c b/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c index 903d9e3dca3..f9a528e5f3c 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c @@ -8,7 +8,7 @@ typedef struct }IMiniportDMusImpl; -const GUID IID_IMiniportDMus; + /* IUnknown methods */ @@ -51,7 +51,7 @@ IMiniportDMust_fnRelease( if (This->ref == 0) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -148,7 +148,7 @@ NewMiniportDMusUART( { IMiniportDMusImpl * This; - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IMiniportDMusImpl), TAG_PORTCLASS); + This = AllocateItem(NonPagedPool, sizeof(IMiniportDMusImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/pool.c b/reactos/drivers/wdm/audio/backpln/portcls/pool.c new file mode 100644 index 00000000000..2d8a2b53cd6 --- /dev/null +++ b/reactos/drivers/wdm/audio/backpln/portcls/pool.c @@ -0,0 +1,26 @@ +#include "private.h" + + + +PVOID +AllocateItem( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag) +{ + PVOID Item = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag); + if (!Item) + return Item; + + RtlZeroMemory(Item, NumberOfBytes); + return Item; +} + +VOID +FreeItem( + IN PVOID Item, + IN ULONG Tag) +{ + + //ExFreePoolWithTag(Item, Tag); +} diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port.c b/reactos/drivers/wdm/audio/backpln/portcls/port.c index f892ff0752e..30ddf35ce4e 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/port.c @@ -1,13 +1,31 @@ #include "private.h" +NTSTATUS StringFromCLSID( + const CLSID *id, /* [in] GUID to be converted */ + LPWSTR idstr /* [out] pointer to buffer to contain converted guid */ +) { + static const char hex[] = "0123456789ABCDEF"; + WCHAR *s; + int i; + + swprintf(idstr, L"{%08X-%04X-%04X-%02X%02X-", + id->Data1, id->Data2, id->Data3, + id->Data4[0], id->Data4[1]); + s = &idstr[25]; + + /* 6 hex bytes */ + for (i = 2; i < 8; i++) { + *s++ = hex[id->Data4[i]>>4]; + *s++ = hex[id->Data4[i] & 0xf]; + } + + *s++ = '}'; + *s++ = '\0'; + + return STATUS_SUCCESS; +} -const GUID CLSID_PortTopology; -const GUID CLSID_PortMidi; -const GUID CLSID_PortWaveCyclic; -const GUID CLSID_PortWavePci; -const GUID CLSID_PortDMus; -PORTCLASSAPI NTSTATUS NTAPI PcNewPort( @@ -15,6 +33,9 @@ PcNewPort( IN REFCLSID ClassId) { NTSTATUS Status; + WCHAR Buffer[100]; + + DPRINT1("PcNewPort entered\n"); if (!OutPort) { @@ -33,8 +54,14 @@ PcNewPort( else if (IsEqualGUIDAligned(ClassId, &CLSID_PortWavePci)) Status = NewPortWavePci(OutPort); else - Status = STATUS_NOT_SUPPORTED; + { + StringFromCLSID(ClassId, Buffer); + DPRINT1("unknown interface %S\n", Buffer); + + Status = STATUS_NOT_SUPPORTED; + return Status; + } DPRINT("PcNewPort Status %lx\n", Status); return Status; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c b/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c index 3ceb756981b..6291982cdae 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c @@ -66,7 +66,7 @@ IPortDMus_fnRelease( { This->pMiniport->lpVtbl->Release(This->pMiniport); } - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c b/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c index 45edf1cd660..8eca9c8633d 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c @@ -3,18 +3,20 @@ typedef struct { IPortTopologyVtbl *lpVtbl; + ISubdeviceVtbl *lpVtblSubDevice; LONG ref; BOOL bInitialized; - PMINIPORTTOPOLOGY Miniport; + PMINIPORTTOPOLOGY pMiniport; PDEVICE_OBJECT pDeviceObject; PRESOURCELIST pResourceList; + PPINCOUNT pPinCount; + PPOWERNOTIFY pPowerNotify; }IPortTopologyImpl; -const GUID IID_IMiniportTopology; -const GUID IID_IPortTopology; + #if 0 static KSPROPERTY_SET PinPropertySet = @@ -49,19 +51,32 @@ IPortTopology_fnQueryInterface( IN REFIID refiid, OUT PVOID* Output) { + WCHAR Buffer[100]; IPortTopologyImpl * This = (IPortTopologyImpl*)iface; + DPRINT1("IPortTopology_fnQueryInterface\n"); + if (IsEqualGUIDAligned(refiid, &IID_IPortTopology) || IsEqualGUIDAligned(refiid, &IID_IUnknown)) { *Output = &This->lpVtbl; - _InterlockedIncrement(&This->ref); + InterlockedIncrement(&This->ref); + return STATUS_SUCCESS; + } + else if (IsEqualGUIDAligned(refiid, &IID_ISubdevice)) + { + *Output = &This->lpVtblSubDevice; + InterlockedIncrement(&This->ref); return STATUS_SUCCESS; } else if (IsEqualGUIDAligned(refiid, &IID_IPortClsVersion)) { return NewPortClsVersion((PPORTCLSVERSION*)Output); } + StringFromCLSID(refiid, Buffer); + DPRINT1("IPortTopology_fnQueryInterface no iface %S\n", Buffer); + StringFromCLSID(&IID_IUnknown, Buffer); + DPRINT1("IPortTopology_fnQueryInterface IUnknown %S\n", Buffer); return STATUS_UNSUCCESSFUL; } @@ -87,7 +102,7 @@ IPortTopology_fnRelease( if (This->ref == 0) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -112,7 +127,7 @@ IPortTopology_fnGetDeviceProperty( if (!This->bInitialized) { - DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n"); + DPRINT("IPortTopology_fnNewRegistryKey called w/o initiazed\n"); return STATUS_UNSUCCESSFUL; } @@ -133,37 +148,43 @@ IPortTopology_fnInit( NTSTATUS Status; IPortTopologyImpl * This = (IPortTopologyImpl*)iface; + DPRINT1("IPortTopology_fnInit entered\n"); + if (This->bInitialized) { - DPRINT("IPortWaveCyclic_Init called again\n"); + DPRINT1("IPortTopology_Init called again\n"); return STATUS_SUCCESS; } Status = UnknownMiniport->lpVtbl->QueryInterface(UnknownMiniport, &IID_IMiniportTopology, (PVOID*)&Miniport); if (!NT_SUCCESS(Status)) { - DPRINT("IPortWaveCyclic_Init called with invalid IMiniport adapter\n"); + DPRINT1("IPortTopology_Init called with invalid IMiniport adapter\n"); return STATUS_INVALID_PARAMETER; } + /* increment reference on resource list */ + //HACK + //ResourceList->lpVtbl->AddRef(ResourceList); + Status = Miniport->lpVtbl->Init(Miniport, UnknownAdapter, ResourceList, iface); if (!NT_SUCCESS(Status)) { - DPRINT("IMiniportWaveCyclic_Init failed with %x\n", Status); + DPRINT1("IPortTopology_Init failed with %x\n", Status); return Status; } /* Initialize port object */ - This->Miniport = Miniport; + This->pMiniport = Miniport; This->pDeviceObject = DeviceObject; This->bInitialized = TRUE; This->pResourceList = ResourceList; /* increment reference on miniport adapter */ Miniport->lpVtbl->AddRef(Miniport); - /* increment reference on resource list */ - ResourceList->lpVtbl->AddRef(ResourceList); + + DPRINT1("IPortTopology_fnInit success\n"); return STATUS_SUCCESS; } @@ -184,7 +205,7 @@ IPortTopology_fnNewRegistryKey( if (!This->bInitialized) { - DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initialized\n"); + DPRINT("IPortTopology_fnNewRegistryKey called w/o initialized\n"); return STATUS_UNSUCCESSFUL; } return PcNewRegistryKey(OutRegistryKey, @@ -210,20 +231,185 @@ static IPortTopologyVtbl vt_IPortTopology = IPortTopology_fnNewRegistryKey }; +//--------------------------------------------------------------- +// ISubdevice interface +// + +static +NTSTATUS +NTAPI +ISubDevice_fnQueryInterface( + IN ISubdevice *iface, + IN REFIID InterfaceId, + IN PVOID* Interface) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + return IPortTopology_fnQueryInterface((IPortTopology*)This, InterfaceId, Interface); +} + +static +ULONG +NTAPI +ISubDevice_fnAddRef( + IN ISubdevice *iface) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + return IPortTopology_fnAddRef((IPortTopology*)This); +} + +static +ULONG +NTAPI +ISubDevice_fnRelease( + IN ISubdevice *iface) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + return IPortTopology_fnRelease((IPortTopology*)This); +} + +static +NTSTATUS +NTAPI +ISubDevice_fnNewIrpTarget( + IN ISubdevice *iface, + OUT struct IIrpTarget **OutTarget, + IN WCHAR * Name, + IN PUNKNOWN Unknown, + IN POOL_TYPE PoolType, + IN PDEVICE_OBJECT * DeviceObject, + IN PIRP Irp, + IN KSOBJECT_CREATE *CreateObject) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + DPRINT1("ISubDevice_NewIrpTarget this %p\n", This); + return STATUS_UNSUCCESSFUL; +} + +static +NTSTATUS +NTAPI +ISubDevice_fnReleaseChildren( + IN ISubdevice *iface) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + DPRINT1("ISubDevice_ReleaseChildren this %p\n", This); + return STATUS_UNSUCCESSFUL; +} + +static +NTSTATUS +NTAPI +ISubDevice_fnGetDescriptor( + IN ISubdevice *iface, + IN struct SUBDEVICE_DESCRIPTOR ** Descriptor) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + DPRINT1("ISubDevice_GetDescriptor this %p\n", This); + return STATUS_UNSUCCESSFUL; +} + +static +NTSTATUS +NTAPI +ISubDevice_fnDataRangeIntersection( + IN ISubdevice *iface, + IN ULONG PinId, + IN PKSDATARANGE DataRange, + IN PKSDATARANGE MatchingDataRange, + IN ULONG OutputBufferLength, + OUT PVOID ResultantFormat OPTIONAL, + OUT PULONG ResultantFormatLength) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + DPRINT("ISubDevice_DataRangeIntersection this %p\n", This); + + if (This->pMiniport) + { + return This->pMiniport->lpVtbl->DataRangeIntersection (This->pMiniport, PinId, DataRange, MatchingDataRange, OutputBufferLength, ResultantFormat, ResultantFormatLength); + } + + return STATUS_UNSUCCESSFUL; +} + +static +NTSTATUS +NTAPI +ISubDevice_fnPowerChangeNotify( + IN ISubdevice *iface, + IN POWER_STATE PowerState) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + if (This->pPowerNotify) + { + This->pPowerNotify->lpVtbl->PowerChangeNotify(This->pPowerNotify, PowerState); + } + + return STATUS_SUCCESS; +} + +static +NTSTATUS +NTAPI +ISubDevice_fnPinCount( + IN ISubdevice *iface, + IN ULONG PinId, + IN OUT PULONG FilterNecessary, + IN OUT PULONG FilterCurrent, + IN OUT PULONG FilterPossible, + IN OUT PULONG GlobalCurrent, + IN OUT PULONG GlobalPossible) +{ + IPortTopologyImpl * This = (IPortTopologyImpl*)CONTAINING_RECORD(iface, IPortTopologyImpl, lpVtblSubDevice); + + if (This->pPinCount) + { + This->pPinCount->lpVtbl->PinCount(This->pPinCount, PinId, FilterNecessary, FilterCurrent, FilterPossible, GlobalCurrent, GlobalPossible); + return STATUS_SUCCESS; + } + + /* FIXME + * scan filter descriptor + */ + return STATUS_UNSUCCESSFUL; +} + +static ISubdeviceVtbl vt_ISubdeviceVtbl = +{ + ISubDevice_fnQueryInterface, + ISubDevice_fnAddRef, + ISubDevice_fnRelease, + ISubDevice_fnNewIrpTarget, + ISubDevice_fnReleaseChildren, + ISubDevice_fnGetDescriptor, + ISubDevice_fnDataRangeIntersection, + ISubDevice_fnPowerChangeNotify, + ISubDevice_fnPinCount +}; + + NTSTATUS NewPortTopology( OUT PPORT* OutPort) { IPortTopologyImpl * This; - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortTopologyImpl), TAG_PORTCLASS); + This = AllocateItem(NonPagedPool, sizeof(IPortTopologyImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; - RtlZeroMemory(This, sizeof(IPortTopologyImpl)); This->lpVtbl = &vt_IPortTopology; + This->lpVtblSubDevice = &vt_ISubdeviceVtbl; This->ref = 1; *OutPort = (PPORT)(&This->lpVtbl); + DPRINT1("NewPortTopology result %p\n", *OutPort); return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c b/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c index 31b042065f7..a2013628382 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c @@ -20,13 +20,6 @@ typedef struct }IPortWaveCyclicImpl; -const GUID IID_IMiniportWaveCyclic; -const GUID IID_IPortWaveCyclic; -const GUID IID_IUnknown; -const GUID IID_IIrpTarget; -const GUID IID_IPinCount; -const GUID IID_IPowerNotify; -const GUID IID_IDmaChannelSlave; const GUID GUID_DEVCLASS_SOUND; //FIXME //--------------------------------------------------------------- @@ -98,7 +91,7 @@ IPortWaveCyclic_fnRelease( if (This->pPowerNotify) This->pPowerNotify->lpVtbl->Release(This->pPowerNotify); - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -509,16 +502,17 @@ NewPortWaveCyclic( { IPortWaveCyclicImpl * This; - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortWaveCyclicImpl), TAG_PORTCLASS); + This = AllocateItem(NonPagedPool, sizeof(IPortWaveCyclicImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; - RtlZeroMemory(This, sizeof(IPortWaveCyclicImpl)); This->lpVtbl = (IPortWaveCyclicVtbl*)&vt_IPortWaveCyclicVtbl; This->lpVtblSubDevice = (ISubdeviceVtbl*)&vt_ISubdeviceVtbl; This->ref = 1; *OutPort = (PPORT)(&This->lpVtbl); + DPRINT1("NewPortWaveCyclic %p\n", *OutPort); + return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c b/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c index 1ad3a4e5b76..1419d268da2 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c @@ -19,8 +19,7 @@ typedef struct }IPortWavePciImpl; -const GUID IID_IPortWavePci; -const GUID IID_IMiniportWavePci; + //--------------------------------------------------------------- // IServiceSink @@ -36,7 +35,10 @@ IServiceSink_fnQueryInterface( { IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); - if (IsEqualGUIDAligned(refiid, &IID_IServiceSink)) + DPRINT1("IServiceSink_fnQueryInterface entered\n"); + + if (IsEqualGUIDAligned(refiid, &IID_IServiceSink) || + IsEqualGUIDAligned(refiid, &IID_IUnknown)) { *Output = &This->lpVtblServiceSink; InterlockedIncrement(&This->ref); @@ -52,7 +54,7 @@ IServiceSink_fnAddRef( IServiceSink* iface) { IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); - + DPRINT1("IServiceSink_fnAddRef entered\n"); return InterlockedIncrement(&This->ref); } @@ -63,12 +65,12 @@ IServiceSink_fnRelease( IServiceSink* iface) { IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); - + DPRINT1("IServiceSink_fnRelease entered\n"); InterlockedDecrement(&This->ref); if (This->ref == 0) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -82,7 +84,7 @@ IServiceSink_fnRequestService( IServiceSink* iface) { IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink); - + DPRINT1("IServiceSink_fnRequestService entered\n"); if (This->Miniport) { This->Miniport->lpVtbl->Service(This->Miniport); @@ -111,7 +113,10 @@ IPortWavePci_fnQueryInterface( { IPortWavePciImpl * This = (IPortWavePciImpl*)iface; - if (IsEqualGUIDAligned(refiid, &IID_IPortWavePci)) + DPRINT1("IPortWavePci_fnQueryInterface entered\n"); + + if (IsEqualGUIDAligned(refiid, &IID_IPortWavePci) || + IsEqualGUIDAligned(refiid, &IID_IUnknown)) { *Output = &This->lpVtbl; InterlockedIncrement(&This->ref); @@ -127,6 +132,9 @@ IPortWavePci_fnQueryInterface( { return NewPortClsVersion((PPORTCLSVERSION*)Output); } + + DPRINT1("IPortWavePci_fnQueryInterface no interface!!!\n"); + return STATUS_UNSUCCESSFUL; } @@ -137,6 +145,9 @@ IPortWavePci_fnAddRef( IPortWavePci* iface) { IPortWavePciImpl * This = (IPortWavePciImpl*)iface; + + DPRINT1("IPortWavePci_fnAddRef entered\n"); + return InterlockedIncrement(&This->ref); } @@ -148,11 +159,13 @@ IPortWavePci_fnRelease( { IPortWavePciImpl * This = (IPortWavePciImpl*)iface; + DPRINT1("IPortWavePci_fnRelease entered\n"); + InterlockedDecrement(&This->ref); if (This->ref == 0) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -167,8 +180,10 @@ ServiceNotifyRoutine( IN PVOID SystemArgument1, IN PVOID SystemArgument2) { + DPRINT1("ServiceNotifyRoutine entered\n"); + IPortWavePciImpl * This = (IPortWavePciImpl*)DeferredContext; - if (This->ServiceGroup) + if (This->ServiceGroup && This->bInitialized) { This->ServiceGroup->lpVtbl->RequestService(This->ServiceGroup); } @@ -191,6 +206,9 @@ IPortWavePci_fnInit( NTSTATUS Status; IPortWavePciImpl * This = (IPortWavePciImpl*)iface; + DPRINT1("IPortWavePci::Init entered with This %p, DeviceObject %p Irp %p UnknownMiniport %p, UnknownAdapter %p ResourceList %p\n", + This, DeviceObject, Irp, UnknownMiniport, UnknownAdapter, ResourceList); + if (This->bInitialized) { DPRINT("IPortWaveCyclic_Init called again\n"); @@ -204,13 +222,17 @@ IPortWavePci_fnInit( return STATUS_INVALID_PARAMETER; } + /* initialize the dpc */ + KeInitializeDpc(&This->Dpc, ServiceNotifyRoutine, (PVOID)This); + + Status = Miniport->lpVtbl->Init(Miniport, UnknownAdapter, ResourceList, iface, &ServiceGroup); if (!NT_SUCCESS(Status)) { DPRINT("IMiniportWaveCyclic_Init failed with %x\n", Status); return Status; } - + DPRINT1("IPortWaveCyclic_Init Miniport adapter initialized\n"); /* Initialize port object */ This->Miniport = Miniport; This->pDeviceObject = DeviceObject; @@ -218,8 +240,6 @@ IPortWavePci_fnInit( This->pResourceList = ResourceList; This->ServiceGroup = ServiceGroup; - /* initialize the dpc */ - KeInitializeDpc(&This->Dpc, ServiceNotifyRoutine, (PVOID)This); /* increment reference on miniport adapter */ Miniport->lpVtbl->AddRef(Miniport); @@ -232,6 +252,7 @@ IPortWavePci_fnInit( /* increment reference on service group */ ServiceGroup->lpVtbl->AddRef(ServiceGroup); + DPRINT("IPortWaveCyclic_Init sucessfully initialized\n"); return STATUS_SUCCESS; } @@ -249,6 +270,8 @@ IPortWavePci_fnNewRegistryKey( { IPortWavePciImpl * This = (IPortWavePciImpl*)iface; + DPRINT1("IPortWavePci_fnNewRegistryKey entered\n"); + if (!This->bInitialized) { DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n"); @@ -277,6 +300,8 @@ IPortWavePci_fnGetDeviceProperty( { IPortWavePciImpl * This = (IPortWavePciImpl*)iface; + DPRINT1("IPortWavePci_fnGetDeviceProperty entered\n"); + if (!This->bInitialized) { DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initiazed\n"); @@ -307,6 +332,8 @@ IPortWavePci_fnNewMasterDmaChannel( DEVICE_DESCRIPTION DeviceDescription; IPortWavePciImpl * This = (IPortWavePciImpl*)iface; + DPRINT1("IPortWavePci_fnNewMasterDmaChannel entered\n"); + Status = PcDmaMasterDescription(ResourceList, ScatterGather, Dma32BitAddresses, IgnoreCount, Dma64BitAddresses, DmaWidth, DmaSpeed, MaximumLength, DmaPort, &DeviceDescription); if (NT_SUCCESS(Status)) { @@ -323,6 +350,10 @@ IPortWavePci_fnNotify( IN PSERVICEGROUP ServiceGroup) { IPortWavePciImpl * This = (IPortWavePciImpl*)iface; + + + DPRINT1("IPortWavePci_fnNotify entered\n"); + KeInsertQueueDpc(&This->Dpc, NULL, NULL); } @@ -348,15 +379,15 @@ NewPortWavePci( { IPortWavePciImpl * This; - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortWavePciImpl), TAG_PORTCLASS); + This = AllocateItem(NonPagedPool, sizeof(IPortWavePciImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; - RtlZeroMemory(This, sizeof(IPortWavePciImpl)); This->lpVtblServiceSink = &vt_IServiceSink; This->lpVtbl = &vt_IPortWavePci; This->ref = 1; *OutPort = (PPORT)&This->lpVtbl; + DPRINT1("NewPortWavePci %p\n", *OutPort); return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild b/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild index 184a0c574b7..7960d5bc1da 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild +++ b/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild @@ -17,6 +17,7 @@ drm_port.c adapter.c filter_wavecyclic.c + guids.c irp.c interrupt.c drm.c @@ -24,7 +25,8 @@ undoc.c resource.c registry.c - service_group.c + service_group.c + pool.c port.c power.c port_dmus.c diff --git a/reactos/drivers/wdm/audio/backpln/portcls/power.c b/reactos/drivers/wdm/audio/backpln/portcls/power.c index 9c1338963a3..dad67cff64c 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/power.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/power.c @@ -1,6 +1,6 @@ #include "private.h" -const GUID IID_IAdapterPowerManagement; + /* * @implemented @@ -17,23 +17,25 @@ PcRegisterAdapterPowerManagement( PCExtension* DeviceExt; IAdapterPowerManagement * pPower; + DPRINT1("PcRegisterAdapterPowerManagement pUnknown %p pvContext %p\n", pUnknown, pvContext); + if (!pUnknown || !pvContext) return STATUS_INVALID_PARAMETER; - Status = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IAdapterPowerManagement, (PVOID*)&pPower); - if (!NT_SUCCESS(Status)) - return Status; pDeviceObject = (PDEVICE_OBJECT)pvContext; DeviceExt = (PCExtension*)pDeviceObject->DeviceExtension; - if (DeviceExt->AdapterPowerManagement) + Status = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IAdapterPowerManagement, (PVOID*)&pPower); + if (!NT_SUCCESS(Status)) { - pPower->lpVtbl->Release(pPower); - return STATUS_UNSUCCESSFUL; + DPRINT1("PcRegisterAdapterPowerManagement no IAdapterPowerManagement interface %x\n", Status); + DeviceExt->AdapterPowerManagement = NULL; + return STATUS_SUCCESS; } DeviceExt->AdapterPowerManagement = pPower; + DPRINT1("PcRegisterAdapterPowerManagement success %x\n", Status); return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/private.h b/reactos/drivers/wdm/audio/backpln/portcls/private.h index e6fbb15f693..ff8f432e3ca 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/private.h +++ b/reactos/drivers/wdm/audio/backpln/portcls/private.h @@ -17,6 +17,7 @@ #include "interfaces.h" #include +#include #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) #define TAG_PORTCLASS TAG('P', 'C', 'L', 'S') @@ -82,6 +83,18 @@ NTSTATUS NewPortClsVersion( NTSTATUS NewPortFilterWaveCyclic( OUT IPortFilterWaveCyclic ** OutFilter); +PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag); + +VOID +FreeItem( + IN PVOID Item, + IN ULONG Tag); + +NTSTATUS StringFromCLSID( + const CLSID *id, + LPWSTR idstr); + + typedef struct { LIST_ENTRY Entry; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/registry.c b/reactos/drivers/wdm/audio/backpln/portcls/registry.c index 3cb7342dd27..59ceb29e276 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/registry.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/registry.c @@ -9,13 +9,8 @@ typedef struct }IRegistryKeyImpl; -const GUID IID_IRegistryKey; -/* - Basic IUnknown methods -*/ - -static IRegistryKeyVtbl vt_IRegistryKeyVtbl; +static IRegistryKeyVtbl vt_IRegistryKey; ULONG @@ -38,14 +33,14 @@ IRegistryKey_fnRelease( IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; _InterlockedDecrement(&This->ref); - + DPRINT1("IRegistryKey_fnRelease ref %u this %p entered\n", This->ref, This); if (This->ref == 0) { if (This->hKey) { ZwClose(This->hKey); } - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -60,7 +55,7 @@ IRegistryKey_fnQueryInterface( OUT PVOID* Output) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; - + DPRINT1("IRegistryKey_fnQueryInterface entered\n"); if (IsEqualGUIDAligned(refiid, &IID_IRegistryKey)) { *Output = (PVOID)&This->lpVtbl; @@ -78,6 +73,7 @@ IRegistryKey_fnDeleteKey( IN IRegistryKey* iface) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; + DPRINT1("IRegistryKey_fnDeleteKey entered\n"); return ZwDeleteKey(This->hKey); } @@ -92,6 +88,7 @@ IRegistryKey_fnEnumerateKey( OUT PULONG ResultLength) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; + DPRINT1("IRegistryKey_fnEnumerateKey entered\n"); return ZwEnumerateKey(This->hKey, Index, KeyInformationClass, KeyInformation, Length, ResultLength); } @@ -106,6 +103,7 @@ IRegistryKey_fnEnumerateKeyValue( OUT PULONG ResultLength) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; + DPRINT1("IRegistryKey_fnEnumerateKeyValue entered\n"); return ZwEnumerateValueKey(This->hKey, Index, KeyValueInformationClass, KeyValueInformation, Length, ResultLength); } @@ -125,13 +123,15 @@ IRegistryKey_fnNewSubKey( HANDLE hKey; IRegistryKeyImpl * NewThis, *This = (IRegistryKeyImpl*)iface; + DPRINT1("IRegistryKey_fnNewSubKey entered\n"); + InitializeObjectAttributes(&Attributes, SubKeyName, 0, This->hKey, NULL); Status = ZwCreateKey(&hKey, KEY_READ | KEY_WRITE, &Attributes, 0, NULL, 0, Disposition); if (!NT_SUCCESS(Status)) return Status; - NewThis = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS); + NewThis = AllocateItem(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS); if (!NewThis) { ZwClose(hKey); @@ -140,8 +140,11 @@ IRegistryKey_fnNewSubKey( NewThis->hKey = hKey; NewThis->ref = 1; - NewThis->lpVtbl = &vt_IRegistryKeyVtbl; - *RegistrySubKey = (PREGISTRYKEY)&This->lpVtbl; + NewThis->lpVtbl = &vt_IRegistryKey; + *RegistrySubKey = (PREGISTRYKEY)&NewThis->lpVtbl; + + DPRINT1("IRegistryKey_fnNewSubKey RESULT %p\n", *RegistrySubKey ); + return STATUS_SUCCESS; } @@ -155,6 +158,7 @@ IRegistryKey_fnQueryKey( OUT PULONG ResultLength) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; + DPRINT1("IRegistryKey_fnQueryKey entered\n"); return ZwQueryKey(This->hKey, KeyInformationClass, KeyInformation, Length, ResultLength); } @@ -166,7 +170,7 @@ IRegistryKey_fnQueryRegistryValues( IN PVOID Context OPTIONAL) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; - DPRINT("IRegistryKey_QueryRegistryValues: This %p\n", This); + DPRINT1("IRegistryKey_QueryRegistryValues: This %p\n", This); return STATUS_UNSUCCESSFUL; } @@ -181,6 +185,7 @@ IRegistryKey_fnQueryValueKey( OUT PULONG ResultLength) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; + DPRINT1("IRegistryKey_fnQueryValueKey entered %p value %wZ\n", This, ValueName); return ZwQueryValueKey(This->hKey, ValueName, KeyValueInformationClass, KeyValueInformation, Length, ResultLength); } @@ -195,6 +200,7 @@ IRegistryKey_fnSetValueKey( ) { IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface; + DPRINT1("IRegistryKey_fnSetValueKey entered\n"); return ZwSetValueKey(This->hKey, ValueName, 0, Type, Data, DataSize); } @@ -233,6 +239,9 @@ PcNewRegistryKey( HANDLE hHandle; NTSTATUS Status = STATUS_UNSUCCESSFUL; IRegistryKeyImpl * This; + PCExtension* portcls_ext; + + DPRINT1("PcNewRegistryKey entered\n"); if (!OutRegistryKey) return STATUS_INVALID_PARAMETER; @@ -246,28 +255,38 @@ PcNewRegistryKey( return STATUS_INVALID_PARAMETER; } + /* check for the key type */ if (RegistryKeyType == GeneralRegistryKey) { + /* do we have the required object attributes */ if (!ObjectAttributes) + { + /* object attributes is mandatory */ return STATUS_INVALID_PARAMETER; - + } + /* try to open the key */ Status = ZwOpenKey(&hHandle, DesiredAccess, ObjectAttributes); } else if (RegistryKeyType == DeviceRegistryKey || RegistryKeyType == DriverRegistryKey || RegistryKeyType == HwProfileRegistryKey) { + /* check for HwProfileRegistryKey case */ if (RegistryKeyType == HwProfileRegistryKey) { /* IoOpenDeviceRegistryKey used different constant */ RegistryKeyType = PLUGPLAY_REGKEY_CURRENT_HWPROFILE; } - Status = IoOpenDeviceRegistryKey(DeviceObject, RegistryKeyType, DesiredAccess, &hHandle); + /* obtain the new device extension */ + portcls_ext = (PCExtension*) ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension; + + Status = IoOpenDeviceRegistryKey(portcls_ext->PhysicalDeviceObject, RegistryKeyType, DesiredAccess, &hHandle); } else if (RegistryKeyType == DeviceInterfaceRegistryKey) { /* FIXME */ + DPRINT1("fixme\n"); } if (!NT_SUCCESS(Status)) @@ -275,7 +294,7 @@ PcNewRegistryKey( return Status; } - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS); + This = AllocateItem(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS); if (!This) { ZwClose(hHandle); @@ -287,6 +306,7 @@ PcNewRegistryKey( This->ref = 1; *OutRegistryKey = (PREGISTRYKEY)&This->lpVtbl; + DPRINT1("PcNewRegistryKey result %p\n", *OutRegistryKey); return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/resource.c b/reactos/drivers/wdm/audio/backpln/portcls/resource.c index 86e650794ae..3f97ddda21d 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/resource.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/resource.c @@ -24,7 +24,7 @@ typedef struct CResourceList PCM_RESOURCE_LIST UntranslatedResourceList; } IResourceListImpl; -const GUID IID_IResourceList; + /* Basic IUnknown methods @@ -41,7 +41,7 @@ IResourceList_fnQueryInterface( if (IsEqualGUIDAligned(refiid, &IID_IResourceList)) { *Output = &This->lpVtbl; - _InterlockedIncrement(&This->ref); + InterlockedIncrement(&This->ref); return STATUS_SUCCESS; } return STATUS_UNSUCCESSFUL; @@ -54,7 +54,7 @@ IResourceList_fnAddRef( { IResourceListImpl * This = (IResourceListImpl*)iface; - return _InterlockedIncrement(&This->ref); + return InterlockedIncrement(&This->ref); } ULONG @@ -64,13 +64,15 @@ IResourceList_fnRelease( { IResourceListImpl * This = (IResourceListImpl*)iface; - _InterlockedDecrement(&This->ref); + InterlockedDecrement(&This->ref); + + DPRINT("IResourceList_fnRelease %p ref %x\n", This, This->ref); if (This->ref == 0) { - ExFreePool(This->TranslatedResourceList); - ExFreePool(This->UntranslatedResourceList); - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This->TranslatedResourceList, TAG_PORTCLASS); + FreeItem(This->UntranslatedResourceList, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -187,15 +189,15 @@ IResourceList_fnAddEntry( IResourceListImpl * This = (IResourceListImpl*)iface; NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + This->TranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - NewTranslatedResources = ExAllocatePoolWithTag(This->PoolType, NewTranslatedSize, TAG_PORTCLASS); + NewTranslatedResources = AllocateItem(This->PoolType, NewTranslatedSize, TAG_PORTCLASS); if (!NewTranslatedResources) return STATUS_INSUFFICIENT_RESOURCES; NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + This->UntranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - NewUntranslatedResources = ExAllocatePoolWithTag(This->PoolType, NewUntranslatedSize, TAG_PORTCLASS); + NewUntranslatedResources = AllocateItem(This->PoolType, NewUntranslatedSize, TAG_PORTCLASS); if (!NewUntranslatedResources) { - ExFreePoolWithTag(NewTranslatedResources, TAG_PORTCLASS); + FreeItem(NewTranslatedResources, TAG_PORTCLASS); return STATUS_INSUFFICIENT_RESOURCES; } @@ -205,8 +207,8 @@ IResourceList_fnAddEntry( RtlCopyMemory(NewUntranslatedResources, This->UntranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); RtlCopyMemory(&NewUntranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->UntranslatedResourceList[0].List->PartialResourceList.Count], Untranslated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); - ExFreePoolWithTag(This->TranslatedResourceList, TAG_PORTCLASS); - ExFreePoolWithTag(This->UntranslatedResourceList, TAG_PORTCLASS); + FreeItem(This->TranslatedResourceList, TAG_PORTCLASS); + FreeItem(This->UntranslatedResourceList, TAG_PORTCLASS); This->UntranslatedResourceList = NewUntranslatedResources; This->TranslatedResourceList = NewTranslatedResources; @@ -235,14 +237,14 @@ IResourceList_fnAddEntryFromParent( return STATUS_INVALID_PARAMETER; NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + This->TranslatedResourceList[0].List->PartialResourceList.Count * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - NewTranslatedResources = ExAllocatePoolWithTag(This->PoolType, NewTranslatedSize, TAG_PORTCLASS); + NewTranslatedResources = AllocateItem(This->PoolType, NewTranslatedSize, TAG_PORTCLASS); if (!NewTranslatedResources) return STATUS_INSUFFICIENT_RESOURCES; RtlCopyMemory(NewTranslatedResources, This->TranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); RtlCopyMemory(&NewTranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->TranslatedResourceList[0].List->PartialResourceList.Count], Translated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)); - ExFreePoolWithTag(This->TranslatedResourceList, TAG_PORTCLASS); + FreeItem(This->TranslatedResourceList, TAG_PORTCLASS); This->TranslatedResourceList = NewTranslatedResources; NewTranslatedResources->List[0].PartialResourceList.Count++; @@ -308,32 +310,32 @@ PcNewResourceList( /* TODO: Validate parameters */ - DPRINT("PcNewResourceList\n"); + DPRINT1("PcNewResourceList\n"); - NewList = ExAllocatePoolWithTag(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS); + NewList = AllocateItem(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS); if (!NewList) { - DPRINT("ExAllocatePoolWithTag failed\n"); + DPRINT("AllocateItem failed\n"); return STATUS_INSUFFICIENT_RESOURCES; } /* Initialize */ NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + (TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - NewTranslatedResources = ExAllocatePoolWithTag(PoolType, NewTranslatedSize, TAG_PORTCLASS); + NewTranslatedResources = AllocateItem(PoolType, NewTranslatedSize, TAG_PORTCLASS); if (!NewTranslatedResources) { - ExFreePoolWithTag(NewList, TAG_PORTCLASS); + FreeItem(NewList, TAG_PORTCLASS); return STATUS_INSUFFICIENT_RESOURCES; } NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + (UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - NewUntranslatedResources = ExAllocatePoolWithTag(PoolType, NewUntranslatedSize, TAG_PORTCLASS); + NewUntranslatedResources = AllocateItem(PoolType, NewUntranslatedSize, TAG_PORTCLASS); if (!NewUntranslatedResources) { - ExFreePoolWithTag(NewList, TAG_PORTCLASS); - ExFreePoolWithTag(NewTranslatedResources, TAG_PORTCLASS); + FreeItem(NewList, TAG_PORTCLASS); + FreeItem(NewTranslatedResources, TAG_PORTCLASS); return STATUS_INSUFFICIENT_RESOURCES; } @@ -363,11 +365,12 @@ PcNewResourceSublist( { IResourceListImpl* NewList, *Parent; - if (!OuterUnknown || !ParentList || !MaximumEntries) + if (!OutResourceList || !ParentList || !MaximumEntries) return STATUS_INVALID_PARAMETER; Parent = (IResourceListImpl*)ParentList; + DPRINT1("PcNewResourceSublist entered\n"); if (!Parent->TranslatedResourceList->List->PartialResourceList.Count || !Parent->UntranslatedResourceList->List->PartialResourceList.Count) @@ -376,22 +379,22 @@ PcNewResourceSublist( return STATUS_INVALID_PARAMETER; } - NewList = ExAllocatePoolWithTag(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS); + NewList = AllocateItem(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS); if (!NewList) return STATUS_INSUFFICIENT_RESOURCES; - NewList->TranslatedResourceList = ExAllocatePoolWithTag(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); + NewList->TranslatedResourceList = AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); if (!NewList->TranslatedResourceList) { - ExFreePoolWithTag(NewList, TAG_PORTCLASS); + FreeItem(NewList, TAG_PORTCLASS); return STATUS_INSUFFICIENT_RESOURCES; } - NewList->UntranslatedResourceList = ExAllocatePoolWithTag(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); + NewList->UntranslatedResourceList = AllocateItem(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS); if (!NewList->UntranslatedResourceList) { - ExFreePoolWithTag(NewList->TranslatedResourceList, TAG_PORTCLASS); - ExFreePoolWithTag(NewList, TAG_PORTCLASS); + FreeItem(NewList->TranslatedResourceList, TAG_PORTCLASS); + FreeItem(NewList, TAG_PORTCLASS); return STATUS_INSUFFICIENT_RESOURCES; } @@ -409,5 +412,6 @@ PcNewResourceSublist( *OutResourceList = (IResourceList*)&NewList->lpVtbl; + DPRINT1("PcNewResourceSublist OutResourceList %p OuterUnknown %p ParentList %p\n", *OutResourceList, OuterUnknown, ParentList); return STATUS_SUCCESS; } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/service_group.c b/reactos/drivers/wdm/audio/backpln/portcls/service_group.c index fa014b589de..d9c9bd64e73 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/service_group.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/service_group.c @@ -21,8 +21,7 @@ typedef struct }IServiceGroupImpl; -const GUID IID_IServiceGroup; -const GUID IID_IServiceSink; + //--------------------------------------------------------------- // IUnknown methods @@ -75,11 +74,11 @@ IServiceGroup_fnRelease( CurEntry = RemoveHeadList(&This->ServiceSinkHead); Entry = CONTAINING_RECORD(CurEntry, GROUP_ENTRY, Entry); Entry->pServiceSink->lpVtbl->Release(Entry->pServiceSink); - ExFreePoolWithTag(Entry, TAG_PORTCLASS); + FreeItem(Entry, TAG_PORTCLASS); } KeWaitForSingleObject(&This->DpcEvent, Executive, KernelMode, FALSE, NULL); KeCancelTimer(&This->Timer); - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -123,7 +122,7 @@ IServiceGroup_fnAddMember( PGROUP_ENTRY Entry; IServiceGroupImpl * This = (IServiceGroupImpl*)iface; - Entry = ExAllocatePoolWithTag(NonPagedPool, sizeof(GROUP_ENTRY), TAG_PORTCLASS); + Entry = AllocateItem(NonPagedPool, sizeof(GROUP_ENTRY), TAG_PORTCLASS); if (!Entry) return STATUS_INSUFFICIENT_RESOURCES; @@ -159,7 +158,7 @@ IServiceGroup_fnRemoveMember( { RemoveEntryList(&Entry->Entry); pServiceSink->lpVtbl->Release(pServiceSink); - ExFreePoolWithTag(Entry, TAG_PORTCLASS); + FreeItem(Entry, TAG_PORTCLASS); return; } CurEntry = CurEntry->Flink; @@ -253,14 +252,15 @@ PcNewServiceGroup( { IServiceGroupImpl * This; - This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IServiceGroupImpl), TAG_PORTCLASS); + DPRINT1("PcNewServiceGroup entered\n"); + + This = AllocateItem(NonPagedPool, sizeof(IServiceGroupImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES; This->lpVtbl = &vt_IServiceGroup; This->ref = 1; InitializeListHead(&This->ServiceSinkHead); - This->Initialized = FALSE; *OutServiceGroup = (PSERVICEGROUP)&This->lpVtbl; return STATUS_SUCCESS; diff --git a/reactos/drivers/wdm/audio/backpln/portcls/version.c b/reactos/drivers/wdm/audio/backpln/portcls/version.c index 2d63b9bff4b..4131b734ca6 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/version.c +++ b/reactos/drivers/wdm/audio/backpln/portcls/version.c @@ -7,7 +7,7 @@ typedef struct LONG ref; }IPortClsVersionImpl; -const GUID IID_IPortClsVersion; + //--------------------------------------------------------------- // IPortClsVersion interface functions @@ -53,7 +53,7 @@ IPortClsVersion_fnRelease( if (This->ref == 0) { - ExFreePoolWithTag(This, TAG_PORTCLASS); + FreeItem(This, TAG_PORTCLASS); return 0; } /* Return new reference count */ @@ -80,7 +80,7 @@ static IPortClsVersionVtbl vt_PortClsVersion = NTSTATUS NewPortClsVersion( OUT PPORTCLSVERSION * OutVersion) { - IPortClsVersionImpl * This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortClsVersionImpl), TAG_PORTCLASS); + IPortClsVersionImpl * This = AllocateItem(NonPagedPool, sizeof(IPortClsVersionImpl), TAG_PORTCLASS); if (!This) return STATUS_INSUFFICIENT_RESOURCES;