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 15 LIST_ENTRY BfiDeferredListHead; 16 17 /* FUNCTIONS *****************************************************************/ 18 19 NTSTATUS 20 BfiLoadFontFile ( 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); 26 return STATUS_NOT_IMPLEMENTED; 27 } 28 29 VOID 30 BfiFreeDeferredFontFile ( 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 50 NTSTATUS 51 BfLoadFontFile ( 52 _In_ PBL_DEVICE_DESCRIPTOR Device, 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 */ 94 InsertTailList(&BfiDeferredListHead, &DeferredFont->ListEntry); 95 return STATUS_SUCCESS; 96 } 97 98 NTSTATUS 99 BfLoadDeferredFontFiles ( 100 VOID 101 ) 102 { 103 PLIST_ENTRY NextEntry; 104 PBL_DEFERRED_FONT_FILE DeferredFont; 105 NTSTATUS Status, LoadStatus; 106 107 /* Assume empty list */ 108 Status = STATUS_SUCCESS; 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 139 BfiFlipCursorCharacter ( 140 _In_ PBL_GRAPHICS_CONSOLE Console, 141 _In_ BOOLEAN Visible 142 ) 143 { 144 /* not implemented */ 145 return STATUS_NOT_IMPLEMENTED; 146 } 147 148 NTSTATUS 149 BfClearToEndOfLine ( 150 _In_ PBL_GRAPHICS_CONSOLE Console 151 ) 152 { 153 /* not implemented */ 154 return STATUS_NOT_IMPLEMENTED; 155 } 156 157 NTSTATUS 158 BfClearScreen ( 159 _In_ PBL_GRAPHICS_CONSOLE Console 160 ) 161 { 162 NTSTATUS Status; 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 */ 169 Status = ConsoleGraphicalClearPixels(Console, 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 */ 180 if (!IsListEmpty(&BfiDeferredListHead)) 181 { 182 BfLoadDeferredFontFiles(); 183 } 184 185 /* Switch the cursor to visible */ 186 Status = BfiFlipCursorCharacter(Console, TRUE); 187 } 188 else 189 { 190 /* Nothing left to do */ 191 Status = STATUS_SUCCESS; 192 } 193 194 /* Return cursor flip result, if any */ 195 return Status; 196 } 197