]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
Remove SafeFreePool from MemoryAllocationLib as this API's name is misleading. Its...
[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 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 EFI_GUID mFontPackageListGuid = {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad};
136
137 CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };
138
139 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 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 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 FreePool (PackageList);
397 FreePool (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 if (Blt != NULL) {
1209 FreePool (Blt);
1210 Blt = NULL;
1211 }
1212 Count++;
1213
1214 if (EFI_ERROR (Status)) {
1215 return EFI_UNSUPPORTED;
1216 }
1217 }
1218
1219 return EFI_SUCCESS;
1220 }
1221
1222
1223 /**
1224 Returns information for an available text mode that the output device(s)
1225 supports
1226
1227 Implements SIMPLE_TEXT_OUTPUT.QueryMode().
1228 It returnes information for an available text mode that the Graphics Console supports.
1229 In this driver,we only support text mode 80x25, which is defined as mode 0.
1230
1231 @param This Protocol instance pointer.
1232 @param ModeNumber The mode number to return information on.
1233 @param Columns The returned columns of the requested mode.
1234 @param Rows The returned rows of the requested mode.
1235
1236 @retval EFI_SUCCESS The requested mode information is returned.
1237 @retval EFI_UNSUPPORTED The mode number is not valid.
1238
1239 **/
1240 EFI_STATUS
1241 EFIAPI
1242 GraphicsConsoleConOutQueryMode (
1243 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1244 IN UINTN ModeNumber,
1245 OUT UINTN *Columns,
1246 OUT UINTN *Rows
1247 )
1248 {
1249 GRAPHICS_CONSOLE_DEV *Private;
1250 EFI_STATUS Status;
1251 EFI_TPL OldTpl;
1252
1253 if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
1254 return EFI_UNSUPPORTED;
1255 }
1256
1257 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1258 Status = EFI_SUCCESS;
1259
1260 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1261
1262 *Columns = Private->ModeData[ModeNumber].Columns;
1263 *Rows = Private->ModeData[ModeNumber].Rows;
1264
1265 if (*Columns <= 0 && *Rows <= 0) {
1266 Status = EFI_UNSUPPORTED;
1267 goto Done;
1268
1269 }
1270
1271 Done:
1272 gBS->RestoreTPL (OldTpl);
1273 return Status;
1274 }
1275
1276
1277 /**
1278 Sets the output device(s) to a specified mode.
1279
1280 Implements SIMPLE_TEXT_OUTPUT.SetMode().
1281 Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
1282
1283 @param This Protocol instance pointer.
1284 @param ModeNumber The text mode to set.
1285
1286 @retval EFI_SUCCESS The requested text mode is set.
1287 @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
1288 Graphics Console device error.
1289 @retval EFI_UNSUPPORTED The text mode number is not valid.
1290
1291 **/
1292 EFI_STATUS
1293 EFIAPI
1294 GraphicsConsoleConOutSetMode (
1295 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1296 IN UINTN ModeNumber
1297 )
1298 {
1299 EFI_STATUS Status;
1300 GRAPHICS_CONSOLE_DEV *Private;
1301 GRAPHICS_CONSOLE_MODE_DATA *ModeData;
1302 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewLineBuffer;
1303 UINT32 HorizontalResolution;
1304 UINT32 VerticalResolution;
1305 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
1306 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1307 UINT32 ColorDepth;
1308 UINT32 RefreshRate;
1309 EFI_TPL OldTpl;
1310
1311 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1312
1313 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1314 GraphicsOutput = Private->GraphicsOutput;
1315 UgaDraw = Private->UgaDraw;
1316 ModeData = &(Private->ModeData[ModeNumber]);
1317
1318 if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {
1319 Status = EFI_UNSUPPORTED;
1320 goto Done;
1321 }
1322
1323 //
1324 // Make sure the requested mode number is supported
1325 //
1326 if (ModeNumber >= (UINTN) This->Mode->MaxMode) {
1327 Status = EFI_UNSUPPORTED;
1328 goto Done;
1329 }
1330
1331 if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {
1332 Status = EFI_UNSUPPORTED;
1333 goto Done;
1334 }
1335 //
1336 // Attempt to allocate a line buffer for the requested mode number
1337 //
1338 NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT);
1339
1340 if (NewLineBuffer == NULL) {
1341 //
1342 // The new line buffer could not be allocated, so return an error.
1343 // No changes to the state of the current console have been made, so the current console is still valid
1344 //
1345 Status = EFI_OUT_OF_RESOURCES;
1346 goto Done;
1347 }
1348 //
1349 // If the mode has been set at least one other time, then LineBuffer will not be NULL
1350 //
1351 if (Private->LineBuffer != NULL) {
1352 //
1353 // Clear the current text window on the current graphics console
1354 //
1355 This->ClearScreen (This);
1356
1357 //
1358 // If the new mode is the same as the old mode, then just return EFI_SUCCESS
1359 //
1360 if ((INT32) ModeNumber == This->Mode->Mode) {
1361 FreePool (NewLineBuffer);
1362 Status = EFI_SUCCESS;
1363 goto Done;
1364 }
1365 //
1366 // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
1367 // so erase the cursor, and free the LineBuffer for the current mode
1368 //
1369 EraseCursor (This);
1370
1371 FreePool (Private->LineBuffer);
1372 }
1373 //
1374 // Assign the current line buffer to the newly allocated line buffer
1375 //
1376 Private->LineBuffer = NewLineBuffer;
1377
1378 if (GraphicsOutput != NULL) {
1379 if (ModeData->GopModeNumber != GraphicsOutput->Mode->Mode) {
1380 //
1381 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1382 //
1383 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeData->GopModeNumber);
1384 if (EFI_ERROR (Status)) {
1385 //
1386 // The mode set operation failed
1387 //
1388 goto Done;
1389 }
1390 } else {
1391 //
1392 // The current graphics mode is correct, so simply clear the entire display
1393 //
1394 Status = GraphicsOutput->Blt (
1395 GraphicsOutput,
1396 &mEfiColors[0],
1397 EfiBltVideoFill,
1398 0,
1399 0,
1400 0,
1401 0,
1402 ModeData->GopWidth,
1403 ModeData->GopHeight,
1404 0
1405 );
1406 }
1407 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1408 //
1409 // Get the current UGA Draw mode information
1410 //
1411 Status = UgaDraw->GetMode (
1412 UgaDraw,
1413 &HorizontalResolution,
1414 &VerticalResolution,
1415 &ColorDepth,
1416 &RefreshRate
1417 );
1418 if (EFI_ERROR (Status) || HorizontalResolution != ModeData->GopWidth || VerticalResolution != ModeData->GopHeight) {
1419 //
1420 // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new grapghics mode
1421 //
1422 Status = UgaDraw->SetMode (
1423 UgaDraw,
1424 ModeData->GopWidth,
1425 ModeData->GopHeight,
1426 32,
1427 60
1428 );
1429 if (EFI_ERROR (Status)) {
1430 //
1431 // The mode set operation failed
1432 //
1433 goto Done;
1434 }
1435 } else {
1436 //
1437 // The current graphics mode is correct, so simply clear the entire display
1438 //
1439 Status = UgaDraw->Blt (
1440 UgaDraw,
1441 (EFI_UGA_PIXEL *) (UINTN) &mEfiColors[0],
1442 EfiUgaVideoFill,
1443 0,
1444 0,
1445 0,
1446 0,
1447 ModeData->GopWidth,
1448 ModeData->GopHeight,
1449 0
1450 );
1451 }
1452 }
1453
1454 //
1455 // The new mode is valid, so commit the mode change
1456 //
1457 This->Mode->Mode = (INT32) ModeNumber;
1458
1459 //
1460 // Move the text cursor to the upper left hand corner of the displat and enable it
1461 //
1462 This->SetCursorPosition (This, 0, 0);
1463
1464 Status = EFI_SUCCESS;
1465
1466 Done:
1467 gBS->RestoreTPL (OldTpl);
1468 return Status;
1469 }
1470
1471
1472 /**
1473 Sets the background and foreground colors for the OutputString () and
1474 ClearScreen () functions.
1475
1476 Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
1477
1478 @param This Protocol instance pointer.
1479 @param Attribute The attribute to set. Bits 0..3 are the foreground
1480 color, and bits 4..6 are the background color.
1481 All other bits are undefined and must be zero.
1482
1483 @retval EFI_SUCCESS The requested attribute is set.
1484 @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
1485 @retval EFI_UNSUPPORTED The attribute requested is not defined.
1486
1487 **/
1488 EFI_STATUS
1489 EFIAPI
1490 GraphicsConsoleConOutSetAttribute (
1491 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1492 IN UINTN Attribute
1493 )
1494 {
1495 EFI_TPL OldTpl;
1496
1497 if ((Attribute | 0xFF) != 0xFF) {
1498 return EFI_UNSUPPORTED;
1499 }
1500
1501 if ((INT32) Attribute == This->Mode->Attribute) {
1502 return EFI_SUCCESS;
1503 }
1504
1505 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1506
1507 EraseCursor (This);
1508
1509 This->Mode->Attribute = (INT32) Attribute;
1510
1511 EraseCursor (This);
1512
1513 gBS->RestoreTPL (OldTpl);
1514
1515 return EFI_SUCCESS;
1516 }
1517
1518
1519 /**
1520 Clears the output device(s) display to the currently selected background
1521 color.
1522
1523 Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
1524
1525 @param This Protocol instance pointer.
1526
1527 @retval EFI_SUCCESS The operation completed successfully.
1528 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1529 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
1530
1531 **/
1532 EFI_STATUS
1533 EFIAPI
1534 GraphicsConsoleConOutClearScreen (
1535 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
1536 )
1537 {
1538 EFI_STATUS Status;
1539 GRAPHICS_CONSOLE_DEV *Private;
1540 GRAPHICS_CONSOLE_MODE_DATA *ModeData;
1541 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
1542 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1543 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
1544 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
1545 EFI_TPL OldTpl;
1546
1547 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1548
1549 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1550 GraphicsOutput = Private->GraphicsOutput;
1551 UgaDraw = Private->UgaDraw;
1552 ModeData = &(Private->ModeData[This->Mode->Mode]);
1553
1554 GetTextColors (This, &Foreground, &Background);
1555 if (GraphicsOutput != NULL) {
1556 Status = GraphicsOutput->Blt (
1557 GraphicsOutput,
1558 &Background,
1559 EfiBltVideoFill,
1560 0,
1561 0,
1562 0,
1563 0,
1564 ModeData->GopWidth,
1565 ModeData->GopHeight,
1566 0
1567 );
1568 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1569 Status = UgaDraw->Blt (
1570 UgaDraw,
1571 (EFI_UGA_PIXEL *) (UINTN) &Background,
1572 EfiUgaVideoFill,
1573 0,
1574 0,
1575 0,
1576 0,
1577 ModeData->GopWidth,
1578 ModeData->GopHeight,
1579 0
1580 );
1581 } else {
1582 Status = EFI_UNSUPPORTED;
1583 }
1584
1585 This->Mode->CursorColumn = 0;
1586 This->Mode->CursorRow = 0;
1587
1588 EraseCursor (This);
1589
1590 gBS->RestoreTPL (OldTpl);
1591
1592 return Status;
1593 }
1594
1595
1596 /**
1597 Sets the current coordinates of the cursor position.
1598
1599 Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
1600
1601 @param This Protocol instance pointer.
1602 @param Column The position to set the cursor to. Must be greater than or
1603 equal to zero and less than the number of columns and rows
1604 by QueryMode ().
1605 @param Row The position to set the cursor to. Must be greater than or
1606 equal to zero and less than the number of columns and rows
1607 by QueryMode ().
1608
1609 @retval EFI_SUCCESS The operation completed successfully.
1610 @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
1611 @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
1612 cursor position is invalid for the current mode.
1613
1614 **/
1615 EFI_STATUS
1616 EFIAPI
1617 GraphicsConsoleConOutSetCursorPosition (
1618 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1619 IN UINTN Column,
1620 IN UINTN Row
1621 )
1622 {
1623 GRAPHICS_CONSOLE_DEV *Private;
1624 GRAPHICS_CONSOLE_MODE_DATA *ModeData;
1625 EFI_STATUS Status;
1626 EFI_TPL OldTpl;
1627
1628 Status = EFI_SUCCESS;
1629
1630 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1631
1632 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1633 ModeData = &(Private->ModeData[This->Mode->Mode]);
1634
1635 if ((Column >= ModeData->Columns) || (Row >= ModeData->Rows)) {
1636 Status = EFI_UNSUPPORTED;
1637 goto Done;
1638 }
1639
1640 if ((This->Mode->CursorColumn == (INT32) Column) && (This->Mode->CursorRow == (INT32) Row)) {
1641 Status = EFI_SUCCESS;
1642 goto Done;
1643 }
1644
1645 EraseCursor (This);
1646
1647 This->Mode->CursorColumn = (INT32) Column;
1648 This->Mode->CursorRow = (INT32) Row;
1649
1650 EraseCursor (This);
1651
1652 Done:
1653 gBS->RestoreTPL (OldTpl);
1654
1655 return Status;
1656 }
1657
1658
1659 /**
1660 Makes the cursor visible or invisible.
1661
1662 Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
1663
1664 @param This Protocol instance pointer.
1665 @param Visible If TRUE, the cursor is set to be visible, If FALSE,
1666 the cursor is set to be invisible.
1667
1668 @retval EFI_SUCCESS The operation completed successfully.
1669
1670 **/
1671 EFI_STATUS
1672 EFIAPI
1673 GraphicsConsoleConOutEnableCursor (
1674 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1675 IN BOOLEAN Visible
1676 )
1677 {
1678 EFI_TPL OldTpl;
1679
1680 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1681
1682 EraseCursor (This);
1683
1684 This->Mode->CursorVisible = Visible;
1685
1686 EraseCursor (This);
1687
1688 gBS->RestoreTPL (OldTpl);
1689 return EFI_SUCCESS;
1690 }
1691
1692 /**
1693 Gets Graphics Console devcie's foreground color and background color.
1694
1695 @param This Protocol instance pointer.
1696 @param Foreground Returned text foreground color.
1697 @param Background Returned text background color.
1698
1699 @retval EFI_SUCCESS It returned always.
1700
1701 **/
1702 EFI_STATUS
1703 GetTextColors (
1704 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1705 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
1706 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
1707 )
1708 {
1709 INTN Attribute;
1710
1711 Attribute = This->Mode->Attribute & 0x7F;
1712
1713 *Foreground = mEfiColors[Attribute & 0x0f];
1714 *Background = mEfiColors[Attribute >> 4];
1715
1716 return EFI_SUCCESS;
1717 }
1718
1719 /**
1720 Draw Unicode string on the Graphice Console device's screen.
1721
1722 @param This Protocol instance pointer.
1723 @param UnicodeWeight One Unicode string to be displayed.
1724 @param Count The count of Unicode string.
1725
1726 @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
1727 @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
1728 protocol exist.
1729 @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
1730
1731 **/
1732 EFI_STATUS
1733 DrawUnicodeWeightAtCursorN (
1734 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
1735 IN CHAR16 *UnicodeWeight,
1736 IN UINTN Count
1737 )
1738 {
1739 EFI_STATUS Status;
1740 GRAPHICS_CONSOLE_DEV *Private;
1741 EFI_IMAGE_OUTPUT *Blt;
1742 EFI_STRING String;
1743 EFI_FONT_DISPLAY_INFO *FontInfo;
1744 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1745 EFI_HII_ROW_INFO *RowInfoArray;
1746 UINTN RowInfoArraySize;
1747
1748 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1749 Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
1750 if (Blt == NULL) {
1751 return EFI_OUT_OF_RESOURCES;
1752 }
1753
1754 Blt->Width = (UINT16) (Private->ModeData[This->Mode->Mode].GopWidth);
1755 Blt->Height = (UINT16) (Private->ModeData[This->Mode->Mode].GopHeight);
1756
1757 String = AllocateCopyPool ((Count + 1) * sizeof (CHAR16), UnicodeWeight);
1758 if (String == NULL) {
1759 FreePool (Blt);
1760 return EFI_OUT_OF_RESOURCES;
1761 }
1762 //
1763 // Set the end character
1764 //
1765 *(String + Count) = L'\0';
1766
1767 FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));
1768 if (FontInfo == NULL) {
1769 FreePool (Blt);
1770 FreePool (String);
1771 return EFI_OUT_OF_RESOURCES;
1772 }
1773 //
1774 // Get current foreground and background colors.
1775 //
1776 GetTextColors (This, &FontInfo->ForegroundColor, &FontInfo->BackgroundColor);
1777
1778 if (Private->GraphicsOutput != NULL) {
1779 //
1780 // If Graphcis Output protocol exists, using HII Font protocol to draw.
1781 //
1782 Blt->Image.Screen = Private->GraphicsOutput;
1783
1784 Status = mHiiFont->StringToImage (
1785 mHiiFont,
1786 EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,
1787 String,
1788 FontInfo,
1789 &Blt,
1790 This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
1791 This->Mode->CursorRow * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
1792 NULL,
1793 NULL,
1794 NULL
1795 );
1796
1797 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1798 //
1799 // If Graphics Output protocol cannot be found and PcdUgaConsumeSupport enabled,
1800 // using UGA Draw protocol to draw.
1801 //
1802 ASSERT (Private->UgaDraw!= NULL);
1803
1804 UgaDraw = Private->UgaDraw;
1805
1806 Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
1807 if (Blt->Image.Bitmap == NULL) {
1808 FreePool (Blt);
1809 FreePool (String);
1810 return EFI_OUT_OF_RESOURCES;
1811 }
1812
1813 RowInfoArray = NULL;
1814 //
1815 // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
1816 // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
1817 //
1818 Status = mHiiFont->StringToImage (
1819 mHiiFont,
1820 EFI_HII_IGNORE_IF_NO_GLYPH,
1821 String,
1822 FontInfo,
1823 &Blt,
1824 This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
1825 This->Mode->CursorRow * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
1826 &RowInfoArray,
1827 &RowInfoArraySize,
1828 NULL
1829 );
1830
1831 if (!EFI_ERROR (Status)) {
1832 //
1833 // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
1834 // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.
1835 //
1836 ASSERT (RowInfoArraySize <= 1);
1837
1838 Status = UgaDraw->Blt (
1839 UgaDraw,
1840 (EFI_UGA_PIXEL *) Blt->Image.Bitmap,
1841 EfiUgaBltBufferToVideo,
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 This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
1845 (This->Mode->CursorRow) * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
1846 RowInfoArray[0].LineWidth,
1847 RowInfoArray[0].LineHeight,
1848 Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
1849 );
1850 }
1851
1852 FreePool (RowInfoArray);
1853 FreePool (Blt->Image.Bitmap);
1854 } else {
1855 Status = EFI_UNSUPPORTED;
1856 }
1857
1858 if (Blt != NULL) {
1859 FreePool (Blt);
1860 }
1861 if (String != NULL) {
1862 FreePool (String);
1863 }
1864 if (FontInfo != NULL) {
1865 FreePool (FontInfo);
1866 }
1867 return Status;
1868 }
1869
1870 /**
1871 Erase the cursor on the screen.
1872
1873 @param This Protocol instance pointer.
1874
1875 @retval EFI_SUCCESS The cursor is erased successfully.
1876
1877 **/
1878 EFI_STATUS
1879 EraseCursor (
1880 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
1881 )
1882 {
1883 GRAPHICS_CONSOLE_DEV *Private;
1884 EFI_SIMPLE_TEXT_OUTPUT_MODE *CurrentMode;
1885 INTN GlyphX;
1886 INTN GlyphY;
1887 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
1888 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
1889 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground;
1890 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background;
1891 EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar[EFI_GLYPH_HEIGHT][EFI_GLYPH_WIDTH];
1892 UINTN PosX;
1893 UINTN PosY;
1894
1895 CurrentMode = This->Mode;
1896
1897 if (!CurrentMode->CursorVisible) {
1898 return EFI_SUCCESS;
1899 }
1900
1901 Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
1902 GraphicsOutput = Private->GraphicsOutput;
1903 UgaDraw = Private->UgaDraw;
1904
1905 //
1906 // In this driver, only narrow character was supported.
1907 //
1908 //
1909 // Blt a character to the screen
1910 //
1911 GlyphX = (CurrentMode->CursorColumn * EFI_GLYPH_WIDTH) + Private->ModeData[CurrentMode->Mode].DeltaX;
1912 GlyphY = (CurrentMode->CursorRow * EFI_GLYPH_HEIGHT) + Private->ModeData[CurrentMode->Mode].DeltaY;
1913 if (GraphicsOutput != NULL) {
1914 GraphicsOutput->Blt (
1915 GraphicsOutput,
1916 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,
1917 EfiBltVideoToBltBuffer,
1918 GlyphX,
1919 GlyphY,
1920 0,
1921 0,
1922 EFI_GLYPH_WIDTH,
1923 EFI_GLYPH_HEIGHT,
1924 EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
1925 );
1926 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1927 UgaDraw->Blt (
1928 UgaDraw,
1929 (EFI_UGA_PIXEL *) (UINTN) BltChar,
1930 EfiUgaVideoToBltBuffer,
1931 GlyphX,
1932 GlyphY,
1933 0,
1934 0,
1935 EFI_GLYPH_WIDTH,
1936 EFI_GLYPH_HEIGHT,
1937 EFI_GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)
1938 );
1939 }
1940
1941 GetTextColors (This, &Foreground.Pixel, &Background.Pixel);
1942
1943 //
1944 // Convert Monochrome bitmap of the Glyph to BltBuffer structure
1945 //
1946 for (PosY = 0; PosY < EFI_GLYPH_HEIGHT; PosY++) {
1947 for (PosX = 0; PosX < EFI_GLYPH_WIDTH; PosX++) {
1948 if ((mCursorGlyph.GlyphCol1[PosY] & (1 << PosX)) != 0) {
1949 BltChar[PosY][EFI_GLYPH_WIDTH - PosX - 1].Raw ^= Foreground.Raw;
1950 }
1951 }
1952 }
1953
1954 if (GraphicsOutput != NULL) {
1955 GraphicsOutput->Blt (
1956 GraphicsOutput,
1957 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltChar,
1958 EfiBltBufferToVideo,
1959 0,
1960 0,
1961 GlyphX,
1962 GlyphY,
1963 EFI_GLYPH_WIDTH,
1964 EFI_GLYPH_HEIGHT,
1965 EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
1966 );
1967 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
1968 UgaDraw->Blt (
1969 UgaDraw,
1970 (EFI_UGA_PIXEL *) (UINTN) BltChar,
1971 EfiUgaBltBufferToVideo,
1972 0,
1973 0,
1974 GlyphX,
1975 GlyphY,
1976 EFI_GLYPH_WIDTH,
1977 EFI_GLYPH_HEIGHT,
1978 EFI_GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)
1979 );
1980 }
1981
1982 return EFI_SUCCESS;
1983 }
1984
1985 /**
1986 The user Entry Point for module GraphicsConsole. The user code starts with this function.
1987
1988 @param[in] ImageHandle The firmware allocated handle for the EFI image.
1989 @param[in] SystemTable A pointer to the EFI System Table.
1990
1991 @retval EFI_SUCCESS The entry point is executed successfully.
1992 @retval other Some error occurs when executing this entry point.
1993
1994 **/
1995 EFI_STATUS
1996 EFIAPI
1997 InitializeGraphicsConsole (
1998 IN EFI_HANDLE ImageHandle,
1999 IN EFI_SYSTEM_TABLE *SystemTable
2000 )
2001 {
2002 EFI_STATUS Status;
2003
2004 //
2005 // Install driver model protocol(s).
2006 //
2007 Status = EfiLibInstallDriverBindingComponentName2 (
2008 ImageHandle,
2009 SystemTable,
2010 &gGraphicsConsoleDriverBinding,
2011 ImageHandle,
2012 &gGraphicsConsoleComponentName,
2013 &gGraphicsConsoleComponentName2
2014 );
2015 ASSERT_EFI_ERROR (Status);
2016
2017
2018 return Status;
2019 }
2020
2021