]> git.proxmox.com Git - mirror_edk2.git/blob - DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
ae3d3eca1d2f64cfc101fdd0b18da5019bdfe32e
[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 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
9
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.
12 **/
13
14 #include <Library/AcpiLib.h>
15 #include <Library/DebugLib.h>
16 #include <Protocol/AcpiTable.h>
17
18 // Module specific include files.
19 #include <AcpiTableGenerator.h>
20 #include <ConfigurationManagerObject.h>
21 #include <ConfigurationManagerHelper.h>
22 #include <Library/TableHelperLib.h>
23 #include <Protocol/ConfigurationManagerProtocol.h>
24
25 /** Construct the ACPI table using the ACPI table data provided.
26
27 This function invokes the Configuration Manager protocol interface
28 to get the required hardware information for generating the ACPI
29 table.
30
31 If this function allocates any resources then they must be freed
32 in the FreeXXXXTableResources function.
33
34 @param [in] This Pointer to the table generator.
35 @param [in] AcpiTableInfo Pointer to the ACPI Table Info.
36 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
37 Protocol Interface.
38 @param [out] Table Pointer to the constructed ACPI Table.
39
40 @retval EFI_SUCCESS Table generated successfully.
41 @retval EFI_INVALID_PARAMETER A parameter is invalid.
42 **/
43 STATIC
44 EFI_STATUS
45 EFIAPI
46 BuildRawTable (
47 IN CONST ACPI_TABLE_GENERATOR * CONST This,
48 IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,
49 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
50 OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table
51 )
52 {
53 ASSERT (This != NULL);
54 ASSERT (AcpiTableInfo != NULL);
55 ASSERT (CfgMgrProtocol != NULL);
56 ASSERT (Table != NULL);
57 ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
58 ASSERT (AcpiTableInfo->AcpiTableData != NULL);
59
60 if (AcpiTableInfo->AcpiTableData == NULL) {
61 *Table = NULL;
62 return EFI_INVALID_PARAMETER;
63 }
64
65 *Table = AcpiTableInfo->AcpiTableData;
66
67 return EFI_SUCCESS;
68 }
69
70 /** This macro defines the Raw Generator revision.
71 */
72 #define RAW_GENERATOR_REVISION CREATE_REVISION (1, 0)
73
74 /** The interface for the Raw Table Generator.
75 */
76 STATIC
77 CONST
78 ACPI_TABLE_GENERATOR RawGenerator = {
79 // Generator ID
80 CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdRaw),
81 // Generator Description
82 L"ACPI.STD.RAW.GENERATOR",
83 // ACPI Table Signature - Unused
84 0,
85 // ACPI Table Revision - Unused
86 0,
87 // Minimum ACPI Table Revision - Unused
88 0,
89 // Creator ID
90 TABLE_GENERATOR_CREATOR_ID_ARM,
91 // Creator Revision
92 RAW_GENERATOR_REVISION,
93 // Build Table function
94 BuildRawTable,
95 // No additional resources are allocated by the generator.
96 // Hence the Free Resource function is not required.
97 NULL,
98 // Extended build function not needed
99 NULL,
100 // Extended build function not implemented by the generator.
101 // Hence extended free resource function is not required.
102 NULL
103 };
104
105 /** Register the Generator with the ACPI Table Factory.
106
107 @param [in] ImageHandle The handle to the image.
108 @param [in] SystemTable Pointer to the System Table.
109
110 @retval EFI_SUCCESS The Generator is registered.
111 @retval EFI_INVALID_PARAMETER A parameter is invalid.
112 @retval EFI_ALREADY_STARTED The Generator for the Table ID
113 is already registered.
114 **/
115 EFI_STATUS
116 EFIAPI
117 AcpiRawLibConstructor (
118 IN CONST EFI_HANDLE ImageHandle,
119 IN EFI_SYSTEM_TABLE * CONST SystemTable
120 )
121 {
122 EFI_STATUS Status;
123 Status = RegisterAcpiTableGenerator (&RawGenerator);
124 DEBUG ((DEBUG_INFO, "RAW: Register Generator. Status = %r\n", Status));
125 ASSERT_EFI_ERROR (Status);
126 return Status;
127 }
128
129 /** Deregister the Generator from the ACPI Table Factory.
130
131 @param [in] ImageHandle The handle to the image.
132 @param [in] SystemTable Pointer to the System Table.
133
134 @retval EFI_SUCCESS The Generator is deregistered.
135 @retval EFI_INVALID_PARAMETER A parameter is invalid.
136 @retval EFI_NOT_FOUND The Generator is not registered.
137 **/
138 EFI_STATUS
139 EFIAPI
140 AcpiRawLibDestructor (
141 IN CONST EFI_HANDLE ImageHandle,
142 IN EFI_SYSTEM_TABLE * CONST SystemTable
143 )
144 {
145 EFI_STATUS Status;
146 Status = DeregisterAcpiTableGenerator (&RawGenerator);
147 DEBUG ((DEBUG_INFO, "RAW: Deregister Generator. Status = %r\n", Status));
148 ASSERT_EFI_ERROR (Status);
149 return Status;
150 }