ReactOS 0.4.16-dev-297-gc569aee
display.c File Reference
#include "bl.h"
#include <bcd.h>
Include dependency graph for display.c:

Go to the source code of this file.

Functions

BOOLEAN DsppGraphicsDisabledByBcd (VOID)
 
NTSTATUS DsppLoadFontFile (_In_ PWCHAR FontFileName)
 
NTSTATUS BlpDisplayRegisterLocale (_In_ PWCHAR Locale)
 
NTSTATUS DsppInitialize (_In_ ULONG Flags)
 
NTSTATUS DsppReinitialize (_In_ ULONG Flags)
 
NTSTATUS BlpDisplayReinitialize (VOID)
 
NTSTATUS BlpDisplayInitialize (_In_ ULONG Flags)
 
VOID BlDisplayGetTextCellResolution (_Out_ PULONG TextWidth, _Out_ PULONG TextHeight)
 
NTSTATUS BlDisplaySetScreenResolution (VOID)
 
NTSTATUS BlDisplayGetScreenResolution (_Out_ PULONG HRes, _Out_ PULONG VRes)
 
VOID BlDisplayInvalidateOemBitmap (VOID)
 
PBITMAP BlDisplayGetOemBitmap (_In_opt_ PCOORD Offsets, _Out_opt_ PULONG Flags)
 
BOOLEAN BlDisplayValidOemBitmap (VOID)
 
NTSTATUS BlDisplayClearScreen (VOID)
 
NTSTATUS BlDisplaySetCursorType (_In_ ULONG Type)
 

Variables

PVOID BfiCachedStrikeData
 
LIST_ENTRY BfiDeferredListHead
 
LIST_ENTRY BfiFontFileListHead
 
PVOID BfiGraphicsRectangle
 
ULONG ConsoleGraphicalResolutionListFlags
 
BL_DISPLAY_MODE ConsoleGraphicalResolutionList [3]
 
ULONG ConsoleGraphicalResolutionListSize = RTL_NUMBER_OF(ConsoleGraphicalResolutionList)
 
BL_DISPLAY_MODE ConsoleTextResolutionList [1]
 
PVOID DspRemoteInputConsole
 
PVOID DspTextConsole
 
PVOID DspGraphicalConsole
 
PVOID DspLocalInputConsole
 

Function Documentation

◆ BlDisplayClearScreen()

NTSTATUS BlDisplayClearScreen ( VOID  )

Definition at line 943 of file display.c.

946{
948 PBL_TEXT_CONSOLE TextConsole;
949
950 /* Nothing to do if there's no text console */
952 TextConsole = DspTextConsole;
953 if (TextConsole)
954 {
955 /* Otherwise, clear the whole screen */
956 Status = TextConsole->Callbacks->ClearText(TextConsole, FALSE);
957 if (NT_SUCCESS(Status))
958 {
959 /* Invalidate the OEM bitmap at this point */
961 }
962 }
963
964 /* All done */
965 return Status;
966};
LONG NTSTATUS
Definition: precomp.h:26
PVOID DspTextConsole
Definition: display.c:36
VOID BlDisplayInvalidateOemBitmap(VOID)
Definition: display.c:723
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
PCONSOLE_CLEAR_TEXT ClearText
Definition: bl.h:1092
PBL_TEXT_CONSOLE_VTABLE Callbacks
Definition: bl.h:1110

Referenced by BmMain(), and OslDrawLogo().

◆ BlDisplayGetOemBitmap()

PBITMAP BlDisplayGetOemBitmap ( _In_opt_ PCOORD  Offsets,
_Out_opt_ PULONG  Flags 
)

Definition at line 743 of file display.c.

747{
749 ULONG Size;
751 PBGRT_TABLE BgrtTable;
754
755 Bitmap = NULL;
756 BgrtTable = NULL;
757
758 /* Search for the BGRT */
760 if (!NT_SUCCESS(Status))
761 {
762 goto Quickie;
763 }
764
765 /* Make sure this is really a BGRT */
766 if (BgrtTable->Header.Signature != BGRT_SIGNATURE)
767 {
769 goto Quickie;
770 }
771
772 /* Make sure the BGRT table length is valid */
773 if (BgrtTable->Header.Length != sizeof(*BgrtTable))
774 {
776 goto Quickie;
777 }
778
779 /* Make sure its a bitmap */
780 if (BgrtTable->ImageType != BgrtImageTypeBitmap)
781 {
783 goto Quickie;
784 }
785
786 /* Make sure it's somewhere in RAM */
787 if (!BgrtTable->LogoAddress)
788 {
790 goto Quickie;
791 }
792
793 /* Map the bitmap header only for now */
796 0,
797 sizeof(BMP_HEADER),
799 if (!NT_SUCCESS(Status))
800 {
801 goto Quickie;
802 }
803
804 /* Capture the real size of the header */
805 Size = Header->Size;
806
807 /* Unmap the bitmap header */
808 BlMmUnmapVirtualAddressEx(BgrtTable, sizeof(BMP_HEADER));
809
810 /* If the real size is smaller than at least a V3 bitmap, bail out */
811 if (Size < sizeof(BITMAP))
812 {
814 goto Quickie;
815 }
816
817 /* Map the real size of the header */
819 0,
820 Size,
822 if (!NT_SUCCESS(Status))
823 {
824 goto Quickie;
825 }
826
827 /* Make sure this is a non-compressed 24-bit or 32-bit V3 bitmap */
828 if ((Bitmap->BmpHeader.Signature != 'MB') ||
829 (Bitmap->DibHeader.Compression) ||
830 ((Bitmap->DibHeader.BitCount != 24) &&
831 (Bitmap->DibHeader.BitCount != 32)) ||
832 (Bitmap->DibHeader.Size != sizeof(DIB_HEADER)))
833 {
835 goto Quickie;
836 }
837
838 /* Check if caller wants the offsets back */
839 if (Offsets)
840 {
841 /* Give them away */
842 Offsets->X = BgrtTable->OffsetX;
843 Offsets->Y = BgrtTable->OffsetY;
844 }
845
846 /* Check if the caller wants flags */
847 if (Flags)
848 {
849 /* Return if the image is valid */
850 *Flags = BgrtTable->Status & BGRT_STATUS_IMAGE_VALID;
851 }
852
853Quickie:
854 /* Check if we had mapped the BGRT */
855 if (BgrtTable)
856 {
857 /* Unmap it */
858 BlMmUnmapVirtualAddressEx(BgrtTable, BgrtTable->Header.Length);
859 }
860
861 /* Check if this is the failure path */
862 if (!NT_SUCCESS(Status))
863 {
864 /* Did we have the OEM bitmap mapped? */
865 if (Bitmap)
866 {
867 /* Unmap it */
868 BlMmUnmapVirtualAddressEx(Bitmap, Bitmap->BmpHeader.Size);
869 }
870
871 /* No bitmap to return */
872 Bitmap = NULL;
873 }
874
875 /* Return the bitmap back, if any */
876 return Bitmap;
877}
NTSTATUS BlMmUnmapVirtualAddressEx(_In_ PVOID VirtualAddress, _In_ ULONGLONG Size)
Definition: mm.c:487
NTSTATUS BlUtlGetAcpiTable(_Out_ PVOID *TableAddress, _In_ ULONG Signature)
Definition: util.c:34
NTSTATUS BlMmMapPhysicalAddressEx(_In_ PVOID *VirtualAddress, _In_ ULONG Attributes, _In_ ULONGLONG Size, _In_ PHYSICAL_ADDRESS PhysicalAddress)
Definition: mm.c:192
Definition: Header.h:9
#define NULL
Definition: types.h:112
#define STATUS_ACPI_INVALID_TABLE
Definition: ntstatus.h:1316
@ BgrtImageTypeBitmap
Definition: acpi.h:60
#define BGRT_STATUS_IMAGE_VALID
Definition: acpi.h:53
#define BGRT_SIGNATURE
Definition: acpi.h:43
ULONG OffsetX
Definition: acpi.h:248
UCHAR ImageType
Definition: acpi.h:246
DESCRIPTION_HEADER Header
Definition: acpi.h:243
ULONGLONG LogoAddress
Definition: acpi.h:247
UCHAR Status
Definition: acpi.h:245
ULONG OffsetY
Definition: acpi.h:249
Definition: bl.h:1331
ULONG Signature
Definition: acpi.h:96
ULONG Length
Definition: acpi.h:97
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098

Referenced by BlDisplayValidOemBitmap().

◆ BlDisplayGetScreenResolution()

NTSTATUS BlDisplayGetScreenResolution ( _Out_ PULONG  HRes,
_Out_ PULONG  VRes 
)

Definition at line 680 of file display.c.

684{
687 PBL_GRAPHICS_CONSOLE GraphicsConsole;
688
689 /* Assume failure if no consoles are active */
691
692 /* Do we have a text console? */
693 if (DspTextConsole)
694 {
695 /* Do we have an active graphics console? */
696 GraphicsConsole = DspGraphicalConsole;
697 if ((GraphicsConsole) &&
698 (((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->IsEnabled(GraphicsConsole)))
699 {
700 /* Get the resolution */
701 Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->GetGraphicalResolution(GraphicsConsole, &Resolution);
702 if (NT_SUCCESS(Status))
703 {
704 /* Return it back to the caller */
705 *HRes = Resolution.HRes;
706 *VRes = Resolution.VRes;
707 }
708 }
709 else
710 {
711 /* Return defaults */
712 *HRes = 640;
713 *VRes = 200;
715 }
716 }
717
718 /* Return if we got a valid resolution back */
719 return Status;
720}
struct _BL_GRAPHICS_CONSOLE_VTABLE * PBL_GRAPHICS_CONSOLE_VTABLE
PVOID DspGraphicalConsole
Definition: display.c:37
BL_TEXT_CONSOLE TextConsole
Definition: bl.h:1146
static BYTE Resolution
Definition: mouse.c:35
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by BlDisplayValidOemBitmap(), and BlpResourceInitialize().

◆ BlDisplayGetTextCellResolution()

VOID BlDisplayGetTextCellResolution ( _Out_ PULONG  TextWidth,
_Out_ PULONG  TextHeight 
)

Definition at line 603 of file display.c.

607{
609 PBL_GRAPHICS_CONSOLE GraphicsConsole;
610
611 /* If the caller doesn't want anything, bail out */
612 if (!(TextWidth) || !(TextHeight))
613 {
614 return;
615 }
616
617 /* Do we have a text console? */
619 if (DspTextConsole)
620 {
621 /* Do we have a graphics console? */
622 GraphicsConsole = DspGraphicalConsole;
623 if (GraphicsConsole)
624 {
625 /* Is it currently active? */
626 if (((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->IsEnabled(GraphicsConsole))
627 {
628 /* Yep -- query it */
629 EfiPrintf(L"GFX active, not supported query\r\n");
631 //Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->GetTextCellResolution(GraphicsConsole);
632 }
633 }
634 }
635
636 /* Check if we failed to get it from the graphics console */
637 if (!NT_SUCCESS(Status))
638 {
639 /* Set default text size */
640 *TextWidth = 8;
641 *TextHeight = 8;
642 }
643}
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define L(x)
Definition: ntvdm.h:50

Referenced by ConsoleEfiTextGetStateFromMode(), ConsoleFirmwareTextClear(), and ConsoleFirmwareTextSetState().

◆ BlDisplayInvalidateOemBitmap()

VOID BlDisplayInvalidateOemBitmap ( VOID  )

Definition at line 723 of file display.c.

726{
727 PBGRT_TABLE BgrtTable;
729
730 /* Search for the BGRT */
732 if (NT_SUCCESS(Status))
733 {
734 /* Mark the bitmap as invalid */
735 BgrtTable->Status &= ~BGRT_STATUS_IMAGE_VALID;
736
737 /* Unmap the table */
738 BlMmUnmapVirtualAddressEx(BgrtTable, BgrtTable->Header.Length);
739 }
740}

Referenced by BlDisplayClearScreen(), ConsoleEfiGopClose(), and ConsoleEfiGopEnable().

◆ BlDisplaySetCursorType()

NTSTATUS BlDisplaySetCursorType ( _In_ ULONG  Type)

Definition at line 969 of file display.c.

972{
974 PBL_TEXT_CONSOLE TextConsole;
976
977 /* Nothing to do if there's no text console */
979 TextConsole = DspTextConsole;
980 if (TextConsole)
981 {
982 /* Write visibility state and call the function to change it */
983 State.CursorVisible = Type;
984 Status = TextConsole->Callbacks->SetTextState(TextConsole, 8, &State);
985 }
986
987 /* All done */
988 return Status;
989}
Type
Definition: Type.h:7
PCONSOLE_SET_TEXT_STATE SetTextState
Definition: bl.h:1089

Referenced by BlXmiInitialize().

◆ BlDisplaySetScreenResolution()

NTSTATUS BlDisplaySetScreenResolution ( VOID  )

Definition at line 646 of file display.c.

649{
652
653 /* Assume success */
655
656 /* Do we have a graphics console? */
658 if (Console)
659 {
660 /* Is it currently active? */
661 if (((PBL_GRAPHICS_CONSOLE_VTABLE)Console->TextConsole.Callbacks)->IsEnabled(Console))
662 {
663 /* If so, disable it */
664 return ((PBL_GRAPHICS_CONSOLE_VTABLE)Console->TextConsole.Callbacks)->Enable(Console, FALSE);
665 }
666 }
667
668 /* We should've now fallen back to text mode */
669 if (!DspTextConsole)
670 {
671 /* Then fail, as no display appears active */
673 }
674
675 /* Return back to the caller */
676 return Status;
677}
CConsole Console

Referenced by BlResourceFindMessage(), and ResSelectLocale().

◆ BlDisplayValidOemBitmap()

BOOLEAN BlDisplayValidOemBitmap ( VOID  )

Definition at line 880 of file display.c.

883{
885 ULONG HRes, VRes, Height, Width, Flags;
886 COORD Offsets;
889
890 /* First check if mobile graphics are enabled */
893 &Result);
894 if ((NT_SUCCESS(Status)) && (Result))
895 {
896 /* Yes, so use the firmware image */
897 return TRUE;
898 }
899
900 /* Nope, so we'll check the ACPI OEM bitmap */
901 Result = FALSE;
902 Bitmap = BlDisplayGetOemBitmap(&Offsets, &Flags);
903
904 /* Is there one? */
905 if (Bitmap)
906 {
907 /* Is it valid? */
909 {
910 /* Get the current screen resolution */
911 Status = BlDisplayGetScreenResolution(&HRes, &VRes);
912 if (NT_SUCCESS(Status))
913 {
914 /* Is there a valid width? */
915 Width = Bitmap->DibHeader.Width;
916 if (Width)
917 {
918 /* Is there a valid height? */
919 Height = Bitmap->DibHeader.Height;
920 if (Height)
921 {
922 /* Will if fit on this screen? */
923 if (((Width + Offsets.X) <= HRes) &&
924 ((Height + Offsets.Y) <= VRes))
925 {
926 /* Then it's all good! */
927 Result = TRUE;
928 }
929 }
930 }
931 }
932 }
933
934 /* Unmap the bitmap for now, it will be drawn later */
935 BlMmUnmapVirtualAddressEx(Bitmap, Bitmap->BmpHeader.Size);
936 }
937
938 /* Return that a valid OEM bitmap exists */
939 return Result;
940}
unsigned char BOOLEAN
@ BcdLibraryBoolean_MobileGraphics
Definition: bcd.h:105
NTSTATUS BlGetBootOptionBoolean(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PBOOLEAN Value)
Definition: bcdopt.c:504
BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry
Definition: bootlib.c:19
NTSTATUS BlDisplayGetScreenResolution(_Out_ PULONG HRes, _Out_ PULONG VRes)
Definition: display.c:680
PBITMAP BlDisplayGetOemBitmap(_In_opt_ PCOORD Offsets, _Out_opt_ PULONG Flags)
Definition: display.c:743
#define TRUE
Definition: types.h:120
PBL_BCD_OPTION BcdData
Definition: bl.h:867
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by BmMain().

◆ BlpDisplayInitialize()

NTSTATUS BlpDisplayInitialize ( _In_ ULONG  Flags)

Definition at line 575 of file display.c.

578{
580
581 /* Are we resetting or initializing? */
583 {
584 /* This is a reset */
586 if (NT_SUCCESS(Status))
587 {
588 /* Re-initialize the class as well */
590 }
591 }
592 else
593 {
594 /* Initialize the display */
596 }
597
598 /* Return display initialization state */
599 return Status;
600}
#define BL_LIBRARY_FLAG_REINITIALIZE
Definition: bl.h:128
NTSTATUS BlpDisplayReinitialize(VOID)
Definition: display.c:542
NTSTATUS DsppInitialize(_In_ ULONG Flags)
Definition: display.c:256
NTSTATUS DsppReinitialize(_In_ ULONG Flags)
Definition: display.c:415

Referenced by BlInitializeLibrary(), and InitializeLibrary().

◆ BlpDisplayRegisterLocale()

NTSTATUS BlpDisplayRegisterLocale ( _In_ PWCHAR  Locale)

Definition at line 177 of file display.c.

180{
181 BOOLEAN StandardLocale;
183 PWCHAR FontFileName;
184 PBL_DEFERRED_FONT_FILE DeferredFont;
185 PLIST_ENTRY NextEntry;
186 WCHAR Prefix[3];
187
188 /* Assume custom locale */
189 StandardLocale = FALSE;
190
191 /* Bail out if the locale string seems invalid */
192 if (wcslen(Locale) < 2)
193 {
195 }
196
197 /* Check the prefix first, then traditional vs. simplified */
198 Prefix[0] = Locale[0];
199 Prefix[1] = Locale[1];
200 Prefix[2] = UNICODE_NULL;
201 if (!_wcsicmp(Prefix, L"ja"))
202 {
203 FontFileName = L"\\jpn_boot.ttf";
204 }
205 else if (!_wcsicmp(Prefix, L"ko"))
206 {
207 FontFileName = L"\\kor_boot.ttf";
208 }
209 else if (!(_wcsicmp(Locale, L"zh-CN")) ||
210 !(_wcsicmp(Locale, L"zh-CHS")) ||
211 !(_wcsicmp(Locale, L"zh-Hans")))
212 {
213 FontFileName = L"\\chs_boot.ttf";
214 }
215 else if (!(_wcsicmp(Locale, L"zh-TW")) &&
216 !(_wcsicmp(Locale, L"zh-CHT")) &&
217 !(_wcsicmp(Locale, L"zh-HK")) &&
218 !(_wcsicmp(Locale, L"zh-Hant")))
219 {
220 FontFileName = L"\\cht_boot.ttf";
221 }
222 else
223 {
224 StandardLocale = TRUE;
225 FontFileName = L"\\wgl4_boot.ttf";
226 }
227
228 /* Parse all the currently deferred fonts*/
229 NextEntry = BfiDeferredListHead.Flink;
230 while (NextEntry != &BfiDeferredListHead)
231 {
232 /* Grab the font */
233 DeferredFont = CONTAINING_RECORD(NextEntry, BL_DEFERRED_FONT_FILE, ListEntry);
234
235 /* Move to the next entry, and remove this one */
236 NextEntry = NextEntry->Flink;
237 RemoveEntryList(&DeferredFont->ListEntry);
238
239 /* Free the deferred font, we'll be loading a new one */
240 BfiFreeDeferredFontFile(DeferredFont);
241 }
242
243 /* Load the primary font */
244 Status = DsppLoadFontFile(FontFileName);
245 if (NT_SUCCESS(Status) && !(StandardLocale))
246 {
247 /* Also load the standard US one if we loaded a different one */
248 Status = DsppLoadFontFile(L"\\wgl4_boot.ttf");
249 }
250
251 /* Return back to caller */
252 return Status;
253}
VOID BfiFreeDeferredFontFile(_In_ PBL_DEFERRED_FONT_FILE DeferredFontFile)
Definition: font.c:30
NTSTATUS DsppLoadFontFile(_In_ PWCHAR FontFileName)
Definition: display.c:58
LIST_ENTRY BfiDeferredListHead
Definition: display.c:17
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
LIST_ENTRY ListEntry
Definition: bl.h:1299
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ __drv_aliasesMem PSTRING Prefix
Definition: rtlfuncs.h:1647
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ResSelectLocale().

◆ BlpDisplayReinitialize()

NTSTATUS BlpDisplayReinitialize ( VOID  )

Definition at line 542 of file display.c.

545{
547 PBL_TEXT_CONSOLE TextConsole;
548 PBL_INPUT_CONSOLE InputConsole;
549
550 /* Do we have a local console? */
551 InputConsole = DspLocalInputConsole;
552 if (InputConsole)
553 {
554 /* Reinitialize it */
555 Status = InputConsole->Callbacks->Reinitialize((PBL_TEXT_CONSOLE)InputConsole);
556 if (!NT_SUCCESS(Status))
557 {
558 return Status;
559 }
560 }
561
562 /* Do we have a text console? */
563 TextConsole = DspTextConsole;
564 if (TextConsole)
565 {
566 /* Reinitialize it */
567 Status = TextConsole->Callbacks->Reinitialize(TextConsole);
568 }
569
570 /* Return status */
571 return Status;
572}
PVOID DspLocalInputConsole
Definition: display.c:38
PCONSOLE_REINITIALIZE Reinitialize
Definition: bl.h:1122
PBL_INPUT_CONSOLE_VTABLE Callbacks
Definition: bl.h:1131
PCONSOLE_REINITIALIZE Reinitialize
Definition: bl.h:1087

Referenced by BlImgStartBootApplication(), and BlpDisplayInitialize().

◆ DsppGraphicsDisabledByBcd()

BOOLEAN DsppGraphicsDisabledByBcd ( VOID  )

Definition at line 43 of file display.c.

46{
49
50 /* Get the boot option, and if present, return the result */
53 &Disabled);
54 return (NT_SUCCESS(Status) && (Disabled));
55}
@ BcdLibraryBoolean_GraphicsModeDisabled
Definition: bcd.h:86
@ Disabled
Definition: mountmgr.h:178

Referenced by DsppInitialize(), and DsppReinitialize().

◆ DsppInitialize()

NTSTATUS DsppInitialize ( _In_ ULONG  Flags)

Definition at line 256 of file display.c.

259{
261 BOOLEAN NoGraphics, HighestMode;
264 ULONGLONG GraphicsResolution;
265 PBL_GRAPHICS_CONSOLE GraphicsConsole;
266 PBL_TEXT_CONSOLE TextConsole, RemoteConsole;
267
268 /* Initialize font data */
272
273 /* Allocate the font rectangle */
276 {
277 return STATUS_NO_MEMORY;
278 }
279
280 /* Check if display re-initialization is requested */
281 if (LibraryParameters.LibraryFlags & BL_LIBRARY_FLAG_REINITIALIZE_ALL)
282 {
283 /* Recreate a local input console */
285 }
286
287 /* Check if no graphics console is needed */
290 {
291 /* Remember this */
292 NoGraphics = TRUE;
293 }
294 else
295 {
296 /* No graphics -- remember this */
297 NoGraphics = FALSE;
298 }
299
300 /* On first load, we always initialize a graphics display */
301 GraphicsConsole = NULL;
302 if (!(Flags & BL_LIBRARY_FLAG_REINITIALIZE_ALL) || !(NoGraphics))
303 {
304 /* Default to mode 0 (1024x768) */
306
307 /* Check what resolution to use*/
310 &GraphicsResolution);
311 if (NT_SUCCESS(Status))
312 {
314 EfiPrintf(L"Display selection not yet handled\r\n");
316 }
317
318 /* Check if the highest mode should be forced */
321 &HighestMode);
322 if (NT_SUCCESS(Status))
323 {
325 EfiPrintf(L"High res mode not yet handled\r\n");
327 }
328
329 /* Do we need graphics mode after all? */
330 if (!NoGraphics)
331 {
332 /* Yep -- go allocate it */
333 GraphicsConsole = BlMmAllocateHeap(sizeof(*GraphicsConsole));
334 if (GraphicsConsole)
335 {
336 /* Construct it */
337 Status = ConsoleGraphicalConstruct(GraphicsConsole);
338 if (!NT_SUCCESS(Status))
339 {
340 EfiPrintf(L"GFX FAILED: %lx\r\n", Status);
341 BlMmFreeHeap(GraphicsConsole);
342 GraphicsConsole = NULL;
343 }
344 }
345 }
346
347 /* Are we using something else than the default mode? */
349 {
350 EfiPrintf(L"Display path not handled\r\n");
352 }
353
354 /* Mask out all the flags now */
357 }
358
359 /* Do we have a graphics console? */
360 TextConsole = NULL;
361 if (!GraphicsConsole)
362 {
363 /* Nope -- go allocate a text console */
364 TextConsole = BlMmAllocateHeap(sizeof(*TextConsole));
365 if (TextConsole)
366 {
367 /* Construct it */
368 Status = ConsoleTextLocalConstruct(TextConsole, TRUE);
369 if (!NT_SUCCESS(Status))
370 {
371 BlMmFreeHeap(TextConsole);
372 TextConsole = NULL;
373 }
374 }
375 }
376
377 /* Initialize all globals to NULL */
381
382 /* If we don't have a text console, go get a remote console */
383 RemoteConsole = NULL;
384 if (!TextConsole)
385 {
386 ConsoleCreateRemoteConsole(&RemoteConsole);
387 }
388
389 /* Do we have a remote console? */
390 if (!RemoteConsole)
391 {
392 /* Nope -- what about a graphical one? */
393 if (GraphicsConsole)
394 {
395 /* Yes, use it for both graphics and text */
396 DspGraphicalConsole = GraphicsConsole;
397 DspTextConsole = GraphicsConsole;
398 }
399 else if (TextConsole)
400 {
401 /* Nope, but we have a text console */
402 DspTextConsole = TextConsole;
403 }
404
405 /* Console has been setup */
406 return STATUS_SUCCESS;
407 }
408
409 /* We have a remote console -- have to figure out how to use it*/
410 EfiPrintf(L"Display path not handled\r\n");
412}
@ BcdLibraryInteger_GraphicsResolution
Definition: bcd.h:94
@ BcdLibraryBoolean_GraphicsForceHighestMode
Definition: bcd.h:99
NTSTATUS ConsoleCreateRemoteConsole(_In_ PBL_TEXT_CONSOLE *TextConsole)
Definition: emscons.c:31
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
NTSTATUS ConsoleCreateLocalInputConsole(VOID)
Definition: textcons.c:243
NTSTATUS ConsoleGraphicalConstruct(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:58
#define BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
Definition: bl.h:135
BL_LIBRARY_PARAMETERS BlpLibraryParameters
Definition: bootlib.c:15
#define BL_LIBRARY_FLAG_REINITIALIZE_ALL
Definition: bl.h:129
NTSTATUS ConsoleTextLocalConstruct(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ BOOLEAN Activate)
Definition: textcons.c:104
#define BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE
Definition: bl.h:132
#define BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
Definition: bl.h:134
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
NTSTATUS BlGetBootOptionInteger(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PULONGLONG Value)
Definition: bcdopt.c:467
BL_DISPLAY_MODE ConsoleGraphicalResolutionList[3]
Definition: display.c:22
LIST_ENTRY BfiFontFileListHead
Definition: display.c:18
PVOID BfiGraphicsRectangle
Definition: display.c:19
BOOLEAN DsppGraphicsDisabledByBcd(VOID)
Definition: display.c:43
PVOID BfiCachedStrikeData
Definition: display.c:16
ULONG ConsoleGraphicalResolutionListFlags
Definition: display.c:21
PVOID DspRemoteInputConsole
Definition: display.c:35
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117
ULONG LibraryFlags
Definition: bl.h:757
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by BlpDisplayInitialize().

◆ DsppLoadFontFile()

NTSTATUS DsppLoadFontFile ( _In_ PWCHAR  FontFileName)

Definition at line 58 of file display.c.

61{
62 PBL_DEVICE_DESCRIPTOR FontDevice;
64 SIZE_T NameLength, DirectoryLength, TotalLength;
65 PWCHAR FontPath, FontDirectory;
66 BL_LIBRARY_PARAMETERS LibraryParameters;
67 BOOLEAN CustomDirectory, CustomDevice;
68
69 /* Initialize locals */
70 CustomDirectory = TRUE;
71 CustomDevice = TRUE;
72 FontDevice = NULL;
73 FontPath = NULL;
74 FontDirectory = NULL;
75
76 /* Check if a custom font path should be used */
79 &FontDirectory);
80 if (!NT_SUCCESS(Status))
81 {
82 /* Nope, use the one configured by the library */
83 CustomDirectory = FALSE;
84 RtlCopyMemory(&LibraryParameters,
86 sizeof(LibraryParameters)),
87 FontDirectory = LibraryParameters.FontBaseDirectory;
88 }
89
90 /* Do we still not have a font directory? */
91 if (!FontDirectory)
92 {
93 /* Use the boot device and boot directory */
94 CustomDevice = FALSE;
95 FontDevice = BlpBootDevice;
96 FontDirectory = L"\\EFI\\Microsoft\\Boot\\Fonts";
97 }
98 else
99 {
100 /* Otherwise, if we have a font directory, what device is the app on? */
103 &FontDevice,
104 NULL);
105 if (!NT_SUCCESS(Status))
106 {
107 /* If we don't know the device, we can't open the path */
108 goto Quickie;
109 }
110 }
111
112 /* Figure out the length of the file name, and of the directory */
113 NameLength = wcslen(FontFileName);
114 DirectoryLength = wcslen(FontDirectory);
115
116 /* Safely add them up*/
117 Status = RtlSIZETAdd(NameLength, DirectoryLength, &TotalLength);
118 if (!NT_SUCCESS(Status))
119 {
120 goto Quickie;
121 }
122
123 /* Convert to bytes */
124 Status = RtlSIZETMult(TotalLength, sizeof(WCHAR), &TotalLength);
125 if (!NT_SUCCESS(Status))
126 {
127 goto Quickie;
128 }
129
130 /* Add a terminating NUL */
131 Status = RtlSIZETAdd(TotalLength, sizeof(UNICODE_NULL), &TotalLength);
132 if (!NT_SUCCESS(Status))
133 {
134 goto Quickie;
135 }
136
137 /* Allocate the final buffer for it */
138 FontPath = BlMmAllocateHeap(TotalLength);
139 if (!FontPath)
140 {
142 goto Quickie;
143 }
144
145 /* Concatenate the directory with the file name */
146 wcscpy(FontPath, FontDirectory);
147 wcscat(FontPath, FontFileName);
148
149 /* Try to load this font */
150 Status = BfLoadFontFile(FontDevice, FontPath);
151
152Quickie:
153 /* Check if we had a custom font device allocated and free it */
154 if ((CustomDevice) && (FontDevice))
155 {
156 BlMmFreeHeap(FontDevice);
157 }
158
159 /* Check if we had a custom font directory allocated and free it */
160 if ((CustomDirectory) && (CustomDevice))
161 {
162 ASSERT(FontDirectory);
163 BlMmFreeHeap(FontDirectory);
164 }
165
166 /* Check if we had allocated a font path and free it */
167 if (FontPath)
168 {
169 BlMmFreeHeap(FontPath);
170 }
171
172 /* Return back */
173 return Status;
174}
@ BcdLibraryString_FontPath
Definition: bcd.h:90
@ BcdLibraryDevice_ApplicationDevice
Definition: bcd.h:50
NTSTATUS BlGetBootOptionDevice(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PBL_DEVICE_DESCRIPTOR *Value, _In_opt_ PBL_BCD_OPTION *ExtraOptions)
Definition: bcdopt.c:321
PBL_DEVICE_DESCRIPTOR BlpBootDevice
Definition: bootlib.c:16
NTSTATUS BfLoadFontFile(_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ PWCHAR FontPath)
Definition: font.c:51
NTSTATUS BlGetBootOptionString(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PWCHAR *Value)
Definition: bcdopt.c:146
#define ASSERT(a)
Definition: mode.c:44
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
PWCHAR FontBaseDirectory
Definition: bl.h:764
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ ULONG TotalLength
Definition: usbdlib.h:158

Referenced by BlpDisplayRegisterLocale().

◆ DsppReinitialize()

NTSTATUS DsppReinitialize ( _In_ ULONG  Flags)

Definition at line 415 of file display.c.

418{
419 PBL_TEXT_CONSOLE TextConsole;
420 PBL_GRAPHICS_CONSOLE GraphicsConsole;
422 ULONGLONG GraphicsResolution;
423 BOOLEAN HighestMode;
424 BL_DISPLAY_MODE CurrentResolution;
425
426 /* Do we have local input yet? */
428 {
429 /* Create it now */
431 }
432
433 /* If a graphics console is present without a remote console... */
434 TextConsole = NULL;
436 {
437 /* Try to create a remote console */
438 ConsoleCreateRemoteConsole(&TextConsole);
439 }
440
441 /* All good for now */
443
444 /* Now check if we were able to create the remote console */
445 if (TextConsole)
446 {
447 EfiPrintf(L"EMS not supported\r\n");
449 }
450
451 /* Set a local for the right cast */
452 GraphicsConsole = DspGraphicalConsole;
453
454 /* Nothing to do without a graphics console being reinitialized */
456 !(GraphicsConsole) ||
457 !(((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->IsEnabled(GraphicsConsole)))
458 {
459 return Status;
460 }
461
462 /* Check if graphics are disabled in the BCD */
464 {
465 /* Turn off the graphics console, switching back to text mode */
466 Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->Enable(GraphicsConsole, FALSE);
467 }
468
469 /* Check if a custom graphics resolution is set */
472 {
473 /* Check what it's set to */
476 &GraphicsResolution);
477 if (!NT_SUCCESS(Status))
478 {
479 return Status;
480 }
481
482 /* Now check our current graphical resolution */
483 Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->GetGraphicalResolution(GraphicsConsole,
484 &CurrentResolution);
485 if (!NT_SUCCESS(Status))
486 {
487 return Status;
488 }
489
490 /* Remember that we're forcing a video mode */
492
493 /* Check which resolution to set */
494 if (!GraphicsResolution)
495 {
496 /* 1024x768 */
497 EfiPrintf(L"Display selection not yet handled\r\n");
499 }
500 else if (GraphicsResolution == 1)
501 {
502 /* 800x600 */
503 EfiPrintf(L"Display selection not yet handled\r\n");
505 }
506 else if (GraphicsResolution == 2)
507 {
508 /* 1024x600 */
509 EfiPrintf(L"Display selection not yet handled\r\n");
511 }
512 }
513
514 /* Check if the force highest mode setting is present */
517 {
518 /* Check what it's set to */
521 &HighestMode);
522 if ((NT_SUCCESS(Status)) && (HighestMode))
523 {
524 /* Remember that high rest mode is being forced */
526
527 /* Turn it on */
528 //((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->SetGraphicalResolution(GraphicsConsole, 0, 0);
529
530 /* All done now */
531 ConsoleGraphicalResolutionListFlags |= ~BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG;
532 EfiPrintf(L"High res mode not yet handled\r\n");
534 }
535 }
536
537 /* Return back to the caller */
538 return Status;
539}
PBL_BCD_OPTION MiscGetBootOption(_In_ PBL_BCD_OPTION List, _In_ ULONG Type)
Definition: bcdopt.c:17

Referenced by BlpDisplayInitialize().

Variable Documentation

◆ BfiCachedStrikeData

PVOID BfiCachedStrikeData

Definition at line 16 of file display.c.

Referenced by DsppInitialize().

◆ BfiDeferredListHead

LIST_ENTRY BfiDeferredListHead

Definition at line 17 of file display.c.

Referenced by BlpDisplayRegisterLocale(), and DsppInitialize().

◆ BfiFontFileListHead

LIST_ENTRY BfiFontFileListHead

Definition at line 18 of file display.c.

Referenced by DsppInitialize().

◆ BfiGraphicsRectangle

PVOID BfiGraphicsRectangle

Definition at line 19 of file display.c.

Referenced by DsppInitialize().

◆ ConsoleGraphicalResolutionList

BL_DISPLAY_MODE ConsoleGraphicalResolutionList[3]
Initial value:
=
{
{1024, 768, 1024},
{800, 600, 800},
{1024, 600, 1024}
}

Definition at line 22 of file display.c.

Referenced by ConsoleEfiGopOpen(), and DsppInitialize().

◆ ConsoleGraphicalResolutionListFlags

ULONG ConsoleGraphicalResolutionListFlags

Definition at line 21 of file display.c.

Referenced by ConsoleEfiGopOpen(), DsppInitialize(), and DsppReinitialize().

◆ ConsoleGraphicalResolutionListSize

ULONG ConsoleGraphicalResolutionListSize = RTL_NUMBER_OF(ConsoleGraphicalResolutionList)

Definition at line 28 of file display.c.

Referenced by ConsoleEfiGopOpen().

◆ ConsoleTextResolutionList

BL_DISPLAY_MODE ConsoleTextResolutionList[1]
Initial value:
=
{
{80, 25, 80}
}

Definition at line 30 of file display.c.

Referenced by ConsoleFirmwareTextOpen().

◆ DspGraphicalConsole

◆ DspLocalInputConsole

PVOID DspLocalInputConsole

◆ DspRemoteInputConsole

PVOID DspRemoteInputConsole

Definition at line 35 of file display.c.

Referenced by ConsoleCreateRemoteConsole(), DsppInitialize(), and DsppReinitialize().

◆ DspTextConsole