-/**@file\r
- Support for Basic Graphics operations.\r
+/** @file\r
+ Library supports diplaying graphical splash screen,\r
+ locking of keyboard input and printing character on\r
+ screen. These basic graphics operations are based on UEFI HII, \r
+ Graphics Output protocol or UGA Draw protocol.\r
\r
- BugBug: Currently *.BMP files are supported. This will be replaced\r
- when Tiano graphics format is supported.\r
-\r
-\r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
#include <Protocol/OEMBadging.h>\r
#include <Protocol/ConsoleControl.h>\r
#include <Protocol/GraphicsOutput.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
#include <Protocol/UgaDraw.h>\r
#include <Protocol/HiiFont.h>\r
#include <Protocol/HiiImage.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/BaseMemoryLib.h>\r
-#include <Library/DxePiLib.h>\r
+#include <Library/DxeServicesLib.h>\r
#include <Library/PcdLib.h>\r
\r
-STATIC EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
- { 0x00, 0x00, 0x00, 0x00 },\r
- { 0x98, 0x00, 0x00, 0x00 },\r
- { 0x00, 0x98, 0x00, 0x00 },\r
- { 0x98, 0x98, 0x00, 0x00 },\r
- { 0x00, 0x00, 0x98, 0x00 },\r
- { 0x98, 0x00, 0x98, 0x00 },\r
- { 0x00, 0x98, 0x98, 0x00 },\r
- { 0x98, 0x98, 0x98, 0x00 },\r
- { 0x10, 0x10, 0x10, 0x00 },\r
- { 0xff, 0x10, 0x10, 0x00 },\r
- { 0x10, 0xff, 0x10, 0x00 },\r
- { 0xff, 0xff, 0x10, 0x00 },\r
- { 0x10, 0x10, 0xff, 0x00 },\r
- { 0xf0, 0x10, 0xff, 0x00 },\r
- { 0x10, 0xff, 0xff, 0x00 },\r
- { 0xff, 0xff, 0xff, 0x00 }\r
-};\r
-\r
-\r
-EFI_STATUS\r
-GetGraphicsBitMapFromFV (\r
- IN EFI_GUID *FileNameGuid,\r
- OUT VOID **Image,\r
- OUT UINTN *ImageSize\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Return the graphics image file named FileNameGuid into Image and return it's\r
- size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
- file name.\r
-\r
-Arguments:\r
-\r
- FileNameGuid - File Name of graphics file in the FV(s).\r
-\r
- Image - Pointer to pointer to return graphics image. If NULL, a\r
- buffer will be allocated.\r
-\r
- ImageSize - Size of the graphics Image in bytes. Zero if no image found.\r
-\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Image and ImageSize are valid.\r
- EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
- EFI_NOT_FOUND - FileNameGuid not found\r
-\r
---*/\r
-{\r
- return GetGraphicsBitMapFromFVEx (NULL, FileNameGuid, Image, ImageSize);\r
-}\r
-\r
-EFI_STATUS\r
-GetGraphicsBitMapFromFVEx (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_GUID *FileNameGuid,\r
- OUT VOID **Image,\r
- OUT UINTN *ImageSize\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Return the graphics image file named FileNameGuid into Image and return it's\r
- size in ImageSize. All Firmware Volumes (FV) in the system are searched for the\r
- file name.\r
-\r
-Arguments:\r
-\r
- ImageHandle - The driver image handle of the caller. The parameter is used to\r
- optimize the loading of the image file so that the FV from which\r
- the driver image is loaded will be tried first.\r
-\r
- FileNameGuid - File Name of graphics file in the FV(s).\r
-\r
- Image - Pointer to pointer to return graphics image. If NULL, a\r
- buffer will be allocated.\r
-\r
- ImageSize - Size of the graphics Image in bytes. Zero if no image found.\r
-\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Image and ImageSize are valid.\r
- EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size\r
- EFI_NOT_FOUND - FileNameGuid not found\r
+/**\r
+ Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer\r
+ is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
+ buffer is passed in it will be used if it is big enough.\r
\r
---*/\r
-{\r
- return PiLibGetSectionFromAnyFv (\r
- FileNameGuid,\r
- EFI_SECTION_RAW,\r
- 0,\r
- Image,\r
- ImageSize\r
- );\r
-}\r
+ @param BmpImage Pointer to BMP file\r
+ @param BmpImageSize Number of bytes in BmpImage\r
+ @param GopBlt Buffer containing GOP version of BmpImage.\r
+ @param GopBltSize Size of GopBlt in bytes.\r
+ @param PixelHeight Height of GopBlt/BmpImage in pixels\r
+ @param PixelWidth Width of GopBlt/BmpImage in pixels\r
\r
+ @retval EFI_SUCCESS GopBlt and GopBltSize are returned. \r
+ @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image\r
+ @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big enough.\r
+ GopBltSize will contain the required size.\r
+ @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.\r
\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
ConvertBmpToGopBlt (\r
- IN VOID *BmpImage,\r
- IN UINTN BmpImageSize,\r
- IN OUT VOID **GopBlt,\r
- IN OUT UINTN *GopBltSize,\r
- OUT UINTN *PixelHeight,\r
- OUT UINTN *PixelWidth\r
+ IN VOID *BmpImage,\r
+ IN UINTN BmpImageSize,\r
+ IN OUT VOID **GopBlt,\r
+ IN OUT UINTN *GopBltSize,\r
+ OUT UINTN *PixelHeight,\r
+ OUT UINTN *PixelWidth\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer\r
- is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
- buffer is passed in it will be used if it is big enough.\r
-\r
-Arguments:\r
-\r
- BmpImage - Pointer to BMP file\r
-\r
- BmpImageSize - Number of bytes in BmpImage\r
-\r
- GopBlt - Buffer containing GOP version of BmpImage.\r
-\r
- GopBltSize - Size of GopBlt in bytes.\r
-\r
- PixelHeight - Height of GopBlt/BmpImage in pixels\r
-\r
- PixelWidth - Width of GopBlt/BmpImage in pixels\r
-\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - GopBlt and GopBltSize are returned.\r
- EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image\r
- EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough.\r
- GopBltSize will contain the required size.\r
- EFI_OUT_OF_RESOURCES - No enough buffer to allocate\r
-\r
---*/\r
{\r
- UINT8 *Image;\r
- UINT8 *ImageHeader;\r
- BMP_IMAGE_HEADER *BmpHeader;\r
- BMP_COLOR_MAP *BmpColorMap;\r
+ UINT8 *Image;\r
+ UINT8 *ImageHeader;\r
+ BMP_IMAGE_HEADER *BmpHeader;\r
+ BMP_COLOR_MAP *BmpColorMap;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
- UINTN BltBufferSize;\r
- UINTN Index;\r
- UINTN Height;\r
- UINTN Width;\r
- UINTN ImageIndex;\r
- BOOLEAN IsAllocated;\r
+ UINTN BltBufferSize;\r
+ UINTN Index;\r
+ UINTN Height;\r
+ UINTN Width;\r
+ UINTN ImageIndex;\r
+ BOOLEAN IsAllocated;\r
\r
BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;\r
+\r
if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {\r
return EFI_UNSUPPORTED;\r
}\r
\r
+ //\r
+ // Doesn't support compress.\r
+ //\r
if (BmpHeader->CompressionType != 0) {\r
return EFI_UNSUPPORTED;\r
}\r
Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;\r
ImageHeader = Image;\r
\r
+ //\r
+ // Calculate the BltBuffer needed size.\r
+ //\r
BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
IsAllocated = FALSE;\r
if (*GopBlt == NULL) {\r
+ //\r
+ // GopBlt is not allocated by caller.\r
+ //\r
*GopBltSize = BltBufferSize;\r
*GopBlt = AllocatePool (*GopBltSize);\r
IsAllocated = TRUE;\r
return EFI_OUT_OF_RESOURCES;\r
}\r
} else {\r
+ //\r
+ // GopBlt has been allocated by caller.\r
+ //\r
if (*GopBltSize < BltBufferSize) {\r
*GopBltSize = BltBufferSize;\r
return EFI_BUFFER_TOO_SMALL;\r
switch (BmpHeader->BitPerPixel) {\r
case 1:\r
//\r
- // Convert 1bit BMP to 24-bit color\r
+ // Convert 1-bit (2 colors) BMP to 24-bit color\r
//\r
for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {\r
Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;\r
\r
case 4:\r
//\r
- // Convert BMP Palette to 24-bit color\r
+ // Convert 4-bit (16 colors) BMP Palette to 24-bit color\r
//\r
Index = (*Image) >> 4;\r
Blt->Red = BmpColorMap[Index].Red;\r
\r
case 8:\r
//\r
- // Convert BMP Palette to 24-bit color\r
+ // Convert 8-bit (256 colors) BMP Palette to 24-bit color\r
//\r
Blt->Red = BmpColorMap[*Image].Red;\r
Blt->Green = BmpColorMap[*Image].Green;\r
break;\r
\r
case 24:\r
+ //\r
+ // It is 24-bit BMP.\r
+ //\r
Blt->Blue = *Image++;\r
Blt->Green = *Image++;\r
Blt->Red = *Image;\r
break;\r
\r
default:\r
+ //\r
+ // Other bit format BMP is not supported.\r
+ //\r
if (IsAllocated) {\r
- gBS->FreePool (*GopBlt);\r
+ FreePool (*GopBlt);\r
*GopBlt = NULL;\r
}\r
return EFI_UNSUPPORTED;\r
}\r
\r
\r
-EFI_STATUS\r
-LockKeyboards (\r
- IN CHAR16 *Password\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Use Console Control Protocol to lock the Console In Spliter virtual handle.\r
+/**\r
+ Use Console Control Protocol to lock the Console In Spliter virtual handle. \r
This is the ConInHandle and ConIn handle in the EFI system table. All key\r
presses will be ignored until the Password is typed in. The only way to\r
disable the password is to type it in to a ConIn device.\r
\r
-Arguments:\r
- Password - Password used to lock ConIn device\r
-\r
+ @param Password Password used to lock ConIn device.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
+ @retval EFI_UNSUPPORTED Password not found.\r
\r
- EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo\r
- displayed.\r
- EFI_UNSUPPORTED - Logo not found\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LockKeyboards (\r
+ IN CHAR16 *Password\r
+ )\r
{\r
EFI_STATUS Status;\r
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
}\r
\r
\r
+/**\r
+ Use Console Control to turn off UGA based Simple Text Out consoles from going\r
+ to the UGA device. Put up LogoFile on every UGA device that is a console.\r
+\r
+ @param LogoFile File name of logo to display on the center of the screen.\r
+\r
+ @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
+ @retval EFI_UNSUPPORTED Logo not found.\r
+\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
EnableQuietBoot (\r
IN EFI_GUID *LogoFile\r
)\r
-/*++\r
-\r
-Routine Description:\r
+{\r
+ return EnableQuietBootEx (LogoFile, NULL);\r
+}\r
\r
+/**\r
Use Console Control to turn off UGA based Simple Text Out consoles from going\r
to the UGA device. Put up LogoFile on every UGA device that is a console\r
\r
-Arguments:\r
-\r
- LogoFile - File name of logo to display on the center of the screen.\r
+ @param LogoFile File name of logo to display on the center of the screen.\r
+ @param ImageHandle The driver image handle of the caller. The parameter is used to\r
+ optimize the loading of the logo file so that the FV from which\r
+ the driver image is loaded will be tried first.\r
\r
+ @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo displayed.\r
+ @retval EFI_UNSUPPORTED Logo not found.\r
\r
-Returns:\r
-\r
- EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo\r
- displayed.\r
- EFI_UNSUPPORTED - Logo not found\r
-\r
---*/\r
-{\r
- return EnableQuietBootEx (LogoFile, NULL);\r
-}\r
-\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
EnableQuietBootEx (\r
IN EFI_GUID *LogoFile,\r
IN EFI_HANDLE ImageHandle\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going\r
- to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console\r
-\r
-Arguments:\r
-\r
- LogoFile - File name of logo to display on the center of the screen.\r
- ImageHandle - The driver image handle of the caller. The parameter is used to\r
- optimize the loading of the logo file so that the FV from which\r
- the driver image is loaded will be tried first.\r
-\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo\r
- displayed.\r
- EFI_UNSUPPORTED - Logo not found\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
UINT32 RefreshRate;\r
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
\r
- Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);\r
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);\r
if (EFI_ERROR (Status)) {\r
return EFI_UNSUPPORTED;\r
}\r
//\r
// Try to open GOP first\r
//\r
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID**)&GraphicsOutput);\r
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);\r
if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
GraphicsOutput = NULL;\r
//\r
// Open GOP failed, try to open UGA\r
//\r
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID**)&UgaDraw);\r
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);\r
}\r
if (EFI_ERROR (Status)) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
Badging = NULL;\r
- Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID**)&Badging);\r
+ Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID **) &Badging);\r
\r
+ //\r
+ // Set console control to graphics mode.\r
+ //\r
Status = ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);\r
if (EFI_ERROR (Status)) {\r
return EFI_UNSUPPORTED;\r
ImageSize = 0;\r
\r
if (Badging != NULL) {\r
+ //\r
+ // Get image from OEMBadging protocol.\r
+ //\r
Status = Badging->GetImage (\r
Badging,\r
&Instance,\r
}\r
\r
//\r
- // Currently only support BMP format\r
+ // Currently only support BMP format.\r
//\r
if (Format != EfiBadgingFormatBMP) {\r
- gBS->FreePool (ImageData);\r
+ if (ImageData != NULL) {\r
+ FreePool (ImageData);\r
+ }\r
continue;\r
}\r
} else {\r
- Status = GetGraphicsBitMapFromFVEx (ImageHandle, LogoFile, (VOID **) &ImageData, &ImageSize);\r
+ //\r
+ // Get the specified image from FV.\r
+ //\r
+ Status = GetSectionFromAnyFv (LogoFile, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);\r
if (EFI_ERROR (Status)) {\r
return EFI_UNSUPPORTED;\r
}\r
Status = ConvertBmpToGopBlt (\r
ImageData,\r
ImageSize,\r
- (VOID**)&Blt,\r
+ (VOID **) &Blt,\r
&BltSize,\r
&Height,\r
&Width\r
);\r
if (EFI_ERROR (Status)) {\r
- gBS->FreePool (ImageData);\r
+ if (ImageData != NULL) {\r
+ FreePool (ImageData);\r
+ }\r
if (Badging == NULL) {\r
return Status;\r
} else {\r
}\r
}\r
\r
+ //\r
+ // Caculate the display position according to Attribute.\r
+ //\r
switch (Attribute) {\r
case EfiBadgingDisplayAttributeLeftTop:\r
DestX = CoordinateX;\r
}\r
}\r
\r
- gBS->FreePool (ImageData);\r
- gBS->FreePool (Blt);\r
+ if (ImageData != NULL) {\r
+ FreePool (ImageData);\r
+ }\r
+ if (Blt != NULL) {\r
+ FreePool (Blt);\r
+ }\r
\r
if (Badging == NULL) {\r
break;\r
return Status;\r
}\r
\r
+/**\r
+ Use Console Control to turn on UGA based Simple Text Out consoles. The UGA \r
+ Simple Text Out screens will now be synced up with all non UGA output devices\r
\r
+ @retval EFI_SUCCESS UGA devices are back in text mode and synced up.\r
+ @retval EFI_UNSUPPORTED Logo not found\r
+\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
DisableQuietBoot (\r
VOID\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA\r
- Simple Text Out screens will now be synced up with all non GOP/UGA output devices\r
-\r
-Arguments:\r
-\r
- NONE\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - GOP/UGA devices are back in text mode and synced up.\r
- EFI_UNSUPPORTED - Logo not found\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;\r
return EFI_UNSUPPORTED;\r
}\r
\r
- return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
-}\r
-\r
-UINTN\r
-_IPrint (\r
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r
- IN EFI_UGA_DRAW_PROTOCOL *UgaDraw,\r
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto,\r
- IN UINTN X,\r
- IN UINTN Y,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,\r
- IN CHAR16 *fmt,\r
- IN VA_LIST args\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Display string worker for: Print, PrintAt, IPrint, IPrintAt\r
-\r
-Arguments:\r
-\r
- GraphicsOutput - Graphics output protocol interface\r
-\r
- UgaDraw - UGA draw protocol interface\r
-\r
- Sto - Simple text out protocol interface\r
-\r
- X - X coordinate to start printing\r
-\r
- Y - Y coordinate to start printing\r
-\r
- Foreground - Foreground color\r
-\r
- Background - Background color\r
-\r
- fmt - Format string\r
-\r
- args - Print arguments\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - success\r
- EFI_OUT_OF_RESOURCES - out of resources\r
-\r
---*/\r
-{\r
- VOID *Buffer;\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- CHAR16 *UnicodeWeight;\r
- UINT32 HorizontalResolution;\r
- UINT32 VerticalResolution;\r
- UINT32 ColorDepth;\r
- UINT32 RefreshRate;\r
- UINTN BufferLen;\r
- UINTN LineBufferLen;\r
- EFI_HII_FONT_PROTOCOL *HiiFont;\r
- EFI_IMAGE_OUTPUT *Blt;\r
- EFI_FONT_DISPLAY_INFO *FontInfo;\r
-\r
//\r
- // For now, allocate an arbitrarily long buffer\r
+ // Set console control to text mode.\r
//\r
- Buffer = AllocateZeroPool (0x10000);\r
- if (Buffer == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- HorizontalResolution = 0;\r
- VerticalResolution = 0;\r
- Blt = NULL;\r
- FontInfo = NULL;\r
-\r
- if (GraphicsOutput != NULL) {\r
- HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
- VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);\r
- } else {\r
- Status = EFI_UNSUPPORTED;\r
- goto Error;\r
- }\r
-\r
- ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
-\r
- ASSERT (GraphicsOutput != NULL);\r
- Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
- if (EFI_ERROR (Status)) {\r
- goto Error;\r
- }\r
-\r
- UnicodeVSPrint (Buffer, 0x10000, fmt, args);\r
-\r
- UnicodeWeight = (CHAR16 *) Buffer;\r
-\r
- for (Index = 0; UnicodeWeight[Index] != 0; Index++) {\r
- if (UnicodeWeight[Index] == CHAR_BACKSPACE ||\r
- UnicodeWeight[Index] == CHAR_LINEFEED ||\r
- UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {\r
- UnicodeWeight[Index] = 0;\r
- }\r
- }\r
-\r
- BufferLen = StrLen (Buffer);\r
-\r
-\r
- LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;\r
- if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
- Status = EFI_INVALID_PARAMETER;\r
- goto Error;\r
- }\r
-\r
- Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));\r
- if (Blt == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error;\r
- }\r
-\r
- Blt->Width = (UINT16) (HorizontalResolution);\r
- Blt->Height = (UINT16) (VerticalResolution);\r
- Blt->Image.Screen = GraphicsOutput;\r
-\r
- FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));\r
- if (FontInfo == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error;\r
- }\r
- if (Foreground != NULL) {\r
- CopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
- } else {\r
- CopyMem (\r
- &FontInfo->ForegroundColor,\r
- &mEfiColors[Sto->Mode->Attribute & 0x0f],\r
- sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
- );\r
- }\r
- if (Background != NULL) {\r
- CopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
- } else {\r
- CopyMem (\r
- &FontInfo->BackgroundColor,\r
- &mEfiColors[Sto->Mode->Attribute >> 4],\r
- sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
- );\r
- }\r
-\r
- Status = HiiFont->StringToImage (\r
- HiiFont,\r
- EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,\r
- Buffer,\r
- FontInfo,\r
- &Blt,\r
- X,\r
- Y,\r
- NULL,\r
- NULL,\r
- NULL\r
- );\r
-\r
-\r
-Error:\r
- SafeFreePool (Blt);\r
- SafeFreePool (FontInfo);\r
- gBS->FreePool (Buffer);\r
- return Status;\r
-}\r
-\r
-UINTN\r
-PrintXY (\r
- IN UINTN X,\r
- IN UINTN Y,\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL\r
- IN CHAR16 *Fmt,\r
- ...\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Prints a formatted unicode string to the default console\r
-\r
-Arguments:\r
-\r
- X - X coordinate to start printing\r
-\r
- Y - Y coordinate to start printing\r
-\r
- ForeGround - Foreground color\r
-\r
- BackGround - Background color\r
-\r
- Fmt - Format string\r
-\r
- ... - Print arguments\r
-\r
-Returns:\r
-\r
- Length of string printed to the console\r
-\r
---*/\r
-{\r
- EFI_HANDLE Handle;\r
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Sto;\r
- EFI_STATUS Status;\r
- VA_LIST Args;\r
-\r
- VA_START (Args, Fmt);\r
-\r
- Handle = gST->ConsoleOutHandle;\r
-\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiGraphicsOutputProtocolGuid,\r
- (VOID**)&GraphicsOutput\r
- );\r
-\r
- UgaDraw = NULL;\r
- if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
- GraphicsOutput = NULL;\r
-\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiUgaDrawProtocolGuid,\r
- (VOID**)&UgaDraw\r
- );\r
- }\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- (VOID**)&Sto\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+ return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);\r
}\r
\r