TianoCore EDK2 master
Loading...
Searching...
No Matches
ConfigurationManagerHelper.h
Go to the documentation of this file.
1
12#ifndef CONFIGURATION_MANAGER_HELPER_H_
13#define CONFIGURATION_MANAGER_HELPER_H_
14
50#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type) \
51STATIC \
52EFI_STATUS \
53EFIAPI \
54Get##CmObjectId ( \
55 IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, \
56 IN CONST CM_OBJECT_TOKEN Token OPTIONAL, \
57 OUT Type ** List, \
58 OUT UINT32 * CONST Count OPTIONAL \
59 ) \
60{ \
61 EFI_STATUS Status; \
62 CM_OBJ_DESCRIPTOR CmObjectDesc; \
63 UINT32 ObjCount = 0; \
64 if (List == NULL) { \
65 Status = EFI_INVALID_PARAMETER; \
66 DEBUG (( \
67 DEBUG_ERROR, \
68 "ERROR: Get" #CmObjectId ": Invalid out parameter for" \
69 " object list. Status = %r\n", \
70 Status \
71 )); \
72 goto error_handler; \
73 } \
74 Status = CfgMgrProtocol->GetObject ( \
75 CfgMgrProtocol, \
76 CREATE_CM_OBJECT_ID ( \
77 CmObjectNameSpace, \
78 CmObjectId \
79 ), \
80 Token, \
81 &CmObjectDesc \
82 ); \
83 if (EFI_ERROR (Status)) { \
84 DEBUG (( \
85 DEBUG_INFO, \
86 "INFO: Get" #CmObjectId ": Platform does not implement " \
87 #CmObjectId ". Status = %r\n", \
88 Status \
89 )); \
90 *List = NULL; \
91 goto error_handler; \
92 } \
93 if (CmObjectDesc.ObjectId != \
94 CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId)) { \
95 DEBUG (( \
96 DEBUG_ERROR, \
97 "ERROR: Get" #CmObjectId ": " #CmObjectId \
98 ": Invalid ObjectId = 0x%x\n, expected Id = 0x%x\n", \
99 CmObjectDesc.ObjectId, \
100 CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId) \
101 )); \
102 ASSERT (FALSE); \
103 Status = EFI_INVALID_PARAMETER; \
104 goto error_handler; \
105 } \
106 if (CmObjectDesc.Size < (sizeof (Type) * CmObjectDesc.Count)) { \
107 DEBUG (( \
108 DEBUG_ERROR, \
109 "ERROR: Get" #CmObjectId ": " #CmObjectId \
110 ": Buffer too small, size = 0x%x\n", \
111 CmObjectDesc.Size \
112 )); \
113 ASSERT (FALSE); \
114 Status = EFI_BAD_BUFFER_SIZE; \
115 goto error_handler; \
116 } \
117 ObjCount = CmObjectDesc.Count; \
118 *List = (Type*)CmObjectDesc.Data; \
119error_handler: \
120 if (Count != NULL) { \
121 *Count = ObjCount; \
122 } \
123 return Status; \
124}
125
126#endif // CONFIGURATION_MANAGER_HELPER_H_