If PI SMM IPL will be dispatched before the CPU AP is installed for a platform, the platform developer is expected to set cache-ability of SMRAM to WB earlier to improve performance of SMM initialization.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10998
6f19259b-4bc3-4df7-8a09-
765794883524
#include <Protocol/SmmConfiguration.h>\r
#include <Protocol/SmmControl2.h>\r
#include <Protocol/DxeSmmReadyToLock.h>\r
#include <Protocol/SmmConfiguration.h>\r
#include <Protocol/SmmControl2.h>\r
#include <Protocol/DxeSmmReadyToLock.h>\r
+#include <Protocol/Cpu.h>\r
\r
#include <Guid/EventGroup.h>\r
#include <Guid/EventLegacyBios.h>\r
\r
#include <Guid/EventGroup.h>\r
#include <Guid/EventLegacyBios.h>\r
EFI_SMM_RESERVED_SMRAM_REGION *SmramResRegion;\r
UINT64 MaxSize;\r
VOID *Registration;\r
EFI_SMM_RESERVED_SMRAM_REGION *SmramResRegion;\r
UINT64 MaxSize;\r
VOID *Registration;\r
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable;\r
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable;\r
+ EFI_CPU_ARCH_PROTOCOL *CpuArch;\r
\r
//\r
// Fill in the image handle of the SMM IPL so the SMM Core can use this as the \r
\r
//\r
// Fill in the image handle of the SMM IPL so the SMM Core can use this as the \r
\r
GetSmramCacheRange (mCurrentSmramRange, &mSmramCacheBase, &mSmramCacheSize);\r
//\r
\r
GetSmramCacheRange (mCurrentSmramRange, &mSmramCacheBase, &mSmramCacheSize);\r
//\r
- // Attempt to set SMRAM cacheability to WB\r
+ // If CPU AP is present, attempt to set SMRAM cacheability to WB\r
+ // Note that it is expected that cacheability of SMRAM has been set to WB if CPU AP\r
+ // is not available here.\r
- Status = gDS->SetMemorySpaceAttributes(\r
- mSmramCacheBase, \r
- mSmramCacheSize,\r
- EFI_MEMORY_WB\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_WARN, "SMM IPL failed to set SMRAM window to EFI_MEMORY_WB\n"));\r
- } \r
+ Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&CpuArch);\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gDS->SetMemorySpaceAttributes(\r
+ mSmramCacheBase, \r
+ mSmramCacheSize,\r
+ EFI_MEMORY_WB\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_WARN, "SMM IPL failed to set SMRAM window to EFI_MEMORY_WB\n"));\r
+ } \r
+ }\r
//\r
// if Loading module at Fixed Address feature is enabled, save the SMRAM base to Load\r
// Modules At Fixed Address Configuration Table.\r
//\r
// if Loading module at Fixed Address feature is enabled, save the SMRAM base to Load\r
// Modules At Fixed Address Configuration Table.\r
gEfiSmmConfigurationProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
gEfiSmmControl2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
gEfiSmmConfigurationProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
gEfiSmmControl2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
- gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
+ gEfiCpuArchProtocolGuid # PROTOCOL SIMETIMES_CONSUMED\r
\r
[Guids]\r
gEfiEventDxeDispatchGuid # ALWAYS_CONSUMED\r
\r
[Guids]\r
gEfiEventDxeDispatchGuid # ALWAYS_CONSUMED\r
- gEfiSmmAccess2ProtocolGuid AND gEfiSmmControl2ProtocolGuid AND gEfiCpuArchProtocolGuid\r
+ gEfiSmmAccess2ProtocolGuid AND gEfiSmmControl2ProtocolGuid\r