21DWORD mTlsIndex = TLS_OUT_OF_INDEXES;
22DWORD mTlsIndexUseCount = 0;
25WinNtGopConvertParamToEfiKeyShiftState (
40 if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
41 Private->RightShift = Flag;
43 Private->LeftShift = Flag;
49 Private->LeftShift = Flag;
53 Private->RightShift = Flag;
57 if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
58 Private->RightCtrl = Flag;
60 Private->LeftCtrl = Flag;
66 Private->LeftCtrl = Flag;
70 Private->RightCtrl = Flag;
74 Private->LeftLogo = Flag;
78 Private->RightLogo = Flag;
89 Private->SysReq = Flag;
95 if ((*lParam & GOP_EXTENDED_KEY) == GOP_EXTENDED_KEY) {
96 Private->RightAlt = Flag;
98 Private->LeftAlt = Flag;
109WinNtGopConvertParamToEfiKey (
120 case VK_HOME: Key->ScanCode = SCAN_HOME;
123 case VK_END: Key->ScanCode = SCAN_END;
126 case VK_LEFT: Key->ScanCode = SCAN_LEFT;
129 case VK_RIGHT: Key->ScanCode = SCAN_RIGHT;
132 case VK_UP: Key->ScanCode = SCAN_UP;
135 case VK_DOWN: Key->ScanCode = SCAN_DOWN;
138 case VK_DELETE: Key->ScanCode = SCAN_DELETE;
141 case VK_INSERT: Key->ScanCode = SCAN_INSERT;
144 case VK_PRIOR: Key->ScanCode = SCAN_PAGE_UP;
147 case VK_NEXT: Key->ScanCode = SCAN_PAGE_DOWN;
150 case VK_ESCAPE: Key->ScanCode = SCAN_ESC;
154 case VK_F1: Key->ScanCode = SCAN_F1;
157 case VK_F2: Key->ScanCode = SCAN_F2;
160 case VK_F3: Key->ScanCode = SCAN_F3;
163 case VK_F4: Key->ScanCode = SCAN_F4;
166 case VK_F5: Key->ScanCode = SCAN_F5;
169 case VK_F6: Key->ScanCode = SCAN_F6;
172 case VK_F7: Key->ScanCode = SCAN_F7;
175 case VK_F8: Key->ScanCode = SCAN_F8;
178 case VK_F9: Key->ScanCode = SCAN_F9;
181 case VK_F11: Key->ScanCode = SCAN_F11;
184 case VK_F12: Key->ScanCode = SCAN_F12;
188 case VK_F13: Key->ScanCode = SCAN_F13;
191 case VK_F14: Key->ScanCode = SCAN_F14;
194 case VK_F15: Key->ScanCode = SCAN_F15;
197 case VK_F16: Key->ScanCode = SCAN_F16;
200 case VK_F17: Key->ScanCode = SCAN_F17;
203 case VK_F18: Key->ScanCode = SCAN_F18;
206 case VK_F19: Key->ScanCode = SCAN_F19;
209 case VK_F20: Key->ScanCode = SCAN_F20;
212 case VK_F21: Key->ScanCode = SCAN_F21;
215 case VK_F22: Key->ScanCode = SCAN_F22;
218 case VK_F23: Key->ScanCode = SCAN_F23;
221 case VK_F24: Key->ScanCode = SCAN_F24;
224 case VK_PAUSE: Key->ScanCode = SCAN_PAUSE;
232 Private->NumLock = (BOOLEAN)(!Private->NumLock);
236 Private->ScrollLock = (BOOLEAN)(!Private->ScrollLock);
240 Private->CapsLock = (BOOLEAN)(!Private->CapsLock);
245 return (WinNtGopConvertParamToEfiKeyShiftState (Private, wParam, lParam,
TRUE)) ==
TRUE ?
TRUE : Flag;
263 RETURN_STATUS RStatus;
267 BITMAPV4HEADER *VirtualScreenInfo;
269 UINTN FrameBufferConfigureSize;
271 Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
277 VirtualScreenInfo = HeapAlloc (
280 Width * Height *
sizeof (RGBQUAD) +
sizeof (BITMAPV4HEADER)
282 if (VirtualScreenInfo ==
NULL) {
283 return EFI_OUT_OF_RESOURCES;
290 VirtualScreenInfo->bV4Size =
sizeof (BITMAPV4HEADER);
291 VirtualScreenInfo->bV4Width = Width;
292 VirtualScreenInfo->bV4Height = -(LONG)Height;
293 VirtualScreenInfo->bV4Planes = 1;
294 VirtualScreenInfo->bV4BitCount = 32;
298 VirtualScreenInfo->bV4V4Compression = BI_RGB;
304 FrameBufferConfigureSize = 0;
306 ASSERT (RStatus == EFI_BUFFER_TOO_SMALL);
307 FrameBufferConfigure =
AllocatePool (FrameBufferConfigureSize);
308 if (FrameBufferConfigure ==
NULL) {
309 HeapFree (GetProcessHeap (), 0, VirtualScreenInfo);
310 return EFI_OUT_OF_RESOURCES;
313 RStatus =
FrameBufferBltConfigure (VirtualScreenInfo + 1, &Info, FrameBufferConfigure, &FrameBufferConfigureSize);
316 if (Private->FrameBufferConfigure !=
NULL) {
317 FreePool (Private->FrameBufferConfigure);
320 Private->FrameBufferConfigure = FrameBufferConfigure;
327 if (Private->VirtualScreenInfo !=
NULL) {
328 HeapFree (GetProcessHeap (), 0, Private->VirtualScreenInfo);
331 Private->VirtualScreenInfo = VirtualScreenInfo;
333 Private->Width = Width;
334 Private->Height = Height;
343 Rect.bottom = Height;
345 AdjustWindowRect (&Rect, WS_OVERLAPPEDWINDOW, 0);
347 Width = Rect.right - Rect.left;
348 Height = Rect.bottom - Rect.top;
353 GetWindowRect (Private->WindowHandle, &Rect);
358 MoveWindow (Private->WindowHandle, Rect.left, Rect.top, (INT32)Width, (INT32)Height,
TRUE);
405 RETURN_STATUS RStatus;
409 Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
411 Private->FrameBufferConfigure,
430 Rect.left = (LONG)Args->DestinationX;
431 Rect.top = (LONG)Args->DestinationY;
432 Rect.right = (LONG)(Args->DestinationX + Args->Width);
433 Rect.bottom = (LONG)(Args->DestinationY + Args->Height);
434 InvalidateRect (Private->WindowHandle, &Rect,
FALSE);
445 UpdateWindow (Private->WindowHandle);
474 PAINTSTRUCT PaintStruct;
487 Private = TlsGetValue (mTlsIndex);
488 ASSERT (
NULL != Private);
492 Handle = BeginPaint (hwnd, &PaintStruct);
504 Private->VirtualScreenInfo + 1,
505 (BITMAPINFO *)Private->VirtualScreenInfo,
509 EndPaint (hwnd, &PaintStruct);
520 Key.UnicodeChar = CHAR_NULL;
523 Key.ScanCode = SCAN_F10;
524 Key.UnicodeChar = CHAR_NULL;
532 if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) {
533 if (Key.ScanCode != 0) {
538 Private->LeftAlt =
TRUE;
546 Private->RightAlt =
FALSE;
547 Private->LeftAlt =
FALSE;
557 if (wParam == 0x1B) {
561 if (AltIsPress ==
TRUE) {
565 Private->LeftAlt =
TRUE;
568 for (Index = 0; Index < (lParam & 0xffff); Index++) {
570 Key.UnicodeChar = (CHAR16)wParam;
571 Key.ScanCode = SCAN_NULL;
576 if (AltIsPress ==
TRUE) {
581 Private->LeftAlt =
FALSE;
582 Private->RightAlt =
FALSE;
591 WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam,
FALSE);
595 Key.ScanCode = SCAN_NULL;
596 Key.UnicodeChar = CHAR_NULL;
601 if (WinNtGopConvertParamToEfiKey (Private, &wParam, &lParam, &Key)) {
611 WinNtGopConvertParamToEfiKeyShiftState (Private, &wParam, &lParam,
FALSE);
615 PosX = GET_X_LPARAM (lParam);
616 PosY = GET_Y_LPARAM (lParam);
618 if (Private->PointerPreviousX != PosX) {
620 Private->PointerPreviousX = PosX;
621 Private->PointerStateChanged =
TRUE;
624 if (Private->PointerPreviousY != PosY) {
626 Private->PointerPreviousY = PosY;
627 Private->PointerStateChanged =
TRUE;
635 Private->PointerStateChanged =
TRUE;
640 Private->PointerStateChanged =
TRUE;
645 Private->PointerStateChanged =
TRUE;
650 Private->PointerStateChanged =
TRUE;
658 ShowWindow (Private->WindowHandle, SW_HIDE);
662 DestroyWindow (hwnd);
665 HeapFree (GetProcessHeap (), 0, Private->VirtualScreenInfo);
673 return DefWindowProc (hwnd, iMsg, wParam, lParam);
699 ASSERT (
NULL != Private);
706 TlsSetValue (mTlsIndex, Private);
708 Private->ThreadId = GetCurrentThreadId ();
710 Private->WindowsClass.cbSize =
sizeof (WNDCLASSEX);
711 Private->WindowsClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
713 Private->WindowsClass.cbClsExtra = 0;
714 Private->WindowsClass.cbWndExtra = 0;
715 Private->WindowsClass.hInstance =
NULL;
716 Private->WindowsClass.hIcon = LoadIcon (
NULL, IDI_APPLICATION);
717 Private->WindowsClass.hCursor = LoadCursor (
NULL, IDC_ARROW);
718 Private->WindowsClass.hbrBackground = (HBRUSH)(
UINTN)COLOR_WINDOW;
719 Private->WindowsClass.lpszMenuName =
NULL;
720 Private->WindowsClass.lpszClassName = WIN_NT_GOP_CLASS_NAME;
721 Private->WindowsClass.hIconSm = LoadIcon (
NULL, IDI_APPLICATION);
726 Private->Width = 100;
727 Private->Height = 100;
733 RegisterClassEx (&Private->WindowsClass);
740 Rect.bottom = Private->Height;
742 Rect.right = Private->Width;
744 AdjustWindowRect (&Rect, WS_OVERLAPPEDWINDOW, 0);
746 Private->WindowHandle = CreateWindowEx (
748 WIN_NT_GOP_CLASS_NAME,
753 Rect.right - Rect.left,
754 Rect.bottom - Rect.top,
767 ShowWindow (Private->WindowHandle, SW_SHOW);
768 UpdateWindow (Private->WindowHandle);
773 ReleaseSemaphore (Private->ThreadInited, 1,
NULL);
778 while (GetMessage (&Message, Private->WindowHandle, 0, 0)) {
779 TranslateMessage (&Message);
780 DispatchMessage (&Message);
783 return (DWORD)Message.wParam;
811 Private->Signature = GRAPHICS_PRIVATE_DATA_SIGNATURE;
813 Private->GraphicsWindowIo.CheckKey = WinNtWndCheckKey;
814 Private->GraphicsWindowIo.GetKey = WinNtWndGetKey;
815 Private->GraphicsWindowIo.KeySetState = WinNtWndKeySetState;
816 Private->GraphicsWindowIo.RegisterKeyNotify = WinNtWndRegisterKeyNotify;
818 Private->GraphicsWindowIo.CheckPointer = WinNtWndCheckPointer;
819 Private->GraphicsWindowIo.GetPointerState = WinNtWndGetPointerState;
821 Private->WindowName = This->ConfigString;
826 if (mTlsIndex == TLS_OUT_OF_INDEXES) {
827 ASSERT (0 == mTlsIndexUseCount);
828 mTlsIndex = TlsAlloc ();
836 Private->ThreadInited = CreateSemaphore (
NULL, 0, 1,
NULL);
837 Private->ThreadHandle = CreateThread (
850 WaitForSingleObject (Private->ThreadInited, INFINITE);
851 CloseHandle (Private->ThreadInited);
853 This->Private = Private;
854 This->Interface = &Private->GraphicsWindowIo;
861WinNtGraphicsWindowClose (
872 SendMessage (Private->WindowHandle, WM_DESTROY, 0, 0);
873 CloseHandle (Private->ThreadHandle);
881 if (0 == mTlsIndexUseCount) {
882 ASSERT (TLS_OUT_OF_INDEXES != mTlsIndex);
885 mTlsIndex = TLS_OUT_OF_INDEXES;
888 Private->WindowsClass.lpszClassName,
889 Private->WindowsClass.hInstance
898 &gEmuGraphicsWindowProtocolGuid,
903 WinNtGraphicsWindowClose,
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
RETURN_STATUS EFIAPI FrameBufferBlt(IN FRAME_BUFFER_CONFIGURE *Configure, IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta)
RETURN_STATUS EFIAPI FrameBufferBltConfigure(IN VOID *FrameBuffer, IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, IN OUT FRAME_BUFFER_CONFIGURE *Configure, IN OUT UINTN *ConfigureSize)
#define RETURN_ERROR(StatusCode)
#define ASSERT_RETURN_ERROR(StatusParameter)
@ PixelBlueGreenRedReserved8BitPerColor
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI TlsFree(IN VOID *Tls)
EFI_STATUS GopPrivateDestroyQ(IN GRAPHICS_PRIVATE_DATA *Private, IN GOP_QUEUE_FIXED *Queue)
EFI_STATUS GopPrivateCreateQ(IN GRAPHICS_PRIVATE_DATA *Private, IN GOP_QUEUE_FIXED *Queue)
EFI_STATUS GopPrivateAddKey(IN GRAPHICS_PRIVATE_DATA *Private, IN EFI_INPUT_KEY Key)
EFI_STATUS EFIAPI WinNtWndSize(IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN UINT32 Width, IN UINT32 Height)
DWORD WINAPI WinNtGopThreadWinMain(LPVOID lpParameter)
EFI_STATUS EFIAPI WinNtGraphicsWindowOpen(IN EMU_IO_THUNK_PROTOCOL *This)
LRESULT CALLBACK WinNtGopThreadWindowProc(IN HWND hwnd, IN UINT iMsg, IN WPARAM wParam, IN LPARAM lParam)
EFI_STATUS WinNtWndBlt(IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, IN EFI_UGA_BLT_OPERATION BltOperation, IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args)
UINT32 VerticalResolution
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat
UINT32 HorizontalResolution