]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
1. added functions header for GraphicsConsoleDxe module.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / GraphicsConsoleDxe / GraphicsConsole.c
1 /** @file
2 This is the main routine for initializing the Graphics Console support routines.
3 Remaining Tasks
4 Add all standard Glyphs from UEFI 2.0 Specification
5 Implement optimal automatic Mode creation algorithm
6 Solve palette issues for mixed graphics and text
7 When does this protocol reset the palette?
8
9 Copyright (c) 2006 - 2008 Intel Corporation. <BR>
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17
18 **/
19
20 #include "GraphicsConsole.h"
21
22 /**
23 Gets Graphics Console devcie's foreground color and background color.
24
25 @param This Protocol instance pointer.
26 @param Foreground Returned text foreground color.
27 @param Background Returned text background color.
28
29 @retval EFI_SUCCESS It returned always.
30
31 **/
32 EFI_STATUS
33 GetTextColors (
34 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
35 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
36 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
37 );
38
39 /**
40 Draw Unicode string on the Graphice Console device's screen.
41
42 @param This Protocol instance pointer.
43 @param UnicodeWeight One Unicode string to be displayed.
44 @param Count The count of Unicode string.
45
46 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
47 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
48 protocol exist.
49 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
50
51 **/
52 EFI_STATUS
53 DrawUnicodeWeightAtCursorN (
54 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
55 IN CHAR16 *UnicodeWeight,
56 IN UINTN Count
57 );
58
59 /**
60 Erase the cursor on the screen.
61
62 @param This Protocol instance pointer.
63
64 @retval EFI_SUCCESS The cursor is erased successfully.
65
66 **/
67 EFI_STATUS
68 EraseCursor (
69 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
70 );
71
72 /**
73 Check if the current specific mode supported the user defined resolution
74 for the Graphice Console devcie based on Graphics Output Protocol.
75
76 If yes, set the graphic devcice's current mode to this specific mode.
77
78 @param GraphicsOutput Graphics Output Protocol instance pointer.
79 @param HorizontalResolution User defined horizontal resolution
80 @param VerticalResolution User defined vertical resolution.
81 @param CurrentModeNumber Current specific mode to be check.
82
83 @retval EFI_SUCCESS This driver is removed ControllerHandle.
84 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
85 devcie supported.
86 @retval other The specific mode does not support user defined
87 resolution or failed to set the current mode to the
88 specific mode on graphics device.
89
90 **/
91 EFI_STATUS
92 CheckModeSupported (
93 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
94 IN UINT32 HorizontalResolution,
95 IN UINT32 VerticalResolution,
96 OUT UINT32 *CurrentModeNumber
97 );
98
99 //
100 // Globals
101 //
102 GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = {
103 GRAPHICS_CONSOLE_DEV_SIGNATURE,
104 (EFI_GRAPHICS_OUTPUT_PROTOCOL *) NULL,
105 (EFI_UGA_DRAW_PROTOCOL *) NULL,
106 {
107 GraphicsConsoleConOutReset,
108 GraphicsConsoleConOutOutputString,
109 GraphicsConsoleConOutTestString,
110 GraphicsConsoleConOutQueryMode,
111 GraphicsConsoleConOutSetMode,
112 GraphicsConsoleConOutSetAttribute,
113 GraphicsConsoleConOutClearScreen,
114 GraphicsConsoleConOutSetCursorPosition,
115 GraphicsConsoleConOutEnableCursor,
116 (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL
117 },
118 {
119 0,
120 0,
121 EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK),
122 0,
123 0,
124 TRUE
125 },
126 {
127 { 80, 25, 0, 0, 0, 0 }, // Mode 0
128 { 80, 50, 0, 0, 0, 0 }, // Mode 1
129 { 100,31, 0, 0, 0, 0 }, // Mode 2
130 { 0, 0, 0, 0, 0, 0 } // Mode 3
131 },
132 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,
133 (EFI_HII_HANDLE ) 0
134 };
135
136 EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
137 EFI_HII_FONT_PROTOCOL *mHiiFont;
138 BOOLEAN mFirstAccessFlag = TRUE;
139
140 STATIC EFI_GUID mFontPackageListGuid = {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad};
141
142 STATIC CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };
143
144 STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
145 //
146 // B G R
147 //
148 {0x00, 0x00, 0x00, 0x00}, // BLACK
149 {0x98, 0x00, 0x00, 0x00}, // BLUE
150 {0x00, 0x98, 0x00, 0x00}, // GREEN
151 {0x98, 0x98, 0x00, 0x00}, // CYAN
152 {0x00, 0x00, 0x98, 0x00}, // RED
153 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
154 {0x00, 0x98, 0x98, 0x00}, // BROWN
155 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
156 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
157 {0xff, 0x00, 0x00, 0x00}, // LIGHTBLUE - ?
158 {0x00, 0xff, 0x00, 0x00}, // LIGHTGREEN - ?
159 {0xff, 0xff, 0x00, 0x00}, // LIGHTCYAN
160 {0x00, 0x00, 0xff, 0x00}, // LIGHTRED
161 {0xff, 0x00, 0xff, 0x00}, // LIGHTMAGENTA
162 {0x00, 0xff, 0xff, 0x00}, // LIGHTBROWN
163 {0xff, 0xff, 0xff, 0x00} // WHITE
164 };
165
166 STATIC EFI_NARROW_GLYPH mCursorGlyph = {
167 0x0000,
168 0x00,
169 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }
170 };
171
172 STATIC CHAR16 SpaceStr[] = { NARROW_CHAR, ' ', 0 };
173
174 EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding = {
175 GraphicsConsoleControllerDriverSupported,
176 GraphicsConsoleControllerDriverStart,
177 GraphicsConsoleControllerDriverStop,
178 0xa,
179 NULL,
180 NULL
181 };
182
183
184 /**
185 Test to see if Graphics Console could be supported on the ControllerHandle.
186
187 Graphics Console could be supported if Graphics Output Protocol or UGA Draw
188 Protocol exists on the ControllerHandle. (UGA Draw Protocol could be shipped
189 if PcdUgaConsumeSupport is set to FALSE.)
190
191 @param This Protocol instance pointer.
192 @param ControllerHandle Handle of device to test.
193 @param RemainingDevicePath Optional parameter use to pick a specific child
194 device to start.
195
196 @retval EFI_SUCCESS This driver supports this device
197 @retval other This driver does not support this device
198
199 **/
200 EFI_STATUS
201 EFIAPI
202 GraphicsConsoleControllerDriverSupported (
203 IN EFI_DRIVER_BINDING_PROTOCOL *This,
204 IN EFI_HANDLE Controller,
205 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
206 )
207 {
208 EFI_STATUS Status;
209 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
210 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
211 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
212
213 GraphicsOutput = NULL;
214 UgaDraw = NULL;
215 //
216 // Open the IO Abstraction(s) needed to perform the supported test
217 //
218 Status = gBS->OpenProtocol (
219 Controller,
220 &gEfiGraphicsOutputProtocolGuid,
221 (VOID **) &GraphicsOutput,
222 This->DriverBindingHandle,
223 Controller,
224 EFI_OPEN_PROTOCOL_BY_DRIVER
225 );
226
227 if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
228 //
229 // Open Graphics Output Protocol failed, try to open UGA Draw Protocol
230 //
231 Status = gBS->OpenProtocol (
232 Controller,
233 &gEfiUgaDrawProtocolGuid,
234 (VOID **) &UgaDraw,
235 This->DriverBindingHandle,
236 Controller,
237 EFI_OPEN_PROTOCOL_BY_DRIVER
238 );
239 }
240 if (EFI_ERROR (Status)) {
241 return Status;
242 }
243
244 //
245 // We need to ensure that we do not layer on top of a virtual handle.
246 // We need to ensure that the handles produced by the conspliter do not
247 // get used.
248 //
249 Status = gBS->OpenProtocol (
250 Controller,
251 &gEfiDevicePathProtocolGuid,
252 (VOID **) &DevicePath,
253 This->DriverBindingHandle,
254 Controller,
255 EFI_OPEN_PROTOCOL_BY_DRIVER
256 );
257 if (!EFI_ERROR (Status)) {
258 gBS->CloseProtocol (
259 Controller,
260 &gEfiDevicePathProtocolGuid,
261 This->DriverBindingHandle,
262 Controller
263 );
264 } else {
265 goto Error;
266 }
267
268 //
269 // Does Hii Exist? If not, we aren't ready to run
270 //
271 Status = EfiLocateHiiProtocol ();
272
273 //
274 // Close the I/O Abstraction(s) used to perform the supported test
275 //
276 Error:
277 if (GraphicsOutput != NULL) {
278 gBS->CloseProtocol (
279 Controller,
280 &gEfiGraphicsOutputProtocolGuid,
281 This->DriverBindingHandle,
282 Controller
283 );
284 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
285 gBS->CloseProtocol (
286 Controller,
287 &gEfiUgaDrawProtocolGuid,
288 This->DriverBindingHandle,
289 Controller
290 );
291 }
292 return Status;
293 }
294
295
296 /**
297 Start this driver on ControllerHandle by opening Graphics Output protocol or
298 UGA Draw protocol, and installing Simple Text Out protocol on ControllerHandle.
299 (UGA Draw protocol could be shkipped if PcdUgaConsumeSupport is set to FALSE.)
300
301 @param This Protocol instance pointer.
302 @param ControllerHandle Handle of device to bind driver to
303 @param RemainingDevicePath Optional parameter use to pick a specific child
304 device to start.
305
306 @retval EFI_SUCCESS This driver is added to ControllerHandle
307 @retval other This driver does not support this device
308
309 **/
310 EFI_STATUS
311 EFIAPI
312 GraphicsConsoleControllerDriverStart (
313 IN EFI_DRIVER_BINDING_PROTOCOL *This,
314 IN EFI_HANDLE Controller,
315 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
316 )
317 {
318 EFI_STATUS Status;
319 GRAPHICS_CONSOLE_DEV *Private;
320 UINTN NarrowFontSize;
321 UINT32 HorizontalResolution;
322 UINT32 VerticalResolution;
323 UINT32 ColorDepth;
324 UINT32 RefreshRate;
325 UINTN MaxMode;
326 UINTN Columns;
327 UINTN Rows;
328 UINT32 ModeNumber;
329 EFI_HII_SIMPLE_FONT_PACKAGE_HDR *SimplifiedFont;
330 UINTN PackageLength;
331 EFI_HII_PACKAGE_LIST_HEADER *PackageList;
332 UINT8 *Package;
333 UINT8 *Location;
334
335 ModeNumber = 0;
336
337 //
338 // Initialize the Graphics Console device instance
339 //
340 Private = AllocateCopyPool (
341 sizeof (GRAPHICS_CONSOLE_DEV),
342 &mGraphicsConsoleDevTemplate
343 );
344 if (Private == NULL) {
345 return EFI_OUT_OF_RESOURCES;
346 }
347
348 Private->SimpleTextOutput.Mode = &(Private->SimpleTextOutputMode);
349
350 Status = gBS->OpenProtocol (
351 Controller,
352 &gEfiGraphicsOutputProtocolGuid,
353 (VOID **) &Private->GraphicsOutput,
354 This->DriverBindingHandle,
355 Controller,
356 EFI_OPEN_PROTOCOL_BY_DRIVER
357 );
358
359 if (EFI_ERROR(Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
360 Status = gBS->OpenProtocol (
361 Controller,
362 &gEfiUgaDrawProtocolGuid,
363 (VOID **) &Private->UgaDraw,
364 This->DriverBindingHandle,
365 Controller,
366 EFI_OPEN_PROTOCOL_BY_DRIVER
367 );
368 }
369
370 if (EFI_ERROR (Status)) {
371 goto Error;
372 }
373
374 NarrowFontSize = ReturnNarrowFontSize ();
375
376 if (mFirstAccessFlag) {
377 //
378 // Add 4 bytes to the header for entire length for HiiLibPreparePackageList use only.
379 // Looks ugly. Might be updated when font tool is ready.
380 //
381 PackageLength = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR) + NarrowFontSize + 4;
382 Package = AllocateZeroPool (PackageLength);
383 if (Package == NULL) {
384 return EFI_OUT_OF_RESOURCES;
385 }
386 CopyMem (Package, &PackageLength, 4);
387 SimplifiedFont = (EFI_HII_SIMPLE_FONT_PACKAGE_HDR*) (Package + 4);
388 SimplifiedFont->Header.Length = (UINT32) (PackageLength - 4);
389 SimplifiedFont->Header.Type = EFI_HII_PACKAGE_SIMPLE_FONTS;
390 SimplifiedFont->NumberOfNarrowGlyphs = (UINT16) (NarrowFontSize / sizeof (EFI_NARROW_GLYPH));
391
392 Location = (UINT8 *) (&SimplifiedFont->NumberOfWideGlyphs + 1);
393 CopyMem (Location, UsStdNarrowGlyphData, NarrowFontSize);
394
395 //
396 // Add this simplified font package to a package list then install it.
397 //
398 PackageList = HiiLibPreparePackageList (1, &mFontPackageListGuid, Package);
399 Status = mHiiDatabase->NewPackageList (mHiiDatabase, PackageList, NULL, &(Private->HiiHandle));
400 ASSERT_EFI_ERROR (Status);
401 SafeFreePool (PackageList);
402 SafeFreePool (Package);
403
404 mFirstAccessFlag = FALSE;
405 }
406 //
407 // If the current mode information can not be retrieved, then attemp to set the default mode
408 // of 800x600, 32 bit colot, 60 Hz refresh.
409 //
410 HorizontalResolution = 800;
411 VerticalResolution = 600;
412
413 if (Private->GraphicsOutput != NULL) {
414 //
415 // The console is build on top of Graphics Output Protocol, find the mode number
416 // for the user-defined mode; if there are multiple video devices,
417 // graphic console driver will set all the video devices to the same mode.
418 //
419 Status = CheckModeSupported (
420 Private->GraphicsOutput,
421 CURRENT_HORIZONTAL_RESOLUTION,
422 CURRENT_VERTICAL_RESOLUTION,
423 &ModeNumber
424 );
425 if (!EFI_ERROR(Status)) {
426 //
427 // Update default mode to current mode
428 //
429 HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;
430 VerticalResolution = CURRENT_VERTICAL_RESOLUTION;
431 } else {
432 //
433 // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec
434 //
435 Status = CheckModeSupported (
436 Private->GraphicsOutput,
437 800,
438 600,
439 &ModeNumber
440 );
441 }
442
443 if (EFI_ERROR (Status) || (ModeNumber == Private->GraphicsOutput->Mode->MaxMode)) {
444 //
445 // Set default mode failed or device don't support default mode, then get the current mode information
446 //
447 HorizontalResolution = Private->GraphicsOutput->Mode->Info->HorizontalResolution;
448 VerticalResolution = Private->GraphicsOutput->Mode->Info->VerticalResolution;
449 ModeNumber = Private->GraphicsOutput->Mode->Mode;
450 }
451 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
452 //
453 // At first try to set user-defined resolution
454 //
455 ColorDepth = 32;
456 RefreshRate = 60;
457 Status = Private->UgaDraw->SetMode (
458 Private->UgaDraw,
459 CURRENT_HORIZONTAL_RESOLUTION,
460 CURRENT_VERTICAL_RESOLUTION,
461 ColorDepth,
462 RefreshRate
463 );
464 if (!EFI_ERROR (Status)) {
465 HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;
466 VerticalResolution = CURRENT_VERTICAL_RESOLUTION;
467 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
468 //
469 // Try to set 800*600 which is required by UEFI/EFI spec
470 //
471 Status = Private->UgaDraw->SetMode (
472 Private->UgaDraw,
473 HorizontalResolution,
474 VerticalResolution,
475 ColorDepth,
476 RefreshRate
477 );
478 if (EFI_ERROR (Status)) {
479 Status = Private->UgaDraw->GetMode (
480 Private->UgaDraw,
481 &HorizontalResolution,
482 &VerticalResolution,
483 &ColorDepth,
484 &RefreshRate
485 );
486 if (EFI_ERROR (Status)) {
487 goto Error;
488 }
489 }
490 } else {
491 Status = EFI_UNSUPPORTED;
492 goto Error;
493 }
494 }
495
496 //
497 // Compute the maximum number of text Rows and Columns that this current graphics mode can support
498 //
499 Columns = HorizontalResolution / EFI_GLYPH_WIDTH;
500 Rows = VerticalResolution / EFI_GLYPH_HEIGHT;
501
502 //
503 // See if the mode is too small to support the required 80x25 text mode
504 //
505 if (Columns < 80 || Rows < 25) {
506 goto Error;
507 }
508 //
509 // Add Mode #0 that must be 80x25
510 //
511 MaxMode = 0;
512 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
513 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
514 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
515 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;
516 Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (25 * EFI_GLYPH_HEIGHT)) >> 1;
517 MaxMode++;
518
519 //
520 // If it is possible to support Mode #1 - 80x50, than add it as an active mode
521 //
522 if (Rows >= 50) {
523 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
524 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
525 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
526 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;
527 Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1;
528 MaxMode++;
529 }
530
531 //
532 // If it is not to support Mode #1 - 80x50, then skip it
533 //
534 if (MaxMode < 2) {
535 Private->ModeData[MaxMode].Columns = 0;
536 Private->ModeData[MaxMode].Rows = 0;
537 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
538 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
539 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
540 Private->ModeData[MaxMode].DeltaX = 0;
541 Private->ModeData[MaxMode].DeltaY = 0;
542 MaxMode++;
543 }
544
545 //
546 // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)
547 //
548 if (Columns >= 100 && Rows >= 31) {
549 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
550 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
551 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
552 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (100 * EFI_GLYPH_WIDTH)) >> 1;
553 Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (31 * EFI_GLYPH_HEIGHT)) >> 1;
554 MaxMode++;
555 }
556
557 //
558 // Add Mode #3 that uses the entire display for user-defined mode
559 //
560 if (HorizontalResolution > 800 && VerticalResolution > 600) {
561 Private->ModeData[MaxMode].Columns = HorizontalResolution/EFI_GLYPH_WIDTH;
562 Private->ModeData[MaxMode].Rows = VerticalResolution/EFI_GLYPH_HEIGHT;
563 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
564 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
565 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
566 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution % EFI_GLYPH_WIDTH) >> 1;
567 Private->ModeData[MaxMode].DeltaY = (VerticalResolution % EFI_GLYPH_HEIGHT) >> 1;
568 MaxMode++;
569 }
570
571 //
572 // Update the maximum number of modes
573 //
574 Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode;
575
576 //
577 // Determine the number of text modes that this protocol can support
578 //
579 Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0);
580 if (EFI_ERROR (Status)) {
581 goto Error;
582 }
583
584 DEBUG_CODE_BEGIN ();
585 GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");
586 DEBUG_CODE_END ();
587
588 //
589 // Install protocol interfaces for the Graphics Console device.
590 //
591 Status = gBS->InstallMultipleProtocolInterfaces (
592 &Controller,
593 &gEfiSimpleTextOutProtocolGuid,
594 &Private->SimpleTextOutput,
595 NULL
596 );
597
598 Error:
599 if (EFI_ERROR (Status)) {
600 //
601 // Close the GOP or UGA IO Protocol
602 //
603 if (Private->GraphicsOutput != NULL) {
604 gBS->CloseProtocol (
605 Controller,
606 &gEfiGraphicsOutputProtocolGuid,
607 This->DriverBindingHandle,
608 Controller
609 );
610 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
611 gBS->CloseProtocol (
612 Controller,
613 &gEfiUgaDrawProtocolGuid,
614 This->DriverBindingHandle,
615 Controller
616 );
617 }
618
619 //
620 // Free private data
621 //
622 if (Private != NULL) {
623 if (Private->LineBuffer != NULL) {
624 FreePool (Private->LineBuffer);
625 }
626 FreePool (Private);
627 }
628 }
629
630 return Status;
631 }
632
633 /**
634 Stop this driver on ControllerHandle by removing Simple Text Out protocol
635 and closing the Graphics Output Protocol or UGA Draw protocol on ControllerHandle.
636 (UGA Draw protocol could be shkipped if PcdUgaConsumeSupport is set to FALSE.)
637
638
639 @param This Protocol instance pointer.
640 @param ControllerHandle Handle of device to stop driver on
641 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
642 children is zero stop the entire bus driver.
643 @param ChildHandleBuffer List of Child Handles to Stop.
644
645 @retval EFI_SUCCESS This driver is removed ControllerHandle.
646 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
647 ControllerHandle.
648 @retval other This driver was not removed from this device.
649
650 **/
651 EFI_STATUS
652 EFIAPI
653 GraphicsConsoleControllerDriverStop (
654 IN EFI_DRIVER_BINDING_PROTOCOL *This,
655 IN EFI_HANDLE Controller,
656 IN UINTN NumberOfChildren,
657 IN EFI_HANDLE *ChildHandleBuffer
658 )
659 {
660 EFI_STATUS Status;
661 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
662 GRAPHICS_CONSOLE_DEV *Private;
663
664 Status = gBS->OpenProtocol (
665 Controller,
666 &gEfiSimpleTextOutProtocolGuid,
667 (VOID **) &SimpleTextOutput,
668 This->DriverBindingHandle,
669 Controller,
670 EFI_OPEN_PROTOCOL_GET_PROTOCOL
671 );
672 if (EFI_ERROR (Status)) {
673 return EFI_NOT_STARTED;
674 }
675
676 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);
677
678 Status = gBS->UninstallProtocolInterface (
679 Controller,
680 &gEfiSimpleTextOutProtocolGuid,
681 &Private->SimpleTextOutput
682 );
683
684 if (!EFI_ERROR (Status)) {
685 //
686 // Close the GOP or UGA IO Protocol
687 //
688 if (Private->GraphicsOutput != NULL) {
689 gBS->CloseProtocol (
690 Controller,
691 &gEfiGraphicsOutputProtocolGuid,
692 This->DriverBindingHandle,
693 Controller
694 );
695 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
696 gBS->CloseProtocol (
697 Controller,
698 &gEfiUgaDrawProtocolGuid,
699 This->DriverBindingHandle,
700 Controller
701 );
702 }
703
704 //
705 // Remove the font pack
706 //
707 if (Private->HiiHandle != NULL) {
708 HiiLibRemovePackages (Private->HiiHandle);
709 mFirstAccessFlag = TRUE;
710 }
711
712 //
713 // Free our instance data
714 //
715 if (Private != NULL) {
716 FreePool (Private->LineBuffer);
717 FreePool (Private);
718 }
719 }
720
721 return Status;
722 }
723
724 /**
725 Check if the current specific mode supported the user defined resolution
726 for the Graphice Console devcie based on Graphics Output Protocol.
727
728 If yes, set the graphic devcice's current mode to this specific mode.
729
730 @param GraphicsOutput Graphics Output Protocol instance pointer.
731 @param HorizontalResolution User defined horizontal resolution
732 @param VerticalResolution User defined vertical resolution.
733 @param CurrentModeNumber Current specific mode to be check.
734
735 @retval EFI_SUCCESS This driver is removed ControllerHandle.
736 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
737 devcie supported.
738 @retval other The specific mode does not support user defined
739 resolution or failed to set the current mode to the
740 specific mode on graphics device.
741
742 **/
743 EFI_STATUS
744 CheckModeSupported (
745 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
746 IN UINT32 HorizontalResolution,
747 IN UINT32 VerticalResolution,
748 OUT UINT32 *CurrentModeNumber
749 )
750 {
751 UINT32 ModeNumber;
752 EFI_STATUS Status;
753 UINTN SizeOfInfo;
754 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
755
756 Status = EFI_SUCCESS;
757
758 for (ModeNumber = 0; ModeNumber < GraphicsOutput->Mode->MaxMode; ModeNumber++) {
759 Status = GraphicsOutput->QueryMode (
760 GraphicsOutput,
761 ModeNumber,
762 &SizeOfInfo,
763 &Info
764 );
765 if (!EFI_ERROR (Status)) {
766 if ((Info->HorizontalResolution == HorizontalResolution) &&
767 (Info->VerticalResolution == VerticalResolution)) {
768 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
769 if (!EFI_ERROR (Status)) {
770 gBS->FreePool (Info);
771 break;
772 }
773 }
774 gBS->FreePool (Info);
775 }
776 }
777
778 if (ModeNumber == GraphicsOutput->Mode->MaxMode) {
779 Status = EFI_UNSUPPORTED;
780 }
781
782 *CurrentModeNumber = ModeNumber;
783 return Status;
784 }
785
786
787 /**
788 Locate HII Database protocol and HII Font protocol.
789
790 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
791 are located successfully.
792 @return other Failed to locate HII Database protocol or
793 HII Font protocol.
794
795 **/
796 EFI_STATUS
797 EfiLocateHiiProtocol (
798 VOID
799 )
800 {
801 EFI_HANDLE Handle;
802 UINTN Size;
803 EFI_STATUS Status;
804
805 //
806 // There should only be one - so buffer size is this
807 //
808 Size = sizeof (EFI_HANDLE);
809
810 Status = gBS->LocateHandle (
811 ByProtocol,
812 &gEfiHiiDatabaseProtocolGuid,
813 NULL,
814 &Size,
815 (VOID **) &Handle
816 );
817
818 if (EFI_ERROR (Status)) {
819 return Status;
820 }
821
822 Status = gBS->HandleProtocol (
823 Handle,
824 &gEfiHiiDatabaseProtocolGuid,
825 (VOID **) &mHiiDatabase
826 );
827
828 if (EFI_ERROR (Status)) {
829 return Status;
830 }
831
832 Status = gBS->HandleProtocol (
833 Handle,
834 &gEfiHiiFontProtocolGuid,
835 (VOID **) &mHiiFont
836 );
837 return Status;
838 }
839
840 //
841 // Body of the STO functions
842 //
843
844 /**
845 Reset the text output device hardware and optionaly run diagnostics.
846
847 Implements SIMPLE_TEXT_OUTPUT.Reset().
848 If ExtendeVerification is TRUE, then perform dependent Graphics Console
849 device reset, and set display mode to mode 0.
850 If ExtendedVerification is FALSE, only set display mode to mode 0.
851
852 @param This Protocol instance pointer.
853 @param ExtendedVerification Indicates that the driver may perform a more
854 exhaustive verification operation of the device
855 during reset.
856
857 @retval EFI_SUCCESS The text output device was reset.
858 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
859 could not be reset.
860
861 **/
862 EFI_STATUS
863 EFIAPI
864 GraphicsConsoleConOutReset (
865 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
866 IN BOOLEAN ExtendedVerification
867 )
868 {
869 This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));
870 return This->SetMode (This, 0);
871 }
872
873
874 /**
875 Write a Unicode string to the output device.
876
877 Implements SIMPLE_TEXT_OUTPUT.OutputString().
878 The Unicode string will be converted to Glyphs and will be
879 sent to the Graphics Console.
880
881 @param This Protocol instance pointer.
882 @param WString The NULL-terminated Unicode string to be displayed
883 on the output device(s). All output devices must
884 also support the Unicode drawing defined in this file.
885
886 @retval EFI_SUCCESS The string was output to the device.
887 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
888 the text.
889 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
890 defined text mode.
891 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
892 characters in the Unicode string could not be
893 rendered and were skipped.
894
895 **/
896 EFI_STATUS
897 EFIAPI
898 GraphicsConsoleConOutOutputString (
899 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
900 IN CHAR16 *WString
901 )
902 {
903 GRAPHICS_CONSOLE_DEV *Private;
904 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
905 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
906 INTN Mode;
907 UINTN MaxColumn;
908 UINTN MaxRow;
909 UINTN Width;
910 UINTN Height;
911 UINTN Delta;
912 EFI_STATUS Status;
913 BOOLEAN Warning;
914 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
915 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
916 UINTN DeltaX;
917 UINTN DeltaY;
918 UINTN Count;
919 UINTN Index;
920 INT32 OriginAttribute;
921 EFI_TPL OldTpl;
922
923 Status = EFI_SUCCESS;
924
925 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
926 //
927 // Current mode
928 //
929 Mode = This->Mode->Mode;
930 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
931 GraphicsOutput = Private->GraphicsOutput;
932 UgaDraw = Private->UgaDraw;
933
934 MaxColumn = Private->ModeData[Mode].Columns;
935 MaxRow = Private->ModeData[Mode].Rows;
936 DeltaX = Private->ModeData[Mode].DeltaX;
937 DeltaY = Private->ModeData[Mode].DeltaY;
938 Width = MaxColumn * EFI_GLYPH_WIDTH;
939 Height = (MaxRow - 1) * EFI_GLYPH_HEIGHT;
940 Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
941
942 //
943 // The Attributes won't change when during the time OutputString is called
944 //
945 GetTextColors (This, &Foreground, &Background);
946
947 EraseCursor (This);
948
949 Warning = FALSE;
950
951 //
952 // Backup attribute
953 //
954 OriginAttribute = This->Mode->Attribute;
955
956 while (*WString != L'\0') {
957
958 if (*WString == CHAR_BACKSPACE) {
959 //
960 // If the cursor is at the left edge of the display, then move the cursor
961 // one row up.
962 //
963 if (This->Mode->CursorColumn == 0 && This->Mode->CursorRow > 0) {
964 This->Mode->CursorRow--;
965 This->Mode->CursorColumn = (INT32) (MaxColumn - 1);
966 This->OutputString (This, SpaceStr);
967 EraseCursor (This);
968 This->Mode->CursorRow--;
969 This->Mode->CursorColumn = (INT32) (MaxColumn - 1);
970 } else if (This->Mode->CursorColumn > 0) {
971 //
972 // If the cursor is not at the left edge of the display, then move the cursor
973 // left one column.
974 //
975 This->Mode->CursorColumn--;
976 This->OutputString (This, SpaceStr);
977 EraseCursor (This);
978 This->Mode->CursorColumn--;
979 }
980
981 WString++;
982
983 } else if (*WString == CHAR_LINEFEED) {
984 //
985 // If the cursor is at the bottom of the display, then scroll the display one
986 // row, and do not update the cursor position. Otherwise, move the cursor
987 // down one row.
988 //
989 if (This->Mode->CursorRow == (INT32) (MaxRow - 1)) {
990 if (GraphicsOutput != NULL) {
991 //
992 // Scroll Screen Up One Row
993 //
994 GraphicsOutput->Blt (
995 GraphicsOutput,
996 NULL,
997 EfiBltVideoToVideo,
998 DeltaX,
999 DeltaY + EFI_GLYPH_HEIGHT,
1000 DeltaX,
1001 DeltaY,
1002 Width,
1003 Height,
1004 Delta
1005 );
1006
1007 //
1008 // Print Blank Line at last line
1009 //
1010 GraphicsOutput->Blt (
1011 GraphicsOutput,
1012 &Background,
1013 EfiBltVideoFill,
1014 0,
1015 0,
1016 DeltaX,
1017 DeltaY + Height,
1018 Width,
1019 EFI_GLYPH_HEIGHT,
1020 Delta
1021 );
1022 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1023 //
1024 // Scroll Screen Up One Row
1025 //
1026 UgaDraw->Blt (
1027 UgaDraw,
1028 NULL,
1029 EfiUgaVideoToVideo,
1030 DeltaX,
1031 DeltaY + EFI_GLYPH_HEIGHT,
1032 DeltaX,
1033 DeltaY,
1034 Width,
1035 Height,
1036 Delta
1037 );
1038
1039 //
1040 // Print Blank Line at last line
1041 //
1042 UgaDraw->Blt (
1043 UgaDraw,
1044 (EFI_UGA_PIXEL *) (UINTN) &Background,
1045 EfiUgaVideoFill,
1046 0,
1047 0,
1048 DeltaX,
1049 DeltaY + Height,
1050 Width,
1051 EFI_GLYPH_HEIGHT,
1052 Delta
1053 );
1054 }
1055 } else {
1056 This->Mode->CursorRow++;
1057 }
1058
1059 WString++;
1060
1061 } else if (*WString == CHAR_CARRIAGE_RETURN) {
1062 //
1063 // Move the cursor to the beginning of the current row.
1064 //
1065 This->Mode->CursorColumn = 0;
1066 WString++;
1067
1068 } else if (*WString == WIDE_CHAR) {
1069
1070 This->Mode->Attribute |= EFI_WIDE_ATTRIBUTE;
1071 WString++;
1072
1073 } else if (*WString == NARROW_CHAR) {
1074
1075 This->Mode->Attribute &= (~ (UINT32) EFI_WIDE_ATTRIBUTE);
1076 WString++;
1077
1078 } else {
1079 //
1080 // Print the character at the current cursor position and move the cursor
1081 // right one column. If this moves the cursor past the right edge of the
1082 // display, then the line should wrap to the beginning of the next line. This
1083 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
1084 // bottom of the display, and the line wraps, then the display will be scrolled
1085 // one line.
1086 // If wide char is going to be displayed, need to display one character at a time
1087 // Or, need to know the display length of a certain string.
1088 //
1089 // Index is used to determine how many character width units (wide = 2, narrow = 1)
1090 // Count is used to determine how many characters are used regardless of their attributes
1091 //
1092 for (Count = 0, Index = 0; (This->Mode->CursorColumn + Index) < MaxColumn; Count++, Index++) {
1093 if (WString[Count] == CHAR_NULL) {
1094 break;
1095 }
1096
1097 if (WString[Count] == CHAR_BACKSPACE) {
1098 break;
1099 }
1100
1101 if (WString[Count] == CHAR_LINEFEED) {
1102 break;
1103 }
1104
1105 if (WString[Count] == CHAR_CARRIAGE_RETURN) {
1106 break;
1107 }
1108
1109 if (WString[Count] == WIDE_CHAR) {
1110 break;
1111 }
1112
1113 if (WString[Count] == NARROW_CHAR) {
1114 break;
1115 }
1116 //
1117 // Is the wide attribute on?
1118 //
1119 if (This->Mode->Attribute & EFI_WIDE_ATTRIBUTE) {
1120 //
1121 // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
1122 //
1123 Index++;
1124 //
1125 // This is the end-case where if we are at column 79 and about to print a wide character
1126 // We should prevent this from happening because we will wrap inappropriately. We should
1127 // not print this character until the next line.
1128 //
1129 if ((This->Mode->CursorColumn + Index + 1) > MaxColumn) {
1130 Index++;
1131 break;
1132 }
1133 }
1134 }
1135
1136 Status = DrawUnicodeWeightAtCursorN (This, WString, Count);
1137 if (EFI_ERROR (Status)) {
1138 Warning = TRUE;
1139 }
1140 //
1141 // At the end of line, output carriage return and line feed
1142 //
1143 WString += Count;
1144 This->Mode->CursorColumn += (INT32) Index;
1145 if (This->Mode->CursorColumn > (INT32) MaxColumn) {
1146 This->Mode->CursorColumn -= 2;
1147 This->OutputString (This, SpaceStr);
1148 }
1149
1150 if (This->Mode->CursorColumn >= (INT32) MaxColumn) {
1151 EraseCursor (This);
1152 This->OutputString (This, mCrLfString);
1153 EraseCursor (This);
1154 }
1155 }
1156 }
1157
1158 This->Mode->Attribute = OriginAttribute;
1159
1160 EraseCursor (This);
1161
1162 if (Warning) {
1163 Status = EFI_WARN_UNKNOWN_GLYPH;
1164 }
1165
1166 gBS->RestoreTPL (OldTpl);
1167 return Status;
1168
1169 }
1170
1171 /**
1172 Verifies that all characters in a Unicode string can be output to the
1173 target device.
1174
1175 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1176 If one of the characters in the *Wstring is neither valid valid Unicode
1177 drawing characters, not ASCII code, then this function will return
1178 EFI_UNSUPPORTED
1179
1180 @param This Protocol instance pointer.
1181 @param WString The NULL-terminated Unicode string to be examined for the output
1182 device(s).
1183
1184 @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
1185 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
1186 rendered by one or more of the output devices mapped
1187 by the EFI handle.
1188
1189 **/
1190 EFI_STATUS
1191 EFIAPI
1192 GraphicsConsoleConOutTestString (
1193 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1194 IN CHAR16 *WString
1195 )
1196 {
1197 EFI_STATUS Status;
1198 UINT16 Count;
1199
1200 EFI_IMAGE_OUTPUT *Blt;
1201
1202 Blt = NULL;
1203 Count = 0;
1204
1205 while (WString[Count] != 0) {
1206 Status = mHiiFont->GetGlyph (
1207 mHiiFont,
1208 WString[Count],
1209 NULL,
1210 &Blt,
1211 NULL
1212 );
1213 SafeFreePool (Blt);
1214 Blt = NULL;
1215 Count++;
1216
1217 if (EFI_ERROR (Status)) {
1218 return EFI_UNSUPPORTED;
1219 }
1220 }
1221
1222 return EFI_SUCCESS;
1223 }
1224
1225
1226 /**
1227 Returns information for an available text mode that the output device(s)
1228 supports
1229
1230 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1231 It returnes information for an available text mode that the Graphics Console supports.
1232 In this driver,we only support text mode 80x25, which is defined as mode 0.
1233
1234 @param This Protocol instance pointer.
1235 @param ModeNumber The mode number to return information on.
1236 @param Columns The returned columns of the requested mode.
1237 @param Rows The returned rows of the requested mode.
1238
1239 @retval EFI_SUCCESS The requested mode information is returned.
1240 @retval EFI_UNSUPPORTED The mode number is not valid.
1241
1242 **/
1243 EFI_STATUS
1244 EFIAPI
1245 GraphicsConsoleConOutQueryMode (
1246 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1247 IN UINTN ModeNumber,
1248 OUT UINTN *Columns,
1249 OUT UINTN *Rows
1250 )
1251 {
1252 GRAPHICS_CONSOLE_DEV *Private;
1253 EFI_STATUS Status;
1254 EFI_TPL OldTpl;
1255
1256 if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
1257 return EFI_UNSUPPORTED;
1258 }
1259
1260 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1261 Status = EFI_SUCCESS;
1262
1263 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1264
1265 *Columns = Private->ModeData[ModeNumber].Columns;
1266 *Rows = Private->ModeData[ModeNumber].Rows;
1267
1268 if (*Columns <= 0 && *Rows <= 0) {
1269 Status = EFI_UNSUPPORTED;
1270 goto Done;
1271
1272 }
1273
1274 Done:
1275 gBS->RestoreTPL (OldTpl);
1276 return Status;
1277 }
1278
1279
1280 /**
1281 Sets the output device(s) to a specified mode.
1282
1283 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1284 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
1285
1286 @param This Protocol instance pointer.
1287 @param ModeNumber The text mode to set.
1288
1289 @retval EFI_SUCCESS The requested text mode is set.
1290 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
1291 Graphics Console device error.
1292 @retval EFI_UNSUPPORTED The text mode number is not valid.
1293
1294 **/
1295 EFI_STATUS
1296 EFIAPI
1297 GraphicsConsoleConOutSetMode (
1298 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1299 IN UINTN ModeNumber
1300 )
1301 {
1302 EFI_STATUS Status;
1303 GRAPHICS_CONSOLE_DEV *Private;
1304 GRAPHICS_CONSOLE_MODE_DATA *ModeData;
1305 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewLineBuffer;
1306 UINT32 HorizontalResolution;
1307 UINT32 VerticalResolution;
1308 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
1309 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1310 UINT32 ColorDepth;
1311 UINT32 RefreshRate;
1312 EFI_TPL OldTpl;
1313
1314 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1315
1316 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1317 GraphicsOutput = Private->GraphicsOutput;
1318 UgaDraw = Private->UgaDraw;
1319 ModeData = &(Private->ModeData[ModeNumber]);
1320
1321 if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {
1322 Status = EFI_UNSUPPORTED;
1323 goto Done;
1324 }
1325
1326 //
1327 // Make sure the requested mode number is supported
1328 //
1329 if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
1330 Status = EFI_UNSUPPORTED;
1331 goto Done;
1332 }
1333
1334 if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {
1335 Status = EFI_UNSUPPORTED;
1336 goto Done;
1337 }
1338 //
1339 // Attempt to allocate a line buffer for the requested mode number
1340 //
1341 NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT);
1342
1343 if (NewLineBuffer == NULL) {
1344 //
1345 // The new line buffer could not be allocated, so return an error.
1346 // No changes to the state of the current console have been made, so the current console is still valid
1347 //
1348 Status = EFI_OUT_OF_RESOURCES;
1349 goto Done;
1350 }
1351 //
1352 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1353 //
1354 if (Private->LineBuffer != NULL) {
1355 //
1356 // Clear the current text window on the current graphics console
1357 //
1358 This->ClearScreen (This);
1359
1360 //
1361 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1362 //
1363 if ((INT32) ModeNumber == This->Mode->Mode) {
1364 FreePool (NewLineBuffer);
1365 Status = EFI_SUCCESS;
1366 goto Done;
1367 }
1368 //
1369 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1370 // so erase the cursor, and free the LineBuffer for the current mode
1371 //
1372 EraseCursor (This);
1373
1374 FreePool (Private->LineBuffer);
1375 }
1376 //
1377 // Assign the current line buffer to the newly allocated line buffer
1378 //
1379 Private->LineBuffer = NewLineBuffer;
1380
1381 if (GraphicsOutput != NULL) {
1382 if (ModeData->GopModeNumber != GraphicsOutput->Mode->Mode) {
1383 //
1384 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1385 //
1386 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeData->GopModeNumber);
1387 if (EFI_ERROR (Status)) {
1388 //
1389 // The mode set operation failed
1390 //
1391 goto Done;
1392 }
1393 } else {
1394 //
1395 // The current graphics mode is correct, so simply clear the entire display
1396 //
1397 Status = GraphicsOutput->Blt (
1398 GraphicsOutput,
1399 &mEfiColors[0],
1400 EfiBltVideoFill,
1401 0,
1402 0,
1403 0,
1404 0,
1405 ModeData->GopWidth,
1406 ModeData->GopHeight,
1407 0
1408 );
1409 }
1410 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1411 //
1412 // Get the current UGA Draw mode information
1413 //
1414 Status = UgaDraw->GetMode (
1415 UgaDraw,
1416 &HorizontalResolution,
1417 &VerticalResolution,
1418 &ColorDepth,
1419 &RefreshRate
1420 );
1421 if (EFI_ERROR (Status) || HorizontalResolution != ModeData->GopWidth || VerticalResolution != ModeData->GopHeight) {
1422 //
1423 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1424 //
1425 Status = UgaDraw->SetMode (
1426 UgaDraw,
1427 ModeData->GopWidth,
1428 ModeData->GopHeight,
1429 32,
1430 60
1431 );
1432 if (EFI_ERROR (Status)) {
1433 //
1434 // The mode set operation failed
1435 //
1436 goto Done;
1437 }
1438 } else {
1439 //
1440 // The current graphics mode is correct, so simply clear the entire display
1441 //
1442 Status = UgaDraw->Blt (
1443 UgaDraw,
1444 (EFI_UGA_PIXEL *) (UINTN) &mEfiColors[0],
1445 EfiUgaVideoFill,
1446 0,
1447 0,
1448 0,
1449 0,
1450 ModeData->GopWidth,
1451 ModeData->GopHeight,
1452 0
1453 );
1454 }
1455 }
1456
1457 //
1458 // The new mode is valid, so commit the mode change
1459 //
1460 This->Mode->Mode = (INT32) ModeNumber;
1461
1462 //
1463 // Move the text cursor to the upper left hand corner of the displat and enable it
1464 //
1465 This->SetCursorPosition (This, 0, 0);
1466
1467 Status = EFI_SUCCESS;
1468
1469 Done:
1470 gBS->RestoreTPL (OldTpl);
1471 return Status;
1472 }
1473
1474
1475 /**
1476 Sets the background and foreground colors for the OutputString () and
1477 ClearScreen () functions.
1478
1479 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1480
1481 @param This Protocol instance pointer.
1482 @param Attribute The attribute to set. Bits 0..3 are the foreground
1483 color, and bits 4..6 are the background color.
1484 All other bits are undefined and must be zero.
1485
1486 @retval EFI_SUCCESS The requested attribute is set.
1487 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
1488 @retval EFI_UNSUPPORTED The attribute requested is not defined.
1489
1490 **/
1491 EFI_STATUS
1492 EFIAPI
1493 GraphicsConsoleConOutSetAttribute (
1494 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1495 IN UINTN Attribute
1496 )
1497 {
1498 EFI_TPL OldTpl;
1499
1500 if ((Attribute | 0xFF) != 0xFF) {
1501 return EFI_UNSUPPORTED;
1502 }
1503
1504 if ((INT32) Attribute == This->Mode->Attribute) {
1505 return EFI_SUCCESS;
1506 }
1507
1508 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1509
1510 EraseCursor (This);
1511
1512 This->Mode->Attribute = (INT32) Attribute;
1513
1514 EraseCursor (This);
1515
1516 gBS->RestoreTPL (OldTpl);
1517
1518 return EFI_SUCCESS;
1519 }
1520
1521
1522 /**
1523 Clears the output device(s) display to the currently selected background
1524 color.
1525
1526 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1527
1528 @param This Protocol instance pointer.
1529
1530 @retval EFI_SUCCESS The operation completed successfully.
1531 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1532 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
1533
1534 **/
1535 EFI_STATUS
1536 EFIAPI
1537 GraphicsConsoleConOutClearScreen (
1538 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
1539 )
1540 {
1541 EFI_STATUS Status;
1542 GRAPHICS_CONSOLE_DEV *Private;
1543 GRAPHICS_CONSOLE_MODE_DATA *ModeData;
1544 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
1545 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1546 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
1547 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
1548 EFI_TPL OldTpl;
1549
1550 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1551
1552 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1553 GraphicsOutput = Private->GraphicsOutput;
1554 UgaDraw = Private->UgaDraw;
1555 ModeData = &(Private->ModeData[This->Mode->Mode]);
1556
1557 GetTextColors (This, &Foreground, &Background);
1558 if (GraphicsOutput != NULL) {
1559 Status = GraphicsOutput->Blt (
1560 GraphicsOutput,
1561 &Background,
1562 EfiBltVideoFill,
1563 0,
1564 0,
1565 0,
1566 0,
1567 ModeData->GopWidth,
1568 ModeData->GopHeight,
1569 0
1570 );
1571 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1572 Status = UgaDraw->Blt (
1573 UgaDraw,
1574 (EFI_UGA_PIXEL *) (UINTN) &Background,
1575 EfiUgaVideoFill,
1576 0,
1577 0,
1578 0,
1579 0,
1580 ModeData->GopWidth,
1581 ModeData->GopHeight,
1582 0
1583 );
1584 } else {
1585 Status = EFI_UNSUPPORTED;
1586 }
1587
1588 This->Mode->CursorColumn = 0;
1589 This->Mode->CursorRow = 0;
1590
1591 EraseCursor (This);
1592
1593 gBS->RestoreTPL (OldTpl);
1594
1595 return Status;
1596 }
1597
1598
1599 /**
1600 Sets the current coordinates of the cursor position.
1601
1602 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1603
1604 @param This Protocol instance pointer.
1605 @param Column The position to set the cursor to. Must be greater than or
1606 equal to zero and less than the number of columns and rows
1607 by QueryMode ().
1608 @param Row The position to set the cursor to. Must be greater than or
1609 equal to zero and less than the number of columns and rows
1610 by QueryMode ().
1611
1612 @retval EFI_SUCCESS The operation completed successfully.
1613 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1614 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
1615 cursor position is invalid for the current mode.
1616
1617 **/
1618 EFI_STATUS
1619 EFIAPI
1620 GraphicsConsoleConOutSetCursorPosition (
1621 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1622 IN UINTN Column,
1623 IN UINTN Row
1624 )
1625 {
1626 GRAPHICS_CONSOLE_DEV *Private;
1627 GRAPHICS_CONSOLE_MODE_DATA *ModeData;
1628 EFI_STATUS Status;
1629 EFI_TPL OldTpl;
1630
1631 Status = EFI_SUCCESS;
1632
1633 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1634
1635 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1636 ModeData = &(Private->ModeData[This->Mode->Mode]);
1637
1638 if ((Column >= ModeData->Columns) || (Row >= ModeData->Rows)) {
1639 Status = EFI_UNSUPPORTED;
1640 goto Done;
1641 }
1642
1643 if (((INT32) Column == This->Mode->CursorColumn) && ((INT32) Row == This->Mode->CursorRow)) {
1644 Status = EFI_SUCCESS;
1645 goto Done;
1646 }
1647
1648 EraseCursor (This);
1649
1650 This->Mode->CursorColumn = (INT32) Column;
1651 This->Mode->CursorRow = (INT32) Row;
1652
1653 EraseCursor (This);
1654
1655 Done:
1656 gBS->RestoreTPL (OldTpl);
1657
1658 return Status;
1659 }
1660
1661
1662 /**
1663 Makes the cursor visible or invisible.
1664
1665 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1666
1667 @param This Protocol instance pointer.
1668 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
1669 the cursor is set to be invisible.
1670
1671 @retval EFI_SUCCESS The operation completed successfully.
1672
1673 **/
1674 EFI_STATUS
1675 EFIAPI
1676 GraphicsConsoleConOutEnableCursor (
1677 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1678 IN BOOLEAN Visible
1679 )
1680 {
1681 EFI_TPL OldTpl;
1682
1683 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1684
1685 EraseCursor (This);
1686
1687 This->Mode->CursorVisible = Visible;
1688
1689 EraseCursor (This);
1690
1691 gBS->RestoreTPL (OldTpl);
1692 return EFI_SUCCESS;
1693 }
1694
1695 /**
1696 Gets Graphics Console devcie's foreground color and background color.
1697
1698 @param This Protocol instance pointer.
1699 @param Foreground Returned text foreground color.
1700 @param Background Returned text background color.
1701
1702 @retval EFI_SUCCESS It returned always.
1703
1704 **/
1705 EFI_STATUS
1706 GetTextColors (
1707 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1708 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
1709 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
1710 )
1711 {
1712 INTN Attribute;
1713
1714 Attribute = This->Mode->Attribute & 0x7F;
1715
1716 *Foreground = mEfiColors[Attribute & 0x0f];
1717 *Background = mEfiColors[Attribute >> 4];
1718
1719 return EFI_SUCCESS;
1720 }
1721
1722 /**
1723 Draw Unicode string on the Graphice Console device's screen.
1724
1725 @param This Protocol instance pointer.
1726 @param UnicodeWeight One Unicode string to be displayed.
1727 @param Count The count of Unicode string.
1728
1729 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
1730 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
1731 protocol exist.
1732 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
1733
1734 **/
1735 EFI_STATUS
1736 DrawUnicodeWeightAtCursorN (
1737 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1738 IN CHAR16 *UnicodeWeight,
1739 IN UINTN Count
1740 )
1741 {
1742 EFI_STATUS Status;
1743 GRAPHICS_CONSOLE_DEV *Private;
1744 EFI_IMAGE_OUTPUT *Blt;
1745 EFI_STRING String;
1746 EFI_FONT_DISPLAY_INFO *FontInfo;
1747 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1748 EFI_HII_ROW_INFO *RowInfoArray;
1749 UINTN RowInfoArraySize;
1750
1751 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1752 Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
1753 if (Blt == NULL) {
1754 return EFI_OUT_OF_RESOURCES;
1755 }
1756
1757 Blt->Width = (UINT16) (Private->ModeData[This->Mode->Mode].GopWidth);
1758 Blt->Height = (UINT16) (Private->ModeData[This->Mode->Mode].GopHeight);
1759
1760 String = AllocateCopyPool ((Count + 1) * sizeof (CHAR16), UnicodeWeight);
1761 if (String == NULL) {
1762 SafeFreePool (Blt);
1763 return EFI_OUT_OF_RESOURCES;
1764 }
1765 *(String + Count) = 0;
1766
1767 FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));
1768 if (FontInfo == NULL) {
1769 SafeFreePool (Blt);
1770 SafeFreePool (String);
1771 return EFI_OUT_OF_RESOURCES;
1772 }
1773 GetTextColors (This, &FontInfo->ForegroundColor, &FontInfo->BackgroundColor);
1774
1775 if (Private->GraphicsOutput != NULL) {
1776 Blt->Image.Screen = Private->GraphicsOutput;
1777
1778 Status = mHiiFont->StringToImage (
1779 mHiiFont,
1780 EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,
1781 String,
1782 FontInfo,
1783 &Blt,
1784 This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
1785 This->Mode->CursorRow * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
1786 NULL,
1787 NULL,
1788 NULL
1789 );
1790
1791 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1792 ASSERT (Private->UgaDraw!= NULL);
1793
1794 UgaDraw = Private->UgaDraw;
1795
1796 Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
1797 if (Blt->Image.Bitmap == NULL) {
1798 SafeFreePool (Blt);
1799 SafeFreePool (String);
1800 return EFI_OUT_OF_RESOURCES;
1801 }
1802
1803 RowInfoArray = NULL;
1804 //
1805 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
1806 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
1807 //
1808 Status = mHiiFont->StringToImage (
1809 mHiiFont,
1810 EFI_HII_IGNORE_IF_NO_GLYPH,
1811 String,
1812 FontInfo,
1813 &Blt,
1814 This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
1815 This->Mode->CursorRow * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
1816 &RowInfoArray,
1817 &RowInfoArraySize,
1818 NULL
1819 );
1820
1821 if (!EFI_ERROR (Status)) {
1822 //
1823 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
1824 // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.
1825 //
1826 ASSERT (RowInfoArraySize <= 1);
1827
1828 Status = UgaDraw->Blt (
1829 UgaDraw,
1830 (EFI_UGA_PIXEL *) Blt->Image.Bitmap,
1831 EfiUgaBltBufferToVideo,
1832 This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
1833 (This->Mode->CursorRow) * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
1834 This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
1835 (This->Mode->CursorRow) * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
1836 RowInfoArray[0].LineWidth,
1837 RowInfoArray[0].LineHeight,
1838 Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
1839 );
1840 }
1841
1842 SafeFreePool (RowInfoArray);
1843 SafeFreePool (Blt->Image.Bitmap);
1844 } else {
1845 Status = EFI_UNSUPPORTED;
1846 }
1847
1848 SafeFreePool (Blt);
1849 SafeFreePool (String);
1850 SafeFreePool (FontInfo);
1851 return Status;
1852 }
1853
1854 /**
1855 Erase the cursor on the screen.
1856
1857 @param This Protocol instance pointer.
1858
1859 @retval EFI_SUCCESS The cursor is erased successfully.
1860
1861 **/
1862 EFI_STATUS
1863 EraseCursor (
1864 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
1865 )
1866 {
1867 GRAPHICS_CONSOLE_DEV *Private;
1868 EFI_SIMPLE_TEXT_OUTPUT_MODE *CurrentMode;
1869 INTN GlyphX;
1870 INTN GlyphY;
1871 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
1872 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1873 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground;
1874 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background;
1875 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar[EFI_GLYPH_HEIGHT][EFI_GLYPH_WIDTH];
1876 UINTN PosX;
1877 UINTN PosY;
1878
1879 CurrentMode = This->Mode;
1880
1881 if (!CurrentMode->CursorVisible) {
1882 return EFI_SUCCESS;
1883 }
1884
1885 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1886 GraphicsOutput = Private->GraphicsOutput;
1887 UgaDraw = Private->UgaDraw;
1888
1889 //
1890 // In this driver, only narrow character was supported.
1891 //
1892 //
1893 // Blt a character to the screen
1894 //
1895 GlyphX = (CurrentMode->CursorColumn * EFI_GLYPH_WIDTH) + Private->ModeData[CurrentMode->Mode].DeltaX;
1896 GlyphY = (CurrentMode->CursorRow * EFI_GLYPH_HEIGHT) + Private->ModeData[CurrentMode->Mode].DeltaY;
1897 if (GraphicsOutput != NULL) {
1898 GraphicsOutput->Blt (
1899 GraphicsOutput,
1900 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,
1901 EfiBltVideoToBltBuffer,
1902 GlyphX,
1903 GlyphY,
1904 0,
1905 0,
1906 EFI_GLYPH_WIDTH,
1907 EFI_GLYPH_HEIGHT,
1908 EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
1909 );
1910 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1911 UgaDraw->Blt (
1912 UgaDraw,
1913 (EFI_UGA_PIXEL *) (UINTN) BltChar,
1914 EfiUgaVideoToBltBuffer,
1915 GlyphX,
1916 GlyphY,
1917 0,
1918 0,
1919 EFI_GLYPH_WIDTH,
1920 EFI_GLYPH_HEIGHT,
1921 EFI_GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)
1922 );
1923 }
1924
1925 GetTextColors (This, &Foreground.Pixel, &Background.Pixel);
1926
1927 //
1928 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1929 //
1930 for (PosY = 0; PosY < EFI_GLYPH_HEIGHT; PosY++) {
1931 for (PosX = 0; PosX < EFI_GLYPH_WIDTH; PosX++) {
1932 if ((mCursorGlyph.GlyphCol1[PosY] & (1 << PosX)) != 0) {
1933 BltChar[PosY][EFI_GLYPH_WIDTH - PosX - 1].Raw ^= Foreground.Raw;
1934 }
1935 }
1936 }
1937
1938 if (GraphicsOutput != NULL) {
1939 GraphicsOutput->Blt (
1940 GraphicsOutput,
1941 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,
1942 EfiBltBufferToVideo,
1943 0,
1944 0,
1945 GlyphX,
1946 GlyphY,
1947 EFI_GLYPH_WIDTH,
1948 EFI_GLYPH_HEIGHT,
1949 EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
1950 );
1951 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1952 UgaDraw->Blt (
1953 UgaDraw,
1954 (EFI_UGA_PIXEL *) (UINTN) BltChar,
1955 EfiUgaBltBufferToVideo,
1956 0,
1957 0,
1958 GlyphX,
1959 GlyphY,
1960 EFI_GLYPH_WIDTH,
1961 EFI_GLYPH_HEIGHT,
1962 EFI_GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)
1963 );
1964 }
1965
1966 return EFI_SUCCESS;
1967 }
1968
1969 /**
1970 The user Entry Point for module GraphicsConsole. The user code starts with this function.
1971
1972 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1973 @param[in] SystemTable A pointer to the EFI System Table.
1974
1975 @retval EFI_SUCCESS The entry point is executed successfully.
1976 @retval other Some error occurs when executing this entry point.
1977
1978 **/
1979 EFI_STATUS
1980 EFIAPI
1981 InitializeGraphicsConsole (
1982 IN EFI_HANDLE ImageHandle,
1983 IN EFI_SYSTEM_TABLE *SystemTable
1984 )
1985 {
1986 EFI_STATUS Status;
1987
1988 //
1989 // Install driver model protocol(s).
1990 //
1991 Status = EfiLibInstallDriverBindingComponentName2 (
1992 ImageHandle,
1993 SystemTable,
1994 &gGraphicsConsoleDriverBinding,
1995 ImageHandle,
1996 &gGraphicsConsoleComponentName,
1997 &gGraphicsConsoleComponentName2
1998 );
1999 ASSERT_EFI_ERROR (Status);
2000
2001
2002 return Status;
2003 }
2004
2005