X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FLibrary%2FGraphicsLib%2FGraphics.c;h=50eb1f56bc0d58f18ddbb84f6b6eb39bf97666c0;hp=0881c3d9656643a507a22a06ebb6096f07d349ec;hb=62409219a151c88d2e9be05533c018d7b824c566;hpb=3db510989eb500296c3f4839c427325a02aea2e3 diff --git a/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c b/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c index 0881c3d965..50eb1f56bc 100644 --- a/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c +++ b/IntelFrameworkModulePkg/Library/GraphicsLib/Graphics.c @@ -5,21 +5,36 @@ when Tiano graphics format is supported. -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -// -// Include common header file for this module. -// -#include "CommonHeader.h" + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include EFI_STATUS GetGraphicsBitMapFromFV ( @@ -39,15 +54,15 @@ Arguments: FileNameGuid - File Name of graphics file in the FV(s). - Image - Pointer to pointer to return graphics image. If NULL, a + Image - Pointer to pointer to return graphics image. If NULL, a buffer will be allocated. ImageSize - Size of the graphics Image in bytes. Zero if no image found. -Returns: +Returns: - EFI_SUCCESS - Image and ImageSize are valid. + EFI_SUCCESS - Image and ImageSize are valid. EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size EFI_NOT_FOUND - FileNameGuid not found @@ -56,14 +71,14 @@ Returns: EFI_STATUS Status; UINTN FvProtocolCount; EFI_HANDLE *FvHandles; - EFI_FIRMWARE_VOLUME_PROTOCOL *Fv; + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; UINTN Index; UINT32 AuthenticationStatus; Status = gBS->LocateHandleBuffer ( ByProtocol, - &gEfiFirmwareVolumeProtocolGuid, + &gEfiFirmwareVolume2ProtocolGuid, NULL, &FvProtocolCount, &FvHandles @@ -75,7 +90,7 @@ Returns: for (Index = 0; Index < FvProtocolCount; Index++) { Status = gBS->HandleProtocol ( FvHandles[Index], - &gEfiFirmwareVolumeProtocolGuid, + &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &Fv ); @@ -118,8 +133,8 @@ ConvertBmpToGopBlt ( Routine Description: - Convert a *.BMP graphics image to a UGA blt buffer. If a NULL UgaBlt buffer - is passed in a UgaBlt buffer will be allocated by this routine. If a UgaBlt + Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer + is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt buffer is passed in it will be used if it is big enough. Arguments: @@ -128,21 +143,21 @@ Arguments: BmpImageSize - Number of bytes in BmpImage - UgaBlt - Buffer containing UGA version of BmpImage. + GopBlt - Buffer containing GOP version of BmpImage. - UgaBltSize - Size of UgaBlt in bytes. + GopBltSize - Size of GopBlt in bytes. - PixelHeight - Height of UgaBlt/BmpImage in pixels + PixelHeight - Height of GopBlt/BmpImage in pixels - PixelWidth - Width of UgaBlt/BmpImage in pixels + PixelWidth - Width of GopBlt/BmpImage in pixels -Returns: +Returns: - EFI_SUCCESS - UgaBlt and UgaBltSize are returned. + EFI_SUCCESS - GopBlt and GopBltSize are returned. EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image - EFI_BUFFER_TOO_SMALL - The passed in UgaBlt buffer is not big enough. - UgaBltSize will contain the required size. + EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough. + GopBltSize will contain the required size. EFI_OUT_OF_RESOURCES - No enough buffer to allocate --*/ @@ -159,7 +174,7 @@ Returns: UINTN Width; UINTN ImageIndex; BOOLEAN IsAllocated; - + BmpHeader = (BMP_IMAGE_HEADER *) BmpImage; if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') { return EFI_UNSUPPORTED; @@ -223,7 +238,7 @@ Returns: Blt --; Width --; break; - + case 4: // // Convert BMP Palette to 24-bit color @@ -288,7 +303,7 @@ LockKeyboards ( /*++ Routine Description: - Use Console Control Protocol to lock the Console In Spliter virtual handle. + Use Console Control Protocol to lock the Console In Spliter virtual handle. This is the ConInHandle and ConIn handle in the EFI system table. All key presses will be ignored until the Password is typed in. The only way to disable the password is to type it in to a ConIn device. @@ -297,7 +312,7 @@ Arguments: Password - Password used to lock ConIn device -Returns: +Returns: EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo displayed. @@ -334,7 +349,7 @@ Arguments: LogoFile - File name of logo to display on the center of the screen. -Returns: +Returns: EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo displayed. @@ -374,7 +389,7 @@ Returns: // // Try to open GOP first // - Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput); + Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput); if (EFI_ERROR(Status)) { GraphicsOutput = NULL; // @@ -560,16 +575,16 @@ DisableQuietBoot ( Routine Description: - Use Console Control to turn on UGA based Simple Text Out consoles. The UGA - Simple Text Out screens will now be synced up with all non UGA output devices + Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA + Simple Text Out screens will now be synced up with all non GOP/UGA output devices Arguments: NONE -Returns: +Returns: - EFI_SUCCESS - UGA devices are back in text mode and synced up. + EFI_SUCCESS - GOP/UGA devices are back in text mode and synced up. EFI_UNSUPPORTED - Logo not found --*/ @@ -626,45 +641,47 @@ Routine Description: Arguments: GraphicsOutput - Graphics output protocol interface - + UgaDraw - UGA draw protocol interface - + Sto - Simple text out protocol interface - + X - X coordinate to start printing - + Y - Y coordinate to start printing - + Foreground - Foreground color - + Background - Background color - + fmt - Format string - + args - Print arguments -Returns: +Returns: EFI_SUCCESS - success EFI_OUT_OF_RESOURCES - out of resources --*/ { - VOID *Buffer; - EFI_STATUS Status; - UINT16 GlyphWidth; - UINT32 GlyphStatus; - UINT16 StringIndex; - UINTN Index; - CHAR16 *UnicodeWeight; - EFI_NARROW_GLYPH *Glyph; - EFI_HII_PROTOCOL *Hii; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer; - UINT32 HorizontalResolution; - UINT32 VerticalResolution; - UINT32 ColorDepth; - UINT32 RefreshRate; - UINTN BufferGlyphWidth; + VOID *Buffer; + EFI_STATUS Status; + UINT16 GlyphWidth; + UINT32 GlyphStatus; + UINT16 StringIndex; + UINTN Index; + CHAR16 *UnicodeWeight; + EFI_NARROW_GLYPH *Glyph; + EFI_HII_PROTOCOL *Hii; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer; + UINT32 HorizontalResolution; + UINT32 VerticalResolution; + UINT32 ColorDepth; + UINT32 RefreshRate; + UINTN BufferLen; + UINTN LineBufferLen; + UINTN BufferGlyphWidth; GlyphStatus = 0; @@ -675,7 +692,7 @@ Returns: if (Buffer == NULL) { return EFI_OUT_OF_RESOURCES; } - + if (GraphicsOutput != NULL) { HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution; VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution; @@ -685,8 +702,10 @@ Returns: // UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); } + ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0)); - LineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_WIDTH * GLYPH_HEIGHT); + LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT; + LineBuffer = AllocatePool (LineBufferLen); if (LineBuffer == NULL) { gBS->FreePool (Buffer); return EFI_OUT_OF_RESOURCES; @@ -709,7 +728,14 @@ Returns: } } - for (Index = 0; Index < StrLen (Buffer); Index++) { + BufferLen = StrLen (Buffer); + + if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) { + Status = EFI_INVALID_PARAMETER; + goto Error; + } + + for (Index = 0; Index < BufferLen; Index++) { StringIndex = (UINT16) Index; Status = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus); if (EFI_ERROR (Status)) { @@ -722,7 +748,7 @@ Returns: (UINT8 *) Glyph, mEfiColors[Sto->Mode->Attribute & 0x0f], mEfiColors[Sto->Mode->Attribute >> 4], - StrLen (Buffer), + BufferLen, GlyphWidth, GLYPH_HEIGHT, &LineBuffer[Index * GLYPH_WIDTH] @@ -733,7 +759,7 @@ Returns: (UINT8 *) Glyph, *Foreground, *Background, - StrLen (Buffer), + BufferLen, GlyphWidth, GLYPH_HEIGHT, &LineBuffer[Index * GLYPH_WIDTH] @@ -744,7 +770,7 @@ Returns: // // Blt a character to the screen // - BufferGlyphWidth = GLYPH_WIDTH * StrLen (Buffer); + BufferGlyphWidth = GLYPH_WIDTH * BufferLen; if (GraphicsOutput != NULL) { Status = GraphicsOutput->Blt ( GraphicsOutput, @@ -798,11 +824,11 @@ Routine Description: Arguments: X - X coordinate to start printing - + Y - Y coordinate to start printing - + ForeGround - Foreground color - + BackGround - Background color Fmt - Format string