]> code.delx.au - refind/blob - libeg/screen.c
Support for loading fonts (as PNG files); new default font.
[refind] / libeg / screen.c
1 /*
2 * libeg/screen.c
3 * Screen handling functions
4 *
5 * Copyright (c) 2006 Christoph Pfisterer
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * Neither the name of Christoph Pfisterer nor the names of the
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36 /*
37 * Modifications copyright (c) 2012 Roderick W. Smith
38 *
39 * Modifications distributed under the terms of the GNU General Public
40 * License (GPL) version 3 (GPLv3), a copy of which must be distributed
41 * with this source code or binaries made from it.
42 *
43 */
44
45 #include "libegint.h"
46 #include "../refind/screen.h"
47 #include "../refind/lib.h"
48 #include "../include/refit_call_wrapper.h"
49
50 #include <efiUgaDraw.h>
51 #include <efiConsoleControl.h>
52
53 #ifndef __MAKEWITH_GNUEFI
54 #define LibLocateProtocol EfiLibLocateProtocol
55 #endif
56
57 // Console defines and variables
58
59 static EFI_GUID ConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
60 static EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL;
61
62 static EFI_GUID UgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID;
63 static EFI_UGA_DRAW_PROTOCOL *UgaDraw = NULL;
64
65 static EFI_GUID GraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
66 static EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL;
67
68 static BOOLEAN egHasGraphics = FALSE;
69 static UINTN egScreenWidth = 800;
70 static UINTN egScreenHeight = 600;
71
72 //
73 // Screen handling
74 //
75
76 // Make the necessary system calls to identify the current graphics mode.
77 // Stores the results in the file-global variables egScreenWidth,
78 // egScreenHeight, and egHasGraphics. The first two of these will be
79 // unchanged if neither GraphicsOutput nor UgaDraw is a valid pointer.
80 static VOID egDetermineScreenSize(VOID) {
81 EFI_STATUS Status = EFI_SUCCESS;
82 UINT32 UGAWidth, UGAHeight, UGADepth, UGARefreshRate;
83
84 // get screen size
85 egHasGraphics = FALSE;
86 if (GraphicsOutput != NULL) {
87 egScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution;
88 egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution;
89 egHasGraphics = TRUE;
90 } else if (UgaDraw != NULL) {
91 Status = refit_call5_wrapper(UgaDraw->GetMode, UgaDraw, &UGAWidth, &UGAHeight, &UGADepth, &UGARefreshRate);
92 if (EFI_ERROR(Status)) {
93 UgaDraw = NULL; // graphics not available
94 } else {
95 egScreenWidth = UGAWidth;
96 egScreenHeight = UGAHeight;
97 egHasGraphics = TRUE;
98 }
99 }
100 } // static VOID egDetermineScreenSize()
101
102 VOID egGetScreenSize(OUT UINTN *ScreenWidth, OUT UINTN *ScreenHeight)
103 {
104 egDetermineScreenSize();
105
106 if (ScreenWidth != NULL)
107 *ScreenWidth = egScreenWidth;
108 if (ScreenHeight != NULL)
109 *ScreenHeight = egScreenHeight;
110 }
111
112 VOID egInitScreen(VOID)
113 {
114 EFI_STATUS Status = EFI_SUCCESS;
115
116 // get protocols
117 Status = LibLocateProtocol(&ConsoleControlProtocolGuid, (VOID **) &ConsoleControl);
118 if (EFI_ERROR(Status))
119 ConsoleControl = NULL;
120
121 Status = LibLocateProtocol(&UgaDrawProtocolGuid, (VOID **) &UgaDraw);
122 if (EFI_ERROR(Status))
123 UgaDraw = NULL;
124
125 Status = LibLocateProtocol(&GraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
126 if (EFI_ERROR(Status))
127 GraphicsOutput = NULL;
128
129 egDetermineScreenSize();
130 }
131
132 // Convert a graphics mode (in *ModeWidth) to a width and height (returned in
133 // *ModeWidth and *Height, respectively).
134 // Returns TRUE if successful, FALSE if not (invalid mode, typically)
135 BOOLEAN egGetResFromMode(UINTN *ModeWidth, UINTN *Height) {
136 UINTN Size;
137 EFI_STATUS Status;
138 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info = NULL;
139
140 if ((ModeWidth != NULL) && (Height != NULL)) {
141 Status = refit_call4_wrapper(GraphicsOutput->QueryMode, GraphicsOutput, *ModeWidth, &Size, &Info);
142 if ((Status == EFI_SUCCESS) && (Info != NULL)) {
143 *ModeWidth = Info->HorizontalResolution;
144 *Height = Info->VerticalResolution;
145 return TRUE;
146 }
147 }
148 return FALSE;
149 } // BOOLEAN egGetResFromMode()
150
151 // Sets the screen resolution to the specified value, if possible. If *ScreenHeight
152 // is 0 and GOP mode is detected, assume that *ScreenWidth contains a GOP mode
153 // number rather than a horizontal resolution. If the specified resolution is not
154 // valid, displays a warning with the valid modes on GOP (UEFI) systems, or silently
155 // fails on UGA (EFI 1.x) systems. Note that this function attempts to set ANY screen
156 // resolution, even 0x0 or ridiculously large values.
157 // Upon success, returns actual screen resolution in *ScreenWidth and *ScreenHeight.
158 // These values are unchanged upon failure.
159 // Returns TRUE if successful, FALSE if not.
160 BOOLEAN egSetScreenSize(IN OUT UINTN *ScreenWidth, IN OUT UINTN *ScreenHeight) {
161 EFI_STATUS Status = EFI_SUCCESS;
162 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
163 UINTN Size;
164 UINT32 ModeNum = 0;
165 UINT32 UGAWidth, UGAHeight, UGADepth, UGARefreshRate;
166 BOOLEAN ModeSet = FALSE;
167
168 if ((ScreenWidth == NULL) || (ScreenHeight == NULL))
169 return FALSE;
170
171 if (GraphicsOutput != NULL) { // GOP mode (UEFI)
172 if (*ScreenHeight == 0) { // User specified a mode number (stored in *ScreenWidth); use it directly
173 ModeNum = (UINT32) *ScreenWidth;
174 if (egGetResFromMode(ScreenWidth, ScreenHeight) &&
175 (refit_call2_wrapper(GraphicsOutput->SetMode, GraphicsOutput, ModeNum) == EFI_SUCCESS)) {
176 ModeSet = TRUE;
177 }
178
179 // User specified width & height; must find mode...
180 } else {
181 // Do a loop through the modes to see if the specified one is available;
182 // and if so, switch to it....
183 do {
184 Status = refit_call4_wrapper(GraphicsOutput->QueryMode, GraphicsOutput, ModeNum, &Size, &Info);
185 if ((Status == EFI_SUCCESS) && (Size >= sizeof(*Info) && (Info != NULL)) &&
186 (Info->HorizontalResolution == *ScreenWidth) && (Info->VerticalResolution == *ScreenHeight)) {
187 Status = refit_call2_wrapper(GraphicsOutput->SetMode, GraphicsOutput, ModeNum);
188 ModeSet = (Status == EFI_SUCCESS);
189 } // if
190 } while ((++ModeNum < GraphicsOutput->Mode->MaxMode) && !ModeSet);
191 } // if/else
192
193 if (ModeSet) {
194 egScreenWidth = *ScreenWidth;
195 egScreenHeight = *ScreenHeight;
196 } else {// If unsuccessful, display an error message for the user....
197 SwitchToText(FALSE);
198 Print(L"Error setting graphics mode %d x %d; using default mode!\nAvailable modes are:\n", *ScreenWidth, *ScreenHeight);
199 ModeNum = 0;
200 do {
201 Status = refit_call4_wrapper(GraphicsOutput->QueryMode, GraphicsOutput, ModeNum, &Size, &Info);
202 if ((Status == EFI_SUCCESS) && (Info != NULL)) {
203 Print(L"Mode %d: %d x %d\n", ModeNum, Info->HorizontalResolution, Info->VerticalResolution);
204 } // else
205 } while (++ModeNum < GraphicsOutput->Mode->MaxMode);
206 PauseForKey();
207 SwitchToGraphics();
208 } // if GOP mode (UEFI)
209
210 } else if (UgaDraw != NULL) { // UGA mode (EFI 1.x)
211 // Try to use current color depth & refresh rate for new mode. Maybe not the best choice
212 // in all cases, but I don't know how to probe for alternatives....
213 Status = refit_call5_wrapper(UgaDraw->GetMode, UgaDraw, &UGAWidth, &UGAHeight, &UGADepth, &UGARefreshRate);
214 Status = refit_call5_wrapper(UgaDraw->SetMode, UgaDraw, *ScreenWidth, *ScreenHeight, UGADepth, UGARefreshRate);
215 if (Status == EFI_SUCCESS) {
216 egScreenWidth = *ScreenWidth;
217 egScreenHeight = *ScreenHeight;
218 ModeSet = TRUE;
219 } else {
220 // TODO: Find a list of supported modes and display it.
221 // NOTE: Below doesn't actually appear unless we explicitly switch to text mode.
222 // This is just a placeholder until something better can be done....
223 Print(L"Error setting graphics mode %d x %d; unsupported mode!\n");
224 } // if/else
225 } // if/else if UGA mode (EFI 1.x)
226 return (ModeSet);
227 } // BOOLEAN egSetScreenSize()
228
229 // Set a text mode.
230 // Returns TRUE if the mode actually changed, FALSE otherwise.
231 // Note that a FALSE return value can mean either an error or no change
232 // necessary.
233 BOOLEAN egSetTextMode(UINT32 RequestedMode) {
234 UINTN i = 0, Width, Height;
235 EFI_STATUS Status;
236 BOOLEAN ChangedIt = FALSE;
237
238 if ((RequestedMode != DONT_CHANGE_TEXT_MODE) && (RequestedMode != ST->ConOut->Mode->Mode)) {
239 Status = refit_call2_wrapper(ST->ConOut->SetMode, ST->ConOut, RequestedMode);
240 if (Status == EFI_SUCCESS) {
241 ChangedIt = TRUE;
242 } else {
243 SwitchToText(FALSE);
244 Print(L"\nError setting text mode %d; available modes are:\n", RequestedMode);
245 do {
246 Status = refit_call4_wrapper(ST->ConOut->QueryMode, ST->ConOut, i, &Width, &Height);
247 if (Status == EFI_SUCCESS)
248 Print(L"Mode %d: %d x %d\n", i, Width, Height);
249 } while (++i < ST->ConOut->Mode->MaxMode);
250 Print(L"Mode %d: Use default mode\n", DONT_CHANGE_TEXT_MODE);
251
252 PauseForKey();
253 SwitchToGraphics();
254 } // if/else successful change
255 } // if need to change mode
256 return ChangedIt;
257 } // BOOLEAN egSetTextMode()
258
259 CHAR16 * egScreenDescription(VOID)
260 {
261 CHAR16 *GraphicsInfo, *TextInfo = NULL;
262
263 GraphicsInfo = AllocateZeroPool(256 * sizeof(CHAR16));
264 if (GraphicsInfo == NULL)
265 return L"memory allocation error";
266
267 if (egHasGraphics) {
268 if (GraphicsOutput != NULL) {
269 SPrint(GraphicsInfo, 255, L"Graphics Output (UEFI), %dx%d", egScreenWidth, egScreenHeight);
270 } else if (UgaDraw != NULL) {
271 GraphicsInfo = AllocateZeroPool(256 * sizeof(CHAR16));
272 SPrint(GraphicsInfo, 255, L"UGA Draw (EFI 1.10), %dx%d", egScreenWidth, egScreenHeight);
273 } else {
274 MyFreePool(GraphicsInfo);
275 MyFreePool(TextInfo);
276 return L"Internal Error";
277 }
278 if (!AllowGraphicsMode) { // graphics-capable HW, but in text mode
279 TextInfo = AllocateZeroPool(256 * sizeof(CHAR16));
280 SPrint(TextInfo, 255, L"(in %dx%d text mode)", ConWidth, ConHeight);
281 MergeStrings(&GraphicsInfo, TextInfo, L' ');
282 }
283 } else {
284 SPrint(GraphicsInfo, 255, L"Text-foo console, %dx%d", ConWidth, ConHeight);
285 }
286 MyFreePool(TextInfo);
287 return GraphicsInfo;
288 }
289
290 BOOLEAN egHasGraphicsMode(VOID)
291 {
292 return egHasGraphics;
293 }
294
295 BOOLEAN egIsGraphicsModeEnabled(VOID)
296 {
297 EFI_CONSOLE_CONTROL_SCREEN_MODE CurrentMode;
298
299 if (ConsoleControl != NULL) {
300 refit_call4_wrapper(ConsoleControl->GetMode, ConsoleControl, &CurrentMode, NULL, NULL);
301 return (CurrentMode == EfiConsoleControlScreenGraphics) ? TRUE : FALSE;
302 }
303
304 return FALSE;
305 }
306
307 VOID egSetGraphicsModeEnabled(IN BOOLEAN Enable)
308 {
309 EFI_CONSOLE_CONTROL_SCREEN_MODE CurrentMode;
310 EFI_CONSOLE_CONTROL_SCREEN_MODE NewMode;
311
312 if (ConsoleControl != NULL) {
313 refit_call4_wrapper(ConsoleControl->GetMode, ConsoleControl, &CurrentMode, NULL, NULL);
314
315 NewMode = Enable ? EfiConsoleControlScreenGraphics
316 : EfiConsoleControlScreenText;
317 if (CurrentMode != NewMode)
318 refit_call2_wrapper(ConsoleControl->SetMode, ConsoleControl, NewMode);
319 }
320 }
321
322 //
323 // Drawing to the screen
324 //
325
326 VOID egClearScreen(IN EG_PIXEL *Color)
327 {
328 EFI_UGA_PIXEL FillColor;
329
330 if (!egHasGraphics)
331 return;
332
333 if (Color != NULL) {
334 FillColor.Red = Color->r;
335 FillColor.Green = Color->g;
336 FillColor.Blue = Color->b;
337 } else {
338 FillColor.Red = 0x0;
339 FillColor.Green = 0x0;
340 FillColor.Blue = 0x0;
341 }
342 FillColor.Reserved = 0;
343
344 if (GraphicsOutput != NULL) {
345 // EFI_GRAPHICS_OUTPUT_BLT_PIXEL and EFI_UGA_PIXEL have the same
346 // layout, and the header from TianoCore actually defines them
347 // to be the same type.
348 refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)&FillColor, EfiBltVideoFill,
349 0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
350 } else if (UgaDraw != NULL) {
351 refit_call10_wrapper(UgaDraw->Blt, UgaDraw, &FillColor, EfiUgaVideoFill, 0, 0, 0, 0, egScreenWidth, egScreenHeight, 0);
352 }
353 }
354
355 VOID egDrawImage(IN EG_IMAGE *Image, IN UINTN ScreenPosX, IN UINTN ScreenPosY)
356 {
357 EG_IMAGE *CompImage = NULL;
358
359 // NOTE: Weird seemingly redundant tests because some placement code can "wrap around" and
360 // send "negative" values, which of course become very large unsigned ints that can then
361 // wrap around AGAIN if values are added to them.....
362 if (!egHasGraphics || ((ScreenPosX + Image->Width) > egScreenWidth) || ((ScreenPosY + Image->Height) > egScreenHeight) ||
363 (ScreenPosX > egScreenWidth) || (ScreenPosY > egScreenHeight))
364 return;
365
366 if ((GlobalConfig.ScreenBackground == NULL) || ((Image->Width == egScreenWidth) && (Image->Height == egScreenHeight))) {
367 CompImage = Image;
368 } else if (GlobalConfig.ScreenBackground == Image) {
369 CompImage = GlobalConfig.ScreenBackground;
370 } else {
371 CompImage = egCropImage(GlobalConfig.ScreenBackground, ScreenPosX, ScreenPosY, Image->Width, Image->Height);
372 if (CompImage == NULL) {
373 Print(L"Error! Can't crop image in egDrawImage()!\n");
374 return;
375 }
376 egComposeImage(CompImage, Image, 0, 0);
377 }
378
379 if (GraphicsOutput != NULL) {
380 refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)CompImage->PixelData,
381 EfiBltBufferToVideo, 0, 0, ScreenPosX, ScreenPosY, CompImage->Width, CompImage->Height, 0);
382 } else if (UgaDraw != NULL) {
383 refit_call10_wrapper(UgaDraw->Blt, UgaDraw, (EFI_UGA_PIXEL *)CompImage->PixelData, EfiUgaBltBufferToVideo,
384 0, 0, ScreenPosX, ScreenPosY, CompImage->Width, CompImage->Height, 0);
385 }
386 if ((CompImage != GlobalConfig.ScreenBackground) && (CompImage != Image))
387 egFreeImage(CompImage);
388 } /* VOID egDrawImage() */
389
390 // Display an unselected icon on the screen, so that the background image shows
391 // through the transparency areas. The BadgeImage may be NULL, in which case
392 // it's not composited in.
393 VOID egDrawImageWithTransparency(EG_IMAGE *Image, EG_IMAGE *BadgeImage, UINTN XPos, UINTN YPos, UINTN Width, UINTN Height) {
394 EG_IMAGE *Background;
395
396 Background = egCropImage(GlobalConfig.ScreenBackground, XPos, YPos, Width, Height);
397 if (Background != NULL) {
398 BltImageCompositeBadge(Background, Image, BadgeImage, XPos, YPos);
399 egFreeImage(Background);
400 }
401 } // VOID DrawImageWithTransparency()
402
403 VOID egDrawImageArea(IN EG_IMAGE *Image,
404 IN UINTN AreaPosX, IN UINTN AreaPosY,
405 IN UINTN AreaWidth, IN UINTN AreaHeight,
406 IN UINTN ScreenPosX, IN UINTN ScreenPosY)
407 {
408 if (!egHasGraphics)
409 return;
410
411 egRestrictImageArea(Image, AreaPosX, AreaPosY, &AreaWidth, &AreaHeight);
412 if (AreaWidth == 0)
413 return;
414
415 if (GraphicsOutput != NULL) {
416 refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData,
417 EfiBltBufferToVideo, AreaPosX, AreaPosY, ScreenPosX, ScreenPosY, AreaWidth, AreaHeight,
418 Image->Width * 4);
419 } else if (UgaDraw != NULL) {
420 refit_call10_wrapper(UgaDraw->Blt, UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaBltBufferToVideo,
421 AreaPosX, AreaPosY, ScreenPosX, ScreenPosY, AreaWidth, AreaHeight, Image->Width * 4);
422 }
423 }
424
425 // Display a message in the center of the screen, surrounded by a box of the
426 // specified color. For the moment, uses graphics calls only. (It still works
427 // in text mode on GOP/UEFI systems, but not on UGA/EFI 1.x systems.)
428 VOID egDisplayMessage(IN CHAR16 *Text, EG_PIXEL *BGColor) {
429 UINTN BoxWidth, BoxHeight;
430 EG_IMAGE *Box;
431
432 if ((Text != NULL) && (BGColor != NULL)) {
433 egMeasureText(Text, &BoxWidth, &BoxHeight);
434 BoxWidth += 14;
435 BoxHeight *= 2;
436 if (BoxWidth > egScreenWidth)
437 BoxWidth = egScreenWidth;
438 Box = egCreateFilledImage(BoxWidth, BoxHeight, FALSE, BGColor);
439 egRenderText(Text, Box, 7, BoxHeight / 4, (BGColor->r + BGColor->g + BGColor->b) / 3);
440 egDrawImage(Box, (egScreenWidth - BoxWidth) / 2, (egScreenHeight - BoxHeight) / 2);
441 } // if non-NULL inputs
442 } // VOID egDisplayMessage()
443
444 // Copy the current contents of the display into an EG_IMAGE....
445 // Returns pointer if successful, NULL if not.
446 EG_IMAGE * egCopyScreen(VOID) {
447 EG_IMAGE *Image = NULL;
448
449 if (!egHasGraphics)
450 return NULL;
451
452 // allocate a buffer for the whole screen
453 Image = egCreateImage(egScreenWidth, egScreenHeight, FALSE);
454 if (Image == NULL) {
455 return NULL;
456 }
457
458 // get full screen image
459 if (GraphicsOutput != NULL) {
460 refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData,
461 EfiBltVideoToBltBuffer, 0, 0, 0, 0, Image->Width, Image->Height, 0);
462 } else if (UgaDraw != NULL) {
463 refit_call10_wrapper(UgaDraw->Blt, UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaVideoToBltBuffer,
464 0, 0, 0, 0, Image->Width, Image->Height, 0);
465 }
466 return Image;
467 } // EG_IMAGE * egCopyScreen()
468
469 //
470 // Make a screenshot
471 //
472
473 VOID egScreenShot(VOID)
474 {
475 EFI_STATUS Status;
476 EG_IMAGE *Image;
477 UINT8 *FileData;
478 UINTN FileDataLength;
479 UINTN Index;
480
481 Image = egCopyScreen();
482 if (Image == NULL) {
483 Print(L"Error: Unable to take screen shot\n");
484 goto bailout_wait;
485 }
486
487 // encode as BMP
488 egEncodeBMP(Image, &FileData, &FileDataLength);
489 egFreeImage(Image);
490 if (FileData == NULL) {
491 Print(L"Error egEncodeBMP returned NULL\n");
492 goto bailout_wait;
493 }
494
495 // save to file on the ESP
496 Status = egSaveFile(NULL, L"screenshot.bmp", FileData, FileDataLength);
497 FreePool(FileData);
498 if (EFI_ERROR(Status)) {
499 Print(L"Error egSaveFile: %x\n", Status);
500 goto bailout_wait;
501 }
502
503 return;
504
505 // DEBUG: switch to text mode
506 bailout_wait:
507 egSetGraphicsModeEnabled(FALSE);
508 refit_call3_wrapper(BS->WaitForEvent, 1, &ST->ConIn->WaitForKey, &Index);
509 }
510
511 /* EOF */