forked from microsoft/Windows-driver-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
113 lines (77 loc) · 2.23 KB
/
queue.h
File metadata and controls
113 lines (77 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*++
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
);