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
|
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
simsensor.h
Abstract:
This is the header file for the simulated sensor driver.
@@BEGIN_DDKSPLIT
Author:
Nicholas Brekhus (NiBrekhu) 25-Jul-2011
Revision History:
@@END_DDKSPLIT
--*/
//--------------------------------------------------------------------- Pragmas
#pragma once
//-------------------------------------------------------------------- Includes
#include <ntddk.h>
#include <wdf.h>
#include <ntstrsafe.h>
#include <initguid.h>
#include <wdmguid.h>
#include <poclass.h>
//----------------------------------------------------------------------- Debug
#if DBG
extern ULONG SimSensorDebug;
#define DebugPrint(l, m, ...) \
if(l & SimSensorDebug) DbgPrint(m, __VA_ARGS__)
#define DebugEnter() \
DebugPrint(SIMSENSOR_TRACE, "Entering " __FUNCTION__ "\n")
#define DebugExit() \
DebugPrint(SIMSENSOR_TRACE, "Leaving " __FUNCTION__ "\n")
#define DebugExitStatus(_status_) \
DebugPrint(SIMSENSOR_TRACE, "Leaving " __FUNCTION__ ": Status=0x%x\n", _status_)
#else
#define DebugPrint(l, m, ...)
#define DebugEnter()
#define DebugExit()
#define DebugExitStatus(_status_)
#endif
#define SIMSENSOR_NOTE 0x00000001
#define SIMSENSOR_WARN 0x00000002
#define SIMSENSOR_ERROR_ONLY 0x00000004
#define SIMSENSOR_ERROR (SIMSENSOR_ERROR_ONLY | SIMSENSOR_WARN)
#define SIMSENSOR_TRACE 0x00000008
#define SIMSENSOR_DEBUG 0x80000000
#define SIMSENSOR_PRINT_ALWAYS 0xffffffff
#define SIMSENSOR_PRINT_NEVER 0x0
//----------------------------------------------------------------- Definitions
typedef struct {
WDFQUEUE PendingRequestQueue;
WDFWAITLOCK QueueLock;
WDFWORKITEM InterruptWorker;
//
// Virtual temperature sensor internal state. This portion of the context
// should be opaque to most of the driver, except the portion implementing
// the virtual sensor hardware.
//
struct {
PVOID PolicyHandle;
BOOLEAN Enabled;
ULONG LowerBound;
ULONG UpperBound;
ULONG Temperature;
WDFWAITLOCK Lock;
} Sensor;
} FDO_DATA, *PFDO_DATA;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FDO_DATA, GetDeviceExtension);
typedef struct {
LARGE_INTEGER ExpirationTime;
ULONG HighTemperature;
ULONG LowTemperature;
} READ_REQUEST_CONTEXT, *PREAD_REQUEST_CONTEXT;
WDF_DECLARE_CONTEXT_TYPE(READ_REQUEST_CONTEXT);
|