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