Author: janderwald
Date: Fri Jun 26 16:05:13 2009
New Revision: 41621
URL:
http://svn.reactos.org/svn/reactos?rev=41621&view=rev
Log:
- Rewrite PcRegisterIoTimeout, PcUnregisterIoTimeout to support more than one
PIO_TIMER_ROUTINE per device object
Modified:
trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/api.c
trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.c
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- 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] Fri Jun 26
16:05:13 2009
@@ -153,6 +153,14 @@
InitializeListHead(&portcls_ext->SubDeviceList);
/* prepare the physical connection list */
InitializeListHead(&portcls_ext->PhysicalConnectionList);
+ /* initialize timer lock */
+ KeInitializeSpinLock(&portcls_ext->TimerListLock);
+ /* initialize timer list */
+ InitializeListHead(&portcls_ext->TimerList);
+ /* initialize io timer */
+ IoInitializeTimer(PhysicalDeviceObject, PcIoTimerRoutine, NULL);
+ /* start the io timer */
+ IoStartTimer(PhysicalDeviceObject);
/* set io flags */
fdo->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE;
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/api.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/api.c [iso-8859-1] Fri Jun 26 16:05:13
2009
@@ -40,7 +40,41 @@
}
/*
- * @unimplemented
+ * @implemented
+ */
+
+VOID
+NTAPI
+PcIoTimerRoutine(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PVOID Context)
+{
+ PPCLASS_DEVICE_EXTENSION DeviceExtension;
+ KIRQL OldIrql;
+ PLIST_ENTRY ListEntry;
+ PTIMER_CONTEXT CurContext;
+
+ if (!DeviceObject || !DeviceObject->DeviceExtension)
+ return;
+
+ DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
+
+ ListEntry = DeviceExtension->TimerList.Flink;
+ while(ListEntry != &DeviceExtension->TimerList)
+ {
+ CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
+
+ CurContext->pTimerRoutine(DeviceObject, CurContext->Context);
+ ListEntry = ListEntry->Flink;
+ }
+
+ KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
+}
+
+/*
+ * @implemented
*/
NTSTATUS NTAPI
PcRegisterIoTimeout(
@@ -48,42 +82,107 @@
IN PIO_TIMER_ROUTINE pTimerRoutine,
IN PVOID pContext)
{
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PTIMER_CONTEXT TimerContext, CurContext;
+ KIRQL OldIrql;
+ PLIST_ENTRY ListEntry;
+ BOOLEAN bFound;
+ PPCLASS_DEVICE_EXTENSION DeviceExtension;
ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
- /* FIXME
- * check if timer is already used
- */
-
- Status = IoInitializeTimer(pDeviceObject, pTimerRoutine, pContext);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("IoInitializeTimer failed with %x\n", Status);
- return Status;
- }
-
- IoStartTimer(pDeviceObject);
- return STATUS_SUCCESS;
-}
-
-/*
- * @unimplemented
- */
-NTSTATUS NTAPI
+ if (!pDeviceObject || !pDeviceObject->DeviceExtension)
+ return STATUS_INVALID_PARAMETER;
+
+ DeviceExtension = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
+
+ TimerContext = AllocateItem(NonPagedPool, sizeof(TIMER_CONTEXT), TAG_PORTCLASS);
+ if (!TimerContext)
+ {
+ DPRINT1("Failed to allocate memory\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
+
+ ListEntry = DeviceExtension->TimerList.Flink;
+ bFound = FALSE;
+ while(ListEntry != &DeviceExtension->TimerList)
+ {
+ CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
+
+ if (CurContext->Context == pContext && CurContext->pTimerRoutine ==
pTimerRoutine)
+ {
+ bFound = TRUE;
+ Status = STATUS_UNSUCCESSFUL;
+ ExFreePool(TimerContext);
+ break;
+ }
+ ListEntry = ListEntry->Flink;
+ }
+
+ if (!bFound)
+ {
+ TimerContext->Context = pContext;
+ TimerContext->pTimerRoutine = pTimerRoutine;
+ InsertTailList(&DeviceExtension->TimerList, &TimerContext->Entry);
+ }
+
+ KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
+
+ return Status;
+}
+
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
PcUnregisterIoTimeout(
IN PDEVICE_OBJECT pDeviceObject,
IN PIO_TIMER_ROUTINE pTimerRoutine,
IN PVOID pContext)
{
+ PTIMER_CONTEXT CurContext;
+ KIRQL OldIrql;
+ PLIST_ENTRY ListEntry;
+ BOOLEAN bFound;
+ PPCLASS_DEVICE_EXTENSION DeviceExtension;
+
ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
- /* FIXME
- * check if timer is already used
- */
-
- IoStopTimer(pDeviceObject);
- return STATUS_SUCCESS;
+ if (!pDeviceObject || !pDeviceObject->DeviceExtension)
+ return STATUS_INVALID_PARAMETER;
+
+
+ DeviceExtension = (PPCLASS_DEVICE_EXTENSION)pDeviceObject->DeviceExtension;
+
+
+ KeAcquireSpinLock(&DeviceExtension->TimerListLock, &OldIrql);
+
+ ListEntry = DeviceExtension->TimerList.Flink;
+ bFound = FALSE;
+
+ while(ListEntry != &DeviceExtension->TimerList)
+ {
+ CurContext = (PTIMER_CONTEXT)CONTAINING_RECORD(ListEntry, TIMER_CONTEXT, Entry);
+
+ if (CurContext->Context == pContext && CurContext->pTimerRoutine ==
pTimerRoutine)
+ {
+ bFound = TRUE;
+ RemoveEntryList(&CurContext->Entry);
+ ExFreePool(CurContext);
+ break;
+ }
+ ListEntry = ListEntry->Flink;
+ }
+
+ KeReleaseSpinLock(&DeviceExtension->TimerListLock, OldIrql);
+
+ if (bFound)
+ return STATUS_SUCCESS;
+ else
+ return STATUS_NOT_FOUND;
}
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/…
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/undoc.c [iso-8859-1] Fri Jun 26
16:05:13 2009
@@ -327,27 +327,3 @@
return KsValidateConnectRequest(Irp, Factory->PinDescriptorCount,
Factory->KsPinDescriptor, Connect);
}
-
-/* PcDeleteSubdeviceDescriptor */
-
-/* PcFreeEventTable */
-
-/* PcFreePropertyTable */
-
-/* PcGenerateEventDeferredRoutine */
-
-/* PcGenerateEventList */
-
-/* PcHandleDisableEventWithTable */
-
-/* PcHandleEnableEventWithTable */
-
-/* PcHandlePropertyWithTable */
-
-/* PcPinPropertyHandler */
-
-/* PcTerminateConnection */
-
-/* PcValidateConnectRequest */
-
-/* PcVerifyFilterIsReady */