-
Notifications
You must be signed in to change notification settings - Fork 2
/
device.h
143 lines (104 loc) · 3.01 KB
/
device.h
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
device.h
Abstract:
This module contains the function definitions for the
WDF device.
Environment:
kernel-mode only
Revision History:
--*/
#ifndef _DEVICE_H_
#define _DEVICE_H_
//
// WDF event callbacks.
//
EVT_WDF_DEVICE_PREPARE_HARDWARE OnPrepareHardware;
EVT_WDF_DEVICE_RELEASE_HARDWARE OnReleaseHardware;
EVT_WDF_DEVICE_D0_ENTRY OnD0Entry;
EVT_WDF_DEVICE_D0_EXIT OnD0Exit;
EVT_WDF_INTERRUPT_ISR OnInterruptIsr;
EVT_WDF_INTERRUPT_DPC OnInterruptDpc;
EVT_WDF_REQUEST_CANCEL OnCancel;
//
// SPBCx event callbacks.
//
EVT_SPB_TARGET_CONNECT OnTargetConnect;
EVT_SPB_TARGET_DISCONNECT OnTargetDisconnect;
EVT_SPB_CONTROLLER_LOCK OnControllerLock;
EVT_SPB_CONTROLLER_UNLOCK OnControllerUnlock;
EVT_SPB_CONTROLLER_READ OnRead;
EVT_SPB_CONTROLLER_WRITE OnWrite;
EVT_SPB_CONTROLLER_SEQUENCE OnSequence;
EVT_WDF_IO_IN_CALLER_CONTEXT OnOtherInCallerContext;
EVT_SPB_CONTROLLER_OTHER OnOther;
//
// PBC function prototypes.
//
NTSTATUS
PbcTargetGetSettings(
_In_ PPBC_DEVICE pDevice,
_In_ PVOID ConnectionParameters,
_Out_ PPBC_TARGET_SETTINGS pSettings);
#if 0
NTSTATUS
FORCEINLINE
PbcRequestSetByte(
_In_ PPBC_REQUEST pRequest,
_In_ size_t Index,
_In_ UCHAR Byte
)
/*++
Routine Description:
This is a helper routine used to set the
specified byte of the current transfer descriptor buffer.
Arguments:
pRequest - a pointer to the PBC request context
Index - index of desired byte in current transfer descriptor buffer
Byte - the byte
Return Value:
STATUS_INFO_LENGTH_MISMATCH if invalid index,
otherwise STATUS_SUCCESS
--*/
{
PMDL mdl = pRequest->pMdlChain;
size_t mdlByteCount;
size_t currentOffset = Index;
PUCHAR pBuffer;
NTSTATUS status = STATUS_INFO_LENGTH_MISMATCH;
//
// Check for out-of-bounds index
//
if (Index < pRequest->Length)
{
while (mdl != NULL)
{
mdlByteCount = MmGetMdlByteCount(mdl);
if (currentOffset < mdlByteCount)
{
pBuffer = (PUCHAR) MmGetSystemAddressForMdlSafe(
mdl,
NormalPagePriority | MdlMappingNoExecute);
if (pBuffer != NULL)
{
//
// Byte found, mark successful
//
pBuffer[currentOffset] = Byte;
status = STATUS_SUCCESS;
}
break;
}
currentOffset -= mdlByteCount;
mdl = mdl->Next;
}
//
// If after walking the MDL the byte hasn't been found,
// status will still be STATUS_INFO_LENGTH_MISMATCH
//
}
return status;
}
#endif
#endif