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)
9 /* INCLUDES ******************************************************************/
13 /* DATA VARIABLES ************************************************************/
15 LIST_ENTRY BfiDeferredListHead
;
17 /* FUNCTIONS *****************************************************************/
21 _In_ PBL_DEVICE_DESCRIPTOR FontDevice
,
25 EfiPrintf(L
"Cannot load font %s, no font loader exists\r\n", FontPath
);
26 return STATUS_NOT_IMPLEMENTED
;
30 BfiFreeDeferredFontFile (
31 _In_ PBL_DEFERRED_FONT_FILE DeferredFontFile
34 /* Free the device copy if there was one */
35 if (DeferredFontFile
->Device
)
37 BlMmFreeHeap(DeferredFontFile
->Device
);
40 /* Free the path copy if there was one */
41 if (DeferredFontFile
->FontPath
)
43 BlMmFreeHeap(DeferredFontFile
->FontPath
);
46 /* Free the whole thing */
47 BlMmFreeHeap(DeferredFontFile
);
52 _In_ PBL_DEVICE_DESCRIPTOR Device
,
56 PBL_DEFERRED_FONT_FILE DeferredFont
;
59 /* Allocate the deferred font structure */
60 DeferredFont
= (PBL_DEFERRED_FONT_FILE
)BlMmAllocateHeap(sizeof(*DeferredFont
));
63 return STATUS_NO_MEMORY
;
67 RtlZeroMemory(DeferredFont
, sizeof(*DeferredFont
));
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
)
74 BfiFreeDeferredFontFile(DeferredFont
);
75 return STATUS_NO_MEMORY
;
78 /* Allocate a copy for the device */
79 DeferredFont
->Device
= BlMmAllocateHeap(Device
->Size
);
80 if (!DeferredFont
->Device
)
82 BfiFreeDeferredFontFile(DeferredFont
);
83 return STATUS_NO_MEMORY
;
86 /* Copy the path and device */
87 RtlCopyMemory(DeferredFont
->FontPath
, FontPath
, FontPathSize
);
88 RtlCopyMemory(DeferredFont
->Device
,Device
, Device
->Size
);
90 /* Set pending flag? */
91 DeferredFont
->Flags
= 1;
93 /* Insert it into the list */
94 InsertTailList(&BfiDeferredListHead
, &DeferredFont
->ListEntry
);
95 return STATUS_SUCCESS
;
99 BfLoadDeferredFontFiles (
103 PLIST_ENTRY NextEntry
;
104 PBL_DEFERRED_FONT_FILE DeferredFont
;
105 NTSTATUS Status
, LoadStatus
;
107 /* Assume empty list */
108 Status
= STATUS_SUCCESS
;
111 NextEntry
= BfiDeferredListHead
.Flink
;
112 while (NextEntry
!= &BfiDeferredListHead
)
115 DeferredFont
= CONTAINING_RECORD(NextEntry
, BL_DEFERRED_FONT_FILE
, ListEntry
);
117 /* Move to the next entry and remove this one */
118 NextEntry
= NextEntry
->Flink
;
119 RemoveEntryList(&DeferredFont
->ListEntry
);
122 LoadStatus
= BfiLoadFontFile(DeferredFont
->Device
,
123 DeferredFont
->FontPath
);
124 if (!NT_SUCCESS(LoadStatus
))
126 /* Remember the load failure if there was one */
130 /* Free the deferred font */
131 BfiFreeDeferredFontFile(DeferredFont
);
134 /* Return load status */
139 BfiFlipCursorCharacter (
140 _In_ PBL_GRAPHICS_CONSOLE Console
,
144 /* not implemented */
145 return STATUS_NOT_IMPLEMENTED
;
150 _In_ PBL_GRAPHICS_CONSOLE Console
153 /* not implemented */
154 return STATUS_NOT_IMPLEMENTED
;
159 _In_ PBL_GRAPHICS_CONSOLE Console
164 /* Reset the cursor position */
165 Console
->TextConsole
.State
.XPos
= 0;
166 Console
->TextConsole
.State
.YPos
= 0;
168 /* Fill the screen with the background color */
169 Status
= ConsoleGraphicalClearPixels(Console
,
170 Console
->TextConsole
.State
.BgColor
);
171 if (!NT_SUCCESS(Status
))
176 /* Check if the cursor should be visible */
177 if (Console
->TextConsole
.State
.CursorVisible
)
179 /* Load any fonts at this time */
180 if (!IsListEmpty(&BfiDeferredListHead
))
182 BfLoadDeferredFontFiles();
185 /* Switch the cursor to visible */
186 Status
= BfiFlipCursorCharacter(Console
, TRUE
);
190 /* Nothing left to do */
191 Status
= STATUS_SUCCESS
;
194 /* Return cursor flip result, if any */