[ros-diffs] [janderwald] 38810: - Check for valid DeviceExtensionSize - Pass correct flags when creating the fdo - set DO_DIRECT_IO flag - clear DO_DEVICE_INITIALIZING flag - Move all calls to ExAllocatePoolWithTag to a function AllocateItem which is also responsible for zeroing memory - Fix ISubDevice GUID - don't disconnect the interrupt on cleanup, IInterruptSync_fnDisconnect exist for that purpose - If there is no interrupt yet connected, call the synchronized routine holding the internal spinlock - Copy the current stack location when forwarding a Irp PcForwardIrpSynchronous - Implement ISubdevice interface for IPortTopology - Initialize the dpc for calling Miniport object, as it might create an interrupt object which immediately fires an interrupt - If the caller doesnt provide an IAdapterPowerManagement interface, clear the existing reference - Fix 2 bugs in IRegistryKey_NewSubKey which made the system crashing - Pass the pdo to IoOpenDeviceRegistryKey - Move all guids and IIDs to own file and initialize them - portcls initializes now to the first interrupt fired (vbox+ICH AC97 driver | qemu+es1370 driver)

janderwald at svn.reactos.org janderwald at svn.reactos.org
Sat Jan 17 12:19:28 CET 2009


Author: janderwald
Date: Sat Jan 17 05:19:27 2009
New Revision: 38810

URL: http://svn.reactos.org/svn/reactos?rev=38810&view=rev
Log:
- Check for valid DeviceExtensionSize
- Pass correct flags when creating the fdo
- set DO_DIRECT_IO flag
- clear DO_DEVICE_INITIALIZING flag
- Move all calls to ExAllocatePoolWithTag to a function AllocateItem which is also responsible for zeroing memory
- Fix ISubDevice GUID
- don't disconnect the interrupt on cleanup, IInterruptSync_fnDisconnect exist for that purpose
- If there is no interrupt yet connected, call the synchronized routine holding the internal spinlock
- Copy the current stack location  when forwarding a Irp PcForwardIrpSynchronous
- Implement ISubdevice interface for IPortTopology
- Initialize the dpc for calling Miniport object, as it might create an interrupt object which immediately fires an interrupt
- If the caller doesnt provide an IAdapterPowerManagement interface, clear the existing reference
- Fix 2 bugs in IRegistryKey_NewSubKey which made the system crashing 
- Pass the pdo to IoOpenDeviceRegistryKey
- Move all guids and IIDs to own file and initialize them
- portcls initializes now to the first interrupt fired (vbox+ICH AC97 driver | qemu+es1370 driver)


Added:
    trunk/reactos/drivers/wdm/audio/backpln/portcls/guids.c   (with props)
    trunk/reactos/drivers/wdm/audio/backpln/portcls/pool.c   (with props)
Modified:
    trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/connection.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h
    trunk/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild
    trunk/reactos/drivers/wdm/audio/backpln/portcls/power.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h
    trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/service_group.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/version.c

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -12,8 +12,6 @@
 #include "private.h"
 #include <devguid.h>
 #include <initguid.h>
-
-const GUID IID_ISubdevice;
 
 /*
     This is called from DriverEntry so that PortCls can take care of some
@@ -49,7 +47,7 @@
     //NTSTATUS status;
     //ULONG i;
 
-    DPRINT("PcInitializeAdapterDriver\n");
+    DPRINT1("PcInitializeAdapterDriver\n");
 
 #if 0
     /* Set default stub - is this a good idea? */
@@ -101,59 +99,41 @@
     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)
-    {
-        DPRINT("DriverObject is NULL!\n");
+    if (!DriverObject || !PhysicalDeviceObject || !StartDevice)
+    {
         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;
         }
-    }
-
-    DPRINT("portcls is creating a device\n");
+        /* set size to our extension size */
+        DeviceExtensionSize = PORT_CLASS_DEVICE_EXTENSION_SIZE;
+    }
+
+    /* 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 @@
 
     /* Obtain the new device extension */
     portcls_ext = (PCExtension*) fdo->DeviceExtension;
-
-    ASSERT(portcls_ext);
-
-    /* Initialize */
-    RtlZeroMemory(portcls_ext, sizeof(PCExtension));
+    /* initialize the device extension */
+    RtlZeroMemory(portcls_ext, DeviceExtensionSize);
+    /* allocate create item */
+    portcls_ext->CreateItems = AllocateItem(NonPagedPool, MaxObjects * sizeof(KSOBJECT_CREATE_ITEM), TAG_PORTCLASS);
+
+    /* 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 @@
         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 @@
     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 @@
     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 @@
     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 @@
         RtlFreeUnicodeString(&SymbolicLinkName);
     }
 
-
-    return Status;
+    DPRINT1("PcRegisterSubdevice Status %x\n", Status);
+
+    /// HACK
+    /// IoRegisterDeviceInterface fails with
+    /// STATUS_OBJECT_PATH_NOT_FOUND
+    /// return Status;
+    return STATUS_SUCCESS;
 }

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/connection.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/connection.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/connection.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/connection.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -59,7 +59,7 @@
         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 @@
     IN  PUNKNOWN ToUnknown,
     IN  ULONG ToPin)
 {
+
+    DPRINT1("PcRegisterPhysicalConnection\n");
+
     if (!DeviceObject || !FromUnknown || !ToUnknown)
         return STATUS_INVALID_PARAMETER;
 

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/dma_slave.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -85,7 +85,7 @@
     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 @@
 
     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 @@
     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;

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/drm_port.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -1,8 +1,7 @@
 #include "private.h"
 
 
-const GUID IID_IDrmPort;
-const GUID IID_IDrmPort2;
+
 
 typedef struct
 {
@@ -33,7 +32,7 @@
 
     if (This->ref == 0)
     {
-        ExFreePoolWithTag(This, TAG_PORTCLASS);
+        FreeItem(This, TAG_PORTCLASS);
         return 0;
     }
     /* Return new reference count */
@@ -154,7 +153,7 @@
 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;
 

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/filter_wavecyclic.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -59,7 +59,7 @@
 
     if (This->ref == 0)
     {
-        ExFreePoolWithTag(This, TAG_PORTCLASS);
+        FreeItem(This, TAG_PORTCLASS);
         return 0;
     }
     return This->ref;
@@ -260,7 +260,7 @@
 {
     IPortFilterWaveCyclicImpl * This;
 
-    This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPortFilterWaveCyclicImpl), TAG_PORTCLASS);
+    This = AllocateItem(NonPagedPool, sizeof(IPortFilterWaveCyclicImpl), TAG_PORTCLASS);
     if (!This)
         return STATUS_INSUFFICIENT_RESOURCES;
 

Added: trunk/reactos/drivers/wdm/audio/backpln/portcls/guids.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/guids.c?rev=38810&view=auto
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/guids.c (added)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/guids.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -1,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}};
+

Propchange: trunk/reactos/drivers/wdm/audio/backpln/portcls/guids.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/interfaces.h [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -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);
 
 
 /*****************************************************************************

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/interrupt.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -28,7 +28,7 @@
 // IUnknown methods
 //
 
-const GUID IID_IInterruptSync;
+
 
 NTSTATUS
 NTAPI
@@ -39,13 +39,15 @@
 {
     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 @@
 {
     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 @@
 
     _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 @@
     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 @@
     IN PINTERRUPTSYNCROUTINE Routine,
     IN PVOID DynamicContext)
 {
-    IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
+    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 @@
     IN IInterruptSync * iface)
 {
     IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
+    DPRINT1("IInterruptSynchronizedRoutine\n");
 
     return This->Interrupt;
 }
@@ -153,6 +164,8 @@
     NTSTATUS Status;
     BOOL Success;
     IInterruptSyncImpl * This = (IInterruptSyncImpl*)ServiceContext;
+
+    DPRINT1("IInterruptServiceRoutine\n");
 
     if (This->Mode == InterruptSyncModeNormal)
     {
@@ -216,6 +229,8 @@
     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 @@
     IN IInterruptSync * iface)
 {
     IInterruptSyncImpl * This = (IInterruptSyncImpl*)iface;
+    DPRINT1("IInterruptSync_fnDisconnect\n");
 
     if (!This->Interrupt)
     {
@@ -266,7 +282,9 @@
     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 @@
 {
     IInterruptSyncImpl * This;
 
+    DPRINT1("PcNewInterruptSync entered\n");
 
     if (!OutInterruptSync || !ResourceList || Mode > InterruptSyncModeRepeat || Mode < 0)
         return STATUS_INVALID_PARAMETER;
@@ -315,22 +334,24 @@
     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;
+}
+

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/irp.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -205,7 +205,7 @@
 {
     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,9 +289,12 @@
     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);

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -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
@@ -27,6 +23,8 @@
     IN  REFCLSID ClassId)
 {
     NTSTATUS Status = STATUS_INVALID_PARAMETER;
+
+    DPRINT1("PcNewMiniport entered\n");
 
     if (!OutMiniport)
     {

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/miniport_dmus.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -8,7 +8,7 @@
 
 }IMiniportDMusImpl;
 
-const GUID IID_IMiniportDMus;
+
 
 /* IUnknown methods */
 
@@ -51,7 +51,7 @@
 
     if (This->ref == 0)
     {
-        ExFreePoolWithTag(This, TAG_PORTCLASS);
+        FreeItem(This, TAG_PORTCLASS);
         return 0;
     }
     /* Return new reference count */
@@ -148,7 +148,7 @@
 {
     IMiniportDMusImpl * This;
 
-    This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IMiniportDMusImpl), TAG_PORTCLASS);
+    This = AllocateItem(NonPagedPool, sizeof(IMiniportDMusImpl), TAG_PORTCLASS);
     if (!This)
         return STATUS_INSUFFICIENT_RESOURCES;
 

Added: trunk/reactos/drivers/wdm/audio/backpln/portcls/pool.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/pool.c?rev=38810&view=auto
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/pool.c (added)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pool.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -1,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);
+}

Propchange: trunk/reactos/drivers/wdm/audio/backpln/portcls/pool.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -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;
 
-const GUID CLSID_PortTopology;
-const GUID CLSID_PortMidi;
-const GUID CLSID_PortWaveCyclic;
-const GUID CLSID_PortWavePci;
-const GUID CLSID_PortDMus;
+  swprintf(idstr, L"{%08X-%04X-%04X-%02X%02X-",
+	  id->Data1, id->Data2, id->Data3,
+	  id->Data4[0], id->Data4[1]);
+  s = &idstr[25];
 
-PORTCLASSAPI
+  /* 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;
+}
+
+
 NTSTATUS
 NTAPI
 PcNewPort(
@@ -15,6 +33,9 @@
     IN  REFCLSID ClassId)
 {
     NTSTATUS Status;
+    WCHAR Buffer[100];
+
+    DPRINT1("PcNewPort entered\n");
 
     if (!OutPort)
     {
@@ -33,8 +54,14 @@
     else if (IsEqualGUIDAligned(ClassId, &CLSID_PortWavePci))
         Status = NewPortWavePci(OutPort);
     else
+    {
+
+        StringFromCLSID(ClassId, Buffer);
+        DPRINT1("unknown interface %S\n", Buffer);
+
         Status = STATUS_NOT_SUPPORTED;
-
+        return Status;
+     }
     DPRINT("PcNewPort Status %lx\n", Status);
 
     return Status;

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -66,7 +66,7 @@
         {
             This->pMiniport->lpVtbl->Release(This->pMiniport);
         }
-        ExFreePoolWithTag(This, TAG_PORTCLASS);
+        FreeItem(This, TAG_PORTCLASS);
         return 0;
     }
     /* Return new reference count */

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -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 @@
     IN  REFIID refiid,
     OUT PVOID* Output)
 {
-    IPortTopologyImpl * This = (IPortTopologyImpl*)iface;
+    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 @@
 
     if (This->ref == 0)
     {
-        ExFreePoolWithTag(This, TAG_PORTCLASS);
+        FreeItem(This, TAG_PORTCLASS);
         return 0;
     }
     /* Return new reference count */
@@ -112,7 +127,7 @@
 
     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 @@
     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 @@
 
     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 @@
     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;
 }

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -20,13 +20,6 @@
 
 }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 @@
         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 @@
 {
     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;
 }
 

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -19,8 +19,7 @@
 }IPortWavePciImpl;
 
 
-const GUID IID_IPortWavePci;
-const GUID IID_IMiniportWavePci;
+
 
 //---------------------------------------------------------------
 // IServiceSink
@@ -36,7 +35,10 @@
 {
     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* iface)
 {
     IPortWavePciImpl * This = (IPortWavePciImpl*)CONTAINING_RECORD(iface, IPortWavePciImpl, lpVtblServiceSink);
-
+    DPRINT1("IServiceSink_fnAddRef entered\n");
     return InterlockedIncrement(&This->ref);
 }
 
@@ -63,12 +65,12 @@
     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* 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 @@
 {
     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 @@
     {
         return NewPortClsVersion((PPORTCLSVERSION*)Output);
     }
+
+    DPRINT1("IPortWavePci_fnQueryInterface no interface!!!\n");
+
     return STATUS_UNSUCCESSFUL;
 }
 
@@ -137,6 +145,9 @@
     IPortWavePci* iface)
 {
     IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
+
+    DPRINT1("IPortWavePci_fnAddRef entered\n");
+
     return InterlockedIncrement(&This->ref);
 }
 
@@ -148,11 +159,13 @@
 {
     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 @@
     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 @@
     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 @@
         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 @@
     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 @@
     /* increment reference on service group */
     ServiceGroup->lpVtbl->AddRef(ServiceGroup);
 
+    DPRINT("IPortWaveCyclic_Init sucessfully initialized\n");
     return STATUS_SUCCESS;
 }
 
@@ -248,6 +269,8 @@
     OUT PULONG  Disposition  OPTIONAL)
 {
     IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
+
+    DPRINT1("IPortWavePci_fnNewRegistryKey entered\n");
 
     if (!This->bInitialized)
     {
@@ -276,6 +299,8 @@
     OUT PULONG  ReturnLength)
 {
     IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
+
+    DPRINT1("IPortWavePci_fnGetDeviceProperty entered\n");
 
     if (!This->bInitialized)
     {
@@ -307,6 +332,8 @@
     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 @@
     IN  PSERVICEGROUP ServiceGroup)
 {
     IPortWavePciImpl * This = (IPortWavePciImpl*)iface;
+
+
+    DPRINT1("IPortWavePci_fnNotify entered\n");
+
     KeInsertQueueDpc(&This->Dpc, NULL, NULL);
 }
 
@@ -348,15 +379,15 @@
 {
     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;
 }

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/portcls.rbuild [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -17,6 +17,7 @@
 	<file>drm_port.c</file>
 	<file>adapter.c</file>
 	<file>filter_wavecyclic.c</file>
+	<file>guids.c</file>
 	<file>irp.c</file>
 	<file>interrupt.c</file>
 	<file>drm.c</file>
@@ -24,7 +25,8 @@
 	<file>undoc.c</file>
 	<file>resource.c</file>
 	<file>registry.c</file>
-	<file>service_group.c</file>	
+	<file>service_group.c</file>
+	<file>pool.c</file>
 	<file>port.c</file>
 	<file>power.c</file>
 	<file>port_dmus.c</file>

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/power.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/power.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/power.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/power.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -1,6 +1,6 @@
 #include "private.h"
 
-const GUID IID_IAdapterPowerManagement;
+
 
 /*
  * @implemented
@@ -17,23 +17,25 @@
     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;
 }
 

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/private.h [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -17,6 +17,7 @@
 
 #include "interfaces.h"
 #include <ks.h>
+#include <stdio.h>
 
 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
 #define TAG_PORTCLASS TAG('P', 'C', 'L', 'S')
@@ -81,6 +82,18 @@
 
 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
 {

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -9,13 +9,8 @@
 
 }IRegistryKeyImpl;
 
-const GUID IID_IRegistryKey;
-
-/*
-    Basic IUnknown methods
-*/
-
-static IRegistryKeyVtbl vt_IRegistryKeyVtbl;
+
+static IRegistryKeyVtbl vt_IRegistryKey;
 
 
 ULONG
@@ -38,14 +33,14 @@
     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 @@
     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 @@
     IN IRegistryKey* iface)
 {
     IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
+    DPRINT1("IRegistryKey_fnDeleteKey entered\n");
     return ZwDeleteKey(This->hKey);
 }
 
@@ -92,6 +88,7 @@
     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 @@
     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 @@
     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 @@
 
     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 @@
     OUT PULONG  ResultLength)
 {
     IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
+    DPRINT1("IRegistryKey_fnQueryKey entered\n");
     return ZwQueryKey(This->hKey, KeyInformationClass, KeyInformation, Length, ResultLength);
 }
 
@@ -166,7 +170,7 @@
     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 @@
     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 @@
     )
 {
     IRegistryKeyImpl * This = (IRegistryKeyImpl*)iface;
+    DPRINT1("IRegistryKey_fnSetValueKey entered\n");
     return ZwSetValueKey(This->hKey, ValueName, 0, Type, Data, DataSize);
 }
 
@@ -233,6 +239,9 @@
     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 @@
         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 @@
         return Status;
     }
 
-    This = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS);
+    This = AllocateItem(NonPagedPool, sizeof(IRegistryKeyImpl), TAG_PORTCLASS);
     if (!This)
     {
         ZwClose(hHandle);
@@ -287,6 +306,7 @@
     This->ref = 1;
 
     *OutRegistryKey = (PREGISTRYKEY)&This->lpVtbl;
+    DPRINT1("PcNewRegistryKey result %p\n", *OutRegistryKey);
     return STATUS_SUCCESS;
 }
 

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -24,7 +24,7 @@
     PCM_RESOURCE_LIST UntranslatedResourceList;
 } IResourceListImpl;
 
-const GUID IID_IResourceList;
+
 
 /*
     Basic IUnknown methods
@@ -41,7 +41,7 @@
     if (IsEqualGUIDAligned(refiid, &IID_IResourceList))
     {
         *Output = &This->lpVtbl;
-        _InterlockedIncrement(&This->ref);
+        InterlockedIncrement(&This->ref);
         return STATUS_SUCCESS;
     }
     return STATUS_UNSUCCESSFUL;
@@ -54,7 +54,7 @@
 {
     IResourceListImpl * This = (IResourceListImpl*)iface;
 
-    return _InterlockedIncrement(&This->ref);
+    return InterlockedIncrement(&This->ref);
 }
 
 ULONG
@@ -64,13 +64,15 @@
 {
     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 @@
     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 @@
     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 @@
         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 @@
 
     /* TODO: Validate parameters */
 
-    DPRINT("PcNewResourceList\n");
-
-    NewList = ExAllocatePoolWithTag(PoolType, sizeof(IResourceListImpl), TAG_PORTCLASS);
+    DPRINT1("PcNewResourceList\n");
+
+    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 @@
 {
     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 @@
         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);
-        return STATUS_INSUFFICIENT_RESOURCES;
-    }
-
-    NewList->UntranslatedResourceList = ExAllocatePoolWithTag(PoolType, sizeof(CM_RESOURCE_LIST), TAG_PORTCLASS);
+        FreeItem(NewList, TAG_PORTCLASS);
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    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 @@
 
     *OutResourceList = (IResourceList*)&NewList->lpVtbl;
 
+    DPRINT1("PcNewResourceSublist OutResourceList %p OuterUnknown %p ParentList %p\n", *OutResourceList, OuterUnknown, ParentList);
     return STATUS_SUCCESS;
 }

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/service_group.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/service_group.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/service_group.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/service_group.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -21,8 +21,7 @@
 
 }IServiceGroupImpl;
 
-const GUID IID_IServiceGroup;
-const GUID IID_IServiceSink;
+
 
 //---------------------------------------------------------------
 // IUnknown methods
@@ -75,11 +74,11 @@
             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 @@
     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 @@
         {
             RemoveEntryList(&Entry->Entry);
             pServiceSink->lpVtbl->Release(pServiceSink);
-            ExFreePoolWithTag(Entry, TAG_PORTCLASS);
+            FreeItem(Entry, TAG_PORTCLASS);
             return;
         }
         CurEntry = CurEntry->Flink;
@@ -253,14 +252,15 @@
 {
     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;

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/version.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/version.c?rev=38810&r1=38809&r2=38810&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/version.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/version.c [iso-8859-1] Sat Jan 17 05:19:27 2009
@@ -7,7 +7,7 @@
     LONG ref;
 }IPortClsVersionImpl;
 
-const GUID IID_IPortClsVersion;
+
 
 //---------------------------------------------------------------
 // IPortClsVersion interface functions
@@ -53,7 +53,7 @@
 
     if (This->ref == 0)
     {
-        ExFreePoolWithTag(This, TAG_PORTCLASS);
+        FreeItem(This, TAG_PORTCLASS);
         return 0;
     }
     /* Return new reference count */
@@ -80,7 +80,7 @@
 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;



More information about the Ros-diffs mailing list