4 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 #include <Library/AcpiLib.h>
9 #include <Library/DebugLib.h>
10 #include <Protocol/AcpiTable.h>
12 // Module specific include files.
13 #include <AcpiTableGenerator.h>
14 #include <ConfigurationManagerObject.h>
15 #include <ConfigurationManagerHelper.h>
16 #include <Library/TableHelperLib.h>
17 #include <Protocol/ConfigurationManagerProtocol.h>
19 /** Construct the ACPI table using the ACPI table data provided.
21 This function invokes the Configuration Manager protocol interface
22 to get the required hardware information for generating the ACPI
25 If this function allocates any resources then they must be freed
26 in the FreeXXXXTableResources function.
28 @param [in] This Pointer to the table generator.
29 @param [in] AcpiTableInfo Pointer to the ACPI Table Info.
30 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
32 @param [out] Table Pointer to the constructed ACPI Table.
34 @retval EFI_SUCCESS Table generated successfully.
35 @retval EFI_INVALID_PARAMETER A parameter is invalid.
41 IN CONST ACPI_TABLE_GENERATOR
* CONST This
,
42 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO
* CONST AcpiTableInfo
,
43 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
44 OUT EFI_ACPI_DESCRIPTION_HEADER
** CONST Table
47 ASSERT (This
!= NULL
);
48 ASSERT (AcpiTableInfo
!= NULL
);
49 ASSERT (CfgMgrProtocol
!= NULL
);
50 ASSERT (Table
!= NULL
);
51 ASSERT (AcpiTableInfo
->TableGeneratorId
== This
->GeneratorID
);
52 ASSERT (AcpiTableInfo
->AcpiTableData
!= NULL
);
54 if (AcpiTableInfo
->AcpiTableData
== NULL
) {
56 return EFI_INVALID_PARAMETER
;
59 *Table
= AcpiTableInfo
->AcpiTableData
;
64 /** This macro defines the Raw Generator revision.
66 #define RAW_GENERATOR_REVISION CREATE_REVISION (1, 0)
68 /** The interface for the Raw Table Generator.
72 ACPI_TABLE_GENERATOR RawGenerator
= {
74 CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdRaw
),
75 // Generator Description
76 L
"ACPI.STD.RAW.GENERATOR",
77 // ACPI Table Signature - Unused
79 // ACPI Table Revision - Unused
81 // Minimum ACPI Table Revision - Unused
84 TABLE_GENERATOR_CREATOR_ID_ARM
,
86 RAW_GENERATOR_REVISION
,
87 // Build Table function
89 // No additional resources are allocated by the generator.
90 // Hence the Free Resource function is not required.
92 // Extended build function not needed
94 // Extended build function not implemented by the generator.
95 // Hence extended free resource function is not required.
99 /** Register the Generator with the ACPI Table Factory.
101 @param [in] ImageHandle The handle to the image.
102 @param [in] SystemTable Pointer to the System Table.
104 @retval EFI_SUCCESS The Generator is registered.
105 @retval EFI_INVALID_PARAMETER A parameter is invalid.
106 @retval EFI_ALREADY_STARTED The Generator for the Table ID
107 is already registered.
111 AcpiRawLibConstructor (
112 IN CONST EFI_HANDLE ImageHandle
,
113 IN EFI_SYSTEM_TABLE
* CONST SystemTable
117 Status
= RegisterAcpiTableGenerator (&RawGenerator
);
118 DEBUG ((DEBUG_INFO
, "RAW: Register Generator. Status = %r\n", Status
));
119 ASSERT_EFI_ERROR (Status
);
123 /** Deregister the Generator from the ACPI Table Factory.
125 @param [in] ImageHandle The handle to the image.
126 @param [in] SystemTable Pointer to the System Table.
128 @retval EFI_SUCCESS The Generator is deregistered.
129 @retval EFI_INVALID_PARAMETER A parameter is invalid.
130 @retval EFI_NOT_FOUND The Generator is not registered.
134 AcpiRawLibDestructor (
135 IN CONST EFI_HANDLE ImageHandle
,
136 IN EFI_SYSTEM_TABLE
* CONST SystemTable
140 Status
= DeregisterAcpiTableGenerator (&RawGenerator
);
141 DEBUG ((DEBUG_INFO
, "RAW: Deregister Generator. Status = %r\n", Status
));
142 ASSERT_EFI_ERROR (Status
);