ReactOS  0.4.15-dev-489-g75a0787
font.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING.ARM in the top level directory
3  * PROJECT: ReactOS UEFI Boot Library
4  * FILE: boot/environ/lib/misc/font.c
5  * PURPOSE: Boot Library Font Functions
6  * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include "bl.h"
12 
13 /* DATA VARIABLES ************************************************************/
14 
16 
17 /* FUNCTIONS *****************************************************************/
18 
21  _In_ PBL_DEVICE_DESCRIPTOR FontDevice,
22  _In_ PWCHAR FontPath
23  )
24 {
25  EfiPrintf(L"Cannot load font %s, no font loader exists\r\n", FontPath);
27 }
28 
29 VOID
31  _In_ PBL_DEFERRED_FONT_FILE DeferredFontFile
32  )
33 {
34  /* Free the device copy if there was one */
35  if (DeferredFontFile->Device)
36  {
37  BlMmFreeHeap(DeferredFontFile->Device);
38  }
39 
40  /* Free the path copy if there was one */
41  if (DeferredFontFile->FontPath)
42  {
43  BlMmFreeHeap(DeferredFontFile->FontPath);
44  }
45 
46  /* Free the whole thing */
47  BlMmFreeHeap(DeferredFontFile);
48 }
49 
53  _In_ PWCHAR FontPath
54  )
55 {
56  PBL_DEFERRED_FONT_FILE DeferredFont;
57  SIZE_T FontPathSize;
58 
59  /* Allocate the deferred font structure */
60  DeferredFont = (PBL_DEFERRED_FONT_FILE)BlMmAllocateHeap(sizeof(*DeferredFont));
61  if (!DeferredFont)
62  {
63  return STATUS_NO_MEMORY;
64  }
65 
66  /* Zero it out */
67  RtlZeroMemory(DeferredFont, sizeof(*DeferredFont));
68 
69  /* Allocate a copy for the file path */
70  FontPathSize = sizeof(WCHAR) * wcslen(FontPath) + sizeof(UNICODE_NULL);
71  DeferredFont->FontPath = (PWCHAR)BlMmAllocateHeap(FontPathSize);
72  if (!DeferredFont->FontPath)
73  {
74  BfiFreeDeferredFontFile(DeferredFont);
75  return STATUS_NO_MEMORY;
76  }
77 
78  /* Allocate a copy for the device */
79  DeferredFont->Device = BlMmAllocateHeap(Device->Size);
80  if (!DeferredFont->Device)
81  {
82  BfiFreeDeferredFontFile(DeferredFont);
83  return STATUS_NO_MEMORY;
84  }
85 
86  /* Copy the path and device */
87  RtlCopyMemory(DeferredFont->FontPath, FontPath, FontPathSize);
88  RtlCopyMemory(DeferredFont->Device,Device, Device->Size);
89 
90  /* Set pending flag? */
91  DeferredFont->Flags = 1;
92 
93  /* Insert it into the list */
95  return STATUS_SUCCESS;
96 }
97 
100  VOID
101  )
102 {
103  PLIST_ENTRY NextEntry;
104  PBL_DEFERRED_FONT_FILE DeferredFont;
105  NTSTATUS Status, LoadStatus;
106 
107  /* Assume empty list */
109 
110  /* Parse the list */
111  NextEntry = BfiDeferredListHead.Flink;
112  while (NextEntry != &BfiDeferredListHead)
113  {
114  /* Get the font */
115  DeferredFont = CONTAINING_RECORD(NextEntry, BL_DEFERRED_FONT_FILE, ListEntry);
116 
117  /* Move to the next entry and remove this one */
118  NextEntry = NextEntry->Flink;
119  RemoveEntryList(&DeferredFont->ListEntry);
120 
121  /* Load the font */
122  LoadStatus = BfiLoadFontFile(DeferredFont->Device,
123  DeferredFont->FontPath);
124  if (!NT_SUCCESS(LoadStatus))
125  {
126  /* Remember the load failure if there was one */
127  Status = LoadStatus;
128  }
129 
130  /* Free the deferred font */
131  BfiFreeDeferredFontFile(DeferredFont);
132  }
133 
134  /* Return load status */
135  return Status;
136 }
137 
138 NTSTATUS
141  _In_ BOOLEAN Visible
142  )
143 {
144  /* not implemented */
145  return STATUS_NOT_IMPLEMENTED;
146 }
147 
148 NTSTATUS
151  )
152 {
153  /* not implemented */
154  return STATUS_NOT_IMPLEMENTED;
155 }
156 
157 NTSTATUS
160  )
161 {
163 
164  /* Reset the cursor position */
165  Console->TextConsole.State.XPos = 0;
166  Console->TextConsole.State.YPos = 0;
167 
168  /* Fill the screen with the background color */
170  Console->TextConsole.State.BgColor);
171  if (!NT_SUCCESS(Status))
172  {
173  return Status;
174  }
175 
176  /* Check if the cursor should be visible */
177  if (Console->TextConsole.State.CursorVisible)
178  {
179  /* Load any fonts at this time */
181  {
183  }
184 
185  /* Switch the cursor to visible */
187  }
188  else
189  {
190  /* Nothing left to do */
192  }
193 
194  /* Return cursor flip result, if any */
195  return Status;
196 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2029
LIST_ENTRY BfiDeferredListHead
Definition: font.c:15
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
VOID BfiFreeDeferredFontFile(_In_ PBL_DEFERRED_FONT_FILE DeferredFontFile)
Definition: font.c:30
uint16_t * PWCHAR
Definition: typedefs.h:55
#define InsertTailList(ListHead, Entry)
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
LIST_ENTRY ListEntry
Definition: bl.h:1300
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
NTSTATUS BfClearScreen(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:158
#define UNICODE_NULL
unsigned char BOOLEAN
NTSTATUS ConsoleGraphicalClearPixels(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
Definition: guicons.c:275
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
PBL_DEVICE_DESCRIPTOR Device
Definition: bl.h:1302
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS BfLoadFontFile(_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ PWCHAR FontPath)
Definition: font.c:51
NTSTATUS BfiLoadFontFile(_In_ PBL_DEVICE_DESCRIPTOR FontDevice, _In_ PWCHAR FontPath)
Definition: font.c:20
struct _BL_DEFERRED_FONT_FILE * PBL_DEFERRED_FONT_FILE
Definition: typedefs.h:118
Status
Definition: gdiplustypes.h:24
NTSTATUS BfiFlipCursorCharacter(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN Visible)
Definition: font.c:139
#define _In_
Definition: no_sal2.h:204
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
CConsole Console
NTSTATUS BfLoadDeferredFontFiles(VOID)
Definition: font.c:99
NTSTATUS BfClearToEndOfLine(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:149
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:3014
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)