1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
/** @file
ARM specific ACPI Maximum System Characteristics Table (MSCT) Generator
Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
#include <ConfigurationManagerHelper.h>
#include <Library/TableHelperLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
#include <Library/CmObjHelperLib.h>
#include "MsctGenerator.h"
/**
ARM standard MSCT Generator
Requirements:
The following Configuration Manager Object(s) are used by this Generator:
- EArmObjGicCInfo (OPTIONAL)
*/
/** This macro expands to a function that retrieves the GIC
CPU interface Information from the Configuration Manager.
*/
GET_OBJECT_LIST (
EObjNameSpaceArm,
EArmObjGicCInfo,
CM_ARM_GICC_INFO
);
/** Get architecture processor domain information.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol.
@param [out] ProcDomainInfo Pointer to the processor domain information.
@param [out] ProcDomainInfoCount Pointer to the count of processor domain
information structures.
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@retval Other Other EFI_STATUS error from called functions.
**/
EFI_STATUS
EFIAPI
GetArchProcessorDomainInfo (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
OUT UINT32 **ProcDomainInfo,
OUT UINT32 *ProcDomainInfoCount
)
{
CM_ARM_GICC_INFO *CmProcDomain;
EFI_STATUS Status;
UINT32 Index;
UINT32 ProcDomainCount;
UINT32 *ProcDomain;
if ((CfgMgrProtocol == NULL) ||
(ProcDomainInfo == NULL) ||
(ProcDomainInfoCount == NULL))
{
ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
return EFI_INVALID_PARAMETER;
}
CmProcDomain = NULL;
ProcDomain = NULL;
ProcDomainCount = 0;
Status = GetEArmObjGicCInfo (
CfgMgrProtocol,
CM_NULL_TOKEN,
&CmProcDomain,
&ProcDomainCount
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: MSCT: Failed to get GICC Info. Status = %r\n",
Status
));
return Status;
}
ProcDomain = AllocateZeroPool (
sizeof (UINT32) *
ProcDomainCount
);
if (ProcDomain == NULL) {
Status = EFI_OUT_OF_RESOURCES;
ASSERT_EFI_ERROR (Status);
return Status;
}
for (Index = 0; Index < ProcDomainCount; Index++) {
Status = GetProximityDomainId (
CfgMgrProtocol,
CmProcDomain[Index].ProximityDomain,
CmProcDomain[Index].ProximityDomainToken,
&ProcDomain[Index]
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"MSCT: Failed to get Proximity Domain ID for index %d. Status = %r\n",
Index,
Status
));
ASSERT_EFI_ERROR (Status);
goto error_handler;
}
}
*ProcDomainInfo = ProcDomain;
*ProcDomainInfoCount = ProcDomainCount;
return EFI_SUCCESS;
error_handler:
if (ProcDomain != NULL) {
FreePool (ProcDomain);
}
return Status;
}
/** Get the count of unique architecture clock domains.
Enumerates all GIC CPU interfaces and returns the number of unique clock
proximity domain IDs in the system.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol.
@param [out] ClockDomainCount On success, the cardinal count of unique
clock domains.
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_INVALID_PARAMETER A parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
@retval Other Other EFI_STATUS error from called functions.
**/
EFI_STATUS
EFIAPI
GetArchClockDomainInfo (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
OUT UINT32 *ClockDomainCount
)
{
EFI_STATUS Status;
UINT32 ProximityDomain;
UINT32 CmCount;
UINT32 Index;
UINT32 UniqueIndex;
CM_ARM_GICC_INFO *CmGiccInfo;
UINT32 *ClockDomains;
UINT32 UniqueCount;
BOOLEAN IsUnique;
if ((CfgMgrProtocol == NULL) ||
(ClockDomainCount == NULL))
{
ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
return EFI_INVALID_PARAMETER;
}
CmGiccInfo = NULL;
ClockDomains = NULL;
UniqueCount = 0;
CmCount = 0;
Status = GetEArmObjGicCInfo (
CfgMgrProtocol,
CM_NULL_TOKEN,
&CmGiccInfo,
&CmCount
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: MSCT: Failed to get GICC Info. Status = %r\n",
Status
));
return Status;
}
if ((CmGiccInfo == NULL) || (CmCount == 0)) {
*ClockDomainCount = 0;
return EFI_SUCCESS;
}
// Allocate worst-case storage: every CPU could be in its own clock domain.
ClockDomains = AllocateZeroPool (sizeof (UINT32) * CmCount);
if (ClockDomains == NULL) {
Status = EFI_OUT_OF_RESOURCES;
ASSERT_EFI_ERROR (Status);
return Status;
}
for (Index = 0; Index < CmCount; Index++) {
Status = GetProximityDomainId (
CfgMgrProtocol,
CmGiccInfo[Index].ClockDomain,
CmGiccInfo[Index].ClockDomainToken,
&ProximityDomain
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: MSCT: Failed to get Clock Domain ID for index %d. Status = %r\n",
Index,
Status
));
ASSERT_EFI_ERROR (Status);
goto error_handler;
}
// Record the proximity domain ID only if not already seen.
IsUnique = TRUE;
for (UniqueIndex = 0; UniqueIndex < UniqueCount; UniqueIndex++) {
if (ClockDomains[UniqueIndex] == ProximityDomain) {
IsUnique = FALSE;
break;
}
}
if (IsUnique) {
ClockDomains[UniqueCount++] = ProximityDomain;
}
}
*ClockDomainCount = UniqueCount;
Status = EFI_SUCCESS;
error_handler:
if (ClockDomains != NULL) {
FreePool (ClockDomains);
}
return Status;
}
|