3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This file produces the graphics abstration of UGA. It is called by
19 WinNtUgaDriver.c file which deals with the EFI 1.1 driver model.
20 This file just does graphics.
26 EFI_WIN_NT_THUNK_PROTOCOL
*mWinNt
;
27 DWORD mTlsIndex
= TLS_OUT_OF_INDEXES
;
28 DWORD mTlsIndexUseCount
= 0; // lets us know when we can free mTlsIndex.
29 static EFI_EVENT mUgaScreenExitBootServicesEvent
;
33 IN UGA_PRIVATE_DATA
*Private
,
34 IN UINT32 HorizontalResolution
,
35 IN UINT32 VerticalResolution
,
49 // UGA Protocol Member Functions
55 EFI_UGA_DRAW_PROTOCOL
*This
,
56 UINT32
*HorizontalResolution
,
57 UINT32
*VerticalResolution
,
64 Return the current video mode information.
67 This - Protocol instance pointer.
68 HorizontalResolution - Current video horizontal resolution in pixels
69 VerticalResolution - Current video Vertical resolution in pixels
70 ColorDepth - Current video color depth in bits per pixel
71 RefreshRate - Current video refresh rate in Hz.
74 EFI_SUCCESS - Mode information returned.
75 EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
76 EFI_INVALID_PARAMETER - One of the input args was NULL.
79 // TODO: ADD IN/OUT description here
81 UGA_PRIVATE_DATA
*Private
;
83 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
85 if (Private
->HardwareNeedsStarting
) {
86 return EFI_NOT_STARTED
;
89 if ((HorizontalResolution
== NULL
) ||
90 (VerticalResolution
== NULL
) ||
91 (ColorDepth
== NULL
) ||
92 (RefreshRate
== NULL
)) {
93 return EFI_INVALID_PARAMETER
;
96 *HorizontalResolution
= Private
->HorizontalResolution
;
97 *VerticalResolution
= Private
->VerticalResolution
;
98 *ColorDepth
= Private
->ColorDepth
;
99 *RefreshRate
= Private
->RefreshRate
;
106 EFI_UGA_DRAW_PROTOCOL
*This
,
107 UINT32 HorizontalResolution
,
108 UINT32 VerticalResolution
,
115 Return the current video mode information.
118 This - Protocol instance pointer.
119 HorizontalResolution - Current video horizontal resolution in pixels
120 VerticalResolution - Current video Vertical resolution in pixels
121 ColorDepth - Current video color depth in bits per pixel
122 RefreshRate - Current video refresh rate in Hz.
125 EFI_SUCCESS - Mode information returned.
126 EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
127 EFI_INVALID_PARAMETER - One of the input args was NULL.
130 // TODO: EFI_DEVICE_ERROR - add return value to function comment
131 // TODO: EFI_DEVICE_ERROR - add return value to function comment
132 // TODO: ADD IN/OUT description here
135 UGA_PRIVATE_DATA
*Private
;
137 EFI_UGA_PIXEL
*NewFillLine
;
143 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
145 if (Private
->HardwareNeedsStarting
) {
146 Status
= WinNtUgaStartWindow (
148 HorizontalResolution
,
153 if (EFI_ERROR (Status
)) {
154 return EFI_DEVICE_ERROR
;
157 Private
->HardwareNeedsStarting
= FALSE
;
160 // Change the resolution and resize of the window
164 // Free the old buffer. We do not save the content of the old buffer since the
165 // screen is to be cleared anyway. Clearing the screen is required by the EFI spec.
166 // See EFI spec chepter 10.5-EFI_UGA_DRAW_PROTOCOL.SetMode()
168 Private
->WinNtThunk
->HeapFree (Private
->WinNtThunk
->GetProcessHeap (), 0, Private
->VirtualScreenInfo
);
171 // Allocate DIB frame buffer directly from NT for performance enhancement
172 // This buffer is the virtual screen/frame buffer. This buffer is not the
173 // same a a frame buffer. The first row of this buffer will be the bottom
174 // line of the image. This is an artifact of the way we draw to the screen.
176 Size
= HorizontalResolution
* VerticalResolution
* sizeof (RGBQUAD
) + sizeof (BITMAPV4HEADER
);
177 Private
->VirtualScreenInfo
= Private
->WinNtThunk
->HeapAlloc (
178 Private
->WinNtThunk
->GetProcessHeap (),
184 // Update the virtual screen info data structure
186 Private
->VirtualScreenInfo
->bV4Size
= sizeof (BITMAPV4HEADER
);
187 Private
->VirtualScreenInfo
->bV4Width
= HorizontalResolution
;
188 Private
->VirtualScreenInfo
->bV4Height
= VerticalResolution
;
189 Private
->VirtualScreenInfo
->bV4Planes
= 1;
190 Private
->VirtualScreenInfo
->bV4BitCount
= 32;
194 Private
->VirtualScreenInfo
->bV4V4Compression
= BI_RGB
;
197 // The rest of the allocated memory block is the virtual screen buffer
199 Private
->VirtualScreen
= (RGBQUAD
*) (Private
->VirtualScreenInfo
+ 1);
202 // Use the AdjuctWindowRect fuction to calculate the real width and height
203 // of the new window including the border and caption
207 Rect
.right
= HorizontalResolution
;
208 Rect
.bottom
= VerticalResolution
;
210 Private
->WinNtThunk
->AdjustWindowRect (&Rect
, WS_OVERLAPPEDWINDOW
, 0);
212 Width
= Rect
.right
- Rect
.left
;
213 Height
= Rect
.bottom
- Rect
.top
;
216 // Retrieve the original window position information
218 Private
->WinNtThunk
->GetWindowRect (Private
->WindowHandle
, &Rect
);
221 // Adjust the window size
223 Private
->WinNtThunk
->MoveWindow (Private
->WindowHandle
, Rect
.left
, Rect
.top
, Width
, Height
, TRUE
);
227 Status
= gBS
->AllocatePool (
229 sizeof (EFI_UGA_PIXEL
) * HorizontalResolution
,
232 if (EFI_ERROR (Status
)) {
233 return EFI_DEVICE_ERROR
;
236 if (Private
->FillLine
!= NULL
) {
237 gBS
->FreePool (Private
->FillLine
);
240 Private
->FillLine
= NewFillLine
;
242 Private
->HorizontalResolution
= HorizontalResolution
;
243 Private
->VerticalResolution
= VerticalResolution
;
244 Private
->ColorDepth
= ColorDepth
;
245 Private
->RefreshRate
= RefreshRate
;
258 HorizontalResolution
,
260 HorizontalResolution
* sizeof (EFI_UGA_PIXEL
)
268 IN EFI_UGA_DRAW_PROTOCOL
*This
,
269 IN EFI_UGA_PIXEL
*BltBuffer
, OPTIONAL
270 IN EFI_UGA_BLT_OPERATION BltOperation
,
273 IN UINTN DestinationX
,
274 IN UINTN DestinationY
,
277 IN UINTN Delta OPTIONAL
282 Blt pixels from the rectangle (Width X Height) formed by the BltBuffer
283 onto the graphics screen starting a location (X, Y). (0, 0) is defined as
284 the upper left hand side of the screen. (X, Y) can be outside of the
285 current screen geometry and the BltBuffer will be cliped when it is
286 displayed. X and Y can be negative or positive. If Width or Height is
287 bigger than the current video screen the image will be clipped.
290 This - Protocol instance pointer.
291 X - X location on graphics screen.
292 Y - Y location on the graphics screen.
293 Width - Width of BltBuffer.
294 Height - Hight of BltBuffer
295 BltOperation - Operation to perform on BltBuffer and video memory
296 BltBuffer - Buffer containing data to blt into video buffer. This
297 buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
298 SourceX - If the BltOperation is a EfiCopyBlt this is the source
299 of the copy. For other BLT operations this argument is not
301 SourceX - If the BltOperation is a EfiCopyBlt this is the source
302 of the copy. For other BLT operations this argument is not
306 EFI_SUCCESS - The palette is updated with PaletteArray.
307 EFI_INVALID_PARAMETER - BltOperation is not valid.
308 EFI_DEVICE_ERROR - A hardware error occured writting to the video
312 // TODO: SourceY - add argument and description to function comment
313 // TODO: DestinationX - add argument and description to function comment
314 // TODO: DestinationY - add argument and description to function comment
315 // TODO: Delta - add argument and description to function comment
317 UGA_PRIVATE_DATA
*Private
;
326 EFI_UGA_PIXEL
*FillPixel
;
328 Private
= UGA_DRAW_PRIVATE_DATA_FROM_THIS (This
);
330 if ((BltOperation
< 0) || (BltOperation
>= EfiUgaBltMax
)) {
331 return EFI_INVALID_PARAMETER
;
334 if (Width
== 0 || Height
== 0) {
335 return EFI_INVALID_PARAMETER
;
338 // If Delta is zero, then the entire BltBuffer is being used, so Delta
339 // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
340 // the number of bytes in each row can be computed.
343 Delta
= Width
* sizeof (EFI_UGA_PIXEL
);
347 // We need to fill the Virtual Screen buffer with the blt data.
348 // The virtual screen is upside down, as the first row is the bootom row of
352 if (BltOperation
== EfiUgaVideoToBltBuffer
) {
355 // Video to BltBuffer: Source is Video, destination is BltBuffer
357 if (SourceY
+ Height
> Private
->VerticalResolution
) {
358 return EFI_INVALID_PARAMETER
;
361 if (SourceX
+ Width
> Private
->HorizontalResolution
) {
362 return EFI_INVALID_PARAMETER
;
365 // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
366 // We would not want a timer based event (Cursor, ...) to come in while we are
367 // doing this operation.
369 OriginalTPL
= gBS
->RaiseTPL (EFI_TPL_NOTIFY
);
371 for (SrcY
= SourceY
, DstY
= DestinationY
; DstY
< (Height
+ DestinationY
); SrcY
++, DstY
++) {
372 Blt
= (EFI_UGA_PIXEL
*) ((UINT8
*) BltBuffer
+ (DstY
* Delta
) + DestinationX
* sizeof (EFI_UGA_PIXEL
));
373 VScreen
= &Private
->VirtualScreen
[(Private
->VerticalResolution
- SrcY
- 1) * Private
->HorizontalResolution
+ SourceX
];
374 CopyMem (Blt
, VScreen
, sizeof (EFI_UGA_PIXEL
) * Width
);
378 // BltBuffer to Video: Source is BltBuffer, destination is Video
380 if (DestinationY
+ Height
> Private
->VerticalResolution
) {
381 return EFI_INVALID_PARAMETER
;
384 if (DestinationX
+ Width
> Private
->HorizontalResolution
) {
385 return EFI_INVALID_PARAMETER
;
389 // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
390 // We would not want a timer based event (Cursor, ...) to come in while we are
391 // doing this operation.
393 OriginalTPL
= gBS
->RaiseTPL (EFI_TPL_NOTIFY
);
395 if (BltOperation
== EfiUgaVideoFill
) {
396 FillPixel
= BltBuffer
;
397 for (Index
= 0; Index
< Width
; Index
++) {
398 Private
->FillLine
[Index
] = *FillPixel
;
402 for (Index
= 0; Index
< Height
; Index
++) {
403 if (DestinationY
<= SourceY
) {
404 SrcY
= SourceY
+ Index
;
405 DstY
= DestinationY
+ Index
;
407 SrcY
= SourceY
+ Height
- Index
- 1;
408 DstY
= DestinationY
+ Height
- Index
- 1;
411 VScreen
= &Private
->VirtualScreen
[(Private
->VerticalResolution
- DstY
- 1) * Private
->HorizontalResolution
+ DestinationX
];
412 switch (BltOperation
) {
413 case EfiUgaBltBufferToVideo
:
414 Blt
= (EFI_UGA_PIXEL
*) ((UINT8
*) BltBuffer
+ (SrcY
* Delta
) + SourceX
* sizeof (EFI_UGA_PIXEL
));
415 CopyMem (VScreen
, Blt
, Width
* sizeof (EFI_UGA_PIXEL
));
418 case EfiUgaVideoToVideo
:
419 VScreenSrc
= &Private
->VirtualScreen
[(Private
->VerticalResolution
- SrcY
- 1) * Private
->HorizontalResolution
+ SourceX
];
420 CopyMem (VScreen
, VScreenSrc
, Width
* sizeof (EFI_UGA_PIXEL
));
423 case EfiUgaVideoFill
:
424 CopyMem (VScreen
, Private
->FillLine
, Width
* sizeof (EFI_UGA_PIXEL
));
430 if (BltOperation
!= EfiUgaVideoToBltBuffer
) {
432 // Mark the area we just blted as Invalid so WM_PAINT will update.
434 Rect
.left
= DestinationX
;
435 Rect
.top
= DestinationY
;
436 Rect
.right
= DestinationX
+ Width
;
437 Rect
.bottom
= DestinationY
+ Height
;
438 Private
->WinNtThunk
->InvalidateRect (Private
->WindowHandle
, &Rect
, FALSE
);
441 // Send the WM_PAINT message to the thread that is drawing the window. We
442 // are in the main thread and the window drawing is in a child thread.
443 // There is a child thread per window. We have no CriticalSection or Mutex
444 // since we write the data and the other thread displays the data. While
445 // we may miss some data for a short period of time this is no different than
446 // a write combining on writes to a frame buffer.
449 Private
->WinNtThunk
->UpdateWindow (Private
->WindowHandle
);
452 gBS
->RestoreTPL (OriginalTPL
);
459 // Construction and Destruction functions
464 IN EFI_WIN_NT_IO_PROTOCOL
*WinNtIo
477 // TODO: WinNtIo - add argument and description to function comment
478 // TODO: EFI_UNSUPPORTED - add return value to function comment
479 // TODO: EFI_SUCCESS - add return value to function comment
482 // Check to see if the IO abstraction represents a device type we support.
484 // This would be replaced a check of PCI subsystem ID, etc.
486 if (!CompareGuid (WinNtIo
->TypeGuid
, &gEfiWinNtUgaGuid
)) {
487 return EFI_UNSUPPORTED
;
495 WinNtUgaThreadWindowProc (
504 Win32 Windows event handler.
513 // TODO: hwnd - add argument and description to function comment
514 // TODO: iMsg - add argument and description to function comment
515 // TODO: wParam - add argument and description to function comment
516 // TODO: lParam - add argument and description to function comment
518 UGA_PRIVATE_DATA
*Private
;
521 PAINTSTRUCT PaintStruct
;
526 // BugBug - if there are two instances of this DLL in memory (such as is
527 // the case for ERM), the correct instance of this function may not be called.
528 // This also means that the address of the mTlsIndex value will be wrong, and
529 // the value may be wrong too.
534 // Use mTlsIndex global to get a Thread Local Storage version of Private.
535 // This works since each Uga protocol has a unique Private data instance and
538 Private
= mWinNt
->TlsGetValue (mTlsIndex
);
539 ASSERT (NULL
!= Private
);
543 Size
= Private
->HorizontalResolution
* Private
->VerticalResolution
* sizeof (RGBQUAD
);
546 // Allocate DIB frame buffer directly from NT for performance enhancement
547 // This buffer is the virtual screen/frame buffer. This buffer is not the
548 // same a a frame buffer. The first fow of this buffer will be the bottom
549 // line of the image. This is an artifact of the way we draw to the screen.
551 Private
->VirtualScreenInfo
= Private
->WinNtThunk
->HeapAlloc (
552 Private
->WinNtThunk
->GetProcessHeap (),
557 Private
->VirtualScreenInfo
->bV4Size
= sizeof (BITMAPV4HEADER
);
558 Private
->VirtualScreenInfo
->bV4Width
= Private
->HorizontalResolution
;
559 Private
->VirtualScreenInfo
->bV4Height
= Private
->VerticalResolution
;
560 Private
->VirtualScreenInfo
->bV4Planes
= 1;
561 Private
->VirtualScreenInfo
->bV4BitCount
= 32;
565 Private
->VirtualScreenInfo
->bV4V4Compression
= BI_RGB
;
566 Private
->VirtualScreen
= (RGBQUAD
*) (Private
->VirtualScreenInfo
+ 1);
571 // I have not found a way to convert hwnd into a Private context. So for
572 // now we use this API to convert hwnd to Private data.
575 Handle
= mWinNt
->BeginPaint (hwnd
, &PaintStruct
);
577 mWinNt
->SetDIBitsToDevice (
578 Handle
, // Destination Device Context
579 0, // Destination X - 0
580 0, // Destination Y - 0
581 Private
->HorizontalResolution
, // Width
582 Private
->VerticalResolution
, // Height
585 0, // DIB Start Scan Line
586 Private
->VerticalResolution
, // Number of scan lines
587 Private
->VirtualScreen
, // Address of array of DIB bits
588 (BITMAPINFO
*) Private
->VirtualScreenInfo
, // Address of structure with bitmap info
589 DIB_RGB_COLORS
// RGB or palette indexes
592 mWinNt
->EndPaint (hwnd
, &PaintStruct
);
596 // F10 and the ALT key do not create a WM_KEYDOWN message, thus this special case
602 Key
.ScanCode
= SCAN_F10
;
604 UgaPrivateAddQ (Private
, Key
);
612 case VK_HOME
: Key
.ScanCode
= SCAN_HOME
; break;
613 case VK_END
: Key
.ScanCode
= SCAN_END
; break;
614 case VK_LEFT
: Key
.ScanCode
= SCAN_LEFT
; break;
615 case VK_RIGHT
: Key
.ScanCode
= SCAN_RIGHT
; break;
616 case VK_UP
: Key
.ScanCode
= SCAN_UP
; break;
617 case VK_DOWN
: Key
.ScanCode
= SCAN_DOWN
; break;
618 case VK_DELETE
: Key
.ScanCode
= SCAN_DELETE
; break;
619 case VK_INSERT
: Key
.ScanCode
= SCAN_INSERT
; break;
620 case VK_PRIOR
: Key
.ScanCode
= SCAN_PAGE_UP
; break;
621 case VK_NEXT
: Key
.ScanCode
= SCAN_PAGE_DOWN
; break;
622 case VK_ESCAPE
: Key
.ScanCode
= SCAN_ESC
; break;
624 case VK_F1
: Key
.ScanCode
= SCAN_F1
; break;
625 case VK_F2
: Key
.ScanCode
= SCAN_F2
; break;
626 case VK_F3
: Key
.ScanCode
= SCAN_F3
; break;
627 case VK_F4
: Key
.ScanCode
= SCAN_F4
; break;
628 case VK_F5
: Key
.ScanCode
= SCAN_F5
; break;
629 case VK_F6
: Key
.ScanCode
= SCAN_F6
; break;
630 case VK_F7
: Key
.ScanCode
= SCAN_F7
; break;
631 case VK_F8
: Key
.ScanCode
= SCAN_F8
; break;
632 case VK_F9
: Key
.ScanCode
= SCAN_F9
; break;
633 case VK_F11
: Key
.ScanCode
= SCAN_F11
; break;
634 case VK_F12
: Key
.ScanCode
= SCAN_F12
; break;
637 if (Key
.ScanCode
!= 0) {
639 UgaPrivateAddQ (Private
, Key
);
646 // The ESC key also generate WM_CHAR.
648 if (wParam
== 0x1B) {
652 for (Index
= 0; Index
< (lParam
& 0xffff); Index
++) {
654 Key
.UnicodeChar
= (CHAR16
) wParam
;
656 UgaPrivateAddQ (Private
, Key
);
664 // This close message is issued by user, core is not aware of this,
665 // so don't release the window display resource, just hide the window.
667 Private
->WinNtThunk
->ShowWindow (Private
->WindowHandle
, SW_HIDE
);
671 mWinNt
->DestroyWindow (hwnd
);
672 mWinNt
->PostQuitMessage (0);
674 mWinNt
->HeapFree (Private
->WinNtThunk
->GetProcessHeap (), 0, Private
->VirtualScreenInfo
);
676 mWinNt
->ExitThread (0);
683 return mWinNt
->DefWindowProc (hwnd
, iMsg
, wParam
, lParam
);
688 WinNtUgaThreadWinMain (
695 This thread simulates the end of WinMain () aplication. Each Winow nededs
696 to process it's events. The messages are dispatched to
697 WinNtUgaThreadWindowProc ().
699 Be very careful sine WinNtUgaThreadWinMain () and WinNtUgaThreadWindowProc ()
700 are running in a seperate thread. We have to do this to process the events.
704 lpParameter - Handle of window to manage.
708 if a WM_QUIT message is returned exit.
713 UGA_PRIVATE_DATA
*Private
;
717 Private
= (UGA_PRIVATE_DATA
*) lpParameter
;
718 ASSERT (NULL
!= Private
);
721 // Since each thread has unique private data, save the private data in Thread
722 // Local Storage slot. Then the shared global mTlsIndex can be used to get
723 // thread specific context.
725 Private
->WinNtThunk
->TlsSetValue (mTlsIndex
, Private
);
727 Private
->ThreadId
= Private
->WinNtThunk
->GetCurrentThreadId ();
729 Private
->WindowsClass
.cbSize
= sizeof (WNDCLASSEX
);
730 Private
->WindowsClass
.style
= CS_HREDRAW
| CS_VREDRAW
| CS_OWNDC
;
731 Private
->WindowsClass
.lpfnWndProc
= WinNtUgaThreadWindowProc
;
732 Private
->WindowsClass
.cbClsExtra
= 0;
733 Private
->WindowsClass
.cbWndExtra
= 0;
734 Private
->WindowsClass
.hInstance
= NULL
;
735 Private
->WindowsClass
.hIcon
= Private
->WinNtThunk
->LoadIcon (NULL
, IDI_APPLICATION
);
736 Private
->WindowsClass
.hCursor
= Private
->WinNtThunk
->LoadCursor (NULL
, IDC_ARROW
);
737 Private
->WindowsClass
.hbrBackground
= (HBRUSH
) COLOR_WINDOW
;
738 Private
->WindowsClass
.lpszMenuName
= NULL
;
739 Private
->WindowsClass
.lpszClassName
= WIN_NT_UGA_CLASS_NAME
;
740 Private
->WindowsClass
.hIconSm
= Private
->WinNtThunk
->LoadIcon (NULL
, IDI_APPLICATION
);
743 // This call will fail after the first time, but thats O.K. since we only need
744 // WIN_NT_UGA_CLASS_NAME to exist to create the window.
746 // Note: Multiple instances of this DLL will use the same instance of this
747 // Class, including the callback function, unless the Class is unregistered and
748 // successfully registered again.
750 Atom
= Private
->WinNtThunk
->RegisterClassEx (&Private
->WindowsClass
);
753 // Setting Rect values to allow for the AdjustWindowRect to provide
754 // us the correct sizes for the client area when doing the CreateWindowEx
757 Rect
.bottom
= Private
->VerticalResolution
;
759 Rect
.right
= Private
->HorizontalResolution
;
761 Private
->WinNtThunk
->AdjustWindowRect (&Rect
, WS_OVERLAPPEDWINDOW
, 0);
763 Private
->WindowHandle
= Private
->WinNtThunk
->CreateWindowEx (
765 WIN_NT_UGA_CLASS_NAME
,
770 Rect
.right
- Rect
.left
,
771 Rect
.bottom
- Rect
.top
,
779 // The reset of this thread is the standard winows program. We need a sperate
780 // thread since we must process the message loop to make windows act like
784 Private
->WinNtThunk
->ShowWindow (Private
->WindowHandle
, SW_SHOW
);
785 Private
->WinNtThunk
->UpdateWindow (Private
->WindowHandle
);
788 // Let the main thread get some work done
790 Private
->WinNtThunk
->ReleaseSemaphore (Private
->ThreadInited
, 1, NULL
);
793 // This is the message loop that all Windows programs need.
795 while (Private
->WinNtThunk
->GetMessage (&Message
, Private
->WindowHandle
, 0, 0)) {
796 Private
->WinNtThunk
->TranslateMessage (&Message
);
797 Private
->WinNtThunk
->DispatchMessage (&Message
);
800 return Message
.wParam
;
804 WinNtUgaStartWindow (
805 IN UGA_PRIVATE_DATA
*Private
,
806 IN UINT32 HorizontalResolution
,
807 IN UINT32 VerticalResolution
,
808 IN UINT32 ColorDepth
,
809 IN UINT32 RefreshRate
815 TODO: Add function description
819 Private - TODO: add argument description
820 HorizontalResolution - TODO: add argument description
821 VerticalResolution - TODO: add argument description
822 ColorDepth - TODO: add argument description
823 RefreshRate - TODO: add argument description
827 TODO: add return values
835 mWinNt
= Private
->WinNtThunk
;
838 // Initialize a Thread Local Storge variable slot. We use TLS to get the
839 // correct Private data instance into the windows thread.
841 if (mTlsIndex
== TLS_OUT_OF_INDEXES
) {
842 ASSERT (0 == mTlsIndexUseCount
);
843 mTlsIndex
= Private
->WinNtThunk
->TlsAlloc ();
847 // always increase the use count!
851 Private
->HorizontalResolution
= HorizontalResolution
;
852 Private
->VerticalResolution
= VerticalResolution
;
855 // Register to be notified on exit boot services so we can destroy the window.
857 Status
= gBS
->CreateEvent (
858 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
862 &mUgaScreenExitBootServicesEvent
865 Private
->ThreadInited
= Private
->WinNtThunk
->CreateSemaphore (NULL
, 0, 1, NULL
);
866 Private
->ThreadHandle
= Private
->WinNtThunk
->CreateThread (
869 WinNtUgaThreadWinMain
,
876 // The other thread has entered the windows message loop so we can
877 // continue our initialization.
879 Private
->WinNtThunk
->WaitForSingleObject (Private
->ThreadInited
, INFINITE
);
880 Private
->WinNtThunk
->CloseHandle (Private
->ThreadInited
);
886 WinNtUgaConstructor (
887 UGA_PRIVATE_DATA
*Private
900 // TODO: Private - add argument and description to function comment
901 // TODO: EFI_SUCCESS - add return value to function comment
904 Private
->UgaDraw
.GetMode
= WinNtUgaGetMode
;
905 Private
->UgaDraw
.SetMode
= WinNtUgaSetMode
;
906 Private
->UgaDraw
.Blt
= WinNtUgaBlt
;
908 Private
->HardwareNeedsStarting
= TRUE
;
909 Private
->FillLine
= NULL
;
911 WinNtUgaInitializeSimpleTextInForWindow (Private
);
918 UGA_PRIVATE_DATA
*Private
931 // TODO: Private - add argument and description to function comment
932 // TODO: EFI_SUCCESS - add return value to function comment
934 UINT32 UnregisterReturn
;
936 if (!Private
->HardwareNeedsStarting
) {
938 // BugBug: Shutdown Uga Hardware and any child devices.
940 Private
->WinNtThunk
->SendMessage (Private
->WindowHandle
, WM_DESTROY
, 0, 0);
941 Private
->WinNtThunk
->CloseHandle (Private
->ThreadHandle
);
946 // The callback function for another window could still be called,
947 // so we need to make sure there are no more users of mTlsIndex.
949 if (0 == mTlsIndexUseCount
) {
950 ASSERT (TLS_OUT_OF_INDEXES
!= mTlsIndex
);
952 Private
->WinNtThunk
->TlsFree (mTlsIndex
);
953 mTlsIndex
= TLS_OUT_OF_INDEXES
;
955 UnregisterReturn
= Private
->WinNtThunk
->UnregisterClass (
956 Private
->WindowsClass
.lpszClassName
,
957 Private
->WindowsClass
.hInstance
961 WinNtUgaDestroySimpleTextInForWindow (Private
);
978 This is the UGA screen's callback notification function for exit-boot-services.
979 All we do here is call WinNtUgaDestructor().
984 Context - pointer to the Private structure.
993 Status
= WinNtUgaDestructor (Context
);