diff --git a/BootloaderCorePkg/Include/Library/FspSupportLib.h b/BootloaderCorePkg/Include/Library/FspSupportLib.h index 7ce0cac0..7c6bda4e 100644 --- a/BootloaderCorePkg/Include/Library/FspSupportLib.h +++ b/BootloaderCorePkg/Include/Library/FspSupportLib.h @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016-2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -27,6 +27,22 @@ GetFspNvsDataBuffer ( CONST VOID *HobListPtr, UINT32 *Length ); +/** + This function retrieves FSP Non-volatile Storage HOB 2 buffer and size. + + @param HobListPtr A HOB list pointer. + @param Length A pointer to the NVS data buffer length. If the FSP NVS + HOB is located, the length will be updated. + @retval NULL Failed to find the NVS HOB. + @retval others FSP NVS data buffer pointer. + +**/ +VOID * +EFIAPI +GetFspNvsData2Buffer ( + CONST VOID *HobListPtr, + UINT32 *Length + ); /** This function retrieves a special reserved memory region. diff --git a/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.c b/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.c index ed55f0b4..e8977f4f 100644 --- a/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.c +++ b/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017-2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -11,6 +11,7 @@ #include #include #include +#include #include /** @@ -30,7 +31,45 @@ GetFspNvsDataBuffer ( UINT32 *Length ) { - return GetGuidHobData (HobListPtr, Length, &gFspNonVolatileStorageHobGuid); + VOID *HobData; + + HobData = GetGuidHobData (HobListPtr, Length, &gFspNonVolatileStorageHobGuid); + if (HobData == NULL){ + return GetFspNvsData2Buffer(HobListPtr, Length); + } + return HobData; +} + +/** + This function retrieves FSP Non-volatile Storage HOB 2 buffer and size. + + @param HobListPtr A HOB list pointer. + @param Length A pointer to the NVS data buffer length. If the FSP NVS + HOB is located, the length will be updated. + @retval NULL Failed to find the NVS HOB. + @retval others FSP NVS data buffer pointer. + +**/ +VOID * +EFIAPI +GetFspNvsData2Buffer ( + CONST VOID *HobListPtr, + UINT32 *Length + ) +{ + UINT8 *GuidHob; + + if (HobListPtr == NULL) { + return NULL; + } + GuidHob = GetNextGuidHob (&gFspNonVolatileStorageHob2Guid, HobListPtr); + if (GuidHob != NULL) { + if (Length != NULL) { + *Length = (UINT32) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHob)->NvsDataLength; + } + return (VOID *) (UINTN) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHob)->NvsDataPtr; + } + return NULL; } /** diff --git a/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.inf b/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.inf index 85a0656e..8a19d831 100644 --- a/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.inf +++ b/BootloaderCorePkg/Library/FspSupportLib/FspSupportLib.inf @@ -1,6 +1,6 @@ ## @file # -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017-2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -36,5 +36,6 @@ [Guids] gFspNonVolatileStorageHobGuid + gFspNonVolatileStorageHob2Guid [Pcd] diff --git a/IntelFsp2Pkg/Include/Guid/FspNonVolatileStorageHob2.h b/IntelFsp2Pkg/Include/Guid/FspNonVolatileStorageHob2.h new file mode 100644 index 00000000..a7277104 --- /dev/null +++ b/IntelFsp2Pkg/Include/Guid/FspNonVolatileStorageHob2.h @@ -0,0 +1,24 @@ +/** @file + Intel FSP Non-Volatile Storage (NVS) HOB version 2 definition from + Intel Firmware Support Package External Architecture Specification v2.3. + + Copyright (c) 2023, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __FSP_NON_VOLATILE_STORAGE_HOB2_H__ +#define __FSP_NON_VOLATILE_STORAGE_HOB2_H__ + +/// +/// The Non-Volatile Storage (NVS) HOB version 2 provides > 64KB buffer support. +/// +typedef struct { + EFI_HOB_GUID_TYPE GuidHob; + EFI_PHYSICAL_ADDRESS NvsDataPtr; + UINT64 NvsDataLength; +} FSP_NON_VOLATILE_STORAGE_HOB2; + +extern EFI_GUID gFspNonVolatileStorageHob2Guid; + +#endif