2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/platform/display.c
5 * PURPOSE: Boot Library Display Management Routines
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
14 /* DATA VARIABLES ************************************************************/
16 PVOID BfiCachedStrikeData
;
17 LIST_ENTRY BfiDeferredListHead
;
18 LIST_ENTRY BfiFontFileListHead
;
19 PVOID BfiGraphicsRectangle
;
21 ULONG ConsoleGraphicalResolutionListFlags
;
22 BL_DISPLAY_MODE ConsoleGraphicalResolutionList
[3] =
28 ULONG ConsoleGraphicalResolutionListSize
= RTL_NUMBER_OF(ConsoleGraphicalResolutionList
);
30 BL_DISPLAY_MODE ConsoleTextResolutionList
[1] =
35 PVOID DspRemoteInputConsole
;
37 PVOID DspGraphicalConsole
;
38 PVOID DspLocalInputConsole
;
40 /* FUNCTIONS *****************************************************************/
43 DsppGraphicsDisabledByBcd (
50 /* Get the boot option, and if present, return the result */
51 Status
= BlGetBootOptionBoolean(BlpApplicationEntry
.BcdData
,
52 BcdLibraryBoolean_GraphicsModeDisabled
,
54 return (NT_SUCCESS(Status
) && (Disabled
));
59 _In_ PWCHAR FontFileName
62 PBL_DEVICE_DESCRIPTOR FontDevice
;
64 ULONG NameLength
, DirectoryLength
, TotalLength
;
65 PWCHAR FontPath
, FontDirectory
;
66 BL_LIBRARY_PARAMETERS LibraryParameters
;
67 BOOLEAN CustomDirectory
, CustomDevice
;
69 /* Initialize locals */
70 CustomDirectory
= TRUE
;
76 /* Check if a custom font path should be used */
77 Status
= BlGetBootOptionString(BlpApplicationEntry
.BcdData
,
78 BcdLibraryString_FontPath
,
80 if (!NT_SUCCESS(Status
))
82 /* Nope, use the one configured by the library */
83 CustomDirectory
= FALSE
;
84 RtlCopyMemory(&LibraryParameters
,
85 &BlpLibraryParameters
,
86 sizeof(LibraryParameters
)),
87 FontDirectory
= LibraryParameters
.FontBaseDirectory
;
90 /* Do we still not have a font directory? */
93 /* Use the boot device and boot directory */
94 FontDevice
= BlpBootDevice
;
95 FontDirectory
= L
"\\EFI\\Microsoft\\Boot\\Fonts";
100 /* Otherwise, if we have a font directory, what device is the app on? */
101 Status
= BlGetBootOptionDevice(BlpApplicationEntry
.BcdData
,
102 BcdLibraryDevice_ApplicationDevice
,
105 if (!NT_SUCCESS(Status
))
107 /* If we don't know the device, we can't open the path */
112 /* Figure out the length of the file name, and of the directory */
113 NameLength
= wcslen(FontFileName
);
114 DirectoryLength
= wcslen(FontDirectory
);
116 /* Safely add them up*/
117 Status
= RtlULongAdd(NameLength
, DirectoryLength
, &TotalLength
);
118 if (!NT_SUCCESS(Status
))
123 /* Convert to bytes */
124 Status
= RtlULongLongToULong(TotalLength
* sizeof(WCHAR
), &TotalLength
);
125 if (!NT_SUCCESS(Status
))
130 /* Add a terminating NUL */
131 Status
= RtlULongAdd(TotalLength
, sizeof(UNICODE_NULL
), &TotalLength
);
132 if (!NT_SUCCESS(Status
))
137 /* Allocate the final buffer for it */
138 FontPath
= BlMmAllocateHeap(TotalLength
);
141 Status
= STATUS_NO_MEMORY
;
145 /* Concatenate the directory with the file name */
146 wcscpy(FontPath
, FontDirectory
);
147 wcscat(FontPath
, FontFileName
);
149 /* Try to load this font */
150 Status
= BfLoadFontFile(FontDevice
, FontPath
);
153 /* Check if we had a custom font device allocated and free it */
154 if ((CustomDevice
) && (FontDevice
))
156 BlMmFreeHeap(FontDevice
);
159 /* Check if we had a custom font directory allocated and free it */
160 if ((FontDirectory
) && (CustomDirectory
))
162 BlMmFreeHeap(FontDirectory
);
165 /* Check if we had allocated a font path and free it */
168 BlMmFreeHeap(FontPath
);
176 BlpDisplayRegisterLocale (
180 BOOLEAN StandardLocale
;
183 PBL_DEFERRED_FONT_FILE DeferredFont
;
184 PLIST_ENTRY NextEntry
;
187 /* Assume custom locale */
188 StandardLocale
= FALSE
;
190 /* Bail out if the locale string seems invalid */
191 if (wcslen(Locale
) < 2)
193 return STATUS_INVALID_PARAMETER
;
196 /* Check the prefix first, then traditional vs. simplified */
197 Prefix
[0] = Locale
[0];
198 Prefix
[1] = Locale
[1];
199 Prefix
[2] = UNICODE_NULL
;
200 if (!_wcsicmp(Prefix
, L
"ja"))
202 FontFileName
= L
"\\jpn_boot.ttf";
204 else if (!_wcsicmp(Prefix
, L
"ko"))
206 FontFileName
= L
"\\kor_boot.ttf";
208 else if (!(_wcsicmp(Locale
, L
"zh-CN")) ||
209 !(_wcsicmp(Locale
, L
"zh-CHS")) ||
210 !(_wcsicmp(Locale
, L
"zh-Hans")))
212 FontFileName
= L
"\\chs_boot.ttf";
214 else if (!(_wcsicmp(Locale
, L
"zh-TW")) &&
215 !(_wcsicmp(Locale
, L
"zh-CHT")) &&
216 !(_wcsicmp(Locale
, L
"zh-HK")) &&
217 !(_wcsicmp(Locale
, L
"zh-Hant")))
219 FontFileName
= L
"\\cht_boot.ttf";
223 StandardLocale
= TRUE
;
224 FontFileName
= L
"\\wgl4_boot.ttf";
227 /* Parse all the currently deferred fonts*/
228 NextEntry
= BfiDeferredListHead
.Flink
;
229 while (NextEntry
!= &BfiDeferredListHead
)
232 DeferredFont
= CONTAINING_RECORD(NextEntry
, BL_DEFERRED_FONT_FILE
, ListEntry
);
234 /* Move to the next entry, and remove this one */
235 NextEntry
= NextEntry
->Flink
;
236 RemoveEntryList(&DeferredFont
->ListEntry
);
238 /* Free the deferred font, we'll be loading a new one */
239 BfiFreeDeferredFontFile(DeferredFont
);
242 /* Load the primary font */
243 Status
= DsppLoadFontFile(FontFileName
);
244 if (NT_SUCCESS(Status
) && !(StandardLocale
))
246 /* Also load the standard US one if we loaded a different one */
247 Status
= DsppLoadFontFile(L
"\\wgl4_boot.ttf");
250 /* Return back to caller */
259 BL_LIBRARY_PARAMETERS LibraryParameters
= BlpLibraryParameters
;
260 BOOLEAN NoGraphics
, HighestMode
;
262 PBL_DISPLAY_MODE DisplayMode
;
263 ULONGLONG GraphicsResolution
;
264 PBL_GRAPHICS_CONSOLE GraphicsConsole
;
265 PBL_TEXT_CONSOLE TextConsole
, RemoteConsole
;
267 /* Initialize font data */
268 BfiCachedStrikeData
= 0;
269 InitializeListHead(&BfiDeferredListHead
);
270 InitializeListHead(&BfiFontFileListHead
);
272 /* Allocate the font rectangle */
273 BfiGraphicsRectangle
= BlMmAllocateHeap(90);
274 if (!BfiGraphicsRectangle
)
276 return STATUS_NO_MEMORY
;
279 /* Display re-initialization not yet handled */
280 if (LibraryParameters
.LibraryFlags
& BL_LIBRARY_FLAG_REINITIALIZE_ALL
)
282 EfiPrintf(L
"Display path not handled\r\n");
283 return STATUS_NOT_SUPPORTED
;
286 /* Check if no graphics console is needed */
287 if ((Flags
& BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE
) ||
288 (DsppGraphicsDisabledByBcd()))
295 /* No graphics -- remember this */
299 /* On first load, we always initialize a graphics display */
300 GraphicsConsole
= NULL
;
301 if (!(Flags
& BL_LIBRARY_FLAG_REINITIALIZE_ALL
) || !(NoGraphics
))
303 /* Default to mode 0 (1024x768) */
304 DisplayMode
= &ConsoleGraphicalResolutionList
[0];
306 /* Check what resolution to use*/
307 Status
= BlGetBootOptionInteger(BlpApplicationEntry
.BcdData
,
308 BcdLibraryInteger_GraphicsResolution
,
309 &GraphicsResolution
);
310 if (NT_SUCCESS(Status
))
312 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
;
313 EfiPrintf(L
"Display selection not yet handled\r\n");
314 return STATUS_NOT_IMPLEMENTED
;
317 /* Check if the highest mode should be forced */
318 Status
= BlGetBootOptionBoolean(BlpApplicationEntry
.BcdData
,
319 BcdLibraryBoolean_GraphicsForceHighestMode
,
321 if (NT_SUCCESS(Status
))
323 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
;
324 EfiPrintf(L
"High res mode not yet handled\r\n");
325 return STATUS_NOT_IMPLEMENTED
;
328 /* Do we need graphics mode after all? */
331 /* Yep -- go allocate it */
332 GraphicsConsole
= BlMmAllocateHeap(sizeof(*GraphicsConsole
));
336 Status
= ConsoleGraphicalConstruct(GraphicsConsole
);
337 if (!NT_SUCCESS(Status
))
339 EfiPrintf(L
"GFX FAILED: %lx\r\n", Status
);
340 BlMmFreeHeap(GraphicsConsole
);
341 GraphicsConsole
= NULL
;
346 RtlFillMemory(GraphicsConsole
->FrameBuffer
, GraphicsConsole
->FrameBufferSize
, 0x55);
351 /* Are we using something else than the default mode? */
352 if (DisplayMode
!= &ConsoleGraphicalResolutionList
[0])
354 EfiPrintf(L
"Display path not handled\r\n");
355 return STATUS_NOT_SUPPORTED
;
358 /* Mask out all the flags now */
359 ConsoleGraphicalResolutionListFlags
&= ~(BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
|
360 BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
);
363 /* Do we have a graphics console? */
365 if (!GraphicsConsole
)
367 /* Nope -- go allocate a text console */
368 TextConsole
= BlMmAllocateHeap(sizeof(*TextConsole
));
372 Status
= ConsoleTextLocalConstruct(TextConsole
, TRUE
);
373 if (!NT_SUCCESS(Status
))
375 BlMmFreeHeap(TextConsole
);
381 /* Initialize all globals to NULL */
382 DspRemoteInputConsole
= NULL
;
383 DspTextConsole
= NULL
;
384 DspGraphicalConsole
= NULL
;
386 /* If we don't have a text console, go get a remote console */
387 RemoteConsole
= NULL
;
390 ConsoleCreateRemoteConsole(&RemoteConsole
);
393 /* Do we have a remote console? */
396 /* Nope -- what about a graphical one? */
399 /* Yes, use it for both graphics and text */
400 DspGraphicalConsole
= GraphicsConsole
;
401 DspTextConsole
= GraphicsConsole
;
403 else if (TextConsole
)
405 /* Nope, but we have a text console */
406 DspTextConsole
= TextConsole
;
409 /* Console has been setup */
410 return STATUS_SUCCESS
;
413 /* We have a remote console -- have to figure out how to use it*/
414 EfiPrintf(L
"Display path not handled\r\n");
415 return STATUS_NOT_SUPPORTED
;
423 PBL_TEXT_CONSOLE TextConsole
;
424 PBL_GRAPHICS_CONSOLE GraphicsConsole
;
426 ULONGLONG GraphicsResolution
;
428 BL_DISPLAY_MODE CurrentResolution
;
430 /* Do we have local input yet? */
431 if (!DspLocalInputConsole
)
434 ConsoleCreateLocalInputConsole();
437 /* If a graphics console is present without a remote console... */
439 if (!(DspRemoteInputConsole
) && (DspGraphicalConsole
))
441 /* Try to create a remote console */
442 ConsoleCreateRemoteConsole(&TextConsole
);
445 /* All good for now */
446 Status
= STATUS_SUCCESS
;
448 /* Now check if we were able to create the remote console */
451 EfiPrintf(L
"EMS not supported\r\n");
452 return STATUS_NOT_IMPLEMENTED
;
455 /* Set a local for the right cast */
456 GraphicsConsole
= DspGraphicalConsole
;
458 /* Nothing to do without a graphics console being reinitialized */
459 if (!(Flags
& BL_LIBRARY_FLAG_REINITIALIZE_ALL
) ||
460 !(GraphicsConsole
) ||
461 !(((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->IsEnabled(GraphicsConsole
)))
466 /* Check if graphics are disabled in the BCD */
467 if (DsppGraphicsDisabledByBcd())
469 /* Turn off the graphics console, switching back to text mode */
470 Status
= ((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->Enable(GraphicsConsole
, FALSE
);
473 /* Check if a custom graphics resolution is set */
474 if (MiscGetBootOption(BlpApplicationEntry
.BcdData
,
475 BcdLibraryInteger_GraphicsResolution
))
477 /* Check what it's set to */
478 Status
= BlGetBootOptionInteger(BlpApplicationEntry
.BcdData
,
479 BcdLibraryInteger_GraphicsResolution
,
480 &GraphicsResolution
);
481 if (!NT_SUCCESS(Status
))
486 /* Now check our current graphical resolution */
487 Status
= ((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->GetGraphicalResolution(GraphicsConsole
,
489 if (!NT_SUCCESS(Status
))
494 /* Remember that we're forcing a video mode */
495 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
;
497 /* Check which resolution to set */
498 if (!GraphicsResolution
)
501 EfiPrintf(L
"Display selection not yet handled\r\n");
502 return STATUS_NOT_IMPLEMENTED
;
504 else if (GraphicsResolution
== 1)
507 EfiPrintf(L
"Display selection not yet handled\r\n");
508 return STATUS_NOT_IMPLEMENTED
;
510 else if (GraphicsResolution
== 2)
513 EfiPrintf(L
"Display selection not yet handled\r\n");
514 return STATUS_NOT_IMPLEMENTED
;
518 /* Check if the force highest mode setting is present */
519 if (MiscGetBootOption(BlpApplicationEntry
.BcdData
,
520 BcdLibraryBoolean_GraphicsForceHighestMode
))
522 /* Check what it's set to */
523 Status
= BlGetBootOptionBoolean(BlpApplicationEntry
.BcdData
,
524 BcdLibraryBoolean_GraphicsForceHighestMode
,
526 if ((NT_SUCCESS(Status
)) && (HighestMode
))
528 /* Remember that high rest mode is being forced */
529 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
;
532 //((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->SetGraphicalResolution(GraphicsConsole, 0, 0);
535 ConsoleGraphicalResolutionListFlags
|= ~BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
;
536 EfiPrintf(L
"High res mode not yet handled\r\n");
537 Status
= STATUS_NOT_IMPLEMENTED
;
541 /* Return back to the caller */
546 BlpDisplayReinitialize (
551 PBL_TEXT_CONSOLE TextConsole
;
552 PBL_INPUT_CONSOLE InputConsole
;
554 /* Do we have a local console? */
555 InputConsole
= DspLocalInputConsole
;
558 /* Reinitialize it */
559 Status
= InputConsole
->Callbacks
->Reinitialize((PBL_TEXT_CONSOLE
)InputConsole
);
560 if (!NT_SUCCESS(Status
))
566 /* Do we have a text console? */
567 TextConsole
= DspTextConsole
;
570 /* Reinitialize it */
571 Status
= TextConsole
->Callbacks
->Reinitialize(TextConsole
);
579 BlpDisplayInitialize (
585 /* Are we resetting or initializing? */
586 if (Flags
& BL_LIBRARY_FLAG_REINITIALIZE
)
588 /* This is a reset */
589 Status
= DsppReinitialize(Flags
);
590 if (NT_SUCCESS(Status
))
592 /* Re-initialize the class as well */
593 Status
= BlpDisplayReinitialize();
598 /* Initialize the display */
599 Status
= DsppInitialize(Flags
);
602 /* Return display initialization state */
607 BlDisplayGetTextCellResolution (
608 _Out_ PULONG TextWidth
,
609 _Out_ PULONG TextHeight
613 PBL_GRAPHICS_CONSOLE GraphicsConsole
;
615 /* If the caller doesn't want anything, bail out */
616 if (!(TextWidth
) || !(TextHeight
))
621 /* Do we have a text console? */
622 Status
= STATUS_UNSUCCESSFUL
;
625 /* Do we have a graphics console? */
626 GraphicsConsole
= DspGraphicalConsole
;
629 /* Is it currently active? */
630 if (((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->IsEnabled(GraphicsConsole
))
632 /* Yep -- query it */
633 EfiPrintf(L
"GFX active, not supported query\r\n");
634 Status
= STATUS_NOT_IMPLEMENTED
;
635 //Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->GetTextCellResolution(GraphicsConsole);
640 /* Check if we failed to get it from the graphics console */
641 if (!NT_SUCCESS(Status
))
643 /* Set default text size */
650 BlDisplaySetScreenResolution (
654 PBL_GRAPHICS_CONSOLE Console
;
658 Status
= STATUS_SUCCESS
;
660 /* Do we have a graphics console? */
661 Console
= DspGraphicalConsole
;
664 /* Is it currently active? */
665 if (((PBL_GRAPHICS_CONSOLE_VTABLE
)Console
->TextConsole
.Callbacks
)->IsEnabled(Console
))
667 /* If so, disable it */
668 return ((PBL_GRAPHICS_CONSOLE_VTABLE
)Console
->TextConsole
.Callbacks
)->Enable(Console
, FALSE
);
672 /* We should've now fallen back to text mode */
675 /* Then fail, as no display appears active */
676 Status
= STATUS_UNSUCCESSFUL
;
679 /* Return back to the caller */
684 BlDisplayGetScreenResolution (
690 BL_DISPLAY_MODE Resolution
;
691 PBL_GRAPHICS_CONSOLE GraphicsConsole
;
693 /* Assume failure if no consoles are active */
694 Status
= STATUS_UNSUCCESSFUL
;
696 /* Do we have a text console? */
699 /* Do we have an active graphics console? */
700 GraphicsConsole
= DspGraphicalConsole
;
701 if ((GraphicsConsole
) &&
702 (((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->IsEnabled(GraphicsConsole
)))
704 /* Get the resolution */
705 Status
= ((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->GetGraphicalResolution(GraphicsConsole
, &Resolution
);
706 if (NT_SUCCESS(Status
))
708 /* Return it back to the caller */
709 *HRes
= Resolution
.HRes
;
710 *VRes
= Resolution
.VRes
;
715 /* Return defaults */
718 Status
= STATUS_SUCCESS
;
722 /* Return if we got a valid resolution back */
727 BlDisplayInvalidateOemBitmap (
731 PBGRT_TABLE BgrtTable
;
734 /* Search for the BGRT */
735 Status
= BlUtlGetAcpiTable((PVOID
*)&BgrtTable
, BGRT_SIGNATURE
);
736 if (NT_SUCCESS(Status
))
738 /* Mark the bitmap as invalid */
739 BgrtTable
->Status
&= BGRT_STATUS_IMAGE_VALID
;
741 /* Unmap the table */
742 BlMmUnmapVirtualAddressEx(BgrtTable
, BgrtTable
->Header
.Length
);
747 BlDisplayGetOemBitmap (
748 _In_opt_ PCOORD Offsets
,
749 _Out_opt_ PULONG Flags
754 PHYSICAL_ADDRESS PhysicalAddress
;
755 PBGRT_TABLE BgrtTable
;
762 /* Search for the BGRT */
763 Status
= BlUtlGetAcpiTable((PVOID
*)&BgrtTable
, BGRT_SIGNATURE
);
764 if (!NT_SUCCESS(Status
))
766 EfiPrintf(L
"no BGRT found\r\n");
770 /* Make sure this is really a BGRT */
771 if (BgrtTable
->Header
.Signature
!= BGRT_SIGNATURE
)
773 Status
= STATUS_ACPI_INVALID_TABLE
;
777 /* Make sure the BGRT table length is valid */
778 if (BgrtTable
->Header
.Length
!= sizeof(*BgrtTable
))
780 Status
= STATUS_ACPI_INVALID_TABLE
;
784 /* Make sure its a bitmap */
785 if (BgrtTable
->ImageType
!= BgrtImageTypeBitmap
)
787 Status
= STATUS_ACPI_INVALID_TABLE
;
791 /* Make sure it's somewhere in RAM */
792 if (!BgrtTable
->LogoAddress
)
794 Status
= STATUS_ACPI_INVALID_TABLE
;
798 /* Map the bitmap header only for now */
799 PhysicalAddress
.QuadPart
= BgrtTable
->LogoAddress
;
800 Status
= BlMmMapPhysicalAddressEx((PVOID
*)&Header
,
804 if (!NT_SUCCESS(Status
))
809 /* Capture the real size of the header */
812 /* Unmap the bitmap header */
813 BlMmUnmapVirtualAddressEx(BgrtTable
, sizeof(BMP_HEADER
));
815 /* If the real size is smaller than at least a V3 bitmap, bail out */
816 if (Size
< sizeof(BITMAP
))
818 Status
= STATUS_ACPI_INVALID_TABLE
;
822 /* Map the real size of the header */
823 Status
= BlMmMapPhysicalAddressEx((PVOID
*)&Bitmap
,
827 if (!NT_SUCCESS(Status
))
832 /* Make sure this is a non-compressed 24-bit or 32-bit V3 bitmap */
833 if ((Bitmap
->BmpHeader
.Signature
!= 'MB') ||
834 (Bitmap
->DibHeader
.Compression
) ||
835 ((Bitmap
->DibHeader
.BitCount
!= 24) &&
836 (Bitmap
->DibHeader
.BitCount
!= 32)) ||
837 (Bitmap
->DibHeader
.Size
!= sizeof(BITMAP
)))
839 Status
= STATUS_ACPI_INVALID_TABLE
;
843 /* Check if caller wants the offsets back */
847 Offsets
->X
= BgrtTable
->OffsetX
;
848 Offsets
->Y
= BgrtTable
->OffsetY
;
851 /* Check if the caller wants flags */
854 /* Return if the image is valid */
855 *Flags
= BgrtTable
->Status
& BGRT_STATUS_IMAGE_VALID
;
859 /* Check if we had mapped the BGRT */
863 BlMmUnmapVirtualAddressEx(BgrtTable
, BgrtTable
->Header
.Length
);
866 /* Check if this is the failure path */
867 if (!NT_SUCCESS(Status
))
869 /* Did we have the OEM bitmap mapped? */
873 BlMmUnmapVirtualAddressEx(Bitmap
, Bitmap
->BmpHeader
.Size
);
876 /* No bitmap to return */
880 /* Return the bitmap back, if any */
885 BlDisplayValidOemBitmap (
890 ULONG HRes
, VRes
, Height
, Width
, Flags
;
895 /* First check if mobile graphics are enabled */
896 Status
= BlGetBootOptionBoolean(BlpApplicationEntry
.BcdData
,
897 BcdLibraryBoolean_MobileGraphics
,
899 if ((NT_SUCCESS(Status
)) && (Result
))
901 /* Yes, so use the firmware image */
905 /* Nope, so we'll check the ACPI OEM bitmap */
907 Bitmap
= BlDisplayGetOemBitmap(&Offsets
, &Flags
);
913 if (Flags
& BGRT_STATUS_IMAGE_VALID
)
915 /* Get the current screen resolution */
916 Status
= BlDisplayGetScreenResolution(&HRes
, &VRes
);
917 if (NT_SUCCESS(Status
))
919 /* Is there a valid width? */
920 Width
= Bitmap
->DibHeader
.Width
;
923 /* Is there a valid height? */
924 Height
= Bitmap
->DibHeader
.Height
;
927 /* Will if fit on this screen? */
928 if (((Width
+ Offsets
.X
) <= HRes
) &&
929 ((Height
+ Offsets
.Y
) <= VRes
))
931 /* Then it's all good! */
939 /* Unmap the bitmap for now, it will be drawn later */
940 BlMmUnmapVirtualAddressEx(Bitmap
, Bitmap
->BmpHeader
.Size
);
943 /* Return that a valid OEM bitmap exists */
948 BlDisplayClearScreen (
953 PBL_TEXT_CONSOLE TextConsole
;
955 /* Nothing to do if there's no text console */
956 Status
= STATUS_SUCCESS
;
957 TextConsole
= DspTextConsole
;
960 /* Otherwise, clear the whole screen */
961 Status
= TextConsole
->Callbacks
->ClearText(TextConsole
, FALSE
);
962 if (NT_SUCCESS(Status
))
964 /* Invalidate the OEM bitmap at this point */
965 BlDisplayInvalidateOemBitmap();
974 BlDisplaySetCursorType (
979 PBL_TEXT_CONSOLE TextConsole
;
980 BL_DISPLAY_STATE State
;
982 /* Nothing to do if there's no text console */
983 Status
= STATUS_SUCCESS
;
984 TextConsole
= DspTextConsole
;
987 /* Write visibility state and call the function to change it */
988 State
.CursorVisible
= Type
;
989 Status
= TextConsole
->Callbacks
->SetTextState(TextConsole
, 8, &State
);