9124081c4537c892698b2a0feff06715026c99a0
[reactos.git] / rosapps / drivers / green / green.h
1 #include <stdarg.h>
2 #include <ntddk.h>
3 #include <ndk/iotypes.h>
4 #include <windef.h>
5 #define WINBASEAPI
6 typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES;
7 #include <ntddser.h>
8 #include <kbdmou.h>
9 #include <wincon.h>
10 #include <drivers/blue/ntddblue.h>
11
12 #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE 1
13 #define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING 2
14
15 #define INFINITE -1
16 #define KEYBOARD_BUFFER_SIZE 100
17
18 typedef enum
19 {
20 GreenPDO,
21 ScreenPDO,
22 KeyboardPDO,
23 GreenFDO,
24 ScreenFDO,
25 KeyboardFDO,
26 PassThroughFDO,
27 } GREEN_DEVICE_TYPE;
28
29 typedef struct _COMMON_DEVICE_EXTENSION
30 {
31 GREEN_DEVICE_TYPE Type;
32 } COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
33
34 /* For PassThroughFDO devices */
35 typedef struct _COMMON_FDO_DEVICE_EXTENSION
36 {
37 GREEN_DEVICE_TYPE Type;
38 PDEVICE_OBJECT LowerDevice;
39 } COMMON_FDO_DEVICE_EXTENSION, *PCOMMON_FDO_DEVICE_EXTENSION;
40
41 /* For KeyboardFDO devices */
42 typedef struct _KEYBOARD_DEVICE_EXTENSION
43 {
44 COMMON_FDO_DEVICE_EXTENSION Common;
45 PDEVICE_OBJECT Green;
46
47 CONNECT_DATA ClassInformation;
48 HANDLE WorkerThreadHandle;
49 KDPC KeyboardDpc;
50
51 ULONG ActiveQueue;
52 ULONG InputDataCount[2];
53 KEYBOARD_INPUT_DATA KeyboardInputData[2][KEYBOARD_BUFFER_SIZE];
54 } KEYBOARD_DEVICE_EXTENSION, *PKEYBOARD_DEVICE_EXTENSION;
55
56 /* For ScreenFDO devices */
57 typedef struct _SCREEN_DEVICE_EXTENSION
58 {
59 COMMON_FDO_DEVICE_EXTENSION Common;
60 PDEVICE_OBJECT Green;
61
62 PUCHAR VideoMemory; /* Pointer to video memory */
63 USHORT CharAttribute; /* Current color attribute */
64 ULONG Mode;
65 UCHAR ScanLines; /* Height of a text line */
66 UCHAR Rows; /* Number of rows */
67 UCHAR Columns; /* Number of columns */
68 UCHAR TabWidth;
69
70 ULONG LogicalOffset; /* Position of the cursor */
71
72 UCHAR SendBuffer[1024];
73 ULONG SendBufferPosition;
74 PDEVICE_OBJECT PreviousBlue;
75 } SCREEN_DEVICE_EXTENSION, *PSCREEN_DEVICE_EXTENSION;
76
77 /* For GreenFDO devices */
78 typedef struct _GREEN_DEVICE_EXTENSION
79 {
80 COMMON_FDO_DEVICE_EXTENSION Common;
81 PDEVICE_OBJECT Serial;
82
83 SERIAL_LINE_CONTROL LineControl;
84 SERIAL_TIMEOUTS Timeouts;
85
86 PDEVICE_OBJECT KeyboardPdo;
87 PDEVICE_OBJECT ScreenPdo;
88 PDEVICE_OBJECT KeyboardFdo;
89 PDEVICE_OBJECT ScreenFdo;
90 } GREEN_DEVICE_EXTENSION, *PGREEN_DEVICE_EXTENSION;
91
92 typedef struct _GREEN_DRIVER_EXTENSION
93 {
94 UNICODE_STRING RegistryPath;
95
96 UNICODE_STRING AttachedDeviceName;
97 ULONG DeviceReported;
98 ULONG SampleRate;
99
100 PDEVICE_OBJECT GreenMainDO;
101 PDEVICE_OBJECT LowerDevice;
102 } GREEN_DRIVER_EXTENSION, *PGREEN_DRIVER_EXTENSION;
103
104 /************************************ createclose.c */
105
106 NTSTATUS
107 GreenCreate(
108 IN PDEVICE_OBJECT DeviceObject,
109 IN PIRP Irp);
110
111 NTSTATUS
112 GreenClose(
113 IN PDEVICE_OBJECT DeviceObject,
114 IN PIRP Irp);
115
116 /************************************ dispatch.c */
117
118 NTSTATUS NTAPI
119 GreenDispatch(
120 IN PDEVICE_OBJECT DeviceObject,
121 IN PIRP Irp);
122
123 /************************************ keyboard.c */
124
125 NTSTATUS
126 KeyboardAddDevice(
127 IN PDRIVER_OBJECT DriverObject,
128 IN PDEVICE_OBJECT Pdo);
129
130 NTSTATUS
131 KeyboardInternalDeviceControl(
132 IN PDEVICE_OBJECT DeviceObject,
133 IN PIRP Irp);
134
135 /************************************ misc.c */
136
137 NTSTATUS
138 GreenDeviceIoControl(
139 IN PDEVICE_OBJECT DeviceObject,
140 IN ULONG CtlCode,
141 IN PVOID InputBuffer OPTIONAL,
142 IN ULONG InputBufferSize,
143 IN OUT PVOID OutputBuffer OPTIONAL,
144 IN OUT PULONG OutputBufferSize);
145
146 NTSTATUS
147 ReadRegistryEntries(
148 IN PUNICODE_STRING RegistryPath,
149 IN PGREEN_DRIVER_EXTENSION DriverExtension);
150
151 /************************************ pnp.c */
152
153 NTSTATUS NTAPI
154 GreenAddDevice(
155 IN PDRIVER_OBJECT DriverObject,
156 IN PDEVICE_OBJECT Pdo);
157
158 NTSTATUS
159 GreenPnp(
160 IN PDEVICE_OBJECT DeviceObject,
161 IN PIRP Irp);
162
163 /************************************ power.c */
164
165 NTSTATUS
166 GreenPower(
167 IN PDEVICE_OBJECT DeviceObject,
168 IN PIRP Irp);
169
170 /************************************ screen.c */
171
172 NTSTATUS
173 ScreenAddDevice(
174 IN PDRIVER_OBJECT DriverObject,
175 IN PDEVICE_OBJECT Pdo);
176
177 NTSTATUS
178 ScreenWrite(
179 IN PDEVICE_OBJECT DeviceObject,
180 IN PIRP Irp);
181
182 NTSTATUS
183 ScreenDeviceControl(
184 IN PDEVICE_OBJECT DeviceObject,
185 IN PIRP Irp);
186
187 /************************************ green.c */
188
189 NTSTATUS
190 GreenDuplicateUnicodeString(
191 IN ULONG Flags,
192 IN PCUNICODE_STRING SourceString,
193 OUT PUNICODE_STRING DestinationString);