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
)))
463 EfiPrintf(L
"Nothing to do for re-init\r\n");
467 /* Check if graphics are disabled in the BCD */
468 if (DsppGraphicsDisabledByBcd())
470 /* Turn off the graphics console, switching back to text mode */
471 Status
= ((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->Enable(GraphicsConsole
, FALSE
);
474 /* Check if a custom graphics resolution is set */
475 if (MiscGetBootOption(BlpApplicationEntry
.BcdData
,
476 BcdLibraryInteger_GraphicsResolution
))
478 /* Check what it's set to */
479 Status
= BlGetBootOptionInteger(BlpApplicationEntry
.BcdData
,
480 BcdLibraryInteger_GraphicsResolution
,
481 &GraphicsResolution
);
482 if (!NT_SUCCESS(Status
))
487 /* Now check our current graphical resolution */
488 Status
= ((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->GetGraphicalResolution(GraphicsConsole
,
490 if (!NT_SUCCESS(Status
))
495 /* Remember that we're forcing a video mode */
496 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
;
498 /* Check which resolution to set */
499 if (!GraphicsResolution
)
502 EfiPrintf(L
"Display selection not yet handled\r\n");
503 return STATUS_NOT_IMPLEMENTED
;
505 else if (GraphicsResolution
== 1)
508 EfiPrintf(L
"Display selection not yet handled\r\n");
509 return STATUS_NOT_IMPLEMENTED
;
511 else if (GraphicsResolution
== 2)
514 EfiPrintf(L
"Display selection not yet handled\r\n");
515 return STATUS_NOT_IMPLEMENTED
;
519 /* Check if the force highest mode setting is present */
520 if (MiscGetBootOption(BlpApplicationEntry
.BcdData
,
521 BcdLibraryBoolean_GraphicsForceHighestMode
))
523 /* Check what it's set to */
524 Status
= BlGetBootOptionBoolean(BlpApplicationEntry
.BcdData
,
525 BcdLibraryBoolean_GraphicsForceHighestMode
,
527 if ((NT_SUCCESS(Status
)) && (HighestMode
))
529 /* Remember that high rest mode is being forced */
530 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
;
533 //((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->SetGraphicalResolution(GraphicsConsole, 0, 0);
536 ConsoleGraphicalResolutionListFlags
|= ~BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
;
537 EfiPrintf(L
"High res mode not yet handled\r\n");
538 Status
= STATUS_NOT_IMPLEMENTED
;
542 /* Return back to the caller */
547 BlpDisplayReinitialize (
552 PBL_TEXT_CONSOLE TextConsole
;
553 PBL_INPUT_CONSOLE InputConsole
;
555 /* Do we have a local console? */
556 InputConsole
= DspLocalInputConsole
;
559 /* Reinitialize it */
560 Status
= InputConsole
->Callbacks
->Reinitialize((PBL_TEXT_CONSOLE
)InputConsole
);
561 if (!NT_SUCCESS(Status
))
567 /* Do we have a text console? */
568 TextConsole
= DspTextConsole
;
571 /* Reinitialize it */
572 Status
= TextConsole
->Callbacks
->Reinitialize(TextConsole
);
580 BlpDisplayInitialize (
586 /* Are we resetting or initializing? */
587 if (Flags
& BL_LIBRARY_FLAG_REINITIALIZE
)
589 /* This is a reset */
590 Status
= DsppReinitialize(Flags
);
591 if (NT_SUCCESS(Status
))
593 /* Re-initialize the class as well */
594 Status
= BlpDisplayReinitialize();
599 /* Initialize the display */
600 Status
= DsppInitialize(Flags
);
603 /* Return display initialization state */
608 BlDisplayGetTextCellResolution (
609 _Out_ PULONG TextWidth
,
610 _Out_ PULONG TextHeight
614 PBL_GRAPHICS_CONSOLE GraphicsConsole
;
616 /* If the caller doesn't want anything, bail out */
617 if (!(TextWidth
) || !(TextHeight
))
622 /* Do we have a text console? */
623 Status
= STATUS_UNSUCCESSFUL
;
626 /* Do we have a graphics console? */
627 GraphicsConsole
= DspGraphicalConsole
;
630 /* Is it currently active? */
631 if (((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->IsEnabled(GraphicsConsole
))
633 /* Yep -- query it */
634 EfiPrintf(L
"GFX active, not supported query\r\n");
635 Status
= STATUS_NOT_IMPLEMENTED
;
636 //Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->GetTextCellResolution(GraphicsConsole);
641 /* Check if we failed to get it from the graphics console */
642 if (!NT_SUCCESS(Status
))
644 /* Set default text size */
651 BlDisplaySetScreenResolution (
655 PBL_GRAPHICS_CONSOLE Console
;
659 Status
= STATUS_SUCCESS
;
661 /* Do we have a graphics console? */
662 Console
= DspGraphicalConsole
;
665 /* Is it currently active? */
666 if (((PBL_GRAPHICS_CONSOLE_VTABLE
)Console
->TextConsole
.Callbacks
)->IsEnabled(Console
))
668 /* If so, disable it */
669 return ((PBL_GRAPHICS_CONSOLE_VTABLE
)Console
->TextConsole
.Callbacks
)->Enable(Console
, FALSE
);
673 /* We should've now fallen back to text mode */
676 /* Then fail, as no display appears active */
677 Status
= STATUS_UNSUCCESSFUL
;
680 /* Return back to the caller */
685 BlDisplayGetScreenResolution (
691 BL_DISPLAY_MODE Resolution
;
692 PBL_GRAPHICS_CONSOLE GraphicsConsole
;
694 /* Assume failure if no consoles are active */
695 Status
= STATUS_UNSUCCESSFUL
;
697 /* Do we have a text console? */
700 /* Do we have an active graphics console? */
701 GraphicsConsole
= DspGraphicalConsole
;
702 if ((GraphicsConsole
) &&
703 (((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->IsEnabled(GraphicsConsole
)))
705 /* Get the resolution */
706 Status
= ((PBL_GRAPHICS_CONSOLE_VTABLE
)GraphicsConsole
->TextConsole
.Callbacks
)->GetGraphicalResolution(GraphicsConsole
, &Resolution
);
707 if (NT_SUCCESS(Status
))
709 /* Return it back to the caller */
710 *HRes
= Resolution
.HRes
;
711 *VRes
= Resolution
.VRes
;
716 /* Return defaults */
719 Status
= STATUS_SUCCESS
;
723 /* Return if we got a valid resolution back */
728 BlDisplayInvalidateOemBitmap (
732 PBGRT_TABLE BgrtTable
;
735 /* Search for the BGRT */
736 Status
= BlUtlGetAcpiTable((PVOID
*)&BgrtTable
, BGRT_SIGNATURE
);
737 if (NT_SUCCESS(Status
))
739 /* Mark the bitmap as invalid */
740 BgrtTable
->Status
&= BGRT_STATUS_IMAGE_VALID
;
742 /* Unmap the table */
743 BlMmUnmapVirtualAddressEx(BgrtTable
, BgrtTable
->Header
.Length
);
748 BlDisplayGetOemBitmap (
749 _In_opt_ PCOORD Offsets
,
750 _Out_opt_ PULONG Flags
755 PHYSICAL_ADDRESS PhysicalAddress
;
756 PBGRT_TABLE BgrtTable
;
763 /* Search for the BGRT */
764 Status
= BlUtlGetAcpiTable((PVOID
*)&BgrtTable
, BGRT_SIGNATURE
);
765 if (!NT_SUCCESS(Status
))
767 EfiPrintf(L
"no BGRT found\r\n");
771 /* Make sure this is really a BGRT */
772 if (BgrtTable
->Header
.Signature
!= BGRT_SIGNATURE
)
774 Status
= STATUS_ACPI_INVALID_TABLE
;
778 /* Make sure the BGRT table length is valid */
779 if (BgrtTable
->Header
.Length
!= sizeof(*BgrtTable
))
781 Status
= STATUS_ACPI_INVALID_TABLE
;
785 /* Make sure its a bitmap */
786 if (BgrtTable
->ImageType
!= BgrtImageTypeBitmap
)
788 Status
= STATUS_ACPI_INVALID_TABLE
;
792 /* Make sure it's somewhere in RAM */
793 if (!BgrtTable
->LogoAddress
)
795 Status
= STATUS_ACPI_INVALID_TABLE
;
799 /* Map the bitmap header only for now */
800 PhysicalAddress
.QuadPart
= BgrtTable
->LogoAddress
;
801 Status
= BlMmMapPhysicalAddressEx((PVOID
*)&Header
,
805 if (!NT_SUCCESS(Status
))
810 /* Capture the real size of the header */
813 /* Unmap the bitmap header */
814 BlMmUnmapVirtualAddressEx(BgrtTable
, sizeof(BMP_HEADER
));
816 /* If the real size is smaller than at least a V3 bitmap, bail out */
817 if (Size
< sizeof(BITMAP
))
819 Status
= STATUS_ACPI_INVALID_TABLE
;
823 /* Map the real size of the header */
824 Status
= BlMmMapPhysicalAddressEx((PVOID
*)&Bitmap
,
828 if (!NT_SUCCESS(Status
))
833 /* Make sure this is a non-compressed 24-bit or 32-bit V3 bitmap */
834 if ((Bitmap
->BmpHeader
.Signature
!= 'MB') ||
835 (Bitmap
->DibHeader
.Compression
) ||
836 ((Bitmap
->DibHeader
.BitCount
!= 24) &&
837 (Bitmap
->DibHeader
.BitCount
!= 32)) ||
838 (Bitmap
->DibHeader
.Size
!= sizeof(BITMAP
)))
840 Status
= STATUS_ACPI_INVALID_TABLE
;
844 /* Check if caller wants the offsets back */
848 Offsets
->X
= BgrtTable
->OffsetX
;
849 Offsets
->Y
= BgrtTable
->OffsetY
;
852 /* Check if the caller wants flags */
855 /* Return if the image is valid */
856 *Flags
= BgrtTable
->Status
& BGRT_STATUS_IMAGE_VALID
;
860 /* Check if we had mapped the BGRT */
864 BlMmUnmapVirtualAddressEx(BgrtTable
, BgrtTable
->Header
.Length
);
867 /* Check if this is the failure path */
868 if (!NT_SUCCESS(Status
))
870 /* Did we have the OEM bitmap mapped? */
874 BlMmUnmapVirtualAddressEx(Bitmap
, Bitmap
->BmpHeader
.Size
);
877 /* No bitmap to return */
881 /* Return the bitmap back, if any */
886 BlDisplayValidOemBitmap (
891 ULONG HRes
, VRes
, Height
, Width
, Flags
;
896 /* First check if mobile graphics are enabled */
897 Status
= BlGetBootOptionBoolean(BlpApplicationEntry
.BcdData
,
898 BcdLibraryBoolean_MobileGraphics
,
900 if ((NT_SUCCESS(Status
)) && (Result
))
902 /* Yes, so use the firmware image */
906 /* Nope, so we'll check the ACPI OEM bitmap */
908 Bitmap
= BlDisplayGetOemBitmap(&Offsets
, &Flags
);
914 if (Flags
& BGRT_STATUS_IMAGE_VALID
)
916 /* Get the current screen resolution */
917 Status
= BlDisplayGetScreenResolution(&HRes
, &VRes
);
918 if (NT_SUCCESS(Status
))
920 /* Is there a valid width? */
921 Width
= Bitmap
->DibHeader
.Width
;
924 /* Is there a valid height? */
925 Height
= Bitmap
->DibHeader
.Height
;
928 /* Will if fit on this screen? */
929 if (((Width
+ Offsets
.X
) <= HRes
) &&
930 ((Height
+ Offsets
.Y
) <= VRes
))
932 /* Then it's all good! */
940 /* Unmap the bitmap for now, it will be drawn later */
941 BlMmUnmapVirtualAddressEx(Bitmap
, Bitmap
->BmpHeader
.Size
);
944 /* Return that a valid OEM bitmap exists */
949 BlDisplayClearScreen (
954 PBL_TEXT_CONSOLE TextConsole
;
956 /* Nothing to do if there's no text console */
957 Status
= STATUS_SUCCESS
;
958 TextConsole
= DspTextConsole
;
961 /* Otherwise, clear the whole screen */
962 Status
= TextConsole
->Callbacks
->ClearText(TextConsole
, FALSE
);
963 if (NT_SUCCESS(Status
))
965 /* Invalidate the OEM bitmap at this point */
966 BlDisplayInvalidateOemBitmap();
975 BlDisplaySetCursorType (
980 PBL_TEXT_CONSOLE TextConsole
;
981 BL_DISPLAY_STATE State
;
983 /* Nothing to do if there's no text console */
984 Status
= STATUS_SUCCESS
;
985 TextConsole
= DspTextConsole
;
988 /* Write visibility state and call the function to change it */
989 State
.CursorVisible
= Type
;
990 Status
= TextConsole
->Callbacks
->SetTextState(TextConsole
, 8, &State
);