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