summaryrefslogtreecommitdiff
path: root/serial/VirtualSerial2/queue.h
diff options
context:
space:
mode:
authorDave Wilson <[email protected]>2015-04-29 09:48:49 -0700
committerDave Wilson <[email protected]>2015-04-29 10:47:29 -0700
commitd40232638faaab19de557e70a3ee938da7a35295 (patch)
tree14e61c973745949af186b7940e3a53d25322f5de /serial/VirtualSerial2/queue.h
parent02e5b090a6131a7cc1b90f4a9373117c9e3c7088 (diff)
samples update for //build
Diffstat (limited to 'serial/VirtualSerial2/queue.h')
-rw-r--r--serial/VirtualSerial2/queue.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/serial/VirtualSerial2/queue.h b/serial/VirtualSerial2/queue.h
new file mode 100644
index 00000000..909d699b
--- /dev/null
+++ b/serial/VirtualSerial2/queue.h
@@ -0,0 +1,113 @@
+/*++
+
+Copyright (c) Microsoft Corporation, All Rights Reserved
+
+Module Name:
+
+ queue.h
+
+Abstract:
+
+ This file defines the queue callback interface.
+
+Environment:
+
+ Windows Driver Framework
+
+--*/
+
+#pragma once
+
+#include "internal.h"
+
+// Set ring buffer size
+#define DATA_BUFFER_SIZE 1024
+
+//
+// Device states
+//
+#define COMMAND_MATCH_STATE_IDLE 0
+#define COMMAND_MATCH_STATE_GOT_A 1
+#define COMMAND_MATCH_STATE_GOT_T 2
+
+//
+// Define useful macros
+//
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+#define MAXULONG 0xffffffff
+
+typedef struct _QUEUE_CONTEXT
+{
+ UCHAR CommandMatchState;
+
+ BOOLEAN ConnectCommand;
+
+ BOOLEAN IgnoreNextChar;
+
+ BOOLEAN ConnectionStateChanged;
+
+ BOOLEAN CurrentlyConnected;
+
+ RING_BUFFER RingBuffer; // Ring buffer for pending data
+
+ BYTE Buffer[DATA_BUFFER_SIZE];
+
+ WDFQUEUE Queue; // Default parallel queue
+
+ WDFQUEUE ReadQueue; // Manual queue for pending reads
+
+ WDFQUEUE WaitMaskQueue; // Manual queue for pending ioctl wait-on-mask
+
+ PDEVICE_CONTEXT DeviceContext;
+
+} QUEUE_CONTEXT, *PQUEUE_CONTEXT;
+
+WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(QUEUE_CONTEXT, GetQueueContext);
+
+EVT_WDF_IO_QUEUE_IO_READ EvtIoRead;
+EVT_WDF_IO_QUEUE_IO_WRITE EvtIoWrite;
+EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL EvtIoDeviceControl;
+
+NTSTATUS
+QueueCreate(
+ _In_ PDEVICE_CONTEXT DeviceContext
+ );
+
+NTSTATUS
+QueueProcessWriteBytes(
+ _In_ PQUEUE_CONTEXT QueueContext,
+ _In_reads_bytes_(Length)
+ PUCHAR Characters,
+ _In_ size_t Length
+ );
+
+NTSTATUS
+QueueProcessGetLineControl(
+ _In_ PQUEUE_CONTEXT QueueContext,
+ _In_ WDFREQUEST Request
+ );
+
+NTSTATUS
+QueueProcessSetLineControl(
+ _In_ PQUEUE_CONTEXT QueueContext,
+ _In_ WDFREQUEST Request
+ );
+
+NTSTATUS
+RequestCopyFromBuffer(
+ _In_ WDFREQUEST Request,
+ _In_ PVOID SourceBuffer,
+ _In_ size_t NumBytesToCopyFrom
+ );
+
+NTSTATUS
+RequestCopyToBuffer(
+ _In_ WDFREQUEST Request,
+ _In_ PVOID DestinationBuffer,
+ _In_ size_t NumBytesToCopyTo
+ );
+