2 Header file for the dynamic PPTT generator
4 Copyright (c) 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - ACPI 6.3 Specification, January 2019
9 - ARM Architecture Reference Manual ARMv8 (D.a)
12 - Cm or CM - Configuration Manager
16 #ifndef PPTT_GENERATOR_H_
17 #define PPTT_GENERATOR_H_
21 /// Cache parameters allowed by the architecture with
22 /// ARMv8.3-CCIDX (Cache extended number of sets)
23 /// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0001
24 #define PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX (1 << 24)
25 #define PPTT_ARM_CCIDX_CACHE_ASSOCIATIVITY_MAX (1 << 21)
27 /// Cache parameters allowed by the architecture without
28 /// ARMv8.3-CCIDX (Cache extended number of sets)
29 /// Derived from CCSIDR_EL1 when ID_AA64MMFR2_EL1.CCIDX==0000
30 #define PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX (1 << 15)
31 #define PPTT_ARM_CACHE_ASSOCIATIVITY_MAX (1 << 10)
33 /// Common cache parameters
34 /// Derived from CCSIDR_EL1
35 /// The LineSize is represented by bits 2:0
36 /// (Log2(Number of bytes in cache line)) - 4 is used to represent
37 /// the LineSize bits.
38 #define PPTT_ARM_CACHE_LINE_SIZE_MAX (1 << 11)
39 #define PPTT_ARM_CACHE_LINE_SIZE_MIN (1 << 4)
41 /// Test if the given Processor Hierarchy Info object has the 'Node is a Leaf'
43 #define IS_PROC_NODE_LEAF(Node) ((Node->Flags & BIT3) != 0)
45 /// Test if the given Processor Hierarchy Info object has the 'ACPI Processor
46 /// ID valid' flag set
47 #define IS_ACPI_PROC_ID_VALID(Node) ((Node->Flags & BIT1) != 0)
50 The GET_SIZE_OF_PPTT_STRUCTS macro expands to a function that is used to
51 calculate the total memory requirement for the PPTT structures represented
52 by the given list of Configuration Manager Objects of the same type. This
53 function also indexes the input CM objects so that various other CM objects
54 (possibly of different type) can reference them.
56 The size of memory needed for the specified type of PPTT structures is based
57 on the number and type of CM objects provided. The macro assumes that the
58 ACPI object PpttObjName has fixed size.
60 The macro expands to a function which has the following prototype:
65 GetSizeof<PpttObjName> (
66 IN CONST UINT32 StartOffset,
67 IN CONST CmObjectType * Nodes,
69 IN OUT PPTT_NODE_INDEXER ** CONST NodeIndexer
72 Generated function parameters:
73 @param [in] StartOffset Offset from the start of PPTT to where
74 the PPTT structures will be placed.
75 @param [in] NodesToIndex Pointer to the list of CM objects to be
76 indexed and size-estimated.
77 @param [out] NodeCount Number of CM objects in NodesToIndex.
78 @param [in, out] NodeIndexer Pointer to the list of Node Indexer
80 @retval Size Total memory requirement for the PPTT
81 structures described in NodesToIndex.
84 @param [in] PpttObjName Name for the type of PPTT structures which
86 @param [in] PpttObjSize Expression to use to calculate the size of
87 of a single instance of the PPTT structure
88 which corresponds to the CM object being
90 @param [in] CmObjectType Data type of the CM nodes in NodesToIndex.
92 #define GET_SIZE_OF_PPTT_STRUCTS( \
99 GetSizeof##PpttObjName ( \
100 IN CONST UINT32 StartOffset, \
101 IN CONST CmObjectType * NodesToIndex, \
102 IN UINT32 NodeCount, \
103 IN OUT PPTT_NODE_INDEXER ** CONST NodeIndexer \
109 (NodesToIndex != NULL) && \
110 (NodeIndexer != NULL) \
114 while (NodeCount-- != 0) { \
115 (*NodeIndexer)->Token = NodesToIndex->Token; \
116 (*NodeIndexer)->Object = (VOID*)NodesToIndex; \
117 (*NodeIndexer)->Offset = Size + StartOffset; \
118 (*NodeIndexer)->CycleDetectionStamp = 0; \
119 (*NodeIndexer)->TopologyParent = NULL; \
122 "PPTT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n", \
124 (*NodeIndexer)->Token, \
125 (*NodeIndexer)->Object, \
126 (*NodeIndexer)->Offset \
129 Size += PpttObjSize; \
137 A structure for indexing CM objects (nodes) used in PPTT generation.
139 PPTT_NODE_INDEXER is a wrapper around CM objects which augments these objects
140 with additional information that enables generating PPTT structures with
141 correct cross-references.
143 PPTT_NODE_INDEXER keeps track of each structure's offset from the base
144 address of the generated table. It also caches certain information and makes
145 PPTT cyclic reference detection possible.
147 typedef struct PpttNodeIndexer
{
148 /// Unique identifier for the node
149 CM_OBJECT_TOKEN Token
;
150 /// Pointer to the CM object being indexed
152 /// Offset from the start of the PPTT table to the PPTT structure which is
153 /// represented by Object
155 /// Field used to mark nodes as 'visited' when detecting cycles in processor
156 /// and cache topology
157 UINT32 CycleDetectionStamp
;
158 /// Reference to a Node Indexer element which is the parent of this Node
159 /// Indexer element in the processor and cache topology
160 /// e.g For a hardware thread the TopologyParent would point to a CPU node
161 /// For a L1 cache the TopologyParent would point to a L2 cache
162 struct PpttNodeIndexer
* TopologyParent
;
165 typedef struct AcpiPpttGenerator
{
166 /// ACPI Table generator header
167 ACPI_TABLE_GENERATOR Header
;
168 /// PPTT structure count
169 UINT32 ProcTopologyStructCount
;
170 /// List of indexed CM objects for PPTT generation
171 PPTT_NODE_INDEXER
* NodeIndexer
;
172 /// Pointer to the start of Processor Hierarchy nodes in
173 /// the Node Indexer array
174 PPTT_NODE_INDEXER
* ProcHierarchyNodeIndexedList
;
175 /// Pointer to the start of Cache Structures in the Node Indexer array
176 PPTT_NODE_INDEXER
* CacheStructIndexedList
;
177 /// Pointer to the start of Id Structures in the Node Indexer array
178 PPTT_NODE_INDEXER
* IdStructIndexedList
;
179 /// Count of Processor Hierarchy Nodes
180 UINT32 ProcHierarchyNodeCount
;
181 /// Count of Cache Structures
182 UINT32 CacheStructCount
;
183 /// Count of Id Structures
184 UINT32 IdStructCount
;
186 } ACPI_PPTT_GENERATOR
;
190 #endif // PPTT_GENERATOR_H_