3 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 - Cm or CM - Configuration Manager
16 - Std or STD - Standard
19 #ifndef DEVICETREE_TABLE_GENERATOR_H_
20 #define DEVICETREE_TABLE_GENERATOR_H_
22 #include <TableGenerator.h>
26 /** The DT_TABLE_GENERATOR_ID type describes Device Tree table generator ID.
28 typedef TABLE_GENERATOR_ID DT_TABLE_GENERATOR_ID
;
30 /** The ESTD_DT_TABLE_ID enum describes the DT table IDs reserved for
31 the standard generators.
33 typedef enum StdDtTableId
{
34 EStdDtTableIdReserved
= 0x0000, ///< Reserved.
35 EStdDtTableIdRaw
, ///< RAW Generator.
39 /** This macro checks if the Table Generator ID is for an DT Table Generator.
41 @param [in] TableGeneratorId The table generator ID.
43 @return TRUE if the table generator ID is for an DT Table
46 #define IS_GENERATOR_TYPE_DT(TableGeneratorId) \
47 (GET_TABLE_TYPE(TableGeneratorId) == ETableGeneratorTypeDt)
49 /** This macro checks if the Table Generator ID is for a standard DT
52 @param [in] TableGeneratorId The table generator ID.
54 @return TRUE if the table generator ID is for a standard DT
57 #define IS_VALID_STD_DT_GENERATOR_ID(TableGeneratorId) \
59 IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) && \
60 IS_GENERATOR_TYPE_DT(TableGeneratorId) && \
61 ((GET_TABLE_ID(GeneratorId) >= EStdDtTableIdRaw) && \
62 (GET_TABLE_ID(GeneratorId) < EStdDtTableIdMax)) \
65 /** This macro creates a standard DT Table Generator ID.
67 @param [in] TableId The table generator ID.
69 @return a standard DT table generator ID.
71 #define CREATE_STD_DT_TABLE_GEN_ID(TableId) \
72 CREATE_TABLE_GEN_ID ( \
73 ETableGeneratorTypeDt, \
74 ETableGeneratorNameSpaceStd, \
78 /** Forward declarations.
80 typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL
;
81 typedef struct CmAStdObjDtTableInfo CM_STD_OBJ_DT_TABLE_INFO
;
82 typedef struct DtTableGenerator DT_TABLE_GENERATOR
;
84 /** This function pointer describes the interface to DT table build
85 functions provided by the DT table generator and called by the
86 Table Manager to build an DT table.
88 @param [in] Generator Pointer to the DT table generator.
89 @param [in] DtTableInfo Pointer to the DT table information.
90 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
92 @param [out] Table Pointer to the generated DT table.
94 @return EFI_SUCCESS If the table is generated successfully or other
95 failure codes as returned by the generator.
97 typedef EFI_STATUS (*DT_TABLE_GENERATOR_BUILD_TABLE
) (
98 IN CONST DT_TABLE_GENERATOR
* Generator
,
99 IN CONST CM_STD_OBJ_DT_TABLE_INFO
* CONST DtTableInfo
,
100 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
104 /** This function pointer describes the interface to used by the
105 Table Manager to give the generator an opportunity to free
106 any resources allocated for building the DT table.
108 @param [in] Generator Pointer to the DT table generator.
109 @param [in] DtTableInfo Pointer to the DT table information.
110 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
112 @param [in] Table Pointer to the generated DT table.
114 @return EFI_SUCCESS If freed successfully or other failure codes
115 as returned by the generator.
117 typedef EFI_STATUS (*DT_TABLE_GENERATOR_FREE_TABLE
) (
118 IN CONST DT_TABLE_GENERATOR
* Generator
,
119 IN CONST CM_STD_OBJ_DT_TABLE_INFO
* CONST DtTableInfo
,
120 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
124 /** The DT_TABLE_GENERATOR structure provides an interface that the
125 Table Manager can use to invoke the functions to build DT tables.
127 typedef struct DtTableGenerator
{
128 /// The DT table generator ID.
129 DT_TABLE_GENERATOR_ID GeneratorID
;
131 /// String describing the DT table generator.
132 CONST CHAR16
* Description
;
134 /// DT table build function pointer.
135 DT_TABLE_GENERATOR_BUILD_TABLE BuildDtTable
;
137 /// The function to free any resources allocated for building the DT table.
138 DT_TABLE_GENERATOR_FREE_TABLE FreeTableResources
;
139 } DT_TABLE_GENERATOR
;
141 /** Register DT table factory generator.
143 The DT table factory maintains a list of the Standard and OEM DT
146 @param [in] Generator Pointer to the DT table generator.
148 @retval EFI_SUCCESS The Generator was registered
150 @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
151 the Generator pointer is NULL.
152 @retval EFI_ALREADY_STARTED The Generator for the Table ID is
157 RegisterDtTableGenerator (
158 IN CONST DT_TABLE_GENERATOR
* CONST Generator
161 /** Deregister DT generator.
163 This function is called by the DT table generator to deregister itself
164 from the DT table factory.
166 @param [in] Generator Pointer to the DT table generator.
168 @retval EFI_SUCCESS Success.
169 @retval EFI_INVALID_PARAMETER The generator is invalid.
170 @retval EFI_NOT_FOUND The requested generator is not found
171 in the list of registered generators.
175 DeregisterDtTableGenerator (
176 IN CONST DT_TABLE_GENERATOR
* CONST Generator
181 #endif // DEVICETREE_TABLE_GENERATOR_H_