Skip to content

Commit 740e3bb

Browse files
pierregondoismergify[bot]
authored andcommitted
DynamicTablesPkg: DynamicPlatRepo: Add TokenFixer
The DynamicPlatRepo library allows to handle dynamically created CmObj. The dynamic platform repository can be in the following states: 1 - Non-initialised 2 - Transient: Possibility to add CmObj to the platform, but not to query them. 3 - Finalised: Possibility to query CmObj, but not to add new. A token is allocated to each CmObj added to the dynamic platform repository (except for reference tokens CmObj). This allows to retrieve dynamic CmObjs among all CmObj (static CmObj for instance). This patch add the TokenFixer files, allowing to update the self-token some CmObj have. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
1 parent 2e2db65 commit 740e3bb

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/** @file
2+
Configuration Manager object token fixer
3+
4+
Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
5+
6+
SPDX-License-Identifier: BSD-2-Clause-Patent
7+
8+
@par Glossary:
9+
- Cm or CM - Configuration Manager
10+
- Obj or OBJ - Object
11+
**/
12+
13+
#include <Library/DebugLib.h>
14+
#include <Protocol/ConfigurationManagerProtocol.h>
15+
#include "CmObjectTokenFixer.h"
16+
17+
/** Token fixer not implemented.
18+
19+
Most of the objects are not generated by this parser. Add the missing
20+
functions when needed.
21+
22+
CmObjectToken fixer function that updates the Tokens in the CmObjects.
23+
24+
@param [in] CmObject Pointer to the Configuration Manager Object.
25+
@param [in] Token Token to be updated in the CmObject.
26+
27+
@retval EFI_SUCCESS Success.
28+
@retval EFI_INVALID_PARAMETER A parameter is invalid.
29+
@retval EFI_UNSUPPORTED Not supported.
30+
**/
31+
STATIC
32+
EFI_STATUS
33+
EFIAPI
34+
TokenFixerNotImplemented (
35+
IN CM_OBJ_DESCRIPTOR *CmObject,
36+
IN CM_OBJECT_TOKEN Token
37+
)
38+
{
39+
ASSERT (0);
40+
return EFI_UNSUPPORTED;
41+
}
42+
43+
/** EArmObjItsGroup token fixer.
44+
45+
CmObjectToken fixer function that updates the Tokens in the CmObjects.
46+
47+
@param [in] CmObject Pointer to the Configuration Manager Object.
48+
@param [in] Token Token to be updated in the CmObject.
49+
50+
@retval EFI_SUCCESS Success.
51+
@retval EFI_INVALID_PARAMETER A parameter is invalid.
52+
@retval EFI_UNSUPPORTED Not supported.
53+
**/
54+
STATIC
55+
EFI_STATUS
56+
EFIAPI
57+
TokenFixerItsGroup (
58+
IN CM_OBJ_DESCRIPTOR *CmObject,
59+
IN CM_OBJECT_TOKEN Token
60+
)
61+
{
62+
ASSERT (CmObject != NULL);
63+
((CM_ARM_ITS_GROUP_NODE *)CmObject)->Token = Token;
64+
return EFI_SUCCESS;
65+
}
66+
67+
/** TokenFixer functions table.
68+
69+
A CmObj having a CM_OBJECT_TOKEN field might need to have its
70+
Token fixed. Each CmObj can have its Token in a specific way.
71+
*/
72+
CONST
73+
CM_OBJECT_TOKEN_FIXER TokenFixer[EArmObjMax] = {
74+
NULL, ///< 0 - Reserved
75+
NULL, ///< 1 - Boot Architecture Info
76+
NULL, ///< 2 - CPU Info
77+
NULL, ///< 3 - Power Management Profile Info
78+
NULL, ///< 4 - GIC CPU Interface Info
79+
NULL, ///< 5 - GIC Distributor Info
80+
NULL, ///< 6 - GIC MSI Frame Info
81+
NULL, ///< 7 - GIC Redistributor Info
82+
NULL, ///< 8 - GIC ITS Info
83+
NULL, ///< 9 - Serial Console Port Info
84+
NULL, ///< 10 - Serial Debug Port Info
85+
NULL, ///< 11 - Generic Timer Info
86+
NULL, ///< 12 - Platform GT Block Info
87+
NULL, ///< 13 - Generic Timer Block Frame Info
88+
NULL, ///< 14 - Platform Generic Watchdog
89+
NULL, ///< 15 - PCI Configuration Space Info
90+
NULL, ///< 16 - Hypervisor Vendor Id
91+
NULL, ///< 17 - Fixed feature flags for FADT
92+
TokenFixerItsGroup, ///< 18 - ITS Group
93+
TokenFixerNotImplemented, ///< 19 - Named Component
94+
TokenFixerNotImplemented, ///< 20 - Root Complex
95+
TokenFixerNotImplemented, ///< 21 - SMMUv1 or SMMUv2
96+
TokenFixerNotImplemented, ///< 22 - SMMUv3
97+
TokenFixerNotImplemented, ///< 23 - PMCG
98+
NULL, ///< 24 - GIC ITS Identifier Array
99+
NULL, ///< 25 - ID Mapping Array
100+
NULL, ///< 26 - SMMU Interrupt Array
101+
TokenFixerNotImplemented, ///< 27 - Processor Hierarchy Info
102+
TokenFixerNotImplemented, ///< 28 - Cache Info
103+
TokenFixerNotImplemented, ///< 29 - Processor Node ID Info
104+
NULL, ///< 30 - CM Object Reference
105+
NULL, ///< 31 - Memory Affinity Info
106+
NULL, ///< 32 - Device Handle Acpi
107+
NULL, ///< 33 - Device Handle Pci
108+
NULL, ///< 34 - Generic Initiator Affinity
109+
NULL, ///< 35 - Generic Serial Port Info
110+
NULL, ///< 36 - CMN-600 Info
111+
NULL, ///< 37 - Lpi Info
112+
NULL, ///< 38 - Pci Address Map Info
113+
NULL, ///< 39 - Pci Interrupt Map Info
114+
};
115+
116+
/** CmObj token fixer.
117+
118+
Some CmObj structures have a self-token, i.e. they are storing their own
119+
token value in the CmObj. Dynamically created CmObj need to have their
120+
self-token assigned at some point.
121+
122+
@param [in] CmObjDesc Pointer to the Configuration Manager Object.
123+
@param [in] Token Token to update the CmObjDesc with.
124+
125+
@retval EFI_SUCCESS Success.
126+
@retval EFI_INVALID_PARAMETER A parameter is invalid.
127+
@retval EFI_UNSUPPORTED Not supported.
128+
**/
129+
EFI_STATUS
130+
EFIAPI
131+
FixupCmObjectSelfToken (
132+
IN CM_OBJ_DESCRIPTOR *CmObjDesc,
133+
IN CM_OBJECT_TOKEN Token
134+
)
135+
{
136+
EFI_STATUS Status;
137+
CM_OBJECT_TOKEN_FIXER TokenFixerFunc;
138+
CM_OBJECT_ID ArmNamespaceObjId;
139+
140+
// Only support Arm objects for now.
141+
if ((CmObjDesc == NULL) ||
142+
(GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId) != EObjNameSpaceArm))
143+
{
144+
ASSERT (0);
145+
return EFI_INVALID_PARAMETER;
146+
}
147+
148+
ArmNamespaceObjId = GET_CM_OBJECT_ID (CmObjDesc->ObjectId);
149+
if (ArmNamespaceObjId >= EArmObjMax) {
150+
ASSERT (0);
151+
return EFI_INVALID_PARAMETER;
152+
}
153+
154+
// Fixup self-token if necessary.
155+
TokenFixerFunc = TokenFixer[ArmNamespaceObjId];
156+
if (TokenFixerFunc != NULL) {
157+
Status = TokenFixerFunc (CmObjDesc, Token);
158+
if (EFI_ERROR (Status)) {
159+
ASSERT (0);
160+
return Status;
161+
}
162+
}
163+
164+
return EFI_SUCCESS;
165+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/** @file
2+
Configuration Manager object token fixer
3+
4+
Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
5+
6+
SPDX-License-Identifier: BSD-2-Clause-Patent
7+
8+
@par Glossary:
9+
- Cm or CM - Configuration Manager
10+
- Obj or OBJ - Object
11+
**/
12+
13+
#ifndef CM_OBJECT_TOKEN_FIXER_H_
14+
#define CM_OBJECT_TOKEN_FIXER_H_
15+
16+
/** CmObjectToken fixer function that updates the Tokens in the CmObjects.
17+
18+
@param [in] CmObject Pointer to the Configuration Manager Object.
19+
@param [in] Token Token to be updated in the CmObject.
20+
21+
@retval EFI_SUCCESS Success.
22+
@retval EFI_INVALID_PARAMETER A parameter is invalid.
23+
@retval EFI_UNSUPPORTED Not supported.
24+
**/
25+
typedef
26+
EFI_STATUS
27+
(EFIAPI *CM_OBJECT_TOKEN_FIXER)(
28+
IN CM_OBJ_DESCRIPTOR *CmObject,
29+
IN CM_OBJECT_TOKEN Token
30+
);
31+
32+
/** CmObj token fixer.
33+
34+
Some CmObj structures have a self-token, i.e. they are storing their own
35+
token value in the CmObj. Dynamically created CmObj need to have their
36+
self-token assigned at some point.
37+
38+
@param [in] CmObjDesc Pointer to the Configuration Manager Object.
39+
@param [in] Token Token to update the CmObjDesc with.
40+
41+
@retval EFI_SUCCESS Success.
42+
@retval EFI_INVALID_PARAMETER A parameter is invalid.
43+
@retval EFI_UNSUPPORTED Not supported.
44+
**/
45+
EFI_STATUS
46+
EFIAPI
47+
FixupCmObjectSelfToken (
48+
IN CM_OBJ_DESCRIPTOR *CmObjDesc,
49+
IN CM_OBJECT_TOKEN Token
50+
);
51+
52+
#endif // CM_OBJECT_TOKEN_FIXER_H_

0 commit comments

Comments
 (0)