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