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