From 31bb486c913795c8b67d1c4dbaae2bdec4943fc9 Mon Sep 17 00:00:00 2001 From: raywu Date: Thu, 13 Sep 2018 16:11:56 +0800 Subject: SLP1.0 / SLP2.0 / Default Password / Logo / Fix Boot Order --- EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c | 103 + EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h | 104 + EDK/MiniSetup/BootOnly/EDKhelper.c | 1737 +++++++++++++++++ EDK/MiniSetup/BootOnly/EDKhelper.h | 419 +++++ EDK/MiniSetup/BootOnly/HookAnchor.c | 676 +++++++ EDK/MiniSetup/BootOnly/MiniSetup.cif | 47 + EDK/MiniSetup/BootOnly/MiniSetup.mak | 138 ++ EDK/MiniSetup/BootOnly/MiniSetup.sdl | 83 + EDK/MiniSetup/BootOnly/Resources.c | 231 +++ EDK/MiniSetup/BootOnly/Timer.h | 91 + EDK/MiniSetup/BootOnly/amiver.h | 143 ++ EDK/MiniSetup/BootOnly/bbs.c | 1552 +++++++++++++++ EDK/MiniSetup/BootOnly/bbs.h | 146 ++ EDK/MiniSetup/BootOnly/boot.c | 3034 ++++++++++++++++++++++++++++++ EDK/MiniSetup/BootOnly/box.c | 241 +++ EDK/MiniSetup/BootOnly/box.h | 95 + EDK/MiniSetup/BootOnly/buffer.c | 501 +++++ EDK/MiniSetup/BootOnly/buffer.h | 95 + EDK/MiniSetup/BootOnly/dobmpmgr.c | 301 +++ EDK/MiniSetup/BootOnly/globals.c | 212 +++ EDK/MiniSetup/BootOnly/hiistring.c | 251 +++ EDK/MiniSetup/BootOnly/hiistring.h | 153 ++ EDK/MiniSetup/BootOnly/logo.c | 1163 ++++++++++++ EDK/MiniSetup/BootOnly/mem.c | 255 +++ EDK/MiniSetup/BootOnly/minisetup.c | 551 ++++++ EDK/MiniSetup/BootOnly/minisetup.h | 1519 +++++++++++++++ EDK/MiniSetup/BootOnly/minisetupext.c | 927 +++++++++ EDK/MiniSetup/BootOnly/notify.c | 1271 +++++++++++++ EDK/MiniSetup/BootOnly/password.c | 253 +++ EDK/MiniSetup/BootOnly/password.h | 111 ++ EDK/MiniSetup/BootOnly/postmgmt.c | 897 +++++++++ EDK/MiniSetup/BootOnly/postmgmtext.c | 964 ++++++++++ EDK/MiniSetup/BootOnly/print.c | 476 +++++ EDK/MiniSetup/BootOnly/protocol.c | 1870 ++++++++++++++++++ EDK/MiniSetup/BootOnly/protocol.h | 198 ++ EDK/MiniSetup/BootOnly/screen.c | 346 ++++ EDK/MiniSetup/BootOnly/screen.h | 96 + EDK/MiniSetup/BootOnly/string.c | 1488 +++++++++++++++ EDK/MiniSetup/BootOnly/string.h | 158 ++ EDK/MiniSetup/BootOnly/timer.c | 154 ++ EDK/MiniSetup/BootOnly/variable.c | 204 ++ 41 files changed, 23254 insertions(+) create mode 100644 EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c create mode 100644 EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h create mode 100644 EDK/MiniSetup/BootOnly/EDKhelper.c create mode 100644 EDK/MiniSetup/BootOnly/EDKhelper.h create mode 100644 EDK/MiniSetup/BootOnly/HookAnchor.c create mode 100644 EDK/MiniSetup/BootOnly/MiniSetup.cif create mode 100644 EDK/MiniSetup/BootOnly/MiniSetup.mak create mode 100644 EDK/MiniSetup/BootOnly/MiniSetup.sdl create mode 100644 EDK/MiniSetup/BootOnly/Resources.c create mode 100644 EDK/MiniSetup/BootOnly/Timer.h create mode 100644 EDK/MiniSetup/BootOnly/amiver.h create mode 100644 EDK/MiniSetup/BootOnly/bbs.c create mode 100644 EDK/MiniSetup/BootOnly/bbs.h create mode 100644 EDK/MiniSetup/BootOnly/boot.c create mode 100644 EDK/MiniSetup/BootOnly/box.c create mode 100644 EDK/MiniSetup/BootOnly/box.h create mode 100644 EDK/MiniSetup/BootOnly/buffer.c create mode 100644 EDK/MiniSetup/BootOnly/buffer.h create mode 100644 EDK/MiniSetup/BootOnly/dobmpmgr.c create mode 100644 EDK/MiniSetup/BootOnly/globals.c create mode 100644 EDK/MiniSetup/BootOnly/hiistring.c create mode 100644 EDK/MiniSetup/BootOnly/hiistring.h create mode 100644 EDK/MiniSetup/BootOnly/logo.c create mode 100644 EDK/MiniSetup/BootOnly/mem.c create mode 100644 EDK/MiniSetup/BootOnly/minisetup.c create mode 100644 EDK/MiniSetup/BootOnly/minisetup.h create mode 100644 EDK/MiniSetup/BootOnly/minisetupext.c create mode 100644 EDK/MiniSetup/BootOnly/notify.c create mode 100644 EDK/MiniSetup/BootOnly/password.c create mode 100644 EDK/MiniSetup/BootOnly/password.h create mode 100644 EDK/MiniSetup/BootOnly/postmgmt.c create mode 100644 EDK/MiniSetup/BootOnly/postmgmtext.c create mode 100644 EDK/MiniSetup/BootOnly/print.c create mode 100644 EDK/MiniSetup/BootOnly/protocol.c create mode 100644 EDK/MiniSetup/BootOnly/protocol.h create mode 100644 EDK/MiniSetup/BootOnly/screen.c create mode 100644 EDK/MiniSetup/BootOnly/screen.h create mode 100644 EDK/MiniSetup/BootOnly/string.c create mode 100644 EDK/MiniSetup/BootOnly/string.h create mode 100644 EDK/MiniSetup/BootOnly/timer.c create mode 100644 EDK/MiniSetup/BootOnly/variable.c (limited to 'EDK/MiniSetup/BootOnly') diff --git a/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c new file mode 100644 index 0000000..c85be31 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c @@ -0,0 +1,103 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.c $ +// +// $Author: Premkumara $ +// +// $Revision: 7 $ +// +// $Date: 8/28/14 5:29a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.c $ +// +// 7 8/28/14 5:29a Premkumara +// EIP-135253 Updating file name proper in #include +// +// 6 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 8 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 5 2/26/10 8:53p Madhans +// For TSE 2.01.1024. refer changelog.log for file checkin history . +// +// 5 2/26/10 1:30p Madhans +// To avoid build issues with EDK. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 8/17/09 12:22p Presannar +// Removed References to Tiano.h +// +// 2 6/23/09 6:55p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: AMILogo.c +// +// Description: This file contains code to handle logo. +// +//---------------------------------------------------------------------------- +// + +#ifdef TSE_FOR_APTIO_4_50 +#include "Token.h" +#else +#include "tokens.h" +#endif + +#if TSE_USE_EDK_LIBRARY +#include "Tiano.h" +#else +#include "Efi.h" +#endif + +#include "AMILogo.h" + +EFI_GUID gAMIEfiLogoGuid = AMI_EFI_LOGO_GUID; +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h new file mode 100644 index 0000000..14a1ccb --- /dev/null +++ b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h @@ -0,0 +1,104 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2012, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.h $ +// +// $Author: Arunsb $ +// +// $Revision: 6 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.h $ +// +// 6 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 8 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 5 1/31/12 1:22p Premkumara +// [TAG] EIP75136 +// [Category] New Feature +// [Description] Generic support for logos in RomHoles +// [Files] CommomHelper.c, AMITSE.sdl, AMITSE.mak, LogoLib.h, +// Postmgmt.c, AMILogo.h +// +// 4 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 5 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 4 6/24/09 6:09p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:55p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: AMILogo.h +// +// Description: header file to define logo related stuff. +// +//---------------------------------------------------------------------------- +// + +#ifndef _AMI_LOGO_FV_ +#define _AMI_LOGO_FV_ + +#define FOUR_GB_LIMIT 0x100000000 +//{63819805-67BB-46ef-AA8D-1524A19A01E4} +#define AMI_EFI_LOGO_GUID \ + { 0x63819805, 0x67BB, 0x46ef, 0xAA, 0x8D, 0x15, 0x24, 0xA1, 0x9A, 0x01, 0xE4} + +extern EFI_GUID gAMIEfiLogoGuid; +#endif //_AMI_LOGO_FV_ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/EDKhelper.c b/EDK/MiniSetup/BootOnly/EDKhelper.c new file mode 100644 index 0000000..b0aabd9 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/EDKhelper.c @@ -0,0 +1,1737 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.c $ +// +// $Author: Arunsb $ +// +// $Revision: 11 $ +// +// $Date: 2/11/14 8:14p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.c $ +// +// 11 2/11/14 8:14p Arunsb +// [TAG] EIP125719 +// [Category] Improvement +// [Description] The EfiCreateEventReadyToBoot is conflicted under +// UefiLib.h and EDKhelper.h. +// [Files] boot.c, EDKhelper.c and EDKHelper.h +// +// 10 5/22/13 10:26a Arunsb +// [TAG] EIP122907 +// [Category] Improvement +// [Description] Functions added for name value support +// +// 9 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 11 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 8 5/29/12 3:58a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 7 6/17/10 2:59p Madhans +// Dynamic parsing support in TSE. +// +// 6 4/23/10 6:22p Madhans +// To resolve Build issues with EDK support on. +// +// 5 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 7 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 6 1/09/10 5:49a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 5 7/31/09 6:27p Presannar +// Removed Redefinition of gEfiOEMBadgingProtocolGuid, EfiCopyMem +// +// 4 6/24/09 6:09p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 2 5/07/09 10:35a Madhans +// Changes after Bin module +// +// 3 5/06/09 8:09p Mallikarjunanv +// updated for if no edk lib support +// +// 2 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 1 3/31/09 3:33p Madhans +// To build with/without EDK libs. +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: EdkHelper.c +// +// Description: This file contains code from EDK library. +// +//---------------------------------------------------------------------------- +// + +/*++ + +Copyright (c) 2004 - 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. + +Module Name: + + xxxxxx.c + +Abstract: + + xxxxxxxxxxxx + +--*/ + +#include "minisetup.h" + +#if !TSE_USE_EDK_LIBRARY + +extern EFI_SYSTEM_TABLE *pST; +extern EFI_BOOT_SERVICES *pBS; +extern EFI_RUNTIME_SERVICES *pRS; + +#if !TSE_APTIO_5_SUPPORT +EFI_SYSTEM_TABLE *gST=NULL; +EFI_BOOT_SERVICES *gBS=NULL; +EFI_RUNTIME_SERVICES *gRT=NULL; +EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE_GUID; +EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT; +#endif + +#define EFI_SHELL_FILE_GUID \ + { 0xc57ad6b7, 0x0515, 0x40a8, 0x9d, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4e, 0x37 } +EFI_GUID gEfiShellFileGuid = EFI_SHELL_FILE_GUID; + +/* +#define EFI_GLOBAL_VARIABLE_GUID \ + { \ + 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C \ + } +*/ + +#define EFI_PRINT_PROTOCOL_GUID \ + { 0xdf2d868e, 0x32fc, 0x4cf0, 0x8e, 0x6b, 0xff, 0xd9, 0x5d, 0x13, 0x43, 0xd0 } + +EFI_GUID gEfiPrintProtocolGuid = EFI_PRINT_PROTOCOL_GUID; + +#ifndef EFI_OEM_BADGING_PROTOCOL_GUID +#define EFI_OEM_BADGING_PROTOCOL_GUID \ + { 0x170e13c0, 0xbf1b, 0x4218, 0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc } +#endif +//EFI_GUID gEfiOEMBadgingProtocolGuid = EFI_OEM_BADGING_PROTOCOL_GUID; +extern EFI_GUID gEfiOEMBadgingProtocolGuid; + +/* +#define EFI_EVENT_GROUP_READY_TO_BOOT \ + { 0x7ce88fb3, 0x4bd7, 0x4679, { 0x87, 0xa8, 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b } } +*/ +VOID InitAmiLib( + IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable +); + +// +//---------------------------------------------------------------------------- +// Procedure: EfiInitializeDriverLib +// +// Description: To avoid including EDK libs. +// +// Input: ImageHandle and Systemtable +// +// Output: Status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +EfiInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + InitAmiLib(ImageHandle,SystemTable); + gST = pST; + gBS = pBS; + gRT = pRS; + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiLibAllocateZeroPool +// +// Description: To avoid including EDK libs. +// +// Input: size +// +// Output: pointer +// +//---------------------------------------------------------------------------- +// +void* MallocZ(UINTN Size); +VOID * +EfiLibAllocateZeroPool ( + IN UINTN AllocationSize + ) +{ + return MallocZ(AllocationSize); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiLibAllocatePool +// +// Description: To avoid including EDK libs. +// +// Input: size +// +// Output: pointer +// +//---------------------------------------------------------------------------- +// +void* Malloc(UINTN Size); +VOID * +EfiLibAllocatePool ( + IN UINTN AllocationSize + ) +{ + return Malloc(AllocationSize); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiCompareGuid +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_GUID *Guid1, IN EFI_GUID *Guid2 +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN +EfiCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +{ + return (BOOLEAN)(0==MemCmp((UINT8*)Guid1,(UINT8*)Guid2,sizeof(EFI_GUID))); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiCompareMem +// +// Description: To avoid including EDK libs. +// +// Input: IN VOID *MemOne, IN VOID *MemTwo, +// +// Output: INTN +// +//---------------------------------------------------------------------------- +// +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Length + ) +{ + return MemCmp(MemOne,MemTwo,Length); +} + +// +//---------------------------------------------------------------------------- +// Procedure: Wcslen +// +// Description: To avoid including EDK libs. +// +// Input: CHAR16 *string +// +// Output: UINTN +// +//---------------------------------------------------------------------------- +// +UINTN Wcslen(CHAR16 *string); +UINTN +EfiStrLen ( + IN CHAR16 *String + ) +{ + return Wcslen(String); +} + +// +//---------------------------------------------------------------------------- +// Procedure: Wcscpy +// +// Description: To avoid including EDK libs. +// +// Input: CHAR16 *string1, CHAR16* string2 +// +// Output: CHAR16* +// +//---------------------------------------------------------------------------- +// +CHAR16* Wcscpy(CHAR16 *string1, CHAR16* string2); +VOID +EfiStrCpy ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +{ + Wcscpy(Destination,Source); +} + +// +//---------------------------------------------------------------------------- +// Procedure: Wcscmp +// +// Description: To avoid including EDK libs. +// +// Input: CHAR16 *string1, CHAR16 *string2 +// +// Output: int +// +//---------------------------------------------------------------------------- +// +int Wcscmp( CHAR16 *string1, CHAR16 *string2 ); +INTN +EfiStrCmp ( + IN CHAR16 *String, + IN CHAR16 *String2 + ) +{ + return Wcscmp( String, String2 ); +} + +int Strcmp( char *string1, char *string2 ); +INTN +EfiAsciiStrCmp ( + IN CHAR8 *String, + IN CHAR8 *String2 + ) +{ + return Strcmp( String, String2 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DPAdd +// +// Description: To avoid including EDK libs. +// +// Input: EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2 +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +VOID* DPAdd(EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2); + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +{ + return (EFI_DEVICE_PATH_PROTOCOL *)DPAdd(Src1,Src2); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DPAddNode +// +// Description: To avoid including EDK libs. +// +// Input: EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2 +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +VOID* DPAddNode(EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2); + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ) +{ + return (EFI_DEVICE_PATH_PROTOCOL *)DPAddNode(Src1, Src2); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiDevicePathFromHandle +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_HANDLE Handle +// +// Output: EFI_DEVICE_PATH_PROTOCOL * +// +//---------------------------------------------------------------------------- +// +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +/*++ + +Routine Description: + + Get the device path protocol interface installed on a specified handle. + +Arguments: + + Handle - a specified handle + +Returns: + + The device path protocol interface installed on that handle. + +--*/ +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + DevicePath = NULL; + gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *) &DevicePath + ); + return DevicePath; +} + +VOID +EfiStrCat ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +/*++ + +Routine Description: + Concatinate Source on the end of Destination + +Arguments: + Destination - String to added to the end of. + Source - String to concatinate. + +Returns: + NONE + +--*/ +{ + EfiStrCpy (Destination + EfiStrLen (Destination), Source); +} + +INTN +EfiStrnCmp ( + IN CHAR16 *String, + IN CHAR16 *String2, + IN UINTN Length + ) +/*++ + +Routine Description: + This function compares the Unicode string String to the Unicode + string String2 for len characters. If the first len characters + of String is identical to the first len characters of String2, + then 0 is returned. If substring of String sorts lexicographically + after String2, the function returns a number greater than 0. If + substring of String sorts lexicographically before String2, the + function returns a number less than 0. + +Arguments: + String - Compare to String2 + String2 - Compare to String + Length - Number of Unicode characters to compare + +Returns: + 0 - The substring of String and String2 is identical. + > 0 - The substring of String sorts lexicographically after String2 + < 0 - The substring of String sorts lexicographically before String2 + +--*/ +{ + while (*String && Length != 0) { + if (*String != *String2) { + break; + } + String += 1; + String2 += 1; + Length -= 1; + } + return Length > 0 ? *String - *String2 : 0; +} + + +UINTN +EfiStrSize ( + IN CHAR16 *String + ) +/*++ + +Routine Description: + Return the number bytes in the Unicode String. This is not the same as + the length of the string in characters. The string size includes the NULL + +Arguments: + String - String to process + +Returns: + Number of bytes in String + +--*/ +{ + return ((EfiStrLen (String) + 1) * sizeof (CHAR16)); +} + + +#define AMI_SIZE_OF_FILEPATH_DEVICE_PATH STRUCT_OFFSET(FILEPATH_DEVICE_PATH,PathName) + +// +//---------------------------------------------------------------------------- +// Procedure: EfiFileDevicePath +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_HANDLE Device OPTIONAL, IN CHAR16 *FileName +// +// Output: EFI_DEVICE_PATH_PROTOCOL * +// +//---------------------------------------------------------------------------- +// +EFI_DEVICE_PATH_PROTOCOL * +EfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ) +/*++ + +Routine Description: + + This function allocates a device path for a file and appends it to an existiong + device path. + +Arguments: + Device - A pointer to a device handle. + + FileName - A pointer to a Null-terminated Unicodestring. + +Returns: + A device path contain the file name. + +--*/ +{ + UINTN Size; + FILEPATH_DEVICE_PATH *FilePath; + EFI_DEVICE_PATH_PROTOCOL *Eop; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + for (Size = 0; FileName[Size] != 0; Size++) + ; + Size = (Size + 1) * 2; + + FilePath = EfiLibAllocateZeroPool (Size + AMI_SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL)); + + DevicePath = NULL; + + if (FilePath != NULL) { + + // + // Build a file path + // + FilePath->Header.Type = MEDIA_DEVICE_PATH; + FilePath->Header.SubType = MEDIA_FILEPATH_DP; + SetDevicePathNodeLength (&FilePath->Header, Size + AMI_SIZE_OF_FILEPATH_DEVICE_PATH); + EfiCopyMem (FilePath->PathName, FileName, Size); + Eop = NextDevicePathNode (&FilePath->Header); + SetDevicePathEndNode (Eop); + + // + // Append file path to device's device path + // + + DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath; + if (Device != NULL) { + DevicePath = EfiAppendDevicePath ( + EfiDevicePathFromHandle (Device), + DevicePath + ); + + gBS->FreePool (FilePath); + } + } + + return DevicePath; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiInitializeFwVolDevicepathNode +// +// Description: To avoid including EDK libs. +// +// Input: IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, +// IN EFI_GUID *NameGuid +// +// Output: VOID EFIAPI +// +//---------------------------------------------------------------------------- +// +VOID +EFIAPI +EfiInitializeFwVolDevicepathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN EFI_GUID *NameGuid + ) +/*++ + +Routine Description: + + Initialize a Firmware Volume (FV) Media Device Path node. + + Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum + so as we move to UEFI 2.0 support we must use a mechanism that conforms with + the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed + device path is defined for PIWG extensions of device path. If the code + is compiled to conform with the UEFI 2.0 specification use the new device path + else use the old form for backwards compatability. + +Arguments: + + FvDevicePathNode - Pointer to a FV device path node to initialize + NameGuid - FV file name to use in FvDevicePathNode + +Returns: + + None + +--*/ +{ +//*** AMI PORTING BEGIN ***// +//NEW PIWG Specific Device Path defined here is not in compliance with PI DXE CIS 1.0 +//Let's disable it +//See also corresponding change in TianoSpecDevicePath.h +#if 1 +//*** AMI PORTING END *****// + // + // Use old Device Path that conflicts with UEFI + // + FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + +#else + // + // Use the new Device path that does not conflict with the UEFI + // + FvDevicePathNode->Piwg.Header.Type = MEDIA_DEVICE_PATH; + FvDevicePathNode->Piwg.Header.SubType = MEDIA_VENDOR_DP; + SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)); + + // + // Add the GUID for generic PIWG device paths + // + EfiCopyMem (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid, sizeof(EFI_GUID)); + + // + // Add in the FW Vol File Path PIWG defined inforation + // + FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE; + +#endif + EfiCopyMem (&((AMITSE_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH*)FvDevicePathNode)->FvFileName, NameGuid, sizeof(EFI_GUID)); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiLibNamedEventSignal +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_GUID *Name +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +EfiLibNamedEventSignal ( + IN EFI_GUID *Name + ) +/*++ + +Routine Description: + Signals a named event. All registered listeners will run. + The listeners should register using EfiLibNamedEventListen() function. + + NOTE: For now, the named listening/signalling is implemented + on a protocol interface being installed and uninstalled. + In the future, this maybe implemented based on a dedicated mechanism. + +Arguments: + Name - Name to perform the signaling on. The name is a GUID. + +Returns: + EFI_SUCCESS if successfull. + +--*/ +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + Name, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->UninstallProtocolInterface ( + Handle, + Name, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: LibReportStatusCode +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, +// IN UINT32 Instance, IN EFI_GUID *CallerId OPTIONAL, +// IN EFI_STATUS_CODE_DATA *Data OPTIONAL +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS LibReportStatusCode( + IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL +); + +EFI_STATUS +EfiLibReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ) +{ + return LibReportStatusCode(Type,Value,Instance,CallerId,Data); +} + + +VOID +EFIAPI +EventNotifySignalAllNullEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // This null event is a size efficent way to enusre that + // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly. + // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into + // CreateEventEx() and this function is used to make the + // old error checking in CreateEvent() for Tiano extensions + // function. + // + return; +} + +// +//---------------------------------------------------------------------------- +// Procedure: TseEfiCreateEventReadyToBoot +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_TPL NotifyTpl, +// IN EFI_EVENT_NOTIFY NotifyFunction, +// IN VOID *NotifyContext, +// OUT EFI_EVENT *ReadyToBootEvent +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +EFIAPI +TseEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ) +/*++ + +Routine Description: + Create a Read to Boot Event. + + Tiano extended the CreateEvent Type enum to add a ready to boot event type. + This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was + added and now it's possible to not voilate the UEFI specification and use + the ready to boot event class defined in UEFI 2.0. This library supports + the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to + work both ways. + +Arguments: + @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) + +Return: + EFI_SUCCESS - Event was created. + Other - Event was not created. + +--*/ +{ + EFI_STATUS Status; + UINT32 EventType; + EFI_EVENT_NOTIFY WorkerNotifyFunction; + +#if (EFI_SPECIFICATION_VERSION < 0x00020000) + + if (NotifyFunction == NULL) { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL; + } else { + EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT; + } + WorkerNotifyFunction = NotifyFunction; + + // + // prior to UEFI 2.0 use Tiano extension to EFI + // + Status = gBS->CreateEvent ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + ReadyToBootEvent + ); +#else + + EventType = EFI_EVENT_NOTIFY_SIGNAL; + if (NotifyFunction == NULL) { + // + // CreatEventEx will check NotifyFunction is NULL or not + // + WorkerNotifyFunction = EventNotifySignalAllNullEvent; + } else { + WorkerNotifyFunction = NotifyFunction; + } + + // + // For UEFI 2.0 and the future use an Event Group + // + Status = gBS->CreateEventEx ( + EventType, + NotifyTpl, + WorkerNotifyFunction, + NotifyContext, + &gEfiEventReadyToBootGuid, + ReadyToBootEvent + ); +#endif + return Status; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: IsHexDigit +// +// Description: To avoid including EDK libs. +// +// Input: +// +// Output: +// +//---------------------------------------------------------------------------- +// +BOOLEAN +IsHexDigit ( + OUT UINT8 *Digit, + IN CHAR16 Char + ) +/*++ + + Routine Description: + Determines if a Unicode character is a hexadecimal digit. + The test is case insensitive. + + Arguments: + Digit - Pointer to byte that receives the value of the hex character. + Char - Unicode character to test. + + Returns: + TRUE - If the character is a hexadecimal digit. + FALSE - Otherwise. + +--*/ +{ + if ((Char >= L'0') && (Char <= L'9')) { + *Digit = (UINT8) (Char - L'0'); + return TRUE; + } + + if ((Char >= L'A') && (Char <= L'F')) { + *Digit = (UINT8) (Char - L'A' + 0x0A); + return TRUE; + } + + if ((Char >= L'a') && (Char <= L'f')) { + *Digit = (UINT8) (Char - L'a' + 0x0A); + return TRUE; + } + + return FALSE; +} + +// +//---------------------------------------------------------------------------- +// Procedure: HexStringToBuf +// +// Description: To avoid including EDK libs. +// +// Input: +// +// Output: +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +HexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ) +/*++ + + Routine Description: + Converts Unicode string to binary buffer. + The conversion may be partial. + The first character in the string that is not hex digit stops the conversion. + At a minimum, any blob of data could be represented as a hex string. + + Arguments: + Buf - Pointer to buffer that receives the data. + Len - Length in bytes of the buffer to hold converted data. + If routine return with EFI_SUCCESS, containing length of converted data. + If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired. + Str - String to be converted from. + ConvertedStrLen - Length of the Hex String consumed. + + Returns: + EFI_SUCCESS: Routine Success. + EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data. + EFI_ + +--*/ +{ + UINTN HexCnt; + UINTN Idx; + UINTN BufferLength; + UINT8 Digit; + UINT8 Byte; + + // + // Find out how many hex characters the string has. + // + for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++); + + if (HexCnt == 0) { + *Len = 0; + return EFI_SUCCESS; + } + // + // Two Unicode characters make up 1 buffer byte. Round up. + // + BufferLength = (HexCnt + 1) / 2; + + // + // Test if buffer is passed enough. + // + if (BufferLength > (*Len)) { + *Len = BufferLength; + return EFI_BUFFER_TOO_SMALL; + } + + *Len = BufferLength; + + for (Idx = 0; Idx < HexCnt; Idx++) { + + IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]); + + // + // For odd charaters, write the lower nibble for each buffer byte, + // and for even characters, the upper nibble. + // + if ((Idx & 1) == 0) { + Byte = Digit; + } else { + Byte = Buf[Idx / 2]; + Byte &= 0x0F; + Byte |= Digit << 4; + } + + Buf[Idx / 2] = Byte; + } + + if (ConvertedStrLen != NULL) { + *ConvertedStrLen = HexCnt; + } + + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------------------------------------------------------------------------------- +// Procedure: NameValueHexStringToBuf +// +// Description: Converts name value string to buffer +// +// Input: : Buf - Pointer to buffer that receives the data. +// Len - Length in bytes of the buffer to hold converted data. +// If routine return with EFI_SUCCESS, containing length of converted data. +// If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired. +// Str - String to be converted from. +// ConvertedStrLen - Length of the Hex String consumed. +// +// Output: EFI_SUCCESS: Routine Success. +// EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data. +// +//----------------------------------------------------------------------------------------------------------------------------------------------------- +// +UINT8 HexToNibbleChar (IN UINT8 Nibble); +EFI_STATUS NameValueHexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ) +{ + UINTN HexCnt; + UINTN Idx, ByteIndex = 0; + UINTN BufferLength; + UINT8 Digit; + UINT8 Byte; + UINT64 Ext8byte = 0; + UINT32 Ext4byte = 0; + UINT16 Word; + + // + // Find out how many hex characters the string has. + // + for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++); + + if (HexCnt == 0) { + *Len = 0; + return EFI_SUCCESS; + } + // + // Two Unicode characters make up 1 buffer byte. Round up. + // + BufferLength = (HexCnt + 1) / 2; + + // + // Test if buffer is passed enough. + // + if (BufferLength > (*Len)) { + *Len = BufferLength; + return EFI_BUFFER_TOO_SMALL; + } + + *Len = BufferLength; + + for (Idx = 0; Idx < HexCnt; Idx += 4) + { + //00 31 00 36 00 30 00 00 + Ext4byte = *((UINT32 *)&Str[Idx+2]); //00 31 00 36 + + Word = ((UINT16)(Ext4byte & 0x0000FFFF)); //00 36 + Byte = ((UINT8)(Word & 0x00FF)); //36 + Buf [ByteIndex] = HexToNibbleChar (Byte); //6 + Buf [ByteIndex] <<= 0x4; //60 + + Word = ((UINT16)(Ext4byte >> 16)); //00 31 + Byte = ((UINT8)(Word & 0x00FF)); //31 + Buf [ByteIndex] |= HexToNibbleChar (Byte); //1 + + ByteIndex ++; + + Ext4byte = *((UINT32 *)&Str[Idx]); //00 30 00 30 + Word = ((UINT16)(Ext4byte & 0x0000FFFF)); //00 30 + Byte = ((UINT8)(Word & 0x00FF)); //30 + Buf [ByteIndex] = HexToNibbleChar (Byte); //0 + Buf [ByteIndex] <<= 0x4; //60 + + Word = ((UINT16)(Ext4byte >> 16)); //00 30 + Byte = ((UINT8)(Word & 0x00FF)); //30 + Buf [ByteIndex] |= HexToNibbleChar (Byte); //0 + + ByteIndex ++; + } + + if (ConvertedStrLen != NULL) { + *ConvertedStrLen = HexCnt; + } + + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: Mul64 +// +// Description: To avoid including EDK libs. +// +// Input: +// +// Output: +// +//---------------------------------------------------------------------------- +// +UINT64 Mul64( + IN UINT64 Value64, + IN UINTN Value32 + ); +#if !TSE_APTIO_5_SUPPORT +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +{ + return Mul64(Multiplicand,Multiplier); +} +#endif +UINTN DPLength(EFI_DEVICE_PATH_PROTOCOL *pDp); + +UINTN +EfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ) +{ + return DPLength(DevicePath); +} + +// +//---------------------------------------------------------------------------- +// Procedure: NibbleToHexChar +// +// Description: Converts the low nibble of a byte to hex unicode character. +// +// Input: Nibble - lower nibble of a byte. +// +// Output: Hex unicode character. +// +//---------------------------------------------------------------------------- +// +CHAR16 +NibbleToHexChar ( + IN UINT8 Nibble + ) +{ + Nibble &= 0x0F; + if (Nibble <= 0x9) { + return (CHAR16)(Nibble + L'0'); + } + + return (CHAR16)(Nibble - 0xA + L'A'); +} + + +// +//------------------------------------------------------------------------------------ +// Procedure: HexToNibbleChar +// +// Description: Converts the hex value to character. +// +// Input: Nibble - lower nibble of a byte. +// +// Output: Hex unicode character. +// +//-------------------------------------------------------------------------------------- +// +UINT8 +HexToNibbleChar ( + IN UINT8 Nibble + ) +{ + if (Nibble - L'0' <= 0x9) { + return (CHAR16)(Nibble - L'0'); + } + + return (CHAR16)(Nibble + 0xA - L'A'); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BufToHexString +// +// Description: Converts binary buffer to Unicode string. +// At a minimum, any blob of data could be represented as a hex string. +// +// Input: Str - Pointer to the string. +// HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character. +// If routine return with EFI_SUCCESS, containing length of hex string buffer. +// If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired. +// Buf - Buffer to be converted from. +// Len - Length in bytes of the buffer to be converted. +// +// Output: EFI_SUCCESS: Routine success. +// EFI_BUFFER_TOO_SMALL: The hex string buffer is too small. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +BufToHexString ( + IN OUT CHAR16 *Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ) +{ + UINTN Idx; + UINT8 Byte; + UINTN StrLen; + + // + // Make sure string is either passed or allocate enough. + // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer. + // Plus the Unicode termination character. + // + StrLen = Len * 2; + if (StrLen > ((*HexStringBufferLength) - 1)) { + *HexStringBufferLength = StrLen + 1; + return EFI_BUFFER_TOO_SMALL; + } + + *HexStringBufferLength = StrLen + 1; + // + // Ends the string. + // + Str[StrLen] = L'\0'; + + for (Idx = 0; Idx < Len; Idx++) { + + Byte = Buf[Idx]; + Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte); + Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4)); + } + + return EFI_SUCCESS; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: NameValueBufToHexString +// +// Description: Converts binary buffer to Unicode string. +// At a minimum, any blob of data could be represented as a hex string. +// Used only for name value implementaion +// +// Input: Str - Pointer to the string. +// HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character. +// If routine return with EFI_SUCCESS, containing length of hex string buffer. +// If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired. +// Buf - Buffer to be converted from. +// Len - Length in bytes of the buffer to be converted. +// +// Output: EFI_SUCCESS: Routine success. +// EFI_BUFFER_TOO_SMALL: The hex string buffer is too small. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +NameValueBufToHexString ( + IN OUT CHAR16 **Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ) +{ + UINT8 Byte; + + // + // Make sure string is either passed or allocate enough. + // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer. + // Plus the Unicode termination character. + // + + if (Len <= sizeof (UINT64)) //For upto 8 bytes we have to take care of endian allignment + { + UINTN Idx; + UINTN StrLen; + CHAR16 *tempStr = (CHAR16 *)NULL; + + // + // Make sure string is either passed or allocate enough. + // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer. + // Plus the Unicode termination character. + // + StrLen = Len * 2; + *Str = EfiLibAllocateZeroPool ((StrLen + 1) * sizeof (UINT16) ); + if (NULL == *Str) + { + return EFI_OUT_OF_RESOURCES; + } + *HexStringBufferLength = (StrLen + 1) * sizeof (UINT16); //UefiVarSetNvram needs full size + // + // Ends the string. + // + tempStr = *Str; + tempStr[StrLen] = L'\0'; + + for (Idx = 0; Idx < Len; Idx++) + { + Byte = Buf[Idx]; + tempStr[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte); + tempStr[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4)); + } + } + else + { + CHAR16 *tempBuf = (CHAR16 *)NULL, *tempStr = (CHAR16 *)NULL; + UINT32 iIndex = 0, StringHexLength = 0; + CHAR16 Word; + + tempBuf = EfiLibAllocateZeroPool (Len + sizeof (CHAR16)); //If full string is given then NULL wont be there so crashing so added one NULL + if (NULL == tempBuf) //character at end + { + return EFI_OUT_OF_RESOURCES; + } + MemCpy (tempBuf, Buf, Len); + //Finding length to allocate + while (tempBuf [iIndex]) + { + StringHexLength ++; + iIndex ++; + } + iIndex = 0; + *Str = EfiLibAllocateZeroPool ((StringHexLength * sizeof (CHAR16) * 4) + sizeof (CHAR16)); + if (NULL == *Str ) + { + return EFI_OUT_OF_RESOURCES; + } + tempStr = *Str; + while (tempBuf [iIndex]) + { + Word = tempBuf [iIndex]; + Byte = ((UINT8)(Word >> 8)); + tempStr [iIndex * 4] = NibbleToHexChar ((UINT8)(Byte >> 4)); + tempStr [iIndex * 4 + 1] = NibbleToHexChar (Byte); + Byte = Word & 0x00FF; + tempStr [iIndex * 4 + 2] = NibbleToHexChar ((UINT8)(Byte >> 4)); + tempStr [iIndex * 4 + 3] = NibbleToHexChar (Byte); + iIndex ++; + } + *HexStringBufferLength = (StringHexLength * sizeof (CHAR16) * 4) + sizeof (CHAR16); + tempStr [StringHexLength * 4] = L'\0'; + MemFreePointer ((VOID **)&tempBuf); + } + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: ToLower +// +// Description: Converts the unicode character of the string from uppercase to lowercase. +// +// Input: Str - String to be converted +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID +ToLower ( + IN OUT CHAR16 *Str + ) +{ + CHAR16 *Ptr; + + for (Ptr = Str; *Ptr != L'\0'; Ptr++) { + if (*Ptr >= L'A' && *Ptr <= L'Z') { + *Ptr = (CHAR16) (*Ptr - L'A' + L'a'); + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SwapBuffer +// +// Description: Swap bytes in the buffer. +// +// Input: Buffer - Binary buffer. +// BufferSize - Size of the buffer in bytes. +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID +SwapBuffer ( + IN OUT UINT8 *Buffer, + IN UINTN BufferSize + ) +{ + UINTN Index; + UINT8 Temp; + UINTN SwapCount; + + SwapCount = BufferSize / 2; + for (Index = 0; Index < SwapCount; Index++) { + Temp = Buffer[Index]; + Buffer[Index] = Buffer[BufferSize - 1 - Index]; + Buffer[BufferSize - 1 - Index] = Temp; + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: UnicodeToConfigString +// +// Description: Convert Unicode string to binary representation Config string, e.g. +// "ABCD" => "0041004200430044". Config string appears in (i.e. +// "&NAME="), or Name/Value pair in (i.e. "label="). +// +// Input: ConfigString - Binary representation of Unicode String, := (4)+ +// StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string. +// Includes tailing '\0' character. +// On output: +// If return EFI_SUCCESS, containing length of Unicode string buffer. +// If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired. +// UnicodeString - Original Unicode string. +// +// Output: EFI_SUCCESS - Routine success. +// EFI_BUFFER_TOO_SMALL - The string buffer is too small. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +UnicodeToConfigString ( + IN OUT CHAR16 *ConfigString, + IN OUT UINTN *StrBufferLen, + IN CHAR16 *UnicodeString + ) +{ + UINTN Index; + UINTN Len; + UINTN BufferSize; + CHAR16 *String; + + Len = EfiStrLen (UnicodeString); + BufferSize = (Len * 4 + 1) * sizeof (CHAR16); + + if (*StrBufferLen < BufferSize) { + *StrBufferLen = BufferSize; + return EFI_BUFFER_TOO_SMALL; + } + + *StrBufferLen = BufferSize; + String = ConfigString; + + for (Index = 0; Index < Len; Index++) { + BufToHexString (ConfigString, &BufferSize, (UINT8 *) UnicodeString, 2); + + ConfigString += 4; + UnicodeString += 1; + } + + // + // Add tailing '\0' character + // + *ConfigString = L'\0'; + + // + // Convert the uppercase to lowercase since is defined in lowercase format. + // + ToLower (String); + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiLibAllocateCopyPool +// +// Description: Allocate BootServicesData pool and use a buffer provided by +// caller to fill it. +// +// Input: AllocationSize - The size to allocate +// Buffer - Buffer that will be filled into the buffer allocated +// +// Output: Pointer of the buffer allocated. +// +//---------------------------------------------------------------------------- +// +VOID * +EfiLibAllocateCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ) +{ + VOID *Memory; + + Memory = NULL; + gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory); + if (Memory != NULL) { + gBS->CopyMem (Memory, Buffer, AllocationSize); + } + + return Memory; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BufferToHexString +// +// Description: Converts binary buffer to Unicode string in reversed byte order from BufToHexString(). +// +// Input: Str - String for output +// Buffer - Binary buffer. +// BufferSize - Size of the buffer in bytes. +// +// Output: EFI_SUCCESS - The function completed successfully. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +BufferToHexString ( + IN OUT CHAR16 *Str, + IN UINT8 *Buffer, + IN UINTN BufferSize + ) +{ + EFI_STATUS Status; + UINT8 *NewBuffer; + UINTN StrBufferLen; + + NewBuffer = EfiLibAllocateCopyPool (BufferSize, Buffer); + SwapBuffer (NewBuffer, BufferSize); + + StrBufferLen = BufferSize * 2 + 1; + Status = BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize); + + gBS->FreePool (NewBuffer); + // + // Convert the uppercase to lowercase since is defined in lowercase format. + // + ToLower (Str); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiStrStr +// +// Description: Find a substring. +// +// Input: String - Null-terminated string to search. +// StrCharSet - Null-terminated string to search for. +// +// Output: The address of the first occurrence of the matching substring if successful, +// or NULL otherwise. +// +//---------------------------------------------------------------------------- +// +CHAR16* + EfiStrStr ( + IN CHAR16 *String, + IN CHAR16 *StrCharSet + ) + { + CHAR16 *Src; + CHAR16 *Sub; + + Src = String; + Sub = StrCharSet; + + while ((*String != L'\0') && (*StrCharSet != L'\0')) { + if (*String++ != *StrCharSet++) { + String = ++Src; + StrCharSet = Sub; + } + } + if (*StrCharSet == L'\0') { + return Src; + } else { + return NULL; + } + } + +UINT64 Shr64( + IN UINT64 Value, + IN UINT8 Shift + ); + +UINT64 Shl64( + IN UINT64 Value, + IN UINT8 Shift + ); +#if !TSE_APTIO_5_SUPPORT +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + UINT8 Shift; + + while(Count) + { + Shift = (UINT8)((Count>256)?256:Count); + Operand = Shl64(Operand,Shift); + Count -= Shift; + } + + return Operand; +} + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +{ + UINT8 Shift; + + while(Count) + { + Shift = (UINT8)((Count>256)?256:Count); + Operand = Shr64(Operand,Shift); + Count -= Shift; + } + + return Operand; +} +#endif +UINT64 Div64 ( + IN UINT64 Dividend, + IN UINTN Divisor, //Can only be 31 bits. + OUT UINTN *Remainder OPTIONAL + ); + +UINT64 +AmiTseDivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +{ + return Div64(Dividend,Divisor,Remainder); +} + +VOID +EfiDebugAssert ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ) +{ +} + +VOID +EfiDebugPrint ( +IN UINTN ErrorLevel, +IN CHAR8 *Format, +... +) +{ +} + +#define EFI_FORM_BROWSER_PROTOCOL_GUID \ + { \ + 0xe5a1333e, 0xe1b4, 0x4d55, 0xce, 0xeb, 0x35, 0xc3, 0xef, 0x13, 0x34, 0x43 \ + } +EFI_GUID gEfiFormBrowserProtocolGuid = EFI_FORM_BROWSER_PROTOCOL_GUID; + +#else //!TSE_USE_EDK_LIBRARY + +// To support building when TSE_USE_EDK_LIBRARY = 1 +#ifdef TSE_FOR_APTIO_4_50 +const UINTN FlashEmpty = (UINTN)(-FLASH_ERASE_POLARITY); +const UINT32 FlashEmptyNext = (FLASH_ERASE_POLARITY ? 0xffffff : 0); + +VOID MemCpy(VOID* pDestination, VOID* pSource, UINTN Count) +{ + gBS->CopyMem (pDestination, pSource, Count); +} +#endif + +#endif //#if !TSE_USE_EDK_LIBRARY + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/EDKhelper.h b/EDK/MiniSetup/BootOnly/EDKhelper.h new file mode 100644 index 0000000..067a8c5 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/EDKhelper.h @@ -0,0 +1,419 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.h $ +// +// $Author: Arunsb $ +// +// $Revision: 6 $ +// +// $Date: 2/11/14 8:19p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.h $ +// +// 6 2/11/14 8:19p Arunsb +// [TAG] EIP125719 +// [Category] Improvement +// [Description] The EfiCreateEventReadyToBoot is conflicted under +// UefiLib.h and EDKhelper.h. +// [Files] boot.c, EDKhelper.c and EDKHelper.h +// +// 5 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 6 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 4 5/29/12 4:02a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 3 12/28/10 6:12p Mallikarjunanv +// [TAG] EIP41615 +// [Category] New Feature +// [Description] Added the file browser support for the Add boot option +// reated controls +// [Files] AmiVfr.h, AmiTse.sdl, AmiTseStr.uni, CommonHelper.c, +// Faketokens.c, TseElinks.h, EdkHelper.h, minisetup.h, TseAdvanced.c, +// AddBootOption.c +// +// 2 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 2 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 1 7/31/09 5:03p Presannar +// Initial Draft - EDKHelper header +// +// +//*****************************************************************// +//*****************************************************************// +//********************************************************************** +// +// +// Name: edkhelper.h +// +// Description: Edk helper header file. +// +// +//********************************************************************** + +#ifndef _EDK_HELPER_H_ +#define _EDK_HELPER_H_ + +//AMI <--> EDK mapping +#define EFI_LOADED_IMAGE_INFORMATION_REVISION EFI_LOADED_IMAGE_PROTOCOL_REVISION +typedef DXE_SERVICES EFI_DXE_SERVICES; +#define EFI_TPL_APPLICATION TPL_APPLICATION +#define EFI_TPL_CALLBACK TPL_CALLBACK +#define EFI_TPL_NOTIFY TPL_NOTIFY +#define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL + +#ifndef END_DEVICE_PATH_TYPE +#define END_DEVICE_PATH_TYPE 0x7F +#endif + +#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xFF +#define EFI_EVENT_EFI_SIGNAL_MASK 0x000000FF +#define EFI_EVENT_EFI_SIGNAL_MAX 4 +#define EFI_TPL_DRIVER 6 +#define EFI_DXE_SERVICES_SIGNATURE DXE_SERVICES_SIGNATURE +#define EFI_DXE_SERVICES_REVISION DXE_SERVICES_REVISION +#define EFI_DXE_ENTRY_POINT(EntryPoint) +#ifndef EFI_DEADLOOP +#define EFI_DEADLOOP() { volatile UINTN __DeadLoopVar__ = 1; while (__DeadLoopVar__); } +#endif +#define EFI_BREAKPOINT() EFI_DEADLOOP() +#define EFI_BAD_POINTER 0xAFAFAFAF +//This is defined in FirmwareValume.h but has nothing to do with the protocol. +//It should be in DxeMain internal header +//#define FV_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '_') +//#define EFI_FVH_SIGNATURE FV_SIGNATURE +//#define EFI_FV_BLOCK_MAP_ENTRY FvBlockMapEntry +//This is define in TianoType.h, however, this is not in DXECIS +// +// attributes for reserved memory before it is promoted to system memory +// +#define EFI_MEMORY_PRESENT 0x0100000000000000 +#define EFI_MEMORY_INITIALIZED 0x0200000000000000 +#define EFI_MEMORY_TESTED 0x0400000000000000 + +// +// range for memory mapped port I/O on IPF +// +#define EFI_MEMORY_PORT_IO 0x4000000000000000 +// +// A pointer to a function in IPF points to a plabel. +// +typedef struct { + UINT64 EntryPoint; + UINT64 GP; +} EFI_PLABEL; +//////////////////////////////////////////////// +//defined for every CPU architecture +// Maximum legal IA-32 address +#define EFI_MAX_ADDRESS 0xFFFFFFFF +//////////////////////////////////////////////// + +// Protocols +#define EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL +#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID FW_VOLUME_BLOCK_PROTOCOL_GUID +#define EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID +#define EFI_SIMPLE_TEXT_OUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL +#define EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID +#define EFI_SIMPLE_TEXT_IN_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL +#define LOAD_FILE_PROTOCOL_GUID EFI_LOAD_FILE_PROTOCOL_GUID +#define EFI_EBC_INTERPRETER_PROTOCOL_GUID EFI_EBC_PROTOCOL_GUID + +//from EfiStdArg.h +#define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1)) + +// +// Also support coding convention rules for var arg macros +// +#ifndef VA_START + +typedef CHAR8 *VA_LIST; +#define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v)) +#define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t))) +#define VA_END(ap) (ap = (VA_LIST) 0) + +#endif + +//from EfiDevicePath.h +#define EFI_DP_TYPE_MASK 0x7F +#define EFI_DP_TYPE_UNPACKED 0x80 +#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01 + +#define DP_IS_END_TYPE(a) +#define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) + +#define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK ) +#define DevicePathSubType(a) ( (a)->SubType ) +#define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) ) + +#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE ) +#define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) +#define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) ) +#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a))) + +#define SetDevicePathNodeLength(a,l) { \ + (a)->Length[0] = (UINT8) (l); \ + (a)->Length[1] = (UINT8) ((l) >> 8); \ + } + +#define SetDevicePathEndNode(a) { \ + (a)->Type = END_DEVICE_PATH_TYPE; \ + (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \ + (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \ + (a)->Length[1] = 0; \ + } + + + +EFI_STATUS +EfiInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +VOID * +EfiLibAllocateZeroPool ( + IN UINTN AllocationSize + ); + +VOID * +EfiLibAllocatePool ( + IN UINTN AllocationSize + ); + +BOOLEAN +EfiCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ); + +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Length + ); + +UINTN +EfiStrLen ( + IN CHAR16 *String + ); + +VOID +EfiStrCpy ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ); + +INTN +EfiStrCmp ( + IN CHAR16 *String, + IN CHAR16 *String2 + ); + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ); + + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ); + +EFI_DEVICE_PATH_PROTOCOL * +EfiDevicePathFromHandle ( + IN EFI_HANDLE Handle + ); + +EFI_DEVICE_PATH_PROTOCOL * +EfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ); + +VOID +EFIAPI +EfiInitializeFwVolDevicepathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN EFI_GUID *NameGuid + ); + + +EFI_STATUS +EfiLibNamedEventSignal ( + IN EFI_GUID *Name + ); + +EFI_STATUS +EfiLibReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ); + +//STATIC +VOID +EFIAPI +EventNotifySignalAllNullEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ); + +EFI_STATUS +EFIAPI +TseEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ); + +BOOLEAN +IsHexDigit ( + OUT UINT8 *Digit, + IN CHAR16 Char + ); + + +EFI_STATUS +HexStringToBuf ( + IN OUT UINT8 *Buf, + IN OUT UINTN *Len, + IN CHAR16 *Str, + OUT UINTN *ConvertedStrLen OPTIONAL + ); + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ); + +UINTN +EfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +VOID +EfiDebugAssert ( + IN CHAR8 *FileName, + IN INTN LineNumber, + IN CHAR8 *Description + ); + +VOID +EfiDebugPrint ( + IN UINTN ErrorLevel, + IN CHAR8 *Format, + ... + ); + +// EDKHelper.c +#define CONST const +#define STATIC static +#define VOLATILE volatile + +#define EfiCopyMem(_Destination, _Source, _Length) gBS->CopyMem ((_Destination), (_Source), (_Length)) +#define EfiZeroMem(_Destination, _Length) gBS->SetMem ((_Destination), (_Length), 0) +// +// Length of temp string buffer to store value string. +// +#define CHARACTER_NUMBER_FOR_VALUE 30 + +UINTN +EfiStrSize ( + IN CHAR16 *String + ); + +VOID +EfiStrCat ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ); + +CHAR16* + EfiStrStr ( + IN CHAR16 *String, + IN CHAR16 *StrCharSet + ); + +UINT64 +AmiTseDivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ); + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ); + +EFI_STATUS +BufToHexString ( + IN OUT CHAR16 *Str, + IN OUT UINTN *HexStringBufferLength, + IN UINT8 *Buf, + IN UINTN Len + ); +// EIP-41615: updated related to file browser support in add boot option +VOID * +EfiLibAllocateCopyPool ( + IN UINTN AllocationSize, + IN VOID *Buffer + ); + +#endif /* _EDK_HELPER_H_ */ + +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// diff --git a/EDK/MiniSetup/BootOnly/HookAnchor.c b/EDK/MiniSetup/BootOnly/HookAnchor.c new file mode 100644 index 0000000..8cdcc37 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/HookAnchor.c @@ -0,0 +1,676 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/HookAnchor.c $ +// +// $Author: Premkumara $ +// +// $Revision: 11 $ +// +// $Date: 3/06/13 12:26a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/HookAnchor.c $ +// +// 11 3/06/13 12:26a Premkumara +// [TAG] EIP111415 +// [Category] Improvement +// [Description] Elink function for SETUP_TOGGLE_KEY_UNICODE function +// [Files] HookAnchor.h, AMITSE.sdl, commonoem.c, Commonoem.h, +// HookList.c, HookAnchor.c +// +// 10 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 14 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 9 11/20/11 7:05a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 8 3/28/11 9:23p Madhans +// [TAG] EIP41744 +// [Category] Improvement +// [Description] SoftKeyBoard Support in TSE. and Support to Work with +// new mouse driver(Label 07). +// [Files] HookAnchor.h +// AMITSE.sdl +// CommonHelper.c +// commonoem.c +// commonoem.h +// HookList.c +// HookAnchor.c +// Mouse.c +// minisetupext.c +// postmgmtext.c +// minisetupext.h +// PopupPassword.c +// PopupString.c +// TseLiteCommon.c +// +// 7 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 9 8/18/10 6:16p Mallikarjunanv +// EIP-38089: Hook after pressing F2 key and before showing setup menu. +// +// 8 6/08/10 5:08p Blaines +// Added new AMITSE hook (hook33), called when TSE determines that console +// out is available. +// +// 7 4/13/10 6:01p Madhans +// Eip: 33100 To create new hook for BootNowLaunching. (From bbsPopoup and +// Boot override menu). +// +// 6 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 5 2/04/10 11:09p Madhans +// MapControlActionMouse Hook added +// +// 4 10/28/09 5:36p Madhans +// +// 3 9/15/09 9:28a Sudhirv +// Added hook functions for LoadSetupDefaults and PreSystemReset +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// + + +// +//---------------------------------------------------------------------------- +// +// Name: HOOKANCHOR.C +// +// Description: file to handle the hook functions +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: SearchLastHook +// +// Description: Returns the lasthookfn number +// +// Input: firsthookfn +// +// Output: lastHookfn +// +//---------------------------------------------------------------------------- +// +UINTN SearchLastHook(UINTN firsthookfn) +{ + UINTN ii; + + for ( ii = firsthookfn; (UINTN)AMITSE_HookList[ii] ; ii++ ) + if( HOOKID0 == ((UINTN)AMITSE_HookList[ii]& HOOKID0) ) // Check till next HOOK + return (UINTN)ii-1; + return (UINTN)ii-1; // Last HOOKID may not be followed by another HOOKID but only by end of table +} + + +// +//---------------------------------------------------------------------------- +// Procedure: SearchHook +// +// Description: Finds the Firsthookfn and Lasthookfn of HookNum +// +// Input: HookNum +// +// Output: firsthookfn , lastHookfn +// returns zero if hook not found. Non Zero on success. +// +//---------------------------------------------------------------------------- +// +UINTN SearchHook(UINTN HookNum,UINTN *firsthookfn,UINTN *lasthookfn) +{ + int ii; + + *firsthookfn = 0; + for ( ii = 0; (UINTN)AMITSE_HookList[ii] ; ii++ ) + { + if ( HookNum == (UINTN)AMITSE_HookList[ii] ) + { + *firsthookfn = (UINTN)ii+2; // Skip the HOOKx and funHook + *lasthookfn = SearchLastHook(*firsthookfn); + return *firsthookfn; + } + + } + return 0; +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHook +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +//Input: HookNum , default function. +// +// Output: none +// +//---------------------------------------------------------------------------- +// +VOID GenericHook( UINTN HookNum, TSE_HOOK * defaultfn ) +{ + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + AMITSE_HookList[ii](); + } + else + defaultfn(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHookType1 +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +// Input: HookNum , default function. +// +// Output: Boolean +// +//---------------------------------------------------------------------------- +// +BOOLEAN GenericHookType1( UINTN HookNum, TSE_HOOK * defaultfn) +{ + BOOLEAN ret = FALSE; + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + ret |= ((TSE_HOOK_T1 *)AMITSE_HookList[ii])(); + } + else + ret = ((TSE_HOOK_T1 *)defaultfn)(); + return ret; +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHookType2 +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +// Input: HookNum , default function and Key. +// +// Output: CONTROL_ACTION +// +//---------------------------------------------------------------------------- +// +CONTROL_ACTION GenericHookType2( UINTN HookNum, TSE_HOOK * defaultfn, AMI_EFI_KEY_DATA key) +{ + CONTROL_ACTION ret = 0; + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + ret = ((TSE_HOOK_T2 *)AMITSE_HookList[ii])(key); + } + else + ret = ((TSE_HOOK_T2 *)defaultfn)(key); + return ret; +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHookType3 +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +// Input: HookNum , default function, Event and Context. +// +// Output: none +// +//---------------------------------------------------------------------------- +// +VOID GenericHookType3( UINTN HookNum, TSE_HOOK * defaultfn, EFI_EVENT Event, VOID *Context) +{ + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + ((TSE_HOOK_T3 *)AMITSE_HookList[ii])(Event, Context); + } + else + ((TSE_HOOK_T3 *)defaultfn)(Event, Context); +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHookType4 +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +// Input: HookNum , default function, Event and Context. +// +// Output: none +// +//---------------------------------------------------------------------------- +// +EFI_STATUS GenericHookType4( UINTN HookNum, TSE_HOOK * defaultfn, BOOT_FLOW *bootFlowPtr) +{ + EFI_STATUS ret = EFI_SUCCESS; + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + ret = ((TSE_HOOK_T4 *)AMITSE_HookList[ii])(bootFlowPtr); + } + else + ret = ((TSE_HOOK_T4 *)defaultfn)(bootFlowPtr); + return ret; +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHookType5 +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +// Input: HookNum , default function, Password and MaxSize. +// +// Output: none +// +//---------------------------------------------------------------------------- +// +VOID GenericHookType5( UINTN HookNum, TSE_HOOK * defaultfn, CHAR16 *Password, UINTN MaxSize) +{ + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + ((TSE_HOOK_T5 *)AMITSE_HookList[ii])(Password, MaxSize); + } + else + ((TSE_HOOK_T5 *)defaultfn)(Password, MaxSize); +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHookType6 +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +// Input: HookNum , default function and Variable pointers to hold colors. +// +// Output: none +// +//---------------------------------------------------------------------------- +// +EFI_STATUS GenericHookType6( UINTN HookNum, TSE_HOOK * defaultfn, + UINT8 *BGColor, UINT8 *FGColor, UINT8 *SecBGColor, UINT8 *SecFGColor, + UINT8 *SelBGColor, UINT8 *SelFGColor, UINT8 *NSelBGColor, UINT8 *NSelFGColor, + UINT8 *LabelBGColor, UINT8 *LabelFGColor,UINT8 *NSelLabelFGColor, + UINT8 *EditBGColor, UINT8 *EditFGColor, UINT8 *PopupFGColor, UINT8 *PopupBGColor) +{ + EFI_STATUS ret = EFI_SUCCESS; + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + ret = ((TSE_HOOK_T6 *)AMITSE_HookList[ii])(BGColor, FGColor, SecBGColor, SecFGColor, SelBGColor, + SelFGColor, NSelBGColor, NSelFGColor, LabelBGColor, + LabelFGColor, NSelLabelFGColor, EditBGColor, EditFGColor, + PopupFGColor, PopupBGColor); + } + else + ret = ((TSE_HOOK_T6 *)defaultfn)(BGColor, FGColor, SecBGColor, SecFGColor, SelBGColor, + SelFGColor, NSelBGColor, NSelFGColor, LabelBGColor, + LabelFGColor, NSelLabelFGColor, EditBGColor, EditFGColor, + PopupFGColor, PopupBGColor); + + return ret; +} + +//#pragma optimize ("",off) + +//Hook #1 +VOID DrawQuietBootLogoHook(VOID) +{ + GenericHook( HOOKID1, DrawQuietBootLogo ); +} + +//Hook #2 +BOOLEAN ProcessConInAvailabilityHook(VOID) +{ + return GenericHookType1( HOOKID2, (TSE_HOOK *)ProcessConInAvailability); +} + +//Hook #3 +VOID ProcessEnterSetupHook(VOID) +{ + GenericHook( HOOKID3, ProcessEnterSetup ); +} + +//Hook #4 +VOID ProcessProceedToBootHook(VOID) +{ + GenericHook( HOOKID4, ProcessProceedToBoot ); +} + +//Hook #5 +VOID MinisetupDriverEntryHookHook(VOID) +{ + GenericHook( HOOKID5, MinisetupDriverEntryHook ); +} + +//Hook #6 +VOID PostManagerHandShakeHookHook(VOID) +{ + GenericHook( HOOKID6, PostManagerHandShakeHook ); +} + +//Hook #7 +CONTROL_ACTION MapControlKeysHook(AMI_EFI_KEY_DATA key) +{ + return GenericHookType2( HOOKID7, (TSE_HOOK *) MapControlKeys, key); +} + +//Hook #8 +VOID CheckForKeyHook( EFI_EVENT Event, VOID *Context ) +{ + GenericHookType3( HOOKID8, (TSE_HOOK *) CheckForKey, Event, Context); +} + +//Hook #9 +VOID BeforeLegacyBootLaunchHook(VOID) +{ + GenericHook( HOOKID9, BeforeLegacyBootLaunch ); +} + +//Hook #10 +VOID AfterLegacyBootLaunchHook(VOID) +{ + GenericHook( HOOKID10, AfterLegacyBootLaunch ); +} + +//Hook #11 +VOID BeforeEfiBootLaunchHook(VOID) +{ + GenericHook( HOOKID11, BeforeEfiBootLaunch ); +} + +//Hook #12 +VOID AfterEfiBootLaunchHook(VOID) +{ + GenericHook( HOOKID12, AfterEfiBootLaunch ); +} + +//Hook #13 +VOID SavedConfigChangesHook(VOID) +{ + GenericHook( HOOKID13, SavedConfigChanges ); +} + +//Hook #14 +VOID LoadedConfigDefaultsHook(VOID) +{ + GenericHook( HOOKID14, LoadedConfigDefaults ); +} + +//Hook #15 +VOID TimeOutLoopHookHook(VOID) +{ + GenericHook( HOOKID15, TimeOutLoopHook ); +} + +//Hook #16 +EFI_STATUS OemKey1HookHook ( BOOT_FLOW *bootFlowPtr ) +{ + return GenericHookType4( HOOKID16, (TSE_HOOK *) OemKey1Hook, bootFlowPtr); +} + +//Hook #17 +EFI_STATUS OemKey2HookHook ( BOOT_FLOW *bootFlowPtr ) +{ + return GenericHookType4( HOOKID17, (TSE_HOOK *) OemKey2Hook, bootFlowPtr); +} + +//Hook #18 +EFI_STATUS OemKey3HookHook ( BOOT_FLOW *bootFlowPtr ) +{ + return GenericHookType4( HOOKID18, (TSE_HOOK *) OemKey3Hook, bootFlowPtr); +} + +//Hook #19 +EFI_STATUS OemKey4HookHook ( BOOT_FLOW *bootFlowPtr ) +{ + return GenericHookType4( HOOKID19, (TSE_HOOK *) OemKey4Hook, bootFlowPtr); +} + +//Hook #20 +VOID PasswordEncodeHook( CHAR16 *Password, UINTN MaxSize) +{ + GenericHookType5( HOOKID20, (TSE_HOOK *)PasswordEncode, Password, MaxSize ); +} + +//Hook #21 +EFI_STATUS SetControlColorsHook(UINT8 *BGColor, UINT8 *FGColor, UINT8 *SecBGColor, UINT8 *SecFGColor, + UINT8 *SelBGColor, UINT8 *SelFGColor, UINT8 *NSelBGColor, UINT8 *NSelFGColor, + UINT8 *LabelBGColor, UINT8 *LabelFGColor,UINT8 *NSelLabelFGColor, UINT8 *EditBGColor, UINT8 *EditFGColor, + UINT8 *PopupFGColor, UINT8 *PopupBGColor) +{ + return GenericHookType6( HOOKID21, (TSE_HOOK *)SetControlColors, + BGColor, FGColor, SecBGColor, SecFGColor, SelBGColor, + SelFGColor, NSelBGColor, NSelFGColor, LabelBGColor, + LabelFGColor, NSelLabelFGColor, EditBGColor, EditFGColor, + PopupFGColor, PopupBGColor ); +} + + +//Hook #22 +VOID InvalidActionHookHook(VOID) +{ + GenericHook( HOOKID22, InvalidActionHook ); +} + +//Hook #23 +VOID LoadedUserDefaultsHook(VOID) +{ + GenericHook( HOOKID23, LoadedUserDefaults ); +} + +//Hook #24 +VOID LoadedBuildDefaultsHook(VOID) +{ + GenericHook( HOOKID24, LoadedBuildDefaults ); +} + +//Hook #25 +VOID LoadedPreviousValuesHook(VOID) +{ + GenericHook( HOOKID25, LoadedPreviousValues ); +} + +//Hook #26 +VOID SetupConfigModifiedHook(VOID) +{ + GenericHook( HOOKID26, SetupConfigModified); +} + +VOID DrawPopupMenuHook() +{ + GenericHook( HOOKID27, DrawBootOnlyBbsPopupMenu ); +} + +VOID BbsBootHook() +{ + GenericHook( HOOKID28, BbsBoot ); +} + +///Hook for Load deafaults fucntions. +VOID LoadSetupDefaultsHook( NVRAM_VARIABLE *defaults, UINTN data ) +{ + GenericHookType5( HOOKID29, (TSE_HOOK *)LoadSetupDefaults, (CHAR16*)defaults, data ); +} + +/// EIP:26409 - Hook function to update before resetting the system +VOID PreSystemResetHookHook(VOID) +{ + GenericHook( HOOKID30, PreSystemResetHook ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: GenericHookType7 +// +// Description: Locates the hook based on hooknum and calls them +// If hook not found it calls the default function. +// +// Input: HookNum , default function and Key. +// +// Output: CONTROL_ACTION +// +//---------------------------------------------------------------------------- +// +CONTROL_ACTION GenericHookType7( UINTN HookNum, TSE_HOOK * defaultfn, VOID * pMouseInfo) +{ + CONTROL_ACTION ret = 0; + UINTN ii; + UINTN firsthookfn = 0; + UINTN lasthookfn = 0; + + if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) ) + { + for ( ii = firsthookfn; ii <= lasthookfn; ii++ ) + ret = ((TSE_HOOK_T7 *)AMITSE_HookList[ii])(pMouseInfo); + } + else + ret = ((TSE_HOOK_T7 *)defaultfn)(pMouseInfo); + return ret; +} + +//Hook #31 +CONTROL_ACTION MapControlMouseActionHook(VOID *pMouseInfo) +{ + return GenericHookType7( HOOKID31, (TSE_HOOK *) MapControlMouseAction, pMouseInfo); +} + +//Hook #32 +VOID ProcessProceedToBootNowHook(VOID) +{ + GenericHook( HOOKID32, ProcessProceedToBootNow ); +} + +//Hook #33 +VOID ProcessConOutAvailableHook(VOID) +{ + GenericHook( HOOKID33, ProcessConOutAvailable ); +} + +VOID ProcessUIInitHookHook(VOID) +{ + GenericHook( HOOKID34, ProcessUIInitHook ); +} + +VOID AfterInitPostScreenHook(VOID) +{ + GenericHook( HOOKID35, AfterInitPostScreen ); +} + +//Hook #36 +VOID CheckForClickHook( EFI_EVENT Event, VOID *Context ) +{ + GenericHookType3( HOOKID36, (TSE_HOOK *) CheckForClick, Event, Context); +} +//HOOK #37 EIP-111415 +VOID SwitchToPostScreenHook(VOID) +{ + GenericHook( HOOKID37, SwitchToPostScreen ); +} + +//Last Hook +VOID LastTSEHook(VOID) +{ +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/MiniSetup.cif b/EDK/MiniSetup/BootOnly/MiniSetup.cif new file mode 100644 index 0000000..6f0d624 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/MiniSetup.cif @@ -0,0 +1,47 @@ + + name = "TSE Sources - BootOnly" + category = ModulePart + LocalRoot = "EDK\MiniSetup\BootOnly" + RefName = "Minisetup" +[files] +"MiniSetup.sdl" +"MiniSetup.mak" +"AMILogo\AMILogo.c" +"AMILogo\AMILogo.h" +"amiver.h" +"bbs.c" +"bbs.h" +"boot.c" +"box.c" +"box.h" +"buffer.c" +"buffer.h" +"dobmpmgr.c" +"globals.c" +"hiistring.c" +"hiistring.h" +"logo.c" +"mem.c" +"minisetup.c" +"minisetup.h" +"minisetupext.c" +"notify.c" +"postmgmt.c" +"print.c" +"protocol.c" +"protocol.h" +"screen.c" +"screen.h" +"string.c" +"string.h" +"timer.c" +"Timer.h" +"variable.c" +"Resources.c" +"HookAnchor.c" +"EDKhelper.c" +"EDKhelper.h" +"password.c" +"password.h" +"postmgmtext.c" + diff --git a/EDK/MiniSetup/BootOnly/MiniSetup.mak b/EDK/MiniSetup/BootOnly/MiniSetup.mak new file mode 100644 index 0000000..d07745a --- /dev/null +++ b/EDK/MiniSetup/BootOnly/MiniSetup.mak @@ -0,0 +1,138 @@ +##*****************************************************************## +##*****************************************************************## +##*****************************************************************## +##** **## +##** (C)Copyright 2004, American Megatrends, Inc. **## +##** **## +##** All Rights Reserved. **## +##** **## +##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **## +##** **## +##** Phone (770)-246-8600 **## +##** **## +##*****************************************************************## +##*****************************************************************## +##*****************************************************************## +## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/MiniSetup.mak $ +## +## $Author: Arunsb $ +## +## $Revision: 9 $ +## +## $Date: 10/18/12 5:58a $ +## +##*****************************************************************## +##*****************************************************************## +## Revision History +## ---------------- +## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/MiniSetup.mak $ +# +# 9 10/18/12 5:58a Arunsb +# Updated for 2.16.1235 QA submission +## +## 12 10/10/12 12:36p Arunsb +## Synched the source for v2.16.1232, backup with Aptio +# +# 8 4/02/10 6:13p Madhans +# EIP 37036 : To make TSE 2.01 Binary module to work with older Cores +# +# 7 2/26/10 8:53p Madhans +# For TSE 2.01.1024. refer changelog.log for file checkin history . +## +## 8 2/26/10 1:29p Madhans +## Bootonly source module need AMITSEStrTokens.h +## +## 7 2/19/10 8:14a Mallikarjunanv +## updated year in copyright message +## +## 6 2/17/10 1:02p Madhans +## minisetupstr.uni removed and Strings token are refered from +## AMITSEStrTokens.h +## +## 5 10/28/09 5:37p Madhans +## +## 4 8/17/09 12:22p Presannar +## Removed include directory Core +## +## 3 6/24/09 6:09p Madhans +## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +## +## 2 6/12/09 7:41p Presannar +## Initial implementation of coding standards +## +## 1 6/04/09 8:05p Madhans +# +# 1 4/28/09 11:12p Madhans +# Tse 2.0 Code complete Checkin. +## +## 5 4/28/09 9:39p Madhans +## Tse 2.0 Code complete Checkin. +## +## 4 3/31/09 3:58p Madhans +## +## 3 2/05/09 10:15a Madhans +## Style Module created. +## +## 2 1/30/09 6:06p Madhans +## Function headers added. +## +## 1 12/18/08 7:58p Madhans +## Intial version of TSE Lite sources +##*****************************************************************## + +# MAK file for the eModule:MiniSetup + +MINISETUP_INCLUDES = \ + -I $(TSESRC_DIR)\AMILogo \ + -I $(TSESRC_DIR) \ +!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1" + -I $(TSE_BOARD_DIR)\ +!endif + -I $(TSEBIN_DIR) \ + -I $(TSEBIN_DIR)\Inc \ + -I $(PROJECT_DIR)\Include\Protocol \ + -I $(PROJECT_DIR) \ + -I $(PROJECT_DIR)\Include \ + -I $(BUILD_DIR) \ + +!if "$(TseLite_SUPPORT)" == "1" +MINISETUP_INCLUDES = -I $(UEFISRC_DIR) $(MINISETUP_INCLUDES) -I $(TSELITESRC_DIR) -I $(TSE_STYLE_DIR) +!endif + + +$(BUILD_DIR)\MiniSetupLocal.lib : MiniSetupLib + +MiniSetupLib : $(BUILD_DIR)\MiniSetup.mak MiniSetupLibBin + +$(BUILD_DIR)\MiniSetup.mak : $(TSESRC_DIR)\$(@B).cif $(TSESRC_DIR)\$(@B).mak $(BUILD_RULES) $(BUILD_DIR)\AMITSEStrTokens.h + $(CIF2MAK) $(TSESRC_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +!if "$(TSE_USE_EDK_LIBRARY)" == "1" +TSE_DEFAULTS = $(EDK_DEFAULTS) +!else +TSE_DEFAULTS = $(BUILD_DEFAULTS) +!endif + +MiniSetupLibBin : + $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\ + /f $(BUILD_DIR)\MiniSetup.mak all\ + "MY_INCLUDES=$(MINISETUP_INCLUDES)"\ + TYPE=LIBRARY \ + "EXT_HEADERS=$(BUILD_DIR)\token.h"\ + LIBRARY_NAME=$(BUILD_DIR)\MiniSetupLocal.lib\ + "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50" + + +##*****************************************************************## +##*****************************************************************## +##** **## +##** (C)Copyright 2010, American Megatrends, Inc. **## +##** **## +##** All Rights Reserved. **## +##** **## +##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **## +##** **## +##** Phone (770)-246-8600 **## +##** **## +##*****************************************************************## +##*****************************************************************## diff --git a/EDK/MiniSetup/BootOnly/MiniSetup.sdl b/EDK/MiniSetup/BootOnly/MiniSetup.sdl new file mode 100644 index 0000000..a96d9b4 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/MiniSetup.sdl @@ -0,0 +1,83 @@ +TOKEN + Name = "MiniSetup_SUPPORT" + Value = "1" + Help = "Main switch to enable MiniSetup support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes +End + +TOKEN + Name = "SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL" + Value = "1" + Help = "1 => Uses Graphics output protocol. 0 => Uses UgaDraw protocol." + TokenType = Boolean + TargetH = Yes +End + +TOKEN + Name = "TSE_USE_EDK_LIBRARY" + Value = "0" + Help = "Turn on to Depend on the EDK Libraries, OFF makes use of Aptio Libaray" + TokenType = Boolean + TargetH = Yes + TargetMAK = Yes +End + +TOKEN + Name = "SETUP_OEM_SPECIAL_CONTROL_SUPPORT" + Value = "0" + Help = "Turn on to have OEM Special Control Support." + TokenType = Boolean + TargetH = Yes + TargetMAK = Yes +End + +TOKEN + Name = "SETUP_USE_GUIDED_SECTION" + Value = "0" + Help = "Enable to have BCP compatibility in Aptio 3.x" + TokenType = Boolean + TargetMAK = Yes + TargetH = Yes +End + +TOKEN + Name = "TSE_MAX_DRIVE_NAME" + Value = "51" + Help = "Set the value to dispaly number of characters for Drive name" + TokenType = Integer + TargetH = Yes +End + +TOKEN + Name = "TSE_BEST_HORIZONTAL_RESOLUTION" + Value = "800" + Help = "800 is Standard horizontal resolution for TSE." + TokenType = Boolean + TargetH = Yes +End + +TOKEN + Name = "TSE_BEST_VERTICAL_RESOLUTION" + Value = "600" + Help = "600 is Standard vertical resolution for TSE." + TokenType = Boolean + TargetH = Yes +End + +PATH + Name = "TSESRC_DIR" +End + +MODULE + Help = "Includes MiniSetup.mak to Project" + File = "MiniSetup.mak" +End + +ELINK + Name = "$(BUILD_DIR)\MiniSetupLocal.lib" + Parent = "$(TSESRC_DIR)\MiniSetupLocal$(ARCH).lib" + InvokeOrder = ReplaceParent +End diff --git a/EDK/MiniSetup/BootOnly/Resources.c b/EDK/MiniSetup/BootOnly/Resources.c new file mode 100644 index 0000000..4b6c52a --- /dev/null +++ b/EDK/MiniSetup/BootOnly/Resources.c @@ -0,0 +1,231 @@ +//********************************************************************** +//********************************************************************** +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** ** +//********************************************************************** +//********************************************************************** + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Resources.c 7 10/18/12 5:59a Arunsb $ +// +// $Revision: 7 $ +// +// $Date: 10/18/12 5:59a $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Resources.c $ +// +// 7 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 10 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 6 5/02/11 3:31p Arunsb +// Changed for EDK library build. PI 1.1 support added. +// +// 5 12/02/10 2:33p Madhans +// [TAG] - EIP 48169 +// [Category]- Enhancement +// [Severity]- Mordarate +// [Symptom]- Code Cleanup and Compiler Warning need to resolved. +// [Rootcause] Warnings reported when we build AMI higher Warning level. +// [Solution]- 1. Fix the warnings and do the code cleanup. +// 2. Introduce proper checks. +// 3. change the popupSel.c to not change the Option/variable +// cache to default or first option +// when the variable cache is not matching with any of +// option. +// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c +// popuppassword.c popupsel.c +// expression.c hii.c parse.c +// +// 4 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 6 9/16/10 3:00p Madhans +// To Avoid build issues with TSE_USE_EDK_LIBRARY Building. +// +// 5 7/12/10 4:49p Madhans +// EIP 39113: Sign ON Message Support. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:00p Madhans +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//********************************************************************** +// +// +// Name: Resources.c +// +// Description: Library routines to load image resources. +// +// +//********************************************************************** +#include + +#if TSE_USE_EDK_LIBRARY + +#include EFI_PROTOCOL_DEFINITION (FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION (LoadedImage) +//#include EFI_PROTOCOL_DEFINITION (HII) +#if PI_SPECIFICATION_VERSION<0x00010000 + EFI_GUID guidFV = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID; //For EDK Library usage tse have to set the fv guids correctly +#else + EFI_GUID guidFV = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID; +#endif + +// +//---------------------------------------------------------------------------- +// Procedure: ReadImageResource +// +// Description: Function to read all the resources of a image. +// +// Input: EFI_HANDLE ImageHandle, EFI_GUID *pGuid, +// VOID **ppData, UINTN *pDataSize +// +// Output: Status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS ReadImageResource( + EFI_HANDLE ImageHandle, EFI_GUID *pGuid, + VOID **ppData, UINTN *pDataSize +) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *pImage; + EFI_FIRMWARE_VOLUME_PROTOCOL *pFV; + UINTN i=0, DataSize; + EFI_GUID *pSectionGuid; + UINT32 Authentication; + + Status=gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, &pImage); + if (EFI_ERROR(Status)) return Status; + Status=gBS->HandleProtocol(pImage->DeviceHandle, &guidFV, &pFV); + if (EFI_ERROR(Status)) return Status; + do{ + pSectionGuid=NULL; + DataSize=0; + Status=pFV->ReadSection ( + pFV,&((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH*)(pImage->FilePath))->NameGuid, + EFI_SECTION_FREEFORM_SUBTYPE_GUID,i++, &pSectionGuid, &DataSize, + &Authentication + ); + if (!EFI_ERROR(Status)&&EfiCompareGuid(pSectionGuid,pGuid)) break; + gBS->FreePool(pSectionGuid); + }while(!EFI_ERROR(Status)); + if (EFI_ERROR(Status)) return Status; + *ppData = pSectionGuid; + if (pDataSize) *pDataSize = DataSize; + return EFI_SUCCESS; +} +#endif + +// +//---------------------------------------------------------------------------- +// Procedure: FvReadResources +// +// Description: Function to read all the section from of specified image. +// +// Input: IN EFI_GUID *NameGuid,IN EFI_GUID *pGuid,IN OUT VOID **Buffer,IN OUT UINTN *BufferSize +// +// Output: Status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS FvReadResources ( + IN EFI_GUID *NameGuid, + IN EFI_GUID *pGuid, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize + ) +{ + EFI_FIRMWARE_VOLUME_PROTOCOL *Fv; + UINT32 AuthenticationStatus; + + EFI_STATUS Status; + UINTN NumHandles; + EFI_HANDLE *HandleBuffer; + UINTN i,j=0; + UINTN DataSize=0; + EFI_GUID *pSectionGuid=NULL; + + Status = gBS->LocateHandleBuffer(ByProtocol,&guidFV,NULL,&NumHandles,&HandleBuffer); + if (EFI_ERROR(Status)) return Status; + + for (i = 0; i< NumHandles; ++i) + { + j=0; + gBS->HandleProtocol(HandleBuffer[i],&guidFV,&Fv); + do{ + pSectionGuid=NULL; + DataSize=0; + Status = Fv->ReadSection( + Fv,NameGuid, + EFI_SECTION_FREEFORM_SUBTYPE_GUID,j++, + &pSectionGuid, &DataSize, + &AuthenticationStatus + ); + if (!EFI_ERROR(Status)&&EfiCompareGuid(pSectionGuid,pGuid)) break; + gBS->FreePool(pSectionGuid); + }while(!EFI_ERROR(Status)); + + if (!EFI_ERROR(Status)) + { + // Section found + break; + } + } + + if (!EFI_ERROR(Status)) + { + *Buffer = pSectionGuid; + if (BufferSize) *BufferSize = DataSize; + } + + gBS->FreePool(HandleBuffer); + return Status; +} + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** \ No newline at end of file diff --git a/EDK/MiniSetup/BootOnly/Timer.h b/EDK/MiniSetup/BootOnly/Timer.h new file mode 100644 index 0000000..38352c1 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/Timer.h @@ -0,0 +1,91 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Timer.h $ +// +// $Author: Arunsb $ +// +// $Revision: 4 $ +// +// $Date: 10/18/12 5:59a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Timer.h $ +// +// 4 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 3 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:13p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: timer.h +// +// Description: Header file for code to handle the timer. +// +//---------------------------------------------------------------------------- +// +#ifndef _TIMER_H_ +#define _TIMER_H_ + +EFI_STATUS TimerCreateTimer( EFI_EVENT *Event, EFI_EVENT_NOTIFY Callback, + VOID *Context, EFI_TIMER_DELAY Delay, UINT64 Trigger, EFI_TPL CallBackTPL ); +EFI_STATUS TimerStopTimer( EFI_EVENT *Event ); + +#endif /* _TIMER_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/amiver.h b/EDK/MiniSetup/BootOnly/amiver.h new file mode 100644 index 0000000..4d5bd91 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/amiver.h @@ -0,0 +1,143 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/amiver.h $ +// +// $Author: Arunsb $ +// +// $Revision: 4 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/amiver.h $ +// +// 4 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 3 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: amiver.h +// +// Description: This file contains version macros. +// +//---------------------------------------------------------------------------- +// + +#ifndef _AMIVER_H_ +#define _AMIVER_H_ + +#define AMI_VERSION_SIGNATURE {'$','A','P','V'} + +#pragma pack(1) +typedef struct +{ + CHAR8 signature[4]; + UINT8 major; + UINT8 minor; + UINT16 build; + CHAR8 name[4]; + UINT8 reserved[4]; +} +AMI_VERSION; +#pragma pack() + +#ifdef __cplusplus +extern "C" +{ +#define AMI_SET_VERSION(major,minor,build,sign) \ +AMI_VERSION gVersion_##sign = { \ + AMI_VERSION_SIGNATURE, \ + major, \ + minor, \ + build, \ + ##sign, \ + { 0, 0, 0, 0 } \ +} + +} +#else + +#define AMI_SET_VERSION(major,minor,build,sign) \ +AMI_VERSION gVersion_##sign = { \ + AMI_VERSION_SIGNATURE, \ + major, \ + minor, \ + build, \ + #sign, \ + { 0, 0, 0, 0 } \ +} + + +#endif //__cplusplus + +#define AMI_GET_VERSION_MAJOR(ver) ((ver).major) +#define AMI_GET_VERSION_MINOR(ver) ((ver).minor) +#define AMI_GET_VERSION_BUILD(ver) ((ver).build) +#define AMI_GET_VERSION_NAME(ver) ((ver).name) + +#define AMI_VERSION_STRUCT(sign) (gVersion_##sign) + +#define AMI_CHECK_VERSION(ver) \ + ( ((ver).major != 0) || ((ver).minor != 0) ) + +#endif /* _AMIVER_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/bbs.c b/EDK/MiniSetup/BootOnly/bbs.c new file mode 100644 index 0000000..4cfc7c7 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/bbs.c @@ -0,0 +1,1552 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.c $ +// +// $Author: Premkumara $ +// +// $Revision: 32 $ +// +// $Date: 7/11/14 1:31p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.c $ +// +// 32 7/11/14 1:31p Premkumara +// [TAG] EIP175119 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Can not boot to PXE with boot override menu if +// GROUP_BOOT_OPTIONS_BY_TAG is 0 +// [RootCause] With GROUP_BOOT_OPTIONS_BY_TAG = 0, the Index +// +// of the BBS Network Device was 0xFFFF Since CSM does not +// +// publish any handle for BBS Network Boot Device. +// +// that's why it was not booting. +// [Solution] Added Condition to check whether the Boot option type is +// +// Network or not.if Network Type then,Directly assigning the +// +// Orig Index so that it will Boot. +// [Files] bbs.c +// +// 31 7/11/14 1:23p Premkumara +// [TAG] EIP166385 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] If the HDD boot option is selected to Disabled in Boot +// Priority, this HDD will be disappeared under DOS +// [RootCause] TSE was setting Boot priority to BBS_UNPRIORITIZED_ENTRY +// +// insted of setting BBS_DO_NOT_BOOT_FROM for the disabled devices +// [Solution] modified the code to assign the Boot priority to +// BBS_DO_NOT_BOOT_FROM +// +// instead of BBS_UNPRIORITIZED_ENTRY for the disabled devices +// +// so that they will be visible under DOS +// [Files] bbs.c +// +// 30 5/14/14 11:56a Arunsb +// [TAG] EIP168723 +// [Description] Removed RT attribute for LegacyDevOrder variable. +// [Files] bbs.c and callback.c +// +// 29 5/02/14 10:39a Premkumara +// [TAG] EIP151484 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] When token MATCH_BOOT_OPTION_BY_LOCATION = 0 and +// GROUP_BOOT_OPTIONS_BY_TAG = 0, the device path info is not proper so +// device is not displaying. +// [RootCause] When MATCH_BOOT_OPTION_BY_LOCATION = 1 the BBS devicepath +// and bootdata DevicePath length are getting matched but when +// MATCH_BOOT_OPTION_BY_LOCATION = 0, then BBS devicepath and bootdata +// DevicePath length will be different. +// [Solution] To resolve this, when MATCH_BOOT_OPTION_BY_LOCATION = 1 +// i'm checking for valid DevicePath length and when +// MATCH_BOOT_OPTION_BY_LOCATION = 0 i'm checking for valid for BBS device +// type +// [Files] BootOnly\BBs.c +// +// 28 12/03/13 2:09p Premkumara +// [TAG] EIP130420 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] String is getting truncated +// [RootCause] The string for messagebox, Popup controls is getting +// truncated +// [Solution] Used temp variable to store original string and modify the +// string temp and used to avoid changing org string. +// [Files] String.c +// +// 27 7/02/13 10:06a Premkumara +// [TAG] EIP120011 +// [Category] Improvement +// [Description] Variable BootOrder and LegacyDevOrder need +// fool-proofing function when TSE load variabled +// [Files] Bbs.c, Boot.c, Callback.c, TseLiteHelper.c, Variable.c +// +// 26 2/06/13 9:03a Arunsb +// Checked in properly +// +// 26 1/31/13 12:51p Arunsb +// [TAG] EIP109382 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Boot Device name incorrect when load default +// [RootCause] Legacy offset in gbootdata corrupted so names displayed +// improperly. +// [Solution] Legacy offsets re-calculated properly +// [Files] CommonHelper.c, BootOnly\bbs.c and callback.c +// +// 25 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 20 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 24 9/24/12 9:04a Premkumara +// [TAG] EIP 93797 +// [Description] Add support to check for enabled device in BBS priority +// order before launching legacy boot. +// [Files] bbs.c, Boot.c, Protocol.c +// +// 23 5/29/12 3:49a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 22 4/27/12 7:21a Premkumara +// [TAG] EIP81402 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] HDD Port Number is not properly updated after adding +// "TseDefaultBootOrder" +// [RootCause] when GROUP_BOOT_OPTIONS_BY_TAG=0 BBSList->Name is not +// returned properly +// [Solution] Returned BBSList->Name properly +// [Files] bbs.c, variable.c +// +// 21 1/11/12 7:11a Arunsb +// [TAG] EIP64700 +// [Category] Improvement +// [Description] Request for _BBSSetDevicePriorities to check current +// BootPriority before assigning a new BootPriority +// [Files] bbs.c +// +// 20 12/16/11 5:41a Arunsb +// Reverted 64700 change. Bcoz legacy boot not happening properly. +// +// 19 11/30/11 1:24p Premkumara +// [TAG] EIP75352 +// [Category] Improvement +// [Description] Suppress the warnings from static code analyzer +// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c, +// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c +// +// 18 10/31/11 9:49a Rajashakerg +// [TAG] EIP71120,71512 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] BIOS gets stuck in infinite loop On enabling +// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is +// disabled in Setup & BBS table but in second boot the correct device is +// disabled in both places. +// [Solution] Hidden option handled properly. +// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c, +// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c +// +// 17 9/29/11 1:15p Premkumara +// [TAG] EIP64700 +// Category] Function Request +// [Description] Checking current BootPriority before assigning a new +// BootPriority. +// Not assigning priority if it also BBS_DO_NOT_BOOT_FROM +// [Files] bbs.c +// +// 16 6/20/11 11:43a Rajashakerg +// [TAG] EIP59417 +// [Category] New Feature +// [Description] Spport LOAD_OPTION_HIDDEN option in TSE +// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, +// minisetup.h, special.c, callback.c +// +// 15 3/07/11 4:49p Arunsb +// [TAG] EIP53106 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Invalid string appears in the boot order for Network +// related devices +// [RootCause] Handle not obtained for network related devices +// [Solution] Disabled option is checked only if +// GROUP_BOOT_OPTIONS_BY_TAG token is enabled +// [Files] bbs.c and commonhelper.c +// +// 14 2/04/11 4:42p Mallikarjunanv +// udpated the BBSGetDeviceList() function to update the +// LegacyDevVariables properly in case of TSE Lite. +// +// 13 12/21/10 11:32a Mallikarjunanv +// +// 13 10/06/10 5:48p Madhans +// [TAG] - EIP 45620 +// [Category]- Enhancment +// [Severity]- Mordarate +// [Symptom]- TSE with TSE_CONTINUE_BOOT_NOW_ON_FAIL ON Not allows to boot +// to USB group of devices with customized BDS. +// [RootCause] - BBSTable does not contain the DeviceType called USB. Only +// in EFI Logical group is created in EFI variables. +// TSE was checking the DeviceType to set the priorities. +// [Solution]- TSE is changed to not check for DeviceType in BBSTable. But +// set the priorities based on LegacyDevOrder. +// [Files] - bbs.c commonhelper.c minisetup.h +// +// 12 10/05/10 5:08p Madhans +// [TAG] - EIP 45299 +// [Category]- Enhancment +// [Severity]- Minor +// [Symptom]- TSE by default saves the Disbaled BBS devices device path in +// NVRAM Varaiable "DisabledDevs" Variable. In Next boots it depend on +// this variable to consider the device as disabled inaddtion to +// LegacyDevOrder. +// Some BDS customized projects don't want this. +// [Solution]- TSE_SAVE_DISABLED_BBS_DEVICEPATH SDL token created to +// control this option. Bydefault It is Enabled. +// [Files] - callback.c bbs.c commonhelper.c minisetup.h AMITSE.sdl +// +// 11 9/21/10 11:26a Madhans +// EIP44542 changes +// +// 8 9/20/10 6:47p Madhans +// [TAG] EIP44542 +// [Category] BUILD ISSUE FIX +// [Symptom] Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST +// when IdeSecurity and FastBoot modules added to the project +// [RootCause] - +// [Solution] Build issues resolved +// [Files] CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h, +// bbs.c, special.c, Bds.c TseLitehelp +// +// 7 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 10 9/16/10 3:01p Madhans +// To Avoid build issues with TSE_USE_EDK_LIBRARY Building. +// +// 9 8/27/10 4:59a Mallikarjunanv +// EIP-39334: support to build TSE without the CSM module support +// +// 8 7/28/10 4:46a Mallikarjunanv +// EIP-29951: TSE Device Path Name support updated +// +// 7 3/23/10 5:07p Blaines +// Preseve the order of disabled BBS boot devices. +// +// 6 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 5 1/09/10 5:10a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 4 9/24/09 9:41a Sudhirv +// EIP-24971: moved the dependency for TSE_CONTINUE_BOOT_NOW_ON_FAIL to +// Tse Binary +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// +//********************************************************************** +// +// +// Name: bbs.c +// +// Description: takecare of bbs/legacy boot management. +// +// +//********************************************************************** + +#include "minisetup.h" + +EFI_GUID gLegacyDevGuid = LEGACY_DEV_ORDER_GUID; +BOOT_DATA *gCurrLegacyBootData; +static EFI_LEGACY_BIOS_PROTOCOL *gLegacyBios = NULL; +extern EFI_GUID gEfiLegacyBiosProtocolGuid; + +//Internal functions +EFI_STATUS _BBSInitProtocol( VOID ); +VOID _BBSSetDevicePriorities( BBS_TABLE *BBSInfo, UINT16 *Priority, BOOT_DATA *BootData ); +VOID _CreateDriveString ( CHAR16 *String, UINT16 *IdentifyDriveData ); +VOID BBSBuildName( CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo ); +BOOLEAN _BBSCheckDisabled( BBS_TABLE *BBSEntry ); +UINT8 IsBootOptionsGroupingEnabled (void); + +// +//---------------------------------------------------------------------------- +// Procedure: _BBSInitProtocol +// +// Description: function to initialize the bbs protocol. +// +// Input: void +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +EFI_STATUS _BBSInitProtocol( VOID ) +{ + EFI_STATUS Status = EFI_SUCCESS; + + if ( gLegacyBios != NULL ) + return Status; + + Status = gBS->LocateProtocol( &gEfiLegacyBiosProtocolGuid, NULL, &gLegacyBios ); + if ( EFI_ERROR( Status ) ) + gLegacyBios = NULL; + + return Status; +} + + +INTN CompareDevicePath(EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2){ + UINTN len; +//--------------------- + if(!pDp1 && !pDp2) return 0; //if both is NULL than Dp1==Dp2 + if(!pDp1 || !pDp2) return -1; // if one is NULL than Dp1!=Dp2 + len=EfiDevicePathSize(pDp1); + if(EfiDevicePathSize(pDp2)!=len) return -1; + return MemCmp(pDp1,pDp2, len); +} + + +// +//---------------------------------------------------------------------------- +// Procedure: MatchDevicePath +// +// Description: Matches the Device path from the BootOption to BBS Device path to locate the +// right Device +// +// Input: pBootData - Boot Data of Boot Option +// LegacyOrder - LegacyDevOrder Entry for Boot Option +// DevHandle - BBS device Handle +// +// Output: BOOLEAN - TRUE - Device path matched betweend LegacyOrder and pBootData. +// +//---------------------------------------------------------------------------- +// +BOOLEAN MatchDevicePath(BOOT_DATA *pBootData, BBS_ORDER_TABLE* LegacyOrder, EFI_HANDLE DevHandle) +{ + CHAR16 *varName = L"BootXXXX"; + BOOT_OPTION *pOption; + UINTN OptionSize; + EFI_DEVICE_PATH_PROTOCOL *Path; + EFI_DEVICE_PATH_PROTOCOL *BBSDevDP; + EFI_STATUS Status; + BOOLEAN bRet=FALSE; + + OptionSize = 0; pOption = NULL; + SPrint( varName, sizeof(CHAR16) * (EfiStrLen( varName )+1),gBootFormarSpecifier, pBootData->Option ); + pOption = (BOOT_OPTION *)VarGetNvramName( varName, &gEfiGlobalVariableGuid, NULL, &OptionSize ); + + if(EfiDevicePathSize(pBootData->DevicePath) == pOption->PathLength) + { // Device path Length Matches + // Not Flex Boot + bRet=TRUE; + goto DONE; + } + + //For Flex Boot try to match Device path of BBS Device + + // Skip the BBS Devicepath + Path = (EFI_DEVICE_PATH_PROTOCOL*)(((UINTN)pBootData->DevicePath) + EfiDevicePathSize(pBootData->DevicePath)); + + Status = gBS->HandleProtocol( DevHandle, &gEfiDevicePathProtocolGuid, &BBSDevDP ); + + // Not able to locate just matched the Device type + if ( EFI_ERROR( Status ) ) + { + bRet=TRUE; + goto DONE; + } + + //Comparing device path length if MATCH_BOOT_OPTION_BY_LOCATION = 1 devicepath(BBSDevDP) and DevicePath length are equal + if(CompareDevicePath(Path, BBSDevDP) == 0) + { + bRet=TRUE; + } + + //EIP-151484 If MATCH_BOOT_OPTION_BY_LOCATION = 0 then devicepath(BBSDevDP) and Device Pathlength will be different so matching with DeviceType + else if( ( ((BBS_ORDER_TABLE*)LegacyOrder)->Type == BBSDevDP->Type ) || + ( ((BBS_BBS_DEVICE_PATH*)pBootData->DevicePath)->DeviceType == BBSDevDP->Type ) + ) + { + bRet = TRUE; + } + +DONE: + MemFreePointer((VOID **)&pOption); + + return bRet; +} + +//EIP109382 Starts +// +//------------------------------------------------------------------------------------- +// Procedure: RearrangeBBSOrder +// +// Description: Rearranges the bootdata legacy entries with legacydevorder defaults +// +// Input: VOID * - Cache Buffer +// +// Output: VOID +// +//-------------------------------------------------------------------------------------- +// +//UINT8 IsBootOptionsGroupingEnabled (VOID); +EFI_STATUS _BBSInitProtocol (VOID); +BOOLEAN MatchDevicePath(BOOT_DATA *pBootData, BBS_ORDER_TABLE* LegacyOrder, EFI_HANDLE DevHandle); +VOID RearrangeBBSOrder (NVRAM_VARIABLE *nvPtr, NVRAM_VARIABLE *DefaultBuffer) +{ + EFI_STATUS Status; + UINT16 HDDCount = 0, BBSCount = 0; + HDD_INFO *HDDInfo = NULL; + BBS_TABLE *BBSInfo = NULL; + UINT16 *BootOrder; + UINTN BootOrderSize,p; + BOOT_DATA *pBootData; + UINT16 count = 0; + UINTN CurrSize = 0, iIndex = 0; + EFI_GUID AmitseBootOrderChangeGuid = AMITSE_BOOT_ORDER_CHANGE_GUID; + BBS_ORDER_TABLE *DevEntry = NULL, *CurrOrder = NULL, *NewLegacyOrder = NULL, *NewDevEntry = NULL; + BBS_BBS_DEVICE_PATH *DevPath = NULL; + + Status = _BBSInitProtocol (); + if (EFI_ERROR (Status)) + return; + + Status = gLegacyBios->GetBbsInfo ( + gLegacyBios, + &HDDCount, + &HDDInfo, + &BBSCount, + &BBSInfo + ); + if (EFI_ERROR (Status)) + { + return; + } + BootOrderSize = 0; + BootOrder = VarGetNvramName (L"BootOrder", &gEfiGlobalVariableGuid, NULL, &BootOrderSize); + + if ((NULL == BootOrder) || (0 == BootOrderSize)) + return; //continue; + + NewLegacyOrder = EfiLibAllocateZeroPool (DefaultBuffer->Size); + if (NULL == NewLegacyOrder) + { + MemFreePointer((VOID **) &BootOrder); + return; + } + + //NOTE: Taking advantage of the fact that + //VARIABLE_ID_BBS_ORDER is after + //VARIABLE_ID_BOOT_ORDER + NewDevEntry = NewLegacyOrder; + for (p=0; p<(BootOrderSize/sizeof(UINT16)); p++) + { + pBootData = BootGetBootData (BootOrder[p]); + //EIP:59417 - Error Handling in case of pBootData is NULL. If its NULL the setupgets a CRASH + if (pBootData == NULL) + goto DONE; + + if (BBSValidDevicePath (pBootData->DevicePath)) + { + DevPath = (BBS_BBS_DEVICE_PATH *)pBootData->DevicePath; + DevEntry = (BBS_ORDER_TABLE *)DefaultBuffer->Buffer; + for (iIndex = 0; iIndex < DefaultBuffer->Size; ) + { + if ( (DevEntry->Length >= DefaultBuffer->Size) || (0 == DevEntry->Length) ) //EIP-120011 + { + return; + } + + count = DevEntry->Length / sizeof(UINT16) - 1; + + if (count) + { + if (DevPath->DeviceType == DevEntry->Type) + { + if (MatchDevicePath (pBootData, DevEntry, (EFI_HANDLE)*(UINTN*)&BBSInfo[(UINT8)DevEntry->Data[0]].IBV1) ) + //Found a valid dev entry group. + break; + } + } + count = sizeof (UINT32) + DevEntry->Length; + DevEntry = (BBS_ORDER_TABLE *)((UINTN)DevEntry + count); + iIndex += count; + } + if (iIndex < DefaultBuffer->Size) + { + MemCopy (NewDevEntry, DevEntry, sizeof(UINT32) + DevEntry->Length); + } + pBootData->LegacyEntryOffset = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder; + //create boot data order list + NewDevEntry = (BBS_ORDER_TABLE *)((UINTN)NewDevEntry + sizeof (UINT32) + DevEntry->Length); + } + } + MemFreePointer ((VOID **)&nvPtr->Buffer); + nvPtr->Buffer = (UINT8 *)NewLegacyOrder; +DONE: + //Update the nv buffer with the re ordered list + + //Signal TPM if BBS order has changed + CurrOrder = VarGetNvramName (L"LegacyDevOrder", &gLegacyDevGuid, NULL, &CurrSize); + if (NULL == CurrOrder) + { + MemFreePointer((VOID **) &BootOrder); + return; + } + if (CurrOrder) + { + if (MemCmp ((UINT8 *)CurrOrder, (UINT8 *)NewLegacyOrder, CurrSize)) + EfiLibNamedEventSignal (&AmitseBootOrderChangeGuid); + + MemFreePointer((VOID **) &CurrOrder); + } + MemFreePointer((VOID **) &BootOrder); +} +//EIP109382 Ends + +// +//---------------------------------------------------------------------------- +// Procedure: BBSGetDeviceList +// +// Description: function to get the list of all the devices +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BBSGetDeviceList( VOID ) +{ + EFI_STATUS Status; + + UINT16 HDDCount = 0, BBSCount = 0; + HDD_INFO *HDDInfo = NULL; + BBS_TABLE *BBSInfo = NULL; + + BBS_ORDER_TABLE *LegacyOrder = NULL, *NewLegacyOrder = NULL, *DevEntry, *NewDevEntry; + UINTN NewLegacyOrderSize, LegacyOrderSize=0, j, l; + UINT16 count = 0,u16Tmp; + UINT16 *BootOrder = NULL, *NewBootOrder = NULL; + UINTN NewBootOrderSize, BootOrderSize=0, i, k; + BOOT_DATA *pBootData; + BBS_BBS_DEVICE_PATH * DevPath; + UINT16 NoOfLegacyGroups = 0; + UINT32 LegDevOrderAttribute = 7; + + Status = _BBSInitProtocol(); + if ( EFI_ERROR( Status ) ) + return; + + Status = gLegacyBios->GetBbsInfo( + gLegacyBios, + &HDDCount, + &HDDInfo, + &BBSCount, + &BBSInfo + ); + + LegacyOrderSize = 0; + + LegacyOrder = VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, &LegDevOrderAttribute, &LegacyOrderSize ); + if ( LegacyOrder == NULL ) + goto DONE; + + BootOrderSize = 0; + BootOrder = VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &BootOrderSize ); + if(NULL == BootOrder) + goto DONE; + + //Check if the Master boot order and Legacy dev order match. + //Create corrected new orders if not. + NewLegacyOrder = EfiLibAllocateZeroPool(LegacyOrderSize); + NewBootOrder = EfiLibAllocateZeroPool(BootOrderSize); + + //NOTE: Device count will not be initialised here. It will be + //initialised with the number of devices in a group when the user + //switches to a page specific to that group. + NoOfLegacyGroups = 0; + k = 0; + NewDevEntry = NewLegacyOrder; + for(i=0; i<(BootOrderSize/sizeof(UINT16)); i++) + { + pBootData = BootGetBootData(BootOrder[i]); + if(pBootData) + { + if(BBSValidDevicePath(pBootData->DevicePath)) + { + //BBS boot order entry + DevPath = (BBS_BBS_DEVICE_PATH *)pBootData->DevicePath; + + DevEntry = LegacyOrder; + for(j=0; jLength >= LegacyOrderSize) || (0 == DevEntry->Length) ) //EIP-120011 + { + return; + } + count = DevEntry->Length / sizeof(UINT16) - 1; + + if (count) + { + if(DevPath->DeviceType == DevEntry->Type) + { + if(MatchDevicePath(pBootData, DevEntry,(EFI_HANDLE)*(UINTN*)&BBSInfo[(UINT8)DevEntry->Data[0]].IBV1 )) + //Found a valid dev entry group. + break; + } + } + + //Go to next entry + count = sizeof(UINT32) + DevEntry->Length; + DevEntry = (BBS_ORDER_TABLE *)((UINTN)DevEntry + count); + j += count; + } + + if(jLength); + NoOfLegacyGroups++; + + pBootData->LegacyEntryOffset = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder; + pBootData->LegacyDevCount = count; + + + if(gIsSaveDisabledBBSDevicePath) + { + //Make sure the right devices are disabled + for(j=0;jData[j] & BBS_ORDER_DISABLE_MASK)) + { + //BBS Type Network Device doesnot publish any Handle hence, directly assigning the actual Index + if(BBS_TYPE_EMBEDDED_NETWORK == NewDevEntry->Type)//EIP-175119 + NewDevEntry->Data[j] = (UINT8)(NewDevEntry->Data[j]); + //Make sure we have the device path in NVRAM for this legacy option + else if( !_BBSCheckDisabled( &(BBSInfo[(UINT8)(NewDevEntry->Data[j])]) ) ) + { + NewDevEntry->Data[j] = (UINT8)(NewDevEntry->Data[j]); + } + } + } + } + + if(!IsPreservedDisabledBootOptionOrder()) + { + //Correct LegacyDevOrder variable if necessary. Move + //disabled devices to end. + for ( j = 0; j < count; j++ ) + { + if(BBS_ORDER_DISABLE_MASK == (NewDevEntry->Data[j] & BBS_ORDER_DISABLE_MASK)) + { + for(l=j+1; lData[l] & BBS_ORDER_DISABLE_MASK)) + { + u16Tmp = NewDevEntry->Data[l]; + NewDevEntry->Data[l] = NewDevEntry->Data[j]; + NewDevEntry->Data[j] = u16Tmp; + break; + } + } + if(l>=count) + break; + } + } + } + + //create boot data order list + pBootData->OrderList = EfiLibAllocateZeroPool( count * sizeof(BBS_ORDER_LIST) ); + for ( j = 0; j < count; j++ ) + { + pBootData->OrderList[j].Index = NewDevEntry->Data[j] & (~BBS_ORDER_DISABLE_MASK); + BBSBuildName( + pBootData->OrderList[j].Name, + &BBSInfo[pBootData->OrderList[j].Index], + pBootData->OrderList[j].Index, + HDDInfo + ); + } + + //Move pointer to the unused portion + count = sizeof(UINT32) + NewDevEntry->Length; + NewDevEntry = (BBS_ORDER_TABLE *)((UINTN)NewDevEntry + count); + + //Mark it used in DevEntry by assigning device type + //to BBS_TYPE_UNKNOWN + DevEntry->Type = BBS_TYPE_UNKNOWN; + } + } + else + { + //A valid non bbs boot order entry + NewBootOrder[k] = BootOrder[i]; + k++; + } + } + } + + //Set corrected variables + NewLegacyOrderSize = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder; + VarSetNvramName(L"LegacyDevOrder", + &gLegacyDevGuid, + LegDevOrderAttribute, + NewLegacyOrder, + NewLegacyOrderSize); + + NewBootOrderSize = k*sizeof(UINT16); + VarSetNvramName(L"BootOrder", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + NewBootOrder, + NewBootOrderSize); + + MemFreePointer( (VOID **)&BootOrder ); + MemFreePointer( (VOID **)&NewBootOrder ); + MemFreePointer( (VOID **)&LegacyOrder ); + MemFreePointer( (VOID **)&NewLegacyOrder ); + +DONE: + //Set LegacyDev variable with number of groups + UpdateLegacyDevVariable(NoOfLegacyGroups); + + //Set the LegacyGroup variable to zero for now + NoOfLegacyGroups = 0; + VarSetNvramName( L"LegacyGroup", &gLegacyDevGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &NoOfLegacyGroups, sizeof(NoOfLegacyGroups) ); + +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSSetBootPriorities_BootOrder +// +// Description: Assign priority as per boot order other than 0 priority devices +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BBSSetBootPriorities_BootOrder(UINT16 Priority) +{ + EFI_STATUS Status; + UINT16 *pBootOrder=NULL; + UINT16 BootOrderCount = 0; + UINT16 DevType=0; + UINTN size=0; + UINT16 HDDCount = 0; + UINT16 BBSCount = 0; + HDD_INFO *HDDInfo = NULL; + BBS_TABLE *BBSInfo = NULL; + BOOT_DATA *pBootData; + UINT16 i,index,index1; + UINT16 j; + UINT8 *pDevOrder; + BBS_ORDER_TABLE *pDevEntry; + + Status = _BBSInitProtocol(); + if ( EFI_ERROR( Status ) ) + return; + + Status = gLegacyBios->GetBbsInfo( + gLegacyBios, + &HDDCount, + &HDDInfo, + &BBSCount, + &BBSInfo + ); + + if ( EFI_ERROR( Status ) ) + return; + + size =0 ; + pBootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + BootOrderCount=(UINT16)(size/sizeof(UINT16)); + + if (pBootOrder==NULL) + return; + + size = 0; + pDevOrder = (UINT8 *)VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size ); + + if (pDevOrder==NULL) + { + MemFreePointer((VOID **) &pBootOrder); + return; + } + + for(j=0;jDevicePath ) ) + { + pDevEntry = (BBS_ORDER_TABLE *)(pDevOrder + pBootData->LegacyEntryOffset); + + if ( (pDevEntry->Length >= size) || (0 == pDevEntry->Length) ) //EIP-120011 + { + return; + } + //search for boot options which are disabled and change their priority to BBS_DO_NOT_BOOT_FROM + for(index=0;indexLegacyDevCount;index++)//EIP-166385 + { + for(index1=0;index1LegacyDevCount;index1++) + { + if(((pBootData->OrderList[index])).Index == pDevEntry->Data[index1]) + break; + } + if(index1 == pBootData->LegacyDevCount) + BBSInfo[((pBootData->OrderList[index])).Index].BootPriority = BBS_DO_NOT_BOOT_FROM; + } + for(i=0;iLegacyDevCount;i++) + { + if(!(pDevEntry->Data[i] & BBS_ORDER_DISABLE_MASK)) + { + if(BBSInfo[pDevEntry->Data[i]].BootPriority == BBS_UNPRIORITIZED_ENTRY) + { + BBSInfo[pDevEntry->Data[i]].BootPriority = Priority; + Priority++; + } + } + } + } + } + + MemFreePointer((VOID **) &pDevOrder); + MemFreePointer((VOID **) &pBootOrder); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSSetBootPriorities +// +// Description: function to set boot priorities +// +// Input: BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BBSSetBootPriorities( BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount) +{ + EFI_STATUS Status; + UINT16 HDDCount = 0, BBSCount = 0; + UINT16 i, Priority = 0; + HDD_INFO *HDDInfo = NULL; + BBS_TABLE *BBSInfo = NULL; + UINT16 *pBootOrder=NULL; + UINT16 BootOrderCount = 0; + UINTN size=0; + + Status = _BBSInitProtocol(); + if ( EFI_ERROR( Status ) ) + return; + + Status = gLegacyBios->GetBbsInfo( + gLegacyBios, + &HDDCount, + &HDDInfo, + &BBSCount, + &BBSInfo + ); + + if ( EFI_ERROR( Status ) ) + return; + pBootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + BootOrderCount=(UINT16)(size/sizeof(UINT16)); + for ( i = 0; i < BBSCount; i++ ) + { + switch ( BBSInfo[i].BootPriority ) + { + case BBS_IGNORE_ENTRY: + case BBS_LOWEST_PRIORITY: + case BBS_DO_NOT_BOOT_FROM: //EIP 64700 + continue; + default: + BBSInfo[i].BootPriority = BBS_UNPRIORITIZED_ENTRY; + break; + } + } + + if(pOrder) + { + for ( i = 0; i < BootOrderCount; i++ ) + { + pBootData = BootGetBootData(pOrder[i]); + + if(!pBootData) + continue; + + if ( BBSValidDevicePath( pBootData->DevicePath ) ) + _BBSSetDevicePriorities( BBSInfo, &Priority, pBootData); + } + } + else + { + if ( BBSValidDevicePath( pBootData->DevicePath ) ) + _BBSSetDevicePriorities( BBSInfo, &Priority, pBootData ); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BBSSetDevicePriorities +// +// Description: function to set boot device priorities +// +// Input: BBS_TABLE *BBSInfo, UINT16 *Priority, BOOT_DATA *BootData +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID _BBSSetDevicePriorities( BBS_TABLE *BBSInfo, UINT16 *Priority, BOOT_DATA *BootData ) +{ + UINT8 *pDevOrder; + UINTN size; + UINT16 i,index,index1; + BBS_ORDER_TABLE *pDevEntry; + + size = 0; + pDevOrder = (UINT8 *)VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size ); + //EIP-75352 Suppress the warnings from static code analyzer + if(NULL == pDevOrder) + return; + + pDevEntry = (BBS_ORDER_TABLE *)(pDevOrder + BootData->LegacyEntryOffset); + + if ( (pDevEntry->Length >= size) || (0 == pDevEntry->Length) ) //EIP-120011 + return; + //search for boot options which are disabled and change their priority to BBS_DO_NOT_BOOT_FROM + for(index=0;indexLegacyDevCount;index++)//EIP-166385 + { + for(index1=0;index1LegacyDevCount;index1++) + { + if(((BootData->OrderList[index])).Index == pDevEntry->Data[index1]) + break; + } + if(index1 == BootData->LegacyDevCount) + BBSInfo[((BootData->OrderList[index])).Index].BootPriority = BBS_DO_NOT_BOOT_FROM; + } + + for ( i = 0; i < BootData->LegacyDevCount; i++ ) + { + if(!(pDevEntry->Data[i] & BBS_ORDER_DISABLE_MASK)) + { + // don't set the BootPriority if it already the first one. + //EIP: 64700 Checking current BootPriority before assigning a new BootPriority + if ( (BBSInfo[pDevEntry->Data[i]].BootPriority != 0) && (BBSInfo[pDevEntry->Data[i]].BootPriority != BBS_DO_NOT_BOOT_FROM) ) //EIP 64700 + { + BBSInfo[pDevEntry->Data[i]].BootPriority = *Priority; + (*Priority)++; + } + } + } + + MemFreePointer((VOID **) &pDevOrder); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSSetBootNowPriority +// +// Description: Sets BBS priority for the BootNow devices. +// +// Input: BootData - Boot data +// uiPrefferedDevice - prefered Device type valid in ShowAllBBSDev case +// ShowAllBbsDev - SETUP_SHOW_ALL_BBS_DEVICES +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS BBSSetBootNowPriority( BOOT_DATA *BootData,UINTN uiPrefferedDevice,BOOLEAN ShowAllBbsDev) +{ + EFI_STATUS Status = EFI_SUCCESS; + UINT16 count = 0, offset = 0; + UINT8 *pDevOrder = NULL; + UINTN size = 0; + UINT16 HDDCount = 0, BBSCount = 0; + UINT16 i; + UINT16 Priority = 0; + + BBS_ORDER_TABLE *pDev = NULL; + HDD_INFO *HDDInfo = NULL; + BBS_TABLE *BBSInfo = NULL; + BBS_ORDER_LIST *BBSList = NULL; + + Status = _BBSInitProtocol(); + if ( EFI_ERROR( Status ) ) + return Status; + + Status = gLegacyBios->GetBbsInfo( + gLegacyBios, + &HDDCount, + &HDDInfo, + &BBSCount, + &BBSInfo + ); + + if ( EFI_ERROR( Status ) ) + return Status; + + for ( i = 0; i < BBSCount; i++ ) + { + switch ( BBSInfo[i].BootPriority ) + { + case BBS_IGNORE_ENTRY: + case BBS_LOWEST_PRIORITY: + case BBS_DO_NOT_BOOT_FROM: //EIP 64700 + continue; + default: + BBSInfo[i].BootPriority = BBS_UNPRIORITIZED_ENTRY; + break; + } + } + if(!ShowAllBbsDev) + { + count = BootData->LegacyDevCount; + offset = (UINT16)BootData->LegacyEntryOffset; + + size = 0; + pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size); + //EIP-75352 Suppress the warnings from static code analyzer + if(NULL == pDevOrder) + return EFI_NOT_FOUND; + + pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset); + + if ( (pDev->Length >= size) ||(0 == pDev->Length) ) //EIP-120011 + return EFI_NOT_FOUND; + + for ( i = 0; i < count; i++ ) + { + if(DISABLED_BOOT_OPTION != pDev->Data[i]) + { + BBSInfo[pDev->Data[i]].BootPriority = Priority; + Priority++; + } + } + } + else + { + BBSList = BootData->OrderList; + BBSInfo[BBSList[uiPrefferedDevice].Index].BootPriority = Priority; + Priority++; + } + + + TseBBSSetBootPriorities_BootOrder(Priority); + + if (0 == Priority ) //EIP-93797 + return EFI_UNSUPPORTED; + + return Status; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: CreateDriveString +// +// Description: function to create the device string +// +// Input: CHAR16 *String, UINT16 *IdentifyDriveData +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID _CreateDriveString ( CHAR16 *String, UINT16 *IdentifyDriveData ) +{ + UINT8 i, data8; + UINT16 data16; + UINT8 s[MAX_DRIVE_NAME] = "APAT :"; // "PATA: " + + //Check if identify drive data is available + if(NULL == IdentifyDriveData) + return; + + // Check Word76 for BIT1 and BIT2; set for SATA drives + data16 = IdentifyDriveData[76]; + if ((data16 != 0xFFFF) && (data16 & 6)) { + s[1] = 'S'; + } + + // Get the drive name out of IdentifyDrive data word 27..46 (upto 40 chars) + MemCopy(&s[6], IdentifyDriveData+27, MAX_DRIVE_NAME-5); + + // Swap the bytes + for (i=0; i +//---------------------------------------------------------------------------- +// Procedure: BBSBuildDefaultName +// +// Description: function to build the default boot device name +// +// Input: CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BBSBuildDefaultName( CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + UINT8 i, *StringDesc; + + // If current BBS entry has its description then use it. + StringDesc = (UINT8*)(UINTN)((info->DescStringSegment << 4) + info->DescStringOffset); + if ( StringDesc != NULL ) + { + for ( i = 0; (i < (MAX_DRIVE_NAME - 1)) && (StringDesc[i] != L'\0'); i++ ) + String[i] = (CHAR16)StringDesc[i]; + + String[i] = L'\0'; + } + else + { + Status = GetAdvanceDeviceName(String, info, index, HDDInfo); + if ( Status != EFI_SUCCESS ) { + switch ( info->DeviceType ) + { + case BBS_TYPE_FLOPPY: + EfiStrCpy(String, L"Floppy"); + break; + + case BBS_TYPE_HARDDRIVE: + EfiStrCpy(String, L"Hard Drive"); + + case BBS_TYPE_CDROM: + if(BBS_TYPE_CDROM == info->DeviceType) + EfiStrCpy(String, L"CDROM"); + + if((index < 17) && (index > 0)) { + _CreateDriveString(String, HDDInfo[(index-1)/2].IdentifyDrive[(index-1)%2].Raw); + } + break; + + case BBS_TYPE_EMBEDDED_NETWORK: + EfiStrCpy(String, L"Network"); + break; + + case BBS_TYPE_DEV: + EfiStrCpy(String, L"BEV Device"); + break; + + case BBS_TYPE_UNKNOWN: + default: + EfiStrCpy(String, L"Unknown"); + break; + } + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSLaunchDevicePath +// +// Description: function to launch the device path +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS BBSLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath ) +{ + EFI_STATUS Status; + + Status = _BBSInitProtocol(); + + if ( EFI_ERROR( Status ) ) + return Status; + + // Performance measurement Pause + PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0); + + Status = gLegacyBios->LegacyBoot( gLegacyBios, (BBS_BBS_DEVICE_PATH *)DevicePath, 0, NULL ); + + // Performance measurement continue + PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSUpdateBootData +// +// Description: function to update boot related data +// +// Input: UINT16 GroupNo +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BBSUpdateBootData(UINT16 GroupNo) +{ + UINTN i,j; + BOOT_DATA *bootData; + + for( j=0,i=0; iActive & LOAD_OPTION_HIDDEN)) + continue; + + if ( BBSValidDevicePath(bootData->DevicePath) ) + { + if(GroupNo == j) + { + gCurrLegacyBootData = bootData; + break; + } + j++; + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSGetOptionName +// +// Description: function to get the name of the option +// +// Input: UINT16 *Option, UINT16 Pos +// +// Output: string +// +//---------------------------------------------------------------------------- +// +CHAR16 *BBSGetOptionName( UINT16 *Option, UINT16 Pos ) +{ + UINT16 count; + BBS_ORDER_LIST *BBSList; + + BBSList = gCurrLegacyBootData->OrderList; + count = gCurrLegacyBootData->LegacyDevCount; + + if(count <= Pos) + return( L""); + + if( Option != NULL ) + *Option=(BBSList+Pos)->Index; + + if ( BBSList != NULL ) + return (BBSList+Pos)->Name; + + return NULL; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BBSCheckDisabled +// +// Description: function to check whether a perticular entry is disabled. +// +// Input: UINT16 *Option, UINT16 Pos +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +BOOLEAN _BBSCheckDisabled( BBS_TABLE *BbsEntry ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + UINTN i,size = 0; + EFI_GUID BootManGuid = BOOT_MANAGER_GUID; + EFI_DEVICE_PATH_PROTOCOL *dpp = NULL, *NvramDP = NULL, *TmpNvramDP; + + Handle = *(VOID**)(&BbsEntry->IBV1); + + if (Handle == 0) + return TRUE; + + Status = gBS->HandleProtocol(Handle, &gEfiDevicePathProtocolGuid, &dpp); + + if(EFI_ERROR(Status)) + return TRUE; + + TmpNvramDP = NvramDP = (EFI_DEVICE_PATH_PROTOCOL *)VarGetNvramName(L"DisabledDevs", &BootManGuid, NULL, &size); + + if(NULL == NvramDP) + return FALSE; + + for(i=0;i +//---------------------------------------------------------------------------- +// Procedure: BBSSetDisabled +// +// Description: function to disable a perticular entry. +// +// Input: UINT16 Index, VOID **DisDPs, UINTN *DPSize +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BBSSetDisabled(UINT16 Index, VOID **DisDPs, UINTN *DPSize) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + UINT16 HDDCount = 0, BBSCount = 0; + + HDD_INFO *HDDInfo = NULL; + BBS_TABLE *BBSInfo = NULL; + EFI_DEVICE_PATH_PROTOCOL *dpp = NULL; + + Status = _BBSInitProtocol(); + if ( EFI_ERROR( Status ) ) + return; + + Status = gLegacyBios->GetBbsInfo( + gLegacyBios, + &HDDCount, + &HDDInfo, + &BBSCount, + &BBSInfo + ); + + Handle = *(VOID**)(&(BBSInfo[Index].IBV1)); + if (Handle) + { + Status = gBS->HandleProtocol(Handle, &gEfiDevicePathProtocolGuid, &dpp); + if(!EFI_ERROR(Status)) + { + *DisDPs = MemReallocateZeroPool(*DisDPs, *DPSize, *DPSize + EfiDevicePathSize(dpp)); + MemCopy( ((UINT8 *)*DisDPs)+*DPSize, dpp, EfiDevicePathSize(dpp)); + *DPSize += EfiDevicePathSize(dpp); + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: GetBBSBootOptionName +// +// Description: function to get the Boot option name. +// +// Input: BOOT_DATA *bootData +// +// Output: CHAR16* - BootOptionName +// +//---------------------------------------------------------------------------- +// + +CHAR16 *GetBBSBootOptionName( BOOT_DATA *bootData) +{ + UINT16 offset = 0, count = 0, i; + UINT8 *pDevOrder; + UINTN size = 0; + BBS_ORDER_LIST *BBSList = NULL; + BBS_ORDER_TABLE *pDev; + + BBSList = bootData->OrderList; + count = bootData->LegacyDevCount; + offset = (UINT16)bootData->LegacyEntryOffset; + + pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size); + //EIP-75352 Suppress the warnings from static code analyzer + if(NULL == pDevOrder) + return NULL; + + if (IsBootOptionsGroupingEnabled ()) + { + pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset); //EIP-81402 + + if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011 + return NULL; + + if (DISABLED_BOOT_OPTION == pDev->Data[0]) //For grouping only test for disable option + { + return gBBSDisabled; + } + + for(i=0; iData[0]) + break; + } + if(iName; + } + + return bootData->Name; +} + +// +//---------------------------------------------------------------------------- +// Procedure: IsBBSDevicePath +// +// Description: function to check for bbs device path support. +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +BOOLEAN IsBBSDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath ) +{ + return (BOOLEAN)( + ( DevicePathType( DevicePath ) == BBS_DEVICE_PATH ) && + ( DevicePathSubType( DevicePath ) == BBS_BBS_DP ) + ); +} + +//EIP-93797 Starts +// +//---------------------------------------------------------------------------- +// Procedure: GetBBSOptionStatus +// +// Description: function to get for bbs option status +// +// Input: BOOT_DATA +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN GetBBSOptionStatus(BOOT_DATA *pBootData) +{ + UINT32 offset=0; + UINT8 *pDevOrder; + BBS_ORDER_TABLE *pDev; + UINTN size = 0; + + offset = (UINT16)pBootData->LegacyEntryOffset; + + pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size); + + pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset); + + if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011 + return TRUE; + + //if(((UINT8)pDev->Data[0] == (pBootData->OrderList->Index))&&(BBS_ORDER_DISABLE_MASK == (UINT8)((pDev->Data[0])>>8))) + if(pDev->Data[0] & BBS_ORDER_DISABLE_MASK) + { + MemFreePointer((VOID **) &pDevOrder); + return TRUE; + } + else + { + MemFreePointer((VOID **) &pDevOrder); + return FALSE; + } +} +//EIP-93797 Ends + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/bbs.h b/EDK/MiniSetup/BootOnly/bbs.h new file mode 100644 index 0000000..1bdd3a4 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/bbs.h @@ -0,0 +1,146 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.h $ +// +// $Author: Arunsb $ +// +// $Revision: 6 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.h $ +// +// 6 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 9 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 5 12/21/10 11:46a Mallikarjunanv +// [TAG] EIP47353 +// [Category] Improvement +// [Description] The #define 32 is tokenized so it can be able to +// display more than 32 characters for some boot options. +// [Files] bbs.h, MiniSetup.sdl +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// +//********************************************************************** +// +// +// Name: bbs.h +// +// Description: Header file for bbs/legacy boot management. +// +// +//********************************************************************** + +#ifndef _BBS_H_ +#define _BBS_H_ + +UINT16 gBBSHardDiskOffset ; +UINT16 gBBSCDOffset ; +UINT16 gBBSFloppyOffset ; +UINT16 gBBSNetworkOffset ; +UINT16 gBBSBevOffset ; + +#ifndef MAX_DRIVE_NAME +#define MAX_DRIVE_NAME TSE_MAX_DRIVE_NAME // EIP : 47353 MAX_DRIVE_NAME 32 macro value is changed to TSE_MAX_DRIVE_NAME SDL TOKEN. So maximum character of Drive name can be determined at run time +#endif //MAX_DRIVE_NAME + +typedef struct +{ + UINT16 HardDiskCount; + UINT16 CDROMCount; + UINT16 FloppyCount; + UINT16 NetworkCount; + UINT16 BevCount; +} +BBS_DEVICE_COUNT; + +typedef struct +{ + UINT32 Type; + UINT16 Length; + UINT16 Data[1]; +} +BBS_ORDER_TABLE; + +#define BBS_ORDER_DISABLE_MASK 0xFF00 + +typedef struct _BBS_ORDER_LIST +{ + UINT16 Index; + CHAR16 Name[MAX_DRIVE_NAME]; +} +BBS_ORDER_LIST; + +//exported variables +extern EFI_GUID gLegacyDevGuid; + +//exported functions +VOID BBSGetDeviceList( VOID ); +VOID BBSSetBootPriorities( BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount); +EFI_STATUS BBSSetBootNowPriority( BOOT_DATA *BootData,UINTN uiPrefferedDevice,BOOLEAN ShowAllBbsDev); +BOOLEAN BBSValidDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath ); +EFI_STATUS BBSLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath ); + +VOID BBSUpdateBootData(UINT16 GroupNo); +CHAR16 *BBSGetOptionName( UINT16 *Option, UINT16 Pos ); +//VOID BBSUpdateOrder(UINT16 newOption,UINT32 *offset,UINTN *size, VOID **buffer); +VOID BBSSetDisabled(UINT16 Index, VOID **DisDPs, UINTN *DPSize); + +EFI_STATUS BbsItkBoot(); + +#endif /* _BBS_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/boot.c b/EDK/MiniSetup/BootOnly/boot.c new file mode 100644 index 0000000..5b5036c --- /dev/null +++ b/EDK/MiniSetup/BootOnly/boot.c @@ -0,0 +1,3034 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/boot.c $ +// +// $Author: Arunsb $ +// +// $Revision: 70 $ +// +// $Date: 5/02/14 9:26p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/boot.c $ +// +// 70 5/02/14 9:26p Arunsb +// semicolon added to PERF_END +// +// 69 5/02/14 5:13p Premkumara +// [TAG] EIP162197 +// [Category] Improvement +// [Description] Password encode feature modify to encode using Hashing +// based on token. +// [[Files] Password.c, PasswordEncodeBin.cif, AMITSE.cif, +// TSESource.cif, PasswordEncode.c, PasswordEncode.h, AMITSE.sdl, +// PasswordEncodeBin.mak, PasswordEncodeBin.sdl +// AMIVfr.h, Boot.c +// +// 68 5/02/14 2:24a Arunsb +// [TAG] EIP158989 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] BGRT status bit not cleared with Shell v2.0 +// [RootCause] Shell v2.0 protocol not registered +// [Solution] Shell v2.0 protocol registered and cleared the BGRT status +// bit +// [Files] AMIVfr.h and boot.c +// +// 67 2/11/14 7:52p Arunsb +// [TAG] EIP125719 +// [Category] Improvement +// [Description] The EfiCreateEventReadyToBoot is conflicted under +// UefiLib.h and EDKhelper.h. +// [Files] boot.c +// +// 66 12/04/13 5:20a Premkumara +// [TAG] EIP123535 +// [Category] Improvement +// [Description] Moved saving quietboot resolution to DrawQuietBootLogo() +// to avoid setting resolution of initPostScreenthis while booting. +// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c +// +// 65 11/06/13 12:16p Arunsb +// [TAG] EIP136592, 141863 +// [Category] Improvement +// [Description] Resolution restored before signalling +// AMITSE_EVENT_BEFORE_BOOT_GUID +// [Files] boot.c +// +// 64 9/13/13 1:55p Premkumara +// Uploaded back EIP-126807 after TSEBootOnly1240 release. +// +// 63 9/13/13 8:33a Premkumara +// Reverted EIP-126807 for TSEBootOnly1240 release. +// +// 61 7/02/13 10:06a Premkumara +// [TAG] EIP120011 +// [Category] Improvement +// [Description] Variable BootOrder and LegacyDevOrder need +// fool-proofing function when TSE load variabled +// [Files] Bbs.c, Boot.c, Callback.c, TseLiteHelper.c, Variable.c +// +// 60 6/10/13 1:17p Arunsb +// BS->CalculateCrc32 used to calculate CRC +// +// 59 5/21/13 5:52a Rajashakerg +// [TAG] EIP121881 +// [Category] Improvement +// [Description] Change resolution before boot in FastBoot path +// [Files] boot.c +// +// 58 4/18/13 2:18a Arunsb +// [TAG] EIP113266 +// [Category] Improvement +// [Description] gBrowserCallbackEnabled variable moved to boot only +// module +// [Files] boot.c and FormBrowser2.c +// +// 57 3/18/13 12:23a Arunsb +// [TAG] EIP117338 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] TSE BootGetBBSOptionStatus asserts +// [RootCause] Pointer incremented from allocated initial memory and +// freed so asserts +// [Solution] Freed the initial allocated memory +// [Files] boot.c +// +// 56 3/14/13 10:50a Premkumara +// [TAG] EIP112796 +// [Category] New Feature +// [Description] AMITSE not signalling AMITSE_EVENT_BEFORE_BOOT_GUID in +// fast boot path and legacy boot path. +// [Files] Boot.c +// +// 55 2/19/13 4:18a Premkumara +// [TAG] EIP103540 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Currently _BootBuildFVDevicePath function using FV +// protocol alone not FV2 protocol. So applications loading from ffs are +// not loading properly. +// [RootCause] _BootBuildFVDevicePath() function used +// gEfiFirmwareVolumeProtocolGuid only not gEfiFirmwareVolume2ProtocolGuid +// [Solution] Used gEfiFirmwareVolume2ProtocolGuid based on +// PISpecVersion +// [Files] CommonHelper.c, Boot.c +// +// 54 12/05/12 5:30a Arunsb +// [TAG] EIP105864 +// [Category] Improvement +// [Description] Screen not cleared properly for successive boots +// [Files] boot.c +// +// 53 10/18/12 11:20a Arunsb +// [TAG] EIP102710 +// [Category] Improvement +// [Description] Include function "_RegisterShellGuid()" in fast boot +// path +// [Files] boot.c +// +// 52 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 19 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 50 9/24/12 9:13a Premkumara +// [TAG] EIP 93797 +// [Category] Improvement +// [Description] Add support to check for enabled device in BBS +// priority order before launching legacy boot. +// [Files] bbs.c, Boot.c, Protocol.c +// +// 49 9/21/12 9:38a Premkumara +// [TAG] EIP 97704 +// [Category] Improvement +// [Description] Support BootFFFF variable +// [Files] Boot.h, Boot.c, Special.c +// +// 48 9/18/12 12:50a Rajashakerg +// [TAG] EIP95518 +// [Category] Improvement +// [Description] Validate the Gop before usage in all the possible cases +// and also get instance of Gop through notification +// [Files] boot.c, notify.c, logo.c +// +// 47 9/17/12 6:10a Rajashakerg +// Updated EIP changes for 2.16 release. +// +// 45 9/12/12 5:23a Rajashakerg +// [TAG] EIP94205 +// [Category] Improvement +// [Description] OEM needs Token to assign the display mode of SHELL +// [Files] AMITSE.sdl, boot.c, CommonHelper.c +// +// 44 8/29/12 4:19p Arunsb +// [TAG] EIP94702 +// [Description] Support for Native Resolution in POST/BOOT +// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c, +// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c, +// ezportplus/stylecommon.c andlegacy/stylecommon.c +// +// 43 6/25/12 5:37p Arunsb +// [TAG] EIP93524 +// [Category] Improvement +// [Description] Invalidate the BGRT table when boot device launched +// from BBS popup or from shell or launched as second boot device +// [Files] boot.c and minisetup.c +// +// 42 5/29/12 3:53a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 41 5/28/12 6:09a Rajashakerg +// [TAG] EIP89377 +// [Category] Improvement +// [Description] Support to LegacyBootFailHook() in TSE. +// [Files] AMITSE.sdl, CommonHelper.c, boot.c +// +// 40 5/25/12 1:38a Premkumara +// [TAG] EIP88430 +// [Category] Improvement +// [Description] Resolution set after logo displayed should retain when +// boot to device. +// [Files] boot.c, logo.c +// +// 39 5/08/12 2:31a Rajashakerg +// [TAG] EIP89483 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Handle hidden boot options properly in BBS Pop up menu +// [RootCause] Check for LOAD_OPTION_HIDDEN is not present when +// TSE_BOOT_NOW_IN_BOOT_ORDER and POPUP_MENU_SHOW_ALL_BBS_DEVICES are +// Disabled +// [Solution] Provided the check for the loda option hidden. +// [Files] boot.c +// +// 38 2/02/12 1:05p Premkumara +// [TAG] EIP75351 +// [Category] Improvement +// [Description] Suppress the warnings from static code analyzer +// [Files] boot.c +// +// 37 1/31/12 6:42a Arunsb +// [TAG] EIP81830 +// [Category] Improvement +// [Description] Support to uninstall the BGRT on legacy boot. +// [Files] Commonhelper.c, postmgmt.c and boot.c +// +// 36 1/13/12 1:40a Arunsb +// For shell the cursor is enabled. Default the cursor is disabled to +// avoid cursor visibility in win8 seamless boot +// +// 35 1/10/12 2:36a Arunsb +// [TAG] EIP77400 +// [Category] Improvement +// [Description] Need to do "Clear Screen" whenever boot to EFI Shell +// [Files] Boot.c and minisetup.h +// +// 34 12/29/11 12:00p Arunsb +// [TAG] EIP74871 +// [Category] Improvement +// [Description] When UEFI booting to windows, a cursor is displayed on +// the lower right hand corner of the screen +// [Files] Screen attribute changed to EFI_BACKGROUND_BLACK | EFI_WHITE +// +// 33 12/14/11 12:14p Premkumara +// [TAG] EIP77400 +// [Category] Improvement +// [Description] Need to do "Clear Screen" whenever boot to EFI Shell +// [Files] Boot.c +// +// 32 12/10/11 4:43a Arunsb +// Corrected the header +// +// 31 12/08/11 12:29p Arunsb +// UpdateDriverVariables function used properly +// +// 30 11/30/11 1:20p Premkumara +// [TAG] EIP75352 +// [Category] Improvement +// [Description] Suppress the warnings from static code analyzer +// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c, +// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c +// +// 29 11/24/11 5:26a Arunsb +// [TAG] EIP75351 +// [Category] Improvement +// [Description] Suppress the warnings from static code analyzer +// [Files] boot.c +// +// 28 11/16/11 11:17a Madhans +// [TAG] EIP75736 +// [Category] Improvement +// [Description] To avoid flicks when booting UEFI OS for seamless boot. +// [Files] Boot.c +// Tseadvanced.c +// +// 27 11/13/11 12:30p Arunsb +// [TAG] EIP70421 +// [Category] New Feature +// [Description] Support for driver order in TSE +// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini, +// boot.c, +// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c, +// addbootoption.c, +// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h, +// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h, +// TseElink.h, variable.h, +// setup.h, Boot.vfr and Setup.uni +// +// 26 11/02/11 10:43a Arunsb +// [TAG] EIP69884 +// [Category] New Feature +// [Description] Support for UEFI Load Options - USB WWID +// [Files] boot.c +// +// 25 11/01/11 3:53p Rajashakerg +// [TAG] EIP71223 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] TSE label 4.6.2_TSE_2_14_1219 has issues in Sandybridge +// platform +// [Solution] Fixed the issue by handling the return status when there +// is no valid boot option to boot. +// [Files] BootOnly\boot.c +// +// 24 10/31/11 9:47a Rajashakerg +// [TAG] EIP71120,71512 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] BIOS gets stuck in infinite loop On enabling +// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is +// disabled in Setup & BBS table but in second boot the correct device is +// disabled in both places. +// [Solution] Hidden option handled properly. +// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c, +// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c +// +// 23 9/24/11 4:41a Arunsb +// [TAG] EIP70096 +// [Category] Improvement +// [Description] Exposing the Handle of the image that's being launched +// for boot. +// This will help other elinks to do the processing. Needed for CsmOptOut +// Feature. +// [Files] BootOnly\boot.c +// +// 22 7/19/11 11:53a Arunsb +// [TAG] EIP65320 +// [Category] Improvement +// [Description] Board module hook for LoadImage failure +// [Files] boot.c and commonhelper.c +// +// 21 7/11/11 4:50p Arunsb +// [TAG] EIP64295 +// [Category] New Feature +// [Description] Support for software created boot entry for USB. +// CheckDevSupShortFormPath function added to check whether the boot +// option supports short-form device path for USB class(Table 60) device +// path. +// Goto statement removed in CheckDevSupShortFormPath function. +// [Files] boot.c +// +// 20 7/11/11 3:24p Arunsb +// [TAG] EIP64295 +// [Category] New Feature +// [Description] Support for software created boot entry for USB. +// CheckDevSupShortFormPath function added to check whether the boot +// option supports short-form device path for USB class(Table 60) device +// path. +// [Files] boot.c +// +// 19 6/30/11 4:13a Arunsb +// [TAG] EIP57661 +// [Category] New Feature +// [Description] Boot manager algorithm for interaction with Driver +// Health protocol. +// Boot device repair operation performed. +// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni, +// commonhelper.c, uefisetup.ini, tsedrvhealth.h, +// amivfr.h, minisetupbin.mak, +// hiistring21.c, hiistring20.c, tseadvanced.c, special.c, +// special.h, boot.h, minisetup.h, +// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and +// uefi21wapper.c. +// +// 18 6/29/11 6:12a Arunsb +// [TAG] EIP 62631, 60128 +// [Category] New Feature +// [Description] Hot key boot option in TSE as per UEFI spec. section +// 3.1.6. +// [Files] AMITSE.sdl, CommonHelper.c, commonoem.c, commonoem.h, +// boot.c, hiistring20.c and hiistring21.c. +// +// 17 6/22/11 2:40p Arunsb +// [TAG] EIP 62631 +// [Category] New Feature +// [Description] Support for Hot key boot option in TSE as per UEFI +// spec. section 3.1.6. +// [Files] AMITSE.sdl, CommonHelper.c, commonoem.c, commonoem.h, +// boot.c, hiistring20.c and hiistring21.c. +// +// 16 6/20/11 3:55p Arunsb +// [TAG] EIP57660 +// [Category] New Feature +// [Description] Non-removable media boot behavior as described in UEFI +// specification v 2.3.1, p. 3.4.1. +// [Files] amitse.sdl, bootflow.c, bootflow.h, commonoem.c, +// boot.c and protocol.c +// +// 15 6/20/11 11:45a Rajashakerg +// [TAG] EIP59417 +// [Category] New Feature +// [Description] Spport LOAD_OPTION_HIDDEN option in TSE +// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, +// minisetup.h, special.c, callback.c +// +// 14 6/10/11 2:35p Arunsb +// [TAG] EIP57660 +// [Category] New Feature +// [Description] Non-removable media boot behavior as described in UEFI +// specification v 2.3.1, p. 3.4.1.2 +// [Files] boot.c, bootflow.c and bootflow.h +// +// 13 6/04/11 1:49p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Wrapper function added for InvalidateStatusInBgrt +// function. +// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and +// commonhelper.c +// +// 12 5/29/11 12:04p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Quiet boot logo's only added for BGRT. BGRT status +// field cleared if any changes happened in screen other than displaying +// the image. +// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and +// commonhelper.c +// +// 11 3/15/11 5:15a Rajashakerg +// [TAG] EIP51671 +// [Category] New Feature +// [Description] Boot overide menu devices are not disable +// [Files] boot.c, minisetup.h, special.c, minisetupext.c, AMITSE.sdl, +// boot.h, CommonHelper.c +// +// 10 2/04/11 4:36p Mallikarjunanv +// UpdateBootVariables() function added to update boot and BBS Order +// varaibles. +// +// 9 1/14/11 6:05p Madhans +// [TAG] EIP52153 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] If new device added once we boot after reboot, Booting +// using BBS popup might Crash +// [RootCause] The BootOrder Varaible is read when TSE entry and And it +// is not synced with Cache value. +// [Solution] Update the BootOrder,BBSOrder variable cache, when we +// handle boot Variables in TSE +// [Files] boot.c +// +// 8 12/02/10 2:33p Madhans +// [TAG] - EIP 48169 +// [Category]- Enhancement +// [Severity]- Mordarate +// [Symptom]- Code Cleanup and Compiler Warning need to resolved. +// [Rootcause] Warnings reported when we build AMI higher Warning level. +// [Solution]- 1. Fix the warnings and do the code cleanup. +// 2. Introduce proper checks. +// 3. change the popupSel.c to not change the Option/variable +// cache to default or first option +// when the variable cache is not matching with any of +// option. +// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c +// popuppassword.c popupsel.c +// expression.c hii.c parse.c +// +// 7 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 13 9/13/10 3:10p Madhans +// [TAG] EIP41137 +// [Category] Improvement +// [Symptom] Boot errors status reported for TSE loaded also +// [RootCause] Fix done in Boot.c. To report the error status only for +// boot options. +// +// 12 9/08/10 6:53a Mallikarjunanv +// EIP-42080: TSE updates with respect to Fast Boot Support +// +// 11 8/23/10 4:00p Blaines +// In the function _BootSetBootManagerVariables, the assert that was +// ensuring that all disabled boot options were forced to the end of the +// list, was left outside of the code block (it was causing a hang after +// inserting a new boot device, then re-booting). +// +// Only process the assert if the preserve disabled boot option order is +// disabled. +// +// 10 7/28/10 4:46a Mallikarjunanv +// EIP-29951: TSE Device Path Name support updated +// +// 9 4/13/10 6:01p Madhans +// Eip: 33100 To create new hook for BootNowLaunching. (From bbsPopoup and +// Boot override menu). +// +// 8 3/23/10 5:08p Blaines +// Preseve the order of disabled BBS boot devices. +// +// 7 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 6 2/15/10 10:10p Madhans +// To avoid Compilation issues +// +// 5 1/29/10 4:37p Madhans +// To not to depend on ConsoleControl and ConOut. +// +// 4 1/29/10 4:34p Madhans +// To avoid compiler warnings. +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 2 5/19/09 6:36p Madhans +// updated the code getting language codes +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 6 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 5 3/31/09 3:33p Madhans +// UnicodeCollection2 protocol support. +// +// 4 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 3 2/05/09 10:15a Madhans +// Style Module created. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: BOOT.C +// +// Description: This file contains code for Boot management +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" +#include EFI_PROTOCOL_DEFINITION (BlockIo) +#include EFI_PROTOCOL_DEFINITION (UsbIo) +#include EFI_PROTOCOL_DEFINITION (DiskIo) +#define BOOT_OPTION_ALLOC_UNIT 10 +////////////////////////////////////// +//Extern Variables +////////////////////////////////////// +extern UINTN gDelOptionCount; +extern BOOT_DATA *gDelBootData; +extern UINT32 gBootFlow; +extern UINTN CurrentScreenresolutionX, CurrentScreenresolutionY; //EIP-88430 +////////////////////////////////////// +//Internal Variable Declarations +////////////////////////////////////// +UINTN gBootOptionCount; +EFI_GUID gBootNowCountGuid = BOOT_NOW_COUNT_GUID; +UINT16 *gBBSDisabled = L"Disabled in BBS Order"; +UINTN gLangCount; +BOOT_DATA *gBootData; +LANGUAGE_DATA *gLanguages; +EFI_HANDLE gCurrentBootHandle = NULL; +EFI_EVENT gShellLaunchEvent = NULL; //EIP 77400 Clearing the screen for shell boot +EFI_EVENT gShell20LaunchEvent = NULL; //EIP158989 For shell2.0 +UINT16 DISABLED_BOOT_OPTION; //EIP-97704 +UINT16 DISABLED_DRIVER_OPTION; //EIP-97704 +UINTN gDriverOptionCount;//EIP70421 & 70422 Support for driver order +BOOT_DATA *gDriverData;//EIP70421 & 70422 Support for driver order +BOOLEAN gBrowserCallbackEnabled = FALSE; //EIP113266 Allow external drivers to change ASL cache only if it's TRUE; ignore browser callback otherwise +////////////////////////////////////// +//Internal Functions Declarations +////////////////////////////////////// +EFI_DEVICE_PATH_PROTOCOL *_BootBuildFVDevicePath( UINT32 *index, EFI_GUID *guidPtr ); +EFI_DEVICE_PATH_PROTOCOL *_BootBuildFileDevicePath( UINT32 *index, CHAR16 *fileName ); +EFI_DEVICE_PATH_PROTOCOL* _DiscoverPartition(EFI_DEVICE_PATH_PROTOCOL *DevicePath); +VOID _BootSetBootManagerVariables(VOID); +VOID _BootInstallLoadOptions( EFI_HANDLE handle, VOID *Options, UINTN OptionSize ); +EFI_STATUS _BootLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Options, UINTN OptionSize, BOOLEAN ValidBootOption ); +UINT16 _BootSetBootNowCount(VOID); +CHAR16 *TseGetUefiDevPathString(EFI_DEVICE_PATH_PROTOCOL *DevPath); +VOID InvalidateStatusInBgrtWrapper (VOID); +VOID UninstallBgrtWrapper(VOID);//EIP81830 Support to uninstall the BGRT on legacy boot +VOID FormHotBootKeys (CHAR16 *VarName); +VOID RefreshBootKeysDetails (VOID); +VOID FreeExtraKeyMemories (VOID); +EFI_STATUS CheckForDeviceNeedRepair (EFI_DEVICE_PATH_PROTOCOL *); +EFI_HANDLE CheckDevSupShortFormPath (EFI_DEVICE_PATH_PROTOCOL *); +VOID LegacyBootFailHook(EFI_STATUS); +VOID UefiBootFailHook (EFI_STATUS); +VOID UpdateBootVariables (); +VOID FixHiddenOptions (BOOLEAN, UINT16 **, UINTN); +VOID _SetDriverManagerVariables (VOID);//EIP70421 & 70422 Support for driver order +VOID UpdateDriverVariables ();//EIP70421 & 70422 Support for driver order +UINT32 ShellTextMode (VOID);//EIP 94205 : OEM needs Token to assign the display mode of SHELL. +UINTN PISpecVersion(VOID);//EIP-103540 + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetBootOptions +// +// Description: This function collects all the boot options, both efi +// and legacy boot options, that are present in the +// system and sets various boot manager variables that +// are used to expand boot manager questions. +// +// Input: VOID +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS BootGetBootOptions( VOID ) +{ + EFI_STATUS Status; + UINTN AllocatedCount; + +#ifndef STANDALONE_APPLICATION + CHAR16 Pattern[]=L"boot[0-9a-f][0-9a-f][0-9a-f][0-9a-f]"; + CHAR16 KeyPattern[]=L"Key[0-9a-f][0-9a-f][0-9a-f][0-9a-f]"; + UINTN OldVarNameSize; + UINTN VarNameSize; + CHAR16 *VarName; + EFI_GUID VarGuid; + VOID * UnicodeInterface; + UINTN size=0, Length = 2; + UINT8 *bufPtr; + BOOT_OPTION *buffer; + BOOT_DATA *dataPtr; + UINT32 *conditionPtr; + UINT16 *BootOrder; + CHAR16 *String=NULL; +// UINTN KeyVarNameSize = 0; +#endif //STANDALONE_APPLICATION + BOOLEAN IsFastBoot=FALSE; +//EIP70421 & 70422 Support for driver order starts + UINTN DriverAllocatedCount; + CHAR16 DriverPattern[] = L"Driver[0-9a-f][0-9a-f][0-9a-f][0-9a-f]"; + BOOLEAN BootOption = FALSE; + BOOLEAN DriverOption = FALSE; +//EIP-97704 Starts + UINT16 jIndex = 0; + DISABLED_BOOT_OPTION = 0xFFFF; + DISABLED_DRIVER_OPTION = 0xFFFF; +//EIP-97704 Ends + DriverAllocatedCount = gDriverOptionCount = 0; +//EIP70421 & 70422 Support for driver order ends + AllocatedCount = gBootOptionCount = 0; +#ifndef STANDALONE_APPLICATION + Status = InitUnicodeCollectionProtocol(&UnicodeInterface); + if(EFI_ERROR(Status)) + return Status; + + RefreshBootKeysDetails (); + //start with a size of 80 bytes + VarNameSize = 80; + OldVarNameSize = VarNameSize; + VarName = EfiLibAllocateZeroPool(VarNameSize); + conditionPtr = VarGetNvramName( L"BootFlow", &_gBootFlowGuid, NULL, &size ); + if ( (conditionPtr != NULL) && (BOOT_FLOW_CONDITION_FAST_BOOT == *conditionPtr) ) + { + IsFastBoot = TRUE; + BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + VarNameSize = ((EfiStrLen(L"BOOTXXXX")+1)*2); + VarName = EfiLibAllocateZeroPool(VarNameSize); + SPrint (VarName, VarNameSize, L"Boot%04X",BootOrder[0] ); + MemFreePointer((VOID **) &BootOrder); + MemFreePointer((VOID **) &conditionPtr); + } + do + { + if (!IsFastBoot) + { + Status = gRT->GetNextVariableName (&VarNameSize, + VarName, + &VarGuid); + if (Status == EFI_BUFFER_TOO_SMALL) + { + //Allocate correct size + VarName = MemReallocateZeroPool (VarName, + OldVarNameSize, + VarNameSize); + OldVarNameSize = VarNameSize; + continue; + } + } +// KeyVarNameSize = VarNameSize; //EIP: 62631 For hot key boot + if ( (VarNameSize == ((EfiStrLen (L"BOOTXXXX")+1)*2)) || (VarNameSize == ((EfiStrLen (L"DRIVERXXXX")+1)*2)) ) //Find if this variable is one of L"BOOTXXXX" or L"DRIVERXXXX" + { + if (MetaiMatch (UnicodeInterface, VarName, Pattern)) //The buffer is definatly a boot#### option + { + size = 0; + buffer = VarGetNvramName (VarName, &gEfiGlobalVariableGuid, NULL, &size); + if (buffer) //Variable exists. Store details in global array. + { + if (gBootOptionCount >= AllocatedCount) //Check if enough size has been already allocated + { + gBootData = MemReallocateZeroPool (gBootData, AllocatedCount * sizeof(BOOT_DATA), (AllocatedCount + BOOT_OPTION_ALLOC_UNIT) * sizeof(BOOT_DATA)); + if (NULL == gBootData) + { + return EFI_UNSUPPORTED; + } + AllocatedCount += BOOT_OPTION_ALLOC_UNIT; + } + dataPtr = &(gBootData [gBootOptionCount]); + HexStringToBuf( + (UINT8 *)(&(dataPtr->Option)), + &Length, + &(VarName[4]), + NULL); + BootOption = TRUE; + gBootOptionCount ++; + } + } + else if (MetaiMatch (UnicodeInterface, VarName, DriverPattern)) //EIP70421 Support for Driver Order + { + size = 0; + buffer = VarGetNvramName (VarName, &gEfiGlobalVariableGuid, NULL, &size); + if (buffer) //Variable exists. Store details in global array. + { + if (gDriverOptionCount >= DriverAllocatedCount) //Check if enough size has been already allocated + { + gDriverData = MemReallocateZeroPool (gDriverData, DriverAllocatedCount * sizeof (BOOT_DATA), (DriverAllocatedCount + BOOT_OPTION_ALLOC_UNIT) * sizeof(BOOT_DATA)); + if (NULL == gDriverData) + { + return EFI_UNSUPPORTED; + } + DriverAllocatedCount += BOOT_OPTION_ALLOC_UNIT; + } + dataPtr = &(gDriverData [gDriverOptionCount]); + HexStringToBuf( + (UINT8 *)(&(dataPtr->Option)), + &Length, + &(VarName[6]), + NULL); + DriverOption = TRUE; + gDriverOptionCount ++; + } + } + else + { + goto _NextVariable; //Jumping for next variable iteration + } + if (DriverOption || BootOption) //Common code for both driver and boot options + { + dataPtr->Active = buffer->Active; + dataPtr->Name = StrDup (buffer->Name); + bufPtr = (UINT8 *)((CHAR16 *)buffer->Name + EfiStrLen( buffer->Name ) + 1); + dataPtr->DevicePath = EfiLibAllocateZeroPool( buffer->PathLength ); + if (NULL != dataPtr->DevicePath) + { + MemCopy (dataPtr->DevicePath, bufPtr, buffer->PathLength); + } + bufPtr += buffer->PathLength; + size -= (UINTN)bufPtr - (UINTN)buffer; + if (size != 0) + { + dataPtr->LoadOptions = EfiLibAllocatePool( size ); + if ( dataPtr->LoadOptions != NULL ) + { + dataPtr->LoadOptionSize = size; + MemCopy( dataPtr->LoadOptions, bufPtr, size ); + } + } + if (BootOption) + { + //In case of DEVIE PATH support, to reset the name using device path + String = TseGetUefiDevPathString(dataPtr->DevicePath); + if (NULL != String) + { + // For UEFI boot options, Prefix the string with "UEFI: " + MemFreePointer( (VOID **)&(dataPtr->Name) ); + dataPtr->Name = EfiLibAllocateZeroPool( EfiStrLen( String ) + EfiStrLen(L"UEFI: ")+ 1 ); + EfiStrCpy(dataPtr->Name, L"UEFI: "); + EfiStrCat(dataPtr->Name, String); + } + } + MemFreePointer( (VOID **)&buffer ); + } +_NextVariable: + BootOption = DriverOption = FALSE; //Getting ready for next iteration + } + else if (VarNameSize == ((EfiStrLen(L"keyXXXX")+1)*2)) //Boot, Driver and Key are different length so handling in else if cases + { + if (MetaiMatch (UnicodeInterface, VarName, KeyPattern)) + { + FormHotBootKeys (VarName); + } + } + // Only one Boot options is valid in FastBoot case + if(IsFastBoot) + break; + //reset the size of this buffer to what has been allocated for it + VarNameSize = OldVarNameSize; + + }while(Status != EFI_NOT_FOUND); + +#endif //STANDALONE_APPLICATION + +//EIP-97704 Starts + //For Boot#### variable + for ( jIndex = 0; jIndex < gBootOptionCount; jIndex++ ) + { + if ( gBootData[jIndex].Option == DISABLED_BOOT_OPTION ) + { + DISABLED_BOOT_OPTION--;//Changing the value based on the available of BOOT#### variable + jIndex = -1; + continue; + } + } + //For Driver#### variable + for ( jIndex = 0; jIndex < gDriverOptionCount; jIndex++ ) + { + if ( gDriverData[jIndex].Option == DISABLED_DRIVER_OPTION ) + { + DISABLED_DRIVER_OPTION--;//Changing the value based on the available of DRIVER#### variable + jIndex = -1; + continue; + } + } +//EIP-97704 Ends + //Free unused memory + if (gBootOptionCount < AllocatedCount) + gBootData = MemReallocateZeroPool(gBootData, AllocatedCount * sizeof (BOOT_DATA), gBootOptionCount * sizeof (BOOT_DATA)); + + if (gDriverOptionCount < DriverAllocatedCount) + gDriverData = MemReallocateZeroPool(gDriverData, DriverAllocatedCount * sizeof (BOOT_DATA), gDriverOptionCount * sizeof (BOOT_DATA)); + + FreeExtraKeyMemories (); + //Set boot manager variables + if(!IsFastBoot) + { + _BootSetBootManagerVariables (); + _SetDriverManagerVariables (); + } + Status = EFI_SUCCESS; + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootLaunchBootOption +// +// Description: This function launches the boot option supplied +// +// Input: u16Option: BootOption to be launched +// pOrder: The order in which to set BBS priorities +// u16OrderCount: No of options in pOrder +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS BootLaunchBootOption(UINT16 u16Option, UINT16 *pOrder, UINTN u16OrderCount) +{ + EFI_STATUS status = EFI_NOT_FOUND; + UINT16 u16BootCurrent; + + BOOT_DATA *pBootData = NULL; + + pBootData = BootGetBootData(u16Option); + if (pBootData) + { + //Set BootCurrent + u16BootCurrent = pBootData->Option; + VarSetNvramName(L"BootCurrent", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + &(u16BootCurrent), + sizeof(u16BootCurrent)); + if( gBootFlow != BOOT_FLOW_CONDITION_FAST_BOOT) { + CsmBBSSetBootPriorities(pBootData, pOrder, u16OrderCount); + } + status = _BootLaunchDevicePath(pBootData->DevicePath, pBootData->LoadOptions, pBootData->LoadOptionSize,TRUE); + + //clear BootCurrent + VarSetNvramName(L"BootCurrent", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + &(u16BootCurrent), + 0); + } + + return status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetBootData +// +// Description: Finds and returns internal data structure BOOT_DATA +// for a given boot option number. +// +// Input: Option: Option number for which BOOT_DATA is needed +// +// Output: Returns pointer to BOOT_DATA if found. Returns NULL +// if BOOT_DATA not found. +// +//---------------------------------------------------------------------------- +// +BOOT_DATA *BootGetBootData( UINT16 Option ) +{ + UINTN i; + + for ( i = 0; i < gBootOptionCount; i++ ) + { + if ( gBootData[i].Option == Option ) + return &gBootData[i]; + } + + return NULL; +} + +//EIP70421 & 70422 Support for driver order +// +//---------------------------------------------------------------------------- +// Procedure: DriverGetDriverData +// +// Description: Finds and returns internal data structure BOOT_DATA +// for a given Driver option number. +// +// Input: Option: Option number for which BOOT_DATA is needed +// +// Output: Returns pointer to BOOT_DATA if found. Returns NULL +// if BOOT_DATA not found. +// +//---------------------------------------------------------------------------- +// +BOOT_DATA *DriverGetDriverData (UINT16 Option) +{ + UINTN i; + + for ( i = 0; i < gDriverOptionCount; i++ ) + { + if ( gDriverData[i].Option == Option ) + return &gDriverData[i]; + } + return NULL; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetOptionName +// +// Description: Provides the unicode name for the given boot option +// in the form of internal data structure BOOT_DATA. +// +// Input: bootData: BOOT_DATA struct for which unicode name is +// needed. +// +// Output: Returns unicode string corresponding to the provided +// BOOT_DATA. If the BOOT_DATA provided is for legacy +// option then the name for the first legacy option in +// that category is returned. +// +//---------------------------------------------------------------------------- +// +CHAR16 *BootGetOptionName( BOOT_DATA *bootData) +{ + if ( BBSValidDevicePath(bootData->DevicePath) ) { + return CsmBBSBootOptionName(bootData); + } + return bootData->Name; +} + +//EIP70421 & 70422 Support for driver order +// +//------------------------------------------------------------------------------------ +// Procedure: DriverGetOptionName +// +// Description: Provides the unicode name for the given driver option +// in the form of internal data structure BOOT_DATA. +// +// Input: DriverData: BOOT_DATA struct for which unicode name is +// needed. +// +// Output: Returns unicode string corresponding to the provided BOOT_DATA +// +//------------------------------------------------------------------------------------ +// +CHAR16 *DriverGetOptionName (BOOT_DATA *DriverData) +{ + return DriverData->Name; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetBootNowName +// +// Description: Provides the unicode name for the given boot option. +// +// Input: value: boot option for which unicode name is needed +// +// Output: Returns unicode string corresponding to the provided +// boot option. +// +//---------------------------------------------------------------------------- +// +CHAR16 *BootGetBootNowName( UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde) +{ + UINT16 *BootOrder=NULL; + UINTN size = 0; + UINTN i,j,k; + UINTN count; + + BOOT_DATA *bootData; + + if((!ShowAllBBSDev) && (!TseBootNowInBootOrde)) + if(gBootData == NULL) + return NULL; + else + { + if(gLoadOptionHidden && (gBootData[value].Active & LOAD_OPTION_HIDDEN)) + return NULL;//EIP 89483 : Cheking for the load option hidden presence in the Boot option + + return BootGetOptionName(&(gBootData[value])); + } + if(TseBootNowInBootOrde) + { + BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + //EIP-75352 Suppress the warnings from static code analyzer + if(NULL == BootOrder){ + ASSERT (0); + return NULL; + } + + //Find the first disabled option + for ( i = 0; i < gBootOptionCount; i++ ) + { + if ( DISABLED_BOOT_OPTION == BootOrder[i] ) + break; + } + + if(i= gBootOptionCount) + { + //gBootData[j].Option is not present in BootOrder; fill it + BootOrder[i] = gBootData[j].Option; + i++; + } + } + } + } + + if(ShowAllBBSDev) + { + count = 0; + for(i=0;iDevicePath) ) + { + if((value >= count) && (value < (count+bootData->LegacyDevCount))) + { + if(TseBootNowInBootOrde) + MemFreePointer((VOID **) &BootOrder); + if (gLoadOptionHidden && ((bootData->Active & LOAD_OPTION_HIDDEN)!= 0)) + return NULL; + + return bootData->OrderList[value-count].Name; + } + + count+=bootData->LegacyDevCount; + } + else { + if(value == count) + { + if(TseBootNowInBootOrde) + MemFreePointer((VOID **) &BootOrder); + if (gLoadOptionHidden && ((bootData->Active & LOAD_OPTION_HIDDEN)!= 0)) + return NULL; + return bootData->Name; + } + count++; + } + } + return NULL; + } + else { + bootData = BootGetBootData(BootOrder[value]); + MemFreePointer((VOID **) &BootOrder); + if (gLoadOptionHidden && ((bootData->Active & LOAD_OPTION_HIDDEN)!= 0)) + return NULL;//EIP 89483 : Cheking for the load option hidden presence in the Boot option + + return BootGetOptionName(bootData); + } + +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetLanguages +// +// Description: Finds the languages that the firmware supports. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID GetBootLanguages( VOID ) +{ + CHAR16 *langString; + CHAR8 *langCodes, *langPtr; + UINTN i, count, size = 0; + + langCodes = VarGetNvramName( L"LangCodes", &gEfiGlobalVariableGuid, NULL, &size ); + count = size /3; + + if ( size == 0 ) + { + langCodes = VarGetNvramName( L"Lang", &gEfiGlobalVariableGuid, NULL, &size ); + if ( size != 0) { + count = 1; + } + else { + gLanguages = EfiLibAllocateZeroPool( sizeof(LANGUAGE_DATA) ); + if ( gLanguages == NULL ) + return; + + gLanguages[0].LangCode = StrDup8("eng"); + gLanguages[0].Unicode = StrDup(L"eng"); + gLangCount = 1; + langString = HiiGetStringLanguage( (VOID*)(UINTN)INVALID_HANDLE, 1, gLanguages[0].Unicode ); + gLanguages[0].Token = HiiAddString( gHiiHandle, langString ); + gLanguages[0].LangString = langString; + return; + } + } + + gLanguages = EfiLibAllocateZeroPool( count * sizeof(LANGUAGE_DATA) ); + if ( gLanguages == NULL ) + return; + + for ( langPtr = langCodes, i = 0; i < count; i++, langPtr += 3 ) + { + gLanguages[i].LangCode = EfiLibAllocateZeroPool( 4 * sizeof(CHAR8)); + MemCopy( gLanguages[i].LangCode, langPtr, 3 * sizeof(CHAR8) ); + gLanguages[i].Unicode = StrDup8to16(gLanguages[i].LangCode); + } + + gLangCount = count; + + for ( langPtr = langCodes, i = 0; i < count; i++, langPtr += 3 ) + { + langString = HiiGetStringLanguage( (VOID*)(UINTN)INVALID_HANDLE, 1, gLanguages[i].Unicode ); + gLanguages[i].Token = HiiAddString( gHiiHandle, langString ); + gLanguages[i].LangString = langString; + } + + MemFreePointer( (VOID **)&langCodes ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetLanguages +// +// Description: Finds the languages that the firmware supports. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID GetPlatformBootLanguages( VOID ) +{ + CHAR16 *langString; + CHAR8 *langCodes, *langPtr; + UINTN i = 0, count=0, size = 0, pos = 0; + + langCodes = VarGetNvramName( L"PlatformLangCodes", &gEfiGlobalVariableGuid, NULL, &size ); + if(langCodes != NULL) + count = GetTokenCount(langCodes); + + if ((0 == size) || (NULL == langCodes)) + { + langCodes = VarGetNvramName( L"PlatformLang", &gEfiGlobalVariableGuid, NULL, &size ); + if ( size != 0 ) { + count=1; + } + else { + gLanguages = (LANGUAGE_DATA *)EfiLibAllocateZeroPool( sizeof(LANGUAGE_DATA) ); + if ( gLanguages == NULL ) + return; + + gLanguages[0].LangCode = StrDup8("en-US"); + gLanguages[0].Unicode = StrDup(L"en-US"); + + gLangCount = 1; + langString = HiiGetStringLanguage( (VOID*)(UINTN)INVALID_HANDLE, 1, gLanguages[0].Unicode ); + gLanguages[0].Token = HiiAddString( gHiiHandle, langString ); + gLanguages[0].LangString = langString; + return; + } + } + + gLanguages = EfiLibAllocateZeroPool( count * sizeof(LANGUAGE_DATA) ); + if ( gLanguages == NULL ) + return; + + for ( langPtr = langCodes, i = 0; i < count; i++ ) + { + gLanguages[i].LangCode = GetTokenString(langPtr, &pos); + gLanguages[i].Unicode = StrDup8to16(gLanguages[i].LangCode); + langString = HiiGetStringLanguage( INVALID_HANDLE, 1, gLanguages[i].Unicode ); + gLanguages[i].Token = HiiAddString( gHiiHandle, langString ); + gLanguages[i].LangString = langString; + + langPtr += pos + 1; + } + + gLangCount = count; + MemFreePointer( (VOID **)&langCodes ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootLaunchBootNow +// +// Description: Launches the boot option provided. +// +// Input: index: The nth option in the boot now menu. +// ShowAllBbsDev - SETUP_SHOW_ALL_BBS_DEVICES +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS BootLaunchBootNow( UINT16 index, BOOLEAN ShowAllBbsDev ) +{ + + EFI_STATUS Status = EFI_OUT_OF_RESOURCES; + BOOLEAN bLegacyBoot = FALSE; + UINT16 count = 0, BootCurrent; + UINT16 *BootOrder; + UINTN i = 0; + + BOOT_DATA *bootData=NULL; + + ProcessProceedToBootNowHook(); + + BootOrder = BootNowinBootOrderInit(); + + if(ShowAllBbsDev) + { + for(i=0;iDevicePath) ) + { + if((index >= count) && (index < (count+bootData->LegacyDevCount))) + { + bLegacyBoot = TRUE; + break; + } + else + count=count+(UINT16)(bootData->LegacyDevCount); + } + else + { + if(index == count) + break; + count++; + } + } + } + else + { + if(0 == gBootOptionCount)//EIP 71223: If there is no valid boot option present, returning EFI_NOT_FOUND. + return EFI_NOT_FOUND; + bootData = BootGetBootNowBootData(gBootData,BootOrder,index); + } + + if(BootOrder!=NULL) + MemFreePointer((VOID **) &BootOrder); + + //EIP-75352 Suppress the warnings from static code analyzer + if(NULL == bootData){ + return EFI_NOT_FOUND; + } + + if(ShowAllBbsDev) + { + if(i == gBootOptionCount) + return Status; + + //Boot bootData and device index-count + //set bbs priorities + if(bLegacyBoot) + { + Status = CsmBBSSetBootNowPriority(bootData,index-count,ShowAllBbsDev); + if(EFI_ERROR( Status )) //EIP-93797 + return EFI_UNSUPPORTED; + } + } + + //Set BootCurrent + BootCurrent = bootData->Option; + VarSetNvramName(L"BootCurrent", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + &(BootCurrent), + sizeof(BootCurrent)); + if(!ShowAllBbsDev) + { + if(BBSValidDevicePath(bootData->DevicePath)) + { + Status = CsmBBSSetBootNowPriority(bootData,0,ShowAllBbsDev); + if(EFI_ERROR( Status )) //EIP-93797 + return EFI_UNSUPPORTED; + } + } + Status = _BootLaunchDevicePath( bootData->DevicePath, bootData->LoadOptions, bootData->LoadOptionSize,TRUE ); + //clear BootCurrent + VarSetNvramName(L"BootCurrent", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + &(BootCurrent), + 0); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootLaunchGuid +// +// Description: Launches the guided file from FV. +// +// Input: guid: Guid of the file to be launched. +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS BootLaunchGuid( EFI_GUID *guid ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + UINT32 index = 0; + + EFI_DEVICE_PATH_PROTOCOL *devicePath; + + do + { + devicePath = _BootBuildFVDevicePath( &index, guid ); + if ( index != (UINT32)-1 ) + Status = _BootLaunchDevicePath( devicePath, NULL, 0,FALSE ); + + MemFreePointer( (VOID **)&devicePath ); + } + while ( ( EFI_ERROR( Status ) ) && ( index != (UINT32)-1 ) ); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootLaunchFilename +// +// Description: Launches the file mentioned in file path from the +// available FS. +// +// Input: fileName: Path of the file to be launched. +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS BootLaunchFilename( CHAR16 *fileName ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + UINT32 index = 0; + + EFI_DEVICE_PATH_PROTOCOL *devicePath; + + do + { + devicePath = _BootBuildFileDevicePath( &index, fileName ); + if ( index != (UINT32)-1 ) + Status = _BootLaunchDevicePath( devicePath, NULL, 0,FALSE ); + + MemFreePointer( (VOID **)&devicePath ); + } + while ( ( EFI_ERROR( Status ) ) && ( index != (UINT32)-1 ) ); + + return Status; +} + +// +//------------------------------------------------------------------------------- +// Procedure: FixHiddenOptions +// +// Description: Function to move the hidden option at last of the boot order +// +// Input: UINT16 ** => Boot order to be reformed +// +// Output: VOID +// +//-------------------------------------------------------------------------------- +// +VOID FixHiddenOptions (BOOLEAN Option, UINT16 **Order, UINTN OptionCount) +{ + UINTN iIndex = 0; + UINTN jIndex = 0; + UINT16 TempBootOption = 0; + BOOT_DATA *pBootData; + + if (0 == OptionCount) + { + return; + } + for (iIndex = 0; iIndex < OptionCount-1; iIndex ++) + { + if (BOOT_ORDER_OPTION == Option) + { + pBootData = BootGetBootData ((*Order) [iIndex]); + } + else + { + pBootData = DriverGetDriverData ((*Order) [iIndex]); + } + if (pBootData) + { + if (pBootData->Active & LOAD_OPTION_HIDDEN) + { + for (jIndex = iIndex+1; jIndex < OptionCount; jIndex ++) + { + if (BOOT_ORDER_OPTION == Option) + { + pBootData = BootGetBootData ((*Order) [jIndex]); + } + else + { + pBootData = DriverGetDriverData ((*Order) [jIndex]); + } + if (!(pBootData->Active & LOAD_OPTION_HIDDEN)) + { + TempBootOption = (*Order) [iIndex]; + (*Order) [iIndex] = (*Order) [jIndex]; + (*Order) [jIndex] = TempBootOption; + break; + } + } + } + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BootSetBootManagerVariables +// +// Description: function to set the variables for the boot manager +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID _BootSetBootManagerVariables(VOID) +{ + UINT16 *NewBootOrder, *BootOrder, count; + UINTN size=0, i=0, j=0, k=0, BootOrderCount; + + EFI_GUID BootManGuid = BOOT_MANAGER_GUID; + BOOT_DATA *pBootData; + + //Correct BootOrder variable if necessary + NewBootOrder = NULL; + if(gBootOptionCount) + NewBootOrder = (UINT16 *)EfiLibAllocateZeroPool(gBootOptionCount * sizeof(UINT16)); + + BootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + BootOrderCount = size/sizeof(UINT16); + + //Get all the enabled boot options in the boot order + for(i = 0; i < BootOrderCount; i++) + { + pBootData = BootGetBootData(BootOrder[i]); + if(pBootData) + { + if(IsPreservedDisabledBootOptionOrder()) + { //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option + /*if(gLoadOptionHidden && (pBootData->Active & LOAD_OPTION_HIDDEN)) + { + j++; + continue; + }*/ + NewBootOrder[j] = BootOrder[i]; + j++; + } + else if(pBootData->Active & LOAD_OPTION_ACTIVE) + { //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option + /*if(gLoadOptionHidden && (pBootData->Active & LOAD_OPTION_HIDDEN)) + { + j++; + continue; + }*/ + NewBootOrder[j] = BootOrder[i]; + j++; + } + } + } + + //Append all options that are enabled but not included in + //BootOrder. FCFS used. + for(i=0; i < gBootOptionCount; i++) + { + if(gBootData[i].Active & LOAD_OPTION_ACTIVE) + { + //Check presence in boot order + for(k=0;k= BootOrderCount) + { + //Not present in boot order! Add option + NewBootOrder[j] = gBootData[i].Option; + j++; + } + } + } + + //Free Boot order + MemFreePointer((VOID **)&BootOrder); + + if(!IsPreservedDisabledBootOptionOrder()) + { + //Put disabled options at the end of NewBootOrder + for(i=0; i < gBootOptionCount; i++) + { + if(!(gBootData[i].Active & LOAD_OPTION_ACTIVE)) + { //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option +/* if(gLoadOptionHidden && (gBootData[i].Active & LOAD_OPTION_HIDDEN)) + { + j++; + continue; + }*/ + NewBootOrder[j] = gBootData[i].Option; + j++; + } + } + ASSERT(j==gBootOptionCount); + } + + //Set BootOrder Variable with corrected order + if (gLoadOptionHidden) + { + FixHiddenOptions (BOOT_ORDER_OPTION, &NewBootOrder, gBootOptionCount); + } + VarSetNvramName(L"BootOrder", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + NewBootOrder, + gBootOptionCount * sizeof(UINT16)); + + //Free NewBootOrder + MemFreePointer((VOID **)&NewBootOrder); + + //Get BBS devices + CsmBBSGetDeviceList(); + + // Update the BootOrder,BBSOrder Cache From the NVRAM. + UpdateBootVariables(); + + //Set Boot manager variable + count = (UINT16)gBootOptionCount; + VarSetNvramName( L"BootManager", &BootManGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) ); + + //Set Boot now count + if(gShowAllBbsDev) + count = _BootSetBootNowCount(); + + VarSetNvramName( L"BootNowCount", &gBootNowCountGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) ); + UpdateAddDeleteBootVar (); +} + +//EIP70421 & 70422 Support for driver order Starts +// +//-------------------------------------------------------------------------------------- +// Procedure: _SetDriverManagerVariables +// +// Description: Sets DriverManager variable for drivers count and sets DriverOrder +// +// Input: void +// +// Output: void +// +//-------------------------------------------------------------------------------------- +// +VOID _SetDriverManagerVariables (VOID) +{ + UINT16 *DriverOrder = NULL; + UINT16 *NewDriverOrder = NULL; + UINT16 DriverOrderCount = 0; + UINTN DriverOrderSize = 0; + UINTN iIndex = 0; + UINTN jIndex = 0; + UINT16 Count = 0; + BOOT_DATA *pDrvData; //BOOT_DATA using same structure for driver options too + EFI_GUID DrvMgrGuid = DRIVER_MANAGER_GUID; + + if (gDriverOptionCount) + { + NewDriverOrder = (UINT16 *)EfiLibAllocateZeroPool (gDriverOptionCount * sizeof(UINT16)); + if (NULL == NewDriverOrder) + { + return; + } + } + DriverOrder = (UINT16 *)VarGetNvramName (L"DriverOrder", &gEfiGlobalVariableGuid, NULL, &DriverOrderSize); + DriverOrderCount = (UINT16)(DriverOrderSize/sizeof(UINT16)); + if ((NULL == DriverOrder) || (0 == DriverOrderSize)) + { + for (iIndex = 0; iIndex < gDriverOptionCount; iIndex++) //Forming DriverOrder variable freshly + { + if (gDriverData [iIndex].Active & LOAD_OPTION_ACTIVE) + { + NewDriverOrder [Count] = gDriverData [iIndex].Option; + Count ++; + } + } + goto _FormDisableDevices; + } + else //Forming DriverOrder variable with first active and non hidden drivers + { + for (iIndex = 0; iIndex < DriverOrderCount; iIndex ++) + { + pDrvData = DriverGetDriverData (DriverOrder [iIndex]); + if (pDrvData) + { + if ( (pDrvData->Active & LOAD_OPTION_ACTIVE) ) + { //Checking for active drivers + NewDriverOrder [Count] = DriverOrder [iIndex]; + Count ++; + } + } + } + } + //Append all options that are enabled but not included in + //DriverOrder. Having same logic as of boot order. + for(iIndex = 0; iIndex < gDriverOptionCount; iIndex ++) + { + if ( (gDriverData [iIndex].Active & LOAD_OPTION_ACTIVE) ) + { + //Check presence in DriverOrder + for (jIndex = 0; jIndex < DriverOrderCount; jIndex ++) + { + if (DriverOrder [jIndex] == gDriverData [iIndex].Option) + break; + } + if (jIndex >= DriverOrderCount) + { + //Not present in Driver order! Add option + NewDriverOrder [Count] = gBootData[iIndex].Option; + Count ++; + } + } + } +_FormDisableDevices: //Forming disabled drivers last in the newly formed DriverOrder variable. + for (iIndex = 0; iIndex < gDriverOptionCount; iIndex ++) + { + if (!(gDriverData [iIndex].Active & LOAD_OPTION_ACTIVE)) + { + NewDriverOrder [Count] = gDriverData [iIndex].Option; + Count ++; + } + } + if (gLoadOptionHidden) + { + FixHiddenOptions (DRIVER_ORDER_OPTION, &NewDriverOrder, gDriverOptionCount); + } + VarSetNvramName ( + L"DriverOrder", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + NewDriverOrder, + gDriverOptionCount * sizeof(UINT16) + ); + //Set Driver manager variable + Count = (UINT16)gDriverOptionCount; + VarSetNvramName (L"DriverManager", &DrvMgrGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &Count, sizeof(Count)); + UpdateDriverVariables (); + if (DriverOrder) + { + MemFreePointer ((VOID **)&DriverOrder); + } + if (DriverOrder) + { + MemFreePointer ((VOID **)&NewDriverOrder); + } + UpdateAddDeleteDriverVar (); +} +//EIP70421 & 70422 Support for driver order Ends + +// +//---------------------------------------------------------------------------- +// Procedure: _BootSetBootNowCount +// +// Description: function to set boot new devices count +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +UINT16 _BootSetBootNowCount(VOID) +{ + UINT16 count = 0; + UINTN i; + + BOOT_DATA *bootData; + + for( i=0; iDevicePath)) + { + count = count + bootData->LegacyDevCount; + } + else + count++; + } + + return count; +} + +//EIP 77400 Starts +// +//---------------------------------------------------------------------------- +// Procedure: _ShellClearScreen +// +// Description: Clears the screen for shell boot +// +// Input: EFI_EVENT , VOID * +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +void ClearGrphxScreen (void); +VOID _ShellClearScreen (EFI_EVENT Event, VOID *Context) +{ + UINT32 shelltextmodetype; + InvalidateStatusInBgrtWrapper(); //EIP93524 : When booting to shell clearing the BGRT status bit. + ClearGrphxScreen (); + gST->ConOut->ClearScreen (gST->ConOut); + gBS->CloseEvent (Event); + gST->ConOut->EnableCursor (gST->ConOut, TRUE); + if (Event != gShellLaunchEvent) //One event will be closed in incoming fnc argument other we have to close it + { + gBS->CloseEvent (gShellLaunchEvent); + } + if (Event != gShell20LaunchEvent) //EIP158989 For shell2.0 + { + gBS->CloseEvent (gShell20LaunchEvent); + } + gShellLaunchEvent = NULL; //Make NULL otherwise we will try to close it after startimage + gShell20LaunchEvent = NULL; + + shelltextmodetype = ShellTextMode();//EIP 94205 : OEM needs Token to assign the display mode of SHELL. + + if ( 0xFF != shelltextmodetype ) + gST->ConOut->SetMode( gST->ConOut, shelltextmodetype ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _RegisterShellGuid +// +// Description: Registers the shell guid +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID _RegisterShellGuid (VOID) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + VOID *Registration = NULL; + EFI_GUID EfiShellInterfaceGuid = EFI_SHELL_PROTOCOL_GUID; + EFI_GUID EfiShell20InterfaceGuid = EFI_SHELL2_0_FILE_GUID; + + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + EFI_TPL_CALLBACK, + _ShellClearScreen, + NULL, + &gShellLaunchEvent); + if (!EFI_ERROR (Status)) + { + Status = gBS->RegisterProtocolNotify( + &EfiShellInterfaceGuid, + gShellLaunchEvent, + &Registration + ); + } + Status = gBS->CreateEvent ( + EFI_EVENT_NOTIFY_SIGNAL, + EFI_TPL_CALLBACK, + _ShellClearScreen, + NULL, + &gShell20LaunchEvent); + if (!EFI_ERROR (Status)) + { + Status = gBS->RegisterProtocolNotify( + &EfiShell20InterfaceGuid, + gShell20LaunchEvent, + &Registration + ); + } +} +//EIP 77400 Ends + +// +//---------------------------------------------------------------------------- +// Procedure: _BootLaunchDevicePath +// +// Description: function to launch the boot operation +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Options, UINTN OptionSize, BOOLEAN ValidBootOption +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS _BootLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Options, UINTN OptionSize, BOOLEAN ValidBootOption ) +{ + EFI_STATUS Status; + EFI_HANDLE handle; + BOOLEAN FreeDevicePath = FALSE; + EFI_EVENT ReadyToBootEvent; + EFI_GUID Bootguid = AMITSE_EVENT_BEFORE_BOOT_GUID; + EFI_GUID AfterBootGuid = AMITSE_EVENT_AFTER_BOOT_GUID; //EIP-162197 + + EFI_TPL CurrentTpl; + TSE_POST_STATUS BackupPostStatus; +#ifndef STANDALONE_APPLICATION + EFI_CONSOLE_CONTROL_SCREEN_MODE ScreenMode = EfiConsoleControlScreenText; +#endif //STANDALONE_APPLICATION + + BackupPostStatus = gPostStatus; // Back it up and of boot fail restore it back + gPostStatus = TSE_POST_STATUS_PROCEED_TO_BOOT; + +#if defined(EFI_EVENT_SIGNAL_READY_TO_BOOT) && EFI_SPECIFICATION_VERSION<0x20000 + Status = gBS->CreateEvent( + EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL, + EFI_TPL_CALLBACK, + NULL, + NULL, + &ReadyToBootEvent + ); +#else + Status = TseEfiCreateEventReadyToBoot( + EFI_TPL_CALLBACK, + NULL, + NULL, + &ReadyToBootEvent + ); +#endif //EFI_EVENT_SIGNAL_READY_TO_BOOT + + if (EFI_ERROR(Status)) + return Status; + + gBS->SignalEvent( ReadyToBootEvent ); + gBS->CloseEvent( ReadyToBootEvent ); + EfiLibReportStatusCode(EFI_PROGRESS_CODE, DXE_READY_TO_BOOT,0,NULL,NULL); + + TSEIDEPasswordFreezeDevices(); + + if( gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT) + { + // Call the Hook and do the FastBoot + if ( BBSValidDevicePath( DevicePath ) ) + { + BeforeLegacyBootLaunchHook(); + UninstallBgrtWrapper(); //EIP81830 Support to uninstall the BGRT on legacy boot + } + else + { + BeforeEfiBootLaunchHook(); //Clearing the logo for shell in fast boot also EIP102710 + if (NULL != gShellLaunchEvent) + { + gBS->CloseEvent (gShellLaunchEvent); + gShellLaunchEvent = NULL; + } + if (NULL != gShell20LaunchEvent) //EIP158989 + { + gBS->CloseEvent (gShell20LaunchEvent); + gShell20LaunchEvent = NULL; + } + //EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification + //EIP136592, 141863, 123535 + if ( ( NULL != gGOP ) && (CurrentScreenresolutionX && CurrentScreenresolutionY) && //If it has valid gGOP and resolution + ((CurrentScreenresolutionX != gGOP->Mode->Info->HorizontalResolution) || (CurrentScreenresolutionY != gGOP->Mode->Info->VerticalResolution)) //If current and quietboot resolution is different + )//EIP-88430 + { + GOPSetScreenResolution(&CurrentScreenresolutionX, &CurrentScreenresolutionY); + //gGOP->SetMode (gGOP, CurrentResolutionIndex); // To maintain graphics resolution + } + EfiLibNamedEventSignal (&Bootguid);//EIP-112796 Signal AMITSE_EVENT_BEFORE_BOOT_GUID for EfiBoot during Fastboot + _RegisterShellGuid (); + } + // Performance measurement Pause + PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0); + Status = FastBootLaunch(); + + EfiLibNamedEventSignal (&AfterBootGuid); + return Status; + } +#if APTIO_4_00 //EIP94702 Useful for secure boot violation message box + gMaxRows = MAX_ROWS; + gMaxCols = MAX_COLS; +#endif + if ( BBSValidDevicePath( DevicePath ) ) //EIP58954 Changing the mode only for csm + { +#ifndef STANDALONE_APPLICATION + // Fast Boot May want to boot without Console Control + if (gConsoleControl != NULL) + { + gConsoleControl->GetMode (gConsoleControl, &ScreenMode, NULL, NULL); + if (ScreenMode != EfiConsoleControlScreenText) + { + gConsoleControl->SetMode (gConsoleControl, EfiConsoleControlScreenText); + InvalidateStatusInBgrtWrapper (); //Since mode changed invalidating status field in BGRT table. EIP 58954 + } + } +#endif //STANDALONE_APPLICATION + BeforeLegacyBootLaunchHook(); + UninstallBgrtWrapper(); //EIP81830 Support to uninstall the BGRT on legacy boot + Status = CsmBBSLaunchDevicePath( DevicePath ); + if (EFI_ERROR (Status)) + LegacyBootFailHook(Status);//EIP 89377 : Support to LegacyBootFailHook() in TSE. + AfterLegacyBootLaunchHook(); + gPostStatus = BackupPostStatus; + + EfiLibNamedEventSignal (&AfterBootGuid); + return Status; + } + + CurrentTpl = gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); + gBS->RestoreTPL( EFI_TPL_APPLICATION ); + if (DevicePath->Type==MEDIA_DEVICE_PATH && DevicePath->SubType==MEDIA_HARDDRIVE_DP) + { + DevicePath = _DiscoverPartition(DevicePath); + FreeDevicePath = TRUE; + } + Status = gBS->LoadImage (TRUE, gImageHandle, DevicePath, NULL, 0, &handle); + if (EFI_ERROR (Status)) + { + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath = DevicePath; + EFI_STATUS RepairStatus = FALSE; + UefiBootFailHook (Status); + RepairStatus = CheckForDeviceNeedRepair (TempDevicePath); //EIP 57661 support for UEFI specification v 2.3.1, p. 10.10.1 Driver health protocol + if (!(EFI_ERROR (RepairStatus))) + { + Status = gBS->LoadImage (TRUE, gImageHandle, DevicePath, NULL, 0, &handle); + if (EFI_ERROR (Status)) + { + UefiBootFailHook (Status); + } + } + } + if (EFI_ERROR (Status)) + { + //Try default behaviour + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath = NULL; + EFI_HANDLE DevHandle; + EFI_HANDLE UsbDevHandle = NULL; + EFI_BLOCK_IO_PROTOCOL *BlkIo = NULL; + VOID *Buffer = NULL; + EFI_DEVICE_PATH_PROTOCOL *FilePath = NULL; + + // Find a Simple File System protocol on the device path. + TempDevicePath = DevicePath; + + UsbDevHandle = CheckDevSupShortFormPath (DevicePath); ////EIP 64295 Support for section 3.1.2. booting from a short-form device path + if (NULL != UsbDevHandle) + { + DevHandle = UsbDevHandle; + } + else + { + Status = gBS->LocateDevicePath ( + &gEfiSimpleFileSystemProtocolGuid, + &TempDevicePath, + &DevHandle + ); + } + if ((!EFI_ERROR (Status) && IsDevicePathEnd (TempDevicePath)) || (NULL != UsbDevHandle)) + { + // Files are specified in the device path so try to + // load the default removable media file name. + + FilePath = EfiFileDevicePath (DevHandle, gBootFileName); + + if (FilePath) + { + // Issue a dummy read to the device to check for media + // change. When the removable media is changed, any Block + // IO read/write will cause the BlockIo protocol be + // reinstalled and EFI_MEDIA_CHANGED is returned. After + // the Block IO protocol is reinstalled, subsequent Block + // IO read/write will success. + Status = gBS->HandleProtocol ( + DevHandle, + &gEfiBlockIoProtocolGuid, + (VOID **) &BlkIo + ); + if (!EFI_ERROR (Status)) + { + Buffer = EfiLibAllocatePool (BlkIo->Media->BlockSize); + if (Buffer != NULL) + { + BlkIo->ReadBlocks ( + BlkIo, + BlkIo->Media->MediaId, + 0, + BlkIo->Media->BlockSize, + Buffer + ); + MemFreePointer((VOID **)&Buffer); + } + } + + Status = gBS->LoadImage ( + TRUE, + gImageHandle, + FilePath, + NULL, + 0, + &handle + ); + if (EFI_ERROR (Status)) + { + UefiBootFailHook (Status); + } + MemFreePointer((VOID **) &FilePath); + } + else + { + Status = EFI_NOT_FOUND; + } + } + else + { + Status = EFI_NOT_FOUND; + } + } + + + if(ValidBootOption==TRUE) + if (EFI_ERROR (Status)) // Report only if it Boot Option launch - Boot of loading Error!!! + EfiLibReportStatusCode(EFI_ERROR_CODE| EFI_ERROR_MAJOR, DXE_BOOT_OPTION_LOAD_ERROR,0,NULL,NULL); + + if (FreeDevicePath) gBS->FreePool(DevicePath); + + if ( ! EFI_ERROR( Status ) ) + { + if (gST->ConOut != NULL) + { + gST->ConOut->EnableCursor (gST->ConOut, FALSE); //Disabling bcoz Cursor appears on the WIN8 boot + } + _BootInstallLoadOptions( handle, Options, OptionSize ); + + BeforeEfiBootLaunchHook(); + + // Performance measurement Pause + PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0); + + //EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification + //EIP136592, 141863 + if ( ( NULL != gGOP ) && (CurrentScreenresolutionX && CurrentScreenresolutionY) && //If it has valid gGOP and resolution + ((CurrentScreenresolutionX != gGOP->Mode->Info->HorizontalResolution) || (CurrentScreenresolutionY != gGOP->Mode->Info->VerticalResolution)) //If current and quietboot resolution is different + )//EIP-88430 + { + GOPSetScreenResolution(&CurrentScreenresolutionX, &CurrentScreenresolutionY); + //gGOP->SetMode (gGOP, CurrentResolutionIndex); // To maintain graphics resolution + } + + // Signal AMITSE_EVENT_BEFORE_BOOT_GUID Event; + EfiLibNamedEventSignal (&Bootguid); + _RegisterShellGuid (); //EIP 77400 clearing the screen if its shell boot + + Status = gBS->StartImage( handle, NULL, NULL ); + if (NULL != gShellLaunchEvent) //EIP 77400 Close the event if it is not the shell boot + { + gBS->CloseEvent (gShellLaunchEvent); + gShellLaunchEvent = NULL; + } + if (NULL != gShell20LaunchEvent) //EIP158989 + { + gBS->CloseEvent (gShell20LaunchEvent); + gShell20LaunchEvent = NULL; + } + // Performance measurement continue + PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0); + + AfterEfiBootLaunchHook(); + EfiLibNamedEventSignal (&AfterBootGuid); +/*#if APTIO_4_00 + gMaxRows = MAX_ROWS; + gMaxCols = MAX_COLS; +#endif //APTIO_4_00 + + SetDesiredTextMode(); //EIP94702 - StyleInit will set the desired text mode*/ + ClearGrphxScreen (); + if(EFI_ERROR( Status )) + { + // Report only if it is Boot Option launch - Starting the Boot option failed.!!!! + if(ValidBootOption==TRUE) + EfiLibReportStatusCode(EFI_ERROR_CODE| EFI_ERROR_MAJOR, DXE_BOOT_OPTION_FAILED,0,NULL,NULL); + + //Clear the flush buffer so that flush lines will actually + //draw the complete screen again + MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0); + + if (gST->ConOut != NULL) + { + //Disable cursor, set desired attributes and clear screen + gST->ConOut->EnableCursor( gST->ConOut, FALSE ); + gST->ConOut->SetAttribute( gST->ConOut, EFI_BACKGROUND_BLACK | EFI_WHITE); + gST->ConOut->ClearScreen( gST->ConOut); + } + + //Call flush lines to draw the whole screen again + FlushLines( 0, gMaxRows - 1 ); +// DoRealFlushLines(); //EIP94702 + } + else + { + InvalidateStatusInBgrtWrapper (); //EIP93524 When win8 launched after successfull boot then BGRT table should be invalidated + } + } + gPostStatus = BackupPostStatus; /// restore the pre. Post status. + + if ( CurrentTpl > EFI_TPL_APPLICATION ) + gBS->RaiseTPL( CurrentTpl ); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _DiscoverPartition +// +// Description: function to launch the boot operation +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +EFI_DEVICE_PATH_PROTOCOL* _DiscoverPartition(EFI_DEVICE_PATH_PROTOCOL *DevicePath) +{ + EFI_STATUS Status; + EFI_HANDLE *Handle; + UINTN Count, i; + + EFI_DEVICE_PATH_PROTOCOL *FullDevicePath=NULL; + HARDDRIVE_DEVICE_PATH* BootParitionDevicePath = (HARDDRIVE_DEVICE_PATH*)DevicePath; + + //get list of available Block I/O devices + Status = gBS->LocateHandleBuffer(ByProtocol,&gEfiBlockIoProtocolGuid,NULL,&Count,&Handle); + if (EFI_ERROR(Status)) return NULL; + + for( i=0; iHandleProtocol(Handle[i],&gEfiBlockIoProtocolGuid,&BlockIo); + if (EFI_ERROR(Status)) + continue; + + // if this is not partition, continue + if (!BlockIo->Media->LogicalPartition) + continue; + + Status = gBS->HandleProtocol(Handle[i],&gEfiDevicePathProtocolGuid,&PartitionDevicePath); + if (EFI_ERROR(Status)) + continue; + + // Get last node of the device path. It should be partition node + PartitionNode = (HARDDRIVE_DEVICE_PATH*)PartitionDevicePath; + + for( TmpDevicePath = PartitionDevicePath; + !IsDevicePathEndType(TmpDevicePath); + TmpDevicePath=NextDevicePathNode(TmpDevicePath) ) + { + PartitionNode = (HARDDRIVE_DEVICE_PATH*)TmpDevicePath; + } + + //Check if our partition matches Boot partition + if (PartitionNode->Header.Type!=MEDIA_DEVICE_PATH || PartitionNode->Header.SubType!=MEDIA_HARDDRIVE_DP) + continue; + + if ( PartitionNode->PartitionNumber==BootParitionDevicePath->PartitionNumber && + PartitionNode->SignatureType==BootParitionDevicePath->SignatureType && + !MemCmp(PartitionNode->Signature,BootParitionDevicePath->Signature,16) ) + { + //Match found + FullDevicePath = EfiAppendDevicePath(PartitionDevicePath,NextDevicePathNode(DevicePath)); + break; + } + } + + gBS->FreePool(Handle); + return FullDevicePath; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BootInstallLoadOptions +// +// Description: function to install the load options +// +// Input: EFI_HANDLE handle, VOID *Options, UINTN OptionSize +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID _BootInstallLoadOptions( EFI_HANDLE handle, VOID *Options, UINTN OptionSize ) +{ + EFI_STATUS Status; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + + Status = gBS->HandleProtocol( handle, &gEfiLoadedImageProtocolGuid, &LoadedImage ); + if ( EFI_ERROR( Status ) ) + return; + + LoadedImage->LoadOptions = Options; + LoadedImage->LoadOptionsSize = (UINT32)OptionSize; + + gCurrentBootHandle = handle; //EIP70096 Exposing the Handle of the image that's being launched for boot, This will help other elinks to do the processing. + +} + +#if EFI_SPECIFICATION_VERSION<0x20000 +static MEDIA_FW_VOL_FILEPATH_DEVICE_PATH gFvFile = +{ + { MEDIA_DEVICE_PATH, MEDIA_FV_FILEPATH_DP, { sizeof(MEDIA_FW_VOL_FILEPATH_DEVICE_PATH), 0 } }, + MINI_SETUP_DATA_GUID +}; +#endif //EFI_SPECIFICATION_VERSION + +static EFI_DEVICE_PATH_PROTOCOL gEndDevicePath = +{ + END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof(EFI_DEVICE_PATH_PROTOCOL), 0 } +}; + +// +//---------------------------------------------------------------------------- +// Procedure: _BootBuildFVDevicePath +// +// Description: function to build firmware volume device path protocol. +// +// Input: UINT32 *index, EFI_GUID *guidPtr +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +EFI_DEVICE_PATH_PROTOCOL *_BootBuildFVDevicePath( UINT32 *index, EFI_GUID *guidPtr ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN Count; + UINT32 i; + EFI_GUID tempEfiFirmwareVolumeProtocolGuid; + + EFI_DEVICE_PATH_PROTOCOL *DevicePath, *FilePath = NULL; +#if EFI_SPECIFICATION_VERSION>=0x20000 + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH gFvFile; +#endif //EFI_SPECIFICATION_VERSION + + if ( PISpecVersion() < 0x00010000 )//EIP-103540 + tempEfiFirmwareVolumeProtocolGuid = gEfiFirmwareVolumeProtocolGuid; + else + tempEfiFirmwareVolumeProtocolGuid = gEfiFirmwareVolume2ProtocolGuid; + + Status = gBS->LocateHandleBuffer( + ByProtocol, + &tempEfiFirmwareVolumeProtocolGuid, + NULL, + &Count, + &HandleBuffer + ); + + if ( EFI_ERROR( Status ) ) + { + *index = (UINT32)-1; + return FilePath; + } + +#if EFI_SPECIFICATION_VERSION<0x20000 + MemCopy( (UINT8 *)&gFvFile + sizeof(EFI_DEVICE_PATH_PROTOCOL), guidPtr, sizeof(EFI_GUID) ); +#endif //EFI_SPECIFICATION_VERSION + + for ( i = *index; i < (UINT32)Count; i++ ) + { + Status = gBS->HandleProtocol( HandleBuffer[i], &gEfiDevicePathProtocolGuid, &DevicePath ); + if ( EFI_ERROR( Status ) ) + continue; + +#if EFI_SPECIFICATION_VERSION>=0x20000 + EfiInitializeFwVolDevicepathNode (&gFvFile, guidPtr); +#endif //EFI_SPECIFICATION_VERSION + + FilePath = EfiAppendDevicePathNode( DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gFvFile ); + if ( FilePath != NULL ) + { + *index = i + 1; + break; + } + } + + if ( i == (UINT32)Count ) + *index = (UINT32)-1; + + MemFreePointer( (VOID **)&HandleBuffer ); + + return FilePath; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BootBuildFileDevicePath +// +// Description: function to build File device path protocol. +// +// Input: UINT32 *index, CHAR16 *fileName +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +EFI_DEVICE_PATH_PROTOCOL *_BootBuildFileDevicePath( UINT32 *index, CHAR16 *fileName ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN Count; + UINT32 i; + + EFI_DEVICE_PATH_PROTOCOL *FilePath = NULL; + + Status = gBS->LocateHandleBuffer( + ByProtocol, + &gEfiSimpleFileSystemProtocolGuid, + NULL, + &Count, + &HandleBuffer + ); + + if ( EFI_ERROR( Status ) ) + { + *index = (UINT32)-1; + return FilePath; + } + + for ( i = *index; i < (UINT32)Count; i++ ) + { + FilePath = EfiFileDevicePath( HandleBuffer[i], fileName ); + if ( FilePath != NULL ) + { + *index = i + 1; + break; + } + } + + if ( i == (UINT32)Count ) + *index = (UINT32)-1; + + MemFreePointer( (VOID **)&HandleBuffer ); + return FilePath; +} + +//EIP: 51671 START +// +//---------------------------------------------------------------------------- +// Procedure: IsBootDeviceEnabled +// +// Description: Function to check the boot option status +// +// Input: UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup +// +// Output: +// +//---------------------------------------------------------------------------- +// +BOOLEAN IsBootDeviceEnabled( UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup) +{ + + UINT16 *BootOrder=NULL; + UINTN size = 0; + UINTN i,j,k; + UINT16 count; + + BOOT_DATA *bootData; + + if((!ShowAllBBSDev) && (!TseBootNowInBootOrde)) + if(gBootData == NULL) + return FALSE; + else + { + bootData = &gBootData[value]; + if(BBSValidDevicePath(bootData->DevicePath) ) + return BootGetBBSOptionStatus(bootData, 0, FromSetup,ShowAllBBSDev); + else + return BootGetOptionStatus(bootData, FromSetup);//EIP: 51671 Getting the Boot option status when TSE_BOOT_NOW_IN_BOOT_ORDER and SETUP_SHOW_ALL_BBS_DEVICES is OFF. + } + if(TseBootNowInBootOrde) + { + BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + if (NULL == BootOrder) //Check for boot order else the system will hang + { + return TRUE; + } + //Find the first disabled option + for ( i = 0; i < gBootOptionCount; i++ ) + { + if ( DISABLED_BOOT_OPTION == BootOrder[i] ) + break; + } + + if(i= gBootOptionCount) + { + //gBootData[j].Option is not present in BootOrder; fill it + BootOrder[i] = gBootData[j].Option; + i++; + } + } + } + } + + if(ShowAllBBSDev) + { + count = 0; + for(i=0;iDevicePath) ) + { + if((value >= count) && (value < (count+bootData->LegacyDevCount))) + { + if(TseBootNowInBootOrde) + MemFreePointer((VOID **) &BootOrder); + return BootGetBBSOptionStatus(bootData, value-count, FromSetup, ShowAllBBSDev);//EIP: 51671 Getting the Legacy Boot option status when SETUP_SHOW_ALL_BBS_DEVICES is ON. + } + + count+=bootData->LegacyDevCount; + } + else { + if(value == count) + { + if(TseBootNowInBootOrde) + MemFreePointer((VOID **) &BootOrder); + return BootGetOptionStatus(bootData, FromSetup);//EIP: 51671 Getting the Boot option status when SETUP_SHOW_ALL_BBS_DEVICES is ON. + } + count++; + } + } + return FALSE; + } + else { + bootData = BootGetBootData(BootOrder[value]); + MemFreePointer((VOID **) &BootOrder); + if(BBSValidDevicePath(bootData->DevicePath) ) + return BootGetBBSOptionStatus(bootData, 0, FromSetup,ShowAllBBSDev); + else + return BootGetOptionStatus(bootData, FromSetup); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetOptionStatus +// +// Description: Function to check the boot option status in Boot Order +// +// Input: BOOT_DATA *bootData, BOOLEAN FromSetup +// +// Output: +// +//---------------------------------------------------------------------------- +// +BOOLEAN BootGetOptionStatus(BOOT_DATA *bootData, BOOLEAN FromSetup) +{ + UINTN size = 0; + UINTN i=0; + UINT16 *buffer = NULL; + + if(0 == FromSetup) + { + if(bootData->Active & LOAD_OPTION_ACTIVE) + return FALSE; + else + return TRUE; + + } + + buffer = EfiLibAllocateZeroPool( gBootOptionCount * sizeof(UINT16)); + buffer = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + if (NULL == buffer) + { + return TRUE; + } + + for(i=0 ; iOption) + break; + } + if(i == gBootOptionCount ) + { + MemFreePointer((VOID **) &buffer); + return TRUE; + } + else + { + MemFreePointer((VOID **) &buffer); + return FALSE; + } + +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetBBSOptionStatus +// +// Description: Function to check the Legacy boot option status +// +// Input: BOOT_DATA *bootData, BOOLEAN FromSetup, BOOLEAN ShowAllBBSDev +// +// Output: +// +//---------------------------------------------------------------------------- +// +BOOLEAN BootGetBBSOptionStatus(BOOT_DATA *bootData, UINT16 value, BOOLEAN FromSetup, BOOLEAN ShowAllBBSDev) +{ + UINT32 offset=0; + UINT32 i; + UINT8 *pDevOrder; + BBS_ORDER_TABLE *pDev; + UINTN size = 0; + UINT16 *buf = NULL, *Tempbuf = NULL; + + if(0 == FromSetup) + { + if(!BootGetOptionStatus(bootData, FromSetup)) + { + offset = (UINT16)bootData->LegacyEntryOffset; + + pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size); + + pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset); + + if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011 + return TRUE; + + if(DISABLED_BOOT_OPTION == pDev->Data[value]) + { + MemFreePointer((VOID **) &pDevOrder); + return TRUE; + } + else + { + MemFreePointer((VOID **) &pDevOrder); + return FALSE; + } + } + else + return TRUE; + } + if(!BootGetOptionStatus(bootData, FromSetup)) + { + + size=0; + offset = (UINT16)bootData->LegacyEntryOffset; + pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size); + if (NULL == pDevOrder) + { + return TRUE; + } + + pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset); + + if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011 + return TRUE; + + if(!ShowAllBBSDev) + { + if(DISABLED_BOOT_OPTION == pDev->Data[value]) + { + MemFreePointer((VOID **) &pDevOrder); + return TRUE; + } + else + { + MemFreePointer((VOID **) &pDevOrder); + return FALSE; + } + } + + buf = EfiLibAllocateZeroPool( pDev->Length - sizeof(UINT16)); + + if (NULL == buf) //EIP117338 + { + return FALSE; + } + + Tempbuf = buf; + MemCopy( buf, &pDev->Data, pDev->Length - sizeof(UINT16) ); + + for(i=0; i < bootData->LegacyDevCount ;i++) + { + if(*buf == bootData->OrderList[value].Index) + break; + buf++; + } + + MemFreePointer((VOID **) &pDevOrder); //EIP117338 + MemFreePointer((VOID **) &Tempbuf); + + if(i == bootData->LegacyDevCount) + { + return TRUE; + } + else + { + return FALSE; + } + } + else + return TRUE; +} +//EIP: 51671 END +// +//---------------------------------------------------------------------------- +// Procedure: LoadOptionhidden +// +// Description: Function to check the Boot option status if gLoadOptionhidden token is Enabled +// +// Input: UINT16 value +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN LoadOptionhidden (UINT16 value, BOOLEAN Option) +{ + if (BOOT_ORDER_OPTION == Option) + { + if (gBootData [value].Active & LOAD_OPTION_HIDDEN) + return TRUE; + } + else if (DRIVER_ORDER_OPTION == Option) //EIP70421 & 70422 + { + if (gDriverData [value].Active & LOAD_OPTION_HIDDEN) + return TRUE; + } + return FALSE; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CheckHiddenforBootDriverOption +// +// Description: Check whether the Boot/Driver option has hidden property +// +// Input: UINT16, BOOLEAN +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN CheckHiddenforBootDriverOption (UINT16 Option, BOOLEAN HiddenOption) +{ + UINTN i = 0; + if (gLoadOptionHidden) + { + if (BOOT_ORDER_OPTION == HiddenOption) + { + for (i = 0 ;i < gBootOptionCount ;i++) + { + if (gBootData [i].Option == Option) + { + if (gBootData [i].Active & LOAD_OPTION_HIDDEN) + { + return TRUE; + } + break; + } + } + } + else if (DRIVER_ORDER_OPTION == HiddenOption) + { + for (i = 0 ;i < gDriverOptionCount ;i++) + { + if (gDriverData [i].Option == Option) + { + if (gDriverData [i].Active & LOAD_OPTION_HIDDEN) + { + return TRUE; + } + break; + } + } + } + } + return FALSE; +} + +//EIP: 62631 Start +// +//----------------------------------------------------------------------------------------------- +// Procedure: CheckBootOptionMatch +// +// Description: Checks the input boot option matches with any of the boot option in the system +// +// Input: UINT16 = Boot option to which match to be find +// +// Output: UINT32 = Returns 0 if no match found +// = 32 bit CRC value of boot option if match found +// +//------------------------------------------------------------------------------------------------ +// +UINT32 CheckBootOptionMatch (UINT16 BootOption) +{ + UINTN iIndex = 0; + CHAR16 BootOptionName [9]; //Bootxxxx + 1 NULL char + UINT32 *LoadOptions = NULL; //Using 32 bit ptr bcoz to find CRC32 + UINTN LoadOptionSize = 0; + UINT32 CRC32 = 0; + + SPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04X", BootOption); + LoadOptions = VarGetNvramName (BootOptionName, &gEfiGlobalVariableGuid, NULL, &LoadOptionSize); //Getting boot options + if ((NULL == LoadOptions) || (0 == LoadOptionSize)) + { + return CRC32; //returning 0 + } + gBS->CalculateCrc32 ((UINT8 *)LoadOptions, LoadOptionSize, &CRC32); + return CRC32; +} + +// +//-------------------------------------------------------------------------------------- +// Procedure: SetBootOptionSupportVariable +// +// Description: Function to set the BootOptionSupport variable +// +// Input: UINT32 = Capabilities for the BootOptionSupport variable +// +// Output: VOID +// +//-------------------------------------------------------------------------------------- +// +VOID SetBootOptionSupportVariable (UINT32 BootManCapabilities) +{ + CHAR16 VariableName [] = L"BootOptionSupport"; + UINT32 Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; + UINTN DataSize = 0; + VOID *Data; + UINT32 SetData = 0; + + Data = VarGetNvramName (VariableName, &gEfiGlobalVariableGuid, &Attributes, &DataSize); //If the variable exists use its attribute to set it + if (NULL != Data) + { + SetData = *((UINT32 *)Data); + } + SetData |= BootManCapabilities; + DataSize = sizeof (UINT32); //Sizeof BootOptionSupport variable is UINT32 + VarSetNvramName (VariableName, &gEfiGlobalVariableGuid, Attributes, (VOID *)&SetData, DataSize); +} +//EIP: 62631 End + +//EIP 64295 Start +// +//-------------------------------------------------------------------------------------- +// Procedure: CheckDevSupShortFormPath +// +// Description: Matches the device path with USB class device path (Table 60) and returns +// the corresponding USB's file system handle +// +// Input: EFI_DEVICE_PATH_PROTOCOL * -> Device path for the boot option +// +// Output: EFI_HANDLE -> Handle for the file system +// +//-------------------------------------------------------------------------------------- +// +EFI_HANDLE CheckDevSupShortFormPath (EFI_DEVICE_PATH_PROTOCOL *DevicePath) +{ + UINTN NumHandles = 0; + UINTN iIndex = 0; + CHAR16 *USBString = NULL; + CHAR16 *USBDevPathString = NULL; + UINT16 *LangIDTable; + UINT16 TableSize = 0; + EFI_STATUS Status; + EFI_HANDLE *UsbIoHandles = NULL; + EFI_USB_IO_PROTOCOL *UsbIoProtocolInstance = NULL; + EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor; + USB_CLASS_DEVICE_PATH *UsbClassDevPath = NULL; + USB_WWID_DEVICE_PATH *UsbWwidDevPath = NULL; + EFI_DEVICE_PATH_PROTOCOL *TempDevPath = DevicePath; + + if ((MESSAGING_DEVICE_PATH == TempDevPath->Type) && (MSG_USB_CLASS_DP == TempDevPath->SubType)) //Check for USB Device Path Class. type = 3 and subtype = 0xf + { + UsbClassDevPath = (USB_CLASS_DEVICE_PATH *)TempDevPath; + } + else if ((MESSAGING_DEVICE_PATH == TempDevPath->Type) && (MSG_USB_WWID_CLASS_DP == TempDevPath->SubType)) + { + UsbWwidDevPath = (USB_WWID_DEVICE_PATH *)TempDevPath; + USBDevPathString = (CHAR16 *)((UINT8 *)UsbWwidDevPath + sizeof (USB_WWID_DEVICE_PATH)); //String will be present at the end of the WWID device path + } + else + { + return NULL; + } + Status = gBS->LocateHandleBuffer ( //To match with USB Device Path Class + ByProtocol, + &gEfiUsbIoProtocolGuid, + NULL, + &NumHandles, + &UsbIoHandles + ); + if (EFI_ERROR (Status)) + { + return NULL; + } + for (iIndex = 0; iIndex < NumHandles; iIndex ++) + { + Status = gBS->HandleProtocol (UsbIoHandles [iIndex], &gEfiUsbIoProtocolGuid, &UsbIoProtocolInstance); + if (EFI_ERROR (Status)) + { + continue; + } + Status = UsbIoProtocolInstance->UsbGetDeviceDescriptor (UsbIoProtocolInstance, &DeviceDescriptor); + if (EFI_ERROR (Status)) + { + continue; + } + if (UsbWwidDevPath) + { + Status = UsbIoProtocolInstance->UsbGetSupportedLanguages (UsbIoProtocolInstance, &LangIDTable, &TableSize); + if (!EFI_ERROR (Status) && TableSize) + { + Status = UsbIoProtocolInstance->UsbGetStringDescriptor (UsbIoProtocolInstance, LangIDTable [0], DeviceDescriptor.StrSerialNumber, &USBString); //LangIDTable [0], getting default as English + if (EFI_ERROR (Status)) + { + USBString = NULL; //Explicitly making as NULL + } + } + if ((NULL != USBString) ^ (0 != EfiStrLen (USBDevPathString))) //If serial number string present in device path and not in descriptor then try for other device and vice versa too + { //If device path and descriptor not has the string then proceed + continue; + } + } + if (UsbClassDevPath? + ( //Check for USB Class device path + ((UsbClassDevPath->VendorId == DeviceDescriptor.IdVendor) || (0xFFFF == UsbClassDevPath->VendorId)) && //If values are 0xF's then dont consider that option + ((UsbClassDevPath->ProductId == DeviceDescriptor.IdProduct) || (0xFFFF == UsbClassDevPath->ProductId)) && + ((UsbClassDevPath->DeviceClass == DeviceDescriptor.DeviceClass) || (0xFF == UsbClassDevPath->DeviceClass)) && + ((UsbClassDevPath->DeviceSubClass == DeviceDescriptor.DeviceSubClass) || (0xFF == UsbClassDevPath->DeviceSubClass)) && + ((UsbClassDevPath->DeviceProtocol == DeviceDescriptor.DeviceProtocol) || (0xFF == UsbClassDevPath->DeviceProtocol)) + ): + ( //Check for USB WWID device path + (UsbWwidDevPath->VendorId == DeviceDescriptor.IdVendor) && + (UsbWwidDevPath->ProductId == DeviceDescriptor.IdProduct) && + (USBString ? (!(EfiStrCmp (USBDevPathString, USBString))):1) //String number of USB might not be filled in some case in such conditions will take it as TRUE + ) + ) + { + UINTN Count; + EFI_GUID **ppGuid; + UINTN jIndex = 0; + UINTN kIndex = 0; + + Status = gBS->ProtocolsPerHandle (UsbIoHandles [iIndex], &ppGuid, &Count); + if (EFI_ERROR (Status)) + { + continue; + } + for (jIndex = 0; jIndex < Count; jIndex ++) + { + if (!guidcmp (ppGuid [jIndex], &gEfiDiskIoProtocolGuid)) + { + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *pInfo; + UINTN InfoCount = 0; + VOID *FilsSystemInstance = NULL; + EFI_HANDLE handle = NULL; + EFI_DEVICE_PATH_PROTOCOL *FilePath = NULL; + + Status = gBS->OpenProtocolInformation (UsbIoHandles [iIndex], ppGuid [jIndex], &pInfo, &InfoCount); + if (EFI_ERROR (Status)) + { + continue; + } + for (kIndex = 0; kIndex < InfoCount; kIndex ++) + { + Status = gBS->HandleProtocol (pInfo [kIndex].ControllerHandle, &gEfiSimpleFileSystemProtocolGuid, &FilsSystemInstance); + if (EFI_ERROR (Status)) + { + continue; + } + FilePath = EfiFileDevicePath (pInfo [kIndex].ControllerHandle, gBootFileName); + if (FilePath) + { + Status = gBS->LoadImage ( //Ensuring the image can load + TRUE, + gImageHandle, + FilePath, + NULL, + 0, + &handle + ); + MemFreePointer((VOID **) &FilePath); + if (!EFI_ERROR (Status)) + { + if (USBString) + { + MemFreePointer ((VOID **)&USBString); + } + MemFreePointer ((VOID **)&UsbIoHandles); + return pInfo [kIndex].ControllerHandle; + } + + } + } + if (InfoCount) + { + MemFreePointer ((VOID **)&pInfo); + } + } + } + } + if (USBString) + { + MemFreePointer ((VOID **)&USBString); + } + } + MemFreePointer ((VOID **)&UsbIoHandles); + return NULL; +} +//EIP 64295 End + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/box.c b/EDK/MiniSetup/BootOnly/box.c new file mode 100644 index 0000000..535995e --- /dev/null +++ b/EDK/MiniSetup/BootOnly/box.c @@ -0,0 +1,241 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.c $ +// +// $Author: Arunsb $ +// +// $Revision: 5 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.c $ +// +// 5 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 8 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 4 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 5 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 4 12/10/09 2:59p Presannar +// Modified DrawBorder fn to check if Width or Height is zero. This is a +// solution to address EiP - 32242 +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: DrawLineWithAttribute +// +// Description: function to draw the lines with attributes +// +// Input: UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawLineWithAttribute( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib ) +{ + UINTN Index; + CHAR16 *Line; + + Line = EfiLibAllocatePool( sizeof(CHAR16) * (Length + 1) ); + if ( Line == NULL ) + return; + + for ( Index = 0; Index < Length; Index++ ) + Line[Index] = Type; + + Line[Index] = 0; + + DrawStringWithAttribute( Col, Row, Line, Attrib ); + + MemFreePointer( (VOID **)&Line ); +} + +VOID DrawLine( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type ) +{ + DrawLineWithAttribute( Col, Row, Length, Type, 0 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBorder +// +// Description: function to draw the border +// +// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height ) +{ + UINTN Index; + CHAR16 *Line; + UINTN Right, Bottom; + + if( Width == 0 || Height == 0 ) + return; + + Line = EfiLibAllocateZeroPool( (Width + 6) * sizeof(CHAR16) ); + if ( Line == NULL ) + return; + + Right = Left + Width - 1; + Bottom = Top + Height - 1; + + for ( Index = 1; Index < Width - 1; Index++ ) + Line[Index] = BOXDRAW_HORIZONTAL; + + Line[0] = BOXDRAW_DOWN_RIGHT; + Line[Index] = BOXDRAW_DOWN_LEFT; + DrawString( Left, Top, Line ); + Line[0] = BOXDRAW_UP_RIGHT; + Line[Index] = BOXDRAW_UP_LEFT; + DrawString( Left, Bottom, Line ); + + Line[0] = BOXDRAW_VERTICAL; + Line[1] = 0; + + for ( Index = Top + 1; Index < Bottom; Index++ ) + { + DrawString( Left, Index, Line ); + DrawString( Right, Index, Line ); + } + + MemFreePointer( (VOID **)&Line ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawWindow +// +// Description: function to draw a window +// +// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height, +// UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow ) +{ + if ( Shadow ) + DrawBox( Left + 2, Top + 1, Width, Height, 0 ); + + DrawBox( Left, Top, Width, Height, Attrib ); + + if ( Border ) + DrawBorder( Left, Top, Width, Height ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBox +// +// Description: function to draw a box +// +// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib ) +{ + UINTN Bottom, Right; + UINTN Index; + UINTN Offset; + CHAR16 WindowLine[MAX_COLS]; + UINT8 AttribLine[MAX_COLS]; + + Bottom = Top + Height; + if ( Bottom >= gMaxRows ) + { + Bottom = gMaxRows - 1; + Height = Bottom - Top; + } + + Right = Left + Width; + if ( Right >= gMaxCols ) + { + Right = gMaxCols - 1; + Width = Right - Left; + } + + MemSet( AttribLine, Width, Attrib ); + for ( Index = 0; Index < Width; Index++ ) + WindowLine[Index] = L' '; + + Offset = Top * gMaxCols + Left; + for ( Index = Top; Index < Bottom; Index++, Offset += gMaxCols ) + { + // to resolve the wide char corruption when box is drawn + if((Left) && ( IsCharWide( gFlushBuffer->Chars[Offset-1]) == TRUE )) + gActiveBuffer->Chars[Offset-1]=L' '; + + MemCopy( &gActiveBuffer->Chars[Offset], WindowLine, sizeof(CHAR16) * Width ); + MemCopy( &gActiveBuffer->Attribs[Offset], AttribLine, Width ); + } +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/box.h b/EDK/MiniSetup/BootOnly/box.h new file mode 100644 index 0000000..559fb6a --- /dev/null +++ b/EDK/MiniSetup/BootOnly/box.h @@ -0,0 +1,95 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.h $ +// +// $Author: Arunsb $ +// +// $Revision: 4 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.h $ +// +// 4 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 3 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: Box.h +// +// Description: Header file for box related functions +// +//---------------------------------------------------------------------------- +// + +#ifndef _BOX_H_ +#define _BOX_H_ + +VOID DrawLine( UINTN Col, UINTN Rown, UINTN Length, CHAR16 Type ); +VOID DrawLineWithAttribute( UINTN Col, UINTN Rown, UINTN Length, CHAR16 Type, UINT8 Attrib ); +VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height ); +VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow ); +VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib ); +#endif /* _BOX_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/buffer.c b/EDK/MiniSetup/BootOnly/buffer.c new file mode 100644 index 0000000..e49203a --- /dev/null +++ b/EDK/MiniSetup/BootOnly/buffer.c @@ -0,0 +1,501 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.c $ +// +// $Author: Arunsb $ +// +// $Revision: 10 $ +// +// $Date: 3/18/13 2:40a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.c $ +// +// 10 3/18/13 2:40a Arunsb +// [TAG] EIP116669 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Mouse shadow can't refresh when switch Multi languages +// under BIOS Setup. +// [RootCause] Mouse not stopped when mouse pointer is at the top(0 row) +// of the screen. +// [Solution] Mouse stopped properly in all the position. +// [Files] buffer.c +// +// 9 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 13 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 8 1/18/12 4:55a Rajashakerg +// [TAG] EIP79962 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Mouse pointer corruption in GTSE +// [RootCause] For GTSE, the cordanites comparison logic went wrong for +// stopping the mouse pointer when it is present while +// updating the screen buffer. +// [Solution] Corrected the logic to stop the mouse when mouse pointer +// is present on screen we are updating. +// [Files] buffer.c, CommonHelper.c, Mouse.c +// +// 7 11/30/11 11:24a Premkumara +// [TAG] EIP67695 +// [Category] Improvement +// [Description] No cursor visible in setup, while editing text input +// box +// [Files] Buffer.c, Postmgmtext.c, PopupString.c, PopupPassword.c +// +// 6 11/20/11 7:02a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 5 9/27/10 7:48a Mallikarjunanv +// EIP 40555 : To avoid Compilation issues with Fareast Windows. +// +// 4 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 9 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 8 1/29/10 4:37p Madhans +// To not to depend on ConsoleControl and ConOut. +// +// 7 10/28/09 5:36p Madhans +// To undo the changes. +// +// 6 9/29/09 5:51p Madhans +// Added more comment. +// +// 5 9/15/09 9:27a Sudhirv +// added a flag for FlushPause +// +// 4 8/17/09 4:31a Mallikarjunanv +// EIP:24991 - updated the DoRealFlush lines function with the changes +// suggested by Murase +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 2 4/29/09 9:02p Madhans +// Bug Fixes after unit Testing.. +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 2/05/09 10:15a Madhans +// Style Module created. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: Buffer.c +// +// Description: This file contains code to manage buffers +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" +VOID GetCoordinates(INT32 *x, INT32 *y, INT32 *z); +INT32 GetactualScreentop(VOID); +BOOLEAN IsMouseSupported(VOID); +// +//---------------------------------------------------------------------------- +// Procedure: InitializeScreenBuffer +// +// Description: function to initialize the screen buffer +// +// Input: UINT8 attrib +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS InitializeScreenBuffer( UINT8 attrib ) +{ + EFI_STATUS Status = EFI_OUT_OF_RESOURCES; + + MemFreePointer( (VOID **)&gFlushBuffer ); + gFlushBuffer = EfiLibAllocateZeroPool( sizeof(SCREEN_BUFFER) ); + if ( gFlushBuffer == NULL ) + return Status; + + MemFreePointer( (VOID **)&gActiveBuffer ); + gActiveBuffer = EfiLibAllocatePool( sizeof(SCREEN_BUFFER) ); + if ( gActiveBuffer != NULL ) + { + ClearScreenWithoutFlush( attrib ); + Status = EFI_SUCCESS; + } + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: SlowFlushLines +// +// Description: function to slow flush lines +// +// Input: UINTN Top, UINTN Bottom +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID SlowFlushLines( UINTN Top, UINTN Bottom ) +{ + UINTN Index; + UINTN Offset = Top * gMaxCols; + UINTN End = (Bottom - Top + 1) * gMaxCols + Offset; + UINT8 LastAttrib = 0xFF; + CHAR16 String[2] = { 0, 0 }; + + gST->ConOut->SetCursorPosition( gST->ConOut, 0, Top ); + for ( Index = Offset; Index < End; Index++ ) + { + if ( gActiveBuffer->Attribs[Index] != LastAttrib ) + { + LastAttrib = gActiveBuffer->Attribs[Index]; + gST->ConOut->SetAttribute( gST->ConOut, LastAttrib ); + } + *String = gActiveBuffer->Chars[Index]; + + gST->ConOut->OutputString( gST->ConOut, String ); + } +} + +#define INVALID_FLUSH_LINE 0xFFFF +UINTN FlushTop=INVALID_FLUSH_LINE; +UINTN FlushBottom=INVALID_FLUSH_LINE; +// +//---------------------------------------------------------------------------- +// Procedure: FlushLines +// +// Description: function to set the positions for flush lines +// +// Input: UINTN Top, UINTN Bottom +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID FlushLines( UINTN Top, UINTN Bottom ) +{ + if( FlushTop==INVALID_FLUSH_LINE) + FlushTop = Top; + + if(FlushBottom==INVALID_FLUSH_LINE) + FlushBottom = Bottom; + + if(FlushTop>Top) + FlushTop = Top; + + if(FlushBottom < Bottom) + FlushBottom = Bottom; +} +// +//---------------------------------------------------------------------------- +// Procedure: DoRealFlushLines +// +// Description: function to flush lines +// +// Input: NIL +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DoRealFlushLines() +{ + UINTN Index; + UINTN ByteStart, ByteEnd; + UINTN Offset = 0; + UINTN End = 0; + UINT8 LastAttrib,LastSetAttrib=0; + CHAR16 *String; + UINTN X=0,Y=0,TempOffSet,PrintLen; + UINTN CurrentX=0; + BOOLEAN FlushIt; + UINTN Top, Bottom; + UINT32 MousePointerX=0,MousePointerY=0,MousePointerZ=0;//EIP 62763 : Mouse poiner declaration + + if( (FlushTop==INVALID_FLUSH_LINE) || (FlushBottom==INVALID_FLUSH_LINE)) + return; + + if(gST->ConOut == NULL) + return; + Top = FlushTop; + Bottom = FlushBottom; + + if ( Top >= gMaxRows ) + return; + + if ( Top > Bottom ) + { + UINTN Swap = Bottom; + Bottom = Top; + Top = Swap; + } + + if ( Bottom >= gMaxRows ) + Bottom = gMaxRows - 1; + + ByteStart = Top * gMaxCols; + ByteEnd = (Bottom - Top + 1) * gMaxCols + ByteStart; + + String = EfiLibAllocateZeroPool( (gMaxCols + 1) * sizeof(CHAR16) ); + + if ( String == NULL ) + { + SlowFlushLines( Top, Bottom ); + return; + } + + // Flush from Top to Bottom + // inside the loop 'Top' refers current line + for ( ; Top <= Bottom; Top++ ) + { + Offset = Top * gMaxCols; + End = Offset + gMaxCols; + + // If All the Chars and attributes are equal in current line. Go to next line. + if ( ( ! EfiCompareMem( &gActiveBuffer->Attribs[Offset], &gFlushBuffer->Attribs[Offset], gMaxCols ) ) && + ( ! EfiCompareMem( &gActiveBuffer->Chars[Offset], &gFlushBuffer->Chars[Offset], gMaxCols * sizeof(CHAR16) ) ) ) + continue; + + // Don't Print the last char in MaxRow X MaxCol + // As it will scroll if we print. + if ( End >= gMaxRows * gMaxCols ) + End = gMaxRows * gMaxCols - 1; + + // Attribute for current print. + LastAttrib = gActiveBuffer->Attribs[Offset]; + + // To improve the flush lines code. + CurrentX=0; + + // To support Terminal host with hight resolution.(EIP-25288) + gST->ConOut->EnableCursor(gST->ConOut, FALSE); //EIP:67695-Make the cursor invisible since the cursor position is changing and visible outside popup box + gST->ConOut->SetCursorPosition( gST->ConOut, CurrentX, Top ); + + PrintLen = 0; + FlushIt = TRUE; // decides printing + + if(IsMouseSupported()) + GetCoordinates(&MousePointerX, &MousePointerY, &MousePointerZ); + + while ( Offset < End ) + { + // Collect the string till the Attribute is differnt as it may need setAttribute + for ( Index = 0, TempOffSet = Offset; (gActiveBuffer->Attribs[Offset] == LastAttrib) && (Offset < End); Offset++, Index++ ) + { + String[Index] = gActiveBuffer->Chars[Offset]; + + if(TRUE == IsCharWide(String[Index])) + Offset++; + + } + String[Index] = 0; +//EIP 79962 : Getting the actual Screen top from the binary for stopping the mouse + if( + (IsMouseSupported() && + ((0 == Top) || (((MousePointerY/HiiGetGlyphHeight()) >= ((Top + ( GetactualScreentop()/ HiiGetGlyphHeight()))-1)) && ( (MousePointerY/HiiGetGlyphHeight()) <= ((Top + (GetactualScreentop()/ HiiGetGlyphHeight()))+1)))) ) + ) //EIP116669 + { + MouseStop(); + } + + // We are trying to print the strings with 'LastAttrib' + // NOW - TempOffSet refers begining of the buffer + // Offset refers end if the print buffer for currnet print. + + // if the String and attribute are equal to flush lines and it is more then 10 then we don't need to Print. + // The reason for 10 is to avoid sending setposition. IF we skip less then 10 then we will end up calling setposition that takes 9 bytes + // for serial redirection. + if(((Offset-TempOffSet)>10)&& + ( ! EfiCompareMem( &gActiveBuffer->Attribs[TempOffSet], &gFlushBuffer->Attribs[TempOffSet], Offset-TempOffSet ) )) + { + // If all the charecters are same between active and flush buffer, let not print it + if ( ( ! EfiCompareMem( &gActiveBuffer->Chars[TempOffSet], &gFlushBuffer->Chars[TempOffSet], (Offset-TempOffSet) * sizeof(CHAR16) ) ) ) + FlushIt = FALSE; + else + { + UINTN i,j=0; + UINTN FirstDiff, LastDiff; + FirstDiff = LastDiff = (Offset-TempOffSet); // Fail case default + + // loop to find out that is the first and last different offset in the printable string. + for(i=0,j=0; i<(Offset-TempOffSet);i++,j++) + { + if(gActiveBuffer->Chars[TempOffSet+i] != gFlushBuffer->Chars[TempOffSet+i]) + { + if(FirstDiff>i) // First Diff set + FirstDiff = i; + LastDiff = i; + Index = j; + } + if(TRUE == IsCharWide(String[j])) + i++; + } + +//EIP:24991 - START + // Modification to erase wide characters correctly. + // Issue: + // If we write "a" over some wide character, the right half of the wide character is sometimes not erased. + // e.g.) + // When we write "aaaa " over "aaa? ", the right half of "?" is not erased. + if (!IsCharWide(String[Index]) && IsCharWide(gFlushBuffer->Chars[TempOffSet + LastDiff]) && LastDiff+1Chars[TempOffSet + LastDiff + 1]) && LastDiff+210) // Is it worth skiping? + { + Offset = TempOffSet+FirstDiff; + String[Index] = 0; // No need. But lets do it anyway + FlushIt = FALSE; + } + else if(((Offset-TempOffSet)- LastDiff) > 10) // Only print the Different sting up to LastDiff + { +//EIP:24991 - START + // Make the offset to point to next char to be printed for next iteration + Offset = TempOffSet+LastDiff+1; + if(TRUE == IsCharWide(String[Index])) + Offset++; +//EIP:24991 - END + String[Index+1] = 0; + } + } + } + + if(FlushIt) + { + // Set of it is different from previous setatribute. + if(LastSetAttrib!=LastAttrib) + { + gST->ConOut->SetAttribute( gST->ConOut, LastAttrib ); + LastSetAttrib = LastAttrib; + } + //do the set position if the cursor is not at expected loc. + if(((X+PrintLen) != CurrentX) || (Y != Top) || ((CurrentX == 0) && (Top==0))) + { + gST->ConOut->SetCursorPosition( gST->ConOut, CurrentX, Top ); + } + + X=CurrentX; + Y=Top; + + gST->ConOut->OutputString( gST->ConOut, String ); + PrintLen = Offset-TempOffSet; + + // if we print till end of line then increament the y and make x=0. + if((X+PrintLen)>=gMaxCols) + { + Y++;X=0; + } + } + + CurrentX += Offset-TempOffSet; + FlushIt = TRUE; + LastAttrib = gActiveBuffer->Attribs[Offset]; + } + } + + MemCopy( &gFlushBuffer->Attribs[ByteStart], &gActiveBuffer->Attribs[ByteStart], ByteEnd - ByteStart ); + MemCopy( &gFlushBuffer->Chars[ByteStart], &gActiveBuffer->Chars[ByteStart], (ByteEnd - ByteStart) * sizeof(CHAR16) ); + FlushTop=INVALID_FLUSH_LINE; + FlushBottom=INVALID_FLUSH_LINE; + MemFreePointer( (VOID **)&String ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetDesiredTextMode +// +// Description: function to set the test mode +// +// Input: nil +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void SetDesiredTextMode() +{ + EFI_STATUS Status; + + if(gST->ConOut==NULL) + return; + Status = gST->ConOut->Reset( gST->ConOut, FALSE ); + Status = gST->ConOut->SetMode( gST->ConOut, StyleGetTextMode( gMaxRows, gMaxCols ) ); + + if ( EFI_ERROR( Status ) ) + { + gMaxRows = StyleGetStdMaxRows(); + gMaxCols = StyleGetStdMaxCols(); + gST->ConOut->SetMode( gST->ConOut, 0 ); + } +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/buffer.h b/EDK/MiniSetup/BootOnly/buffer.h new file mode 100644 index 0000000..1fa054d --- /dev/null +++ b/EDK/MiniSetup/BootOnly/buffer.h @@ -0,0 +1,95 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.h $ +// +// $Author: Arunsb $ +// +// $Revision: 4 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.h $ +// +// 4 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 3 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: Buffer.h +// +// Description: Header file for code to manage buffers +// +//---------------------------------------------------------------------------- +// + +#ifndef _BUFFER_H_ +#define _BUFFER_H_ + +VOID FlushLines( UINTN Top, UINTN Bottom ); +VOID DoRealFlushLines(); + +#endif /* _BUFFER_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/dobmpmgr.c b/EDK/MiniSetup/BootOnly/dobmpmgr.c new file mode 100644 index 0000000..076649b --- /dev/null +++ b/EDK/MiniSetup/BootOnly/dobmpmgr.c @@ -0,0 +1,301 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/dobmpmgr.c $ +// +// $Author: Arunsb $ +// +// $Revision: 13 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/dobmpmgr.c $ +// +// 13 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 10 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 11 9/17/12 6:10a Rajashakerg +// Updated EIP changes for 2.16 release. +// +// 9 8/29/12 12:38p Arunsb +// [TAG] EIP93521 +// [Category] New Feature +// [Description] Support of ESRT +// [Files] amitse.sdl, bootflow.c, bootflow.h, commonhelper.c and +// dobmpmgr.c +// +// 8 8/23/12 6:24p Arunsb +// Reverted back 2.15.1229 for making GTSE, TSELite and BootOnly labels +// +// 7 8/21/12 7:57p Arunsb +// [TAG] EIP93521, EIP92901 and EIP92900 +// [Category] New Feature +// [Description] Support of ESRT +// [Files] amitse.sdl, bootflow.c, bootflow.h, commonhelper.c and +// dobmpmgr.c +// +// 6 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 7 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 6 9/02/09 7:40p Madhans +// To Realy fix the Logo Security issue +// +// 5 8/13/09 12:14p Blaines +// Move Image support to binary module +// +// 4 6/24/09 6:09p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: DoBMPmgr.c +// +// Description: file contains code that is taken from graphics.c +// to eliminnate library dependancy +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + + +//#if SETUP_BMP_LOGO_SUPPORT + +// +//---------------------------------------------------------------------------- +// Procedure: MemFreePointer +// +// 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 buffer is passed +// in it will be used if it is big enough. +// +// Input: BmpImage - Pointer to BMP file +// BmpImageSize - Number of bytes in BmpImage +// UgaBlt - Buffer containing UGA version of BmpImage. +// UgaBltSize - Size of UgaBlt in bytes. +// PixelHeight - Height of UgaBlt/BmpImage in pixels +// PixelWidth - Width of UgaBlt/BmpImage in pixels +// +// Output: EFI_SUCCESS - UgaBlt and UgaBltSize 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_OUT_OF_RESOURCES - No enough buffer to allocate +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +ConvertBmpToUgaBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT VOID **UgaBlt, + IN OUT UINTN *UgaBltSize, + OUT UINTN *PixelHeight, + OUT UINTN *PixelWidth + ) +{ + UINT8 *Image; + BMP_IMAGE_HEADER *BmpHeader; + BMP_COLOR_MAP *BmpColorMap; + EFI_UGA_PIXEL *BltBuffer; + EFI_UGA_PIXEL *Blt; + UINT64 BltBufferSize; + UINTN Index; + UINTN Height; + UINTN Width; + UINTN ImageIndex; + + BmpHeader = (BMP_IMAGE_HEADER *) BmpImage; + if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') + return EFI_UNSUPPORTED; + + if (BmpHeader->CompressionType != 0) + return EFI_UNSUPPORTED; + + // Calculate Color Map offset in the image. + Image = BmpImage; + BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER)); + + // Calculate graphics image data address in the image + Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset; + + // Make sure to do x64 Mul + BltBufferSize = MultU64x32((UINT64)BmpHeader->PixelWidth ,BmpHeader->PixelHeight); + + /// Check whether the Size exceeds the limit... + // 4GB/PIXEL_SIZE becoz we need Resolution*PIXEL_SIZE for bltbuffer + if ( BltBufferSize >= (FOUR_GB_LIMIT/sizeof (EFI_UGA_PIXEL))) { + // The buffer size extends the limitation + return EFI_UNSUPPORTED; + } + + BltBufferSize = MultU64x32( BltBufferSize ,sizeof (EFI_UGA_PIXEL)); + + if (*UgaBlt == NULL) + { + *UgaBltSize = (UINTN)BltBufferSize; + *UgaBlt = EfiLibAllocatePool (*UgaBltSize); + if (*UgaBlt == NULL) + return EFI_OUT_OF_RESOURCES; + } + else + { + if (*UgaBltSize < (UINTN)BltBufferSize) + { + *UgaBltSize = (UINTN)BltBufferSize; + return EFI_BUFFER_TOO_SMALL; + } + } + + *PixelWidth = BmpHeader->PixelWidth; + *PixelHeight = BmpHeader->PixelHeight; + + // Convert image from BMP to Blt buffer format + + BltBuffer = *UgaBlt; + for (Height = 0; Height < BmpHeader->PixelHeight; Height++) + { + Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth]; + for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) + { + switch (BmpHeader->BitPerPixel) + { + case 1: //the bitmap is monochrome //EIP93521 and EIP92900 + //for every bit + for(Index = 8; Index ; Index--) + { + if(1<<(Index-1) & *Image) + { + Blt->Red = BmpColorMap[1].Red; + Blt->Green = BmpColorMap[1].Green; + Blt->Blue = BmpColorMap[1].Blue; + } + else + { + Blt->Red = BmpColorMap[0].Red; + Blt->Green = BmpColorMap[0].Green; + Blt->Blue = BmpColorMap[0].Blue; + } + if (Width < (BmpHeader->PixelWidth)) + { + Blt++; + Width++; + } + } + Blt--; + Width--; + break; + + case 4: // Convert BMP Palette to 24-bit color + Index = (*Image) >> 4; + Blt->Red = BmpColorMap[Index].Red; + Blt->Green = BmpColorMap[Index].Green; + Blt->Blue = BmpColorMap[Index].Blue; + if (Width < (BmpHeader->PixelWidth - 1)) + { + Blt++; + Width++; + Index = (*Image) & 0x0f; + Blt->Red = BmpColorMap[Index].Red; + Blt->Green = BmpColorMap[Index].Green; + Blt->Blue = BmpColorMap[Index].Blue; + } + break; + + case 8: // Convert BMP Palette to 24-bit color + Blt->Red = BmpColorMap[*Image].Red; + Blt->Green = BmpColorMap[*Image].Green; + Blt->Blue = BmpColorMap[*Image].Blue; + break; + + case 24: + Blt->Blue = *Image++; + Blt->Green = *Image++; + Blt->Red = *Image; + break; + case 32: //EIP93521 and EIP92901 + { + if((BmpHeader->CompressionType)==0) + { + Blt->Blue = *Image++; + Blt->Green = *Image++; + Blt->Red = *Image++; + } + else + { + return EFI_UNSUPPORTED; + } + } + break; + default: + return EFI_UNSUPPORTED; + break; + }; + } + ImageIndex = (UINTN) (Image - BmpHeader->ImageOffset); + if ((ImageIndex % 4) != 0) // Bmp Image starts each row on a 32-bit boundary! + Image = Image + (4 - (ImageIndex % 4)); + } + return EFI_SUCCESS; +} + +//#endif //SETUP_BMP_LOGO_SUPPORT + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/globals.c b/EDK/MiniSetup/BootOnly/globals.c new file mode 100644 index 0000000..a8b39a6 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/globals.c @@ -0,0 +1,212 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/globals.c $ +// +// $Author: Arunsb $ +// +// $Revision: 9 $ +// +// $Date: 2/11/14 7:54p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/globals.c $ +// +// 9 2/11/14 7:54p Arunsb +// [TAG] EIP132360 +// [Category] Improvement +// [Description] Verify ESA will show a form if SendForm interface is +// called by a driver. +// [Files] globals.c +// EsaBin.c +// FormBrowser2.c +// protocol.c +// minisetup.h +// +// 8 4/18/13 1:50a Arunsb +// [TAG] EIP81490 +// [Category] New Feature +// [Description] Post message support for BBS popup menu +// [Files] AMITSE.sdl, AmiTSEStr.uni, commonoem.c, FakeTokens.c and +// globals.c +// +// 7 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 6 1/24/12 4:24a Arunsb +// [TAG] EIP81581 +// [Category] Improvement +// [Description] Default driver order support +// [Files] globals.c, addbootoption.c, callback.c, minisetupext.h and +// variable.c +// +// 5 11/20/11 7:03a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 4 11/14/11 2:43p Blaines +// [TAG] - EIP 75481 +// [Category]- Function Request +// [Synopsis]- TSE debug print infrastructure. +// [Description]- Add TSE debug print info for basic functions such as +// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms +// data. +// [Files] +// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c +// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c, +// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h, +// Uefi21Wrapper.c, setupdbg.h +// +// 3 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 2/04/10 12:03p Blaines +// EIP-28005 +// +// Added PostManagerSetAttribute to support display of text in color. +// Added support for handling string characters --- \n, \r. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 3/31/09 3:34p Madhans +// Hii string support for UEFI 2.0 or UEFI 2.1 +// +// 3 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: globals.c +// +// Description: file contains code to take care of the globals in boot only +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +PROGRESSBAR_INFO *gProgress; + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL +EFI_GRAPHICS_OUTPUT_PROTOCOL *gGOP = NULL; +#else +EFI_UGA_DRAW_PROTOCOL *gUgaDraw = NULL; +#endif //SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + +#ifndef STANDALONE_APPLICATION +EFI_CONSOLE_CONTROL_PROTOCOL *gConsoleControl = NULL; +#endif //STANDALONE_APPLICATION + +SCREEN_BUFFER *gActiveBuffer; +SCREEN_BUFFER *gFlushBuffer; + +EFI_HANDLE gImageHandle; +VOID* gHiiHandle; + +BOOLEAN gPostMsgProtocolActive = TRUE; +BOOLEAN gSetupContextActive = FALSE; +UINT8 gPostMgrAttribute = 0; + +#if 0 +// This adds no code space but allows the StrGather utility to know that these tokens are used +STRING_TOKEN(STR_MAIN_TITLE); +STRING_TOKEN(STR_MAIN_COPYRIGHT); +STRING_TOKEN(STR_HELP_TITLE); +STRING_TOKEN(STR_EVAL_MSG); +#endif // 0 + +UINT8 *gApplicationData; + +#ifdef USE_DEPRICATED_INTERFACE +UINT8 *STRING_ARRAY_NAME; +#endif //USE_DEPRICATED_INTERFACE + +NVRAM_VARIABLE *gVariableList = NULL; +NVRAM_VARIABLE *gFailsafeDefaults = NULL; +NVRAM_VARIABLE *gOptimalDefaults = NULL; + +BOOLEAN gEnterSetup = FALSE; +BOOLEAN gEnterBoot = FALSE; +EFI_EVENT gKeyTimer = NULL; +EFI_EVENT gClickTimer = NULL; +UINT32 gPasswordType = AMI_PASSWORD_NONE; + +UINTN gPostStatus = TSE_POST_STATUS_BEFORE_POST_SCREEN; + +UINTN gMaxRows = MAX_ROWS; +UINTN gMaxCols = MAX_COLS; +UINTN gPostManagerHandshakeCallIndex = 0; + +#define EFI_DEFAULT_LEGACY_DEV_ORDER_VARIABLE_GUID \ + { 0x3c4ead08, 0x45ae, 0x4315, 0x8d, 0x15, 0xa6, 0x0e, 0xaa, 0x8c, 0xaf, 0x69 } + +#define EFI_DEFAULT_BOOT_ORDER_VARIABLE_GUID \ + { 0x45cf35f6, 0x0d6e, 0x4d04, 0x85, 0x6a, 0x03, 0x70, 0xa5, 0xb1, 0x6f, 0x53 } + +//EIP81581 Default driver order support +#define EFI_DEFAULT_DRIVER_ORDER_VARIABLE_GUID \ + { 0xde788bed, 0xb6e2, 0x4290, 0xbd, 0xc8, 0x2a, 0xbb, 0x65, 0xd6, 0x21, 0x78 } + +EFI_GUID EfiDefaultLegacyDevOrderGuid = EFI_DEFAULT_LEGACY_DEV_ORDER_VARIABLE_GUID; +EFI_GUID EfiDefaultBootOrderGuid = EFI_DEFAULT_BOOT_ORDER_VARIABLE_GUID; +EFI_GUID EfiDefaultDriverOrderGuid = EFI_DEFAULT_DRIVER_ORDER_VARIABLE_GUID; + +//Globals for Debug prints +UINT16 gDbgPrint = TSE_DEBUG_MESSAGES; +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** \ No newline at end of file diff --git a/EDK/MiniSetup/BootOnly/hiistring.c b/EDK/MiniSetup/BootOnly/hiistring.c new file mode 100644 index 0000000..7fab2ae --- /dev/null +++ b/EDK/MiniSetup/BootOnly/hiistring.c @@ -0,0 +1,251 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.c $ +// +// $Author: Arunsb $ +// +// $Revision: 5 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.c $ +// +// 5 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 9 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 4 12/02/10 2:33p Madhans +// [TAG] - EIP 48169 +// [Category]- Enhancement +// [Severity]- Mordarate +// [Symptom]- Code Cleanup and Compiler Warning need to resolved. +// [Rootcause] Warnings reported when we build AMI higher Warning level. +// [Solution]- 1. Fix the warnings and do the code cleanup. +// 2. Introduce proper checks. +// 3. change the popupSel.c to not change the Option/variable +// cache to default or first option +// when the variable cache is not matching with any of +// option. +// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c +// popuppassword.c popupsel.c +// expression.c hii.c parse.c +// +// 3 2/19/10 1:01p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 5 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 4 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 3 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 2 6/08/09 5:35p Madhans +// Functionality moved to CommonHelper. +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 3:34p Madhans +// Hii string support for UEFI 2.0 or UEFI 2.1 +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: hiistring.c +// +// Description: file contains code to handle the hii sting operations +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +#define VARIABLE_NAME_LENGTH 40 + +// +//---------------------------------------------------------------------------- +// Procedure: HiiFindStrPrintBoundary +// +// Description: function to check the boundary of the print stirng. +// Find out the index of the character from where the print boundry will be met +// +// Input: IN CHAR16 *String, IN UINTN PrintWidth +// +// Output: count +// +//---------------------------------------------------------------------------- +// +UINTN HiiFindStrPrintBoundary ( IN CHAR16 *String, IN UINTN PrintWidth ) +{ + UINTN Length = 0; + UINT16 Count = 0; + CHAR16 TempString[10]; + + while (String[Count]) { + TempString[0] = String[Count]; + TempString[1] = 0; + + if((Length + TestPrintLength(TempString) / NG_SIZE) > PrintWidth) + break; + + Length += TestPrintLength(TempString) / NG_SIZE; + + Count++; + } + return Count; +} + +// +//---------------------------------------------------------------------------- +// Procedure: IsCharWide +// +// Description: function to check the given character is wide +// +// Input: CHAR16 strWide +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +UINTN IsCharWide( CHAR16 strWide) +{ + UINTN Length = 0; + CHAR16 TempString[10]; + + TempString[0] = strWide; + TempString[1] = 0; + Length = 0; + Length = TestPrintLength( TempString ) / (NG_SIZE); + if(2 == Length) + return TRUE; + else + return FALSE; +} + +CHAR16 *HiiGetString( VOID* handle, UINT16 token ) +{ + if(INVALID_TOKEN != token) + return HiiGetStringLanguage( handle, token, NULL ); + else + return NULL; +} + +// +//---------------------------------------------------------------------------- +// Procedure: HiiAddString +// +// Description: function to add a string +// +// Input: VOID* handle, CHAR16 *string +// +// Output: token +// +//---------------------------------------------------------------------------- +// + +UINT16 HiiAddString( VOID* handle, CHAR16 *string ) +{ + UINT16 token = 0; + + if(ItkSupport()) + { + token = HiiChangeStringLanguage( handle, 0, gLanguages[0].Unicode, string ); + } + else + { + UINT16 FirstToken; + UINTN i, j; + + FirstToken = token = HiiChangeStringLanguage( handle, 0, gLanguages[0].Unicode, string ); + if ( token == INVALID_TOKEN ) + return token; + for ( j = 0, i = 1; i < gLangCount; i++ ) + { + if ( i != j ) + token = HiiChangeStringLanguage( handle, token, gLanguages[i].Unicode, string ); + if ( token == INVALID_TOKEN ) + { + token = HiiChangeStringLanguage( handle, 0, gLanguages[i].Unicode, string ); + if ( token == INVALID_TOKEN ) + return FirstToken; //token; + j = i; + i = 0; + } + } + } + return token; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiTestPrintLength +// +// Description: function to get the printable lenght of the string +// +// Input: CHAR16 *string +// +// Output: Size of string +// +//---------------------------------------------------------------------------- +// +UINTN EfiTestPrintLength ( IN CHAR16 *String ) +{ + UINTN Size; + + if(String == NULL) + return 0; + + String = (UINT16* )TseSkipEscCode(String); + Size = (EfiStrLen(String) * NG_SIZE); + gBS->FreePool( String ); + return Size; +} +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + diff --git a/EDK/MiniSetup/BootOnly/hiistring.h b/EDK/MiniSetup/BootOnly/hiistring.h new file mode 100644 index 0000000..ab76d7c --- /dev/null +++ b/EDK/MiniSetup/BootOnly/hiistring.h @@ -0,0 +1,153 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.h $ +// +// $Author: Premkumara $ +// +// $Revision: 8 $ +// +// $Date: 8/28/14 5:30a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.h $ +// +// 8 8/28/14 5:30a Premkumara +// EIP-135253 Updating file name proper in #include +// +// 7 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 12 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 6 6/17/10 2:59p Madhans +// Dynamic parsing support in TSE. +// +// 5 2/26/10 8:53p Madhans +// For TSE 2.01.1024. refer changelog.log for file checkin history . +// +// 8 2/26/10 1:30p Madhans +// To avoid build issues with EDK. +// +// 7 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 6 1/09/10 5:13a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 5 1/04/10 10:40a Mallikarjunanv +// EIPs 27161/29095 - Added support for reserved boot option names and +// added support not to create empty boot option names +// +// 4 8/17/09 12:19p Presannar +// Removed References to Tiano.h +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:11p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 3:34p Madhans +// Hii string support for UEFI 2.0 or UEFI 2.1 +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +// 1 9/17/08 7:57p Madhans +// Boot Only driver after file split. +// +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: hiistring.h +// +// Description: Header file for code to handle the hii sting operations +// +//---------------------------------------------------------------------------- +// + +#ifndef _AMIHIISTRING_H_ // DO NOT CHANGE THIS TO _HII_H_ !! That is used by the HII Protocol header +#define _AMIHIISTRING_H_ + +#ifdef TSE_FOR_APTIO_4_50 +#include "Token.h" +#else +#include "tokens.h" +#endif + +#if TSE_USE_EDK_LIBRARY +#include "Tiano.h" +#else +#include "Efi.h" +#endif + + +#define INVALID_HANDLE ((VOID*)(UINTN)-1) +#define INVALID_TOKEN ((UINT16)-1) + + +UINT16 HiiAddString( /*EFI_HII_HANDLE*/VOID* handle, CHAR16 *string ); +UINT16 HiiChangeStringLanguage( /*EFI_HII_HANDLE*/VOID * handle, UINT16 token, CHAR16 *lang, CHAR16 *string ); +CHAR16 *HiiGetStringLanguage( /*EFI_HII_HANDLE*/VOID * handle, UINT16 token, CHAR16 *lang ); +CHAR16 *GetVariableNameByID( UINT32 VariableID ); +CHAR16 *GetGUIDNameByID( UINT32 VariableID ); + +UINTN HiiFindStrPrintBoundary ( IN CHAR16 *String, IN UINTN PrintWidth ); +UINTN IsCharWide( CHAR16 strWide); + +CHAR16 *SkipEscCode(CHAR16 *String); +CHAR16 *GetLanguageVariableName(); +UINTN HiiGetGlyphWidth(VOID); +UINTN HiiGetGlyphHeight(VOID); +EFI_STATUS GetUnicodeCollection2Protocol(VOID **Protocol); +EFI_STATUS GetUnicodeCollectionProtocol(VOID **Protocol); +EFI_STATUS InitUnicodeCollectionProtocol(VOID **Protocol); +BOOLEAN MetaiMatch(VOID *Protocol,IN CHAR16 *String,IN CHAR16 *Pattern); +INTN StringColl(VOID *Protocol,IN CHAR16 *String1,IN CHAR16 *String2); + +#endif /* _AMIHIISTRING_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/logo.c b/EDK/MiniSetup/BootOnly/logo.c new file mode 100644 index 0000000..5000447 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/logo.c @@ -0,0 +1,1163 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/logo.c $ +// +// $Author: Premkumara $ +// +// $Revision: 29 $ +// +// $Date: 12/04/13 5:22a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/logo.c $ +// +// 29 12/04/13 5:22a Premkumara +// [TAG] EIP123535 +// [Category] Improvement +// [Description] Moved saving quietboot resolution to DrawQuietBootLogo() +// to avoid setting resolution of initPostScreenthis while booting. +// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c +// +// 28 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 14 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 26 9/18/12 12:50a Rajashakerg +// [TAG] EIP95518 +// [Category] Improvement +// [Description] Validate the Gop before usage in all the possible cases +// and also get instance of Gop through notification +// [Files] boot.c, notify.c, logo.c +// +// 25 9/17/12 6:10a Rajashakerg +// Updated EIP changes for 2.16 release. +// +// 23 8/29/12 4:22p Arunsb +// [TAG] EIP94702 +// [Description] Support for Native Resolution in POST/BOOT +// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c, +// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c, +// ezportplus/stylecommon.c andlegacy/stylecommon.c +// +// 22 5/29/12 4:25a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 21 5/25/12 1:42a Premkumara +// [TAG] EIP88430 +// [Category] Improvement +// [Description] Resolution set after logo displayed should retain when +// boot to device. +// [Files] boot.c, logo.c +// +// 20 4/27/12 1:46a Premkumara +// [TAG] EIP88527 +// [Category] Improvement +// [Description] Implement BGRT logo calculation based on Windows-8 +// [Files] CommonHelper.c, Logo.c +// +// 19 9/16/11 6:42a Arunsb +// [TAG] EIP69171 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] POST Logo 1024x768 not displayed properly +// [RootCause] Mode not set properly +// [Solution] Mode set properly +// [Files] BootOnly\logo.c +// +// 18 7/01/11 3:28a Arunsb +// Header corrected for chm file creation +// +// 17 6/30/11 4:37a Arunsb +// If Jpeg off and Bmp on, Jpeg image unsuccess to draw on the screen +// clearing the +// drawm bmp image. +// Fixed this issue. +// +// 16 6/29/11 10:08a Arunsb +// [TAG] EIP58954 +// [Category] Improvement +// [Description] BGRT status field is cleared when setup key is +// intervented for +// setup launch while in quiet boot. +// [Files] bootonly\logo.c and postmgmt.c +// +// 15 6/22/11 9:15a Premkumara +// [TAG] EIP60048 +// [Category] Improvement +// [Description] TSE should Change the System Resolution according to +// the Quite Logo Size +// [Files] CommonHelper.c, AMITSE.sdl, Logo.c, LogoLib.h +// +// 14 5/31/11 7:21p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Quiet boot logos only added for BGRT. BGRT status +// field cleared if any changes happened in screen other than displaying +// the images. BltBuffer freed in ConvertBlt2Bmp function. +// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and +// commonhelper.c +// +// 13 5/29/11 12:07p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Quiet boot logo's only added for BGRT. BGRT status +// field cleared if any changes happened in screen other than displaying +// the image. +// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and +// commonhelper.c +// +// 12 5/13/11 2:35p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Contributing BGRT table to ACPI table. Image blt formed +// with the coordinates drawn onto the screen. +// [Files] Postmgmt.c, commonoem.c,logo.c and commonhelper.c +// +// 11 5/04/11 5:08p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Contributing BGRT table to ACPI table. +// CONTRIB_BGRT_TABLE_TO_ACPI token added. Wrapper function +// ContribBGRTTableToAcpi added. +// [Files] Postmgmt.c, commonoem.c,logo.c and commonhelper.c +// +// 10 5/03/11 9:53p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Contributing BGRT table to ACPI +// table.CONTRIB_BGRT_TABLE_TO_ACPI token added. EDK Build support added. +// [Files] Postmgmt.c, commonoem.c and commonhelper.c +// +// 9 4/29/11 4:43p Madhans +// [TAG] EIP59177 +// [Category] Improvement +// [Description] Support for JPEG with RSI markers. Fix to support logo +// size that bigger then Screen resolution. +// [Files] Logo.c +// Jpeg6.c +// commonHelper.c +// +// 8 4/04/11 10:30a Arunsb +// GetGraphicsBitMapFromFV function moved to commonhelper.c +// +// 7 12/29/10 2:25a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] After the notification, if the graphics driver +// uninstalled and reinstalled from core module then gGOP getting +// corrupted. +// [Solution] Updated gGop before using it in AMITSE. +// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c +// +// 5 4/21/10 12:01p Madhans +// Tse 2.02 +// +// 4 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 7 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 6 1/09/10 5:14a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 5 12/04/09 7:13a Mallikarjunanv +// Fix for EIP:30263 - Gif Logo Issue +// +// 4 8/13/09 12:14p Blaines +// Move Image support to binary module +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 3:37p Madhans +// Cleanup +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: logo.c +// +// Description: file contains code to handle the logo operations. +// Taken from graphics.c to eliminnate library dependancy +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" +#include "EdidActive.h" + +// to retrieve the frame coordinates in case different frames in a image +UINT16 gGifSrcX=0; +UINT16 gGifSrcY=0; +UINT16 gGifDestX=0; +UINT16 gGifDestY=0; +BOOLEAN GifImageFlag = 0; + +#define TSE_ABS(a,b) (((a) < (b)) ? ((b) - (a)) : ((a) - (b))) + +extern LOGO_TYPE GetBmpLogoType(UINT8 *ImageData); + +extern EFI_STATUS ConvertBmpToUgaBltWrapper (IN VOID *BmpImage, IN UINTN BmpImageSize, IN OUT VOID **UgaBlt, + IN OUT UINTN *UgaBltSize, OUT UINTN *PixelHeight, OUT UINTN *PixelWidth ); + +VOID *ConvertBlt2Bmp (); +VOID AddImageDetailToACPI (UINT8 *, INTN, INTN, BOOLEAN); +UINT8 gAddBgrtResolutions = 0; +VOID SetGetBgrtCoordinates ( + UINTN *DestX, + UINTN *DestY, + UINTN *Width, + UINTN *Height, + BOOLEAN Command + ); +VOID InvalidateStatusInBgrtWrapper (VOID); +BOOLEAN IsBGRTSupported(VOID); //EIP-88527 + + +LOGO_TYPE GetLogoType(UINT8 *ImageData) +{ + if ( BMP_Logo == GetBmpLogoType(ImageData)) + return BMP_Logo; + + return Unsupported_Logo; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CleanUpLogo +// +// Description: function to Clear all the logo buffers. +// +// Input: nil +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID CleanUpLogo() +{ + CleanUpExtendedLogoWrapper(); + InvalidateStatusInBgrtWrapper (); //Setup key detected so clearing the status field +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetScreenResolution +// +// Description: function to set the screen resolutions. +// +// Input: UINTN ResX, UINTN ResY +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS SetScreenResolution(UINTN ResX, UINTN ResY) +{ + EFI_STATUS Status; + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + UINT32 i; + UINTN SizeOfInfo; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *pModeInfo; + + if( gGOP == NULL ) + return EFI_UNSUPPORTED; + + for(i=0;iMode->MaxMode;i++) + { + Status = gGOP->QueryMode(gGOP,i,&SizeOfInfo,&pModeInfo); + if((EFI_SUCCESS == Status) && SizeOfInfo) + { + if((ResX == pModeInfo->HorizontalResolution) && + (ResY == pModeInfo->VerticalResolution)) + { + //Set to this mode + Status = gGOP->SetMode(gGOP,i); + return Status; + } + } + } + + return EFI_UNSUPPORTED; +#else + UINT32 ColorDepth, RefreshRate; + UINTN CurrResX, CurrResY; + + if ( gUgaDraw == NULL ) + return EFI_UNSUPPORTED; + + Status = gUgaDraw->GetMode( gUgaDraw, (UINT32 *)(&CurrResX), (UINT32 *)(&CurrResY), &ColorDepth, &RefreshRate ); + + if(EFI_SUCCESS == Status) + Status = gUgaDraw->SetMode( gUgaDraw, (UINT32)ResX, (UINT32)ResY, ColorDepth, RefreshRate ); + + return Status; +#endif +} + +//EIP60048 starts +// +//---------------------------------------------------------------------------------------------- +// Procedure: GOPSetScreenResolution +// +// Description: Sets the mode which approximately fits the current image resolution +// +// Input: UINTN *, UINTN * -> Pointer to the width and height of the image to be drawn +// +// Output: EFI_STATUS -> Status for the operation +// +//---------------------------------------------------------------------------------------------- +// +EFI_STATUS GOPSetScreenResolution (UINTN *Width, UINTN *Height) +{ + UINT32 i=0, Index = 0; + UINTN DiffXY = 0, ResXY = 0; + UINTN SizeOfInfo; + BOOLEAN ResXYSet = FALSE; + EFI_STATUS Status; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *pModeInfo; + + if( NULL == gGOP ) + return EFI_UNSUPPORTED;//EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification + //Find proper mode to fit image + for (i=0;iMode->MaxMode;i++) + { + Status = gGOP->QueryMode (gGOP,i,&SizeOfInfo,&pModeInfo); + if ((EFI_SUCCESS == Status) && SizeOfInfo) + { + DiffXY = TSE_ABS(*Width , pModeInfo->HorizontalResolution) + TSE_ABS(*Height , pModeInfo->VerticalResolution); + if ((ResXY || ResXYSet) ? (DiffXY <= ResXY) : (ResXY <= DiffXY)) //EIP69171, Mode not set properly + { + Index = i; + ResXY = DiffXY; + ResXYSet = TRUE; + } + } + } + gGOP->SetMode (gGOP, Index); + Status = GOPSetScreenResolutionHook (Width, Height, Index); + return Status; +} +//EIP60048 Ends + +// +//---------------------------------------------------------------------------- +// Procedure: GetScreenResolution +// +// Description: function to get the screen resolutions. +// +// Input: UINTN *ResX, UINTN *ResY +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS GetScreenResolution(UINTN *ResX, UINTN *ResY) +{ +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if( gGOP == NULL ) + return EFI_UNSUPPORTED; + *ResX = gGOP->Mode->Info->HorizontalResolution; + *ResY = gGOP->Mode->Info->VerticalResolution; + return EFI_SUCCESS; +#else + UINT32 ColorDepth, RefreshRate; + + if ( gUgaDraw == NULL ) + return EFI_UNSUPPORTED; + return gUgaDraw->GetMode( gUgaDraw, (UINT32 *)ResX, (UINT32 *) ResY, &ColorDepth, &RefreshRate ); +#endif +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawImage +// +// Description: function to draw a image +// +// Input: UINT8 *ImageData, UINTN ImageSize, CO_ORD_ATTRIBUTE Attribute, +// INTN CoordinateX, INTN CoordinateY, BOOLEAN AdjustScreenResolution, +// UINTN *Width, UINTN *Height +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +DrawImage( + IN UINT8 *ImageData, + IN UINTN ImageSize, + IN CO_ORD_ATTRIBUTE Attribute, + IN INTN CoordinateX, + IN INTN CoordinateY, + IN BOOLEAN AdjustScreenResolution, + OUT UINTN *Width, + OUT UINTN *Height +) +{ + + EFI_STATUS Status; + UINTN SizeOfX, SizeOfY; + UINTN UgaBltSize=0; + UINTN unBufferWidth=0; + UINTN LogoType; + BOOLEAN Animate = FALSE; + + EFI_UGA_PIXEL *UgaBlt = NULL; + + *Height = *Width = 0; + UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE. + Status = GetScreenResolution(&SizeOfX, &SizeOfY); + if ( EFI_ERROR(Status) ) + return Status; + + LogoType = GetLogoType(ImageData); + switch(LogoType) + { + + case BMP_Logo: + Status = ConvertBmpToUgaBltWrapper( + ImageData, + ImageSize, + &UgaBlt, + &UgaBltSize, + Height, + Width ); + unBufferWidth = *Width; + break; + + case Unsupported_Logo: + default: + + Status = ConvertAdvancedImageToUgaBlt( + ImageData, + ImageSize, + &UgaBlt, + &UgaBltSize, + Height, + Width, + &Animate); + unBufferWidth = *Width; + + + break; + } + + if( EFI_ERROR(Status) ) + { +// CleanUpLogo(); //If Jpeg off bmp on, jpeg image unsuccess clearing the drawn bmp image so commented. + return Status; + } + + if(AdjustScreenResolution) + { + //If the image is bigger than the current resolution + //then try to set resolution to fit the image + if((*Width > SizeOfX) || (*Height > SizeOfY)) + { +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + Status = GOPSetScreenResolution (Width, Height); //EIP69171, Always check to suite the best resolution + +#else + UINT32 NewSizeOfX = 0; + UINT32 NewSizeOfY = 0; + + if((*Width > 1024) || (*Height > 768)) + { + // Set to max resolution available ie 1024 x 768 + NewSizeOfX = 1024; NewSizeOfY = 768; + } + else if((*Width > 800) || (*Height > 600)) + { + //Set to 1024 x 768 + NewSizeOfX = 1024; NewSizeOfY = 768; + } + else if((*Width > 640) || (*Height > 480)) + { + //Set to 800 x 600 + NewSizeOfX = 800; NewSizeOfY = 600; + } + + if(NewSizeOfX) + { + SetScreenResolution(NewSizeOfX,NewSizeOfY); + } +#endif + GetScreenResolution (&SizeOfX,&SizeOfY); + } + } + DrawBltBuffer (UgaBlt, Attribute, *Width, *Height, CoordinateX, CoordinateY, unBufferWidth); + if(Animate) + { + DoLogoAnimate(Attribute,CoordinateX,CoordinateY); + } + else + { + //MemFreePointer( (VOID **)&ImageData ); //eip 36596 - image data will be freed in the calling function. + MemFreePointer( (VOID **)&UgaBlt ); + } + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBltProgressBar +// +// Description: function to draw a progress bar +// +// Input: nil +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawBltProgressBar() +{ +#ifndef STANDALONE_APPLICATION + + UINTN x = gProgress->x ; + UINTN y = gProgress->y ; + UINTN w = gProgress->w ; + UINTN h = gProgress->h ; + UINTN delta = gProgress->delta ; + gProgress->completed+=delta ; + + if(gProgress->quiteBootActive && (gProgress->completed <= w)) + { + DrawBlock(x, y, w, h, gProgress->backgroundColor) ; //draw background + DrawBlock(x, y, gProgress->completed, h, gProgress->fillColor) ; //draw progression + DrawProgressBarBorder(x, y, w, h, gProgress->borderColor, 2) ; //draw border + } +#endif +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawProgressBarBorder +// +// Description: function to draw the border of a progress bar +// +// Input: UINTN DestX, UINTN DestY, UINTN Width, UINTN Height, +// EFI_UGA_PIXEL *BltBuffer, UINTN bw +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawProgressBarBorder( + UINTN x, + UINTN y, + UINTN w, + UINTN h, + EFI_UGA_PIXEL *BltBuffer, + UINTN bw + ) +{ +#ifndef STANDALONE_APPLICATION + //Top + DrawBlock(x, y, w, bw, BltBuffer) ; + //Bottom + DrawBlock(x, y+h-bw, w, bw, BltBuffer) ; + //Left + DrawBlock(x, y, bw, h, BltBuffer) ; + //Right + DrawBlock(x+w-bw, y, bw, h, BltBuffer) ; +#endif +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBlock +// +// Description: function to draw draw a block +// +// Input: UINTN DestX, UINTN DestY, UINTN Width, UINTN Height, EFI_UGA_PIXEL *BltBuffer +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawBlock( + UINTN x, + UINTN y, + UINTN w, + UINTN h, + EFI_UGA_PIXEL *BltBuffer + ) +{ +#ifndef STANDALONE_APPLICATION + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if ( gQuietBoot && gGOP) +#else + if ( gQuietBoot && gUgaDraw) +#endif + { +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + gGOP->Blt ( + gGOP, + BltBuffer, + EfiBltVideoFill, + 0, 0, + x, y, + w, h, + 0 /*BufferWidth * sizeof (EFI_UGA_PIXEL)*/ + ); +#else + gUgaDraw->Blt ( + gUgaDraw, + BltBuffer, + EfiBltVideoFill, + 0, 0, + x, y, + w, h, + 0 /*BufferWidth * sizeof (EFI_UGA_PIXEL)*/ + ); +#endif + } +#endif +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBltBuffer +// +// Description: function to draw draw a block +// +// Input: EFI_UGA_PIXEL *UgaBlt, CO_ORD_ATTRIBUTE Attribute, +// UINTN Width, UINTN Height, INTN DestX, INTN DestY, +// UINTN BufferWidth +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawBltBuffer( + EFI_UGA_PIXEL *UgaBlt, + CO_ORD_ATTRIBUTE Attribute, + UINTN Width, + UINTN Height, + INTN DestX, + INTN DestY, + UINTN BufferWidth + ) +{ + UINTN SizeOfX=0, SizeOfY=0; + UINTN SourceX=0, SourceY=0; + + GetScreenResolution(&SizeOfX,&SizeOfY); + // In case of gif set the frame position + if(GifImageFlag) { + SourceX = gGifSrcX; + SourceY = gGifSrcY; + } + switch(Attribute) + { + case CA_AttributeLeftTop: + //Need to alter DestX and DestY based on the image descriptor. + if(GifImageFlag) { + DestX = SourceX; + DestY = SourceY; + } + //No need to alter DestX and DestY + break; + + case CA_AttributeCenterTop: + DestX = ((INTN)(SizeOfX - Width)) / 2; + //DestY need not be altered + break; + + case CA_AttributeRightTop: + DestX = (INTN)(SizeOfX - Width - DestX); + //DestY need not be altered + break; + + case CA_AttributeRightCenter: + DestX = (INTN)(SizeOfX - Width - DestX); + DestY = ((INTN)(SizeOfY - Height))/2; + break; + + case CA_AttributeRightBottom: + DestX = (INTN)(SizeOfX - Width - DestX); + DestY = (INTN)(SizeOfY - Height - DestY); + break; + + case CA_AttributeCenterBottom: + DestX = ((INTN)(SizeOfX - Width))/2; + DestY = (INTN)(SizeOfY - Height - DestY); + break; + + case CA_AttributeLeftBottom: + //DestX need not be altered + DestY = (INTN)(SizeOfY - Height - DestY); + break; + + case CA_AttributeLeftCenter: + //DestX need not be altered + DestY = ((INTN)(SizeOfY - Height))/2; + break; + + case CA_AttributeCenter: + // in case of gif, set the video display positions based on the image frame position. + if(GifImageFlag) { + DestX = ((INTN)(SizeOfX - Width))/2 + SourceX; + DestY = ((INTN)(SizeOfY - Height))/2 + SourceY; + } + //EIP-88527 Logo should be 40% of sreen dimension + else if (IsBGRTSupported() && ( Width <= (((UINTN)(40 *SizeOfX))/100) ) && ( Height <= (((UINTN)(40 *SizeOfY))/100) )) + { + DestX = ((INTN)(SizeOfX - Width))/2; //Exact center of x-axis + DestY = (((INTN)(SizeOfY*382))/1000) - ((INTN)Height/2);//Center of logo is 38.2% from the top of screen + } + else + { + DestX = ((INTN)(SizeOfX - Width))/2; + DestY = ((INTN)(SizeOfY - Height))/2; + } + + break; + + default: + //DestX and DestY remains as it is + break; + } + + //Fill the video based on image frame descriptor values + if(GifImageFlag) { + Width = gGifDestX; + Height = gGifDestY; + } + + if( DestX < 0 ) + { + SourceX = (-(DestX)); + DestX = 0; + } + + if( DestY < 0 ) + { + SourceY = (-(DestY)); + DestY = 0; + } + + // Fix to show Logo images correctly when it is bigger then screen resolution. + if((DestX + (Width - SourceX)) > SizeOfX) + Width = (SizeOfX - DestX); + + if((DestY + (Height - SourceY)) > SizeOfY) + Height = (SizeOfY - DestY); + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if ( gGOP) + gGOP->Blt ( + gGOP, + UgaBlt, + EfiBltBufferToVideo, + SourceX, SourceY, + (UINTN)DestX, (UINTN)DestY, + Width, Height, + BufferWidth * sizeof (EFI_UGA_PIXEL) + ); +#else + if ( gUgaDraw) + gUgaDraw->Blt ( + gUgaDraw, + UgaBlt, + EfiUgaBltBufferToVideo, + SourceX, SourceY, + (UINTN)DestX, (UINTN)DestY, + Width, Height, + BufferWidth * sizeof (EFI_UGA_PIXEL) + ); +#endif + if (gAddBgrtResolutions) + { + SetGetBgrtCoordinates (&DestX, &DestY, &Width, &Height, TRUE); //1 for set the value + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: ConvertBlt2Bmp +// +// Description: Converts the Blt in the screen to Bmp buffer +// +// Input: VOID +// +// Output: VOID * +// +//---------------------------------------------------------------------------- +// +VOID *ConvertBlt2Bmp (VOID) +{ + BMP_IMAGE_HEADER BmpHeaderStruct = { + 'B', // CHAR8 CharB; + 'M', // CHAR8 CharM; + 0, // UINT32 Size; // Dynamic + {0,0}, // UINT16 Reserved[2]; + 0x36, // UINT32 ImageOffset; + 0x28, // UINT32 HeaderSize; + 0, // UINT32 PixelWidth; // Dynamic + 0, // UINT32 PixelHeight; // Dynamic + 1, // UINT16 Planes; // Must be 1 + 0x18, // UINT16 BitPerPixel; // 1, 4, 8, or 24 + 0, // UINT32 CompressionType; + 0, // UINT32 ImageSize; // // Dynamic + 0, // UINT32 XPixelsPerMeter; + 0, // UINT32 YPixelsPerMeter; + 0, // UINT32 NumberOfColors; + 0, // UINT32 ImportantColors; + + }; + BMP_IMAGE_HEADER *BmpBuffer=NULL; + UINT32 i=0,j=0; + UINT8 *Image; + UINTN ImageIndex; + UINTN AllignWidth = 0; + UINTN SourceX = 0, SourceY = 0; + UINTN Width = 0, Height = 0; + EFI_STATUS Status = EFI_SUCCESS; + EFI_UGA_PIXEL *BltBuffer; + + SetGetBgrtCoordinates (&SourceX, &SourceY, &Width, &Height, FALSE); //Get the BGRT logo resolutions +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if(gGOP) + { + BltBuffer = EfiLibAllocateZeroPool (Width * Height * sizeof (EFI_UGA_PIXEL)); + if (NULL == BltBuffer) + { + return NULL; + } + Status = gGOP->Blt ( + gGOP, + BltBuffer, + EfiBltVideoToBltBuffer, + SourceX, SourceY, + 0, 0, + Width, Height, + 0); + if (EFI_SUCCESS != Status) + { + MemFreePointer ((VOID **)&BltBuffer); + return NULL; + } + } +#else + if (gUgaDraw) + { + BltBuffer = EfiLibAllocateZeroPool (Width * Height * sizeof (EFI_UGA_PIXEL)); + if (NULL == BltBuffer) + { + return NULL; + } + Status = gUgaDraw->Blt ( + gUgaDraw, + BltBuffer, + EfiUgaVideoToBltBuffer, + SourceX, SourceY, + 0, 0, + Width, Height, + 0); + if (EFI_SUCCESS != Status) + { + MemFreePointer ((VOID **)&BltBuffer); + return NULL; + } + } +#endif + else + { + return NULL; + } + AllignWidth = Width; + if (Width%4 != 0) + { + AllignWidth += Width%4; //Width should be 4 bytes alligned + } + BmpHeaderStruct.ImageSize = (UINT32)(3*AllignWidth*Height); + BmpHeaderStruct.Size = sizeof (BmpHeaderStruct)+ BmpHeaderStruct.ImageSize; + BmpBuffer = EfiLibAllocateZeroPool (BmpHeaderStruct.Size); + if (BmpBuffer) + { + BmpHeaderStruct.PixelWidth = (UINT32)Width; + BmpHeaderStruct.PixelHeight = (UINT32)Height; + + gBS->CopyMem(BmpBuffer,&BmpHeaderStruct,sizeof(BmpHeaderStruct)); + Image = (UINT8*)BmpBuffer; + Image += BmpBuffer->ImageOffset; + + for(i=(UINT32)(Width*Height);i;i-=BmpHeaderStruct.PixelWidth) + { + for(j=BmpHeaderStruct.PixelWidth;j;j--) + { + *Image++ = BltBuffer[i-j].Blue; + *Image++ = BltBuffer[i-j].Green; + *Image++ = BltBuffer[i-j].Red; + } + ImageIndex = (UINTN) (Image - BmpBuffer->ImageOffset); + if ((ImageIndex % 4) != 0) // Bmp Image starts each row on a 32-bit boundary! + Image = Image + (4 - (ImageIndex % 4)); + } + MemFreePointer ((VOID **)&BltBuffer); + return (VOID*)BmpBuffer; + } + MemFreePointer ((VOID **)&BltBuffer); + return NULL; +} + +// +//------------------------------------------------------------------------------------------------------- +// Procedure: ConvertBmpandAddBGRT +// +// Description: Converts Blt to Bmp buffer and form BGRT table and add to ACPI. +// +// Input: BOOLEAN = Indicates whether to set the BGRT status field or not. +// +// Output: VOID +// +//-------------------------------------------------------------------------------------------------------- +// +VOID ConvertBmpandAddBGRT ( + BOOLEAN GifImagePresence + ) +{ + VOID *BmpData = NULL; + BmpData = ConvertBlt2Bmp (); + if (BmpData) + { + UINTN DestX = 0, DestY = 0, Width = 0, Height = 0; + SetGetBgrtCoordinates (&DestX, &DestY, &Width, &Height, FALSE); //Get the Bgrt logo resolution + AddImageDetailToACPI (BmpData, DestX, DestY, GifImagePresence); + } +} + +// +//------------------------------------------------------------------------------------------------------- +// Procedure: SetGetBgrtCoordinates +// +// Description: Sets the BGRT logo coordinates +// +// Input: UINTN *DestX = X coordinate +// UINTN *DestY = Y coordinate +// UINTN *Width = Width of the logo +// UINTN *Height = Heigth of the logo +// BOOLEAN Command = To set or get the Bgrt logo resolutions +// +// Output: VOID +// +//-------------------------------------------------------------------------------------------------------- +// +VOID SetGetBgrtCoordinates ( + UINTN *DestX, + UINTN *DestY, + UINTN *Width, + UINTN *Height, + BOOLEAN Command + ) +{ + static UINTN gBgrtStartResX = 0; + static UINTN gBgrtStartResY = 0; + static UINTN gBgrtEndResX = 0; + static UINTN gBgrtEndResY = 0; + + if (FALSE == Command) //To get the Bgrt logo resolution + { + *DestX = gBgrtStartResX; + *DestY = gBgrtStartResY; + *Width = gBgrtEndResX - gBgrtStartResX; + *Height = gBgrtEndResY - gBgrtStartResY; + } + else + { + if (1 == gAddBgrtResolutions) //At first time initialize the values + { + gBgrtStartResX = *DestX; + gBgrtStartResY = *DestY; + gBgrtEndResX = *DestX + *Width; + gBgrtEndResY = *DestY + *Height; + } + else + { + if (*DestX < gBgrtStartResX) + { + gBgrtStartResX = *DestX; + } + if (*DestY < gBgrtStartResY) + { + gBgrtStartResY = *DestY; + } + if (gBgrtEndResX < (*DestX + *Width)) + { + gBgrtEndResX = (*DestX + *Width); + } + if (gBgrtEndResY < (*DestY + *Height)) + { + gBgrtEndResY = (*DestY + *Height); + } + } + gAddBgrtResolutions ++; + } +} + +//EIP94702 starts +// +//------------------------------------------------------------------------------------------------------- +// Procedure: SetGraphicsResolution +// +// Description: Sets the graphical resolution corresponding to the input parameter +// +// Input: UINT32 - Horizontal resolution of the mode to set +// UINT32 - Vertical resolution of the mode to set +// +// Output: EFI_STATUS - EFI_SUCCESS - If input resolutions are set successfully +// !EFI_SUCCESS - If input resolutions are not set successfully +// +//-------------------------------------------------------------------------------------------------------- +// +EFI_STATUS SetGraphicsResolution (UINT32 HorResolution, UINT32 VerResolution) +{ + EFI_STATUS Status = EFI_SUCCESS; + UINT32 iIndex = 0; + UINTN SizeOfInfo = 0; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *pModeInfo = NULL; + + for (iIndex = 0; iIndex < gGOP->Mode->MaxMode; iIndex ++) + { + Status = gGOP->QueryMode (gGOP, iIndex, &SizeOfInfo, &pModeInfo); + if (!EFI_ERROR (Status)) + { + SETUP_DEBUG_TSE ("\n[TSE] pModeInfo HorizontalResolution=%d VerticalResolution=%d\n", pModeInfo->HorizontalResolution, pModeInfo->VerticalResolution); + if ((HorResolution == pModeInfo->HorizontalResolution) && (VerResolution == pModeInfo->VerticalResolution)) + { + if (gGOP->Mode->Mode != iIndex) //If Current mode not equals the found mode then call SetMode otherwise return success + { + SETUP_DEBUG_TSE ("\n[TSE] Setting %d Mode\n", iIndex); + Status = gGOP->SetMode (gGOP, iIndex); + if (!EFI_ERROR (Status)) //Loop for all the cases. Not success also loop for another without returning from here + { + return EFI_SUCCESS; + } + } + else + { + SETUP_DEBUG_TSE ("\n[TSE] Without Setting %d Mode\n", iIndex); + return EFI_SUCCESS; + } + } + } + } + return EFI_NOT_FOUND; +} + +// +//------------------------------------------------------------------------------------------------------- +// Procedure: SetNativeResFromEdid +// +// Description: Finds and sets the resolution from EDID +// +// Input: VOID +// +// Output: VOID +// +//-------------------------------------------------------------------------------------------------------- +// +EFI_STATUS SetNativeResFromEdid (VOID) +{ + EFI_STATUS Status; + UINT32 HorRes; + UINT32 VerRes; + EFI_EDID_ACTIVE_PROTOCOL *EdidActive; + EFI_GUID EdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID; + + Status = gBS->LocateProtocol (&EdidActiveProtocolGuid, NULL, &EdidActive); + if(EFI_ERROR(Status) || EdidActive->SizeOfEdid == 0) + { + SETUP_DEBUG_TSE ("\n[TSE] Edid active protocol fails \n"); + Status = SetGraphicsResolution (1024, 768); //If EDID not found set 1024*768 mode + return Status; + } + + if(!((EdidActive->Edid)[24] & BIT01)) + { + /* native resolution not supported */ + return EFI_UNSUPPORTED; + } + + HorRes = ((((EdidActive->Edid)[0x36 + 4]) & 0xF0) << 4) + (EdidActive->Edid)[0x36 + 2]; + VerRes = ((((EdidActive->Edid)[0x36 + 7]) & 0xF0) << 4) + (EdidActive->Edid)[0x36 + 5]; + + SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 4]); + SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 2]); + SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 7]); + SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 5]); + SETUP_DEBUG_TSE ("\n[TSE] EDID HorizontalResolution=%d VerticalResolution=%d\n", HorRes, VerRes); + + Status = SetGraphicsResolution (HorRes, VerRes); + if (EFI_ERROR(Status)) + { + SETUP_DEBUG_TSE ("\n[TSE] Setting 1024 * 768 Mode \n"); + Status = SetGraphicsResolution (1024, 768); //If EDID not found set 1024*768 mode + } + return Status; +} +//EIP94702 ends +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + diff --git a/EDK/MiniSetup/BootOnly/mem.c b/EDK/MiniSetup/BootOnly/mem.c new file mode 100644 index 0000000..6f68b25 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/mem.c @@ -0,0 +1,255 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/mem.c $ +// +// $Author: Arunsb $ +// +// $Revision: 5 $ +// +// $Date: 10/18/12 5:58a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/mem.c $ +// +// 5 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 4 11/10/11 12:52a Arunsb +// [TAG] EIP67735 +// [Category] Improvement +// [Description] Zeroing password buffers before freeing +// [Files] mem.c, mem.h, popupedit.c, popuppassword.c and tseadvanced.c +// +// 3 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 3:37p Madhans +// TSE_USE_EDK_LIBRARY +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: mem.c +// +// Description: file contains code to handle the memory operations. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: MemFreePointer +// +// Description: function to free the pointers +// +// Input: VOID **ptr +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID MemFreePointer( VOID **ptr ) +{ + if ( ( ptr == NULL ) || ( *ptr == NULL ) ) + return; + + gBS->FreePool( *ptr ); + *ptr = NULL; +} + +// +//----------------------------------------------------------------------------------------------- +// Procedure: StringZeroFreeMemory +// +// Description: Function to free the string pointers and zeroing its memory, used for strings +// Care should be taken String Length identification function is used +// +// Input: VOID **ptr +// +// Output: void +// +//------------------------------------------------------------------------------------------------- +// +VOID StringZeroFreeMemory (VOID **ptr) +{ + if ( (ptr == NULL) || (*ptr == NULL)) + return; + + MemSet (*ptr, (EfiStrLen ((CHAR16 *)*ptr) * sizeof (CHAR16)), 0); + gBS->FreePool (*ptr); + *ptr = NULL; +} +// +//---------------------------------------------------------------------------- +// Procedure: MemCopy +// +// Description: function to copy a memory +// +// Input: VOID *dest, VOID *src, UINTN size +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID MemCopy( VOID *dest, VOID *src, UINTN size ) +{ + gBS->CopyMem( dest, src, size ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: MemSet +// +// Description: function to set the memory with the specified value +// +// Input: VOID *buffer, UINTN size, UINT8 value +// +// Output: void +// +//---------------------------------------------------------------------------- +// +#if TSE_USE_EDK_LIBRARY +VOID MemSet( VOID *buffer, UINTN size, UINT8 value ) +{ + gBS->SetMem( buffer, size, value ); +} +#endif //#if TSE_USE_EDK_LIBRARY + +// +//---------------------------------------------------------------------------- +// Procedure: MemReallocateZeroPool +// +// Description: function to reuse a allocated buffer +// +// Input: VOID *oldBuffer, UINTN oldSize, UINTN newSize +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID *MemReallocateZeroPool( VOID *oldBuffer, UINTN oldSize, UINTN newSize ) +{ + VOID *buffer; + + buffer = EfiLibAllocateZeroPool( newSize ); + if ( buffer == NULL ) + return buffer; + + if ( newSize < oldSize ) + oldSize = newSize; + + if ( oldBuffer != NULL ) + MemCopy( buffer, oldBuffer, oldSize ); + + MemFreePointer( (VOID **)&oldBuffer ); + + return buffer; +} + +// +//---------------------------------------------------------------------------- +// Procedure: MemFillUINT16Buffer +// +// Description: function to fill a UINT16 Buffer +// +// Input: VOID *buffer, UINTN bufferSize, UINT16 value +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID MemFillUINT16Buffer( VOID *buffer, UINTN bufferSize, UINT16 value ) +{ + UINTN Index; + UINT16 *bufPtr = (UINT16 *)buffer; + + for ( Index = 0; Index < bufferSize; Index++ ) + *bufPtr++ = value; +} + +// +//---------------------------------------------------------------------------- +// Procedure: MemCmp +// +// Description: function to compare the memory of two buffers. +// +// Input: UINT8 *dest, UINT8 *src, UINTN size +// +// Output: 0/1/-1 +// +//---------------------------------------------------------------------------- +// +#if TSE_USE_EDK_LIBRARY +INTN MemCmp( UINT8 *dest, UINT8 *src, UINTN size ) +{ + UINTN i; + + for( i=0; i src[i]) + return 1; + } + return 0; +} +#endif //#if TSE_USE_EDK_LIBRARY + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/minisetup.c b/EDK/MiniSetup/BootOnly/minisetup.c new file mode 100644 index 0000000..ef499ff --- /dev/null +++ b/EDK/MiniSetup/BootOnly/minisetup.c @@ -0,0 +1,551 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2014, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.c $ +// +// $Author: Arunsb $ +// +// $Revision: 15 $ +// +// $Date: 5/08/14 9:16p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.c $ +// +// 15 5/08/14 9:16p Arunsb +// [TAG] EIP162981 +// [Category] Improvement +// [Description] Configuring default Password through SDL token. +// Made dependency with RT_ACCESS_SUPPORT_IN_HPKTOOL. +// +// 14 5/02/14 8:41a Premkumara +// [TAG] EIP162981 +// [Category] Improvement +// [Description] Configuring default Password through SDL token +// [Files] AMITSE.sdl, CommonHelper.c, Minisetup.c, TseAdvanced.c +// +// 13 5/01/14 4:05p Premkumara +// [TAG] EIP149734 +// [Category] Improvement +// [Description] Softkbd should not display in BBS menu +// [Files] Minisetup.c +// +// 12 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 13 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 10 6/25/12 5:39p Arunsb +// [TAG] EIP93524 +// [Category] Improvement +// [Description] Invalidate the BGRT table when boot device launched +// from BBS popup or from shell or launched as second boot device +// [Files] boot.c and minisetup.c +// +// 9 4/27/12 5:16a Rajashakerg +// [TAG] EIP82804 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] System hangs at password prompt when Administrator password +// set. +// [RootCause] When admin passwor set, in the absence of built in efi +// shell and no usb connected to SUT. IF we wont select any option at post +// we will try to launch setup but before launcing setup mouse is +// destroyed. +// [Solution] Fixed the issue by invoking the Mouseinit() for a specail +// case of admin password set and when no boot option to boot. +// [Files] minisetup.c +// +// 8 4/27/12 2:09a Rajashakerg +// [TAG] EIP88454 +// [Category] Improvement +// [Description] SoftKbd activate functionality in BBS Menu by AMITSE +// [Files] minisetup.c +// +// 7 6/20/11 10:33a Arunsb +// [TAG] EIP54861 +// [Category] Improvement +// [Description] Updating string token value dynamically for Title Bar +// and Copyright messages. +// [Files] minisetup.c and tselite\minisetupext.c +// +// 6 4/16/10 5:13p Madhans +// Changes for Tse 2.02. Please see Changelog.log for more details. +// +// 5 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 8 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 7 2/04/10 11:20p Madhans +// Post Status update for BBS popup. +// +// 6 1/29/10 4:37p Madhans +// To not to depend on ConsoleControl and ConOut. +// +// 5 1/09/10 5:16a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 4 6/24/09 6:09p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 5 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 3/31/09 3:40p Madhans +// MinisetupLoopInit is moved to minisetup.c +// +// 3 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: MINISETUP.C +// +// Description: This file contains code for entrypoint and setup loop +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + + +#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION +// from Resources.c +#if TSE_USE_EDK_LIBRARY +EFI_STATUS LoadStrings( + EFI_HANDLE ImageHandle, /*EFI_HII_HANDLE*/VOID* *pHiiHandle +); +#endif +#endif + +#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION || TSE_FOR_64BIT +EFI_STATUS ReadImageResource( + EFI_HANDLE ImageHandle, EFI_GUID *pGuid, + VOID **ppData, UINTN *pDataSize +); +#endif + +//Internal function definitions +#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1 +EFI_STATUS InitMiniSetupStrings( VOID ); +#endif + +EFI_DRIVER_ENTRY_POINT (MiniSetupApplication) + +///////////////////////////////////////////////////////// +// FUNCTION DECLARATION +//////////////////////////////////////////////////////// +VOID InitGlobalPointers( VOID ); +VOID UpdategScreenParams (VOID); +VOID StopClickEvent(VOID); +AMI_SET_VERSION(TSE_MAJOR,TSE_MINOR,TSE_BUILD,TSE); +VOID InvalidateStatusInBgrtWrapper (VOID); + +//EIP 162981 Providing defaults through sdl tokens +BOOLEAN TseDefaultSetupPasswordSupported(VOID); +EFI_STATUS SetDefaultPassword (VOID); + +#define TSE_FIRST_BOOT_GUID \ + { 0xc5912ed9, 0x83c2, 0x4bff, 0x99, 0x36, 0x23, 0x1f, 0xeb, 0x85, 0xf3, 0xe8 } +// +//---------------------------------------------------------------------------- +// Procedure: MiniSetupApplication +// +// Description: This function is the entry point for TSE. It loads +// resources like strings and setup-data. It registers +// notification for console protocols. It Installs TSE +// protocols. +// +// Input: EFI_HANDLE ImageHandle +// EFI_SYSTEM_TABLE *SystemTable +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS MiniSetupApplication ( + EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemTable ) +{ + EFI_STATUS Status; + UINTN OptionSize = 0; + void *FirstBoot = NULL; + EFI_GUID TseFirstBootGuid = TSE_FIRST_BOOT_GUID; + + gImageHandle = ImageHandle; + + EfiInitializeDriverLib ( ImageHandle, SystemTable ); + + RUNTIME_DEBUG( L"entry" ); + +#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION +#if TSE_USE_EDK_LIBRARY + LoadStrings(ImageHandle,&gHiiHandle); +#else + LoadStrings(ImageHandle,(EFI_HII_HANDLE*)&gHiiHandle); +#endif +#else +#ifdef USE_DEPRICATED_INTERFACE + // Read in the strings from the GUIDed section + Status = LoadStringsDriverLib( ImageHandle, &STRING_ARRAY_NAME ); + if ( EFI_ERROR( Status ) ) + { + return Status; + } +#endif + + Status = InitMiniSetupStrings(); + if ( EFI_ERROR( Status ) ) + { + return Status; + } +#endif + + Status = HiiInitializeProtocol(); + if ( EFI_ERROR ( Status ) ) + return Status; + + // initialize screen buffer + RUNTIME_DEBUG( L"screen" ); + InitializeScreenBuffer( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ); + + RUNTIME_DEBUG( L"guid" ); + + Status = InitApplicationData(ImageHandle); + if ( EFI_ERROR( Status ) ) + { + return MiniSetupExit( Status ); + } + + RUNTIME_DEBUG( L"globals" ); + InitGlobalPointers(); + UpdategScreenParams (); + + Status = VarLoadVariables( (VOID **)&gVariableList, NULL ); + if ( EFI_ERROR( Status ) ) + { + return Status; + } + + MinisetupDriverEntryHookHook(); + + gPostStatus = TSE_POST_STATUS_BEFORE_POST_SCREEN; + +#ifndef STANDALONE_APPLICATION + // Install our handshake protocol + InstallProtocol(); + + // Register any notification 'callbacks' that we need + Status = RegisterNotification(); + if ( EFI_ERROR( Status ) ) + UninstallProtocol(); +#else + PostManagerHandshake(); +#endif // STANDALONE_APPLICATION + + if (TseDefaultSetupPasswordSupported ()) //EIP 162981 Providing defaults through sdl tokens + { + FirstBoot = (BOOT_OPTION *)VarGetNvramName (L"TseFirstBootFlag", &TseFirstBootGuid, NULL, &OptionSize); + if (NULL == FirstBoot) + { + SetDefaultPassword (); //Get default password, if any present in SDL, and set default pass to NVRAM EIP 162981 + VarSetNvramName( L"TseFirstBootFlag", &TseFirstBootGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, &OptionSize, sizeof (OptionSize) ); + } + } + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: MiniSetupExit +// +// Description: This function is responsible for releasing the memory +// allocated during MinisetuEntry(). It destroys the +// application hierarchy; clears the memory used for +// variables; clears the memory used for fixup of +// setup-data. +// +// Input: EFI_STATUS Status: Guideline status for MiniSetupExit +// to return with. +// +// Output: Return Status based on input status and errors that +// occurred in library functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS MiniSetupExit( EFI_STATUS Status ) +{ + MiniSetupUIExit(); + + if(gST->ConOut!=NULL) + { + gST->ConOut->Reset( gST->ConOut, FALSE ); + gST->ConOut->ClearScreen( gST->ConOut); + gST->ConOut->EnableCursor( gST->ConOut, TRUE ); + } + + return Status; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: DoPopup +// +// Description: This function runs the loop for Pop up boot menu. +// This function is responsible for creating the list +// box control. It also gathers actions and passes them +// to list box control and initiates draw sequence. +// +// Input: BOOT_FLOW *BootFlow: Ptr to BOOT_FLOW responsible for +// the call. +// +// Output: Return Status based on errors that occurred in +// library functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS DoPopup(BOOT_FLOW *BootFlow) +{ + EFI_STATUS Status = EFI_SUCCESS; + + gPostStatus = TSE_POST_STATUS_IN_BBS_POPUP; + + DoBbsPopupInit() ; //minisetupext.c + + if (gClickTimer) //EIP-149734 Stopping ClickEvent timer, if gClickTimer event is not stopped, before drawing BBS menu to avoid drawing softkbd if any mouse action happens during BBS menu + StopClickEvent(); + + //TSEStringReadLoopEntryHook();//EIP 88454 : Initializing the Softkbd for BBS popup menu + DrawPopupMenuHook() ; //HookAnchor.c -> DrawBootOnlyBbsPopupMenu (minisetupext.c) + BbsBootHook() ; //HookAnchor.c -> BbsBoot (minisetupext.c) + + return Status; +} +// +//---------------------------------------------------------------------------- +// Procedure: MainSetupLoopInit +// +// Description: Main function that initializes the setup Loops. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID MainSetupLoopInit(VOID) +{ +#ifndef STANDALONE_APPLICATION + EFI_CONSOLE_CONTROL_SCREEN_MODE ScreenMode; +#endif + EFI_GUID AmitseSetupEnterGuid = AMITSE_SETUP_ENTER_GUID; + static int Initdone =0; + + if(Initdone) + { + EfiLibNamedEventSignal ( &AmitseSetupEnterGuid ); + return; + } + Initdone = 1; + +#ifndef STANDALONE_APPLICATION + if ( gConsoleControl != NULL ) + { + gConsoleControl->GetMode(gConsoleControl, &ScreenMode, NULL, NULL); + if(EfiConsoleControlScreenGraphics == ScreenMode) + { + gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenText ); + InvalidateStatusInBgrtWrapper (); //EIP93524. Since mode changed invalidating status field in BGRT table. Usefull for boot from BBS Pop up. + } + } +#endif + + MouseInit();//EIP 82804 : Initiatializing the Mouse before prompting password + ProcessEnterSetupHook(); + + TSEUnlockHDD(); ///Modified as a hook + + EfiLibNamedEventSignal ( &AmitseSetupEnterGuid ); + // Report the Status code DXE_SETUP_START + EfiLibReportStatusCode(EFI_PROGRESS_CODE, DXE_SETUP_START,0,NULL,NULL); +} + +//EIP 162981 starts +// +//---------------------------------------------------------------------------- +// Procedure: GetDefaultPassword +// +// Description: Getting default password from SDL token based on USER/ADMIN token +// +// Input: UINT32, AMITSESETUP* +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +CHAR16 *GetDefaultPasswordFromTokens (UINT32 PasswordType); +EFI_STATUS GetDefaultPassword (UINT32 PasswordInstalled, void **DefaultPassword) +{ + CHAR16 *adminPwd = NULL, *usrPwd = NULL; + EFI_STATUS Status = EFI_NOT_FOUND; + CHAR16 *tmpPasswd = NULL; + + if ((PasswordInstalled == AMI_PASSWORD_ADMIN) || (AMI_PASSWORD_NONE == PasswordInstalled)) + { + usrPwd = GetDefaultPasswordFromTokens (AMI_PASSWORD_USER); + if ((NULL != usrPwd) && (EfiStrCmp (usrPwd, L"\"\""))) + { + tmpPasswd = (CHAR16 *)EfiLibAllocateZeroPool (sizeof (AMITSESETUP)); + if (NULL == tmpPasswd) + { + return EFI_OUT_OF_RESOURCES; + } + EfiStrCpy (tmpPasswd, usrPwd); + PasswordEncodeHook (tmpPasswd, TsePasswordLength*sizeof(CHAR16)); + MemCopy (*DefaultPassword, tmpPasswd, TsePasswordLength*sizeof(CHAR16)); + MemFreePointer ((VOID **) &tmpPasswd); + Status = EFI_SUCCESS; + } + } + + if ((PasswordInstalled == AMI_PASSWORD_USER) || (AMI_PASSWORD_NONE == PasswordInstalled)) + { + adminPwd = GetDefaultPasswordFromTokens (AMI_PASSWORD_ADMIN); + if ((NULL != adminPwd) && (EfiStrCmp (adminPwd, L"\"\""))) + { + tmpPasswd = (CHAR16 *) EfiLibAllocateZeroPool (sizeof (AMITSESETUP)); + if (NULL == tmpPasswd) + { + return EFI_OUT_OF_RESOURCES; + } + EfiStrCpy (tmpPasswd, adminPwd); + PasswordEncodeHook (tmpPasswd, TsePasswordLength*sizeof(CHAR16)); + MemCopy ((CHAR16*)(*DefaultPassword) + TsePasswordLength, tmpPasswd, TsePasswordLength*sizeof(CHAR16)); + MemFreePointer ((VOID **) &tmpPasswd); + Status = EFI_SUCCESS; + } + } + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetDefaultPassword +// +// Description: Function to set defaults password in NVRAM, if any present in SDL +// +// Input: void +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +BOOLEAN TseRtAccessSupport (VOID); +EFI_STATUS SetDefaultPassword (VOID) +{ + UINTN size = 0; + UINT32 Installed = AMI_PASSWORD_NONE; + void *DefaultPassword = NULL; + UINT32 PasswordInstalled; + EFI_STATUS Status = EFI_SUCCESS; + AMITSESETUP *pSetupVariable = (AMITSESETUP *)NULL; + EFI_GUID amitsesetupGuid = AMITSESETUP_GUID; + + pSetupVariable = HelperGetVariable( VARIABLE_ID_AMITSESETUP, (CHAR16 *)NULL, (EFI_GUID *)NULL, NULL, &size ); + + if(size < sizeof(AMITSESETUP)) + { + pSetupVariable = (AMITSESETUP *) EfiLibAllocateZeroPool(sizeof(AMITSESETUP)); + if(gVariableList && (gVariableList[VARIABLE_ID_AMITSESETUP].Buffer)) + MemCopy( pSetupVariable, gVariableList[VARIABLE_ID_AMITSESETUP].Buffer, gVariableList[VARIABLE_ID_AMITSESETUP].Size ); + if (TseRtAccessSupport ()) + { + VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS, pSetupVariable, sizeof (AMITSESETUP)); + } + else + { + VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, pSetupVariable, sizeof (AMITSESETUP)); + } +// VarSetNvram( VARIABLE_ID_AMITSESETUP, pSetupVariable, sizeof(AMITSESETUP)); + } + PasswordInstalled = PasswordCheckInstalled(); + + if (AMI_PASSWORD_ANY == PasswordInstalled) + { + return EFI_ALREADY_STARTED; + } + + Status = GetDefaultPassword (PasswordInstalled, &pSetupVariable); + + if (!EFI_ERROR (Status)) + { + if (TseRtAccessSupport ()) + { + VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS, pSetupVariable, sizeof (AMITSESETUP)); + } + else + { + VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, pSetupVariable, sizeof (AMITSESETUP)); + } +// VarSetNvram( VARIABLE_ID_AMITSESETUP, pSetupVariable, sizeof(AMITSESETUP)); +// VarUpdateDefaults(VARIABLE_ID_AMITSESETUP); + } + return EFI_SUCCESS; +} +//EIP 162981 ends + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2014, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/minisetup.h b/EDK/MiniSetup/BootOnly/minisetup.h new file mode 100644 index 0000000..cdd9a0e --- /dev/null +++ b/EDK/MiniSetup/BootOnly/minisetup.h @@ -0,0 +1,1519 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2012, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.h $ +// +// $Author: Premkumara $ +// +// $Revision: 49 $ +// +// $Date: 8/28/14 5:43a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.h $ +// +// 49 8/28/14 5:43a Premkumara +// EIP-135253 Updating file name proper in #include +// +// 48 2/11/14 7:56p Arunsb +// [TAG] EIP125719 +// [Category] Improvement +// [Description] The EfiCreateEventReadyToBoot is conflicted under +// UefiLib.h and EDKhelper.h. +// [Files] boot.c +// +// 47 10/18/12 5:58a Arunsb +// Updated for 2.16.1235 QA submission +// +// 37 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 45 5/29/12 4:31a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 44 5/28/12 5:39a Premkumara +// [TAG] EIP75236 +// [Category] Improvement +// [Description] Add the support to control the GOP dependency in TSE +// notification. +// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h, +// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c +// +// 43 1/10/12 2:36a Arunsb +// [TAG] EIP77400 +// [Category] Improvement +// [Description] Need to do "Clear Screen" whenever boot to EFI Shell +// [Files] Boot.c and minisetup.h +// +// 42 12/08/11 12:34p Arunsb +// [TAG] EIP63190 +// [Category] New Feature +// [Description] Security operations in BootOnly module instead of +// TSELite +// +// 41 12/05/11 5:48a Rajashakerg +// [TAG] EIP76381 +// [Category] Improvement +// [Description] Performance: Improving variable data load and usage +// [Files] callback.c, minisetupext.c, variable.c, variable.h, +// minisetup.h, Hii.c, FormBrowser2.c +// +// 40 12/01/11 5:36a Rajashakerg +// [TAG] EIP74963 +// [Category] Improvement +// [Description] MAX_MSGBOX_WIDTH cannot be overridden +// [Files] AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c, +// MessageBox.c, MessageBox.h, FormBrowser.c +// +// 39 12/01/11 4:58a Arunsb +// // [TAG] EIP70175 +// // [Category] Improvement +// // [Description] Removed unwanted declarations +// // [Files] CommonHelper.c, postmgmtext.c +// +// 38 11/21/11 10:44a Premkumara +// [TAG] EIP72610 +// [Category] Improvement +// [Description] Moving TSE_MULTILINE_CONTROLS to Binary +// [Files] AMITSE-CommonHelper.c, AMITSE.sdl, +// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c, +// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c, +// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c, +// Date.h, Date.c, +// LEGACY-Legacy.c, +// BOOTONLY- Minisetup.h +// +// 37 11/21/11 5:47a Rajashakerg +// [TAG] EIP74591 +// [Category] Improvement +// [Description] Make MainSetupLoop as board module hook +// [Files] AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h, +// FormBrowser.c, FormBrowser2.c +// +// 36 11/20/11 8:10a Premkumara +// [TAG] EIP70175 +// [Category] Improvement +// [Description] Color of PopupPassword Window to validate password in +// GTSE style +// [Files] CommonHelper.c, postmgmtext.c, minisetup.h +// +// 35 11/20/11 7:09a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 34 11/14/11 2:43p Blaines +// [TAG] - EIP 75481 +// [Category]- Function Request +// [Synopsis]- TSE debug print infrastructure. +// [Description]- Add TSE debug print info for basic functions such as +// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms +// data. +// [Files] +// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c +// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c, +// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h, +// Uefi21Wrapper.c, setupdbg.h +// +// 33 11/13/11 12:32p Arunsb +// [TAG] EIP70421 +// [Category] New Feature +// [Description] Support for driver order in TSE +// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini, +// boot.c, +// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c, +// addbootoption.c, +// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h, +// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h, +// TseElink.h, variable.h, +// setup.h, Boot.vfr and Setup.uni +// +// 32 10/31/11 9:45a Rajashakerg +// [TAG] EIP71120,71512 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] BIOS gets stuck in infinite loop On enabling +// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is +// disabled in Setup & BBS table but in second boot the correct device is +// disabled in both places. +// [Solution] Hidden option handled properly. +// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c, +// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c +// +// 31 7/19/11 10:50a Blaines +// [TAG] - EIP 63262 +// [Category]- Defect +// [Symptom]- Setup page display problem on rose city. +// When SETUP_GROUP_DYNAMIC_PAGES is enabled and Network Stack is enabled, +// the "iSCSI" menu is listed as a dynamic page in advanced menu but only +// 3 of 4 "Port Configuration" pages shows up. The TSE dynamic page count +// is incorrect. +// +// [Solution]- In the functions (RTIfrProcessRunTimeForms, +// HandleNewIFRPack, HandleRemoveIFRPack, HandleAddIFRPack), make sure the +// nvram cache is updated by calling +// VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT) when updating +// "DynamicPageCount" variable name. +// . +// [Files] - Hii.c, Minisetup.h, Variable.h +// +// 30 7/01/11 5:19a Arunsb +// Driver health related declaration moved to tsedrvhealth.h. +// +// 29 6/30/11 5:05a Premkumara +// [TAG] EIP57661 +// [Category] New Feature +// [Description] Resolve Build error with Driver Health protocol +// +// 28 6/30/11 4:14a Arunsb +// [TAG] EIP57661 +// [Category] New Feature +// [Description] Boot manager algorithm for interaction with Driver +// Health protocol. +// 2.0 & 2.1 compatibility added +// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni, +// commonhelper.c, uefisetup.ini, tsedrvhealth.h, +// amivfr.h, minisetupbin.mak, +// hiistring21.c, hiistring20.c, tseadvanced.c, special.c, +// special.h, boot.h, minisetup.h, +// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and +// uefi21wapper.c. +// +// 27 6/29/11 12:19p Rajashakerg +// [TAG] EIP47086, 62098 +// [Category] New Feature +// [Description] Right clicking from the Main page is not exiting from +// BIOS setup and the Mouse hotclicks. +// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl, +// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, +// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, +// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h, +// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, +// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c, +// application.h, application.c, commonoem.h, CommonHelper.c +// +// 26 6/23/11 4:06p Rajashakerg +// [TAG] EIP55762, 58925, 59971 +// [Category] New Feature +// [Description] Support REF2,REF3 and REF4 in AMITSE +// Support direct form navigation path +// Improper layout of controls in the root page when Dynamic pages are +// added using the Legacy Setup Style +// +// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c, +// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, +// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c, +// Uefi21Wrapper.c, Parse.c Hii.c +// +// 25 6/20/11 11:46a Rajashakerg +// [TAG] EIP59417 +// [Category] New Feature +// [Description] Spport LOAD_OPTION_HIDDEN option in TSE +// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, +// minisetup.h, special.c, callback.c +// +// 24 3/28/11 11:40p Madhans +// [TAG] EIP50878 +// [Category] Improvement +// [Description] Support to move the Control With Boot Order Change. +// [Files] AMITSE.sdl +// commonoem.c +// minisetup.h +// popupsel.c +// +// 23 3/23/11 8:38p Blaines +// [TAG] - EIP 23601 +// [Category]- Enhancement +// [Symptom]- Add support for OEM special controls. +// [Files] - AmiTse.sdl, CommonHelper.c, Setup.ini, UefiSetup.ini, +// AmiVfr.h, minisetup.h, minisetup.sdl, variable.c, special.c +// +// 22 3/21/11 1:23a Rajashakerg +// [TAG] EIP53740 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Animation does not continue after the last frame of the +// logo. +// [RootCause] +// Animation is continued upto the last frame of the animated image +// [Solution] Fixed the issue by handling Gif image data to redraw image +// if all the frames are completed and if boottimeout is present. +// [Files] minisetup.h, dogif.c, dogifmgr.c +// +// 21 3/15/11 5:14a Rajashakerg +// [TAG] EIP51671 +// [Category] New Feature +// [Description] Boot overide menu devices are not disable +// [Files] boot.c, minisetup.h, special.c, minisetupext.c, AMITSE.sdl, +// boot.h, CommonHelper.c +// +// 20 1/10/11 3:55p Mallikarjunanv +// Updated to work with respect to EDK Libraries +// +// 19 12/29/10 2:27a Mallikarjunanv +// Updated the funcation name of the EIP:50479 +// +// 18 12/28/10 6:14p Mallikarjunanv +// [TAG] EIP41615 +// [Category] New Feature +// [Description] Added the file browser support for the Add boot option +// reated controls +// [Files] AmiVfr.h, AmiTse.sdl, AmiTseStr.uni, CommonHelper.c, +// Faketokens.c, TseElinks.h, EdkHelper.h, minisetup.h, TseAdvanced.c, +// AddBootOption.c +// +// 17 12/26/10 10:27a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] fter the notification, if the graphics driver uninstalled +// and reinstalled from core module then gGOP getting corrupted. +// [Solution] Updated gGop before using it in AMITSE. +// [Files] logo.c,minisetup.h, notify.c, postmgmt.c +// +// 16 10/06/10 5:59p Madhans +// [TAG] - EIP 45620 +// [Category]- Enhancment +// [Severity]- Mordarate +// [Symptom]- TSE with TSE_CONTINUE_BOOT_NOW_ON_FAIL ON Not allows to boot +// to USB group of devices with customized BDS. +// [RootCause] - BBSTable does not contain the DeviceType called USB. Only +// in EFI Logical group is created in EFI variables. +// TSE was checking the DeviceType to set the priorities. +// [Solution]- TSE is changed to not check for DeviceType in BBSTable. But +// set the priorities based on LegacyDevOrder. +// [Files] - bbs.c commonhelper.c minisetup.h +// +// 15 10/05/10 5:38p Madhans +// [TAG] - EIP 45299 +// [Category]- Enhancment +// [Severity]- Minor +// [Symptom]- TSE by default saves the Disbaled BBS devices device path in +// NVRAM Varaiable "DisabledDevs" Variable. In Next boots it depend on +// this variable to consider the device as disabled inaddtion to +// LegacyDevOrder. +// Some BDS customized projects don't want this. +// [Solution]- TSE_SAVE_DISABLED_BBS_DEVICEPATH SDL token created to +// control this option. Bydefault It is Enabled. +// [Files] - callback.c bbs.c commonhelper.c minisetup.h AMITSE.sdl +// +// 14 9/20/10 6:47p Madhans +// [TAG] EIP44542 +// [Category] BUILD ISSUE FIX +// [Symptom] Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST +// when IdeSecurity and FastBoot modules added to the project +// [RootCause] - +// [Solution] Build issues resolved +// [Files] CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h, +// bbs.c, special.c, Bds.c TseLitehelp +// +// 13 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 28 9/08/10 6:53a Mallikarjunanv +// EIP-42080: TSE updates with respect to Fast Boot Support +// +// 27 8/27/10 5:00a Mallikarjunanv +// EIP-39334: support to build TSE without the CSM module support +// +// 26 4/07/10 6:24p Madhans +// post screen Sroll area support. TSE_POSTSCREEN_SCROLL_AREA SDL +// configures the area. +// +// 25 4/02/10 4:37p Madhans +// To get ride of TSEOEM.H referance in TSE. Oem hearder files can be +// refered only in Tse Binary. +// +// 24 3/23/10 5:08p Blaines +// Preseve the order of disabled BBS boot devices. +// +// 23 2/26/10 7:06p Madhans +// Cleanup on formbrowrser.h +// +// 3 2/26/10 3:36p Madhans +// Formbrowser.h need to be in Hii modules. +// +// 21 2/17/10 1:02p Madhans +// minisetupstr.uni removed and Strings token are refered from +// AMITSEStrTokens.h +// +// 20 2/15/10 10:10p Madhans +// To avoid Compilation issues +// +// 19 2/11/10 7:14a Mallikarjunanv +// added Tse Advanced module dependency to include TseElinks.h +// +// 18 2/04/10 12:03p Blaines +// EIP-28005 +// +// Added PostManagerSetAttribute to support display of text in color. +// Added support for handling string characters --- \n, \r. +// +// 17 1/18/10 2:07a Mallikarjunanv +// EIP-28501: Updated for Keyboard scancode as password. Added a new Token +// SETUP_STORE_KEYCODE_PASSWORD to support the EFI key or Scan code as +// password +// +// 16 1/09/10 5:26a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 15 1/04/10 10:40a Mallikarjunanv +// EIPs 27161/29095 - Added support for reserved boot option names and +// added support not to create empty boot option names +// +// 14 10/28/09 5:37p Madhans +// +// 13 9/24/09 9:41a Sudhirv +// EIP-24971: moved the dependency for TSE_CONTINUE_BOOT_NOW_ON_FAIL to +// Tse Binary +// +// 12 9/17/09 9:04a Sudhirv +// Remove Load Driver Option from TSE 2.x as it will be handled from Core +// +// 11 9/16/09 6:15p Madhans +// EIP 25416 : Support have 1/10 sec Timeout +// +// 10 9/15/09 9:31a Sudhirv +// removed Version macros and added function declarations for Add Del boot +// option handling +// +// 9 8/18/09 6:34p Blaines +// Support additional date styles +// +// 8 8/17/09 12:21p Presannar +// Removed References to Tiano.h +// +// 7 8/17/09 10:52a Presannar +// Added code to include EDKHelper.h +// Removed redefinition of structure LOGO_TYPE +// Added fn prototype for CleanUpExtendedLogoWrapper and +// DoLogoAnimateWrapper +// +// 6 8/13/09 7:35a Mallikarjunanv +// eip:24971 - supporting tse features without tse sources +// +// 5 7/30/09 7:49a Mallikarjunanv +// updated the code to move the exit page option elinks to Tse Binary - +// included the new header file TseElinks.h to access all tse modules +// +// 4 6/24/09 6:09p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 3 5/13/09 2:22p Madhans +// To patch the version number in the Bootonly TSE. update the build +// number. +// +// 2 5/07/09 10:35a Madhans +// Changes after Bin module +// +// 9 5/06/09 12:31p Mallikarjunanv +// updated the version info +// +// 8 5/05/09 3:11p Madhans +// Std Col default. +// +// 7 5/01/09 9:45p Blaines +// Control and Label margin support changes +// +// 6 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 5 3/31/09 3:58p Madhans +// +// 4 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 3 2/05/09 10:15a Madhans +// Style Module created. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: MINISETUP.h +// +// Description: Main header file takes care of TSE includes. +// +//---------------------------------------------------------------------------- +// + +#ifndef _MINISETUP_H_ +#define _MINISETUP_H_ + +#ifdef TSE_FOR_APTIO_4_50 +#include +#else +#include "tokens.h" +#endif + + +#ifndef SETUP_USE_GUIDED_SECTION +#define SETUP_USE_GUIDED_SECTION 0 +#endif + +#ifndef SETUP_JPEG_LOGO_SUPPORT +#define SETUP_JPEG_LOGO_SUPPORT 0 +#endif + +#ifndef SETUP_PCX_LOGO_SUPPORT +#define SETUP_PCX_LOGO_SUPPORT 0 +#endif + +#ifndef SETUP_GIF_LOGO_SUPPORT +#define SETUP_GIF_LOGO_SUPPORT 0 +#endif + +#ifndef TSE_BOOT_NOW_IN_BOOT_ORDER +#define TSE_BOOT_NOW_IN_BOOT_ORDER 0 +#endif + +#if TSE_USE_EDK_LIBRARY +#include "Tiano.h" + +#include "EfiDriverLib.h" +#include "EfiPrintLib.h" + +#include EFI_PROTOCOL_DEFINITION(FirmwareVolume) +#include EFI_PROTOCOL_DEFINITION(SimpleFileSystem) +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL +#include EFI_PROTOCOL_DEFINITION(GraphicsOutput) +// Between GOP and UGA draw protocols blt buffer structure remains +// the same. The difference is only in the name so we can safely +// typedef the new structure to old structure's name. +typedef EFI_GRAPHICS_OUTPUT_BLT_PIXEL EFI_UGA_PIXEL; +#else +#include EFI_PROTOCOL_DEFINITION(UgaDraw) +#endif +#include EFI_PROTOCOL_DEFINITION(ConsoleControl) +#include EFI_PROTOCOL_DEFINITION(DevicePath) +#include EFI_PROTOCOL_DEFINITION(ComponentName) +#include EFI_PROTOCOL_DEFINITION(LegacyBios) +#include EFI_PROTOCOL_DEFINITION(LoadedImage) +#include EFI_PROTOCOL_DEFINITION(FileInfo) +#if EFI_SPECIFICATION_VERSION<=0x20000 +#include EFI_PROTOCOL_DEFINITION(Hii) +#endif + +#if SETUP_ITK_COMPATIBILITY +#include "..\ITK\OemBadgingSupport\EfiOEMBadging.h" +#else +#include EFI_PROTOCOL_DEFINITION(EfiOEMBadging) +#endif +#include EFI_GUID_DEFINITION(Bmp) +INTN MemCmp( UINT8 *dest, UINT8 *src, UINTN size ); + +#define MSG_USB_WWID_CLASS_DP MSG_USB_WWID_DP +#define MSG_USB_LOGICAL_UNIT_CLASS_DP MSG_DEVICE_LOGICAL_UNIT_DP +#define MSG_USB_SATA_DP MSG_SATA_DP +#define MSG_USB_ISCSI_DP MSG_ISCSI_DP + +#else //TSE_USE_EDK_LIBRARY + +#include "Efi.h" + +#include "Protocol/FirmwareVolume.h" +#include "Protocol/SimpleFileSystem.h" +#include "Protocol/SimpleTextOut.h" +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL +#include "Protocol/GraphicsOutput.h" + // Between GOP and UGA draw protocols blt buffer structure remains + // the same. The difference is only in the name so we can safely + // typedef the new structure to old structure's name. +typedef EFI_GRAPHICS_OUTPUT_BLT_PIXEL EFI_UGA_PIXEL; +#else +#include "UgaDraw.h" +#endif + +#include "Protocol/ConsoleControl.h" +#include "Protocol/DevicePath.h" +#include "Protocol/ComponentName.h" +//#include "LegacyBios.h" +#include "Protocol/LoadedImage.h" + + +#if SETUP_ITK_COMPATIBILITY +#include "..\ITK\OemBadgingSupport\EfiOEMBadging.h" +#else +#include "Protocol/EfiOemBadging.h" +#endif + +#include "Protocol/SimpleTextInEx.h" +//#include "LegacyBios.h" +#include "AmiDxeLib.h" +#define EFI_DRIVER_ENTRY_POINT(a) + +#include "EDKhelper.h" + +// EfiDriverlib +VOID * +EfiLibAllocateZeroPool ( + IN UINTN AllocationSize + ); + +VOID +EfiStrCpy ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ); +UINTN +EfiDevicePathSize ( + IN EFI_DEVICE_PATH_PROTOCOL *DevPath + ); +VOID * +EfiLibAllocatePool ( + IN UINTN AllocationSize + ); +EFI_STATUS +EFIAPI +TseEfiCreateEventReadyToBoot ( + IN EFI_TPL NotifyTpl, + IN EFI_EVENT_NOTIFY NotifyFunction, + IN VOID *NotifyContext, + OUT EFI_EVENT *ReadyToBootEvent + ); +EFI_STATUS +EfiLibReportStatusCode ( + IN EFI_STATUS_CODE_TYPE Type, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID *CallerId OPTIONAL, + IN EFI_STATUS_CODE_DATA *Data OPTIONAL + ); +EFI_DEVICE_PATH_PROTOCOL * +EfiFileDevicePath ( + IN EFI_HANDLE Device OPTIONAL, + IN CHAR16 *FileName + ); +EFI_STATUS +EfiLibNamedEventSignal ( + IN EFI_GUID *Name + ); +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ); + +EFI_DEVICE_PATH_PROTOCOL * +EfiAppendDevicePathNode ( + IN EFI_DEVICE_PATH_PROTOCOL *Src1, + IN EFI_DEVICE_PATH_PROTOCOL *Src2 + ); + +VOID +EFIAPI +EfiInitializeFwVolDevicepathNode ( + IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, + IN EFI_GUID *NameGuid + ); + +UINTN +SPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ); +EFI_STATUS +EfiInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +VOID SetupDebugPrint(IN CONST CHAR8 *Format, ...) ; + +extern EFI_SYSTEM_TABLE *gST; +extern EFI_BOOT_SERVICES *gBS; +extern EFI_RUNTIME_SERVICES *gRT; + +#define EFI_TPL_APPLICATION TPL_APPLICATION +#define EFI_TPL_CALLBACK TPL_CALLBACK +#define EFI_TPL_NOTIFY TPL_NOTIFY +#define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL + +#ifndef BBS_TYPE_FLOPPY +#define BBS_TYPE_FLOPPY BBS_FLOPPY +#endif +#ifndef BBS_TYPE_HARDDRIVE +#define BBS_TYPE_HARDDRIVE BBS_HARDDISK +#endif +#ifndef BBS_TYPE_CDROM +#define BBS_TYPE_CDROM BBS_CDROM +#endif +#ifndef BBS_TYPE_PCMCIA +#define BBS_TYPE_PCMCIA BBS_PCMCIA +#endif +#ifndef BBS_TYPE_USB +#define BBS_TYPE_USB BBS_USB +#endif +#ifndef BBS_TYPE_EMBEDDED_NETWORK +#define BBS_TYPE_EMBEDDED_NETWORK BBS_EMBED_NETWORK +#endif +#ifndef BBS_TYPE_BEV +#define BBS_TYPE_BEV BBS_BEV_DEVICE +#endif +#ifndef BBS_TYPE_UNKNOWN +#define BBS_TYPE_UNKNOWN BBS_UNKNOWN +#endif + +#ifndef SCAN_NULL +#define SCAN_NULL EFI_SCAN_NULL +#endif +#ifndef SCAN_UP +#define SCAN_UP EFI_SCAN_UP +#endif +#ifndef SCAN_DOWN +#define SCAN_DOWN EFI_SCAN_DN +#endif +#ifndef SCAN_RIGHT +#define SCAN_RIGHT EFI_SCAN_RIGHT +#endif +#ifndef SCAN_LEFT +#define SCAN_LEFT EFI_SCAN_LEFT +#endif +#ifndef SCAN_HOME +#define SCAN_HOME EFI_SCAN_HOME +#endif +#ifndef SCAN_END +#define SCAN_END EFI_SCAN_END +#endif +#ifndef SCAN_INSERT +#define SCAN_INSERT EFI_SCAN_INS +#endif +#ifndef SCAN_DELETE +#define SCAN_DELETE EFI_SCAN_DEL +#endif +#ifndef SCAN_PAGE_UP +#define SCAN_PAGE_UP EFI_SCAN_PGUP +#endif +#ifndef SCAN_PAGE_DOWN +#define SCAN_PAGE_DOWN EFI_SCAN_PGDN +#endif +#ifndef SCAN_F1 +#define SCAN_F1 EFI_SCAN_F1 +#endif +#ifndef SCAN_F2 +#define SCAN_F2 EFI_SCAN_F2 +#endif +#ifndef SCAN_F3 +#define SCAN_F3 EFI_SCAN_F3 +#endif +#ifndef SCAN_F4 +#define SCAN_F4 EFI_SCAN_F4 +#endif +#ifndef SCAN_F5 +#define SCAN_F5 EFI_SCAN_F5 +#endif +#ifndef SCAN_F6 +#define SCAN_F6 EFI_SCAN_F6 +#endif +#ifndef SCAN_F7 +#define SCAN_F7 EFI_SCAN_F7 +#endif +#ifndef SCAN_F8 +#define SCAN_F8 EFI_SCAN_F8 +#endif +#ifndef SCAN_F9 +#define SCAN_F9 EFI_SCAN_F9 +#endif +#ifndef SCAN_F10 +#define SCAN_F10 EFI_SCAN_F10 +#endif +#ifndef SCAN_F11 +#define SCAN_F11 EFI_SCAN_F11 +#endif +#ifndef SCAN_F12 +#define SCAN_F12 EFI_SCAN_F12 +#endif +#ifndef SCAN_ESC +#define SCAN_ESC EFI_SCAN_ESC +#endif + +#define CHAR_NULL 0x0000 +#define CHAR_BACKSPACE 0x0008 +#define CHAR_TAB 0x0009 +#define CHAR_LINEFEED 0x000A +#define CHAR_CARRIAGE_RETURN 0x000D +#define GLYPH_WIDTH 8 +#define GLYPH_HEIGHT 19 +#define NARROW_CHAR 0xFFF0 +#define WIDE_CHAR 0xFFF1 +#define NON_BREAKING_CHAR 0xFFF2 + +// BMP +// +// Definitions for BMP files +// +#pragma pack(1) + +typedef struct { + UINT8 Blue; + UINT8 Green; + UINT8 Red; + UINT8 Reserved; +} BMP_COLOR_MAP; + +typedef struct { + CHAR8 CharB; + CHAR8 CharM; + UINT32 Size; + UINT16 Reserved[2]; + UINT32 ImageOffset; + UINT32 HeaderSize; + UINT32 PixelWidth; + UINT32 PixelHeight; + UINT16 Planes; // Must be 1 + UINT16 BitPerPixel; // 1, 4, 8, or 24 + UINT32 CompressionType; + UINT32 ImageSize; // Compressed image size in bytes + UINT32 XPixelsPerMeter; + UINT32 YPixelsPerMeter; + UINT32 NumberOfColors; + UINT32 ImportantColors; +} BMP_IMAGE_HEADER; + +#pragma pack() + +#define EFI_DEFAULT_BMP_LOGO_GUID \ + {0x7BB28B99,0x61BB,0x11d5,0x9A,0x5D,0x00,0x90,0x27,0x3F,0xC1,0x4D} + +extern EFI_GUID gEfiDefaultBmpLogoGuid; + +///DEVICE PATH Definitions +#ifndef MSG_USB_WWID_CLASS_DP +#define MSG_USB_WWID_CLASS_DP 0x10 +#endif +#ifndef MSG_USB_LOGICAL_UNIT_CLASS_DP +#define MSG_USB_LOGICAL_UNIT_CLASS_DP 0x11 +#endif +#ifndef MSG_USB_SATA_DP +#define MSG_USB_SATA_DP 0x12 +#endif +#ifndef MSG_USB_ISCSI_DP +#define MSG_USB_ISCSI_DP 0x13 +#endif +#endif //TSE_USE_EDK_LIBRARY + +//USB Class devices - Device path.. +#define USB_PHY_DEV_CLASS 0x05 +#define USB_MASS_DEV_CLASS 0x08 + +extern EFI_GUID gEfiGlobalVariableGuid; + +#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL +#if TSE_USE_EDK_LIBRARY +#if EFI_SPECIFICATION_VERSION>=0x2000A +#define __UEFI_HII__H__ +#include +#else +#define __HII_PROTOCOL_H__ +#endif +#endif //TSE_USE_EDK_LIBRARY +#include "Protocol/AmiKeyCode.h" +#else +#ifndef _AMI_EFI_KEY_DATA_ +#define _AMI_EFI_KEY_DATA_ +typedef struct { + EFI_INPUT_KEY Key; +} AMI_EFI_KEY_DATA; +#endif +#endif + +#ifdef TSE_FOR_APTIO_4_50 +#include "Include/Protocol/AMIPostMgr.h" +#else +#include "AMIPostMgr.h" +#endif + +#include "amiver.h" + +//handling version macros as tokens +//#define TSE_MAJOR 0x02 +//#define TSE_MINOR 0x00 +//#define TSE_BUILD 0x1201 + +#define MINI_SETUP_DATA_GUID \ + { 0xFE612B72, 0x203C, 0x47B1, 0x85, 0x60, 0xA6, 0x6D, 0x94, 0x6E, 0xB3, 0x71 } + +#include "hiistring.h" +#include "string.h" +#include "protocol.h" +#include "variable.h" +#include "boot.h" +#include "AMILogo.h" +#include "bootflow.h" +#include "Timer.h" + +#ifdef TSE_FOR_APTIO_4_50 +#include "AMITSEStrTokens.h" +#else +#include STRING_DEFINES_FILE +#endif + +#ifdef TSE_FOR_APTIO_4_50 +#include "Include/AMIVfr.h" +#else +#include "AMIVFR.h" +#endif + +#if TSE_APTIO_5_SUPPORT +#define AMITSE_TEXT(a) a +#else +#define AMITSE_TEXT(a) L##a +#endif + +#include "bbs.h" + +///for Hotkey customizations - 6/1/09 +#if TSE_STYLE_SOURCES_SUPPORT +#include "HotkeyBin.h" +#include "HotclickBin.h" //EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup. +#endif + +#if TSE_LITE_SOURCES_SUPPORT +#include "frame.h" +#include "Label.h" +#include "hotkey.h" +#include "hotclick.h"//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup. +#include "minisetupext.h" +#endif + +#ifndef STRING_TOKEN +#define STRING_TOKEN(t) t +#endif + +UINTN StyleGetTextMode( UINTN Rows, UINTN Cols ); +VOID StyleUpdateVersionString( VOID ); +UINTN StyleGetClearScreenColor(VOID); +UINT8 StyleGetPageLinkColor(VOID); +UINT8 StyleGetScrollBarColor(VOID); +UINT8 StyleGetScrollBarUpArrowColor(VOID); +UINT8 StyleGetScrollBarDownArrowColor(VOID); + +UINTN StyleGetStdMaxRows(VOID); +UINTN StyleGetStdMaxCols(VOID); +VOID GetProgressColor(EFI_UGA_PIXEL * BGColor, EFI_UGA_PIXEL * BDRColor, EFI_UGA_PIXEL * FillColor); + +#ifndef STYLE_FULL_MAX_ROWS +#define STYLE_FULL_MAX_ROWS 31 +#endif + +#ifndef STYLE_FULL_MAX_COLS +#define STYLE_FULL_MAX_COLS 100 +#endif + +#ifndef STYLE_STD_MAX_ROWS +#define STYLE_STD_MAX_ROWS 24 +#endif + +#ifndef STYLE_STD_MAX_COLS +#define STYLE_STD_MAX_COLS 80 +#endif + +#ifndef STYLE_MAX_COLS +#define STYLE_MAX_COLS STYLE_FULL_MAX_COLS +#endif + +#ifndef STYLE_MAX_ROWS +#define STYLE_MAX_ROWS STYLE_FULL_MAX_ROWS +#endif + +#define MAX_ROWS STYLE_MAX_ROWS +#define MAX_COLS STYLE_MAX_COLS +#define MAX_DIMENSIONS (STYLE_FULL_MAX_ROWS * STYLE_FULL_MAX_COLS) + +#include "screen.h" + +#include "commonoem.h" +#include "LogoLib.h" +#include "PwdLib.h" +#include "HiiLib.h" +#include "mem.h" +#include "HookAnchor.h" +#if TSE_ADVANCED_SUPPORT +#include "TseElinks.h" +#endif +#ifdef TSE_FOR_APTIO_4_50 +#include "AmiStatusCodes.h" +#else +#include "EfiStatusCode.h" +#endif + +#ifndef BBS_TYPE_DEV +#ifdef BBS_TYPE_BEV +#define BBS_TYPE_DEV BBS_TYPE_BEV +#else +#define BBS_TYPE_DEV 0x80 +#endif +#endif +/* B1DA0ADF-4F77-4070-A88E-BFFE1C60529A */ +#define MINI_SETUP_GUID \ + { 0xB1DA0ADF, 0x4F77, 0x4070, { 0xA8, 0x8E, 0xBF, 0xFE, 0x1C, 0x60, 0x52, 0x9A } } + +#define SETUP_VARIABLE_GUID \ + { 0xEC87D643, 0xEBA4, 0x4BB5, { 0xA1, 0xE5, 0x3F, 0x3E, 0x36, 0xB2, 0x0D, 0xA9 } } + +/* 47C7B224-C42A-11D2-8E57-00A0C969723B */ +#define ENVIRONMENT_VARIABLE_ID \ + { 0x47c7b224, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } + +// End Notifications + + +// Status code reporting - Defines >> Start +// Defined in AmiStatusCodes.h +// Redefining for Aptio 3.x +#ifndef AMI_STATUS_CODE_CLASS +#define AMI_STATUS_CODE_CLASS EFI_OEM_SPECIFIC //0x8000 +#endif + +#ifndef AMI_DXE_BS_EC_INVALID_PASSWORD +#define AMI_DXE_BS_EC_INVALID_PASSWORD (AMI_STATUS_CODE_CLASS | 0x00000002) +#endif + +#ifndef AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR +#define AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR (AMI_STATUS_CODE_CLASS | 0x00000003) +#endif + +#ifndef AMI_DXE_BS_EC_BOOT_OPTION_FAILED +#define AMI_DXE_BS_EC_BOOT_OPTION_FAILED (AMI_STATUS_CODE_CLASS | 0x00000004) +#endif + + +#ifndef DXE_SETUP_VERIFYING_PASSWORD +#define DXE_SETUP_VERIFYING_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD) +#endif + +#ifndef DXE_SETUP_START +#define DXE_SETUP_START (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP) +#endif + +#ifndef DXE_SETUP_INPUT_WAIT +#define DXE_SETUP_INPUT_WAIT (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT) +#endif + +#ifndef DXE_READY_TO_BOOT +#define DXE_READY_TO_BOOT (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT) +#endif + +#ifndef DXE_INVALID_PASSWORD +#define DXE_INVALID_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_INVALID_PASSWORD) +#endif + +#ifndef DXE_BOOT_OPTION_LOAD_ERROR +#define DXE_BOOT_OPTION_LOAD_ERROR (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR) +#endif + +#ifndef DXE_BOOT_OPTION_FAILED +#define DXE_BOOT_OPTION_FAILED (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_BOOT_OPTION_FAILED) +#endif +// Status code reporting -Define >> End + +#define NG_SIZE 19 +#define WG_SIZE 38 + +#ifdef EFI_NT_EMULATOR +#define RUNTIME_DEBUG_SUPPORT +#define RUNTIME_DEBUG(str) { if ( __RuntimeCheckDebugMode( str ) ) _asm int 3 } +#else +#undef RUNTIME_DEBUG_SUPPORT +#define RUNTIME_DEBUG(str) +#endif + +#ifndef STANDALONE_APPLICATION +#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1 +extern SETUP_PKG _SetupPackage; +#endif +#else +extern UINT8 DummySetupData[]; +#endif + + +extern SCREEN_BUFFER *gActiveBuffer; +extern SCREEN_BUFFER *gFlushBuffer; +#ifdef USE_DEPRICATED_INTERFACE +extern UINT8 *STRING_ARRAY_NAME; +#else +#if APTIO_4_00 +#else +extern UINT8 STRING_ARRAY_NAME[]; +#endif +#endif +extern UINT8 *gApplicationData; +extern EFI_HANDLE gImageHandle; +extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; +extern UINT16 gCheckboxTokens[]; + +extern BOOLEAN gVariableChanged; +extern BOOLEAN gResetRequired; + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL +extern EFI_GRAPHICS_OUTPUT_PROTOCOL *gGOP; +#else +extern EFI_UGA_DRAW_PROTOCOL *gUgaDraw; +#endif + +#ifndef STANDALONE_APPLICATION +extern EFI_CONSOLE_CONTROL_PROTOCOL *gConsoleControl; +#endif + +//EIP75481 Support TSE debug print infrastructure + +#define PRINT_UEFI 1 +#define PRINT_UEFI_CALLBACK 2 +#define PRINT_UEFI_NOTIFICATION 4 +#define PRINT_UEFI_PARSE 8 + +#if SUPPRESS_PRINT + #define SETUP_DEBUG_TSE(format,...) + #define SETUP_DEBUG_UEFI(format,...) + #define SETUP_DEBUG_UEFI_PARSE(format,...) + #define SETUP_DEBUG_UEFI_NOTIFICATION(format,...) + #define SETUP_DEBUG_UEFI_CALLBACK(format,...) + #define SETUP_DEBUG_VAR(format,...) +#else //Else of SUPPRESS_PRINT + #define SETUP_DEBUG_TSE(format,...) SetupDebugPrint(format, __VA_ARGS__) + #define SETUP_DEBUG_UEFI(format,...) if((gDbgPrint & PRINT_UEFI)== PRINT_UEFI)SetupDebugPrint(format, __VA_ARGS__) + #define SETUP_DEBUG_UEFI_PARSE(format,...) if((gDbgPrint & PRINT_UEFI_PARSE)== PRINT_UEFI_PARSE)SetupDebugPrint(format, __VA_ARGS__) + #define SETUP_DEBUG_UEFI_NOTIFICATION(format,...) if((gDbgPrint & PRINT_UEFI_NOTIFICATION)== PRINT_UEFI_NOTIFICATION)SetupDebugPrint(format, __VA_ARGS__) + #define SETUP_DEBUG_UEFI_CALLBACK(format,...) if((gDbgPrint & PRINT_UEFI_CALLBACK)== PRINT_UEFI_CALLBACK)SetupDebugPrint(format, __VA_ARGS__) + #define SETUP_DEBUG_VAR(format,...) SetupDebugPrint(format, __VA_ARGS__) +#endif //End of SUPPRESS_PRINT +//EIP75481 + + +extern BOOLEAN gQuietBoot; +extern BOOLEAN gEnterSetup; +extern EFI_EVENT gKeyTimer; +extern EFI_EVENT gClickTimer; +extern UINT32 gPasswordType; + +extern UINTN gPostStatus; + +extern BOOT_DATA *gBootData; + +extern BOOT_DATA *gCurrLegacyBootData; + +extern UINTN gLangCount; +extern LANGUAGE_DATA *gLanguages; + +extern BOOLEAN gSetupContextActive; +extern BOOLEAN gPostMsgProtocolActive; +extern UINT8 gPostMgrAttribute; +extern AMI_VERSION gVersion_TSE; +extern UINT32 gStartPage; + +extern UINTN gLabelLeftMargin ; +extern UINTN gControlLeftPad ; +extern UINTN gControlLeftMargin; +extern UINTN gControlRightAreaWidth; + +extern UINTN gMaxRows; +extern UINTN gMaxCols; +extern UINTN gPostManagerHandshakeCallIndex; +extern UINT16 gDbgPrint ; + +extern EFI_GUID _gBootFlowGuid; +extern BOOLEAN gDoNotBoot; + +extern UINTN gCurrIDESecPage; + + +#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL +extern EFI_GUID gAmiEfiKeycodeProtocolGuid; +#endif + +//EIP-28501: To support SETUP_STORE_KEYCODE_PASSWORD options +#define PW_EFI_KEY 1 +#define PW_SCAN_CODE 2 + +#define DATE_STYLE_MMDDYYYY 0 +#define DATE_STYLE_YYYYDDMM 1 +#define DATE_STYLE_DDMMYYYY 2 +#define DATE_STYLE_YYYYMMDD 3 + +#define TIMER_ONE_SECOND (10 * 1000 * 1000) +#define TIMER_HALF_SECOND (TIMER_ONE_SECOND / 2) +#define TIMER_TENTH_SECOND (TIMER_ONE_SECOND / 10) + +#define STRUCT_OFFSET(type, field) (UINTN)&(((type *)0)->field) + +typedef struct _PROGRESSBAR_INFO //Structure containing global information used by progressbar handler +{ + UINTN x; // ProgressBar Left Position + UINTN y; // ProgressBar Top Position + UINTN w; // ProgressBar width + UINTN h; // ProgressBar Height + EFI_UGA_PIXEL *backgroundColor; // ProgressBar Background Color + EFI_UGA_PIXEL *borderColor; // ProgressBar Border Color + EFI_UGA_PIXEL *fillColor; // ProgressBar Fill Color + UINTN delta; // Varies increment + UINTN completed; // Varies increment + BOOLEAN quiteBootActive; // True if quiteBoot is active + BOOLEAN active; // True if progressbar has been initialized +}PROGRESSBAR_INFO; + +extern PROGRESSBAR_INFO *gProgress; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Function Number (0 = First Function). + /// + UINT8 FunctionNumber; +} AMITSE_PCCARD_DEVICE_PATH; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Firmware file name + /// + EFI_GUID FvFileName; +} AMITSE_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Tid; +} AMITSE_I2O_DEVICE_PATH; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// The MAC address for a network interface padded with 0s. + /// + EFI_MAC_ADDRESS MacAddress; + /// + /// Network interface type(i.e. 802.3, FDDI). + /// + UINT8 IfType; +} AMITSE_MAC_ADDR_DEVICE_PATH; + +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// The HBA port number that facilitates the connection to the + /// device or a port multiplier. The value 0xFFFF is reserved. + /// + UINT16 HBAPortNumber; + /// + /// The Port multiplier port number that facilitates the connection + /// to the device. Bit 15 should be set if the device is directly + /// connected to the HBA. + /// + UINT16 PortMultiplierPortNumber; + /// + /// Logical Unit Number. + /// + UINT16 Lun; +} AMITSE_SATA_DEVICE_PATH; +typedef struct { + EFI_DEVICE_PATH_PROTOCOL Header; + /// + /// Network Protocol (0 = TCP, 1+ = reserved). + /// + UINT16 NetworkProtocol; + /// + /// iSCSI Login Options. + /// + UINT16 LoginOption; + /// + /// iSCSI Logical Unit Number. + /// + UINT64 Lun; + /// + /// iSCSI Target Portal group tag the initiator intends + /// to establish a session with. + /// + UINT16 TargetPortalGroupTag; + /// + /// iSCSI NodeTarget Name. The length of the name + /// is determined by subtracting the offset of this field from Length. + /// + /// CHAR8 iSCSI Target Name. +} AMITSE_ISCSI_DEVICE_PATH; + +// box.c +VOID DrawLineWithAttribute( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib ); +VOID DrawLine( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type ); +VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height ); +VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow ); +VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib ); + +// buffer.c +EFI_STATUS InitializeScreenBuffer( UINT8 attrib ); +VOID SlowFlushLines( UINTN Top, UINTN Bottom ); +VOID FlushLines( UINTN Top, UINTN Bottom ); +VOID DoRealFlushLines(); +void SetDesiredTextMode(); + + +// logo.c +VOID CleanUpExtendedLogoWrapper(); +VOID DoLogoAnimateWrapper(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY); +VOID DrawBltProgressBar(/*UINTN completed*/ ); + +VOID DrawProgressBarBorder( + UINTN x, + UINTN y, + UINTN w, + UINTN h, + EFI_UGA_PIXEL *BltBuffer, + UINTN bw + ); + +VOID DrawBlock( + UINTN x, + UINTN y, + UINTN w, + UINTN h, + EFI_UGA_PIXEL *BltBuffer + ); + + +VOID DrawBltBuffer( + EFI_UGA_PIXEL *UgaBlt, + CO_ORD_ATTRIBUTE Attribute, + UINTN Width, + UINTN Height, + INTN DestX, + INTN DestY, + UINTN BufferWidth + ); +EFI_STATUS GetScreenResolution(UINTN *ResX, UINTN *ResY); + +typedef struct RefreshIdInfo{ + UINT8 *pEvent; + UINT8 *pNotifyContext; +} REFRESH_ID_INFO; + +// dobmpmgr.c +#if SETUP_BMP_LOGO_SUPPORT +EFI_STATUS ConvertBmpToUgaBlt (IN VOID *BmpImage, IN UINTN BmpImageSize, IN OUT VOID **UgaBlt, + IN OUT UINTN *UgaBltSize, OUT UINTN *PixelHeight, OUT UINTN *PixelWidth ); +#endif + +EFI_STATUS +ConvertAdvancedImageToUgaBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT VOID **UgaBlt, + IN OUT UINTN *UgaBltSize, + OUT UINTN *PixelHeight, + OUT UINTN *PixelWidth, + OUT BOOLEAN *Animate +); + +VOID DoLogoAnimate(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY); +VOID CleanUpExtendedLogo(VOID); + + +// minisetup.c +BOOLEAN __RuntimeCheckDebugMode( CHAR16 *string ); +VOID UIUpdateCallbackHook( VOID * Handle, UINT32 OldVariableCount );//EIP 129750: UIUpdateCallback as board module hook +EFI_STATUS MainSetupLoopHook( VOID );//EIP74591: MainSetupLoop as board module hook +EFI_STATUS Handshake( VOID ); +EFI_STATUS MiniSetupExit( EFI_STATUS Status ); +EFI_STATUS MiniSetupEntry( VOID ); + +//EIP# 58925 +extern UINT32 gNavStartPage ; +extern EFI_STATUS GetParentFormID(UINT16 ChildID, UINT16 *ParentID, UINT32 *StackIndex); +extern EFI_STATUS SetParentFormID(UINT16 ParentID, UINT16 TargetID); +extern VOID ResetNavStack(); +//EIP# 58925 + +// notify.c +EFI_STATUS RegisterNotification( VOID ); +VOID NotificationFunction( EFI_EVENT Event, VOID *Context ); +VOID ActivateApplication( VOID ); + +//EIP-75236 Starts +VOID ActivateInput( VOID ); +BOOLEAN GetNotifyMaskValue (VOID); +BOOLEAN IsDelayLogoTillInputSupported (VOID); +//EIP-75236 Ends + +// postmgmt.c +VOID EncodePassword( CHAR16 *Password, UINTN MaxSize ); +VOID CheckEnableQuietBoot( VOID ); +//UINTN DrawAMILogo( VOID ); +VOID InstallKeyHandlers( VOID ); +VOID InstallClickHandlers( VOID ); +VOID _DrawPasswordWindow(UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos); +VOID _ReportInBox(UINTN PasswordLength, UINT16 BoxToken, UINTN CurrXPos, UINTN CurrYPos, BOOLEAN bWaitForReturn); +EFI_STATUS _GetPassword(CHAR16 *PasswordEntered, UINTN PasswordLength, UINTN CurrXPos, UINTN CurrYPos, UINTN *TimeOut); + +// helper functions +VOID * HelperGetVariable( UINT32 variable, CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size ); +EFI_STATUS InitApplicationData(EFI_HANDLE ImageHandle); +VOID MiniSetupUIExit(VOID); +VOID TSEIDEPasswordCheck(); +VOID TSEIDEPasswordFreezeDevices(); +VOID TSEUnlockHDD(VOID); +extern NVRAM_VARIABLE *gVariableList; + +// EIP 76381 : Performance Improving of variable data load and usage +extern NVRAM_VARIABLE *gCurrNvramVarList; +extern UINTN gCurrNvramVarCount; + +#define VARIABLE_ID_SETUP 0 +#define VARIABLE_ID_LANGUAGE 1 +#define VARIABLE_ID_BOOT_TIMEOUT 2 +#define VARIABLE_ID_USER_DEFAULTS 3 +#define VARIABLE_ID_ERROR_MANAGER 4 +#define VARIABLE_ID_AMITSESETUP 5 +#define VARIABLE_ID_IDE_SECURITY 6 +#define VARIABLE_ID_BOOT_ORDER 7 +#define VARIABLE_ID_BBS_ORDER 8 +#define VARIABLE_ID_DEL_BOOT_OPTION 9 +#define VARIABLE_ID_ADD_BOOT_OPTION 10 +#define VARIABLE_ID_BOOT_MANAGER 11 +#define VARIABLE_ID_BOOT_NOW 12 +#define VARIABLE_ID_LEGACY_DEV_INFO 13 +#define VARIABLE_ID_AMI_CALLBACK 14 +#define VARIABLE_ID_LEGACY_GROUP_INFO 15 +#define VARIABLE_ID_OEM_TSE_VAR 17 +#define VARIABLE_ID_DYNAMIC_PAGE_COUNT 18 + +UINT16 GetBootTimeOut(UINT16 DefaultValue); +EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer); +EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size); +void UpdateAddDeleteBootVar(void); +UINT16 * BootNowinBootOrderInit(VOID); +BOOT_DATA * BootGetBootNowBootData(BOOT_DATA *bootData, UINT16 *BootOrder, UINTN i ); +BOOLEAN NoVarStoreSupport(VOID); +BOOLEAN ItkSupport(VOID); +VOID UpdateLegacyDevVariable(UINT16 NoOfLegacyGroups); +VOID CsmBBSSetBootPriorities( BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount); +CHAR16 *CsmBBSBootOptionName( BOOT_DATA *bootData); +EFI_STATUS CsmBBSSetBootNowPriority( BOOT_DATA *BootData,UINTN uiPrefferedDevice,BOOLEAN ShowAllBbsDev); +VOID CsmBBSGetDeviceList( VOID ); +EFI_STATUS CsmBBSLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath ); +EFI_STATUS InstallFormBrowserProtocol(EFI_HANDLE Handle); +VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle); +EFI_STATUS DoBbsPopupInit(VOID); +VOID MainSetupLoopInit(VOID); +UINTN TseGetANSIEscapeCode(CHAR16 *String,UINT8 *Bold,UINT8 *Foreground, UINT8 *Background); +CHAR16 *TseSkipEscCode(CHAR16 *String); +VOID DrawBootOnlyBbsPopupMenu( VOID ); +VOID BbsBoot(VOID); +VOID BootGetLanguages(); + +extern BOOLEAN PlatformLangVerSupport(); +extern BOOLEAN BootNowInBootOrderSupport(); + +VOID TseBootAddBootOption(); +BOOLEAN CheckForAddDelBootOption(); +VOID TSESpecialFixupDelBootOption(VOID *ControlInfo); +VOID TseDoAddBootOptionFixup(VOID *ControlInfo ); +BOOLEAN TseDoBootDelBootOption(VOID *popupSel); +VOID TseDiscardAddDelBootOptions(); +VOID TseSaveAddDelBootOptions(); + +// EIP-41615: Functions for the file browser support in add boot option +VOID TseLaunchFileSystem(); + +VOID TseBBSSetBootPriorities_BootOrder(UINT16 Priority); //EIP-24971: moved TSE_CONTINUE_BOOT_NOW_ON_FAIL support to Binary. + +#define ___INTERNAL_CONVERT_TO_WSTRING___(a) L#a +#define CONVERT_TO_WSTRING(a) ___INTERNAL_CONVERT_TO_WSTRING___(a) + +///Extended checks for Add/Delete Boot Option support +BOOLEAN IsUpdateBootOrderCursor(); +BOOLEAN IsReservedBootOptionNamesEnable(); +BOOLEAN IsPreservedDisabledBootOptionOrder(); +EFI_STATUS FastBootLaunch(VOID); +extern BOOLEAN gIsSaveDisabledBBSDevicePath; +VOID UpdateGoPUgaDraw( VOID );//EIP:50479 : Function to Update gGop before using it in AMITSE. +//EIP:51671 Start +//Function declarations +BOOLEAN IsBootDeviceEnabled( UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup); +BOOLEAN BootGetOptionStatus(BOOT_DATA *bootData, BOOLEAN FromSetup ); +BOOLEAN BootGetBBSOptionStatus(BOOT_DATA *bootData, UINT16 value, BOOLEAN FromSetup, BOOLEAN ShowAllBBSDev); +//EIP:51671 End +VOID RedrawGif(VOID);//EIP:53740 : Function to Redraw the Gif animated image. +BOOLEAN LoadOptionhidden(UINT16, BOOLEAN); //EIP:59417 - Fucntion Decleration to check the LOAD_OPTION_HIDDEN attribute for a boot option +EFI_STATUS TSEGetCoordinates(INT32 *x, INT32 *y, INT32 *z); +BOOLEAN CheckHiddenforBootDriverOption (UINT16, BOOLEAN); + +//EIP70421 & 70422 Support for driver order starts +extern BOOT_DATA *gDriverData; +void UpdateAddDeleteDriverVar (void); +VOID TseDriverAddDriverOption(); +VOID TSESpecialFixupDelDriverOption (VOID *); +BOOLEAN TseDoDriverDelDriverOption(VOID *popupSel); +VOID TseDiscardAddDelDriverOptions(); +VOID TseSaveAddDelDriverOptions(); +//EIP70421 & 70422 Support for driver order ends +BOOLEAN IsTSEMultilineControlSupported (VOID); //EIP-72610 Moved TSE_MULTILINE_CONTROLS to binary +UINT32 GetMsgboxWidth(VOID);//EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary +extern const UINTN TsePasswordLength; +VOID GetAMITSEVariable(AMITSESETUP **mSysConf,UINT8 **setup,UINTN *VarSize); +VOID NoVarStoreUpdateSystemAccess(UINT8 sysAccessValue); +VOID SetSystemAccessValueItk(UINT8 sysAccessValue); +VOID TSEStringReadLoopEntryHook(VOID); +VOID TSEStringReadLoopExitHook(VOID); +UINT32 PasswordAuthenticate( CHAR16 *Password ); +EFI_STATUS AMIReadKeyStroke(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData); +EFI_STATUS HelperIsPasswordCharValid(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData,UINTN StrIndex,UINTN PasswordLength, CHAR16 *OutChar); +VOID TSEIDEUpdateConfig(VOID *ideSecConfig, UINTN value); +//EIP 77400 +#define EFI_SHELL_PROTOCOL_GUID \ + { \ + 0x47C7B223, 0xC42A, 0x11D2, 0x8E, 0x57, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \ + } +#endif /* _MINISETUP_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/minisetupext.c b/EDK/MiniSetup/BootOnly/minisetupext.c new file mode 100644 index 0000000..5065488 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/minisetupext.c @@ -0,0 +1,927 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetupext.c $ +// +// $Author: Premkumara $ +// +// $Revision: 16 $ +// +// $Date: 8/28/14 8:37a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetupext.c $ +// +// 16 8/28/14 8:37a Premkumara +// [TAG] EIP142551 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Mouse Movement is not initialized to Full Screen Resolution +// in case of quiet boot mode with high resolution OEM Logo. +// [Root Cause] Mouse Initialization was not across the full screen incase +// of High Resolution Quiet Boot Logo. +// [Solution] Initialised the Mouse with the Resolution Set in case of +// Quiet Boot logo so that Mouse will move acroos the Whole screen +// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c, +// Notify.c, MinisetupExt.c +// +// 15 5/02/14 3:56a Premkumara +// [TAG] EIP151966 +// [Category] Improvement +// [Description] Added the implementation for getting the BIOS build +// year dynamically +// from TimeStamp.h file and updated the Build year in copyright message +// in both Setup and POST. +// [Files] style.c,style.c,style.c,notify.c,minisetupext.c,CommonHelper +// .c, +// AmiTSEStr.uni,AMITSE.mak +// +// 14 2/11/14 7:59p Arunsb +// [TAG] EIP131739 +// [Category] Bug Fix +// [Severity:] Important +// [Symptom:] UI is not Displaying properly after enabling Quite Boot +// [Root Cause] While doing MainSetupLoopInit() it changes the mode to +// Text. +// [Solution] A hook function is created in ESA which keeps the mode as +// Graphics +// [Files] minisetupext.c +// +// 13 12/04/13 2:10p Premkumara +// [TAG] EIP123535 +// [Category] Improvement +// [Description] Moved saving quietboot resolution to DrawQuietBootLogo() +// to avoid setting resolution of initPostScreenthis while booting. +// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c +// +// 12 12/04/13 5:29a Premkumara +// [TAG] EIP123535 +// [Category] Improvement +// [Description] Moved saving quietboot resolution to DrawQuietBootLogo() +// to avoid setting resolution of initPostScreenthis while booting. +// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c +// +// 11 3/16/13 4:02a Rajashakerg +// [TAG] EIP107221 +// [Category] Improvement +// [Description] Logo disappear after HDD password verified +// [Files] CommonHelper.c, notify.c, minisetupext.c +// +// 10 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 13 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 9 5/29/12 4:33a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 8 4/25/12 6:08a Rajashakerg +// [TAG] EIP86827 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] "gBootFlow" variable should be changed to +// BOOT_FLOW_CONDITION_NORMAL if we press ESC key from pop-pup menu +// [RootCause] ProcessProceedToBootHook() is not invoked when we press +// ESC key in the BBS popup Menu. +// [Solution] Fixed the issue by calling ProcessProceedToBootHook() when +// we press ESC key in the BBS popup Menu. +// [Files] BootOlny/minisetupext.c, TseLite/minisetupext.c. +// +// 7 6/23/11 5:32a Rajashakerg +// [TAG] EIP63073 +// [Category] New Feature +// [Description] Source modules in TSE should get the version details +// from binary in run time not at build time +// [Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c, +// EzportPlus\style.c, Legacy\style.c +// +// 6 4/16/10 5:13p Madhans +// Changes for Tse 2.02. Please see Changelog.log for more details. +// +// 5 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 8 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 7 2/15/10 10:10p Madhans +// To avoid Compilation issues +// +// 6 1/29/10 4:37p Madhans +// To not to depend on ConsoleControl and ConOut. +// +// 5 1/09/10 5:28a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 4 8/13/09 7:35a Mallikarjunanv +// eip:24971 - supporting tse features without tse sources +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 3 5/13/09 2:22p Madhans +// To patch the version number in the Bootonly TSE. update the build +// number. +// +// 2 5/07/09 10:35a Madhans +// Changes after Bin module +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 3:59p Madhans +// fix in ClearGrphxScreen +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: MINISETUPEXT.C +// +// Description: This file contains code for entrypoint and setup loop +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + + +//**************************** BBS POPUP CODE ********************************// + +//#if SETUP_BBS_POPUP_ENABLE +extern EFI_GUID gBootNowCountGuid; +UINT16 gBBSPopupSel; + +extern NVRAM_VARIABLE *gOptimalDefaults; +extern UINTN CurrentScreenresolutionX, CurrentScreenresolutionY;//EIP-105717 + +struct DevName +{ + CHAR16 *String; + int Index; +} *gDevNames; + +int gHiStr = 0; +int gStrIdx = 0; +int gNumOfDev = 0; +CHAR16 *gBlankSpace = L" "; +#define START_ROW_IDX 10 +#define START_COL_IDX 20 +#define MAX_STR_LEN 28 +#define MAX_LENGTH (MAX_STR_LEN+7) +#define MAX_DISP_LINES 8 + +#define _ENTER_KEY 0x0D +#define _ESC_KEY 0x170000 +#define _UP_ARROW 0x10000 +#define _DOWN_ARROW 0x20000 + +void CheckStrings(void); +void SetScrollPosition(int Index, int DirFlg); +INTN BBS_GetKey(VOID); +EFI_STATUS BbsPopupMenu( VOID ); +void HighLightLine(int UpDown, int NumLines); +void DownDisplayList(int Start, int End, int NumLines); +void UpDisplayList(int Start, int End, int flag, int NumLines); +VOID MainSetupLoopInitHook(VOID); +UINT16 _BootSetBootNowCount(VOID); +CHAR16 *HiiGetStringLanguage( VOID* handle, UINT16 token, CHAR16 *lang ); +UINT16 HiiChangeStringLanguage( VOID* handle, UINT16 token, CHAR16 *lang, CHAR16 *string ); +VOID GetTseBuildVersion(UINTN *TseMajor, UINTN *TseMinor, UINTN *TseBuild);//EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time +VOID GetTseBuildYear(UINT16 *TseBuildYear);//EIP 151966 : Use BIOS build year for copyright message +BOOLEAN IsMouseSupported(VOID); +BOOLEAN IsSoftKbdSupported(VOID); +// +//---------------------------------------------------------------------------- +// Procedure: ClearGrphxScreen +// +// Description: Function to clear the graphics screen. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void ClearGrphxScreen(void) +{ + EFI_UGA_PIXEL UgaBlt={0,0,0,0}; + UINT32 HorizontalResolution = 0; + UINT32 VerticalResolution = 0; + EFI_STATUS Status = EFI_SUCCESS; + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if(gGOP) + { + HorizontalResolution = gGOP->Mode->Info->HorizontalResolution; + VerticalResolution = gGOP->Mode->Info->VerticalResolution; + Status = gGOP->Blt ( + gGOP, + &UgaBlt, + EfiBltVideoFill, + 0, 0, + 0, 0, + HorizontalResolution, VerticalResolution, + 0); + } +#else + if ( gUgaDraw != NULL ) + { + gUgaDraw->GetMode (gUgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); + Status = gUgaDraw->Blt ( + gUgaDraw, + &UgaBlt, + EfiUgaVideoFill, + 0, 0, + 0, 0, + HorizontalResolution, VerticalResolution, + 0); + } +#endif +} + + +// +//---------------------------------------------------------------------------- +// Procedure: DoBbsPopupInit +// +// Description: This function runs the loop for Pop up boot menu. +// This function is responsible for creating the list +// box control. It also gathers actions and passes them +// to list box control and initiates draw sequence. +// +// Input: BOOT_FLOW *BootFlow: Ptr to BOOT_FLOW responsible for +// the call. +// +// Output: Return Status based on errors that occurred in +// library functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS DoBbsPopupInit(VOID) +{ + EFI_STATUS Status = EFI_SUCCESS; + UINT16 i=0, u16BootCount = 2, *pu16BootCount = NULL; + UINTN size = 0; + UINT16 count; + + PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0); + + MainSetupLoopInitHook(); + + count = (UINT16)gBootOptionCount; + + if(gPopupMenuShowAllBbsDev) + count = _BootSetBootNowCount(); + + VarSetNvramName( L"BootNowCount", &gBootNowCountGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) ); + + Status = VarLoadVariables( (VOID **)&gVariableList, (NVRAM_VARIABLE *)gOptimalDefaults ); + if ( EFI_ERROR( Status ) ) + return Status; + +#if APTIO_4_00 + gMaxRows = MAX_ROWS; + gMaxCols = MAX_COLS; +#endif + + pu16BootCount = VarGetNvramName( L"BootNowCount", &gBootNowCountGuid, NULL, &size ); + if(pu16BootCount) + u16BootCount = *pu16BootCount; + MemFreePointer(&pu16BootCount); + + //For Boot Only TSE + gDevNames = EfiLibAllocatePool(u16BootCount * (sizeof(*gDevNames))); + for (i=0; i +//---------------------------------------------------------------------------- +// Procedure: DrawBootOnlyBbsPopupMenu +// +// Description: function for the BBS Popup menu +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawBootOnlyBbsPopupMenu( VOID ) +{ + int Row = 0; + INTN Key; + int DispLines=0; + int EnoughOfThis = 0; + + if(gST->ConOut == NULL) + return; + + SetDesiredTextMode(); + // Clean of the Graphics Screen + ClearGrphxScreen(); + ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ); + + //Initialise the global buffers + InitializeScreenBuffer( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ); + + //check the lengh of device strings, and truncate if it is out of boundaries + CheckStrings(); + + //Create heading + DrawStringWithAttribute( START_COL_IDX+(MAX_STR_LEN/2)-4, START_ROW_IDX-2, L"BBS MENU", EFI_WHITE); + DrawBorder( START_COL_IDX-3, START_ROW_IDX-3, MAX_LENGTH, 3); + + if( gNumOfDev < MAX_DISP_LINES ) + { + DispLines = gNumOfDev; + } + else { + DispLines = MAX_DISP_LINES; + } + //print all the avilable device info + for( Row=START_ROW_IDX; Row < START_ROW_IDX+DispLines; Row++ ) { + DrawStringWithAttribute( START_COL_IDX, Row, gDevNames[Row-START_ROW_IDX].String, EFI_LIGHTGRAY); + } + DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, DispLines+2); + + //keep the cursor in the staring line of strings display + gST->ConOut->SetCursorPosition( gST->ConOut, START_COL_IDX, START_ROW_IDX ); + + //highlight first option in the list by default + DrawStringWithAttribute( START_COL_IDX, START_ROW_IDX, gDevNames[0].String, EFI_WHITE); + DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, DispLines+2); + + WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX+MAX_LENGTH-4),BOXDRAW_VERTICAL_LEFT, EFI_WHITE ); + WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX-3),BOXDRAW_VERTICAL_RIGHT, EFI_WHITE ); + + SetScrollPosition(DispLines, 2); + FlushLines( 0, gMaxRows - 1 ); + DoRealFlushLines(); + + while(TRUE) + { + //Get input key + Key = BBS_GetKey(); + + if(_ESC_KEY == Key) { + PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0); + gBBSPopupSel = 0 ; + EnoughOfThis = 1 ; + ProcessProceedToBootHook();//EIP 86827 : When ESC pressed in the BBS popup menu + break; + } + + switch(Key) + { + case _DOWN_ARROW: + if(gStrIdx<(gNumOfDev-1)) { + gStrIdx++; + if( gHiStr >= (DispLines-1) ) { + DownDisplayList(gStrIdx-(DispLines-1), gStrIdx, DispLines); + } + else { + HighLightLine(0, DispLines); + } + } + break; + + case _UP_ARROW: + + if(gStrIdx > 0) { + gStrIdx--; + if( gHiStr == 0 ) { + if(gStrIdx>=0) + UpDisplayList(gStrIdx, gStrIdx+(DispLines-1), 0, DispLines); + } + else if( gHiStr > 0 ) { + HighLightLine(1, DispLines); + } + } + break; + + case _ENTER_KEY: + if( ( gStrIdx >= 0) && ( gStrIdx <= gNumOfDev) ) { + //call the function with the selected device index + PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0); + gBBSPopupSel = (UINT16) gStrIdx ; + EnoughOfThis = 1 ; + } + break; + } + DoRealFlushLines(); + if(EnoughOfThis) + break ; + } +} +// +//---------------------------------------------------------------------------- +// Procedure: BbsBoot +// +// Description: This function is a hook called after launching +// BBS Popup Menu. This function is available as +// ELINK. In the generic implementation this function is +// empty. OEMs may choose to do additional logic here. +// +// Input: index: The nth option in the boot now menu. +// ShowAllBbsDev - SETUP_SHOW_ALL_BBS_DEVICES +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// + +VOID BbsBoot(VOID) +{ + if(gEnterSetup != TRUE) + BootLaunchBootNow(gBBSPopupSel, gPopupMenuShowAllBbsDev) ; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BbsStrnCpy +// +// Description: function the string copy +// +// Input: CHAR16 *Dst, CHAR16 *Src, UINTN Length +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BbsStrnCpy ( CHAR16 *Dst, CHAR16 *Src, UINTN Length ) +{ + UINTN Index; + UINTN SrcLen; + + SrcLen = EfiStrLen (Src); + + Index = 0; + while (Index < Length && Index < SrcLen) { + Dst[Index] = Src[Index]; + Index++; + } + + for (Index = SrcLen; Index < Length; Index++) { + Dst[Index] = 0; + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBS_GetKey +// +// Description: function to read the input key +// +// Input: void +// +// Output: ScanCode/UniCode +// +//---------------------------------------------------------------------------- +// +INTN BBS_GetKey(VOID) +{ + EFI_INPUT_KEY Key; + UINTN Index; + + // flush keyboard buffer + while ( gST->ConIn->ReadKeyStroke(gST->ConIn,&Key) == EFI_SUCCESS ); + + gBS->WaitForEvent( 1, &gST->ConIn->WaitForKey, &Index ); + gST->ConIn->ReadKeyStroke(gST->ConIn,&Key); + return (Key.ScanCode<<16)|Key.UnicodeChar; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CheckStrings +// +// Description: function to validate the stings +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void CheckStrings(void) +{ + int idx; + UINTN Length=0; + CHAR16 TmpStr[50]; + + for( idx=0; idx < gNumOfDev; idx++ ) { + + + Length = EfiStrLen( gDevNames[idx].String ); + + if(Length > MAX_STR_LEN) + { + BbsStrnCpy(TmpStr,L" ",MAX_STR_LEN); + BbsStrnCpy(TmpStr, gDevNames[idx].String, (MAX_STR_LEN-3)); + EfiStrCpy (TmpStr + EfiStrLen(TmpStr),L"..."); + + BbsStrnCpy(gDevNames[idx].String,L" ",Length); + BbsStrnCpy(gDevNames[idx].String, TmpStr, MAX_STR_LEN); + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetScrollPosition +// +// Description: function to set the position of the Scroll bar +// +// Input: int Index, int DirFlg +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void SetScrollPosition(int Index, int DirFlg) +{ + if(gNumOfDev > MAX_DISP_LINES) + { + if(DirFlg==2) { + WriteCharWithAttribute( (START_ROW_IDX+Index-1), (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_DOWN_TRIANGLE, EFI_WHITE ); + } + else if( (DirFlg==0) && (gStrIdx>Index-1) ) { + if(gStrIdx!= gNumOfDev-1) + WriteCharWithAttribute( (START_ROW_IDX+Index-1), (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_DOWN_TRIANGLE, EFI_WHITE ); + WriteCharWithAttribute( START_ROW_IDX, (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_UP_TRIANGLE, EFI_WHITE ); + } + else if( (DirFlg==1) && (gStrIdx +//---------------------------------------------------------------------------- +// Procedure: UpDisplayList +// +// Description: function to display the upside list +// +// Input: int Start, int End, int flag, int NumLines +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void UpDisplayList(int Start, int End, int flag, int NumLines) +{ + int RowNum, i; + + i= End; + for( RowNum=START_ROW_IDX; Start<=End; RowNum++ ) { + DrawStringWithAttribute( START_COL_IDX, RowNum, gBlankSpace, 0); + DrawStringWithAttribute( START_COL_IDX, RowNum, gDevNames[Start++].String, EFI_LIGHTGRAY); + } + DrawStringWithAttribute( START_COL_IDX, (RowNum-NumLines), gBlankSpace, 0); + DrawStringWithAttribute( START_COL_IDX, (RowNum-NumLines), gDevNames[Start-NumLines].String, EFI_WHITE); + DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, (NumLines+2)); + + WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX+MAX_LENGTH-4),BOXDRAW_VERTICAL_LEFT, EFI_WHITE ); + WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX-3),BOXDRAW_VERTICAL_RIGHT, EFI_WHITE ); + + SetScrollPosition(NumLines, 1); + + FlushLines( 0, gMaxRows - 1 ); + + if(gHiStr) gHiStr--; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DownDisplayList +// +// Description: function to display the downside list +// +// Input: int Start, int End, int NumLines +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void DownDisplayList(int Start, int End, int NumLines) +{ + int RowNum; + + for( RowNum=START_ROW_IDX; Start +//---------------------------------------------------------------------------- +// Procedure: HighLightLine +// +// Description: function to hilight a perticular line +// +// Input: int UpDown, int NumLines +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void HighLightLine(int UpDown, int NumLines) +{ + + if(UpDown) { + DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr-1), gDevNames[gStrIdx].String, EFI_WHITE); + DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr), gDevNames[gStrIdx+1].String, EFI_LIGHTGRAY); + DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, (NumLines+2)); + } + else { + DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr+1), gDevNames[gStrIdx].String, EFI_WHITE); + DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr), gDevNames[gStrIdx-1].String, EFI_LIGHTGRAY); + DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, (NumLines+2)); + } + WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX+MAX_LENGTH-4),BOXDRAW_VERTICAL_LEFT, EFI_WHITE ); + WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX-3),BOXDRAW_VERTICAL_RIGHT, EFI_WHITE ); + + SetScrollPosition(NumLines, UpDown); + FlushLines( 0, gMaxRows - 1 ); + + if(UpDown) { + if( gHiStr>0 ) gHiStr--; + } + else{ + if( gHiStr<(NumLines-1) ) gHiStr++; + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: InitgProgress +// +// Description: +// +// Input: No Arguments +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID InitgProgress( VOID ) +{ + gProgress = EfiLibAllocateZeroPool(sizeof (PROGRESSBAR_INFO) ); + gProgress->quiteBootActive = FALSE ; + gProgress->active = FALSE ; + gProgress->completed = 0 ; + gProgress->delta = 0 ; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: BootOnlyUpdateVersionString +// +// Description: Function to update version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID BootOnlyUpdateVersionString( VOID ) +{ + CHAR16 *string = NULL, *newString = NULL; + UINTN length,TseMajor,TseMinor, TseBuild; + UINT16 TseBuildYear=0; + UINTN i; + + for ( i = 0; i < gLangCount; i++ ) + { + string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode ); + if ( string == NULL ) + return; + + length = EfiStrLen(string) + 10; + newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) ); + if ( newString != NULL ) + { + //EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time + GetTseBuildVersion(&TseMajor,&TseMinor,&TseBuild); + //EIP 151966 : Use BIOS build year for copyright message + GetTseBuildYear(&TseBuildYear); + SPrint( newString, length * sizeof(CHAR16), string, TseMajor, TseMinor, TseBuild,TseBuildYear ); + HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode, newString ); + } + + MemFreePointer( (VOID **)&newString ); + MemFreePointer( (VOID **)&string ); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SavePostScreen +// +// Description: Function to save the post screen +// +// Input: UINTN *SizeOfX, UINTN *SizeOfY +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +VOID *SavePostScreen( UINTN *SizeOfX, UINTN *SizeOfY ) +{ + EFI_UGA_PIXEL *UgaBlt = NULL; + UINTN UgaBltSize; + EFI_STATUS Status = EFI_UNSUPPORTED; + + UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE. + + MouseStop(); + if ( gQuietBoot ) + { + if(EFI_SUCCESS == GetScreenResolution(SizeOfX,SizeOfY)) + { + UgaBltSize = (*SizeOfX) * (*SizeOfY) * sizeof(EFI_UGA_PIXEL); + UgaBlt = EfiLibAllocatePool(UgaBltSize); + + if(UgaBlt) + { +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + Status = gGOP->Blt( + gGOP, + UgaBlt, + EfiBltVideoToBltBuffer, + 0, 0, + 0, 0, + *SizeOfX, *SizeOfY, + 0); +#else + Status = gUgaDraw->Blt( + gUgaDraw, + UgaBlt, + EfiBltVideoToBltBuffer, + 0, 0, + 0, 0, + *SizeOfX, *SizeOfY, + 0); +#endif + } + } + } + + MouseRefresh(); + return (VOID *)UgaBlt; +} + +// +//---------------------------------------------------------------------------- +// Procedure: RestorePostScreen +// +// Description: Function to restore the saved screen +// +// Input: VOID *UgaBlt, UINTN SizeOfX, UINTN SizeOfY +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID RestorePostScreen( VOID *UgaBlt, UINTN SizeOfX, UINTN SizeOfY ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + EFI_UGA_PIXEL *Buffer = (EFI_UGA_PIXEL *)UgaBlt; + + MouseStop(); + if ( Buffer ) + { + if(gConsoleControl != NULL) + gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenGraphics ); + + if( (NULL != gGOP) && (SizeOfX && SizeOfY) && //If it has vaild gGOP and Resolution + ( (SizeOfX != gGOP->Mode->Info->HorizontalResolution) || (SizeOfY != gGOP->Mode->Info->VerticalResolution) ) //If QuietBoot resolution is differ + )//EIP-105717 + { + GOPSetScreenResolution(&SizeOfX, &SizeOfY); + } + + if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present + MouseInit(); + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + Status = gGOP->Blt ( + gGOP, + Buffer, + EfiBltBufferToVideo, + 0, 0, + 0, 0, + SizeOfX, SizeOfY, + 0); +#else + Status = gUgaDraw->Blt ( + gUgaDraw, + Buffer, + EfiUgaBltBufferToVideo, + 0, 0, + 0, 0, + SizeOfX, SizeOfY, + 0); +#endif + } + + MouseRefresh(); + // If ConOut is available in System Table the activate the post screen. + if ( gST->ConOut != NULL ) + { + //Show post screen if it is not quiet boot or if it is a headless system +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if ( ! gQuietBoot || !gGOP) +#else + if ( ! gQuietBoot || !gUgaDraw) +#endif + { + //Clear the flush buffer to avoid messages missing + MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0); + + CleanUpLogo(); + InitPostScreen(); + } + } + MemFreePointer((VOID **) &Buffer); + +} +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/notify.c b/EDK/MiniSetup/BootOnly/notify.c new file mode 100644 index 0000000..8507ac9 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/notify.c @@ -0,0 +1,1271 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/notify.c $ +// +// $Author: Premkumara $ +// +// $Revision: 46 $ +// +// $Date: 8/28/14 8:35a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/notify.c $ +// +// 46 8/28/14 8:35a Premkumara +// [TAG] EIP142551 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Mouse Movement is not initialized to Full Screen Resolution +// in case of quiet boot mode with high resolution OEM Logo. +// [Root Cause] Mouse Initialization was not across the full screen incase +// of High Resolution Quiet Boot Logo. +// [Solution] Initialised the Mouse with the Resolution Set in case of +// Quiet Boot logo so that Mouse will move acroos the Whole screen +// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c, +// Notify.c, MinisetupExt.c +// +// 45 7/12/14 5:46p Arunsb +// [TAG] EIP160126 +// [Category] Bug Fix +// [Severity:] Normal +// [Symptom:] When Softkbd Enabled, Post display gets delayed +// [Root Cause] If softkbd enabled then TSE waits up to mouse +// notification. +// Mouse notification will happen next to installing conin so delayed. +// [Solution] Mouse initialized only when softkbd present and password +// installed. +// Removed NOTIFY_MASK_MOUSE_DRIVER in SETUP_DELAY_LOGO_TILL_INPUT +// [Files] CommonHelper.c and BootOnly\notify.c +// +// 44 5/02/14 3:59a Premkumara +// [TAG] EIP151966 +// [Category] Improvement +// [Description] Added the implementation for getting the BIOS build +// year dynamically +// from TimeStamp.h file and updated the Build year in copyright message +// in both Setup and POST. +// [Files] style.c,style.c,style.c,notify.c,minisetupext.c,CommonHelper +// .c, +// AmiTSEStr.uni,AMITSE.mak +// +// 43 5/02/14 12:05a Arunsb +// [TAG] EIP141066,141084,144118 +// [Category] Bug Fix +// [Severity] Normal +// [RootCause] Keys in USB and PS2 are not working to enter into setup. +// [Solution] Hanlded ConsoleInHandle proplerly with ConsoleOutHandle +// when ConIn is available. +// [Files] Notify.c +// +// 42 2/11/14 8:06p Arunsb +// Changes reverted for 2.16.1243 label +// +// 41 11/26/13 7:57a Premkumara +// [TAG] EIP141066,141084,144118 +// [Category] Bug Fix +// [Severity] Normal +// [RootCause] Keys in USB and PS2 are not working to enter into setup. +// [Solution] Hanlded ConsoleInHandle proplerly with ConsoleOutHandle +// when ConIn is available. +// [Files] Notify.c +// +// 40 5/23/13 12:56a Arunsb +// [TAG] EIP103962 +// [Description] Reverting the notify TPL from EFI_TPL_NOTIFY to +// EFI_TPL_CALLBACK +// [Files] notify.c +// +// 39 4/17/13 1:11a Arunsb +// [TAG] EIP121116 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] AMI small logo has damage on POST and boot +// [RootCause] When system starts with higher text resolution more than +// 100*31 then TSE not setting proper text mode +// [Solution] Mode set properly +// [Files] notify.c and postmgmt.c +// +// 38 3/16/13 4:00a Rajashakerg +// [TAG] EIP107221 +// [Category] Improvement +// [Description] Logo disappear after HDD password verified +// [Files] CommonHelper.c, notify.c, minisetupext.c +// +// 37 3/08/13 2:57a Premkumara +// [TAG] EIP116451 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] When User password alone is set, Setup gets hang in post +// while validating User Password. +// [RootCause] ConsoleInHandle is NULL while validating password. +// [Solution] Setting gST->ConsoleInHandle with "gST->ConsoleInHandle" +// to locate the Keycode protocol +// [Files] nofify.c +// +// 36 1/27/13 11:36p Rajashakerg +// [TAG] EIP103962 +// [Category] Improvement +// [Description] AMITSE Simpletextin, Simpletextout etc event should +// have high priority. +// [Files] notify.c +// +// 35 12/05/12 4:57a Premkumara +// [TAG] EIP105717 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Splash logo is not displaying when Admin/User password is +// set in setup +// [RootCause] The resolution is not handled properly while drawing +// QuietBoot logo +// [Solution] Restoring the QuietBoot logo resolution after drawing +// password window. +// [Files] Notify.c +// +// 34 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 20 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 32 9/26/12 7:21a Arunsb +// Avoided calling ActivateInput twice +// +// 31 9/26/12 4:08a Premkumara +// [TAG] EIP98112 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] When the SETUP_DELAY_LOGO_TILL_INPUT set to 1, +// ActivateInput() function called very late. +// [RootCause] ActivateInput and ProcessconInavailability are not +// handled properly +// [Solution] Handled ActivateInput(), ActivateAppilcation() and +// ProcessConInAvailability() properly when all device are available +// [Files] Notify.c +// +// 30 9/25/12 7:20a Premkumara +// Updated missed changes for EIP98112 +// +// 29 9/24/12 10:28a Premkumara +// [TAG] EIP98112 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] When the SETUP_DELAY_LOGO_TILL_INPUT set to 1, +// ActivateInput() function called very late. +// [RootCause] ActivateInput and ProcessconInavailability are not +// handled properly +// [Solution] Handled ActivateInput(), ActivateAppilcation() and +// ProcessConInAvailability() properly when all device are available +// [Files] Notify.c +// +// 28 9/21/12 6:14a Arunsb +// GopEvent corrected +// +// 27 9/20/12 11:52a Arunsb +// [TAG] EIP92497 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] ActivateApplication is delayed when softkeyboard is added +// [RootCause] Notification functions not handled properly +// [Solution] Notification functions changed from switch to if condition +// [Files] notify.c +// +// 26 9/18/12 12:50a Rajashakerg +// [TAG] EIP95518 +// [Category] Improvement +// [Description] Validate the Gop before usage in all the possible cases +// and also get instance of Gop through notification +// [Files] boot.c, notify.c, logo.c +// +// 25 9/17/12 6:10a Rajashakerg +// Updated EIP changes for 2.16 release. +// +// 23 8/29/12 4:22p Arunsb +// [TAG] EIP94702 +// [Description] Support for Native Resolution in POST/BOOT +// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c, +// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c, +// ezportplus/stylecommon.c andlegacy/stylecommon.c +// +// 22 8/27/12 6:20a Premkumara +// [TAG] EIP 94616 +// [Category] Improvement +// [Description] TSE should not wait for key if fast boot is in progress +// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Protocol.c +// +// 21 5/28/12 5:47a Premkumara +// [TAG] EIP75236 +// [Category] Improvement +// [Description] Add the support to control the GOP dependency in TSE +// notification. +// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h, +// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c +// +// 20 4/27/12 5:29a Rajashakerg +// [TAG] EIP88435 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Touch does not have functionality at POST +// [RootCause] Mouse is initialized after getting notification from +// mousedriver. So mouse avaliable at post and if we click at post, then +// the button status is not consumed by any other application and mouse +// pointer stuck at post +// [Solution] Provided the changes to init the mouse at setup in the +// absence of softkbd. +// [Files] notify.c, minisetupext.c +// +// 19 1/25/12 8:02a Rajashakerg +// [TAG] EIP81617 +// [Category] Improvement +// [Description] Avoiding memory leaks in TSE +// [Files] hiistring21.c, CommonHelper.c, notify.c +// +// 18 1/17/12 8:55a Arunsb +// Break statement added in NOTIFY_MASK_MOUSE_DRIVER. Without break +// statement postmessage displayed twice. +// +// 17 11/20/11 7:14a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 16 7/19/11 3:00p Arunsb +// [TAG] EIP57661 +// [Category] New Feature +// [Description] Driver health related variables are updated via +// notification function. +// [Files] notify.c, Uefi21Wapper.c and variable.h +// +// 15 6/29/11 6:29a Arunsb +// [TAG] EIP 62631 +// [Category] New Feature +// [Description] Hot key boot option support in TSE as per UEFI spec. +// section 3.1.6. +// Hot boot keys formed in AtivateInput function. +// [Files] AMITSE.sdl, bootflow.c, bootflow.h, CommonHelper.c, +// commonoem.c, commonoem.h, boot.c, +// hiistring20.c, hiistring21.c and notify.c. +// +// 14 6/23/11 5:36a Rajashakerg +// [TAG] EIP63073 +// [Category] New Feature +// [Description] Source modules in TSE should get the version details +// from binary in run time not at build time +// [Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c, +// EzportPlus\style.c, Legacy\style.c +// +// 13 6/19/11 4:04p Arunsb +// [TAG] EIP58712 +// [Category] New Feature +// [Description] To disable the BIOS Signon Message and TSE copyright +// version in post screen. +// [Files] amitse.sdl, amitse.mak, commonhelper.c and notify.c +// +// 12 4/29/11 4:33p Arunsb +// For 2.13 public patch release signon message hiding feature is omitted +// +// 10 1/06/11 1:53a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] After the notification, if the graphics driver +// uninstalled and reinstalled from core module then gGOP is getting +// corrupted. +// [Solution] Updated the files, by making gGOP/gUgaDraw to NULL in the +// update function and in switch to posty screen returining status as +// aborted if the gGOP/gUgaDraw is NULL +// [Files] protocol.c,notify.c,postmgmt.c +// +// 9 12/29/10 2:30a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] After the notification, if the graphics driver +// uninstalled and reinstalled from core module then gGOP getting +// corrupted. +// [Solution] Updated gGop/UgaDraw before using it in AMITSE. +// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c +// +// 7 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 14 9/16/10 3:01p Madhans +// To avoid compiler warning +// +// 13 7/12/10 4:49p Madhans +// EIP 39113: Sign ON Message Support. +// +// 12 6/08/10 5:09p Blaines +// Added new AMITSE hook (hook33), called when TSE determines that console +// out is available. +// +// 11 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 10 2/15/10 10:10p Madhans +// +// 9 2/04/10 11:20p Madhans +// To avoid calling notification function when entring setup.(in Fastboot +// case) +// +// 8 1/29/10 4:37p Madhans +// To not to depend on ConsoleControl and ConOut. +// +// 7 1/09/10 5:30a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 6 10/28/09 5:36p Madhans +// +// 5 9/25/09 6:37a Sudhirv +// EIP-26893 : when the DisplayPostMessage() function of the AMI Post +// Manager protocol is called multiple times, strings are truncated when +// displayed. +// +// 4 9/15/09 9:32a Sudhirv +// //Fix for EIP 21807 - Version number at the Setup/POST Screen corrupted +// if other language is chosen +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 5 3/31/09 3:59p Madhans +// EIP19632 +// +// 4 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 3 2/05/09 10:15a Madhans +// Style Module created. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: notify.c +// +// Description: file contains code to support the notification functions +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +EFI_GUID gEfiDXEMouseDriverProtocolGuid = + EFI_MOUSE_DRIVER_PROTOCOL_GUID; +#include "TseDrvHealth.h" //Has TSE related driver health structures + +#define NOTIFY_MASK_UGA (0x00000001) +#define NOTIFY_MASK_CONSOLE_CONTROL (0x00000002) +#define NOTIFY_MASK_CONSOLE_IN (0x00000004) +#define NOTIFY_MASK_CONSOLE_OUT (0x00000008) +#define NOTIFY_MASK_MOUSE_DRIVER (0x00000010) +BOOLEAN IsDriverHealthSupported (VOID); +//////////////////////////////////////////////////////////// +/// VARIABLE DECLARATIONS +/////////////////////////////////////////////////////////// +typedef struct _NOTIFICATION_INFO +{ + EFI_HANDLE NotifyHandle; + EFI_EVENT NotifyEvent; + UINT32 NotifyMask; + EFI_GUID *NotifyGuid; + BOOLEAN NotifyDevicePath; + VOID *NotifyRegistration; + VOID *NotifyProtocol; + VOID **pgProtocol; +} +NOTIFICATION_INFO; + +#ifndef STANDALONE_APPLICATION +static UINT32 gGlobalNotify = 0; +BOOLEAN gQuietBoot = FALSE; +VOID ActivateInput(VOID); + +static NOTIFICATION_INFO _gUgaNotify = +{ + NULL, //EFI_HANDLE NotifyHandle; + NULL, //EFI_EVENT NotifyEvent; + NOTIFY_MASK_UGA, //UINT32 NotifyMask; +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + &gEfiGraphicsOutputProtocolGuid, //EFI_GUID *NotifyGuid; +#else + &gEfiUgaDrawProtocolGuid, //EFI_GUID *NotifyGuid; +#endif + TRUE, //BOOLEAN NotifyDevicePath; + NULL, //VOID *NotifyRegistration; + NULL, //VOID *NotifyProtocol; +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + (VOID**)&gGOP //VOID **pgProtocol; +#else + (VOID**)&gUgaDraw //VOID **pgProtocol; +#endif +}; + +static NOTIFICATION_INFO _gConsoleControlNotify = +{ + NULL, //EFI_HANDLE NotifyHandle; + NULL, //EFI_EVENT NotifyEvent; + NOTIFY_MASK_CONSOLE_CONTROL, //UINT32 NotifyMask; + &gEfiConsoleControlProtocolGuid, //EFI_GUID *NotifyGuid; + FALSE, //BOOLEAN NotifyDevicePath; + NULL, //VOID *NotifyRegistration; + NULL, //VOID *NotifyProtocol; + NULL //(VOID**)&gConsoleControl //VOID **pgProtocol; + //gConsoleControl is used by PostManagerHAndshake to know if ActivateApplication has been called + //if we allow Notification function to set it, when PostManager handshake need to call ActivateApplication as in case of + //headless system, the call may be missed. +}; + +static NOTIFICATION_INFO _gConInNotify = +{ + NULL, //EFI_HANDLE NotifyHandle; + NULL, //EFI_EVENT NotifyEvent; + NOTIFY_MASK_CONSOLE_IN, //UINT32 NotifyMask; + &gEfiSimpleTextInProtocolGuid, //EFI_GUID *NotifyGuid; + FALSE, //BOOLEAN NotifyDevicePath; + NULL, //VOID *NotifyRegistration; + NULL, //VOID *NotifyProtocol; + NULL //(VOID**)&gConIn //VOID **pgProtocol; +}; + +static NOTIFICATION_INFO _gConOutNotify = +{ + NULL, //EFI_HANDLE NotifyHandle; + NULL, //EFI_EVENT NotifyEvent; + NOTIFY_MASK_CONSOLE_OUT, //UINT32 NotifyMask; + &gEfiSimpleTextOutProtocolGuid, //EFI_GUID *NotifyGuid; + FALSE, //BOOLEAN NotifyDevicePath; + NULL, //VOID *NotifyRegistration; + NULL, //VOID *NotifyProtocol; + NULL //(VOID**)&gConOut //VOID **pgProtocol; +}; + +static NOTIFICATION_INFO _gMousedriverNotify = +{ + NULL, //EFI_HANDLE NotifyHandle; + NULL, //EFI_EVENT NotifyEvent; + NOTIFY_MASK_MOUSE_DRIVER, //UINT32 NotifyMask; + &gEfiDXEMouseDriverProtocolGuid, //EFI_GUID *NotifyGuid; + FALSE, //BOOLEAN NotifyDevicePath; + NULL, //VOID *NotifyRegistration; + NULL, //VOID *NotifyProtocol; + NULL //VOID **pgProtocol; +}; + + +static NOTIFICATION_INFO *_gNotifyList[] = +{ + &_gUgaNotify, + &_gConsoleControlNotify, + &_gConInNotify, + &_gConOutNotify, + &_gMousedriverNotify, + NULL +}; + +#if APTIO_4_00 +EFI_STATUS FvReadResources ( + IN EFI_GUID *NameGuid, + IN EFI_GUID *pGuid, + IN OUT VOID **Buffer, + IN OUT UINTN *BufferSize + ); + +// Signon Section Guide +// {2EBE0275-6458-4af9-91ED-D3F4EDB100AA} +#define SGN_ON_SECTION_GUID {0x2ebe0275, 0x6458, 0x4af9, 0x91, 0xed, 0xd3, 0xf4, 0xed, 0xb1, 0x0, 0xaa} + +// Signon file guid +// {A59A0056-3341-44b5-9C9C-6D76F7673817} +// {0xa59a0056, 0x3341, 0x44b5, 0x9c, 0x9c, 0x6d, 0x76, 0xf7, 0x67, 0x38, 0x17}; +#define SGN_ON_FILE_GUID {0xa59a0056, 0x3341, 0x44b5, 0x9c, 0x9c, 0x6d, 0x76, 0xf7, 0x67, 0x38, 0x17} + +typedef struct _SIGNON +{ + UINT8 Sig[5]; + UINT8 Ver; + UINT16 Reserved; + CHAR8 SgnMsg1[]; +}AMI_SIGN_ON; + +#endif +//////////////////////////////////////////////////////////// +/// EXTERN VARIABLES +/////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +/// FUNCTIONS DECLARATIONS +/////////////////////////////////////////////////////////// +VOID FindandSetHotKeys (VOID); +UINT8 IsSetupHideBiosSignOnMsg (void); +VOID GetTseBuildVersion(UINTN *TseMajor, UINTN *TseMinor, UINTN *TseBuild);//EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time +VOID GetTseBuildYear(UINT16 *TseBuildYear);//EIP 151966 : Use BIOS build year for copyright message +VOID SetDriverHealthCount (VOID); +BOOLEAN IsMouseSupported(VOID); +BOOLEAN IsSoftKbdSupported(VOID); +BOOLEAN TseIgnoreKeyForFastBoot(); //EIP-94616 + +VOID *SavePostScreen( UINTN *SizeOfX, UINTN *SizeOfY ); +VOID RestorePostScreen( VOID *UgaBlt, UINTN SizeOfX, UINTN SizeOfY ); + +// +//---------------------------------------------------------------------------- +// Procedure: _DrvHealthNotifyFunction +// +// Description: Notification function for driver health protocol instal. +// +// Input: EFI_EVENT , VOID * +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID _DrvHealthNotifyFunction (EFI_EVENT Event, VOID *Context) +{ + SetDriverHealthCount (); +} + + +// +//---------------------------------------------------------------------------- +// Procedure: _UpdateGoPNotifyFunction +// +// Description: Notification function for driver health protocol instal. +// +// Input: EFI_EVENT , VOID * +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID _UpdateGoPNotifyFunction (EFI_EVENT Event, VOID *Context) +{ + UpdateGoPUgaDraw();//EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification +} +// +//---------------------------------------------------------------------------- +// Procedure: RegisterNotification +// +// Description: It will create a notify event and register a notification. +// +// Input: VOID +// +// Output: Status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS RegisterNotification( VOID ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + UINTN i; + EFI_EVENT Event, GopEvent; + EFI_GUID EfiDriverHealthProtocolGuid = EFI_DRIVER_HEALTH_PROTOCOL_GUID; + VOID *Registration = NULL, *GopRegistration = NULL; + + NOTIFICATION_INFO **notify = _gNotifyList; + + for ( i = 0; *notify != NULL; i++, notify++ ) + { + Status = gBS->CreateEvent( + EFI_EVENT_NOTIFY_SIGNAL, + EFI_TPL_CALLBACK, + NotificationFunction, + *notify, + &((*notify)->NotifyEvent) + ); + + if ( EFI_ERROR(Status) ) + continue; + + Status = gBS->RegisterProtocolNotify( + (*notify)->NotifyGuid, + (*notify)->NotifyEvent, + &((*notify)->NotifyRegistration) + ); + + // get any of these events that have occured in the past + gBS->SignalEvent( (*notify)->NotifyEvent ); + } + if (IsDriverHealthSupported ()) //EIP 57661 Notifying the driver health protocol installation to update the drv health variable in cache + { + Status = gBS->CreateEvent( + EFI_EVENT_NOTIFY_SIGNAL, + EFI_TPL_CALLBACK, + _DrvHealthNotifyFunction, + NULL, + &Event + ); + if (!EFI_ERROR (Status)) + { + Status = gBS->RegisterProtocolNotify( + &EfiDriverHealthProtocolGuid, + Event, + &Registration + ); + if (!EFI_ERROR(Status)) + { + gBS->SignalEvent (Event); + } + } + } + +//EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification + Status = gBS->CreateEvent( + EFI_EVENT_NOTIFY_SIGNAL, + EFI_TPL_CALLBACK, + _UpdateGoPNotifyFunction, + NULL, + &GopEvent + ); + if (!EFI_ERROR (Status)) + { + Status = gBS->RegisterProtocolNotify( + &gEfiGraphicsOutputProtocolGuid, + GopEvent, + &GopRegistration + ); + if (!EFI_ERROR(Status)) + { + gBS->SignalEvent (GopEvent); + } + } + + return Status; +} + +#if 0 +static _gConOutCount = 0; +#endif + +#if !APTIO_4_00 +extern EFI_GUID gEfiConsoleOutDeviceGuid; + +#endif + +// +//---------------------------------------------------------------------------- +// Procedure: NotificationFunction +// +// Description: function to perform the notification operations. +// +// Input: EFI_EVENT Event, NOTIFICATION_INFO *Context +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID NotificationFunction( EFI_EVENT Event, NOTIFICATION_INFO *Context ) +{ + EFI_STATUS Status; + UINTN Count = 0; + EFI_HANDLE *HandleBuffer = NULL; + BOOLEAN found = FALSE; + UINT32 ModSomething = 0; +// NOTIFICATION_INFO *Context = NotificationContext; + void *MouseDriverProtocol = NULL; + UINT32 PasswordInstalled = AMI_PASSWORD_NONE; + static BOOLEAN ActivateInputDone = FALSE; + + if ( Context == NULL ) + return; + + // Do nothing on Notification when Enters to setup/BBSPopup/Booting. + if(gPostStatus >= TSE_POST_STATUS_ENTERING_TSE) + return; + + //According to UEFI spec 2.0.: When LocateHandleBuffer() is called + //with ByRegisterNotify it returns the next handle that is new + //for the registration. Only one handle is returned at a time and + //the caller must loop until no more handles. + do + { + Status = gBS->LocateHandleBuffer( + ByRegisterNotify, + NULL, + Context->NotifyRegistration, + &Count, + &HandleBuffer + ); + + if (EFI_ERROR( Status )) + break; + + if(0 != Count) + { + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + Status = gBS->HandleProtocol( HandleBuffer[0], &gEfiDevicePathProtocolGuid, &DevicePath ); + +#if !APTIO_4_00 + if(Context == &_gConOutNotify) //Special handling for ConOut + { + if( + (_gUgaNotify.NotifyHandle) && //Wait until local console is initiated + (EFI_ERROR(Status)) //This is the notification for the virtual ConOut device + ) + { + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer = NULL; + UINTN EntryCount = 0, Index; + + Status = gBS->OpenProtocolInformation( + _gUgaNotify.NotifyHandle, + &gEfiConsoleOutDeviceGuid, + &OpenInfoBuffer, + &EntryCount + ); + if(EFI_SUCCESS == Status) + { + for (Index = 0; Index < EntryCount; Index++) + { + if (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) + { + found = TRUE; + } + } + + MemFreePointer((VOID **) &OpenInfoBuffer); + + if(found) + break; + } + } + } + else + { +#endif + //Check if notification for this protocol has to have a + //device path + if(Context->NotifyDevicePath) + { + if ( !EFI_ERROR( Status )) + { + found = TRUE; + break; + } + } + else + { + found = TRUE; + break; + } + +#if !APTIO_4_00 + } +#endif + + MemFreePointer( (VOID **)&HandleBuffer ); + } + + }while(Count); + +#if 0 + if ( Context == &_gConOutNotify ) + { + if ( _gConOutCount == 0 ) + { + if(found) + { + MemFreePointer( (VOID **)&HandleBuffer ); + found = FALSE; + } + } + + _gConOutCount++; + } +#endif + + if ( ! found ) + return; + + Context->NotifyHandle = HandleBuffer[0]; + + MemFreePointer( (VOID **)&HandleBuffer ); + + RUNTIME_DEBUG( L"notify" ); + + Status = gBS->HandleProtocol( Context->NotifyHandle, Context->NotifyGuid, (VOID **)&Context->NotifyProtocol ); + if( Context->pgProtocol ) + *(Context->pgProtocol) = Context->NotifyProtocol; + + if ( gGlobalNotify & Context->NotifyMask ) + return; + + if(Context->NotifyMask != NOTIFY_MASK_CONSOLE_IN) + gGlobalNotify |= Context->NotifyMask; + else + { //EIP19632: ConIn Notification is only valid with gST->ConIn != NULL. Otherwise not all the ConIn Connected. + if(gST->ConIn != NULL ) + { + gGlobalNotify |= Context->NotifyMask; + gST->ConsoleInHandle = gST->ConsoleOutHandle;//EIP-141066 Context->NotifyHandle; //EIP:116451, To assign the "gST->ConsoleInHandle" to locate the Keycode protocol. + } + } + + ModSomething = GetNotifyMaskValue(); //EIP-75236 + /*if(IsSoftKbdSupported()) + {//Checking for the presence of Softkbd + ModSomething = SOMETHING; + } + else + {//If softkbd is not present the unmasking the mousedriver notify from something + ModSomething = SOMETHING & (~NOTIFY_MASK_MOUSE_DRIVER); + }*/ + //EIP-98112 & 92497 Starts +//Commented because ActivateInput getting called twice + /*if (NOTIFY_MASK_CONSOLE_IN == Context->NotifyMask) //EIP92497 if softkbd presented then ActivateApplication invoked in postmanager only + { //So changed the logic from switch to if + //Check if Input has been activated and if yes Activate input + //EIP19632: ConIn Notification is only valid with gST->ConIn != NULL + if ( !IsDelayLogoTillInputSupported() ) //EIP-75236 + { + if( (( gGlobalNotify & ModSomething ) == ModSomething) && ( gST->ConIn != NULL ) ) + { + ActivateInput(); + } + } + }*/ + if (NOTIFY_MASK_MOUSE_DRIVER == Context->NotifyMask) + { + if(IsMouseSupported()&& IsSoftKbdSupported())//EIP 88435 : Initializing the mouse at post when mouse and softkbd present + { + MouseInit(); //If mouse is notified then Initializing the mouse + InstallClickHandlers (); //EIP160126 install click handlers in notification itself. In other places installing click handler is removed. + } + } + if (((gGlobalNotify & ModSomething) == ModSomething)) //EIP92497 if gConsoleControl is not validated then ActivateApplication will be invoked twice + { + /*//All necessary protocols available activate output + if (NULL == gConsoleControl) //If kept outside then activateinput wont get call succesully + { + ActivateApplication(); + }*/ + + //If Simple Text Input already available but input has not been activated yet activate now + //EIP19632: ConIn Notification is only valid with gST->ConIn != NULL + if (IsDelayLogoTillInputSupported ()) //EIP-75236 + { + if( (( gGlobalNotify & ModSomething ) == ModSomething) && ( gST->ConIn != NULL ) && (FALSE == ActivateInputDone)) + { + if (IsMouseSupported()&& IsSoftKbdSupported()) //EIP160126 if softkbd & password presents wait until mouse notify + { + PasswordInstalled = PasswordCheckInstalled(); + if(CheckSystemPasswordPolicy(PasswordInstalled)) + { + Status = gBS->LocateProtocol(&gEfiDXEMouseDriverProtocolGuid, NULL, &MouseDriverProtocol); + if (EFI_ERROR (Status)) + { + return; + } + } + } + ActivateApplication(); + ActivateInput(); + ActivateInputDone = TRUE; + } + } + else + { + if (NULL == gConsoleControl) + { + ActivateApplication (); + } + if( (( gGlobalNotify & ModSomething ) == ModSomething) && ( gST->ConIn != NULL ) && (FALSE == ActivateInputDone)) //EIP-98112 + { + if (IsMouseSupported()&& IsSoftKbdSupported()) //EIP160126 if softkbd & password presents wait until mouse notify + { + PasswordInstalled = PasswordCheckInstalled(); + if(CheckSystemPasswordPolicy(PasswordInstalled)) + { + Status = gBS->LocateProtocol(&gEfiDXEMouseDriverProtocolGuid, NULL, &MouseDriverProtocol); + if (EFI_ERROR (Status)) + { + return; + } + } + } + ActivateInput(); + ActivateInputDone = TRUE; + } + } + } + //EIP-98112 & 92497 Ends +} + +// +//---------------------------------------------------------------------------- +// Procedure: ActivateApplication +// +// Description: function for the Active application operations. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID ActivateApplication( VOID ) +{ + CHAR16 *text=NULL,*newString=NULL, *text2=NULL; + UINTN length, TseMajor,TseMinor, TseBuild; + UINT16 TseBuildYear=0; +#if APTIO_4_00 + UINTN ConCols,ConRows; +#endif + gConsoleControl = (EFI_CONSOLE_CONTROL_PROTOCOL *)_gConsoleControlNotify.NotifyProtocol; + + BootGetLanguages(); + CheckEnableQuietBoot (); + if(gST->ConOut != NULL) + { +#if !APTIO_4_00 + SetDesiredTextMode(); +#else +//eip:26893-Start + if(EFI_ERROR(gST->ConOut->QueryMode( gST->ConOut, gST->ConOut->Mode->Mode, &ConCols, &ConRows ))) + { + gMaxRows = StyleGetStdMaxRows(); + gMaxCols = StyleGetStdMaxCols(); + } + else + { + if((gMaxRows > ConRows) && (gMaxCols > ConCols)) + { + // In Aptio 4.x use the Text mode as is it in post screen (Set by the Core) + // Old Post messages already provided may be affected. + // Preserve Post messages + PreservePostMessages(ConCols, gMaxCols); + gMaxRows = ConRows; + gMaxCols = ConCols; + } + else if ((gMaxRows < ConRows) && (gMaxCols < ConCols) && (!gQuietBoot)) //EIP94702 Desired Text mode will be set at InitPostScreen, if quiet boot dont set mode for seamless boot + { + // Current screen mode is bigger then the TSE supports. + // TSE sets DesiredTextMode + SetDesiredTextMode(); + } + } +//eip:26893-end +#endif + } +#if APTIO_4_00 + { + EFI_GUID SgnFile = SGN_ON_FILE_GUID; + EFI_GUID SgnSection = SGN_ON_SECTION_GUID; + AMI_SIGN_ON *SignOn; + VOID *pSection; + UINTN SectionSize; + EFI_STATUS Status; + CHAR8 *SgnMsg2; + + Status = FvReadResources (&SgnFile, &SgnSection,(VOID**)&pSection,&SectionSize); + if (! EFI_ERROR( Status ) ) { + SignOn = (AMI_SIGN_ON*)((UINT8 *)pSection + sizeof(EFI_GUID)); + if( (MemCmp( (UINT8*)&SignOn->Sig, (UINT8*)"$SGN$",5) == 0) && (SignOn->Ver >= 2)) + { + text = StrDup8to16( SignOn->SgnMsg1 ); + if (!IsSetupHideBiosSignOnMsg ()) + { + SgnMsg2 = ((UINT8 *)&SignOn->SgnMsg1 + StrLen8(SignOn->SgnMsg1)+1); + text2 = StrDup8to16( SgnMsg2 ); + } + } + } + else + text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT) ); + } +#else + //EIP 21807 - Version number at the Setup/POST Screen corrupted if other language is chosen + text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT) ); +#endif + + if ( text != NULL ) + { + length = EfiStrLen(text) + 10; + newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) ); + if ( newString != NULL ) + { + //EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time + GetTseBuildVersion(&TseMajor,&TseMinor,&TseBuild); + //EIP 151966 : Use BIOS build year for copyright message + GetTseBuildYear(&TseBuildYear); + SPrint( newString, length * sizeof(CHAR16), text, TseMajor, TseMinor, TseBuild,TseBuildYear ); + PostManagerDisplayPostMessage(newString); + MemFreePointer( (VOID **)&newString ); + } + else + PostManagerDisplayPostMessage(text); + MemFreePointer( (VOID **)&text ); + } + // Sign on OEM String + if(text2 != NULL) + { + PostManagerDisplayPostMessage(text2); + MemFreePointer( (VOID **)&text2 ); + } + + if (IsDelayLogoTillInputSupported()) //EIP-75236 + ProcessConInAvailabilityHook(); + +#ifdef EFI_NT_EMULATOR + gGlobalNotify = gGlobalNotify | NOTIFY_MASK_CONSOLE_OUT; +#endif + + if ( gGlobalNotify & NOTIFY_MASK_UGA ) + { + if ( gQuietBoot ) + { + gPostStatus = TSE_POST_STATUS_IN_QUITE_BOOT_SCREEN; + if(gConsoleControl != NULL) + gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenGraphics ); + DrawQuietBootLogoHook(); + if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present + MouseInit(); + gProgress->quiteBootActive = TRUE ; + if(gProgress->active) + PostManagerSetProgressBarPosition() ; + + } + } + +// if ( gGlobalNotify & NOTIFY_MASK_CONSOLE_OUT ) + if ( gST->ConOut != NULL ) // If ConOut is available in System Table the display the post messages. + { + //Show post screen if it is not quiet boot or if it is a headless system +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if ( ! gQuietBoot || !gGOP) +#else + if ( ! gQuietBoot || !gUgaDraw) +#endif + { + CleanUpLogo(); + InitPostScreen(); + } + + ProcessConOutAvailableHook(); + } + + if (IsDelayLogoTillInputSupported()) //EIP-75236 + { + if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616 + InstallKeyHandlers(); +/* + //Lets install mouse click event in NotificationFunction itself + if( IsMouseSupported() && IsSoftKbdSupported())//EIP62763 : Checking for mouse and softkbd presence + InstallClickHandlers(); +*/ + } +} + + + +// +//---------------------------------------------------------------------------- +// Procedure: ActivateInput +// +// Description: function for the active Input. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID ActivateInput( VOID ) +{ +// EFI_STATUS Status; Set not used + VOID *UgaBlt = NULL; + UINTN SizeOfX=0, SizeOfY=0; + BOOLEAN bRedraw = FALSE; //If not initialized then on delay till logo input case we always restoring post due to garabage initialization + + FindandSetHotKeys (); + // if it is quiet boot copy the screen for later restoration + if ( gGlobalNotify & NOTIFY_MASK_UGA ) + { + UgaBlt = SavePostScreen(&SizeOfX, &SizeOfY); + } + + if (!IsDelayLogoTillInputSupported()) //EIP-98112 + { + bRedraw = ProcessConInAvailabilityHook(); + } + + //Restore + if(bRedraw) + { + RestorePostScreen (UgaBlt, SizeOfX, SizeOfY); + } + else + { + MemFreePointer((VOID **) &UgaBlt); //if redraw required this buffer will be freed in RestorePostScreen + } + + if (!IsDelayLogoTillInputSupported()) //EIP-98112 + { + if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616 + InstallKeyHandlers(); +/* + //Lets install mouse click event in NotificationFunction itself + if( IsMouseSupported() && IsSoftKbdSupported())//EIP62763 : Checking for mouse and softkbd presence + InstallClickHandlers(); +*/ + } +} + +//EIP:50479 : Start +//Function to update gGop +// +//---------------------------------------------------------------------------- +// Procedure: UpdateGoPUgaDraw +// +// Description: function to update the Gop when controls comes to TSE. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// + +VOID UpdateGoPUgaDraw( VOID ) +{ + EFI_STATUS Status; + UINTN Count = 0; + UINTN Index=0; + EFI_HANDLE *HandleBuffer = NULL; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + BOOLEAN found = FALSE; + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL//EIP:50479 Initializing gGOP/gUgaDraw to NULL before locating +gGOP = NULL; +#else +gUgaDraw = NULL; +#endif + + Status = gBS->LocateHandleBuffer( + ByProtocol, +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + &gEfiGraphicsOutputProtocolGuid, +#else + &gEfiUgaDrawProtocolGuid, +#endif + NULL, + &Count, + &HandleBuffer + ); + + for(Index=0;Index < Count;Index++) + { + Status = gBS->HandleProtocol( HandleBuffer[Index], &gEfiDevicePathProtocolGuid, &DevicePath ); + if (EFI_ERROR( Status )) + continue; +#if !APTIO_4_00 + { + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer = NULL; + UINTN EntryCount = 0, i; + + Status = gBS->OpenProtocolInformation( + HandleBuffer[Index], + &gEfiConsoleOutDeviceGuid, + &OpenInfoBuffer, + &EntryCount + ); + if(EFI_SUCCESS == Status) + { + for (i = 0; i < EntryCount; i++) + { + if (OpenInfoBuffer[i].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) + { + found = TRUE; + } + } + MemFreePointer((VOID **) &OpenInfoBuffer); + } + } +#else + found = TRUE; +#endif + if(!found) + continue; + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + Status = gBS->LocateProtocol( + &gEfiGraphicsOutputProtocolGuid, + NULL, // Registration key + &gGOP //VOID **pgProtocol; + ); + if(EFI_ERROR(Status)) + gGOP = NULL; +#else + Status = gBS->LocateProtocol( + &gEfiUgaDrawProtocolGuid, + NULL, // Registration key + &gUgaDraw //VOID **pgProtocol; + ); + if(EFI_ERROR(Status)) + gUgaDraw = NULL; +#endif + } + + //81617 : Avoiding memory leaks in TSE + MemFreePointer( (VOID **)&HandleBuffer ); + +} +//EIP:50479 : End +#endif // STANDALONE_APPLICATION + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/password.c b/EDK/MiniSetup/BootOnly/password.c new file mode 100644 index 0000000..a03bf4d --- /dev/null +++ b/EDK/MiniSetup/BootOnly/password.c @@ -0,0 +1,253 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.c $ +// +// $Author: Arunsb $ +// +// $Revision: 7 $ +// +// $Date: 5/08/14 9:17p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.c $ +// +// 7 5/08/14 9:17p Arunsb +// TsePasswordEncodeLocal function moved to PasswordEncode module +// +// 6 5/02/14 9:27p Arunsb +// TsePasswordEncodeLocal function moved to source +// +// 5 5/02/14 2:04a Premkumara +// TAG] EIP162197 +// [Category] Improvement +// [Description] Password encode feature modify to encode using Hashing +// based on token. +// [Files] Password.c, PasswordEncodeBin.cif, AMITSE.cif, +// TSESource.cif, PasswordEncode.c, PasswordEncode.h, AMITSE.sdl, +// CommonHelper.c, PasswordEncodeBin.mak, PasswordEncodeBin.sdl +// +// 4 5/22/13 10:37a Arunsb +// EIP123047 - +// +// 3 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 2 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 2 12/08/11 12:46p Rajashakerg +// [TAG] EIP63190 +// [Category] New Feature +// [Description] Security operations in BootOnly module instead of +// TSELite. GetAMITSEVariableLocal moved to tselite. +// +// 1 12/08/11 4:54a Arunsb +// EIP63190 => Moving password support from TSELite to BootOnly +// +// 4 2/19/10 1:04p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 6 2/19/10 8:18a Mallikarjunanv +// updated year in copyright message +// +// 5 7/09/09 12:29p Mallikarjunanv +// updated the password encoding fix +// +// 3 6/23/09 6:52p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:05p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: password.c +// +// Description: This file contains code to handle password operations +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: PasswordCheckInstalledLocal +// +// Description: function to check the password type +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +UINT32 PasswordCheckInstalledLocal(VOID) +{ + UINT32 Installed = AMI_PASSWORD_NONE; + UINT8 *setup = NULL; + AMITSESETUP *mSysConf = NULL; + UINTN VarSize = 0; + CHAR16 *TestPassword; + + TestPassword = EfiLibAllocateZeroPool((TsePasswordLength + 1)*sizeof(CHAR16)); + + GetAMITSEVariable(&mSysConf,&setup,&VarSize); + + if ( ( mSysConf != NULL ) && ( VarSize == sizeof(AMITSESETUP) ) ) + { + MemSet( TestPassword, (TsePasswordLength + 1)*sizeof(CHAR16), 0 ); + if ( ! EfiCompareMem( TestPassword, mSysConf->UserPassword, TsePasswordLength * sizeof(CHAR16) ) ) + Installed |= AMI_PASSWORD_USER; + if ( ! EfiCompareMem( TestPassword, mSysConf->AdminPassword, TsePasswordLength * sizeof(CHAR16) ) ) + Installed |= AMI_PASSWORD_ADMIN; + Installed ^= AMI_PASSWORD_ANY; + } + + if(setup) + MemFreePointer( (VOID **)&setup ); + else + MemFreePointer( (VOID **)&mSysConf ); + + MemFreePointer( (VOID **)&TestPassword); + + return Installed; +} + +// +//---------------------------------------------------------------------------- +// Procedure: PasswordAuthenticateLocal +// +// Description: function to check the authentication of the password +// +// Input: CHAR16 *Password +// +// Output: password type +// +//---------------------------------------------------------------------------- +// +BOOLEAN IsPasswordSupportNonCaseSensitive (); +UINT32 PasswordAuthenticateLocal( CHAR16 *Password ) +{ + UINT32 PasswordType = AMI_PASSWORD_NONE; + UINT8 *setup = NULL; + AMITSESETUP *mSysConf = NULL; + UINTN VarSize = 0; + CHAR16 *EncPass; + UINTN ii; + + GetAMITSEVariable(&mSysConf,&setup,&VarSize); + + if ( ( mSysConf == NULL ) || ( VarSize != sizeof(AMITSESETUP) ) ) + return PasswordType; + + EncPass = EfiLibAllocateZeroPool((TsePasswordLength + 1)*sizeof(CHAR16)); + + MemSet( EncPass, (TsePasswordLength + 1)*sizeof(CHAR16), 0 ); + EfiStrCpy( EncPass, Password ); + if (IsPasswordSupportNonCaseSensitive ()) //If admin/user passwords are not encoded then case pbm will arose so avoiding that + { + for (ii = 0; ii < TsePasswordLength; ii++) + Password [ii] = ((Password [ii]>=L'a')&&(Password [ii]<=L'z'))?(Password [ii]+L'A'-L'a'):Password [ii]; + } + + PasswordEncodeHook( EncPass, TsePasswordLength*sizeof(CHAR16)); + +//EIP 23354 : Start + if ( ( ! EfiCompareMem( Password, mSysConf->UserPassword, TsePasswordLength * sizeof(CHAR16) ) ) || + ( ! EfiCompareMem( EncPass, mSysConf->UserPassword, TsePasswordLength * sizeof(CHAR16) ) ) ) + { + PasswordType = AMI_PASSWORD_USER; + } + + if ( ( ! EfiCompareMem( Password, mSysConf->AdminPassword, TsePasswordLength * sizeof(CHAR16) ) ) || + ( ! EfiCompareMem( EncPass, mSysConf->AdminPassword, TsePasswordLength * sizeof(CHAR16) ) ) ) + { + PasswordType = AMI_PASSWORD_ADMIN; + } +//EIP 23354 : End + + if(setup) + MemFreePointer( (VOID **)&setup ); + else + MemFreePointer( (VOID **)&mSysConf ); + + MemFreePointer( (VOID **)&EncPass ); + + return PasswordType; +} + +// +//---------------------------------------------------------------------------- +// Procedure: PasswordUpdateLocal +// +// Description: function to ubdate the password +// +// Input: CHAR16 *Password, , UINTN Size +// +// Output: updated password +// +//---------------------------------------------------------------------------- +// +CHAR16 *PasswordUpdateLocal( CHAR16 *Password, UINTN Size ) +{ + CHAR16 *Buffer = NULL; + + if ( Password[0] == L'\0' ) + return Password; + + Buffer = EfiLibAllocateZeroPool( Size ); + if ( Buffer == NULL ) + return Buffer; + + MemCopy( Buffer, Password, Size ); + PasswordEncodeHook( Buffer, Size ); + + return Buffer; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/password.h b/EDK/MiniSetup/BootOnly/password.h new file mode 100644 index 0000000..708e4ca --- /dev/null +++ b/EDK/MiniSetup/BootOnly/password.h @@ -0,0 +1,111 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.h $ +// +// $Author: Arunsb $ +// +// $Revision: 2 $ +// +// $Date: 10/18/12 5:59a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.h $ +// +// 2 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 2 10/10/12 12:37p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 1 12/08/11 4:54a Arunsb +// EIP63190 => Moving password support from TSELite to BootOnly +// +// 5 2/26/10 8:54p Madhans +// For TSE 2.01.1024. refer changelog.log for file checkin history . +// +// 6 2/26/10 1:30p Madhans +// To avoid build issues with EDK. +// +// 5 2/19/10 8:18a Mallikarjunanv +// updated year in copyright message +// +// 4 8/17/09 12:27p Presannar +// Removed References to Tiano.h and replaced it with Efi.h +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:05p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: password.h +// +// Description: Header file for code to handle password operations +// +//---------------------------------------------------------------------------- +// + +#ifndef _PASSWORD_H_ +#define _PASSWORD_H_ + +#if TSE_USE_EDK_LIBRARY +#include "Tiano.h" +#else +#include "Efi.h" +#endif + +BOOLEAN _PasswordProtocolInit( VOID ); +BOOLEAN PasswordBootMode( VOID ); +UINT32 PasswordCheckInstalledVarIndex( UINT32 VarIndex ); +UINT32 PasswordAuthenticate( CHAR16 *Password ); +BOOLEAN PasswordAuthenticateVarIndex( UINT32 VarIndex, CHAR16 *Password ); +CHAR16 *PasswordUpdate( CHAR16 *Password, UINTN Size ); +VOID PasswordCommitChanges( BOOLEAN SaveChanges ); + +#endif /* _PASSWORD_H_ */ + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/postmgmt.c b/EDK/MiniSetup/BootOnly/postmgmt.c new file mode 100644 index 0000000..36a332b --- /dev/null +++ b/EDK/MiniSetup/BootOnly/postmgmt.c @@ -0,0 +1,897 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2012, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmt.c $ +// +// $Author: Premkumara $ +// +// $Revision: 38 $ +// +// $Date: 8/28/14 8:38a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmt.c $ +// +// 38 8/28/14 8:38a Premkumara +// [TAG] EIP142551 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Mouse Movement is not initialized to Full Screen Resolution +// in case of quiet boot mode with high resolution OEM Logo. +// [Root Cause] Mouse Initialization was not across the full screen incase +// of High Resolution Quiet Boot Logo. +// [Solution] Initialised the Mouse with the Resolution Set in case of +// Quiet Boot logo so that Mouse will move acroos the Whole screen +// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c, +// Notify.c, MinisetupExt.c +// +// 37 8/28/14 7:29a Premkumara +// [TAG] EIP107833, 125388 +// [Category] Improvement +// [Symptom:] Setting best text and GOP mode while using TSEPostinterfaces +// before TSE or after TSE. +// [Files] Protocol.c, AMITSE.sdl, CommonHelper.c, MiniSetup.sdl, +// PostMgmtc, PostmgmtExt.c, MessagBox.c +// +// 36 8/28/14 5:52a Premkumara +// EIP-135253 Updating file name proper in #include +// +// 35 5/02/14 12:51a Arunsb +// [TAG] EIP148122 +// [Category] Improvement +// [Description] INTN to UINTN for CordinateX and CordinateY variable in +// InitPostScreen to avoid negative condition +// [Files] postmgmt.c +// +// 34 2/11/14 9:30p Arunsb +// Changes reverted for 2.16.1243 label +// +// 33 2/11/14 8:08p Arunsb +// [TAG] EIP126104 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Calling SwitchToPostScreen after selecting option from BBS +// draws PostScreen and display post messages. +// [RootCause] When switchToPostscreen is called BBS menu is d +// [Solution] Drawing postscreen image and display post messages before +// BBS +// [Files] Postmgmt.c +// +// 32 1/29/14 5:43p Arunsb +// [TAG] EIP148122 +// [Category] Improvement +// [Description] INTN to UINTN for CordinateX and CordinateY variable in +// InitPostScreen to avoid negative condition +// [Files] postmgmt.c +// +// 31 5/21/13 12:32p Arunsb +// [TAG] EIP124369 +// [Category] Bug Fix +// [Solution] BGRT table header revision revised to 1 as per ACPI spec +// 5.0 +// [Files] postmgmt.c +// +// 30 5/12/13 8:35a Arunsb +// [TAG] EIP122277 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] System halted when 4GB memory installed with Quiet Boot +// enabled in 32 bit platform +// [RootCause] Type casting problem +// [Solution] Type casted properly with UINTN for UINT64 member +// [Files] postmgmt.c +// +// 29 4/17/13 1:13a Arunsb +// [TAG] EIP121116 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] AMI small logo has damage on POST and boot +// [RootCause] When system starts with higher text resolution more than +// 100*31 then TSE not setting proper text mode +// [Solution] Mode set properly +// [Files] notify.c and postmgmt.c +// +// 28 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 10 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 26 9/25/12 12:39p Arunsb +// [TAG] EIP100558 +// [Category] New Feature +// [Description] Provide solution to display the small logo in (0,0) +// graphics position +// [Files] postmgmt.c +// +// 25 9/17/12 6:10a Rajashakerg +// Updated EIP changes for 2.16 release. +// +// 23 9/08/12 6:40p Arunsb +// [TAG] EIP100558 +// [Category] New Feature +// [Description] Provide solution to display the small logo in (0,0) +// graphics position +// [Files] AMITSE.sdl, commonhelper.c, postmgmt.c and boot.c +// +// 22 8/29/12 4:24p Arunsb +// [TAG] EIP94702 +// [Description] Support for Native Resolution in POST/BOOT +// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c, +// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c, +// ezportplus/stylecommon.c andlegacy/stylecommon.c +// +// 21 5/29/12 7:02a Arunsb +// Commented for build error +// +// 20 5/29/12 4:33a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 19 2/04/12 9:06a Premkumara +// Moved DrawOEMImage with some modification from binary to source +// +// 18 1/31/12 1:22p Premkumara +// [TAG] EIP75136 +// [Category] New Feature +// [Description] Generic support for logos in RomHoles +// [Files] CommomHelper.c, AMITSE.sdl, AMITSE.mak, LogoLib.h, +// Postmgmt.c, AMILogo.h +// +// 17 1/31/12 6:44a Arunsb +// [TAG] EIP81830 +// [Category] Improvement +// [Description] Support to uninstall the BGRT on legacy boot. +// [Files] Commonhelper.c, postmgmt.c and boot.c +// +// 16 11/21/11 8:37a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 15 11/20/11 7:15a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 14 6/29/11 10:16a Arunsb +// [TAG] EIP58954 +// [Category] Improvement +// [Description] Support for BGRT spec. version 1.2. +// ImageType field added in BGRT_TABLE to represent the +// type of image. +// [Files] bootonly\logo.c and postmgmt.c +// +// 13 6/04/11 1:52p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Wrapper function added for InvalidateStatusInBgrt +// function. +// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and +// commonhelper.c +// +// 12 5/29/11 12:09p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Quiet boot logo's only added for BGRT. BGRT status +// field cleared if any changes happened in screen other than displaying +// the image. +// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and +// commonhelper.c +// +// 11 5/04/11 5:09p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Contributing BGRT table to ACPI table. +// CONTRIB_BGRT_TABLE_TO_ACPI token added. Wrapper function +// ContribBGRTTableToAcpi added. +// [Files] Postmgmt.c, commonoem.c,logo.c and commonhelper.c +// +// 10 5/03/11 9:54p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Contributing BGRT table to ACPI table. +// CONTRIB_BGRT_TABLE_TO_ACPI token added. EDK Build support added. +// [Files] Postmgmt.c, commonoem.c and commonhelper.c +// +// 9 5/02/11 3:29p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Contributing BGRT table to ACPI table. +// CONTRIB_BGRT_TABLE_TO_ACPI token added. EDK Build support added. +// [Files] Postmgmt.c, commonoem.c and commonhelper.c +// +// 8 4/23/11 3:18p Arunsb +// [TAG] EIP58954 +// [Category] New Feature +// [Description] Contributing BGRT table to ACPI table. +// CONTRIB_BGRT_TABLE_TO_ACPI token added. +// [Files] Postmgmt.c, commonoem.c and commonhelper.c +// +// 7 3/28/11 9:23p Madhans +// [TAG] EIP41744 +// [Category] Improvement +// [Description] SoftKeyBoard Support in TSE. and Support to Work with +// new mouse driver(Label 07). +// [Files] HookAnchor.h +// AMITSE.sdl +// CommonHelper.c +// commonoem.c +// commonoem.h +// HookList.c +// HookAnchor.c +// Mouse.c +// minisetupext.c +// postmgmtext.c +// minisetupext.h +// PopupPassword.c +// PopupString.c +// TseLiteCommon.c +// +// 6 1/06/11 1:55a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] After the notification, if the graphics driver +// uninstalled and reinstalled from core module then gGOP is getting +// corrupted. +// [Solution] Updated the files, by making gGOP/gUgaDraw to NULL in the +// update function and in switch to posty screen returining status as +// aborted if the gGOP/gUgaDraw is NULL +// [Files] protocol.c,notify.c,postmgmt.c +// +// 5 12/29/10 2:31a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] After the notification, if the graphics driver +// uninstalled and reinstalled from core module then gGOP getting +// corrupted. +// [Solution] Updated gGop/UgaDraw before using it in AMITSE. +// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c +// +// 3 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 5 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 4 2/04/10 11:21p Madhans +// To remove ConsoleControl dependance. +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 2 5/13/09 11:01a Madhans +// Signal the event once we create the timer. to read any pending keys +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 5 3/31/09 4:00p Madhans +// +// 4 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 3 2/05/09 10:15a Madhans +// Style Module created. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: postmgmt.c +// +// Description: file to handle the post management operations +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" +#if !TSE_USE_EDK_LIBRARY +#include "Acpi.h" +#include +#else +#include EFI_PROTOCOL_DEFINITION (AcpiTable) +#endif + +#pragma pack (1) +typedef struct //Structure for forming BGRT Table +{ + UINT16 Version; + UINT8 Status; + UINT8 ImageType; + UINT64 ImageAddress; + UINT32 ImageOffsetX; + UINT32 ImageOffsetY; +}BGRT_TABLE; +#pragma pack() +#if !TSE_USE_EDK_LIBRARY +#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) +#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16 (A,B) | (EFI_SIGNATURE_16 (C,D) << 16)) +#endif +#define BGRT_SIGNATURE EFI_SIGNATURE_32 ('B','G','R','T') +VOID FormBGRTTable (VOID **, UINTN *, UINT8 *, INTN, INTN, BOOLEAN); +UINT8 CalculateChecksum (VOID *, UINT8); +#define CREATOR_ID_AMI 0x20494D41 +#define CREATOR_REV_MS 0x00010013 +UINT8 *GetACPIOEMID (VOID); +UINT8 *GetACPIOEMTableID (VOID); +UINT32 GetACPIOEMRevision (VOID); +LOGO_TYPE GetLogoType(UINT8 *ImageData); +LOGO_TYPE GetExtendedLogoType(UINT8 *ImageData); +VOID *gBgrtSafeBuffer = NULL; //EIP 58954 For BGRT table support +UINTN gTableKey = 0; +VOID InvalidateStatusInBgrtWrapper (VOID); +//EIP-75136 ROMHole Support +BOOLEAN IsOEMPOSTLogoSupport(); +//EIP-75136 End +BOOLEAN IsMouseSupported(VOID); +BOOLEAN IsSoftKbdSupported(VOID); +// +//---------------------------------------------------------------------------- +// Procedure: DrawOEMImage +// +// Description: Function to draw OEMLogo to in post screen operations +// +// Input: UINTN *, UINTN*, INTN, INTN +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS DrawOEMImage (UINTN *width, UINTN *height, INTN CoordinateX, INTN CoordinateY) +{ + EFI_GUID OEMLogoGuid = AMI_OEM_LOGO_GUID; + UINT8 *ImageData = NULL; + UINTN ImageSize = 0; + EFI_STATUS Status = EFI_UNSUPPORTED; + UINTN LogoType = 0; + + Status = GetGraphicsBitMapFromFV( &OEMLogoGuid, &ImageData, &ImageSize ); + if(EFI_SUCCESS == Status) + { + DrawImage( ImageData, ImageSize, CA_AttributeRightTop, CoordinateX, CoordinateY, FALSE, width, height ); + LogoType = GetExtendedLogoType (ImageData); + if (GIF_Logo != LogoType) + { + MemFreePointer ((VOID **)&ImageData); + } + } + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: InitPostScreen +// +// Description: fucntion to perform the post screen operations +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +BOOLEAN DrawPostLogoAt0Pos (VOID); +VOID InitPostScreen( VOID ) +{ + UINTN height, width, OrgHeight = 0; + UINT8 *ImageData = NULL; + UINTN ImageSize = 0; + UINTN CoordinateX = 0; + UINTN CoordinateY = 0; + UINT32 HorizontalResolution = 0; + UINT32 VerticalResolution = 0; + UINTN ConCols = 0, ConRows = 0; +#if !SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + UINT32 ColorDepth; + UINT32 RefreshRate; +#endif + EFI_SIMPLE_TEXT_OUT_PROTOCOL *pConOut = gST->ConOut; + UINTN LogoType = 0; + UINTN tempPostStatus; + + if ( pConOut == NULL ) + return; + + //If any SwitchToPostScreen happens during ProceedToBoot then taking backup of original gPostStatus before changing to IN_POST_SCREEN + if (TSE_POST_STATUS_PROCEED_TO_BOOT == gPostStatus) + tempPostStatus = gPostStatus; + + if ( gPostStatus <= TSE_POST_STATUS_IN_TSE ) //EIP-126104 + gPostStatus = TSE_POST_STATUS_IN_POST_SCREEN; + +#ifndef STANDALONE_APPLICATION + if(gConsoleControl != NULL) + gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenText ); +#endif + +#if !APTIO_4_00 + SetDesiredTextMode (); +#else + // In Aptio use the Text mode as is it in post screen + if (EFI_ERROR (gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &ConCols, &ConRows))) + { + gMaxRows = StyleGetStdMaxRows(); + gMaxCols = StyleGetStdMaxCols(); + } + else if ((gMaxRows < ConRows) && (gMaxCols < ConCols)) + { + SetDesiredTextMode (); + } +#endif + if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present + MouseInit(); + pConOut->EnableCursor( pConOut, FALSE ); + pConOut->SetAttribute( pConOut, EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ); + pConOut->ClearScreen( pConOut ); + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if(gGOP) + { + HorizontalResolution = gGOP->Mode->Info->HorizontalResolution; + VerticalResolution = gGOP->Mode->Info->VerticalResolution; + } +#else + if ( gUgaDraw != NULL ) + { + gUgaDraw->GetMode (gUgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate); + } +#endif + + if ( gPostStatus > TSE_POST_STATUS_IN_TSE ) //EIP-126104 + { + InvalidateStatusInBgrtWrapper (); + return; + } + + height = 0; + +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if(gGOP ) +#else + if ( gUgaDraw ) +#endif + { + if (!DrawPostLogoAt0Pos ()) + { + CoordinateX = (HorizontalResolution - (gMaxCols * HiiGetGlyphWidth ())) / 2; + CoordinateY = (VerticalResolution - (gMaxRows * HiiGetGlyphHeight ())) / 2; + } + //EIP-75136 To display AMILogo on TopLeft corner of setup + if(EFI_SUCCESS == GetGraphicsBitMapFromFV( &gAMIEfiLogoGuid, &ImageData, &ImageSize )) + { + + MouseStop();//EIP 62763: Mouse stopped before drawing the post image. + + DrawImage( + ImageData, + ImageSize, + CA_AttributeLeftTop, + CoordinateX, + CoordinateY, + FALSE, + &width, + &height + ); + OrgHeight = height; + LogoType = GetExtendedLogoType (ImageData); + if (GIF_Logo != LogoType) + { + MemFreePointer ((VOID **)&ImageData); + } + InvalidateStatusInBgrtWrapper (); + } + //EIP-75136 To display OEM_POST_Logo on RightTop corner of setup + if (IsOEMPOSTLogoSupport()) + { + if(EFI_SUCCESS == DrawOEMImage(&width, &height, CoordinateX, CoordinateY)) + { + InvalidateStatusInBgrtWrapper (); + } + } + if (DrawPostLogoAt0Pos ()) + { + if (height > (VerticalResolution - (gMaxRows * HiiGetGlyphHeight())) / 2) //If height is lesser than empty space then make height as 0. Occurs for greater graphics resolution with lesser text resolution. + { + height -= (VerticalResolution - (gMaxRows * HiiGetGlyphHeight())) / 2; + } + } + height = (height / HiiGetGlyphHeight()); + if(OrgHeight % HiiGetGlyphHeight()) //Seeing remainder for original height + height ++; + } + + //If SwitchToPostScreen is called during TSE_POST_STATUS_PROCEED_TO_BOOT poststatus then we need to save PROCEED_TO_BOOT to set it back after drawing postlogo to avoid drawing msgbox, message, other postinterfaces + if (TSE_POST_STATUS_PROCEED_TO_BOOT == tempPostStatus) + gPostStatus = TSE_POST_STATUS_PROCEED_TO_BOOT; + + DisplayActivePostMsgs(height); + + AfterInitPostScreenHook(); + MouseRefresh(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: InstallKeyHandlers +// +// Description: fucntion to install the timer event +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID InstallKeyHandlers( VOID ) +{ + EFI_STATUS Status; + if(gKeyTimer != NULL) + return; // timer already created. + Status = TimerCreateTimer( &gKeyTimer, CheckForKeyHook, NULL, TimerPeriodic, TIMER_HALF_SECOND, EFI_TPL_CALLBACK ); + // Signal it once immediately. + if (!EFI_ERROR(Status)) + gBS->SignalEvent( gKeyTimer ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: InstallClickHandlers +// +// Description: fucntion to install the timer event +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID InstallClickHandlers( VOID ) +{ + EFI_STATUS Status; + if(gClickTimer != NULL) + return; // timer already created. + Status = TimerCreateTimer( &gClickTimer, CheckForClickHook, NULL, TimerPeriodic, TIMER_HALF_SECOND, EFI_TPL_CALLBACK ); + // Signal it once immediately. + if (!EFI_ERROR(Status)) + gBS->SignalEvent( gClickTimer ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: FormBGRTTable +// +// Description: Created the BGRT table with the input params +// +// Input: VOID * = Buffer to store the ACPI table +// UINTN * = To store the size of the ACPI + BGRT table +// UINT8 * = Address of the image to be to stored +// INTN = X coordinate of the image +// INTN = Y coordinate of the image +// BOOLEAN = Indicates whether to set the BGRT status field or not. +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID FormBGRTTable (VOID **AcpiTableBuffer, UINTN *AcpiTableBufferSize, UINT8 *ImageAddress, INTN ImageXOffset, INTN ImageYOffset, BOOLEAN GifImagePresence) +{ + BGRT_TABLE BgrtTable = {0}; + const UINT8 *OemId = GetACPIOEMID (); + const UINT8 *OemTblId = GetACPIOEMTableID (); + UINT8 iIndex = 0; + UINT8 Checksum = 0; + UINT8 AcpiHdrSize = 0; +#if TSE_USE_EDK_LIBRARY + EFI_ACPI_DESCRIPTION_HEADER AcpiHdr = {0}; + AcpiHdrSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER); +#else + ACPI_HDR AcpiHdr = {0}; + AcpiHdrSize = sizeof (ACPI_HDR); +#endif + AcpiHdr.Signature = BGRT_SIGNATURE; + AcpiHdr.Length = AcpiHdrSize + sizeof(BGRT_TABLE); + AcpiHdr.Revision = 1; + AcpiHdr.Checksum = 0; + AcpiHdr.CreatorId = CREATOR_ID_AMI; //"AMI" + for (iIndex = 0; ((iIndex < 6) && (OemId [iIndex])); iIndex ++) + { + AcpiHdr.OemId [iIndex] = OemId [iIndex]; + } +#if TSE_USE_EDK_LIBRARY + AcpiHdr.OemRevision = GetACPIOEMRevision (); + AcpiHdr.CreatorRevision = CREATOR_REV_MS; + for (iIndex = 0; ((iIndex < 8) && (OemTblId [iIndex])); iIndex ++) + { + ((UINT8 *)(&AcpiHdr.OemTableId)) [iIndex] = OemTblId [iIndex]; + } +#else + AcpiHdr.OemRev = GetACPIOEMRevision (); + AcpiHdr.CreatorRev = CREATOR_REV_MS; + for (iIndex = 0; ((iIndex < 8) && (OemTblId [iIndex])); iIndex ++) + { + AcpiHdr.OemTblId [iIndex] = OemTblId [iIndex]; + } +#endif + BgrtTable.Version = 1; + if (!GifImagePresence) //If gif image presented then status field should be 0. + { + BgrtTable.Status = 1; + } + BgrtTable.ImageType = 0; //0 Represents BMP image + BgrtTable.ImageAddress = (UINTN)ImageAddress; + BgrtTable.ImageOffsetX = (UINT32)ImageXOffset; + BgrtTable.ImageOffsetY = (UINT32)ImageYOffset; + + Checksum = CalculateChecksum (&AcpiHdr, AcpiHdrSize); + Checksum += CalculateChecksum (&BgrtTable, (UINT8)sizeof (BGRT_TABLE)); + AcpiHdr.Checksum = Checksum; + + *AcpiTableBuffer = EfiLibAllocatePool (AcpiHdrSize + sizeof (BGRT_TABLE)); + if (NULL == *AcpiTableBuffer) + { + return; + } + EfiCopyMem (*AcpiTableBuffer, &AcpiHdr, AcpiHdrSize); + EfiCopyMem (((UINT8 *)(*AcpiTableBuffer)) + AcpiHdrSize, &BgrtTable, sizeof (BGRT_TABLE)); + *AcpiTableBufferSize = AcpiHdrSize + sizeof(BGRT_TABLE); +} + +// +//---------------------------------------------------------------------------- +// Procedure: AddImageDetailToACPI +// +// Description: Adds the image data to the ACPI Table. +// +// Input: UINT8 * = Address of the image to be to stored +// INTN = X coordinate of the image +// INTN = Y coordinate of the image +// BOOLEAN = Indicates whether to set the BGRT status field or not +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID AddImageDetailToACPI (UINT8 *ImageData, INTN CoordinateX, INTN CoordinateY, BOOLEAN GifImagePresence) +{ + EFI_STATUS Status = EFI_SUCCESS; + EFI_GUID AcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID; + VOID *AcpiTableBuffer = NULL; + UINTN AcpiTableBufferSize = 0; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableInstance = NULL; + + Status = gBS->LocateProtocol (&AcpiTableProtocolGuid, NULL, &AcpiTableInstance); + if (EFI_SUCCESS != Status) + { + return; + } + FormBGRTTable (&AcpiTableBuffer, &AcpiTableBufferSize, ImageData, CoordinateX, CoordinateY, GifImagePresence); + if (NULL != AcpiTableBuffer) + { + Status = AcpiTableInstance->InstallAcpiTable (AcpiTableInstance, AcpiTableBuffer, AcpiTableBufferSize, &gTableKey); + if (EFI_SUCCESS == Status) + { + gBgrtSafeBuffer = AcpiTableBuffer; + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: CalculateChecksum +// +// Description: Calculates the checksum for the given structure +// +// Input: VOID => Table structure +// UINT8 => Table Size +// +// Output: UINT8 => Checksum for the table +// +//---------------------------------------------------------------------------- +// +UINT8 CalculateChecksum (VOID *AcpiTable, UINT8 TableSize) +{ + UINT8 *TablePtr = (UINT8 *)AcpiTable; + UINT8 iIndex = 0; + UINT8 Checksum = 0; + + for (iIndex= 0; iIndex < TableSize; iIndex ++) + { + Checksum += TablePtr [iIndex]; + } + return (0 - Checksum); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BGRTSupportedLogoType +// +// Description: Checks whether the BGRT data supports the specified logo +// +// Input: UINT8 * => Data for the image +// +// Output: BOOLEAN => TRUE if BGRT supports otherwise FALSE +// +//---------------------------------------------------------------------------- +// +BOOLEAN BGRTSupportedLogoType (UINT8 *ImageData) +{ + UINTN LogoType; + LogoType = GetLogoType (ImageData); + if (BMP_Logo== LogoType) + { + BMP_IMAGE_HEADER *BmpHeader; + BmpHeader = (BMP_IMAGE_HEADER *)ImageData; + if (24 == BmpHeader->BitPerPixel) //As per spec. BMP image should be 24 bitmap + { + return TRUE; + } + } + return FALSE; +} + +// +//---------------------------------------------------------------------------------------------------------------- +// Procedure: InvalidateStatusInBgrt +// +// Description: Disables the BGRT status field if any changes happened in screen other than the image display +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------------------------------------------- +// +VOID InvalidateStatusInBgrt (VOID) +{ + EFI_STATUS Status = EFI_SUCCESS; + EFI_GUID AcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID; + BGRT_TABLE *BgrtTable; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableInstance = NULL; + UINTN TableSize = 0; +#if TSE_USE_EDK_LIBRARY + UINT8 AcpiHdrSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER); + EFI_ACPI_DESCRIPTION_HEADER *AcpiHdr; +#else + UINT8 AcpiHdrSize = sizeof (ACPI_HDR); + ACPI_HDR *AcpiHdr; +#endif + TRACE((-1,"In InvalidateStatusInBgrt")); + if (NULL == gBgrtSafeBuffer) //EIP 58954 For BGRT table support + { + return; + } + BgrtTable = (BGRT_TABLE *)((UINT8 *)gBgrtSafeBuffer + AcpiHdrSize); + BgrtTable->Status = 0; +#if TSE_USE_EDK_LIBRARY + AcpiHdr = (EFI_ACPI_DESCRIPTION_HEADER *)gBgrtSafeBuffer; +#else + AcpiHdr = (ACPI_HDR *)gBgrtSafeBuffer; +#endif + AcpiHdr->Checksum ++; //Since changing the status bit from 1 to 0 adding checksum by 1. + Status = gBS->LocateProtocol (&AcpiTableProtocolGuid, NULL, &AcpiTableInstance); + if (EFI_SUCCESS != Status) + { + return; + } + Status = AcpiTableInstance->UninstallAcpiTable (AcpiTableInstance, gTableKey); + if (EFI_SUCCESS != Status) + { + return; + } + gTableKey = 0; //If not set to 0 then ACPI table is not created again + TableSize = AcpiHdrSize + sizeof(BGRT_TABLE); + Status = AcpiTableInstance->InstallAcpiTable (AcpiTableInstance, gBgrtSafeBuffer, TableSize, &gTableKey); +} + +//EIP81830 starts - Support to uninstall the BGRT on legacy boot +// +//---------------------------------------------------------------------------------------------------------------- +// Procedure: UninstallBGRT +// +// Description: UninstallsBGRT table, Called for Legacy Boot +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------------------------------------------- +// +VOID UninstallBGRT (VOID) +{ + EFI_STATUS Status = EFI_SUCCESS; + EFI_GUID AcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID; + BGRT_TABLE *BgrtTable; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableInstance = NULL; +#if TSE_USE_EDK_LIBRARY + UINT8 AcpiHdrSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER); +#else + UINT8 AcpiHdrSize = sizeof (ACPI_HDR); +#endif + TRACE((-1,"In UninstallBGRT")); + + if (NULL == gBgrtSafeBuffer) + { + return; + } + BgrtTable = (BGRT_TABLE *)((UINT8 *)gBgrtSafeBuffer + AcpiHdrSize); + + Status = gBS->LocateProtocol (&AcpiTableProtocolGuid, NULL, &AcpiTableInstance); + if (EFI_SUCCESS != Status) + { + return; + } + Status = AcpiTableInstance->UninstallAcpiTable (AcpiTableInstance, gTableKey); + if (EFI_SUCCESS != Status) + { + return; + } + MemFreePointer((VOID**)&BgrtTable->ImageAddress); + MemFreePointer((VOID**)&gBgrtSafeBuffer); + +} +//EIP81830 ends + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************* \ No newline at end of file diff --git a/EDK/MiniSetup/BootOnly/postmgmtext.c b/EDK/MiniSetup/BootOnly/postmgmtext.c new file mode 100644 index 0000000..530be2a --- /dev/null +++ b/EDK/MiniSetup/BootOnly/postmgmtext.c @@ -0,0 +1,964 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2014, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmtext.c $ +// +// $Author: Premkumara $ +// +// $Revision: 19 $ +// +// $Date: 8/28/14 8:39a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmtext.c $ +// +// 19 8/28/14 8:39a Premkumara +// [TAG] EIP142551 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Mouse Movement is not initialized to Full Screen Resolution +// in case of quiet boot mode with high resolution OEM Logo. +// [Root Cause] Mouse Initialization was not across the full screen incase +// of High Resolution Quiet Boot Logo. +// [Solution] Initialised the Mouse with the Resolution Set in case of +// Quiet Boot logo so that Mouse will move acroos the Whole screen +// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c, +// Notify.c, MinisetupExt.c +// +// 18 8/28/14 7:30a Premkumara +// [TAG] EIP107833, 125388 +// [Category] Improvement +// [Symptom:] Setting best text and GOP mode while using TSEPostinterfaces +// before TSE or after TSE. +// [Files] Protocol.c, AMITSE.sdl, CommonHelper.c, MiniSetup.sdl, +// PostMgmtc, PostmgmtExt.c, MessagBox.c +// +// 17 7/15/14 5:50p Arunsb +// [TAG] EIP174261 +// [Category] Bug Fix +// [Severity:] Important +// [Symptom:] Location issue of Password Popup +// [Root Cause] Text Mode was not setting properly when gMaxRows != Rows +// or gMaxCols != Cols +// [Solution] Modified the code to set the Text Mode properly when +// gMaxRows != Rows +// or gMaxCols != Cols +// [Files] postmgmtext.c +// +// 16 6/25/14 12:33a Premkumara +// [TAG] EIP173965 +// [Category] Bug Fix +// [Severity:] Important +// [Symptom:] HDD password prompt is not proper in post. +// [Root Cause] Since the password length for HDD password is +// IDE_PASSWORD_LENGTH = 32 and Setup password is SETUP_PASSWORD_LENGTH = +// 20(TsePasswordLength) . So using TsePasswordLength to find coordinate +// of X for displaying either HDD/Setup password prompt in post will cause +// distortion for HDD. +// [Solution] Using respective password (HDD/Setup) length to find the +// coordinates of X for drawing post HDD/Setup password prompt in proper +// place. +// [Files] PostMgmtExt.c +// +// 15 5/03/14 6:24p Premkumara +// [TAG] EIP135665 +// [Category] Bug Fix +// Solved crashing issue in post password when password window title is +// more than 80 +// [Files] PostMgmtExt.c +// +// 14 5/03/14 4:04p Premkumara +// [TAG] EIP135665 +// [Category] Bug Fix +// [Severity:] Important +// [Symptom:] TSE get hangs, when long string is given as title for +// password +// [Root Cause] TSE is not handling properl when PasswordTitle length +// exceeds screen width +// [Solution] Handled password title length based on screen width and +// given support to display title in multiple lines. +// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c +// +// 13 2/11/14 8:21p Arunsb +// Changes reverted for 2.16.1243 label +// +// 12 12/05/13 10:57a Premkumara +// [TAG] EIP135665 +// [Category] Bug Fix +// [Severity:] Important +// [Symptom:] TSE get hangs, when long string is given as title for +// password +// [Root Cause] TSE is not handling properl when PasswordTitle length +// exceeds screen width +// [Solution] Handled password title length based on screen width and +// given support to display title in multiple lines. +// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c +// +// 11 9/18/13 7:09a Arunsb +// [TAG] EIP135029, 136209 +// [Category] Bug Fix +// [Severity:] Normal +// [Symptom:] Password popup window displayed with post messages +// [Root Cause] Since ClearScreen is commented, dorealflushlines displays +// the previous saved post messages also +// [Solution] ClearScreen uncommented +// [Files] postmgmtext.c +// +// 10 3/16/13 2:16a Rajashakerg +// [TAG] EIP111479 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] BIOS dialog box is crashed with special +// monitor(160,53,1280*1024) +// [RootCause] DesiredTextMode was not set properly. +// [Solution] Provided proper mode number while setting text mode. +// [Files] postmgmtext.c, Ezport\stylecommon.c, +// EzportPlus\stylecommon.c, Legacy\stylecommon.c +// +// 9 10/19/12 6:28a Arunsb +// [Issue] - Screen is not cleared fully while displaying logo at (0,0) +// position in post screen. +// [Solution] - Clearing whole graphics screen while drawing logo at (0,0) +// co-ordinates +// +// 3 10/19/12 5:28a Premkumara +// [Issue] - Screen is not cleared fully while displaying log at (0,0) +// position in post screen +// [Solution] - Clearing complete screen while drawing logo at (0,0) +// co-ordinates +// +// 2 10/10/12 12:37p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 6 9/17/12 6:10a Rajashakerg +// Updated EIP changes for 2.16 release. +// +// 4 8/29/12 8:30a Premkumara +// [TAG] EIP 91364 +// [Category] Improvement +// [Description] Token to disable the Cursor of TSE Password Dialog +// [Files] AMITSE.sdl, CommonHelper.c, Postmgmtext.c, PopupPassword.c, +// PopupString.c +// +// 3 5/28/12 11:27a Premkumara +// [TAG] EIP88912 +// [Category] Improvement +// [Description] On password window display the softkbd with only with +// valid key's +// [Files] CommonHelper.c, Postmgmtext.c, Mouse.c, PopupPassword.c +// +// 2 12/08/11 1:06p Rajashakerg +// [TAG] EIP75379 +// [Category] Improvement +// [Description] Suppress the warnings from static code analyzer +// [Files] Postmgmtext.c, Uefi21Wapper.c +// +// 1 12/08/11 4:54a Arunsb +// EIP63190 => Moving password support from TSELite to BootOnly +// +// 18 11/30/11 11:26a Premkumara +// [TAG] EIP67695 +// [Category] Improvement +// [Description] No cursor visible in setup, while editing text input +// box +// [Files] Buffer.c, Postmgmtext.c, PopupString.c, PopupPassword.c +// +// 17 11/22/11 5:33a Rajashakerg +// [TAG] EIP62763 +// [Description] Removed wanted mouseinit before drawing password window +// at post. +// +// 16 11/22/11 12:13a Premkumara +// [TAG] EIP70175 +// [Category] Improvement +// [Description] Color of Password Validation for TSE and GTSE +// [Files] CommonHelper.c, postmgmtext.c +// +// 15 11/20/11 8:16a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 14 11/20/11 8:08a Premkumara +// [TAG] EIP70175 +// [Category] Improvement +// [Description] Color of PopupPassword Window to validate password in +// GTSE style +// [Files] CommonHelper.c, postmgmtext.c, minisetup.h +// +// 13 8/26/11 6:46a Arunsb +// [TAG] EIP66211 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Password window hangs while pressing ESC +// [RootCause] If status is not equals success then TSE hangs the +// system. +// [Solution] If password window is time out then TSE will hang. +// If ESC pressed for password window then that try wont taken +// into account. +// [Files] postmgmtext.c +// +// 12 6/24/11 9:35a Arunsb +// [TAG] EIP62754 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Time out not occurring in password popup window +// [RootCause] Timer event was set only for the first try in consecutive +// tries +// event not created +// [Solution] If time out occurs in first try then TSE wont try for next +// iteration to get password. +// TSE will report error and waits upto +// restarting the system. +// +// [Files] postmgmtext.c +// +// 11 6/08/11 11:26p Arunsb +// [TAG] EIP59138 +// [Category] Improvement +// [Description] TSE expects extra key on the last wrong password retry +// [Files] postmgmtext.c +// +// 10 3/28/11 9:25p Madhans +// [TAG] EIP41744 +// [Category] Improvement +// [Description] SoftKeyBoard Support in TSE. and Support to Work with +// new mouse driver(Label 07). +// [Files] HookAnchor.h +// AMITSE.sdl +// CommonHelper.c +// commonoem.c +// commonoem.h +// HookList.c +// HookAnchor.c +// Mouse.c +// minisetupext.c +// postmgmtext.c +// minisetupext.h +// PopupPassword.c +// PopupString.c +// TseLiteCommon.c +// +// 9 1/10/11 3:59p Mallikarjunanv +// [TAG] EIP51621 +// [Description] Updated with respect to pressing ESC in password dialog +// box while entring to setup +// +// 8 1/07/11 12:42a Mallikarjunanv +// [TAG] EIP51621 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] pressing ESC in password dialog makes system hang +// [RootCause] While entering password to boot to setup ESC key is not +// handled properly +// [Solution] Fixed the issue by handling the ESC key properly. +// [Files] postmgmtext.c +// +// 7 10/27/10 3:14p Madhans +// [TAG] EIP44886 +// [Category] Defect +// [Symptom] If the SETUP_PASSWORD_LENGTH Changed to smaller then while +// entering Invalid Password in POST causes +// Error message printed outside of the box. +// [RootCause] The Boxsize is depending on Max Password length +// [Solution] Boxsize is desided on Maximum of ErrorString or +// PasswordLength +// [Files] postmgmtext.c +// +// 6 4/16/10 5:13p Madhans +// Changes for Tse 2.02. Please see Changelog.log for more details. +// +// 5 2/26/10 8:56p Madhans +// EIP-28501: fix for the issue for validating password using scan code +// +// 4 2/26/10 8:54p Madhans +// For TSE 2.01.1024. refer changelog.log for file checkin history . +// +// 7 2/25/10 12:27p Madhans +// EIP 35391 To resolve the Get Password Window if it is called second +// time. +// +// 5 2/19/10 8:19a Mallikarjunanv +// updated year in copyright message +// +// 4 2/04/10 11:17p Madhans +// Mouse support related code optimized +// +// 3 6/23/09 6:53p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:44p Presannar +// Initial implementation of coding standards for AMITSE2.0 +// +// 1 6/04/09 8:05p Madhans +// +// 2 5/19/09 6:32p Madhans +// DoRealFlushLines added to avoid the image overriding during post if +// password set +// +// 1 4/28/09 11:06p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 4/28/09 9:40p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:59p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: PostMgmtExt.c +// +// Description: This file contains code extended post management operations +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +//////////////////////////////////////////////////////////////////// +// Function Declarations +//////////////////////////////////////////////////////////////////// +//EIP-70175 Set Password Popup Window and PopupTextBox color +UINT8 GetPasswordPopupTextBoxColor (VOID); +UINT8 GetPasswordPopupWindowColor (VOID); +UINT8 GetPasswordReportInboxcolor (VOID); +BOOLEAN IsMouseSupported (VOID); +BOOLEAN IsSoftKbdSupported (VOID); +VOID SetPwdKeyboardLayout (VOID);//EIP-88912 +VOID ResetPwdKeyboardLayout (VOID);//EIP-88912 +BOOLEAN IsTSECursorSupport (); //EIP-91364 +void ClearGrphxScreen (void); +BOOLEAN IsTSEMultilineControlSupported (VOID); //EIP-135665 Multiline support for Password and String control +EFI_STATUS SaveCurrentTextGOP ( UINTN *currenttextModeCols, UINTN *currenttextModeRows, UINT32 *currentGOPMode ); +EFI_STATUS RestoreTextGOPMode ( UINTN prevTextModeCols, UINTN prevTextModeRows, UINT32 prevGOPMode ); +// +//---------------------------------------------------------------------------- +// Procedure: SetSystemAccessValue +// +// Description: function to set the system access Value +// +// Input: UINT8 sysAccessValue +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID SetSystemAccessValue(UINT8 sysAccessValue) +{ + EFI_GUID sysAccessGuid = SYSTEM_ACCESS_GUID; + if(NoVarStoreSupport()) + { + NoVarStoreUpdateSystemAccess(sysAccessValue); + } + else + VarSetNvramName( L"SystemAccess", &sysAccessGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &sysAccessValue, sizeof(sysAccessValue) ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetPasswordType +// +// Description: function to set the type of password +// +// Input: UINT32 PasswordType +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID SetPasswordType( UINT32 PasswordType ) +{ + UINT8 sysAccessValue = SYSTEM_PASSWORD_ADMIN; + + gPasswordType = PasswordType; + + if ( gPasswordType == AMI_PASSWORD_USER ) + sysAccessValue = SYSTEM_PASSWORD_USER; + + if ( gPasswordType != AMI_PASSWORD_NONE ) + { + if(ItkSupport()) + { + SetSystemAccessValueItk(sysAccessValue); + } + else + { + SetSystemAccessValue(sysAccessValue); + } + } + + return; +} +/*Removed from BootOnly +// +//---------------------------------------------------------------------------- +// Procedure: CheckEnableQuietBoot +// +// Description: Function to check the quick boot enable option +// +// Input: void +// +// Output: void +// +// Notes : if NVRAM variable field AMISilentBoot = 0, then disable silent +// mode else enable In case of error reading the Setup variable, +// then return as silent boot disable +// +//---------------------------------------------------------------------------- +// +VOID CheckEnableQuietBoot( VOID ) +{ +#ifndef STANDALONE_APPLICATION + if(ItkSupport()) + gQuietBoot = TRUE; + else + { + UINT8 *setupvar=NULL; + UINT8 *setup=NULL; + UINTN size = 0; + UINTN offset; + + GetAMITSEVariable((AMITSESETUP**)&setup,&setupvar,&size); + + offset = STRUCT_OFFSET( AMITSESETUP, AMISilentBoot ); + if ( ( setup == NULL ) || ( size < offset ) ) + gQuietBoot = FALSE; + else + gQuietBoot = (BOOLEAN)setup[offset]; + + if(setupvar) + MemFreePointer( (VOID **)&setupvar ); + else + MemFreePointer( (VOID **)&setup ); + } +#endif //#ifndef STANDALONE_APPLICATION +} +*/ +// +//---------------------------------------------------------------------------- +// Procedure: CheckSystemPassword +// +// Description: Function to check the system password +// +// Input: UINT32 EmptyPasswordType, UINTN *NoOfRetries, UINTN *TimeOut +// +// Output: PasswordCheck +// +//---------------------------------------------------------------------------- +// +UINT32 CheckSystemPassword(UINT32 EmptyPasswordType, UINTN *NoOfRetries, UINTN *TimeOut) +{ + UINTN PasswordCheck = AMI_PASSWORD_NONE; + UINTN CurrXPos, CurrYPos; + CHAR16 *PasswordEntered; + UINT32 PasswordInstalled; + SCREEN_BUFFER *TempScreenBuffer = NULL; + CHAR16 *BoxStr=NULL; + UINTN BoxLength = TsePasswordLength; + + UINTN currenttextModeCols = 0, currenttextModeRows = 0; + UINT32 currentGOPMode = 0; + + EFI_STATUS Status = EFI_SUCCESS; + + EFI_GUID AmitsePasswordPromptEnterGuid = AMITSE_PASSWORD_PROMPT_ENTER_GUID; + EFI_GUID AmitsePasswordPromptExitGuid = AMITSE_PASSWORD_PROMPT_EXIT_GUID; + EFI_GUID AmitseUserPasswordValidGuid = AMITSE_USER_PASSWORD_VALID_GUID; + EFI_GUID AmitseAdminPasswordValidGuid = AMITSE_ADMIN_PASSWORD_VALID_GUID; + EFI_GUID AmitseInvalidPasswordGuid = AMITSE_INVALID_PASSWORD_GUID; + + EfiLibNamedEventSignal (&AmitsePasswordPromptEnterGuid); + // Report the Status code DXE_SETUP_VERIFYING_PASSWORD + EfiLibReportStatusCode(EFI_PROGRESS_CODE, DXE_SETUP_VERIFYING_PASSWORD,0,NULL,NULL); + + CheckForKeyHook( (EFI_EVENT)NULL, NULL ); + if( IsMouseSupported() && IsSoftKbdSupported()) + CheckForClickHook( (EFI_EVENT)NULL, NULL );//EIP 62763 : Checking for mouse and softkbd. + + gST->ConIn->Reset( gST->ConIn, FALSE ); + + // Copy the contents of Active buffer so password code can use it + TempScreenBuffer = EfiLibAllocateZeroPool( sizeof(SCREEN_BUFFER) ); + if(TempScreenBuffer != NULL) + MemCopy(TempScreenBuffer, gActiveBuffer, sizeof(SCREEN_BUFFER)); + + BoxStr = HiiGetString( gHiiHandle, STRING_TOKEN(STR_ERROR_PSWD)); + if ( BoxStr ){ + if ((TestPrintLength( BoxStr ) / NG_SIZE) > BoxLength ){ + BoxLength = TestPrintLength( BoxStr ) / NG_SIZE; + } + } + MemFreePointer((VOID**) &BoxStr ); + + SaveCurrentTextGOP (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + //Draw password window + _DrawPasswordWindow(STRING_TOKEN(STR_PASSWORD_PROMPT), BoxLength, &CurrXPos, &CurrYPos); + + PasswordEntered = EfiLibAllocatePool((TsePasswordLength + 1)*sizeof(CHAR16)); + PasswordInstalled = PasswordCheckInstalled(); + PasswordCheck = AMI_PASSWORD_NONE; + + //Give retries based on NoOfRetries + while(*NoOfRetries) + { + //EIP:51621 Handling ESC key for the the input password + Status = _GetPassword (PasswordEntered, TsePasswordLength, CurrXPos, CurrYPos, TimeOut); + if (EFI_ABORTED == Status) //Status should be aborted, success or timeout. If time out we should not go for another iteration + { //If user presses ESC TSE handle that as invalid case so let it for another iteration. + continue; + } + else if (EFI_TIMEOUT == Status) + { + break; //EIP 62754; Breaking if time out occurs + } + PasswordCheck = PasswordAuthenticate( PasswordEntered ); + PasswordCheck &= PasswordInstalled; + + if((PasswordEntered[0] == L'\0') && (AMI_PASSWORD_NONE == PasswordCheck)) + { + //Honour EmptyPasswordType + if( + (!(PasswordInstalled & AMI_PASSWORD_USER ))&& + (EmptyPasswordType & AMI_PASSWORD_USER) + ) + PasswordCheck = AMI_PASSWORD_USER; + if( + (!(PasswordInstalled & AMI_PASSWORD_ADMIN ))&& + (EmptyPasswordType & AMI_PASSWORD_ADMIN) + ) + PasswordCheck = AMI_PASSWORD_ADMIN; + } + + if(AMI_PASSWORD_NONE != PasswordCheck) + break; + else + { + if (1 == *NoOfRetries) // Do not wait for key if it is the lastest try + _ReportInBox( TsePasswordLength, STRING_TOKEN(STR_ERROR_PSWD), CurrXPos, CurrYPos, FALSE); + else + _ReportInBox( TsePasswordLength, STRING_TOKEN(STR_ERROR_PSWD), CurrXPos, CurrYPos, TRUE); + } + + (*NoOfRetries)--; + } + + MemFreePointer((VOID **)&PasswordEntered); + + if(AMI_PASSWORD_NONE == PasswordCheck) + { + EfiLibNamedEventSignal (&AmitseInvalidPasswordGuid); + EfiLibReportStatusCode(EFI_ERROR_CODE| EFI_ERROR_MAJOR, DXE_INVALID_PASSWORD,0,NULL,NULL); + + //Report Invalid password + _ReportInBox( TsePasswordLength, STRING_TOKEN(STR_ERROR_PSWD), CurrXPos, CurrYPos, FALSE); + } + else + { + MouseStop(); + ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ); + DoRealFlushLines(); + MouseRefresh(); + + if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present + MouseInit(); + + if (!( PasswordInstalled & AMI_PASSWORD_ADMIN )) + PasswordCheck = AMI_PASSWORD_ADMIN; + SetPasswordType( (UINT32)PasswordCheck ); + + if(AMI_PASSWORD_ADMIN == PasswordCheck) + EfiLibNamedEventSignal (&AmitseAdminPasswordValidGuid); + + if(AMI_PASSWORD_USER == PasswordCheck) + EfiLibNamedEventSignal (&AmitseUserPasswordValidGuid); + } + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + EfiLibNamedEventSignal (&AmitsePasswordPromptExitGuid); + + //Copy the original active buffer contents + if(TempScreenBuffer != NULL) + { + MemCopy(gActiveBuffer, TempScreenBuffer, sizeof(SCREEN_BUFFER)); + MemFreePointer((VOID **) &TempScreenBuffer); + } + return ((UINT32)PasswordCheck); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _DrawPasswordWindow +// +// Description: Function to draw password window with attributes +// +// Input: UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID _DrawPasswordWindow(UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos) +{ + UINTN DlogWidth = PasswordLength + 4; + UINTN Height=1; + CHAR16 *PasswordPrompt; + +#ifndef STANDALONE_APPLICATION + if ( gConsoleControl != NULL ) + gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenText ); +#endif + + //Set desired Mode. +#if !APTIO_4_00 + SetDesiredTextMode(); +#else + // In Aptio use the Text mode as is it in post screen + if(gST->ConOut!=NULL) + { + UINTN Rows, Cols; + if(EFI_ERROR(gST->ConOut->QueryMode( gST->ConOut, gST->ConOut->Mode->Mode, &Cols, &Rows ))) + { + gMaxRows = STYLE_STD_MAX_ROWS; + gMaxCols = STYLE_STD_MAX_COLS; + } + else if ((gMaxRows != Rows) || (gMaxCols != Cols)) + { + //Setting the Desired text mode as is it in post screen + SetDesiredTextMode (); + } + + } + else + { + gMaxRows = STYLE_STD_MAX_ROWS; + gMaxCols = STYLE_STD_MAX_COLS; + } +#endif + + if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present + MouseInit(); + + MouseStop(); + // Clear the Screen + ClearGrphxScreen ();//To clear screen while drawing logo at (0,0) co-ordinates +// ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ); + DoRealFlushLines(); + MouseRefresh(); + + PasswordPrompt = HiiGetString( gHiiHandle, PromptToken); + if ( PasswordPrompt != NULL ) + { + if ( (TestPrintLength(PasswordPrompt) / NG_SIZE +6) > DlogWidth ) + DlogWidth = TestPrintLength(PasswordPrompt) / NG_SIZE +6; + } + + if (DlogWidth >= (gMaxCols-2)) //EIP-135665 If string is more than gMaxCols 80/100 + { + if ( IsTSEMultilineControlSupported() ) //If multiline supported + { + Height=(DlogWidth / (gMaxCols-2))+(((DlogWidth % (gMaxCols-2)) > 0)?1:0); + DlogWidth = gMaxCols-2; + } + else + { + DlogWidth = gMaxCols-2; + PasswordPrompt[DlogWidth-4]=L'\0'; + PasswordPrompt[DlogWidth-5]=L'.'; + PasswordPrompt[DlogWidth-6]=L'.'; + PasswordPrompt[DlogWidth-7]=L'.'; + } + } + + *CurrYPos = (gMaxRows - 5) / 2; + *CurrXPos = (gMaxCols-2 - DlogWidth) / 2; + + //EIP-70175 Set Password Window color + //DrawWindow( *CurrXPos, *CurrYPos, DlogWidth, 5, EFI_BACKGROUND_BLUE | EFI_WHITE, TRUE, FALSE ); + DrawWindow( *CurrXPos, *CurrYPos, DlogWidth, 4+Height, GetPasswordPopupWindowColor(), TRUE, FALSE ); + + if ( PasswordPrompt != NULL ) + { + if ( IsTSEMultilineControlSupported() ) //If multiline supported + DrawMultiLineStringWithAttribute ((*CurrXPos)+2, *CurrYPos, DlogWidth-3, Height, PasswordPrompt, 0); + else + DrawStringJustified( 0, gMaxCols-2, *CurrYPos, JUSTIFY_CENTER, PasswordPrompt ); + } + MemFreePointer( (VOID **)&PasswordPrompt ); + + //Record position of the Box + *CurrXPos = ((gMaxCols - DlogWidth) / 2)+1; //EIP-173320 HDD password prompt issue + *CurrYPos += Height+1; + + FlushLines( *CurrYPos - Height-1, *CurrYPos + 2); + MouseStop(); + DoRealFlushLines(); + MouseRefresh(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _ReportInBox +// +// Description: Function to report using Box +// +// Input: UINTN PasswordLength, UINT16 BoxToken, UINTN CurrXPos, +// UINTN CurrYPos, BOOLEAN bWaitForReturn +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID _ReportInBox( + UINTN PasswordLength, + UINT16 BoxToken, + UINTN CurrXPos, + UINTN CurrYPos, + BOOLEAN bWaitForReturn + ) +{ + CHAR16 *BoxStr=NULL; + EFI_INPUT_KEY Key; + + //Draw Box + //EIP-70175 Set Password ReportInbox color + //DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, EFI_BACKGROUND_BLUE | EFI_WHITE ); + DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, GetPasswordReportInboxcolor()); + + //Draw Box string + if(BoxToken != INVALID_TOKEN) + { + BoxStr = HiiGetString( gHiiHandle, BoxToken ); + DrawString( CurrXPos, CurrYPos, BoxStr); + } + + SetPwdKeyboardLayout();//EIP-88912 + TSEStringReadLoopEntryHook(); + + FlushLines( CurrYPos - 2, CurrYPos + 2 ); + MouseStop(); + DoRealFlushLines(); + MouseRefresh(); + + if(bWaitForReturn) + { + MemFillUINT16Buffer(BoxStr, (TestPrintLength(BoxStr)/ NG_SIZE), L' '); + + Key.UnicodeChar = 0; + do + { + gST->ConIn->ReadKeyStroke( gST->ConIn, &Key ); + } while( Key.UnicodeChar != CHAR_CARRIAGE_RETURN ); + + DrawString( CurrXPos, CurrYPos, BoxStr); + MemFreePointer((VOID **) &BoxStr); + } + + TSEStringReadLoopExitHook(); + ResetPwdKeyboardLayout();//EIP-88912 + + MemFreePointer((VOID **)&BoxStr); +} + +VOID SetPwdTimeOut( EFI_EVENT Event, BOOLEAN *timeout ) +{ + if ( timeout != NULL ) + *timeout = TRUE; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _GetPassword +// +// Description: Function to get password from the user +// +// Input: CHAR16 *PasswordEntered, UINTN PasswordLength, UINTN CurrXPos, +// UINTN CurrYPos, UINTN *pTimeOut +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS _GetPassword( + CHAR16 *PasswordEntered, + UINTN PasswordLength, + UINTN CurrXPos, + UINTN CurrYPos, + UINTN *pTimeOut + ) +{ + EFI_INPUT_KEY Key = {0,0}; + UINTN StrIndex; + CHAR16 *StrStar; + UINTN i; + volatile BOOLEAN bTimeOut = FALSE; + UINTN TimeOutValue; + EFI_EVENT timer; + EFI_STATUS Status; + AMI_EFI_KEY_DATA KeyData; + + MemSet( PasswordEntered, (PasswordLength + 1)*sizeof(CHAR16), 0 ); + StrStar = EfiLibAllocatePool((PasswordLength + 1)*sizeof(CHAR16)); + StrIndex = 0; + + //EIP-70175 Set Password PopupTextBox color + //DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, EFI_BACKGROUND_LIGHTGRAY | EFI_BLUE ); + DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, GetPasswordPopupTextBoxColor() ); + + FlushLines( CurrYPos, CurrYPos ); + MouseStop(); + DoRealFlushLines(); + MouseRefresh(); + + SetPwdKeyboardLayout();//EIP-88912 + TSEStringReadLoopEntryHook(); + + if (IsTSECursorSupport()) //EIP-91364 + { + gST->ConOut->SetCursorPosition( gST->ConOut, CurrXPos, CurrYPos); //EIP:67695 Cursor support for msg boxes + gST->ConOut->EnableCursor(gST->ConOut, TRUE);//EIP:67695 Enable Cursor support for msg boxes + } + do + { + TimeOutValue = pTimeOut ? *pTimeOut : 0; + + if(TimeOutValue) + { + timer = NULL; + Status = TimerCreateTimer( &timer, SetPwdTimeOut, (VOID *)&bTimeOut, TimerRelative, TimeOutValue * TIMER_ONE_SECOND, EFI_TPL_NOTIFY ); + } + + // While the timeout has not expired + while ( ! bTimeOut ) + { + Status = AMIReadKeyStroke(&Key,&KeyData); + if ( !(EFI_ERROR(Status)) ) + break; + } + + if(TimeOutValue) + TimerStopTimer( &timer ); + + if(bTimeOut) + { + Status = gST->ConIn->Reset( gST->ConIn, FALSE ); + MemFreePointer((VOID **)&StrStar); + PasswordEntered[0] = L'\0'; + break; + } + + switch (Key.UnicodeChar) + { + case CHAR_NULL: + if (Key.ScanCode == SCAN_ESC) + { + Status = gST->ConIn->Reset( gST->ConIn, FALSE ); + MemFreePointer((VOID **)&StrStar); + PasswordEntered[0] = L'\0'; + TSEStringReadLoopExitHook(); + ResetPwdKeyboardLayout();//EIP-88912 + return EFI_ABORTED; + } + if (Key.ScanCode != SCAN_NULL) { + if(HelperIsPasswordCharValid(&Key,&KeyData,StrIndex,PasswordLength,&PasswordEntered[StrIndex]) == EFI_SUCCESS) + StrIndex++; + } + else { + InvalidActionHookHook(); + } + break; + + case CHAR_CARRIAGE_RETURN: + Status = gST->ConIn->Reset( gST->ConIn, FALSE ); + MemFreePointer((VOID **)&StrStar); + TSEStringReadLoopExitHook(); + ResetPwdKeyboardLayout();//EIP-88912 + return EFI_SUCCESS; + + case CHAR_BACKSPACE: + if ( StrIndex != 0 ) + PasswordEntered[--StrIndex] = L'\0'; + break; + + default: + if(HelperIsPasswordCharValid(&Key,&KeyData,StrIndex,PasswordLength,&PasswordEntered[StrIndex]) == EFI_SUCCESS) + StrIndex++; + break; + } + if ( StrIndex > PasswordLength ) { + InvalidActionHookHook(); + } + //Draw stars for entered characters + for ( i = 0; i < PasswordLength; i++ ) + StrStar[i] = (iConOut->SetCursorPosition( gST->ConOut, ((PasswordLength!=StrIndex)?(CurrXPos + StrIndex):(CurrXPos + StrIndex-1)), CurrYPos); //EIP:67695 For restricting the cursor within the limit + gST->ConOut->EnableCursor(gST->ConOut, TRUE); //EIP:67695 Enable Cursor support for msg boxes + } + MouseRefresh(); + } + while( 1 ); + + TSEStringReadLoopExitHook(); + ResetPwdKeyboardLayout();//EIP-88912 + + //EIP-75379 Suppress the warnings from static code analyzer + if (pTimeOut) + *pTimeOut = 0; + return EFI_TIMEOUT; +} + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2014, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/print.c b/EDK/MiniSetup/BootOnly/print.c new file mode 100644 index 0000000..f8a4549 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/print.c @@ -0,0 +1,476 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/print.c $ +// +// $Author: Arunsb $ +// +// $Revision: 9 $ +// +// $Date: 5/21/14 6:27p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/print.c $ +// +// 9 5/21/14 6:27p Arunsb +// [TAG] EIPEIP169096,168632 +// [Description] Changed global variable guid usage for tse debug messages +// [Files] commonoem.c, setupdbg.h and print.c +// +// 8 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 9 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 7 5/29/12 4:34a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 6 11/14/11 2:58p Blaines +// [TAG] - EIP 75481 +// [Category]- Function Request +// [Synopsis]- TSE debug print infrastructure. +// [Description]- Add TSE debug print info for basic functions such as +// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms +// data. +// [Files] +// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c +// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c, +// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h, +// Uefi21Wrapper.c, setupdbg.h +// +// Update an incorrect string field. +// +// 5 11/14/11 2:43p Blaines +// [TAG] - EIP 75481 +// [Category]- Function Request +// [Synopsis]- TSE debug print infrastructure. +// [Description]- Add TSE debug print info for basic functions such as +// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms +// data. +// [Files] +// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c +// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c, +// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h, +// Uefi21Wrapper.c, setupdbg.h +// +// 4 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 6 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 5 2/15/10 10:11p Madhans +// to avoid compilation issues +// +// 4 6/24/09 6:09p Madhans +// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module. +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: Print.c +// +// Description: file contains code to support the print functionalities +// +//---------------------------------------------------------------------------- +// + +/*++ + VSPrint, Print, SPrint format specification has the follwoing form + + %[flags][width]type + + flags: + '-' - Left justify + '+' - Prefix a sign + ' ' - Prefix a blank + ',' - Place commas in numberss + '0' - Prefix for width with zeros + 'l' - UINT64 + 'L' - UINT64 + + width: + '*' - Get width from a UINTN argumnet from the argument list + Decimal number that represents width of print + + type: + 'X' - argument is a UINTN hex number, prefix '0' + 'x' - argument is a hex number + 'd' - argument is a decimal number + 'a' - argument is an ascii string + 'S','s' - argument is an Unicode string + 'g' - argument is a pointer to an EFI_GUID + 't' - argument is a pointer to an EFI_TIME structure + 'c' - argument is an ascii character + 'r' - argument is EFI_STATUS + '%' - Print a % + +--*/ +#include "minisetup.h" +#include "setupdbg.h" + +#if !TSE_USE_EDK_LIBRARY + +typedef struct _EFI_PRINT_PROTOCOL EFI_PRINT_PROTOCOL; + +typedef UINTN (EFIAPI *EFI_VSPRINT)( + OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, IN va_list Marker +); +extern EFI_GUID gEfiPrintProtocolGuid; +struct _EFI_PRINT_PROTOCOL{ + EFI_VSPRINT VSPrint; +}; + +#else + +#include "Tiano.h" +#include "EfiDriverLib.h" +#include "TianoCommon.h" +#include "EfiCommonLib.h" +#include "EfiPrintLib.h" + +#endif + +//EIP75481 Support TSE debug print infrastructure +#if TSE_DEBUG_MESSAGES + +extern BOOLEAN SetupDebugKeyHandler(UINT16 ItemIndex, UINT16 Unicode, CHAR16 *Value) ; +extern EFI_STATUS DisplayParseFormSetData(VOID) ; +extern EFI_STATUS DebugShowAllHiiVariable(UINT32 formID); +#endif +//typedef CHAR16 CHAR_W; +#if TSE_APTIO_5_SUPPORT +#define AMITSE_VSPrint Swprintf_s_va_list +#else +#define AMITSE_VSPrint VSPrint +#endif +// +//------------------------------------------------------------------------------------------------------------- +// Procedure: VSPrint +// +// Description: VSPrint function to process format and place the results in Buffer. Since a +// VA_LIST is used this rountine allows the nesting of Vararg routines. Thus +// this is the main print working routine +// +// Input: StartOfBuffer - Unicode buffer to print the results of the parsing of Format into. +// BufferSize - Maximum number of characters to put into buffer. Zero means no limit. +// FormatString - Unicode format string see file header for more details. +// Marker - Vararg list consumed by processing Format. +// +// Output: Number of characters printed. +// +//------------------------------------------------------------------------------------------------------------- +// +UINTN +VSPrint ( + OUT CHAR16 *StartOfBuffer, + IN UINTN BufferSize, + IN CONST CHAR16 *FormatString, + IN VA_LIST Marker + ) +{ + EFI_STATUS Status; + EFI_PRINT_PROTOCOL *PrintProtocol; + + Status = gBS->LocateProtocol ( + &gEfiPrintProtocolGuid, + NULL, + &PrintProtocol + ); + if (EFI_ERROR (Status)) { + return 0; + } else { + return PrintProtocol->VSPrint ( + StartOfBuffer, + BufferSize, + FormatString, + Marker + ); + } +} + + + +// +//------------------------------------------------------------------------------------------------------------- +// Procedure: SPrint +// +// Description: SPrint function to process format and place the results in Buffer +// +// Input: Buffer - Wide char buffer to print the results of the parsing of Format into. +// BufferSize - Maximum number of characters to put into buffer. Zero means no limit. +// Format - Format string see file header for more details. +// ... - Vararg list consumed by processing Format. +// +// Output: Number of characters printed. +// +//------------------------------------------------------------------------------------------------------------- +// +UINTN +SPrint ( + OUT CHAR16 *Buffer, + IN UINTN BufferSize, + IN CONST CHAR16 *Format, + ... + ) +{ + UINTN Return; + VA_LIST Marker; + + VA_START (Marker, Format); + Return = AMITSE_VSPrint(Buffer, BufferSize, Format, Marker); + VA_END (Marker); + + return Return; +} + +#define MAX_DEBUG_STRING_SIZE 1000 + +CHAR16 tmpBuffer[MAX_DEBUG_STRING_SIZE]; + +// +//------------------------------------------------------------------------------------------------------------- +// Procedure: SetupDebugPrint +// +// Description: +// +// Input: +// +// Output: +// +//------------------------------------------------------------------------------------------------------------- +// +VOID SetupDebugPrint(IN CONST CHAR8 *Format, ...) +{ + UINTN Return = 0; + VA_LIST Marker; + CHAR16 *c16Format = (CHAR16 *)NULL; + CHAR8 *trace = NULL; + + c16Format = StrDup8to16((CHAR8 *)Format); + + VA_START (Marker, Format); + Return = AMITSE_VSPrint(tmpBuffer, MAX_DEBUG_STRING_SIZE, (CONST CHAR16 *)c16Format, Marker); + VA_END (Marker); + + //For TRACE (Serial Output) +#if SERIAL_DEBUG +// TRACE(-1, Format, Marker); + + trace = StrDup16to8(tmpBuffer); + TRACE ((-1, trace)); + MemFreePointer( (VOID **)&trace ); + +#else //Else of SERIAL_DEBUG + +#if SCREEN_PRINT + Print(tmpBuffer); +#else //Else of SCREEN_PRINT + if(gST->ConOut){ + gST->ConOut->OutputString( gST->ConOut, tmpBuffer ); + } +#endif //End of SCREEN_PRINT +#endif //End of SERIAL_DEBUG + MemFreePointer( (VOID **)&c16Format ); +} + +// +//---------------------------------------------------------------------------- +// +// Procedure: SetupShowDebugScreen +// +// Description: +// +// Parameter: +// +// Return value: +//---------------------------------------------------------------------------- +// +//extern VOID HandleDebugDumpKey( VOID *app, VOID *hotkey, VOID *cookie ); +VOID SetupShowDebugScreen(VOID *app, VOID *hotkey, VOID *cookie ) +{ + +#if TSE_DEBUG_MESSAGES + CHAR16 HiiParseing[2] = L"x" ; + CHAR16 HiiFunction[2] = L"x" ; + CHAR16 HiiNotification[2] = L"x"; + CHAR16 HiiCallback[2] = L"x" ; + CHAR16 PrintIfrForm[27] = L"press any key" ; + CHAR16 PrintVariableCache[27] = L"press any key" ; + + TEXT_INPUT_TEMPLATE SetupDebugItems[6] = + { + {STRING_TOKEN(STR_DBG_PRINT_HIIPARSING), 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiParseing}, + {STRING_TOKEN(STR_DBG_PRINT_HIIFUNCTION), 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiFunction}, + {STRING_TOKEN(STR_DBG_PRINT_HIICALLBACK), 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiCallback}, + {STRING_TOKEN(STR_DBG_PRINT_HIINOTIFICATION) , 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiNotification}, + {STRING_TOKEN(STR_DBG_PRINT_IFRFORM), 13, TSE_FILTER_KEY_CUSTOM, FALSE, PrintIfrForm}, + {STRING_TOKEN(STR_DBG_PRINT_VARIABLE_CACHE), 13, TSE_FILTER_KEY_CUSTOM, FALSE, PrintVariableCache} + }; + + UINT16 Title = HiiAddString( gHiiHandle, L"TSE Debug Print") ; + + if((gDbgPrint & PRINT_UEFI_PARSE)!= PRINT_UEFI_PARSE) + EfiStrCpy( HiiParseing, L" ") ; + + if((gDbgPrint & PRINT_UEFI)!= PRINT_UEFI) + EfiStrCpy( HiiFunction, L" ") ; + + if((gDbgPrint & PRINT_UEFI_NOTIFICATION)!= PRINT_UEFI_NOTIFICATION) + EfiStrCpy( HiiNotification, L" ") ; + + if((gDbgPrint & PRINT_UEFI_CALLBACK)!= PRINT_UEFI_CALLBACK) + EfiStrCpy( HiiCallback, L" ") ; + + + + PostManagerDisplayTextBox( + gHiiHandle, + Title, + SetupDebugItems, + 6, + SetupDebugKeyHandler + ) ; +#endif +} + +#if TSE_DEBUG_MESSAGES + +// +//---------------------------------------------------------------------------- +// +// Procedure: SetupShowDebugScreen +// +// Description: +// +// Parameter: +// +// Return value: +//---------------------------------------------------------------------------- +// +VOID SetupToggleDebugFeature(UINT16 FeatureBit, CHAR16 *Value) +{ + + EFI_STATUS Status = EFI_UNSUPPORTED; + EFI_GUID guidDbgPrint = TSE_DEBUG_MESSAGES_GUID; + + if((gDbgPrint & FeatureBit)== FeatureBit) + { + gDbgPrint &= ~((UINT16)FeatureBit) ; + EfiStrCpy( Value, L" ") ; + } + else + { + gDbgPrint |= (UINT16)FeatureBit ; + EfiStrCpy( Value, L"x"); + } + + Status = pRS->SetVariable(L"TseDebugPrint", + &guidDbgPrint, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof(gDbgPrint), + &gDbgPrint); + + +} +// +//---------------------------------------------------------------------------- +// +// Procedure: SetupDebugKeyHandler +// +// Description: +// +// Parameter: +// +// Return value: +//---------------------------------------------------------------------------- +// +BOOLEAN SetupDebugKeyHandler(UINT16 ItemIndex, UINT16 Unicode, CHAR16 *Value) +{ + + switch(ItemIndex) + { + case 0: + SetupToggleDebugFeature(PRINT_UEFI_PARSE, Value) ; + break ; + case 1: + SetupToggleDebugFeature(PRINT_UEFI, Value) ; + break ; + case 2: + SetupToggleDebugFeature(PRINT_UEFI_CALLBACK, Value) ; + break ; + case 3: + SetupToggleDebugFeature(PRINT_UEFI_NOTIFICATION, Value) ; + break ; + case 4: + DisplayParseFormSetData() ; + break; + case 5: + DebugShowAllHiiVariable(0) ; + break; + default: + + break; + } + + return TRUE ; +} + + +#endif //End of TSE_DEBUG_MESSAGES +//EIP75481 + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/protocol.c b/EDK/MiniSetup/BootOnly/protocol.c new file mode 100644 index 0000000..d112674 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/protocol.c @@ -0,0 +1,1870 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2014, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.c $ +// +// $Author: Premkumara $ +// +// $Revision: 51 $ +// +// $Date: 8/28/14 7:36a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.c $ +// +// 51 8/28/14 7:36a Premkumara +// [TAG] EIP107833, 125388 +// [Category] Improvement +// [Symptom:] Setting best text and GOP mode while using TSEPostinterfaces +// before TSE or after TSE. +// [Files] Protocol.c, AMITSE.sdl, CommonHelper.c, MiniSetup.sdl, +// PostMgmtc, PostmgmtExt.c, MessagBox.c +// +// 50 5/02/14 7:06a Premkumara +// [TAG] EIP137373 +// [Category] Improvement +// [Description] Added signal event for BeforeTimeOut and AfterTimeOut +// with guids +// [Files] AMIVfr.h,protocol.c +// +// 49 5/02/14 6:15a Arunsb +// [TAG] EIP128665 +// [Category] Improvement +// [Description] Providing support to invalidate the BGRT status bit. +// Defined gTSEInvalidateBgrtStatusProtocolGuid +// [Files] protocol.c and amivfr.h +// +// 48 5/02/14 6:12a Arunsb +// [TAG] EIP128665 +// [Category] Improvement +// [Description] Providing support to invalidate the BGRT status bit +// [Files] protocol.c and amivfr.h +// +// 47 2/11/14 8:09p Arunsb +// Changes reverted for 2.16.1243 label +// +// 46 11/07/13 1:55a Premkumara +// [TAG] EIP-137373 +// [Category] Improvement +// [Description] Added signal event for BeforeTimeOut and AfterTimeOut +// with GUID +// [Files] Protocol.c, AMIVfr.h +// +// 45 10/07/13 3:17a Premkumara +// Resolved build error in EIP-128665 +// +// 44 9/13/13 2:01p Premkumara +// Uploaded back for EIP-128665 after TSEBootOnly 1240 release +// Files - Protocol.c, Protocol.h, AMIPostMgr.h +// +// 43 8/26/13 2:16a Premkumara +// Reverted back for BootOnly1240 release +// +// 41 4/18/13 6:15a Arunsb +// [TAG] EIP113081 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Post message displays twice +// [RootCause] Buffer not cleared after displaying post message +// [Solution] Buffer cleared properly. Save and restored the post +// graphics screen properly. +// [Files] protocol.c, screen.c and string.c +// +// 40 4/17/13 12:38p Arunsb +// [TAG] EIP107967 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Ami Post Management functionalities reliant on ConOut need +// checks added. +// [Files] protocol.c +// +// 39 12/05/12 5:31a Rajashakerg +// [TAG] EIP103381 +// [Category] Improvement +// [Description] adopting SDL to control timeout spec +// [Files] AMITSE.sdl, CommonHelper.c, protocol.c +// +// 38 12/05/12 4:50a Arunsb +// [TAG] EIP107967 +// [Category] Improvement +// [Description] Ami Post Management functionalities reliant on ConOut +// need checks added +// [Files] protocol.c +// +// 37 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 31 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 35 9/24/12 9:14a Premkumara +// [TAG] EIP 93797 +// [Category] Improvement +// [Description] Add support to check for enabled device in BBS priority +// order before launching legacy boot. +// [Files] bbs.c, Boot.c, Protocol.c +// +// 34 9/17/12 6:10a Rajashakerg +// Updated EIP changes for 2.16 release. +// +// 32 8/27/12 6:21a Premkumara +// [TAG] EIP 94616 +// [Category] Improvement +// [Description] TSE should not wait for key if fast boot is in progress +// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Protocol.c +// +// 31 5/29/12 4:35a Arunsb +// [TAG] EIP91109 +// [Category] Improvement +// [Description] Sync the Aptio IV source for AptioV +// +// 30 5/28/12 5:52a Premkumara +// [TAG] EIP75236 +// [Category] Improvement +// [Description] Add the support to control the GOP dependency in TSE +// notification. +// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h, +// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c +// +// 29 4/27/12 10:25a Premkumara +// [TAG] EIP87769 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] Strings are not cleared after calling +// PostManagerSwitchToPostScreen() function +// [RootCause] DoRealFlushLines() is not done in +// PostManagerSwitchToPostScreen() function +// [Solution] Updateed the PostManagerSwitchToPostScreen() function to +// perform DoRealFlushLines(). +// [Files] Protocol.c +// +// 28 4/04/12 12:27a Rajashakerg +// [TAG] EIP86253 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Mouse and SoftKbd does not work after displaying "No option +// to boot to" in POST +// [RootCause] Mouse timer cleared once after displaying the "No option +// to boot to" in POST +// [Solution] Mouse timer cleared only when its going to boot. +// [Files] CommonHelper.c, commonoem.c, minisetupext.c, protocol.c +// +// 27 4/03/12 9:54a Premkumara +// [TAG] EIP84150 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] All the timers for mouse drivers before exiting from setup +// is not stopped +// [RootCause] MouseDestroy() is not called StopPointingDevice() +// function to stop Mouse device +// [Solution] StopPointingDevice() function is called in MouseDestroy() +// function +// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c, +// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c +// +// 26 4/03/12 3:01a Premkumara +// [TAG] EIP84150 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] All the timers for mouse drivers before exiting from setup +// is not stopped +// [RootCause] MouseDestroy() is not called StopPointingDevice() +// function to stop Mouse device +// [Solution] StopPointingDevice() function is called in MouseDestroy() +// function +// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c, +// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c +// +// 25 1/25/12 5:12a Rajashakerg +// [TAG] EIP81549 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] BOOT_FLOW_NORMAL_INFINITE_LOOP enabled and pressing F7 +// while displaying "No option to boot to" is not working properly +// [RootCause] When F7 key is pressed we have gBootFlow = +// BOOT_FLOW_CONDITION_BBS_POPUP, and returning from checkforkey() and the +// F7 key is not getting consumed and keeps on looping. +// [Solution] Checking gBootFlow and making to normal in the loop. +// [Files] protocol.c +// +// 24 12/30/11 1:51a Arunsb +// [TAG] EIP76721 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] BOOT_FLOW_NORMAL_INFINITE_LOOP option is not working +// properly +// [RootCause] Iterating variable reinitialized to 0 so in next loop it +// becoming 1 so its missing first boot option +// [Solution] Iterating vairable reinitialized to -1. +// [Files] Protocol.c +// +// 23 11/21/11 5:48a Rajashakerg +// [TAG] EIP74591 +// [Category] Improvement +// [Description] Make MainSetupLoop as board module hook +// [Files] AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h, +// FormBrowser.c, FormBrowser2.c +// +// 22 11/20/11 7:19a Rajashakerg +// [TAG] EIP62763 +// [Category] Improvement +// [Description] Utilize the Improvements done from mouse driver in +// AMITSE +// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c, +// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c, +// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c, +// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c, +// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h, +// PopupPassword.c, postmgmtext.c, time.c. +// +// 21 10/31/11 2:14p Premkumara +// [TAG] EIP73751 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] L"BootFlow" variable uses inconsistent attributes +// [RootCause] L"BootFlow" variable uses inconsistent attributes in +// protocol.c +// [Solution] Made consistent use of L"Bootlow" variable with +// EFI_VARIABLE_BOOTSERVICE_ACCESS attribute +// [Files] protocol.c +// +// 20 9/29/11 7:02p Blaines +// [TAG] - EIP 66860 +// [Category]- Function Request +// [Synopsis]- AmiPostManager interface for text entry. +// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h, +// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c +// +// 19 6/23/11 7:38p Arunsb +// [TAG] EIP57660 +// [Category] New Feature +// [Description] Non-removable media boot behavior as described in UEFI +// specification v 2.3.1, p. 3.4.1. +// Checks for the setup key if no boot options avail +// or not succedded to boot. If setup key pressed launches +// the setup. +// If no boot option avail then inserting thumb drive with +// image efi\boot\bootxxxx.efi TSE will launch that image. +// [Files] amitse.sdl, bootflow.c and protocol.c +// +// 18 6/20/11 3:59p Arunsb +// [TAG] EIP57660 +// [Category] New Feature +// [Description] Non-removable media boot behavior as described in UEFI +// specification v 2.3.1, p. 3.4.1. +// Checks for the setup key if no boot options avail +// or succedded to boot and launches the setup. +// [Files] amitse.sdl, bootflow.c, bootflow.h, commonoem.c, +// boot.c and protocol.c +// +// 17 1/06/11 1:58a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] After the notification, if the graphics driver +// uninstalled and reinstalled from core module then gGOP is getting +// corrupted. +// [Solution] Updated the files, by making gGOP/gUgaDraw to NULL in the +// update function and in switch to posty screen returining status as +// aborted if the gGOP/gUgaDraw is NULL +// [Files] protocol.c,notify.c,postmgmt.c +// +// 16 12/29/10 2:33a Mallikarjunanv +// [TAG] EIP50479 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after +// legacy option ROM execution cause CPU exception. +// [RootCause] After the notification, if the graphics driver +// uninstalled and reinstalled from core module then gGOP getting +// corrupted. +// [Solution] Updated gGop/Ugadraw before using it in AMITSE. +// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c +// +// 15 12/02/10 1:07p Madhans +// [TAG] - EIP 41838 +// [Category]- Enhancement +// [Severity]- Mordarate +// [Symptom]- Update AMI Post Manager Protocol witht he following. 2. +// Updating the interface PostManagerDisplayPostMessageEx to handle the +// cursor position properly. 2. Need to add new interface to GetAttribute +// To keep the GetAttribute to end of protocol. +// [Rootcause] - 1. Display string is over written by the next string if +// the interface PostManagerDisplayPostMessageEx used simultaneously. 2. +// Need to get the attribute info to use PostManagerDisplayPostMessage +// interfaces effectively +// [Solution]- Fix in string.c to handle cursor and line positions. The +// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface +// implementaion to get the attribute. +// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c +// +// 14 11/16/10 8:56a Mallikarjunanv +// [TAG] - EIP 41838 +// [Category]- Enhancement +// [Severity]- Mordarate +// [Symptom]- Update AMI Post Manager Protocol witht he following. 2. +// Updating the interface PostManagerDisplayPostMessageEx to handle the +// cursor position properly. 2. Need to add new interface to GetAttribute +// [Rootcause] - 1. Display string is over written by the next string if +// the interface PostManagerDisplayPostMessageEx used simultaneously. 2. +// Need to get the attribute info to use PostManagerDisplayPostMessage +// interfaces effectively +// [Solution]- Fix in string.c to handle cursor and line positions. The +// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface +// implementaion to get the attribute. +// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c +// +// 13 10/05/10 6:41p Madhans +// [TAG] - EIP 45301 +// [Category]- Bug Fix +// [Severity]- Minor +// [Symptom]- when TSE_PRESERVE_DISABLED_BBS_DEVICE_ORDER is set disabling +// first device cause system not to boot. +// [Rootcause] - protocol.c was assuming disabled opens are coming in the +// End. +// [Solution]- Fix in protocol.c to handle this case. +// [Files] - protocol.c +// +// 12 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 23 9/13/10 4:34p Madhans +// 1. To preserve FastBootflow condition before going to Boottimeout. +// 2. Preformance Calls optimized. +// +// 22 9/13/10 12:11p Blaines +// Fix for the gPostMsgProtocolActive not being available past a certain +// point +// +// 21 9/08/10 6:53a Mallikarjunanv +// EIP-42080: TSE updates with respect to Fast Boot Support +// +// 20 6/17/10 4:19p Madhans +// +// 19 6/17/10 3:20p Blaines +// Added error checking to PostManagerDisplayQuietBootMessage() for +// messages that are 0 in length. +// +// 18 6/14/10 7:06p Madhans +// +// 17 4/02/10 4:34p Madhans +// +// 16 3/30/10 4:45p Blaines +// Fix to prevent BBS Popup from being launched twice when selecting +// ENTER_SETUP option +// +// 15 3/23/10 5:09p Blaines +// Add PostManager Extentions +// +// 14 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 13 2/17/10 7:02p Madhans +// To support PrintQuiteBootmessage for UEFI 2.1 +// +// 12 2/15/10 10:12p Madhans +// To support Printquitebootmessage +// +// 11 2/04/10 11:21p Madhans +// To remove Conout dependance +// +// 10 2/04/10 12:10p Blaines +// Correct function header description for PostManagerSetAtribute. +// +// 9 2/04/10 12:03p Blaines +// EIP-28005 +// +// Added PostManagerSetAttribute to support display of text in color. +// Added support for handling string characters --- \n, \r. +// +// 8 1/09/10 5:35a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 7 12/14/09 12:21p Blaines +// Include EIP Comment +// +// EIP 28007, FIX: If Post message printed in the Quiteboot by using Set +// cur position It is better to flash all the screen. +// +// +// 6 10/28/09 5:37p Madhans +// +// 5 9/17/09 9:04a Sudhirv +// Remove Load Driver Option from TSE 2.x as it will be handled from Core +// +// 4 9/16/09 6:15p Madhans +// EIP 25416 : Support have 1/10 sec Timeout +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 2 5/13/09 2:22p Madhans +// To patch the version number in the Bootonly TSE. update the build +// number. +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 6 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 5 3/31/09 4:00p Madhans +// UEFI2.1 +// +// 4 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 3 2/05/09 10:15a Madhans +// Style Module created. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: PROTOCOL.C +// +// Description: This file contains code for TSE exported protocol +// functions. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +UINT32 gBootFlow = BOOT_FLOW_CONDITION_NORMAL; + +BOOLEAN gDoNotBoot = FALSE; +VOID StopClickEvent(VOID);//EIP-84150 Stopping ClickEvents + +static EFI_HANDLE gProtocolHandle = NULL; +EFI_GUID gAmiPostManagerProtocolGuid = AMI_POST_MANAGER_PROTOCOL_GUID; +EFI_GUID gTSEInvalidateBgrtStatusProtocolGuid = TSE_INVALIDATE_BGRT_STATUS_PROTOCOL_GUID; + +BOOLEAN TseIgnoreKeyForFastBoot(); //EIP-94616 Don't wait for key when FastBoot is Enabled +BOOLEAN GetBBSOptionStatus(BOOT_DATA *pBootData); //EIP-93797 + +static AMI_POST_MANAGER_PROTOCOL gPostManagerProtocol = +{ + PostManagerHandshake, + PostManagerDisplayPostMessage, + PostManagerDisplayPostMessageEx, + PostManagerDisplayQuietBootMessage, + PostManagerDisplayMsgBox, + PostManagerSwitchToPostScreen, + PostManagerSetCursorPosition, + PostManagerGetCursorPosition, + PostManagerInitProgressBar, + PostManagerSetProgressBarPosition, + PostManagerGetPostStatus, + PostManagerDisplayInfoBox, + PostManagerSetAttribute, + PostManagerDisplayMenu, + PostManagerDisplayMsgBoxEx, + PostManagerDisplayProgress, + PostManagerGetAttribute, //EIP-41838: New interface added to get the attribute + PostManagerDisplayTextBox //EIP-64877: New interface added to get the text input +}; + +//EIP 128665 starts +EFI_STATUS InvalidateBgrtStatusByProtocol (VOID); +TSE_INVALIDATE_BGRT_STATUS_PROTOCOL gInvalidateBgrtStatus = {InvalidateBgrtStatusByProtocol}; +EFI_STATUS InstallInvalBGRTStatusProtocol (EFI_HANDLE Handle); +//EIP 128665 ends + +EFI_STATUS ShowPostMsgBox(IN CHAR16 *MsgBoxTitle,IN CHAR16 *Message,IN UINT8 MsgBoxType, UINT8 *pSelection); + + +EFI_STATUS ShowPostMsgBoxEx( + IN CHAR16 *Title, + IN CHAR16 *Message, + IN CHAR16 *Legend, + IN MSGBOX_EX_CATAGORY MsgBoxExCatagory, + IN UINT8 MsgBoxType, + IN UINT16 *OptionPtrTokens, // Valid only with MSGBOX_TYPE_CUSTOM + IN UINT16 OptionCount, // Valid only with MSGBOX_TYPE_CUSTOM + IN AMI_POST_MGR_KEY *HotKeyList, // NULL - AnyKeyPress closes + IN UINT16 HotKeyListCount, + OUT UINT8 *MsgBoxSel, + OUT AMI_POST_MGR_KEY *OutKey + ); +EFI_STATUS ShowInfoBox(IN CHAR16 *InfoBoxTitle, IN CHAR16 *Message, IN UINTN TimeLimit, EFI_EVENT *RetEvent); + +EFI_STATUS HiiString2BltBuffer( CHAR16 *Message, + EFI_UGA_PIXEL Foreground, + EFI_UGA_PIXEL Background, + OUT UINTN *Width, + OUT EFI_UGA_PIXEL **BltBuffer, + OUT UINTN *BltGlyphWidth); +EFI_STATUS DrawHiiStringBltBuffer(CHAR16 *Message, INTN CoOrdX, INTN CoOrdY, CO_ORD_ATTRIBUTE Attribute, EFI_UGA_PIXEL Foreground, EFI_UGA_PIXEL Background); +EFI_STATUS ShowPostMenu ( + IN VOID *HiiHandle, + IN UINT16 TitleToken, + IN UINT16 LegendToken, + IN POSTMENU_TEMPLATE *MenuData, + IN UINT16 MenuCount, + OUT UINT16 *pSelection +); + +EFI_STATUS ShowPostTextBox( + IN VOID *HiiHandle, + IN UINT16 TitleToken, + IN TEXT_INPUT_TEMPLATE *InputData, + IN UINT16 ItemCount, + IN DISPLAY_TEXT_KEY_VALIDATE DisplayTextKeyValidate +); + +EFI_STATUS ShowPostProgress( + IN UINT8 ProgressBoxState, + IN CHAR16 *Title, + IN CHAR16 *Message, + IN CHAR16 *Legend, + IN UINTN Percent, + IN OUT VOID **Handle, + OUT AMI_POST_MGR_KEY *OutKey +); +BOOLEAN IsTseBestTextGOPModeSupported (VOID); +EFI_STATUS SaveCurrentTextGOP ( UINTN *currenttextModeCols, UINTN *currenttextModeRows, UINT32 *currentGOPMode ); //EIP-107833 Fixing proper mode and resolution for post interfaces +EFI_STATUS RestoreTextGOPMode ( UINTN prevTextModeCols, UINTN prevTextModeRows, UINT32 prevGOPMode ); //EIP-107833 Fixing proper mode and resolution for post interfaces + +// +//---------------------------------------------------------------------------- +// Procedure: InstallProtocol +// +// Description: This function installs different protocols exported. +// +// Input: VOID +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS InstallProtocol( VOID ) +{ + EFI_STATUS Status; + + Status = gBS->InstallMultipleProtocolInterfaces( + &gProtocolHandle, + &gAmiPostManagerProtocolGuid, &gPostManagerProtocol, +#ifdef USE_COMPONENT_NAME + &gEfiComponentNameProtocolGuid, &gComponentName, +#endif + NULL + ); + if ( !EFI_ERROR( Status ) ) + { + Status = InstallFormBrowserProtocol(gProtocolHandle); + Status = InstallInvalBGRTStatusProtocol (gProtocolHandle); + } + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: UninstallProtocol +// +// Description: This function uninstalls different protocols exported. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID UninstallProtocol( VOID ) +{ + gBS->UninstallMultipleProtocolInterfaces( + &gProtocolHandle, + &gAmiPostManagerProtocolGuid, &gPostManagerProtocol, +#ifdef USE_COMPONENT_NAME + &gEfiComponentNameProtocolGuid, &gComponentName, +#endif + NULL + ); + + UnInstallFormBrowserProtocol(gProtocolHandle); + +} + +VOID SetBootTimeout( EFI_EVENT Event, BOOLEAN *timeout ) +{ + if ( timeout != NULL ) + *timeout = TRUE; +} + +VOID AboartFastBootPath(VOID) +{ + gBootFlow = BOOT_FLOW_CONDITION_NORMAL; + gPostManagerHandshakeCallIndex--; + gRT->SetVariable( + L"BootFlow", + &_gBootFlowGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof(gBootFlow), + &gBootFlow + ); +} +BOOLEAN IsBootTimeOutValueZero(VOID); +// +//---------------------------------------------------------------------------- +// Procedure: PostManagerHandshake +// +// Description: This function is the handshake function to which BDS +// hands-off. +// +// Input: VOID +// +// Output: This function never returns. It only boots different +// options. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS PostManagerHandshake( VOID ) +{ + EFI_EVENT timer = NULL; + EFI_STATUS Status = EFI_UNSUPPORTED; + + volatile BOOLEAN bootTimeout = FALSE; + UINT16 Value = 1; + UINT64 TimeoutValue; + UINTN size = 0; + EFI_GUID AmitseAfterFirstBootOptionGuid = AMITSE_AFTER_FIRST_BOOT_OPTION_GUID; + EFI_GUID AmiTseBeforeTimeOutGuid = AMITSE_BEFORE_TIMEOUT_GUID; + EFI_GUID AmiTseAfterTimeOutGuid = AMITSE_AFTER_TIMEOUT_GUID; + BOOLEAN AfterFirstBootSignalled = FALSE; + UINT16 *pBootOrder=NULL; + UINT16 u16BootCount = 0,i; //Dont change i data type, in infinite loop it is reinitialized to -1. + UINT16 BootNext, *pBootNext = NULL; + + // Performance measurement starta + PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0); + + RUNTIME_DEBUG( L"mre" ); + + gPostManagerHandshakeCallIndex++; + + if(gPostManagerHandshakeCallIndex!=1) + { + gEnterSetup = TRUE; + goto _ShowMainMenu; + } + + PostManagerHandShakeHookHook(); + +#ifndef STANDALONE_APPLICATION + if ( ! gConsoleControl ) + { + //All necessary protocols are not available yet. + //We can still proceed if Uga Draw is the only protocol not available yet. + ActivateApplication(); + //EIP-75236 + if (!IsDelayLogoTillInputSupported()) + ActivateInput(); + } +#endif + + if(!gVariableList) + VarLoadVariables( (VOID **)&gVariableList, NULL ); + + TimerStopTimer( &gKeyTimer ); + + // this *MUST* be run a EFI_TPL_APPLICATION + gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); // guarantees that RestoreTPL won't ASSERT + gBS->RestoreTPL( EFI_TPL_APPLICATION ); + + // Performance measurement Pause +// PERF_END (0,L"Boot", NULL, 0); + // Exclude IDEPasswordCheck IDEPasswordCheck that it may get the use input. + // IDE password Module takes care of the Password check. + //TSEIDEPasswordCheck(); + + // Performance measurement continue +// PERF_START (0, L"Boot", NULL, 0); + + // get the current boot options and languages + BootGetBootOptions(); + BootGetLanguages(); + + StyleUpdateVersionString(); + + gPostStatus = TSE_POST_STATUS_IN_BOOT_TIME_OUT; + + //EIP 103381 - Providing boot time out value depending on TSE_BOOT_TIME_OUT_AS_ZERO token + if(!IsBootTimeOutValueZero()) + Value = GetBootTimeOut(Value); + else + Value = 0; + +#ifdef STANDALONE_APPLICATION + Value = 0; + gEnterSetup = TRUE; +#endif + + if ( Value == 0 ) + bootTimeout = TRUE; + + if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616 + { + CheckForKeyHook( (EFI_EVENT)NULL, NULL ); + } + + if((BOOT_FLOW_CONDITION_NORMAL != gBootFlow) || (gEnterSetup==TRUE)) + { + UINT32 condition = BOOT_FLOW_CONDITION_NORMAL; + UINT32 *conditionPtr; + + size = 0; + conditionPtr = VarGetNvramName( L"BootFlow", &_gBootFlowGuid, NULL, &size ); + if ( conditionPtr != NULL ) + condition = *conditionPtr; + + MemFreePointer( (VOID **)&conditionPtr ); + + if((condition == BOOT_FLOW_CONDITION_FAST_BOOT) && ((gBootFlow != condition)||(gEnterSetup==TRUE))) + { + // Take the Normal boot path as Fast boot path is altered by CheckForKeyHook(). + AboartFastBootPath(); + return EFI_UNSUPPORTED; + } + + if(BOOT_FLOW_CONDITION_NORMAL == condition) + { + gRT->SetVariable( + L"BootFlow", + &_gBootFlowGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS,//EIP-73751 BootFlow wil use RS attribute to avoid inconsistent attributes + sizeof(UINT32), + &gBootFlow + ); + } + else + gBootFlow = BOOT_FLOW_CONDITION_NORMAL; + } + + Status = BootFlowManageEntry(); + if (Status == EFI_UNSUPPORTED) + { + Value = 0xFFFF; + gDoNotBoot = TRUE; + } + if(Status == EFI_NOT_STARTED) + bootTimeout = TRUE; + + if(gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT) + { + UINT32 PasswordInstalled = PasswordCheckInstalled(); + + if((gPasswordType == AMI_PASSWORD_NONE) && (PasswordInstalled != AMI_PASSWORD_NONE)) + { + if(CheckSystemPasswordPolicy(PasswordInstalled)) + { + // Take the Normal boot path as Password is installed and not validated by the user yet + AboartFastBootPath(); + return EFI_UNSUPPORTED; + } + } + } + else + { + // Reinit Before Boottimeout So any action can set the boot flow again. + gBootFlow = BOOT_FLOW_CONDITION_NORMAL; + } + + if ( Value != 0xFFFF ) + { + TimeoutValue = (UINT64) TIMER_TENTH_SECOND; + TimeoutValue = MultU64x32( TimeoutValue, (UINT32) Value ); + + TimerCreateTimer( &timer, SetBootTimeout, (VOID *)&bootTimeout, TimerRelative, TimeoutValue, EFI_TPL_CALLBACK ); + } + + // Performance measurement Pause + PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0); + + // While the boot timeout has not expired + EfiLibNamedEventSignal (&AmiTseBeforeTimeOutGuid); + while ( ! bootTimeout ) + { + if ( gEnterSetup || gBootFlow ) + { + bootTimeout = TRUE; + continue; + } + if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616 + { + // check for 'hotkey' actions that would invoke something + CheckForKeyHook( (EFI_EVENT)NULL, NULL ); + } + + TimeOutLoopHookHook(); + } + EfiLibNamedEventSignal (&AmiTseAfterTimeOutGuid); + + // Performance measurement continue + PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0); + + TimerStopTimer( &timer ); + + if ((!gDoNotBoot) && (gBootFlow)) + { + gRT->SetVariable( + L"BootFlow", + &_gBootFlowGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS,//EIP-73751 BootFlow wil use RS attribute to avoid inconsistent attributes + sizeof(UINT32), + &gBootFlow + ); + BootFlowManageEntry(); + } + +_ShowMainMenu: + + if ( gEnterSetup ) + { + // Performance measurement Pause + PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0); + // Disable access to the post manager protocol display post message functions and to + // the switch to post screen functions of post manager protocol + gPostMsgProtocolActive = FALSE; + + gPostStatus = TSE_POST_STATUS_ENTERING_TSE; + gSetupContextActive = TRUE; + + Status = gST->ConIn->Reset( gST->ConIn, FALSE ); + Status = MainSetupLoopHook();//EIP74591 : Modified MainSetupLoop as board module hook + gSetupContextActive = FALSE; + + + // Reenable access to the post manager protocol display post message functions and to + // the switch to post screen functions of post manager protocol + gPostMsgProtocolActive = TRUE; + // Performance measurement continue + PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0); + } + + + if(gPostManagerHandshakeCallIndex!=1) + { + // In case of not a first call + // Don't do the Boot Manager Work just exit the to caller. + gPostManagerHandshakeCallIndex--; + return Status; + } + + // Pass control to the boot process to handle the selected boot option + // if the boot is allowed + if (gDoNotBoot) + { + if(!ItkSupport()) + { + gEnterSetup = TRUE; + goto _ShowMainMenu; + } + else + gEnterSetup = FALSE; + } + + if(!NoVarStoreSupport()) + { + size = 0; + //VarGetNvram( VARIABLE_ID_AMITSESETUP, &size ); + HelperGetVariable( VARIABLE_ID_AMITSESETUP, (CHAR16 *)NULL, (EFI_GUID *)NULL, NULL, &size ); + + if(size < sizeof(AMITSESETUP)) + { + Status = MiniSetupEntry(); + MiniSetupExit( Status ); + } + } + + gPostStatus = TSE_POST_STATUS_PROCEED_TO_BOOT; + + // LoadDriverOrder(); //EIP: 25799 - Remove Load Driver Option from TSE 2.x as it is handling from Core. + + ProcessProceedToBootHook(); + + TSEUnlockHDD(); + + if(ItkSupport()) + BbsItkBoot(); + else + { + //Try boot next first + size = 0; + pBootNext = (UINT16 *)VarGetNvramName(L"BootNext", &gEfiGlobalVariableGuid, NULL, &size); + if(pBootNext && (size == sizeof(UINT16))) + { + BootNext = *pBootNext; + //Clear Boot next + VarSetNvramName(L"BootNext", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + pBootNext, + 0); + if( gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT) { + // FastBoot module normally checks for Bootnext before taking the FastBoot path + // If the Boot next is set in FastBoot case then do the full boot. + AboartFastBootPath(); + return Status; + } + else { + BootLaunchBootOption(BootNext, NULL, 0); + } + } + + + if(pBootNext) + MemFreePointer((void **) &pBootNext); + + size =0 ; + pBootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size ); + + #ifdef EFI_NT_EMULATOR + if(!pBootOrder || !gBootData) + { + VarSetNvramName(L"BootOrder", + &gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + NULL, + 0); + + return Status; + } + #endif + + //Get enabled options count + for(u16BootCount=0; u16BootCount<(UINT16)(size/sizeof(UINT16)); u16BootCount++ ) + { + if(!IsPreservedDisabledBootOptionOrder()) + { + BOOT_DATA *pBootData; + + pBootData = BootGetBootData(pBootOrder[u16BootCount]); + if(!(pBootData->Active & LOAD_OPTION_ACTIVE)) + break; + } + } + + if(!u16BootCount) + { + //No valid/enabled boot option + Status = BootFlowManageExit(); + //infinite loop + while(EFI_NOT_STARTED == Status) + { + CHAR16 *text = NULL; + + text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_NO_BOOT_OPTIONS)); + if ( ( text != NULL ) && (gST->ConOut != NULL)) + gST->ConOut->OutputString(gST->ConOut, text); + + //Wait for key + gBS->WaitForEvent( 1, &gST->ConIn->WaitForKey, &size ); + CheckForKeyHook( (EFI_EVENT)NULL, NULL ); + if (TRUE == gEnterSetup) //If setup key detects then launch the setup + { + goto _ShowMainMenu; + } + Status = BootFlowManageExit (); //EIP: 57660 Condition: If user plugs the any thumb drive after boot then TSE will try to launch the image from that file system using the path efi\boot\bootxxxx.efi + if( gBootFlow )//EIP 81549 : Checking for gBootFlow, making gBootFlow to normal such that the key will be consumed in chcekforkey + gBootFlow = BOOT_FLOW_CONDITION_NORMAL; + } + } + + if ( !gEnterSetup )//EIP-86253 If no key is pressed to go to setup then stopping MousePointingDevice and stopping ClickEvents + { + StopClickEvent(); + MouseDestroy(); + } + for ( i = 0; i < u16BootCount; i++) + { + BOOT_DATA *pBootData; + + pBootData = BootGetBootData(pBootOrder[i]); + + if(pBootData == NULL || !(pBootData->Active & LOAD_OPTION_ACTIVE)) + continue; + + if ( BBSValidDevicePath(pBootData->DevicePath) ) //EIP-93797 + if ( GetBBSOptionStatus (pBootData) ) + continue; + + Status = BootLaunchBootOption(pBootOrder[i], pBootOrder+i, u16BootCount - i); + + if ( !AfterFirstBootSignalled ) + { + EfiLibNamedEventSignal ( &AmitseAfterFirstBootOptionGuid ); + + if( gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT) { + AboartFastBootPath(); + return Status; + } + + AfterFirstBootSignalled = TRUE; + } + + if((i+1) >= u16BootCount) + { + Status = BootFlowManageExit(); + if ( EFI_NOT_STARTED == Status ) + { + CheckForKeyHook( (EFI_EVENT)NULL, NULL ); + if (TRUE == gEnterSetup) //If setup key detects then launch the setup + { + goto _ShowMainMenu; + } + // Infinite loop is true so we start again + i = -1; //Changed 0 to -1. Then only in next iteration it will be zero otherwise it will be 1. + } //If it is i = 0 then it will miss first boot option + } + } + + } +#ifndef STANDALONE_APPLICATION + gEnterSetup = TRUE; + goto _ShowMainMenu; +#else + return Status; +#endif + +} + +// +//---------------------------------------------------------------------------- +// Procedure: PostManagerDisplayPostMessage +// +// Description: This function is the protocol to display messages in +// the post screen. +// +// Input: CHAR16 *message: Unicode string to be displayed. +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS PostManagerDisplayPostMessage( CHAR16 *message ) +{ + if ( ! gPostMsgProtocolActive ) + return EFI_UNSUPPORTED; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + return PrintPostMessage(message, TRUE); +} + +// +//---------------------------------------------------------------------------- +// Procedure: PostManagerDisplayPostMessageEx +// +// Description: This function is the protocol to display messages with +// attributes in the post screen. +// +// Input: CHAR16 *message: Unicode string to be displayed. +// UINTN Attribute: Attribute for the message +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS PostManagerDisplayPostMessageEx( CHAR16 *message, UINTN Attribute ) +{ + if ( ! gPostMsgProtocolActive ) + return EFI_UNSUPPORTED; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + switch(Attribute) + { + case PM_EX_DONT_ADVANCE_TO_NEXT_LINE: + return PrintPostMessage(message, FALSE); + } + + return EFI_UNSUPPORTED; +} + +// +//---------------------------------------------------------------------------- +// Procedure: PostManagerSwitchToPostScreen +// +// Description: This function is the protocol to switch to post screen +// +// Input: VOID +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS PostManagerSwitchToPostScreen( VOID ) +{ +#ifdef STANDALONE_APPLICATION + return EFI_UNSUPPORTED; +#else + if ( ! gPostMsgProtocolActive ) + return EFI_UNSUPPORTED; + + if ( gQuietBoot ) + { + UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE. +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if (!gGOP) +#else + if (!gUgaDraw) +#endif + return EFI_UNSUPPORTED;//EIP:50479 : Returning unsupported if the GOP is NULL + + gQuietBoot = FALSE; + CleanUpLogo(); + //EIP 28007, FIX: If Post message printed in the Quiteboot by using Set cur position + // It is better to flash all the screen. + FlushLines( 0, gMaxRows - 1 ); + DoRealFlushLines(); //EIP-87769 + InitPostScreen(); + return EFI_SUCCESS; + } + + return EFI_UNSUPPORTED; +#endif +} +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerInitProgressBar +// +// Description: Initializes the PostManagerProgressBar +// +// Input: UINTN x - Column or Left screen position of ProgressBar in pixels +// UINTN y - Row or Top screen position of ProgressBar in pixels +// UINTN w - Width of ProgressBar in pixels +// UINTN h - Height of ProgressBar in pixels +// UINTN iterate - Total number of iterations or Calls +// to advanced the progressbar to 100% of the given width. +// The delta or changed value will be computed. +// +// Output: EFI_STATUS status - If the function runs correctly, returns +// EFI_SUCCESS, else other EFI defined error values. +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS PostManagerInitProgressBar( + UINTN x, + UINTN y, + UINTN w, + UINTN h, + UINTN iterate) +{ + EFI_STATUS Status = 0; + + EFI_UGA_PIXEL *BGColor; + EFI_UGA_PIXEL *BDRColor; + EFI_UGA_PIXEL *FillColor; + + BGColor = EfiLibAllocateZeroPool(sizeof (EFI_UGA_PIXEL)); + BDRColor = EfiLibAllocateZeroPool(sizeof (EFI_UGA_PIXEL)); + FillColor = EfiLibAllocateZeroPool(sizeof (EFI_UGA_PIXEL)); + + GetProgressColor(BGColor,BDRColor,FillColor); + + gProgress->delta = w/iterate; + gProgress->w = gProgress->delta*iterate; + gProgress->h = h; + gProgress->x = x; + gProgress->y = y; + gProgress->backgroundColor = BGColor; + gProgress->borderColor = BDRColor; + gProgress->fillColor = FillColor; + gProgress->quiteBootActive = FALSE ; + gProgress->active = TRUE ; // progressbar has been initialized + + return Status; +} + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerSetProgressBarPosition +// +// Description: Increments the PostManagerProgressBar +// +// Input: None +// +// +// Output: EFI_STATUS status - If the function runs correctly, returns +// EFI_SUCCESS, else other EFI defined error values. +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS PostManagerSetProgressBarPosition() +{ + EFI_STATUS Status = EFI_SUCCESS; + if(gProgress->active) + DrawBltProgressBar(); + else + Status = EFI_UNSUPPORTED; + + return Status; +} + + + + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerSetCursorPosition +// +// Description: Wrapper function for SetCurPos +// +// Input: UINTN X - Value of the column +// UINTN Y - Number of row below the last written line +// +// Output: EFI_STATUS status - If the function runs correctly, returns +// EFI_SUCCESS, else other EFI defined error values. +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS PostManagerSetCursorPosition(UINTN X, UINTN Y) +{ + return SetCurPos(X,Y); +} + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerGetCursorPosition +// +// Description: Wrapper function for GetCurPos +// Writes cursor position into given X and Y locations. +// +// Input: UINTN *pX - Pointer to storage for current column value +// UINTN *pY - Pointer to storage for current row value +// +// Output: EFI_STATUS status - EFI_SUCCESS if OK, +// EFI_INVALID_PARAMETER if NULL pointer +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS PostManagerGetCursorPosition(UINTN *pX, UINTN *pY) +{ + return GetCurPos(pX, pY); +} + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerDisplayMsgBox +// +// Description: +// +// +// Input: IN CHAR16 *MsgBoxTitle, +// IN CHAR16 *Message, +// IN UINT8 MsgBoxType, +// +// Output: EFI_STATUS status and UINT8 MsgBoxSel +// +//-------------------------------------------------------------------------- +// +VOID SaveGraphicsScreen(VOID); +VOID RestoreGraphicsScreen(VOID); +EFI_STATUS +PostManagerDisplayMsgBox ( + IN CHAR16 *MsgBoxTitle, + IN CHAR16 *Message, + IN UINT8 MsgBoxType, + OUT UINT8 *MsgBoxSel + ) +{ + UINTN currenttextModeCols = 0, currenttextModeRows = 0; + UINT32 currentGOPMode = 0; + + EFI_STATUS Status = EFI_UNSUPPORTED; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + if( gPostStatus == TSE_POST_STATUS_IN_POST_SCREEN ) + SaveGraphicsScreen(); + + Status = SaveCurrentTextGOP (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + if (EFI_ERROR(Status)) + return Status; + + Status = ShowPostMsgBox(MsgBoxTitle, Message, MsgBoxType,MsgBoxSel); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + if( gPostStatus == TSE_POST_STATUS_IN_POST_SCREEN ) + RestoreGraphicsScreen(); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: PostManagerDisplayQuietBootMessage +// +// Description: Function for the quit booting display. +// +// Input: CHAR16 *Message, INTN CoOrdX, INTN CoOrdY, +// CO_ORD_ATTRIBUTE Attribute, EFI_UGA_PIXEL Foreground, +// EFI_UGA_PIXEL Background +// +// Output: Status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +PostManagerDisplayQuietBootMessage( + CHAR16 *Message, + INTN CoOrdX, + INTN CoOrdY, + CO_ORD_ATTRIBUTE Attribute, + EFI_UGA_PIXEL Foreground, + EFI_UGA_PIXEL Background + ) +{ +#ifdef STANDALONE_APPLICATION + return EFI_UNSUPPORTED; +#elif defined TSE_FOR_APTIO_4_50 + UINTN BltGlyphWidth=0; + EFI_UGA_PIXEL *BltBuffer=NULL; + UINTN BltIndex; + EFI_STATUS Status = EFI_SUCCESS; + UINTN SizeOfX, SizeOfY; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE. + if(EFI_SUCCESS != HiiInitializeProtocol()) + return EFI_UNSUPPORTED; + + if( + (EFI_SUCCESS != GetScreenResolution(&SizeOfX, &SizeOfY))|| + (!gQuietBoot) + ) + return EFI_UNSUPPORTED; + + if ((Message != NULL) && (EfiStrLen(Message) == 0)) + return EFI_SUCCESS; + BltIndex = 0; + + Status = HiiString2BltBuffer(Message,Foreground,Background,&BltIndex,&BltBuffer,&BltGlyphWidth); + if(Status == EFI_SUCCESS) + DrawBltBuffer(BltBuffer, Attribute, BltIndex, HiiGetGlyphHeight(), CoOrdX, CoOrdY, BltGlyphWidth); + + //Free BltBuffer + MemFreePointer((VOID **)&BltBuffer); + + return Status; +#else +// For EDK Nt32 support. +// Status = DrawHiiStringBltBuffer(Message, CoOrdX, CoOrdY, Attribute, Foreground, Background); + return EFI_UNSUPPORTED; +#endif +} + +// +//---------------------------------------------------------------------------- +// Procedure: PostManagerGetPostStatus +// +// Description: Function returns current Post status. +// +// Input: none +// +// Output: One of the TSE_POST_STATUS +// TSE_POST_STATUS_BEFORE_POST_SCREEN - TSE Loaded and yet goto post screen +// TSE_POST_STATUS_IN_POST_SCREEN - In the post screen +// TSE_POST_STATUS_IN_QUITE_BOOT_SCREEN- In the quite boot screen +// TSE_POST_STATUS_IN_BOOT_TIME_OUT - Witing for Boot timeout +// TSE_POST_STATUS_ENTERING_TSE - Entering TSE +// TSE_POST_STATUS_IN_TSE - Inside TSE +// TSE_POST_STATUS_IN_BBS_POPUP - Inside BBS Poupup +// TSE_POST_STATUS_PROCEED_TO_BOOT - Outside TSE and Booting or in Shell +// +//---------------------------------------------------------------------------- +// +TSE_POST_STATUS PostManagerGetPostStatus(VOID) +{ + return gPostStatus; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: PostManagerDisplayInfoBox +// +// Description: Function to display the Information box +// +// Input: none +// +// Output: One of the TSE_POST_STATUS +// TSE_POST_STATUS_BEFORE_POST_SCREEN - TSE Loaded and yet goto post screen +// TSE_POST_STATUS_IN_POST_SCREEN - In the post screen +// TSE_POST_STATUS_IN_QUITE_BOOT_SCREEN- In the quite boot screen +// TSE_POST_STATUS_IN_BOOT_TIME_OUT - Witing for Boot timeout +// TSE_POST_STATUS_ENTERING_TSE - Entering TSE +// TSE_POST_STATUS_IN_TSE - Inside TSE +// TSE_POST_STATUS_IN_BBS_POPUP - Inside BBS Poupup +// TSE_POST_STATUS_PROCEED_TO_BOOT - Outside TSE and Booting or in Shell +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +PostManagerDisplayInfoBox( IN CHAR16 *InfoBoxTitle, + IN CHAR16 *InfoString, + IN UINTN Timeout, + OUT EFI_EVENT *Event + ) +{ + UINTN currenttextModeCols = 0, currenttextModeRows = 0; + UINT32 currentGOPMode = 0; + EFI_STATUS Status = EFI_SUCCESS; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + Status = SaveCurrentTextGOP (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + if ( EFI_ERROR(Status) ) + return Status; + + Status = ShowInfoBox(InfoBoxTitle, InfoString, Timeout, Event); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + return Status; + +} + + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerSetAtribute +// +// Description: Function to set color +// +// Input: UINT8 Attrib - Text color +// +// +// Output: EFI_STATUS status - If the function runs correctly, returns +// EFI_SUCCESS, else other EFI defined error values. +// +//-------------------------------------------------------------------------- +// +EFI_STATUS PostManagerSetAttribute(UINT8 Attrib) +{ + gPostMgrAttribute = Attrib ; + return EFI_SUCCESS ; +} +//EIP-41838: New interface to get the attribute using AMI Post Manager Protocol +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerGetAttribute +// +// Description: Function to Get color +// +// Input: UINT8 *Attrib - Pointer to get Text color +// +// +// Output: EFI_STATUS status - If the function runs correctly, returns +// EFI_SUCCESS, else other EFI defined error values. +// +//-------------------------------------------------------------------------- +// +EFI_STATUS PostManagerGetAttribute(UINT8 *Attrib) +{ + *Attrib = gPostMgrAttribute ; + return EFI_SUCCESS ; +} + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerDisplayMsgBoxEx +// +// Description: Wrapper function for Display OEM Message box. +// +// +// Input: IN CHAR16 *MsgBoxTitle - Caption of the Message Box +// IN CHAR16 *Message - String to be displayed by the Message Box +// IN CHAR16 *Legend - Legend String to be displayed by the Message Box +// IN UINT8 MsgBoxType - Message Box type +// +// Output: EFI_STATUS status - EFI_SUCCESS if OK, +// EFI_INVALID_PARAMETER if NULL pointer +// +//-------------------------------------------------------------------------- +// +EFI_STATUS PostManagerDisplayMsgBoxEx ( + IN CHAR16 *Title, + IN CHAR16 *Message, + IN CHAR16 *Legend, + IN MSGBOX_EX_CATAGORY MsgBoxExCatagory, + IN UINT8 MsgBoxType, + IN UINT16 *OptionPtrTokens, // Valid only with MSGBOX_TYPE_CUSTOM + IN UINT16 OptionCount, // Valid only with MSGBOX_TYPE_CUSTOM + IN AMI_POST_MGR_KEY *HotKeyList, // NULL - AnyKeyPress closes + IN UINT16 HotKeyListCount, + OUT UINT8 *MsgBoxSel, + OUT AMI_POST_MGR_KEY *OutKey +) +{ + UINTN currenttextModeCols = 0, currenttextModeRows = 0; + UINT32 currentGOPMode = 0; + EFI_STATUS Status = EFI_SUCCESS; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + Status = SaveCurrentTextGOP (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + if ( EFI_ERROR(Status) ) + return Status; + + Status = ShowPostMsgBoxEx (Title, Message, Legend, MsgBoxExCatagory, + MsgBoxType, OptionPtrTokens, OptionCount, + HotKeyList, HotKeyListCount, MsgBoxSel, OutKey + ); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + return Status; +} +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerDisplayProgress +// +// Description: Wrapper function for Display OEM Message box. +// +// +// Input: IIN UINTN Percent - Percent Complete +// +// Output: EFI_STATUS status - EFI_SUCCESS if OK, +// EFI_INVALID_PARAMETER if NULL pointer +// +//-------------------------------------------------------------------------- +// +EFI_STATUS PostManagerDisplayProgress ( + IN UINT8 ProgressBoxState, + IN CHAR16 *Title, + IN CHAR16 *Message, + IN CHAR16 *Legend, + IN UINTN Percent, // 0 - 100 + IN OUT VOID **Handle, //Out HANDLE. Valid Handle for update and close + OUT AMI_POST_MGR_KEY *OutKey //Out Key +) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + Status = ShowPostProgress( ProgressBoxState, Title, Message, Legend, Percent, Handle, OutKey) ; + return Status ; +} +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerDisplayMenu +// +// Description: Wrapper function for Display Menu. +// +// +// Input: IN VOID *HiiHandle, - Handle that contains String +// IN UINT16 TitleToken, - Menu Title Token +// IN UINT16 LegendToken, - Menu Legend Token +// IN POSTMENU_TEMPLATE *MenuData, - Menu Items to be displayed +// IN UINT16 MenuCount, - Number of Menu items +// OUT UINT16 *pSelection - Menu selection (DEFAULT) +// +// Output: EFI_STATUS status - EFI_SUCCESS if OK, +// EFI_INVALID_PARAMETER if NULL pointer +// +//-------------------------------------------------------------------------- +// +EFI_STATUS PostManagerDisplayMenu ( + IN VOID *HiiHandle, + IN UINT16 TitleToken, + IN UINT16 LegendToken, + IN POSTMENU_TEMPLATE *MenuData, + IN UINT16 MenuCount, + OUT UINT16 *pSelection +) +{ + UINTN currenttextModeCols = 0, currenttextModeRows = 0; + UINT32 currentGOPMode = 0; + EFI_STATUS Status = EFI_SUCCESS; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + if(gPostStatus < TSE_POST_STATUS_IN_BOOT_TIME_OUT) + return EFI_NOT_READY; + + Status = SaveCurrentTextGOP (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + if ( EFI_ERROR(Status) ) + return Status; + + Status = ShowPostMenu(HiiHandle, TitleToken, LegendToken, MenuData, MenuCount, pSelection); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + return Status; +} + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerDisplayTextBox +// +// Description: Function to display text entry interface +// +// +// Input: IN VOID *HiiHandle, +// IN UINT16 TitleToken, +// IN TEXT_INPUT_TEMPLATE *InputData, +// IN UINT16 ItemCount, +// IN DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc +// +// Output: EFI_STATUS +// +//-------------------------------------------------------------------------- +// +EFI_STATUS +PostManagerDisplayTextBox ( + IN VOID *HiiHandle, + IN UINT16 TitleToken, + IN TEXT_INPUT_TEMPLATE *InputData, + IN UINT16 ItemCount, + IN DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc + ) +{ + UINTN currenttextModeCols = 0, currenttextModeRows = 0; + UINT32 currentGOPMode = 0; + EFI_STATUS Status = EFI_UNSUPPORTED; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + Status = SaveCurrentTextGOP (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + if ( EFI_ERROR(Status) ) + return Status; + + Status = ShowPostTextBox(HiiHandle, TitleToken, InputData, ItemCount, ValidateKeyFunc); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + return Status; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StopClickEvent +// +// Description: Function to Stop the Click Event +// +// Input: VOID +// +// Output: VOID +// +//-------------------------------------------------------------------------- +// +VOID StopClickEvent(VOID) +{ + if(gClickTimer) + { + gBS->SetTimer ( gClickTimer,TimerCancel,0); + TimerStopTimer( &gClickTimer ); + } +} + +//EIP 128665 starts +// +//-------------------------------------------------------------------------- +// +// Name: InvalidateBgrtStatusByProtocol +// +// Description: Protocol interface to invalidate BGRT status +// +// +// Input: VOID +// +// +// Output: EFI_STATUS +// +//-------------------------------------------------------------------------- +// +VOID InvalidateStatusInBgrtWrapper (VOID); +EFI_STATUS InvalidateBgrtStatusByProtocol (VOID) +{ + InvalidateStatusInBgrtWrapper(); + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// +// Procedure: InvalidateBGRTStatusProtocol +// +// Description: Install Invalidate BGRT status protocol +// +// Parameter: EFI_HANDLE Handle +// +// Return value:EFI_STATUS +//---------------------------------------------------------------------------- +// +EFI_STATUS InstallInvalBGRTStatusProtocol (EFI_HANDLE Handle) +{ + EFI_STATUS Status = EFI_SUCCESS; + + Status = gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gTSEInvalidateBgrtStatusProtocolGuid, + &gInvalidateBgrtStatus, + NULL + ); + + return Status; +} +//EIP 128665 ends + +// +//-------------------------------------------------------------------------- +// +// Name : SaveCurrentTextGOP +// +// Description : Function to Save current TextMode and GOP +// +// Input : UINTN currentTextModCols, UINTN currentTextModRows, UINT32 currentGOPMode +// +// Output : EFI_STATUS +// +//-------------------------------------------------------------------------- +// +EFI_STATUS SaveCurrentTextGOP ( UINTN *currenttextModeCols, UINTN *currenttextModeRows, UINT32 *currentGOPMode ) +{ + + EFI_STATUS Status = EFI_SUCCESS; + + if ( IsTseBestTextGOPModeSupported() && TSE_POST_STATUS_IN_TSE != gPostStatus ) + { + if (gGOP) + { + *currentGOPMode = gGOP->Mode->Mode; + } + + if (TSE_BEST_HORIZONTAL_RESOLUTION != gGOP->Mode->Info->HorizontalResolution || TSE_BEST_VERTICAL_RESOLUTION != gGOP->Mode->Info->VerticalResolution) + { + SetScreenResolution(TSE_BEST_HORIZONTAL_RESOLUTION,TSE_BEST_VERTICAL_RESOLUTION); //If any postinterface is invoked during QuietBoot + } + + Status = gST->ConOut->QueryMode( gST->ConOut, gST->ConOut->Mode->Mode, currenttextModeCols, currenttextModeRows); + if (EFI_ERROR(Status)) + return EFI_NOT_FOUND; + + if ((STYLE_FULL_MAX_COLS != *currenttextModeCols) || (STYLE_FULL_MAX_ROWS != *currenttextModeRows)) + { + gMaxRows = STYLE_FULL_MAX_ROWS; + gMaxCols = STYLE_FULL_MAX_COLS; + SetDesiredTextMode (); + } + } + return Status; +} + +// +//-------------------------------------------------------------------------- +// +// Name : RestoreTextGOPMode +// +// Description : Function to Save current TextMode and GOP +// +// Input : UINTN currentTextModCols, UINTN currentTextModRows, UINT32 currentGOPMode +// +// Output : EFI_STATUS +// +//-------------------------------------------------------------------------- +// +EFI_STATUS RestoreTextGOPMode ( UINTN prevTextModeCols, UINTN prevTextModeRows, UINT32 prevGOPMode ) +{ + EFI_STATUS Status = EFI_SUCCESS; + + if ( IsTseBestTextGOPModeSupported() && TSE_POST_STATUS_IN_TSE != gPostStatus ) + { + if ( (gMaxRows != prevTextModeRows) || (gMaxCols != prevTextModeCols) ) + { + gMaxRows = prevTextModeRows; + gMaxCols = prevTextModeCols; + SetDesiredTextMode (); //Restoring to previous textmode if any changed + } + + if (gGOP && prevGOPMode != gGOP->Mode->Mode) + { + Status = gGOP->SetMode (gGOP, prevGOPMode); //In some case changing text mode will change the graphcis mode, so reverting here. + } + } + return Status; +} +//EIP-107833 END + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 2014, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/protocol.h b/EDK/MiniSetup/BootOnly/protocol.h new file mode 100644 index 0000000..23b882f --- /dev/null +++ b/EDK/MiniSetup/BootOnly/protocol.h @@ -0,0 +1,198 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2013, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.h $ +// +// $Author: Arunsb $ +// +// $Revision: 12 $ +// +// $Date: 2/11/14 8:10p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.h $ +// +// 12 2/11/14 8:10p Arunsb +// Changes reverted for 2.16.1243 label +// +// 11 9/13/13 2:02p Premkumara +// Uploaded back for EIP-128665 after TSEBootOnly 1240 release +// Files - Protocol.c, Protocol.h, AMIPostMgr.h +// +// 10 8/26/13 2:15a Premkumara +// Reverted back for labelling BootOnly1240 +// +// 8 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 10 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 7 11/10/11 7:21p Blaines +// [TAG] - EIP 66860 +// [Category]- Function Request +// [Synopsis]- AmiPostManager interface for text entry. +// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h, +// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c +// +// Added new parameter to the function prototype DISPLAY_TEXT_KEY_VALIDATE +// +// 6 9/29/11 7:02p Blaines +// [TAG] - EIP 66860 +// [Category]- Function Request +// [Synopsis]- AmiPostManager interface for text entry. +// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h, +// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c +// +// 5 11/16/10 8:57a Mallikarjunanv +// [TAG] - EIP 41838 +// [Category]- Enhancement +// [Severity]- Mordarate +// [Symptom]- Update AMI Post Manager Protocol witht he following. 2. +// Updating the interface PostManagerDisplayPostMessageEx to handle the +// cursor position properly. 2. Need to add new interface to GetAttribute +// [Rootcause] - 1. Display string is over written by the next string if +// the interface PostManagerDisplayPostMessageEx used simultaneously. 2. +// Need to get the attribute info to use PostManagerDisplayPostMessage +// interfaces effectively +// [Solution]- Fix in string.c to handle cursor and line positions. The +// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface +// implementaion to get the attribute. +// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c +// +// 4 4/16/10 5:13p Madhans +// Changes for Tse 2.02. Please see Changelog.log for more details. +// +// 3 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 5 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 4 2/04/10 12:03p Blaines +// EIP-28005 +// +// Added PostManagerSetAttribute to support display of text in color. +// Added support for handling string characters --- \n, \r. +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:12p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 2/05/09 5:19p Madhans +// PostMgrStatus interface added. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +#ifndef _PROTOCOL_H_ +#define _PROTOCOL_H_ + +EFI_STATUS InstallProtocol( VOID ); +VOID UninstallProtocol( VOID ); +EFI_STATUS PostManagerHandshake( VOID ); +EFI_STATUS PostManagerSetCursorPosition(UINTN X, UINTN Y); +EFI_STATUS PostManagerGetCursorPosition(UINTN *pX, UINTN *pY); +EFI_STATUS PostManagerSetProgressBarPosition(); +EFI_STATUS PostManagerInitProgressBar( + UINTN x, + UINTN y, + UINTN w, + UINTN h, + UINTN delta); + +TSE_POST_STATUS PostManagerGetPostStatus(VOID); + +EFI_STATUS PostManagerDisplayInfoBox( CHAR16 *InfoBoxTitle, + CHAR16 *InfoString, + UINTN Timeout, + EFI_EVENT *Event + ); + + +EFI_STATUS PostManagerSetAttribute(UINT8 ATTRIB); +EFI_STATUS PostManagerGetAttribute(UINT8 *ATTRIB); //EIP-41838: new interface to get the attribute + +EFI_STATUS +PostManagerDisplayMenu( + IN VOID *HiiHandle, + IN UINT16 TitleToken, + IN UINT16 LegendToken, + IN POSTMENU_TEMPLATE *MenuData, + IN UINT16 MenuCount, + OUT UINT16 *pSelection +); + +typedef +BOOLEAN +(EFIAPI *DISPLAY_TEXT_KEY_VALIDATE) ( + UINT16 ItemIndex, + UINT16 Unicode, + CHAR16 *Value +); + + +EFI_STATUS +PostManagerDisplayTextBox( + IN VOID *HiiHandle, + IN UINT16 TitleToken, + IN TEXT_INPUT_TEMPLATE *InputData, + IN UINT16 ItemCount, + IN DISPLAY_TEXT_KEY_VALIDATE DisplayTextKeyValidate +); + +EFI_STATUS PostManagerDisplayProgress ( +IN UINT8 ProgressBoxState, +IN CHAR16 *Title, +IN CHAR16 *Message, +IN CHAR16 *Legend, +IN UINTN Percent, // 0 - 100 +IN OUT VOID **Handle, //Out HANDLE. Valid Handle for update and close +OUT AMI_POST_MGR_KEY *OutKey //Out Key +); +#endif /* _PROTOCOL_H_ */ + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2013, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/screen.c b/EDK/MiniSetup/BootOnly/screen.c new file mode 100644 index 0000000..ba1bd23 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/screen.c @@ -0,0 +1,346 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.c $ +// +// $Author: Arunsb $ +// +// $Revision: 7 $ +// +// $Date: 4/18/13 6:16a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.c $ +// +// 7 4/18/13 6:16a Arunsb +// [TAG] EIP113081 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Post message displays twice +// [RootCause] Buffer not cleared after displaying post message +// [Solution] Buffer cleared properly. Save and restored the post +// graphics screen properly. +// [Files] protocol.c, screen.c and string.c +// +// 6 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 10 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 5 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 7 6/22/10 5:32a Mallikarjunanv +// EIP:39102 - Updated Restore screen to restore complete screen +// +// 6 4/07/10 6:24p Madhans +// post screen Sroll area support. TSE_POSTSCREEN_SCROLL_AREA SDL +// configures the area. +// +// 5 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 4 2/04/10 11:22p Madhans +// To remove conout dependance +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:13p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: screen.c +// +// Description: This file contains code for screen operations. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +VOID MouseStop(VOID); +VOID MouseRefresh(VOID); + +// +//---------------------------------------------------------------------------- +// Procedure: ClearScreenWithoutFlush +// +// Description: function to clear screen without flushing. +// +// Input: UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID ClearScreenWithoutFlush( UINT8 Attrib ) +{ + + gActiveBuffer->ScreenTag = ACTIVE_SCREEN_TAG; + MemSet( gActiveBuffer->Attribs, sizeof(gActiveBuffer->Attribs), Attrib ); + + MemFillUINT16Buffer( gActiveBuffer->Chars, MAX_DIMENSIONS, (UINT16)L' ' ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: ClearLinesWithoutFlush +// +// Description: function to clear lines without flushing. +// +// Input: UINT8 LineStart, UINT8 NumLines, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID ClearLinesWithoutFlush( UINT8 LineStart, UINT8 NumLines, UINT8 Attrib ) +{ + + gActiveBuffer->ScreenTag = ACTIVE_SCREEN_TAG; + MemSet(&( gActiveBuffer->Attribs[LineStart*gMaxCols]), NumLines*gMaxCols /*sizeof(gActiveBuffer->Attribs)*/, Attrib ); + + MemFillUINT16Buffer( &(gActiveBuffer->Chars[LineStart*gMaxCols]), NumLines*gMaxCols/*MAX_ROWS * MAX_COLS*/, (UINT16)L' ' ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: ClearScreen +// +// Description: function to clear the screen. +// +// Input: UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID ClearScreen( UINT8 Attrib ) +{ + ClearScreenWithoutFlush( Attrib ); + + if(gST->ConOut!=NULL) + { + gST->ConOut->EnableCursor( gST->ConOut, FALSE ); + gST->ConOut->SetAttribute( gST->ConOut, Attrib ); + gST->ConOut->ClearScreen( gST->ConOut); + } + + FlushLines( 0, gMaxRows - 1 ); + +} + +EFI_UGA_PIXEL *gPostscreenwithlogo; +// +//---------------------------------------------------------------------------- +// Procedure: SaveScreen +// +// Description: function to get the backup of the screen. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID *SaveScreen( VOID ) +{ + SCREEN_BUFFER *Buffer; + + Buffer = EfiLibAllocatePool( sizeof(SCREEN_BUFFER) ); + + if ( Buffer != NULL ) + { + MemCopy( Buffer, gActiveBuffer, sizeof(SCREEN_BUFFER) ); + Buffer->ScreenTag = SAVE_SCREEN_TAG; + } + + return (VOID *)Buffer; +} + +// +//---------------------------------------------------------------------------- +// Procedure: RestoreScreen +// +// Description: function to restore the screen from the saved screen buffer. +// +// Input: VOID *ScreenBuffer +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID RestoreScreen( VOID *ScreenBuffer ) +{ + SCREEN_BUFFER *Buffer = (SCREEN_BUFFER *)ScreenBuffer; + + MouseStop(); + + if ( ( Buffer == NULL ) || ( Buffer->ScreenTag != SAVE_SCREEN_TAG ) ) + return; + + ///Clear Original data in the buffers before restoring with saved screen buffer. + MemSet(gActiveBuffer, sizeof(SCREEN_BUFFER), 0); + MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0); + + MemCopy( gActiveBuffer, Buffer, sizeof(SCREEN_BUFFER) ); + gActiveBuffer->ScreenTag = ACTIVE_SCREEN_TAG; + + FlushLines( 0, gMaxRows - 1 ); + DoRealFlushLines(); + + MemFreePointer( (VOID **)&Buffer ); + + MouseRefresh(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SaveGraphicsScreen +// +// Description: Saves post graphics screen +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID SaveGraphicsScreen(VOID) +{ + UINTN HorizontalResolution = 0; + UINTN VerticalResolution = 0; + + GetScreenResolution(&HorizontalResolution, &VerticalResolution); + gPostscreenwithlogo = EfiLibAllocateZeroPool( HorizontalResolution * VerticalResolution * sizeof(EFI_UGA_PIXEL)); + + if (NULL == gPostscreenwithlogo) + { + return; + } + MouseStop(); +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if ( gGOP) + gGOP->Blt ( + gGOP, + gPostscreenwithlogo, + EfiBltVideoToBltBuffer, + (UINTN)0, (UINTN)0, + (UINTN)0, (UINTN)0, + HorizontalResolution, VerticalResolution, + 0 + ); +#else + if ( gUgaDraw) + gUgaDraw->Blt ( + gUgaDraw, + gPostscreenwithlogo, + EfiUgaVideoToBltBuffer, + (UINTN)0, (UINTN)0, + (UINTN)0, (UINTN)0, + HorizontalResolution, VerticalResolution, + 0 + ); +#endif + MouseRefresh(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: RestoreGraphicsScreen +// +// Description: Restores the saved post graphics screen +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID RestoreGraphicsScreen (VOID) +{ + + if( gPostscreenwithlogo != NULL ) + { + UINTN HorizontalResolution = 0; + UINTN VerticalResolution = 0; + + GetScreenResolution(&HorizontalResolution, &VerticalResolution); + MouseStop(); +#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL + if ( gGOP) + gGOP->Blt ( + gGOP, + gPostscreenwithlogo, + EfiBltBufferToVideo, + (UINTN)0, (UINTN)0, + (UINTN)0, (UINTN)0, + HorizontalResolution, VerticalResolution, + 0 + ); +#else + if ( gUgaDraw) + gUgaDraw->Blt ( + gUgaDraw, + gPostscreenwithlogo, + EfiUgaBltBufferToVideo, + (UINTN)0, (UINTN)0, + (UINTN)0, (UINTN)0, + HorizontalResolution, VerticalResolution, + 0 + ); +#endif + MouseRefresh(); + MemFreePointer( (VOID **)&gPostscreenwithlogo ); + } +} +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/screen.h b/EDK/MiniSetup/BootOnly/screen.h new file mode 100644 index 0000000..ce2cb38 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/screen.h @@ -0,0 +1,96 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.h $ +// +// $Author: Arunsb $ +// +// $Revision: 4 $ +// +// $Date: 10/18/12 5:59a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.h $ +// +// 4 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 6 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 3 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 3 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:13p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +#ifndef _SCREEN_H_ +#define _SCREEN_H_ + +VOID ClearScreenWithoutFlush( UINT8 Attrib ); +VOID ClearLinesWithoutFlush( UINT8 LineStart, UINT8 NumLines, UINT8 Attrib ); +VOID ClearScreen( UINT8 Attrib ); +VOID *SaveScreen( VOID ); +VOID RestoreScreen( VOID *ScreenBuffer ); + +typedef struct +{ + UINT32 ScreenTag; + UINT8 Attribs[MAX_DIMENSIONS]; + CHAR16 Chars[MAX_DIMENSIONS]; +} +SCREEN_BUFFER; + +#define ACTIVE_SCREEN_TAG 0x54434153 // "SACT" +#define SAVE_SCREEN_TAG 0x56415353 // "SSAV" + +extern SCREEN_BUFFER *gActiveBuffer; + +VOID MemFillUINT16Buffer( VOID *buffer, UINTN bufferSize, UINT16 value ); + +#endif /* _SCREEN_H_ */ + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/string.c b/EDK/MiniSetup/BootOnly/string.c new file mode 100644 index 0000000..36908eb --- /dev/null +++ b/EDK/MiniSetup/BootOnly/string.c @@ -0,0 +1,1488 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2012, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.c $ +// +// $Author: Arunsb $ +// +// $Revision: 20 $ +// +// $Date: 2/11/14 10:10p $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.c $ +// +// 20 2/11/14 10:10p Arunsb +// [TAG] EIP149640 +// [Category] Bug Fix +// [Severity:] Normal +// [Symptom:] F1 not displaying help message +// [Root Cause] If we have \n in string then it replaced with 0x0d(\r) and +// 0xa(\n) so both \r and \n treated as new line so incremented in height +// not displayed the message box. +// ie., height is beyond the max rows +// [Solution] If we have \n in string we will get 0x0d(\r) and 0xa(\n) +// continuously so removed \r for \n. +// For \r alone case it will replaced with \0 +// [Files] string.c +// +// 19 2/11/14 8:13p Arunsb +// [TAG] EIP126746 +// [Category] Improvement +// [Description] AMITSE - ANSI escape code support for multiline +// [Files] string.c and commonhelper.c +// +// 18 12/03/13 1:55p Premkumara +// [TAG] EIP130420 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] String is getting truncated +// [RootCause] The string for messagebox, Popup controls is getting +// truncated +// [Solution] Used temp variable to store original string and modify the +// string temp and used to avoid changing org string. +// [Files] String.c +// +// 17 11/08/13 7:55a Premkumara +// [TAG] EIP131481 +// [Category] Improvement +// [Description] TSE support '\r' to do line break +// [Files] String.c +// +// 16 4/18/13 6:17a Arunsb +// [TAG] EIP113081 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Post message displays twice +// [RootCause] Buffer not cleared after displaying post message +// [Solution] Buffer cleared properly. Save and restored the post +// graphics screen properly. +// [Files] protocol.c, screen.c and string.c +// +// 15 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 16 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 14 4/27/12 3:57a Rajashakerg +// [TAG] EIP87424 +// [Category] Bug Fix +// [Severity] Normal +// [Symptom] Mouse pointer is destroyed by TSE when it is on SETUP icon +// during POST +// [RootCause] When SOFTKBD_ICON_SUPPORT is enabled the mouse pointer is +// restricted to the ICON location. In the same line we are updating the +// Post Message in which DoRealFlushLines() will stop the mouse while +// updating the string in Post, but immediate Mouse refresh is not present +// in PrintPostMessage() which is causing mouse pointer disappear. +// +// [Solution] Provided mouserefresh after DoRealFlushLines() in +// PrintPostMessage() function. +// [Files] BootOnly/string.c +// +// 13 2/02/12 1:13p Premkumara +// [TAG] EIP75351,75352,75384 +// [Category] Improvement +// [Description] Suppress the warnings from static code analyzer +// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c, +// MessageBox.c, Label.c, Edit.c, Date.c +// +// 12 11/30/11 12:17a Premkumara +// [TAG] EIP75351 +// [Category] Improvement +// [Description] Static code analysis.Suppress the warnings from static +// code analyzer +// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c, +// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c +// +// 11 10/21/11 2:57a Rajashakerg +// [TAG] EIP60563 +// [Category] New Feature +// [Description] Updating the file with fix for issue : maximum 8 byte +// value shows negative number +// [Files] numeric.c, numeric.h, string.c, string.h +// +// 10 6/20/11 12:25p Rajashakerg +// [TAG] EIP60563 +// [Category] New Feature +// [Description] Support for signed decimal value for +// EFI_IFR_NUMERIC_OP. +// [Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c +// +// 9 12/22/10 5:03a Mallikarjunanv +// [TAG] EIP41838 +// [Category] Improvement +// [Description] Updated the fix for 41838. Previously for \r is not +// returning the cursor position to the starting column and \n it is not +// moved to the first column of the next line. Now \r and \n functionality +// updated to work properly. +// [Files] string.c +// +// 8 11/16/10 8:55a Mallikarjunanv +// [TAG] - EIP 41838 +// [Category]- Enhancement +// [Severity]- Mordarate +// [Symptom]- Update AMI Post Manager Protocol witht he following. 2. +// Updating the interface PostManagerDisplayPostMessageEx to handle the +// cursor position properly. 2. Need to add new interface to GetAttribute +// [Rootcause] - 1. Display string is over written by the next string if +// the interface PostManagerDisplayPostMessageEx used simultaneously. 2. +// Need to get the attribute info to use PostManagerDisplayPostMessage +// interfaces effectively +// [Solution]- Fix in string.c to handle cursor and line positions. The +// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface +// implementaion to get the attribute. +// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c +// +// 7 9/16/10 8:38p Madhans +// Update for TSE 2.10. Refer Changelog.log for more details. +// +// 6 4/16/10 5:13p Madhans +// Changes for Tse 2.02. Please see Changelog.log for more details. +// +// 5 2/19/10 8:50p Madhans +// +// 4 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 8 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 7 2/04/10 12:03p Blaines +// EIP-28005 +// +// Added PostManagerSetAttribute to support display of text in color. +// Added support for handling string characters --- \n, \r. +// +// 6 1/09/10 5:43a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 5 10/05/09 10:36a Madhans +// To allow printing without affecting the previous screen when it is used +// with SetCursorPosition. +// +// 4 9/25/09 6:37a Sudhirv +// EIP-26893 : when the DisplayPostMessage() function of the AMI Post +// Manager protocol is called multiple times, strings are truncated when +// displayed. +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:13p Madhans +// Tse 2.0 Code complete Checkin. +// +// 5 4/28/09 9:49p Madhans +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:01p Madhans +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: string.c +// +// Description: This file contains code for string functionalities. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +static UINTN StartRow = 0; +static UINTN StartCol = 0; +static UINTN EndRow = STYLE_FULL_MAX_ROWS; +static UINTN EndCol = STYLE_FULL_MAX_COLS; + +static UINTN stStartLine= 0 ; +static UINTN stNextLine = 0; +static UINTN stColNum = 0; + +static BOOLEAN stPostScreenActive = FALSE; +VOID ScrollPostScreenLine(); + + +// +//---------------------------------------------------------------------------- +// Procedure: SetPostScreenScrollArea +// +// Description: Sets the PostScreen Scroll Area. +// +// Input: UINTN TopX, UINTN TopY, UINTN BottomX, UINTN BottomY +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID SetPostScreenScrollArea(UINTN TopRow, UINTN TopCol, UINTN BottomRow, UINTN BottomCol) +{ + if((TopCol +//---------------------------------------------------------------------------- +// Procedure: atoi +// +// Description: function to convet a string to integer +// +// Input: CHAR16 *string, UINT8 base +// +// Output: integer +// +//---------------------------------------------------------------------------- +// +UINTN atoi(CHAR16 *string, UINT8 base) +{ + UINTN dval = 0;//EIP:60563 to support signed integers for NUMERIC opcode + CHAR16 ch; + + if ( base == 10 ) + { + while ( (ch = *string++ ) != 0x0) + { + if ( ch >= L'0' && ch <= L'9' ) + dval = dval * 10 + ch - L'0'; + else + break; + + } + } + else if ( base == 16 ) + { + while ( (ch = *string++) != 0x0 ) + { + if ( ch >= L'0' && ch <= L'9' ) + dval = dval * 16 + ch - L'0'; + else if ( ch >= L'a' && ch <= L'f' ) + dval = dval * 16 + ch - L'a' + 10; + else if ( ch >= L'A' && ch <= L'F' ) + dval = dval * 16 + ch - L'A' + 10; + else + break; + } + }//EIP:60563 to support signed integers for NUMERIC opcode + else if( base == 32) + { + if(string[0]== L'-') + { + string++; + while ( (ch = *string++ ) != 0x0) + { + if ( ch >= L'0' && ch <= L'9' ) + dval = dval * 10 + ch - L'0'; + else + break; + } + dval= (INTN)((0xffffffffffffffff - dval )+ 0x1); + } + else + { + while ( (ch = *string++ ) != 0x0) + { + if ( ch >= L'0' && ch <= L'9' ) + dval = dval * 10 + ch - L'0'; + else + break; + } + } + } + return dval; +} + +// +//---------------------------------------------------------------------------- +// Procedure: StrZeroPad +// +// Description: function to pad with zero +// +// Input: INT32 Tm, CHAR16 *Str +// +// Output: String +// +//---------------------------------------------------------------------------- +// +CHAR16 *StrZeroPad(INT32 Tm, CHAR16 *Str) +{ + CHAR16 *fmt = L"%d"; + + if ( Tm < 10 ) + fmt = L"0%d"; + + SPrint( Str, 10, fmt, Tm ); + return Str; +} + +// +//---------------------------------------------------------------------------- +// Procedure: StrDup +// +// Description: function to dump and return the string +// +// Input: CHAR16 *String +// +// Output: String +// +//---------------------------------------------------------------------------- +// +CHAR16 *StrDup( CHAR16 *string ) +{ + CHAR16 *text; + + if(string == NULL) + return NULL; + + text = EfiLibAllocatePool( (1 + EfiStrLen( string )) * sizeof(CHAR16) ); + if ( text != NULL ) + EfiStrCpy( text, string ); + + return text; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawAttribute +// +// Description: function to write a attribute +// +// Input: UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawAttribute( UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length ) +{ + UINTN Offset = Row * gMaxCols + Col; + + if ( Row >= gMaxRows ) + return; + + DrawAttributeOffset( Offset, Attrib, Length ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawAttributeOffset +// +// Description: function to write in a peticular offset. +// +// Input: UINTN Offset, UINT8 Attrib, UINTN Length +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawAttributeOffset( UINTN Offset, UINT8 Attrib, UINTN Length ) +{ + if ( Attrib ) + MemSet( &gActiveBuffer->Attribs[Offset], Length, Attrib ); +} +UINT8 ForegroundColors[] = { + 30, //Black + 34, //Blue + 32, //Green + 36, //Cyan + 31, //Red + 35, //Magenta + 33, //Brown (code is for Yellow) + 37, //Light Gray (code is for White) +}; + +UINT8 BackgroundColors[] = { + 40, //Black + 44, //Blue + 42, //Green + 46, //Cyan + 41, //Red + 45, //Magenta + 43, //Brown (code is for Yellow) + 47 //Light Gray (code is for White) +}; + +UINT8 GetEFIFG(UINT8 ANSIColor) +{ + UINT8 i=0; + for(i=0;i +//---------------------------------------------------------------------------- +// Procedure: DrawMultiLineStringWithAttribute +// +// Description: function to write a multiline string. +// +// Input: UINTN Col, UINTN Row,UINTN Width, UINTN Height, +// CHAR16 *line, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawMultiLineStringWithAttribute( UINTN Col, UINTN Row,UINTN Width, UINTN Height, CHAR16 *line, UINT8 Attrib ) +{ + CHAR16 * text; + UINTN i; + CHAR16 * String,*newtext; + UINT16 height; + + newtext = StringWrapText( line, (UINT16)Width, &height ); + //EIP-75351 Suppress the warnings from static code analyzer + if(NULL == newtext){ + return; + } + if(height < Height) + Height = height; + String = newtext; + for(i=0;i +//---------------------------------------------------------------------------- +// Procedure: DrawPostStringWithAttribute +// +// Description: function to write a multiline string in the post screen. +// +// Input: UINTN Col, UINTN Row, +// CHAR16 *line, UINT8 Attrib +// +// Output: UINTN +// +//---------------------------------------------------------------------------- +// +UINTN DrawPostStringWithAttribute( UINTN Col, UINTN Row,CHAR16 *line, UINT8 Attrib, BOOLEAN AdvanceLine ) +{ + CHAR16 * text; + UINTN i=0; + CHAR16 * String=line; + UINTN Offset; + UINTN mxCol=gMaxCols; + while(1) + { + CHAR16 save; + + text = String; + if ( *String == L'\0' ) + break; + + while ( ( *String != L'\n' ) &&( *String != L'\r' ) && ( *String != L'\0' ) ) + String++; + + save = *String; + *String = L'\0'; + + if(AdvanceLine) + { + mxCol = EndCol; + } + + Offset = HiiFindStrPrintBoundary(text,(mxCol - Col)); + + if((AdvanceLine) && (Row+i >= gMaxRows)) + { + ScrollPostScreenLine(); + Row = gMaxRows-1-i; + } + + if(Offset < EfiStrLen(text)) + {// Printing the string printed next line also + *String = save; + save = text[Offset]; + text[Offset] = 0; + DrawStringWithAttribute( Col , Row+i, (CHAR16*)text, Attrib); + String = &text[Offset]; + } + else + DrawStringWithAttribute( Col , Row+i, (CHAR16*)text, Attrib); + + stColNum = EfiStrLen(text);//EIP-41838: Updating the col position based on present string length. + if ( ( *String = save ) != L'\0' ) + { + stColNum = 0; Col=0;//EIP-41838: Updating the col position to zero in case of \n and \r. + if ( *String == L'\r' ) + { String++; + i--; + } + if ( *String == L'\n' ) + { + String++; + + if ( *(String - sizeof(CHAR16)) == L'\r' ) + i++; + } + } + else + break; + i++; + //EIP-41838: Update the col position based on string processed to display. + if ( (!AdvanceLine) && ( (Col+Offset) >= mxCol) ) { + Col =0; + } + } + return i; +} +// +//---------------------------------------------------------------------------- +// Procedure: DrawStringWithAttribute +// +// Description: function to write a string with attributes. +// +// Input: UINTN Col, UINTN Row, CHAR16 *String, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawStringWithAttribute( UINTN Col, UINTN Row, CHAR16 *String, UINT8 Attrib ) +{ + UINTN Length,printLength; + UINTN Offset = Row * gMaxCols + Col; + UINTN nIndex = 0; + UINTN Size; + UINT8 EscBold,EscFg,EscBg,EscAttrib=Attrib; + + if ( Row >= gMaxRows ) + return; + + Length = EfiStrLen( String ); + printLength = TestPrintLength( String ) / (NG_SIZE); + if ( Length == 0 ) + return; + + if ( printLength == 0 ) + return; + DrawAttributeOffset( Offset, Attrib, printLength ); + EscAttrib = Attrib; + + for(nIndex = 0;nIndex < Length;nIndex++) + { + if((String[nIndex] == 0xfff0) || (String[nIndex] == 0xfff1)) + { + continue; + } + Size=TseGetANSIEscapeCode(&String[nIndex],&EscBold,&EscFg,&EscBg); + if(Size) + { + EscAttrib = Attrib; + if(EscBg!=0xFF) + EscAttrib = (EscAttrib & 0x0F) | (GetEFIBG(EscBg)<<4); + if(EscFg!=0xFF) + EscAttrib = (EscAttrib & 0xF0) | GetEFIFG(EscFg); + if(EscBold!=0xFF) + EscAttrib = (EscAttrib & 0xF7) | (EscBold<<3); + + nIndex +=Size; + continue; + } + gActiveBuffer->Chars[Offset] = String[nIndex]; + if(EscAttrib) + gActiveBuffer->Attribs[Offset] = EscAttrib; + if(TRUE == IsCharWide(String[nIndex])) + { + Offset+=2; + } + else + { + Offset++; + } + } +} + +VOID DrawString( UINTN Col, UINTN Row, CHAR16 *String ) +{ + DrawStringWithAttribute( Col, Row, String, 0 ); +} + +VOID DrawStringJustified( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String ) +{ + DrawStringJustifiedWithAttribute( MinCol, MaxCol, Row, Justify, String, 0 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawStringJustifiedWithAttribute +// +// Description: function to write a string with justify and attributes. +// +// Input: UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, +// CHAR16 *String, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawStringJustifiedWithAttribute( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String, UINT8 Attrib ) +{ + UINTN Col = MinCol; + CHAR16 *text; + UINTN Length = 0; + + text = StrDup(String); //EIP-130420 + + Length = TestPrintLength( text ) / (NG_SIZE); + if ( Length == 0 ) + return; + + if ( Justify == JUSTIFY_RIGHT ) + { + if(Length < MaxCol) + Col = MaxCol - Length; + } + else if ( Justify == JUSTIFY_CENTER ) + { + if(Length < (MaxCol - MinCol)) + Col = MinCol + (((MaxCol - MinCol) - Length) / 2); + else + text[MaxCol - MinCol] = '\0'; + } + + if ( Col < MinCol ) + Col = MinCol; + + DrawStringWithAttribute( Col, Row, text, Attrib ); + MemFreePointer( (VOID **)&text ); +} + +VOID WriteChar( UINTN Row, UINTN Col, CHAR16 Char ) +{ + WriteCharWithAttribute( Row, Col, Char, 0 ); +} + +VOID WriteCharWithAttribute( UINTN Row, UINTN Col, CHAR16 Char, UINT8 Attrib ) +{ + UINTN Offset = Row * gMaxCols + Col; + + if ( Row >= gMaxRows ) + return; + + DrawAttributeOffset( Offset, Attrib, 1 ); + + gActiveBuffer->Chars[Offset] = Char; +} + +// +//---------------------------------------------------------------------------- +// Procedure: StringWrapText +// +// Description: function to create a new text by wrapping the given text. +// +// Input: CHAR16 *OrgText, UINT16 width, UINT16 *height +// +// Output: text +// +//---------------------------------------------------------------------------- +// +void FindAnsiEscCode (CHAR16 *ThisLine, CHAR16 **EscCode); +BOOLEAN IsANSIEscapeCodeSupported (VOID); +CHAR16 * StringWrapText( CHAR16 *OrgText, UINT16 width, UINT16 *height ) +{ + CHAR16 *newText, *text; + UINTN TextLen, i, j, newTextLen; + CHAR16 *ESCCode = (CHAR16 *)NULL; + + if(OrgText == NULL) + return NULL; + + if (IsANSIEscapeCodeSupported ()) + { + ESCCode = EfiLibAllocateZeroPool (12 * sizeof(CHAR16)); + if (NULL == ESCCode) + { + return NULL; + } + } + text = StrDup(OrgText); + TextLen = EfiStrLen(text); + //reformat input string by replacing \n and \r with \0 + i=0; + while(text[i]) + { + switch(text[i]) + { + case L'\r': + //IF we have \n in string we will get 0x0d(\r) and 0xa(\n) continuously so removing \r for \n alone + j=i; + if (text[i+1] == L'\n') + { + while(text[j]) + { + text[j]= text[j+1]; + j++; + } + //Adjust text length + TextLen--; + break; + } + case L'\n': + text[i] = L'\0'; + //No break on purpose + default: + i++; + } + } + + //Assuming max no of '\n's that may be added is no of rows + if (!IsANSIEscapeCodeSupported ()) + { + newText = EfiLibAllocateZeroPool( (TextLen + 1 + gMaxRows) * sizeof(CHAR16)); + } + else + { + newText = EfiLibAllocateZeroPool( (TextLen + 1 + (gMaxRows * 12)) * sizeof(CHAR16)); //If ANSI supported then chances are there to fill + } //ANSI code in all rows so 12 * gMaxRows bytes allocated + if (NULL == newText) + { + return NULL; + } + + *height=0; + newTextLen = 0; + for(i=0; i= (TestPrintLength(ThisLine)/(NG_SIZE)) ) //Can accomodate this line + { + if ((IsANSIEscapeCodeSupported ()) && (*ESCCode)) + { + if ( (ThisLine [0] == 0x001b) && (ThisLine [1] == L'[') ) + { + EfiStrCpy (newText + newTextLen, ThisLine); + } + else + { + EfiStrCpy (newText + newTextLen, ESCCode); + EfiStrCat (newText + newTextLen, ThisLine); + } + if ( (ThisLine [0] != 0x001b) || (ThisLine [1] != L'[') ) + { + newTextLen += EfiStrLen (ESCCode); + } + newTextLen += EfiStrLen (ThisLine); + newText[newTextLen] = L'\n'; + newTextLen++; + } + else + { + //Found space break the str here + EfiStrCpy(newText + newTextLen, ThisLine); + newTextLen+=EfiStrLen(ThisLine); + newText[newTextLen] = L'\n'; + newTextLen++; + } + if (IsANSIEscapeCodeSupported ()) + { + FindAnsiEscCode (ThisLine, &ESCCode); + } + i+=EfiStrLen(ThisLine); + i++; + } + else //Can not accomodate this line + { + //See if we can find a L" " + j = HiiFindStrPrintBoundary ( ThisLine, width )-1; + while(j) + { + if(ThisLine[j] == L' ') + { + //Found space break the str here + ThisLine[j]=L'\0'; + if ((IsANSIEscapeCodeSupported ()) && (*ESCCode)) + { + if ( (ThisLine [0] == 0x001b) && (ThisLine [1] == L'[') ) + { + EfiStrCpy (newText + newTextLen, ThisLine); + } + else + { + EfiStrCpy (newText + newTextLen, ESCCode); + EfiStrCat (newText + newTextLen, ThisLine); + } + if ( (ThisLine [0] != 0x001b) || (ThisLine [1] != L'[') ) + { + newTextLen += EfiStrLen (ESCCode); + } + newTextLen += EfiStrLen (ThisLine); + newText[newTextLen] = L'\n'; + newTextLen++; + } + else + { + EfiStrCpy(newText + newTextLen, ThisLine); + newTextLen+=EfiStrLen(ThisLine); + newText[newTextLen] = L'\n'; + newTextLen++; + } + if (IsANSIEscapeCodeSupported ()) + { + FindAnsiEscCode (ThisLine, &ESCCode); + } + i+=EfiStrLen(ThisLine); + i++; + break; + } + j--; + } + + if(0==j) + { + CHAR16 temp; + + //did not find L' ' + j = HiiFindStrPrintBoundary ( ThisLine, width ) - 1; + temp = ThisLine[j]; + ThisLine[j] = '\0'; + if ((IsANSIEscapeCodeSupported ()) && (*ESCCode)) + { + if ( (ThisLine [0] == 0x001b) && (ThisLine [1] == L'[') ) + { + EfiStrCpy (newText + newTextLen, ThisLine); + } + else + { + EfiStrCpy (newText + newTextLen, ESCCode); + EfiStrCat (newText + newTextLen, ThisLine); + } + if ( (ThisLine [0] != 0x001b) || (ThisLine [1] != L'[') ) + { + newTextLen += EfiStrLen (ESCCode); + } + newTextLen += EfiStrLen (ThisLine); + newText[newTextLen] = temp; + newTextLen++; + newText[newTextLen] = L'\n'; + newTextLen++; + } + else + { + EfiStrCpy(newText + newTextLen, ThisLine); + newTextLen+=EfiStrLen(ThisLine); + newText[newTextLen] = temp; + newTextLen++; + newText[newTextLen] = L'\n'; + newTextLen++; + } + if (IsANSIEscapeCodeSupported ()) + { + FindAnsiEscCode (ThisLine, &ESCCode); + } + i+=EfiStrLen(ThisLine); + i++; + } + } + } + newText[newTextLen] = L'\0'; + MemFreePointer((VOID **)&text); + + if (IsANSIEscapeCodeSupported ()) + { + MemFreePointer((VOID **)&ESCCode); + } + return newText; +} + +VOID ScrollPostScreenLine() +{ + UINTN i,j; + UINTN CopyFrom, CopyTo; + + + for(i=stStartLine;iAttribs[CopyTo] = gActiveBuffer->Attribs[CopyFrom]; + gActiveBuffer->Chars[CopyTo] = gActiveBuffer->Chars[CopyFrom]; + if((i+1)==EndRow) + { + gActiveBuffer->Chars[CopyFrom] = L' '; + } + CopyFrom++; + CopyTo++; + } + } + +} + +// +//---------------------------------------------------------------------------- +// Procedure: PrintPostMessage +// +// Description: function to Print the post massages +// +// Input: CHAR16 *message, BOOLEAN bAdvanceLine +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS PrintPostMessage( CHAR16 *message, BOOLEAN bAdvanceLine ) +{ + UINTN LineCount; + + RUNTIME_DEBUG(L"printpostmsg"); + + if(bAdvanceLine && (stNextLine > EndRow)) + { + ScrollPostScreenLine(); + stNextLine = EndRow; + stColNum = StartCol; + } + + LineCount = DrawPostStringWithAttribute(stColNum,stNextLine,message, gPostMgrAttribute,bAdvanceLine); + + if(stPostScreenActive) + { + FlushLines(stStartLine,stNextLine+LineCount); + DoRealFlushLines(); + MouseRefresh();//EIP 87424 : Mouse pointer disappear in POST when SOFTKBD_ICON_SUPPORT is enabled + } + + if(bAdvanceLine) + { + stNextLine += LineCount; + stColNum = StartCol; + stNextLine++; + if(stNextLine > gMaxRows) + stNextLine = gMaxRows; + } + else { + //EIP-41838: Update the Line number based on the string displayed, to not to overwrite the existing line in case of a big string. + if(stColNum > gMaxCols) + { + stColNum = (stColNum%gMaxCols); + } + stNextLine = stNextLine+LineCount; + if(stNextLine > EndRow) + { + ScrollPostScreenLine(); + stNextLine = EndRow; + } + } + + return EFI_SUCCESS; +} + +//eip:26893-Start +// +//---------------------------------------------------------------------------- +// Procedure: PreservePostMessages +// +// Description: function to take care the postmessages when Screen mode changes +// Only supported if OldMaxCols <= NewMaxCols +// +// Input: UINTN NewMaxCols, UINTN OldMaxCols +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID PreservePostMessages(UINTN NewMaxCols, UINTN OldMaxCols) +{ + UINTN i,CharCount; + + if(OldMaxCols <= NewMaxCols) + return; + // Loop to copy each line to newmax cols + for(i=0;iCopyMem ((VOID*)&gActiveBuffer->Attribs[i*NewMaxCols], (VOID*)&gActiveBuffer->Attribs[i*OldMaxCols],NewMaxCols); + gBS->CopyMem ((VOID*)&gActiveBuffer->Chars[i*NewMaxCols], (VOID*)&gActiveBuffer->Chars[i*OldMaxCols],NewMaxCols*sizeof(CHAR16)); + } + + //clear chars after (NewCol * stNextLine) in the buffer + CharCount = (stNextLine*OldMaxCols) - (stNextLine*NewMaxCols); + for(i=0;iChars[(stNextLine*NewMaxCols)+i] = L' '; +} +//eip:26893-End + +// +//---------------------------------------------------------------------------- +// Procedure: DisplayActivePostMsgs +// +// Description: function to Display active messages +// +// Input: UINTN LogoHeight +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DisplayActivePostMsgs(UINTN LogoHeight) +{ + UINTN LinesToPush; + + if(!stPostScreenActive) + { + //First time showing the messages received. Adjust buffer to Logo height + //Find out no of extra lines + if((stNextLine-stStartLine) >= (gMaxRows - LogoHeight)) + { + //Dicard only extra line that can not be shown + stStartLine = (stNextLine - stStartLine) - (gMaxRows - LogoHeight); + } + //Push lines so that they will be seen below the logo + LinesToPush = LogoHeight - stStartLine; + if(LinesToPush) + { + UINTN CopyFrom, CopyTo; + + //Copy previous line if any + if(stNextLine > stStartLine) + { + CopyTo = (stNextLine + LinesToPush) * gMaxCols; + CopyFrom = stNextLine * gMaxCols; + + //Go to the end char of the previous line + CopyTo--; + CopyFrom--; + + while(1) + { + gActiveBuffer->Attribs[CopyTo] = gActiveBuffer->Attribs[CopyFrom]; + gActiveBuffer->Chars[CopyTo] = gActiveBuffer->Chars[CopyFrom]; + gActiveBuffer->Chars[CopyFrom] = (UINT16)L' '; + gActiveBuffer->Attribs[CopyFrom] = (UINT8) EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ; + + if(CopyFrom == (stStartLine * gMaxCols)) // Copy till the first char of the start line + break; + + CopyFrom--; + CopyTo--; + } + } + + //Modify Start and Next line values to new values + stStartLine = LogoHeight; + stNextLine = stNextLine + LinesToPush; + } + + // make sure EndRow and EndCol is not bigger then ScreenSize + EndRow = (EndRow>gMaxRows)?gMaxRows:EndRow; + EndCol = (EndCol>gMaxCols)?gMaxCols:EndCol; + } + + + //Post screen activated + stPostScreenActive = TRUE; + + //Flush lines if any + if(stNextLine > stStartLine) + { + FlushLines(stStartLine,stNextLine-1); + DoRealFlushLines(); + } +} + +// +//-------------------------------------------------------------------------- +// +// Name: SetCurPos +// +// Description: Sets the cursor to the position defined by X and Y. +// +// Input: UINTN X - Value of the column +// UINTN Y - Number of row below the last written line +// +// Output: EFI_STATUS status - If the function runs correctly, returns +// EFI_SUCCESS, else other EFI defined error values. +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS SetCurPos(UINTN X, UINTN Y) +{ + if((X < gMaxCols) && ( Y < gMaxRows)) + { + stColNum = X; + stNextLine = Y; + return EFI_SUCCESS; + } + + return EFI_UNSUPPORTED; +} + +// +//-------------------------------------------------------------------------- +// +// Name: GetCurPos +// +// Description: Writes cursor position into given X and Y locations. +// +// Input: UINTN *pX - Pointer to storage for current column value +// UINTN *pY - Pointer to storage for current row value +// +// Output: EFI_STATUS status - EFI_SUCCESS if OK, +// EFI_INVALID_PARAMETER if NULL pointer +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS GetCurPos(UINTN * const pX, UINTN * const pY) +{ + EFI_STATUS retcode = EFI_INVALID_PARAMETER; + + if (NULL != pX && NULL != pY) + { + if(stColNum < gMaxCols) { + *pX = stColNum; + } + else { //EIP-41753: If the nextline exceeds the limit, set the value based on gMaxCols value. + *pX = gMaxCols-1; + } + + if(stNextLine < gMaxRows) { + *pY = stNextLine; + } + else { //EIP-41753: If the nextline exceeds the limit, set the value based on gMaxRows value. + *pY = gMaxRows-1; + } + + retcode = EFI_SUCCESS; + } + return retcode; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrDup8 +// +// Description: Duplicates a String of type CHAR8 +// +// Input: CHAR8* string +// +// Output: CHAR8 * +// +// +//-------------------------------------------------------------------------- +// +CHAR8 *StrDup8( CHAR8 *string ) +{ + CHAR8 *text; + + text = EfiLibAllocatePool(1 + StrLen8( string )); + if ( text != NULL ) + StrCpy8( text, string ); + + return text; +} +#pragma warning( disable : 4706 ) + +// +//-------------------------------------------------------------------------- +// +// Name: StrDup8to16 +// +// Description: Duplicates a String from CHAR8 to CHAR16 +// +// Input: CHAR8* string +// +// Output: CHAR16 * +// +// +//-------------------------------------------------------------------------- +// +CHAR16 *StrDup8to16( CHAR8 *string ) +{ + CHAR16 *text; + UINTN i; + + text = EfiLibAllocatePool( (1 + StrLen8( string )) * sizeof(CHAR16)); + if ( text != NULL ) + { + i=0; + while(text[i] = (CHAR16)string[i]) + i++; + } + + return text; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrLen8 +// +// Description: Returns Length of a String of type CHAR8 +// +// Input: CHAR8* string +// +// Output: UINTN +// +// +//-------------------------------------------------------------------------- +// +UINTN StrLen8(CHAR8 *string) +{ + UINTN i=0; + while(string[i]) + i++; + + return i; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrCpy8 +// +// Description: Copies a CHAR8 String from source to destination +// +// Input: CHAR8 *dest, CHAR8 *src +// +// Output: VOID +// +// +//-------------------------------------------------------------------------- +// +VOID StrCpy8(CHAR8 *dest, CHAR8 *src) +{ + UINTN i=0; + while(dest[i] = src[i]) + i++; +} + + +// +//-------------------------------------------------------------------------- +// +// Name: GetTokenCount +// +// Description: +// +// Input: CHAR8 *String +// +// Output: UINTN +// +// +//-------------------------------------------------------------------------- +// +UINTN GetTokenCount(CHAR8 *String) +{ + UINTN count = 0; + UINTN j = 0; + BOOLEAN token = FALSE; + + do + { + if(String[j] == ';') + { + if(token) + count++; + token = FALSE; + }else + { + token = TRUE; + } + }while(String[j++]); + + return (token? (count + 1) : count); +} + +// +//-------------------------------------------------------------------------- +// +// Name: GetTokenString +// +// Description: +// +// Input: CHAR8 *String, UINTN *pos +// +// Output: CHAR8 * +// +// +//-------------------------------------------------------------------------- +// +CHAR8* GetTokenString(CHAR8 *String, UINTN *pos) +{ + CHAR8 *text; + UINTN i = 0, count = 0, j = 0; + + do + { + if(String[i] == ';') + { + break; + } + count++; + }while(String[i++]); + + text = EfiLibAllocateZeroPool( (1 + count) * sizeof(CHAR8)); + if(text != NULL) + { + i = 0; + do + { + text[j++] = String[i++]; + }while(j < count); + *pos = i; + } + + return text; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrDup16to8 +// +// Description: Duplicates a String from CHAR16 to CHAR8 +// +// Input: CHAR16 *String +// +// Output: CHAR8 * +// +// +//-------------------------------------------------------------------------- +// +CHAR8* StrDup16to8(CHAR16 *String) +{ + CHAR8 *text; + UINTN len = 0, j = 0; + + while(String[j++]) + len++; + text = EfiLibAllocateZeroPool( (1 + len) * sizeof(CHAR8)); + if(text != NULL) + { + j = 0; + do + { + text[j] = (CHAR8)String[j]; + }while(j++ < len); + } + + return text; +} + +//EIP-126746 Start +// +//-------------------------------------------------------------------------- +// +// Name: FindAnsiEscCode +// +// Description: Fills the EscCode in current line +// +// Input: CHAR16 *, CHAR16 ** +// +// Output: void +// +// +//-------------------------------------------------------------------------- +// +void FindAnsiEscCode (CHAR16 *ThisLine, CHAR16 **EscCode) +{ + UINTN iIndex = 0, size = 0; + + while (ThisLine [iIndex]) + { + if ( (ThisLine [iIndex] == 0x001b) && (ThisLine [iIndex+1] == L'[') ) + { + size = 0; + MemSet (*EscCode, 12 * sizeof (CHAR16), 0); + while (ThisLine [iIndex] != L'm') + { + (*EscCode)[size] = ThisLine [iIndex]; + size++; + iIndex++; + } + (*EscCode)[size] = L'm'; + } + iIndex ++; + } +} +//EIP-126746 END + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** + diff --git a/EDK/MiniSetup/BootOnly/string.h b/EDK/MiniSetup/BootOnly/string.h new file mode 100644 index 0000000..c855bb2 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/string.h @@ -0,0 +1,158 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.h $ +// +// $Author: Arunsb $ +// +// $Revision: 7 $ +// +// $Date: 10/18/12 5:59a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.h $ +// +// 7 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 9 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 6 10/21/11 2:58a Rajashakerg +// [TAG] EIP60563 +// [Category] New Feature +// [Description] Updating the file with fix for issue : maximum 8 byte +// value shows negative number +// [Files] numeric.c, numeric.h, string.c, string.h +// +// 5 6/20/11 12:26p Rajashakerg +// [TAG] EIP60563 +// [Category] New Feature +// [Description] Support for signed decimal value for +// EFI_IFR_NUMERIC_OP. +// [Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c +// +// 4 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 6 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 5 1/09/10 5:43a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 4 9/25/09 6:37a Sudhirv +// EIP-26893 : when the DisplayPostMessage() function of the AMI Post +// Manager protocol is called multiple times, strings are truncated when +// displayed. +// +// 3 6/16/09 2:16p Presannar +// Added File Headers for Header Files +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:13p Madhans +// Tse 2.0 Code complete Checkin. +// +// 4 4/28/09 9:39p Madhans +// Tse 2.0 Code complete Checkin. +// +// 3 3/31/09 4:01p Madhans +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: string.h +// +// Description: Header file for string functionalities. +// +//---------------------------------------------------------------------------- +// + +#ifndef _STRING_H_ +#define _STRING_H_ + +#define CharIsUpper(c) ((c >= L'A') && (c <= L'Z')) +#define CharIsLower(c) ((c >= L'a') && (c <= L'z')) +#define CharIsAlpha(c) (CharIsUpper(c) || CharIsLower(c)) +#define CharIsNumeric(c) ((c >= L'0') && (c <= L'9')) +#define CharIsAlphaNumeric(c) (CharIsAlpha(c) || CharIsNumeric(c)) +#define CharIsAlphaNumericSpecial(c) ((c >= (CHAR16)0x20) && (c <= (CHAR16)0x7E)) + +#define JUSTIFY_CENTER (0) +#define JUSTIFY_LEFT (1) +#define JUSTIFY_RIGHT (2) +#define JUSTIFY_MAX JUSTIFY_RIGHT + +UINTN atoi(CHAR16 *string, UINT8 base); +CHAR16 *StrZeroPad(INT32 Tm, CHAR16 *Str); +CHAR16 *StrDup(CHAR16 *string); +VOID DrawAttribute( UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length ); +VOID DrawAttributeOffset( UINTN Offset, UINT8 Attrib, UINTN Length ); +VOID DrawString( UINTN Col, UINTN Row, CHAR16 *String ); +VOID DrawStringWithAttribute( UINTN Col, UINTN Row, CHAR16 *String, UINT8 Attrib ); +VOID DrawMultiLineStringWithAttribute( UINTN Col, UINTN Row,UINTN Width, UINTN Height, CHAR16 *line, UINT8 Attrib ); +VOID DrawStringJustified( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String ); +VOID DrawStringJustifiedWithAttribute( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String, UINT8 Attrib ); +VOID WriteChar( UINTN Row, UINTN Col, CHAR16 Char ); +VOID WriteCharWithAttribute( UINTN Row, UINTN Col, CHAR16 Char, UINT8 Attrib ); + +CHAR16 *StringWrapText( CHAR16 *text, UINT16 width, UINT16 *height ); +UINTN StringGetWrapHeight( CHAR16 *text, UINT16 width ); +UINTN _StringFindBreak( CHAR16 *string ); + +EFI_STATUS PrintPostMessage( CHAR16 *message, BOOLEAN bAdvanceLine ); +VOID DisplayActivePostMsgs(UINTN LogoHeight); +VOID PreservePostMessages(UINTN NewMaxCols, UINTN OldMaxCols); //eip:26893 + +EFI_STATUS SetCurPos(UINTN X, UINTN Y); +EFI_STATUS GetCurPos(UINTN * const pX, UINTN * const pY); +UINTN GetTokenCount(CHAR8 *String); +CHAR8* GetTokenString(CHAR8 *String, UINTN *pos); +CHAR8 *StrDup8( CHAR8 *string ); +CHAR16 *StrDup8to16( CHAR8 *string ); +UINTN StrLen8(CHAR8 *string); +VOID StrCpy8(CHAR8 *dest, CHAR8 *src); +CHAR8* StrDup16to8(CHAR16 *String); + +#endif /* _STRING_H_ */ + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/timer.c b/EDK/MiniSetup/BootOnly/timer.c new file mode 100644 index 0000000..54c77be --- /dev/null +++ b/EDK/MiniSetup/BootOnly/timer.c @@ -0,0 +1,154 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/timer.c $ +// +// $Author: Arunsb $ +// +// $Revision: 4 $ +// +// $Date: 10/18/12 5:59a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/timer.c $ +// +// 4 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 7 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 3 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 4 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:13p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: timer.c +// +// Description: This file contains code to handle the timer. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: TimerCreateTimer +// +// Description: function to create a timer event and to set the timer +// +// Input: EFI_EVENT *Event, EFI_EVENT_NOTIFY Callback, +// VOID *Context, EFI_TIMER_DELAY Delay, UINT64 Trigger, +// EFI_TPL CallBackTPL +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS TimerCreateTimer( EFI_EVENT *Event, EFI_EVENT_NOTIFY Callback, + VOID *Context, EFI_TIMER_DELAY Delay, UINT64 Trigger, EFI_TPL CallBackTPL ) +{ + EFI_STATUS Status; + UINT32 EventType = EFI_EVENT_TIMER; + + if ( Callback != NULL ) + EventType |= EFI_EVENT_NOTIFY_SIGNAL; + + Status = gBS->CreateEvent( + EventType, + CallBackTPL, + Callback, + Context, + Event + ); + + if ( EFI_ERROR( Status ) ) + return Status; + + Status = gBS->SetTimer( *Event, Delay, Trigger ); + if ( EFI_ERROR( Status ) ) + TimerStopTimer( Event ); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// Procedure: TimerStopTimer +// +// Description: function to stop the timer event. +// +// Input: EFI_EVENT *Event +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS TimerStopTimer( EFI_EVENT *Event ) +{ + EFI_STATUS Status = EFI_SUCCESS; + + if ( ( Event == NULL ) || ( *Event == NULL ) ) + return Status; + + gBS->CloseEvent( *Event ); + *Event = NULL; + + return Status; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2007, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/EDK/MiniSetup/BootOnly/variable.c b/EDK/MiniSetup/BootOnly/variable.c new file mode 100644 index 0000000..f600267 --- /dev/null +++ b/EDK/MiniSetup/BootOnly/variable.c @@ -0,0 +1,204 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2011, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/variable.c $ +// +// $Author: Arunsb $ +// +// $Revision: 7 $ +// +// $Date: 10/18/12 5:59a $ +// +//*****************************************************************// +//*****************************************************************// +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/variable.c $ +// +// 7 10/18/12 5:59a Arunsb +// Updated for 2.16.1235 QA submission +// +// 10 10/10/12 12:36p Arunsb +// Synched the source for v2.16.1232, backup with Aptio +// +// 6 9/28/11 10:48p Arunsb +// [TAG] EIP66369 +// [Category] Bug Fix +// [Severity] Important +// [Symptom] English strings appears intermediately when Chinese is a +// current language +// [RootCause] Some cases lang variable is not NULL terminated +// [Solution] Lang variable made as NULL terminated. +// [Files] BootOnly\Variable.c +// +// 5 6/17/10 2:59p Madhans +// Dynamic parsing support in TSE. +// +// 4 2/19/10 1:02p Madhans +// Updated for TSE 2.01. Refer Changelog.log for File change history. +// +// 6 2/19/10 8:14a Mallikarjunanv +// updated year in copyright message +// +// 5 2/18/10 8:26p Madhans +// To take care NOGET and NOSET Attribs from Exetendedflags of +// VariableInfo +// +// 4 1/09/10 5:44a Mallikarjunanv +// Updated TSE2.01 Release sources with coding standards +// +// 3 6/23/09 6:56p Blaines +// Coding standard update, +// Remove spaces from file header to allow proper chm function list +// creation. +// +// 2 6/12/09 7:41p Presannar +// Initial implementation of coding standards +// +// 1 6/04/09 8:05p Madhans +// +// 1 4/28/09 11:13p Madhans +// Tse 2.0 Code complete Checkin. +// +// 2 1/30/09 6:06p Madhans +// Function headers added. +// +// 1 12/18/08 7:58p Madhans +// Intial version of TSE Lite sources +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: variable.c +// +// Description: This file contains code to handle bootonly lever variables operations. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +extern UINTN gSetupCount; + +// +//---------------------------------------------------------------------------- +// Procedure: VarGetNvramName +// +// Description: function to get the NvRam Variable Name +// +// Input: CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size +// +// Output: Name String +// +//---------------------------------------------------------------------------- +// +VOID *VarGetNvramName( CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size ) +{ + VOID *buffer = NULL; + UINT32 attrib = 0; + EFI_STATUS Status = EFI_UNSUPPORTED; + + // NO GET Functionality is taken care by VarGetNvram() + + if ( attributes != NULL ) + { + attrib = *attributes; + } + + Status = UefiFormCallbackNVRead(name, guid, &attrib, size, &buffer); + + if(EFI_ERROR(Status)) + { + Status = gRT->GetVariable( + name, + guid, + &attrib, + size, + buffer + ); + + if ( Status != EFI_BUFFER_TOO_SMALL ) + return buffer; + + buffer = EfiLibAllocateZeroPool ( *size + 1); + if ( buffer == NULL ) + return buffer; + + Status = gRT->GetVariable( + name, + guid, + &attrib, + size, + buffer + ); + } + + if ( EFI_ERROR( Status ) ) + MemFreePointer( (VOID *)&buffer ); + + if ( attributes != NULL ) + *attributes = attrib; + + return buffer; +} + +// +//---------------------------------------------------------------------------- +// Procedure: VarSetNvramName +// +// Description: function to Set the NvRam Variable Name +// +// Input: CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, +// VOID *buffer, UINTN *size +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS VarSetNvramName( CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size ) +{ + EFI_STATUS Status = EFI_UNSUPPORTED; + + // NO SET Functionality is taken care by VarSetNvram() + + Status = UefiFormCallbackNVWrite(name, guid, attributes, buffer, size); + + if(EFI_ERROR(Status ) ) + Status = gRT->SetVariable( + name, + guid, + attributes, + size, + buffer + ); + + return(Status); +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** -- cgit v1.2.3