summaryrefslogtreecommitdiff
path: root/general/echo
diff options
context:
space:
mode:
Diffstat (limited to 'general/echo')
-rw-r--r--general/echo/kmdf/README.md10
-rw-r--r--general/echo/kmdf/driver/AutoSync/echo.inxbin4942 -> 4842 bytes
-rw-r--r--general/echo/kmdf/driver/AutoSync/echo.vcxproj4
-rw-r--r--general/echo/kmdf/driver/AutoSync/queue.c8
-rw-r--r--general/echo/kmdf/driver/DriverSync/device.c11
-rw-r--r--general/echo/kmdf/driver/DriverSync/echo_2.inxbin5088 -> 4998 bytes
-rw-r--r--general/echo/kmdf/driver/DriverSync/echo_2.vcxproj2
-rw-r--r--general/echo/kmdf/driver/DriverSync/queue.c33
-rw-r--r--general/echo/umdf/README.md10
-rw-r--r--general/echo/umdf/WUDFEchoDriver.vcxproj2
-rw-r--r--general/echo/umdf2/README.md9
-rw-r--r--general/echo/umdf2/driver/AutoSync/echo.vcxproj2
-rw-r--r--general/echo/umdf2/driver/AutoSync/echoum.inxbin3962 -> 3924 bytes
-rw-r--r--general/echo/umdf2/driver/AutoSync/queue.c19
-rw-r--r--general/echo/umdfSocketEcho/Driver/SocketEcho.inxbin4234 -> 4280 bytes
-rw-r--r--general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj2
-rw-r--r--general/echo/umdfSocketEcho/README.md10
17 files changed, 79 insertions, 43 deletions
diff --git a/general/echo/kmdf/README.md b/general/echo/kmdf/README.md
index 3b89850c..2ed4518a 100644
--- a/general/echo/kmdf/README.md
+++ b/general/echo/kmdf/README.md
@@ -1,3 +1,13 @@
+<!---
+ name: KMDF Echo Sample
+ platform: KMDF
+ language: cpp
+ category: General WDF
+ description: Demonstrates how to use a sequential queue to serialize read and write requests presented to the driver.
+ samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=617706
+--->
+
+
KMDF Echo Sample
================
diff --git a/general/echo/kmdf/driver/AutoSync/echo.inx b/general/echo/kmdf/driver/AutoSync/echo.inx
index d22c8806..bfb3b356 100644
--- a/general/echo/kmdf/driver/AutoSync/echo.inx
+++ b/general/echo/kmdf/driver/AutoSync/echo.inx
Binary files differ
diff --git a/general/echo/kmdf/driver/AutoSync/echo.vcxproj b/general/echo/kmdf/driver/AutoSync/echo.vcxproj
index b41d49c9..ee243a5d 100644
--- a/general/echo/kmdf/driver/AutoSync/echo.vcxproj
+++ b/general/echo/kmdf/driver/AutoSync/echo.vcxproj
@@ -146,7 +146,7 @@
<ClCompile Include="queue.c" />
</ItemGroup>
<ItemGroup>
- <Inf Exclude="@(Inf)" Include="*.inf" />
+ <Inf Exclude="@(Inf)" Include="*.inx" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
</ItemGroup>
<ItemGroup>
@@ -158,4 +158,4 @@
<ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-</Project> \ No newline at end of file
+</Project>
diff --git a/general/echo/kmdf/driver/AutoSync/queue.c b/general/echo/kmdf/driver/AutoSync/queue.c
index b821add2..d881c003 100644
--- a/general/echo/kmdf/driver/AutoSync/queue.c
+++ b/general/echo/kmdf/driver/AutoSync/queue.c
@@ -86,7 +86,7 @@ Return Value:
// with the same lock.
//
queueAttributes.SynchronizationScope = WdfSynchronizationScopeQueue;
-
+
queueAttributes.EvtDestroyCallback = EchoEvtIoQueueContextDestroy;
status = WdfIoQueueCreate(
@@ -155,12 +155,12 @@ Return Value:
PAGED_CODE();
//
- // Create a WDFTIMER object
+ // Create a periodic timer.
+ //
+ // WDF_TIMER_CONFIG_INIT_PERIODIC sets AutomaticSerialization to TRUE by default.
//
WDF_TIMER_CONFIG_INIT_PERIODIC(&timerConfig, EchoEvtTimerFunc, Period);
- timerConfig.AutomaticSerialization = FALSE;
-
WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes);
timerAttributes.ParentObject = Queue; // Synchronize with the I/O Queue
diff --git a/general/echo/kmdf/driver/DriverSync/device.c b/general/echo/kmdf/driver/DriverSync/device.c
index c9dbcbb4..23f684e9 100644
--- a/general/echo/kmdf/driver/DriverSync/device.c
+++ b/general/echo/kmdf/driver/DriverSync/device.c
@@ -77,17 +77,6 @@ Return Value:
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);
- //
- // By not setting the synchronization scope and using the default, there is
- // no locking between any of the callbacks in this driver.
- //
- // We will create a sequential queue so all of the EvtIoXxx callbacks are
- // serialized against each other (at least until the request is completed),
- // but the cancel routine and the timer DPC are not synchronized against the
- // queue's EvtIoXxx callbacks.
- //
- // attributes.SynchronizationScope = ...
-
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if (NT_SUCCESS(status)) {
diff --git a/general/echo/kmdf/driver/DriverSync/echo_2.inx b/general/echo/kmdf/driver/DriverSync/echo_2.inx
index 235d12c0..ea524f85 100644
--- a/general/echo/kmdf/driver/DriverSync/echo_2.inx
+++ b/general/echo/kmdf/driver/DriverSync/echo_2.inx
Binary files differ
diff --git a/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj b/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj
index 95957fec..4a77818d 100644
--- a/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj
+++ b/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj
@@ -158,7 +158,7 @@
<ClCompile Include="queue.c" />
</ItemGroup>
<ItemGroup>
- <Inf Exclude="@(Inf)" Include="*.inf" />
+ <Inf Exclude="@(Inf)" Include="*.inx" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
</ItemGroup>
<ItemGroup>
diff --git a/general/echo/kmdf/driver/DriverSync/queue.c b/general/echo/kmdf/driver/DriverSync/queue.c
index 78c199d2..7835b73b 100644
--- a/general/echo/kmdf/driver/DriverSync/queue.c
+++ b/general/echo/kmdf/driver/DriverSync/queue.c
@@ -158,6 +158,18 @@ Return Value:
// Fill in a callback for destroy, and our QUEUE_CONTEXT size
//
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, QUEUE_CONTEXT);
+
+ //
+ // By not setting the synchronization scope and using the default, there is
+ // no locking between any of the callbacks in this driver.
+ //
+ // We will create a sequential queue so all of the EvtIoXxx callbacks are
+ // serialized against each other (at least until the request is completed),
+ // but the cancel routine and the timer DPC are not synchronized against the
+ // queue's EvtIoXxx callbacks.
+ //
+ // attributes.SynchronizationScope = ...
+
attributes.EvtDestroyCallback = EchoEvtIoQueueContextDestroy;
status = WdfIoQueueCreate(
@@ -192,7 +204,7 @@ Return Value:
KdPrint(("WdfSpinLockCreate failed 0x%x\n",status));
return status;
}
-
+
//
// Create the Queue timer
//
@@ -234,16 +246,15 @@ Return Value:
PAGED_CODE();
//
- // Create a WDFTIMER object
+ // Create a periodic timer.
+ //
+ // By not setting the synchronization scope and using the default at WdfIoQueueCreate,
+ // we are explicitly *not* serializing against the queue's lock. Instead, we will do
+ // that on our own.
//
WDF_TIMER_CONFIG_INIT_PERIODIC(&timerConfig, EchoEvtTimerFunc, Period);
WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes);
-
- //
- // We are explicitly *not* serializing against the queue's lock, we will do
- // that on our own.
- //
timerAttributes.ParentObject = Queue;
Status = WdfTimerCreate(
@@ -456,9 +467,9 @@ EchoSetCurrentRequest(
queueContext->CurrentStatus = STATUS_SUCCESS;
//
- // Set the cancel routine under the lock, otherwise if we set it outside
- // of the lock, the timer could run and attempt to mark the request
- // uncancelable before we can mark it cancelable on this thread. Use
+ // Set the cancel routine under the lock, otherwise if we set it outside
+ // of the lock, the timer could run and attempt to mark the request
+ // uncancelable before we can mark it cancelable on this thread. Use
// WdfRequestMarkCancelableEx here to prevent to deadlock with ourselves
// (cancel routine tries to acquire the queue object lock).
//
@@ -746,7 +757,7 @@ Return Value:
//
}
}
-
+
WdfSpinLockRelease(queueContext->SpinLock);
//
diff --git a/general/echo/umdf/README.md b/general/echo/umdf/README.md
index e2123cd3..af4818d4 100644
--- a/general/echo/umdf/README.md
+++ b/general/echo/umdf/README.md
@@ -1,3 +1,13 @@
+<!---
+ name: Echo Sample (UMDF Version 1)
+ platform: UMDF1
+ language: cpp
+ category: General WDF
+ description: Demonstrates how to use UMDF version 1 to write a driver and demonstrates best practices.
+ samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=617707
+--->
+
+
Echo Sample (UMDF Version 1)
============================
diff --git a/general/echo/umdf/WUDFEchoDriver.vcxproj b/general/echo/umdf/WUDFEchoDriver.vcxproj
index c9a5a638..b00330bf 100644
--- a/general/echo/umdf/WUDFEchoDriver.vcxproj
+++ b/general/echo/umdf/WUDFEchoDriver.vcxproj
@@ -235,7 +235,7 @@
<ResourceCompile Include="Echo.rc" />
</ItemGroup>
<ItemGroup>
- <Inf Exclude="@(Inf)" Include="*.inf" />
+ <Inf Exclude="@(Inf)" Include="*.inx" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
</ItemGroup>
<ItemGroup>
diff --git a/general/echo/umdf2/README.md b/general/echo/umdf2/README.md
index ba3ffa36..a9ec9e76 100644
--- a/general/echo/umdf2/README.md
+++ b/general/echo/umdf2/README.md
@@ -1,3 +1,12 @@
+<!---
+ name: Echo Sample (UMDF Version 2)
+ platform: UMDF2
+ language: cpp
+ category: General WDF
+ description: Demonstrates how to use UMDF 2 to write a driver and to employ best practices.
+ samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=617708
+--->
+
Echo Sample (UMDF Version 2)
============================
diff --git a/general/echo/umdf2/driver/AutoSync/echo.vcxproj b/general/echo/umdf2/driver/AutoSync/echo.vcxproj
index e3a2e18d..17763154 100644
--- a/general/echo/umdf2/driver/AutoSync/echo.vcxproj
+++ b/general/echo/umdf2/driver/AutoSync/echo.vcxproj
@@ -158,7 +158,7 @@
<ClCompile Include="queue.c" />
</ItemGroup>
<ItemGroup>
- <Inf Exclude="@(Inf)" Include="*.inf" />
+ <Inf Exclude="@(Inf)" Include="*.inx" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
</ItemGroup>
<ItemGroup>
diff --git a/general/echo/umdf2/driver/AutoSync/echoum.inx b/general/echo/umdf2/driver/AutoSync/echoum.inx
index 4e3cd6b3..cae8b45f 100644
--- a/general/echo/umdf2/driver/AutoSync/echoum.inx
+++ b/general/echo/umdf2/driver/AutoSync/echoum.inx
Binary files differ
diff --git a/general/echo/umdf2/driver/AutoSync/queue.c b/general/echo/umdf2/driver/AutoSync/queue.c
index 3162a683..98860df6 100644
--- a/general/echo/umdf2/driver/AutoSync/queue.c
+++ b/general/echo/umdf2/driver/AutoSync/queue.c
@@ -79,7 +79,7 @@ Return Value:
// with the same lock.
//
queueAttributes.SynchronizationScope = WdfSynchronizationScopeQueue;
-
+
queueAttributes.EvtDestroyCallback = EchoEvtIoQueueContextDestroy;
status = WdfIoQueueCreate(
@@ -145,21 +145,18 @@ Return Value:
WDF_OBJECT_ATTRIBUTES timerAttributes;
//
- // Create a WDFTIMER object
+ // Create a non-periodic timer since WDF does not allow periodic timer
+ // at passive level, which is the level UMDF callbacks are invoked at.
+ // The workaround is to always restart the timer in the timer callback.
+ //
+ // WDF_TIMER_CONFIG_INIT sets AutomaticSerialization to TRUE by default.
//
WDF_TIMER_CONFIG_INIT(&timerConfig, EchoEvtTimerFunc);
- //
- // WDF_OBJECT_ATTRIBUTES_INIT sets AutomaticSerialization to TRUE by default
- //
WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes);
timerAttributes.ParentObject = Queue; // Synchronize with the I/O Queue
- timerAttributes.ExecutionLevel = WdfExecutionLevelPassive;
+ timerAttributes.ExecutionLevel = WdfExecutionLevelPassive;
- //
- // Create a non-periodic timer since WDF does not allow periodic timer
- // with autosynchronization at passive level
- //
Status = WdfTimerCreate(&timerConfig,
&timerAttributes,
Timer // Output handle
@@ -530,7 +527,7 @@ Return Value:
}
//
- // Restart the Timer since WDF does not allow periodic timer
+ // Restart the Timer since WDF does not allow periodic timer
// with autosynchronization at passive level
//
WdfTimerStart(Timer, WDF_REL_TIMEOUT_IN_MS(TIMER_PERIOD));
diff --git a/general/echo/umdfSocketEcho/Driver/SocketEcho.inx b/general/echo/umdfSocketEcho/Driver/SocketEcho.inx
index b80dee9a..b660186b 100644
--- a/general/echo/umdfSocketEcho/Driver/SocketEcho.inx
+++ b/general/echo/umdfSocketEcho/Driver/SocketEcho.inx
Binary files differ
diff --git a/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj b/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj
index 750422be..14a05def 100644
--- a/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj
+++ b/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj
@@ -224,7 +224,7 @@
<ResourceCompile Include="SocketEcho.rc" />
</ItemGroup>
<ItemGroup>
- <Inf Exclude="@(Inf)" Include="*.inf" />
+ <Inf Exclude="@(Inf)" Include="*.inx" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
</ItemGroup>
<ItemGroup>
diff --git a/general/echo/umdfSocketEcho/README.md b/general/echo/umdfSocketEcho/README.md
index 06819a47..26cd5a7e 100644
--- a/general/echo/umdfSocketEcho/README.md
+++ b/general/echo/umdfSocketEcho/README.md
@@ -1,3 +1,13 @@
+<!---
+ name: UMDF SocketEcho Sample (UMDF Version 1)
+ platform: UMDF1
+ language: cpp
+ category: General WDF
+ description: Demonstrates how to use UMDF version 1 to write a driver and demonstrates best practices.
+ samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=617709
+--->
+
+
UMDF SocketEcho Sample (UMDF Version 1)
=======================================