From 93e3992d1ea50fb30c48f498d257d4e66252dd9b Mon Sep 17 00:00:00 2001 From: qwang12 Date: Mon, 21 Jan 2008 14:39:56 +0000 Subject: UEFI HII: Merge UEFI HII support changes from branch. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4599 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Console/GraphicsConsoleDxe/GraphicsConsole.c | 180 ++++++++++++++++++--- 1 file changed, 155 insertions(+), 25 deletions(-) (limited to 'MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c') diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index 37e816af01..77a209e1e4 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -83,10 +83,19 @@ GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = { { 0, 0, 0, 0, 0, 0 } // Mode 3 }, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL, - (EFI_HII_HANDLE) 0 + (EFI_HII_HANDLE ) 0 }; +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; +EFI_HII_FONT_PROTOCOL *mHiiFont; +BOOLEAN mFirstAccessFlag = TRUE; + +STATIC EFI_GUID mFontPackageListGuid = {0xf5f219d3, 0x7006, 0x4648, 0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad}; + +#else EFI_HII_PROTOCOL *mHii; +#endif static CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL }; @@ -194,6 +203,7 @@ GraphicsConsoleControllerDriverSupported ( } else { goto Error; } + // // Does Hii Exist? If not, we aren't ready to run // @@ -249,8 +259,6 @@ GraphicsConsoleControllerDriverStart ( { EFI_STATUS Status; GRAPHICS_CONSOLE_DEV *Private; - EFI_HII_PACKAGES *Package; - EFI_HII_FONT_PACK *FontPack; UINTN NarrowFontSize; UINT32 HorizontalResolution; UINT32 VerticalResolution; @@ -259,9 +267,8 @@ GraphicsConsoleControllerDriverStart ( UINTN MaxMode; UINTN Columns; UINTN Rows; - UINT8 *Location; UINT32 ModeNumber; - + ModeNumber = 0; // @@ -301,17 +308,14 @@ GraphicsConsoleControllerDriverStart ( } } - // - // Get the HII protocol. If Supported() succeeds, do we really - // need to get HII protocol again? - // - Status = EfiLocateHiiProtocol (); - if (EFI_ERROR (Status)) { - goto Error; - } - NarrowFontSize = ReturnNarrowFontSize (); +#if 1 + if (mFirstAccessFlag) { + HiiLibAddFontPackageToHiiDatabase (NarrowFontSize, (UINT8 *) UsStdNarrowGlyphData, &mFontPackageListGuid, &(Private->HiiHandle)); + mFirstAccessFlag = FALSE; + } +#else FontPack = AllocateZeroPool (sizeof (EFI_HII_FONT_PACK) + NarrowFontSize); ASSERT (FontPack); @@ -333,7 +337,7 @@ GraphicsConsoleControllerDriverStart ( // Free the font database // FreePool (FontPack); - +#endif // // If the current mode information can not be retrieved, then attemp to set the default mode // of 800x600, 32 bit colot, 60 Hz refresh. @@ -614,7 +618,14 @@ GraphicsConsoleControllerDriverStop ( // // Remove the font pack // +#if 1 + Status = HiiLibRemovePackagesFromHiiDatabase (Private->HiiHandle); + if (!EFI_ERROR (Status)) { + mFirstAccessFlag = TRUE; + } +#else mHii->RemovePack (mHii, Private->HiiHandle); +#endif // // Free our instance data @@ -678,7 +689,7 @@ EfiLocateHiiProtocol ( /*++ Routine Description: - Find if the HII protocol is available. If yes, locate the HII protocol + Locate HII protocols for future usage. Arguments: @@ -690,6 +701,43 @@ EfiLocateHiiProtocol ( UINTN Size; EFI_STATUS Status; +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) + + // + // There should only be one - so buffer size is this + // + Size = sizeof (EFI_HANDLE); + + Status = gBS->LocateHandle ( + ByProtocol, + &gEfiHiiDatabaseProtocolGuid, + NULL, + &Size, + (VOID **) &Handle + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->HandleProtocol ( + Handle, + &gEfiHiiDatabaseProtocolGuid, + (VOID **) &mHiiDatabase + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->HandleProtocol ( + Handle, + &gEfiHiiFontProtocolGuid, + (VOID **) &mHiiFont + ); + return Status; +#else + // // There should only be one - so buffer size is this // @@ -710,11 +758,13 @@ EfiLocateHiiProtocol ( Status = gBS->HandleProtocol ( Handle, &gEfiHiiProtocolGuid, - (VOID **)&mHii + &mHii ); return Status; +#endif } + // // Body of the STO functions // @@ -1090,15 +1140,31 @@ GraphicsConsoleConOutTestString ( --*/ { EFI_STATUS Status; - UINT16 GlyphWidth; - UINT32 GlyphStatus; UINT16 Count; - GLYPH_UNION *Glyph; - - GlyphStatus = 0; - Count = 0; - while (WString[Count]) { +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) + EFI_IMAGE_OUTPUT *Blt = NULL; +#else + UINT16 GlyphWidth; + UINT32 GlyphStatus = 0; + GLYPH_UNION *Glyph; +#endif + + Count = 0; + + while (WString[Count] != 0) { +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) + Status = mHiiFont->GetGlyph ( + mHiiFont, + WString[Count], + NULL, + &Blt, + NULL + ); + SafeFreePool (Blt); + Blt = NULL; + Count++; +#else Status = mHii->GetGlyph ( mHii, WString, @@ -1107,7 +1173,7 @@ GraphicsConsoleConOutTestString ( &GlyphWidth, &GlyphStatus ); - +#endif if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } @@ -1654,6 +1720,69 @@ GetTextColors ( return EFI_SUCCESS; } +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +EFI_STATUS +DrawUnicodeWeightAtCursorN ( + IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, + IN CHAR16 *UnicodeWeight, + IN UINTN Count + ) +{ + EFI_STATUS Status; + GRAPHICS_CONSOLE_DEV *Private; + EFI_IMAGE_OUTPUT *Blt; + EFI_STRING String; + EFI_FONT_DISPLAY_INFO *FontInfo; + + Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This); + // + // GOP protocol is required in UEFI mode. + // + ASSERT (Private->GraphicsOutput != NULL); + + Blt = (EFI_IMAGE_OUTPUT *) AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT)); + if (Blt == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Blt->Width = (UINT16) (Private->ModeData[This->Mode->Mode].GopWidth); + Blt->Height = (UINT16) (Private->ModeData[This->Mode->Mode].GopHeight); + Blt->Image.Screen = Private->GraphicsOutput; + + String = AllocateCopyPool ((Count + 1) * sizeof (CHAR16), UnicodeWeight); + if (String == NULL) { + SafeFreePool (Blt); + return EFI_OUT_OF_RESOURCES; + } + *(String + Count) = 0; + + FontInfo = (EFI_FONT_DISPLAY_INFO *) AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO)); + if (FontInfo == NULL) { + SafeFreePool (Blt); + SafeFreePool (String); + return EFI_OUT_OF_RESOURCES; + } + GetTextColors (This, &FontInfo->ForegroundColor, &FontInfo->BackgroundColor); + + Status = mHiiFont->StringToImage ( + mHiiFont, + EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN, + String, + FontInfo, + &Blt, + This->Mode->CursorColumn * GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX, + This->Mode->CursorRow * GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY, + NULL, + NULL, + NULL + ); + + SafeFreePool (Blt); + SafeFreePool (String); + SafeFreePool (FontInfo); + return Status; +} +#else STATIC EFI_STATUS DrawUnicodeWeightAtCursorN ( @@ -1794,6 +1923,7 @@ DrawUnicodeWeightAtCursorN ( return ReturnStatus; } +#endif STATIC EFI_STATUS -- cgit v1.2.3