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
|
/** @file
Configuration Manager Helper Library.
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
// Module specific include files.
#include <AcpiTableGenerator.h>
#include <ConfigurationManagerObject.h>
#include <ConfigurationManagerHelper.h>
#include <MetadataHelpers.h>
#include <Library/MetadataHandlerLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
/**
This macro expands to a function that retrieves the ACPI Table list
information from the Configuration Manager.
*/
GET_OBJECT_LIST (
EObjNameSpaceStandard,
EStdObjAcpiTableList,
CM_STD_OBJ_ACPI_TABLE_INFO
);
/**
This macro expands to a function that retrieves Proximity Domain
information from the Configuration Manager.
*/
GET_OBJECT_LIST (
EObjNameSpaceArchCommon,
EArchCommonObjProximityDomainInfo,
CM_ARCH_COMMON_PROXIMITY_DOMAIN_INFO
);
/** Check if an ACPI table is present in the Configuration manager's ACPI table list.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface.
@param [in] AcpiTableId Acpi Table Id.
@retval TRUE if the ACPI table is in the list of ACPI tables to install.
FALSE otherwise.
**/
BOOLEAN
EFIAPI
CheckAcpiTablePresent (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol,
IN ESTD_ACPI_TABLE_ID AcpiTableId
)
{
EFI_STATUS Status;
CM_STD_OBJ_ACPI_TABLE_INFO *AcpiTableList;
UINT32 AcpiTableListCount;
UINT32 Index;
Status = GetEStdObjAcpiTableList (
CfgMgrProtocol,
CM_NULL_TOKEN,
&AcpiTableList,
&AcpiTableListCount
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return FALSE;
}
for (Index = 0; Index < AcpiTableListCount; Index++) {
if (AcpiTableList[Index].TableGeneratorId ==
CREATE_STD_ACPI_TABLE_GEN_ID (AcpiTableId))
{
return TRUE;
}
}
return FALSE;
}
/** Get a Proximity Domain Id.
Proximity Domain Id are now to be placed in
CM_ARCH_COMMON_PROXIMITY_DOMAIN_INFO objects rather than in the various
CmObj using them. This function handles the logic in the selection
of the ProximityDomainId to use.
Proximity Domain Id should be preferably placed in
CM_ARCH_COMMON_PROXIMITY_DOMAIN_INFO objects now.
@param [in] CfgMgrProtocol Pointer to the Configuration Manager
Protocol Interface.
@param [in] DefaultDomainId Default per-CmObj Proximity Domain Id.
The CM_ARCH_COMMON_PROXIMITY_DOMAIN_INFO
should be preferably used.
@param [in] Token Token referencing a
CM_ARCH_COMMON_PROXIMITY_DOMAIN_INFO object.
@param [out] DomainId If Success, contains DomainId to use.
@retval EFI_SUCCESS Table generated successfully.
@retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid.
**/
EFI_STATUS
EFIAPI
GetProximityDomainId (
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol,
IN UINT32 DefaultDomainId,
IN CM_OBJECT_TOKEN Token,
OUT UINT32 *DomainId
)
{
EFI_STATUS Status;
CM_ARCH_COMMON_PROXIMITY_DOMAIN_INFO *ProximityDomain;
METADATA_OBJ_PROXIMITY_DOMAIN Metadata;
if ((CfgMgrProtocol == NULL) ||
(DomainId == NULL))
{
ASSERT (CfgMgrProtocol != NULL);
ASSERT (DomainId != NULL);
return EFI_INVALID_PARAMETER;
}
if (Token != CM_NULL_TOKEN) {
Status = GetEArchCommonObjProximityDomainInfo (
CfgMgrProtocol,
Token,
&ProximityDomain,
NULL
);
} else {
// If CM_NULL_TOKEN, cannot found any Proximity Domain
Status = EFI_NOT_FOUND;
}
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((
DEBUG_ERROR,
"ERROR: CM_OBJ_HELPER_LIB: Failed to get Proximity Domain. Status=%r Token=%llx\n",
Status,
Token
));
return Status;
} else if ((Status == EFI_SUCCESS) && (ProximityDomain->GenerateDomainId)) {
// A Proximity Domain was found and the Id must be generated.
Status = MetadataHandlerGenerate (
GetMetadataRoot (),
MetadataTypeProximityDomain,
Token,
NULL,
&Metadata,
sizeof (METADATA_OBJ_PROXIMITY_DOMAIN)
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
*DomainId = Metadata.Id;
} else {
// A hard-coded DomainId is used.
if (Status == EFI_NOT_FOUND) {
// No ProximityDomain CmObj was found.
// Use the default Id.
*DomainId = DefaultDomainId;
DEBUG ((
DEBUG_WARN,
"CM_OBJ_HELPER_LIB: Proximity Domain Ids should be described using "
"the new EArchCommonObjProximityDomainInfo object. "
"The field currently used will be deprecated.\n"
));
} else if (!ProximityDomain->GenerateDomainId) {
// A ProximityDomain CmObj was found, but generation is disabled.
// Use the Domain Id.
*DomainId = ProximityDomain->DomainId;
Metadata.Id = *DomainId;
// Add the Domain Id to the Metadata database to check duplicated values.
Status = MetadataAdd (
GetMetadataRoot (),
MetadataTypeProximityDomain,
Token,
&Metadata,
sizeof (METADATA_OBJ_PROXIMITY_DOMAIN)
);
if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
} else {
ASSERT_EFI_ERROR (Status);
}
}
return EFI_SUCCESS;
}
|