VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.c

Last change on this file was 105670, checked in by vboxsync, 8 months ago

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • Property svn:eol-style set to native
File size: 11.1 KB
Line 
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
13REDFISH_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**/
28EFI_STATUS
29RedfishPlatformConfigGetValue (
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**/
61EFI_STATUS
62RedfishPlatformConfigGetAttribute (
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**/
96EFI_STATUS
97RedfishPlatformConfigGetDefaultValue (
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**/
132EFI_STATUS
133RedfishPlatformConfigSetValue (
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**/
167EFI_STATUS
168RedfishPlatformConfigGetConfigureLang (
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**/
203EFI_STATUS
204EFIAPI
205RedfishPlatformConfigGetSupportedSchema (
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**/
228VOID
229EFIAPI
230RedfishPlatformConfigProtocolInstalled (
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**/
264EFI_STATUS
265EFIAPI
266RedfishPlatformConfigLibConstructor (
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**/
295EFI_STATUS
296EFIAPI
297RedfishPlatformConfigLibDestructor (
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}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette