Skip to content

Commit

Permalink
Make PlatformInitPreMem independent to IntelSiliconPkg and IntelFsp2W…
Browse files Browse the repository at this point in the history
…rapperPkg

This driver is shared across different Silicon vendors.
It should not use Intel specific packages
To achieve this, added a new lib `FspSupportLib` to isolate silicon related PCDs
  • Loading branch information
PaddyDengKC committed Sep 5, 2024
1 parent 2c90f2b commit 0f1c877
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 5 deletions.
35 changes: 35 additions & 0 deletions MinPlatformPkg/Include/Library/FspSupportLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** @file FspSupportLib.c
Library to report FSP support state
Copyright (c) Microsoft Corporation. All rights reserved.
**/

#ifndef _FSP_SUPPORT_LIB_H_
#define _FSP_SUPPORT_LIB_H_

/**
Return if platform is boot in FSP wrapper enabled
@retval TRUE FSP binary is used.
FALSE FSP binary is not used.
**/
BOOLEAN
EFIAPI
FspGetWrapperBootMode (
VOID
);

/**
Return FSP mode selection. Only valid on certain platforms
@retval FSP mode.
**/
UINT8
EFIAPI
FspGetModeSelection (
VOID
);

#endif // _FSP_SUPPORT_LIB_H_
41 changes: 41 additions & 0 deletions MinPlatformPkg/Library/FspSupportLib/FspSupportLib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** @file FspSupportLib.c
Library to report FSP support state
Copyright (c) Microsoft Corporation. All rights reserved.
**/

#include <Uefi.h>

#include <Library/FspSupportLib.h>
#include <Library/PcdLib.h>

/**
Return if platform is boot in FSP wrapper enabled
@retval TRUE FSP binary is used.
FALSE FSP binary is not used.
**/
BOOLEAN
EFIAPI
FspGetWrapperBootMode (
VOID
)
{
return PcdGetBool (PcdFspWrapperBootMode);
}

/**
Return FSP mode selection. Only valid on certain platforms
@retval FSP mode.
**/
UINT8
EFIAPI
FspGetModeSelection (
VOID
)
{
return PcdGet8 (PcdFspModeSelection);
}
31 changes: 31 additions & 0 deletions MinPlatformPkg/Library/FspSupportLib/FspSupportLib.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @file FspSupportLib.inf
#
# Default implementation of FspSupportLib.
# Library to report FSP support state
#
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#

[Defines]
INF_VERSION = 0x00010006
BASE_NAME = FspSupportLib
FILE_GUID = 9D79825F-C6A5-4D94-AF26-23AF2BD6BEC7
VERSION_STRING = 1.0
MODULE_TYPE = BASE
LIBRARY_CLASS = FspSupportLib

[Sources]
FspSupportLib.c

[Packages]
MdePkg/MdePkg.dec
MinPlatformPkg/MinPlatformPkg.dec
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec

[LibraryClasses]
PcdLib

[Pcd]
gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBootMode
gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection
3 changes: 3 additions & 0 deletions MinPlatformPkg/MinPlatformPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
TestPointPciSpeedInfoLib|Include/Library/TestPointPciSpeedInfoLib.h

PhatAcpiLib|Include/Library/PhatAcpiLib.h
# MU_CHANGE Make PlatformInitPreMem silicon independent
FspSupportLib|Include/Library/FspSupportLib.h
# MU_CHANGE end

[PcdsFixedAtBuild, PcdsPatchableInModule]

Expand Down
6 changes: 6 additions & 0 deletions MinPlatformPkg/MinPlatformPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
NULL|MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf # MU_CHANGE: /GS and -fstack-protector support
TestPointCheckLib|MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.inf
TestPointPciSpeedInfoLib|MinPlatformPkg/Library/TestPointPciSpeedInfoLibNull/TestPointPciSpeedInfoLibNull.inf
# MU_CHANGE Make PlatformInitPreMem silicon independent
FspSupportLib|MinPlatformPkg/Library/FspSupportLib/FspSupportLib.inf
# MU_CHANGE end

[LibraryClasses.common.SEC]
TestPointCheckLib|MinPlatformPkg/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
Expand Down Expand Up @@ -237,6 +240,9 @@
MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf

MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.inf
# MU_CHANGE Make PlatformInitPreMem silicon independent
MinPlatformPkg/Library/FspSupportLib/FspSupportLib.inf
# MU_CHANGE end

[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Ppi/PlatformMemorySize.h>
#include <Ppi/BaseMemoryTest.h>
#include <Ppi/PlatformInitTempRamExitPpi.h>
// MU_CHANGE Make PlatformInitPreMem silicon independent
#include <Library/FspSupportLib.h>
// MU_CHANGE end

EFI_STATUS
EFIAPI
Expand Down Expand Up @@ -516,7 +519,10 @@ PlatformInitPreMem (

BuildMemoryTypeInformation ();

if ((!PcdGetBool (PcdFspWrapperBootMode)) || (PcdGet8 (PcdFspModeSelection) == 0)) {
// MU_CHANGE Make PlatformInitPreMem silicon independent
//if ((!PcdGetBool (PcdFspWrapperBootMode)) || (PcdGet8 (PcdFspModeSelection) == 0)) {
if ((!FspGetWrapperBootMode()) || (FspGetModeSelection() == 0)) {
// MU_CHANGE end
//
// Install memory relating PPIs for EDKII native build and FSP dispatch mode
//
Expand Down
17 changes: 13 additions & 4 deletions MinPlatformPkg/PlatformInit/PlatformInitPei/PlatformInitPreMem.inf
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,28 @@
TimerLib
SetCacheMtrrLib
ReportCpuHobLib
# MU_CHANGE Make PlatformInitPreMem silicon independent
FspSupportLib
# MU_CHANGE end

[Packages]
MinPlatformPkg/MinPlatformPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
IntelSiliconPkg/IntelSiliconPkg.dec
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
# MU_CHANGE Make PlatformInitPreMem silicon independent
# IntelSiliconPkg/IntelSiliconPkg.dec
# IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
# MU_CHANGE end

[Pcd]
gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBootMode ## CONSUMES
# MU_CHANGE Make PlatformInitPreMem silicon independent
# gMinPlatformPkgTokenSpaceGuid.PcdFspWrapperBootMode ## CONSUMES
# MU_CHANGE end
gMinPlatformPkgTokenSpaceGuid.PcdStopAfterDebugInit ## CONSUMES
gMinPlatformPkgTokenSpaceGuid.PcdStopAfterMemInit ## CONSUMES
gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection ## CONSUMES
# MU_CHANGE Make PlatformInitPreMem silicon independent
# gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection ## CONSUMES
# MU_CHANGE end

[FixedPcd]
gMinPlatformPkgTokenSpaceGuid.PcdPlatformEfiAcpiReclaimMemorySize ## CONSUMES
Expand Down

0 comments on commit 0f1c877

Please sign in to comment.