3 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - Cm or CM - Configuration Manager
10 - Std or STD - Standard
13 #ifndef DEVICETREE_TABLE_GENERATOR_H_
14 #define DEVICETREE_TABLE_GENERATOR_H_
16 #include <TableGenerator.h>
20 /** The DT_TABLE_GENERATOR_ID type describes Device Tree table generator ID.
22 typedef TABLE_GENERATOR_ID DT_TABLE_GENERATOR_ID
;
24 /** The ESTD_DT_TABLE_ID enum describes the DT table IDs reserved for
25 the standard generators.
27 typedef enum StdDtTableId
{
28 EStdDtTableIdReserved
= 0x0000, ///< Reserved.
29 EStdDtTableIdRaw
, ///< RAW Generator.
33 /** This macro checks if the Table Generator ID is for an DT Table Generator.
35 @param [in] TableGeneratorId The table generator ID.
37 @return TRUE if the table generator ID is for an DT Table
40 #define IS_GENERATOR_TYPE_DT(TableGeneratorId) \
41 (GET_TABLE_TYPE(TableGeneratorId) == ETableGeneratorTypeDt)
43 /** This macro checks if the Table Generator ID is for a standard DT
46 @param [in] TableGeneratorId The table generator ID.
48 @return TRUE if the table generator ID is for a standard DT
51 #define IS_VALID_STD_DT_GENERATOR_ID(TableGeneratorId) \
53 IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) && \
54 IS_GENERATOR_TYPE_DT(TableGeneratorId) && \
55 ((GET_TABLE_ID(GeneratorId) >= EStdDtTableIdRaw) && \
56 (GET_TABLE_ID(GeneratorId) < EStdDtTableIdMax)) \
59 /** This macro creates a standard DT Table Generator ID.
61 @param [in] TableId The table generator ID.
63 @return a standard DT table generator ID.
65 #define CREATE_STD_DT_TABLE_GEN_ID(TableId) \
66 CREATE_TABLE_GEN_ID ( \
67 ETableGeneratorTypeDt, \
68 ETableGeneratorNameSpaceStd, \
72 /** Forward declarations.
74 typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PROTOCOL
;
75 typedef struct CmAStdObjDtTableInfo CM_STD_OBJ_DT_TABLE_INFO
;
76 typedef struct DtTableGenerator DT_TABLE_GENERATOR
;
78 /** This function pointer describes the interface to DT table build
79 functions provided by the DT table generator and called by the
80 Table Manager to build an DT table.
82 @param [in] Generator Pointer to the DT table generator.
83 @param [in] DtTableInfo Pointer to the DT table information.
84 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
86 @param [out] Table Pointer to the generated DT table.
88 @return EFI_SUCCESS If the table is generated successfully or other
89 failure codes as returned by the generator.
91 typedef EFI_STATUS (*DT_TABLE_GENERATOR_BUILD_TABLE
) (
92 IN CONST DT_TABLE_GENERATOR
* Generator
,
93 IN CONST CM_STD_OBJ_DT_TABLE_INFO
* CONST DtTableInfo
,
94 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
98 /** This function pointer describes the interface to used by the
99 Table Manager to give the generator an opportunity to free
100 any resources allocated for building the DT table.
102 @param [in] Generator Pointer to the DT table generator.
103 @param [in] DtTableInfo Pointer to the DT table information.
104 @param [in] CfgMgrProtocol Pointer to the Configuration Manager
106 @param [in] Table Pointer to the generated DT table.
108 @return EFI_SUCCESS If freed successfully or other failure codes
109 as returned by the generator.
111 typedef EFI_STATUS (*DT_TABLE_GENERATOR_FREE_TABLE
) (
112 IN CONST DT_TABLE_GENERATOR
* Generator
,
113 IN CONST CM_STD_OBJ_DT_TABLE_INFO
* CONST DtTableInfo
,
114 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL
* CONST CfgMgrProtocol
,
118 /** The DT_TABLE_GENERATOR structure provides an interface that the
119 Table Manager can use to invoke the functions to build DT tables.
121 typedef struct DtTableGenerator
{
122 /// The DT table generator ID.
123 DT_TABLE_GENERATOR_ID GeneratorID
;
125 /// String describing the DT table generator.
126 CONST CHAR16
* Description
;
128 /// DT table build function pointer.
129 DT_TABLE_GENERATOR_BUILD_TABLE BuildDtTable
;
131 /// The function to free any resources allocated for building the DT table.
132 DT_TABLE_GENERATOR_FREE_TABLE FreeTableResources
;
133 } DT_TABLE_GENERATOR
;
135 /** Register DT table factory generator.
137 The DT table factory maintains a list of the Standard and OEM DT
140 @param [in] Generator Pointer to the DT table generator.
142 @retval EFI_SUCCESS The Generator was registered
144 @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
145 the Generator pointer is NULL.
146 @retval EFI_ALREADY_STARTED The Generator for the Table ID is
151 RegisterDtTableGenerator (
152 IN CONST DT_TABLE_GENERATOR
* CONST Generator
155 /** Deregister DT generator.
157 This function is called by the DT table generator to deregister itself
158 from the DT table factory.
160 @param [in] Generator Pointer to the DT table generator.
162 @retval EFI_SUCCESS Success.
163 @retval EFI_INVALID_PARAMETER The generator is invalid.
164 @retval EFI_NOT_FOUND The requested generator is not found
165 in the list of registered generators.
169 DeregisterDtTableGenerator (
170 IN CONST DT_TABLE_GENERATOR
* CONST Generator
175 #endif // DEVICETREE_TABLE_GENERATOR_H_