Skip to content

Commit

Permalink
AmdMinBoardPkg/PeiBoardInitPreMemLib: AmdMemoryInfoRange fix
Browse files Browse the repository at this point in the history
EndofAmdMemoryInfoHobPpiGuidCallBack() should only consume
information from AmdMemoryInfoRange structure. Hence, the structure
should not be modified

Cc: Abdul Lateef Attar <[email protected]>
Cc: Abner Chang <[email protected]>
Cc: Paul Grimes <[email protected]>
Signed-off-by: Shankar C <[email protected]>
  • Loading branch information
shkrc authored and abdattar committed Jan 28, 2025
1 parent 400b3e0 commit 649cc10
Showing 1 changed file with 68 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,52 @@ EndofAmdMemoryInfoHobPpiGuidCallBack (
SmramBaseAddress,
FixedPcdGet32 (PcdAmdSmramAreaSize)
);
DEBUG ((
DEBUG_INFO,
"SMRAM RESERVED_MEMORY: Base = 0x%lX, Size = 0x%lX\n",
SmramBaseAddress,
FixedPcdGet32 (PcdAmdSmramAreaSize)
));
DEBUG (
(
DEBUG_INFO,
"SMRAM RESERVED_MEMORY: Base = 0x%lX, Size = 0x%lX\n",
SmramBaseAddress,
FixedPcdGet32 (PcdAmdSmramAreaSize)
)
);

if (AmdMemoryInfoRange->Size > 0) {
BuildResourceDescriptorHob (
EFI_RESOURCE_SYSTEM_MEMORY,
SYSTEM_MEMORY_ATTRIBUTES,
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size - FixedPcdGet32 (PcdAmdSmramAreaSize)
);

DEBUG (
(
DEBUG_INFO,
"SYSTEM_MEMORY: Base = 0x%lX, Size = 0x%lX\n",
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size - FixedPcdGet32 (PcdAmdSmramAreaSize)
)
);
}

AmdMemoryInfoRange->Size -= FixedPcdGet32 (PcdAmdSmramAreaSize);
break;
}

if (AmdMemoryInfoRange->Size) {
if (AmdMemoryInfoRange->Size > 0) {
BuildResourceDescriptorHob (
EFI_RESOURCE_SYSTEM_MEMORY,
SYSTEM_MEMORY_ATTRIBUTES,
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size
);

DEBUG ((
DEBUG_INFO,
"SYSTEM_MEMORY: Base = 0x%lX, Size = 0x%lX\n",
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size
));
DEBUG (
(
DEBUG_INFO,
"SYSTEM_MEMORY: Base = 0x%lX, Size = 0x%lX\n",
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size
)
);
}

break;
Expand All @@ -118,12 +140,14 @@ EndofAmdMemoryInfoHobPpiGuidCallBack (
AmdMemoryInfoRange->Size
);

DEBUG ((
DEBUG_INFO,
"MMIO: Base = 0x%lX, Size = 0x%lX\n",
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size
));
DEBUG (
(
DEBUG_INFO,
"MMIO: Base = 0x%lX, Size = 0x%lX\n",
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size
)
);
break;

case AMD_MEMORY_ATTRIBUTE_RESERVED:
Expand All @@ -136,12 +160,14 @@ EndofAmdMemoryInfoHobPpiGuidCallBack (
AmdMemoryInfoRange->Size
);

DEBUG ((
DEBUG_INFO,
"RESERVED_MEMORY: Base = 0x%lX, Size = 0x%lX\n",
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size
));
DEBUG (
(
DEBUG_INFO,
"RESERVED_MEMORY: Base = 0x%lX, Size = 0x%lX\n",
AmdMemoryInfoRange->Base,
AmdMemoryInfoRange->Size
)
);
break;
}
}
Expand Down Expand Up @@ -177,21 +203,25 @@ EndofAmdMemoryInfoHobPpiGuidCallBack (
&MemorySize
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"%a: Error(%r) in getting Platform Memory size.\n",
__func__,
Status
));
DEBUG (
(
DEBUG_ERROR,
"%a: Error(%r) in getting Platform Memory size.\n",
__func__,
Status
)
);
return Status;
}

DEBUG ((
DEBUG_INFO,
"Installing PeiMemory, BaseAddress = 0x%x, Size = 0x%x\n",
0,
MemorySize
));
DEBUG (
(
DEBUG_INFO,
"Installing PeiMemory, BaseAddress = 0x%x, Size = 0x%x\n",
0,
MemorySize
)
);
Status = PeiServicesInstallPeiMemory (0, MemorySize);
ASSERT_EFI_ERROR (Status);
return Status;
Expand Down

0 comments on commit 649cc10

Please sign in to comment.