TianoCore EDK2 master
Loading...
Searching...
No Matches
ArmSratGenerator.c
Go to the documentation of this file.
1
15#include <Library/AcpiLib.h>
16#include <Library/BaseLib.h>
17#include <Library/DebugLib.h>
19#include <Protocol/AcpiTable.h>
20
21// Module specific include files.
22#include <AcpiTableGenerator.h>
27
28#include "SratGenerator.h"
29
46 );
47
56 );
57
61typedef enum ArmSratSubTableType {
62 EArmGicCSubTableType,
63 EArmGicItsSubTableType,
64 EArmSubTableTypeMax,
66
67typedef struct SratSubTable {
69 UINT32 Offset;
70
72 UINT32 Count;
73
75 VOID *CmInfo;
77
78STATIC SRAT_SUB_TABLE mSratSubTable[EArmSubTableTypeMax];
79
98EFIAPI
101 IN OUT UINT32 *ArchOffset
102 )
103{
104 EFI_STATUS Status;
105
106 ASSERT (CfgMgrProtocol != NULL);
107 ASSERT (ArchOffset != NULL);
108
109 Status = GetEArmObjGicCInfo (
110 CfgMgrProtocol,
112 (CM_ARM_GICC_INFO **)&mSratSubTable[EArmGicCSubTableType].CmInfo,
113 &mSratSubTable[EArmGicCSubTableType].Count
114 );
115 if (EFI_ERROR (Status)) {
116 DEBUG ((
117 DEBUG_ERROR,
118 "ERROR: SRAT: Failed to get GICC Info. Status = %r\n",
119 Status
120 ));
121 return Status;
122 }
123
124 if (mSratSubTable[EArmGicCSubTableType].Count == 0) {
125 DEBUG ((
126 DEBUG_ERROR,
127 "ERROR: SRAT: GIC CPU Interface information not provided.\n"
128 ));
129 ASSERT (0);
130 return EFI_INVALID_PARAMETER;
131 }
132
133 Status = GetEArmObjGicItsInfo (
134 CfgMgrProtocol,
136 (CM_ARM_GIC_ITS_INFO **)&mSratSubTable[EArmGicItsSubTableType].CmInfo,
137 &mSratSubTable[EArmGicItsSubTableType].Count
138 );
139 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
140 DEBUG ((
141 DEBUG_ERROR,
142 "ERROR: SRAT: Failed to get GIC ITS Info. Status = %r\n",
143 Status
144 ));
145 return Status;
146 }
147
148 mSratSubTable[EArmGicCSubTableType].Offset = *ArchOffset;
149 *ArchOffset += (sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE) *
150 mSratSubTable[EArmGicCSubTableType].Count);
151
152 if (mSratSubTable[EArmGicItsSubTableType].Count != 0) {
153 mSratSubTable[EArmGicItsSubTableType].Offset = *ArchOffset;
154 *ArchOffset += (sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE) *
155 mSratSubTable[EArmGicItsSubTableType].Count);
156 }
157
158 return EFI_SUCCESS;
159}
160
167STATIC
168VOID
169EFIAPI
173 )
174{
176 CM_ARM_GICC_INFO *GicCInfo;
177
178 GicCInfo = mSratSubTable[EArmGicCSubTableType].CmInfo;
179 GicCAff = (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *)((UINT8 *)Srat +
180 mSratSubTable[EArmGicCSubTableType].Offset);
181
182 while (mSratSubTable[EArmGicCSubTableType].Count-- != 0) {
183 DEBUG ((DEBUG_INFO, "SRAT: GicCAff = 0x%p\n", GicCAff));
184
185 GicCAff->Type = EFI_ACPI_6_3_GICC_AFFINITY;
186 GicCAff->Length = sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE);
187 GicCAff->ProximityDomain = GicCInfo->ProximityDomain;
188 GicCAff->AcpiProcessorUid = GicCInfo->AcpiProcessorUid;
189 GicCAff->Flags = GicCInfo->AffinityFlags;
190 GicCAff->ClockDomain = GicCInfo->ClockDomain;
191
192 // Next
193 GicCAff++;
194 GicCInfo++;
195 }// while
196}
197
204STATIC
205VOID
206EFIAPI
210 )
211{
213 CM_ARM_GIC_ITS_INFO *GicItsInfo;
214
215 GicItsInfo = mSratSubTable[EArmGicItsSubTableType].CmInfo;
216 GicItsAff = (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *)((UINT8 *)Srat +
217 mSratSubTable[EArmGicItsSubTableType].Offset);
218
219 while (mSratSubTable[EArmGicItsSubTableType].Count-- != 0) {
220 DEBUG ((DEBUG_INFO, "SRAT: GicItsAff = 0x%p\n", GicItsAff));
221
222 GicItsAff->Type = EFI_ACPI_6_3_GIC_ITS_AFFINITY;
223 GicItsAff->Length = sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE);
224 GicItsAff->ProximityDomain = GicItsInfo->ProximityDomain;
225 GicItsAff->Reserved[0] = EFI_ACPI_RESERVED_BYTE;
226 GicItsAff->Reserved[1] = EFI_ACPI_RESERVED_BYTE;
227 GicItsAff->ItsId = GicItsInfo->GicItsId;
228
229 // Next
230 GicItsAff++;
231 GicItsInfo++;
232 }// while
233}
234
246EFIAPI
250 )
251{
252 ASSERT (CfgMgrProtocol != NULL);
253 ASSERT (Srat != NULL);
254
255 AddGICCAffinity (CfgMgrProtocol, Srat);
256
257 if (mSratSubTable[EArmGicCSubTableType].Count != 0) {
258 AddGICItsAffinity (CfgMgrProtocol, Srat);
259 }
260
261 return EFI_SUCCESS;
262}
@ EArmObjGicCInfo
2 - GIC CPU Interface Info
@ EArmObjGicItsInfo
6 - GIC ITS Info
STATIC VOID EFIAPI AddGICItsAffinity(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat)
ArmSratSubTableType
EFI_STATUS EFIAPI AddArchObjects(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat)
enum ArmSratSubTableType EARM_SRAT_SUB_TABLE_TYPE
STATIC VOID EFIAPI AddGICCAffinity(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER *CONST Srat)
EFI_STATUS EFIAPI ArchReserveOffsets(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN OUT UINT32 *ArchOffset)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceArm
ARM Objects Namespace.
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define CM_NULL_TOKEN
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
UINT32 GicItsId
The GIC ITS ID.
VOID * CmInfo
Array of CmInfo objects of the relevant type.
UINT32 Count
Count.
UINT32 Offset
Start offset of the arch specific sub-table.