StandaloneMmPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the StandaloneMmPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
committed by
mergify[bot]
parent
c1e126b119
commit
91415a36ae
@@ -206,7 +206,6 @@ MmIsSchedulable (
|
|||||||
//
|
//
|
||||||
mDepexEvaluationStackPointer = mDepexEvaluationStack;
|
mDepexEvaluationStackPointer = mDepexEvaluationStack;
|
||||||
|
|
||||||
|
|
||||||
Iterator = DriverEntry->Depex;
|
Iterator = DriverEntry->Depex;
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
@@ -257,6 +256,7 @@ MmIsSchedulable (
|
|||||||
*Iterator = EFI_DEP_REPLACE_TRUE;
|
*Iterator = EFI_DEP_REPLACE_TRUE;
|
||||||
Status = PushBool (TRUE);
|
Status = PushBool (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -284,6 +284,7 @@ MmIsSchedulable (
|
|||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_DEP_OR:
|
case EFI_DEP_OR:
|
||||||
@@ -305,6 +306,7 @@ MmIsSchedulable (
|
|||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_DEP_NOT:
|
case EFI_DEP_NOT:
|
||||||
@@ -320,6 +322,7 @@ MmIsSchedulable (
|
|||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_DEP_TRUE:
|
case EFI_DEP_TRUE:
|
||||||
@@ -329,6 +332,7 @@ MmIsSchedulable (
|
|||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_DEP_FALSE:
|
case EFI_DEP_FALSE:
|
||||||
@@ -338,6 +342,7 @@ MmIsSchedulable (
|
|||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_DEP_END:
|
case EFI_DEP_END:
|
||||||
@@ -347,6 +352,7 @@ MmIsSchedulable (
|
|||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Unexpected error)\n"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", Operator ? "TRUE" : "FALSE"));
|
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", Operator ? "TRUE" : "FALSE"));
|
||||||
return Operator;
|
return Operator;
|
||||||
|
|
||||||
|
@@ -107,7 +107,7 @@ BOOLEAN gRequestDispatch = FALSE;
|
|||||||
// memory range usage. It is a bit mapped array in which every bit indicates the correspoding
|
// memory range usage. It is a bit mapped array in which every bit indicates the correspoding
|
||||||
// memory page available or not.
|
// memory page available or not.
|
||||||
//
|
//
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED UINT64 *mMmCodeMemoryRangeUsageBitMap=NULL;
|
GLOBAL_REMOVE_IF_UNREFERENCED UINT64 *mMmCodeMemoryRangeUsageBitMap = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
To check memory usage bit map array to figure out if the memory range in which the image will be loaded
|
To check memory usage bit map array to figure out if the memory range in which the image will be loaded
|
||||||
@@ -159,7 +159,7 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
|
|||||||
//
|
//
|
||||||
// see if the memory range for loading the image is in the MM code range.
|
// see if the memory range for loading the image is in the MM code range.
|
||||||
//
|
//
|
||||||
if (MmCodeBase + MmCodeSize < ImageBase + ImageSize || MmCodeBase > ImageBase) {
|
if ((MmCodeBase + MmCodeSize < ImageBase + ImageSize) || (MmCodeBase > ImageBase)) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
|
|||||||
//
|
//
|
||||||
BaseOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES ((UINT32)(ImageBase - MmCodeBase));
|
BaseOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES ((UINT32)(ImageBase - MmCodeBase));
|
||||||
TopOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES ((UINT32)(ImageBase + ImageSize - MmCodeBase));
|
TopOffsetPageNumber = (UINTN)EFI_SIZE_TO_PAGES ((UINT32)(ImageBase + ImageSize - MmCodeBase));
|
||||||
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {
|
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index++) {
|
||||||
if ((mMmCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64 (1, (Index % 64))) != 0) {
|
if ((mMmCodeMemoryRangeUsageBitMap[Index / 64] & LShiftU64 (1, (Index % 64))) != 0) {
|
||||||
//
|
//
|
||||||
// This page is already used.
|
// This page is already used.
|
||||||
@@ -180,9 +180,10 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
|
|||||||
//
|
//
|
||||||
// Being here means the memory range is available. So mark the bits for the memory range
|
// Being here means the memory range is available. So mark the bits for the memory range
|
||||||
//
|
//
|
||||||
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {
|
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index++) {
|
||||||
mMmCodeMemoryRangeUsageBitMap[Index / 64] |= LShiftU64 (1, (Index % 64));
|
mMmCodeMemoryRangeUsageBitMap[Index / 64] |= LShiftU64 (1, (Index % 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +198,7 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetPeCoffImageFixLoadingAssignedAddress(
|
GetPeCoffImageFixLoadingAssignedAddress (
|
||||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -217,7 +218,7 @@ GetPeCoffImageFixLoadingAssignedAddress(
|
|||||||
//
|
//
|
||||||
// Get PeHeader pointer
|
// Get PeHeader pointer
|
||||||
//
|
//
|
||||||
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
|
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8 *)ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
|
||||||
SectionHeaderOffset = ImageContext->PeCoffHeaderOffset + sizeof (UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) +
|
SectionHeaderOffset = ImageContext->PeCoffHeaderOffset + sizeof (UINT32) + sizeof (EFI_IMAGE_FILE_HEADER) +
|
||||||
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
|
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
|
||||||
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
|
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
|
||||||
@@ -250,7 +251,7 @@ GetPeCoffImageFixLoadingAssignedAddress(
|
|||||||
// assigned by tools, the PointerToRelocations & PointerToLineNumbers fields should not be
|
// assigned by tools, the PointerToRelocations & PointerToLineNumbers fields should not be
|
||||||
// Zero, or else, these 2 fields should be set to Zero
|
// Zero, or else, these 2 fields should be set to Zero
|
||||||
//
|
//
|
||||||
ValueInSectionHeader = ReadUnaligned64 ((UINT64*)&SectionHeader.PointerToRelocations);
|
ValueInSectionHeader = ReadUnaligned64 ((UINT64 *)&SectionHeader.PointerToRelocations);
|
||||||
if (ValueInSectionHeader != 0) {
|
if (ValueInSectionHeader != 0) {
|
||||||
//
|
//
|
||||||
// Found first section header that doesn't point to code section in which build tool saves the
|
// Found first section header that doesn't point to code section in which build tool saves the
|
||||||
@@ -261,21 +262,29 @@ GetPeCoffImageFixLoadingAssignedAddress(
|
|||||||
// Check if the memory range is available.
|
// Check if the memory range is available.
|
||||||
//
|
//
|
||||||
Status = CheckAndMarkFixLoadingMemoryUsageBitMap (FixLoadingAddress, (UINTN)(ImageContext->ImageSize + ImageContext->SectionAlignment));
|
Status = CheckAndMarkFixLoadingMemoryUsageBitMap (FixLoadingAddress, (UINTN)(ImageContext->ImageSize + ImageContext->SectionAlignment));
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
// The assigned address is valid. Return the specified loading address
|
// The assigned address is valid. Return the specified loading address
|
||||||
//
|
//
|
||||||
ImageContext->ImageAddress = FixLoadingAddress;
|
ImageContext->ImageAddress = FixLoadingAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||||
}
|
}
|
||||||
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r\n",
|
|
||||||
FixLoadingAddress, Status));
|
DEBUG ((
|
||||||
|
DEBUG_INFO|DEBUG_LOAD,
|
||||||
|
"LOADING MODULE FIXED INFO: Loading module at fixed address %x, Status = %r\n",
|
||||||
|
FixLoadingAddress,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Loads an EFI image into SMRAM.
|
Loads an EFI image into SMRAM.
|
||||||
|
|
||||||
@@ -355,7 +364,7 @@ MmLoadImage (
|
|||||||
//
|
//
|
||||||
// Flush the instruction cache so the image data are written before we execute it
|
// Flush the instruction cache so the image data are written before we execute it
|
||||||
//
|
//
|
||||||
InvalidateInstructionCacheRange ((VOID *)(UINTN) ImageContext.ImageAddress, (UINTN) ImageContext.ImageSize);
|
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save Image EntryPoint in DriverEntry
|
// Save Image EntryPoint in DriverEntry
|
||||||
@@ -412,10 +421,12 @@ MmLoadImage (
|
|||||||
UINTN StartIndex;
|
UINTN StartIndex;
|
||||||
CHAR8 EfiFileName[256];
|
CHAR8 EfiFileName[256];
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO | DEBUG_LOAD,
|
DEBUG ((
|
||||||
|
DEBUG_INFO | DEBUG_LOAD,
|
||||||
"Loading MM driver at 0x%11p EntryPoint=0x%11p ",
|
"Loading MM driver at 0x%11p EntryPoint=0x%11p ",
|
||||||
(VOID *)(UINTN) ImageContext.ImageAddress,
|
(VOID *)(UINTN)ImageContext.ImageAddress,
|
||||||
FUNCTION_ENTRY_POINT (ImageContext.EntryPoint)));
|
FUNCTION_ENTRY_POINT (ImageContext.EntryPoint)
|
||||||
|
));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Print Module Name by Pdb file path.
|
// Print Module Name by Pdb file path.
|
||||||
@@ -439,6 +450,7 @@ MmLoadImage (
|
|||||||
if (EfiFileName[Index] == 0) {
|
if (EfiFileName[Index] == 0) {
|
||||||
EfiFileName[Index] = '.';
|
EfiFileName[Index] = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EfiFileName[Index] == '.') {
|
if (EfiFileName[Index] == '.') {
|
||||||
EfiFileName[Index + 1] = 'e';
|
EfiFileName[Index + 1] = 'e';
|
||||||
EfiFileName[Index + 2] = 'f';
|
EfiFileName[Index + 2] = 'f';
|
||||||
@@ -451,8 +463,10 @@ MmLoadImage (
|
|||||||
if (Index == sizeof (EfiFileName) - 4) {
|
if (Index == sizeof (EfiFileName) - 4) {
|
||||||
EfiFileName[Index] = 0;
|
EfiFileName[Index] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName));
|
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n"));
|
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n"));
|
||||||
|
|
||||||
DEBUG_CODE_END ();
|
DEBUG_CODE_END ();
|
||||||
@@ -520,6 +534,7 @@ MmGetDepexSectionAndPreProccess (
|
|||||||
} else {
|
} else {
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
if (Status == EFI_PROTOCOL_ERROR) {
|
if (Status == EFI_PROTOCOL_ERROR) {
|
||||||
//
|
//
|
||||||
@@ -639,17 +654,18 @@ MmDispatcher (
|
|||||||
//
|
//
|
||||||
if (mEfiSystemTable == NULL) {
|
if (mEfiSystemTable == NULL) {
|
||||||
DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Standalone Mode)\n", DriverEntry->ImageEntryPoint));
|
DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Standalone Mode)\n", DriverEntry->ImageEntryPoint));
|
||||||
Status = ((MM_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint) (DriverEntry->ImageHandle, &gMmCoreMmst);
|
Status = ((MM_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(DriverEntry->ImageHandle, &gMmCoreMmst);
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Tradition Mode)\n", DriverEntry->ImageEntryPoint));
|
DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Tradition Mode)\n", DriverEntry->ImageEntryPoint));
|
||||||
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint) (
|
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint)(
|
||||||
DriverEntry->ImageHandle,
|
DriverEntry->ImageHandle,
|
||||||
mEfiSystemTable
|
mEfiSystemTable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (EFI_ERROR(Status)) {
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_INFO, "StartImage Status - %r\n", Status));
|
DEBUG ((DEBUG_INFO, "StartImage Status - %r\n", Status));
|
||||||
MmFreePages(DriverEntry->ImageBuffer, DriverEntry->NumberOfPage);
|
MmFreePages (DriverEntry->ImageBuffer, DriverEntry->NumberOfPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,8 +740,8 @@ MmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
|
|||||||
// Process Before Dependency
|
// Process Before Dependency
|
||||||
//
|
//
|
||||||
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
|
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
|
||||||
DriverEntry = CR(Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
|
DriverEntry = CR (Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
|
||||||
if (DriverEntry->Before && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
|
if (DriverEntry->Before && DriverEntry->Dependent && (DriverEntry != InsertedDriverEntry)) {
|
||||||
DEBUG ((DEBUG_DISPATCH, "Evaluate MM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
|
DEBUG ((DEBUG_DISPATCH, "Evaluate MM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
|
||||||
DEBUG ((DEBUG_DISPATCH, " BEFORE FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
|
DEBUG ((DEBUG_DISPATCH, " BEFORE FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
|
||||||
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
|
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
|
||||||
@@ -748,13 +764,12 @@ MmInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
|
|||||||
InsertedDriverEntry->Scheduled = TRUE;
|
InsertedDriverEntry->Scheduled = TRUE;
|
||||||
InsertTailList (&mScheduledQueue, &InsertedDriverEntry->ScheduledLink);
|
InsertTailList (&mScheduledQueue, &InsertedDriverEntry->ScheduledLink);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Process After Dependency
|
// Process After Dependency
|
||||||
//
|
//
|
||||||
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
|
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
|
||||||
DriverEntry = CR(Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
|
DriverEntry = CR (Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
|
||||||
if (DriverEntry->After && DriverEntry->Dependent && DriverEntry != InsertedDriverEntry) {
|
if (DriverEntry->After && DriverEntry->Dependent && (DriverEntry != InsertedDriverEntry)) {
|
||||||
DEBUG ((DEBUG_DISPATCH, "Evaluate MM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
|
DEBUG ((DEBUG_DISPATCH, "Evaluate MM DEPEX for FFS(%g)\n", &DriverEntry->FileName));
|
||||||
DEBUG ((DEBUG_DISPATCH, " AFTER FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
|
DEBUG ((DEBUG_DISPATCH, " AFTER FFS(%g) = ", &DriverEntry->BeforeAfterGuid));
|
||||||
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
|
if (CompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
|
||||||
@@ -792,12 +807,14 @@ FvHasBeenProcessed (
|
|||||||
|
|
||||||
for (Link = mFwVolList.ForwardLink;
|
for (Link = mFwVolList.ForwardLink;
|
||||||
Link != &mFwVolList;
|
Link != &mFwVolList;
|
||||||
Link = Link->ForwardLink) {
|
Link = Link->ForwardLink)
|
||||||
|
{
|
||||||
KnownFwVol = CR (Link, KNOWN_FWVOL, Link, KNOWN_FWVOL_SIGNATURE);
|
KnownFwVol = CR (Link, KNOWN_FWVOL, Link, KNOWN_FWVOL_SIGNATURE);
|
||||||
if (KnownFwVol->FwVolHeader == FwVolHeader) {
|
if (KnownFwVol->FwVolHeader == FwVolHeader) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,7 +910,7 @@ MmDisplayDiscoveredNotDispatched (
|
|||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
EFI_MM_DRIVER_ENTRY *DriverEntry;
|
EFI_MM_DRIVER_ENTRY *DriverEntry;
|
||||||
|
|
||||||
for (Link = mDiscoveredList.ForwardLink;Link !=&mDiscoveredList; Link = Link->ForwardLink) {
|
for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
|
||||||
DriverEntry = CR (Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
|
DriverEntry = CR (Link, EFI_MM_DRIVER_ENTRY, Link, EFI_MM_DRIVER_ENTRY_SIGNATURE);
|
||||||
if (DriverEntry->Dependent) {
|
if (DriverEntry->Dependent) {
|
||||||
DEBUG ((DEBUG_LOAD, "MM Driver %g was discovered but not loaded!!\n", &DriverEntry->FileName));
|
DEBUG ((DEBUG_LOAD, "MM Driver %g was discovered but not loaded!!\n", &DriverEntry->FileName));
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
//
|
//
|
||||||
EFI_FV_FILETYPE mMmFileTypes[] = {
|
EFI_FV_FILETYPE mMmFileTypes[] = {
|
||||||
EFI_FV_FILETYPE_MM,
|
EFI_FV_FILETYPE_MM,
|
||||||
0xE, //EFI_FV_FILETYPE_MM_STANDALONE,
|
0xE, // EFI_FV_FILETYPE_MM_STANDALONE,
|
||||||
//
|
//
|
||||||
// Note: DXE core will process the FV image file, so skip it in MM core
|
// Note: DXE core will process the FV image file, so skip it in MM core
|
||||||
// EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
|
// EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
|
||||||
@@ -95,19 +95,32 @@ MmCoreFfsFindMmDriver (
|
|||||||
//
|
//
|
||||||
FileHeader = NULL;
|
FileHeader = NULL;
|
||||||
do {
|
do {
|
||||||
Status = FfsFindNextFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,
|
Status = FfsFindNextFile (
|
||||||
FwVolHeader, &FileHeader);
|
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE,
|
||||||
|
FwVolHeader,
|
||||||
|
&FileHeader
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Status = FfsFindSectionData (EFI_SECTION_GUID_DEFINED, FileHeader,
|
|
||||||
&SectionData, &SectionDataSize);
|
Status = FfsFindSectionData (
|
||||||
|
EFI_SECTION_GUID_DEFINED,
|
||||||
|
FileHeader,
|
||||||
|
&SectionData,
|
||||||
|
&SectionDataSize
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
|
Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
|
||||||
Status = ExtractGuidedSectionGetInfo (Section, &DstBufferSize,
|
Status = ExtractGuidedSectionGetInfo (
|
||||||
&ScratchBufferSize, &SectionAttribute);
|
Section,
|
||||||
|
&DstBufferSize,
|
||||||
|
&ScratchBufferSize,
|
||||||
|
&SectionAttribute
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -131,19 +144,29 @@ MmCoreFfsFindMmDriver (
|
|||||||
//
|
//
|
||||||
// Call decompress function
|
// Call decompress function
|
||||||
//
|
//
|
||||||
Status = ExtractGuidedSectionDecode (Section, &DstBuffer, ScratchBuffer,
|
Status = ExtractGuidedSectionDecode (
|
||||||
&AuthenticationStatus);
|
Section,
|
||||||
|
&DstBuffer,
|
||||||
|
ScratchBuffer,
|
||||||
|
&AuthenticationStatus
|
||||||
|
);
|
||||||
FreePages (ScratchBuffer, EFI_SIZE_TO_PAGES (ScratchBufferSize));
|
FreePages (ScratchBuffer, EFI_SIZE_TO_PAGES (ScratchBufferSize));
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto FreeDstBuffer;
|
goto FreeDstBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO,
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"Processing compressed firmware volume (AuthenticationStatus == %x)\n",
|
"Processing compressed firmware volume (AuthenticationStatus == %x)\n",
|
||||||
AuthenticationStatus));
|
AuthenticationStatus
|
||||||
|
));
|
||||||
|
|
||||||
Status = FindFfsSectionInSections (DstBuffer, DstBufferSize,
|
Status = FindFfsSectionInSections (
|
||||||
EFI_SECTION_FIRMWARE_VOLUME_IMAGE, &Section);
|
DstBuffer,
|
||||||
|
DstBufferSize,
|
||||||
|
EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
|
||||||
|
&Section
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto FreeDstBuffer;
|
goto FreeDstBuffer;
|
||||||
}
|
}
|
||||||
|
@@ -36,9 +36,11 @@ MmValidateHandle (
|
|||||||
if (Handle == NULL) {
|
if (Handle == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Handle->Signature != EFI_HANDLE_SIGNATURE) {
|
if (Handle->Signature != EFI_HANDLE_SIGNATURE) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +70,8 @@ MmFindProtocolEntry (
|
|||||||
ProtEntry = NULL;
|
ProtEntry = NULL;
|
||||||
for (Link = mProtocolDatabase.ForwardLink;
|
for (Link = mProtocolDatabase.ForwardLink;
|
||||||
Link != &mProtocolDatabase;
|
Link != &mProtocolDatabase;
|
||||||
Link = Link->ForwardLink) {
|
Link = Link->ForwardLink)
|
||||||
|
{
|
||||||
Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
|
Item = CR (Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
|
||||||
if (CompareGuid (&Item->ProtocolID, Protocol)) {
|
if (CompareGuid (&Item->ProtocolID, Protocol)) {
|
||||||
//
|
//
|
||||||
@@ -85,7 +87,7 @@ MmFindProtocolEntry (
|
|||||||
// allocate a new entry
|
// allocate a new entry
|
||||||
//
|
//
|
||||||
if ((ProtEntry == NULL) && Create) {
|
if ((ProtEntry == NULL) && Create) {
|
||||||
ProtEntry = AllocatePool (sizeof(PROTOCOL_ENTRY));
|
ProtEntry = AllocatePool (sizeof (PROTOCOL_ENTRY));
|
||||||
if (ProtEntry != NULL) {
|
if (ProtEntry != NULL) {
|
||||||
//
|
//
|
||||||
// Initialize new protocol entry structure
|
// Initialize new protocol entry structure
|
||||||
@@ -101,6 +103,7 @@ MmFindProtocolEntry (
|
|||||||
InsertTailList (&mProtocolDatabase, &ProtEntry->AllEntries);
|
InsertTailList (&mProtocolDatabase, &ProtEntry->AllEntries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ProtEntry;
|
return ProtEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,17 +140,19 @@ MmFindProtocolInterface (
|
|||||||
//
|
//
|
||||||
// Look at each protocol interface for any matches
|
// Look at each protocol interface for any matches
|
||||||
//
|
//
|
||||||
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link=Link->ForwardLink) {
|
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
|
||||||
//
|
//
|
||||||
// If this protocol interface matches, remove it
|
// If this protocol interface matches, remove it
|
||||||
//
|
//
|
||||||
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
Prot = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
|
||||||
if (Prot->Interface == Interface && Prot->Protocol == ProtEntry) {
|
if ((Prot->Interface == Interface) && (Prot->Protocol == ProtEntry)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Prot = NULL;
|
Prot = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Prot;
|
return Prot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +224,7 @@ MmInstallProtocolInterfaceNotify (
|
|||||||
// returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
|
// returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
|
||||||
// Also added check for invalid UserHandle and Protocol pointers.
|
// Also added check for invalid UserHandle and Protocol pointers.
|
||||||
//
|
//
|
||||||
if (UserHandle == NULL || Protocol == NULL) {
|
if ((UserHandle == NULL) || (Protocol == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,6 +325,7 @@ MmInstallProtocolInterfaceNotify (
|
|||||||
if (Notify) {
|
if (Notify) {
|
||||||
MmNotifyProtocol (Prot);
|
MmNotifyProtocol (Prot);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
@@ -336,6 +342,7 @@ Done:
|
|||||||
FreePool (Prot);
|
FreePool (Prot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,6 +423,7 @@ MmUninstallProtocolInterface (
|
|||||||
RemoveEntryList (&Handle->AllHandles);
|
RemoveEntryList (&Handle->AllHandles);
|
||||||
FreePool (Handle);
|
FreePool (Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +465,7 @@ MmGetProtocolInterface (
|
|||||||
return Prot;
|
return Prot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,7 +87,6 @@ MmInstallConfigurationTable (
|
|||||||
&(ConfigurationTable[Index + 1]),
|
&(ConfigurationTable[Index + 1]),
|
||||||
(gMmCoreMmst.NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
|
(gMmCoreMmst.NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// No matching GUIDs were found, so this is an add operation.
|
// No matching GUIDs were found, so this is an add operation.
|
||||||
|
@@ -27,7 +27,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef
|
typedef
|
||||||
IHANDLE *
|
IHANDLE *
|
||||||
(* CORE_GET_NEXT) (
|
(*CORE_GET_NEXT) (
|
||||||
IN OUT LOCATE_POSITION *Position,
|
IN OUT LOCATE_POSITION *Position,
|
||||||
OUT VOID **Interface
|
OUT VOID **Interface
|
||||||
);
|
);
|
||||||
@@ -64,6 +64,7 @@ MmGetNextLocateAllHandles (
|
|||||||
if (Position->Position != &gHandleList) {
|
if (Position->Position != &gHandleList) {
|
||||||
Handle = CR (Position->Position, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
|
Handle = CR (Position->Position, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Handle;
|
return Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +112,7 @@ MmGetNextLocateByRegisterNotify (
|
|||||||
*Interface = Prot->Interface;
|
*Interface = Prot->Interface;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Handle;
|
return Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +139,7 @@ MmGetNextLocateByProtocol (
|
|||||||
|
|
||||||
Handle = NULL;
|
Handle = NULL;
|
||||||
*Interface = NULL;
|
*Interface = NULL;
|
||||||
for (; ;) {
|
for ( ; ;) {
|
||||||
//
|
//
|
||||||
// Next entry
|
// Next entry
|
||||||
//
|
//
|
||||||
@@ -168,6 +170,7 @@ MmGetNextLocateByProtocol (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Handle;
|
return Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,6 +227,7 @@ MmLocateProtocol (
|
|||||||
if (Position.ProtEntry == NULL) {
|
if (Position.ProtEntry == NULL) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position.Position = &Position.ProtEntry->Protocols;
|
Position.Position = &Position.ProtEntry->Protocols;
|
||||||
|
|
||||||
Handle = MmGetNextLocateByProtocol (&Position, Interface);
|
Handle = MmGetNextLocateByProtocol (&Position, Interface);
|
||||||
@@ -300,7 +304,7 @@ MmLocateHandle (
|
|||||||
Position.Position = &gHandleList;
|
Position.Position = &gHandleList;
|
||||||
|
|
||||||
ResultSize = 0;
|
ResultSize = 0;
|
||||||
ResultBuffer = (IHANDLE **) Buffer;
|
ResultBuffer = (IHANDLE **)Buffer;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -319,6 +323,7 @@ MmLocateHandle (
|
|||||||
if (SearchKey == NULL) {
|
if (SearchKey == NULL) {
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ByProtocol:
|
case ByProtocol:
|
||||||
@@ -327,6 +332,7 @@ MmLocateHandle (
|
|||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Look up the protocol entry and set the head pointer
|
// Look up the protocol entry and set the head pointer
|
||||||
//
|
//
|
||||||
@@ -335,6 +341,7 @@ MmLocateHandle (
|
|||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position.Position = &Position.ProtEntry->Protocols;
|
Position.Position = &Position.ProtEntry->Protocols;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -351,7 +358,7 @@ MmLocateHandle (
|
|||||||
// Enumerate out the matching handles
|
// Enumerate out the matching handles
|
||||||
//
|
//
|
||||||
mEfiLocateHandleRequest += 1;
|
mEfiLocateHandleRequest += 1;
|
||||||
for (; ;) {
|
for ( ; ;) {
|
||||||
//
|
//
|
||||||
// Get the next handle. If no more handles, stop
|
// Get the next handle. If no more handles, stop
|
||||||
//
|
//
|
||||||
@@ -388,7 +395,7 @@ MmLocateHandle (
|
|||||||
|
|
||||||
*BufferSize = ResultSize;
|
*BufferSize = ResultSize;
|
||||||
|
|
||||||
if (SearchType == ByRegisterNotify && !EFI_ERROR (Status)) {
|
if ((SearchType == ByRegisterNotify) && !EFI_ERROR (Status)) {
|
||||||
ASSERT (SearchKey != NULL);
|
ASSERT (SearchKey != NULL);
|
||||||
//
|
//
|
||||||
// If this is a search by register notify and a handle was
|
// If this is a search by register notify and a handle was
|
||||||
@@ -461,10 +468,11 @@ MmLocateHandleBuffer (
|
|||||||
//
|
//
|
||||||
// Add code to correctly handle expected errors from MmLocateHandle().
|
// Add code to correctly handle expected errors from MmLocateHandle().
|
||||||
//
|
//
|
||||||
if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
|
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
|
||||||
if (Status != EFI_INVALID_PARAMETER) {
|
if (Status != EFI_INVALID_PARAMETER) {
|
||||||
Status = EFI_NOT_FOUND;
|
Status = EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,7 +489,7 @@ MmLocateHandleBuffer (
|
|||||||
*Buffer
|
*Buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
|
*NumberHandles = BufferSize / sizeof (EFI_HANDLE);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
*NumberHandles = 0;
|
*NumberHandles = 0;
|
||||||
}
|
}
|
||||||
|
@@ -65,8 +65,8 @@ MmCoreFindMmiEntry (
|
|||||||
MmiEntry = NULL;
|
MmiEntry = NULL;
|
||||||
for (Link = mMmiEntryList.ForwardLink;
|
for (Link = mMmiEntryList.ForwardLink;
|
||||||
Link != &mMmiEntryList;
|
Link != &mMmiEntryList;
|
||||||
Link = Link->ForwardLink) {
|
Link = Link->ForwardLink)
|
||||||
|
{
|
||||||
Item = CR (Link, MMI_ENTRY, AllEntries, MMI_ENTRY_SIGNATURE);
|
Item = CR (Link, MMI_ENTRY, AllEntries, MMI_ENTRY_SIGNATURE);
|
||||||
if (CompareGuid (&Item->HandlerType, HandlerType)) {
|
if (CompareGuid (&Item->HandlerType, HandlerType)) {
|
||||||
//
|
//
|
||||||
@@ -97,6 +97,7 @@ MmCoreFindMmiEntry (
|
|||||||
InsertTailList (&mMmiEntryList, &MmiEntry->AllEntries);
|
InsertTailList (&mMmiEntryList, &MmiEntry->AllEntries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MmiEntry;
|
return MmiEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +143,7 @@ MmiManage (
|
|||||||
//
|
//
|
||||||
// Non-root MMI handler
|
// Non-root MMI handler
|
||||||
//
|
//
|
||||||
MmiEntry = MmCoreFindMmiEntry ((EFI_GUID *) HandlerType, FALSE);
|
MmiEntry = MmCoreFindMmiEntry ((EFI_GUID *)HandlerType, FALSE);
|
||||||
if (MmiEntry == NULL) {
|
if (MmiEntry == NULL) {
|
||||||
//
|
//
|
||||||
// There is no handler registered for this interrupt source
|
// There is no handler registered for this interrupt source
|
||||||
@@ -157,7 +158,7 @@ MmiManage (
|
|||||||
MmiHandler = CR (Link, MMI_HANDLER, Link, MMI_HANDLER_SIGNATURE);
|
MmiHandler = CR (Link, MMI_HANDLER, Link, MMI_HANDLER_SIGNATURE);
|
||||||
|
|
||||||
Status = MmiHandler->Handler (
|
Status = MmiHandler->Handler (
|
||||||
(EFI_HANDLE) MmiHandler,
|
(EFI_HANDLE)MmiHandler,
|
||||||
Context,
|
Context,
|
||||||
CommBuffer,
|
CommBuffer,
|
||||||
CommBufferSize
|
CommBufferSize
|
||||||
@@ -172,6 +173,7 @@ MmiManage (
|
|||||||
if (HandlerType != NULL) {
|
if (HandlerType != NULL) {
|
||||||
return EFI_INTERRUPT_PENDING;
|
return EFI_INTERRUPT_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_SUCCESS:
|
case EFI_SUCCESS:
|
||||||
@@ -183,6 +185,7 @@ MmiManage (
|
|||||||
if (HandlerType != NULL) {
|
if (HandlerType != NULL) {
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SuccessReturn = TRUE;
|
SuccessReturn = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -240,7 +243,7 @@ MmiHandlerRegister (
|
|||||||
MMI_ENTRY *MmiEntry;
|
MMI_ENTRY *MmiEntry;
|
||||||
LIST_ENTRY *List;
|
LIST_ENTRY *List;
|
||||||
|
|
||||||
if (Handler == NULL || DispatchHandle == NULL) {
|
if ((Handler == NULL) || (DispatchHandle == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +265,7 @@ MmiHandlerRegister (
|
|||||||
//
|
//
|
||||||
// None root MMI handler
|
// None root MMI handler
|
||||||
//
|
//
|
||||||
MmiEntry = MmCoreFindMmiEntry ((EFI_GUID *) HandlerType, TRUE);
|
MmiEntry = MmCoreFindMmiEntry ((EFI_GUID *)HandlerType, TRUE);
|
||||||
if (MmiEntry == NULL) {
|
if (MmiEntry == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@@ -273,7 +276,7 @@ MmiHandlerRegister (
|
|||||||
MmiHandler->MmiEntry = MmiEntry;
|
MmiHandler->MmiEntry = MmiEntry;
|
||||||
InsertTailList (List, &MmiHandler->Link);
|
InsertTailList (List, &MmiHandler->Link);
|
||||||
|
|
||||||
*DispatchHandle = (EFI_HANDLE) MmiHandler;
|
*DispatchHandle = (EFI_HANDLE)MmiHandler;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -296,7 +299,7 @@ MmiHandlerUnRegister (
|
|||||||
MMI_HANDLER *MmiHandler;
|
MMI_HANDLER *MmiHandler;
|
||||||
MMI_ENTRY *MmiEntry;
|
MMI_ENTRY *MmiEntry;
|
||||||
|
|
||||||
MmiHandler = (MMI_HANDLER *) DispatchHandle;
|
MmiHandler = (MMI_HANDLER *)DispatchHandle;
|
||||||
|
|
||||||
if (MmiHandler == NULL) {
|
if (MmiHandler == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
@@ -25,7 +25,7 @@ MmNotifyProtocol (
|
|||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
|
|
||||||
ProtEntry = Prot->Protocol;
|
ProtEntry = Prot->Protocol;
|
||||||
for (Link=ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
|
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
|
||||||
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||||
ProtNotify->Function (&ProtEntry->ProtocolID, Prot->Interface, Prot->Handle);
|
ProtNotify->Function (&ProtEntry->ProtocolID, Prot->Interface, Prot->Handle);
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,6 @@ MmRemoveInterfaceFromProtocol (
|
|||||||
|
|
||||||
Prot = MmFindProtocolInterface (Handle, Protocol, Interface);
|
Prot = MmFindProtocolInterface (Handle, Protocol, Interface);
|
||||||
if (Prot != NULL) {
|
if (Prot != NULL) {
|
||||||
|
|
||||||
ProtEntry = Prot->Protocol;
|
ProtEntry = Prot->Protocol;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -106,7 +105,7 @@ MmRegisterProtocolNotify (
|
|||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
if (Protocol == NULL || Registration == NULL) {
|
if ((Protocol == NULL) || (Registration == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,12 +113,13 @@ MmRegisterProtocolNotify (
|
|||||||
//
|
//
|
||||||
// Get the protocol entry per Protocol
|
// Get the protocol entry per Protocol
|
||||||
//
|
//
|
||||||
ProtEntry = MmFindProtocolEntry ((EFI_GUID *) Protocol, FALSE);
|
ProtEntry = MmFindProtocolEntry ((EFI_GUID *)Protocol, FALSE);
|
||||||
if (ProtEntry != NULL) {
|
if (ProtEntry != NULL) {
|
||||||
ProtNotify = (PROTOCOL_NOTIFY * )*Registration;
|
ProtNotify = (PROTOCOL_NOTIFY *)*Registration;
|
||||||
for (Link = ProtEntry->Notify.ForwardLink;
|
for (Link = ProtEntry->Notify.ForwardLink;
|
||||||
Link != &ProtEntry->Notify;
|
Link != &ProtEntry->Notify;
|
||||||
Link = Link->ForwardLink) {
|
Link = Link->ForwardLink)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Compare the notification record
|
// Compare the notification record
|
||||||
//
|
//
|
||||||
@@ -134,6 +134,7 @@ MmRegisterProtocolNotify (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If the registration is not found
|
// If the registration is not found
|
||||||
//
|
//
|
||||||
@@ -145,19 +146,19 @@ MmRegisterProtocolNotify (
|
|||||||
//
|
//
|
||||||
// Get the protocol entry to add the notification too
|
// Get the protocol entry to add the notification too
|
||||||
//
|
//
|
||||||
ProtEntry = MmFindProtocolEntry ((EFI_GUID *) Protocol, TRUE);
|
ProtEntry = MmFindProtocolEntry ((EFI_GUID *)Protocol, TRUE);
|
||||||
if (ProtEntry != NULL) {
|
if (ProtEntry != NULL) {
|
||||||
//
|
//
|
||||||
// Find whether notification already exist
|
// Find whether notification already exist
|
||||||
//
|
//
|
||||||
for (Link = ProtEntry->Notify.ForwardLink;
|
for (Link = ProtEntry->Notify.ForwardLink;
|
||||||
Link != &ProtEntry->Notify;
|
Link != &ProtEntry->Notify;
|
||||||
Link = Link->ForwardLink) {
|
Link = Link->ForwardLink)
|
||||||
|
{
|
||||||
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
|
||||||
if (CompareGuid (&ProtNotify->Protocol->ProtocolID, Protocol) &&
|
if (CompareGuid (&ProtNotify->Protocol->ProtocolID, Protocol) &&
|
||||||
(ProtNotify->Function == Function)) {
|
(ProtNotify->Function == Function))
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Notification already exist
|
// Notification already exist
|
||||||
//
|
//
|
||||||
@@ -193,5 +194,6 @@ MmRegisterProtocolNotify (
|
|||||||
*Registration = ProtNotify;
|
*Registration = ProtNotify;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@@ -43,10 +43,11 @@ InternalAllocPagesOnOneNode (
|
|||||||
if (Top > Pages->NumberOfPages) {
|
if (Top > Pages->NumberOfPages) {
|
||||||
Top = Pages->NumberOfPages;
|
Top = Pages->NumberOfPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bottom = Top - NumberOfPages;
|
Bottom = Top - NumberOfPages;
|
||||||
|
|
||||||
if (Top < Pages->NumberOfPages) {
|
if (Top < Pages->NumberOfPages) {
|
||||||
Node = (FREE_PAGE_LIST*)((UINTN)Pages + EFI_PAGES_TO_SIZE (Top));
|
Node = (FREE_PAGE_LIST *)((UINTN)Pages + EFI_PAGES_TO_SIZE (Top));
|
||||||
Node->NumberOfPages = Pages->NumberOfPages - Top;
|
Node->NumberOfPages = Pages->NumberOfPages - Top;
|
||||||
InsertHeadList (&Pages->Link, &Node->Link);
|
InsertHeadList (&Pages->Link, &Node->Link);
|
||||||
}
|
}
|
||||||
@@ -82,11 +83,13 @@ InternalAllocMaxAddress (
|
|||||||
|
|
||||||
for (Node = FreePageList->BackLink; Node != FreePageList; Node = Node->BackLink) {
|
for (Node = FreePageList->BackLink; Node != FreePageList; Node = Node->BackLink) {
|
||||||
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
|
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
|
||||||
if (Pages->NumberOfPages >= NumberOfPages &&
|
if ((Pages->NumberOfPages >= NumberOfPages) &&
|
||||||
(UINTN)Pages + EFI_PAGES_TO_SIZE (NumberOfPages) - 1 <= MaxAddress) {
|
((UINTN)Pages + EFI_PAGES_TO_SIZE (NumberOfPages) - 1 <= MaxAddress))
|
||||||
|
{
|
||||||
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, MaxAddress);
|
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, MaxAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UINTN)(-1);
|
return (UINTN)(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,15 +119,17 @@ InternalAllocAddress (
|
|||||||
}
|
}
|
||||||
|
|
||||||
EndAddress = Address + EFI_PAGES_TO_SIZE (NumberOfPages);
|
EndAddress = Address + EFI_PAGES_TO_SIZE (NumberOfPages);
|
||||||
for (Node = FreePageList->BackLink; Node!= FreePageList; Node = Node->BackLink) {
|
for (Node = FreePageList->BackLink; Node != FreePageList; Node = Node->BackLink) {
|
||||||
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
|
Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
|
||||||
if ((UINTN)Pages <= Address) {
|
if ((UINTN)Pages <= Address) {
|
||||||
if ((UINTN)Pages + EFI_PAGES_TO_SIZE (Pages->NumberOfPages) < EndAddress) {
|
if ((UINTN)Pages + EFI_PAGES_TO_SIZE (Pages->NumberOfPages) < EndAddress) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, EndAddress);
|
return InternalAllocPagesOnOneNode (Pages, NumberOfPages, EndAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ~Address;
|
return ~Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +160,9 @@ MmInternalAllocatePages (
|
|||||||
{
|
{
|
||||||
UINTN RequestedAddress;
|
UINTN RequestedAddress;
|
||||||
|
|
||||||
if (MemoryType != EfiRuntimeServicesCode &&
|
if ((MemoryType != EfiRuntimeServicesCode) &&
|
||||||
MemoryType != EfiRuntimeServicesData) {
|
(MemoryType != EfiRuntimeServicesData))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,6 +186,7 @@ MmInternalAllocatePages (
|
|||||||
if (*Memory == (UINTN)-1) {
|
if (*Memory == (UINTN)-1) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AllocateAddress:
|
case AllocateAddress:
|
||||||
*Memory = InternalAllocAddress (
|
*Memory = InternalAllocAddress (
|
||||||
@@ -190,10 +197,12 @@ MmInternalAllocatePages (
|
|||||||
if (*Memory != RequestedAddress) {
|
if (*Memory != RequestedAddress) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,13 +254,15 @@ InternalMergeNodes (
|
|||||||
|
|
||||||
Next = BASE_CR (First->Link.ForwardLink, FREE_PAGE_LIST, Link);
|
Next = BASE_CR (First->Link.ForwardLink, FREE_PAGE_LIST, Link);
|
||||||
ASSERT (
|
ASSERT (
|
||||||
TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) >= First->NumberOfPages);
|
TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) >= First->NumberOfPages
|
||||||
|
);
|
||||||
|
|
||||||
if (TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) == First->NumberOfPages) {
|
if (TRUNCATE_TO_PAGES ((UINTN)Next - (UINTN)First) == First->NumberOfPages) {
|
||||||
First->NumberOfPages += Next->NumberOfPages;
|
First->NumberOfPages += Next->NumberOfPages;
|
||||||
RemoveEntryList (&Next->Link);
|
RemoveEntryList (&Next->Link);
|
||||||
Next = First;
|
Next = First;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Next;
|
return Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,11 +298,13 @@ MmInternalFreePages (
|
|||||||
if (Memory < (UINTN)Pages) {
|
if (Memory < (UINTN)Pages) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node = Node->ForwardLink;
|
Node = Node->ForwardLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Node != &mMmMemoryMap &&
|
if ((Node != &mMmMemoryMap) &&
|
||||||
Memory + EFI_PAGES_TO_SIZE (NumberOfPages) > (UINTN)Pages) {
|
(Memory + EFI_PAGES_TO_SIZE (NumberOfPages) > (UINTN)Pages))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +315,7 @@ MmInternalFreePages (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pages = (FREE_PAGE_LIST*)(UINTN)Memory;
|
Pages = (FREE_PAGE_LIST *)(UINTN)Memory;
|
||||||
Pages->NumberOfPages = NumberOfPages;
|
Pages->NumberOfPages = NumberOfPages;
|
||||||
InsertTailList (Node, &Pages->Link);
|
InsertTailList (Node, &Pages->Link);
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ MmInitializeMemoryServices (
|
|||||||
InitializeListHead (&mMmPoolLists[--Index]);
|
InitializeListHead (&mMmPoolLists[--Index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize free MMRAM regions
|
// Initialize free MMRAM regions
|
||||||
//
|
//
|
||||||
@@ -49,8 +48,14 @@ MmInitializeMemoryServices (
|
|||||||
if (MmramRanges[Index].CpuStart < BASE_1MB) {
|
if (MmramRanges[Index].CpuStart < BASE_1MB) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DEBUG ((DEBUG_INFO, "MmAddMemoryRegion %d : 0x%016lx - 0x%016lx\n",
|
|
||||||
Index, MmramRanges[Index].CpuStart, MmramRanges[Index].PhysicalSize));
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"MmAddMemoryRegion %d : 0x%016lx - 0x%016lx\n",
|
||||||
|
Index,
|
||||||
|
MmramRanges[Index].CpuStart,
|
||||||
|
MmramRanges[Index].PhysicalSize
|
||||||
|
));
|
||||||
MmAddMemoryRegion (
|
MmAddMemoryRegion (
|
||||||
MmramRanges[Index].CpuStart,
|
MmramRanges[Index].CpuStart,
|
||||||
MmramRanges[Index].PhysicalSize,
|
MmramRanges[Index].PhysicalSize,
|
||||||
@@ -58,7 +63,6 @@ MmInitializeMemoryServices (
|
|||||||
MmramRanges[Index].RegionState
|
MmramRanges[Index].RegionState
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +98,8 @@ InternalAllocPoolByIndex (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
Hdr = (FREE_POOL_HEADER *) (UINTN) Address;
|
|
||||||
|
Hdr = (FREE_POOL_HEADER *)(UINTN)Address;
|
||||||
} else if (!IsListEmpty (&mMmPoolLists[PoolIndex])) {
|
} else if (!IsListEmpty (&mMmPoolLists[PoolIndex])) {
|
||||||
Hdr = BASE_CR (GetFirstNode (&mMmPoolLists[PoolIndex]), FREE_POOL_HEADER, Link);
|
Hdr = BASE_CR (GetFirstNode (&mMmPoolLists[PoolIndex]), FREE_POOL_HEADER, Link);
|
||||||
RemoveEntryList (&Hdr->Link);
|
RemoveEntryList (&Hdr->Link);
|
||||||
@@ -104,7 +109,7 @@ InternalAllocPoolByIndex (
|
|||||||
Hdr->Header.Size >>= 1;
|
Hdr->Header.Size >>= 1;
|
||||||
Hdr->Header.Available = TRUE;
|
Hdr->Header.Available = TRUE;
|
||||||
InsertHeadList (&mMmPoolLists[PoolIndex], &Hdr->Link);
|
InsertHeadList (&mMmPoolLists[PoolIndex], &Hdr->Link);
|
||||||
Hdr = (FREE_POOL_HEADER*)((UINT8*)Hdr + Hdr->Header.Size);
|
Hdr = (FREE_POOL_HEADER *)((UINT8 *)Hdr + Hdr->Header.Size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +141,7 @@ InternalFreePoolByIndex (
|
|||||||
ASSERT (((UINTN)FreePoolHdr & (FreePoolHdr->Header.Size - 1)) == 0);
|
ASSERT (((UINTN)FreePoolHdr & (FreePoolHdr->Header.Size - 1)) == 0);
|
||||||
ASSERT (FreePoolHdr->Header.Size >= MIN_POOL_SIZE);
|
ASSERT (FreePoolHdr->Header.Size >= MIN_POOL_SIZE);
|
||||||
|
|
||||||
PoolIndex = (UINTN) (HighBitSet32 ((UINT32)FreePoolHdr->Header.Size) - MIN_POOL_SHIFT);
|
PoolIndex = (UINTN)(HighBitSet32 ((UINT32)FreePoolHdr->Header.Size) - MIN_POOL_SHIFT);
|
||||||
FreePoolHdr->Header.Available = TRUE;
|
FreePoolHdr->Header.Available = TRUE;
|
||||||
ASSERT (PoolIndex < MAX_POOL_INDEX);
|
ASSERT (PoolIndex < MAX_POOL_INDEX);
|
||||||
InsertHeadList (&mMmPoolLists[PoolIndex], &FreePoolHdr->Link);
|
InsertHeadList (&mMmPoolLists[PoolIndex], &FreePoolHdr->Link);
|
||||||
@@ -170,8 +175,9 @@ MmInternalAllocatePool (
|
|||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
UINTN PoolIndex;
|
UINTN PoolIndex;
|
||||||
|
|
||||||
if (PoolType != EfiRuntimeServicesCode &&
|
if ((PoolType != EfiRuntimeServicesCode) &&
|
||||||
PoolType != EfiRuntimeServicesData) {
|
(PoolType != EfiRuntimeServicesData))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +189,7 @@ MmInternalAllocatePool (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolHdr = (POOL_HEADER*)(UINTN)Address;
|
PoolHdr = (POOL_HEADER *)(UINTN)Address;
|
||||||
PoolHdr->Size = EFI_PAGES_TO_SIZE (Size);
|
PoolHdr->Size = EFI_PAGES_TO_SIZE (Size);
|
||||||
PoolHdr->Available = FALSE;
|
PoolHdr->Available = FALSE;
|
||||||
*Buffer = PoolHdr + 1;
|
*Buffer = PoolHdr + 1;
|
||||||
@@ -191,7 +197,7 @@ MmInternalAllocatePool (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Size = (Size + MIN_POOL_SIZE - 1) >> MIN_POOL_SHIFT;
|
Size = (Size + MIN_POOL_SIZE - 1) >> MIN_POOL_SHIFT;
|
||||||
PoolIndex = (UINTN) HighBitSet32 ((UINT32)Size);
|
PoolIndex = (UINTN)HighBitSet32 ((UINT32)Size);
|
||||||
if ((Size & (Size - 1)) != 0) {
|
if ((Size & (Size - 1)) != 0) {
|
||||||
PoolIndex++;
|
PoolIndex++;
|
||||||
}
|
}
|
||||||
@@ -200,6 +206,7 @@ MmInternalAllocatePool (
|
|||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
*Buffer = &FreePoolHdr->Header + 1;
|
*Buffer = &FreePoolHdr->Header + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +258,7 @@ MmInternalFreePool (
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePoolHdr = (FREE_POOL_HEADER*)((POOL_HEADER*)Buffer - 1);
|
FreePoolHdr = (FREE_POOL_HEADER *)((POOL_HEADER *)Buffer - 1);
|
||||||
ASSERT (!FreePoolHdr->Header.Available);
|
ASSERT (!FreePoolHdr->Header.Available);
|
||||||
|
|
||||||
if (FreePoolHdr->Header.Size > MAX_POOL_SIZE) {
|
if (FreePoolHdr->Header.Size > MAX_POOL_SIZE) {
|
||||||
@@ -262,6 +269,7 @@ MmInternalFreePool (
|
|||||||
EFI_SIZE_TO_PAGES (FreePoolHdr->Header.Size)
|
EFI_SIZE_TO_PAGES (FreePoolHdr->Header.Size)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return InternalFreePoolByIndex (FreePoolHdr);
|
return InternalFreePoolByIndex (FreePoolHdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,6 @@ MM_CORE_PRIVATE_DATA *gMmCorePrivate;
|
|||||||
// MM Core global variable for MM System Table. Only accessed as a physical structure in MMRAM.
|
// MM Core global variable for MM System Table. Only accessed as a physical structure in MMRAM.
|
||||||
//
|
//
|
||||||
EFI_MM_SYSTEM_TABLE gMmCoreMmst = {
|
EFI_MM_SYSTEM_TABLE gMmCoreMmst = {
|
||||||
|
|
||||||
// The table header for the MMST.
|
// The table header for the MMST.
|
||||||
{
|
{
|
||||||
MM_MMST_SIGNATURE,
|
MM_MMST_SIGNATURE,
|
||||||
@@ -49,12 +48,12 @@ EFI_MM_SYSTEM_TABLE gMmCoreMmst = {
|
|||||||
// I/O Service
|
// I/O Service
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
(EFI_MM_CPU_IO) MmEfiNotAvailableYetArg5, // MmMemRead
|
(EFI_MM_CPU_IO)MmEfiNotAvailableYetArg5, // MmMemRead
|
||||||
(EFI_MM_CPU_IO) MmEfiNotAvailableYetArg5 // MmMemWrite
|
(EFI_MM_CPU_IO)MmEfiNotAvailableYetArg5 // MmMemWrite
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
(EFI_MM_CPU_IO) MmEfiNotAvailableYetArg5, // MmIoRead
|
(EFI_MM_CPU_IO)MmEfiNotAvailableYetArg5, // MmIoRead
|
||||||
(EFI_MM_CPU_IO) MmEfiNotAvailableYetArg5 // MmIoWrite
|
(EFI_MM_CPU_IO)MmEfiNotAvailableYetArg5 // MmIoWrite
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Runtime memory services
|
// Runtime memory services
|
||||||
@@ -87,7 +86,7 @@ EFI_MM_SYSTEM_TABLE gMmCoreMmst = {
|
|||||||
MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = {
|
MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = {
|
||||||
{ MmReadyToLockHandler, &gEfiDxeMmReadyToLockProtocolGuid, NULL, TRUE },
|
{ MmReadyToLockHandler, &gEfiDxeMmReadyToLockProtocolGuid, NULL, TRUE },
|
||||||
{ MmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, FALSE },
|
{ MmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, FALSE },
|
||||||
{ MmExitBootServiceHandler,&gEfiEventExitBootServicesGuid, NULL, FALSE },
|
{ MmExitBootServiceHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE },
|
||||||
{ MmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },
|
{ MmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },
|
||||||
{ NULL, NULL, NULL, FALSE },
|
{ NULL, NULL, NULL, FALSE },
|
||||||
};
|
};
|
||||||
@@ -162,6 +161,7 @@ MmExitBootServiceHandler (
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
mInExitBootServices = TRUE;
|
mInExitBootServices = TRUE;
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@@ -201,6 +201,7 @@ MmReadyToBootHandler (
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
mInReadyToBoot = TRUE;
|
mInReadyToBoot = TRUE;
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@@ -259,26 +260,25 @@ MmReadyToLockHandler (
|
|||||||
//
|
//
|
||||||
// Make sure MM CPU I/O 2 Protocol has been installed into the handle database
|
// Make sure MM CPU I/O 2 Protocol has been installed into the handle database
|
||||||
//
|
//
|
||||||
//Status = MmLocateProtocol (&EFI_MM_CPU_IO_PROTOCOL_GUID, NULL, &Interface);
|
// Status = MmLocateProtocol (&EFI_MM_CPU_IO_PROTOCOL_GUID, NULL, &Interface);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Print a message on a debug build if the MM CPU I/O 2 Protocol is not installed
|
// Print a message on a debug build if the MM CPU I/O 2 Protocol is not installed
|
||||||
//
|
//
|
||||||
//if (EFI_ERROR (Status)) {
|
// if (EFI_ERROR (Status)) {
|
||||||
//DEBUG ((DEBUG_ERROR, "\nSMM: SmmCpuIo Arch Protocol not present!!\n"));
|
// DEBUG ((DEBUG_ERROR, "\nSMM: SmmCpuIo Arch Protocol not present!!\n"));
|
||||||
//}
|
// }
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Assert if the CPU I/O 2 Protocol is not installed
|
// Assert if the CPU I/O 2 Protocol is not installed
|
||||||
//
|
//
|
||||||
//ASSERT_EFI_ERROR (Status);
|
// ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Display any drivers that were not dispatched because dependency expression
|
// Display any drivers that were not dispatched because dependency expression
|
||||||
// evaluated to false if this is a debug build
|
// evaluated to false if this is a debug build
|
||||||
//
|
//
|
||||||
//MmDisplayDiscoveredNotDispatched ();
|
// MmDisplayDiscoveredNotDispatched ();
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@@ -323,8 +323,6 @@ MmEndOfDxeHandler (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The main entry point to MM Foundation.
|
The main entry point to MM Foundation.
|
||||||
|
|
||||||
@@ -338,7 +336,7 @@ VOID
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
MmEntryPoint (
|
MmEntryPoint (
|
||||||
IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext
|
IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_MM_COMMUNICATE_HEADER *CommunicateHeader;
|
EFI_MM_COMMUNICATE_HEADER *CommunicateHeader;
|
||||||
@@ -353,7 +351,7 @@ MmEntryPoint (
|
|||||||
//
|
//
|
||||||
// Call platform hook before Mm Dispatch
|
// Call platform hook before Mm Dispatch
|
||||||
//
|
//
|
||||||
//PlatformHookBeforeMmDispatch ();
|
// PlatformHookBeforeMmDispatch ();
|
||||||
|
|
||||||
//
|
//
|
||||||
// If a legacy boot has occurred, then make sure gMmCorePrivate is not accessed
|
// If a legacy boot has occurred, then make sure gMmCorePrivate is not accessed
|
||||||
@@ -472,10 +470,11 @@ GetHobListSize (
|
|||||||
|
|
||||||
ASSERT (HobStart != NULL);
|
ASSERT (HobStart != NULL);
|
||||||
|
|
||||||
Hob.Raw = (UINT8 *) HobStart;
|
Hob.Raw = (UINT8 *)HobStart;
|
||||||
while (!END_OF_HOB_LIST (Hob)) {
|
while (!END_OF_HOB_LIST (Hob)) {
|
||||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Need plus END_OF_HOB_LIST
|
// Need plus END_OF_HOB_LIST
|
||||||
//
|
//
|
||||||
@@ -529,7 +528,7 @@ StandaloneMmMain (
|
|||||||
// Allocate and zero memory for a MM_CORE_PRIVATE_DATA table and then
|
// Allocate and zero memory for a MM_CORE_PRIVATE_DATA table and then
|
||||||
// initialise it
|
// initialise it
|
||||||
//
|
//
|
||||||
gMmCorePrivate = (MM_CORE_PRIVATE_DATA *) AllocateRuntimePages(EFI_SIZE_TO_PAGES(sizeof (MM_CORE_PRIVATE_DATA)));
|
gMmCorePrivate = (MM_CORE_PRIVATE_DATA *)AllocateRuntimePages (EFI_SIZE_TO_PAGES (sizeof (MM_CORE_PRIVATE_DATA)));
|
||||||
SetMem ((VOID *)(UINTN)gMmCorePrivate, sizeof (MM_CORE_PRIVATE_DATA), 0);
|
SetMem ((VOID *)(UINTN)gMmCorePrivate, sizeof (MM_CORE_PRIVATE_DATA), 0);
|
||||||
gMmCorePrivate->Signature = MM_CORE_PRIVATE_DATA_SIGNATURE;
|
gMmCorePrivate->Signature = MM_CORE_PRIVATE_DATA_SIGNATURE;
|
||||||
gMmCorePrivate->MmEntryPointRegistered = FALSE;
|
gMmCorePrivate->MmEntryPointRegistered = FALSE;
|
||||||
@@ -540,8 +539,9 @@ StandaloneMmMain (
|
|||||||
// Extract the MMRAM ranges from the MMRAM descriptor HOB
|
// Extract the MMRAM ranges from the MMRAM descriptor HOB
|
||||||
//
|
//
|
||||||
MmramRangesHob = GetNextGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, HobStart);
|
MmramRangesHob = GetNextGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, HobStart);
|
||||||
if (MmramRangesHob == NULL)
|
if (MmramRangesHob == NULL) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
|
MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
|
||||||
ASSERT (MmramRangesHobData != NULL);
|
ASSERT (MmramRangesHobData != NULL);
|
||||||
@@ -575,9 +575,13 @@ StandaloneMmMain (
|
|||||||
//
|
//
|
||||||
DEBUG ((DEBUG_INFO, "MmramRangeCount - 0x%x\n", MmramRangeCount));
|
DEBUG ((DEBUG_INFO, "MmramRangeCount - 0x%x\n", MmramRangeCount));
|
||||||
for (Index = 0; Index < MmramRangeCount; Index++) {
|
for (Index = 0; Index < MmramRangeCount; Index++) {
|
||||||
DEBUG ((DEBUG_INFO, "MmramRanges[%d]: 0x%016lx - 0x%lx\n", Index,
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"MmramRanges[%d]: 0x%016lx - 0x%lx\n",
|
||||||
|
Index,
|
||||||
MmramRanges[Index].CpuStart,
|
MmramRanges[Index].CpuStart,
|
||||||
MmramRanges[Index].PhysicalSize));
|
MmramRanges[Index].PhysicalSize
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -728,7 +728,7 @@ MmEfiNotAvailableYetArg5 (
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
//Functions used during debug builds
|
// Functions used during debug builds
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
#include <Pi/PiMmCis.h>
|
#include <Pi/PiMmCis.h>
|
||||||
|
|
||||||
|
|
||||||
#include <Library/ArmSvcLib.h>
|
#include <Library/ArmSvcLib.h>
|
||||||
#include <Library/ArmLib.h>
|
#include <Library/ArmLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
@@ -94,7 +93,8 @@ PiMmStandaloneArmTfCpuDriverEntry (
|
|||||||
// between synchronous and asynchronous events.
|
// between synchronous and asynchronous events.
|
||||||
//
|
//
|
||||||
if ((ARM_SMC_ID_MM_COMMUNICATE != EventId) &&
|
if ((ARM_SMC_ID_MM_COMMUNICATE != EventId) &&
|
||||||
(ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ != EventId)) {
|
(ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ != EventId))
|
||||||
|
{
|
||||||
DEBUG ((DEBUG_INFO, "UnRecognized Event - 0x%x\n", EventId));
|
DEBUG ((DEBUG_INFO, "UnRecognized Event - 0x%x\n", EventId));
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
@@ -109,17 +109,19 @@ PiMmStandaloneArmTfCpuDriverEntry (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=
|
if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=
|
||||||
(mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) {
|
(mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out the size of the buffer passed
|
// Find out the size of the buffer passed
|
||||||
NsCommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *) NsCommBufferAddr)->MessageLength +
|
NsCommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *)NsCommBufferAddr)->MessageLength +
|
||||||
sizeof (EFI_MM_COMMUNICATE_HEADER);
|
sizeof (EFI_MM_COMMUNICATE_HEADER);
|
||||||
|
|
||||||
// perform bounds check.
|
// perform bounds check.
|
||||||
if (NsCommBufferAddr + NsCommBufferSize >=
|
if (NsCommBufferAddr + NsCommBufferSize >=
|
||||||
mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize) {
|
mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)
|
||||||
|
{
|
||||||
return EFI_ACCESS_DENIED;
|
return EFI_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +131,7 @@ PiMmStandaloneArmTfCpuDriverEntry (
|
|||||||
Status = mMmst->MmAllocatePool (
|
Status = mMmst->MmAllocatePool (
|
||||||
EfiRuntimeServicesData,
|
EfiRuntimeServicesData,
|
||||||
NsCommBufferSize,
|
NsCommBufferSize,
|
||||||
(VOID **) &GuidedEventContext
|
(VOID **)&GuidedEventContext
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Status != EFI_SUCCESS) {
|
if (Status != EFI_SUCCESS) {
|
||||||
@@ -139,7 +141,7 @@ PiMmStandaloneArmTfCpuDriverEntry (
|
|||||||
|
|
||||||
// X1 contains the VA of the normal world memory accessible from
|
// X1 contains the VA of the normal world memory accessible from
|
||||||
// S-EL0
|
// S-EL0
|
||||||
CopyMem (GuidedEventContext, (CONST VOID *) NsCommBufferAddr, NsCommBufferSize);
|
CopyMem (GuidedEventContext, (CONST VOID *)NsCommBufferAddr, NsCommBufferSize);
|
||||||
|
|
||||||
// Stash the pointer to the allocated Event Context for this CPU
|
// Stash the pointer to the allocated Event Context for this CPU
|
||||||
PerCpuGuidedEventContext[CpuNumber] = GuidedEventContext;
|
PerCpuGuidedEventContext[CpuNumber] = GuidedEventContext;
|
||||||
@@ -164,12 +166,13 @@ PiMmStandaloneArmTfCpuDriverEntry (
|
|||||||
|
|
||||||
// Free the memory allocation done earlier and reset the per-cpu context
|
// Free the memory allocation done earlier and reset the per-cpu context
|
||||||
ASSERT (GuidedEventContext);
|
ASSERT (GuidedEventContext);
|
||||||
CopyMem ((VOID *)NsCommBufferAddr, (CONST VOID *) GuidedEventContext, NsCommBufferSize);
|
CopyMem ((VOID *)NsCommBufferAddr, (CONST VOID *)GuidedEventContext, NsCommBufferSize);
|
||||||
|
|
||||||
Status = mMmst->MmFreePool ((VOID *) GuidedEventContext);
|
Status = mMmst->MmFreePool ((VOID *)GuidedEventContext);
|
||||||
if (Status != EFI_SUCCESS) {
|
if (Status != EFI_SUCCESS) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
PerCpuGuidedEventContext[CpuNumber] = NULL;
|
PerCpuGuidedEventContext[CpuNumber] = NULL;
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
@@ -232,9 +235,12 @@ PiMmCpuTpFwRootMmiHandler (
|
|||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
|
||||||
PerCpuGuidedEventContext[CpuNumber],
|
PerCpuGuidedEventContext[CpuNumber],
|
||||||
PerCpuGuidedEventContext[CpuNumber]->MessageLength));
|
PerCpuGuidedEventContext[CpuNumber]->MessageLength
|
||||||
|
));
|
||||||
|
|
||||||
Status = mMmst->MmiManage (
|
Status = mMmst->MmiManage (
|
||||||
&PerCpuGuidedEventContext[CpuNumber]->HeaderGuid,
|
&PerCpuGuidedEventContext[CpuNumber]->HeaderGuid,
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
#include <Guid/ZeroGuid.h>
|
#include <Guid/ZeroGuid.h>
|
||||||
#include <Guid/MmramMemoryReserve.h>
|
#include <Guid/MmramMemoryReserve.h>
|
||||||
|
|
||||||
|
|
||||||
#include "StandaloneMmCpu.h"
|
#include "StandaloneMmCpu.h"
|
||||||
|
|
||||||
// GUID to identify HOB with whereabouts of communication buffer with Normal
|
// GUID to identify HOB with whereabouts of communication buffer with Normal
|
||||||
@@ -155,7 +154,7 @@ StandaloneMmCpuInitialize (
|
|||||||
Status = GetGuidedHobData (
|
Status = GetGuidedHobData (
|
||||||
HobStart,
|
HobStart,
|
||||||
&gEfiArmTfCpuDriverEpDescriptorGuid,
|
&gEfiArmTfCpuDriverEpDescriptorGuid,
|
||||||
(VOID **) &CpuDriverEntryPointDesc
|
(VOID **)&CpuDriverEntryPointDesc
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_INFO, "ArmTfCpuDriverEpDesc HOB data extraction failed - 0x%x\n", Status));
|
DEBUG ((DEBUG_INFO, "ArmTfCpuDriverEpDesc HOB data extraction failed - 0x%x\n", Status));
|
||||||
@@ -163,9 +162,12 @@ StandaloneMmCpuInitialize (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Share the entry point of the CPU driver
|
// Share the entry point of the CPU driver
|
||||||
DEBUG ((DEBUG_INFO, "Sharing Cpu Driver EP *0x%lx = 0x%lx\n",
|
DEBUG ((
|
||||||
(UINTN) CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr,
|
DEBUG_INFO,
|
||||||
(UINTN) PiMmStandaloneArmTfCpuDriverEntry));
|
"Sharing Cpu Driver EP *0x%lx = 0x%lx\n",
|
||||||
|
(UINTN)CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr,
|
||||||
|
(UINTN)PiMmStandaloneArmTfCpuDriverEntry
|
||||||
|
));
|
||||||
*(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandaloneArmTfCpuDriverEntry;
|
*(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) = PiMmStandaloneArmTfCpuDriverEntry;
|
||||||
|
|
||||||
// Find the descriptor that contains the whereabouts of the buffer for
|
// Find the descriptor that contains the whereabouts of the buffer for
|
||||||
@@ -173,17 +175,17 @@ StandaloneMmCpuInitialize (
|
|||||||
Status = GetGuidedHobData (
|
Status = GetGuidedHobData (
|
||||||
HobStart,
|
HobStart,
|
||||||
&gEfiStandaloneMmNonSecureBufferGuid,
|
&gEfiStandaloneMmNonSecureBufferGuid,
|
||||||
(VOID **) &NsCommBufMmramRange
|
(VOID **)&NsCommBufMmramRange
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_INFO, "NsCommBufMmramRange HOB data extraction failed - 0x%x\n", Status));
|
DEBUG ((DEBUG_INFO, "NsCommBufMmramRange HOB data extraction failed - 0x%x\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalStart - 0x%lx\n", (UINTN) NsCommBufMmramRange->PhysicalStart));
|
DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalStart - 0x%lx\n", (UINTN)NsCommBufMmramRange->PhysicalStart));
|
||||||
DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalSize - 0x%lx\n", (UINTN) NsCommBufMmramRange->PhysicalSize));
|
DEBUG ((DEBUG_INFO, "mNsCommBuffer.PhysicalSize - 0x%lx\n", (UINTN)NsCommBufMmramRange->PhysicalSize));
|
||||||
|
|
||||||
CopyMem (&mNsCommBuffer, NsCommBufMmramRange, sizeof(EFI_MMRAM_DESCRIPTOR));
|
CopyMem (&mNsCommBuffer, NsCommBufMmramRange, sizeof (EFI_MMRAM_DESCRIPTOR));
|
||||||
DEBUG ((DEBUG_INFO, "mNsCommBuffer: 0x%016lx - 0x%lx\n", mNsCommBuffer.CpuStart, mNsCommBuffer.PhysicalSize));
|
DEBUG ((DEBUG_INFO, "mNsCommBuffer: 0x%016lx - 0x%lx\n", mNsCommBuffer.CpuStart, mNsCommBuffer.PhysicalSize));
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -192,7 +194,7 @@ StandaloneMmCpuInitialize (
|
|||||||
Status = GetGuidedHobData (
|
Status = GetGuidedHobData (
|
||||||
HobStart,
|
HobStart,
|
||||||
&gMpInformationHobGuid,
|
&gMpInformationHobGuid,
|
||||||
(VOID **) &MpInformationHobData
|
(VOID **)&MpInformationHobData
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_INFO, "MpInformationHob extraction failed - 0x%x\n", Status));
|
DEBUG ((DEBUG_INFO, "MpInformationHob extraction failed - 0x%x\n", Status));
|
||||||
@@ -210,7 +212,7 @@ StandaloneMmCpuInitialize (
|
|||||||
Status = mMmst->MmAllocatePool (
|
Status = mMmst->MmAllocatePool (
|
||||||
EfiRuntimeServicesData,
|
EfiRuntimeServicesData,
|
||||||
MpInfoSize,
|
MpInfoSize,
|
||||||
(VOID **) &mMpInformationHobData
|
(VOID **)&mMpInformationHobData
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_INFO, "mMpInformationHobData mem alloc failed - 0x%x\n", Status));
|
DEBUG ((DEBUG_INFO, "mMpInformationHobData mem alloc failed - 0x%x\n", Status));
|
||||||
@@ -220,15 +222,21 @@ StandaloneMmCpuInitialize (
|
|||||||
CopyMem (mMpInformationHobData, MpInformationHobData, MpInfoSize);
|
CopyMem (mMpInformationHobData, MpInformationHobData, MpInfoSize);
|
||||||
|
|
||||||
// Print MP information
|
// Print MP information
|
||||||
DEBUG ((DEBUG_INFO, "mMpInformationHobData: 0x%016lx - 0x%lx\n",
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"mMpInformationHobData: 0x%016lx - 0x%lx\n",
|
||||||
mMpInformationHobData->NumberOfProcessors,
|
mMpInformationHobData->NumberOfProcessors,
|
||||||
mMpInformationHobData->NumberOfEnabledProcessors));
|
mMpInformationHobData->NumberOfEnabledProcessors
|
||||||
|
));
|
||||||
for (Index = 0; Index < mMpInformationHobData->NumberOfProcessors; Index++) {
|
for (Index = 0; Index < mMpInformationHobData->NumberOfProcessors; Index++) {
|
||||||
DEBUG ((DEBUG_INFO, "mMpInformationHobData[0x%lx]: %d, %d, %d\n",
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"mMpInformationHobData[0x%lx]: %d, %d, %d\n",
|
||||||
mMpInformationHobData->ProcessorInfoBuffer[Index].ProcessorId,
|
mMpInformationHobData->ProcessorInfoBuffer[Index].ProcessorId,
|
||||||
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Package,
|
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Package,
|
||||||
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Core,
|
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Core,
|
||||||
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Thread));
|
mMpInformationHobData->ProcessorInfoBuffer[Index].Location.Thread
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -240,11 +248,12 @@ StandaloneMmCpuInitialize (
|
|||||||
Status = mMmst->MmAllocatePool (
|
Status = mMmst->MmAllocatePool (
|
||||||
EfiRuntimeServicesData,
|
EfiRuntimeServicesData,
|
||||||
ArraySize,
|
ArraySize,
|
||||||
(VOID **) &PerCpuGuidedEventContext
|
(VOID **)&PerCpuGuidedEventContext
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_INFO, "PerCpuGuidedEventContext mem alloc failed - 0x%x\n", Status));
|
DEBUG ((DEBUG_INFO, "PerCpuGuidedEventContext mem alloc failed - 0x%x\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,6 @@ typedef struct {
|
|||||||
EFI_PHYSICAL_ADDRESS Address;
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
} MM_CORE_DATA_HOB_DATA;
|
} MM_CORE_DATA_HOB_DATA;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Define values for the communications buffer used when gEfiEventDxeDispatchGuid is
|
/// Define values for the communications buffer used when gEfiEventDxeDispatchGuid is
|
||||||
/// event signaled. This event is signaled by the DXE Core each time the DXE Core
|
/// event signaled. This event is signaled by the DXE Core each time the DXE Core
|
||||||
|
@@ -53,4 +53,3 @@ typedef struct {
|
|||||||
extern EFI_GUID gEfiMmPeiSmramMemoryReserveGuid;
|
extern EFI_GUID gEfiMmPeiSmramMemoryReserveGuid;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -91,7 +91,6 @@ UpdateMmFoundationPeCoffPermissions (
|
|||||||
IN REGION_PERMISSION_UPDATE_FUNC ReadWriteUpdater
|
IN REGION_PERMISSION_UPDATE_FUNC ReadWriteUpdater
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Privileged firmware assigns RO & Executable attributes to all memory occupied
|
Privileged firmware assigns RO & Executable attributes to all memory occupied
|
||||||
by the Boot Firmware Volume. This function locates the section information of
|
by the Boot Firmware Volume. This function locates the section information of
|
||||||
@@ -115,7 +114,6 @@ GetStandaloneMmCorePeCoffSections (
|
|||||||
IN OUT UINT16 *NumberOfSections
|
IN OUT UINT16 *NumberOfSections
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Privileged firmware assigns RO & Executable attributes to all memory occupied
|
Privileged firmware assigns RO & Executable attributes to all memory occupied
|
||||||
by the Boot Firmware Volume. This function locates the Standalone MM Core
|
by the Boot Firmware Volume. This function locates the Standalone MM Core
|
||||||
@@ -135,7 +133,6 @@ LocateStandaloneMmCorePeCoffData (
|
|||||||
IN OUT UINTN *TeDataSize
|
IN OUT UINTN *TeDataSize
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Use the boot information passed by privileged firmware to populate a HOB list
|
Use the boot information passed by privileged firmware to populate a HOB list
|
||||||
suitable for consumption by the MM Core and drivers.
|
suitable for consumption by the MM Core and drivers.
|
||||||
@@ -152,7 +149,6 @@ CreateHobListFromBootInfo (
|
|||||||
IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
|
IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The entry point of Standalone MM Foundation.
|
The entry point of Standalone MM Foundation.
|
||||||
|
|
||||||
@@ -171,7 +167,6 @@ _ModuleEntryPoint (
|
|||||||
IN UINT64 cookie2
|
IN UINT64 cookie2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Auto generated function that calls the library constructors for all of the module's dependent libraries.
|
Auto generated function that calls the library constructors for all of the module's dependent libraries.
|
||||||
|
|
||||||
@@ -195,7 +190,6 @@ ProcessLibraryConstructorList (
|
|||||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Auto generated function that calls a set of module entry points.
|
Auto generated function that calls a set of module entry points.
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
///
|
///
|
||||||
extern VOID *gHobList;
|
extern VOID *gHobList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The entry point of PE/COFF Image for the STANDALONE MM Core.
|
The entry point of PE/COFF Image for the STANDALONE MM Core.
|
||||||
|
|
||||||
@@ -35,7 +34,6 @@ _ModuleEntryPoint (
|
|||||||
IN VOID *HobStart
|
IN VOID *HobStart
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
|
Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
|
||||||
|
|
||||||
@@ -50,7 +48,6 @@ EfiMain (
|
|||||||
IN VOID *HobStart
|
IN VOID *HobStart
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Auto generated function that calls the library constructors for all of the module's dependent libraries.
|
Auto generated function that calls the library constructors for all of the module's dependent libraries.
|
||||||
|
|
||||||
@@ -74,7 +71,6 @@ ProcessLibraryConstructorList (
|
|||||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Autogenerated function that calls a set of module entry points.
|
Autogenerated function that calls a set of module entry points.
|
||||||
|
|
||||||
|
@@ -15,14 +15,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
|
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *MM_IMAGE_ENTRY_POINT) (
|
(EFIAPI *MM_IMAGE_ENTRY_POINT)(
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
(EFIAPI *STANDALONE_MM_FOUNDATION_ENTRY_POINT) (
|
(EFIAPI *STANDALONE_MM_FOUNDATION_ENTRY_POINT)(
|
||||||
IN VOID *HobStart
|
IN VOID *HobStart
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ GetFileState (
|
|||||||
FileState = FfsHeader->State;
|
FileState = FfsHeader->State;
|
||||||
|
|
||||||
if (ErasePolarity != 0) {
|
if (ErasePolarity != 0) {
|
||||||
FileState = (EFI_FFS_FILE_STATE)~FileState;
|
FileState = (EFI_FFS_FILE_STATE) ~FileState;
|
||||||
}
|
}
|
||||||
|
|
||||||
HighestBit = 0x80;
|
HighestBit = 0x80;
|
||||||
@@ -65,26 +65,27 @@ CalculateHeaderChecksum (
|
|||||||
UINT8 Sum;
|
UINT8 Sum;
|
||||||
|
|
||||||
Sum = 0;
|
Sum = 0;
|
||||||
ptr = (UINT8 *) FileHeader;
|
ptr = (UINT8 *)FileHeader;
|
||||||
|
|
||||||
for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
|
for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
|
||||||
Sum = (UINT8) (Sum + ptr[Index]);
|
Sum = (UINT8)(Sum + ptr[Index]);
|
||||||
Sum = (UINT8) (Sum + ptr[Index + 1]);
|
Sum = (UINT8)(Sum + ptr[Index + 1]);
|
||||||
Sum = (UINT8) (Sum + ptr[Index + 2]);
|
Sum = (UINT8)(Sum + ptr[Index + 2]);
|
||||||
Sum = (UINT8) (Sum + ptr[Index + 3]);
|
Sum = (UINT8)(Sum + ptr[Index + 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
|
for ( ; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
|
||||||
Sum = (UINT8) (Sum + ptr[Index]);
|
Sum = (UINT8)(Sum + ptr[Index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// State field (since this indicates the different state of file).
|
// State field (since this indicates the different state of file).
|
||||||
//
|
//
|
||||||
Sum = (UINT8) (Sum - FileHeader->State);
|
Sum = (UINT8)(Sum - FileHeader->State);
|
||||||
//
|
//
|
||||||
// Checksum field of the file is not part of the header checksum.
|
// Checksum field of the file is not part of the header checksum.
|
||||||
//
|
//
|
||||||
Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
|
Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);
|
||||||
|
|
||||||
return Sum;
|
return Sum;
|
||||||
}
|
}
|
||||||
@@ -128,41 +129,40 @@ FfsFindNextFile (
|
|||||||
} else {
|
} else {
|
||||||
ErasePolarity = 0;
|
ErasePolarity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If FileHeader is not specified (NULL) start with the first file in the
|
// If FileHeader is not specified (NULL) start with the first file in the
|
||||||
// firmware volume. Otherwise, start from the FileHeader.
|
// firmware volume. Otherwise, start from the FileHeader.
|
||||||
//
|
//
|
||||||
if (*FileHeader == NULL) {
|
if (*FileHeader == NULL) {
|
||||||
|
|
||||||
if (FwVolHeader->ExtHeaderOffset != 0) {
|
if (FwVolHeader->ExtHeaderOffset != 0) {
|
||||||
|
|
||||||
FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)FwVolHeader +
|
FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)FwVolHeader +
|
||||||
FwVolHeader->ExtHeaderOffset);
|
FwVolHeader->ExtHeaderOffset);
|
||||||
|
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvExtHeader +
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FvExtHeader +
|
||||||
FvExtHeader->ExtHeaderSize);
|
FvExtHeader->ExtHeaderSize);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader +
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader +
|
||||||
FwVolHeader->HeaderLength);
|
FwVolHeader->HeaderLength);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FwVolHeader +
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINTN)FwVolHeader +
|
||||||
ALIGN_VALUE((UINTN)FfsFileHeader -
|
ALIGN_VALUE (
|
||||||
(UINTN)FwVolHeader, 8));
|
(UINTN)FfsFileHeader -
|
||||||
|
(UINTN)FwVolHeader,
|
||||||
|
8
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Length is 24 bits wide so mask upper 8 bits
|
// Length is 24 bits wide so mask upper 8 bits
|
||||||
// FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
// FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
||||||
//
|
//
|
||||||
FileLength = FFS_FILE_SIZE(*FileHeader);
|
FileLength = FFS_FILE_SIZE (*FileHeader);
|
||||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)*FileHeader + FileOccupiedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
|
FileOffset = (UINT32)((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
|
||||||
|
|
||||||
while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
|
while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
|
||||||
//
|
//
|
||||||
@@ -171,42 +171,40 @@ FfsFindNextFile (
|
|||||||
FileState = GetFileState (ErasePolarity, FfsFileHeader);
|
FileState = GetFileState (ErasePolarity, FfsFileHeader);
|
||||||
|
|
||||||
switch (FileState) {
|
switch (FileState) {
|
||||||
|
|
||||||
case EFI_FILE_HEADER_INVALID:
|
case EFI_FILE_HEADER_INVALID:
|
||||||
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
|
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_FILE_DATA_VALID:
|
case EFI_FILE_DATA_VALID:
|
||||||
case EFI_FILE_MARKED_FOR_UPDATE:
|
case EFI_FILE_MARKED_FOR_UPDATE:
|
||||||
if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
|
if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
|
||||||
FileLength = FFS_FILE_SIZE(FfsFileHeader);
|
FileLength = FFS_FILE_SIZE (FfsFileHeader);
|
||||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||||
|
|
||||||
if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
|
if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
|
||||||
|
|
||||||
*FileHeader = FfsFileHeader;
|
*FileHeader = FfsFileHeader;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOffset += FileOccupiedSize;
|
FileOffset += FileOccupiedSize;
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
|
||||||
} else {
|
} else {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EFI_FILE_DELETED:
|
case EFI_FILE_DELETED:
|
||||||
FileLength = FFS_FILE_SIZE(FfsFileHeader);
|
FileLength = FFS_FILE_SIZE (FfsFileHeader);
|
||||||
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
|
||||||
FileOffset += FileOccupiedSize;
|
FileOffset += FileOccupiedSize;
|
||||||
FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
|
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,15 +242,16 @@ FindFfsSectionInSections (
|
|||||||
//
|
//
|
||||||
// Loop through the FFS file sections
|
// Loop through the FFS file sections
|
||||||
//
|
//
|
||||||
EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN) Sections;
|
EndOfSection = (EFI_PHYSICAL_ADDRESS)(UINTN)Sections;
|
||||||
EndOfSections = EndOfSection + SizeOfSections;
|
EndOfSections = EndOfSection + SizeOfSections;
|
||||||
for (;;) {
|
for ( ; ;) {
|
||||||
if (EndOfSection == EndOfSections) {
|
if (EndOfSection == EndOfSections) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentAddress = EndOfSection;
|
CurrentAddress = EndOfSection;
|
||||||
|
|
||||||
Section = (EFI_COMMON_SECTION_HEADER*)(UINTN) CurrentAddress;
|
Section = (EFI_COMMON_SECTION_HEADER *)(UINTN)CurrentAddress;
|
||||||
|
|
||||||
Size = SECTION_SIZE (Section);
|
Size = SECTION_SIZE (Section);
|
||||||
if (Size < sizeof (*Section)) {
|
if (Size < sizeof (*Section)) {
|
||||||
@@ -263,6 +262,7 @@ FindFfsSectionInSections (
|
|||||||
if (EndOfSection > EndOfSections) {
|
if (EndOfSection > EndOfSections) {
|
||||||
return EFI_VOLUME_CORRUPTED;
|
return EFI_VOLUME_CORRUPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size = GET_OCCUPIED_SIZE (Size, 4);
|
Size = GET_OCCUPIED_SIZE (Size, 4);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -306,8 +306,8 @@ FfsFindSection (
|
|||||||
// Does not include FfsFileHeader header size
|
// Does not include FfsFileHeader header size
|
||||||
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
||||||
//
|
//
|
||||||
Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
|
Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
|
||||||
FileSize = FFS_FILE_SIZE(FfsFileHeader);
|
FileSize = FFS_FILE_SIZE (FfsFileHeader);
|
||||||
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
|
||||||
Status = FindFfsSectionInSections (
|
Status = FindFfsSectionInSections (
|
||||||
@@ -351,28 +351,29 @@ FfsFindSectionData (
|
|||||||
// Does not include FfsFileHeader header size
|
// Does not include FfsFileHeader header size
|
||||||
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
// FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
|
||||||
//
|
//
|
||||||
Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
|
Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
|
||||||
FileSize = FFS_FILE_SIZE(FfsFileHeader);
|
FileSize = FFS_FILE_SIZE (FfsFileHeader);
|
||||||
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
||||||
|
|
||||||
*SectionData = NULL;
|
*SectionData = NULL;
|
||||||
ParsedLength = 0;
|
ParsedLength = 0;
|
||||||
while (ParsedLength < FileSize) {
|
while (ParsedLength < FileSize) {
|
||||||
if (Section->Type == SectionType) {
|
if (Section->Type == SectionType) {
|
||||||
*SectionData = (VOID *) (Section + 1);
|
*SectionData = (VOID *)(Section + 1);
|
||||||
*SectionDataSize = SECTION_SIZE(Section);
|
*SectionDataSize = SECTION_SIZE (Section);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Size is 24 bits wide so mask upper 8 bits.
|
// Size is 24 bits wide so mask upper 8 bits.
|
||||||
// SectionLength is adjusted it is 4 byte aligned.
|
// SectionLength is adjusted it is 4 byte aligned.
|
||||||
// Go to the next section
|
// Go to the next section
|
||||||
//
|
//
|
||||||
SectionLength = SECTION_SIZE(Section);
|
SectionLength = SECTION_SIZE (Section);
|
||||||
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
|
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
|
||||||
|
|
||||||
ParsedLength += SectionLength;
|
ParsedLength += SectionLength;
|
||||||
Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
|
Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
|
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <PiMm.h>
|
#include <PiMm.h>
|
||||||
|
|
||||||
#include <PiPei.h>
|
#include <PiPei.h>
|
||||||
@@ -25,7 +24,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
|
|
||||||
#include <IndustryStandard/ArmStdSmc.h>
|
#include <IndustryStandard/ArmStdSmc.h>
|
||||||
|
|
||||||
extern EFI_HOB_HANDOFF_INFO_TABLE*
|
extern EFI_HOB_HANDOFF_INFO_TABLE *
|
||||||
HobConstructor (
|
HobConstructor (
|
||||||
IN VOID *EfiMemoryBegin,
|
IN VOID *EfiMemoryBegin,
|
||||||
IN UINTN EfiMemoryLength,
|
IN UINTN EfiMemoryLength,
|
||||||
@@ -55,7 +54,7 @@ VOID *
|
|||||||
CreateHobListFromBootInfo (
|
CreateHobListFromBootInfo (
|
||||||
IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
|
IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
|
||||||
IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
|
IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE *HobStart;
|
EFI_HOB_HANDOFF_INFO_TABLE *HobStart;
|
||||||
EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
|
EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
|
||||||
@@ -72,14 +71,14 @@ CreateHobListFromBootInfo (
|
|||||||
|
|
||||||
// Create a hoblist with a PHIT and EOH
|
// Create a hoblist with a PHIT and EOH
|
||||||
HobStart = HobConstructor (
|
HobStart = HobConstructor (
|
||||||
(VOID *) (UINTN) PayloadBootInfo->SpMemBase,
|
(VOID *)(UINTN)PayloadBootInfo->SpMemBase,
|
||||||
(UINTN) PayloadBootInfo->SpMemLimit - PayloadBootInfo->SpMemBase,
|
(UINTN)PayloadBootInfo->SpMemLimit - PayloadBootInfo->SpMemBase,
|
||||||
(VOID *) (UINTN) PayloadBootInfo->SpHeapBase,
|
(VOID *)(UINTN)PayloadBootInfo->SpHeapBase,
|
||||||
(VOID *) (UINTN) (PayloadBootInfo->SpHeapBase + PayloadBootInfo->SpHeapSize)
|
(VOID *)(UINTN)(PayloadBootInfo->SpHeapBase + PayloadBootInfo->SpHeapSize)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check that the Hoblist starts at the bottom of the Heap
|
// Check that the Hoblist starts at the bottom of the Heap
|
||||||
ASSERT (HobStart == (VOID *) (UINTN) PayloadBootInfo->SpHeapBase);
|
ASSERT (HobStart == (VOID *)(UINTN)PayloadBootInfo->SpHeapBase);
|
||||||
|
|
||||||
// Build a Boot Firmware Volume HOB
|
// Build a Boot Firmware Volume HOB
|
||||||
BuildFvHob (PayloadBootInfo->SpImageBase, PayloadBootInfo->SpImageSize);
|
BuildFvHob (PayloadBootInfo->SpImageBase, PayloadBootInfo->SpImageSize);
|
||||||
@@ -99,7 +98,7 @@ CreateHobListFromBootInfo (
|
|||||||
BuildResourceDescriptorHob (
|
BuildResourceDescriptorHob (
|
||||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||||
Attributes,
|
Attributes,
|
||||||
(UINTN) PayloadBootInfo->SpMemBase,
|
(UINTN)PayloadBootInfo->SpMemBase,
|
||||||
PayloadBootInfo->SpMemLimit - PayloadBootInfo->SpMemBase
|
PayloadBootInfo->SpMemLimit - PayloadBootInfo->SpMemBase
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -120,20 +119,21 @@ CreateHobListFromBootInfo (
|
|||||||
|
|
||||||
for (Index = 0; Index < PayloadBootInfo->NumCpus; Index++) {
|
for (Index = 0; Index < PayloadBootInfo->NumCpus; Index++) {
|
||||||
ProcInfoBuffer[Index].ProcessorId = CpuInfo[Index].Mpidr;
|
ProcInfoBuffer[Index].ProcessorId = CpuInfo[Index].Mpidr;
|
||||||
ProcInfoBuffer[Index].Location.Package = GET_CLUSTER_ID(CpuInfo[Index].Mpidr);
|
ProcInfoBuffer[Index].Location.Package = GET_CLUSTER_ID (CpuInfo[Index].Mpidr);
|
||||||
ProcInfoBuffer[Index].Location.Core = GET_CORE_ID(CpuInfo[Index].Mpidr);
|
ProcInfoBuffer[Index].Location.Core = GET_CORE_ID (CpuInfo[Index].Mpidr);
|
||||||
ProcInfoBuffer[Index].Location.Thread = GET_CORE_ID(CpuInfo[Index].Mpidr);
|
ProcInfoBuffer[Index].Location.Thread = GET_CORE_ID (CpuInfo[Index].Mpidr);
|
||||||
|
|
||||||
Flags = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;
|
Flags = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;
|
||||||
if (CpuInfo[Index].Flags & CPU_INFO_FLAG_PRIMARY_CPU) {
|
if (CpuInfo[Index].Flags & CPU_INFO_FLAG_PRIMARY_CPU) {
|
||||||
Flags |= PROCESSOR_AS_BSP_BIT;
|
Flags |= PROCESSOR_AS_BSP_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcInfoBuffer[Index].StatusFlag = Flags;
|
ProcInfoBuffer[Index].StatusFlag = Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a Guided HOB to tell the ARM TF CPU driver the location and length
|
// Create a Guided HOB to tell the ARM TF CPU driver the location and length
|
||||||
// of the communication buffer shared with the Normal world.
|
// of the communication buffer shared with the Normal world.
|
||||||
NsCommBufMmramRange = (EFI_MMRAM_DESCRIPTOR *) BuildGuidHob (
|
NsCommBufMmramRange = (EFI_MMRAM_DESCRIPTOR *)BuildGuidHob (
|
||||||
&gEfiStandaloneMmNonSecureBufferGuid,
|
&gEfiStandaloneMmNonSecureBufferGuid,
|
||||||
sizeof (EFI_MMRAM_DESCRIPTOR)
|
sizeof (EFI_MMRAM_DESCRIPTOR)
|
||||||
);
|
);
|
||||||
@@ -144,7 +144,7 @@ CreateHobListFromBootInfo (
|
|||||||
|
|
||||||
// Create a Guided HOB to enable the ARM TF CPU driver to share its entry
|
// Create a Guided HOB to enable the ARM TF CPU driver to share its entry
|
||||||
// point and populate it with the address of the shared buffer
|
// point and populate it with the address of the shared buffer
|
||||||
CpuDriverEntryPointDesc = (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *) BuildGuidHob (
|
CpuDriverEntryPointDesc = (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *)BuildGuidHob (
|
||||||
&gEfiArmTfCpuDriverEpDescriptorGuid,
|
&gEfiArmTfCpuDriverEpDescriptorGuid,
|
||||||
sizeof (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR)
|
sizeof (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR)
|
||||||
);
|
);
|
||||||
@@ -190,9 +190,9 @@ CreateHobListFromBootInfo (
|
|||||||
MmramRanges[3].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
|
MmramRanges[3].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
|
||||||
|
|
||||||
// Base and size of heap memory shared by all cpus
|
// Base and size of heap memory shared by all cpus
|
||||||
MmramRanges[4].PhysicalStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
|
MmramRanges[4].PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)HobStart;
|
||||||
MmramRanges[4].CpuStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
|
MmramRanges[4].CpuStart = (EFI_PHYSICAL_ADDRESS)(UINTN)HobStart;
|
||||||
MmramRanges[4].PhysicalSize = HobStart->EfiFreeMemoryBottom - (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
|
MmramRanges[4].PhysicalSize = HobStart->EfiFreeMemoryBottom - (EFI_PHYSICAL_ADDRESS)(UINTN)HobStart;
|
||||||
MmramRanges[4].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
|
MmramRanges[4].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
|
||||||
|
|
||||||
// Base and size of heap memory shared by all cpus
|
// Base and size of heap memory shared by all cpus
|
||||||
|
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <PiMm.h>
|
#include <PiMm.h>
|
||||||
|
|
||||||
#include <PiPei.h>
|
#include <PiPei.h>
|
||||||
@@ -78,25 +77,47 @@ UpdateMmFoundationPeCoffPermissions (
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"%a: ImageContext->ImageRead () failed (Status = %r)\n",
|
"%a: ImageContext->ImageRead () failed (Status = %r)\n",
|
||||||
__FUNCTION__, Status));
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO,
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Section %d of image at 0x%lx has 0x%x permissions\n",
|
"%a: Section %d of image at 0x%lx has 0x%x permissions\n",
|
||||||
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Characteristics));
|
__FUNCTION__,
|
||||||
DEBUG ((DEBUG_INFO,
|
Index,
|
||||||
|
ImageContext->ImageAddress,
|
||||||
|
SectionHeader.Characteristics
|
||||||
|
));
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Section %d of image at 0x%lx has %a name\n",
|
"%a: Section %d of image at 0x%lx has %a name\n",
|
||||||
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Name));
|
__FUNCTION__,
|
||||||
DEBUG ((DEBUG_INFO,
|
Index,
|
||||||
|
ImageContext->ImageAddress,
|
||||||
|
SectionHeader.Name
|
||||||
|
));
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Section %d of image at 0x%lx has 0x%x address\n",
|
"%a: Section %d of image at 0x%lx has 0x%x address\n",
|
||||||
__FUNCTION__, Index, ImageContext->ImageAddress,
|
__FUNCTION__,
|
||||||
ImageContext->ImageAddress + SectionHeader.VirtualAddress));
|
Index,
|
||||||
DEBUG ((DEBUG_INFO,
|
ImageContext->ImageAddress,
|
||||||
|
ImageContext->ImageAddress + SectionHeader.VirtualAddress
|
||||||
|
));
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Section %d of image at 0x%lx has 0x%x data\n",
|
"%a: Section %d of image at 0x%lx has 0x%x data\n",
|
||||||
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.PointerToRawData));
|
__FUNCTION__,
|
||||||
|
Index,
|
||||||
|
ImageContext->ImageAddress,
|
||||||
|
SectionHeader.PointerToRawData
|
||||||
|
));
|
||||||
|
|
||||||
//
|
//
|
||||||
// If the section is marked as XN then remove the X attribute. Furthermore,
|
// If the section is marked as XN then remove the X attribute. Furthermore,
|
||||||
@@ -109,19 +130,33 @@ UpdateMmFoundationPeCoffPermissions (
|
|||||||
|
|
||||||
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) != 0) {
|
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) != 0) {
|
||||||
ReadWriteUpdater (Base, SectionHeader.Misc.VirtualSize);
|
ReadWriteUpdater (Base, SectionHeader.Misc.VirtualSize);
|
||||||
DEBUG ((DEBUG_INFO,
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Mapping section %d of image at 0x%lx with RW-XN permissions\n",
|
"%a: Mapping section %d of image at 0x%lx with RW-XN permissions\n",
|
||||||
__FUNCTION__, Index, ImageContext->ImageAddress));
|
__FUNCTION__,
|
||||||
|
Index,
|
||||||
|
ImageContext->ImageAddress
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO,
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Mapping section %d of image at 0x%lx with RO-XN permissions\n",
|
"%a: Mapping section %d of image at 0x%lx with RO-XN permissions\n",
|
||||||
__FUNCTION__, Index, ImageContext->ImageAddress));
|
__FUNCTION__,
|
||||||
|
Index,
|
||||||
|
ImageContext->ImageAddress
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO,
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Ignoring section %d of image at 0x%lx with 0x%x permissions\n",
|
"%a: Ignoring section %d of image at 0x%lx with 0x%x permissions\n",
|
||||||
__FUNCTION__, Index, ImageContext->ImageAddress, SectionHeader.Characteristics));
|
__FUNCTION__,
|
||||||
|
Index,
|
||||||
|
ImageContext->ImageAddress,
|
||||||
|
SectionHeader.Characteristics
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +193,11 @@ LocateStandaloneMmCorePeCoffData (
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM FFS file - 0x%x\n",
|
DEBUG ((
|
||||||
Status));
|
DEBUG_ERROR,
|
||||||
|
"Unable to locate Standalone MM FFS file - 0x%x\n",
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +205,11 @@ LocateStandaloneMmCorePeCoffData (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
Status = FfsFindSectionData (EFI_SECTION_TE, FileHeader, TeData, TeDataSize);
|
Status = FfsFindSectionData (EFI_SECTION_TE, FileHeader, TeData, TeDataSize);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Section data - %r\n",
|
DEBUG ((
|
||||||
Status));
|
DEBUG_ERROR,
|
||||||
|
"Unable to locate Standalone MM Section data - %r\n",
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,9 +248,12 @@ GetPeCoffSectionInformation (
|
|||||||
|
|
||||||
Status = PeCoffLoaderGetImageInfo (ImageContext);
|
Status = PeCoffLoaderGetImageInfo (ImageContext);
|
||||||
if (RETURN_ERROR (Status)) {
|
if (RETURN_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"%a: PeCoffLoaderGetImageInfo () failed (Status == %r)\n",
|
"%a: PeCoffLoaderGetImageInfo () failed (Status == %r)\n",
|
||||||
__FUNCTION__, Status));
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,11 +263,16 @@ GetPeCoffSectionInformation (
|
|||||||
// granularity at which we can tighten permissions.
|
// granularity at which we can tighten permissions.
|
||||||
//
|
//
|
||||||
if (!ImageContext->IsTeImage) {
|
if (!ImageContext->IsTeImage) {
|
||||||
DEBUG ((DEBUG_WARN,
|
DEBUG ((
|
||||||
|
DEBUG_WARN,
|
||||||
"%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n",
|
"%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n",
|
||||||
__FUNCTION__, ImageContext->ImageAddress, ImageContext->SectionAlignment));
|
__FUNCTION__,
|
||||||
|
ImageContext->ImageAddress,
|
||||||
|
ImageContext->SectionAlignment
|
||||||
|
));
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageContext->SectionAlignment = EFI_PAGE_SIZE;
|
ImageContext->SectionAlignment = EFI_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,9 +293,12 @@ GetPeCoffSectionInformation (
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"%a: TmpContext->ImageRead () failed (Status = %r)\n",
|
"%a: TmpContext->ImageRead () failed (Status = %r)\n",
|
||||||
__FUNCTION__, Status));
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,6 +325,7 @@ GetPeCoffSectionInformation (
|
|||||||
*NumberOfSections = Hdr.Te->NumberOfSections;
|
*NumberOfSections = Hdr.Te->NumberOfSections;
|
||||||
*ImageBase -= (UINT32)Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER);
|
*ImageBase -= (UINT32)Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,15 +361,23 @@ GetStandaloneMmCorePeCoffSections (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Found Standalone MM PE data - 0x%x\n", TeData));
|
DEBUG ((DEBUG_INFO, "Found Standalone MM PE data - 0x%x\n", TeData));
|
||||||
|
|
||||||
Status = GetPeCoffSectionInformation (ImageContext, ImageBase,
|
Status = GetPeCoffSectionInformation (
|
||||||
SectionHeaderOffset, NumberOfSections);
|
ImageContext,
|
||||||
|
ImageBase,
|
||||||
|
SectionHeaderOffset,
|
||||||
|
NumberOfSections
|
||||||
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Section information - %r\n", Status));
|
DEBUG ((DEBUG_ERROR, "Unable to locate Standalone MM Core PE-COFF Section information - %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Standalone MM Core PE-COFF SectionHeaderOffset - 0x%x, NumberOfSections - %d\n",
|
DEBUG ((
|
||||||
*SectionHeaderOffset, *NumberOfSections));
|
DEBUG_INFO,
|
||||||
|
"Standalone MM Core PE-COFF SectionHeaderOffset - 0x%x, NumberOfSections - %d\n",
|
||||||
|
*SectionHeaderOffset,
|
||||||
|
*NumberOfSections
|
||||||
|
));
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <PiMm.h>
|
#include <PiMm.h>
|
||||||
|
|
||||||
#include <Library/Arm/StandaloneMmCoreEntryPoint.h>
|
#include <Library/Arm/StandaloneMmCoreEntryPoint.h>
|
||||||
@@ -55,13 +54,13 @@ PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;
|
|||||||
EFI_SECURE_PARTITION_BOOT_INFO *
|
EFI_SECURE_PARTITION_BOOT_INFO *
|
||||||
GetAndPrintBootinformation (
|
GetAndPrintBootinformation (
|
||||||
IN VOID *SharedBufAddress
|
IN VOID *SharedBufAddress
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
|
EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
|
||||||
EFI_SECURE_PARTITION_CPU_INFO *PayloadCpuInfo;
|
EFI_SECURE_PARTITION_CPU_INFO *PayloadCpuInfo;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
|
||||||
PayloadBootInfo = (EFI_SECURE_PARTITION_BOOT_INFO *) SharedBufAddress;
|
PayloadBootInfo = (EFI_SECURE_PARTITION_BOOT_INFO *)SharedBufAddress;
|
||||||
|
|
||||||
if (PayloadBootInfo == NULL) {
|
if (PayloadBootInfo == NULL) {
|
||||||
DEBUG ((DEBUG_ERROR, "PayloadBootInfo NULL\n"));
|
DEBUG ((DEBUG_ERROR, "PayloadBootInfo NULL\n"));
|
||||||
@@ -69,8 +68,12 @@ GetAndPrintBootinformation (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PayloadBootInfo->Header.Version != BOOT_PAYLOAD_VERSION) {
|
if (PayloadBootInfo->Header.Version != BOOT_PAYLOAD_VERSION) {
|
||||||
DEBUG ((DEBUG_ERROR, "Boot Information Version Mismatch. Current=0x%x, Expected=0x%x.\n",
|
DEBUG ((
|
||||||
PayloadBootInfo->Header.Version, BOOT_PAYLOAD_VERSION));
|
DEBUG_ERROR,
|
||||||
|
"Boot Information Version Mismatch. Current=0x%x, Expected=0x%x.\n",
|
||||||
|
PayloadBootInfo->Header.Version,
|
||||||
|
BOOT_PAYLOAD_VERSION
|
||||||
|
));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +95,7 @@ GetAndPrintBootinformation (
|
|||||||
DEBUG ((DEBUG_INFO, "NumCpus - 0x%x\n", PayloadBootInfo->NumCpus));
|
DEBUG ((DEBUG_INFO, "NumCpus - 0x%x\n", PayloadBootInfo->NumCpus));
|
||||||
DEBUG ((DEBUG_INFO, "CpuInfo - 0x%p\n", PayloadBootInfo->CpuInfo));
|
DEBUG ((DEBUG_INFO, "CpuInfo - 0x%p\n", PayloadBootInfo->CpuInfo));
|
||||||
|
|
||||||
PayloadCpuInfo = (EFI_SECURE_PARTITION_CPU_INFO *) PayloadBootInfo->CpuInfo;
|
PayloadCpuInfo = (EFI_SECURE_PARTITION_CPU_INFO *)PayloadBootInfo->CpuInfo;
|
||||||
|
|
||||||
if (PayloadCpuInfo == NULL) {
|
if (PayloadCpuInfo == NULL) {
|
||||||
DEBUG ((DEBUG_ERROR, "PayloadCpuInfo NULL\n"));
|
DEBUG ((DEBUG_ERROR, "PayloadCpuInfo NULL\n"));
|
||||||
@@ -128,14 +131,14 @@ DelegatedEventLoop (
|
|||||||
ArmCallSvc (EventCompleteSvcArgs);
|
ArmCallSvc (EventCompleteSvcArgs);
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Received delegated event\n"));
|
DEBUG ((DEBUG_INFO, "Received delegated event\n"));
|
||||||
DEBUG ((DEBUG_INFO, "X0 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg0));
|
DEBUG ((DEBUG_INFO, "X0 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg0));
|
||||||
DEBUG ((DEBUG_INFO, "X1 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg1));
|
DEBUG ((DEBUG_INFO, "X1 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg1));
|
||||||
DEBUG ((DEBUG_INFO, "X2 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg2));
|
DEBUG ((DEBUG_INFO, "X2 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg2));
|
||||||
DEBUG ((DEBUG_INFO, "X3 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg3));
|
DEBUG ((DEBUG_INFO, "X3 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg3));
|
||||||
DEBUG ((DEBUG_INFO, "X4 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg4));
|
DEBUG ((DEBUG_INFO, "X4 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg4));
|
||||||
DEBUG ((DEBUG_INFO, "X5 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg5));
|
DEBUG ((DEBUG_INFO, "X5 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg5));
|
||||||
DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg6));
|
DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg6));
|
||||||
DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg7));
|
DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg7));
|
||||||
|
|
||||||
FfaEnabled = FeaturePcdGet (PcdFfaEnable);
|
FfaEnabled = FeaturePcdGet (PcdFfaEnable);
|
||||||
if (FfaEnabled) {
|
if (FfaEnabled) {
|
||||||
@@ -145,8 +148,12 @@ DelegatedEventLoop (
|
|||||||
EventCompleteSvcArgs->Arg3
|
EventCompleteSvcArgs->Arg3
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n",
|
DEBUG ((
|
||||||
EventCompleteSvcArgs->Arg3, Status));
|
DEBUG_ERROR,
|
||||||
|
"Failed delegated event 0x%x, Status 0x%x\n",
|
||||||
|
EventCompleteSvcArgs->Arg3,
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Status = CpuDriverEntryPoint (
|
Status = CpuDriverEntryPoint (
|
||||||
@@ -155,8 +162,12 @@ DelegatedEventLoop (
|
|||||||
EventCompleteSvcArgs->Arg1
|
EventCompleteSvcArgs->Arg1
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n",
|
DEBUG ((
|
||||||
EventCompleteSvcArgs->Arg0, Status));
|
DEBUG_ERROR,
|
||||||
|
"Failed delegated event 0x%x, Status 0x%x\n",
|
||||||
|
EventCompleteSvcArgs->Arg0,
|
||||||
|
Status
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +213,9 @@ DelegatedEventLoop (
|
|||||||
**/
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetSpmVersion (VOID)
|
GetSpmVersion (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT16 CalleeSpmMajorVer;
|
UINT16 CalleeSpmMajorVer;
|
||||||
@@ -244,14 +257,22 @@ GetSpmVersion (VOID)
|
|||||||
if ((CalleeSpmMajorVer == CallerSpmMajorVer) &&
|
if ((CalleeSpmMajorVer == CallerSpmMajorVer) &&
|
||||||
(CalleeSpmMinorVer >= CallerSpmMinorVer))
|
(CalleeSpmMinorVer >= CallerSpmMinorVer))
|
||||||
{
|
{
|
||||||
DEBUG ((DEBUG_INFO, "SPM Version: Major=0x%x, Minor=0x%x\n",
|
DEBUG ((
|
||||||
CalleeSpmMajorVer, CalleeSpmMinorVer));
|
DEBUG_INFO,
|
||||||
|
"SPM Version: Major=0x%x, Minor=0x%x\n",
|
||||||
|
CalleeSpmMajorVer,
|
||||||
|
CalleeSpmMinorVer
|
||||||
|
));
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
}
|
} else {
|
||||||
else
|
DEBUG ((
|
||||||
{
|
DEBUG_INFO,
|
||||||
DEBUG ((DEBUG_INFO, "Incompatible SPM Versions.\n Callee Version: Major=0x%x, Minor=0x%x.\n Caller: Major=0x%x, Minor>=0x%x.\n",
|
"Incompatible SPM Versions.\n Callee Version: Major=0x%x, Minor=0x%x.\n Caller: Major=0x%x, Minor>=0x%x.\n",
|
||||||
CalleeSpmMajorVer, CalleeSpmMinorVer, CallerSpmMajorVer, CallerSpmMinorVer));
|
CalleeSpmMajorVer,
|
||||||
|
CalleeSpmMinorVer,
|
||||||
|
CallerSpmMajorVer,
|
||||||
|
CallerSpmMinorVer
|
||||||
|
));
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +349,7 @@ _ModuleEntryPoint (
|
|||||||
|
|
||||||
// Locate PE/COFF File information for the Standalone MM core module
|
// Locate PE/COFF File information for the Standalone MM core module
|
||||||
Status = LocateStandaloneMmCorePeCoffData (
|
Status = LocateStandaloneMmCorePeCoffData (
|
||||||
(EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PayloadBootInfo->SpImageBase,
|
(EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PayloadBootInfo->SpImageBase,
|
||||||
&TeData,
|
&TeData,
|
||||||
&TeDataSize
|
&TeDataSize
|
||||||
);
|
);
|
||||||
@@ -395,7 +416,7 @@ _ModuleEntryPoint (
|
|||||||
//
|
//
|
||||||
ProcessModuleEntryPointList (HobStart);
|
ProcessModuleEntryPointList (HobStart);
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Shared Cpu Driver EP %p\n", (VOID *) CpuDriverEntryPoint));
|
DEBUG ((DEBUG_INFO, "Shared Cpu Driver EP %p\n", (VOID *)CpuDriverEntryPoint));
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
if (Status == RETURN_UNSUPPORTED) {
|
if (Status == RETURN_UNSUPPORTED) {
|
||||||
@@ -407,7 +428,8 @@ finish:
|
|||||||
} else {
|
} else {
|
||||||
Ret = 0;
|
Ret = 0;
|
||||||
}
|
}
|
||||||
ZeroMem (&InitMmFoundationSvcArgs, sizeof(InitMmFoundationSvcArgs));
|
|
||||||
|
ZeroMem (&InitMmFoundationSvcArgs, sizeof (InitMmFoundationSvcArgs));
|
||||||
InitArmSvcArgs (&InitMmFoundationSvcArgs, &Ret);
|
InitArmSvcArgs (&InitMmFoundationSvcArgs, &Ret);
|
||||||
DelegatedEventLoop (&InitMmFoundationSvcArgs);
|
DelegatedEventLoop (&InitMmFoundationSvcArgs);
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <PiMm.h>
|
#include <PiMm.h>
|
||||||
|
|
||||||
#include <Library/StandaloneMmCoreEntryPoint.h>
|
#include <Library/StandaloneMmCoreEntryPoint.h>
|
||||||
@@ -52,7 +51,6 @@ _ModuleEntryPoint (
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
|
Required by the EBC compiler and identical in functionality to _ModuleEntryPoint().
|
||||||
|
|
||||||
|
@@ -42,19 +42,19 @@ CreateHob (
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
|
Hob = (VOID *)(UINTN)HandOffHob->EfiEndOfHobList;
|
||||||
((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType;
|
((EFI_HOB_GENERIC_HEADER *)Hob)->HobType = HobType;
|
||||||
((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength;
|
((EFI_HOB_GENERIC_HEADER *)Hob)->HobLength = HobLength;
|
||||||
((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0;
|
((EFI_HOB_GENERIC_HEADER *)Hob)->Reserved = 0;
|
||||||
|
|
||||||
HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength);
|
HobEnd = (EFI_HOB_GENERIC_HEADER *)((UINTN)Hob + HobLength);
|
||||||
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
|
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
|
||||||
|
|
||||||
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
|
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
|
||||||
HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
|
HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
|
||||||
HobEnd->Reserved = 0;
|
HobEnd->Reserved = 0;
|
||||||
HobEnd++;
|
HobEnd++;
|
||||||
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
|
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
|
||||||
|
|
||||||
return Hob;
|
return Hob;
|
||||||
}
|
}
|
||||||
@@ -83,8 +83,10 @@ BuildModuleHob (
|
|||||||
{
|
{
|
||||||
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
|
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
|
||||||
|
|
||||||
ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
|
ASSERT (
|
||||||
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
|
((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||||
|
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)
|
||||||
|
);
|
||||||
|
|
||||||
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
|
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
|
||||||
|
|
||||||
@@ -164,12 +166,11 @@ BuildGuidHob (
|
|||||||
//
|
//
|
||||||
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
|
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
|
||||||
|
|
||||||
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));
|
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
|
||||||
CopyGuid (&Hob->Name, Guid);
|
CopyGuid (&Hob->Name, Guid);
|
||||||
return Hob + 1;
|
return Hob + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Copies a data buffer to a newly-built HOB.
|
Copies a data buffer to a newly-built HOB.
|
||||||
|
|
||||||
@@ -230,7 +231,6 @@ BuildFvHob (
|
|||||||
Hob->Length = Length;
|
Hob->Length = Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Builds a EFI_HOB_TYPE_FV2 HOB.
|
Builds a EFI_HOB_TYPE_FV2 HOB.
|
||||||
|
|
||||||
@@ -262,7 +262,6 @@ BuildFv2Hob (
|
|||||||
CopyGuid (&Hob->FileName, FileName);
|
CopyGuid (&Hob->FileName, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Builds a HOB for the CPU.
|
Builds a HOB for the CPU.
|
||||||
|
|
||||||
@@ -314,8 +313,10 @@ BuildMemoryAllocationHob (
|
|||||||
{
|
{
|
||||||
EFI_HOB_MEMORY_ALLOCATION *Hob;
|
EFI_HOB_MEMORY_ALLOCATION *Hob;
|
||||||
|
|
||||||
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
|
ASSERT (
|
||||||
((Length & (EFI_PAGE_SIZE - 1)) == 0));
|
((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||||
|
((Length & (EFI_PAGE_SIZE - 1)) == 0)
|
||||||
|
);
|
||||||
|
|
||||||
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
|
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
//
|
//
|
||||||
extern VOID *gHobList;
|
extern VOID *gHobList;
|
||||||
|
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE*
|
EFI_HOB_HANDOFF_INFO_TABLE *
|
||||||
HobConstructor (
|
HobConstructor (
|
||||||
IN VOID *EfiMemoryBegin,
|
IN VOID *EfiMemoryBegin,
|
||||||
IN UINTN EfiMemoryLength,
|
IN UINTN EfiMemoryLength,
|
||||||
|
@@ -64,7 +64,7 @@ GetNextHob (
|
|||||||
|
|
||||||
ASSERT (HobStart != NULL);
|
ASSERT (HobStart != NULL);
|
||||||
|
|
||||||
Hob.Raw = (UINT8 *) HobStart;
|
Hob.Raw = (UINT8 *)HobStart;
|
||||||
//
|
//
|
||||||
// Parse the HOB list until end of list or matching type is found.
|
// Parse the HOB list until end of list or matching type is found.
|
||||||
//
|
//
|
||||||
@@ -72,8 +72,10 @@ GetNextHob (
|
|||||||
if (Hob.Header->HobType == Type) {
|
if (Hob.Header->HobType == Type) {
|
||||||
return Hob.Raw;
|
return Hob.Raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,13 +135,15 @@ GetNextGuidHob (
|
|||||||
{
|
{
|
||||||
EFI_PEI_HOB_POINTERS GuidHob;
|
EFI_PEI_HOB_POINTERS GuidHob;
|
||||||
|
|
||||||
GuidHob.Raw = (UINT8 *) HobStart;
|
GuidHob.Raw = (UINT8 *)HobStart;
|
||||||
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
||||||
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GuidHob.Raw;
|
return GuidHob.Raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,12 +198,11 @@ GetBootModeHob (
|
|||||||
{
|
{
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
||||||
|
|
||||||
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
|
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *)GetHobList ();
|
||||||
|
|
||||||
return HandOffHob->BootMode;
|
return HandOffHob->BootMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Builds a HOB that describes a chunk of system memory with Owner GUID.
|
Builds a HOB that describes a chunk of system memory with Owner GUID.
|
||||||
|
|
||||||
@@ -247,7 +250,6 @@ BuildCvHob (
|
|||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Builds a HOB for the BSP store.
|
Builds a HOB for the BSP store.
|
||||||
|
|
||||||
|
@@ -49,7 +49,8 @@ InternalAllocatePages (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (VOID *) (UINTN) Memory;
|
|
||||||
|
return (VOID *)(UINTN)Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +146,7 @@ FreePages (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
ASSERT (Pages != 0);
|
ASSERT (Pages != 0);
|
||||||
Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
|
Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +190,7 @@ InternalAllocateAlignedPages (
|
|||||||
if (Pages == 0) {
|
if (Pages == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Alignment > EFI_PAGE_SIZE) {
|
if (Alignment > EFI_PAGE_SIZE) {
|
||||||
//
|
//
|
||||||
// Calculate the total number of pages since alignment is larger than page size.
|
// Calculate the total number of pages since alignment is larger than page size.
|
||||||
@@ -204,8 +206,9 @@ InternalAllocateAlignedPages (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
|
|
||||||
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
|
AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
|
||||||
|
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
|
||||||
if (UnalignedPages > 0) {
|
if (UnalignedPages > 0) {
|
||||||
//
|
//
|
||||||
// Free first unaligned page(s).
|
// Free first unaligned page(s).
|
||||||
@@ -213,7 +216,8 @@ InternalAllocateAlignedPages (
|
|||||||
Status = gMmst->MmFreePages (Memory, UnalignedPages);
|
Status = gMmst->MmFreePages (Memory, UnalignedPages);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
|
|
||||||
|
Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
|
||||||
UnalignedPages = RealPages - Pages - UnalignedPages;
|
UnalignedPages = RealPages - Pages - UnalignedPages;
|
||||||
if (UnalignedPages > 0) {
|
if (UnalignedPages > 0) {
|
||||||
//
|
//
|
||||||
@@ -230,9 +234,11 @@ InternalAllocateAlignedPages (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
AlignedMemory = (UINTN) Memory;
|
|
||||||
|
AlignedMemory = (UINTN)Memory;
|
||||||
}
|
}
|
||||||
return (VOID *) AlignedMemory;
|
|
||||||
|
return (VOID *)AlignedMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -346,7 +352,7 @@ FreeAlignedPages (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
ASSERT (Pages != 0);
|
ASSERT (Pages != 0);
|
||||||
Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
|
Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,6 +384,7 @@ InternalAllocatePool (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
Memory = NULL;
|
Memory = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Memory;
|
return Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,6 +477,7 @@ InternalAllocateZeroPool (
|
|||||||
if (Memory != NULL) {
|
if (Memory != NULL) {
|
||||||
Memory = ZeroMem (Memory, AllocationSize);
|
Memory = ZeroMem (Memory, AllocationSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Memory;
|
return Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,12 +574,13 @@ InternalAllocateCopyPool (
|
|||||||
VOID *Memory;
|
VOID *Memory;
|
||||||
|
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
|
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
|
|
||||||
Memory = InternalAllocatePool (PoolType, AllocationSize);
|
Memory = InternalAllocatePool (PoolType, AllocationSize);
|
||||||
if (Memory != NULL) {
|
if (Memory != NULL) {
|
||||||
Memory = CopyMem (Memory, Buffer, AllocationSize);
|
Memory = CopyMem (Memory, Buffer, AllocationSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Memory;
|
return Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,10 +698,11 @@ InternalReallocatePool (
|
|||||||
VOID *NewBuffer;
|
VOID *NewBuffer;
|
||||||
|
|
||||||
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
|
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
|
||||||
if (NewBuffer != NULL && OldBuffer != NULL) {
|
if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
|
||||||
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
||||||
FreePool (OldBuffer);
|
FreePool (OldBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewBuffer;
|
return NewBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,16 +878,15 @@ MemoryAllocationLibConstructor (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmramRangeCount = (UINTN) MmramRangesHobData->NumberOfMmReservedRegions;
|
MmramRangeCount = (UINTN)MmramRangesHobData->NumberOfMmReservedRegions;
|
||||||
if (MmramRanges == NULL) {
|
if (MmramRanges == NULL) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DataInHob = GET_GUID_HOB_DATA (GuidHob);
|
DataInHob = GET_GUID_HOB_DATA (GuidHob);
|
||||||
MmCorePrivate = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
|
MmCorePrivate = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
|
||||||
MmramRanges = (EFI_MMRAM_DESCRIPTOR *)(UINTN)MmCorePrivate->MmramRanges;
|
MmramRanges = (EFI_MMRAM_DESCRIPTOR *)(UINTN)MmCorePrivate->MmramRanges;
|
||||||
MmramRangeCount = (UINTN) MmCorePrivate->MmramRangeCount;
|
MmramRangeCount = (UINTN)MmCorePrivate->MmramRangeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -885,8 +894,13 @@ MemoryAllocationLibConstructor (
|
|||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "MmramRangeCount - 0x%x\n", MmramRangeCount));
|
DEBUG ((DEBUG_INFO, "MmramRangeCount - 0x%x\n", MmramRangeCount));
|
||||||
for (Index = 0; Index < MmramRangeCount; Index++) {
|
for (Index = 0; Index < MmramRangeCount; Index++) {
|
||||||
DEBUG ((DEBUG_INFO, "MmramRanges[%d]: 0x%016lx - 0x%016lx\n",
|
DEBUG ((
|
||||||
Index, MmramRanges[Index].CpuStart, MmramRanges[Index].PhysicalSize));
|
DEBUG_INFO,
|
||||||
|
"MmramRanges[%d]: 0x%016lx - 0x%016lx\n",
|
||||||
|
Index,
|
||||||
|
MmramRanges[Index].CpuStart,
|
||||||
|
MmramRanges[Index].PhysicalSize
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,6 +49,7 @@ HobLibConstructor (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ GetHobList (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (gHobList != NULL);
|
ASSERT (gHobList != NULL);
|
||||||
return gHobList;
|
return gHobList;
|
||||||
}
|
}
|
||||||
@@ -109,7 +111,7 @@ GetNextHob (
|
|||||||
|
|
||||||
ASSERT (HobStart != NULL);
|
ASSERT (HobStart != NULL);
|
||||||
|
|
||||||
Hob.Raw = (UINT8 *) HobStart;
|
Hob.Raw = (UINT8 *)HobStart;
|
||||||
//
|
//
|
||||||
// Parse the HOB list until end of list or matching type is found.
|
// Parse the HOB list until end of list or matching type is found.
|
||||||
//
|
//
|
||||||
@@ -117,8 +119,10 @@ GetNextHob (
|
|||||||
if (Hob.Header->HobType == Type) {
|
if (Hob.Header->HobType == Type) {
|
||||||
return Hob.Raw;
|
return Hob.Raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,13 +182,15 @@ GetNextGuidHob (
|
|||||||
{
|
{
|
||||||
EFI_PEI_HOB_POINTERS GuidHob;
|
EFI_PEI_HOB_POINTERS GuidHob;
|
||||||
|
|
||||||
GuidHob.Raw = (UINT8 *) HobStart;
|
GuidHob.Raw = (UINT8 *)HobStart;
|
||||||
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
||||||
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GuidHob.Raw;
|
return GuidHob.Raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +245,7 @@ GetBootModeHob (
|
|||||||
{
|
{
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
||||||
|
|
||||||
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
|
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *)GetHobList ();
|
||||||
|
|
||||||
return HandOffHob->BootMode;
|
return HandOffHob->BootMode;
|
||||||
}
|
}
|
||||||
@@ -265,19 +271,19 @@ CreateHob (
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
|
Hob = (VOID *)(UINTN)HandOffHob->EfiEndOfHobList;
|
||||||
((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType;
|
((EFI_HOB_GENERIC_HEADER *)Hob)->HobType = HobType;
|
||||||
((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength;
|
((EFI_HOB_GENERIC_HEADER *)Hob)->HobLength = HobLength;
|
||||||
((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0;
|
((EFI_HOB_GENERIC_HEADER *)Hob)->Reserved = 0;
|
||||||
|
|
||||||
HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength);
|
HobEnd = (EFI_HOB_GENERIC_HEADER *)((UINTN)Hob + HobLength);
|
||||||
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
|
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
|
||||||
|
|
||||||
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
|
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
|
||||||
HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
|
HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
|
||||||
HobEnd->Reserved = 0;
|
HobEnd->Reserved = 0;
|
||||||
HobEnd++;
|
HobEnd++;
|
||||||
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
|
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
|
||||||
|
|
||||||
return Hob;
|
return Hob;
|
||||||
}
|
}
|
||||||
@@ -306,8 +312,10 @@ BuildModuleHob (
|
|||||||
{
|
{
|
||||||
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
|
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
|
||||||
|
|
||||||
ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
|
ASSERT (
|
||||||
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
|
((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||||
|
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)
|
||||||
|
);
|
||||||
|
|
||||||
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
|
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
|
||||||
|
|
||||||
@@ -349,7 +357,7 @@ BuildResourceDescriptorHob (
|
|||||||
EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
|
EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
|
||||||
|
|
||||||
Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
|
Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
|
||||||
ASSERT(Hob != NULL);
|
ASSERT (Hob != NULL);
|
||||||
|
|
||||||
Hob->ResourceType = ResourceType;
|
Hob->ResourceType = ResourceType;
|
||||||
Hob->ResourceAttribute = ResourceAttribute;
|
Hob->ResourceAttribute = ResourceAttribute;
|
||||||
@@ -387,12 +395,11 @@ BuildGuidHob (
|
|||||||
//
|
//
|
||||||
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
|
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
|
||||||
|
|
||||||
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));
|
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
|
||||||
CopyGuid (&Hob->Name, Guid);
|
CopyGuid (&Hob->Name, Guid);
|
||||||
return Hob + 1;
|
return Hob + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Copies a data buffer to a newly-built HOB.
|
Copies a data buffer to a newly-built HOB.
|
||||||
|
|
||||||
@@ -453,7 +460,6 @@ BuildFvHob (
|
|||||||
Hob->Length = Length;
|
Hob->Length = Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Builds a EFI_HOB_TYPE_FV2 HOB.
|
Builds a EFI_HOB_TYPE_FV2 HOB.
|
||||||
|
|
||||||
@@ -485,7 +491,6 @@ BuildFv2Hob (
|
|||||||
CopyGuid (&Hob->FileName, FileName);
|
CopyGuid (&Hob->FileName, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Builds a HOB for the CPU.
|
Builds a HOB for the CPU.
|
||||||
|
|
||||||
@@ -537,8 +542,10 @@ BuildMemoryAllocationHob (
|
|||||||
{
|
{
|
||||||
EFI_HOB_MEMORY_ALLOCATION *Hob;
|
EFI_HOB_MEMORY_ALLOCATION *Hob;
|
||||||
|
|
||||||
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
|
ASSERT (
|
||||||
((Length & (EFI_PAGE_SIZE - 1)) == 0));
|
((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||||
|
((Length & (EFI_PAGE_SIZE - 1)) == 0)
|
||||||
|
);
|
||||||
|
|
||||||
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
|
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
|
||||||
|
|
||||||
@@ -599,7 +606,6 @@ BuildCvHob (
|
|||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Builds a HOB for the BSP store.
|
Builds a HOB for the BSP store.
|
||||||
|
|
||||||
|
@@ -74,4 +74,3 @@ MmMemLibInternalFreeMmramRanges (
|
|||||||
{
|
{
|
||||||
// Not implemented for AARCH64.
|
// Not implemented for AARCH64.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include <PiMm.h>
|
#include <PiMm.h>
|
||||||
|
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
@@ -82,7 +81,8 @@ MmIsBufferOutsideMmValid (
|
|||||||
//
|
//
|
||||||
if ((Length > mMmMemLibInternalMaximumSupportAddress) ||
|
if ((Length > mMmMemLibInternalMaximumSupportAddress) ||
|
||||||
(Buffer > mMmMemLibInternalMaximumSupportAddress) ||
|
(Buffer > mMmMemLibInternalMaximumSupportAddress) ||
|
||||||
((Length != 0) && (Buffer > (mMmMemLibInternalMaximumSupportAddress - (Length - 1)))) ) {
|
((Length != 0) && (Buffer > (mMmMemLibInternalMaximumSupportAddress - (Length - 1)))))
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Overflow happen
|
// Overflow happen
|
||||||
//
|
//
|
||||||
@@ -96,11 +96,12 @@ MmIsBufferOutsideMmValid (
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Index = 0; Index < mMmMemLibInternalMmramCount; Index ++) {
|
for (Index = 0; Index < mMmMemLibInternalMmramCount; Index++) {
|
||||||
if (((Buffer >= mMmMemLibInternalMmramRanges[Index].CpuStart) &&
|
if (((Buffer >= mMmMemLibInternalMmramRanges[Index].CpuStart) &&
|
||||||
(Buffer < mMmMemLibInternalMmramRanges[Index].CpuStart + mMmMemLibInternalMmramRanges[Index].PhysicalSize)) ||
|
(Buffer < mMmMemLibInternalMmramRanges[Index].CpuStart + mMmMemLibInternalMmramRanges[Index].PhysicalSize)) ||
|
||||||
((mMmMemLibInternalMmramRanges[Index].CpuStart >= Buffer) &&
|
((mMmMemLibInternalMmramRanges[Index].CpuStart >= Buffer) &&
|
||||||
(mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length))) {
|
(mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length)))
|
||||||
|
{
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_ERROR,
|
DEBUG_ERROR,
|
||||||
"MmIsBufferOutsideMmValid: Overlap: Buffer (0x%lx) - Length (0x%lx), ",
|
"MmIsBufferOutsideMmValid: Overlap: Buffer (0x%lx) - Length (0x%lx), ",
|
||||||
@@ -149,6 +150,7 @@ MmCopyMemToMmram (
|
|||||||
DEBUG ((DEBUG_ERROR, "MmCopyMemToMmram: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
|
DEBUG ((DEBUG_ERROR, "MmCopyMemToMmram: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
|
||||||
return EFI_SECURITY_VIOLATION;
|
return EFI_SECURITY_VIOLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -179,10 +181,15 @@ MmCopyMemFromMmram (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
|
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
|
||||||
DEBUG ((DEBUG_ERROR, "MmCopyMemFromMmram: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
DEBUG ((
|
||||||
DestinationBuffer, Length));
|
DEBUG_ERROR,
|
||||||
|
"MmCopyMemFromMmram: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
||||||
|
DestinationBuffer,
|
||||||
|
Length
|
||||||
|
));
|
||||||
return EFI_SECURITY_VIOLATION;
|
return EFI_SECURITY_VIOLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -214,14 +221,20 @@ MmCopyMem (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
|
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {
|
||||||
DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
DEBUG ((
|
||||||
DestinationBuffer, Length));
|
DEBUG_ERROR,
|
||||||
|
"MmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n",
|
||||||
|
DestinationBuffer,
|
||||||
|
Length
|
||||||
|
));
|
||||||
return EFI_SECURITY_VIOLATION;
|
return EFI_SECURITY_VIOLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer, Length)) {
|
if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer, Length)) {
|
||||||
DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
|
DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));
|
||||||
return EFI_SECURITY_VIOLATION;
|
return EFI_SECURITY_VIOLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
CopyMem (DestinationBuffer, SourceBuffer, Length);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -254,6 +267,7 @@ MmSetMem (
|
|||||||
DEBUG ((DEBUG_ERROR, "MmSetMem: Security Violation: Source (0x%x), Length (0x%x)\n", Buffer, Length));
|
DEBUG ((DEBUG_ERROR, "MmSetMem: Security Violation: Source (0x%x), Length (0x%x)\n", Buffer, Length));
|
||||||
return EFI_SECURITY_VIOLATION;
|
return EFI_SECURITY_VIOLATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMem (Buffer, Length, Value);
|
SetMem (Buffer, Length, Value);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -305,7 +319,6 @@ MemLibDestructor (
|
|||||||
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// Deinitialize cached Mmram Ranges.
|
// Deinitialize cached Mmram Ranges.
|
||||||
//
|
//
|
||||||
|
@@ -48,16 +48,17 @@ MmMemLibInternalCalculateMaximumSupportAddress (
|
|||||||
//
|
//
|
||||||
Hob = GetFirstHob (EFI_HOB_TYPE_CPU);
|
Hob = GetFirstHob (EFI_HOB_TYPE_CPU);
|
||||||
if (Hob != NULL) {
|
if (Hob != NULL) {
|
||||||
PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;
|
PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
|
||||||
} else {
|
} else {
|
||||||
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
|
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
|
||||||
if (RegEax >= 0x80000008) {
|
if (RegEax >= 0x80000008) {
|
||||||
AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
|
AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
|
||||||
PhysicalAddressBits = (UINT8) RegEax;
|
PhysicalAddressBits = (UINT8)RegEax;
|
||||||
} else {
|
} else {
|
||||||
PhysicalAddressBits = 36;
|
PhysicalAddressBits = 36;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.
|
// IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.
|
||||||
//
|
//
|
||||||
@@ -108,7 +109,7 @@ MmMemLibInternalPopulateMmramRanges (
|
|||||||
}
|
}
|
||||||
|
|
||||||
MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
|
MmramRangesHobData = GET_GUID_HOB_DATA (MmramRangesHob);
|
||||||
if (MmramRangesHobData == NULL || MmramRangesHobData->Descriptor == NULL) {
|
if ((MmramRangesHobData == NULL) || (MmramRangesHobData->Descriptor == NULL)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,20 +121,22 @@ MmMemLibInternalPopulateMmramRanges (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmCorePrivateData = (MM_CORE_PRIVATE_DATA *) (UINTN) DataInHob->Address;
|
MmCorePrivateData = (MM_CORE_PRIVATE_DATA *)(UINTN)DataInHob->Address;
|
||||||
if (MmCorePrivateData == NULL || MmCorePrivateData->MmramRanges == 0) {
|
if ((MmCorePrivateData == NULL) || (MmCorePrivateData->MmramRanges == 0)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
mMmMemLibInternalMmramCount = (UINTN) MmCorePrivateData->MmramRangeCount;
|
mMmMemLibInternalMmramCount = (UINTN)MmCorePrivateData->MmramRangeCount;
|
||||||
MmramDescriptors = (EFI_MMRAM_DESCRIPTOR *) (UINTN) MmCorePrivateData->MmramRanges;
|
MmramDescriptors = (EFI_MMRAM_DESCRIPTOR *)(UINTN)MmCorePrivateData->MmramRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
mMmMemLibInternalMmramRanges = AllocatePool (mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR));
|
mMmMemLibInternalMmramRanges = AllocatePool (mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR));
|
||||||
if (mMmMemLibInternalMmramRanges) {
|
if (mMmMemLibInternalMmramRanges) {
|
||||||
CopyMem (mMmMemLibInternalMmramRanges,
|
CopyMem (
|
||||||
|
mMmMemLibInternalMmramRanges,
|
||||||
MmramDescriptors,
|
MmramDescriptors,
|
||||||
mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR));
|
mMmMemLibInternalMmramCount * sizeof (EFI_MMRAM_DESCRIPTOR)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@@ -152,4 +155,3 @@ MmMemLibInternalFreeMmramRanges (
|
|||||||
FreePool (mMmMemLibInternalMmramRanges);
|
FreePool (mMmMemLibInternalMmramRanges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,6 +45,7 @@ InternalAllocatePages (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (VOID *)(UINTN)Memory;
|
return (VOID *)(UINTN)Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +142,7 @@ FreePages (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
ASSERT (Pages != 0);
|
ASSERT (Pages != 0);
|
||||||
Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN)Buffer, Pages);
|
Status = gMmst->MmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +186,7 @@ InternalAllocateAlignedPages (
|
|||||||
if (Pages == 0) {
|
if (Pages == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Alignment > EFI_PAGE_SIZE) {
|
if (Alignment > EFI_PAGE_SIZE) {
|
||||||
//
|
//
|
||||||
// Calculate the total number of pages since alignment is larger than page size.
|
// Calculate the total number of pages since alignment is larger than page size.
|
||||||
@@ -200,8 +202,9 @@ InternalAllocateAlignedPages (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
|
AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
|
||||||
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
|
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
|
||||||
if (UnalignedPages > 0) {
|
if (UnalignedPages > 0) {
|
||||||
//
|
//
|
||||||
// Free first unaligned page(s).
|
// Free first unaligned page(s).
|
||||||
@@ -209,6 +212,7 @@ InternalAllocateAlignedPages (
|
|||||||
Status = gMmst->MmFreePages (Memory, UnalignedPages);
|
Status = gMmst->MmFreePages (Memory, UnalignedPages);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
|
Memory = (EFI_PHYSICAL_ADDRESS)(AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
|
||||||
UnalignedPages = RealPages - Pages - UnalignedPages;
|
UnalignedPages = RealPages - Pages - UnalignedPages;
|
||||||
if (UnalignedPages > 0) {
|
if (UnalignedPages > 0) {
|
||||||
@@ -226,9 +230,11 @@ InternalAllocateAlignedPages (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
AlignedMemory = (UINTN) Memory;
|
|
||||||
|
AlignedMemory = (UINTN)Memory;
|
||||||
}
|
}
|
||||||
return (VOID *) AlignedMemory;
|
|
||||||
|
return (VOID *)AlignedMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -374,6 +380,7 @@ InternalAllocatePool (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
Memory = NULL;
|
Memory = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Memory;
|
return Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,6 +473,7 @@ InternalAllocateZeroPool (
|
|||||||
if (Memory != NULL) {
|
if (Memory != NULL) {
|
||||||
Memory = ZeroMem (Memory, AllocationSize);
|
Memory = ZeroMem (Memory, AllocationSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Memory;
|
return Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,12 +570,13 @@ InternalAllocateCopyPool (
|
|||||||
VOID *Memory;
|
VOID *Memory;
|
||||||
|
|
||||||
ASSERT (Buffer != NULL);
|
ASSERT (Buffer != NULL);
|
||||||
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
|
ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
|
||||||
|
|
||||||
Memory = InternalAllocatePool (PoolType, AllocationSize);
|
Memory = InternalAllocatePool (PoolType, AllocationSize);
|
||||||
if (Memory != NULL) {
|
if (Memory != NULL) {
|
||||||
Memory = CopyMem (Memory, Buffer, AllocationSize);
|
Memory = CopyMem (Memory, Buffer, AllocationSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Memory;
|
return Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,10 +694,11 @@ InternalReallocatePool (
|
|||||||
VOID *NewBuffer;
|
VOID *NewBuffer;
|
||||||
|
|
||||||
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
|
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
|
||||||
if (NewBuffer != NULL && OldBuffer != NULL) {
|
if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
|
||||||
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
||||||
FreePool (OldBuffer);
|
FreePool (OldBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewBuffer;
|
return NewBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,17 +52,25 @@ UpdatePeCoffPermissions (
|
|||||||
if (TmpContext.PeCoffHeaderOffset == 0) {
|
if (TmpContext.PeCoffHeaderOffset == 0) {
|
||||||
Status = PeCoffLoaderGetImageInfo (&TmpContext);
|
Status = PeCoffLoaderGetImageInfo (&TmpContext);
|
||||||
if (RETURN_ERROR (Status)) {
|
if (RETURN_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"%a: PeCoffLoaderGetImageInfo () failed (Status = %r)\n",
|
"%a: PeCoffLoaderGetImageInfo () failed (Status = %r)\n",
|
||||||
__FUNCTION__, Status));
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TmpContext.IsTeImage &&
|
if (TmpContext.IsTeImage &&
|
||||||
TmpContext.ImageAddress == ImageContext->ImageAddress) {
|
(TmpContext.ImageAddress == ImageContext->ImageAddress))
|
||||||
DEBUG ((DEBUG_INFO, "%a: ignoring XIP TE image at 0x%lx\n", __FUNCTION__,
|
{
|
||||||
ImageContext->ImageAddress));
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
|
"%a: ignoring XIP TE image at 0x%lx\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
ImageContext->ImageAddress
|
||||||
|
));
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,10 +81,15 @@ UpdatePeCoffPermissions (
|
|||||||
// noexec permissions on the entire region.
|
// noexec permissions on the entire region.
|
||||||
//
|
//
|
||||||
if (!TmpContext.IsTeImage) {
|
if (!TmpContext.IsTeImage) {
|
||||||
DEBUG ((DEBUG_WARN,
|
DEBUG ((
|
||||||
|
DEBUG_WARN,
|
||||||
"%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n",
|
"%a: non-TE Image at 0x%lx has SectionAlignment < 4 KB (%lu)\n",
|
||||||
__FUNCTION__, ImageContext->ImageAddress, TmpContext.SectionAlignment));
|
__FUNCTION__,
|
||||||
|
ImageContext->ImageAddress,
|
||||||
|
TmpContext.SectionAlignment
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Base = ImageContext->ImageAddress & ~(EFI_PAGE_SIZE - 1);
|
Base = ImageContext->ImageAddress & ~(EFI_PAGE_SIZE - 1);
|
||||||
Size = ImageContext->ImageAddress - Base + ImageContext->ImageSize;
|
Size = ImageContext->ImageAddress - Base + ImageContext->ImageSize;
|
||||||
return NoExecUpdater (Base, ALIGN_VALUE (Size, EFI_PAGE_SIZE));
|
return NoExecUpdater (Base, ALIGN_VALUE (Size, EFI_PAGE_SIZE));
|
||||||
@@ -91,12 +104,19 @@ UpdatePeCoffPermissions (
|
|||||||
Hdr.Union = &HdrData;
|
Hdr.Union = &HdrData;
|
||||||
Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
|
Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
|
||||||
ReadSize = Size;
|
ReadSize = Size;
|
||||||
Status = TmpContext.ImageRead (TmpContext.Handle,
|
Status = TmpContext.ImageRead (
|
||||||
TmpContext.PeCoffHeaderOffset, &Size, Hdr.Pe32);
|
TmpContext.Handle,
|
||||||
|
TmpContext.PeCoffHeaderOffset,
|
||||||
|
&Size,
|
||||||
|
Hdr.Pe32
|
||||||
|
);
|
||||||
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"%a: TmpContext.ImageRead () failed (Status = %r)\n",
|
"%a: TmpContext.ImageRead () failed (Status = %r)\n",
|
||||||
__FUNCTION__, Status));
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,40 +146,61 @@ UpdatePeCoffPermissions (
|
|||||||
//
|
//
|
||||||
Size = sizeof (EFI_IMAGE_SECTION_HEADER);
|
Size = sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||||
ReadSize = Size;
|
ReadSize = Size;
|
||||||
Status = TmpContext.ImageRead (TmpContext.Handle, SectionHeaderOffset,
|
Status = TmpContext.ImageRead (
|
||||||
&Size, &SectionHeader);
|
TmpContext.Handle,
|
||||||
|
SectionHeaderOffset,
|
||||||
|
&Size,
|
||||||
|
&SectionHeader
|
||||||
|
);
|
||||||
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
if (RETURN_ERROR (Status) || (Size != ReadSize)) {
|
||||||
DEBUG ((DEBUG_ERROR,
|
DEBUG ((
|
||||||
|
DEBUG_ERROR,
|
||||||
"%a: TmpContext.ImageRead () failed (Status = %r)\n",
|
"%a: TmpContext.ImageRead () failed (Status = %r)\n",
|
||||||
__FUNCTION__, Status));
|
__FUNCTION__,
|
||||||
|
Status
|
||||||
|
));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Base = TmpContext.ImageAddress + SectionHeader.VirtualAddress;
|
Base = TmpContext.ImageAddress + SectionHeader.VirtualAddress;
|
||||||
|
|
||||||
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) == 0) {
|
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) == 0) {
|
||||||
|
|
||||||
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) == 0) {
|
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_MEM_WRITE) == 0) {
|
||||||
|
DEBUG ((
|
||||||
DEBUG ((DEBUG_INFO,
|
DEBUG_INFO,
|
||||||
"%a: Mapping section %d of image at 0x%lx with RO-XN permissions and size 0x%x\n",
|
"%a: Mapping section %d of image at 0x%lx with RO-XN permissions and size 0x%x\n",
|
||||||
__FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize));
|
__FUNCTION__,
|
||||||
|
Index,
|
||||||
|
Base,
|
||||||
|
SectionHeader.Misc.VirtualSize
|
||||||
|
));
|
||||||
ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize);
|
ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize);
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_WARN,
|
DEBUG ((
|
||||||
|
DEBUG_WARN,
|
||||||
"%a: Mapping section %d of image at 0x%lx with RW-XN permissions and size 0x%x\n",
|
"%a: Mapping section %d of image at 0x%lx with RW-XN permissions and size 0x%x\n",
|
||||||
__FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize));
|
__FUNCTION__,
|
||||||
|
Index,
|
||||||
|
Base,
|
||||||
|
SectionHeader.Misc.VirtualSize
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO,
|
DEBUG ((
|
||||||
|
DEBUG_INFO,
|
||||||
"%a: Mapping section %d of image at 0x%lx with RO-X permissions and size 0x%x\n",
|
"%a: Mapping section %d of image at 0x%lx with RO-X permissions and size 0x%x\n",
|
||||||
__FUNCTION__, Index, Base, SectionHeader.Misc.VirtualSize));
|
__FUNCTION__,
|
||||||
|
Index,
|
||||||
|
Base,
|
||||||
|
SectionHeader.Misc.VirtualSize
|
||||||
|
));
|
||||||
ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize);
|
ReadOnlyUpdater (Base, SectionHeader.Misc.VirtualSize);
|
||||||
NoExecUpdater (Base, SectionHeader.Misc.VirtualSize);
|
NoExecUpdater (Base, SectionHeader.Misc.VirtualSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RETURN_SUCCESS;
|
return RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,8 +226,6 @@ PeCoffLoaderRelocateImageExtraAction (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
Performs additional actions just before a PE/COFF image is unloaded. Any resources
|
||||||
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
|
||||||
|
Reference in New Issue
Block a user