/*++\r
\r
-Copyright (c) 2004 - 2006, Intel Corporation \r
+Copyright (c) 2004 - 2007, 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 "PrintWidth.h"\r
#include "EfiPrintLib.h"\r
#include "Print.h"\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+#include EFI_PROTOCOL_DEFINITION (HiiFont)\r
+#else\r
#include EFI_PROTOCOL_DEFINITION (Hii)\r
+#endif\r
\r
static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {\r
0x00, 0x00, 0x00, 0x00,\r
{\r
VOID *Buffer;\r
EFI_STATUS Status;\r
- UINT16 GlyphWidth;\r
- UINT32 GlyphStatus;\r
- UINT16 StringIndex;\r
UINTN Index;\r
CHAR16 *UnicodeWeight;\r
- EFI_NARROW_GLYPH *Glyph;\r
- EFI_HII_PROTOCOL *Hii;\r
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;\r
UINT32 HorizontalResolution;\r
UINT32 VerticalResolution;\r
UINT32 ColorDepth;\r
UINT32 RefreshRate;\r
UINTN BufferLen;\r
UINTN LineBufferLen;\r
-\r
- GlyphStatus = 0;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+ EFI_HII_FONT_PROTOCOL *HiiFont;\r
+ EFI_IMAGE_OUTPUT *Blt;\r
+ EFI_FONT_DISPLAY_INFO *FontInfo; \r
+#else\r
+ EFI_HII_PROTOCOL *Hii;\r
+ UINT16 GlyphWidth;\r
+ UINT32 GlyphStatus;\r
+ UINT16 StringIndex;\r
+ EFI_NARROW_GLYPH *Glyph;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;\r
+#endif\r
\r
//\r
// For now, allocate an arbitrarily long buffer\r
}\r
ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));\r
\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+ Blt = NULL;\r
+ FontInfo = NULL;\r
+ ASSERT (GraphicsOutput != NULL);\r
+ Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ } \r
+#else \r
+ LineBuffer = NULL;\r
+ Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID**)&Hii);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT;\r
LineBuffer = EfiLibAllocatePool (LineBufferLen);\r
if (LineBuffer == NULL) {\r
- gBS->FreePool (Buffer);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, &Hii);\r
- if (EFI_ERROR (Status)) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Error;\r
- }\r
+ } \r
+#endif\r
\r
VSPrint (Buffer, 0x10000, fmt, args);\r
\r
\r
BufferLen = EfiStrLen (Buffer);\r
\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\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 *) EfiLibAllocateZeroPool (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 *) EfiLibAllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));\r
+ if (FontInfo == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error;\r
+ }\r
+ if (Foreground != NULL) {\r
+ EfiCopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ } else {\r
+ EfiCopyMem (\r
+ &FontInfo->ForegroundColor, \r
+ &mEfiColors[Sto->Mode->Attribute & 0x0f], \r
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
+ );\r
+ }\r
+ if (Background != NULL) {\r
+ EfiCopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ } else {\r
+ EfiCopyMem (\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
+#else\r
+ GlyphStatus = 0;\r
+\r
if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {\r
Status = EFI_INVALID_PARAMETER;\r
goto Error;\r
);\r
}\r
\r
+#endif\r
+\r
Error:\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+ EfiLibSafeFreePool (Blt);\r
+ EfiLibSafeFreePool (FontInfo);\r
+#else\r
gBS->FreePool (LineBuffer);\r
+#endif \r
gBS->FreePool (Buffer);\r
return Status;\r
}\r
}\r
\r
UINTN\r
+EFIAPI\r
VSPrint (\r
OUT CHAR_W *StartOfBuffer,\r
IN UINTN BufferSize,\r