4 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include <Protocol/AcpiTable.h>
15 #include <Library/BaseLib.h>
16 #include <Library/DebugLib.h>
17 #include <Library/BaseMemoryLib.h>
19 // Module specific include files.
20 #include <AcpiTableGenerator.h>
21 #include <ConfigurationManagerObject.h>
22 #include <Protocol/ConfigurationManagerProtocol.h>
24 /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
25 object from the Configuration Manager.
27 @param [in] CfgMgrProtocol Pointer to the Configuration Manager protocol
29 @param [out] CfgMfrInfo Pointer to the Configuration Manager Info
32 @retval EFI_SUCCESS The object is returned.
33 @retval EFI_INVALID_PARAMETER The Object ID is invalid.
34 @retval EFI_NOT_FOUND The requested Object is not found.
35 @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
36 Manager is less than the Object size.
41 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
42 OUT CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
** CfgMfrInfo
46 CM_OBJ_DESCRIPTOR CmObjectDesc
;
48 ASSERT (CfgMgrProtocol
!= NULL
);
49 ASSERT (CfgMfrInfo
!= NULL
);
52 Status
= CfgMgrProtocol
->GetObject (
54 CREATE_CM_STD_OBJECT_ID (EStdObjCfgMgrInfo
),
58 if (EFI_ERROR (Status
)) {
61 "ERROR: Failed to Get Configuration Manager Info. Status = %r\n",
67 if (CmObjectDesc
.ObjectId
!= CREATE_CM_STD_OBJECT_ID (EStdObjCfgMgrInfo
)) {
70 "ERROR: EStdObjCfgMgrInfo: Invalid ObjectId = 0x%x, expected Id = 0x%x\n",
71 CmObjectDesc
.ObjectId
,
72 CREATE_CM_STD_OBJECT_ID (EStdObjCfgMgrInfo
)
75 return EFI_INVALID_PARAMETER
;
78 if (CmObjectDesc
.Size
<
79 (sizeof (CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
) * CmObjectDesc
.Count
)) {
82 "ERROR: EStdObjCfgMgrInfo: Buffer too small, size = 0x%x\n",
86 return EFI_BAD_BUFFER_SIZE
;
89 *CfgMfrInfo
= (CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
*)CmObjectDesc
.Data
;
93 /** The AddAcpiHeader function updates the ACPI header structure pointed by
94 the AcpiHeader. It utilizes the ACPI table Generator and the Configuration
95 Manager protocol to obtain any information required for constructing the
98 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
100 @param [in] Generator Pointer to the ACPI table Generator.
101 @param [in,out] AcpiHeader Pointer to the ACPI table header to be
103 @param [in] AcpiTableInfo Pointer to the ACPI table info structure.
104 @param [in] Length Length of the ACPI table.
106 @retval EFI_SUCCESS The ACPI table is updated successfully.
107 @retval EFI_INVALID_PARAMETER A parameter is invalid.
108 @retval EFI_NOT_FOUND The required object information is not found.
109 @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration
110 Manager is less than the Object size for the
116 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
117 IN CONST ACPI_TABLE_GENERATOR
* CONST Generator
,
118 IN OUT EFI_ACPI_DESCRIPTION_HEADER
* CONST AcpiHeader
,
119 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO
* CONST AcpiTableInfo
,
120 IN CONST UINT32 Length
124 CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
* CfgMfrInfo
;
126 ASSERT (CfgMgrProtocol
!= NULL
);
127 ASSERT (Generator
!= NULL
);
128 ASSERT (AcpiHeader
!= NULL
);
129 ASSERT (Length
>= sizeof (EFI_ACPI_DESCRIPTION_HEADER
));
131 if ((CfgMgrProtocol
== NULL
) ||
132 (Generator
== NULL
) ||
133 (AcpiHeader
== NULL
) ||
134 (Length
< sizeof (EFI_ACPI_DESCRIPTION_HEADER
))
136 return EFI_INVALID_PARAMETER
;
139 Status
= GetCgfMgrInfo (CfgMgrProtocol
, &CfgMfrInfo
);
140 if (EFI_ERROR (Status
)) {
143 "ERROR: Failed to get Configuration Manager info. Status = %r\n",
150 AcpiHeader
->Signature
= Generator
->AcpiTableSignature
;
152 AcpiHeader
->Length
= Length
;
154 AcpiHeader
->Revision
= AcpiTableInfo
->AcpiTableRevision
;
156 AcpiHeader
->Checksum
= 0;
159 CopyMem (AcpiHeader
->OemId
, CfgMfrInfo
->OemId
, sizeof (AcpiHeader
->OemId
));
162 if (AcpiTableInfo
->OemTableId
!= 0) {
163 AcpiHeader
->OemTableId
= AcpiTableInfo
->OemTableId
;
165 AcpiHeader
->OemTableId
= SIGNATURE_32 (
166 CfgMfrInfo
->OemId
[0],
167 CfgMfrInfo
->OemId
[1],
168 CfgMfrInfo
->OemId
[2],
171 ((UINT64
)Generator
->AcpiTableSignature
<< 32);
174 // UINT32 OemRevision
175 if (AcpiTableInfo
->OemRevision
!= 0) {
176 AcpiHeader
->OemRevision
= AcpiTableInfo
->OemRevision
;
178 AcpiHeader
->OemRevision
= CfgMfrInfo
->Revision
;
182 AcpiHeader
->CreatorId
= Generator
->CreatorId
;
183 // UINT32 CreatorRevision
184 AcpiHeader
->CreatorRevision
= Generator
->CreatorRevision
;