summaryrefslogtreecommitdiff
path: root/general/echo/kmdf
diff options
context:
space:
mode:
authorLuke <[email protected]>2017-11-28 00:22:11 -0800
committerGitHub <[email protected]>2017-11-28 00:22:11 -0800
commit79bbbca2f6e37d94fbbbd60d12c5c1e7dde650da (patch)
tree793ff943b8b641f95d05401156badd42da4a0f12 /general/echo/kmdf
parented1df9a8b80b154b71b79635e40af75f4f19001c (diff)
parent2817004092cee784d4aaf36c045fdb5b0bc09f7e (diff)
Merge pull request #1 from Microsoft/master
Updating Local
Diffstat (limited to 'general/echo/kmdf')
-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
8 files changed, 39 insertions, 29 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);
//