X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Vlv2TbltDevicePkg%2FLibrary%2FPlatformBdsLib%2FBdsPlatform.c;h=c25e1d301a342704660bf58abff04e2afe8f56ad;hp=82ad974dc2dfff1ebf0b349477952195e238d526;hb=af7bc37a001f0a34dc273c78e3220dcfc2ef8869;hpb=b52e697b2a68e37e973653877733484ad2f65c29 diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c index 82ad974dc2..c25e1d301a 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c @@ -1,15 +1,15 @@ /** @file - Copyright (c) 2004 - 2016, 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 that accompanies this distribution. - The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - + Copyright (c) 2004 - 2018, 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 that 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: @@ -27,7 +27,7 @@ Abstract: #include "SetupMode.h" #include #include -#include +#include #include #include #include @@ -45,6 +45,9 @@ Abstract: #include #include +#include +#include + EFI_GUID *ConnectDriverTable[] = { &gEfiMmioDeviceProtocolGuid, &gEfiI2cMasterProtocolGuid, @@ -181,6 +184,11 @@ InstallReadyToLock ( ); ASSERT_EFI_ERROR (Status); + // + // Signal EndOfDxe PI Event + // + EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); + Handle = NULL; Status = gBS->InstallProtocolInterface ( &Handle, @@ -209,7 +217,7 @@ ShellImageCallback ( // BDS Platform Functions // /** - Platform Bds init. Incude the platform firmware vendor, revision + Platform Bds init. Include the platform firmware vendor, revision and so crc check. @param VOID @@ -226,11 +234,6 @@ PlatformBdsInit ( EFI_STATUS Status; EFI_EVENT ShellImageEvent; EFI_GUID ShellEnvProtocol = SHELL_ENVIRONMENT_INTERFACE_PROTOCOL; - - // - // Signal EndOfDxe PI Event - // - EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); #ifdef __GNUC__ SerialPortWrite((UINT8 *)">>>>BdsEntry[GCC]\r\n", 19); @@ -310,7 +313,7 @@ GetGopDevicePath ( } // - // Try to connect this handle, so that GOP dirver could start on this + // Try to connect this handle, so that GOP driver could start on this // device and create child handles with GraphicsOutput Protocol installed // on them, then we get device paths of these child handles and select // them as possible console device. @@ -427,7 +430,7 @@ GetGopDevicePath ( // In current implementation, we only enable one of the child handles // as console device, i.e. sotre one of the child handle's device // path to variable "ConOut" - // In futhure, we could select all child handles to be console device + // In future, we could select all child handles to be console device // *GopDevicePath = TempDevicePath; } @@ -780,7 +783,7 @@ UpdateConsoleResolution( Connect the predefined platform default console device. Always try to find and enable the vga device if have. - @param PlatformConsole Predfined platform default console device array. + @param PlatformConsole Predefined platform default console device array. @retval EFI_SUCCESS Success connect at least one ConIn and ConOut device, there must have one ConOut device is @@ -819,7 +822,7 @@ PlatformBdsConnectConsole ( if (VarConout == NULL || VarConin == NULL) { // // Have chance to connect the platform default console, - // the platform default console is the minimue device group + // the platform default console is the minimum device group // the platform should support // while (PlatformConsole[Index].DevicePath != NULL) { @@ -866,7 +869,7 @@ PlatformBdsConnectConsole ( } /** - Connect with predeined platform connect sequence, + Connect with predefined platform connect sequence, the OEM/IBV can customize with their own connect sequence. @param None. @@ -1568,7 +1571,7 @@ PlatformBdsLibEnumerateAllBootOption ( /** - The function will excute with as the platform policy, current policy + The function will execute with as the platform policy, current policy is driven by boot mode. IBV/OEM can customize this code for their specific policy action. @@ -1585,7 +1588,7 @@ EFIAPI PlatformBdsPolicyBehavior ( IN OUT LIST_ENTRY *DriverOptionList, IN OUT LIST_ENTRY *BootOptionList, - IN PROCESS_CAPSULES ProcessCapsules, + IN PROCESS_CAPSULES BdsProcessCapsules, IN BASEM_MEMORY_TEST BaseMemoryTest ) { @@ -1594,11 +1597,8 @@ PlatformBdsPolicyBehavior ( EFI_BOOT_MODE BootMode; BOOLEAN DeferredImageExist; UINTN Index; - CHAR16 CapsuleVarName[36]; - CHAR16 *TempVarName; SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; - BOOLEAN SetVariableFlag; PLATFORM_PCI_DEVICE_PATH *EmmcBootDevPath; EFI_GLOBAL_NVS_AREA_PROTOCOL *GlobalNvsArea; EFI_HANDLE FvProtocolHandle; @@ -1612,13 +1612,14 @@ PlatformBdsPolicyBehavior ( BOOLEAN IsFirstBoot; UINT16 *BootOrder; UINTN BootOrderSize; + ESRT_MANAGEMENT_PROTOCOL *EsrtManagement; Timeout = PcdGet16 (PcdPlatformBootTimeOut); if (Timeout > 10 ) { //we think the Timeout variable is corrupted Timeout = 10; } - + VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( NORMAL_SETUP_NAME, @@ -1639,7 +1640,7 @@ PlatformBdsPolicyBehavior ( &SystemConfiguration ); ASSERT_EFI_ERROR (Status); - } + } // // Load the driver option as the driver option list @@ -1651,37 +1652,6 @@ PlatformBdsPolicyBehavior ( // BootMode = GetBootModeHob(); - // - // Clear all the capsule variables CapsuleUpdateData, CapsuleUpdateData1, CapsuleUpdateData2... - // as early as possible which will avoid the next time boot after the capsule update - // will still into the capsule loop - // - StrCpy (CapsuleVarName, EFI_CAPSULE_VARIABLE_NAME); - TempVarName = CapsuleVarName + StrLen (CapsuleVarName); - Index = 0; - SetVariableFlag = TRUE; - while (SetVariableFlag) { - if (Index > 0) { - UnicodeValueToString (TempVarName, 0, Index, 0); - } - Status = gRT->SetVariable ( - CapsuleVarName, - &gEfiCapsuleVendorGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0, - (VOID *)NULL - ); - if (EFI_ERROR (Status)) { - // - // There is no capsule variables, quit - // - SetVariableFlag = FALSE; - continue; - } - Index++; - } - // // No deferred images exist by default // @@ -1733,6 +1703,11 @@ PlatformBdsPolicyBehavior ( } } + Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtManagement); + if (EFI_ERROR(Status)) { + EsrtManagement = NULL; + } + switch (BootMode) { case BOOT_WITH_MINIMAL_CONFIGURATION: @@ -1820,15 +1795,20 @@ PlatformBdsPolicyBehavior ( TcgPhysicalPresenceLibProcessRequest(); #endif #ifdef FTPM_ENABLE - TrEEPhysicalPresenceLibProcessRequest(NULL); + Tcg2PhysicalPresenceLibProcessRequest(NULL); #endif + + if (EsrtManagement != NULL) { + EsrtManagement->LockEsrtRepository(); + } + // // Close boot script and install ready to lock // InstallReadyToLock (); // - // Give one chance to enter the setup if we + // Give one chance to enter the setup if we // select Gummiboot "Reboot Into Firmware Interface" and Fast Boot is enabled. // BootIntoFirmwareInterface(); @@ -1863,6 +1843,10 @@ PlatformBdsPolicyBehavior ( } } + if (EsrtManagement != NULL) { + EsrtManagement->LockEsrtRepository(); + } + // // Close boot script and install ready to lock // @@ -1887,6 +1871,17 @@ PlatformBdsPolicyBehavior ( // PlatformBdsConnectConsole (gPlatformConsole); PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest); + EnableQuietBoot (PcdGetPtr(PcdLogoFile)); + + DEBUG((DEBUG_INFO, "ProcessCapsules Before EndOfDxe......\n")); + ProcessCapsules (); + DEBUG((DEBUG_INFO, "ProcessCapsules Done\n")); + + // + // Close boot script and install ready to lock + // + InstallReadyToLock (); + BdsLibConnectAll (); // @@ -1903,12 +1898,13 @@ PlatformBdsPolicyBehavior ( } } - // - // Close boot script and install ready to lock - // - InstallReadyToLock (); + if (EsrtManagement != NULL) { + EsrtManagement->SyncEsrtFmp(); + } - ProcessCapsules (BOOT_ON_FLASH_UPDATE); + DEBUG((DEBUG_INFO, "ProcessCapsules After ConnectAll......\n")); + ProcessCapsules(); + DEBUG((DEBUG_INFO, "ProcessCapsules Done\n")); break; case BOOT_IN_RECOVERY_MODE: @@ -2010,8 +2006,12 @@ FULL_CONFIGURATION: TcgPhysicalPresenceLibProcessRequest(); #endif #ifdef FTPM_ENABLE - TrEEPhysicalPresenceLibProcessRequest(NULL); + Tcg2PhysicalPresenceLibProcessRequest(NULL); #endif + + if (EsrtManagement != NULL) { + EsrtManagement->SyncEsrtFmp(); + } // // Close boot script and install ready to lock // @@ -2029,7 +2029,7 @@ FULL_CONFIGURATION: PlatformBdsEnterFrontPageWithHotKey (Timeout, FALSE); // - // Give one chance to enter the setup if we + // Give one chance to enter the setup if we // select Gummiboot "Reboot Into Firmware Interface" // BootIntoFirmwareInterface(); @@ -2047,7 +2047,7 @@ FULL_CONFIGURATION: return; } - + break; } @@ -2163,7 +2163,6 @@ BdsLockFv ( EFI_FV_BLOCK_MAP_ENTRY *BlockMap; EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_PHYSICAL_ADDRESS BaseAddress; - UINT8 Data; UINT32 BlockLength; UINTN Index; @@ -2174,7 +2173,7 @@ BdsLockFv ( while ((BlockMap->NumBlocks != 0) && (BlockMap->Length != 0)) { BlockLength = BlockMap->Length; for (Index = 0; Index < BlockMap->NumBlocks; Index++) { - Data = MmioOr8 ((UINTN) BaseAddress, 0x03); + MmioOr8 ((UINTN) BaseAddress, 0x03); BaseAddress += BlockLength; } BlockMap++; @@ -2413,6 +2412,12 @@ ShowProgressHotKey ( EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color; UINT32 GpioValue; + CHAR16 *TmpStr1; + CHAR16 *TmpStr2; + CHAR16 *TmpStr3; + UINTN TmpStrSize; + VOID *Buffer; + UINTN Size; if (TimeoutDefault == 0) { return EFI_TIMEOUT; @@ -2436,10 +2441,76 @@ ShowProgressHotKey ( SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0); SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff); + TmpStr2 = NULL; + TmpStr3 = NULL; + + // + // Check if the platform is using test key. + // + Status = GetSectionFromAnyFv( + PcdGetPtr(PcdEdkiiRsa2048Sha256TestPublicKeyFileGuid), + EFI_SECTION_RAW, + 0, + &Buffer, + &Size + ); + if (!EFI_ERROR(Status)) { + if ((Size == PcdGetSize(PcdRsa2048Sha256PublicKeyBuffer)) && + (CompareMem(Buffer, PcdGetPtr(PcdRsa2048Sha256PublicKeyBuffer), Size) == 0)) { + TmpStr2 = L"WARNING: Recovery Test Key is used.\r\n"; + if (DebugAssertEnabled()) { + DEBUG ((DEBUG_INFO, "\n\nWARNING: Recovery Test Key is used.\n")); + } else { + SerialPortWrite((UINT8 *)"\n\nWARNING: Recovery Test Key is used.", sizeof("\n\nWARNING: Recovery Test Key is used.")); + } + PcdSetBoolS(PcdTestKeyUsed, TRUE); + } + FreePool(Buffer); + } + Status = GetSectionFromAnyFv( + PcdGetPtr(PcdEdkiiPkcs7TestPublicKeyFileGuid), + EFI_SECTION_RAW, + 0, + &Buffer, + &Size + ); + if (!EFI_ERROR(Status)) { + if ((Size == PcdGetSize(PcdPkcs7CertBuffer)) && + (CompareMem(Buffer, PcdGetPtr(PcdPkcs7CertBuffer), Size) == 0)) { + TmpStr3 = L"WARNING: Capsule Test Key is used.\r\n"; + if (DebugAssertEnabled()) { + DEBUG ((DEBUG_INFO, "\n\nWARNING: Capsule Test Key is used.\r\n")); + } else { + SerialPortWrite((UINT8 *)"\n\nWARNING: Capsule Test Key is used.", sizeof("\n\nWARNING: Capsule Test Key is used.")); + } + PcdSetBoolS(PcdTestKeyUsed, TRUE); + } + FreePool(Buffer); + } + // // Clear the progress status bar first // - TmpStr = L"Start boot option, Press or to enter setup page."; + TmpStr1 = L"Start boot option, Press or to enter setup page.\r\n"; + TmpStrSize = StrSize(TmpStr1); + if (TmpStr2 != NULL) { + TmpStrSize += StrSize(TmpStr2); + } + if (TmpStr3 != NULL) { + TmpStrSize += StrSize(TmpStr3); + } + TmpStr = AllocatePool (TmpStrSize); + if (TmpStr == NULL) { + TmpStr = TmpStr1; + } else { + StrCpyS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr1); + if (TmpStr2 != NULL) { + StrCatS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr2); + } + if (TmpStr3 != NULL) { + StrCatS(TmpStr, TmpStrSize/sizeof(CHAR16), TmpStr3); + } + } PlatformBdsShowProgress (Foreground, Background, TmpStr, Color, 0, 0); TimeoutRemain = TimeoutDefault; @@ -2572,6 +2643,8 @@ PlatformBdsEnterFrontPageWithHotKey ( { EFI_STATUS Status; + EFI_STATUS LogoStatus; + EFI_BOOT_LOGO_PROTOCOL *BootLogo; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut; UINTN BootTextColumn; @@ -2651,6 +2724,14 @@ PlatformBdsEnterFrontPageWithHotKey ( gST->ConOut->EnableCursor (gST->ConOut, TRUE); gST->ConOut->ClearScreen (gST->ConOut); + // + // Boot Logo is corrupted, report it using Boot Logo protocol. + // + LogoStatus = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo); + if (!EFI_ERROR (LogoStatus) && (BootLogo != NULL)) { + BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0); + } + if (EFI_ERROR (Status)) { // // Timeout or user press enter to continue @@ -2658,6 +2739,7 @@ PlatformBdsEnterFrontPageWithHotKey ( goto Exit; } } + // // Install BM HiiPackages. // Keep BootMaint HiiPackage, so that it can be covered by global setting. @@ -2840,7 +2922,7 @@ PlatformBdsConnectSimpleConsole ( if (VarConout == NULL || VarConin == NULL) { // // Have chance to connect the platform default console, - // the platform default console is the minimue device group + // the platform default console is the minimum device group // the platform should support // while (PlatformConsole[Index].DevicePath != NULL) {