//\r
SMM_IPL_EVENT_NOTIFICATION mSmmIplEvents[] = {\r
//\r
- // Declare protocol notification on the SMM Configuration protocol. When this notification is etablished, \r
+ // Declare protocol notification on the SMM Configuration protocol. When this notification is established,\r
// the associated event is immediately signalled, so the notification function will be executed and the \r
// SMM Configuration Protocol will be found if it is already in the handle database.\r
//\r
//\r
{ TRUE, TRUE, &gEfiDxeSmmReadyToLockProtocolGuid, SmmIplReadyToLockEventNotify, &gEfiDxeSmmReadyToLockProtocolGuid, TPL_CALLBACK, NULL },\r
//\r
- // Declare event notification on EndOfDxe event. When this notification is etablished, \r
+ // Declare event notification on EndOfDxe event. When this notification is established,\r
// the associated event is immediately signalled, so the notification function will be executed and the \r
// SMM End Of Dxe Protocol will be found if it is already in the handle database.\r
//\r
}\r
\r
/**\r
- Get the fixed loadding address from image header assigned by build tool. This function only be called\r
+ Get the fixed loading address from image header assigned by build tool. This function only be called\r
when Loading module at Fixed address feature enabled.\r
\r
@param ImageContext Pointer to the image context structure that describes the PE/COFF\r
image that needs to be examined by this function.\r
@retval EFI_SUCCESS An fixed loading address is assigned to this image by build tools .\r
- @retval EFI_NOT_FOUND The image has no assigned fixed loadding address.\r
+ @retval EFI_NOT_FOUND The image has no assigned fixed loading address.\r
**/\r
EFI_STATUS\r
GetPeCoffImageFixLoadingAssignedAddress(\r
EFI_STATUS Status;\r
EFI_IMAGE_SECTION_HEADER SectionHeader;\r
EFI_IMAGE_OPTIONAL_HEADER_UNION *ImgHdr;\r
- EFI_PHYSICAL_ADDRESS FixLoaddingAddress;\r
+ EFI_PHYSICAL_ADDRESS FixLoadingAddress;\r
UINT16 Index;\r
UINTN Size;\r
UINT16 NumberOfSections;\r
//\r
SmmCodeSize = EFI_PAGES_TO_SIZE (PcdGet32(PcdLoadFixAddressSmmCodePageNumber));\r
\r
- FixLoaddingAddress = 0;\r
+ FixLoadingAddress = 0;\r
Status = EFI_NOT_FOUND;\r
SmramBase = mCurrentSmramRange->CpuStart;\r
//\r
// Build tool saves the offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields in the\r
// first section header that doesn't point to code section in image header. And there is an assumption that when the\r
// feature is enabled, if a module is assigned a loading address by tools, PointerToRelocations & PointerToLineNumbers\r
- // fields should NOT be Zero, or else, these 2 fileds should be set to Zero\r
+ // fields should NOT be Zero, or else, these 2 fields should be set to Zero\r
//\r
ValueInSectionHeader = ReadUnaligned64((UINT64*)&SectionHeader.PointerToRelocations);\r
if (ValueInSectionHeader != 0) {\r
//\r
- // Found first section header that doesn't point to code section in which uild tool saves the\r
+ // Found first section header that doesn't point to code section in which build tool saves the\r
// offset to SMRAM base as image base in PointerToRelocations & PointerToLineNumbers fields\r
//\r
- FixLoaddingAddress = (EFI_PHYSICAL_ADDRESS)(SmramBase + (INT64)ValueInSectionHeader);\r
+ FixLoadingAddress = (EFI_PHYSICAL_ADDRESS)(SmramBase + (INT64)ValueInSectionHeader);\r
\r
- if (SmramBase + SmmCodeSize > FixLoaddingAddress && SmramBase <= FixLoaddingAddress) {\r
+ if (SmramBase + SmmCodeSize > FixLoadingAddress && SmramBase <= FixLoadingAddress) {\r
//\r
- // The assigned address is valid. Return the specified loadding address\r
+ // The assigned address is valid. Return the specified loading address\r
//\r
- ImageContext->ImageAddress = FixLoaddingAddress;\r
+ ImageContext->ImageAddress = FixLoadingAddress;\r
Status = EFI_SUCCESS;\r
}\r
}\r
}\r
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);\r
}\r
- DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r \n", FixLoaddingAddress, Status));\r
+ DEBUG ((EFI_D_INFO|EFI_D_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r \n", FixLoadingAddress, Status));\r
return Status;\r
}\r
/**\r
// Since the memory range to load SMM CORE will be cut out in SMM core, so no need to allocate and free this range\r
//\r
PageCount = 0;\r
+ //\r
+ // Reserved Smram Region for SmmCore is not used, and remove it from SmramRangeCount.\r
+ //\r
+ gSmmCorePrivate->SmramRangeCount --;\r
} else {\r
DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED ERROR: Loading module at fixed address at address failed\n"));\r
//\r
UINTN Index2;\r
EFI_SMRAM_DESCRIPTOR *FullSmramRanges;\r
UINTN TempSmramRangeCount;\r
+ UINTN AdditionSmramRangeCount;\r
EFI_SMRAM_DESCRIPTOR *TempSmramRanges;\r
UINTN SmramRangeCount;\r
EFI_SMRAM_DESCRIPTOR *SmramRanges;\r
}\r
}\r
\r
+ //\r
+ // Reserve one entry for SMM Core in the full SMRAM ranges.\r
+ //\r
+ AdditionSmramRangeCount = 1;\r
+ if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0) {\r
+ //\r
+ // Reserve two entries for all SMM drivers and SMM Core in the full SMRAM ranges.\r
+ //\r
+ AdditionSmramRangeCount = 2;\r
+ }\r
+\r
if (SmramReservedCount == 0) {\r
//\r
// No reserved SMRAM entry from SMM Configuration Protocol.\r
- // Reserve one entry for SMM Core in the full SMRAM ranges.\r
//\r
- *FullSmramRangeCount = SmramRangeCount + 1;\r
+ *FullSmramRangeCount = SmramRangeCount + AdditionSmramRangeCount;\r
Size = (*FullSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR);\r
FullSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateZeroPool (Size);\r
ASSERT (FullSmramRanges != NULL);\r
ASSERT (TempSmramRangeCount <= MaxCount);\r
\r
//\r
- // Sort the entries,\r
- // and reserve one entry for SMM Core in the full SMRAM ranges.\r
+ // Sort the entries\r
//\r
- FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + 1) * sizeof (EFI_SMRAM_DESCRIPTOR));\r
+ FullSmramRanges = AllocateZeroPool ((TempSmramRangeCount + AdditionSmramRangeCount) * sizeof (EFI_SMRAM_DESCRIPTOR));\r
ASSERT (FullSmramRanges != NULL);\r
*FullSmramRangeCount = 0;\r
do {\r
TempSmramRanges[Index].PhysicalSize = 0;\r
} while (*FullSmramRangeCount < TempSmramRangeCount);\r
ASSERT (*FullSmramRangeCount == TempSmramRangeCount);\r
- *FullSmramRangeCount += 1;\r
+ *FullSmramRangeCount += AdditionSmramRangeCount;\r
\r
FreePool (SmramRanges);\r
FreePool (SmramReservedRanges);\r
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable;\r
EFI_CPU_ARCH_PROTOCOL *CpuArch;\r
EFI_STATUS SetAttrStatus;\r
+ EFI_SMRAM_DESCRIPTOR *SmramRangeSmmDriver;\r
\r
//\r
// Fill in the image handle of the SMM IPL so the SMM Core can use this as the \r
//\r
DEBUG ((EFI_D_INFO, "LOADING MODULE FIXED INFO: TSEG BASE is %x. \n", LMFAConfigurationTable->SmramBase));\r
}\r
+\r
+ //\r
+ // Fill the Smram range for all SMM code\r
+ //\r
+ SmramRangeSmmDriver = &gSmmCorePrivate->SmramRanges[gSmmCorePrivate->SmramRangeCount - 2];\r
+ SmramRangeSmmDriver->CpuStart = mCurrentSmramRange->CpuStart;\r
+ SmramRangeSmmDriver->PhysicalStart = mCurrentSmramRange->PhysicalStart;\r
+ SmramRangeSmmDriver->RegionState = mCurrentSmramRange->RegionState | EFI_ALLOCATED;\r
+ SmramRangeSmmDriver->PhysicalSize = SmmCodeSize;\r
+\r
+ mCurrentSmramRange->PhysicalSize -= SmmCodeSize;\r
+ mCurrentSmramRange->CpuStart = mCurrentSmramRange->CpuStart + SmmCodeSize;\r
+ mCurrentSmramRange->PhysicalStart = mCurrentSmramRange->PhysicalStart + SmmCodeSize;\r
}\r
//\r
// Load SMM Core into SMRAM and execute it from SMRAM\r