alder_lake_bios/Intel/AlderLake/AlderLakePlatSamplePkg/Setup/PlatformSetup.c

1954 lines
57 KiB
C

/** @file
;******************************************************************************
;* Copyright (c) 2012 - 2020, Insyde Software Corp. All Rights Reserved.
;*
;* You may not reproduce, distribute, publish, display, perform, modify, adapt,
;* transmit, broadcast, present, recite, release, license or otherwise exploit
;* any part of this publication in any form, by any means, without the prior
;* written permission of Insyde Software Corporation.
;*
;******************************************************************************
*/
/** @file
Platform Setup Routines
@copyright
INTEL CONFIDENTIAL
Copyright 2010 - 2021 Intel Corporation.
The source code contained or described herein and all documents related to the
source code ("Material") are owned by Intel Corporation or its suppliers or
licensors. Title to the Material remains with Intel Corporation or its suppliers
and licensors. The Material may contain trade secrets and proprietary and
confidential information of Intel Corporation and its suppliers and licensors,
and is protected by worldwide copyright and trade secret laws and treaty
provisions. No part of the Material may be used, copied, reproduced, modified,
published, uploaded, posted, transmitted, distributed, or disclosed in any way
without Intel's prior express written permission.
No license under any patent, copyright, trade secret or other intellectual
property right is granted to or conferred upon you by disclosure or delivery
of the Materials, either expressly, by implication, inducement, estoppel or
otherwise. Any license under such intellectual property rights must be
express and approved by Intel in writing.
Unless otherwise agreed by Intel in writing, you may not remove or alter
this notice or any other notice embedded in Materials by Intel or
Intel's suppliers or licensors in any way.
This file contains a 'Sample Driver' and is licensed as such under the terms
of your license agreement with Intel or your vendor. This file may be modified
by the user, subject to the additional terms of the license agreement.
@par Specification Reference:
**/
//[-start-200215-IB06462109-remove]//
//#include "SetupPrivate.h"
//[-end-200215-IB06462109-remove]//
#include <Library/PciSegmentLib.h>
#include <Guid/GlobalVariable.h>
#include <Protocol/Wdt.h>
#include <Library/BaseMemoryLib.h>
#include <Protocol/HiiString.h>
#include <Txt.h>
#include <TxtInfoHob.h>
#include <IndustryStandard/SmBios.h>
#include <Protocol/Smbios.h>
#include <PlatformBoardId.h>
#include <Protocol/I2cIo.h>
#include <Library/GpioLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Protocol/MePlatformGetResetType.h>
#include <Protocol/UsbIo.h>
#include <IndustryStandard/Usb.h>
#include <Library/GbeLib.h>
#include <Library/PeiDxeBoardIdsLib.h>
#include <CpuPcieHob.h>
#include <BootStateLib.h>
//
// ME/AMT Protocol
//
#include <Protocol/HeciProtocol.h>
#include "MeSetup.h"
#include <CoreBiosMsg.h>
#include <IccSetupData.h>
#include <Library/DxeMeLib.h>
#include <Register/PchRegs.h>
#include <Uefi/UefiSpec.h>
#include <Protocol/PlatformSpecificResetFilter.h>
#include <Library/UefiRuntimeLib.h>
#include <PchResetPlatformSpecific.h>
#include <Library/EcLib.h>
//[-start-200215-IB06462109-add]//
#include "IccSetup.h"
SETUP_DATA mSetupData;
//[-end-200215-IB06462109-add]//
extern BOOLEAN mMeReset;
extern BOOLEAN gIccReset;
//
// BCD to Decimal Conversion
//
#define BCD_TO_DECIMAL(A) (((((A) >> 4) & 0xF) * 10) + ((A) & 0xF))
GLOBAL_REMOVE_IF_UNREFERENCED EFI_HII_HANDLE gPsHiiHandle = INVALID_HII_HANDLE;
//
// LAN PHY Revision definitions
//
#define LAN_PHY_REV_TC 0xA0
#define LAN_PHY_REV_A0 0xA1
#define LAN_PHY_REV_A1 0xA2
#define LAN_PHY_REV_A2 0xA3
#define LAN_PHY_REV_A3 0xA4
#define LAN_PHY_REV_B1 0xA5
#define LAN_PHY_REV_B2 0xA6
typedef struct _LAN_PHY_INFO {
UINT16 LanPhyRev;
char *LanPhyString;
} LAN_PHY_INFO;
#pragma pack(push, 1)
typedef struct {
UINT8 ReportId;
struct
{
UINT16 Width;
UINT16 Height;
} Dimensions;
UINT8 BitDepth;
UINT8 Orientation : 2;
UINT8 SupportsCS : 1;
UINT8 : 5; // padding
UINT8 NumberOfBuffers;
UINT8 NumberOfButtons;
UINT8 NumberOfFingers;
UINT8 NumberOfFrontLights;
UINT32 FirmwareVersion;
UINT32 PipSizeInBytes;
} HID_FEATURE_REPORT_DISPLAY_ATTRIBUTES;
#pragma pack(pop)
LAN_PHY_INFO LanPhyInfoTable[] = {
{LAN_PHY_REV_TC, "(TC Stepping)"},
{LAN_PHY_REV_A0, "(A0 Stepping)"},
{LAN_PHY_REV_A1, "(A1 Stepping)"},
{LAN_PHY_REV_A2, "(A2 Stepping)"},
{LAN_PHY_REV_A3, "(A3 Stepping)"},
{LAN_PHY_REV_B1, "(B1 Stepping)"},
{LAN_PHY_REV_B2, "(B2 Stepping)"}
};
/**
Determine if TXT supported on a platform based on CPU and PCH TXT capability
@retval True if TXT supported on the platform
**/
BOOLEAN
IsTxtSupportedOnPlatform(
VOID
)
{
TXT_INFO_HOB *HobList;
TXT_INFO_DATA *TxtInfoData;
HobList = NULL;
TxtInfoData = NULL;
///
/// Find TXT HOB
///
HobList = (TXT_INFO_HOB *) GetFirstGuidHob (&gTxtInfoHobGuid);
if (HobList == NULL) {
return FALSE;
}
TxtInfoData = &HobList->Data;
if (TxtInfoData == NULL) {
return FALSE;
}
if (TxtInfoData->ProcessorIsTxtCapable && TxtInfoData->ChipsetIsTxtCapable)
return TRUE;
else
return FALSE;
}
VOID
EFIAPI
CallbackGetLanPhyRevision (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
Acquire the string associated with the Index from smbios structure and return it.
The caller is responsible for free the string buffer.
@param OptionalStrStart The start position to search the string
@param Index The index of the string to extract
@param String The string that is extracted
@retval EFI_SUCCESS The function returns EFI_SUCCESS always.
**/
EFI_STATUS
GetSmBiosStringByIndex (
IN CHAR8 *OptionalStrStart,
IN UINT8 Index,
OUT CHAR8 **String
)
{
UINTN StrSize;
if (Index == 0) {
*String = AllocateZeroPool (sizeof (CHAR8));
return EFI_SUCCESS;
}
StrSize = 0;
do {
Index--;
OptionalStrStart += StrSize;
StrSize = AsciiStrSize (OptionalStrStart);
} while (OptionalStrStart[StrSize] != 0 && Index != 0);
*String = AllocatePool (StrSize);
ASSERT (*String != NULL);
if (*String != NULL) {
CopyMem (*String, OptionalStrStart, StrSize);
}
return EFI_SUCCESS;
}
/**
Platform Setup Callback
@param[in] Event - Event based on EFI_SETUP_ENTER_GUID.
@param[in] Context - Pointer to the notification function's context.
**/
VOID
EFIAPI
PlatformSetupCallback (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
UINT8 StrIndex;
CHAR8 *NewString;
UINT8 RevisionHigh;
UINT8 RevisionLow;
BOOLEAN BoardInfo;
BOOLEAN BiosInfo;
EFI_SMBIOS_HANDLE SmbiosHandle;
EFI_SMBIOS_PROTOCOL *Smbios;
SMBIOS_TABLE_TYPE2 *Type2Record;
SMBIOS_TABLE_TYPE0 *Type0Record;
EFI_SMBIOS_TABLE_HEADER *Record;
UINTN Index;
EFI_STRING BoardNameString;
SETUP_DATA SetupData;
UINT32 VarAttributes;
UINTN VarSize;
gBS->CloseEvent (Event);
BoardInfo = FALSE;
BiosInfo = FALSE;
Status = gBS->LocateProtocol (
&gEfiSmbiosProtocolGuid,
NULL,
(VOID **) &Smbios
);
if (EFI_ERROR (Status)) {
return ;
}
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
do {
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
if (EFI_ERROR (Status)) {
break;
}
if (Record->Type == EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION) {
Type2Record = (SMBIOS_TABLE_TYPE2 *) Record;
//Update Board Name
StrIndex = Type2Record->ProductName;
GetSmBiosStringByIndex ((CHAR8*)((UINT8*)Type2Record + Type2Record->Hdr.Length), StrIndex, &NewString);
InitString (gPsHiiHandle,STRING_TOKEN (STR_BOARD_NAME_VALUE),L"%a%",NewString);
FreePool (NewString);
BoardNameString = HiiGetString (gPsHiiHandle, STRING_TOKEN (STR_BOARD_NAME_VALUE), NULL);
//Update Board ID
if (BoardNameString != NULL) {
for (Index = 0; Index < mSizeOfmBoardIndex; Index++) {
if (StrCmp((CHAR16*)BoardNameString, mBoardIdIndex[Index]) == 0) {
InitString (gPsHiiHandle,STRING_TOKEN (STR_BOARD_ID_VALUE),L"0x%X",Index);
break;
}
}
}
//Update Fab ID
StrIndex = Type2Record->Version;
GetSmBiosStringByIndex ((CHAR8*)((UINT8*)Type2Record + Type2Record->Hdr.Length), StrIndex, &NewString);
InitString (gPsHiiHandle,STRING_TOKEN (STR_FAB_ID_VALUE),L"%a%",NewString);
FreePool (NewString);
BoardInfo = TRUE;
}
if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
//Update EC FirmwareMajorRelease
RevisionHigh = Type0Record->EmbeddedControllerFirmwareMajorRelease;
//Update EC FirmwareMinorRelease
RevisionLow = Type0Record->EmbeddedControllerFirmwareMinorRelease;
InitString (gPsHiiHandle,STRING_TOKEN (STR_CHIP_EC_REV_VALUE),L"%02d%a%02d",RevisionHigh,".",RevisionLow);
BiosInfo = TRUE;
}
} while (!(BoardInfo && BiosInfo));
//Update eSPI Flash Sharing Mode Info
switch (PcdGet8 (PcdEcEspiFlashSharingMode)) {
case 1:
InitString (gPsHiiHandle,STRING_TOKEN (STR_ESPI_SHARING_MODE_VALUE),L"%s",L"SAF");
break;
case 2:
InitString (gPsHiiHandle,STRING_TOKEN (STR_ESPI_SHARING_MODE_VALUE),L"%s",L"MAF");
break;
case 0:
default:
InitString (gPsHiiHandle,STRING_TOKEN (STR_ESPI_SHARING_MODE_VALUE),L"%s",L"G3");
}
//Update eSPI PECI Mode Info
VarSize = sizeof (SETUP_DATA);
Status = gRT->GetVariable (
L"Setup",
&gSetupVariableGuid,
&VarAttributes,
&VarSize,
&SetupData
);
if (!EFI_ERROR (Status)) {
switch (SetupData.EcPeciMode) {
case 1:
InitString (gPsHiiHandle,STRING_TOKEN (STR_READ_PECI_MODE_VALUE),L"%s",L"PECI over eSPI mode");
break;
case 0:
default:
InitString (gPsHiiHandle,STRING_TOKEN (STR_READ_PECI_MODE_VALUE),L"%s",L"Legacy PECI mode");
}
}
}
VOID
UpdateSetUpVarRevisionString (
EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
SA_SETUP SaSetup;
CPU_SETUP CpuSetup;
PCH_SETUP PchSetup;
ME_SETUP MeSetup;
SI_SETUP SiSetup;
SETUP_DATA SetupData;
UINTN VarSize;
VarSize = sizeof (ME_SETUP);
Status = gRT->GetVariable (
L"MeSetup",
&gMeSetupVariableGuid,
NULL,
&VarSize,
&MeSetup
);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_ME_SETUP_REVISION_VALUE),
L"%d",
MeSetup.Revision
);
}
VarSize = sizeof (CPU_SETUP);
Status = gRT->GetVariable (
L"CpuSetup",
&gCpuSetupVariableGuid,
NULL,
&VarSize,
&CpuSetup
);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_CPU_SETUP_REVISION_VALUE),
L"%d",
CpuSetup.Revision
);
}
VarSize = sizeof (SA_SETUP);
Status = gRT->GetVariable (
L"SaSetup",
&gSaSetupVariableGuid,
NULL,
&VarSize,
&SaSetup
);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_SA_SETUP_REVISION_VALUE),
L"%d",
SaSetup.Revision
);
}
VarSize = sizeof (PCH_SETUP);
Status = gRT->GetVariable (
L"PchSetup",
&gPchSetupVariableGuid,
NULL,
&VarSize,
&PchSetup
);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_PCH_SETUP_REVISION_VALUE),
L"%d",
PchSetup.Revision
);
}
VarSize = sizeof (SI_SETUP);
Status = gRT->GetVariable (
L"SiSetup",
&gSiSetupVariableGuid,
NULL,
&VarSize,
&SiSetup
);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_SI_SETUP_REVISION_VALUE),
L"%d",
SiSetup.Revision
);
}
VarSize = sizeof (SETUP_DATA);
Status = gRT->GetVariable (
L"Setup",
&gSetupVariableGuid,
NULL,
&VarSize,
&SetupData
);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_SETUP_DATA_REVISION_VALUE),
L"%d",
SetupData.Revision
);
}
}
/**
Update PD Information
@param[in] HiiHandle HiiHandle Handle to HII database
**/
VOID
UpdatePDInformation (
IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
UINT8 DataBuffer [PD_INFORMATION_LEN];
DEBUG ((DEBUG_INFO, "<UpdatePDInformation> - Start\n"));
Status = EFI_NOT_READY;
//
// PD 0
//
SetMem (DataBuffer, PD_INFORMATION_LEN, 0);
if (PcdGetBool (PcdUsbcEcPdNegotiation)) {
Status = GetPDInformation (0, DataBuffer);
}
//
// if success then update string
//
if (Status == EFI_SUCCESS) {
switch (PcdGet8 (PcdTcssPdType)) {
case TcssPdTypeCypress:
DEBUG ((DEBUG_INFO, "PD type is Cypress\n"));
// Update information for Cypress TCSS PD
InitString (
HiiHandle,
STRING_TOKEN (STR_PD0_APPLICATION_NAME_VALUE),
L"%c%c",
DataBuffer [0],
DataBuffer [1]
);
InitString (
HiiHandle,
STRING_TOKEN (STR_PD0_EXTERNAL_CIRCUIT_SPECIFIC_VERSION_VALUE),
L"%d",
DataBuffer [2]
);
InitString (
HiiHandle,
STRING_TOKEN (STR_PD0_VERSION_VALUE),
L"%d.%d",
((DataBuffer [3] >> 4) & 0x0F),
(DataBuffer [3] & 0x0F)
);
break;
case TcssPdTypeTi:
DEBUG ((DEBUG_INFO, "PD type is TI\n"));
// Update information for TI TCSS PD
InitString (
HiiHandle,
STRING_TOKEN (STR_PD0_VERSION_VALUE),
L"%02X%02X.%02X.%02X",
DataBuffer [3],
DataBuffer [2],
DataBuffer [1],
DataBuffer [0]
);
break;
default:
DEBUG ((DEBUG_WARN, "PD type unknown\n"));
break;
}
}
//
// PD 1
//
SetMem (DataBuffer, PD_INFORMATION_LEN, 0);
if (PcdGetBool (PcdUsbcEcPdNegotiation)) {
Status = GetPDInformation (1, DataBuffer);
}
//
// if success then update string
//
if (Status == EFI_SUCCESS) {
switch (PcdGet8 (PcdTcssPdType)) {
case TcssPdTypeCypress:
// Update information for Cypress TCSS PD
InitString (
HiiHandle,
STRING_TOKEN (STR_PD1_APPLICATION_NAME_VALUE),
L"%c%c",
DataBuffer [0],
DataBuffer [1]
);
InitString (
HiiHandle,
STRING_TOKEN (STR_PD1_EXTERNAL_CIRCUIT_SPECIFIC_VERSION_VALUE),
L"%d",
DataBuffer [2]
);
InitString (
HiiHandle,
STRING_TOKEN (STR_PD1_VERSION_VALUE),
L"%d.%d",
((DataBuffer [3] >> 4) & 0x0F),
(DataBuffer [3] & 0x0F)
);
break;
case TcssPdTypeTi:
// Update information for TI TCSS PD
InitString (
HiiHandle,
STRING_TOKEN (STR_PD1_VERSION_VALUE),
L"%02X%02X.%02X.%02X",
DataBuffer [3],
DataBuffer [2],
DataBuffer [1],
DataBuffer [0]
);
break;
default:
break;
}
}
DEBUG ((DEBUG_INFO, "<UpdatePDInformation> - End\n"));
}
/**
Initialize Platform Strings
@param[in] HiiHandle HiiHandle Handle to HII database
@param[in] Class Indicates the setup class
**/
VOID
InitPlatformStrings (
EFI_HII_HANDLE HiiHandle,
UINT16 Class
)
{
EFI_STATUS Status;
UINTN VariableSize;
//[-start-201202-IB18410025-remove]//
// EFI_BOOT_MODE BootMode;
//[-start-201202-IB18410025-remove]//
ME_INFO_SETUP_DATA MeInfoSetupData;
UINT8 *FwMeSku[] = {
(UINT8 *) ME_FW_IMAGE_TYPE_CONSUMER_STRING,
(UINT8 *) ME_FW_IMAGE_TYPE_CORPORATE_STRING,
(UINT8 *) ME_FW_IMAGE_TYPE_UNIDENTIFIED_STRING,
};
UINT8 *MeFwSkuValue;
EFI_EVENT SetupEnterEvent;
VOID *pSetupRegistration;
EFI_EVENT PlatformSetupEvent;
VOID *Registration;
BOOLEAN IsTriggeredAtSetupMenu;
CPU_PCIE_HOB *CpuPcieHob;
FLASH_PARTITION_DATA PartitionIdData;
VOID *TempProtocolPtr=NULL;
EFI_GUID XmlCliCommonGuid = {
0xbf030b10, 0x2d9b, 0x4e71, { 0xa0, 0xc4, 0xbc, 0x99, 0x10, 0x57, 0x9d, 0x40
}};
//[-start-200215-IB06462109-add]//
ME_SETUP MeSetup;
//[-end-200215-IB06462109-add]//
///
/// Get CpuPcieHob HOB
///
CpuPcieHob = NULL;
CpuPcieHob = (CPU_PCIE_HOB *)GetFirstGuidHob(&gCpuPcieHobGuid);
if (CpuPcieHob != NULL) {
InitString (
HiiHandle,
STRING_TOKEN (STR_DEKEL_FIRMWARE_VERSION_VALUE),
L"%d.%d",
CpuPcieHob->DekelFwVersionMajor,
CpuPcieHob->DekelFwVersionMinor
);
InitString (
HiiHandle,
STRING_TOKEN (STR_HSPHY_RECIPE_VERSION_VALUE),
L"%d.%d",
CpuPcieHob->HsPhyRecipeVersionMajor,
CpuPcieHob->HsPhyRecipeVersionMinor
);
InitString (
HiiHandle,
STRING_TOKEN (STR_HSPHY_FIRMWARE_VERSION_VALUE),
L"%d.%d.%d.%d.%d.%d",
CpuPcieHob->HsPhyFwProdMajor,
CpuPcieHob->HsPhyFwProdMinor,
CpuPcieHob->HsPhyFwHotFix,
CpuPcieHob->HsPhyFwBuild,
CpuPcieHob->HsPhyFwEvBitProgMajor,
CpuPcieHob->HsPhyFwEvBitProgMinor
);
}
//[-start-200215-IB06462109-add]//
VariableSize = sizeof (ME_SETUP);
Status = gRT->GetVariable (
L"MeSetup",
&gMeSetupVariableGuid,
NULL,
&VariableSize,
&MeSetup
);
ASSERT_EFI_ERROR (Status);
//[-end-200215-IB06462109-add]//
//[-start-190628-16990073-add]//
// if (Class == MAIN_FORM_SET_CLASS) {
if (Class == ADVANCED_FORM_SET_CLASS || Class == MAIN_FORM_SET_CLASS) {
DEBUG ((DEBUG_INFO, "<InitPlatformStrings>"));
//
// Preserve HiiHandle to access Strings in callbacks
//
// if (gPsHiiHandle == INVALID_HII_HANDLE) {
gPsHiiHandle = HiiHandle;
// }
//[-end-190628-16990073-add]//
VariableSize = sizeof (ME_INFO_SETUP_DATA);
Status = gRT->GetVariable (
L"MeInfoSetup",
&gMeInfoSetupGuid,
NULL,
&VariableSize,
&MeInfoSetupData
);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_ME_FW_REV_VALUE),
L"%d.%d.%d.%d",
MeInfoSetupData.MeMajor,
MeInfoSetupData.MeMinor,
MeInfoSetupData.MeHotFix,
MeInfoSetupData.MeBuildNo
);
}
//
// Check if InitPlatformStrings is triggered via mSetupEnterGuid
//
IsTriggeredAtSetupMenu = FALSE;
//[-start-201202-IB18410025-remove]//
// VariableSize = sizeof(SETUP_DATA);
// Status = gRT->GetVariable
// L"Setup",
// &gSystemConfigurationGuid,
// NULL,
// &VariableSize,
// &mSetupData
// );
// ASSERT_EFI_ERROR(Status);
//
// if (!EFI_ERROR (Status) && mSetupData.FastBoot) {
// BootMode = GetBootModeHob();
// if ((mSetupData.SkipHIIUpdate) &&
// ((BootMode == BOOT_WITH_MINIMAL_CONFIGURATION) ||
// (BootMode == BOOT_ON_S4_RESUME) ||
// (BootMode == BOOT_ASSUMING_NO_CONFIGURATION_CHANGES))) {
// IsTriggeredAtSetupMenu = TRUE;
// }
// }
//[-end-201202-IB18410025-remove]//
//
// Call routine to calculate LAN PHY Revision when entering Setup UI
//
if (IsTriggeredAtSetupMenu == TRUE) {
PlatformSetupCallback (NULL, NULL);
CallbackGetLanPhyRevision (NULL, NULL);
} else {
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
PlatformSetupCallback,
NULL,
&PlatformSetupEvent
);
ASSERT_EFI_ERROR (Status);
Status = gBS->RegisterProtocolNotify (
&gSetupEnterGuid,
PlatformSetupEvent,
&Registration
);
ASSERT_EFI_ERROR (Status);
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
CallbackGetLanPhyRevision,
NULL,
&SetupEnterEvent
);
ASSERT_EFI_ERROR(Status);
Status = gBS->RegisterProtocolNotify (
&gSetupEnterGuid,
SetupEnterEvent,
&pSetupRegistration
);
ASSERT_EFI_ERROR(Status);
}
if (mMeSetup.MeImageType == ME_IMAGE_CONSUMER_SKU_FW) {
MeFwSkuValue = FwMeSku[0];
} else if (mMeSetup.MeImageType == ME_IMAGE_CORPORATE_SKU_FW) {
MeFwSkuValue = FwMeSku[1];
} else {
MeFwSkuValue = FwMeSku[2];
}
InitString (
HiiHandle,
STRING_TOKEN (STR_ME_FW_SKU_VALUE),
L"%a",
MeFwSkuValue
);
Status = HeciGetImageFwVersionMsg (FTP_PARTITION_NAME_PMCP, &PartitionIdData);
if (!EFI_ERROR (Status)) {
InitString (
HiiHandle,
STRING_TOKEN (STR_PMC_FW_REV_VALUE),
L"%d.%d.%d.%d",
PartitionIdData.Version.Major,
PartitionIdData.Version.Minor,
PartitionIdData.Version.Hotfix,
PartitionIdData.Version.Build
);
}
//
// Platform/PCH TXT capability
//
if (IsTxtSupportedOnPlatform() == TRUE) {
InitString (
HiiHandle,
STRING_TOKEN (STR_PLATFORM_TXT_VALUE),
L"%a",
"Supported"
);
} else {
InitString (
HiiHandle,
STRING_TOKEN (STR_PLATFORM_TXT_VALUE),
L"%a",
"Unsupported"
);
}
//
// Production Type
//
if (MmioRead32(TXT_PUBLIC_BASE + 0x200) & BIT31) {
InitString (
HiiHandle,
STRING_TOKEN (STR_PRODUCTION_TYPE_VALUE),
L"%a",
"Production"
);
} else {
InitString (
HiiHandle,
STRING_TOKEN (STR_PRODUCTION_TYPE_VALUE),
L"%a",
"Pre-Production"
);
}
//
// if XmlCli Support is present bios will update the BoardID, FabID, KSC version and LanPhyversion without entering into setup
//
Status = gBS->LocateProtocol(&XmlCliCommonGuid, NULL, (VOID **)&TempProtocolPtr);
if ( EFI_ERROR (Status) ) { // XmlCliCommon not published.
DEBUG ((EFI_D_INFO, "XML_CLI: XmlCli Support Status: Disabled. \n"));
} else {
DEBUG ((EFI_D_INFO, "XML_CLI: XmlCli Support Status: Enabled. \n"));
PlatformSetupCallback (NULL, NULL);
CallbackGetLanPhyRevision (NULL, NULL);
}
//[-start-200218-IB14630322-remove]//
// } else if (Class == ADVANCED_FORM_SET_CLASS) {
//[-end-200218-IB14630322-remove]//
#if (FixedPcdGetBool(PcdAdlLpSupport) == 1)
DEBUG ((DEBUG_INFO, "<InitPlatformStrings> - Advanced Form\n"));
UpdatePDInformation (HiiHandle);
#endif //#if ((FixedPcdGetBool (PcdAdlLpSupport) == 1) || (FixedPcdGetBool (PcdRplsSupport) == 1))
}
//[-start-200215-IB06462109-remove]//
// UpdateSetUpVarRevisionString (HiiHandle);
//[-end-200215-IB06462109-remove]//
}
/**
Retrieves LAN PHY Revision
@param[in] Event - Event based on EFI_SETUP_ENTER_GUID.
@param[in] Context - Pointer to the notification function's context.
**/
VOID
EFIAPI
CallbackGetLanPhyRevision (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
UINT16 LanPhyRev;
UINTN Index;
BOOLEAN LanPhyRevisionUpdated;
LanPhyRev = 0;
LanPhyRevisionUpdated = FALSE;
//
// Get Phy Version
//
Status = GbeGetLanPhyRevision (&LanPhyRev);
if (Status == EFI_NOT_FOUND) {
return;
}
//
// Close event, so it will not be invoked again.
//
gBS->CloseEvent (Event);
if (EFI_ERROR (Status)) {
return;
}
//
// LAN PHY Revision
//
if (LanPhyRev) {
for (Index = 0; Index < (sizeof (LanPhyInfoTable) / sizeof (LAN_PHY_INFO)); Index++) {
if ((UINT8) LanPhyRev == LanPhyInfoTable[Index].LanPhyRev) {
InitString (
gPsHiiHandle,
STRING_TOKEN (STR_LAN_PHY_REV_VALUE),
L"%02x %a",
(UINT8) LanPhyRev,
LanPhyInfoTable[Index].LanPhyString
);
LanPhyRevisionUpdated = TRUE;
break;
}
}
if (LanPhyRevisionUpdated == FALSE) {
InitString (
gPsHiiHandle,
STRING_TOKEN (STR_LAN_PHY_REV_VALUE),
L"%02x",
(UINT8) LanPhyRev
);
}
}
return;
}
/**
Determines if Full Sku ME is present.
@retval TRUE if fullSku ME is present
**/
BOOLEAN
IsFullSkuMePresent (
VOID
)
{
EFI_STATUS Status;
HECI_PROTOCOL *Heci;
UINT32 MeMode;
BOOLEAN RetVal;
RetVal = FALSE;
Status = gBS->LocateProtocol (
&gHeciProtocolGuid,
NULL,
(VOID **) &Heci
);
if (!EFI_ERROR (Status)) {
Status = Heci->GetMeMode (&MeMode);
//
// ASSERT_EFI_ERROR (Status);
//
if (!EFI_ERROR (Status)) {
if (MeMode == ME_MODE_NORMAL) {
RetVal = TRUE;
}
}
}
return RetVal;
}
/**
Platform Reset function
@param[in] PlatformResetType Reset type aligned with EFI_RESET_TYPE
@retval EFI_RESET_TYPE final reset type aligned with EFI_RESET_TYPE
**/
EFI_RESET_TYPE
PlatformReset (
IN EFI_RESET_TYPE PlatformResetType
)
{
EFI_STATUS Status;
UINTN VariableSize;
//
// Reset Flag
//
BOOLEAN GlobalResetRequired = FALSE;
BOOLEAN PowerCycleResetRequired = FALSE;
SETUP_DATA CurrentData;
SETUP_DATA SetupData;
SA_SETUP SaCurrentData;
SA_SETUP SaSetup;
CPU_SETUP CpuCurrentData;
CPU_SETUP CpuSetup;
PCH_SETUP PchCurrentData;
PCH_SETUP PchSetup;
SI_SETUP SiSetup;
SI_SETUP SiCurrentData;
EFI_HANDLE Handle;
VariableSize = sizeof (SETUP_DATA);
Status = gRT->GetVariable (
L"Setup",
&gSetupVariableGuid,
NULL,
&VariableSize,
&SetupData
);
//
// ASSERT_EFI_ERROR (Status);
//
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (SA_SETUP);
Status = gRT->GetVariable (
L"SaSetup",
&gSaSetupVariableGuid,
NULL,
&VariableSize,
&SaSetup
);
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (CPU_SETUP);
Status = gRT->GetVariable (
L"CpuSetup",
&gCpuSetupVariableGuid,
NULL,
&VariableSize,
&CpuSetup
);
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (PCH_SETUP);
Status = gRT->GetVariable (
L"PchSetup",
&gPchSetupVariableGuid,
NULL,
&VariableSize,
&PchSetup
);
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (SI_SETUP);
Status = gRT->GetVariable(
L"SiSetup",
&gSiSetupVariableGuid,
NULL,
&VariableSize,
&SiSetup
);
if (EFI_ERROR(Status)) {
return PlatformResetType;
}
VariableSize = sizeof (SETUP_DATA);
Status = gRT->GetVariable (
L"ColdReset",
&gSetupVariableGuid,
NULL,
&VariableSize,
&CurrentData
);
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (SA_SETUP);
Status = gRT->GetVariable (
L"SaColdReset",
&gSaSetupVariableGuid,
NULL,
&VariableSize,
&SaCurrentData
);
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (CPU_SETUP);
Status = gRT->GetVariable (
L"CpuColdReset",
&gCpuSetupVariableGuid,
NULL,
&VariableSize,
&CpuCurrentData
);
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (PCH_SETUP);
Status = gRT->GetVariable (
L"PchColdReset",
&gPchSetupVariableGuid,
NULL,
&VariableSize,
&PchCurrentData
);
if (EFI_ERROR (Status)) {
return PlatformResetType;
}
VariableSize = sizeof (SI_SETUP);
Status = gRT->GetVariable(
L"SiColdReset",
&gSiSetupVariableGuid,
NULL,
&VariableSize,
&SiCurrentData
);
if (EFI_ERROR(Status)) {
return PlatformResetType;
}
//
// Checks if silicon setup variables has been modified
//
if (CompareMem(&PchSetup, &PchCurrentData, sizeof(PchSetup)) != 0 ||
CompareMem(&CpuSetup, &CpuCurrentData, sizeof(CpuSetup)) != 0 ||
CompareMem(&SaSetup, &SaCurrentData, sizeof(SaSetup)) != 0 ||
CompareMem(&SiSetup, &SiCurrentData, sizeof(SiSetup)) != 0
) {
//
// Install gPlatformConfigChangeProtocolGuid
//
Handle = NULL;
gBS->InstallProtocolInterface(
&Handle,
&gPlatformConfigChangeProtocolGuid,
EFI_NATIVE_INTERFACE,
NULL
);
}
//
// Clear PdtExist non-volatile variable to update PDT, when MPdtSupport(SensorBomId) option change in BIOS setup menu.
//
if (SetupData.MPdtSupport != CurrentData.MPdtSupport) {
gRT->SetVariable (
L"PdtExist",
&gPdtExistGuid,
0,
0,
NULL
);
}
//
// Change boot mode for critical setup questions.
//
if ((PchSetup.SataInterfaceMode != PchCurrentData.SataInterfaceMode) ||
(SetupData.EfiNetworkSupport != CurrentData.EfiNetworkSupport)
) {
//
// Delete BootState variable to force next boot is FullConfiguration boot
// Boot option enumeration only happens in FullConfiguration boot
//
UnsetBootState();
}
if ((SaSetup.EnableVtd != SaCurrentData.EnableVtd) ||
(PchSetup.PchHdAudio != PchCurrentData.PchHdAudio) ||
(CpuSetup.Txt != CpuCurrentData.Txt) ||
(SaSetup.GTTSize != SaCurrentData.GTTSize) ||
(SaSetup.IgdDvmt50PreAlloc != SaCurrentData.IgdDvmt50PreAlloc) ||
(SaSetup.MaxTolud != SaCurrentData.MaxTolud) ||
(SaSetup.InternalGraphics != SaCurrentData.InternalGraphics) ||
(SaSetup.PrimaryDisplay != SaCurrentData.PrimaryDisplay) ||
(SaSetup.SpdProfileSelected != SaCurrentData.SpdProfileSelected) ||
(CpuSetup.BiosGuardToolsInterface != CpuCurrentData.BiosGuardToolsInterface)
) {
PowerCycleResetRequired = TRUE;
}
if (mMeReset
) {
GlobalResetRequired = TRUE;
}
if (gIccReset) {
PowerCycleResetRequired = TRUE;
}
if (SetupData.EnablePcieTunnelingOverUsb4 != CurrentData.EnablePcieTunnelingOverUsb4) {
DEBUG ((DEBUG_INFO,"GlobalResetRequired = TRUE\n"));
GlobalResetRequired = TRUE;
}
if ((CpuSetup.ConfigTdpLevel != CpuCurrentData.ConfigTdpLevel) ||
(CpuSetup.ConfigTdpLock != CpuCurrentData.ConfigTdpLock) ||
(CpuSetup.Custom1TurboActivationRatio != CpuCurrentData.Custom1TurboActivationRatio) ||
(CpuSetup.Custom2TurboActivationRatio != CpuCurrentData.Custom2TurboActivationRatio) ||
(CpuSetup.Custom3TurboActivationRatio != CpuCurrentData.Custom3TurboActivationRatio)
) {
PowerCycleResetRequired = TRUE;
}
//
// CrashLog variable set in PMC needs a G3 or global reset to clear it up.
//
if ((SetupData.EnableCrashLog != CurrentData.EnableCrashLog) ||
(SetupData.CrashLogOnAllReset != CurrentData.CrashLogOnAllReset)) {
GlobalResetRequired = TRUE;
}
//
// Doesn't need to do platform special reset
//
if (GlobalResetRequired) {
return EfiResetPlatformSpecific;
} else if (PowerCycleResetRequired) {
return EfiResetCold;
}
return PlatformResetType;
}
VOID
InitBoardStrings (
EFI_HII_HANDLE HiiHandle,
UINT16 Class
)
{
return;
}
/**
ThermalFunctionCallback() is called when we enter Thermal Configuration Form
When "Enable All Thermal Functions" setup option value is changed then it updated
as below:
"Enable All Thermal Functions" is enabled it enables:
1. Memory Thermal Management
2. Active Trip Points
3. Critical Trip Points
"Enable All Thermal Functions" option is disabled then "Memory Thermal Management",
Active ,Critical Trip Points option is disabled
**/
EFI_STATUS
EFIAPI
ThermalFunctionCallback (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID KeyValue,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
SA_SETUP *SaSetup;
//[-start-200911-IB17040162-modify]//
SA_SETUP *MySaIfrNVData;
SETUP_DATA *SetupData;
SETUP_DATA *MySetupDataIfrNVData;
//[-end-200911-IB17040162-modify]//
UINTN VarSize;
EFI_STATUS Status;
EFI_STRING RequestString;
RequestString = NULL;
if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {
return EFI_UNSUPPORTED;
}
VarSize = sizeof (SA_SETUP);
SaSetup = AllocatePool (VarSize);
ASSERT (SaSetup != NULL);
if (SaSetup == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// "Enable All Thermal Functions" option is enabled then "Memory Thermal Management" option is enabled
// "Enable All Thermal Functions" option is disabled then "Memory Thermal Management" option is disabled
//
//[-start-200911-IB17040162-add]//
MySaIfrNVData = (SA_SETUP *)gRcSUBrowser->SaSUBrowserData;
CopyMem (SaSetup, MySaIfrNVData, VarSize);
//[-end-200911-IB17040162-add]//
Status = HiiGetBrowserData (&gSaSetupVariableGuid, L"SaSetup", VarSize, (UINT8 *) SaSetup);
ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
if(!(SaSetup->MemoryThermalManagement == Value->u8) ) {
SaSetup->MemoryThermalManagement = Value->u8;
RequestString = NULL;
RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SA_SETUP, MemoryThermalManagement),sizeof(SaSetup->MemoryThermalManagement));
if (RequestString != NULL) {
Status = HiiSetBrowserData (&gSaSetupVariableGuid, L"SaSetup", VarSize, (UINT8 *) SaSetup, RequestString);
ASSERT_EFI_ERROR (Status);
//[-start-200911-IB17040162-add]//
VarSize = sizeof (SA_SETUP);
CopyMem (MySaIfrNVData, SaSetup, VarSize);
//[-end-200911-IB17040162-add]//
FreePool (RequestString);
}
}
}
//[-start-200911-IB17040162-modify]//
FreePool (SaSetup);
VarSize = sizeof(SETUP_DATA);
SetupData = AllocatePool (VarSize);
ASSERT (SetupData != NULL);
if (SetupData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
MySetupDataIfrNVData = (SETUP_DATA *)gRcSUBrowser->SetupDataSUBrowserData;
CopyMem (SetupData, MySetupDataIfrNVData, VarSize);
Status = HiiGetBrowserData(&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) SetupData);
//[-end-200911-IB17040162-modify]//
ASSERT_EFI_ERROR(Status);
//
// "Enable All Thermal Functions" option is enabled then "Active Trip Points", "Critical Trip Points" option is enabled
// "Enable All Thermal Functions" option is disabled then "Active Trip Points", "Critical Trip Points" option is disabled
//
//[-start-200911-IB17040162-modify]//
if (!EFI_ERROR (Status)) {
if(!(SetupData->DisableActiveTripPoints == Value->u8) ) {
SetupData->DisableActiveTripPoints = Value->u8;
RequestString = NULL;
RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, DisableActiveTripPoints),sizeof(SetupData->DisableActiveTripPoints));
if (RequestString != NULL) {
Status = HiiSetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) SetupData, RequestString);
ASSERT_EFI_ERROR (Status);
VarSize = sizeof (SETUP_DATA);
CopyMem (MySetupDataIfrNVData, SetupData, VarSize);
FreePool (RequestString);
}
}
if(!(SetupData->DisableCriticalTripPoints == Value->u8) ) {
SetupData->DisableCriticalTripPoints = Value->u8;
RequestString = NULL;
RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, DisableCriticalTripPoints),sizeof(SetupData->DisableCriticalTripPoints));
}
if (RequestString != NULL) {
Status = HiiSetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) SetupData, RequestString);
ASSERT_EFI_ERROR (Status);
VarSize = sizeof (SETUP_DATA);
CopyMem (MySetupDataIfrNVData, SetupData, VarSize);
FreePool (RequestString);
}
}
FreePool (SetupData);
//[-end-200911-IB17040162-modify]//
return Status;
}
/**
setup reset call back function
@param[in] ResetType UEFI defined reset type.
@param[in] ResetStatus The status code for the reset.
@param[in] DataSize The size of ResetData in bytes.
@param[in] ResetData Optional element used to introduce a platform specific reset.
The exact type of the reset is defined by the EFI_GUID that follows
the Null-terminated Unicode string.
**/
VOID
EFIAPI
PlatformSetupResetCallback (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN VOID *ResetData OPTIONAL
)
{
static BOOLEAN IsExecuted;
EFI_RESET_TYPE OrgResetType;
PCH_RESET_DATA NewResetData;
if (IsExecuted) return;
IsExecuted = TRUE;
DEBUG ((DEBUG_INFO,"PlatformSetupResetCallback() Executed\n"));
OrgResetType = ResetType;
ResetType = PlatformReset (ResetType);
if(OrgResetType == ResetType) return;
DEBUG((DEBUG_INFO,"new ResetType is %d\n",ResetType));
if(ResetType != EfiResetPlatformSpecific) {
gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);
} else {
DataSize = sizeof (PCH_RESET_DATA);
CopyMem (&NewResetData.Guid, &gPchGlobalResetGuid, sizeof (EFI_GUID));
StrCpyS (NewResetData.Description, PCH_RESET_DATA_STRING_MAX_LENGTH, PCH_PLATFORM_SPECIFIC_RESET_STRING);
gRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, &NewResetData);
}
}
/**
Hook the system reset to properly reset function for platform setup reset
@param[in] Event Event whose notification function is being invoked
@param[in] Context Pointer to the notification function's context
**/
VOID
EFIAPI
OnResetFilterInstall (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
EFI_RESET_NOTIFICATION_PROTOCOL *ResetNotify;
Status = gBS->LocateProtocol (&gEdkiiPlatformSpecificResetFilterProtocolGuid, NULL, (VOID **) &ResetNotify);
if (!EFI_ERROR (Status)) {
Status = ResetNotify->RegisterResetNotify (ResetNotify, PlatformSetupResetCallback);
if (Event) gBS->CloseEvent (Event);
}
}
/**
add a reset filter protocol call back for setup exit funciton
**/
VOID
InstallPlatfromReset (
VOID
)
{
VOID *Registration;
EfiCreateProtocolNotifyEvent (
&gEdkiiPlatformSpecificResetFilterProtocolGuid,
TPL_CALLBACK,
OnResetFilterInstall,
NULL,
&Registration
);
}
/**
Initializes xHCI ACPI Path Name and String Length
@retval EFI_SUCCESS Successfully completed updates.
@retval EFI_NOT_FOUND Setup data not found.
@retval EFI_OUT_OF_RESOURCES Allocation failure for Setup data.
**/
EFI_STATUS
SdevXhciAcpiPathNameUpdate (
VOID
)
{
SETUP_DATA *CurrentUserSetupData;
UINTN VarSize;
EFI_STATUS Status;
//[-start-200908-IB17040156-remove]//
// EFI_STRING RequestString = NULL;
//[-end-200908-IB17040156-remove]//
UINT16 Device1AcpiPathName[] = L"\\_SB.PC00.XHCI.RHUB.HS00.CRGB";
UINT16 Device2AcpiPathName[] = L"\\_SB.PC00.XHCI.RHUB.HS01.CIR";
//[-start-200908-IB17040156-add]//
SETUP_DATA *MyIfrNVData;
//[-end-200908-IB17040156-add]//
VarSize = sizeof (SETUP_DATA);
CurrentUserSetupData = AllocatePool (VarSize);
ASSERT (CurrentUserSetupData != NULL);
if (CurrentUserSetupData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//[-start-200908-IB17040156-add]//
MyIfrNVData = (SETUP_DATA *)gRcSUBrowser->SetupDataSUBrowserData;
//[-start-200909-IB17040157-add]//
CopyMem (CurrentUserSetupData, MyIfrNVData, VarSize);
//[-end-200909-IB17040157-add]//
//[-end-200908-IB17040156-add]//
Status = HiiGetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) CurrentUserSetupData);
ASSERT_EFI_ERROR (Status);
if (Status != TRUE) {
FreePool (CurrentUserSetupData);
return EFI_NOT_FOUND;
}
///
/// Populate xHCI Device 1 ACPI Path Name and Length with default value
///
if (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1[0] == 0x0) {
ZeroMem (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1, sizeof (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1));
CurrentUserSetupData->SdevXhciAcpiPathStringLength[0] = (UINT16) (StrLen (Device1AcpiPathName) + 1);
CopyMem (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1, Device1AcpiPathName, StrSize (Device2AcpiPathName));
}
///
/// Populate xHCI Device 2 ACPI Path Name and Length with default value
///
if (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2[0] == 0x0) {
ZeroMem (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2, sizeof (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2));
CurrentUserSetupData->SdevXhciAcpiPathStringLength[1] = (UINT16) (StrLen (Device2AcpiPathName) + 1);
CopyMem (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2, Device2AcpiPathName, StrSize (Device2AcpiPathName));
}
//[-start-200908-IB17040156-remove]//
// RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, SdevXhciAcpiPathNameDevice1), sizeof (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1));
// RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, SdevXhciAcpiPathNameDevice2), sizeof (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2));
// RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, SdevXhciAcpiPathStringLength), sizeof (CurrentUserSetupData->SdevXhciAcpiPathStringLength));
// if (RequestString != NULL) {
// VarSize = sizeof (SETUP_DATA);
// Status = HiiSetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) CurrentUserSetupData, RequestString);
// ASSERT_EFI_ERROR (Status);
// FreePool (RequestString);
// if (Status != TRUE) {
// return EFI_NOT_FOUND;
// }
// }
//[-end-200908-IB17040156-remove]//
//[-start-200908-IB17040156-add]//
VarSize = sizeof (SETUP_DATA);
CopyMem (MyIfrNVData, CurrentUserSetupData, VarSize);
if (CurrentUserSetupData != NULL) {
FreePool (CurrentUserSetupData);
}
//[-end-200908-IB17040156-add]//
return EFI_SUCCESS;
}
/**
Updates xHCI ACPI Path Name and String Length
@param[IN] EFI_FORM_CALLBACK_PROTOCOL *This
@param[IN] EFI_BROWSER_ACTION Action,
@param[IN] EFI_QUESTION_ID KeyValue
@param[IN] UINT8 Type,
@param[IN] EFI_IFR_TYPE_VALUE *Value,
@param[IN] EFI_BROWSER_ACTION_REQUEST *ActionRequest
@retval EFI_SUCCESS Successfully completed updates.
@retval EFI_NOT_FOUND Setup data not found.
@retval EFI_UNSUPPORTED Unsupported browser action.
@retval EFI_OUT_OF_RESOURCES Allocation failure for Setup data.
**/
EFI_STATUS
EFIAPI
VtioFormCallBackFunction (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID KeyValue,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
SETUP_DATA *CurrentUserSetupData;
UINTN VarSize;
EFI_STATUS Status;
//[-start-200908-IB17040156-remove]//
// EFI_STRING RequestString = NULL;
//[-end-200908-IB17040156-remove]//
UINT8 Index = 0;
//[-start-200908-IB17040156-add]//
SETUP_DATA *MyIfrNVData;
//[-end-200908-IB17040156-add]//
///
/// No action to perform on Action Changing
///
if (Action == EFI_BROWSER_ACTION_CHANGING) {
return EFI_SUCCESS;
}
///
/// Initializations on form open
///
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
return SdevXhciAcpiPathNameUpdate ();
}
///
/// No action to perform on Action Changed
///
if (Action != EFI_BROWSER_ACTION_CHANGED) {
return EFI_UNSUPPORTED;
}
VarSize = sizeof (SETUP_DATA);
CurrentUserSetupData = AllocatePool (VarSize);
ASSERT (CurrentUserSetupData != NULL);
if (CurrentUserSetupData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
///
/// GetBrowserData by VarStore Name (Setup)
///
//[-start-200908-IB17040156-add]//
MyIfrNVData = (SETUP_DATA *)gRcSUBrowser->SetupDataSUBrowserData;
//[-start-200909-IB17040157-add]//
CopyMem (CurrentUserSetupData, MyIfrNVData, VarSize);
//[-end-200909-IB17040157-add]//
//[-end-200908-IB17040156-add]//
Status = HiiGetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) CurrentUserSetupData);
ASSERT_EFI_ERROR (Status);
if (Status != TRUE) {
FreePool (CurrentUserSetupData);
return EFI_NOT_FOUND;
}
switch (KeyValue) {
case KEY_SdevXhciAcpiPathNameDevice1:
///
/// Update xHCI ACPI Path Name
/// Ensure last entry is NULL terminator
///
CurrentUserSetupData->SdevXhciAcpiPathNameDevice1[48] = 0x00;
///
/// Update xHCI ACPI Path String Length
///
if (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1[0] == 0x0) {
CurrentUserSetupData->SdevXhciAcpiPathStringLength[0] = 0;
} else {
Index = 0;
while (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1[Index] != 0x0) {
Index++;
}
CurrentUserSetupData->SdevXhciAcpiPathStringLength[0] = Index + 1;
}
//[-start-200908-IB17040156-modify]//
VarSize = sizeof (SETUP_DATA);
CopyMem (MyIfrNVData, CurrentUserSetupData, VarSize);
// RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, SdevXhciAcpiPathStringLength), sizeof (CurrentUserSetupData->SdevXhciAcpiPathStringLength));
// RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, SdevXhciAcpiPathNameDevice1), sizeof (CurrentUserSetupData->SdevXhciAcpiPathNameDevice1));
// if (RequestString != NULL) {
// VarSize = sizeof (SETUP_DATA);
// Status = HiiSetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) CurrentUserSetupData, RequestString);
// ASSERT_EFI_ERROR (Status);
// FreePool (RequestString);
// if (Status != TRUE) {
// FreePool (CurrentUserSetupData);
// Status = EFI_NOT_FOUND;
// }
// }
//[-end-200908-IB17040156-modify]//
Status = EFI_SUCCESS;
break;
case KEY_SdevXhciAcpiPathNameDevice2:
///
/// Update xHCI ACPI Path Name
/// Ensure last entry is NULL terminator
///
CurrentUserSetupData->SdevXhciAcpiPathNameDevice2[48] = 0x00;
///
/// Update xHCI ACPI Path String Length
///
if (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2[0] == 0x0) {
CurrentUserSetupData->SdevXhciAcpiPathStringLength[1] = 0;
} else {
Index = 0;
while (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2[Index] != 0x0) {
Index++;
}
CurrentUserSetupData->SdevXhciAcpiPathStringLength[1] = Index + 1;
}
//[-start-200908-IB17040156-modify]//
VarSize = sizeof (SETUP_DATA);
CopyMem (MyIfrNVData, CurrentUserSetupData, VarSize);
// RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, SdevXhciAcpiPathStringLength), sizeof (CurrentUserSetupData->SdevXhciAcpiPathStringLength));
// RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, SdevXhciAcpiPathNameDevice2), sizeof (CurrentUserSetupData->SdevXhciAcpiPathNameDevice2));
// if (RequestString != NULL) {
// VarSize = sizeof (SETUP_DATA);
// Status = HiiSetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) CurrentUserSetupData, RequestString);
// ASSERT_EFI_ERROR (Status);
// FreePool (RequestString);
// if (Status != TRUE) {
// FreePool (CurrentUserSetupData);
// Status = EFI_NOT_FOUND;
// }
// }
//[-end-200908-IB17040156-modify]//
Status = EFI_SUCCESS;
break;
default:
Status = EFI_UNSUPPORTED;
}
FreePool (CurrentUserSetupData);
return Status;
}
/**
DeepestUsbSleepWakeCapability CallBack function
@param[IN] EFI_FORM_CALLBACK_PROTOCOL *This
@param[IN] EFI_BROWSER_ACTION Action,
@param[IN] EFI_QUESTION_ID KeyValue
@param[IN] UINT8 Type,
@param[IN] EFI_IFR_TYPE_VALUE *Value,
@param[IN] EFI_BROWSER_ACTION_REQUEST *ActionRequest
@retval EFI_SUCCESS Successfully completed updates.
@retval EFI_UNSUPPORTED Unsupported browser action.
@retval EFI_DEVICE_ERROR The variable could not be read or saved.
**/
EFI_STATUS
EFIAPI
DeepestUsbSleepWakeCapabilityCallBack (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID KeyValue,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
SA_SETUP SaSetup;
SETUP_DATA SetupData;
UINTN VarSize;
EFI_STATUS Status;
EFI_STRING RequestString;
if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {
return EFI_UNSUPPORTED;
}
Status = EFI_SUCCESS;
DEBUG ((DEBUG_INFO, "DeepestUsbSleepWakeCapabilityCallBack Start\n"));
VarSize = sizeof (SA_SETUP);
if (!HiiGetBrowserData (&gSaSetupVariableGuid, L"SaSetup", VarSize, (UINT8 *) &SaSetup)) {
DEBUG ((DEBUG_ERROR, "The SaSetup variable could not be read\n"));
return EFI_DEVICE_ERROR;
}
VarSize = sizeof (SETUP_DATA);
if (!HiiGetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) &SetupData)) {
DEBUG ((DEBUG_ERROR, "The Setup variable could not be read\n"));
return EFI_DEVICE_ERROR;
}
RequestString = NULL;
//
// Wake Capability is S3
//
if (SetupData.DeepestUSBSleepWakeCapability == 3) {
SaSetup.TcssVccstStatus = 0;
RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SA_SETUP, TcssVccstStatus), sizeof (SaSetup.TcssVccstStatus));
}
if (RequestString != NULL) {
VarSize = sizeof (SA_SETUP);
if (!HiiSetBrowserData (&gSaSetupVariableGuid, L"SaSetup", VarSize, (UINT8 *) &SaSetup, RequestString)) {
DEBUG ((DEBUG_ERROR, "The SaSetup variable could not be saved\n"));
Status = EFI_DEVICE_ERROR;
}
ASSERT_EFI_ERROR (Status);
FreePool (RequestString);
}
DEBUG ((DEBUG_INFO, "DeepestUsbSleepWakeCapabilityCallBack End\n"));
return Status;
}
/**
Update the Rtd3 setting base on the board type.
@param[IN] UINT8 Rtd3Support,
@param[IN][OUT] SETUP_DATA *SetupData
@retval EFI_SUCCESS Successfully completed updates.
@retval Others Fail to update.
**/
EFI_STATUS
EFIAPI
UpdateRtd3Setting (
IN UINT8 Rtd3Support,
IN OUT SETUP_DATA *SetupData
)
{
if (SetupData == NULL) {
return EFI_INVALID_PARAMETER;
}
if (Rtd3Support == 0) {
if (SetupData->StorageRtd3Support == 2) {
SetupData->StorageRtd3Support = 1;
}
} else {
//
// When RTD3 is enable, non-mobile SKU would only support D3Cold.
//
if (((PcdGet8 (PcdPlatformFlavor) != FlavorMobile) || (PcdGet8 (PcdPlatformFlavor) != FlavorMobileWorkstation)) &&
(PcdGet8 (PcdPlatformType) != TypeUltUlx)) {
if (SetupData->StorageRtd3Support == 1) {
//[-start-211227-QINGLIN0135-modify]//
#ifndef LCFC_SUPPORT
SetupData->StorageRtd3Support = 2;
#endif
//[-end-211227-QINGLIN0135-modify]//
}
}
}
return EFI_SUCCESS;
}
/**
Rtd3Support setup knob call back.
@param[IN] EFI_FORM_CALLBACK_PROTOCOL *This,
@param[IN] EFI_BROWSER_ACTION Action,
@param[IN] EFI_QUESTION_ID KeyValue
@param[IN] UINT8 Type,
@param[IN] EFI_IFR_TYPE_VALUE *Value,
@param[IN] EFI_BROWSER_ACTION_REQUEST *ActionRequest
@retval EFI_SUCCESS Successfully completed updates.
@retval EFI_UNSUPPORTED Unsupported browser action.
@retval EFI_DEVICE_ERROR The variable could not be read or saved.
**/
EFI_STATUS
EFIAPI
Rtd3SupportCallBackFunction (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID KeyValue,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
SETUP_DATA SetupData;
UINTN VarSize;
EFI_STATUS Status;
//[-start-211027-IB09480164-modify]//
//EFI_STRING RequestString;
DEBUG ((DEBUG_INFO, "%a() start\n", __FUNCTION__));
if (Action != EFI_BROWSER_ACTION_CHANGING &&
Action != EFI_BROWSER_ACTION_CHANGED &&
Action != EFI_BROWSER_ACTION_DEFAULT_STANDARD) {
return EFI_UNSUPPORTED;
}
VarSize = sizeof (SETUP_DATA);
CopyMem (&SetupData, gRcSUBrowser->SetupDataSUBrowserData, VarSize);
//if (!HiiGetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) &SetupData)) {
// DEBUG ((DEBUG_ERROR, "Fail to get Setup Browser Data!\n"));
// return EFI_DEVICE_ERROR;
//}
Status = UpdateRtd3Setting (Value->u8, &SetupData);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "Fail to update rtd3 setting: %r\n", Status));
return Status;
}
//RequestString = NULL;
//RequestString = HiiConstructRequestString (RequestString, OFFSET_OF (SETUP_DATA, StorageRtd3Support), sizeof (SetupData.StorageRtd3Support));
//if (RequestString != NULL) {
// VarSize = sizeof (SETUP_DATA);
// if (!HiiSetBrowserData (&gSetupVariableGuid, L"Setup", VarSize, (UINT8 *) &SetupData, RequestString)) {
// DEBUG ((DEBUG_ERROR, "Fail to set STD3 value to browser!\n"));
// return EFI_DEVICE_ERROR;
// }
//}
//
// When Rtd3Support be enabled and StorageRtd3Support !=0, always restore StorageRtd3Support to default value (D3Cold(2)).
//
if (SetupData.Rtd3Support == 1) {
if (SetupData.StorageRtd3Support == 1) {
//[-start-211227-QINGLIN0135-modify]//
#ifndef LCFC_SUPPORT
SetupData.StorageRtd3Support = 2;
#endif
//[-end-211227-QINGLIN0135-modify]//
}
}
VarSize = sizeof (SETUP_DATA);
CopyMem (gRcSUBrowser->SetupDataSUBrowserData, &SetupData, VarSize);
//[-end-211027-IB09480164-modify]//
DEBUG ((DEBUG_INFO, "%a() end\n", __FUNCTION__));
return Status;
}