]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
Code scrub for Universal\Console\GraphicsConsoleDxe.
[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 // Graphics Console Device Private Data template
19 //
20 GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = {
21 GRAPHICS_CONSOLE_DEV_SIGNATURE,
22 (EFI_GRAPHICS_OUTPUT_PROTOCOL *) NULL,
23 (EFI_UGA_DRAW_PROTOCOL *) NULL,
24 {
25 GraphicsConsoleConOutReset,
26 GraphicsConsoleConOutOutputString,
27 GraphicsConsoleConOutTestString,
28 GraphicsConsoleConOutQueryMode,
29 GraphicsConsoleConOutSetMode,
30 GraphicsConsoleConOutSetAttribute,
31 GraphicsConsoleConOutClearScreen,
32 GraphicsConsoleConOutSetCursorPosition,
33 GraphicsConsoleConOutEnableCursor,
34 (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL
35 },
36 {
37 0,
38 0,
39 EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK),
40 0,
41 0,
42 TRUE
43 },
44 {
45 { 80, 25, 0, 0, 0, 0 }, // Mode 0
46 { 80, 50, 0, 0, 0, 0 }, // Mode 1
47 { 100,31, 0, 0, 0, 0 }, // Mode 2
48 { 0, 0, 0, 0, 0, 0 } // Mode 3
49 },
50 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,
51 (EFI_HII_HANDLE ) 0
52 };
53
54 EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
55 EFI_HII_FONT_PROTOCOL *mHiiFont;
56 BOOLEAN mFirstAccessFlag = TRUE;
57
58 EFI_GUID mFontPackageListGuid = {0xf5f219d3, 0x7006, 0x4648, {0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad}};
59
60 CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };
61
62 EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
63 //
64 // B G R reserved
65 //
66 {0x00, 0x00, 0x00, 0x00}, // BLACK
67 {0x98, 0x00, 0x00, 0x00}, // LIGHTBLUE
68 {0x00, 0x98, 0x00, 0x00}, // LIGHGREEN
69 {0x98, 0x98, 0x00, 0x00}, // LIGHCYAN
70 {0x00, 0x00, 0x98, 0x00}, // LIGHRED
71 {0x98, 0x00, 0x98, 0x00}, // MAGENTA
72 {0x00, 0x98, 0x98, 0x00}, // BROWN
73 {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
74 {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
75 {0xff, 0x00, 0x00, 0x00}, // BLUE
76 {0x00, 0xff, 0x00, 0x00}, // LIME
77 {0xff, 0xff, 0x00, 0x00}, // CYAN
78 {0x00, 0x00, 0xff, 0x00}, // RED
79 {0xff, 0x00, 0xff, 0x00}, // FUCHSIA
80 {0x00, 0xff, 0xff, 0x00}, // YELLOW
81 {0xff, 0xff, 0xff, 0x00} // WHITE
82 };
83
84 EFI_NARROW_GLYPH mCursorGlyph = {
85 0x0000,
86 0x00,
87 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }
88 };
89
90 CHAR16 SpaceStr[] = { NARROW_CHAR, ' ', 0 };
91
92 EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding = {
93 GraphicsConsoleControllerDriverSupported,
94 GraphicsConsoleControllerDriverStart,
95 GraphicsConsoleControllerDriverStop,
96 0xa,
97 NULL,
98 NULL
99 };
100
101 /**
102 Gets Graphics Console devcie's foreground color and background color.
103
104 @param This Protocol instance pointer.
105 @param Foreground Returned text foreground color.
106 @param Background Returned text background color.
107
108 @retval EFI_SUCCESS It returned always.
109
110 **/
111 EFI_STATUS
112 GetTextColors (
113 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
114 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
115 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
116 );
117
118 /**
119 Draw Unicode string on the Graphics Console device's screen.
120
121 @param This Protocol instance pointer.
122 @param UnicodeWeight One Unicode string to be displayed.
123 @param Count The count of Unicode string.
124
125 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
126 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
127 protocol exist.
128 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
129
130 **/
131 EFI_STATUS
132 DrawUnicodeWeightAtCursorN (
133 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
134 IN CHAR16 *UnicodeWeight,
135 IN UINTN Count
136 );
137
138 /**
139 Erase the cursor on the screen.
140
141 @param This Protocol instance pointer.
142
143 @retval EFI_SUCCESS The cursor is erased successfully.
144
145 **/
146 EFI_STATUS
147 EraseCursor (
148 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
149 );
150
151 /**
152 Check if the current specific mode supported the user defined resolution
153 for the Graphics Console device based on Graphics Output Protocol.
154
155 If yes, set the graphic device's current mode to this specific mode.
156
157 @param GraphicsOutput Graphics Output Protocol instance pointer.
158 @param HorizontalResolution User defined horizontal resolution
159 @param VerticalResolution User defined vertical resolution.
160 @param CurrentModeNumber Current specific mode to be check.
161
162 @retval EFI_SUCCESS The mode is supported.
163 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
164 device supported.
165 @retval other The specific mode does not support user defined
166 resolution or failed to set the current mode to the
167 specific mode on graphics device.
168
169 **/
170 EFI_STATUS
171 CheckModeSupported (
172 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
173 IN UINT32 HorizontalResolution,
174 IN UINT32 VerticalResolution,
175 OUT UINT32 *CurrentModeNumber
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 skipped 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 UINT32 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 UINT32 PackageLength;
326 EFI_HII_PACKAGE_LIST_HEADER *PackageList;
327 UINT8 *Package;
328 UINT8 *Location;
329 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
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 // +--------------------------------+ <-- Package
377 // | |
378 // | PackageLength(4 bytes) |
379 // | |
380 // |--------------------------------| <-- SimplifiedFont
381 // | |
382 // |EFI_HII_SIMPLE_FONT_PACKAGE_HDR |
383 // | |
384 // |--------------------------------| <-- Location
385 // | |
386 // | gUsStdNarrowGlyphData |
387 // | |
388 // +--------------------------------+
389
390 PackageLength = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR) + NarrowFontSize + 4;
391 Package = AllocateZeroPool (PackageLength);
392 if (Package == NULL) {
393 return EFI_OUT_OF_RESOURCES;
394 }
395 WriteUnaligned32((UINT32 *) Package,PackageLength);
396 SimplifiedFont = (EFI_HII_SIMPLE_FONT_PACKAGE_HDR *) (Package + 4);
397 SimplifiedFont->Header.Length = (UINT32) (PackageLength - 4);
398 SimplifiedFont->Header.Type = EFI_HII_PACKAGE_SIMPLE_FONTS;
399 SimplifiedFont->NumberOfNarrowGlyphs = (UINT16) (NarrowFontSize / sizeof (EFI_NARROW_GLYPH));
400
401 Location = (UINT8 *) (&SimplifiedFont->NumberOfWideGlyphs + 1);
402 CopyMem (Location, gUsStdNarrowGlyphData, NarrowFontSize);
403
404 //
405 // Add this simplified font package to a package list then install it.
406 //
407 PackageList = HiiLibPreparePackageList (1, &mFontPackageListGuid, Package);
408 Status = mHiiDatabase->NewPackageList (mHiiDatabase, PackageList, NULL, &(Private->HiiHandle));
409 ASSERT_EFI_ERROR (Status);
410 FreePool (PackageList);
411 FreePool (Package);
412
413 mFirstAccessFlag = FALSE;
414 }
415 //
416 // If the current mode information can not be retrieved, then attempt to set the default mode
417 // of 800x600, 32 bit color, 60 Hz refresh.
418 //
419 HorizontalResolution = 800;
420 VerticalResolution = 600;
421
422 if (Private->GraphicsOutput != NULL) {
423 //
424 // The console is build on top of Graphics Output Protocol, find the mode number
425 // for the user-defined mode; if there are multiple video devices,
426 // graphic console driver will set all the video devices to the same mode.
427 //
428 Status = CheckModeSupported (
429 Private->GraphicsOutput,
430 CURRENT_HORIZONTAL_RESOLUTION,
431 CURRENT_VERTICAL_RESOLUTION,
432 &ModeNumber
433 );
434 if (!EFI_ERROR(Status)) {
435 //
436 // Update default mode to current mode
437 //
438 HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;
439 VerticalResolution = CURRENT_VERTICAL_RESOLUTION;
440 } else {
441 //
442 // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec
443 //
444 Status = CheckModeSupported (
445 Private->GraphicsOutput,
446 800,
447 600,
448 &ModeNumber
449 );
450 }
451
452 Mode = Private->GraphicsOutput->Mode;
453
454 if (EFI_ERROR (Status) || (Mode->MaxMode)) {
455 //
456 // Set default mode failed or device don't support default mode, then get the current mode information
457 //
458 HorizontalResolution = Mode->Info->HorizontalResolution;
459 VerticalResolution = Mode->Info->VerticalResolution;
460 ModeNumber = Mode->Mode;
461 }
462 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
463 //
464 // At first try to set user-defined resolution
465 //
466 ColorDepth = 32;
467 RefreshRate = 60;
468 Status = Private->UgaDraw->SetMode (
469 Private->UgaDraw,
470 CURRENT_HORIZONTAL_RESOLUTION,
471 CURRENT_VERTICAL_RESOLUTION,
472 ColorDepth,
473 RefreshRate
474 );
475 if (!EFI_ERROR (Status)) {
476 HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;
477 VerticalResolution = CURRENT_VERTICAL_RESOLUTION;
478 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
479 //
480 // Try to set 800*600 which is required by UEFI/EFI spec
481 //
482 Status = Private->UgaDraw->SetMode (
483 Private->UgaDraw,
484 HorizontalResolution,
485 VerticalResolution,
486 ColorDepth,
487 RefreshRate
488 );
489 if (EFI_ERROR (Status)) {
490 Status = Private->UgaDraw->GetMode (
491 Private->UgaDraw,
492 &HorizontalResolution,
493 &VerticalResolution,
494 &ColorDepth,
495 &RefreshRate
496 );
497 if (EFI_ERROR (Status)) {
498 goto Error;
499 }
500 }
501 } else {
502 Status = EFI_UNSUPPORTED;
503 goto Error;
504 }
505 }
506
507 //
508 // Compute the maximum number of text Rows and Columns that this current graphics mode can support
509 //
510 Columns = HorizontalResolution / EFI_GLYPH_WIDTH;
511 Rows = VerticalResolution / EFI_GLYPH_HEIGHT;
512
513 //
514 // See if the mode is too small to support the required 80x25 text mode
515 //
516 if (Columns < 80 || Rows < 25) {
517 goto Error;
518 }
519 //
520 // Add Mode #0 that must be 80x25
521 //
522 MaxMode = 0;
523 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
524 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
525 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
526 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;
527 Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (25 * EFI_GLYPH_HEIGHT)) >> 1;
528 MaxMode++;
529
530 //
531 // If it is possible to support Mode #1 - 80x50, than add it as an active mode
532 //
533 if (Rows >= 50) {
534 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
535 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
536 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
537 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;
538 Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1;
539 MaxMode++;
540 }
541
542 //
543 // If it is not to support Mode #1 - 80x50, then skip it
544 //
545 if (MaxMode < 2) {
546 Private->ModeData[MaxMode].Columns = 0;
547 Private->ModeData[MaxMode].Rows = 0;
548 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
549 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
550 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
551 Private->ModeData[MaxMode].DeltaX = 0;
552 Private->ModeData[MaxMode].DeltaY = 0;
553 MaxMode++;
554 }
555
556 //
557 // Add Mode #2 that must be 100x31 (graphic mode >= 800x600)
558 //
559 if (Columns >= 100 && Rows >= 31) {
560 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
561 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
562 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
563 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution - (100 * EFI_GLYPH_WIDTH)) >> 1;
564 Private->ModeData[MaxMode].DeltaY = (VerticalResolution - (31 * EFI_GLYPH_HEIGHT)) >> 1;
565 MaxMode++;
566 }
567
568 //
569 // Add Mode #3 that uses the entire display for user-defined mode
570 //
571 if (HorizontalResolution > 800 && VerticalResolution > 600) {
572 Private->ModeData[MaxMode].Columns = HorizontalResolution/EFI_GLYPH_WIDTH;
573 Private->ModeData[MaxMode].Rows = VerticalResolution/EFI_GLYPH_HEIGHT;
574 Private->ModeData[MaxMode].GopWidth = HorizontalResolution;
575 Private->ModeData[MaxMode].GopHeight = VerticalResolution;
576 Private->ModeData[MaxMode].GopModeNumber = ModeNumber;
577 Private->ModeData[MaxMode].DeltaX = (HorizontalResolution % EFI_GLYPH_WIDTH) >> 1;
578 Private->ModeData[MaxMode].DeltaY = (VerticalResolution % EFI_GLYPH_HEIGHT) >> 1;
579 MaxMode++;
580 }
581
582 //
583 // Update the maximum number of modes
584 //
585 Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode;
586
587 //
588 // Determine the number of text modes that this protocol can support
589 //
590 Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0);
591 if (EFI_ERROR (Status)) {
592 goto Error;
593 }
594
595 DEBUG_CODE_BEGIN ();
596 GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");
597 DEBUG_CODE_END ();
598
599 //
600 // Install protocol interfaces for the Graphics Console device.
601 //
602 Status = gBS->InstallMultipleProtocolInterfaces (
603 &Controller,
604 &gEfiSimpleTextOutProtocolGuid,
605 &Private->SimpleTextOutput,
606 NULL
607 );
608
609 Error:
610 if (EFI_ERROR (Status)) {
611 //
612 // Close the GOP and UGA Draw Protocol
613 //
614 if (Private->GraphicsOutput != NULL) {
615 gBS->CloseProtocol (
616 Controller,
617 &gEfiGraphicsOutputProtocolGuid,
618 This->DriverBindingHandle,
619 Controller
620 );
621 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
622 gBS->CloseProtocol (
623 Controller,
624 &gEfiUgaDrawProtocolGuid,
625 This->DriverBindingHandle,
626 Controller
627 );
628 }
629
630 //
631 // Free private data
632 //
633 if (Private != NULL) {
634 if (Private->LineBuffer != NULL) {
635 FreePool (Private->LineBuffer);
636 }
637 FreePool (Private);
638 }
639 }
640
641 return Status;
642 }
643
644 /**
645 Stop this driver on Controller by removing Simple Text Out protocol
646 and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
647 (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
648
649
650 @param This Protocol instance pointer.
651 @param Controller Handle of device to stop driver on
652 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
653 children is zero stop the entire bus driver.
654 @param ChildHandleBuffer List of Child Handles to Stop.
655
656 @retval EFI_SUCCESS This driver is removed Controller.
657 @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
658 Controller.
659 @retval other This driver was not removed from this device.
660
661 **/
662 EFI_STATUS
663 EFIAPI
664 GraphicsConsoleControllerDriverStop (
665 IN EFI_DRIVER_BINDING_PROTOCOL *This,
666 IN EFI_HANDLE Controller,
667 IN UINTN NumberOfChildren,
668 IN EFI_HANDLE *ChildHandleBuffer
669 )
670 {
671 EFI_STATUS Status;
672 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
673 GRAPHICS_CONSOLE_DEV *Private;
674
675 Status = gBS->OpenProtocol (
676 Controller,
677 &gEfiSimpleTextOutProtocolGuid,
678 (VOID **) &SimpleTextOutput,
679 This->DriverBindingHandle,
680 Controller,
681 EFI_OPEN_PROTOCOL_GET_PROTOCOL
682 );
683 if (EFI_ERROR (Status)) {
684 return EFI_NOT_STARTED;
685 }
686
687 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);
688
689 Status = gBS->UninstallProtocolInterface (
690 Controller,
691 &gEfiSimpleTextOutProtocolGuid,
692 &Private->SimpleTextOutput
693 );
694
695 if (!EFI_ERROR (Status)) {
696 //
697 // Close the GOP or UGA IO Protocol
698 //
699 if (Private->GraphicsOutput != NULL) {
700 gBS->CloseProtocol (
701 Controller,
702 &gEfiGraphicsOutputProtocolGuid,
703 This->DriverBindingHandle,
704 Controller
705 );
706 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
707 gBS->CloseProtocol (
708 Controller,
709 &gEfiUgaDrawProtocolGuid,
710 This->DriverBindingHandle,
711 Controller
712 );
713 }
714
715 //
716 // Remove the font pack
717 //
718 if (Private->HiiHandle != NULL) {
719 HiiLibRemovePackages (Private->HiiHandle);
720 mFirstAccessFlag = TRUE;
721 }
722
723 //
724 // Free our instance data
725 //
726 if (Private != NULL) {
727 FreePool (Private->LineBuffer);
728 FreePool (Private);
729 }
730 }
731
732 return Status;
733 }
734
735 /**
736 Check if the current specific mode supported the user defined resolution
737 for the Graphics Console device based on Graphics Output Protocol.
738
739 If yes, set the graphic devcice's current mode to this specific mode.
740
741 @param GraphicsOutput Graphics Output Protocol instance pointer.
742 @param HorizontalResolution User defined horizontal resolution
743 @param VerticalResolution User defined vertical resolution.
744 @param CurrentModeNumber Current specific mode to be check.
745
746 @retval EFI_SUCCESS The mode is supported.
747 @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
748 device supported.
749 @retval other The specific mode does not support user defined
750 resolution or failed to set the current mode to the
751 specific mode on graphics device.
752
753 **/
754 EFI_STATUS
755 CheckModeSupported (
756 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
757 IN UINT32 HorizontalResolution,
758 IN UINT32 VerticalResolution,
759 OUT UINT32 *CurrentModeNumber
760 )
761 {
762 UINT32 ModeNumber;
763 EFI_STATUS Status;
764 UINTN SizeOfInfo;
765 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
766
767 Status = EFI_SUCCESS;
768
769 for (ModeNumber = 0; ModeNumber < GraphicsOutput->Mode->MaxMode; ModeNumber++) {
770 Status = GraphicsOutput->QueryMode (
771 GraphicsOutput,
772 ModeNumber,
773 &SizeOfInfo,
774 &Info
775 );
776 if (!EFI_ERROR (Status)) {
777 if ((Info->HorizontalResolution == HorizontalResolution) &&
778 (Info->VerticalResolution == VerticalResolution)) {
779 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
780 if (!EFI_ERROR (Status)) {
781 gBS->FreePool (Info);
782 break;
783 }
784 }
785 gBS->FreePool (Info);
786 }
787 }
788
789 if (ModeNumber == GraphicsOutput->Mode->MaxMode) {
790 Status = EFI_UNSUPPORTED;
791 }
792
793 *CurrentModeNumber = ModeNumber;
794 return Status;
795 }
796
797
798 /**
799 Locate HII Database protocol and HII Font protocol.
800
801 @retval EFI_SUCCESS HII Database protocol and HII Font protocol
802 are located successfully.
803 @return other Failed to locate HII Database protocol or
804 HII Font protocol.
805
806 **/
807 EFI_STATUS
808 EfiLocateHiiProtocol (
809 VOID
810 )
811 {
812 EFI_HANDLE Handle;
813 UINTN Size;
814 EFI_STATUS Status;
815
816 //
817 // There should only be one - so buffer size is this
818 //
819 Size = sizeof (EFI_HANDLE);
820
821 Status = gBS->LocateHandle (
822 ByProtocol,
823 &gEfiHiiDatabaseProtocolGuid,
824 NULL,
825 &Size,
826 (VOID **) &Handle
827 );
828
829 if (EFI_ERROR (Status)) {
830 return Status;
831 }
832
833 Status = gBS->HandleProtocol (
834 Handle,
835 &gEfiHiiDatabaseProtocolGuid,
836 (VOID **) &mHiiDatabase
837 );
838
839 if (EFI_ERROR (Status)) {
840 return Status;
841 }
842
843 Status = gBS->HandleProtocol (
844 Handle,
845 &gEfiHiiFontProtocolGuid,
846 (VOID **) &mHiiFont
847 );
848 return Status;
849 }
850
851 //
852 // Body of the STO functions
853 //
854
855 /**
856 Reset the text output device hardware and optionally run diagnostics.
857
858 Implements SIMPLE_TEXT_OUTPUT.Reset().
859 If ExtendeVerification is TRUE, then perform dependent Graphics Console
860 device reset, and set display mode to mode 0.
861 If ExtendedVerification is FALSE, only set display mode to mode 0.
862
863 @param This Protocol instance pointer.
864 @param ExtendedVerification Indicates that the driver may perform a more
865 exhaustive verification operation of the device
866 during reset.
867
868 @retval EFI_SUCCESS The text output device was reset.
869 @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
870 could not be reset.
871
872 **/
873 EFI_STATUS
874 EFIAPI
875 GraphicsConsoleConOutReset (
876 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
877 IN BOOLEAN ExtendedVerification
878 )
879 {
880 This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));
881 return This->SetMode (This, 0);
882 }
883
884
885 /**
886 Write a Unicode string to the output device.
887
888 Implements SIMPLE_TEXT_OUTPUT.OutputString().
889 The Unicode string will be converted to Glyphs and will be
890 sent to the Graphics Console.
891
892 @param This Protocol instance pointer.
893 @param WString The NULL-terminated Unicode string to be displayed
894 on the output device(s). All output devices must
895 also support the Unicode drawing defined in this file.
896
897 @retval EFI_SUCCESS The string was output to the device.
898 @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
899 the text.
900 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
901 defined text mode.
902 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
903 characters in the Unicode string could not be
904 rendered and were skipped.
905
906 **/
907 EFI_STATUS
908 EFIAPI
909 GraphicsConsoleConOutOutputString (
910 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
911 IN CHAR16 *WString
912 )
913 {
914 GRAPHICS_CONSOLE_DEV *Private;
915 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
916 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
917 INTN Mode;
918 UINTN MaxColumn;
919 UINTN MaxRow;
920 UINTN Width;
921 UINTN Height;
922 UINTN Delta;
923 EFI_STATUS Status;
924 BOOLEAN Warning;
925 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
926 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
927 UINTN DeltaX;
928 UINTN DeltaY;
929 UINTN Count;
930 UINTN Index;
931 INT32 OriginAttribute;
932 EFI_TPL OldTpl;
933
934 Status = EFI_SUCCESS;
935
936 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
937 //
938 // Current mode
939 //
940 Mode = This->Mode->Mode;
941 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
942 GraphicsOutput = Private->GraphicsOutput;
943 UgaDraw = Private->UgaDraw;
944
945 MaxColumn = Private->ModeData[Mode].Columns;
946 MaxRow = Private->ModeData[Mode].Rows;
947 DeltaX = Private->ModeData[Mode].DeltaX;
948 DeltaY = Private->ModeData[Mode].DeltaY;
949 Width = MaxColumn * EFI_GLYPH_WIDTH;
950 Height = (MaxRow - 1) * EFI_GLYPH_HEIGHT;
951 Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
952
953 //
954 // The Attributes won't change when during the time OutputString is called
955 //
956 GetTextColors (This, &Foreground, &Background);
957
958 EraseCursor (This);
959
960 Warning = FALSE;
961
962 //
963 // Backup attribute
964 //
965 OriginAttribute = This->Mode->Attribute;
966
967 while (*WString != L'\0') {
968
969 if (*WString == CHAR_BACKSPACE) {
970 //
971 // If the cursor is at the left edge of the display, then move the cursor
972 // one row up.
973 //
974 if (This->Mode->CursorColumn == 0 && This->Mode->CursorRow > 0) {
975 This->Mode->CursorRow--;
976 This->Mode->CursorColumn = (INT32) (MaxColumn - 1);
977 This->OutputString (This, SpaceStr);
978 EraseCursor (This);
979 This->Mode->CursorRow--;
980 This->Mode->CursorColumn = (INT32) (MaxColumn - 1);
981 } else if (This->Mode->CursorColumn > 0) {
982 //
983 // If the cursor is not at the left edge of the display, then move the cursor
984 // left one column.
985 //
986 This->Mode->CursorColumn--;
987 This->OutputString (This, SpaceStr);
988 EraseCursor (This);
989 This->Mode->CursorColumn--;
990 }
991
992 WString++;
993
994 } else if (*WString == CHAR_LINEFEED) {
995 //
996 // If the cursor is at the bottom of the display, then scroll the display one
997 // row, and do not update the cursor position. Otherwise, move the cursor
998 // down one row.
999 //
1000 if (This->Mode->CursorRow == (INT32) (MaxRow - 1)) {
1001 if (GraphicsOutput != NULL) {
1002 //
1003 // Scroll Screen Up One Row
1004 //
1005 GraphicsOutput->Blt (
1006 GraphicsOutput,
1007 NULL,
1008 EfiBltVideoToVideo,
1009 DeltaX,
1010 DeltaY + EFI_GLYPH_HEIGHT,
1011 DeltaX,
1012 DeltaY,
1013 Width,
1014 Height,
1015 Delta
1016 );
1017
1018 //
1019 // Print Blank Line at last line
1020 //
1021 GraphicsOutput->Blt (
1022 GraphicsOutput,
1023 &Background,
1024 EfiBltVideoFill,
1025 0,
1026 0,
1027 DeltaX,
1028 DeltaY + Height,
1029 Width,
1030 EFI_GLYPH_HEIGHT,
1031 Delta
1032 );
1033 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1034 //
1035 // Scroll Screen Up One Row
1036 //
1037 UgaDraw->Blt (
1038 UgaDraw,
1039 NULL,
1040 EfiUgaVideoToVideo,
1041 DeltaX,
1042 DeltaY + EFI_GLYPH_HEIGHT,
1043 DeltaX,
1044 DeltaY,
1045 Width,
1046 Height,
1047 Delta
1048 );
1049
1050 //
1051 // Print Blank Line at last line
1052 //
1053 UgaDraw->Blt (
1054 UgaDraw,
1055 (EFI_UGA_PIXEL *) (UINTN) &Background,
1056 EfiUgaVideoFill,
1057 0,
1058 0,
1059 DeltaX,
1060 DeltaY + Height,
1061 Width,
1062 EFI_GLYPH_HEIGHT,
1063 Delta
1064 );
1065 }
1066 } else {
1067 This->Mode->CursorRow++;
1068 }
1069
1070 WString++;
1071
1072 } else if (*WString == CHAR_CARRIAGE_RETURN) {
1073 //
1074 // Move the cursor to the beginning of the current row.
1075 //
1076 This->Mode->CursorColumn = 0;
1077 WString++;
1078
1079 } else if (*WString == WIDE_CHAR) {
1080
1081 This->Mode->Attribute |= EFI_WIDE_ATTRIBUTE;
1082 WString++;
1083
1084 } else if (*WString == NARROW_CHAR) {
1085
1086 This->Mode->Attribute &= (~ (UINT32) EFI_WIDE_ATTRIBUTE);
1087 WString++;
1088
1089 } else {
1090 //
1091 // Print the character at the current cursor position and move the cursor
1092 // right one column. If this moves the cursor past the right edge of the
1093 // display, then the line should wrap to the beginning of the next line. This
1094 // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
1095 // bottom of the display, and the line wraps, then the display will be scrolled
1096 // one line.
1097 // If wide char is going to be displayed, need to display one character at a time
1098 // Or, need to know the display length of a certain string.
1099 //
1100 // Index is used to determine how many character width units (wide = 2, narrow = 1)
1101 // Count is used to determine how many characters are used regardless of their attributes
1102 //
1103 for (Count = 0, Index = 0; (This->Mode->CursorColumn + Index) < MaxColumn; Count++, Index++) {
1104 if (WString[Count] == CHAR_NULL ||
1105 WString[Count] == CHAR_BACKSPACE ||
1106 WString[Count] == CHAR_LINEFEED ||
1107 WString[Count] == CHAR_CARRIAGE_RETURN ||
1108 WString[Count] == WIDE_CHAR ||
1109 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 graphics 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 graphics 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 display 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 Graphics 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 Graphics 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] & (BIT0 << 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