Skip to content

Commit

Permalink
DynamicTablesPkg/AmlLib: Enumerate memory attributes
Browse files Browse the repository at this point in the history
AmlCodeGenRdQWordMemory's and AmlCodeGenRdDWordMemory's Cacheable
and MemoryRangeType parameters treat specific values as having
specific meanings as defined by the spec. This change adds enums to map
those meanings to their corresponding values.

Signed-off-by: Jeshua Smith <jeshuas@nvidia.com>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
  • Loading branch information
jeshuasmith authored and mergify[bot] committed Oct 23, 2023
1 parent ec7f734 commit 309450d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
1 change: 1 addition & 0 deletions DynamicTablesPkg/DynamicTablesPkg.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"ARMLTD",
"AMLDBG",
"EISAID",
"cacheablity",
"CCIDX",
"CCSIDR",
"countof",
Expand Down
49 changes: 45 additions & 4 deletions DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,47 @@ typedef void *AML_DATA_NODE_HANDLE;

#endif // AML_HANDLE

/** Memory attributes, _MEM (2 bits)
Possible values are:
0-The memory is non-cacheable
1-The memory is cacheable (DEPRECATED)
2-The memory is cacheable and supports
write combining (DEPRECATED)
3-The memory is cacheable and prefetchable
@par Reference(s):
- ACPI 6.5, s6.4.3.5.5 "Resource Type Specific Flags"
**/
typedef enum {
AmlMemoryNonCacheable = 0,
AmlMemoryCacheable = 1,
AmlMemoryCacheableWriteCombine = 2,
AmlMemoryCacheablePrefetch = 3,
AmlMemoryCacheablityMax = 4
} AML_MEMORY_ATTRIBUTES_MEM;

/** Memory attributes, _MTP (2 bits)
Possible values are:
0-AddressRangeMemory
1-AddressRangeReserved
2-AddressRangeACPI
3-AddressRangeNVS
@par Reference(s):
- ACPI 6.5, s6.4.3.5.5 "Resource Type Specific Flags"
**/
typedef enum {
AmlAddressRangeMemory = 0,
AmlAddressRangeReserved = 1,
AmlAddressRangeACPI = 2,
AmlAddressRangeNVS = 3,
AmlAddressRangeMax = 4
} AML_MEMORY_ATTRIBUTES_MTP;

/** Parse the definition block.
The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
Expand Down Expand Up @@ -578,7 +619,7 @@ AmlCodeGenRdDWordMemory (
IN BOOLEAN IsPosDecode,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN UINT8 Cacheable,
IN AML_MEMORY_ATTRIBUTES_MEM Cacheable,
IN BOOLEAN IsReadWrite,
IN UINT32 AddressGranularity,
IN UINT32 AddressMinimum,
Expand All @@ -587,7 +628,7 @@ AmlCodeGenRdDWordMemory (
IN UINT32 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN UINT8 MemoryRangeType,
IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
Expand Down Expand Up @@ -809,7 +850,7 @@ AmlCodeGenRdQWordMemory (
IN BOOLEAN IsPosDecode,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN UINT8 Cacheable,
IN AML_MEMORY_ATTRIBUTES_MEM Cacheable,
IN BOOLEAN IsReadWrite,
IN UINT64 AddressGranularity,
IN UINT64 AddressMinimum,
Expand All @@ -818,7 +859,7 @@ AmlCodeGenRdQWordMemory (
IN UINT64 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN UINT8 MemoryRangeType,
IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ GeneratePciCrs (
IsPosDecode,
TRUE,
TRUE,
TRUE,
AmlMemoryCacheable,
TRUE,
0,
AddrMapInfo->PciAddress,
Expand All @@ -575,7 +575,7 @@ GeneratePciCrs (
AddrMapInfo->AddressSize,
0,
NULL,
0,
AmlAddressRangeMemory,
TRUE,
CrsNode,
NULL
Expand All @@ -588,7 +588,7 @@ GeneratePciCrs (
IsPosDecode,
TRUE,
TRUE,
TRUE,
AmlMemoryCacheable,
TRUE,
0,
AddrMapInfo->PciAddress,
Expand All @@ -597,7 +597,7 @@ GeneratePciCrs (
AddrMapInfo->AddressSize,
0,
NULL,
0,
AmlAddressRangeMemory,
TRUE,
CrsNode,
NULL
Expand Down Expand Up @@ -718,7 +718,7 @@ ReserveEcamSpace (
TRUE,
TRUE,
TRUE,
FALSE, // non-cacheable
AmlMemoryNonCacheable,
TRUE,
0,
AddressMinimum,
Expand All @@ -727,7 +727,7 @@ ReserveEcamSpace (
AddressMaximum - AddressMinimum + 1,
0,
NULL,
0,
AmlAddressRangeMemory,
TRUE,
CrsNode,
NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ AmlCodeGenRdDWordMemory (
IN BOOLEAN IsPosDecode,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN UINT8 Cacheable,
IN AML_MEMORY_ATTRIBUTES_MEM Cacheable,
IN BOOLEAN IsReadWrite,
IN UINT32 AddressGranularity,
IN UINT32 AddressMinimum,
Expand All @@ -579,7 +579,7 @@ AmlCodeGenRdDWordMemory (
IN UINT32 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN UINT8 MemoryRangeType,
IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
Expand Down Expand Up @@ -1161,7 +1161,7 @@ AmlCodeGenRdQWordMemory (
IN BOOLEAN IsPosDecode,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN UINT8 Cacheable,
IN AML_MEMORY_ATTRIBUTES_MEM Cacheable,
IN BOOLEAN IsReadWrite,
IN UINT64 AddressGranularity,
IN UINT64 AddressMinimum,
Expand All @@ -1170,7 +1170,7 @@ AmlCodeGenRdQWordMemory (
IN UINT64 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN UINT8 MemoryRangeType,
IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
Expand Down

0 comments on commit 309450d

Please sign in to comment.