Skip to content

Commit

Permalink
Add the EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE attribute.
Browse files Browse the repository at this point in the history
Add the EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE resource attribute as per
the PI 1.8 spec. This flag is used to indicate that the memory should be
treated as special purpose memory (SPM).

Also adds GCD code that marks the SPM with the EFI_MEMORY_SP bit and
sets the GCD memory type to EfiGcdMemoryTypeSystemMemory.
  • Loading branch information
Patrick Payne authored and os-d committed May 17, 2024
1 parent 0eb94a3 commit b324d96
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion MdeModulePkg/Core/Dxe/Gcd/Gcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

#define MINIMUM_INITIAL_MEMORY_SIZE 0x10000

// MU_CHANGE BEGIN: Add EFI_MEMORY_SP

#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
EFI_RESOURCE_ATTRIBUTE_TESTED | \
Expand All @@ -26,7 +28,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
EFI_RESOURCE_ATTRIBUTE_64_BIT_IO | \
EFI_RESOURCE_ATTRIBUTE_PERSISTENT )
EFI_RESOURCE_ATTRIBUTE_PERSISTENT | \
EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE )

// MU_CHANGE END: Add EFI_MEMORY_SP

#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
Expand Down Expand Up @@ -92,6 +97,7 @@ GCD_ATTRIBUTE_CONVERSION_ENTRY mAttributeConversionTable[] = {
{ EFI_RESOURCE_ATTRIBUTE_TESTED, EFI_MEMORY_TESTED, FALSE },
{ EFI_RESOURCE_ATTRIBUTE_PERSISTABLE, EFI_MEMORY_NV, TRUE },
{ EFI_RESOURCE_ATTRIBUTE_MORE_RELIABLE, EFI_MEMORY_MORE_RELIABLE, TRUE },
{ EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE, EFI_MEMORY_SP, TRUE }, // MU_CHANGE: Add EFI_MEMORY_SP
{ 0, 0, FALSE }
};

Expand Down Expand Up @@ -703,6 +709,14 @@ ConverToCpuArchAttributes (
CpuArchAttributes |= EFI_MEMORY_WP;
}

// MU_CHANGE BEGIN: Add EFI_MEMORY_SP

if ((Attributes & EFI_MEMORY_SP) == EFI_MEMORY_SP) {
CpuArchAttributes |= EFI_MEMORY_SP;
}

// MU_CHANGE END: Add EFI_MEMORY_SP

return CpuArchAttributes;
}

Expand Down Expand Up @@ -2611,6 +2625,14 @@ CoreInitializeGcdServices (
GcdMemoryType = EfiGcdMemoryTypeReserved;
}

// MU_CHANGE BEGIN: Add EFI_MEMORY_SP

if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE) == EFI_RESOURCE_ATTRIBUTE_SPECIAL_PURPOSE) {
GcdMemoryType = EfiGcdMemoryTypeReserved;
}

// MU_CHANGE END: Add EFI_MEMORY_SP

if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_PERSISTENT) == EFI_RESOURCE_ATTRIBUTE_PERSISTENT) {
GcdMemoryType = EfiGcdMemoryTypePersistent;
}
Expand Down

0 comments on commit b324d96

Please sign in to comment.