Changeset 105670 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg
- Timestamp:
- Aug 14, 2024 1:16:30 PM (6 months ago)
- svn:sync-xref-src-repo-rev:
- 164367
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 18 added
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-159268 /vendor/edk2/current 103735-103757,103769-103776,129194-164365
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Include/Library/JsonLib.h
r101291 r105670 655 655 IN CONST CHAR8 *Key, 656 656 IN EDKII_JSON_VALUE Json 657 ); 658 659 /** 660 The function is used to delete a JSON key from the given JSON bject, 661 662 @param[in] JsonObj The provided JSON object. 663 @param[in] Key The key of the JSON value to be deleted. 664 665 @retval EFI_ABORTED Some error occur and operation aborted. 666 @retval EFI_SUCCESS The JSON value has been deleted from this JSON object. 667 668 **/ 669 EFI_STATUS 670 EFIAPI 671 JsonObjectDelete ( 672 IN EDKII_JSON_OBJECT JsonObj, 673 IN CONST CHAR8 *Key 657 674 ); 658 675 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Include/Library/RedfishCrtLib.h
r99404 r105670 70 70 // Basic types mapping 71 71 // 72 typedef UINTN size_t; 73 typedef INTN ssize_t; 74 typedef INT32 time_t; 75 typedef UINT8 __uint8_t; 76 typedef UINT8 sa_family_t; 77 typedef UINT32 uid_t; 78 typedef UINT32 gid_t; 79 typedef INT32 int32_t; 80 typedef UINT32 uint32_t; 81 typedef UINT16 uint16_t; 82 typedef UINT8 uint8_t; 83 typedef enum { 84 false, true 85 } bool; 72 typedef UINTN size_t; 73 typedef INTN ssize_t; 74 typedef INT32 time_t; 75 typedef INT32 int32_t; 76 typedef UINT32 uint32_t; 77 typedef UINT16 uint16_t; 78 typedef UINT8 uint8_t; 79 typedef BOOLEAN bool; 80 81 #define true (1 == 1) 82 #define false (1 == 0) 86 83 87 84 // … … 173 170 ); 174 171 175 void * 176 memset ( 177 void *, 178 int, 172 int 173 isdigit ( 174 int 175 ); 176 177 int 178 isspace ( 179 int 180 ); 181 182 int 183 tolower ( 184 int 185 ); 186 187 int 188 isupper ( 189 int 190 ); 191 192 int 193 isxdigit ( 194 int 195 ); 196 197 int 198 isalnum ( 199 int 200 ); 201 202 int 203 strncmp ( 204 const char *, 205 const char *, 179 206 size_t 180 207 ); 181 208 182 209 int 183 memcmp (184 const void *,185 const void *,186 size_t187 );188 189 int190 isdigit (191 int192 );193 194 int195 isspace (196 int197 );198 199 int200 tolower (201 int202 );203 204 int205 isupper (206 int207 );208 209 int210 isxdigit (211 int212 );213 214 int215 isalnum (216 int217 );218 219 void *220 memcpy (221 void *,222 const void *,223 size_t224 );225 226 void *227 memset (228 void *,229 int,230 size_t231 );232 233 void *234 memchr (235 const void *,236 int,237 size_t238 );239 240 int241 memcmp (242 const void *,243 const void *,244 size_t245 );246 247 void *248 memmove (249 void *,250 const void *,251 size_t252 );253 254 int255 strcmp (256 const char *,257 const char *258 );259 260 int261 strncmp (262 const char *,263 const char *,264 size_t265 );266 267 char *268 strcpy (269 char *,270 const char *271 );272 273 size_t274 strlen (275 const char *276 );277 278 char *279 strcat (280 char *,281 const char *282 );283 284 char *285 strchr (286 const char *,287 int288 );289 290 int291 strcasecmp (292 const char *,293 const char *294 );295 296 int297 210 strncasecmp ( 298 const char *,299 const char *,300 size_t301 );302 303 char *304 strncpy (305 char *,306 size_t,307 const char *,308 size_t309 );310 311 int312 strncmp (313 211 const char *, 314 212 const char *, … … 327 225 char **, 328 226 int 329 );330 331 char *332 strstr (333 const char *s1,334 const char *s2335 227 ); 336 228 … … 447 339 fgetc ( 448 340 FILE *_File 449 );450 451 uid_t452 getuid (453 void454 );455 456 uid_t457 geteuid (458 void459 );460 461 gid_t462 getgid (463 void464 );465 466 gid_t467 getegid (468 void469 341 ); 470 342 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Include/Library/RedfishDebugLib.h
r101291 r105670 2 2 This file defines the Redfish debug library interface. 3 3 4 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 6 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 12 13 13 14 #include <Uefi.h> 15 #include <Library/DebugLib.h> 16 #include <RedfishServiceData.h> 14 17 #include <Library/HiiUtilityLib.h> 15 18 #include <Library/JsonLib.h> 16 #include <Library/RedfishLib.h>17 19 18 20 #include <Protocol/EdkIIRedfishPlatformConfig.h> 19 21 20 #define DEBUG_REDFISH_NETWORK DEBUG_MANAGEABILITY ///< Debug error level for Redfish networking function 21 #define DEBUG_REDFISH_HOST_INTERFACE DEBUG_MANAGEABILITY ///< Debug error level for Redfish networking function 22 // Used with MdePKg DEBUG macro. 23 #define DEBUG_REDFISH_NETWORK DEBUG_MANAGEABILITY ///< Debug error level for Redfish networking function 24 #define DEBUG_REDFISH_HOST_INTERFACE DEBUG_MANAGEABILITY ///< Debug error level for Redfish Host INterface 25 #define DEBUG_REDFISH_PLATFORM_CONFIG DEBUG_MANAGEABILITY ///< Debug error level for Redfish Platform Configure Driver 26 27 // 28 // Definitions of Redfish debug capability in Redfish component scope, used with DEBUG_REDFISH macro 29 // For example, Redfish Platform Config Driver 30 // DEBUG_REDFISH(DEBUG_REDFISH_PLATFORM_CONFIG_DXE, ...) 31 // 32 #define DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE 0x00000001 33 34 #define DEBUG_REDFISH(DebugCategory, ...) \ 35 do { \ 36 if (!DebugPrintEnabled()) { \ 37 break; \ 38 } \ 39 if (!DebugRedfishComponentEnabled (DebugCategory)) { \ 40 break; \ 41 } \ 42 DEBUG ((DEBUG_MANAGEABILITY, ##__VA_ARGS__)); \ 43 } while (FALSE) 22 44 23 45 /** 24 Debug print the value of StatementValue. 46 Determine whether the Redfish debug category is enabled in 47 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory. 25 48 26 @param[in] ErrorLevel DEBUG macro error level. 27 @param[in] StatementValue The statement value to print. 49 @param[in] DebugCategory Redfish debug category. 28 50 29 @retval EFI_SUCCESS StatementValue is printed.30 @retval EFI_INVALID_PARAMETER StatementValue is NULL.51 @retval TRUE This debug category is enabled. 52 @retval FALSE This debug category is disabled.. 31 53 **/ 32 EFI_STATUS 33 DumpHiiStatementValue ( 34 IN UINTN ErrorLevel, 35 IN HII_STATEMENT_VALUE *StatementValue 54 BOOLEAN 55 DebugRedfishComponentEnabled ( 56 IN UINT64 DebugCategory 36 57 ); 37 58 … … 139 160 ); 140 161 162 /** 163 Debug output raw data buffer. 164 165 @param[in] ErrorLevel DEBUG macro error level 166 @param[in] Buffer Debug output data buffer. 167 @param[in] BufferSize The size of Buffer in byte. 168 169 @retval EFI_SUCCESS Debug dump finished. 170 @retval EFI_INVALID_PARAMETER Buffer is NULL. 171 172 **/ 173 EFI_STATUS 174 DumpBuffer ( 175 IN UINTN ErrorLevel, 176 IN UINT8 *Buffer, 177 IN UINTN BufferSize 178 ); 179 141 180 #endif -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Include/Library/RedfishLib.h
r99404 r105670 62 62 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 63 63 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 64 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 64 65 65 66 SPDX-License-Identifier: BSD-2-Clause-Patent … … 70 71 #define REDFISH_LIB_H_ 71 72 73 #include <RedfishServiceData.h> 72 74 #include <Library/JsonLib.h> 73 75 … … 77 79 #define ODATA_TYPE_NAME_MAX_SIZE 128 78 80 #define ODATA_TYPE_MAX_SIZE 128 79 80 ///81 /// Library class public defines82 ///83 typedef VOID *REDFISH_SERVICE;84 typedef VOID *REDFISH_PAYLOAD;85 86 ///87 /// Library class public structures/unions88 ///89 typedef struct {90 EFI_HTTP_STATUS_CODE *StatusCode;91 UINTN HeaderCount;92 EFI_HTTP_HEADER *Headers;93 REDFISH_PAYLOAD Payload;94 } REDFISH_RESPONSE;95 81 96 82 /// … … 185 171 186 172 /** 173 This function returns the Redfish service of a REDFISH_PAYLOAD. 174 175 Caller doesn't need to free the returned JSON value because it will be released 176 in corresponding RedfishCleanupService() function. 177 178 @param[in] Payload A REDFISH_PAYLOAD instance. 179 180 @return Redfish service of the payload. 181 182 **/ 183 REDFISH_SERVICE 184 EFIAPI 185 RedfishServiceInPayload ( 186 IN REDFISH_PAYLOAD Payload 187 ); 188 189 /** 187 190 Fill the input RedPath string with system UUID from SMBIOS table or use the customized 188 191 ID if FromSmbios == FALSE. … … 223 226 @param[out] RedResponse Pointer to the Redfish response data. 224 227 225 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not228 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 226 229 NULL and the value is 2XX. The corresponding redfish resource has 227 230 been returned in Payload within RedResponse. … … 253 256 @param[out] RedResponse Pointer to the Redfish response data. 254 257 255 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not258 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 256 259 NULL and the value is 2XX. The corresponding redfish resource has 257 260 been returned in Payload within RedResponse. … … 283 286 @param[out] RedResponse Pointer to the Redfish response data. 284 287 285 @retval EFI_SUCCESS The ope artion is successful:288 @retval EFI_SUCCESS The operation is successful: 286 289 1. The HTTP StatusCode is NULL and the returned Payload in 287 290 RedResponse is not NULL, indicates the Redfish resource has … … 324 327 @param[out] RedResponse Pointer to the Redfish response data. 325 328 326 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not329 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 327 330 NULL and the value is 2XX. The Redfish resource will be returned 328 331 in Payload within RedResponse if server send it back in the HTTP … … 358 361 359 362 @param[in] Target The target payload to be updated. 360 @param[in] Payload Pa lyoad with properties to be changed.363 @param[in] Payload Payload with properties to be changed. 361 364 @param[out] RedResponse Pointer to the Redfish response data. 362 365 363 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not366 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 364 367 NULL and the value is 2XX. The Redfish resource will be returned 365 368 in Payload within RedResponse if server send it back in the HTTP … … 399 402 @param[out] RedResponse Pointer to the Redfish response data. 400 403 401 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not404 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 402 405 NULL and the value is 2XX. The Redfish resource will be returned 403 406 in Payload within RedResponse if server send it back in the HTTP … … 417 420 IN CONST CHAR8 *Uri, 418 421 IN CONST CHAR8 *Content, 419 IN UINTN ContentSize ,420 IN CONST CHAR8 *ContentType ,422 IN UINTN ContentSize OPTIONAL, 423 IN CONST CHAR8 *ContentType OPTIONAL, 421 424 OUT REDFISH_RESPONSE *RedResponse 422 425 ); … … 437 440 @param[out] RedResponse Pointer to the Redfish response data. 438 441 439 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not442 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 440 443 NULL and the value is 2XX. The Redfish resource will be returned 441 444 in Payload within RedResponse if server send it back in the HTTP … … 472 475 @param[out] RedResponse Pointer to the Redfish response data. 473 476 474 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not477 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 475 478 NULL and the value is 2XX, the Redfish resource has been removed. 476 479 If there is any message returned from server, it will be returned … … 508 511 @param[out] RedResponse Pointer to the Redfish response data. 509 512 510 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not513 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 511 514 NULL and the value is 2XX, the Redfish resource has been removed. 512 515 If there is any message returned from server, it will be returned … … 526 529 IN CONST CHAR8 *Uri, 527 530 IN CONST CHAR8 *Content, 531 OUT REDFISH_RESPONSE *RedResponse 532 ); 533 534 /** 535 Use HTTP PUT to create new Redfish resource in the Resource Collection. 536 537 This function uses the RedfishService to put a Redfish resource addressed by 538 Uri (only the relative path is required). Changes to one or more properties within 539 the target resource are represented in the input Content, properties not specified 540 in Content won't be changed by this request. The corresponding redfish response will 541 returned, including HTTP StatusCode, Headers and Payload which record any HTTP response 542 messages. 543 544 Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in 545 redfish response data. 546 547 @param[in] RedfishService The Service to access the Redfish resources. 548 @param[in] Uri Relative path to address the resource. 549 @param[in] Content JSON represented properties to be update. 550 @param[in] ContentSize Size of the Content to be send to Redfish service 551 @param[in] ContentType Type of the Content to be send to Redfish service 552 @param[out] RedResponse Pointer to the Redfish response data. 553 554 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 555 NULL and the value is 2XX. The Redfish resource will be returned 556 in Payload within RedResponse if server send it back in the HTTP 557 response message body. 558 @retval EFI_INVALID_PARAMETER RedfishService, Uri, Content, or RedResponse is NULL. 559 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get 560 more error info from returned HTTP StatusCode, Headers and Payload 561 within RedResponse: 562 1. If the returned StatusCode is NULL, indicates any error happen. 563 2. If the returned StatusCode is not NULL and the value is not 2XX, 564 indicates any error happen. 565 **/ 566 EFI_STATUS 567 EFIAPI 568 RedfishPutToUri ( 569 IN REDFISH_SERVICE RedfishService, 570 IN CONST CHAR8 *Uri, 571 IN CONST CHAR8 *Content, 572 IN UINTN ContentSize OPTIONAL, 573 IN CONST CHAR8 *ContentType OPTIONAL, 528 574 OUT REDFISH_RESPONSE *RedResponse 529 575 ); … … 583 629 584 630 @param[in] Payload The Redfish payload to be checked. 585 @param[in] OdataTypeName OdataType will be retri ved from mapping list.631 @param[in] OdataTypeName OdataType will be retrieved from mapping list. 586 632 @param[in] OdataTypeMappingList The list of OdataType. 587 633 @param[in] OdataTypeMappingListSize The number of mapping list … … 617 663 @param[in] CollectionSize Size of this collection 618 664 619 @return EFI_SUCCESS Co olection size is returned in CollectionSize665 @return EFI_SUCCESS Collection size is returned in CollectionSize 620 666 @return EFI_INVALID_PARAMETER The payload is not a collection. 621 667 **/ … … 675 721 This function returns the string of Redfish service version. 676 722 677 @param[in] ServiceVer isonStr The string of Redfish service version.723 @param[in] ServiceVersionStr The string of Redfish service version. 678 724 @param[in] Url The URL to build Redpath with ID. 679 725 Start with "/", for example "/Registries" 680 726 @param[in] Id ID string 681 @param[out] Redpath Pointer to retri veRedpath, caller has to free727 @param[out] Redpath Pointer to retrieved Redpath, caller has to free 682 728 the memory allocated for this string. 683 729 @return EFI_STATUS … … 686 732 EFI_STATUS 687 733 RedfishBuildRedpathUseId ( 688 IN CHAR8 *ServiceVer isonStr,734 IN CHAR8 *ServiceVersionStr, 689 735 IN CHAR8 *Url, 690 736 IN CHAR8 *Id, -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Include/Library/RedfishPlatformConfigLib.h
r101291 r105670 3 3 4 4 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 5 Copyright (c) 2022-202 3, NVIDIA CORPORATION & AFFILIATES. All rights reserved.5 Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 6 7 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 83 83 84 84 @param[out] SupportedSchema The supported schema list which is separated by ';'. 85 For example: "x- uefi-redfish-Memory.v1_7_1;x-uefi-redfish-Boot.v1_0_1"85 For example: "x-UEFI-redfish-Memory.v1_7_1;x-UEFI-redfish-Boot.v1_0_1" 86 86 The SupportedSchema is allocated by the callee. It's caller's 87 87 responsibility to free this buffer using FreePool(). -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Include/Protocol/EdkIIRedfishPlatformConfig.h
r101291 r105670 3 3 4 4 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR> 5 Copyright (c) 2022-202 3, NVIDIA CORPORATION & AFFILIATES. All rights reserved.5 Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 6 7 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 228 228 @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance. 229 229 @param[out] SupportedSchema The supported schema list which is separated by ';'. 230 For example: "x- uefi-redfish-Memory.v1_7_1;x-uefi-redfish-Boot.v1_0_1"230 For example: "x-UEFI-redfish-Memory.v1_7_1;x-UEFI-redfish-Boot.v1_0_1" 231 231 The SupportedSchema is allocated by the callee. It's caller's 232 232 responsibility to free this buffer using FreePool(). -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/HiiUtilityLib/HiiUtilityInternal.c
r101291 r105670 5452 5452 Status = EFI_NOT_FOUND; 5453 5453 StrValue = NULL; 5454 ConfigAccess = NULL; 5454 5455 OriginalDefaultId = DefaultId; 5455 5456 DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead); -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.c
r101291 r105670 389 389 Question->Value.Buffer = AllocateZeroPool (Question->StorageWidth); 390 390 if (Question->Value.Buffer == NULL) { 391 FreePool (TemString); 391 392 return EFI_OUT_OF_RESOURCES; 392 393 } … … 394 395 CopyMem (Question->Value.Buffer, TemString, StrSize (TemString)); 395 396 Src = Question->Value.Buffer; 397 FreePool (TemString); 396 398 } else { 397 399 CopyMem (&Question->Value.Value, &QuestionValue->Value, sizeof (EFI_IFR_TYPE_VALUE)); -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/JsonLib/JsonLib.c
r101291 r105670 19 19 20 20 #include "jansson.h" 21 22 extern volatile UINT32 hashtable_seed; 21 23 22 24 /** … … 803 805 { 804 806 if (json_object_set ((json_t *)JsonObj, Key, (json_t *)Json) != 0) { 807 return EFI_ABORTED; 808 } else { 809 return EFI_SUCCESS; 810 } 811 } 812 813 /** 814 The function is used to delete a JSON key from the given JSON bject 815 816 @param[in] JsonObj The provided JSON object. 817 @param[in] Key The key of the JSON value to be deleted. 818 819 @retval EFI_ABORTED Some error occur and operation aborted. 820 @retval EFI_SUCCESS The JSON value has been deleted from this JSON object. 821 822 **/ 823 EFI_STATUS 824 EFIAPI 825 JsonObjectDelete ( 826 IN EDKII_JSON_OBJECT JsonObj, 827 IN CONST CHAR8 *Key 828 ) 829 { 830 if (json_object_del ((json_t *)JsonObj, (const char *)Key) != 0) { 805 831 return EFI_ABORTED; 806 832 } else { … … 1139 1165 return (EDKII_JSON_TYPE)(((json_t *)JsonValue)->type); 1140 1166 } 1167 1168 /** 1169 JSON Library constructor. 1170 1171 @param ImageHandle The image handle. 1172 @param SystemTable The system table. 1173 1174 @retval EFI_SUCCESS Protocol listener is registered successfully. 1175 1176 **/ 1177 EFI_STATUS 1178 EFIAPI 1179 JsonLibConstructor ( 1180 IN EFI_HANDLE ImageHandle, 1181 IN EFI_SYSTEM_TABLE *SystemTable 1182 ) 1183 { 1184 // 1185 // hashtable_seed is initalized by current time while JsonLib is loaded. 1186 // Due to above mechanism, hashtable_seed will be different in each individual 1187 // UEFI driver. As the result, the hash of same key in different UEFI driver 1188 // would be different. This breaks JsonObjectGetValue() because 1189 // JsonObjectGetValue() won't be able to find corresponding JSON value if 1190 // this EDKII_JSON_VALUE is created by another UEFI driver. 1191 // 1192 // Initial the seed to a fixed magic value for JsonLib to be working in all 1193 // UEFI drivers. This fixed number will be removed after the protocol version 1194 // of JsonLib is implemented in the future. 1195 // 1196 hashtable_seed = 0xFDAE2143; 1197 1198 return EFI_SUCCESS; 1199 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/JsonLib/JsonLib.inf
r89983 r105670 16 16 VERSION_STRING = 1.0 17 17 LIBRARY_CLASS = JsonLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER 18 CONSTRUCTOR = JsonLibConstructor 18 19 19 20 # -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/JsonLib/load.c
r99404 r105670 6 6 7 7 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 8 Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 8 9 9 10 SPDX-License-Identifier: BSD-2-Clause-Patent AND MIT … … 718 719 } 719 720 720 lex->token = TOKEN_REAL;721 lex->value. real= doubleval;721 lex->token = TOKEN_INTEGER; 722 lex->value.integer = doubleval; 722 723 return 0; 723 724 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
r101291 r105670 66 66 )) 67 67 { 68 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " Redfish Credent ail Bootstrapping is supported\n", __func__));68 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " Redfish Credential Bootstrapping is supported\n")); 69 69 ReturnBool = TRUE; 70 70 } else { 71 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " Redfish Credent ail Bootstrapping is not supported\n", __func__));71 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " Redfish Credential Bootstrapping is not supported\n")); 72 72 ReturnBool = FALSE; 73 73 } … … 121 121 CopyMem ( 122 122 (VOID *)&InterfaceData->DeviceDescriptor.UsbDeviceV2.MacAddress, 123 (VOID *) &ThisInstance->MacAddress,123 (VOID *)ThisInstance->MacAddress, 124 124 sizeof (InterfaceData->DeviceDescriptor.UsbDeviceV2.MacAddress) 125 125 ); … … 181 181 ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *)AllocateZeroPool ( 182 182 sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1 + 183 sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) +183 sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1 + 184 184 HostNameLength 185 185 ); … … 190 190 191 191 ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP; 192 ThisProtocolRecord->ProtocolTypeDataLen = sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) + HostNameLength;192 ThisProtocolRecord->ProtocolTypeDataLen = sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) -1 + HostNameLength; 193 193 RedfishOverIpData = (REDFISH_OVER_IP_PROTOCOL_DATA *)&ThisProtocolRecord->ProtocolTypeData[0]; 194 194 // … … 245 245 246 246 // RedfishServiceIpPort 247 RedfishOverIpData->RedfishServiceIpPort = 0;247 RedfishOverIpData->RedfishServiceIpPort = PcdGet16 (PcdRedfishServicePort); 248 248 249 249 // RedfishServiceVlanId … … 369 369 CopyMem ((VOID *)&ThisInstance->RedfishIpAddressIpv4, (VOID *)&DestIpAddress->IpAddress, sizeof (DestIpAddress->IpAddress)); 370 370 // 371 // According to UEFI spec, the IP address at BMC USB NIC host end is the IP address at BMC end minus 1. 371 // According to the design spec: 372 // https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-bmc-and-the-bmc-exposed-usb-network-device 373 // The IP address at BMC USB NIC host end is the IP address at BMC end minus 1. 372 374 // 373 375 CopyMem ((VOID *)&ThisInstance->HostIpAddressIpv4, (VOID *)&DestIpAddress->IpAddress, sizeof (DestIpAddress->IpAddress)); … … 615 617 616 618 // Initial the get MAC address request. 617 GetLanConfigReq.SetSelector = 0; 618 GetLanConfigReq.BlockSelector = 0; 619 GetLanConfigReq.ParameterSelector = IpmiLanMacAddress; 619 GetLanConfigReq.ChannelNumber.Uint8 = 0; 620 GetLanConfigReq.SetSelector = 0; 621 GetLanConfigReq.BlockSelector = 0; 622 GetLanConfigReq.ParameterSelector = IpmiLanMacAddress; 620 623 621 624 ExitStatus = EFI_NOT_FOUND; … … 639 642 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " No cached IPMI LAN info\n")); 640 643 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " Send NetFn = App, Command = 0x42 to channel %d\n", ChannelNum)); 644 GetChanelInfoRequest.ChannelNumber.Uint8 = 0; 641 645 GetChanelInfoRequest.ChannelNumber.Bits.ChannelNo = (UINT8)ChannelNum; 642 646 Status = IpmiGetChannelInfo ( … … 646 650 ); 647 651 if (EFI_ERROR (Status)) { 648 DEBUG ((DEBUG_ERROR, " - Fails to send command.\n", ChannelNum));652 DEBUG ((DEBUG_ERROR, " - Channel %d fails to send command.\n", ChannelNum)); 649 653 continue; 650 654 } … … 730 734 // 731 735 // According to design spec in Readme file under RedfishPkg. 732 // Compare the first five MAC address and 733 // the 6th MAC address. 736 // https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-bmc-and-the-bmc-exposed-usb-network-device 737 // Compare the first five elements of MAC address and the 6th element of MAC address. 738 // The 6th element of MAC address must be the 6th element of 739 // IPMI channel MAC address minus 1. 734 740 // 735 741 if ((IpmiLanMacAddressSize != UsbNicInfo->MacAddressSize) || … … 739 745 IpmiLanMacAddressSize - 1 740 746 ) != 0) || 741 ( IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1]!=742 *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1) - 1)747 ((IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] - 1) != 748 *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1)) 743 749 ) 744 750 { … … 964 970 965 971 /** 972 This function identifies if the USB NIC has MAC address and internet 973 protocol device path installed. (Only support IPv4) 974 975 @param[in] UsbDevicePath USB device path. 976 977 @retval EFI_SUCCESS Yes, this is IPv4 SNP handle 978 @retval EFI_NOT_FOUND No, this is not IPv4 SNP handle 979 980 **/ 981 EFI_STATUS 982 IdentifyNetworkMessageDevicePath ( 983 IN EFI_DEVICE_PATH_PROTOCOL *UsbDevicePath 984 ) 985 { 986 EFI_DEVICE_PATH_PROTOCOL *DevicePath; 987 988 DevicePath = UsbDevicePath; 989 while (TRUE) { 990 DevicePath = NextDevicePathNode (DevicePath); 991 if (IsDevicePathEnd (DevicePath)) { 992 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address device path is not found on this handle.\n")); 993 break; 994 } 995 996 if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType == MSG_MAC_ADDR_DP)) { 997 DevicePath = NextDevicePathNode (DevicePath); // Advance to next device path protocol. 998 if (IsDevicePathEnd (DevicePath)) { 999 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "IPv4 device path is not found on this handle.\n")); 1000 break; 1001 } 1002 1003 if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType == MSG_IPv4_DP)) { 1004 return EFI_SUCCESS; 1005 } 1006 1007 break; 1008 } 1009 } 1010 1011 return EFI_NOT_FOUND; 1012 } 1013 1014 /** 966 1015 This function identifies if the USB NIC is exposed by BMC as 967 1016 the host-BMC channel. … … 1014 1063 InitializeListHead (&BmcUsbNic->NextInstance); 1015 1064 BmcUsbNic->MacAddressSize = Snp->Mode->HwAddressSize; 1016 BmcUsbNic->MacAddress = Allocate ZeroPool (sizeof (BmcUsbNic->MacAddressSize));1065 BmcUsbNic->MacAddress = AllocatePool (BmcUsbNic->MacAddressSize); 1017 1066 if (BmcUsbNic->MacAddress == NULL) { 1018 1067 DEBUG ((DEBUG_ERROR, " Failed to allocate memory for HW MAC addresss.\n")); … … 1026 1075 BmcUsbNic->MacAddressSize 1027 1076 ); 1028 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " MAC address (in size %d) for this SNP instance:\n 1077 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " MAC address (in size %d) for this SNP instance:\n", BmcUsbNic->MacAddressSize)); 1029 1078 for (Index = 0; Index < BmcUsbNic->MacAddressSize; Index++) { 1030 1079 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "%02x ", *(BmcUsbNic->MacAddress + Index))); … … 1069 1118 EFI_STATUS Status; 1070 1119 EFI_DEVICE_PATH_PROTOCOL *DevicePath; 1071 BOOLEAN GotOneUsbNIc; 1120 BOOLEAN GotBmcUsbNic; 1121 CHAR16 *DevicePathStr; 1072 1122 1073 1123 if ((HandleNumer == 0) || (HandleBuffer == NULL)) { … … 1077 1127 DEBUG ((DEBUG_MANAGEABILITY, "%a: Entry, #%d SNP handle\n", __func__, HandleNumer)); 1078 1128 1079 Got OneUsbNIc = FALSE;1129 GotBmcUsbNic = FALSE; 1080 1130 for (Index = 0; Index < HandleNumer; Index++) { 1131 DEBUG ((DEBUG_MANAGEABILITY, " Locate device path on handle 0x%08x\n", *(HandleBuffer + Index))); 1081 1132 Status = gBS->HandleProtocol ( 1082 1133 *(HandleBuffer + Index), … … 1085 1136 ); 1086 1137 if (EFI_ERROR (Status)) { 1087 DEBUG ((DEBUG_ERROR, " Failed to locate SNP on %d handle.\n", __func__, Index));1138 DEBUG ((DEBUG_ERROR, " Failed to locate device path on %d handle.\n", Index)); 1088 1139 continue; 1140 } 1141 1142 DevicePathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE); 1143 if (DevicePathStr != NULL) { 1144 DEBUG ((DEBUG_MANAGEABILITY, " Device path: %s\n", DevicePathStr)); 1145 FreePool (DevicePathStr); 1089 1146 } 1090 1147 … … 1092 1149 while (TRUE) { 1093 1150 if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType == MSG_USB_DP)) { 1094 Status = Identify UsbNicBmcChannel (*(HandleBuffer + Index),DevicePath);1151 Status = IdentifyNetworkMessageDevicePath (DevicePath); 1095 1152 if (!EFI_ERROR (Status)) { 1096 GotOneUsbNIc = TRUE; 1097 break; 1153 Status = IdentifyUsbNicBmcChannel (*(HandleBuffer + Index), DevicePath); 1154 if (!EFI_ERROR (Status)) { 1155 GotBmcUsbNic = TRUE; 1156 } 1098 1157 } 1158 1159 break; // Advance to next SNP handle. 1099 1160 } 1100 1161 … … 1106 1167 } 1107 1168 1108 if (Got OneUsbNIc) {1169 if (GotBmcUsbNic) { 1109 1170 return EFI_SUCCESS; 1110 1171 } 1111 1172 1173 DEBUG ((DEBUG_MANAGEABILITY, "No BMC USB NIC found on SNP handles\n")); 1112 1174 return EFI_NOT_FOUND; 1113 1175 } … … 1140 1202 DEBUG ((DEBUG_MANAGEABILITY, "%a: Entry, the registration key - 0x%08x.\n", __func__, Registration)); 1141 1203 1142 Handle = NULL; 1143 Status = EFI_SUCCESS; 1144 BufferSize = 0; 1145 1146 Status = gBS->LocateHandle ( 1147 Registration == NULL ? ByProtocol : ByRegisterNotify, 1148 &gEfiSimpleNetworkProtocolGuid, 1149 Registration, 1150 &BufferSize, 1151 NULL 1152 ); 1153 if (Status == EFI_BUFFER_TOO_SMALL) { 1154 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " %d SNP protocol instances.\n", BufferSize/sizeof (EFI_HANDLE))); 1155 HandleBuffer = AllocateZeroPool (BufferSize); 1156 if (HandleBuffer == NULL) { 1157 DEBUG ((DEBUG_ERROR, " Falied to allocate buffer for the handles.\n")); 1158 return EFI_OUT_OF_RESOURCES; 1159 } 1160 1161 Status = gBS->LocateHandle ( 1162 Registration == NULL ? ByProtocol : ByRegisterNotify, 1163 &gEfiSimpleNetworkProtocolGuid, 1164 Registration, 1165 &BufferSize, 1166 HandleBuffer 1167 ); 1168 if (EFI_ERROR (Status)) { 1169 DEBUG ((DEBUG_ERROR, " Falied to locate SNP protocol handles.\n")); 1170 FreePool (HandleBuffer); 1171 return Status; 1172 } 1173 } else if (EFI_ERROR (Status)) { 1174 return Status; 1175 } 1176 1177 // Check USB NIC on handles. 1178 Status = CheckBmcUsbNicOnHandles (BufferSize/sizeof (EFI_HANDLE), HandleBuffer); 1179 if (!EFI_ERROR (Status)) { 1180 // Retrieve the rest of BMC USB NIC information for Redfish over IP information 1181 // and USB Network Interface V2. 1182 Status = RetrievedBmcUsbNicInfo (); 1183 if (!EFI_ERROR (Status)) { 1184 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " Install protocol to notify the platform Redfish Host Interface information is ready.\n")); 1185 Status = gBS->InstallProtocolInterface ( 1186 &Handle, 1187 &mPlatformHostInterfaceBmcUsbNicReadinessGuid, 1188 EFI_NATIVE_INTERFACE, 1189 NULL 1204 Handle = NULL; 1205 Status = EFI_SUCCESS; 1206 1207 do { 1208 BufferSize = 0; 1209 Status = gBS->LocateHandle ( 1210 Registration == NULL ? ByProtocol : ByRegisterNotify, 1211 &gEfiSimpleNetworkProtocolGuid, 1212 Registration, 1213 &BufferSize, 1214 NULL 1215 ); 1216 if (Status == EFI_BUFFER_TOO_SMALL) { 1217 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " %d SNP protocol instance(s).\n", BufferSize/sizeof (EFI_HANDLE))); 1218 HandleBuffer = AllocateZeroPool (BufferSize); 1219 if (HandleBuffer == NULL) { 1220 DEBUG ((DEBUG_ERROR, " Falied to allocate buffer for the handles.\n")); 1221 return EFI_OUT_OF_RESOURCES; 1222 } 1223 1224 Status = gBS->LocateHandle ( 1225 Registration == NULL ? ByProtocol : ByRegisterNotify, 1226 &gEfiSimpleNetworkProtocolGuid, 1227 Registration, 1228 &BufferSize, 1229 HandleBuffer 1190 1230 ); 1191 1231 if (EFI_ERROR (Status)) { 1192 DEBUG ((DEBUG_ERROR, " Install protocol fail %r.\n", Status)); 1193 } 1194 } 1195 } 1196 1197 FreePool (HandleBuffer); 1232 DEBUG ((DEBUG_ERROR, " Falied to locate SNP protocol handles.\n")); 1233 FreePool (HandleBuffer); 1234 return Status; 1235 } 1236 } else if (EFI_ERROR (Status)) { 1237 if (Registration != NULL) { 1238 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " No more newly installed SNP protocol for this registration - %r.\n", Status)); 1239 return EFI_SUCCESS; 1240 } 1241 1242 return Status; 1243 } 1244 1245 // Check USB NIC on handles. 1246 Status = CheckBmcUsbNicOnHandles (BufferSize/sizeof (EFI_HANDLE), HandleBuffer); 1247 if (!EFI_ERROR (Status)) { 1248 // Retrieve the rest of BMC USB NIC information for Redfish over IP information 1249 // and USB Network Interface V2. 1250 Status = RetrievedBmcUsbNicInfo (); 1251 if (!EFI_ERROR (Status)) { 1252 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, " Install protocol to notify the platform Redfish Host Interface information is ready.\n")); 1253 Status = gBS->InstallProtocolInterface ( 1254 &Handle, 1255 &mPlatformHostInterfaceBmcUsbNicReadinessGuid, 1256 EFI_NATIVE_INTERFACE, 1257 NULL 1258 ); 1259 if (EFI_ERROR (Status)) { 1260 DEBUG ((DEBUG_ERROR, " Install protocol fail %r.\n", Status)); 1261 } 1262 } 1263 } 1264 1265 FreePool (HandleBuffer); 1266 } while (Registration != NULL); 1267 1198 1268 return Status; 1199 1269 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.inf
r101291 r105670 15 15 MODULE_TYPE = DXE_DRIVER 16 16 VERSION_STRING = 1.0 17 LIBRARY_CLASS = PlatformHostInterfaceBmcUsbNicLib17 LIBRARY_CLASS = RedfishPlatformHostInterfaceLib 18 18 19 19 [Sources] … … 44 44 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishHostName ## CONSUMED 45 45 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServiceUuid ## CONSUMED 46 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServicePort ## CONSUMED 46 47 47 48 [Depex] -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c
r101291 r105670 2 2 Redfish debug library to debug Redfish application. 3 3 4 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 6 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 14 15 #include <Library/MemoryAllocationLib.h> 15 16 #include <Library/RedfishDebugLib.h> 17 #include <Library/RedfishHttpLib.h> 16 18 #include <Library/UefiLib.h> 17 19 … … 20 22 #endif 21 23 22 #define REDFISH_JSON_STRING_LENGTH 200 23 #define REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2)) 24 25 /** 26 Debug print the value of StatementValue. 27 28 @param[in] ErrorLevel DEBUG macro error level. 29 @param[in] StatementValue The statement value to print. 30 31 @retval EFI_SUCCESS StatementValue is printed. 32 @retval EFI_INVALID_PARAMETER StatementValue is NULL. 33 **/ 34 EFI_STATUS 35 DumpHiiStatementValue ( 36 IN UINTN ErrorLevel, 37 IN HII_STATEMENT_VALUE *StatementValue 38 ) 39 { 40 if (StatementValue == NULL) { 41 return EFI_INVALID_PARAMETER; 42 } 43 44 DEBUG ((ErrorLevel, "BufferValueType: 0x%x\n", StatementValue->BufferValueType)); 45 DEBUG ((ErrorLevel, "BufferLen: 0x%x\n", StatementValue->BufferLen)); 46 DEBUG ((ErrorLevel, "Buffer: 0x%p\n", StatementValue->Buffer)); 47 DEBUG ((ErrorLevel, "Type: 0x%p\n", StatementValue->Type)); 48 49 switch (StatementValue->Type) { 50 case EFI_IFR_TYPE_NUM_SIZE_8: 51 DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u8)); 52 break; 53 case EFI_IFR_TYPE_NUM_SIZE_16: 54 DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u16)); 55 break; 56 case EFI_IFR_TYPE_NUM_SIZE_32: 57 DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.u32)); 58 break; 59 case EFI_IFR_TYPE_NUM_SIZE_64: 60 DEBUG ((ErrorLevel, "Value: 0x%lx\n", StatementValue->Value.u64)); 61 break; 62 case EFI_IFR_TYPE_BOOLEAN: 63 DEBUG ((ErrorLevel, "Value: %a\n", (StatementValue->Value.b ? "true" : "false"))); 64 break; 65 case EFI_IFR_TYPE_STRING: 66 DEBUG ((ErrorLevel, "Value: 0x%x\n", StatementValue->Value.string)); 67 break; 68 case EFI_IFR_TYPE_TIME: 69 case EFI_IFR_TYPE_DATE: 70 default: 71 break; 72 } 73 74 return EFI_SUCCESS; 24 #define REDFISH_JSON_STRING_LENGTH 200 25 #define REDFISH_JSON_OUTPUT_FORMAT (EDKII_JSON_COMPACT | EDKII_JSON_INDENT(2)) 26 #define REDFISH_PRINT_BUFFER_BYTES_PER_ROW 16 27 28 /** 29 Determine whether the Redfish debug category is enabled in 30 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory. 31 32 @param[in] RedfishDebugCategory Redfish debug category. 33 34 @retval TRUE This debug category is enabled. 35 @retval FALSE This debug category is disabled.. 36 **/ 37 BOOLEAN 38 DebugRedfishComponentEnabled ( 39 IN UINT64 RedfishDebugCategory 40 ) 41 { 42 UINT64 DebugCategory; 43 44 DebugCategory = FixedPcdGet64 (PcdRedfishDebugCategory); 45 return ((DebugCategory & RedfishDebugCategory) != 0); 75 46 } 76 47 … … 367 338 return EFI_SUCCESS; 368 339 } 340 341 /** 342 Debug output raw data buffer. 343 344 @param[in] ErrorLevel DEBUG macro error level 345 @param[in] Buffer Debug output data buffer. 346 @param[in] BufferSize The size of Buffer in byte. 347 348 @retval EFI_SUCCESS Debug dump finished. 349 @retval EFI_INVALID_PARAMETER Buffer is NULL. 350 351 **/ 352 EFI_STATUS 353 DumpBuffer ( 354 IN UINTN ErrorLevel, 355 IN UINT8 *Buffer, 356 IN UINTN BufferSize 357 ) 358 { 359 UINTN Index; 360 361 if (Buffer == NULL) { 362 return EFI_INVALID_PARAMETER; 363 } 364 365 DEBUG ((ErrorLevel, "Address: 0x%p size: %d\n", Buffer, BufferSize)); 366 for (Index = 0; Index < BufferSize; Index++) { 367 if (Index % REDFISH_PRINT_BUFFER_BYTES_PER_ROW == 0) { 368 DEBUG ((ErrorLevel, "\n%04X: ", Index)); 369 } 370 371 DEBUG ((ErrorLevel, "%02X ", Buffer[Index])); 372 } 373 374 DEBUG ((ErrorLevel, "\n")); 375 376 return EFI_SUCCESS; 377 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf
r101291 r105670 2 2 # INF file for Redfish debug library. 3 3 # 4 # Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 4 # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 # 6 7 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 33 34 JsonLib 34 35 MemoryAllocationLib 35 Redfish Lib36 RedfishHttpLib 36 37 UefiLib 38 39 [FixedPcd] 40 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory 37 41 38 42 [Depex] -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.c
r101291 r105670 3 3 4 4 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 5 Copyright (c) 2022-202 3, NVIDIA CORPORATION & AFFILIATES. All rights reserved.5 Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 6 7 7 SPDX-License-Identifier: BSD-2-Clause-Patent … … 192 192 193 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"194 For example: "x-UEFI-redfish-Memory.v1_7_1;x-UEFI-redfish-Boot.v1_0_1" 195 195 The SupportedSchema is allocated by the callee. It's caller's 196 196 responsibility to free this buffer using FreePool(). -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Library/RedfishPlatformCredentialIpmiLib/RedfishPlatformCredentialIpmiLib.inf
r101291 r105670 14 14 MODULE_TYPE = DXE_DRIVER 15 15 VERSION_STRING = 1.0 16 LIBRARY_CLASS = RedfishPlatformCredential IpmiLib16 LIBRARY_CLASS = RedfishPlatformCredentialLib 17 17 18 18 [Sources] -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c
r101291 r105670 5 5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 6 6 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 7 Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 7 8 8 9 SPDX-License-Identifier: BSD-2-Clause-Patent … … 520 521 521 522 /** 522 edk2 Jansson port does not support doubles, simply return 0.523 edk2 Jansson port does not support doubles, simply return integer part. 523 524 524 525 These conversion functions convert the initial portion of the string … … 541 542 would cause underflow, zero is returned and ERANGE is stored in errno. 542 543 543 @return Return 0.544 @return Integer part of decimal number. 544 545 **/ 545 546 double … … 549 550 ) 550 551 { 551 DEBUG ((DEBUG_ERROR, "We don't supprot double type on edk2 yet!")); 552 ASSERT (FALSE); 553 return (double)0; 552 UINTN Data; 553 UINTN StrLen; 554 555 Data = 0; 556 StrLen = 0; 557 558 if (nptr == NULL) { 559 return (double)0; 560 } 561 562 AsciiStrDecimalToUintnS (nptr, NULL, &Data); 563 DEBUG ((DEBUG_WARN, "%a: \"%a\" We don't support double type on edk2 yet. Only integer part is returned: %d\n", __func__, nptr, Data)); 564 565 // 566 // Force endptr to the last position of nptr because caller may 567 // check endptr and raise assertion. We don't support floating 568 // number in edk2 so this prevents unecessary assertion from happening. 569 // 570 if (endptr != NULL) { 571 StrLen = AsciiStrLen (nptr); 572 *endptr = (char *__restrict)nptr + StrLen; 573 } 574 575 return (double)Data; 554 576 } 555 577 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf
r101291 r105670 4 4 # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 5 5 # (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 6 # Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 7 # 7 8 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 24 25 RedfishCrtLib.c 25 26 27 [Sources.IA32] 28 Ia32/MathFtol.c | MSFT 29 26 30 [LibraryClasses] 27 31 BaseLib … … 36 40 RedfishPkg/RedfishPkg.dec 37 41 38 42 [BuildOptions] 43 MSFT:*_*_IA32_CC_FLAGS = /GL- -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c
r101291 r105670 5 5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 6 6 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 7 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 7 8 8 9 SPDX-License-Identifier: BSD-2-Clause-Patent … … 169 170 170 171 /** 172 This function returns the Redfish service of a REDFISH_PAYLOAD. 173 174 Caller doesn't need to free the returned JSON value because it will be released 175 in corresponding RedfishCleanupService() function. 176 177 @param[in] Payload A REDFISH_PAYLOAD instance. 178 179 @return Redfish service of the payload. 180 181 **/ 182 REDFISH_SERVICE 183 EFIAPI 184 RedfishServiceInPayload ( 185 IN REDFISH_PAYLOAD Payload 186 ) 187 { 188 if (Payload == NULL) { 189 return NULL; 190 } 191 192 return ((redfishPayload *)Payload)->service; 193 } 194 195 /** 171 196 Fill the input RedPath string with system UUID from SMBIOS table or use the customized 172 197 ID if FromSmbios == FALSE. … … 245 270 @param[out] RedResponse Pointer to the Redfish response data. 246 271 247 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not272 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 248 273 NULL and the value is 2XX. The corresponding redfish resource has 249 274 been returned in Payload within RedResponse. … … 305 330 @param[out] RedResponse Pointer to the Redfish response data. 306 331 307 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not332 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 308 333 NULL and the value is 2XX. The corresponding redfish resource has 309 334 been returned in Payload within RedResponse. … … 332 357 ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); 333 358 334 JsonValue = getUriFromService (RedfishService, Uri, &RedResponse->StatusCode);359 JsonValue = getUriFromServiceEx (RedfishService, Uri, &RedResponse->Headers, &RedResponse->HeaderCount, &RedResponse->StatusCode); 335 360 RedResponse->Payload = createRedfishPayload (JsonValue, RedfishService); 336 361 … … 368 393 @param[out] RedResponse Pointer to the Redfish response data. 369 394 370 @retval EFI_SUCCESS The ope artion is successful:395 @retval EFI_SUCCESS The operation is successful: 371 396 1. The HTTP StatusCode is NULL and the returned Payload in 372 397 RedResponse is not NULL, indicates the Redfish resource has … … 441 466 @param[out] RedResponse Pointer to the Redfish response data. 442 467 443 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not468 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 444 469 NULL and the value is 2XX. The Redfish resource will be returned 445 470 in Payload within RedResponse if server send it back in the HTTP … … 474 499 ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); 475 500 476 JsonValue = (EDKII_JSON_VALUE)patchUriFromService (501 JsonValue = (EDKII_JSON_VALUE)patchUriFromServiceEx ( 477 502 RedfishService, 478 503 Uri, 479 504 Content, 505 &(RedResponse->Headers), 506 &(RedResponse->HeaderCount), 480 507 &(RedResponse->StatusCode) 481 508 ); … … 528 555 529 556 @param[in] Target The target payload to be updated. 530 @param[in] Payload Pa lyoad with properties to be changed.557 @param[in] Payload Payload with properties to be changed. 531 558 @param[out] RedResponse Pointer to the Redfish response data. 532 559 533 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not560 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 534 561 NULL and the value is 2XX. The Redfish resource will be returned 535 562 in Payload within RedResponse if server send it back in the HTTP … … 602 629 @param[out] RedResponse Pointer to the Redfish response data. 603 630 604 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not631 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 605 632 NULL and the value is 2XX. The Redfish resource will be returned 606 633 in Payload within RedResponse if server send it back in the HTTP … … 620 647 IN CONST CHAR8 *Uri, 621 648 IN CONST CHAR8 *Content, 622 IN UINTN ContentSize ,623 IN CONST CHAR8 *ContentType ,649 IN UINTN ContentSize OPTIONAL, 650 IN CONST CHAR8 *ContentType OPTIONAL, 624 651 OUT REDFISH_RESPONSE *RedResponse 625 652 ) … … 637 664 ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); 638 665 639 JsonValue = (EDKII_JSON_VALUE)postUriFromService (666 JsonValue = (EDKII_JSON_VALUE)postUriFromServiceEx ( 640 667 RedfishService, 641 668 Uri, … … 643 670 ContentSize, 644 671 ContentType, 672 &(RedResponse->Headers), 673 &(RedResponse->HeaderCount), 645 674 &(RedResponse->StatusCode) 646 675 ); … … 695 724 @param[out] RedResponse Pointer to the Redfish response data. 696 725 697 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not726 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 698 727 NULL and the value is 2XX. The Redfish resource will be returned 699 728 in Payload within RedResponse if server send it back in the HTTP … … 763 792 @param[out] RedResponse Pointer to the Redfish response data. 764 793 765 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not794 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 766 795 NULL and the value is 2XX, the Redfish resource has been removed. 767 796 If there is any message returned from server, it will be returned … … 851 880 @param[out] RedResponse Pointer to the Redfish response data. 852 881 853 @retval EFI_SUCCESS The ope artion is successful, indicates the HTTP StatusCode is not882 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 854 883 NULL and the value is 2XX, the Redfish resource has been removed. 855 884 If there is any message returned from server, it will be returned … … 1061 1090 1062 1091 @param[in] Payload The Redfish payload to be checked. 1063 @param[in] OdataTypeName OdataType will be retri ved from mapping list.1092 @param[in] OdataTypeName OdataType will be retrieved from mapping list. 1064 1093 @param[in] OdataTypeMappingList The list of OdataType. 1065 1094 @param[in] OdataTypeMappingListSize The number of mapping list … … 1128 1157 @param[in] CollectionSize Size of this collection 1129 1158 1130 @return EFI_SUCCESS Co olection size is returned in CollectionSize1159 @return EFI_SUCCESS Collection size is returned in CollectionSize 1131 1160 @return EFI_INVALID_PARAMETER The payload is not a collection. 1132 1161 **/ … … 1218 1247 return EFI_SUCCESS; 1219 1248 } 1249 1250 /** 1251 Use HTTP PUT to create new Redfish resource in the Resource Collection. 1252 1253 This function uses the RedfishService to put a Redfish resource addressed by 1254 Uri (only the relative path is required). Changes to one or more properties within 1255 the target resource are represented in the input Content, properties not specified 1256 in Content won't be changed by this request. The corresponding redfish response will 1257 returned, including HTTP StatusCode, Headers and Payload which record any HTTP response 1258 messages. 1259 1260 Callers are responsible for freeing the HTTP StatusCode, Headers and Payload returned in 1261 redfish response data. 1262 1263 @param[in] RedfishService The Service to access the Redfish resources. 1264 @param[in] Uri Relative path to address the resource. 1265 @param[in] Content JSON represented properties to be update. 1266 @param[in] ContentSize Size of the Content to be send to Redfish service 1267 @param[in] ContentType Type of the Content to be send to Redfish service 1268 @param[out] RedResponse Pointer to the Redfish response data. 1269 1270 @retval EFI_SUCCESS The operation is successful, indicates the HTTP StatusCode is not 1271 NULL and the value is 2XX. The Redfish resource will be returned 1272 in Payload within RedResponse if server send it back in the HTTP 1273 response message body. 1274 @retval EFI_INVALID_PARAMETER RedfishService, Uri, Content, or RedResponse is NULL. 1275 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. Callers can get 1276 more error info from returned HTTP StatusCode, Headers and Payload 1277 within RedResponse: 1278 1. If the returned StatusCode is NULL, indicates any error happen. 1279 2. If the returned StatusCode is not NULL and the value is not 2XX, 1280 indicates any error happen. 1281 **/ 1282 EFI_STATUS 1283 EFIAPI 1284 RedfishPutToUri ( 1285 IN REDFISH_SERVICE RedfishService, 1286 IN CONST CHAR8 *Uri, 1287 IN CONST CHAR8 *Content, 1288 IN UINTN ContentSize OPTIONAL, 1289 IN CONST CHAR8 *ContentType OPTIONAL, 1290 OUT REDFISH_RESPONSE *RedResponse 1291 ) 1292 { 1293 EFI_STATUS Status; 1294 EDKII_JSON_VALUE JsonValue; 1295 1296 Status = EFI_SUCCESS; 1297 JsonValue = NULL; 1298 1299 if ((RedfishService == NULL) || (Uri == NULL) || (Content == NULL) || (RedResponse == NULL)) { 1300 return EFI_INVALID_PARAMETER; 1301 } 1302 1303 ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); 1304 1305 JsonValue = (EDKII_JSON_VALUE)putUriFromServiceEx ( 1306 RedfishService, 1307 Uri, 1308 Content, 1309 ContentSize, 1310 ContentType, 1311 &(RedResponse->Headers), 1312 &(RedResponse->HeaderCount), 1313 &(RedResponse->StatusCode) 1314 ); 1315 1316 // 1317 // 1. If the returned StatusCode is NULL, indicates any error happen. 1318 // 1319 if (RedResponse->StatusCode == NULL) { 1320 Status = EFI_DEVICE_ERROR; 1321 goto ON_EXIT; 1322 } 1323 1324 // 1325 // 2. If the returned StatusCode is not NULL and the value is not 2XX, indicates any error happen. 1326 // NOTE: If there is any error message returned from server, it will be returned in 1327 // Payload within RedResponse. 1328 // 1329 if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \ 1330 (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)) 1331 { 1332 Status = EFI_DEVICE_ERROR; 1333 } 1334 1335 ON_EXIT: 1336 if (JsonValue != NULL) { 1337 RedResponse->Payload = createRedfishPayload (JsonValue, RedfishService); 1338 if (RedResponse->Payload == NULL) { 1339 // 1340 // Ignore the error when create RedfishPayload, just free the JsonValue since it's not what 1341 // we care about if the returned StatusCode is 2XX. 1342 // 1343 JsonValueFree (JsonValue); 1344 } 1345 } 1346 1347 return Status; 1348 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.inf
r89983 r105670 4 4 # Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 5 5 # (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 6 # Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 7 # 7 8 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 43 44 BaseMemoryLib 44 45 DebugLib 46 JsonLib 45 47 HttpLib 46 48 MemoryAllocationLib -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.c
r99404 r105670 4 4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 5 5 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 6 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 7 7 8 SPDX-License-Identifier: BSD-2-Clause-Patent … … 169 170 This function returns the string of Redfish service version. 170 171 171 @param[in] ServiceVer isonStr The string of Redfish service version.172 @param[in] ServiceVersionStr The string of Redfish service version. 172 173 @param[in] Url The URL to build Redpath with ID. 173 174 Start with "/", for example "/Registries" 174 175 @param[in] Id ID string 175 @param[out] Redpath Pointer to retri veRedpath, caller has to free176 @param[out] Redpath Pointer to retrieved Redpath, caller has to free 176 177 the memory allocated for this string. 177 178 @return EFI_STATUS … … 180 181 EFI_STATUS 181 182 RedfishBuildRedpathUseId ( 182 IN CHAR8 *ServiceVer isonStr,183 IN CHAR8 *ServiceVersionStr, 183 184 IN CHAR8 *Url, 184 185 IN CHAR8 *Id, … … 188 189 UINTN RedpathSize; 189 190 190 if ((Redpath == NULL) || (ServiceVer isonStr == NULL) || (Url == NULL) || (Id == NULL)) {191 if ((Redpath == NULL) || (ServiceVersionStr == NULL) || (Url == NULL) || (Id == NULL)) { 191 192 return EFI_INVALID_PARAMETER; 192 193 } 193 194 194 195 RedpathSize = AsciiStrLen ("/") + 195 AsciiStrLen (ServiceVer isonStr) +196 AsciiStrLen (ServiceVersionStr) + 196 197 AsciiStrLen (Url) + 197 198 AsciiStrLen ("[Id=]") + … … 202 203 } 203 204 204 AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVer isonStr, Url, Id);205 AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVersionStr, Url, Id); 205 206 return EFI_SUCCESS; 206 207 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishPayload.h
r99404 r105670 11 11 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 12 12 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 13 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 13 14 14 15 SPDX-License-Identifier: BSD-2-Clause-Patent … … 20 21 21 22 #include <Include/Library/RedfishCrtLib.h> 22 23 #include <Library/JsonLib.h> 23 24 #include <jansson.h> 24 25 #include <redfishService.h> -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishService.h
r99404 r105670 11 11 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 12 12 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 13 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 13 14 14 15 SPDX-License-Identifier: BSD-2-Clause-Patent … … 106 107 107 108 json_t * 109 getUriFromServiceEx ( 110 redfishService *service, 111 const char *uri, 112 EFI_HTTP_HEADER **Headers, 113 UINTN *HeaderCount, 114 EFI_HTTP_STATUS_CODE **StatusCode 115 ); 116 117 json_t * 108 118 patchUriFromService ( 109 119 redfishService *service, 110 120 const char *uri, 111 121 const char *content, 122 EFI_HTTP_STATUS_CODE **StatusCode 123 ); 124 125 json_t * 126 patchUriFromServiceEx ( 127 redfishService *service, 128 const char *uri, 129 const char *content, 130 EFI_HTTP_HEADER **Headers, 131 UINTN *HeaderCount, 112 132 EFI_HTTP_STATUS_CODE **StatusCode 113 133 ); … … 120 140 size_t contentLength, 121 141 const char *contentType, 142 EFI_HTTP_STATUS_CODE **StatusCode 143 ); 144 145 json_t * 146 postUriFromServiceEx ( 147 redfishService *service, 148 const char *uri, 149 const char *content, 150 size_t contentLength, 151 const char *contentType, 152 EFI_HTTP_HEADER **Headers, 153 UINTN *HeaderCount, 154 EFI_HTTP_STATUS_CODE **StatusCode 155 ); 156 157 json_t * 158 putUriFromServiceEx ( 159 redfishService *service, 160 const char *uri, 161 const char *content, 162 size_t contentLength, 163 const char *contentType, 164 EFI_HTTP_HEADER **Headers, 165 UINTN *HeaderCount, 122 166 EFI_HTTP_STATUS_CODE **StatusCode 123 167 ); -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
r99404 r105670 11 11 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 12 12 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 13 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 13 14 14 15 SPDX-License-Identifier: BSD-2-Clause-Patent … … 525 526 526 527 stringProp = prop->json; 527 jsonType = prop->json->type;528 jsonType = JsonGetType (prop->json); 528 529 switch (jsonType) { 529 530 case JSON_OBJECT: -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c
r101291 r105670 11 11 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> 12 12 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 13 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 13 14 14 15 SPDX-License-Identifier: BSD-2-Clause-Patent … … 402 403 } 403 404 405 EFI_HTTP_HEADER * 406 cloneHttpHeaders ( 407 EFI_HTTP_MESSAGE *message, 408 UINTN *HeaderCount 409 ) 410 { 411 EFI_HTTP_HEADER *Buffer; 412 UINTN Index; 413 414 if ((message == NULL) || (HeaderCount == NULL)) { 415 return NULL; 416 } 417 418 *HeaderCount = message->HeaderCount; 419 Buffer = AllocatePool (sizeof (EFI_HTTP_HEADER) * message->HeaderCount); 420 if (Buffer == NULL) { 421 return NULL; 422 } 423 424 for (Index = 0; Index < message->HeaderCount; Index++) { 425 Buffer[Index].FieldName = AllocateCopyPool (AsciiStrSize (message->Headers[Index].FieldName), message->Headers[Index].FieldName); 426 ASSERT (Buffer[Index].FieldName != NULL); 427 Buffer[Index].FieldValue = AllocateCopyPool (AsciiStrSize (message->Headers[Index].FieldValue), message->Headers[Index].FieldValue); 428 ASSERT (Buffer[Index].FieldValue != NULL); 429 } 430 431 return Buffer; 432 } 433 404 434 json_t * 405 getUriFromService (435 getUriFromServiceEx ( 406 436 redfishService *service, 407 437 const char *uri, 438 EFI_HTTP_HEADER **Headers OPTIONAL, 439 UINTN *HeaderCount OPTIONAL, 408 440 EFI_HTTP_STATUS_CODE **StatusCode 409 441 ) … … 423 455 424 456 *StatusCode = NULL; 457 if (HeaderCount != NULL) { 458 *HeaderCount = 0; 459 } 460 461 if (Headers != NULL) { 462 *Headers = NULL; 463 } 425 464 426 465 url = makeUrlForService (service, uri); … … 429 468 } 430 469 431 DEBUG ((DEBUG_MANAGEABILITY, " libredfish: getUriFromService(): %a\n", url));470 DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); 432 471 433 472 // … … 492 531 if (EFI_ERROR (Status)) { 493 532 ret = NULL; 533 534 // 535 // Deliver status code to caller when error happens so caller can do error handling. 536 // 537 if (ResponseMsg.Data.Response != NULL) { 538 *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); 539 if (*StatusCode == NULL) { 540 ret = NULL; 541 goto ON_EXIT; 542 } 543 544 // 545 // The caller shall take the responsibility to free the buffer. 546 // 547 **StatusCode = ResponseMsg.Data.Response->StatusCode; 548 } 549 494 550 goto ON_EXIT; 495 551 } … … 509 565 // 510 566 **StatusCode = ResponseMsg.Data.Response->StatusCode; 567 } 568 569 if ((ResponseMsg.Headers != NULL) && (Headers != NULL) && (HeaderCount != NULL)) { 570 *Headers = cloneHttpHeaders (&ResponseMsg, HeaderCount); 511 571 } 512 572 … … 559 619 560 620 json_t * 561 p atchUriFromService(621 putUriFromServiceEx ( 562 622 redfishService *service, 563 623 const char *uri, 564 624 const char *content, 625 size_t contentLength, 626 const char *contentType, 627 EFI_HTTP_HEADER **Headers OPTIONAL, 628 UINTN *HeaderCount OPTIONAL, 565 629 EFI_HTTP_STATUS_CODE **StatusCode 566 630 ) … … 582 646 583 647 *StatusCode = NULL; 648 if (HeaderCount != NULL) { 649 *HeaderCount = 0; 650 } 651 652 if (Headers != NULL) { 653 *Headers = NULL; 654 } 655 656 url = makeUrlForService (service, uri); 657 if (url == NULL) { 658 return NULL; 659 } 660 661 DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); 662 663 if (contentLength == 0) { 664 contentLength = strlen (content); 665 } 666 667 // 668 // Step 1: Create HTTP request message with 4 headers: 669 // 670 HttpIoHeader = HttpIoCreateHeader ((service->sessionToken != NULL || service->basicAuthStr != NULL) ? 9 : 8); 671 if (HttpIoHeader == NULL) { 672 ret = NULL; 673 goto ON_EXIT; 674 } 675 676 if (service->sessionToken) { 677 Status = HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->sessionToken); 678 ASSERT_EFI_ERROR (Status); 679 } else if (service->basicAuthStr) { 680 Status = HttpIoSetHeader (HttpIoHeader, "Authorization", service->basicAuthStr); 681 ASSERT_EFI_ERROR (Status); 682 } 683 684 if (contentType == NULL) { 685 Status = HttpIoSetHeader (HttpIoHeader, "Content-Type", "application/json"); 686 ASSERT_EFI_ERROR (Status); 687 } else { 688 Status = HttpIoSetHeader (HttpIoHeader, "Content-Type", (CHAR8 *)contentType); 689 ASSERT_EFI_ERROR (Status); 690 } 691 692 Status = HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderValue); 693 ASSERT_EFI_ERROR (Status); 694 Status = HttpIoSetHeader (HttpIoHeader, "Content-Type", "application/json"); 695 ASSERT_EFI_ERROR (Status); 696 Status = HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"); 697 ASSERT_EFI_ERROR (Status); 698 Status = HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); 699 ASSERT_EFI_ERROR (Status); 700 Status = HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); 701 ASSERT_EFI_ERROR (Status); 702 703 AsciiSPrint ( 704 ContentLengthStr, 705 sizeof (ContentLengthStr), 706 "%lu", 707 (UINT64)contentLength 708 ); 709 Status = HttpIoSetHeader (HttpIoHeader, "Content-Length", ContentLengthStr); 710 ASSERT_EFI_ERROR (Status); 711 Status = HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); 712 ASSERT_EFI_ERROR (Status); 713 714 // 715 // Step 2: build the rest of HTTP request info. 716 // 717 RequestData = AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); 718 if (RequestData == NULL) { 719 ret = NULL; 720 goto ON_EXIT; 721 } 722 723 RequestData->Method = HttpMethodPut; 724 RequestData->Url = C8ToC16 (url); 725 726 // 727 // Step 3: fill in EFI_HTTP_MESSAGE 728 // 729 RequestMsg = AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); 730 if (RequestMsg == NULL) { 731 ret = NULL; 732 goto ON_EXIT; 733 } 734 735 EncodedContent = (CHAR8 *)content; 736 EncodedContentLen = contentLength; 737 // 738 // We currently only support gzip Content-Encoding. 739 // 740 Status = EncodeRequestContent ((CHAR8 *)HTTP_CONTENT_ENCODING_GZIP, (CHAR8 *)content, (VOID **)&EncodedContent, &EncodedContentLen); 741 if (Status == EFI_INVALID_PARAMETER) { 742 DEBUG ((DEBUG_ERROR, "%a: Error to encode content.\n", __func__)); 743 ret = NULL; 744 goto ON_EXIT; 745 } else if (Status == EFI_UNSUPPORTED) { 746 DEBUG ((DEBUG_MANAGEABILITY, "No content coding for %a! Use raw data instead.\n", HTTP_CONTENT_ENCODING_GZIP)); 747 Status = HttpIoSetHeader (HttpIoHeader, "Content-Encoding", HTTP_CONTENT_ENCODING_IDENTITY); 748 ASSERT_EFI_ERROR (Status); 749 } else { 750 Status = HttpIoSetHeader (HttpIoHeader, "Content-Encoding", HTTP_CONTENT_ENCODING_GZIP); 751 ASSERT_EFI_ERROR (Status); 752 } 753 754 RequestMsg->Data.Request = RequestData; 755 RequestMsg->HeaderCount = HttpIoHeader->HeaderCount; 756 RequestMsg->Headers = HttpIoHeader->Headers; 757 RequestMsg->BodyLength = EncodedContentLen; 758 RequestMsg->Body = (VOID *)EncodedContent; 759 760 ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); 761 762 // 763 // Step 4: call RESTEx to get response from REST service. 764 // 765 Status = service->RestEx->SendReceive (service->RestEx, RequestMsg, &ResponseMsg); 766 if (EFI_ERROR (Status)) { 767 ret = NULL; 768 goto ON_EXIT; 769 } 770 771 // 772 // Step 5: Return the HTTP StatusCode and Body message. 773 // 774 if (ResponseMsg.Data.Response != NULL) { 775 *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); 776 if (*StatusCode == NULL) { 777 ret = NULL; 778 goto ON_EXIT; 779 } 780 781 // 782 // The caller shall take the responsibility to free the buffer. 783 // 784 **StatusCode = ResponseMsg.Data.Response->StatusCode; 785 } 786 787 if ((ResponseMsg.Headers != NULL) && (Headers != NULL) && (HeaderCount != NULL)) { 788 *Headers = cloneHttpHeaders (&ResponseMsg, HeaderCount); 789 } 790 791 if (EncodedContent != content) { 792 FreePool (EncodedContent); 793 } 794 795 if ((ResponseMsg.BodyLength != 0) && (ResponseMsg.Body != NULL)) { 796 ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); 797 } else { 798 // 799 // There is no message body returned from server. 800 // 801 ret = NULL; 802 } 803 804 ON_EXIT: 805 if (url != NULL) { 806 free (url); 807 } 808 809 if (HttpIoHeader != NULL) { 810 HttpIoFreeHeader (HttpIoHeader); 811 } 812 813 if (RequestData != NULL) { 814 RestConfigFreeHttpRequestData (RequestData); 815 } 816 817 if (RequestMsg != NULL) { 818 FreePool (RequestMsg); 819 } 820 821 RestConfigFreeHttpMessage (&ResponseMsg, FALSE); 822 823 return ret; 824 } 825 826 json_t * 827 patchUriFromServiceEx ( 828 redfishService *service, 829 const char *uri, 830 const char *content, 831 EFI_HTTP_HEADER **Headers OPTIONAL, 832 UINTN *HeaderCount OPTIONAL, 833 EFI_HTTP_STATUS_CODE **StatusCode 834 ) 835 { 836 char *url; 837 json_t *ret; 838 HTTP_IO_HEADER *HttpIoHeader = NULL; 839 EFI_STATUS Status; 840 EFI_HTTP_REQUEST_DATA *RequestData = NULL; 841 EFI_HTTP_MESSAGE *RequestMsg = NULL; 842 EFI_HTTP_MESSAGE ResponseMsg; 843 CHAR8 ContentLengthStr[80]; 844 CHAR8 *EncodedContent; 845 UINTN EncodedContentLen; 846 847 if ((service == NULL) || (uri == NULL) || (content == NULL) || (StatusCode == NULL)) { 848 return NULL; 849 } 850 851 *StatusCode = NULL; 852 if (HeaderCount != NULL) { 853 *HeaderCount = 0; 854 } 855 856 if (Headers != NULL) { 857 *Headers = NULL; 858 } 584 859 585 860 url = makeUrlForService (service, uri); … … 588 863 } 589 864 590 DEBUG ((DEBUG_MANAGEABILITY, " libredfish: patchUriFromService(): %a\n", url));865 DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); 591 866 592 867 // … … 702 977 } 703 978 979 if ((ResponseMsg.Headers != NULL) && (Headers != NULL) && (HeaderCount != NULL)) { 980 *Headers = cloneHttpHeaders (&ResponseMsg, HeaderCount); 981 } 982 704 983 if (EncodedContent != content) { 705 984 FreePool (EncodedContent); … … 738 1017 739 1018 json_t * 740 postUriFromService (1019 postUriFromServiceEx ( 741 1020 redfishService *service, 742 1021 const char *uri, … … 744 1023 size_t contentLength, 745 1024 const char *contentType, 1025 EFI_HTTP_HEADER **Headers OPTIONAL, 1026 UINTN *HeaderCount OPTIONAL, 746 1027 EFI_HTTP_STATUS_CODE **StatusCode 747 1028 ) … … 764 1045 765 1046 *StatusCode = NULL; 1047 if (HeaderCount != NULL) { 1048 *HeaderCount = 0; 1049 } 1050 1051 if (Headers != NULL) { 1052 *Headers = NULL; 1053 } 766 1054 767 1055 url = makeUrlForService (service, uri); … … 770 1058 } 771 1059 772 DEBUG ((DEBUG_MANAGEABILITY, " libredfish: postUriFromService(): %a\n", url));1060 DEBUG ((DEBUG_MANAGEABILITY, "%a: %a\n", __func__, url)); 773 1061 774 1062 if (contentLength == 0) { … … 851 1139 Status = service->RestEx->SendReceive (service->RestEx, RequestMsg, &ResponseMsg); 852 1140 if (EFI_ERROR (Status)) { 853 goto ON_EXIT; 1141 // 1142 // If there is no response to handle, go to error exit. 1143 // 1144 if (ResponseMsg.Data.Response == NULL) { 1145 goto ON_EXIT; 1146 } 854 1147 } 855 1148 … … 869 1162 } 870 1163 1164 if ((ResponseMsg.Headers != NULL) && (Headers != NULL) && (HeaderCount != NULL)) { 1165 *Headers = cloneHttpHeaders (&ResponseMsg, HeaderCount); 1166 } 1167 871 1168 if ((ResponseMsg.BodyLength != 0) && (ResponseMsg.Body != NULL)) { 872 1169 ret = json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); … … 874 1171 875 1172 // 876 // Step 6: Parsing the HttpHeader to retrive the X-Auth-Token if the HTTP StatusCode is correct. 877 // 878 if ((ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_200_OK) || 879 (ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_204_NO_CONTENT)) 1173 // Step 6: Parsing the HttpHeader to retrieve the X-Auth-Token if the HTTP StatusCode is correct. 1174 // 1175 if ((ResponseMsg.Data.Response != NULL) && 1176 ((ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_200_OK) || 1177 (ResponseMsg.Data.Response->StatusCode == HTTP_STATUS_204_NO_CONTENT))) 880 1178 { 881 1179 HttpHeader = HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.Headers, "X-Auth-Token"); … … 887 1185 service->sessionToken = AllocateCopyPool (AsciiStrSize (HttpHeader->FieldValue), HttpHeader->FieldValue); 888 1186 } 889 890 /*891 //892 // Below opeation seems to be unnecessary.893 // Besides, the FieldValue for the Location is the full HTTP URI (Http://0.0.0.0:5000/XXX), so we can't use it as the894 // parameter of getUriFromService () directly.895 //896 HttpHeader = HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.Headers, "Location");897 if (HttpHeader != NULL) {898 ret = getUriFromService(service, HttpHeader->FieldValue);899 goto ON_EXIT;900 }901 */902 1187 } 903 1188 … … 922 1207 923 1208 return ret; 1209 } 1210 1211 json_t * 1212 getUriFromService ( 1213 redfishService *service, 1214 const char *uri, 1215 EFI_HTTP_STATUS_CODE **StatusCode 1216 ) 1217 { 1218 return getUriFromServiceEx (service, uri, NULL, NULL, StatusCode); 1219 } 1220 1221 json_t * 1222 patchUriFromService ( 1223 redfishService *service, 1224 const char *uri, 1225 const char *content, 1226 EFI_HTTP_STATUS_CODE **StatusCode 1227 ) 1228 { 1229 return patchUriFromServiceEx (service, uri, content, NULL, NULL, StatusCode); 1230 } 1231 1232 json_t * 1233 postUriFromService ( 1234 redfishService *service, 1235 const char *uri, 1236 const char *content, 1237 size_t contentLength, 1238 const char *contentType, 1239 EFI_HTTP_STATUS_CODE **StatusCode 1240 ) 1241 { 1242 return postUriFromServiceEx (service, uri, content, contentLength, contentType, NULL, NULL, StatusCode); 924 1243 } 925 1244 … … 1499 1818 1500 1819 url = (char *)malloc (strlen (service->host)+strlen (uri)+1); 1820 if (url == NULL) { 1821 return NULL; 1822 } 1823 1501 1824 strcpy (url, service->host); 1502 1825 strcat (url, uri); -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/Redfish.fdf.inc
r101291 r105670 7 7 # 8 8 # (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR> 9 # Copyright (c) 2023 , NVIDIA CORPORATION & AFFILIATES. All rights reserved.9 # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 10 10 # 11 11 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 21 21 INF RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf 22 22 INF MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf 23 INF RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf 23 24 !endif -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishComponents.dsc.inc
r101291 r105670 8 8 # 9 9 # (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR> 10 # Copyright (c) 2023 , NVIDIA CORPORATION & AFFILIATES. All rights reserved.10 # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 11 11 # 12 12 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 17 17 RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf 18 18 RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf 19 RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf 19 RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf { 20 <LibraryClasses> 21 SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf 22 } 20 23 RedfishPkg/RedfishCredentialDxe/RedfishCredentialDxe.inf 21 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf 24 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf { 25 <LibraryClasses> 26 SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf 27 } 22 28 RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf 23 29 RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf 24 30 MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf 31 RedfishPkg/RedfishHttpDxe/RedfishHttpDxe.inf 25 32 !endif -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c
r101291 r105670 18 18 // Variables for using RFI Redfish Discover Protocol 19 19 // 20 VOID *gEfiRedfishDiscoverRegistration; 21 EFI_HANDLE gEfiRedfishDiscoverControllerHandle = NULL; 22 EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol = NULL; 23 BOOLEAN gRedfishDiscoverActivated = FALSE; 24 BOOLEAN gRedfishServiceDiscovered = FALSE; 20 VOID *gEfiRedfishDiscoverRegistration; 21 EFI_HANDLE gEfiRedfishDiscoverControllerHandle = NULL; 22 EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol = NULL; 23 BOOLEAN gRedfishDiscoverActivated = FALSE; 24 BOOLEAN gRedfishServiceDiscovered = FALSE; 25 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *mNetworkInterfaces = NULL; 26 UINTN mNumberOfNetworkInterfaces; 27 EFI_EVENT mEdkIIRedfishHostInterfaceReadyEvent; 28 VOID *mEdkIIRedfishHostInterfaceRegistration; 25 29 26 30 /// … … 341 345 342 346 /** 347 Callback function executed when the gEdkIIRedfishHostInterfaceReadyProtocolGuid 348 protocol interface is installed. 349 350 @param[in] Event Event whose notification function is being invoked. 351 @param[in] Context Pointer to the Context buffer 352 353 **/ 354 VOID 355 EFIAPI 356 AcquireRedfishServiceOnNetworkInterfaceCallback ( 357 IN EFI_EVENT Event, 358 IN VOID *Context 359 ) 360 { 361 EFI_STATUS Status; 362 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; 363 UINTN NetworkInterfaceIndex; 364 EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; 365 366 ThisNetworkInterface = mNetworkInterfaces; 367 // 368 // Loop to discover Redfish service on each network interface. 369 // 370 for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < mNumberOfNetworkInterfaces; NetworkInterfaceIndex++) { 371 ThisRedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); 372 if (ThisRedfishDiscoveredToken == NULL) { 373 DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __func__)); 374 return; 375 } 376 377 ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE; 378 379 // 380 // Initial this Redfish Discovered Token 381 // 382 Status = gBS->CreateEvent ( 383 EVT_NOTIFY_SIGNAL, 384 TPL_CALLBACK, 385 RedfishServiceDiscoveredCallback, 386 (VOID *)ThisRedfishDiscoveredToken, 387 &ThisRedfishDiscoveredToken->Event 388 ); 389 if (EFI_ERROR (Status)) { 390 FreePool (ThisRedfishDiscoveredToken); 391 DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __func__)); 392 return; 393 } 394 395 // 396 // Acquire for Redfish service which is reported by 397 // Redfish Host Interface. 398 // 399 Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService ( 400 gEfiRedfishDiscoverProtocol, 401 gRedfishConfigData.Image, 402 ThisNetworkInterface, 403 EFI_REDFISH_DISCOVER_HOST_INTERFACE, 404 ThisRedfishDiscoveredToken 405 ); 406 407 // 408 // Free Redfish Discovered Token if Discover Instance was not created and 409 // Redfish Service Discovered Callback event was not triggered. 410 // 411 if ((ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound == 0) || 412 EFI_ERROR (ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances->Status)) 413 { 414 gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); 415 DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", __func__, ThisRedfishDiscoveredToken)); 416 FreePool (ThisRedfishDiscoveredToken); 417 } 418 419 ThisNetworkInterface++; 420 } 421 } 422 423 /** 343 424 Callback function executed when the EFI_REDFISH_DISCOVER_PROTOCOL 344 425 protocol interface is installed. 345 426 346 427 @param[in] Event Event whose notification function is being invoked. 347 @param[ out]Context Pointer to the Context buffer428 @param[in] Context Pointer to the Context buffer 348 429 349 430 **/ … … 352 433 RedfishDiscoverProtocolInstalled ( 353 434 IN EFI_EVENT Event, 354 OUT VOID *Context 355 ) 356 { 357 EFI_STATUS Status; 358 UINTN BufferSize; 359 EFI_HANDLE HandleBuffer; 360 UINTN NetworkInterfaceIndex; 361 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; 362 EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; 363 UINTN NumberOfNetworkInterfaces; 435 IN VOID *Context 436 ) 437 { 438 EFI_STATUS Status; 439 UINTN BufferSize; 440 EFI_HANDLE HandleBuffer; 441 VOID *RedfishHostInterfaceReadyProtocol; 364 442 365 443 DEBUG ((DEBUG_MANAGEABILITY, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __func__)); … … 402 480 gEfiRedfishDiscoverProtocol, 403 481 gRedfishConfigData.Image, 404 & NumberOfNetworkInterfaces,405 & ThisNetworkInterface482 &mNumberOfNetworkInterfaces, 483 &mNetworkInterfaces 406 484 ); 407 if (EFI_ERROR (Status) || ( NumberOfNetworkInterfaces == 0)) {485 if (EFI_ERROR (Status) || (mNumberOfNetworkInterfaces == 0)) { 408 486 DEBUG ((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __func__)); 409 487 return; … … 411 489 412 490 // 413 // Loop to discover Redfish service on each network interface. 414 // 415 for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < NumberOfNetworkInterfaces; NetworkInterfaceIndex++) { 416 ThisRedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); 417 if (ThisRedfishDiscoveredToken == NULL) { 418 DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __func__)); 419 return; 420 } 421 422 ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE; 423 424 // 425 // Initial this Redfish Discovered Token 426 // 491 // Check if Redfish Host Interface is ready or not. 492 // 493 Status = gBS->LocateProtocol (&gEdkIIRedfishHostInterfaceReadyProtocolGuid, NULL, &RedfishHostInterfaceReadyProtocol); 494 if (!EFI_ERROR (Status)) { 495 // Acquire Redfish service; 496 AcquireRedfishServiceOnNetworkInterfaceCallback ((EFI_EVENT)NULL, (VOID *)NULL); 497 } else { 427 498 Status = gBS->CreateEvent ( 428 499 EVT_NOTIFY_SIGNAL, 429 500 TPL_CALLBACK, 430 RedfishServiceDiscoveredCallback,431 (VOID *)ThisRedfishDiscoveredToken,432 & ThisRedfishDiscoveredToken->Event501 AcquireRedfishServiceOnNetworkInterfaceCallback, 502 NULL, 503 &mEdkIIRedfishHostInterfaceReadyEvent 433 504 ); 434 505 if (EFI_ERROR (Status)) { 435 FreePool (ThisRedfishDiscoveredToken); 436 DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __func__)); 506 DEBUG ((DEBUG_ERROR, "%a: Failed to create event for gEdkIIRedfishHostInterfaceReadyProtocolGuid installation.", __func__)); 437 507 return; 438 508 } 439 509 440 // 441 // Acquire for Redfish service which is reported by 442 // Redfish Host Interface. 443 // 444 Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService ( 445 gEfiRedfishDiscoverProtocol, 446 gRedfishConfigData.Image, 447 ThisNetworkInterface, 448 EFI_REDFISH_DISCOVER_HOST_INTERFACE, 449 ThisRedfishDiscoveredToken 450 ); 451 452 // 453 // Free Redfish Discovered Token if Discover Instance was not created and 454 // Redfish Service Discovered Callback event was not triggered. 455 // 456 if ((ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound == 0) || 457 EFI_ERROR (ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances->Status)) 458 { 459 gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); 460 DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", __func__, ThisRedfishDiscoveredToken)); 461 FreePool (ThisRedfishDiscoveredToken); 462 } 463 464 ThisNetworkInterface++; 510 Status = gBS->RegisterProtocolNotify ( 511 &gEdkIIRedfishHostInterfaceReadyProtocolGuid, 512 mEdkIIRedfishHostInterfaceReadyEvent, 513 &mEdkIIRedfishHostInterfaceRegistration 514 ); 515 if (EFI_ERROR (Status)) { 516 DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installation of gEdkIIRedfishHostInterfaceReadyProtocolGuid.", __func__)); 517 return; 518 } 465 519 } 466 520 … … 548 602 // Install UEFI Driver Model protocol(s). 549 603 // 550 Status = EfiLibInstall DriverBinding(604 Status = EfiLibInstallAllDriverProtocols2 ( 551 605 ImageHandle, 552 606 SystemTable, 553 607 &gRedfishConfigDriverBinding, 554 ImageHandle 608 ImageHandle, 609 &gRedfishConfigHandlerComponentName, 610 &gRedfishConfigHandlerComponentName2, 611 NULL, 612 NULL, 613 NULL, 614 NULL 555 615 ); 556 616 if (EFI_ERROR (Status)) { -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.h
r99404 r105670 25 25 // Protocol instances 26 26 // 27 extern EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding; 27 extern EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding; 28 extern EFI_COMPONENT_NAME_PROTOCOL gRedfishConfigHandlerComponentName; 29 extern EFI_COMPONENT_NAME2_PROTOCOL gRedfishConfigHandlerComponentName2; 28 30 29 31 extern REDFISH_CONFIG_DRIVER_DATA gRedfishConfigData; -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf
r101291 r105670 31 31 32 32 [Sources] 33 ComponentName.c 33 34 RedfishConfigHandlerDriver.h 34 35 RedfishConfigHandlerDriver.c … … 47 48 48 49 [Protocols] 49 gEfiRedfishDiscoverProtocolGuid ## CONSUMES50 gEfiRedfishDiscoverProtocolGuid ## CONSUMES 50 51 gEfiRestExServiceBindingProtocolGuid 51 gEfiRestExProtocolGuid ## CONSUMES 52 gEdkIIRedfishCredentialProtocolGuid ## CONSUMES 53 gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMES 52 gEfiRestExProtocolGuid ## CONSUMES 53 gEdkIIRedfishCredentialProtocolGuid ## CONSUMES 54 gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMES 55 gEdkIIRedfishHostInterfaceReadyProtocolGuid ## CONSUMES 54 56 55 57 [Guids] -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
r101291 r105670 7 7 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 8 8 Copyright (c) 2023, Ampere Computing LLC. All rights reserved.<BR> 9 Copyright (c) 2023, Mike Maslenkin <[email protected]> <BR> 9 10 10 11 SPDX-License-Identifier: BSD-2-Clause-Patent … … 41 42 ); 42 43 43 static REDFISH_DISCOVER_REQUIRED_PROTOCOL gRequiredProtocol[] = {44 static REDFISH_DISCOVER_REQUIRED_PROTOCOL mRequiredProtocol[] = { 44 45 { 45 46 ProtocolTypeTcp4, … … 199 200 Status = Tcp4->Configure (Tcp4, &Tcp4CfgData); 200 201 if (EFI_ERROR (Status)) { 201 DEBUG ((DEBUG_ERROR, "%a: Can't get subnet information\n", __func__)); 202 if (Status == EFI_NO_MAPPING) { 203 return EFI_SUCCESS; 204 } 205 206 DEBUG ((DEBUG_ERROR, "%a: Can't get subnet information: %r\n", __func__, Status)); 202 207 return Status; 203 208 } … … 205 210 Status = Tcp4->GetModeData (Tcp4, NULL, NULL, &IpModedata, NULL, NULL); 206 211 if (EFI_ERROR (Status)) { 207 DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information \n", __func__));212 DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information: %r\n", __func__, Status)); 208 213 return Status; 209 214 } … … 268 273 Status = Tcp6->GetModeData (Tcp6, NULL, NULL, &IpModedata, NULL, NULL); 269 274 if (EFI_ERROR (Status)) { 270 DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information \n", __func__));275 DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information: %r\n", __func__, Status)); 271 276 return Status; 272 277 } … … 319 324 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; 320 325 326 if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { 327 return NULL; 328 } 329 321 330 ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); 322 331 while (TRUE) { 323 if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) { 332 if ((MAC_COMPARE (ThisNetworkInterface, TargetNetworkInterface)) && 333 (VALID_TCP6 (TargetNetworkInterface, ThisNetworkInterface) || 334 VALID_TCP4 (TargetNetworkInterface, ThisNetworkInterface))) 335 { 324 336 return ThisNetworkInterface; 325 337 } … … 350 362 { 351 363 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; 364 365 if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { 366 return NULL; 367 } 352 368 353 369 ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); … … 396 412 ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); 397 413 while (TRUE) { 398 if ( CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {414 if (MAC_COMPARE (ThisNetworkInterface, TargetNetworkInterface)) { 399 415 break; 400 416 } … … 468 484 if (ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) { 469 485 return TRUE; 486 } 487 488 return FALSE; 489 } 490 491 /** 492 Check if Network Protocol Type matches with SMBIOS Type 42 IP Address Type. 493 494 @param[in] NetworkProtocolType The Network Protocol Type to check with. 495 @param[in] IpType The Host IP Address Type from SMBIOS Type 42. 496 **/ 497 STATIC 498 BOOLEAN 499 FilterProtocol ( 500 IN UINT32 NetworkProtocolType, 501 IN UINT8 IpType 502 ) 503 { 504 if (NetworkProtocolType == ProtocolTypeTcp4) { 505 return IpType != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4; 506 } 507 508 if (NetworkProtocolType == ProtocolTypeTcp6) { 509 return IpType != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6; 470 510 } 471 511 … … 508 548 509 549 Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h 510 if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) { 550 if (EFI_ERROR (Status) || (Data == NULL) || (DeviceDescriptor == NULL)) { 551 DEBUG ((DEBUG_ERROR, "%a: RedfishGetHostInterfaceProtocolData is failed.\n", __func__)); 552 return Status; 553 } else { 554 // Check IP Type and skip an unnecessary network protocol if does not match 555 if (FilterProtocol (Instance->NetworkInterface->NetworkProtocolType, Data->HostIpAddressFormat)) { 556 return EFI_UNSUPPORTED; 557 } 558 511 559 // 512 560 // Check if we can reach out Redfish service using this network interface. … … 523 571 524 572 if (MacCompareStatus != 0) { 573 DEBUG ((DEBUG_ERROR, "%a: MAC address is not matched.\n", __func__)); 574 DEBUG (( 575 DEBUG_ERROR, 576 " NetworkInterface: %02x %02x %02x %02x %02x %02x.\n", 577 Instance->NetworkInterface->MacAddress.Addr[0], 578 Instance->NetworkInterface->MacAddress.Addr[1], 579 Instance->NetworkInterface->MacAddress.Addr[2], 580 Instance->NetworkInterface->MacAddress.Addr[3], 581 Instance->NetworkInterface->MacAddress.Addr[4], 582 Instance->NetworkInterface->MacAddress.Addr[5] 583 )); 584 DEBUG (( 585 DEBUG_ERROR, 586 " Redfish Host interface: %02x %02x %02x %02x %02x %02x.\n", 587 DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[0], 588 DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[1], 589 DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[2], 590 DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[3], 591 DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[4], 592 DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[5] 593 )); 525 594 return EFI_UNSUPPORTED; 526 595 } … … 574 643 if (Data->RedfishServiceIpPort == 443) { 575 644 IsHttps = TRUE; 645 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service port: 443\n")); 646 } else { 647 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service port: 80\n")); 576 648 } 577 649 … … 642 714 643 715 /** 716 The function releases particular strings into the structure instance. 717 718 @param[in] Information EFI_REDFISH_DISCOVERED_INFORMATION 719 720 **/ 721 STATIC 722 VOID 723 FreeInformationData ( 724 IN EFI_REDFISH_DISCOVERED_INFORMATION *Information 725 ) 726 { 727 if (Information->Location != NULL) { 728 FreePool (Information->Location); 729 Information->Location = NULL; 730 } 731 732 if (Information->Uuid != NULL) { 733 FreePool (Information->Uuid); 734 Information->Uuid = NULL; 735 } 736 737 if (Information->Os != NULL) { 738 FreePool (Information->Os); 739 Information->Os = NULL; 740 } 741 742 if (Information->OsVersion != NULL) { 743 FreePool (Information->OsVersion); 744 Information->OsVersion = NULL; 745 } 746 747 if (Information->Product != NULL) { 748 FreePool (Information->Product); 749 Information->Product = NULL; 750 } 751 752 if (Information->ProductVer != NULL) { 753 FreePool (Information->ProductVer); 754 Information->ProductVer = NULL; 755 } 756 } 757 758 /** 759 The function initializes particular strings into the structure instance. 760 761 @param[in] Information EFI_REDFISH_DISCOVERED_INFORMATION 762 @param[in] IsIpv6 Flag indicating IP version 6 protocol is used 763 @param[in] RedfishVersion Redfish version. 764 @param[in] RedfishLocation Redfish location. 765 @param[in] Uuid Service UUID string. 766 @param[in] Os OS string. 767 @param[in] OsVer OS version string. 768 @param[in] Product Product string. 769 @param[in] ProductVer Product version string. 770 771 **/ 772 STATIC 773 VOID 774 InitInformationData ( 775 IN EFI_REDFISH_DISCOVERED_INFORMATION *Information, 776 IN BOOLEAN IsIpv6, 777 IN UINTN *RedfishVersion OPTIONAL, 778 IN CONST CHAR8 *RedfishLocation OPTIONAL, 779 IN CONST CHAR8 *Uuid OPTIONAL, 780 IN CONST CHAR8 *Os OPTIONAL, 781 IN CONST CHAR8 *OsVer OPTIONAL, 782 IN CONST CHAR8 *Product OPTIONAL, 783 IN CONST CHAR8 *ProductVer OPTIONAL 784 ) 785 { 786 UINTN AllocationSize; 787 788 if (RedfishVersion != NULL) { 789 Information->RedfishVersion = *RedfishVersion; 790 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service version: %d.\n", Information->RedfishVersion)); 791 } 792 793 if (RedfishLocation != NULL) { 794 AllocationSize = AsciiStrSize (RedfishLocation) * sizeof (CHAR16); 795 796 if (IsIpv6) { 797 AllocationSize += 2 * sizeof (CHAR16); // take into account '[' and ']' 798 } 799 800 Information->Location = AllocatePool (AllocationSize); 801 if (Information->Location != NULL) { 802 if (IsIpv6) { 803 UnicodeSPrintAsciiFormat (Information->Location, AllocationSize, "[%a]", RedfishLocation); 804 } else { 805 AsciiStrToUnicodeStrS (RedfishLocation, Information->Location, AllocationSize); 806 } 807 808 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", Information->Location)); 809 } else { 810 DEBUG (( 811 DEBUG_ERROR, 812 "%a: Can not allocate memory for Redfish service location: %a.\n", 813 __func__, 814 RedfishLocation 815 )); 816 } 817 } 818 819 if (Uuid != NULL) { 820 AllocationSize = AsciiStrSize (Uuid) * sizeof (CHAR16); 821 Information->Uuid = AllocatePool (AllocationSize); 822 if (Information->Uuid != NULL) { 823 AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize); 824 DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid)); 825 } else { 826 DEBUG (( 827 DEBUG_ERROR, 828 "%a: Can not allocate memory for Service UUID: %a.\n", 829 __func__, 830 Uuid 831 )); 832 } 833 } 834 835 if (Os != NULL) { 836 AllocationSize = AsciiStrSize (Os) * sizeof (CHAR16); 837 Information->Os = AllocatePool (AllocationSize); 838 if (Information->Os != NULL) { 839 AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize); 840 } else { 841 DEBUG (( 842 DEBUG_ERROR, 843 "%a: Can not allocate memory for Redfish service OS: %a.\n", 844 __func__, 845 Os 846 )); 847 } 848 } 849 850 if (OsVer != NULL) { 851 AllocationSize = AsciiStrSize (OsVer) * sizeof (CHAR16); 852 Information->OsVersion = AllocatePool (AllocationSize); 853 if (Information->OsVersion != NULL) { 854 AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize); 855 DEBUG (( 856 DEBUG_MANAGEABILITY, 857 "Redfish service OS: %s, Version:%s.\n", 858 Information->Os, 859 Information->OsVersion 860 )); 861 } else { 862 DEBUG (( 863 DEBUG_ERROR, 864 "%a: Can not allocate memory for Redfish OS Version:%a.\n", 865 __func__, 866 OsVer 867 )); 868 } 869 } 870 871 if (Product != NULL) { 872 AllocationSize = AsciiStrSize (Product) * sizeof (CHAR16); 873 Information->Product = AllocatePool (AllocationSize); 874 if (Information->Product != NULL) { 875 AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize); 876 } else { 877 DEBUG (( 878 DEBUG_ERROR, 879 "%a: Can not allocate memory for Redfish service product: %a.\n", 880 __func__, 881 Product 882 )); 883 } 884 } 885 886 if (ProductVer != NULL) { 887 AllocationSize = AsciiStrSize (ProductVer) * sizeof (CHAR16); 888 Information->ProductVer = AllocatePool (AllocationSize); 889 if (Information->ProductVer != NULL) { 890 AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, AllocationSize); 891 DEBUG (( 892 DEBUG_MANAGEABILITY, 893 "Redfish service product: %s, Version:%s.\n", 894 Information->Product, 895 Information->ProductVer 896 )); 897 } else { 898 DEBUG (( 899 DEBUG_ERROR, 900 "%a: Can not allocate memory for Redfish service product Version: %a.\n", 901 __func__, 902 ProductVer 903 )); 904 } 905 } 906 } 907 908 /** 644 909 The function adds a new found Redfish service to internal list and 645 910 notify client. … … 759 1024 } 760 1025 1026 if (Char16Uuid != NULL) { 1027 FreePool (Char16Uuid); 1028 } 1029 761 1030 if (NewFound || InfoRefresh) { 762 1031 if (!InfoRefresh) { … … 772 1041 return EFI_OUT_OF_RESOURCES; 773 1042 } 1043 } else { 1044 FreeInformationData (&DiscoveredInstance->Information); 774 1045 } 775 1046 … … 777 1048 778 1049 DiscoveredInstance->Information.UseHttps = UseHttps; 779 if (RedfishVersion != NULL) { 780 DiscoveredInstance->Information.RedfishVersion = *RedfishVersion; 781 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service version: %d.\n", DiscoveredInstance->Information.RedfishVersion)); 782 } 783 784 if (RedfishLocation != NULL) { 785 DiscoveredInstance->Information.Location = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof (CHAR16)); 786 AsciiStrToUnicodeStrS ((const CHAR8 *)RedfishLocation, DiscoveredInstance->Information.Location, AsciiStrSize ((const CHAR8 *)RedfishLocation) * sizeof (CHAR16)); 787 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n", DiscoveredInstance->Information.Location)); 788 } 789 790 if (Uuid != NULL) { 791 DiscoveredInstance->Information.Uuid = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16)); 792 AsciiStrToUnicodeStrS ((const CHAR8 *)Uuid, DiscoveredInstance->Information.Uuid, AsciiStrSize ((const CHAR8 *)Uuid) * sizeof (CHAR16)); 793 DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", DiscoveredInstance->Information.Uuid)); 794 } 795 796 if (Os != NULL) { 797 DiscoveredInstance->Information.Os = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Os) * sizeof (CHAR16)); 798 AsciiStrToUnicodeStrS ((const CHAR8 *)Os, DiscoveredInstance->Information.Os, AsciiStrSize ((const CHAR8 *)Os) * sizeof (CHAR16)); 799 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n", DiscoveredInstance->Information.Os, DiscoveredInstance->Information.OsVersion)); 800 } 801 802 if (OsVer != NULL) { 803 DiscoveredInstance->Information.OsVersion = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)OsVer) * sizeof (CHAR16)); 804 AsciiStrToUnicodeStrS ((const CHAR8 *)OsVer, DiscoveredInstance->Information.OsVersion, AsciiStrSize ((const CHAR8 *)OsVer) * sizeof (CHAR16)); 805 } 806 807 if ((Product != NULL) && (ProductVer != NULL)) { 808 DiscoveredInstance->Information.Product = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)Product) * sizeof (CHAR16)); 809 AsciiStrToUnicodeStrS ((const CHAR8 *)Product, DiscoveredInstance->Information.Product, AsciiStrSize ((const CHAR8 *)Product) * sizeof (CHAR16)); 810 DiscoveredInstance->Information.ProductVer = (CHAR16 *)AllocatePool (AsciiStrSize ((const CHAR8 *)ProductVer) * sizeof (CHAR16)); 811 AsciiStrToUnicodeStrS ((const CHAR8 *)ProductVer, DiscoveredInstance->Information.ProductVer, AsciiStrSize ((const CHAR8 *)ProductVer) * sizeof (CHAR16)); 812 DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.\n", DiscoveredInstance->Information.Product, DiscoveredInstance->Information.ProductVer)); 813 } 1050 1051 InitInformationData ( 1052 &DiscoveredInstance->Information, 1053 CheckIsIpVersion6 (NetworkInterface), 1054 RedfishVersion, 1055 RedfishLocation, 1056 Uuid, 1057 Os, 1058 OsVer, 1059 Product, 1060 ProductVer 1061 ); 814 1062 815 1063 if (RedfishLocation == NULL) { … … 835 1083 } 836 1084 } 837 }838 839 if (Char16Uuid != NULL) {840 FreePool ((VOID *)Char16Uuid);841 1085 } 842 1086 … … 878 1122 } 879 1123 880 RestExHttpConfigData->SendReceiveTimeout = 5000;1124 RestExHttpConfigData->SendReceiveTimeout = PcdGet32 (PcdRedfishSendReceiveTimeout); 881 1125 RestExHttpConfigData->HttpConfigData.HttpVersion = HttpVersion11; 882 1126 RestExHttpConfigData->HttpConfigData.LocalAddressIsIPv6 = CheckIsIpVersion6 (NetworkInterface); … … 912 1156 ); 913 1157 if (EFI_ERROR (Status)) { 914 DEBUG ((DEBUG_ERROR, "%a: REST EXconfigured..\n", __func__));1158 DEBUG ((DEBUG_ERROR, "%a: REST EX is not configured..\n", __func__)); 915 1159 DeleteRestEx = TRUE; 916 1160 goto EXIT_FREE_ALL; 1161 } else { 1162 DEBUG ((DEBUG_MANAGEABILITY, "%a: REST EX is configured..\n", __func__)); 917 1163 } 918 1164 … … 997 1243 998 1244 ProtocolType = Instance->NetworkProtocolType; 999 if (( gRequiredProtocol[ProtocolType].GetSubnetInfo != NULL) && (Instance->GotSubnetInfo == FALSE)) {1000 Status = gRequiredProtocol[ProtocolType].GetSubnetInfo (1245 if ((mRequiredProtocol[ProtocolType].GetSubnetInfo != NULL) && (Instance->GotSubnetInfo == FALSE)) { 1246 Status = mRequiredProtocol[ProtocolType].GetSubnetInfo ( 1001 1247 ImageHandle, 1002 1248 Instance 1003 1249 ); 1004 1250 if (EFI_ERROR (Status)) { 1005 DEBUG ((DEBUG_ERROR, "%a:Failed to get Subnet info mation.\n", __func__));1251 DEBUG ((DEBUG_ERROR, "%a:Failed to get Subnet information.\n", __func__)); 1006 1252 return Status; 1007 1253 } else { … … 1009 1255 if (CheckIsIpVersion6 (Instance)) { 1010 1256 if (Instance->SubnetAddrInfoIPv6Number == 0) { 1011 DEBUG ((DEBUG_ ERROR, "%a: There is no Subnet infomation for IPv6 network interface.\n", __func__));1257 DEBUG ((DEBUG_WARN, "%a: There is no Subnet information for IPv6 network interface.\n", __func__)); 1012 1258 return EFI_NOT_FOUND; 1013 1259 } … … 1099 1345 ) 1100 1346 { 1347 EFI_STATUS Status; 1101 1348 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterfaceIntn; 1102 1349 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; 1103 1350 EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; 1351 1352 DEBUG ((DEBUG_MANAGEABILITY, "%a: Entry.\n", __func__)); 1104 1353 1105 1354 if ((This == NULL) || (NetworkIntfInstances == NULL) || (NumberOfNetworkIntfs == NULL) || … … 1144 1393 1145 1394 CopyMem ((VOID *)&ThisNetworkInterface->MacAddress, &ThisNetworkInterfaceIntn->MacAddress, ThisNetworkInterfaceIntn->HwAddressSize); 1146 NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info. 1147 if (!ThisNetworkInterface->IsIpv6) { 1148 IP4_COPY_ADDRESS (&ThisNetworkInterface->SubnetId.v4, &ThisNetworkInterfaceIntn->SubnetAddr.v4); // IPv4 subnet information. 1149 } else { 1150 IP6_COPY_ADDRESS (&ThisNetworkInterface->SubnetId.v6, &ThisNetworkInterfaceIntn->SubnetAddr.v6); // IPv6 subnet information in IPv6 address information. 1151 } 1152 1153 ThisNetworkInterface->SubnetPrefixLength = ThisNetworkInterfaceIntn->SubnetPrefixLength; 1154 ThisNetworkInterface->VlanId = ThisNetworkInterfaceIntn->VlanId; 1395 // 1396 // If Get Subnet Info failed then skip this interface 1397 // 1398 Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info 1399 if (!EFI_ERROR (Status)) { 1400 if (!ThisNetworkInterface->IsIpv6) { 1401 IP4_COPY_ADDRESS (&ThisNetworkInterface->SubnetId.v4, &ThisNetworkInterfaceIntn->SubnetAddr.v4); // IPv4 subnet information. 1402 } else { 1403 IP6_COPY_ADDRESS (&ThisNetworkInterface->SubnetId.v6, &ThisNetworkInterfaceIntn->SubnetAddr.v6); // IPv6 subnet information in IPv6 address information. 1404 } 1405 1406 ThisNetworkInterface->SubnetPrefixLength = ThisNetworkInterfaceIntn->SubnetPrefixLength; 1407 } 1408 1409 ThisNetworkInterface->VlanId = ThisNetworkInterfaceIntn->VlanId; 1155 1410 RestExInstance->NumberOfNetworkInterfaces++; 1156 1411 if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) { … … 1227 1482 if (TargetNetworkInterface != NULL) { 1228 1483 TargetNetworkInterfaceInternal = GetTargetNetworkInterfaceInternal (TargetNetworkInterface); 1229 NumNetworkInterfaces = 1; 1484 if (TargetNetworkInterfaceInternal == NULL) { 1485 DEBUG ((DEBUG_ERROR, "%a:No network interface on platform.\n", __func__)); 1486 return EFI_UNSUPPORTED; 1487 } 1488 1489 NumNetworkInterfaces = 1; 1230 1490 } else { 1231 1491 TargetNetworkInterfaceInternal = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); … … 1257 1517 // RedfishServiceGetNetworkInterfaces hasn't been called yet. 1258 1518 // 1259 NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle); 1519 Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle); 1520 if (EFI_ERROR (Status1)) { 1521 // 1522 // Get subnet information could be failed for EFI_REDFISH_DISCOVER_HOST_INTERFACE case. 1523 // We will configure network in AddAndSignalNewRedfishService. So don't skip this 1524 // target network interface. 1525 // 1526 if ((Flags & EFI_REDFISH_DISCOVER_HOST_INTERFACE) == 0) { 1527 DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__)); 1528 FreePool (Instance); 1529 continue; 1530 } 1531 } 1532 1260 1533 NewInstance = TRUE; 1261 1534 } … … 1323 1596 ) 1324 1597 { 1598 DEBUG ((DEBUG_MANAGEABILITY, "%a: Entry.\n", __func__)); 1325 1599 // This function is used to abort Redfish service discovery through SSDP 1326 1600 // on the network interface. SSDP is optionally suppoted by EFI_REDFISH_DISCOVER_PROTOCOL, … … 1351 1625 EFI_REDFISH_DISCOVERED_INSTANCE *ThisRedfishInstance; 1352 1626 EFI_REDFISH_DISCOVERED_INTERNAL_LIST *DiscoveredRedfishInstance; 1627 1628 DEBUG ((DEBUG_MANAGEABILITY, "%a: Entry.\n", __func__)); 1353 1629 1354 1630 if (IsListEmpty (&mRedfishInstanceList)) { … … 1364 1640 if (DiscoveredRedfishInstance->Instance == ThisRedfishInstance) { 1365 1641 RemoveEntryList (&DiscoveredRedfishInstance->NextInstance); 1366 if (ThisRedfishInstance->Information.Location != NULL) { 1367 FreePool (ThisRedfishInstance->Information.Location); 1368 } 1369 1370 if (ThisRedfishInstance->Information.Uuid != NULL) { 1371 FreePool (ThisRedfishInstance->Information.Uuid); 1372 } 1373 1374 if (ThisRedfishInstance->Information.Os != NULL) { 1375 FreePool (ThisRedfishInstance->Information.Os); 1376 } 1377 1378 if (ThisRedfishInstance->Information.OsVersion != NULL) { 1379 FreePool (ThisRedfishInstance->Information.OsVersion); 1380 } 1381 1382 if (ThisRedfishInstance->Information.Product != NULL) { 1383 FreePool (ThisRedfishInstance->Information.Product); 1384 } 1385 1386 if (ThisRedfishInstance->Information.ProductVer != NULL) { 1387 FreePool (ThisRedfishInstance->Information.ProductVer); 1388 } 1389 1642 FreeInformationData (&ThisRedfishInstance->Information); 1390 1643 FreePool ((VOID *)ThisRedfishInstance); 1391 1644 goto ReleaseNext; … … 1503 1756 Status = gBS->UninstallProtocolInterface ( 1504 1757 ThisNetworkInterface->OpenDriverControllerHandle, 1505 gRequiredProtocol[ThisNetworkInterface->NetworkProtocolType].DiscoveredProtocolGuid,1758 mRequiredProtocol[ThisNetworkInterface->NetworkProtocolType].DiscoveredProtocolGuid, 1506 1759 &ThisNetworkInterface->NetworkInterfaceProtocolInfo.ProtocolDiscoverId 1507 1760 ); … … 1534 1787 UINTN ListCount; 1535 1788 1536 ListCount = (sizeof ( gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));1789 ListCount = (sizeof (mRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL)); 1537 1790 for (Index = 0; Index < ListCount; Index++) { 1538 1791 Status = gBS->OpenProtocol ( 1539 1792 ControllerHandle, 1540 gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,1793 mRequiredProtocol[Index].RequiredServiceBindingProtocolGuid, 1541 1794 NULL, 1542 1795 This->DriverBindingHandle, … … 1544 1797 EFI_OPEN_PROTOCOL_TEST_PROTOCOL 1545 1798 ); 1799 if (EFI_ERROR (Status)) { 1800 return EFI_UNSUPPORTED; 1801 } 1802 1803 Status = gBS->OpenProtocol ( 1804 ControllerHandle, 1805 mRequiredProtocol[Index].DiscoveredProtocolGuid, 1806 (VOID **)&Id, 1807 This->DriverBindingHandle, 1808 ControllerHandle, 1809 EFI_OPEN_PROTOCOL_GET_PROTOCOL 1810 ); 1546 1811 if (!EFI_ERROR (Status)) { 1547 Status = gBS->OpenProtocol ( 1548 ControllerHandle, 1549 gRequiredProtocol[Index].DiscoveredProtocolGuid, 1550 (VOID **)&Id, 1551 This->DriverBindingHandle, 1552 ControllerHandle, 1553 EFI_OPEN_PROTOCOL_GET_PROTOCOL 1554 ); 1555 if (EFI_ERROR (Status)) { 1556 if (Index == ListCount - 1) { 1557 DEBUG ((DEBUG_ERROR, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle)); 1558 return EFI_SUCCESS; 1559 } 1560 } 1561 } 1562 } 1563 1564 return EFI_UNSUPPORTED; 1812 // Already installed 1813 return EFI_UNSUPPORTED; 1814 } 1815 } 1816 1817 DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle)); 1818 return EFI_SUCCESS; 1565 1819 } 1566 1820 … … 1597 1851 EFI_TPL OldTpl; 1598 1852 BOOLEAN NewNetworkInterfaceInstalled; 1599 1853 UINTN ListCount; 1854 1855 ListCount = (sizeof (mRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL)); 1600 1856 NewNetworkInterfaceInstalled = FALSE; 1601 1857 Index = 0; 1602 do { 1858 1859 for (Index = 0; Index < ListCount; Index++) { 1603 1860 Status = gBS->OpenProtocol ( 1604 1861 // Already in list? 1605 1862 ControllerHandle, 1606 gRequiredProtocol[Index].DiscoveredProtocolGuid,1863 mRequiredProtocol[Index].DiscoveredProtocolGuid, 1607 1864 (VOID **)&Id, 1608 1865 This->DriverBindingHandle, … … 1611 1868 ); 1612 1869 if (!EFI_ERROR (Status)) { 1613 Index++;1614 if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {1615 break;1616 }1617 1618 1870 continue; 1619 1871 } … … 1621 1873 Status = gBS->OpenProtocol ( 1622 1874 ControllerHandle, 1623 gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,1875 mRequiredProtocol[Index].RequiredServiceBindingProtocolGuid, 1624 1876 &TempInterface, 1625 1877 This->DriverBindingHandle, … … 1628 1880 ); 1629 1881 if (EFI_ERROR (Status)) { 1630 Index++;1631 if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {1632 break;1633 }1634 1635 1882 continue; 1636 1883 } 1637 1884 1638 if ( gRequiredProtocol[Index].ProtocolType != ProtocolTypeRestEx) {1885 if (mRequiredProtocol[Index].ProtocolType != ProtocolTypeRestEx) { 1639 1886 OldTpl = gBS->RaiseTPL (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL); 1640 Status = CreateRedfishDiscoverNetworkInterface (ControllerHandle, gRequiredProtocol[Index].ProtocolType, &IsNew, &NetworkInterface);1887 Status = CreateRedfishDiscoverNetworkInterface (ControllerHandle, mRequiredProtocol[Index].ProtocolType, &IsNew, &NetworkInterface); 1641 1888 if (EFI_ERROR (Status)) { 1642 1889 gBS->RestoreTPL (OldTpl); … … 1644 1891 } 1645 1892 1646 NetworkInterface->NetworkProtocolType = gRequiredProtocol[Index].ProtocolType;1893 NetworkInterface->NetworkProtocolType = mRequiredProtocol[Index].ProtocolType; 1647 1894 NetworkInterface->OpenDriverAgentHandle = This->DriverBindingHandle; 1648 1895 NetworkInterface->OpenDriverControllerHandle = ControllerHandle; 1649 CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolGuid, gRequiredProtocol[Index].RequiredProtocolGuid);1650 CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolServiceGuid, gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid);1896 CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolGuid, mRequiredProtocol[Index].RequiredProtocolGuid); 1897 CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolServiceGuid, mRequiredProtocol[Index].RequiredServiceBindingProtocolGuid); 1651 1898 ProtocolDiscoverIdPtr = &NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolDiscoverId; 1652 1899 OpenDriverAgentHandle = NetworkInterface->OpenDriverAgentHandle; … … 1686 1933 Status = gBS->InstallProtocolInterface ( 1687 1934 &ControllerHandle, 1688 gRequiredProtocol[Index].DiscoveredProtocolGuid,1935 mRequiredProtocol[Index].DiscoveredProtocolGuid, 1689 1936 EFI_NATIVE_INTERFACE, 1690 1937 ProtocolDiscoverIdPtr 1691 1938 ); 1692 1939 if (EFI_ERROR (Status)) { 1693 Index++;1694 if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {1695 break;1696 }1697 1698 1940 continue; 1699 1941 } … … 1705 1947 ControllerHandle, 1706 1948 This->ImageHandle, 1707 gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,1949 mRequiredProtocol[Index].RequiredServiceBindingProtocolGuid, 1708 1950 HandleOfProtocolInterfacePtr 1709 1951 ); … … 1711 1953 Status = gBS->OpenProtocol ( 1712 1954 *HandleOfProtocolInterfacePtr, 1713 gRequiredProtocol[Index].RequiredProtocolGuid,1955 mRequiredProtocol[Index].RequiredProtocolGuid, 1714 1956 Interface, 1715 1957 OpenDriverAgentHandle, … … 1718 1960 ); 1719 1961 if (!EFI_ERROR (Status)) { 1720 if (( gRequiredProtocol[Index].ProtocolType == ProtocolTypeRestEx)) {1962 if ((mRequiredProtocol[Index].ProtocolType == ProtocolTypeRestEx)) { 1721 1963 // Install Redfish Discover Protocol when EFI REST EX protocol is discovered. 1722 1964 // This ensures EFI REST EX is ready while the consumer of EFI_REDFISH_DISCOVER_PROTOCOL … … 1752 1994 } else { 1753 1995 DEBUG ((DEBUG_MANAGEABILITY, "%a: Not REST EX, continue with next\n", __func__)); 1754 Index++;1755 if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {1756 break;1757 }1758 1759 1996 continue; 1760 1997 } … … 1762 1999 1763 2000 return Status; 1764 } else { 1765 Index++; 1766 if (Index == (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) { 1767 break; 1768 } 1769 1770 continue; 1771 } 1772 } while (Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL))); 2001 } 2002 } 1773 2003 1774 2004 return EFI_DEVICE_ERROR; … … 1845 2075 EFI_REDFISH_DISCOVER_PROTOCOL *RedfishDiscoverProtocol; 1846 2076 1847 for (Index = 0; Index < (sizeof ( gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL)); Index++) {2077 for (Index = 0; Index < (sizeof (mRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL)); Index++) { 1848 2078 Status = gBS->HandleProtocol ( 1849 2079 ControllerHandle, 1850 gRequiredProtocol[Index].RequiredProtocolGuid,2080 mRequiredProtocol[Index].RequiredProtocolGuid, 1851 2081 (VOID **)&Interface 1852 2082 ); 1853 2083 if (!EFI_ERROR (Status)) { 1854 if ( gRequiredProtocol[Index].ProtocolType != ProtocolTypeRestEx) {2084 if (mRequiredProtocol[Index].ProtocolType != ProtocolTypeRestEx) { 1855 2085 if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { 1856 2086 return EFI_NOT_FOUND; … … 1868 2098 ThisBindingProtocol, 1869 2099 ControllerHandle, 1870 & gRequiredProtocol[Index],2100 &mRequiredProtocol[Index], 1871 2101 ThisNetworkInterface->OpenDriverAgentHandle, 1872 2102 ThisNetworkInterface->OpenDriverControllerHandle … … 1931 2161 ThisBindingProtocol, 1932 2162 ControllerHandle, 1933 & gRequiredProtocol[Index],2163 &mRequiredProtocol[Index], 1934 2164 RestExInstance->OpenDriverAgentHandle, 1935 2165 RestExInstance->OpenDriverControllerHandle … … 2053 2283 ) 2054 2284 { 2285 DEBUG ((DEBUG_MANAGEABILITY, "%a:Entry.\n", __func__)); 2055 2286 return BuildupNetworkInterface (This, ControllerHandle); 2056 2287 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf
r101291 r105670 55 55 [Pcd] 56 56 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDiscoverAccessModeInBand ## CONSUMES 57 57 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishSendReceiveTimeout ## CONSUEMS -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
r101291 r105670 39 39 #define REDFISH_DISCOVER_VERSION 0x00010000 40 40 #define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY 41 42 #define MAC_COMPARE(This, Target) (CompareMem ((VOID *)&(This)->MacAddress, &(Target)->MacAddress, (This)->HwAddressSize) == 0) 43 #define VALID_TCP6(Target, This) ((Target)->IsIpv6 && ((This)->NetworkProtocolType == ProtocolTypeTcp6)) 44 #define VALID_TCP4(Target, This) (!(Target)->IsIpv6 && ((This)->NetworkProtocolType == ProtocolTypeTcp4)) 45 #define REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET ((UINT16)(UINTN)(&((SMBIOS_TABLE_TYPE42 *)0)->InterfaceTypeSpecificDataLength)) 46 #define REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET ((UINT16)(UINTN)(&((REDFISH_OVER_IP_PROTOCOL_DATA *)0)->RedfishServiceHostnameLength)) 41 47 42 48 // -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
r101291 r105670 57 57 if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) { 58 58 ASSERT (Record->Length >= 9); 59 Offset = 5;59 Offset = REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET; 60 60 RecordTmp = (UINT8 *)Record + Offset; 61 61 // … … 71 71 if ((*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) || (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) { 72 72 if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) { 73 // According to Redfish Host Interface specification, add additional one byte for Device Type field. 73 74 if (SpecificDataLen != sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) { 74 75 ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1); … … 76 77 } 77 78 } else { 79 // According to Redfish Host Interface specification, add additional one byte for Device Type field. 78 80 if (SpecificDataLen != sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) { 79 81 ASSERT (SpecificDataLen == sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1); … … 106 108 // Redfish Over IP protocol is wrong. 107 109 // 108 if ((*(RecordTmp + 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) { 110 if ((*(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) { 111 DEBUG (( 112 DEBUG_ERROR, 113 "%a: Length of protocol specific data is not match: %d != ProtocolLength(%d).\n", 114 __func__, 115 *(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1, 116 ProtocolLength 117 )); 109 118 return EFI_SECURITY_VIOLATION; 110 119 } … … 115 124 // 116 125 if (Offset > mType42Record->Hdr.Length) { 126 DEBUG (( 127 DEBUG_ERROR, 128 "%a: Offset (%d) > mType42Record->Hdr.Length (%d).\n", 129 __func__, 130 Offset, 131 mType42Record->Hdr.Length 132 )); 117 133 return EFI_SECURITY_VIOLATION; 118 134 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
r101291 r105670 54 54 EFI_SMBIOS_PROTOCOL *Smbios; 55 55 EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle; 56 56 EFI_HANDLE Handle; 57 58 Handle = NULL; 57 59 // 58 60 // Get platform Redfish host interface device type descriptor data. … … 227 229 } 228 230 231 // 232 // Install Redfish Host Interface ready protocol. 233 // 234 Status = gBS->InstallProtocolInterface ( 235 &Handle, 236 &gEdkIIRedfishHostInterfaceReadyProtocolGuid, 237 EFI_NATIVE_INTERFACE, 238 (VOID *)NULL 239 ); 240 if (EFI_ERROR (Status)) { 241 DEBUG ((DEBUG_ERROR, "Failed to install gEdkIIRedfishHostInterfaceReadyProtocolGuid.\n")); 242 DEBUG ((DEBUG_ERROR, "PlatformConfigHandler driver may not be triggered to acquire Redfish service.\n")); 243 } 244 245 // Set Status to EFI_SUCCESS that indicates SMBIOS 42 record was installed 246 // on the platform sucessfully. 229 247 Status = EFI_SUCCESS; 230 248 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
r89983 r105670 44 44 45 45 [Protocols] 46 gEfiSmbiosProtocolGuid ## TO_START 46 gEfiSmbiosProtocolGuid ## TO_START 47 gEdkIIRedfishHostInterfaceReadyProtocolGuid ## PRODUCED 47 48 48 49 [Depex] -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishLibs.dsc.inc
r101291 r105670 7 7 # 8 8 # (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 9 # Copyright (c) 2023 , NVIDIA CORPORATION & AFFILIATES. All rights reserved.9 # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 10 10 # 11 11 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 15 15 RestExLib|RedfishPkg/Library/DxeRestExLib/DxeRestExLib.inf 16 16 Ucs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf 17 SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf18 17 RedfishCrtLib|RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf 19 18 JsonLib|RedfishPkg/Library/JsonLib/JsonLib.inf … … 23 22 HiiUtilityLib|RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.inf 24 23 RedfishPlatformConfigLib|RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.inf 24 RedfishHttpLib|RedfishPkg/Library/RedfishHttpLib/RedfishHttpLib.inf 25 25 !endif 26 26 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPkg.ci.yaml
r99404 r105670 3 3 # 4 4 # (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 5 # Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 6 # SPDX-License-Identifier: BSD-2-Clause-Patent 6 7 ## 7 8 { 9 "PrEval": { 10 "DscPath": "RedfishPkg.dsc", 11 }, 8 12 "LicenseCheck": { 9 13 "IgnoreFiles": [] … … 36 40 "PrivateInclude/Crt/time.h", 37 41 "PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c", 42 "PrivateLibrary/RedfishCrtLib/Ia32/MathFtol.c", 38 43 "Include/Library/RedfishCrtLib.h", 39 44 ## -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPkg.dec
r101291 r105670 5 5 # (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 6 6 # Copyright (c) 2023, American Megatrends International LLC. 7 # Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 7 # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 8 # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 8 9 # 9 10 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 70 71 RedfishPlatformConfigLib|Include/Library/RedfishPlatformConfigLib.h 71 72 73 ## @libraryclass Provides the library functions to access Redfish HTTP 74 # protocol. 75 # 76 RedfishHttpLib|Include/Library/RedfishHttpLib.h 77 72 78 [LibraryClasses.Common.Private] 73 79 ## @libraryclass Provides the private C runtime library functions. … … 90 96 ## Include/Protocol/EdkIIRedfishPlatformConfig.h 91 97 gEdkIIRedfishPlatformConfigProtocolGuid = { 0X4D94A7C7, 0X4CE4, 0X4A84, { 0X88, 0XC1, 0X33, 0X0C, 0XD4, 0XA3, 0X47, 0X67 } } 98 99 # Redfish Host Interface ready notification protocol 100 gEdkIIRedfishHostInterfaceReadyProtocolGuid = { 0xC3F6D062, 0x3D38, 0x4EA4, { 0x92, 0xB1, 0xE8, 0xF8, 0x02, 0x27, 0x63, 0xDF } } 101 102 ## Include/Protocol/EdkIIRedfishHttpProtocol.h 103 gEdkIIRedfishHttpProtocolGuid = { 0x58a0f47e, 0xf45f, 0x4d44, { 0x89, 0x5b, 0x2a, 0xfe, 0xb0, 0x80, 0x15, 0xe2 } } 92 104 93 105 [Guids] … … 139 151 # 140 152 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServiceUuid|L"00000000-0000-0000-0000-000000000000"|VOID*|0x00001006 153 # Use PCD to declare the Redfish service port, default set to port 443. 154 # Platform can overide this value in platform DSC file. 155 # 156 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServicePort|443|UINT16|0x00001007 141 157 # 142 158 # This PCD indicates that if BMC bootstrap credential service will be disabled by BIOS or not. 143 159 # 144 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDisableBootstrapCredentialService|FALSE|BOOLEAN|0x00001007 160 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDisableBootstrapCredentialService|FALSE|BOOLEAN|0x00001008 161 # 162 # The EFI_REST_EX_HTTP_CONFIG_DATA.SendReceiveTimeout value that RedfishDiscoverDxe driver 163 # set to EFI_REST_EX_PROTOCOL. 164 # 165 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishSendReceiveTimeout|5000|UINT32|0x00001009 166 # 167 # This PCD string is introduced for platform developer to set the encoding method supported by BMC Redfish. 168 # Currently only "None" and "gzip" are supported. 169 # 170 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishServiceContentEncoding|"None"|VOID*|0x0000100A 171 # 172 # Use below PCDs to control Redfhs HTTP protocol. 173 # 174 ## The number of retry when HTTP GET request failed. If the value is 0, there is no retry enabled. 175 gEfiRedfishPkgTokenSpaceGuid.PcdHttpGetRetry|0|UINT16|0x0000100B 176 ## The number of retry when HTTP PUT request failed. If the value is 0, there is no retry enabled. 177 gEfiRedfishPkgTokenSpaceGuid.PcdHttpPutRetry|0|UINT16|0x0000100C 178 ## The number of retry when HTTP PATCH request failed. If the value is 0, there is no retry enabled. 179 gEfiRedfishPkgTokenSpaceGuid.PcdHttpPatchRetry|0|UINT16|0x0000100D 180 ## The number of retry when HTTP POST request failed. If the value is 0, there is no retry enabled. 181 gEfiRedfishPkgTokenSpaceGuid.PcdHttpPostRetry|0|UINT16|0x0000100E 182 ## The number of retry when HTTP DELETE request failed. If the value is 0, there is no retry enabled. 183 gEfiRedfishPkgTokenSpaceGuid.PcdHttpDeleteRetry|0|UINT16|0x0000100F 184 ## The number of second to wait before driver retry HTTP request. If the value is 0, there is no wait before next retry. 185 gEfiRedfishPkgTokenSpaceGuid.PcdHttpRetryWaitInSecond|1|UINT16|0x00001010 186 ## This is used to disable Redfish HTTP cache function and every request will be sent to Redfish service. 187 gEfiRedfishPkgTokenSpaceGuid.PcdHttpCacheDisabled|FALSE|BOOLEAN|0x00001011 188 # 189 # Redfish debug catagories 190 # To enable the debug message for the entire edk2 Redfish implementation, below PCDs must be set. 191 # DEBUG_MANAGEABILITY must be set PcdDebugPrintErrorLevel. 192 # 193 # 0x0000000000000001 RedfishPlatformConfigDxe driver debug enabled. 194 # 195 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishDebugCategory|0|UINT64|0x00001012 196 # 197 # Redfish RedfishPlatformConfigDxe Debug Properties 198 # 0x00000001 x-UEFI-redfish string database message enabled 199 # 0x00000002 Debug Message for dumping formset 200 # 0x00000004 Debug Message for x-UEFI-redfish searching result 201 # 0x00000008 Debug Message for x-UEFI-redfish Regular Expression searching result 202 # 203 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigDebugProperty|0|UINT32|0x00001013 204 # 205 # RedfishPlatformConfigDxe feature enablement 206 # 0x00000001 Enable building Redfish Attribute Registry menu path. 207 # 0x00000002 Allow supressed HII option to be exposed on Redfish. 208 # 209 # Redfish RedfishPlatformConfigDxe feature Properties 210 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigFeatureProperty|0|UINT32|0x00001014 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPkg.dsc
r101291 r105670 5 5 # (C) Copyright 2021 Hewlett-Packard Enterprise Development LP. 6 6 # Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. 7 # Copyright (c) 2023 , NVIDIA CORPORATION & AFFILIATES. All rights reserved.7 # Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 8 8 # 9 9 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 46 46 RedfishPlatformCredentialLib|RedfishPkg/Library/PlatformCredentialLibNull/PlatformCredentialLibNull.inf 47 47 RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf 48 ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf 49 SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf 48 50 49 51 # NULL instance of IPMI related library. … … 73 75 RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.inf 74 76 RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.inf 77 RedfishPkg/Library/RedfishHttpLib/RedfishHttpLib.inf 75 78 76 79 !include RedfishPkg/Redfish.dsc.inc -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c
r101291 r105670 3 3 4 4 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR> 5 Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 6 7 7 8 SPDX-License-Identifier: BSD-2-Clause-Patent … … 205 206 206 207 /** 208 Debug dump HII statement value. 209 210 @param[in] ErrorLevel DEBUG macro error level 211 @param[in] Value HII statement value to dump 212 @param[in] Message Debug message 213 214 @retval EFI_SUCCESS Dump HII statement value successfully 215 @retval Others Errors occur 216 217 **/ 218 EFI_STATUS 219 DumpHiiStatementValue ( 220 IN UINTN ErrorLevel, 221 IN HII_STATEMENT_VALUE *Value, 222 IN CHAR8 *Message OPTIONAL 223 ) 224 { 225 UINT64 Data; 226 227 if (Value == NULL) { 228 return EFI_INVALID_PARAMETER; 229 } 230 231 switch (Value->Type) { 232 case EFI_IFR_TYPE_NUM_SIZE_8: 233 Data = Value->Value.u8; 234 break; 235 case EFI_IFR_TYPE_NUM_SIZE_16: 236 Data = Value->Value.u16; 237 break; 238 case EFI_IFR_TYPE_NUM_SIZE_32: 239 Data = Value->Value.u32; 240 break; 241 case EFI_IFR_TYPE_NUM_SIZE_64: 242 Data = Value->Value.u64; 243 break; 244 case EFI_IFR_TYPE_BOOLEAN: 245 Data = (Value->Value.b ? 1 : 0); 246 break; 247 default: 248 DEBUG ((ErrorLevel, "%a: unsupported type: 0x%x\n", __func__, Value->Type)); 249 return EFI_UNSUPPORTED; 250 } 251 252 if (IS_EMPTY_STRING (Message)) { 253 DEBUG ((ErrorLevel, "0x%lx\n", Data)); 254 } else { 255 DEBUG ((ErrorLevel, "%a: 0x%lx\n", Message, Data)); 256 } 257 258 return EFI_SUCCESS; 259 } 260 261 /** 262 Debug dump HII statement prompt string. 263 264 @param[in] ErrorLevel DEBUG macro error level 265 @param[in] HiiHandle HII handle instance 266 @param[in] HiiStatement HII statement 267 @param[in] Message Debug message 268 269 @retval EFI_SUCCESS Dump HII statement string successfully 270 @retval Others Errors occur 271 272 **/ 273 EFI_STATUS 274 DumpHiiStatementPrompt ( 275 IN UINTN ErrorLevel, 276 IN EFI_HII_HANDLE HiiHandle, 277 IN HII_STATEMENT *HiiStatement, 278 IN CHAR8 *Message OPTIONAL 279 ) 280 { 281 EFI_STRING String; 282 283 if ((HiiHandle == NULL) || (HiiStatement == NULL)) { 284 return EFI_INVALID_PARAMETER; 285 } 286 287 if (HiiStatement->Prompt == 0) { 288 return EFI_NOT_FOUND; 289 } 290 291 String = HiiGetString (HiiHandle, HiiStatement->Prompt, NULL); 292 if (String == NULL) { 293 return EFI_NOT_FOUND; 294 } 295 296 if (IS_EMPTY_STRING (Message)) { 297 DEBUG ((ErrorLevel, "%s\n", String)); 298 } else { 299 DEBUG ((ErrorLevel, "%a: %s\n", Message, String)); 300 } 301 302 FreePool (String); 303 304 return EFI_SUCCESS; 305 } 306 307 /** 207 308 Build the menu path to given statement instance. It is caller's 208 309 responsibility to free returned string buffer. … … 215 316 **/ 216 317 CHAR8 * 217 BuildMen Path (318 BuildMenuPath ( 218 319 IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *StatementPrivate 219 320 ) … … 245 346 246 347 do { 247 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "F(%d) <-", FormPrivate->Id));348 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "F(%d) <-", FormPrivate->Id)); 248 349 FormPrivate = FindFormLinkToThis (FormPrivate); 249 350 if (FormPrivate == NULL) { … … 287 388 AsciiStrCatS (Buffer, OldBufferSize, FormTitle); 288 389 FreePool (FormTitle); 289 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, " %a\n", Buffer));390 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " %a\n", Buffer)); 290 391 } 291 392 … … 829 930 830 931 TmpString = HiiGetRedfishString (Statement->ParentForm->ParentFormset->HiiHandle, Schema, Option->Text); 932 if (TmpString == NULL) { 933 TmpString = HiiGetRedfishString (Statement->ParentForm->ParentFormset->HiiHandle, ENGLISH_LANGUAGE_CODE, Option->Text); 934 } 935 831 936 if (TmpString != NULL) { 832 937 if (StrCmp (TmpString, HiiString) == 0) { … … 891 996 default: 892 997 RedfishValue->Type = RedfishValueTypeUnknown; 998 DEBUG ((DEBUG_ERROR, "%a: Unsupported value type: 0x%x\n", __func__, Value->Type)); 893 999 break; 894 1000 } … … 956 1062 } 957 1063 958 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "Value.Type= 0x%x\n", OrderedListStatement->Value.Type));959 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "Value.BufferValueType= 0x%x\n", OrderedListStatement->Value.BufferValueType));960 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "Value.BufferLen= 0x%x\n", OrderedListStatement->Value.BufferLen));961 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "Value.Buffer= 0x%x\n", OrderedListStatement->Value.Buffer));962 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "Value.MaxContainers= 0x%x\n", OrderedListStatement->ExtraData.OrderListData.MaxContainers));963 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "StorageWidth= 0x%x\n", OrderedListStatement->StorageWidth));1064 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.Type= 0x%x\n", OrderedListStatement->Value.Type)); 1065 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.BufferValueType= 0x%x\n", OrderedListStatement->Value.BufferValueType)); 1066 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.BufferLen= 0x%x\n", OrderedListStatement->Value.BufferLen)); 1067 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.Buffer= 0x%x\n", OrderedListStatement->Value.Buffer)); 1068 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "Value.MaxContainers= 0x%x\n", OrderedListStatement->ExtraData.OrderListData.MaxContainers)); 1069 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "StorageWidth= 0x%x\n", OrderedListStatement->StorageWidth)); 964 1070 965 1071 if (OrderedListStatement->Value.Buffer == NULL) { … … 978 1084 Count = OrderedListStatement->StorageWidth / sizeof (UINT8); 979 1085 for (Index = 0; Index < Count; Index++) { 980 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value8[Index]));1086 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value8[Index])); 981 1087 } 982 1088 … … 986 1092 Count = OrderedListStatement->StorageWidth / sizeof (UINT16); 987 1093 for (Index = 0; Index < Count; Index++) { 988 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value16[Index]));1094 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value16[Index])); 989 1095 } 990 1096 … … 994 1100 Count = OrderedListStatement->StorageWidth / sizeof (UINT32); 995 1101 for (Index = 0; Index < Count; Index++) { 996 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value32[Index]));1102 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value32[Index])); 997 1103 } 998 1104 … … 1002 1108 Count = OrderedListStatement->StorageWidth / sizeof (UINT64); 1003 1109 for (Index = 0; Index < Count; Index++) { 1004 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value64[Index]));1110 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value64[Index])); 1005 1111 } 1006 1112 … … 1010 1116 Count = OrderedListStatement->StorageWidth / sizeof (UINT8); 1011 1117 for (Index = 0; Index < Count; Index++) { 1012 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%d ", Value8[Index]));1013 } 1014 1015 break; 1016 } 1017 1018 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "\n"));1118 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%d ", Value8[Index])); 1119 } 1120 1121 break; 1122 } 1123 1124 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "\n")); 1019 1125 } 1020 1126 … … 1127 1233 1128 1234 TmpString = HiiGetRedfishString (Statement->ParentForm->ParentFormset->HiiHandle, Schema, Option->Text); 1235 if (TmpString == NULL) { 1236 TmpString = HiiGetRedfishString (Statement->ParentForm->ParentFormset->HiiHandle, ENGLISH_LANGUAGE_CODE, Option->Text); 1237 } 1238 1129 1239 if (TmpString != NULL) { 1130 1240 if (StrCmp (TmpString, HiiString) == 0) { … … 1188 1298 StringId = HiiValueToOneOfOptionStringId (HiiStatement, Value); 1189 1299 if (StringId == 0) { 1300 // 1301 // Print prompt string of HII statement for ease of debugging 1302 // 1303 DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "Can not find string ID"); 1304 DumpHiiStatementValue (DEBUG_ERROR, Value, "Current value"); 1190 1305 ASSERT (FALSE); 1191 1306 Status = EFI_DEVICE_ERROR; … … 1255 1370 StringIdArray = HiiValueToOrderedListOptionStringId (HiiStatement, &Count); 1256 1371 if (StringIdArray == NULL) { 1372 // 1373 // Print prompt string of HII statement for ease of debugging 1374 // 1375 DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "Can not get string ID array"); 1257 1376 ASSERT (FALSE); 1258 1377 Status = EFI_DEVICE_ERROR; … … 1262 1381 RedfishValue->Value.StringArray = AllocatePool (sizeof (CHAR8 *) * Count); 1263 1382 if (RedfishValue->Value.StringArray == NULL) { 1383 // 1384 // Print prompt string of HII statement for ease of debugging 1385 // 1386 DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "Can not allocate memory"); 1264 1387 ASSERT (FALSE); 1265 1388 Status = EFI_OUT_OF_RESOURCES; … … 1268 1391 1269 1392 for (Index = 0; Index < Count; Index++) { 1270 ASSERT (StringIdArray[Index] != 0); 1393 if (StringIdArray[Index] == 0) { 1394 // 1395 // Print prompt string of HII statement for ease of debugging 1396 // 1397 DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "String ID in array is 0"); 1398 ASSERT (FALSE); 1399 } 1400 1271 1401 RedfishValue->Value.StringArray[Index] = HiiGetRedfishAsciiString (HiiHandle, FullSchema, StringIdArray[Index]); 1272 1402 ASSERT (RedfishValue->Value.StringArray[Index] != NULL); … … 1290 1420 if (RedfishValue->Value.Buffer == NULL) { 1291 1421 // 1292 // No x- uefi-redfish string defined. Try to get string in English.1422 // No x-UEFI-redfish string defined. Try to get string in English. 1293 1423 // 1294 1424 RedfishValue->Value.Buffer = HiiGetEnglishAsciiString (HiiHandle, HiiStatement->ExtraData.TextTwo); … … 1371 1501 } 1372 1502 1373 StringLen = StrLen (UnicodeString) + 1;1503 StringLen = HiiStrLen (UnicodeString) + 1; 1374 1504 Buffer = AllocatePool (StringLen * sizeof (CHAR8)); 1375 1505 if (Buffer == NULL) { … … 1661 1791 // 1662 1792 if ((TargetStatement->HiiStatement->Operand == EFI_IFR_ONE_OF_OP) && (StatementValue->Type == EFI_IFR_TYPE_STRING)) { 1663 TempBuffer = StrToUnicodeStr ((CHAR8 *)StatementValue->Buffer); 1664 if (TempBuffer == NULL) { 1665 return EFI_OUT_OF_RESOURCES; 1666 } 1667 1668 FreePool (StatementValue->Buffer); 1793 // 1794 // Keep input buffer to TempBuffer because StatementValue will be 1795 // assigned in HiiStringToOneOfOptionValue(). 1796 // 1797 TempBuffer = (EFI_STRING)StatementValue->Buffer; 1669 1798 StatementValue->Buffer = NULL; 1670 1799 StatementValue->BufferLen = 0; … … 1745 1874 } 1746 1875 1747 if (StatementValue->Value.string != 0) { 1748 HiiDeleteString (StatementValue->Value.string, TargetStatement->ParentForm->ParentFormset->HiiHandle); 1876 if ((TargetStatement->HiiStatement->Operand == EFI_IFR_STRING_OP) && (StatementValue->Type == EFI_IFR_TYPE_STRING)) { 1877 if (StatementValue->Value.string != 0) { 1878 // Delete HII string which was created for HII statement operand = EFI_IFR_STRING_OP and Type = EFI_IFR_TYPE_STRING. 1879 HiiDeleteString (StatementValue->Value.string, TargetStatement->ParentForm->ParentFormset->HiiHandle); 1880 } 1749 1881 } 1750 1882 … … 1881 2013 REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_REF *StatementRef; 1882 2014 LIST_ENTRY *NextLink; 1883 EFI_STRING TmpString;1884 2015 EFI_STRING *TmpConfigureLangList; 1885 2016 UINTN Index; 1886 2017 CHAR8 *FullSchema; 2018 2019 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: Harvest config language of %a_%a (Regex: %s).\n", __func__, Schema, Version, RegexPattern)); 1887 2020 1888 2021 if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || (Count == NULL) || (ConfigureLangList == NULL) || IS_EMPTY_STRING (RegexPattern)) { … … 1935 2068 ASSERT (StatementRef->Statement->Description != 0); 1936 2069 if (StatementRef->Statement->Description != 0) { 1937 TmpString = HiiGetRedfishString (StatementRef->Statement->ParentForm->ParentFormset->HiiHandle, FullSchema, StatementRef->Statement->Description); 1938 ASSERT (TmpString != NULL); 1939 if (TmpString != NULL) { 1940 TmpConfigureLangList[Index] = AllocateCopyPool (StrSize (TmpString), TmpString); 1941 ASSERT (TmpConfigureLangList[Index] != NULL); 1942 FreePool (TmpString); 1943 ++Index; 1944 } 2070 ASSERT (StatementRef->Statement->XuefiRedfishStr != NULL); 2071 TmpConfigureLangList[Index] = AllocateCopyPool (HiiStrSize (StatementRef->Statement->XuefiRedfishStr), (VOID *)StatementRef->Statement->XuefiRedfishStr); 2072 ++Index; 1945 2073 } 1946 2074 } … … 1950 2078 *ConfigureLangList = TmpConfigureLangList; 1951 2079 2080 DEBUG_REDFISH_THIS_MODULE ( 2081 REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_REGEX, 2082 "%a: Number of configure language strings harvested: %d\n", 2083 __func__, 2084 StatementList.Count 2085 ); 2086 2087 DEBUG_REDFISH_THIS_MODULE_CODE ( 2088 REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_REGEX, 2089 DEBUG_REDFISH (DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE, "%a: Number of configure language strings harvested: %d\n", __func__, StatementList.Count); 2090 for (Index = 0; Index < *Count; Index++) { 2091 DEBUG_REDFISH (DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE, " (%d) %s\n", Index, TmpConfigureLangList[Index]); 2092 } 2093 2094 ); 2095 1952 2096 RELEASE_RESOURCE: 1953 2097 … … 1960 2104 } 1961 2105 2106 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: exit.\n", __func__)); 1962 2107 return Status; 1963 2108 } … … 1968 2113 @param[in] This Pointer to EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL instance. 1969 2114 @param[out] SupportedSchema The supported schema list which is separated by ';'. 1970 For example: "x- uefi-redfish-Memory.v1_7_1;x-uefi-redfish-Boot.v1_0_1"2115 For example: "x-UEFI-redfish-Memory.v1_7_1;x-UEFI-redfish-Boot.v1_0_1" 1971 2116 The SupportedSchema is allocated by the callee. It's caller's 1972 2117 responsibility to free this buffer using FreePool(). … … 2174 2319 CHAR8 *Buffer; 2175 2320 2321 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: Entry\n", __func__)); 2176 2322 if ((This == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_STRING (ConfigureLang) || (AttributeValue == NULL)) { 2177 2323 return EFI_INVALID_PARAMETER; … … 2215 2361 // Build up menu path 2216 2362 // 2217 AttributeValue->MenuPath = BuildMenPath (TargetStatement); 2218 if (AttributeValue->MenuPath == NULL) { 2219 DEBUG ((DEBUG_ERROR, "%a: failed to build menu path for \"%a\"\n", __func__, AttributeValue->AttributeName)); 2363 if (RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) { 2364 AttributeValue->MenuPath = BuildMenuPath (TargetStatement); 2365 if (AttributeValue->MenuPath == NULL) { 2366 DEBUG ((DEBUG_ERROR, "%a: failed to build menu path for \"%a\"\n", __func__, AttributeValue->AttributeName)); 2367 } 2220 2368 } 2221 2369 … … 2248 2396 } 2249 2397 2398 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: Exit\n", __func__)); 2250 2399 return Status; 2251 2400 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.h
r101291 r105670 3 3 4 4 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 5 Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 6 7 7 8 SPDX-License-Identifier: BSD-2-Clause-Patent … … 21 22 #include <Library/DebugLib.h> 22 23 #include <Library/MemoryAllocationLib.h> 24 #include <Library/PcdLib.h> 23 25 #include <Library/PrintLib.h> 26 #include <Library/RedfishDebugLib.h> 24 27 #include <Library/UefiLib.h> 25 28 #include <Library/UefiBootServicesTableLib.h> … … 37 40 // 38 41 #include <Protocol/EdkIIRedfishPlatformConfig.h> 42 43 // 44 // Debug message in DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE scope. 45 // To enable the debug message for this module, below PCDs must be set. 46 // 47 // 1. DEBUG_MANAGEABILITY must be set PcdDebugPrintErrorLevel. 48 // 49 // 2 RedfishPlatformConfigDxe debug enablement must be set in 50 // PcdRedfishDebugCategory (defined in RedfishPkg.dec) 51 // 52 // 3. The subordinate debug enablement for RedfishPlatformConfigDxe 53 // must be set in PcdRedfishPlatformConfigDebugProperty (defined 54 // in RedfishPkg.dec). 55 // 56 #define DEBUG_REDFISH_THIS_MODULE(DebugSubordinate, ...) \ 57 while (RedfishPlatformConfigDebugProp (DebugSubordinate)) { \ 58 DEBUG_REDFISH(DEBUG_REDFISH_COMPONENT_PLATFORM_CONFIG_DXE, ##__VA_ARGS__); \ 59 break; \ 60 } 61 62 #define DEBUG_REDFISH_THIS_MODULE_CODE_BEGIN(DebugSubordinate) \ 63 if (RedfishPlatformConfigDebugProp (DebugSubordinate)) { 64 65 #define DEBUG_REDFISH_THIS_MODULE_CODE_END() } 66 67 #define DEBUG_REDFISH_THIS_MODULE_CODE(DebugSubordinate, Expression) \ 68 DEBUG_REDFISH_THIS_MODULE_CODE_BEGIN(DebugSubordinate) \ 69 Expression \ 70 DEBUG_REDFISH_THIS_MODULE_CODE_END() 71 72 // Subordinate debug property for DEBUG_REDFISH_PLATFORM_CONFIG_DXE 73 #define REDFISH_PLATFORM_CONFIG_DEBUG_STRING_DATABASE 0x00000001 74 #define REDFISH_PLATFORM_CONFIG_DEBUG_DUMP_FORMSET 0x00000002 75 #define REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_SEARCH 0x00000004 76 #define REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_REGEX 0x00000008 39 77 40 78 /// … … 74 112 #define REDFISH_PLATFORM_CONFIG_PRIVATE_FROM_THIS(a) BASE_CR (a, REDFISH_PLATFORM_CONFIG_PRIVATE, Protocol) 75 113 #define REGULAR_EXPRESSION_INCLUDE_ALL L".*" 76 #define CONFIGURE_LANGUAGE_PREFIX "x- uefi-redfish-"114 #define CONFIGURE_LANGUAGE_PREFIX "x-UEFI-redfish-" 77 115 #define REDFISH_PLATFORM_CONFIG_VERSION 0x00010000 78 #define REDFISH_PLATFORM_CONFIG_DEBUG DEBUG_MANAGEABILITY 79 #define REDFISH_MENU_PATH_SIZE 8 116 117 #define REDFISH_MENU_PATH_SIZE 8 118 119 // Definitions of Redfish platform config capability 120 #define REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH 0x000000001 121 #define REDFISH_PLATFORM_CONFIG_ALLOW_SUPPRESSED 0x000000002 80 122 81 123 /** -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.inf
r101291 r105670 4 4 # (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR> 5 5 # Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 6 7 # 7 8 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 24 25 25 26 [Sources] 27 RedfishPlatformConfigCapability.c 26 28 RedfishPlatformConfigDxe.h 27 29 RedfishPlatformConfigDxe.c … … 37 39 HiiUtilityLib 38 40 MemoryAllocationLib 41 PcdLib 39 42 PrintLib 43 RedfishDebugLib 40 44 UefiLib 41 45 UefiBootServicesTableLib … … 52 56 gEfiRegexSyntaxTypePerlGuid ## CONSUMED 53 57 58 [FixedPcd] 59 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigFeatureProperty 60 gEfiRedfishPkgTokenSpaceGuid.PcdRedfishPlatformConfigDebugProperty 61 54 62 [Depex] 55 63 TRUE -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.c
r101291 r105670 3 3 4 4 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR> 5 Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 6 7 7 8 SPDX-License-Identifier: BSD-2-Clause-Patent … … 32 33 33 34 if ((HiiHandle == NULL) || (StringId == 0)) { 34 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "???"));35 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "???")); 35 36 return EFI_INVALID_PARAMETER; 36 37 } … … 41 42 } 42 43 43 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%s", String));44 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%s", String)); 44 45 FreePool (String); 45 46 … … 79 80 HiiNextFormLink = GetNextNode (&FormsetPrivate->HiiFormList, HiiFormLink); 80 81 81 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, " [%d] form: %d title: ", ++Index, HiiFormPrivate->Id));82 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " [%d] form: %d title: ", ++Index, HiiFormPrivate->Id)); 82 83 DumpHiiString (FormsetPrivate->HiiHandle, HiiFormPrivate->Title); 83 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "\n"));84 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "\n")); 84 85 85 86 HiiStatementLink = GetFirstNode (&HiiFormPrivate->StatementList); … … 88 89 HiiNextStatementLink = GetNextNode (&HiiFormPrivate->StatementList, HiiStatementLink); 89 90 90 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, " QID: 0x%x Prompt: ", HiiStatementPrivate->QuestionId));91 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " QID: 0x%x Prompt: ", HiiStatementPrivate->QuestionId)); 91 92 DumpHiiString (FormsetPrivate->HiiHandle, HiiStatementPrivate->Description); 92 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "\n"));93 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "\n")); 93 94 94 95 HiiStatementLink = HiiNextStatementLink; … … 125 126 126 127 if (IsListEmpty (FormsetList)) { 127 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: Empty formset list\n", __func__));128 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: Empty formset list\n", __func__)); 128 129 return EFI_SUCCESS; 129 130 } … … 135 136 HiiFormsetPrivate = REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFormsetLink); 136 137 137 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "[%d] HII Handle: 0x%x formset: %g at %s\n", ++Index, HiiFormsetPrivate->HiiHandle, &HiiFormsetPrivate->Guid, HiiFormsetPrivate->DevicePathStr));138 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "[%d] HII Handle: 0x%x formset: %g at %s\n", ++Index, HiiFormsetPrivate->HiiHandle, &HiiFormsetPrivate->Guid, HiiFormsetPrivate->DevicePathStr)); 138 139 DumpFormset (HiiFormsetPrivate); 139 140 … … 142 143 143 144 return EFI_SUCCESS; 145 } 146 147 /** 148 Return the HII string length. We don't check word alignment 149 of the input string as same as the checking in StrLen 150 function, because the HII string in the database is compact 151 at the byte alignment. 152 153 @param[in] String Input UCS format string. 154 155 @retval Length of the string. 156 157 **/ 158 UINTN 159 EFIAPI 160 HiiStrLen ( 161 IN CONST CHAR16 *String 162 ) 163 { 164 UINTN Length; 165 166 ASSERT (String != NULL); 167 168 for (Length = 0; *String != L'\0'; String++, Length++) { 169 } 170 171 return Length; 172 } 173 174 /** 175 Return the HII string size. We don't check word alignment 176 of the input string as same as the checking in StrLen 177 function, because the HII string in the database is compact 178 at the byte alignment. 179 180 @param[in] String Input UCS format string. 181 182 @retval Size of the string. 183 184 **/ 185 UINTN 186 EFIAPI 187 HiiStrSize ( 188 IN CONST CHAR16 *String 189 ) 190 { 191 return (HiiStrLen (String) + 1) * sizeof (*String); 192 } 193 194 /** 195 Compare two HII strings. We don't check word alignment 196 of the input string as same as the checking in StrLen 197 function, because the HII string in the database is compact 198 at the byte alignment. 199 200 @param[in] FirstString Input UCS format of string to search. 201 @param[in] SecondString Input UCS format of string to look for in 202 FirstString; 203 204 @retval 0 The strings are identical. 205 !0 The strings are not identical. 206 207 **/ 208 INTN 209 EFIAPI 210 HiiStrCmp ( 211 IN CONST CHAR16 *FirstString, 212 IN CONST CHAR16 *SecondString 213 ) 214 { 215 // 216 // ASSERT both strings are less long than PcdMaximumUnicodeStringLength 217 // 218 ASSERT (HiiStrSize (FirstString) != 0); 219 ASSERT (HiiStrSize (SecondString) != 0); 220 221 while ((*FirstString != L'\0') && (*FirstString == *SecondString)) { 222 FirstString++; 223 SecondString++; 224 } 225 226 return *FirstString - *SecondString; 144 227 } 145 228 … … 303 386 304 387 /** 305 Get string from HII database in English language. The returned string is allocated306 using AllocatePool(). The caller is responsible for freeing the allocated buffer using307 FreePool().308 309 @param[in] HiiHandle A handle that was previously registered in the HII Database.310 @param[in] StringId The identifier of the string to retrieved from the string311 package associated with HiiHandle.312 313 @retval NULL The string specified by StringId is not present in the string package.314 @retval Other The string was returned.315 316 **/317 EFI_STRING318 HiiGetEnglishString (319 IN EFI_HII_HANDLE HiiHandle,320 IN EFI_STRING_ID StringId321 )322 {323 return HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId);324 }325 326 /**327 388 Get ASCII string from HII database in English language. The returned string is allocated 328 389 using AllocatePool(). The caller is responsible for freeing the allocated buffer using … … 562 623 HiiStatementPrivate = REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK (HiiStatementLink); 563 624 564 if ((HiiStatementPrivate->Description != 0) && !HiiStatementPrivate->Suppressed) { 565 TmpString = HiiGetRedfishString (HiiFormsetPrivate->HiiHandle, Schema, HiiStatementPrivate->Description); 625 if ((HiiStatementPrivate->Description != 0) && 626 (RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_ALLOW_SUPPRESSED) || !HiiStatementPrivate->Suppressed)) 627 { 628 TmpString = HiiStatementPrivate->XuefiRedfishStr; 566 629 if (TmpString != NULL) { 567 630 Status = RegularExpressionProtocol->MatchString ( … … 593 656 ++StatementList->Count; 594 657 } 595 596 FreePool (TmpString); 658 } else { 659 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) { 660 DEBUG ((DEBUG_ERROR, "%a: HiiStatementPrivate->XuefiRedfishStr is NULL, x-UEFI-string has something wrong.\n", __func__)); 661 ASSERT (FALSE); 662 } 597 663 } 598 664 } … … 637 703 REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate; 638 704 EFI_STRING TmpString; 705 UINTN Index; 639 706 640 707 if ((FormsetList == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (ConfigureLang)) { … … 646 713 } 647 714 715 Index = 0; 648 716 HiiFormsetLink = GetFirstNode (FormsetList); 649 717 while (!IsNull (FormsetList, HiiFormsetLink)) { … … 670 738 HiiStatementPrivate = REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK (HiiStatementLink); 671 739 672 DEBUG_CODE ( 673 STATIC UINTN Index = 0; 674 DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%a: [%d] search %s in QID: 0x%x form: 0x%x formset: %g\n", __func__, ++Index, ConfigureLang, HiiStatementPrivate->QuestionId, HiiFormPrivate->Id, &HiiFormsetPrivate->Guid)); 675 ); 676 677 if (HiiStatementPrivate->Description != 0) { 678 TmpString = HiiGetRedfishString (HiiFormsetPrivate->HiiHandle, Schema, HiiStatementPrivate->Description); 740 if ((HiiStatementPrivate->Description != 0) && 741 (RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_ALLOW_SUPPRESSED) || !HiiStatementPrivate->Suppressed)) 742 { 743 TmpString = HiiStatementPrivate->XuefiRedfishStr; 679 744 if (TmpString != NULL) { 680 if (StrCmp (TmpString, ConfigureLang) == 0) { 681 FreePool (TmpString); 745 Index++; 746 DEBUG_REDFISH_THIS_MODULE ( 747 REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_SEARCH, 748 "%a: [%d] check %s in QID: 0x%x form: 0x%x formset: %g\n", 749 __func__, 750 Index, 751 ConfigureLang, 752 HiiStatementPrivate->QuestionId, 753 HiiFormPrivate->Id, 754 &HiiFormsetPrivate->Guid 755 ); 756 if (HiiStrCmp (TmpString, ConfigureLang) == 0) { 682 757 return HiiStatementPrivate; 683 758 } 684 685 FreePool (TmpString); 759 } else { 760 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) { 761 DEBUG ((DEBUG_ERROR, "%a: HiiStatementPrivate->XuefiRedfishStr is NULL, x-UEFI-string has something wrong.\n", __func__)); 762 ASSERT (FALSE); 763 } 686 764 } 687 765 } … … 742 820 743 821 /** 822 Release x-UEFI-string related information. 823 824 @param[in] FormsetPrivate Pointer to HII form-set private instance. 825 826 @retval EFI_STATUS 827 828 **/ 829 EFI_STATUS 830 ReleaseXuefiStringDatabase ( 831 IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate 832 ) 833 { 834 REDFISH_X_UEFI_STRING_DATABASE *ThisDatabase; 835 REDFISH_X_UEFI_STRING_DATABASE *PreDatabase; 836 REDFISH_X_UEFI_STRINGS_ARRAY *ThisStringArray; 837 REDFISH_X_UEFI_STRINGS_ARRAY *PreStringArray; 838 BOOLEAN EndDatabase; 839 BOOLEAN EndArray; 840 841 if (FormsetPrivate->HiiPackageListHeader != NULL) { 842 FreePool (FormsetPrivate->HiiPackageListHeader); 843 } 844 845 // Walk through x-UEFI-redfish string database. 846 if (!IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) { 847 EndDatabase = FALSE; 848 ThisDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase); 849 while (!EndDatabase) { 850 // Walk through string arrays. 851 if (!IsListEmpty (&ThisDatabase->XuefiRedfishStringArrays)) { 852 EndArray = FALSE; 853 ThisStringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode (&ThisDatabase->XuefiRedfishStringArrays); 854 while (!EndArray) { 855 // Remove this array 856 FreePool (ThisStringArray->ArrayEntryAddress); 857 EndArray = IsNodeAtEnd (&ThisDatabase->XuefiRedfishStringArrays, &ThisStringArray->NextArray); 858 PreStringArray = ThisStringArray; 859 if (!EndArray) { 860 ThisStringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode (&ThisDatabase->XuefiRedfishStringArrays, &ThisStringArray->NextArray); 861 } 862 863 RemoveEntryList (&PreStringArray->NextArray); 864 FreePool (PreStringArray); 865 } 866 } 867 868 // 869 // Remove this database 870 // 871 EndDatabase = IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, &ThisDatabase->NextXuefiRedfishLanguage); 872 PreDatabase = ThisDatabase; 873 if (!EndDatabase) { 874 ThisDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode (&FormsetPrivate->XuefiRedfishStringDatabase, &ThisDatabase->NextXuefiRedfishLanguage); 875 } 876 877 RemoveEntryList (&PreDatabase->NextXuefiRedfishLanguage); 878 FreePool (PreDatabase); 879 } 880 } 881 882 return EFI_SUCCESS; 883 } 884 885 /** 744 886 Release formset and all the forms and statements that belong to this formset. 745 887 746 @param[in] FormsetPrivate Pointer to H P_HII_FORM_SET_PRIVATE888 @param[in] FormsetPrivate Pointer to HII form-set private instance. 747 889 748 890 @retval EFI_STATUS … … 779 921 // HiiStatementPrivate->HiiStatement will be released in DestroyFormSet(). 780 922 // 781 782 if (HiiStatementPrivate->DesStringCache != NULL) {783 FreePool (HiiStatementPrivate->DesStringCache);784 HiiStatementPrivate->DesStringCache = NULL;785 }786 787 923 RemoveEntryList (&HiiStatementPrivate->Link); 788 924 FreePool (HiiStatementPrivate); … … 821 957 } 822 958 959 ReleaseXuefiStringDatabase (FormsetPrivate); 960 823 961 return EFI_SUCCESS; 824 962 } … … 846 984 // 847 985 InitializeListHead (&NewFormsetPrivate->HiiFormList); 986 InitializeListHead (&NewFormsetPrivate->XuefiRedfishStringDatabase); 848 987 849 988 return NewFormsetPrivate; 989 } 990 991 /** 992 Create new x-UEFI-redfish string array. 993 994 @param[in] XuefiRedfishStringDatabase The x-UEFI-redfish string database. 995 996 @retval EFI_OUT_OF_RESOURCES Not enough memory for creating a new array. 997 EFI_SUCCESS New array is created successfully. 998 999 **/ 1000 EFI_STATUS 1001 NewRedfishXuefiStringArray ( 1002 IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase 1003 ) 1004 { 1005 REDFISH_X_UEFI_STRINGS_ARRAY *ArrayAddress; 1006 1007 // Initial first REDFISH_X_UEFI_STRINGS_ARRAY memory. 1008 ArrayAddress = (REDFISH_X_UEFI_STRINGS_ARRAY *)AllocateZeroPool (sizeof (REDFISH_X_UEFI_STRINGS_ARRAY)); 1009 if (ArrayAddress == NULL) { 1010 DEBUG ((DEBUG_ERROR, "%a: Failed to allocate REDFISH_X_UEFI_STRINGS_ARRAY.\n", __func__)); 1011 return EFI_OUT_OF_RESOURCES; 1012 } 1013 1014 InitializeListHead (&ArrayAddress->NextArray); 1015 1016 // Allocate memory buffer for REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT elements. 1017 ArrayAddress->ArrayEntryAddress = \ 1018 (REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT *)AllocateZeroPool (sizeof (REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT) * X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER); 1019 if (ArrayAddress->ArrayEntryAddress == NULL) { 1020 FreePool (ArrayAddress); 1021 DEBUG ((DEBUG_ERROR, "%a: Failed to allocate array for REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENTs.\n", __func__)); 1022 return EFI_OUT_OF_RESOURCES; 1023 } 1024 1025 XuefiRedfishStringDatabase->StringsArrayBlocks++; 1026 InsertTailList (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &ArrayAddress->NextArray); 1027 return EFI_SUCCESS; 1028 } 1029 1030 /** 1031 Get the pointer of x-UEFI-redfish database or create a new database. 1032 1033 @param[in] FormsetPrivate Pointer to HII form-set private instance. 1034 @param[in] HiiStringPackageHeader HII string package header. 1035 1036 @retval Pointer to REDFISH_X_UEFI_STRING_DATABASE. 1037 If NULL, it fails to obtain x-UEFI-redfish database. 1038 1039 **/ 1040 REDFISH_X_UEFI_STRING_DATABASE * 1041 GetExistOrCreateXuefiStringDatabase ( 1042 IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, 1043 IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader 1044 ) 1045 { 1046 EFI_STATUS Status; 1047 BOOLEAN CreateNewOne; 1048 REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase; 1049 1050 CreateNewOne = TRUE; 1051 XuefiRedfishStringDatabase = NULL; 1052 if (!IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) { 1053 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase); 1054 1055 while (TRUE) { 1056 if (AsciiStriCmp (XuefiRedfishStringDatabase->XuefiRedfishLanguage, HiiStringPackageHeader->Language) == 0) { 1057 CreateNewOne = FALSE; 1058 break; 1059 } 1060 1061 if (IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage)) { 1062 break; 1063 } 1064 1065 XuefiRedfishStringDatabase = \ 1066 (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage); 1067 } 1068 } 1069 1070 if (CreateNewOne) { 1071 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " Creating x-UEFI-redfish (%a) string database...\n", HiiStringPackageHeader->Language)); 1072 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)AllocateZeroPool (sizeof (REDFISH_X_UEFI_STRING_DATABASE)); 1073 if (XuefiRedfishStringDatabase == NULL) { 1074 DEBUG ((DEBUG_ERROR, " Failed to allocate REDFISH_X_UEFI_STRING_DATABASE.\n")); 1075 return NULL; 1076 } 1077 1078 InitializeListHead (&XuefiRedfishStringDatabase->NextXuefiRedfishLanguage); 1079 InitializeListHead (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays); 1080 XuefiRedfishStringDatabase->StringsArrayBlocks = 0; 1081 XuefiRedfishStringDatabase->XuefiRedfishLanguage = HiiStringPackageHeader->Language; 1082 1083 Status = NewRedfishXuefiStringArray (XuefiRedfishStringDatabase); 1084 if (EFI_ERROR (Status)) { 1085 FreePool (XuefiRedfishStringDatabase); 1086 return NULL; 1087 } 1088 1089 DEBUG (( 1090 DEBUG_REDFISH_PLATFORM_CONFIG, 1091 " x-UEFI-redfish (%a):\n String array is added to XuefiRedfishStringDatabase, total %d arrays now.\n", 1092 XuefiRedfishStringDatabase->XuefiRedfishLanguage, 1093 XuefiRedfishStringDatabase->StringsArrayBlocks 1094 )); 1095 1096 // Link string database to FormsetPrivate. 1097 InsertTailList (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage); 1098 } 1099 1100 return XuefiRedfishStringDatabase; 1101 } 1102 1103 /** 1104 Check and allocate a new x-UEFI-redfish array if it is insufficient for the 1105 newly added x-UEFI-redfish string. 1106 1107 @param[in] FormsetPrivate Pointer to HII form-set private instance. 1108 @param[in] XuefiRedfishStringDatabase Pointer to the x-UEFI-redfish database. 1109 @param[in] StringId String ID added to database. 1110 1111 @retval EFI_SUCCESS The size of x-UEFI-string array is adjusted or 1112 is not required to be adjusted. 1113 Otherwise, refer to the error code returned from NewRedfishXuefiStringArray(). 1114 1115 **/ 1116 EFI_STATUS 1117 RedfishXuefiStringAdjustArrays ( 1118 IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, 1119 IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase, 1120 IN EFI_STRING_ID StringId 1121 ) 1122 { 1123 EFI_STATUS Status; 1124 1125 while (((StringId + X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) / X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) > (UINT16)XuefiRedfishStringDatabase->StringsArrayBlocks) { 1126 Status = NewRedfishXuefiStringArray (XuefiRedfishStringDatabase); 1127 if (EFI_ERROR (Status)) { 1128 DEBUG ((DEBUG_ERROR, "%a: Failed to adjust x-UEFI-string array", __func__)); 1129 return Status; 1130 } 1131 } 1132 1133 return EFI_SUCCESS; 1134 } 1135 1136 /** 1137 Insert a x-UEFI-redfish string to database. 1138 1139 @param[in] FormsetPrivate Pointer to HII form-set private instance. 1140 @param[in] HiiStringPackageHeader Pointer to HII string package. 1141 @param[in] StringId The HII string ID 1142 @param[in] StringTextPtr Pointer to HII string text. 1143 1144 @retval EFI_SUCCESS The HII string is added to database. 1145 EFI_LOAD_ERROR Something wrong when insert an HII string 1146 to database. 1147 1148 **/ 1149 EFI_STATUS 1150 RedfishXuefiStringInsertDatabase ( 1151 IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, 1152 IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader, 1153 IN EFI_STRING_ID StringId, 1154 IN CHAR16 *StringTextPtr 1155 ) 1156 { 1157 EFI_STATUS Status; 1158 UINTN StringIdOffset; 1159 REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase; 1160 REDFISH_X_UEFI_STRINGS_ARRAY *ThisArray; 1161 1162 XuefiRedfishStringDatabase = GetExistOrCreateXuefiStringDatabase (FormsetPrivate, HiiStringPackageHeader); 1163 if (XuefiRedfishStringDatabase == NULL) { 1164 DEBUG ((DEBUG_ERROR, "%a: Failed to get REDFISH_X_UEFI_STRING_DATABASE of x-UEFI-redfish language %a.\n", __func__, HiiStringPackageHeader->Language)); 1165 ReleaseXuefiStringDatabase (FormsetPrivate); 1166 return EFI_LOAD_ERROR; 1167 } 1168 1169 Status = RedfishXuefiStringAdjustArrays (FormsetPrivate, XuefiRedfishStringDatabase, StringId); 1170 if (EFI_ERROR (Status)) { 1171 DEBUG ((DEBUG_ERROR, "%a: Failed to adjust x-UEFI-redfish string array.\n", __func__)); 1172 ReleaseXuefiStringDatabase (FormsetPrivate); 1173 return EFI_LOAD_ERROR; 1174 } 1175 1176 // Insert string to x-UEFI-redfish string array. 1177 StringIdOffset = (UINTN)StringId; 1178 ThisArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays); 1179 while (StringIdOffset >= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) { 1180 ThisArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &ThisArray->NextArray); 1181 StringIdOffset -= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER; 1182 } 1183 1184 // Insert string 1185 (ThisArray->ArrayEntryAddress + StringIdOffset)->StringId = StringId; 1186 (ThisArray->ArrayEntryAddress + StringIdOffset)->UcsString = StringTextPtr; 1187 1188 DEBUG_REDFISH_THIS_MODULE ( 1189 REDFISH_PLATFORM_CONFIG_DEBUG_STRING_DATABASE, 1190 " Insert string ID: (%d) to database\n x-UEFI-string: \"%s\"\n Language: %a.\n", 1191 StringId, 1192 StringTextPtr, 1193 HiiStringPackageHeader->Language 1194 ); 1195 return EFI_SUCCESS; 1196 } 1197 1198 /** 1199 Get x-UEFI-redfish string and language by string ID. 1200 1201 @param[in] FormsetPrivate Pointer to HII form-set private instance. 1202 @param[in] HiiStringPackageHeader HII string package header. 1203 @param[out] TotalStringAdded Return the total strings added to database. 1204 1205 @retval TRUE x-UEFI-redfish string and ID map is inserted to database. 1206 FALSE Something is wrong when insert x-UEFI-redfish string and ID map. 1207 1208 **/ 1209 BOOLEAN 1210 CreateXuefiLanguageStringIdMap ( 1211 IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, 1212 IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader, 1213 OUT UINTN *TotalStringAdded 1214 ) 1215 { 1216 EFI_STATUS Status; 1217 UINT8 *BlockHdr; 1218 EFI_STRING_ID CurrentStringId; 1219 UINTN BlockSize; 1220 UINTN Index; 1221 UINT8 *StringTextPtr; 1222 UINTN Offset; 1223 UINT16 StringCount; 1224 UINT16 SkipCount; 1225 UINT8 Length8; 1226 EFI_HII_SIBT_EXT2_BLOCK Ext2; 1227 UINT32 Length32; 1228 UINT8 *StringBlockInfo; 1229 UINTN StringsAdded; 1230 1231 StringsAdded = 0; 1232 1233 // 1234 // Parse the string blocks to get the string text and font. 1235 // 1236 StringBlockInfo = (UINT8 *)((UINTN)HiiStringPackageHeader + HiiStringPackageHeader->StringInfoOffset); 1237 BlockHdr = StringBlockInfo; 1238 BlockSize = 0; 1239 Offset = 0; 1240 CurrentStringId = 1; 1241 while (*BlockHdr != EFI_HII_SIBT_END) { 1242 switch (*BlockHdr) { 1243 case EFI_HII_SIBT_STRING_SCSU: 1244 Offset = sizeof (EFI_HII_STRING_BLOCK); 1245 StringTextPtr = BlockHdr + Offset; 1246 BlockSize += Offset + AsciiStrSize ((CHAR8 *)StringTextPtr); 1247 CurrentStringId++; 1248 break; 1249 1250 case EFI_HII_SIBT_STRING_SCSU_FONT: 1251 Offset = sizeof (EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK) - sizeof (UINT8); 1252 StringTextPtr = BlockHdr + Offset; 1253 BlockSize += Offset + AsciiStrSize ((CHAR8 *)StringTextPtr); 1254 CurrentStringId++; 1255 break; 1256 1257 case EFI_HII_SIBT_STRINGS_SCSU: 1258 CopyMem (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16)); 1259 StringTextPtr = (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_BLOCK) - sizeof (UINT8)); 1260 BlockSize += StringTextPtr - BlockHdr; 1261 1262 for (Index = 0; Index < StringCount; Index++) { 1263 BlockSize += AsciiStrSize ((CHAR8 *)StringTextPtr); 1264 StringTextPtr = StringTextPtr + AsciiStrSize ((CHAR8 *)StringTextPtr); 1265 CurrentStringId++; 1266 } 1267 1268 break; 1269 1270 case EFI_HII_SIBT_STRINGS_SCSU_FONT: 1271 CopyMem ( 1272 &StringCount, 1273 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 1274 sizeof (UINT16) 1275 ); 1276 StringTextPtr = (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK) - sizeof (UINT8)); 1277 BlockSize += StringTextPtr - BlockHdr; 1278 1279 for (Index = 0; Index < StringCount; Index++) { 1280 BlockSize += AsciiStrSize ((CHAR8 *)StringTextPtr); 1281 StringTextPtr = StringTextPtr + AsciiStrSize ((CHAR8 *)StringTextPtr); 1282 CurrentStringId++; 1283 } 1284 1285 break; 1286 1287 case EFI_HII_SIBT_STRING_UCS2: 1288 Offset = sizeof (EFI_HII_STRING_BLOCK); 1289 StringTextPtr = BlockHdr + Offset; 1290 1291 // x-UEFI-redfish string is always encoded as UCS and started with '/'. 1292 if (*StringTextPtr == (UINT16)'/') { 1293 Status = RedfishXuefiStringInsertDatabase ( 1294 FormsetPrivate, 1295 HiiStringPackageHeader, 1296 CurrentStringId, 1297 (CHAR16 *)StringTextPtr 1298 ); 1299 if (EFI_ERROR (Status)) { 1300 DEBUG ((DEBUG_ERROR, "%a: Failed to insert x-UEFI-redfish string %s.\n", __func__, StringTextPtr)); 1301 return FALSE; 1302 } 1303 1304 StringsAdded++; 1305 } 1306 1307 BlockSize += (Offset + HiiStrSize ((CHAR16 *)StringTextPtr)); 1308 CurrentStringId++; 1309 break; 1310 1311 case EFI_HII_SIBT_STRING_UCS2_FONT: 1312 Offset = sizeof (EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK) - sizeof (CHAR16); 1313 StringTextPtr = BlockHdr + Offset; 1314 BlockSize += (Offset + HiiStrSize ((CHAR16 *)StringTextPtr)); 1315 CurrentStringId++; 1316 break; 1317 1318 case EFI_HII_SIBT_STRINGS_UCS2: 1319 Offset = sizeof (EFI_HII_SIBT_STRINGS_UCS2_BLOCK) - sizeof (CHAR16); 1320 StringTextPtr = BlockHdr + Offset; 1321 BlockSize += Offset; 1322 CopyMem (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16)); 1323 for (Index = 0; Index < StringCount; Index++) { 1324 BlockSize += HiiStrSize ((CHAR16 *)StringTextPtr); 1325 StringTextPtr = StringTextPtr + HiiStrSize ((CHAR16 *)StringTextPtr); 1326 CurrentStringId++; 1327 } 1328 1329 break; 1330 1331 case EFI_HII_SIBT_STRINGS_UCS2_FONT: 1332 Offset = sizeof (EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK) - sizeof (CHAR16); 1333 StringTextPtr = BlockHdr + Offset; 1334 BlockSize += Offset; 1335 CopyMem ( 1336 &StringCount, 1337 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 1338 sizeof (UINT16) 1339 ); 1340 for (Index = 0; Index < StringCount; Index++) { 1341 BlockSize += HiiStrSize ((CHAR16 *)StringTextPtr); 1342 StringTextPtr = StringTextPtr + HiiStrSize ((CHAR16 *)StringTextPtr); 1343 CurrentStringId++; 1344 } 1345 1346 break; 1347 1348 case EFI_HII_SIBT_DUPLICATE: 1349 BlockSize += sizeof (EFI_HII_SIBT_DUPLICATE_BLOCK); 1350 CurrentStringId++; 1351 break; 1352 1353 case EFI_HII_SIBT_SKIP1: 1354 SkipCount = (UINT16)(*(UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK))); 1355 CurrentStringId = (UINT16)(CurrentStringId + SkipCount); 1356 BlockSize += sizeof (EFI_HII_SIBT_SKIP1_BLOCK); 1357 break; 1358 1359 case EFI_HII_SIBT_SKIP2: 1360 CopyMem (&SkipCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16)); 1361 CurrentStringId = (UINT16)(CurrentStringId + SkipCount); 1362 BlockSize += sizeof (EFI_HII_SIBT_SKIP2_BLOCK); 1363 break; 1364 1365 case EFI_HII_SIBT_EXT1: 1366 CopyMem ( 1367 &Length8, 1368 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 1369 sizeof (UINT8) 1370 ); 1371 BlockSize += Length8; 1372 break; 1373 1374 case EFI_HII_SIBT_EXT2: 1375 CopyMem (&Ext2, BlockHdr, sizeof (EFI_HII_SIBT_EXT2_BLOCK)); 1376 BlockSize += Ext2.Length; 1377 break; 1378 1379 case EFI_HII_SIBT_EXT4: 1380 CopyMem ( 1381 &Length32, 1382 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)), 1383 sizeof (UINT32) 1384 ); 1385 1386 BlockSize += Length32; 1387 break; 1388 1389 default: 1390 break; 1391 } 1392 1393 BlockHdr = (UINT8 *)(StringBlockInfo + BlockSize); 1394 } 1395 1396 *TotalStringAdded = StringsAdded; 1397 return TRUE; 1398 } 1399 1400 /** 1401 Get x-UEFI-redfish string and language by string ID. 1402 1403 @param[in] FormsetPrivate Pointer to HII form-set private instance. 1404 @param[in] StringId The HII string ID. 1405 @param[out] String Optionally return USC string. 1406 @param[out] Language Optionally return x-UEFI-redfish language. 1407 @param[out] XuefiStringDatabase Optionally return x-UEFI-redfish database. 1408 1409 @retval EFI_SUCCESS String information is returned. 1410 EFI_INVALID_PARAMETER One of the given parameters to this function is 1411 invalid. 1412 EFI_NOT_FOUND String is not found. 1413 1414 **/ 1415 EFI_STATUS 1416 GetXuefiStringAndLangByStringId ( 1417 IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, 1418 IN EFI_STRING_ID StringId, 1419 OUT CHAR16 **String OPTIONAL, 1420 OUT CHAR8 **Language OPTIONAL, 1421 OUT REDFISH_X_UEFI_STRING_DATABASE **XuefiStringDatabase OPTIONAL 1422 ) 1423 { 1424 REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase; 1425 REDFISH_X_UEFI_STRINGS_ARRAY *StringArray; 1426 UINT16 StringIndex; 1427 1428 if ((String == NULL) && (Language == NULL) && (XuefiStringDatabase == NULL)) { 1429 DEBUG ((DEBUG_ERROR, "%a: Invalid parameters for this function.\n", __func__)); 1430 return EFI_INVALID_PARAMETER; 1431 } 1432 1433 if (IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) { 1434 return EFI_NOT_FOUND; 1435 } 1436 1437 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase); 1438 while (TRUE) { 1439 if (Language != NULL) { 1440 *Language = XuefiRedfishStringDatabase->XuefiRedfishLanguage; 1441 } 1442 1443 StringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays); 1444 1445 // Loop to the correct string array. 1446 StringIndex = StringId; 1447 while (StringIndex >= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) { 1448 if (IsNodeAtEnd (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &StringArray->NextArray)) { 1449 goto ErrorExit; 1450 } 1451 1452 StringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &StringArray->NextArray); 1453 StringIndex -= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER; 1454 } 1455 1456 // 1457 // NOTE: The string ID in the formset is a unique number. 1458 // If the string in the array is NULL, then the matched string ID 1459 // should be in another x-UEFI-redfish database. 1460 // 1461 if ((StringArray->ArrayEntryAddress + StringIndex)->UcsString != NULL) { 1462 // 1463 // String ID is belong to this x-uef-redfish language database. 1464 // 1465 if (String != NULL) { 1466 *String = (StringArray->ArrayEntryAddress + StringIndex)->UcsString; 1467 } 1468 1469 if (XuefiStringDatabase != NULL) { 1470 *XuefiStringDatabase = XuefiRedfishStringDatabase; 1471 } 1472 1473 return EFI_SUCCESS; 1474 } 1475 1476 if (IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage)) { 1477 return EFI_NOT_FOUND; 1478 } 1479 1480 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode ( 1481 &FormsetPrivate->XuefiRedfishStringDatabase, 1482 &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage 1483 ); 1484 } 1485 1486 ErrorExit:; 1487 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: String ID (%d) is not in any x-uef-redfish string databases.\n", __func__, StringId)); 1488 return EFI_NOT_FOUND; 1489 } 1490 1491 /** 1492 Build a x-UEFI-redfish database for the newly added x-UEFI-redfish language. 1493 1494 @param[in] FormsetPrivate Pointer to HII form-set private instance. 1495 1496 **/ 1497 VOID 1498 BuildXUefiRedfishStringDatabase ( 1499 IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate 1500 ) 1501 { 1502 EFI_STATUS Status; 1503 UINTN BufferSize; 1504 EFI_HII_PACKAGE_HEADER *PackageHeader; 1505 UINTN EndingPackageAddress; 1506 EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader; 1507 UINTN SupportedSchemaLangCount; 1508 CHAR8 **SupportedSchemaLang; 1509 BOOLEAN StringIdMapIsBuilt; 1510 UINTN TotalStringsAdded; 1511 UINTN NumberPackageStrings; 1512 1513 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: Building x-UEFI-redfish string database, HII Formset GUID - %g.\n", __func__, FormsetPrivate->Guid)); 1514 1515 BufferSize = 0; 1516 Status = mRedfishPlatformConfigPrivate->HiiDatabase->ExportPackageLists ( 1517 mRedfishPlatformConfigPrivate->HiiDatabase, 1518 FormsetPrivate->HiiHandle, 1519 &BufferSize, 1520 FormsetPrivate->HiiPackageListHeader 1521 ); 1522 if (Status != EFI_BUFFER_TOO_SMALL) { 1523 DEBUG ((DEBUG_ERROR, " Failed to export package list.\n")); 1524 return; 1525 } 1526 1527 FormsetPrivate->HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)AllocateZeroPool (BufferSize); 1528 if (FormsetPrivate->HiiPackageListHeader == NULL) { 1529 DEBUG ((DEBUG_ERROR, " Failed to allocate memory for the exported package list.\n")); 1530 return; 1531 } 1532 1533 Status = mRedfishPlatformConfigPrivate->HiiDatabase->ExportPackageLists ( 1534 mRedfishPlatformConfigPrivate->HiiDatabase, 1535 FormsetPrivate->HiiHandle, 1536 &BufferSize, 1537 FormsetPrivate->HiiPackageListHeader 1538 ); 1539 if (EFI_ERROR (Status)) { 1540 FreePool (FormsetPrivate->HiiPackageListHeader); 1541 FormsetPrivate->HiiPackageListHeader = NULL; 1542 return; 1543 } 1544 1545 TotalStringsAdded = 0; 1546 // 1547 // Finding the string package. 1548 // 1549 EndingPackageAddress = (UINTN)FormsetPrivate->HiiPackageListHeader + FormsetPrivate->HiiPackageListHeader->PackageLength; 1550 PackageHeader = (EFI_HII_PACKAGE_HEADER *)(FormsetPrivate->HiiPackageListHeader + 1); 1551 SupportedSchemaLang = FormsetPrivate->SupportedSchema.SchemaList; 1552 while ((UINTN)PackageHeader < EndingPackageAddress) { 1553 switch (PackageHeader->Type) { 1554 case EFI_HII_PACKAGE_STRINGS: 1555 StringIdMapIsBuilt = FALSE; 1556 HiiStringPackageHeader = (EFI_HII_STRING_PACKAGE_HDR *)PackageHeader; 1557 1558 // Check if this is the string package for x-UEFI-redfish 1559 for (SupportedSchemaLangCount = 0; 1560 SupportedSchemaLangCount < FormsetPrivate->SupportedSchema.Count; 1561 SupportedSchemaLangCount++ 1562 ) 1563 { 1564 if (AsciiStrnCmp ( 1565 *(SupportedSchemaLang + SupportedSchemaLangCount), 1566 HiiStringPackageHeader->Language, 1567 AsciiStrLen (HiiStringPackageHeader->Language) 1568 ) == 0) 1569 { 1570 StringIdMapIsBuilt = CreateXuefiLanguageStringIdMap (FormsetPrivate, HiiStringPackageHeader, &NumberPackageStrings); 1571 if (StringIdMapIsBuilt) { 1572 TotalStringsAdded += NumberPackageStrings; 1573 } 1574 1575 break; 1576 } 1577 } 1578 1579 if (StringIdMapIsBuilt == FALSE) { 1580 if (AsciiStrStr (HiiStringPackageHeader->Language, X_UEFI_SCHEMA_PREFIX) == NULL) { 1581 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " No need to build x-UEFI-redfish string ID map for HII language %a\n", HiiStringPackageHeader->Language)); 1582 } else { 1583 DEBUG ((DEBUG_ERROR, " Failed to build x-UEFI-redfish string ID map of HII language %a\n", HiiStringPackageHeader->Language)); 1584 } 1585 } 1586 1587 default: 1588 PackageHeader = (EFI_HII_PACKAGE_HEADER *)((UINTN)PackageHeader + PackageHeader->Length); 1589 } 1590 } 1591 1592 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " Total %d x-UEFI-redfish config language are added.\n", TotalStringsAdded)); 850 1593 } 851 1594 … … 856 1599 @param[out] FormsetPrivate The formset private data. 857 1600 858 @retval EFI_STATUS 1601 @retval EFI_STATUS The formset is loaded successfully. 1602 @retval EFI_UNSUPPORTED This formset doesn't have any x-UEFI-redfish configuration. 859 1603 860 1604 **/ … … 875 1619 EFI_GUID ZeroGuid; 876 1620 EXPRESS_RESULT ExpressionResult; 1621 CHAR16 *String; 877 1622 878 1623 if ((HiiHandle == NULL) || (FormsetPrivate == NULL)) { … … 882 1627 HiiFormSet = AllocateZeroPool (sizeof (HII_FORMSET)); 883 1628 if (HiiFormSet == NULL) { 1629 DEBUG ((DEBUG_ERROR, "%a: No memory resource for HII_FORMSET - %g\n", __func__, FormsetPrivate->Guid)); 884 1630 return EFI_OUT_OF_RESOURCES; 885 1631 } … … 891 1637 Status = CreateFormSetFromHiiHandle (HiiHandle, &ZeroGuid, HiiFormSet); 892 1638 if (EFI_ERROR (Status) || IsListEmpty (&HiiFormSet->FormListHead)) { 1639 DEBUG ((DEBUG_ERROR, "%a: Formset not found by HII handle - %g\n", __func__, FormsetPrivate->Guid)); 893 1640 Status = EFI_NOT_FOUND; 894 1641 goto ErrorExit; … … 909 1656 Status = GetSupportedSchema (FormsetPrivate->HiiHandle, &FormsetPrivate->SupportedSchema); 910 1657 if (EFI_ERROR (Status)) { 911 DEBUG ((REDFISH_PLATFORM_CONFIG_DEBUG, "%a: No schema from HII handle: 0x%x found: %r\n", __func__, FormsetPrivate->HiiHandle, Status)); 1658 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) { 1659 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: No x-UEFI-redfish configuration found on the formset - %g\n", __func__, FormsetPrivate->Guid)); 1660 // 1661 // If there is no x-UEFI-redfish language in this form-set, we don't add formset 1662 // since we don't need to build menu path for attribute registry. 1663 // 1664 return EFI_UNSUPPORTED; 1665 } 1666 } else { 1667 // Building x-UEFI-redfish string database 1668 BuildXUefiRedfishStringDatabase (FormsetPrivate); 912 1669 } 913 1670 … … 919 1676 if (HiiFormPrivate == NULL) { 920 1677 Status = EFI_OUT_OF_RESOURCES; 1678 DEBUG ((DEBUG_ERROR, "%a: No memory resource for REDFISH_PLATFORM_CONFIG_FORM_PRIVATE.\n", __func__)); 921 1679 goto ErrorExit; 922 1680 } … … 944 1702 HiiStatementPrivate = AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE)); 945 1703 if (HiiStatementPrivate == NULL) { 1704 DEBUG ((DEBUG_ERROR, "%a: No memory resource for REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE.\n", __func__)); 946 1705 Status = EFI_OUT_OF_RESOURCES; 947 1706 goto ErrorExit; … … 981 1740 } 982 1741 983 // 984 // Attach to statement list. 985 // 986 InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPrivate->Link); 1742 // Get x-UEFI-redfish string using String ID. 1743 Status = GetXuefiStringAndLangByStringId (FormsetPrivate, HiiStatementPrivate->Description, &String, NULL, NULL); 1744 if (!EFI_ERROR (Status)) { 1745 HiiStatementPrivate->XuefiRedfishStr = String; 1746 // 1747 // Attach to statement list. 1748 // 1749 InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPrivate->Link); 1750 } else { 1751 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) { 1752 // 1753 // If there is no x-UEFI-redfish language for this statement, we don't add this statement 1754 // since we don't need to build menu path for attribute registry. 1755 // 1756 FreePool (HiiStatementPrivate); 1757 } else { 1758 // 1759 // This is not x-UEFI-redfish string and we don't cache its string for searching Redfish configure language. 1760 // When caller wants the string, we will read English string by calling HiiGetString(). 1761 // 1762 HiiStatementPrivate->XuefiRedfishStr = NULL; 1763 // 1764 // Attach to statement list. 1765 // 1766 InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPrivate->Link); 1767 } 1768 } 1769 987 1770 HiiStatementLink = GetNextNode (&HiiForm->StatementListHead, HiiStatementLink); 988 1771 } … … 1052 1835 Status = LoadFormset (HiiHandle, FormsetPrivate); 1053 1836 if (EFI_ERROR (Status)) { 1054 DEBUG ((DEBUG_ERROR, "%a: failed to load formset: %r\n", __func__, Status));1837 DEBUG ((DEBUG_ERROR, "%a: Formset is not loaded for edk2 redfish: %r\n", __func__, Status)); 1055 1838 FreePool (FormsetPrivate); 1056 1839 return Status; … … 1063 1846 1064 1847 DEBUG_CODE ( 1848 if (RedfishPlatformConfigDebugProp (REDFISH_PLATFORM_CONFIG_DEBUG_DUMP_FORMSET)) { 1065 1849 DumpFormsetList (FormsetList); 1850 } 1851 1066 1852 ); 1067 1853 … … 1183 1969 TargetPendingList->IsDeleted = FALSE; 1184 1970 DEBUG_CODE ( 1185 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: HII handle: 0x%x is updated\n", __func__, HiiHandle));1971 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is updated\n", __func__, HiiHandle)); 1186 1972 ); 1187 1973 return EFI_SUCCESS; … … 1199 1985 1200 1986 DEBUG_CODE ( 1201 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: HII handle: 0x%x is created\n", __func__, HiiHandle));1987 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is created\n", __func__, HiiHandle)); 1202 1988 ); 1203 1989 … … 1236 2022 TargetPendingList->IsDeleted = TRUE; 1237 2023 DEBUG_CODE ( 1238 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: HII handle: 0x%x is updated and deleted\n", __func__, HiiHandle));2024 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is updated and deleted\n", __func__, HiiHandle)); 1239 2025 ); 1240 2026 return EFI_SUCCESS; … … 1252 2038 1253 2039 DEBUG_CODE ( 1254 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: HII handle: 0x%x is deleted\n", __func__, HiiHandle));2040 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is deleted\n", __func__, HiiHandle)); 1255 2041 ); 1256 2042 … … 1301 2087 FormsetPrivate = GetFormsetPrivateByHiiHandle (Target->HiiHandle, FormsetList); 1302 2088 if (FormsetPrivate != NULL) { 1303 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: formset: %g is removed because driver release HII resource it already\n", __func__, FormsetPrivate->Guid));2089 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: formset: %g is removed because driver release HII resource it already\n", __func__, FormsetPrivate->Guid)); 1304 2090 RemoveEntryList (&FormsetPrivate->Link); 1305 2091 ReleaseFormset (FormsetPrivate); 1306 2092 FreePool (FormsetPrivate); 1307 2093 } else { 1308 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: formset on HII handle 0x%x was removed already\n", __func__, Target->HiiHandle));2094 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: formset on HII handle 0x%x was removed already\n", __func__, Target->HiiHandle)); 1309 2095 } 1310 2096 } else { … … 1317 2103 // HII formset already exist, release it and query again. 1318 2104 // 1319 DEBUG (( REDFISH_PLATFORM_CONFIG_DEBUG, "%a: formset: %g is updated. Release current formset\n", __func__, &FormsetPrivate->Guid));2105 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: formset: %g is updated. Release current formset\n", __func__, &FormsetPrivate->Guid)); 1320 2106 RemoveEntryList (&FormsetPrivate->Link); 1321 2107 ReleaseFormset (FormsetPrivate); … … 1325 2111 Status = LoadFormsetList (Target->HiiHandle, FormsetList); 1326 2112 if (EFI_ERROR (Status)) { 1327 DEBUG ((DEBUG_ERROR, "%a: load formset from HII handle: 0x%x failed: %r\n", __func__, Target->HiiHandle, Status)); 2113 if (Status == EFI_UNSUPPORTED) { 2114 DEBUG ((DEBUG_ERROR, " The formset has no x-UEFI-redfish configurations.\n")); 2115 } else { 2116 DEBUG ((DEBUG_ERROR, " load formset from HII handle: 0x%x failed: %r\n", Target->HiiHandle, Status)); 2117 } 1328 2118 } 1329 2119 } -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigImpl.h
r101291 r105670 3 3 4 4 (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR> 5 Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 6 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 6 7 7 8 SPDX-License-Identifier: BSD-2-Clause-Patent … … 29 30 #define IS_EMPTY_STRING(a) (a == NULL || a[0] == L'\0') 30 31 #define ENGLISH_LANGUAGE_CODE "en-US" 31 #define X_UEFI_SCHEMA_PREFIX "x-uefi-redfish-" 32 #define X_UEFI_SCHEMA_PREFIX "x-UEFI-redfish-" 33 34 #define MAX_X_UEFI_REDFISH_STRING_SIZE (128 * 2)// 128 character in UCS. 35 36 typedef struct _REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE; 32 37 33 38 // … … 47 52 } REDFISH_PLATFORM_CONFIG_SCHEMA; 48 53 54 // Defines the number of elements in array 55 #define X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER 1024 56 57 // 58 // Definition of x-UEFI-redfish string element. 59 // 60 typedef struct { 61 EFI_STRING_ID StringId; 62 CHAR16 *UcsString; 63 } REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT; 64 65 // 66 // Discrete string array buffer, each has X_UEFI_REDFISH_STRING_ARRAY_NUMBER element. 67 // 68 typedef struct { 69 LIST_ENTRY NextArray; 70 REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT *ArrayEntryAddress; 71 } REDFISH_X_UEFI_STRINGS_ARRAY; 72 73 // 74 // x-UEFI-redfish string database, x-UEFI-redfish language based. 75 // 76 typedef struct { 77 LIST_ENTRY NextXuefiRedfishLanguage; // Link to the next suppoted x-UEFI-Redfish language. 78 CHAR8 *XuefiRedfishLanguage; // x-UEFI-redfish language. 79 UINTN StringsArrayBlocks; // Number of the array blocks that accommodate X_UEFI_REDFISH_STRING_ARRAY_NUMBER 80 // elements in each. 81 LIST_ENTRY XuefiRedfishStringArrays; // Link entry of x-UEFI-redfish string array. 82 } REDFISH_X_UEFI_STRING_DATABASE; 83 49 84 // 50 85 // Definition of REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE … … 52 87 typedef struct { 53 88 LIST_ENTRY Link; 54 HII_FORMSET *HiiFormSet; // Pointer to HII formset data. 55 EFI_GUID Guid; // Formset GUID. 56 EFI_HII_HANDLE HiiHandle; // Hii Handle of this formset. 57 LIST_ENTRY HiiFormList; // Form list that keep form data under this formset. 58 CHAR16 *DevicePathStr; // Device path of this formset. 59 REDFISH_PLATFORM_CONFIG_SCHEMA SupportedSchema; // Schema that is supported in this formset. 89 HII_FORMSET *HiiFormSet; // Pointer to HII formset data. 90 EFI_GUID Guid; // Formset GUID. 91 EFI_HII_HANDLE HiiHandle; // Hii Handle of this formset. 92 EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader; // Hii Package list header. 93 LIST_ENTRY HiiFormList; // Form list that keep form data under this formset. 94 CHAR16 *DevicePathStr; // Device path of this formset. 95 REDFISH_PLATFORM_CONFIG_SCHEMA SupportedSchema; // Schema that is supported in this formset. 96 LIST_ENTRY XuefiRedfishStringDatabase; // x-UEFI-redfish string/Id data base; 60 97 } REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE; 61 98 … … 91 128 // Definition of REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE 92 129 // 93 typedef struct{130 struct _REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE { 94 131 LIST_ENTRY Link; 95 132 REDFISH_PLATFORM_CONFIG_FORM_PRIVATE *ParentForm; 96 HII_STATEMENT *HiiStatement; // Pointer to HII statement data.97 EFI_QUESTION_ID QuestionId; // Question ID of this statement.98 EFI_STRING_ID Description; // String token of this question.99 EFI_STRING_ID Help; // String token of help message.100 EFI_STRING DesStringCache; // The string cache for search function.101 UINT8 Flags; // The statement flag.102 REDFISH_PLATFORM_CONFIG_STATEMENT_DATA StatementData; // The max/min for statement value.103 BOOLEAN Suppressed; // Statement is suppressed.104 BOOLEAN GrayedOut; // Statement is GrayedOut.105 } REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE;133 HII_STATEMENT *HiiStatement; // Pointer to HII statement data. 134 EFI_QUESTION_ID QuestionId; // Question ID of this statement. 135 EFI_STRING_ID Description; // String token of this question. 136 CHAR16 *XuefiRedfishStr; // x-UEFI-redfish string of this question. 137 EFI_STRING_ID Help; // String token of help message. 138 UINT8 Flags; // The statement flag. 139 REDFISH_PLATFORM_CONFIG_STATEMENT_DATA StatementData; // The max/min for statement value. 140 BOOLEAN Suppressed; // Statement is suppressed. 141 BOOLEAN GrayedOut; // Statement is GrayedOut. 142 }; 106 143 107 144 #define REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK(a) BASE_CR (a, REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE, Link) … … 348 385 ); 349 386 387 /** 388 Return the HII string length. We don't check word alignment 389 of the input string as the same as the checking in StrLen 390 function. Because the HII string in the database is compact 391 at the byte alignment. 392 393 @param[in] String Input UCS format string. 394 395 @retval Length of 396 397 **/ 398 UINTN 399 EFIAPI 400 HiiStrLen ( 401 IN CONST CHAR16 *String 402 ); 403 404 /** 405 Return the HII string size. We don't check word alignment 406 of the input string as the same as the checking in StrLen 407 function. Because the HII string in the database is compact 408 at the byte alignment. 409 410 @param[in] String Input UCS format string. 411 412 @retval Size of the string. 413 414 **/ 415 UINTN 416 EFIAPI 417 HiiStrSize ( 418 IN CONST CHAR16 *String 419 ); 420 421 /** 422 Check if the debug property is enabled or not. 423 424 @param[in] DebugType Debug enablement type 425 426 @retval TRUE, the debug property is enabled. 427 FALSE, the debug property is not enabled. 428 429 **/ 430 BOOLEAN 431 RedfishPlatformConfigDebugProp ( 432 IN UINT64 DebugProp 433 ); 434 435 /** 436 Check if the Platform Configure feature is enabled or not. 437 438 @param[in] FeatureType Redfish platform config feature enablement 439 440 @retval TRUE, the feature is enabled. 441 FALSE, the feature is not enabled. 442 443 **/ 444 BOOLEAN 445 RedfishPlatformConfigFeatureProp ( 446 IN UINT64 FeatureProp 447 ); 448 350 449 #endif -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c
r101291 r105670 5 5 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 6 6 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 7 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 7 8 8 9 SPDX-License-Identifier: BSD-2-Clause-Patent … … 357 358 ) 358 359 { 360 EFI_STATUS Status; 361 UINT32 *Id; 362 363 Status = gBS->OpenProtocol ( 364 ControllerHandle, 365 &gEfiCallerIdGuid, 366 (VOID **)&Id, 367 This->DriverBindingHandle, 368 ControllerHandle, 369 EFI_OPEN_PROTOCOL_GET_PROTOCOL 370 ); 371 if (!EFI_ERROR (Status)) { 372 return EFI_ALREADY_STARTED; 373 } 374 359 375 // 360 376 // Test for the HttpServiceBinding Protocol. … … 587 603 588 604 /** 605 Callback function that is invoked when HTTP event occurs. 606 607 @param[in] This Pointer to the EDKII_HTTP_CALLBACK_PROTOCOL instance. 608 @param[in] Event The event that occurs in the current state. 609 @param[in] EventStatus The Status of Event, EFI_SUCCESS or other errors. 610 **/ 611 VOID 612 EFIAPI 613 RestExHttpCallback ( 614 IN EDKII_HTTP_CALLBACK_PROTOCOL *This, 615 IN EDKII_HTTP_CALLBACK_EVENT Event, 616 IN EFI_STATUS EventStatus 617 ) 618 { 619 EFI_STATUS Status; 620 EFI_TLS_PROTOCOL *TlsProtocol; 621 RESTEX_INSTANCE *Instance; 622 EFI_TLS_VERIFY TlsVerifyMethod; 623 624 if ((Event == HttpEventTlsConfigured) && (EventStatus == EFI_SUCCESS)) { 625 // Reconfigure TLS configuration data. 626 Instance = RESTEX_INSTANCE_FROM_HTTP_CALLBACK (This); 627 Status = gBS->HandleProtocol ( 628 Instance->HttpIo.Handle, 629 &gEfiTlsProtocolGuid, 630 (VOID **)&TlsProtocol 631 ); 632 if (EFI_ERROR (Status)) { 633 return; 634 } 635 636 TlsVerifyMethod = EFI_TLS_VERIFY_NONE; 637 Status = TlsProtocol->SetSessionData ( 638 TlsProtocol, 639 EfiTlsVerifyMethod, 640 &TlsVerifyMethod, 641 sizeof (EFI_TLS_VERIFY) 642 ); 643 if (!EFI_ERROR (Status)) { 644 DEBUG ((DEBUG_MANAGEABILITY, "%a: REST EX reconfigures TLS verify method.\n", __func__)); 645 } 646 } 647 648 return; 649 } 650 651 /** 589 652 Creates a child handle and installs a protocol. 590 653 … … 700 763 } 701 764 765 // Initial HTTP callback funciton on this REST EX instance 766 Instance->HttpCallbakFunction.Callback = RestExHttpCallback; 767 Status = gBS->InstallProtocolInterface ( 768 &Instance->HttpIo.Handle, 769 &gEdkiiHttpCallbackProtocolGuid, 770 EFI_NATIVE_INTERFACE, 771 &Instance->HttpCallbakFunction 772 ); 773 if (EFI_ERROR (Status)) { 774 DEBUG ((DEBUG_ERROR, "%a: Fail to install HttpCallbakFunction.\n", __func__)); 775 goto ON_ERROR; 776 } 777 702 778 // 703 779 // Add it to the parent's child list. … … 813 889 ); 814 890 891 // 892 // Uninstall the HTTP callback protocol. 893 // 894 Status = gBS->UninstallProtocolInterface ( 895 Instance->HttpIo.Handle, 896 &gEdkiiHttpCallbackProtocolGuid, 897 &Instance->HttpCallbakFunction 898 ); 899 815 900 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 816 901 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
r101291 r105670 5 5 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 6 6 Copyright (c) 2023, Ampere Computing LLC. All rights reserved.<BR> 7 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 7 8 8 9 SPDX-License-Identifier: BSD-2-Clause-Patent … … 33 34 #include <Protocol/RestEx.h> 34 35 #include <Protocol/ServiceBinding.h> 36 #include <Protocol/HttpCallback.h> 37 #include <Protocol/Tls.h> 35 38 36 39 /// … … 67 70 #define RESTEX_INSTANCE_FROM_THIS(a) \ 68 71 CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE) 72 73 #define RESTEX_INSTANCE_FROM_HTTP_CALLBACK(a) \ 74 CR (a, RESTEX_INSTANCE, HttpCallbakFunction, RESTEX_INSTANCE_SIGNATURE) 69 75 70 76 #define RESTEX_STATE_UNCONFIGED 0 … … 95 101 96 102 struct _RESTEX_INSTANCE { 97 UINT32 Signature;98 LIST_ENTRY Link;99 100 EFI_REST_EX_PROTOCOL RestEx;101 102 INTN State;103 BOOLEAN InDestroy;104 105 RESTEX_SERVICE *Service;106 EFI_HANDLE ChildHandle;107 108 EFI_REST_EX_CONFIG_DATA ConfigData;103 UINT32 Signature; 104 LIST_ENTRY Link; 105 106 EFI_REST_EX_PROTOCOL RestEx; 107 108 INTN State; 109 BOOLEAN InDestroy; 110 111 RESTEX_SERVICE *Service; 112 EFI_HANDLE ChildHandle; 113 114 EFI_REST_EX_CONFIG_DATA ConfigData; 109 115 110 116 // 111 117 // HTTP_IO to access the HTTP service 112 118 // 113 HTTP_IO HttpIo; 114 115 UINT32 Flags; 119 HTTP_IO HttpIo; 120 121 // 122 // EDKII_HTTP_CALLBACK_PROTOCOL that listens to 123 // HttpEventInitSession event. 124 // 125 EDKII_HTTP_CALLBACK_PROTOCOL HttpCallbakFunction; 126 127 UINT32 Flags; 116 128 }; 117 129 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf
r101291 r105670 6 6 # Copyright (c) 2023, American Megatrends International LLC. 7 7 # Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 8 # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 8 9 # 9 10 # SPDX-License-Identifier: BSD-2-Clause-Patent … … 58 59 gEfiHttpProtocolGuid ## TO_START 59 60 gEfiDevicePathProtocolGuid ## TO_START 61 gEdkiiHttpCallbackProtocolGuid ## CONSUMES 62 gEfiTlsProtocolGuid ## CONSUMES 60 63 61 64 [Pcd] -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c
r101291 r105670 30 30 request to the REST resource identified by RequestMessage.Request.Url. The 31 31 ResponseMessage is the returned HTTP response for that request, including any HTTP 32 status. 32 status. It's caller's responsibility to free this ResponseMessage using FreePool(). 33 RestConfigFreeHttpMessage() in RedfishLib is an example to release ResponseMessage structure. 33 34 34 35 @param[in] This Pointer to EFI_REST_EX_PROTOCOL instance for a particular … … 321 322 DumpHttpStatusCode (DEBUG_REDFISH_NETWORK, ResponseData->Response.StatusCode); 322 323 Status = EFI_UNSUPPORTED; 324 325 // 326 // Deliver status code back to caller so caller can handle it. 327 // 328 ResponseMessage->Data.Response = AllocateZeroPool (sizeof (EFI_HTTP_RESPONSE_DATA)); 329 if (ResponseMessage->Data.Response == NULL) { 330 Status = EFI_OUT_OF_RESOURCES; 331 goto ON_EXIT; 332 } 333 334 ResponseMessage->Data.Response->StatusCode = ResponseData->Response.StatusCode; 335 323 336 goto ON_EXIT; 324 337 } … … 442 455 if (ResponseData != NULL) { 443 456 FreePool (ResponseData); 444 }445 446 if (EFI_ERROR (Status)) {447 if (ResponseMessage->Data.Response != NULL) {448 FreePool (ResponseMessage->Data.Response);449 ResponseMessage->Data.Response = NULL;450 }451 452 if (ResponseMessage->Body != NULL) {453 FreePool (ResponseMessage->Body);454 ResponseMessage->Body = NULL;455 }456 457 } 457 458 -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.c
r99404 r105670 5 5 6 6 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 7 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 7 8 8 9 SPDX-License-Identifier: BSD-2-Clause-Patent … … 11 12 12 13 #include <Uefi.h> 14 #include <Library/DebugLib.h> 13 15 #include <Protocol/RestJsonStructure.h> 14 16 #include "RestJsonStructureInternal.h" … … 73 75 } 74 76 77 DEBUG ((DEBUG_MANAGEABILITY, "%a: %d REST JSON-C interpreter(s) to register for the name spaces.\n", __func__, NumberOfNS)); 78 75 79 Instance = 76 80 (REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); … … 89 93 for (Index = 0; Index < NumberOfNS; Index++) { 90 94 CopyMem ((VOID *)CloneSupportedInterpId, (VOID *)&ThisSupportedInterp->RestResourceInterp, sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER)); 95 DEBUG ((DEBUG_MANAGEABILITY, " Resource type : %a\n", ThisSupportedInterp->RestResourceInterp.NameSpace.ResourceTypeName)); 96 DEBUG ((DEBUG_MANAGEABILITY, " Major version : %a\n", ThisSupportedInterp->RestResourceInterp.NameSpace.MajorVersion)); 97 DEBUG ((DEBUG_MANAGEABILITY, " Minor version : %a\n", ThisSupportedInterp->RestResourceInterp.NameSpace.MinorVersion)); 98 DEBUG ((DEBUG_MANAGEABILITY, " Errata version: %a\n\n", ThisSupportedInterp->RestResourceInterp.NameSpace.ErrataVersion)); 91 99 ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink; 92 100 CloneSupportedInterpId++; … … 125 133 EFI_STATUS Status; 126 134 EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; 135 136 DEBUG ((DEBUG_MANAGEABILITY, "%a: Entry\n", __func__)); 127 137 128 138 if ((This == NULL) || … … 147 157 RestJSonHeader 148 158 ); 159 if (EFI_ERROR (Status)) { 160 if (Status == EFI_UNSUPPORTED) { 161 DEBUG (( 162 DEBUG_MANAGEABILITY, 163 "%a %a.%a.%a REST JSON to C structure interpreter has no capability to interpret the resource.\n", 164 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.ResourceTypeName, 165 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.MajorVersion, 166 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.MinorVersion, 167 InterpreterInstance->SupportedRsrcIndentifier->NameSpace.ErrataVersion 168 )); 169 } else { 170 DEBUG ((DEBUG_MANAGEABILITY, "REST JsonToStructure returns failure - %r\n", Status)); 171 } 172 } 149 173 } else { 150 174 // 151 // Check if the names apce and version is supported by this interpreter.175 // Check if the namespace and version is supported by this interpreter. 152 176 // 153 177 ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier; … … 172 196 RestJSonHeader 173 197 ); 198 if (EFI_ERROR (Status)) { 199 DEBUG ((DEBUG_MANAGEABILITY, "Don't check version of this resource type identifier JsonToStructure returns %r\n", Status)); 200 DEBUG ((DEBUG_MANAGEABILITY, " Supported ResourceTypeName = %a\n", ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName)); 201 } 202 174 203 break; 175 204 } else { … … 196 225 RestJSonHeader 197 226 ); 227 if (EFI_ERROR (Status)) { 228 DEBUG ((DEBUG_MANAGEABILITY, "Check version of this resource type identifier JsonToStructure returns %r\n", Status)); 229 DEBUG ((DEBUG_MANAGEABILITY, " Supported ResourceTypeName = %a\n", ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName)); 230 DEBUG ((DEBUG_MANAGEABILITY, " Supported MajorVersion = %a\n", ThisSupportedRsrcTypeId->NameSpace.MajorVersion)); 231 DEBUG ((DEBUG_MANAGEABILITY, " Supported MinorVersion = %a\n", ThisSupportedRsrcTypeId->NameSpace.MinorVersion)); 232 DEBUG ((DEBUG_MANAGEABILITY, " Supported ErrataVersion = %a\n", ThisSupportedRsrcTypeId->NameSpace.ErrataVersion)); 233 } 234 198 235 break; 199 236 } … … 232 269 EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId; 233 270 EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier; 271 272 DEBUG ((DEBUG_MANAGEABILITY, "%a: Entry\n", __func__)); 234 273 235 274 if ((This == NULL) || … … 285 324 ResourceRaw 286 325 ); 326 if (EFI_ERROR (Status)) { 327 DEBUG ((DEBUG_MANAGEABILITY, "StructureToJson returns %r\n", Status)); 328 DEBUG ((DEBUG_MANAGEABILITY, " Supported ResourceTypeName = %a\n", ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName)); 329 DEBUG ((DEBUG_MANAGEABILITY, " Supported MajorVersion = %a\n", ThisSupportedRsrcTypeId->NameSpace.MajorVersion)); 330 DEBUG ((DEBUG_MANAGEABILITY, " Supported MinorVersion = %a\n", ThisSupportedRsrcTypeId->NameSpace.MinorVersion)); 331 DEBUG ((DEBUG_MANAGEABILITY, " Supported ErrataVersion = %a\n", ThisSupportedRsrcTypeId->NameSpace.ErrataVersion)); 332 } 333 287 334 break; 288 335 } … … 417 464 } 418 465 466 if (RsrcTypeIdentifier != NULL) { 467 DEBUG ((DEBUG_MANAGEABILITY, "%a: Looking for the REST JSON to C Structure converter:\n", __func__)); 468 if (RsrcTypeIdentifier->NameSpace.ResourceTypeName != NULL) { 469 DEBUG ((DEBUG_MANAGEABILITY, " ResourceType: %a\n", RsrcTypeIdentifier->NameSpace.ResourceTypeName)); 470 } else { 471 DEBUG ((DEBUG_MANAGEABILITY, " ResourceType: NULL")); 472 } 473 474 if (RsrcTypeIdentifier->NameSpace.MajorVersion != NULL) { 475 DEBUG ((DEBUG_MANAGEABILITY, " MajorVersion: %a\n", RsrcTypeIdentifier->NameSpace.MajorVersion)); 476 } else { 477 DEBUG ((DEBUG_MANAGEABILITY, " MajorVersion: NULL")); 478 } 479 480 if (RsrcTypeIdentifier->NameSpace.MinorVersion != NULL) { 481 DEBUG ((DEBUG_MANAGEABILITY, " MinorVersion: %a\n", RsrcTypeIdentifier->NameSpace.MinorVersion)); 482 } else { 483 DEBUG ((DEBUG_MANAGEABILITY, " MinorVersion: NULL")); 484 } 485 486 if (RsrcTypeIdentifier->NameSpace.ErrataVersion != NULL) { 487 DEBUG ((DEBUG_MANAGEABILITY, " ErrataVersion: %a\n", RsrcTypeIdentifier->NameSpace.ErrataVersion)); 488 } else { 489 DEBUG ((DEBUG_MANAGEABILITY, " ErrataVersion: NULL")); 490 } 491 } else { 492 DEBUG ((DEBUG_MANAGEABILITY, "%a: RsrcTypeIdentifier is given as NULL, go through all of the REST JSON to C structure interpreters.\n", __func__)); 493 } 494 419 495 Status = EFI_SUCCESS; 420 496 Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList); … … 428 504 ); 429 505 if (!EFI_ERROR (Status)) { 506 DEBUG ((DEBUG_MANAGEABILITY, "%a: REST JSON to C structure is interpreted successfully.\n", __func__)); 430 507 break; 431 508 } 432 509 433 510 if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) { 511 DEBUG ((DEBUG_ERROR, "%a: No REST JSON to C structure interpreter found.\n", __func__)); 434 512 Status = EFI_UNSUPPORTED; 435 513 break; … … 484 562 485 563 if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) { 564 DEBUG ((DEBUG_ERROR, "%a: No REST JSON to C structure interpreter found.\n", __func__)); 486 565 Status = EFI_UNSUPPORTED; 487 566 break; … … 513 592 ) 514 593 { 515 EFI_STATUS Status; 516 REST_JSON_STRUCTURE_INSTANCE *Instance; 594 EFI_STATUS Status; 595 REST_JSON_STRUCTURE_INSTANCE *Instance; 596 EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier; 517 597 518 598 if ((This == NULL) || (RestJSonHeader == NULL) || (ResourceRaw == NULL)) { … … 523 603 return EFI_UNSUPPORTED; 524 604 } 605 606 RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier; 607 DEBUG ((DEBUG_MANAGEABILITY, "Looking for the REST C Structure to JSON resource converter:\n")); 608 DEBUG ((DEBUG_MANAGEABILITY, " ResourceType : %a\n", RsrcTypeIdentifier->NameSpace.ResourceTypeName)); 609 DEBUG ((DEBUG_MANAGEABILITY, " MajorVersion : %a\n", RsrcTypeIdentifier->NameSpace.MajorVersion)); 610 DEBUG ((DEBUG_MANAGEABILITY, " MinorVersion : %a\n", RsrcTypeIdentifier->NameSpace.MinorVersion)); 611 DEBUG ((DEBUG_MANAGEABILITY, " ErrataVersion: %a\n", RsrcTypeIdentifier->NameSpace.ErrataVersion)); 525 612 526 613 Status = EFI_SUCCESS; … … 538 625 539 626 if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) { 627 DEBUG ((DEBUG_ERROR, "%a: No REST C structure to JSON interpreter found.\n", __func__)); 540 628 Status = EFI_UNSUPPORTED; 541 629 break; … … 588 676 589 677 /** 590 This is the unload handle for R edfish discovermodule.678 This is the unload handle for REST JSON to C structure module. 591 679 592 680 Disconnect the driver specified by ImageHandle from all the devices in the handle database. -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.inf
r89983 r105670 3 3 # 4 4 # (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 5 # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 5 6 # SPDX-License-Identifier: BSD-2-Clause-Patent 6 7 ## … … 18 19 MdePkg/MdePkg.dec 19 20 MdeModulePkg/MdeModulePkg.dec 20 RedfishPkg/RedfishPkg.dec21 21 22 22 [Sources] … … 27 27 BaseLib 28 28 BaseMemoryLib 29 DebugLib 29 30 MemoryAllocationLib 30 31 UefiBootServicesTableLib -
trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RestJsonStructureDxe/RestJsonStructureInternal.h
r99404 r105670 4 4 5 5 (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> 6 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR> 6 7 7 8 SPDX-License-Identifier: BSD-2-Clause-Patent … … 26 27 LIST_ENTRY NextRestJsonStructureInstance; ///< Next convertor instance 27 28 UINTN NumberOfNameSpaceToConvert; ///< Number of resource type this convertor supports. 28 EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *SupportedRsrcIndentifier; ///< The resource type linklist29 EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *SupportedRsrcIndentifier; ///< The supported resource type array. 29 30 EFI_REST_JSON_STRUCTURE_TO_STRUCTURE JsonToStructure; ///< JSON to C structure function 30 31 EFI_REST_JSON_STRUCTURE_TO_JSON StructureToJson; ///< C structure to JSON function
Note:
See TracChangeset
for help on using the changeset viewer.