1 | /** @file
|
---|
2 | Wrapper function to support Redfish Platform Config protocol.
|
---|
3 |
|
---|
4 | (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
|
---|
5 | Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | **/
|
---|
10 |
|
---|
11 | #include "RedfishPlatformConfigInternal.h"
|
---|
12 |
|
---|
13 | REDFISH_PLATFORM_CONFIG_LIB_PRIVATE mRedfishPlatformConfigLibPrivate;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | Get Redfish value with the given Schema and Configure Language.
|
---|
17 |
|
---|
18 | @param[in] Schema The Redfish schema to query.
|
---|
19 | @param[in] Version The Redfish version to query.
|
---|
20 | @param[in] ConfigureLang The target value which match this configure Language.
|
---|
21 | @param[out] Value The returned value.
|
---|
22 |
|
---|
23 | @retval EFI_SUCCESS Value is returned successfully.
|
---|
24 | @retval EFI_NOT_READY Redfish Platform Config protocol is not ready.
|
---|
25 | @retval Others Some error happened.
|
---|
26 |
|
---|
27 | **/
|
---|
28 | EFI_STATUS
|
---|
29 | RedfishPlatformConfigGetValue (
|
---|
30 | IN CHAR8 *Schema,
|
---|
31 | IN CHAR8 *Version,
|
---|
32 | IN EFI_STRING ConfigureLang,
|
---|
33 | OUT EDKII_REDFISH_VALUE *Value
|
---|
34 | )
|
---|
35 | {
|
---|
36 | if (mRedfishPlatformConfigLibPrivate.Protocol == NULL) {
|
---|
37 | return EFI_NOT_READY;
|
---|
38 | }
|
---|
39 |
|
---|
40 | return mRedfishPlatformConfigLibPrivate.Protocol->GetValue (
|
---|
41 | mRedfishPlatformConfigLibPrivate.Protocol,
|
---|
42 | Schema,
|
---|
43 | Version,
|
---|
44 | ConfigureLang,
|
---|
45 | Value
|
---|
46 | );
|
---|
47 | }
|
---|
48 |
|
---|
49 | /**
|
---|
50 | Get Redfish attribute value with the given Schema and Configure Language.
|
---|
51 |
|
---|
52 | @param[in] Schema The Redfish schema to query.
|
---|
53 | @param[in] Version The Redfish version to query.
|
---|
54 | @param[in] ConfigureLang The target value which match this configure Language.
|
---|
55 | @param[out] AttributeValue The attribute value.
|
---|
56 |
|
---|
57 | @retval EFI_SUCCESS Value is returned successfully.
|
---|
58 | @retval Others Some error happened.
|
---|
59 |
|
---|
60 | **/
|
---|
61 | EFI_STATUS
|
---|
62 | RedfishPlatformConfigGetAttribute (
|
---|
63 | IN CHAR8 *Schema,
|
---|
64 | IN CHAR8 *Version,
|
---|
65 | IN EFI_STRING ConfigureLang,
|
---|
66 | OUT EDKII_REDFISH_ATTRIBUTE *AttributeValue
|
---|
67 | )
|
---|
68 | {
|
---|
69 | if (mRedfishPlatformConfigLibPrivate.Protocol == NULL) {
|
---|
70 | return EFI_NOT_READY;
|
---|
71 | }
|
---|
72 |
|
---|
73 | return mRedfishPlatformConfigLibPrivate.Protocol->GetAttribute (
|
---|
74 | mRedfishPlatformConfigLibPrivate.Protocol,
|
---|
75 | Schema,
|
---|
76 | Version,
|
---|
77 | ConfigureLang,
|
---|
78 | AttributeValue
|
---|
79 | );
|
---|
80 | }
|
---|
81 |
|
---|
82 | /**
|
---|
83 | Get Redfish default value with the given Schema and Configure Language.
|
---|
84 |
|
---|
85 | @param[in] Schema The Redfish schema to query.
|
---|
86 | @param[in] Version The Redfish version to query.
|
---|
87 | @param[in] ConfigureLang The target value which match this configure Language.
|
---|
88 | @param[in] DefaultClass The UEFI defined default class.
|
---|
89 | Please refer to UEFI spec. 33.2.5.8 "defaults" for details.
|
---|
90 | @param[out] Value The returned value.
|
---|
91 |
|
---|
92 | @retval EFI_SUCCESS Value is returned successfully.
|
---|
93 | @retval Others Some error happened.
|
---|
94 |
|
---|
95 | **/
|
---|
96 | EFI_STATUS
|
---|
97 | RedfishPlatformConfigGetDefaultValue (
|
---|
98 | IN CHAR8 *Schema,
|
---|
99 | IN CHAR8 *Version,
|
---|
100 | IN EFI_STRING ConfigureLang,
|
---|
101 | IN UINT16 DefaultClass,
|
---|
102 | OUT EDKII_REDFISH_VALUE *Value
|
---|
103 | )
|
---|
104 | {
|
---|
105 | if (mRedfishPlatformConfigLibPrivate.Protocol == NULL) {
|
---|
106 | return EFI_NOT_READY;
|
---|
107 | }
|
---|
108 |
|
---|
109 | return mRedfishPlatformConfigLibPrivate.Protocol->GetDefaultValue (
|
---|
110 | mRedfishPlatformConfigLibPrivate.Protocol,
|
---|
111 | Schema,
|
---|
112 | Version,
|
---|
113 | ConfigureLang,
|
---|
114 | DefaultClass,
|
---|
115 | Value
|
---|
116 | );
|
---|
117 | }
|
---|
118 |
|
---|
119 | /**
|
---|
120 | Set Redfish value with the given Schema and Configure Language.
|
---|
121 |
|
---|
122 | @param[in] Schema The Redfish schema to query.
|
---|
123 | @param[in] Version The Redfish version to query.
|
---|
124 | @param[in] ConfigureLang The target value which match this configure Language.
|
---|
125 | @param[in] Value The value to set.
|
---|
126 |
|
---|
127 | @retval EFI_SUCCESS Value is returned successfully.
|
---|
128 | @retval EFI_NOT_READY Redfish Platform Config protocol is not ready.
|
---|
129 | @retval Others Some error happened.
|
---|
130 |
|
---|
131 | **/
|
---|
132 | EFI_STATUS
|
---|
133 | RedfishPlatformConfigSetValue (
|
---|
134 | IN CHAR8 *Schema,
|
---|
135 | IN CHAR8 *Version,
|
---|
136 | IN EFI_STRING ConfigureLang,
|
---|
137 | IN EDKII_REDFISH_VALUE Value
|
---|
138 | )
|
---|
139 | {
|
---|
140 | if (mRedfishPlatformConfigLibPrivate.Protocol == NULL) {
|
---|
141 | return EFI_NOT_READY;
|
---|
142 | }
|
---|
143 |
|
---|
144 | return mRedfishPlatformConfigLibPrivate.Protocol->SetValue (
|
---|
145 | mRedfishPlatformConfigLibPrivate.Protocol,
|
---|
146 | Schema,
|
---|
147 | Version,
|
---|
148 | ConfigureLang,
|
---|
149 | Value
|
---|
150 | );
|
---|
151 | }
|
---|
152 |
|
---|
153 | /**
|
---|
154 | Get the list of Configure Language from platform configuration by the given Schema and Pattern.
|
---|
155 |
|
---|
156 | @param[in] Schema The Redfish schema to query.
|
---|
157 | @param[in] Version The Redfish version to query.
|
---|
158 | @param[in] Pattern The target Configure Language pattern.
|
---|
159 | @param[out] ConfigureLangList The list of Configure Language.
|
---|
160 | @param[out] Count The number of Configure Language in ConfigureLangList.
|
---|
161 |
|
---|
162 | @retval EFI_SUCCESS ConfigureLangList is returned successfully.
|
---|
163 | @retval EFI_NOT_READY Redfish Platform Config protocol is not ready.
|
---|
164 | @retval Others Some error happened.
|
---|
165 |
|
---|
166 | **/
|
---|
167 | EFI_STATUS
|
---|
168 | RedfishPlatformConfigGetConfigureLang (
|
---|
169 | IN CHAR8 *Schema,
|
---|
170 | IN CHAR8 *Version,
|
---|
171 | IN EFI_STRING Pattern,
|
---|
172 | OUT EFI_STRING **ConfigureLangList,
|
---|
173 | OUT UINTN *Count
|
---|
174 | )
|
---|
175 | {
|
---|
176 | if (mRedfishPlatformConfigLibPrivate.Protocol == NULL) {
|
---|
177 | return EFI_NOT_READY;
|
---|
178 | }
|
---|
179 |
|
---|
180 | return mRedfishPlatformConfigLibPrivate.Protocol->GetConfigureLang (
|
---|
181 | mRedfishPlatformConfigLibPrivate.Protocol,
|
---|
182 | Schema,
|
---|
183 | Version,
|
---|
184 | Pattern,
|
---|
185 | ConfigureLangList,
|
---|
186 | Count
|
---|
187 | );
|
---|
188 | }
|
---|
189 |
|
---|
190 | /**
|
---|
191 | Get the list of supported Redfish schema from platform configuration.
|
---|
192 |
|
---|
193 | @param[out] SupportedSchema The supported schema list which is separated by ';'.
|
---|
194 | For example: "x-UEFI-redfish-Memory.v1_7_1;x-UEFI-redfish-Boot.v1_0_1"
|
---|
195 | The SupportedSchema is allocated by the callee. It's caller's
|
---|
196 | responsibility to free this buffer using FreePool().
|
---|
197 |
|
---|
198 | @retval EFI_SUCCESS Schema is returned successfully.
|
---|
199 | @retval EFI_NOT_READY Redfish Platform Config protocol is not ready.
|
---|
200 | @retval Others Some error happened.
|
---|
201 |
|
---|
202 | **/
|
---|
203 | EFI_STATUS
|
---|
204 | EFIAPI
|
---|
205 | RedfishPlatformConfigGetSupportedSchema (
|
---|
206 | OUT CHAR8 **SupportedSchema
|
---|
207 | )
|
---|
208 | {
|
---|
209 | if (mRedfishPlatformConfigLibPrivate.Protocol == NULL) {
|
---|
210 | return EFI_NOT_READY;
|
---|
211 | }
|
---|
212 |
|
---|
213 | return mRedfishPlatformConfigLibPrivate.Protocol->GetSupportedSchema (
|
---|
214 | mRedfishPlatformConfigLibPrivate.Protocol,
|
---|
215 | SupportedSchema
|
---|
216 | );
|
---|
217 | }
|
---|
218 |
|
---|
219 | /**
|
---|
220 | This is a EFI_REDFISH_PLATFORM_CONFIG_PROTOCOL notification event handler.
|
---|
221 |
|
---|
222 | Install HII package notification.
|
---|
223 |
|
---|
224 | @param[in] Event Event whose notification function is being invoked.
|
---|
225 | @param[in] Context Pointer to the notification function's context.
|
---|
226 |
|
---|
227 | **/
|
---|
228 | VOID
|
---|
229 | EFIAPI
|
---|
230 | RedfishPlatformConfigProtocolInstalled (
|
---|
231 | IN EFI_EVENT Event,
|
---|
232 | IN VOID *Context
|
---|
233 | )
|
---|
234 | {
|
---|
235 | EFI_STATUS Status;
|
---|
236 |
|
---|
237 | //
|
---|
238 | // Locate EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL.
|
---|
239 | //
|
---|
240 | Status = gBS->LocateProtocol (
|
---|
241 | &gEdkIIRedfishPlatformConfigProtocolGuid,
|
---|
242 | NULL,
|
---|
243 | (VOID **)&mRedfishPlatformConfigLibPrivate.Protocol
|
---|
244 | );
|
---|
245 | if (EFI_ERROR (Status)) {
|
---|
246 | DEBUG ((DEBUG_ERROR, "%a: locate EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL failure: %r\n", __func__, Status));
|
---|
247 | return;
|
---|
248 | }
|
---|
249 |
|
---|
250 | gBS->CloseEvent (Event);
|
---|
251 | mRedfishPlatformConfigLibPrivate.ProtocolEvent = NULL;
|
---|
252 | }
|
---|
253 |
|
---|
254 | /**
|
---|
255 |
|
---|
256 | Create protocol listener and wait for Redfish Platform Config protocol.
|
---|
257 |
|
---|
258 | @param ImageHandle The image handle.
|
---|
259 | @param SystemTable The system table.
|
---|
260 |
|
---|
261 | @retval EFI_SUCCESS Protocol listener is registered successfully.
|
---|
262 |
|
---|
263 | **/
|
---|
264 | EFI_STATUS
|
---|
265 | EFIAPI
|
---|
266 | RedfishPlatformConfigLibConstructor (
|
---|
267 | IN EFI_HANDLE ImageHandle,
|
---|
268 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
269 | )
|
---|
270 | {
|
---|
271 | ZeroMem (&mRedfishPlatformConfigLibPrivate, sizeof (REDFISH_PLATFORM_CONFIG_LIB_PRIVATE));
|
---|
272 | mRedfishPlatformConfigLibPrivate.ProtocolEvent = EfiCreateProtocolNotifyEvent (
|
---|
273 | &gEdkIIRedfishPlatformConfigProtocolGuid,
|
---|
274 | TPL_CALLBACK,
|
---|
275 | RedfishPlatformConfigProtocolInstalled,
|
---|
276 | NULL,
|
---|
277 | &mRedfishPlatformConfigLibPrivate.Registration
|
---|
278 | );
|
---|
279 | if (mRedfishPlatformConfigLibPrivate.ProtocolEvent == NULL) {
|
---|
280 | DEBUG ((DEBUG_ERROR, "%a: failed to create protocol notify event\n", __func__));
|
---|
281 | }
|
---|
282 |
|
---|
283 | return EFI_SUCCESS;
|
---|
284 | }
|
---|
285 |
|
---|
286 | /**
|
---|
287 | Unloads the application and its installed protocol.
|
---|
288 |
|
---|
289 | @param ImageHandle Handle that identifies the image to be unloaded.
|
---|
290 | @param SystemTable The system table.
|
---|
291 |
|
---|
292 | @retval EFI_SUCCESS The image has been unloaded.
|
---|
293 |
|
---|
294 | **/
|
---|
295 | EFI_STATUS
|
---|
296 | EFIAPI
|
---|
297 | RedfishPlatformConfigLibDestructor (
|
---|
298 | IN EFI_HANDLE ImageHandle,
|
---|
299 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
300 | )
|
---|
301 | {
|
---|
302 | if (mRedfishPlatformConfigLibPrivate.ProtocolEvent != NULL) {
|
---|
303 | gBS->CloseEvent (mRedfishPlatformConfigLibPrivate.ProtocolEvent);
|
---|
304 | mRedfishPlatformConfigLibPrivate.ProtocolEvent = NULL;
|
---|
305 | }
|
---|
306 |
|
---|
307 | mRedfishPlatformConfigLibPrivate.Protocol = NULL;
|
---|
308 |
|
---|
309 | return EFI_SUCCESS;
|
---|
310 | }
|
---|