]> git.proxmox.com Git - mirror_edk2.git/blob - DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
544ea06f0bcb3442b78cf6409846f70ae5360664
[mirror_edk2.git] / DynamicTablesPkg / Library / Acpi / Arm / AcpiRawLibArm / RawGenerator.c
1 /** @file
2 MCFG Table Generator
3
4 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6 **/
7
8 #include <Library/AcpiLib.h>
9 #include <Library/DebugLib.h>
10 #include <Protocol/AcpiTable.h>
11
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>
18
19 /** Construct the ACPI table using the ACPI table data provided.
20
21 This function invokes the Configuration Manager protocol interface
22 to get the required hardware information for generating the ACPI
23 table.
24
25 If this function allocates any resources then they must be freed
26 in the FreeXXXXTableResources function.
27
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
31 Protocol Interface.
32 @param [out] Table Pointer to the constructed ACPI Table.
33
34 @retval EFI_SUCCESS Table generated successfully.
35 @retval EFI_INVALID_PARAMETER A parameter is invalid.
36 **/
37 STATIC
38 EFI_STATUS
39 EFIAPI
40 BuildRawTable (
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
45 )
46 {
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);
53
54 if (AcpiTableInfo->AcpiTableData == NULL) {
55 *Table = NULL;
56 return EFI_INVALID_PARAMETER;
57 }
58
59 *Table = AcpiTableInfo->AcpiTableData;
60
61 return EFI_SUCCESS;
62 }
63
64 /** This macro defines the Raw Generator revision.
65 */
66 #define RAW_GENERATOR_REVISION CREATE_REVISION (1, 0)
67
68 /** The interface for the Raw Table Generator.
69 */
70 STATIC
71 CONST
72 ACPI_TABLE_GENERATOR RawGenerator = {
73 // Generator ID
74 CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdRaw),
75 // Generator Description
76 L"ACPI.STD.RAW.GENERATOR",
77 // ACPI Table Signature - Unused
78 0,
79 // ACPI Table Revision - Unused
80 0,
81 // Minimum ACPI Table Revision - Unused
82 0,
83 // Creator ID
84 TABLE_GENERATOR_CREATOR_ID_ARM,
85 // Creator Revision
86 RAW_GENERATOR_REVISION,
87 // Build Table function
88 BuildRawTable,
89 // No additional resources are allocated by the generator.
90 // Hence the Free Resource function is not required.
91 NULL,
92 // Extended build function not needed
93 NULL,
94 // Extended build function not implemented by the generator.
95 // Hence extended free resource function is not required.
96 NULL
97 };
98
99 /** Register the Generator with the ACPI Table Factory.
100
101 @param [in] ImageHandle The handle to the image.
102 @param [in] SystemTable Pointer to the System Table.
103
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.
108 **/
109 EFI_STATUS
110 EFIAPI
111 AcpiRawLibConstructor (
112 IN CONST EFI_HANDLE ImageHandle,
113 IN EFI_SYSTEM_TABLE * CONST SystemTable
114 )
115 {
116 EFI_STATUS Status;
117 Status = RegisterAcpiTableGenerator (&RawGenerator);
118 DEBUG ((DEBUG_INFO, "RAW: Register Generator. Status = %r\n", Status));
119 ASSERT_EFI_ERROR (Status);
120 return Status;
121 }
122
123 /** Deregister the Generator from the ACPI Table Factory.
124
125 @param [in] ImageHandle The handle to the image.
126 @param [in] SystemTable Pointer to the System Table.
127
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.
131 **/
132 EFI_STATUS
133 EFIAPI
134 AcpiRawLibDestructor (
135 IN CONST EFI_HANDLE ImageHandle,
136 IN EFI_SYSTEM_TABLE * CONST SystemTable
137 )
138 {
139 EFI_STATUS Status;
140 Status = DeregisterAcpiTableGenerator (&RawGenerator);
141 DEBUG ((DEBUG_INFO, "RAW: Deregister Generator. Status = %r\n", Status));
142 ASSERT_EFI_ERROR (Status);
143 return Status;
144 }