blob: 3490de06ca6c7d21843a14a0ff2289e37edfd3df [file] [log] [blame]
klu2c9fc89a2007-06-27 06:48:58 +00001/** @file
2
niruiyu66fe7142011-04-19 06:46:55 +00003Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
hhtian8f2a5f82010-04-28 12:24:39 +00004This program and the accompanying materials
klu2c9fc89a2007-06-27 06:48:58 +00005are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 WinNtGop.h
15
16Abstract:
17
18 Private data for the Gop driver that is bound to the WinNt Thunk protocol
19
20
21**/
22
23#ifndef _WIN_NT_GOP_H_
24#define _WIN_NT_GOP_H_
25
qhuang862cf1132007-10-19 02:36:33 +000026
27#include <Uefi.h>
28#include <WinNtDxe.h>
29
30#include <Guid/EventGroup.h>
31#include <Protocol/WinNtIo.h>
32#include <Protocol/ComponentName.h>
33#include <Protocol/SimpleTextIn.h>
34#include <Protocol/SimpleTextInEx.h>
35#include <Protocol/DriverBinding.h>
36#include <Protocol/GraphicsOutput.h>
37
38#include <Library/DebugLib.h>
39#include <Library/BaseLib.h>
40#include <Library/UefiDriverEntryPoint.h>
41#include <Library/UefiLib.h>
42#include <Library/BaseMemoryLib.h>
43#include <Library/UefiBootServicesTableLib.h>
44#include <Library/MemoryAllocationLib.h>
klu2c9fc89a2007-06-27 06:48:58 +000045
46//
qhuang862cf1132007-10-19 02:36:33 +000047// WM_SYSKEYDOWN/WM_SYSKEYUP Notification
48// lParam
49// bit 24: Specifies whether the key is an extended key,
50// such as the right-hand ALT and CTRL keys that appear on
51// an enhanced 101- or 102-key keyboard.
52// The value is 1 if it is an extended key; otherwise, it is 0.
53// bit 29:Specifies the context code.
54// The value is 1 if the ALT key is down while the key is pressed/released;
55// it is 0 if the WM_SYSKEYDOWN message is posted to the active window
56// because no window has the keyboard focus.
57#define GOP_EXTENDED_KEY (0x1 << 24)
58#define GOP_ALT_KEY_PRESSED (0x1 << 29)
klu2c9fc89a2007-06-27 06:48:58 +000059
niruiyu66fe7142011-04-19 06:46:55 +000060#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
klu2c9fc89a2007-06-27 06:48:58 +000061
62#define MAX_Q 256
63
64typedef struct {
niruiyu66fe7142011-04-19 06:46:55 +000065 UINTN Front;
66 UINTN Rear;
67 EFI_KEY_DATA Q[MAX_Q];
68 CRITICAL_SECTION Cs;
klu2c9fc89a2007-06-27 06:48:58 +000069} GOP_QUEUE_FIXED;
70
71#define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow"
72
qhuang899e1dd82008-12-16 15:17:02 +000073#define GOP_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('S', 'g', 'o', 'N')
klu2c9fc89a2007-06-27 06:48:58 +000074
qhuang899e1dd82008-12-16 15:17:02 +000075#define WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('W', 'g', 'S', 'n')
qhuang862cf1132007-10-19 02:36:33 +000076
77typedef struct _WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY {
78 UINTN Signature;
79 EFI_HANDLE NotifyHandle;
80 EFI_KEY_DATA KeyData;
81 EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
82 LIST_ENTRY NotifyEntry;
83} WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY;
84
klu2c9fc89a2007-06-27 06:48:58 +000085#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
86
87typedef struct {
88 UINT32 HorizontalResolution;
89 UINT32 VerticalResolution;
90 UINT32 ColorDepth;
91 UINT32 RefreshRate;
92} GOP_MODE_DATA;
93
94typedef struct {
95 UINT64 Signature;
96
97 EFI_HANDLE Handle;
98 EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
99 EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
100
101 EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
102
103 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
104
105 //
106 // GOP Private Data for QueryMode ()
107 //
108 GOP_MODE_DATA *ModeData;
109
110 //
111 // GOP Private Data knowing when to start hardware
112 //
113 BOOLEAN HardwareNeedsStarting;
114
115 CHAR16 *WindowName;
116 CHAR16 Buffer[160];
117
118 HANDLE ThreadInited; // Semaphore
119 HANDLE ThreadHandle; // Thread
120 DWORD ThreadId;
121
122 HWND WindowHandle;
123 WNDCLASSEX WindowsClass;
124
125 //
126 // This screen is used to redraw the scree when windows events happen. It's
127 // updated in the main thread and displayed in the windows thread.
128 //
129 BITMAPV4HEADER *VirtualScreenInfo;
130 RGBQUAD *VirtualScreen;
131
132 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FillLine;
133
134 //
niruiyu66fe7142011-04-19 06:46:55 +0000135 // Keyboard Queue used by Simple Text In.
136 // QueueForRead: WinProc thread adds, and main thread removes.
137 // QueueForNotify: WinProc thread adds, and timer thread removes.
klu2c9fc89a2007-06-27 06:48:58 +0000138 //
niruiyu66fe7142011-04-19 06:46:55 +0000139 GOP_QUEUE_FIXED QueueForRead;
140 GOP_QUEUE_FIXED QueueForNotify;
klu2c9fc89a2007-06-27 06:48:58 +0000141
qhuang862cf1132007-10-19 02:36:33 +0000142 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
143 EFI_KEY_STATE KeyState;
144 LIST_ENTRY NotifyList;
145 BOOLEAN LeftShift;
146 BOOLEAN RightShift;
147 BOOLEAN LeftAlt;
148 BOOLEAN RightAlt;
149 BOOLEAN LeftCtrl;
150 BOOLEAN RightCtrl;
151 BOOLEAN LeftLogo;
152 BOOLEAN RightLogo;
153 BOOLEAN Menu;
154 BOOLEAN SysReq;
155 BOOLEAN NumLock;
156 BOOLEAN ScrollLock;
niruiyu66fe7142011-04-19 06:46:55 +0000157 BOOLEAN CapsLock;
158 EFI_EVENT TimerEvent;
klu2c9fc89a2007-06-27 06:48:58 +0000159} GOP_PRIVATE_DATA;
160
161#define GOP_PRIVATE_DATA_FROM_THIS(a) \
162 CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
163
164#define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \
165 CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)
166
qhuang862cf1132007-10-19 02:36:33 +0000167#define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a) \
168 CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE)
169
klu2c9fc89a2007-06-27 06:48:58 +0000170//
171// Global Protocol Variables
172//
qhuang8e6e53c92007-09-29 11:22:46 +0000173extern EFI_DRIVER_BINDING_PROTOCOL gWinNtGopDriverBinding;
174extern EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName;
175extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtGopComponentName2;
klu2c9fc89a2007-06-27 06:48:58 +0000176
qhuang862cf1132007-10-19 02:36:33 +0000177
klu2c9fc89a2007-06-27 06:48:58 +0000178//
179// Gop Hardware abstraction internal worker functions
180//
181
182/**
183 TODO: Add function description
184
185 @param WinNtIo TODO: add argument description
186
187 @return TODO: add return values
188
189**/
190EFI_STATUS
191WinNtGopSupported (
192 IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo
vanjeffed66e1b2008-09-04 09:37:28 +0000193 );
klu2c9fc89a2007-06-27 06:48:58 +0000194
195
196/**
197 TODO: Add function description
198
199 @param Private TODO: add argument description
200
201 @return TODO: add return values
202
203**/
204EFI_STATUS
205WinNtGopConstructor (
206 IN GOP_PRIVATE_DATA *Private
vanjeffed66e1b2008-09-04 09:37:28 +0000207 );
klu2c9fc89a2007-06-27 06:48:58 +0000208
209
210/**
211 TODO: Add function description
212
213 @param Private TODO: add argument description
214
215 @return TODO: add return values
216
217**/
218EFI_STATUS
219WinNtGopDestructor (
220 IN GOP_PRIVATE_DATA *Private
vanjeffed66e1b2008-09-04 09:37:28 +0000221 );
klu2c9fc89a2007-06-27 06:48:58 +0000222
223//
qhuang88a7d75b2007-11-22 06:00:39 +0000224// UEFI 2.0 driver model prototypes for Win NT GOP
klu2c9fc89a2007-06-27 06:48:58 +0000225//
226
227
228/**
229 TODO: Add function description
230
231 @param ImageHandle TODO: add argument description
232 @param SystemTable TODO: add argument description
233
234 @return TODO: add return values
235
236**/
237EFI_STATUS
238EFIAPI
239WinNtGopInitialize (
240 IN EFI_HANDLE ImageHandle,
241 IN EFI_SYSTEM_TABLE *SystemTable
vanjeffed66e1b2008-09-04 09:37:28 +0000242 );
klu2c9fc89a2007-06-27 06:48:58 +0000243
244
245/**
246 TODO: Add function description
247
248 @param This TODO: add argument description
249 @param Handle TODO: add argument description
250 @param RemainingDevicePath TODO: add argument description
251
252 @return TODO: add return values
253
254**/
255EFI_STATUS
256EFIAPI
257WinNtGopDriverBindingSupported (
258 IN EFI_DRIVER_BINDING_PROTOCOL *This,
259 IN EFI_HANDLE Handle,
260 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
vanjeffed66e1b2008-09-04 09:37:28 +0000261 );
klu2c9fc89a2007-06-27 06:48:58 +0000262
263
264/**
265 TODO: Add function description
266
267 @param This TODO: add argument description
268 @param Handle TODO: add argument description
269 @param RemainingDevicePath TODO: add argument description
270
271 @return TODO: add return values
272
273**/
274EFI_STATUS
275EFIAPI
276WinNtGopDriverBindingStart (
277 IN EFI_DRIVER_BINDING_PROTOCOL *This,
278 IN EFI_HANDLE Handle,
279 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
vanjeffed66e1b2008-09-04 09:37:28 +0000280 );
klu2c9fc89a2007-06-27 06:48:58 +0000281
282
283/**
284 TODO: Add function description
285
286 @param This TODO: add argument description
287 @param Handle TODO: add argument description
288 @param NumberOfChildren TODO: add argument description
289 @param ChildHandleBuffer TODO: add argument description
290
291 @return TODO: add return values
292
293**/
294EFI_STATUS
295EFIAPI
296WinNtGopDriverBindingStop (
297 IN EFI_DRIVER_BINDING_PROTOCOL *This,
298 IN EFI_HANDLE Handle,
299 IN UINTN NumberOfChildren,
300 IN EFI_HANDLE *ChildHandleBuffer
vanjeffed66e1b2008-09-04 09:37:28 +0000301 );
klu2c9fc89a2007-06-27 06:48:58 +0000302
303
304/**
305 TODO: Add function description
306
307 @param Private TODO: add argument description
308 @param Key TODO: add argument description
309
310 @return TODO: add return values
311
312**/
313EFI_STATUS
niruiyu66fe7142011-04-19 06:46:55 +0000314GopPrivateAddKey (
klu2c9fc89a2007-06-27 06:48:58 +0000315 IN GOP_PRIVATE_DATA *Private,
316 IN EFI_INPUT_KEY Key
vanjeffed66e1b2008-09-04 09:37:28 +0000317 );
klu2c9fc89a2007-06-27 06:48:58 +0000318
319
320/**
321 TODO: Add function description
322
323 @param Private TODO: add argument description
324
325 @return TODO: add return values
326
327**/
328EFI_STATUS
329WinNtGopInitializeSimpleTextInForWindow (
330 IN GOP_PRIVATE_DATA *Private
vanjeffed66e1b2008-09-04 09:37:28 +0000331 );
klu2c9fc89a2007-06-27 06:48:58 +0000332
333
334/**
335 TODO: Add function description
336
337 @param Private TODO: add argument description
338
339 @return TODO: add return values
340
341**/
342EFI_STATUS
343WinNtGopDestroySimpleTextInForWindow (
344 IN GOP_PRIVATE_DATA *Private
vanjeffed66e1b2008-09-04 09:37:28 +0000345 );
klu2c9fc89a2007-06-27 06:48:58 +0000346
347
klu2c9fc89a2007-06-27 06:48:58 +0000348
349#endif