public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
@ 2024-01-26  1:00 Chang, Abner via groups.io
  2024-01-26  2:20 ` Nickle Wang via groups.io
  0 siblings, 1 reply; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-26  1:00 UTC (permalink / raw)
  To: devel; +Cc: Nickle Wang, Igor Kulchytskyy

From: Abner Chang <abner.chang@amd.com>

Initial version of edk2 Redfish feature of
Redfish schema ComputerSystem_1_13_0. This driver
handles ComputerSystem Boot properties but not all.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 .../v1_13_0/Dxe/ComputerSystemDxe.inf         |  53 ++
 .../v1_13_0/Common/ComputerSystemCommon.h     |  29 +
 .../v1_13_0/Common/ComputerSystemCommon.c     | 899 ++++++++++++++++++
 .../v1_13_0/Dxe/ComputerSystemDxe.c           | 702 ++++++++++++++
 4 files changed, 1683 insertions(+)
 create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf
 create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.h
 create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c
 create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c

diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf
new file mode 100644
index 0000000000..6bc5cb358e
--- /dev/null
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.inf
@@ -0,0 +1,53 @@
+## @file
+#
+#  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+#  Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+
+[Defines]
+  INF_VERSION               = 0x00010005
+  BASE_NAME                 = ComputerSystemDxe
+  FILE_GUID                 = D94362A1-C358-4059-B014-F07D1AE04F16
+  MODULE_TYPE               = DXE_DRIVER
+  VERSION_STRING            = 1.0
+  ENTRY_POINT               = RedfishResourceEntryPoint
+  UNLOAD_IMAGE              = RedfishResourceUnload
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  RedfishPkg/RedfishPkg.dec
+  RedfishClientPkg/RedfishClientPkg.dec
+
+[Sources]
+  ../Common/ComputerSystemCommon.h
+  ../Common/ComputerSystemCommon.c
+  ComputerSystemDxe.c
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  EdkIIRedfishResourceConfigLib
+  RedfishLib
+  RedfishFeatureUtilityLib
+  RedfishResourceIdentifyLib
+  UefiLib
+  UefiDriverEntryPoint
+  RedfishAddendumLib
+  RedfishHttpCacheLib
+
+[Protocols]
+  gEdkIIRedfishConfigHandlerProtocolGuid          ## PRODUCED
+  gEfiRestJsonStructureProtocolGuid               ## CONSUMED
+  gEdkIIRedfishResourceConfigProtocolGuid         ## PRODUCED
+
+[Pcd]
+  gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize
+  gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize
+
+[Depex]
+  TRUE
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.h b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.h
new file mode 100644
index 0000000000..c9c8512881
--- /dev/null
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.h
@@ -0,0 +1,29 @@
+/** @file
+
+  Redfish feature driver implementation - internal header file
+  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_
+#define EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_
+
+#include <RedfishJsonStructure/ComputerSystem/v1_13_0/EfiComputerSystemV1_13_0.h>
+#include <RedfishResourceCommon.h>
+
+//
+// Schema information.
+//
+#define RESOURCE_SCHEMA          "ComputerSystem"
+#define RESOURCE_SCHEMA_MAJOR    "1"
+#define RESOURCE_SCHEMA_MINOR    "13"
+#define RESOURCE_SCHEMA_ERRATA   "0"
+#define RESOURCE_SCHEMA_VERSION  "v1_13_0"
+#define REDPATH_ARRAY_PATTERN    L"/Systems/\\{.*\\}/"
+#define REDPATH_ARRAY_PREFIX     L"/Systems/"
+#define RESOURCE_SCHEMA_FULL     "x-uefi-redfish-ComputerSystem.v1_13_0"
+
+#endif
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c
new file mode 100644
index 0000000000..bc24c49206
--- /dev/null
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSystemCommon.c
@@ -0,0 +1,899 @@
+/** @file
+  Redfish feature driver implementation - common functions
+
+  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "ComputerSystemCommon.h"
+
+CHAR8  ComputerSystemEmptyJson[] = "{\"@odata.id\": \"\", \"@odata.type\": \"#ComputerSystem.v1_13_0.ComputerSystem\", \"Id\": \"\", \"Name\": \"\", \"Boot\":{}}";
+
+REDFISH_RESOURCE_COMMON_PRIVATE  *mRedfishResourcePrivate             = NULL;
+EFI_HANDLE                       mRedfishResourceConfigProtocolHandle = NULL;
+
+/**
+  Consume resource from given URI.
+
+  @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
+  @param[in]   Json                The JSON to consume.
+  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+RedfishConsumeResourceCommon (
+  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
+  IN  CHAR8                            *Json,
+  IN  CHAR8                            *HeaderEtag OPTIONAL
+  )
+{
+  EFI_STATUS                             Status;
+  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystem;
+  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCs;
+  EFI_STRING                             ConfigureLang;
+
+  if ((Private == NULL) || IS_EMPTY_STRING (Json)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  ComputerSystem   = NULL;
+  ComputerSystemCs = NULL;
+  ConfigureLang    = NULL;
+
+  Status = Private->JsonStructProtocol->ToStructure (
+                                          Private->JsonStructProtocol,
+                                          NULL,
+                                          Json,
+                                          (EFI_REST_JSON_STRUCTURE_HEADER **)&ComputerSystem
+                                          );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, Status));
+    return Status;
+  }
+
+  ComputerSystemCs = ComputerSystem->ComputerSystem;
+
+  //
+  // Check ETAG to see if we need to consume it
+  //
+  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
+    //
+    // No change
+    //
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore consume action\n", __func__, Private->Uri));
+    Status = EFI_SUCCESS;
+    goto ON_RELEASE;
+  }
+
+  //
+  // Handle BOOT
+  //
+  if (ComputerSystemCs->Boot == NULL) {
+    ComputerSystemCs->Boot = AllocateZeroPool (sizeof (RedfishComputerSystem_V1_13_0_Boot_CS));
+    ASSERT (ComputerSystemCs->Boot != NULL);
+  }
+
+  //
+  // Handle BOOT->BOOTNEXT
+  //
+  if (ComputerSystemCs->Boot->BootNext != NULL) {
+    //
+    // Find corresponding configure language for collection resource.
+    //
+    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id, "Boot/BootNext");
+    if (ConfigureLang != NULL) {
+      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootNext);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __func__, ConfigureLang, Status));
+      }
+
+      FreePool (ConfigureLang);
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s\n", __func__, Private->Uri));
+    }
+  }
+
+  //
+  // Handle BOOT->BOOTORDER
+  //
+  if (ComputerSystemCs->Boot->BootOrder != NULL) {
+    //
+    // Find corresponding configure language for collection resource.
+    //
+    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id, "Boot/BootOrder");
+    if (ConfigureLang != NULL) {
+      Status = ApplyFeatureSettingsStringArrayType (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootOrder);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__, ConfigureLang, Status));
+      }
+
+      FreePool (ConfigureLang);
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: %s\n", __func__, Private->Uri));
+    }
+  }
+
+  //
+  // Handle BOOT->BOOTSOURCEOVERRIDEENABLED
+  //
+  if (ComputerSystemCs->Boot->BootSourceOverrideEnabled != NULL) {
+    //
+    // Find corresponding configure language for collection resource.
+    //
+    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id, "Boot/BootSourceOverrideEnabled");
+    if (ConfigureLang != NULL) {
+      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootSourceOverrideEnabled);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__, ConfigureLang, Status));
+      }
+
+      FreePool (ConfigureLang);
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: %s\n", __func__, Private->Uri));
+    }
+  }
+
+  //
+  // Handle BOOT->BOOTSOURCEOVERRIDEMODE
+  //
+  if (ComputerSystemCs->Boot->BootSourceOverrideMode != NULL) {
+    //
+    // Find corresponding configure language for collection resource.
+    //
+    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id, "Boot/BootSourceOverrideMode");
+    if (ConfigureLang != NULL) {
+      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootSourceOverrideMode);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__, ConfigureLang, Status));
+      }
+
+      FreePool (ConfigureLang);
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: %s\n", __func__, Private->Uri));
+    }
+  }
+
+  //
+  // Handle BOOT->BOOTSOURCEOVERRIDETARGET
+  //
+  if (ComputerSystemCs->Boot->BootSourceOverrideTarget != NULL) {
+    //
+    // Find corresponding configure language for collection resource.
+    //
+    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id, "Boot/BootSourceOverrideTarget");
+    if (ConfigureLang != NULL) {
+      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootSourceOverrideTarget);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __func__, ConfigureLang, Status));
+      }
+
+      FreePool (ConfigureLang);
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s\n", __func__, Private->Uri));
+    }
+  }
+
+  //
+  // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE
+  //
+  if (ComputerSystemCs->Boot->UefiTargetBootSourceOverride != NULL) {
+    //
+    // Find corresponding configure language for collection resource.
+    //
+    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id, "Boot/UefiTargetBootSourceOverride");
+    if (ConfigureLang != NULL) {
+      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->UefiTargetBootSourceOverride);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__, ConfigureLang, Status));
+      }
+
+      FreePool (ConfigureLang);
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: %s\n", __func__, Private->Uri));
+    }
+  }
+
+ON_RELEASE:
+
+  //
+  // Release resource.
+  //
+  Private->JsonStructProtocol->DestoryStructure (
+                                 Private->JsonStructProtocol,
+                                 (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
+                                 );
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ProvisioningComputerSystemProperties (
+  IN  EFI_REST_JSON_STRUCTURE_PROTOCOL  *JsonStructProtocol,
+  IN  CHAR8                             *InputJson,
+  IN  CHAR8                             *ResourceId OPTIONAL,
+  IN  EFI_STRING                        ConfigureLang,
+  IN  BOOLEAN                           ProvisionMode,
+  OUT CHAR8                             **ResultJson
+  )
+{
+  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystem;
+  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCs;
+  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystemEmpty;
+  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCsEmpty;
+  EFI_STATUS                             Status;
+  BOOLEAN                                PropertyChanged;
+  CHAR8                                  *AsciiStringValue;
+  CHAR8                                  **AsciiStringArrayValue;
+  UINTN                                  ArraySize;
+
+  if ((JsonStructProtocol == NULL) || (ResultJson == NULL) || IS_EMPTY_STRING (InputJson) || IS_EMPTY_STRING (ConfigureLang)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s with: %s\n", __func__, ConfigureLang, (ProvisionMode ? L"Provision resource" : L"Update resource")));
+
+  *ResultJson     = NULL;
+  PropertyChanged = FALSE;
+
+  ComputerSystem = NULL;
+  Status         = JsonStructProtocol->ToStructure (
+                                         JsonStructProtocol,
+                                         NULL,
+                                         InputJson,
+                                         (EFI_REST_JSON_STRUCTURE_HEADER **)&ComputerSystem
+                                         );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status));
+    return Status;
+  }
+
+  ComputerSystemEmpty = NULL;
+  Status              = JsonStructProtocol->ToStructure (
+                                              JsonStructProtocol,
+                                              NULL,
+                                              ComputerSystemEmptyJson,
+                                              (EFI_REST_JSON_STRUCTURE_HEADER **)&ComputerSystemEmpty
+                                              );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status));
+    return Status;
+  }
+
+  ComputerSystemCs = ComputerSystem->ComputerSystem;
+  //
+  // Initial an empty ComputerSystemCS
+  //
+  ComputerSystemCsEmpty = ComputerSystemEmpty->ComputerSystem;
+
+  //
+  // Handle BOOT
+  //
+  if (ComputerSystemCs->Boot != NULL) {
+    //
+    // Handle BOOT->BOOTNEXT
+    //
+    if (PropertyChecker (ComputerSystemCs->Boot->BootNext, ProvisionMode)) {
+      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, L"Boot/BootNext", ConfigureLang);
+      if (AsciiStringValue != NULL) {
+        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot->BootNext, AsciiStringValue) != 0)) {
+          ComputerSystemCsEmpty->Boot->BootNext = AsciiStringValue;
+          PropertyChanged                       = TRUE;
+        }
+      }
+    }
+
+    //
+    // Handle BOOT->BOOTORDER
+    //
+    if (PropertyChecker (ComputerSystemCs->Boot->BootOrder, ProvisionMode)) {
+      AsciiStringArrayValue = GetPropertyStringArrayValue (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, L"Boot/BootOrder", ConfigureLang, &ArraySize);
+      if (AsciiStringArrayValue != NULL) {
+        if (ProvisionMode || !CompareRedfishStringArrayValues (ComputerSystemCs->Boot->BootOrder, AsciiStringArrayValue, ArraySize)) {
+          AddRedfishCharArray (&ComputerSystemCsEmpty->Boot->BootOrder, AsciiStringArrayValue, ArraySize);
+          PropertyChanged = TRUE;
+        }
+      }
+    }
+
+    //
+    // Handle BOOT->BOOTSOURCEOVERRIDEENABLED
+    //
+    if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideEnabled, ProvisionMode)) {
+      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideEnabled", ConfigureLang);
+      if (AsciiStringValue != NULL) {
+        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot->BootSourceOverrideEnabled, AsciiStringValue) != 0)) {
+          ComputerSystemCsEmpty->Boot->BootSourceOverrideEnabled = AsciiStringValue;
+          PropertyChanged                                        = TRUE;
+        }
+      }
+    }
+
+    //
+    // Handle BOOT->BOOTSOURCEOVERRIDEMODE
+    //
+    if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideMode, ProvisionMode)) {
+      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideMode", ConfigureLang);
+      if (AsciiStringValue != NULL) {
+        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot->BootSourceOverrideMode, AsciiStringValue) != 0)) {
+          ComputerSystemCsEmpty->Boot->BootSourceOverrideMode = AsciiStringValue;
+          PropertyChanged                                     = TRUE;
+        }
+      }
+    }
+
+    //
+    // Handle BOOT->BOOTSOURCEOVERRIDETARGET
+    //
+    if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideTarget, ProvisionMode)) {
+      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideTarget", ConfigureLang);
+      if (AsciiStringValue != NULL) {
+        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot->BootSourceOverrideTarget, AsciiStringValue) != 0)) {
+          ComputerSystemCsEmpty->Boot->BootSourceOverrideTarget = AsciiStringValue;
+          PropertyChanged                                       = TRUE;
+        }
+      }
+    }
+
+    //
+    // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE
+    //
+    if (PropertyChecker (ComputerSystemCs->Boot->UefiTargetBootSourceOverride, ProvisionMode)) {
+      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, L"Boot/UefiTargetBootSourceOverride", ConfigureLang);
+      if (AsciiStringValue != NULL) {
+        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot->UefiTargetBootSourceOverride, AsciiStringValue) != 0)) {
+          ComputerSystemCsEmpty->Boot->UefiTargetBootSourceOverride = AsciiStringValue;
+          PropertyChanged                                           = TRUE;
+        }
+      }
+    }
+  }
+
+  //
+  // Convert C structure back to JSON text.
+  //
+  Status = JsonStructProtocol->ToJson (
+                                 JsonStructProtocol,
+                                 (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEmpty,
+                                 ResultJson
+                                 );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status));
+    return Status;
+  }
+
+  if (PropertyChanged) {
+    // Remove Redfish unchangeable properties.
+    Status = RedfishRemoveUnchangeableProperties (ResultJson);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable properties from ResultJson.\n", __func__));
+      *ResultJson = NULL;
+      return Status;
+    }
+  }
+
+  //
+  // Release resource.
+  //
+  JsonStructProtocol->DestoryStructure (
+                        JsonStructProtocol,
+                        (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
+                        );
+
+  //
+  // Free memory allocated for Computersystem empty CS
+  //
+  if (ComputerSystemCsEmpty->Boot->BootOrder != NULL) {
+    DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, ArraySize);
+  }
+
+  JsonStructProtocol->DestoryStructure (
+                        JsonStructProtocol,
+                        (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEmpty
+                        );
+  return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND);
+}
+
+EFI_STATUS
+ProvisioningComputerSystemResource (
+  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
+  IN  UINTN                            Index,
+  IN  EFI_STRING                       ConfigureLang
+  )
+{
+  CHAR8       *Json;
+  CHAR8       *JsonWithAddendum;
+  EFI_STATUS  Status;
+  EFI_STRING  NewResourceLocation;
+  CHAR8       *EtagStr;
+  CHAR8       ResourceId[16];
+
+  if (IS_EMPTY_STRING (ConfigureLang) || (Private == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  EtagStr = NULL;
+  AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index);
+
+  Status = ProvisioningComputerSystemProperties (
+             Private->JsonStructProtocol,
+             ComputerSystemEmptyJson,
+             ResourceId,
+             ConfigureLang,
+             TRUE,
+             &Json
+             );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: provisioning resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+    return Status;
+  }
+
+  //
+  // Check and see if platform has OEM data or not
+  //
+  Status = RedfishGetOemData (
+             Private->Uri,
+             RESOURCE_SCHEMA,
+             RESOURCE_SCHEMA_VERSION,
+             Json,
+             &JsonWithAddendum
+             );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+    FreePool (Json);
+    Json             = JsonWithAddendum;
+    JsonWithAddendum = NULL;
+  }
+
+  //
+  // Check and see if platform has addendum data or not
+  //
+  Status = RedfishGetAddendumData (
+             Private->Uri,
+             RESOURCE_SCHEMA,
+             RESOURCE_SCHEMA_VERSION,
+             Json,
+             &JsonWithAddendum
+             );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+    FreePool (Json);
+    Json             = JsonWithAddendum;
+    JsonWithAddendum = NULL;
+  }
+
+  Status = CreatePayloadToPostResource (Private->RedfishService, Private->Payload, Json, &NewResourceLocation, &EtagStr);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+    goto RELEASE_RESOURCE;
+  }
+
+  ASSERT (NewResourceLocation != NULL);
+
+  //
+  // Keep location of new resource.
+  //
+  if (NewResourceLocation != NULL) {
+    RedfishSetRedfishUri (ConfigureLang, NewResourceLocation);
+  }
+
+RELEASE_RESOURCE:
+
+  if (EtagStr != NULL) {
+    FreePool (EtagStr);
+  }
+
+  if (NewResourceLocation != NULL) {
+    FreePool (NewResourceLocation);
+  }
+
+  if (Json != NULL) {
+    FreePool (Json);
+  }
+
+  return Status;
+}
+
+EFI_STATUS
+ProvisioningComputerSystemResources (
+  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private
+  )
+{
+  UINTN                                        Index;
+  EFI_STATUS                                   Status;
+  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST  UnifiedConfigureLangList;
+
+  if (Private == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &UnifiedConfigureLangList);
+  if (EFI_ERROR (Status) || (UnifiedConfigureLangList.Count == 0)) {
+    DEBUG ((DEBUG_ERROR, "%a: No HII question found with configure language: %s: %r\n", __func__, REDPATH_ARRAY_PATTERN, Status));
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
+  // This information is sent back to the parent resource (e.g. the collection driver).
+  //
+  EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &UnifiedConfigureLangList);
+
+  for (Index = 0; Index < UnifiedConfigureLangList.Count; Index++) {
+    DEBUG ((DEBUG_MANAGEABILITY, "[%d] create ComputerSystem resource from: %s\n", UnifiedConfigureLangList.List[Index].Index, UnifiedConfigureLangList.List[Index].ConfigureLang));
+    ProvisioningComputerSystemResource (Private, UnifiedConfigureLangList.List[Index].Index, UnifiedConfigureLangList.List[Index].ConfigureLang);
+    FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang);
+  }
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ProvisioningComputerSystemExistResource (
+  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private
+  )
+{
+  EFI_STATUS  Status;
+  EFI_STRING  ConfigureLang;
+  CHAR8       *Json;
+  CHAR8       *JsonWithAddendum;
+
+  if (Private == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Json          = NULL;
+  ConfigureLang = NULL;
+
+  ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
+  if (ConfigureLang == NULL) {
+    return EFI_NOT_FOUND;
+  }
+
+  Status = ProvisioningComputerSystemProperties (
+             Private->JsonStructProtocol,
+             ComputerSystemEmptyJson,
+             NULL,
+             ConfigureLang,
+             TRUE,
+             &Json
+             );
+  if (EFI_ERROR (Status)) {
+    if (Status == EFI_NOT_FOUND) {
+      DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for %s ignored. Nothing changed\n", __func__, ConfigureLang));
+      Status = EFI_SUCCESS;
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a: provisioning existing resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+    }
+
+    goto ON_RELEASE;
+  }
+
+  //
+  // Check and see if platform has OEM data or not
+  //
+  Status = RedfishGetOemData (
+             Private->Uri,
+             RESOURCE_SCHEMA,
+             RESOURCE_SCHEMA_VERSION,
+             Json,
+             &JsonWithAddendum
+             );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+    FreePool (Json);
+    Json             = JsonWithAddendum;
+    JsonWithAddendum = NULL;
+  }
+
+  //
+  // Check and see if platform has addendum data or not
+  //
+  Status = RedfishGetAddendumData (
+             Private->Uri,
+             RESOURCE_SCHEMA,
+             RESOURCE_SCHEMA_VERSION,
+             Json,
+             &JsonWithAddendum
+             );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+    FreePool (Json);
+    Json             = JsonWithAddendum;
+    JsonWithAddendum = NULL;
+  }
+
+  DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for %s\n", __func__, ConfigureLang));
+
+  //
+  // PUT back to instance
+  //
+  Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, NULL);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+  }
+
+ON_RELEASE:
+
+  if (Json != NULL) {
+    FreePool (Json);
+  }
+
+  if (ConfigureLang != NULL) {
+    FreePool (ConfigureLang);
+  }
+
+  return Status;
+}
+
+/**
+  Provisioning redfish resource by given URI.
+
+  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL instance.
+  @param[in]   ResourceExist       TRUE if resource exists, PUT method will be used.
+                                   FALSE if resource does not exist POST method is used.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+RedfishProvisioningResourceCommon (
+  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
+  IN     BOOLEAN                          ResourceExist
+  )
+{
+  if (Private == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  return (ResourceExist ? ProvisioningComputerSystemExistResource (Private) : ProvisioningComputerSystemResources (Private));
+}
+
+/**
+  Check resource from given URI.
+
+  @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
+  @param[in]   Json                The JSON to consume.
+  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+RedfishCheckResourceCommon (
+  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
+  IN     CHAR8                            *Json,
+  IN     CHAR8                            *HeaderEtag OPTIONAL
+  )
+{
+  UINTN       Index;
+  EFI_STATUS  Status;
+  EFI_STRING  *ConfigureLangList;
+  UINTN       Count;
+  EFI_STRING  Property;
+
+  if ((Private == NULL) || IS_EMPTY_STRING (Json)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Check ETAG to see if we need to check it
+  //
+  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
+    //
+    // No change
+    //
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore check action\n", __func__, Private->Uri));
+    return EFI_SUCCESS;
+  }
+
+  Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigureLangList, &Count);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed: %r\n", __func__, Status));
+    return Status;
+  }
+
+  if (Count == 0) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Status = EFI_SUCCESS;
+  for (Index = 0; Index < Count; Index++) {
+    Property = GetPropertyFromConfigureLang (Private->Uri, ConfigureLangList[Index]);
+    if (Property == NULL) {
+      continue;
+    }
+
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: [%d] check attribute for: %s\n", __func__, Index, Property));
+    if (!MatchPropertyWithJsonContext (Property, Json)) {
+      DEBUG ((DEBUG_MANAGEABILITY, "%a: property is missing: %s\n", __func__, Property));
+      Status = EFI_NOT_FOUND;
+    }
+  }
+
+  FreePool (ConfigureLangList);
+
+  return Status;
+}
+
+/**
+  Update resource to given URI.
+
+  @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
+  @param[in]   Json                The JSON to consume.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+RedfishUpdateResourceCommon (
+  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
+  IN     CHAR8                            *InputJson
+  )
+{
+  EFI_STATUS  Status;
+  CHAR8       *Json;
+  CHAR8       *JsonWithAddendum;
+  EFI_STRING  ConfigureLang;
+
+  if ((Private == NULL) || IS_EMPTY_STRING (InputJson)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Json          = NULL;
+  ConfigureLang = NULL;
+
+  ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
+  if (ConfigureLang == NULL) {
+    return EFI_NOT_FOUND;
+  }
+
+  Status = ProvisioningComputerSystemProperties (
+             Private->JsonStructProtocol,
+             InputJson,
+             NULL,
+             ConfigureLang,
+             FALSE,
+             &Json
+             );
+  if (EFI_ERROR (Status)) {
+    if (Status == EFI_NOT_FOUND) {
+      DEBUG ((DEBUG_MANAGEABILITY, "%a: update resource for %s ignored. Nothing changed\n", __func__, ConfigureLang));
+      Status = EFI_SUCCESS;
+    } else {
+      DEBUG ((DEBUG_ERROR, "%a: update resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+    }
+
+    goto ON_RELEASE;
+  }
+
+  //
+  // Check and see if platform has OEM data or not
+  //
+  Status = RedfishGetOemData (
+             Private->Uri,
+             RESOURCE_SCHEMA,
+             RESOURCE_SCHEMA_VERSION,
+             Json,
+             &JsonWithAddendum
+             );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+    FreePool (Json);
+    Json             = JsonWithAddendum;
+    JsonWithAddendum = NULL;
+  }
+
+  //
+  // Check and see if platform has addendum data or not
+  //
+  Status = RedfishGetAddendumData (
+             Private->Uri,
+             RESOURCE_SCHEMA,
+             RESOURCE_SCHEMA_VERSION,
+             Json,
+             &JsonWithAddendum
+             );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+    FreePool (Json);
+    Json             = JsonWithAddendum;
+    JsonWithAddendum = NULL;
+  }
+
+  DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __func__, ConfigureLang));
+
+  //
+  // PUT back to instance
+  //
+  Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, NULL);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
+  }
+
+ON_RELEASE:
+
+  if (Json != NULL) {
+    FreePool (Json);
+  }
+
+  if (ConfigureLang != NULL) {
+    FreePool (ConfigureLang);
+  }
+
+  return Status;
+}
+
+/**
+  Identify resource from given URI.
+
+  @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
+  @param[in]   Json                The JSON to consume.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+RedfishIdentifyResourceCommon (
+  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
+  IN     CHAR8                            *Json
+  )
+{
+  BOOLEAN                                      Supported;
+  EFI_STATUS                                   Status;
+  EFI_STRING                                   EndOfChar;
+  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST  ConfigLangList;
+
+  Supported = RedfishIdentifyResource (Private->Uri, Private->Json);
+  if (Supported) {
+    Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigLangList);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "%a: RedfishFeatureGetUnifiedArrayTypeConfigureLang failed: %r\n", __func__, Status));
+      return Status;
+    }
+
+    if (ConfigLangList.Count == 0) {
+      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish ConfigureLang found for %s\n", __func__, Private->Uri));
+      return EFI_SUCCESS;
+    }
+
+    EndOfChar = StrStr (ConfigLangList.List[0].ConfigureLang, L"}");
+    if (EndOfChar == NULL) {
+      ASSERT (FALSE);
+      return EFI_DEVICE_ERROR;
+    }
+
+    // EndOfChar = StrStr (ConfigLangList.List[0].ConfigureLang, L"}");
+    Status = IsRedpathArray (ConfigLangList.List[0].ConfigureLang, NULL, &EndOfChar);
+    if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
+      ASSERT (FALSE);
+      return EFI_DEVICE_ERROR;
+    }
+
+    if (Status != EFI_SUCCESS) {
+      //
+      // This is not the collection redpath.
+      //
+      GetRedpathNodeByIndex (ConfigLangList.List[0].ConfigureLang, 0, &EndOfChar);
+    }
+
+    *(++EndOfChar) = '\0';
+    //
+    // Keep URI and ConfigLang mapping
+    //
+    RedfishSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private->Uri);
+    //
+    // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
+    // This information is sent back to the parent resource (e.g. the collection driver).
+    //
+    EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &ConfigLangList);
+    DestroyConfiglanguageList (&ConfigLangList);
+    return EFI_SUCCESS;
+  }
+
+  return EFI_UNSUPPORTED;
+}
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c
new file mode 100644
index 0000000000..30a0e64c64
--- /dev/null
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.c
@@ -0,0 +1,702 @@
+/** @file
+  Redfish feature driver implementation - ComputerSystem
+
+  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "../Common/ComputerSystemCommon.h"
+
+extern REDFISH_RESOURCE_COMMON_PRIVATE  *mRedfishResourcePrivate;
+extern EFI_HANDLE                       mRedfishResourceConfigProtocolHandle;
+
+/**
+  Provision redfish resource by given URI.
+
+  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL instance.
+  @param[in]   Uri                 Target URI to create resource.
+  @param[in]   PostMode            TRUE if the resource does not exist, post method is used.
+                                   FALSE if the resource exist but property is missing, put method is used.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceProvisioningResource (
+  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
+  IN     EFI_STRING                              Uri,
+  IN     BOOLEAN                                 PostMode
+  )
+{
+  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
+  EFI_STATUS                       Status;
+  REDFISH_RESPONSE                 Response;
+
+  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning in %s mode\n", __func__, (PostMode ? L"POST" : L"PATCH")));
+
+  Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL (This);
+
+  if (Private->RedfishService == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  ZeroMem (&Response, sizeof (Response));
+  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
+    return Status;
+  }
+
+  Private->Uri     = Uri;
+  Private->Payload = Response.Payload;
+  ASSERT (Private->Payload != NULL);
+
+  Status = RedfishProvisioningResourceCommon (Private, !PostMode);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to provision resource to: %s: %r\n", __func__, Uri, Status));
+  } else {
+    //
+    // Get latest ETag on URI and keep it in variable.
+    //
+    SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
+  }
+
+  //
+  // Release resource
+  //
+  if (Private->Payload != NULL) {
+    RedfishFreeResponse (
+      Response.StatusCode,
+      Response.HeaderCount,
+      Response.Headers,
+      Response.Payload
+      );
+    Private->Payload = NULL;
+  }
+
+  return Status;
+}
+
+/**
+  Consume resource from given URI.
+
+  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL instance.
+  @param[in]   Uri                 The target URI to consume.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceConsumeResource (
+  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
+  IN     EFI_STRING                              Uri
+  )
+{
+  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
+  EFI_STATUS                       Status;
+  REDFISH_RESPONSE                 Response;
+  EFI_STRING                       PendingSettingUri;
+  REDFISH_RESPONSE                 PendingSettingResponse;
+  REDFISH_RESPONSE                 *ExpectedResponse;
+  CHAR8                            *Etag;
+
+  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL (This);
+
+  if (Private->RedfishService == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  ZeroMem (&Response, sizeof (Response));
+  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
+    return Status;
+  }
+
+  //
+  // Check and see if "@Redfish.Settings" exist or not.
+  //
+  ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE));
+  Status = GetPendingSettings (
+             Private->RedfishService,
+             Response.Payload,
+             &PendingSettingResponse,
+             &PendingSettingUri
+             );
+  if (!EFI_ERROR (Status)) {
+    DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
+    Private->Uri     = PendingSettingUri;
+    ExpectedResponse = &PendingSettingResponse;
+  } else {
+    DEBUG ((REDFISH_DEBUG_TRACE, "%a: No @Redfish.Settings is found\n", __func__));
+    Private->Uri     = Uri;
+    ExpectedResponse = &Response;
+  }
+
+  Private->Payload = ExpectedResponse->Payload;
+  ASSERT (Private->Payload != NULL);
+
+  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
+  ASSERT (Private->Json != NULL);
+
+  //
+  // Find etag in HTTP response header
+  //
+  Etag = NULL;
+  GetHttpResponseEtag (ExpectedResponse, &Etag);
+  Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", __func__, Private->Uri, Status));
+  }
+
+  //
+  // Release resource
+  //
+  if (Etag != NULL) {
+    FreePool (Etag);
+  }
+
+  //
+  // Release resource
+  //
+  if (Private->Payload != NULL) {
+    if (Response.Payload != NULL) {
+      RedfishFreeResponse (
+        Response.StatusCode,
+        Response.HeaderCount,
+        Response.Headers,
+        Response.Payload
+        );
+    }
+
+    if (PendingSettingResponse.Payload != NULL) {
+      RedfishFreeResponse (
+        PendingSettingResponse.StatusCode,
+        PendingSettingResponse.HeaderCount,
+        PendingSettingResponse.Headers,
+        PendingSettingResponse.Payload
+        );
+    }
+
+    Private->Payload = NULL;
+  }
+
+  if (Private->Json != NULL) {
+    FreePool (Private->Json);
+    Private->Json = NULL;
+  }
+
+  return Status;
+}
+
+/**
+  Get information about this protocol.
+
+  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL instance.
+  @param[out]  Schema              Supported schema.
+  @param[out]  Major               Supported major number.
+  @param[out]  Minor               Supported minor number.
+  @param[out]  Errata              Supported errata number.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceGetInfo (
+  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
+  OUT    REDFISH_SCHEMA_INFO                     *Info
+  )
+{
+  if ((This == NULL) || (Info == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  AsciiStrCpyS (Info->Schema, REDFISH_SCHEMA_STRING_SIZE, RESOURCE_SCHEMA);
+  AsciiStrCpyS (Info->Major, REDFISH_SCHEMA_VERSION_SIZE, RESOURCE_SCHEMA_MAJOR);
+  AsciiStrCpyS (Info->Minor, REDFISH_SCHEMA_VERSION_SIZE, RESOURCE_SCHEMA_MINOR);
+  AsciiStrCpyS (Info->Errata, REDFISH_SCHEMA_VERSION_SIZE, RESOURCE_SCHEMA_ERRATA);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Update resource to given URI.
+
+  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL instance.
+  @param[in]   Uri                 The target URI to consume.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceUpdate (
+  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
+  IN     EFI_STRING                              Uri
+  )
+{
+  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
+  EFI_STATUS                       Status;
+  REDFISH_RESPONSE                 Response;
+
+  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL (This);
+
+  if (Private->RedfishService == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  ZeroMem (&Response, sizeof (Response));
+  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
+    return Status;
+  }
+
+  Private->Uri     = Uri;
+  Private->Payload = Response.Payload;
+  ASSERT (Private->Payload != NULL);
+
+  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
+  ASSERT (Private->Json != NULL);
+
+  Status = RedfishUpdateResourceCommon (Private, Private->Json);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to update resource to: %s: %r\n", __func__, Uri, Status));
+  } else {
+    //
+    // Get latest ETag on URI and keep it in variable.
+    //
+    SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
+  }
+
+  //
+  // Release resource
+  //
+  if (Private->Payload != NULL) {
+    RedfishFreeResponse (
+      Response.StatusCode,
+      Response.HeaderCount,
+      Response.Headers,
+      Response.Payload
+      );
+    RedfishHttpResetResource (Uri);
+    Private->Payload = NULL;
+  }
+
+  if (Private->Json != NULL) {
+    FreePool (Private->Json);
+    Private->Json = NULL;
+  }
+
+  return Status;
+}
+
+/**
+  Check resource on given URI.
+
+  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL instance.
+  @param[in]   Uri                 The target URI to consume.
+
+  @retval EFI_SUCCESS              Value is returned successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceCheck (
+  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
+  IN     EFI_STRING                              Uri
+  )
+{
+  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
+  EFI_STATUS                       Status;
+  REDFISH_RESPONSE                 Response;
+  CHAR8                            *Etag;
+
+  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL (This);
+
+  if (Private->RedfishService == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  ZeroMem (&Response, sizeof (Response));
+  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
+    return Status;
+  }
+
+  Private->Uri     = Uri;
+  Private->Payload = Response.Payload;
+  ASSERT (Private->Payload != NULL);
+
+  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
+  ASSERT (Private->Json != NULL);
+
+  //
+  // Find etag in HTTP response header
+  //
+  Etag = NULL;
+  GetHttpResponseEtag (&Response, &Etag);
+  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to check resource from: %s: %r\n", __func__, Uri, Status));
+  }
+
+  //
+  // Release resource
+  //
+  if (Etag != NULL) {
+    FreePool (Etag);
+  }
+
+  if (Private->Payload != NULL) {
+    RedfishFreeResponse (
+      Response.StatusCode,
+      Response.HeaderCount,
+      Response.Headers,
+      Response.Payload
+      );
+    Private->Payload = NULL;
+  }
+
+  if (Private->Json != NULL) {
+    FreePool (Private->Json);
+    Private->Json = NULL;
+  }
+
+  return Status;
+}
+
+/**
+  Identify resource on given URI.
+
+  @param[in]   This                Pointer to EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL instance.
+  @param[in]   Uri                 The target URI to consume.
+
+  @retval EFI_SUCCESS              This is target resource which we want to handle.
+  @retval EFI_UNSUPPORTED          This is not the target resource.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceIdentify (
+  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
+  IN     EFI_STRING                              Uri
+  )
+{
+  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
+  EFI_STATUS                       Status;
+  REDFISH_RESPONSE                 Response;
+
+  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL (This);
+
+  if (Private->RedfishService == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  ZeroMem (&Response, sizeof (Response));
+  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
+    return Status;
+  }
+
+  Private->Uri     = Uri;
+  Private->Payload = Response.Payload;
+  ASSERT (Private->Payload != NULL);
+
+  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
+  ASSERT (Private->Json != NULL);
+
+  Status = RedfishIdentifyResourceCommon (Private, Private->Json);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: identify %s failed: %r\n", __func__, Uri, Status));
+  }
+
+  //
+  // Release resource
+  //
+  if (Private->Payload != NULL) {
+    RedfishFreeResponse (
+      Response.StatusCode,
+      Response.HeaderCount,
+      Response.Headers,
+      Response.Payload
+      );
+    Private->Payload = NULL;
+  }
+
+  if (Private->Json != NULL) {
+    FreePool (Private->Json);
+    Private->Json = NULL;
+  }
+
+  return Status;
+}
+
+EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  mRedfishResourceConfig = {
+  RedfishResourceProvisioningResource,
+  RedfishResourceConsumeResource,
+  RedfishResourceUpdate,
+  RedfishResourceCheck,
+  RedfishResourceIdentify,
+  RedfishResourceGetInfo
+};
+
+/**
+  Initialize a Redfish configure handler.
+
+  This function will be called by the Redfish config driver to initialize each Redfish configure
+  handler.
+
+  @param[in]   This                     Pointer to EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance.
+  @param[in]   RedfishConfigServiceInfo Redfish service information.
+
+  @retval EFI_SUCCESS                  The handler has been initialized successfully.
+  @retval EFI_DEVICE_ERROR             Failed to create or configure the REST EX protocol instance.
+  @retval EFI_ALREADY_STARTED          This handler has already been initialized.
+  @retval Other                        Error happens during the initialization.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceInit (
+  IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *This,
+  IN  REDFISH_CONFIG_SERVICE_INFORMATION     *RedfishConfigServiceInfo
+  )
+{
+  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
+
+  Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL (This);
+
+  Private->RedfishService = RedfishCreateService (RedfishConfigServiceInfo);
+  if (Private->RedfishService == NULL) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Stop a Redfish configure handler.
+
+  @param[in]   This                Pointer to EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance.
+
+  @retval EFI_SUCCESS              This handler has been stoped successfully.
+  @retval Others                   Some error happened.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceStop (
+  IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *This
+  )
+{
+  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
+
+  Private = REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL (This);
+
+  if (Private->Event != NULL) {
+    gBS->CloseEvent (Private->Event);
+    Private->Event = NULL;
+  }
+
+  if (Private->RedfishService != NULL) {
+    RedfishCleanupService (Private->RedfishService);
+    Private->RedfishService = NULL;
+  }
+
+  if (Private->Payload != NULL) {
+    RedfishCleanupPayload (Private->Payload);
+    Private->Payload = NULL;
+  }
+
+  return EFI_SUCCESS;
+}
+
+EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  mRedfishConfigHandler = {
+  RedfishResourceInit,
+  RedfishResourceStop
+};
+
+/**
+  Callback function when gEfiRestJsonStructureProtocolGuid is installed.
+
+  @param[in] Event    Event whose notification function is being invoked.
+  @param[in] Context  Pointer to the notification function's context.
+**/
+VOID
+EFIAPI
+EfiRestJasonStructureProtocolIsReady (
+  IN  EFI_EVENT  Event,
+  IN  VOID       *Context
+  )
+{
+  EFI_STATUS  Status;
+
+  if (mRedfishResourcePrivate == NULL) {
+    return;
+  }
+
+  if (mRedfishResourcePrivate->JsonStructProtocol != NULL) {
+    return;
+  }
+
+  Status = gBS->LocateProtocol (
+                  &gEfiRestJsonStructureProtocolGuid,
+                  NULL,
+                  (VOID **)&mRedfishResourcePrivate->JsonStructProtocol
+                  );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to locate gEfiRestJsonStructureProtocolGuid: %r\n", __func__, Status));
+  }
+
+  gBS->CloseEvent (Event);
+}
+
+/**
+  Unloads an image.
+
+  @param  ImageHandle           Handle that identifies the image to be unloaded.
+
+  @retval EFI_SUCCESS           The image has been unloaded.
+  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceUnload (
+  IN EFI_HANDLE  ImageHandle
+  )
+{
+  EFI_STATUS                             Status;
+  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *ConfigHandler;
+
+  if (mRedfishResourcePrivate == NULL) {
+    return EFI_NOT_READY;
+  }
+
+  ConfigHandler = NULL;
+
+  //
+  // Firstly, find ConfigHandler Protocol interface in this ImageHandle.
+  //
+  Status = gBS->OpenProtocol (
+                  ImageHandle,
+                  &gEdkIIRedfishConfigHandlerProtocolGuid,
+                  (VOID **)&ConfigHandler,
+                  NULL,
+                  NULL,
+                  EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
+                  );
+  if (EFI_ERROR (Status) || (ConfigHandler == NULL)) {
+    return Status;
+  }
+
+  ConfigHandler->Stop (ConfigHandler);
+
+  //
+  // Last, uninstall ConfigHandler Protocol and resource protocol.
+  //
+  Status = gBS->UninstallMultipleProtocolInterfaces (
+                  ImageHandle,
+                  &gEdkIIRedfishConfigHandlerProtocolGuid,
+                  ConfigHandler,
+                  &gEdkIIRedfishResourceConfigProtocolGuid,
+                  &mRedfishResourcePrivate->RedfishResourceConfig,
+                  NULL
+                  );
+
+  FreePool (mRedfishResourcePrivate);
+  mRedfishResourcePrivate = NULL;
+
+  return Status;
+}
+
+/**
+  This is the declaration of an EFI image entry point. This entry point is
+  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
+  both device drivers and bus drivers. It initialize the global variables and
+  publish the driver binding protocol.
+
+  @param[in]   ImageHandle      The firmware allocated handle for the UEFI image.
+  @param[in]   SystemTable      A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval Others                Other errors as indicated.
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  VOID        *Registration;
+
+  if (mRedfishResourcePrivate != NULL) {
+    return EFI_ALREADY_STARTED;
+  }
+
+  mRedfishResourceConfigProtocolHandle = ImageHandle;
+
+  mRedfishResourcePrivate = AllocateZeroPool (sizeof (REDFISH_RESOURCE_COMMON_PRIVATE));
+  CopyMem (&mRedfishResourcePrivate->ConfigHandler, &mRedfishConfigHandler, sizeof (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL));
+  CopyMem (&mRedfishResourcePrivate->RedfishResourceConfig, &mRedfishResourceConfig, sizeof (EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL));
+
+  //
+  // Publish config handler protocol and resource protocol.
+  //
+  Status = gBS->InstallMultipleProtocolInterfaces (
+                  &ImageHandle,
+                  &gEdkIIRedfishConfigHandlerProtocolGuid,
+                  &mRedfishResourcePrivate->ConfigHandler,
+                  &gEdkIIRedfishResourceConfigProtocolGuid,
+                  &mRedfishResourcePrivate->RedfishResourceConfig,
+                  NULL
+                  );
+
+  EfiCreateProtocolNotifyEvent (
+    &gEfiRestJsonStructureProtocolGuid,
+    TPL_CALLBACK,
+    EfiRestJasonStructureProtocolIsReady,
+    NULL,
+    &Registration
+    );
+
+  return Status;
+}
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114481): https://edk2.groups.io/g/devel/message/114481
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26  1:00 [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver Chang, Abner via groups.io
@ 2024-01-26  2:20 ` Nickle Wang via groups.io
  2024-01-26  2:32   ` Chang, Abner via groups.io
  2024-01-26 13:55   ` Mike Maslenkin
  0 siblings, 2 replies; 9+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-26  2:20 UTC (permalink / raw)
  To: devel@edk2.groups.io, abner.chang@amd.com; +Cc: Igor Kulchytskyy

Hi Abner,

Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.

> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish ConfigureLang
> found for %s\n", __func__, Private->Uri));

Regards,
Nickle

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner
> via groups.io
> Sent: Friday, January 26, 2024 9:00 AM
> To: devel@edk2.groups.io
> Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
> Subject: [edk2-devel] [edk2-redfish-client][PATCH V2]
> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang <abner.chang@amd.com>
> 
> Initial version of edk2 Redfish feature of
> Redfish schema ComputerSystem_1_13_0. This driver
> handles ComputerSystem Boot properties but not all.
> 
> Signed-off-by: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> ---
>  .../v1_13_0/Dxe/ComputerSystemDxe.inf         |  53 ++
>  .../v1_13_0/Common/ComputerSystemCommon.h     |  29 +
>  .../v1_13_0/Common/ComputerSystemCommon.c     | 899
> ++++++++++++++++++
>  .../v1_13_0/Dxe/ComputerSystemDxe.c           | 702 ++++++++++++++
>  4 files changed, 1683 insertions(+)
>  create mode 100644
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.
> inf
>  create mode 100644
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste
> mCommon.h
>  create mode 100644
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste
> mCommon.c
>  create mode 100644
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe.
> c
> 
> diff --git
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD
> xe.inf
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD
> xe.inf
> new file mode 100644
> index 0000000000..6bc5cb358e
> --- /dev/null
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD
> xe.inf
> @@ -0,0 +1,53 @@
> +## @file
> +#
> +#  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> +#  Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +
> +[Defines]
> +  INF_VERSION               = 0x00010005
> +  BASE_NAME                 = ComputerSystemDxe
> +  FILE_GUID                 = D94362A1-C358-4059-B014-F07D1AE04F16
> +  MODULE_TYPE               = DXE_DRIVER
> +  VERSION_STRING            = 1.0
> +  ENTRY_POINT               = RedfishResourceEntryPoint
> +  UNLOAD_IMAGE              = RedfishResourceUnload
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  RedfishPkg/RedfishPkg.dec
> +  RedfishClientPkg/RedfishClientPkg.dec
> +
> +[Sources]
> +  ../Common/ComputerSystemCommon.h
> +  ../Common/ComputerSystemCommon.c
> +  ComputerSystemDxe.c
> +
> +[LibraryClasses]
> +  BaseMemoryLib
> +  DebugLib
> +  EdkIIRedfishResourceConfigLib
> +  RedfishLib
> +  RedfishFeatureUtilityLib
> +  RedfishResourceIdentifyLib
> +  UefiLib
> +  UefiDriverEntryPoint
> +  RedfishAddendumLib
> +  RedfishHttpCacheLib
> +
> +[Protocols]
> +  gEdkIIRedfishConfigHandlerProtocolGuid          ## PRODUCED
> +  gEfiRestJsonStructureProtocolGuid               ## CONSUMED
> +  gEdkIIRedfishResourceConfigProtocolGuid         ## PRODUCED
> +
> +[Pcd]
> +  gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize
> +  gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize
> +
> +[Depex]
> +  TRUE
> diff --git
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.h
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.h
> new file mode 100644
> index 0000000000..c9c8512881
> --- /dev/null
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.h
> @@ -0,0 +1,29 @@
> +/** @file
> +
> +  Redfish feature driver implementation - internal header file
> +  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_
> +#define EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_
> +
> +#include
> <RedfishJsonStructure/ComputerSystem/v1_13_0/EfiComputerSystemV1_13_0.h
> >
> +#include <RedfishResourceCommon.h>
> +
> +//
> +// Schema information.
> +//
> +#define RESOURCE_SCHEMA          "ComputerSystem"
> +#define RESOURCE_SCHEMA_MAJOR    "1"
> +#define RESOURCE_SCHEMA_MINOR    "13"
> +#define RESOURCE_SCHEMA_ERRATA   "0"
> +#define RESOURCE_SCHEMA_VERSION  "v1_13_0"
> +#define REDPATH_ARRAY_PATTERN    L"/Systems/\\{.*\\}/"
> +#define REDPATH_ARRAY_PREFIX     L"/Systems/"
> +#define RESOURCE_SCHEMA_FULL     "x-uefi-redfish-
> ComputerSystem.v1_13_0"
> +
> +#endif
> diff --git
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.c
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.c
> new file mode 100644
> index 0000000000..bc24c49206
> --- /dev/null
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst
> emCommon.c
> @@ -0,0 +1,899 @@
> +/** @file
> +  Redfish feature driver implementation - common functions
> +
> +  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> +  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "ComputerSystemCommon.h"
> +
> +CHAR8  ComputerSystemEmptyJson[] = "{\"@odata.id\": \"\", \"@odata.type\":
> \"#ComputerSystem.v1_13_0.ComputerSystem\", \"Id\": \"\", \"Name\": \"\",
> \"Boot\":{}}";
> +
> +REDFISH_RESOURCE_COMMON_PRIVATE  *mRedfishResourcePrivate             =
> NULL;
> +EFI_HANDLE                       mRedfishResourceConfigProtocolHandle = NULL;
> +
> +/**
> +  Consume resource from given URI.
> +
> +  @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
> +  @param[in]   Json                The JSON to consume.
> +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +RedfishConsumeResourceCommon (
> +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> +  IN  CHAR8                            *Json,
> +  IN  CHAR8                            *HeaderEtag OPTIONAL
> +  )
> +{
> +  EFI_STATUS                             Status;
> +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystem;
> +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCs;
> +  EFI_STRING                             ConfigureLang;
> +
> +  if ((Private == NULL) || IS_EMPTY_STRING (Json)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  ComputerSystem   = NULL;
> +  ComputerSystemCs = NULL;
> +  ConfigureLang    = NULL;
> +
> +  Status = Private->JsonStructProtocol->ToStructure (
> +                                          Private->JsonStructProtocol,
> +                                          NULL,
> +                                          Json,
> +                                          (EFI_REST_JSON_STRUCTURE_HEADER
> **)&ComputerSystem
> +                                          );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, Status));
> +    return Status;
> +  }
> +
> +  ComputerSystemCs = ComputerSystem->ComputerSystem;
> +
> +  //
> +  // Check ETAG to see if we need to consume it
> +  //
> +  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
> +    //
> +    // No change
> +    //
> +    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore
> consume action\n", __func__, Private->Uri));
> +    Status = EFI_SUCCESS;
> +    goto ON_RELEASE;
> +  }
> +
> +  //
> +  // Handle BOOT
> +  //
> +  if (ComputerSystemCs->Boot == NULL) {
> +    ComputerSystemCs->Boot = AllocateZeroPool (sizeof
> (RedfishComputerSystem_V1_13_0_Boot_CS));
> +    ASSERT (ComputerSystemCs->Boot != NULL);
> +  }
> +
> +  //
> +  // Handle BOOT->BOOTNEXT
> +  //
> +  if (ComputerSystemCs->Boot->BootNext != NULL) {
> +    //
> +    // Find corresponding configure language for collection resource.
> +    //
> +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> "Boot/BootNext");
> +    if (ConfigureLang != NULL) {
> +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> >BootNext);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +      }
> +
> +      FreePool (ConfigureLang);
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI:
> %s\n", __func__, Private->Uri));
> +    }
> +  }
> +
> +  //
> +  // Handle BOOT->BOOTORDER
> +  //
> +  if (ComputerSystemCs->Boot->BootOrder != NULL) {
> +    //
> +    // Find corresponding configure language for collection resource.
> +    //
> +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> "Boot/BootOrder");
> +    if (ConfigureLang != NULL) {
> +      Status = ApplyFeatureSettingsStringArrayType (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> >BootOrder);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +      }
> +
> +      FreePool (ConfigureLang);
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> %s\n", __func__, Private->Uri));
> +    }
> +  }
> +
> +  //
> +  // Handle BOOT->BOOTSOURCEOVERRIDEENABLED
> +  //
> +  if (ComputerSystemCs->Boot->BootSourceOverrideEnabled != NULL) {
> +    //
> +    // Find corresponding configure language for collection resource.
> +    //
> +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> "Boot/BootSourceOverrideEnabled");
> +    if (ConfigureLang != NULL) {
> +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> >BootSourceOverrideEnabled);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +      }
> +
> +      FreePool (ConfigureLang);
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> %s\n", __func__, Private->Uri));
> +    }
> +  }
> +
> +  //
> +  // Handle BOOT->BOOTSOURCEOVERRIDEMODE
> +  //
> +  if (ComputerSystemCs->Boot->BootSourceOverrideMode != NULL) {
> +    //
> +    // Find corresponding configure language for collection resource.
> +    //
> +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> "Boot/BootSourceOverrideMode");
> +    if (ConfigureLang != NULL) {
> +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> >BootSourceOverrideMode);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +      }
> +
> +      FreePool (ConfigureLang);
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> %s\n", __func__, Private->Uri));
> +    }
> +  }
> +
> +  //
> +  // Handle BOOT->BOOTSOURCEOVERRIDETARGET
> +  //
> +  if (ComputerSystemCs->Boot->BootSourceOverrideTarget != NULL) {
> +    //
> +    // Find corresponding configure language for collection resource.
> +    //
> +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> "Boot/BootSourceOverrideTarget");
> +    if (ConfigureLang != NULL) {
> +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> >BootSourceOverrideTarget);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +      }
> +
> +      FreePool (ConfigureLang);
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI:
> %s\n", __func__, Private->Uri));
> +    }
> +  }
> +
> +  //
> +  // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE
> +  //
> +  if (ComputerSystemCs->Boot->UefiTargetBootSourceOverride != NULL) {
> +    //
> +    // Find corresponding configure language for collection resource.
> +    //
> +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> "Boot/UefiTargetBootSourceOverride");
> +    if (ConfigureLang != NULL) {
> +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> >UefiTargetBootSourceOverride);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +      }
> +
> +      FreePool (ConfigureLang);
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> %s\n", __func__, Private->Uri));
> +    }
> +  }
> +
> +ON_RELEASE:
> +
> +  //
> +  // Release resource.
> +  //
> +  Private->JsonStructProtocol->DestoryStructure (
> +                                 Private->JsonStructProtocol,
> +                                 (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
> +                                 );
> +
> +  return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +ProvisioningComputerSystemProperties (
> +  IN  EFI_REST_JSON_STRUCTURE_PROTOCOL  *JsonStructProtocol,
> +  IN  CHAR8                             *InputJson,
> +  IN  CHAR8                             *ResourceId OPTIONAL,
> +  IN  EFI_STRING                        ConfigureLang,
> +  IN  BOOLEAN                           ProvisionMode,
> +  OUT CHAR8                             **ResultJson
> +  )
> +{
> +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystem;
> +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCs;
> +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystemEmpty;
> +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCsEmpty;
> +  EFI_STATUS                             Status;
> +  BOOLEAN                                PropertyChanged;
> +  CHAR8                                  *AsciiStringValue;
> +  CHAR8                                  **AsciiStringArrayValue;
> +  UINTN                                  ArraySize;
> +
> +  if ((JsonStructProtocol == NULL) || (ResultJson == NULL) || IS_EMPTY_STRING
> (InputJson) || IS_EMPTY_STRING (ConfigureLang)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s with: %s\n", __func__,
> ConfigureLang, (ProvisionMode ? L"Provision resource" : L"Update resource")));
> +
> +  *ResultJson     = NULL;
> +  PropertyChanged = FALSE;
> +
> +  ComputerSystem = NULL;
> +  Status         = JsonStructProtocol->ToStructure (
> +                                         JsonStructProtocol,
> +                                         NULL,
> +                                         InputJson,
> +                                         (EFI_REST_JSON_STRUCTURE_HEADER
> **)&ComputerSystem
> +                                         );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status));
> +    return Status;
> +  }
> +
> +  ComputerSystemEmpty = NULL;
> +  Status              = JsonStructProtocol->ToStructure (
> +                                              JsonStructProtocol,
> +                                              NULL,
> +                                              ComputerSystemEmptyJson,
> +                                              (EFI_REST_JSON_STRUCTURE_HEADER
> **)&ComputerSystemEmpty
> +                                              );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status));
> +    return Status;
> +  }
> +
> +  ComputerSystemCs = ComputerSystem->ComputerSystem;
> +  //
> +  // Initial an empty ComputerSystemCS
> +  //
> +  ComputerSystemCsEmpty = ComputerSystemEmpty->ComputerSystem;
> +
> +  //
> +  // Handle BOOT
> +  //
> +  if (ComputerSystemCs->Boot != NULL) {
> +    //
> +    // Handle BOOT->BOOTNEXT
> +    //
> +    if (PropertyChecker (ComputerSystemCs->Boot->BootNext, ProvisionMode)) {
> +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, L"Boot/BootNext", ConfigureLang);
> +      if (AsciiStringValue != NULL) {
> +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot->BootNext,
> AsciiStringValue) != 0)) {
> +          ComputerSystemCsEmpty->Boot->BootNext = AsciiStringValue;
> +          PropertyChanged                       = TRUE;
> +        }
> +      }
> +    }
> +
> +    //
> +    // Handle BOOT->BOOTORDER
> +    //
> +    if (PropertyChecker (ComputerSystemCs->Boot->BootOrder, ProvisionMode)) {
> +      AsciiStringArrayValue = GetPropertyStringArrayValue (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, L"Boot/BootOrder", ConfigureLang, &ArraySize);
> +      if (AsciiStringArrayValue != NULL) {
> +        if (ProvisionMode || !CompareRedfishStringArrayValues
> (ComputerSystemCs->Boot->BootOrder, AsciiStringArrayValue, ArraySize)) {
> +          AddRedfishCharArray (&ComputerSystemCsEmpty->Boot->BootOrder,
> AsciiStringArrayValue, ArraySize);
> +          PropertyChanged = TRUE;
> +        }
> +      }
> +    }
> +
> +    //
> +    // Handle BOOT->BOOTSOURCEOVERRIDEENABLED
> +    //
> +    if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideEnabled,
> ProvisionMode)) {
> +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideEnabled",
> ConfigureLang);
> +      if (AsciiStringValue != NULL) {
> +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> >BootSourceOverrideEnabled, AsciiStringValue) != 0)) {
> +          ComputerSystemCsEmpty->Boot->BootSourceOverrideEnabled =
> AsciiStringValue;
> +          PropertyChanged                                        = TRUE;
> +        }
> +      }
> +    }
> +
> +    //
> +    // Handle BOOT->BOOTSOURCEOVERRIDEMODE
> +    //
> +    if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideMode,
> ProvisionMode)) {
> +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideMode",
> ConfigureLang);
> +      if (AsciiStringValue != NULL) {
> +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> >BootSourceOverrideMode, AsciiStringValue) != 0)) {
> +          ComputerSystemCsEmpty->Boot->BootSourceOverrideMode =
> AsciiStringValue;
> +          PropertyChanged                                     = TRUE;
> +        }
> +      }
> +    }
> +
> +    //
> +    // Handle BOOT->BOOTSOURCEOVERRIDETARGET
> +    //
> +    if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideTarget,
> ProvisionMode)) {
> +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideTarget",
> ConfigureLang);
> +      if (AsciiStringValue != NULL) {
> +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> >BootSourceOverrideTarget, AsciiStringValue) != 0)) {
> +          ComputerSystemCsEmpty->Boot->BootSourceOverrideTarget =
> AsciiStringValue;
> +          PropertyChanged                                       = TRUE;
> +        }
> +      }
> +    }
> +
> +    //
> +    // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE
> +    //
> +    if (PropertyChecker (ComputerSystemCs->Boot-
> >UefiTargetBootSourceOverride, ProvisionMode)) {
> +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, L"Boot/UefiTargetBootSourceOverride",
> ConfigureLang);
> +      if (AsciiStringValue != NULL) {
> +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> >UefiTargetBootSourceOverride, AsciiStringValue) != 0)) {
> +          ComputerSystemCsEmpty->Boot->UefiTargetBootSourceOverride =
> AsciiStringValue;
> +          PropertyChanged                                           = TRUE;
> +        }
> +      }
> +    }
> +  }
> +
> +  //
> +  // Convert C structure back to JSON text.
> +  //
> +  Status = JsonStructProtocol->ToJson (
> +                                 JsonStructProtocol,
> +                                 (EFI_REST_JSON_STRUCTURE_HEADER
> *)ComputerSystemEmpty,
> +                                 ResultJson
> +                                 );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status));
> +    return Status;
> +  }
> +
> +  if (PropertyChanged) {
> +    // Remove Redfish unchangeable properties.
> +    Status = RedfishRemoveUnchangeableProperties (ResultJson);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable
> properties from ResultJson.\n", __func__));
> +      *ResultJson = NULL;
> +      return Status;
> +    }
> +  }
> +
> +  //
> +  // Release resource.
> +  //
> +  JsonStructProtocol->DestoryStructure (
> +                        JsonStructProtocol,
> +                        (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
> +                        );
> +
> +  //
> +  // Free memory allocated for Computersystem empty CS
> +  //
> +  if (ComputerSystemCsEmpty->Boot->BootOrder != NULL) {
> +    DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder,
> ArraySize);
> +  }
> +
> +  JsonStructProtocol->DestoryStructure (
> +                        JsonStructProtocol,
> +                        (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEmpty
> +                        );
> +  return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND);
> +}
> +
> +EFI_STATUS
> +ProvisioningComputerSystemResource (
> +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> +  IN  UINTN                            Index,
> +  IN  EFI_STRING                       ConfigureLang
> +  )
> +{
> +  CHAR8       *Json;
> +  CHAR8       *JsonWithAddendum;
> +  EFI_STATUS  Status;
> +  EFI_STRING  NewResourceLocation;
> +  CHAR8       *EtagStr;
> +  CHAR8       ResourceId[16];
> +
> +  if (IS_EMPTY_STRING (ConfigureLang) || (Private == NULL)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  EtagStr = NULL;
> +  AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index);
> +
> +  Status = ProvisioningComputerSystemProperties (
> +             Private->JsonStructProtocol,
> +             ComputerSystemEmptyJson,
> +             ResourceId,
> +             ConfigureLang,
> +             TRUE,
> +             &Json
> +             );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: provisioning resource for %s failed: %r\n",
> __func__, ConfigureLang, Status));
> +    return Status;
> +  }
> +
> +  //
> +  // Check and see if platform has OEM data or not
> +  //
> +  Status = RedfishGetOemData (
> +             Private->Uri,
> +             RESOURCE_SCHEMA,
> +             RESOURCE_SCHEMA_VERSION,
> +             Json,
> +             &JsonWithAddendum
> +             );
> +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> +    FreePool (Json);
> +    Json             = JsonWithAddendum;
> +    JsonWithAddendum = NULL;
> +  }
> +
> +  //
> +  // Check and see if platform has addendum data or not
> +  //
> +  Status = RedfishGetAddendumData (
> +             Private->Uri,
> +             RESOURCE_SCHEMA,
> +             RESOURCE_SCHEMA_VERSION,
> +             Json,
> +             &JsonWithAddendum
> +             );
> +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> +    FreePool (Json);
> +    Json             = JsonWithAddendum;
> +    JsonWithAddendum = NULL;
> +  }
> +
> +  Status = CreatePayloadToPostResource (Private->RedfishService, Private-
> >Payload, Json, &NewResourceLocation, &EtagStr);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s failed:
> %r\n", __func__, ConfigureLang, Status));
> +    goto RELEASE_RESOURCE;
> +  }
> +
> +  ASSERT (NewResourceLocation != NULL);
> +
> +  //
> +  // Keep location of new resource.
> +  //
> +  if (NewResourceLocation != NULL) {
> +    RedfishSetRedfishUri (ConfigureLang, NewResourceLocation);
> +  }
> +
> +RELEASE_RESOURCE:
> +
> +  if (EtagStr != NULL) {
> +    FreePool (EtagStr);
> +  }
> +
> +  if (NewResourceLocation != NULL) {
> +    FreePool (NewResourceLocation);
> +  }
> +
> +  if (Json != NULL) {
> +    FreePool (Json);
> +  }
> +
> +  return Status;
> +}
> +
> +EFI_STATUS
> +ProvisioningComputerSystemResources (
> +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private
> +  )
> +{
> +  UINTN                                        Index;
> +  EFI_STATUS                                   Status;
> +  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST
> UnifiedConfigureLangList;
> +
> +  if (Private == NULL) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang
> (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION,
> REDPATH_ARRAY_PATTERN, &UnifiedConfigureLangList);
> +  if (EFI_ERROR (Status) || (UnifiedConfigureLangList.Count == 0)) {
> +    DEBUG ((DEBUG_ERROR, "%a: No HII question found with configure
> language: %s: %r\n", __func__, REDPATH_ARRAY_PATTERN, Status));
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  //
> +  // Set the configuration language in the
> RESOURCE_INFORMATION_EXCHANGE.
> +  // This information is sent back to the parent resource (e.g. the collection
> driver).
> +  //
> +  EdkIIRedfishResourceSetConfigureLang
> (mRedfishResourceConfigProtocolHandle, &UnifiedConfigureLangList);
> +
> +  for (Index = 0; Index < UnifiedConfigureLangList.Count; Index++) {
> +    DEBUG ((DEBUG_MANAGEABILITY, "[%d] create ComputerSystem resource
> from: %s\n", UnifiedConfigureLangList.List[Index].Index,
> UnifiedConfigureLangList.List[Index].ConfigureLang));
> +    ProvisioningComputerSystemResource (Private,
> UnifiedConfigureLangList.List[Index].Index,
> UnifiedConfigureLangList.List[Index].ConfigureLang);
> +    FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang);
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +ProvisioningComputerSystemExistResource (
> +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private
> +  )
> +{
> +  EFI_STATUS  Status;
> +  EFI_STRING  ConfigureLang;
> +  CHAR8       *Json;
> +  CHAR8       *JsonWithAddendum;
> +
> +  if (Private == NULL) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Json          = NULL;
> +  ConfigureLang = NULL;
> +
> +  ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
> +  if (ConfigureLang == NULL) {
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  Status = ProvisioningComputerSystemProperties (
> +             Private->JsonStructProtocol,
> +             ComputerSystemEmptyJson,
> +             NULL,
> +             ConfigureLang,
> +             TRUE,
> +             &Json
> +             );
> +  if (EFI_ERROR (Status)) {
> +    if (Status == EFI_NOT_FOUND) {
> +      DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for
> %s ignored. Nothing changed\n", __func__, ConfigureLang));
> +      Status = EFI_SUCCESS;
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a: provisioning existing resource for %s failed:
> %r\n", __func__, ConfigureLang, Status));
> +    }
> +
> +    goto ON_RELEASE;
> +  }
> +
> +  //
> +  // Check and see if platform has OEM data or not
> +  //
> +  Status = RedfishGetOemData (
> +             Private->Uri,
> +             RESOURCE_SCHEMA,
> +             RESOURCE_SCHEMA_VERSION,
> +             Json,
> +             &JsonWithAddendum
> +             );
> +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> +    FreePool (Json);
> +    Json             = JsonWithAddendum;
> +    JsonWithAddendum = NULL;
> +  }
> +
> +  //
> +  // Check and see if platform has addendum data or not
> +  //
> +  Status = RedfishGetAddendumData (
> +             Private->Uri,
> +             RESOURCE_SCHEMA,
> +             RESOURCE_SCHEMA_VERSION,
> +             Json,
> +             &JsonWithAddendum
> +             );
> +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> +    FreePool (Json);
> +    Json             = JsonWithAddendum;
> +    JsonWithAddendum = NULL;
> +  }
> +
> +  DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for
> %s\n", __func__, ConfigureLang));
> +
> +  //
> +  // PUT back to instance
> +  //
> +  Status = CreatePayloadToPatchResource (Private->RedfishService, Private-
> >Payload, Json, NULL);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +  }
> +
> +ON_RELEASE:
> +
> +  if (Json != NULL) {
> +    FreePool (Json);
> +  }
> +
> +  if (ConfigureLang != NULL) {
> +    FreePool (ConfigureLang);
> +  }
> +
> +  return Status;
> +}
> +
> +/**
> +  Provisioning redfish resource by given URI.
> +
> +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> instance.
> +  @param[in]   ResourceExist       TRUE if resource exists, PUT method will be
> used.
> +                                   FALSE if resource does not exist POST method is used.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +RedfishProvisioningResourceCommon (
> +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> +  IN     BOOLEAN                          ResourceExist
> +  )
> +{
> +  if (Private == NULL) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  return (ResourceExist ? ProvisioningComputerSystemExistResource (Private) :
> ProvisioningComputerSystemResources (Private));
> +}
> +
> +/**
> +  Check resource from given URI.
> +
> +  @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
> +  @param[in]   Json                The JSON to consume.
> +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +RedfishCheckResourceCommon (
> +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> +  IN     CHAR8                            *Json,
> +  IN     CHAR8                            *HeaderEtag OPTIONAL
> +  )
> +{
> +  UINTN       Index;
> +  EFI_STATUS  Status;
> +  EFI_STRING  *ConfigureLangList;
> +  UINTN       Count;
> +  EFI_STRING  Property;
> +
> +  if ((Private == NULL) || IS_EMPTY_STRING (Json)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  //
> +  // Check ETAG to see if we need to check it
> +  //
> +  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
> +    //
> +    // No change
> +    //
> +    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore
> check action\n", __func__, Private->Uri));
> +    return EFI_SUCCESS;
> +  }
> +
> +  Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigureLangList,
> &Count);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed: %r\n", __func__, Status));
> +    return Status;
> +  }
> +
> +  if (Count == 0) {
> +    return EFI_UNSUPPORTED;
> +  }
> +
> +  Status = EFI_SUCCESS;
> +  for (Index = 0; Index < Count; Index++) {
> +    Property = GetPropertyFromConfigureLang (Private->Uri,
> ConfigureLangList[Index]);
> +    if (Property == NULL) {
> +      continue;
> +    }
> +
> +    DEBUG ((DEBUG_MANAGEABILITY, "%a: [%d] check attribute for: %s\n",
> __func__, Index, Property));
> +    if (!MatchPropertyWithJsonContext (Property, Json)) {
> +      DEBUG ((DEBUG_MANAGEABILITY, "%a: property is missing: %s\n",
> __func__, Property));
> +      Status = EFI_NOT_FOUND;
> +    }
> +  }
> +
> +  FreePool (ConfigureLangList);
> +
> +  return Status;
> +}
> +
> +/**
> +  Update resource to given URI.
> +
> +  @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
> +  @param[in]   Json                The JSON to consume.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +RedfishUpdateResourceCommon (
> +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> +  IN     CHAR8                            *InputJson
> +  )
> +{
> +  EFI_STATUS  Status;
> +  CHAR8       *Json;
> +  CHAR8       *JsonWithAddendum;
> +  EFI_STRING  ConfigureLang;
> +
> +  if ((Private == NULL) || IS_EMPTY_STRING (InputJson)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Json          = NULL;
> +  ConfigureLang = NULL;
> +
> +  ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
> +  if (ConfigureLang == NULL) {
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  Status = ProvisioningComputerSystemProperties (
> +             Private->JsonStructProtocol,
> +             InputJson,
> +             NULL,
> +             ConfigureLang,
> +             FALSE,
> +             &Json
> +             );
> +  if (EFI_ERROR (Status)) {
> +    if (Status == EFI_NOT_FOUND) {
> +      DEBUG ((DEBUG_MANAGEABILITY, "%a: update resource for %s ignored.
> Nothing changed\n", __func__, ConfigureLang));
> +      Status = EFI_SUCCESS;
> +    } else {
> +      DEBUG ((DEBUG_ERROR, "%a: update resource for %s failed: %r\n",
> __func__, ConfigureLang, Status));
> +    }
> +
> +    goto ON_RELEASE;
> +  }
> +
> +  //
> +  // Check and see if platform has OEM data or not
> +  //
> +  Status = RedfishGetOemData (
> +             Private->Uri,
> +             RESOURCE_SCHEMA,
> +             RESOURCE_SCHEMA_VERSION,
> +             Json,
> +             &JsonWithAddendum
> +             );
> +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> +    FreePool (Json);
> +    Json             = JsonWithAddendum;
> +    JsonWithAddendum = NULL;
> +  }
> +
> +  //
> +  // Check and see if platform has addendum data or not
> +  //
> +  Status = RedfishGetAddendumData (
> +             Private->Uri,
> +             RESOURCE_SCHEMA,
> +             RESOURCE_SCHEMA_VERSION,
> +             Json,
> +             &JsonWithAddendum
> +             );
> +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> +    FreePool (Json);
> +    Json             = JsonWithAddendum;
> +    JsonWithAddendum = NULL;
> +  }
> +
> +  DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __func__,
> ConfigureLang));
> +
> +  //
> +  // PUT back to instance
> +  //
> +  Status = CreatePayloadToPatchResource (Private->RedfishService, Private-
> >Payload, Json, NULL);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__,
> ConfigureLang, Status));
> +  }
> +
> +ON_RELEASE:
> +
> +  if (Json != NULL) {
> +    FreePool (Json);
> +  }
> +
> +  if (ConfigureLang != NULL) {
> +    FreePool (ConfigureLang);
> +  }
> +
> +  return Status;
> +}
> +
> +/**
> +  Identify resource from given URI.
> +
> +  @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
> +  @param[in]   Json                The JSON to consume.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +RedfishIdentifyResourceCommon (
> +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> +  IN     CHAR8                            *Json
> +  )
> +{
> +  BOOLEAN                                      Supported;
> +  EFI_STATUS                                   Status;
> +  EFI_STRING                                   EndOfChar;
> +  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST  ConfigLangList;
> +
> +  Supported = RedfishIdentifyResource (Private->Uri, Private->Json);
> +  if (Supported) {
> +    Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang
> (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION,
> REDPATH_ARRAY_PATTERN, &ConfigLangList);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "%a:
> RedfishFeatureGetUnifiedArrayTypeConfigureLang failed: %r\n", __func__,
> Status));
> +      return Status;
> +    }
> +
> +    if (ConfigLangList.Count == 0) {
> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish ConfigureLang
> found for %s\n", __func__, Private->Uri));
> +      return EFI_SUCCESS;
> +    }
> +
> +    EndOfChar = StrStr (ConfigLangList.List[0].ConfigureLang, L"}");
> +    if (EndOfChar == NULL) {
> +      ASSERT (FALSE);
> +      return EFI_DEVICE_ERROR;
> +    }
> +
> +    // EndOfChar = StrStr (ConfigLangList.List[0].ConfigureLang, L"}");
> +    Status = IsRedpathArray (ConfigLangList.List[0].ConfigureLang, NULL,
> &EndOfChar);
> +    if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
> +      ASSERT (FALSE);
> +      return EFI_DEVICE_ERROR;
> +    }
> +
> +    if (Status != EFI_SUCCESS) {
> +      //
> +      // This is not the collection redpath.
> +      //
> +      GetRedpathNodeByIndex (ConfigLangList.List[0].ConfigureLang, 0,
> &EndOfChar);
> +    }
> +
> +    *(++EndOfChar) = '\0';
> +    //
> +    // Keep URI and ConfigLang mapping
> +    //
> +    RedfishSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private->Uri);
> +    //
> +    // Set the configuration language in the
> RESOURCE_INFORMATION_EXCHANGE.
> +    // This information is sent back to the parent resource (e.g. the collection
> driver).
> +    //
> +    EdkIIRedfishResourceSetConfigureLang
> (mRedfishResourceConfigProtocolHandle, &ConfigLangList);
> +    DestroyConfiglanguageList (&ConfigLangList);
> +    return EFI_SUCCESS;
> +  }
> +
> +  return EFI_UNSUPPORTED;
> +}
> diff --git
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD
> xe.c
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD
> xe.c
> new file mode 100644
> index 0000000000..30a0e64c64
> --- /dev/null
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD
> xe.c
> @@ -0,0 +1,702 @@
> +/** @file
> +  Redfish feature driver implementation - ComputerSystem
> +
> +  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> +  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "../Common/ComputerSystemCommon.h"
> +
> +extern REDFISH_RESOURCE_COMMON_PRIVATE  *mRedfishResourcePrivate;
> +extern EFI_HANDLE                       mRedfishResourceConfigProtocolHandle;
> +
> +/**
> +  Provision redfish resource by given URI.
> +
> +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> instance.
> +  @param[in]   Uri                 Target URI to create resource.
> +  @param[in]   PostMode            TRUE if the resource does not exist, post
> method is used.
> +                                   FALSE if the resource exist but property is missing, put
> method is used.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceProvisioningResource (
> +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> +  IN     EFI_STRING                              Uri,
> +  IN     BOOLEAN                                 PostMode
> +  )
> +{
> +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> +  EFI_STATUS                       Status;
> +  REDFISH_RESPONSE                 Response;
> +
> +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning in %s mode\n", __func__,
> (PostMode ? L"POST" : L"PATCH")));
> +
> +  Private =
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL
> (This);
> +
> +  if (Private->RedfishService == NULL) {
> +    return EFI_NOT_READY;
> +  }
> +
> +  ZeroMem (&Response, sizeof (Response));
> +  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response,
> TRUE);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> Uri));
> +    return Status;
> +  }
> +
> +  Private->Uri     = Uri;
> +  Private->Payload = Response.Payload;
> +  ASSERT (Private->Payload != NULL);
> +
> +  Status = RedfishProvisioningResourceCommon (Private, !PostMode);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to provision resource to: %s: %r\n",
> __func__, Uri, Status));
> +  } else {
> +    //
> +    // Get latest ETag on URI and keep it in variable.
> +    //
> +    SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
> +  }
> +
> +  //
> +  // Release resource
> +  //
> +  if (Private->Payload != NULL) {
> +    RedfishFreeResponse (
> +      Response.StatusCode,
> +      Response.HeaderCount,
> +      Response.Headers,
> +      Response.Payload
> +      );
> +    Private->Payload = NULL;
> +  }
> +
> +  return Status;
> +}
> +
> +/**
> +  Consume resource from given URI.
> +
> +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> instance.
> +  @param[in]   Uri                 The target URI to consume.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceConsumeResource (
> +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> +  IN     EFI_STRING                              Uri
> +  )
> +{
> +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> +  EFI_STATUS                       Status;
> +  REDFISH_RESPONSE                 Response;
> +  EFI_STRING                       PendingSettingUri;
> +  REDFISH_RESPONSE                 PendingSettingResponse;
> +  REDFISH_RESPONSE                 *ExpectedResponse;
> +  CHAR8                            *Etag;
> +
> +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Private =
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL
> (This);
> +
> +  if (Private->RedfishService == NULL) {
> +    return EFI_NOT_READY;
> +  }
> +
> +  ZeroMem (&Response, sizeof (Response));
> +  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response,
> TRUE);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> Uri));
> +    return Status;
> +  }
> +
> +  //
> +  // Check and see if "@Redfish.Settings" exist or not.
> +  //
> +  ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE));
> +  Status = GetPendingSettings (
> +             Private->RedfishService,
> +             Response.Payload,
> +             &PendingSettingResponse,
> +             &PendingSettingUri
> +             );
> +  if (!EFI_ERROR (Status)) {
> +    DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n",
> __func__, PendingSettingUri));
> +    Private->Uri     = PendingSettingUri;
> +    ExpectedResponse = &PendingSettingResponse;
> +  } else {
> +    DEBUG ((REDFISH_DEBUG_TRACE, "%a: No @Redfish.Settings is found\n",
> __func__));
> +    Private->Uri     = Uri;
> +    ExpectedResponse = &Response;
> +  }
> +
> +  Private->Payload = ExpectedResponse->Payload;
> +  ASSERT (Private->Payload != NULL);
> +
> +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT);
> +  ASSERT (Private->Json != NULL);
> +
> +  //
> +  // Find etag in HTTP response header
> +  //
> +  Etag = NULL;
> +  GetHttpResponseEtag (ExpectedResponse, &Etag);
> +  Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n",
> __func__, Private->Uri, Status));
> +  }
> +
> +  //
> +  // Release resource
> +  //
> +  if (Etag != NULL) {
> +    FreePool (Etag);
> +  }
> +
> +  //
> +  // Release resource
> +  //
> +  if (Private->Payload != NULL) {
> +    if (Response.Payload != NULL) {
> +      RedfishFreeResponse (
> +        Response.StatusCode,
> +        Response.HeaderCount,
> +        Response.Headers,
> +        Response.Payload
> +        );
> +    }
> +
> +    if (PendingSettingResponse.Payload != NULL) {
> +      RedfishFreeResponse (
> +        PendingSettingResponse.StatusCode,
> +        PendingSettingResponse.HeaderCount,
> +        PendingSettingResponse.Headers,
> +        PendingSettingResponse.Payload
> +        );
> +    }
> +
> +    Private->Payload = NULL;
> +  }
> +
> +  if (Private->Json != NULL) {
> +    FreePool (Private->Json);
> +    Private->Json = NULL;
> +  }
> +
> +  return Status;
> +}
> +
> +/**
> +  Get information about this protocol.
> +
> +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> instance.
> +  @param[out]  Schema              Supported schema.
> +  @param[out]  Major               Supported major number.
> +  @param[out]  Minor               Supported minor number.
> +  @param[out]  Errata              Supported errata number.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceGetInfo (
> +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> +  OUT    REDFISH_SCHEMA_INFO                     *Info
> +  )
> +{
> +  if ((This == NULL) || (Info == NULL)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  AsciiStrCpyS (Info->Schema, REDFISH_SCHEMA_STRING_SIZE,
> RESOURCE_SCHEMA);
> +  AsciiStrCpyS (Info->Major, REDFISH_SCHEMA_VERSION_SIZE,
> RESOURCE_SCHEMA_MAJOR);
> +  AsciiStrCpyS (Info->Minor, REDFISH_SCHEMA_VERSION_SIZE,
> RESOURCE_SCHEMA_MINOR);
> +  AsciiStrCpyS (Info->Errata, REDFISH_SCHEMA_VERSION_SIZE,
> RESOURCE_SCHEMA_ERRATA);
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Update resource to given URI.
> +
> +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> instance.
> +  @param[in]   Uri                 The target URI to consume.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceUpdate (
> +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> +  IN     EFI_STRING                              Uri
> +  )
> +{
> +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> +  EFI_STATUS                       Status;
> +  REDFISH_RESPONSE                 Response;
> +
> +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Private =
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL
> (This);
> +
> +  if (Private->RedfishService == NULL) {
> +    return EFI_NOT_READY;
> +  }
> +
> +  ZeroMem (&Response, sizeof (Response));
> +  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response,
> TRUE);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> Uri));
> +    return Status;
> +  }
> +
> +  Private->Uri     = Uri;
> +  Private->Payload = Response.Payload;
> +  ASSERT (Private->Payload != NULL);
> +
> +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT);
> +  ASSERT (Private->Json != NULL);
> +
> +  Status = RedfishUpdateResourceCommon (Private, Private->Json);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to update resource to: %s: %r\n",
> __func__, Uri, Status));
> +  } else {
> +    //
> +    // Get latest ETag on URI and keep it in variable.
> +    //
> +    SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
> +  }
> +
> +  //
> +  // Release resource
> +  //
> +  if (Private->Payload != NULL) {
> +    RedfishFreeResponse (
> +      Response.StatusCode,
> +      Response.HeaderCount,
> +      Response.Headers,
> +      Response.Payload
> +      );
> +    RedfishHttpResetResource (Uri);
> +    Private->Payload = NULL;
> +  }
> +
> +  if (Private->Json != NULL) {
> +    FreePool (Private->Json);
> +    Private->Json = NULL;
> +  }
> +
> +  return Status;
> +}
> +
> +/**
> +  Check resource on given URI.
> +
> +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> instance.
> +  @param[in]   Uri                 The target URI to consume.
> +
> +  @retval EFI_SUCCESS              Value is returned successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceCheck (
> +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> +  IN     EFI_STRING                              Uri
> +  )
> +{
> +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> +  EFI_STATUS                       Status;
> +  REDFISH_RESPONSE                 Response;
> +  CHAR8                            *Etag;
> +
> +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Private =
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL
> (This);
> +
> +  if (Private->RedfishService == NULL) {
> +    return EFI_NOT_READY;
> +  }
> +
> +  ZeroMem (&Response, sizeof (Response));
> +  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response,
> TRUE);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> Uri));
> +    return Status;
> +  }
> +
> +  Private->Uri     = Uri;
> +  Private->Payload = Response.Payload;
> +  ASSERT (Private->Payload != NULL);
> +
> +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT);
> +  ASSERT (Private->Json != NULL);
> +
> +  //
> +  // Find etag in HTTP response header
> +  //
> +  Etag = NULL;
> +  GetHttpResponseEtag (&Response, &Etag);
> +  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to check resource from: %s: %r\n",
> __func__, Uri, Status));
> +  }
> +
> +  //
> +  // Release resource
> +  //
> +  if (Etag != NULL) {
> +    FreePool (Etag);
> +  }
> +
> +  if (Private->Payload != NULL) {
> +    RedfishFreeResponse (
> +      Response.StatusCode,
> +      Response.HeaderCount,
> +      Response.Headers,
> +      Response.Payload
> +      );
> +    Private->Payload = NULL;
> +  }
> +
> +  if (Private->Json != NULL) {
> +    FreePool (Private->Json);
> +    Private->Json = NULL;
> +  }
> +
> +  return Status;
> +}
> +
> +/**
> +  Identify resource on given URI.
> +
> +  @param[in]   This                Pointer to
> EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL instance.
> +  @param[in]   Uri                 The target URI to consume.
> +
> +  @retval EFI_SUCCESS              This is target resource which we want to handle.
> +  @retval EFI_UNSUPPORTED          This is not the target resource.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceIdentify (
> +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> +  IN     EFI_STRING                              Uri
> +  )
> +{
> +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> +  EFI_STATUS                       Status;
> +  REDFISH_RESPONSE                 Response;
> +
> +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Private =
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL
> (This);
> +
> +  if (Private->RedfishService == NULL) {
> +    return EFI_NOT_READY;
> +  }
> +
> +  ZeroMem (&Response, sizeof (Response));
> +  Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response,
> TRUE);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> Uri));
> +    return Status;
> +  }
> +
> +  Private->Uri     = Uri;
> +  Private->Payload = Response.Payload;
> +  ASSERT (Private->Payload != NULL);
> +
> +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT);
> +  ASSERT (Private->Json != NULL);
> +
> +  Status = RedfishIdentifyResourceCommon (Private, Private->Json);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: identify %s failed: %r\n", __func__, Uri,
> Status));
> +  }
> +
> +  //
> +  // Release resource
> +  //
> +  if (Private->Payload != NULL) {
> +    RedfishFreeResponse (
> +      Response.StatusCode,
> +      Response.HeaderCount,
> +      Response.Headers,
> +      Response.Payload
> +      );
> +    Private->Payload = NULL;
> +  }
> +
> +  if (Private->Json != NULL) {
> +    FreePool (Private->Json);
> +    Private->Json = NULL;
> +  }
> +
> +  return Status;
> +}
> +
> +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  mRedfishResourceConfig = {
> +  RedfishResourceProvisioningResource,
> +  RedfishResourceConsumeResource,
> +  RedfishResourceUpdate,
> +  RedfishResourceCheck,
> +  RedfishResourceIdentify,
> +  RedfishResourceGetInfo
> +};
> +
> +/**
> +  Initialize a Redfish configure handler.
> +
> +  This function will be called by the Redfish config driver to initialize each Redfish
> configure
> +  handler.
> +
> +  @param[in]   This                     Pointer to
> EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance.
> +  @param[in]   RedfishConfigServiceInfo Redfish service information.
> +
> +  @retval EFI_SUCCESS                  The handler has been initialized successfully.
> +  @retval EFI_DEVICE_ERROR             Failed to create or configure the REST EX
> protocol instance.
> +  @retval EFI_ALREADY_STARTED          This handler has already been initialized.
> +  @retval Other                        Error happens during the initialization.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceInit (
> +  IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *This,
> +  IN  REDFISH_CONFIG_SERVICE_INFORMATION     *RedfishConfigServiceInfo
> +  )
> +{
> +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> +
> +  Private =
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL
> (This);
> +
> +  Private->RedfishService = RedfishCreateService (RedfishConfigServiceInfo);
> +  if (Private->RedfishService == NULL) {
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Stop a Redfish configure handler.
> +
> +  @param[in]   This                Pointer to
> EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance.
> +
> +  @retval EFI_SUCCESS              This handler has been stoped successfully.
> +  @retval Others                   Some error happened.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceStop (
> +  IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *This
> +  )
> +{
> +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> +
> +  Private =
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL
> (This);
> +
> +  if (Private->Event != NULL) {
> +    gBS->CloseEvent (Private->Event);
> +    Private->Event = NULL;
> +  }
> +
> +  if (Private->RedfishService != NULL) {
> +    RedfishCleanupService (Private->RedfishService);
> +    Private->RedfishService = NULL;
> +  }
> +
> +  if (Private->Payload != NULL) {
> +    RedfishCleanupPayload (Private->Payload);
> +    Private->Payload = NULL;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  mRedfishConfigHandler = {
> +  RedfishResourceInit,
> +  RedfishResourceStop
> +};
> +
> +/**
> +  Callback function when gEfiRestJsonStructureProtocolGuid is installed.
> +
> +  @param[in] Event    Event whose notification function is being invoked.
> +  @param[in] Context  Pointer to the notification function's context.
> +**/
> +VOID
> +EFIAPI
> +EfiRestJasonStructureProtocolIsReady (
> +  IN  EFI_EVENT  Event,
> +  IN  VOID       *Context
> +  )
> +{
> +  EFI_STATUS  Status;
> +
> +  if (mRedfishResourcePrivate == NULL) {
> +    return;
> +  }
> +
> +  if (mRedfishResourcePrivate->JsonStructProtocol != NULL) {
> +    return;
> +  }
> +
> +  Status = gBS->LocateProtocol (
> +                  &gEfiRestJsonStructureProtocolGuid,
> +                  NULL,
> +                  (VOID **)&mRedfishResourcePrivate->JsonStructProtocol
> +                  );
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to locate
> gEfiRestJsonStructureProtocolGuid: %r\n", __func__, Status));
> +  }
> +
> +  gBS->CloseEvent (Event);
> +}
> +
> +/**
> +  Unloads an image.
> +
> +  @param  ImageHandle           Handle that identifies the image to be unloaded.
> +
> +  @retval EFI_SUCCESS           The image has been unloaded.
> +  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceUnload (
> +  IN EFI_HANDLE  ImageHandle
> +  )
> +{
> +  EFI_STATUS                             Status;
> +  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *ConfigHandler;
> +
> +  if (mRedfishResourcePrivate == NULL) {
> +    return EFI_NOT_READY;
> +  }
> +
> +  ConfigHandler = NULL;
> +
> +  //
> +  // Firstly, find ConfigHandler Protocol interface in this ImageHandle.
> +  //
> +  Status = gBS->OpenProtocol (
> +                  ImageHandle,
> +                  &gEdkIIRedfishConfigHandlerProtocolGuid,
> +                  (VOID **)&ConfigHandler,
> +                  NULL,
> +                  NULL,
> +                  EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
> +                  );
> +  if (EFI_ERROR (Status) || (ConfigHandler == NULL)) {
> +    return Status;
> +  }
> +
> +  ConfigHandler->Stop (ConfigHandler);
> +
> +  //
> +  // Last, uninstall ConfigHandler Protocol and resource protocol.
> +  //
> +  Status = gBS->UninstallMultipleProtocolInterfaces (
> +                  ImageHandle,
> +                  &gEdkIIRedfishConfigHandlerProtocolGuid,
> +                  ConfigHandler,
> +                  &gEdkIIRedfishResourceConfigProtocolGuid,
> +                  &mRedfishResourcePrivate->RedfishResourceConfig,
> +                  NULL
> +                  );
> +
> +  FreePool (mRedfishResourcePrivate);
> +  mRedfishResourcePrivate = NULL;
> +
> +  return Status;
> +}
> +
> +/**
> +  This is the declaration of an EFI image entry point. This entry point is
> +  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
> +  both device drivers and bus drivers. It initialize the global variables and
> +  publish the driver binding protocol.
> +
> +  @param[in]   ImageHandle      The firmware allocated handle for the UEFI
> image.
> +  @param[in]   SystemTable      A pointer to the EFI System Table.
> +
> +  @retval EFI_SUCCESS           The operation completed successfully.
> +  @retval Others                Other errors as indicated.
> +**/
> +EFI_STATUS
> +EFIAPI
> +RedfishResourceEntryPoint (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  EFI_STATUS  Status;
> +  VOID        *Registration;
> +
> +  if (mRedfishResourcePrivate != NULL) {
> +    return EFI_ALREADY_STARTED;
> +  }
> +
> +  mRedfishResourceConfigProtocolHandle = ImageHandle;
> +
> +  mRedfishResourcePrivate = AllocateZeroPool (sizeof
> (REDFISH_RESOURCE_COMMON_PRIVATE));
> +  CopyMem (&mRedfishResourcePrivate->ConfigHandler,
> &mRedfishConfigHandler, sizeof
> (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL));
> +  CopyMem (&mRedfishResourcePrivate->RedfishResourceConfig,
> &mRedfishResourceConfig, sizeof
> (EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL));
> +
> +  //
> +  // Publish config handler protocol and resource protocol.
> +  //
> +  Status = gBS->InstallMultipleProtocolInterfaces (
> +                  &ImageHandle,
> +                  &gEdkIIRedfishConfigHandlerProtocolGuid,
> +                  &mRedfishResourcePrivate->ConfigHandler,
> +                  &gEdkIIRedfishResourceConfigProtocolGuid,
> +                  &mRedfishResourcePrivate->RedfishResourceConfig,
> +                  NULL
> +                  );
> +
> +  EfiCreateProtocolNotifyEvent (
> +    &gEfiRestJsonStructureProtocolGuid,
> +    TPL_CALLBACK,
> +    EfiRestJasonStructureProtocolIsReady,
> +    NULL,
> +    &Registration
> +    );
> +
> +  return Status;
> +}
> --
> 2.37.1.windows.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114485): https://edk2.groups.io/g/devel/message/114485
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26  2:20 ` Nickle Wang via groups.io
@ 2024-01-26  2:32   ` Chang, Abner via groups.io
  2024-01-26 13:55   ` Mike Maslenkin
  1 sibling, 0 replies; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-26  2:32 UTC (permalink / raw)
  To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy

[AMD Official Use Only - General]

Thanks Nickle, I just sent out the updates.

Abner

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Friday, January 26, 2024 10:21 AM
> To: devel@edk2.groups.io; Chang, Abner <Abner.Chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Subject: RE: [edk2-devel] [edk2-redfish-client][PATCH V2]
> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.
>
> > +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
> ConfigureLang
> > found for %s\n", __func__, Private->Uri));
>
> Regards,
> Nickle
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
> Abner
> > via groups.io
> > Sent: Friday, January 26, 2024 9:00 AM
> > To: devel@edk2.groups.io
> > Cc: Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
> > Subject: [edk2-devel] [edk2-redfish-client][PATCH V2]
> > RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
> >
> > External email: Use caution opening links or attachments
> >
> >
> > From: Abner Chang <abner.chang@amd.com>
> >
> > Initial version of edk2 Redfish feature of
> > Redfish schema ComputerSystem_1_13_0. This driver
> > handles ComputerSystem Boot properties but not all.
> >
> > Signed-off-by: Abner Chang <abner.chang@amd.com>
> > Cc: Nickle Wang <nicklew@nvidia.com>
> > Cc: Igor Kulchytskyy <igork@ami.com>
> > ---
> >  .../v1_13_0/Dxe/ComputerSystemDxe.inf         |  53 ++
> >  .../v1_13_0/Common/ComputerSystemCommon.h     |  29 +
> >  .../v1_13_0/Common/ComputerSystemCommon.c     | 899
> > ++++++++++++++++++
> >  .../v1_13_0/Dxe/ComputerSystemDxe.c           | 702 ++++++++++++++
> >  4 files changed, 1683 insertions(+)
> >  create mode 100644
> >
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystem
> Dxe.
> > inf
> >  create mode 100644
> >
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerS
> yste
> > mCommon.h
> >  create mode 100644
> >
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerS
> yste
> > mCommon.c
> >  create mode 100644
> >
> RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystem
> Dxe.
> > c
> >
> > diff --git
> >
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSyste
> mD
> > xe.inf
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSyst
> emD
> > xe.inf
> > new file mode 100644
> > index 0000000000..6bc5cb358e
> > --- /dev/null
> > +++
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSyst
> emD
> > xe.inf
> > @@ -0,0 +1,53 @@
> > +## @file
> > +#
> > +#  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development
> LP<BR>
> > +#  Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +#
> > +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +#
> > +##
> > +
> > +
> > +[Defines]
> > +  INF_VERSION               = 0x00010005
> > +  BASE_NAME                 = ComputerSystemDxe
> > +  FILE_GUID                 = D94362A1-C358-4059-B014-F07D1AE04F16
> > +  MODULE_TYPE               = DXE_DRIVER
> > +  VERSION_STRING            = 1.0
> > +  ENTRY_POINT               = RedfishResourceEntryPoint
> > +  UNLOAD_IMAGE              = RedfishResourceUnload
> > +
> > +[Packages]
> > +  MdePkg/MdePkg.dec
> > +  MdeModulePkg/MdeModulePkg.dec
> > +  RedfishPkg/RedfishPkg.dec
> > +  RedfishClientPkg/RedfishClientPkg.dec
> > +
> > +[Sources]
> > +  ../Common/ComputerSystemCommon.h
> > +  ../Common/ComputerSystemCommon.c
> > +  ComputerSystemDxe.c
> > +
> > +[LibraryClasses]
> > +  BaseMemoryLib
> > +  DebugLib
> > +  EdkIIRedfishResourceConfigLib
> > +  RedfishLib
> > +  RedfishFeatureUtilityLib
> > +  RedfishResourceIdentifyLib
> > +  UefiLib
> > +  UefiDriverEntryPoint
> > +  RedfishAddendumLib
> > +  RedfishHttpCacheLib
> > +
> > +[Protocols]
> > +  gEdkIIRedfishConfigHandlerProtocolGuid          ## PRODUCED
> > +  gEfiRestJsonStructureProtocolGuid               ## CONSUMED
> > +  gEdkIIRedfishResourceConfigProtocolGuid         ## PRODUCED
> > +
> > +[Pcd]
> > +  gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize
> > +  gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize
> > +
> > +[Depex]
> > +  TRUE
> > diff --git
> >
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Compute
> rSyst
> > emCommon.h
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Compute
> rSyst
> > emCommon.h
> > new file mode 100644
> > index 0000000000..c9c8512881
> > --- /dev/null
> > +++
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Compute
> rSyst
> > emCommon.h
> > @@ -0,0 +1,29 @@
> > +/** @file
> > +
> > +  Redfish feature driver implementation - internal header file
> > +  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> > +  Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights
> > reserved.
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#ifndef EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_
> > +#define EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_
> > +
> > +#include
> >
> <RedfishJsonStructure/ComputerSystem/v1_13_0/EfiComputerSystemV1_1
> 3_0.h
> > >
> > +#include <RedfishResourceCommon.h>
> > +
> > +//
> > +// Schema information.
> > +//
> > +#define RESOURCE_SCHEMA          "ComputerSystem"
> > +#define RESOURCE_SCHEMA_MAJOR    "1"
> > +#define RESOURCE_SCHEMA_MINOR    "13"
> > +#define RESOURCE_SCHEMA_ERRATA   "0"
> > +#define RESOURCE_SCHEMA_VERSION  "v1_13_0"
> > +#define REDPATH_ARRAY_PATTERN    L"/Systems/\\{.*\\}/"
> > +#define REDPATH_ARRAY_PREFIX     L"/Systems/"
> > +#define RESOURCE_SCHEMA_FULL     "x-uefi-redfish-
> > ComputerSystem.v1_13_0"
> > +
> > +#endif
> > diff --git
> >
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Compute
> rSyst
> > emCommon.c
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Compute
> rSyst
> > emCommon.c
> > new file mode 100644
> > index 0000000000..bc24c49206
> > --- /dev/null
> > +++
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Compute
> rSyst
> > emCommon.c
> > @@ -0,0 +1,899 @@
> > +/** @file
> > +  Redfish feature driver implementation - common functions
> > +
> > +  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> > +  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> > +  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include "ComputerSystemCommon.h"
> > +
> > +CHAR8  ComputerSystemEmptyJson[] = "{\"@odata.id\": \"\",
> \"@odata.type\":
> > \"#ComputerSystem.v1_13_0.ComputerSystem\", \"Id\": \"\", \"Name\":
> \"\",
> > \"Boot\":{}}";
> > +
> > +REDFISH_RESOURCE_COMMON_PRIVATE  *mRedfishResourcePrivate
> =
> > NULL;
> > +EFI_HANDLE                       mRedfishResourceConfigProtocolHandle = NULL;
> > +
> > +/**
> > +  Consume resource from given URI.
> > +
> > +  @param[in]   This                Pointer to
> > REDFISH_RESOURCE_COMMON_PRIVATE instance.
> > +  @param[in]   Json                The JSON to consume.
> > +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +RedfishConsumeResourceCommon (
> > +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> > +  IN  CHAR8                            *Json,
> > +  IN  CHAR8                            *HeaderEtag OPTIONAL
> > +  )
> > +{
> > +  EFI_STATUS                             Status;
> > +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystem;
> > +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCs;
> > +  EFI_STRING                             ConfigureLang;
> > +
> > +  if ((Private == NULL) || IS_EMPTY_STRING (Json)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  ComputerSystem   = NULL;
> > +  ComputerSystemCs = NULL;
> > +  ConfigureLang    = NULL;
> > +
> > +  Status = Private->JsonStructProtocol->ToStructure (
> > +                                          Private->JsonStructProtocol,
> > +                                          NULL,
> > +                                          Json,
> > +                                          (EFI_REST_JSON_STRUCTURE_HEADER
> > **)&ComputerSystem
> > +                                          );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__,
> Status));
> > +    return Status;
> > +  }
> > +
> > +  ComputerSystemCs = ComputerSystem->ComputerSystem;
> > +
> > +  //
> > +  // Check ETAG to see if we need to consume it
> > +  //
> > +  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
> > +    //
> > +    // No change
> > +    //
> > +    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore
> > consume action\n", __func__, Private->Uri));
> > +    Status = EFI_SUCCESS;
> > +    goto ON_RELEASE;
> > +  }
> > +
> > +  //
> > +  // Handle BOOT
> > +  //
> > +  if (ComputerSystemCs->Boot == NULL) {
> > +    ComputerSystemCs->Boot = AllocateZeroPool (sizeof
> > (RedfishComputerSystem_V1_13_0_Boot_CS));
> > +    ASSERT (ComputerSystemCs->Boot != NULL);
> > +  }
> > +
> > +  //
> > +  // Handle BOOT->BOOTNEXT
> > +  //
> > +  if (ComputerSystemCs->Boot->BootNext != NULL) {
> > +    //
> > +    // Find corresponding configure language for collection resource.
> > +    //
> > +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> > "Boot/BootNext");
> > +    if (ConfigureLang != NULL) {
> > +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> > >BootNext);
> > +      if (EFI_ERROR (Status)) {
> > +        DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +      }
> > +
> > +      FreePool (ConfigureLang);
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI:
> > %s\n", __func__, Private->Uri));
> > +    }
> > +  }
> > +
> > +  //
> > +  // Handle BOOT->BOOTORDER
> > +  //
> > +  if (ComputerSystemCs->Boot->BootOrder != NULL) {
> > +    //
> > +    // Find corresponding configure language for collection resource.
> > +    //
> > +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> > "Boot/BootOrder");
> > +    if (ConfigureLang != NULL) {
> > +      Status = ApplyFeatureSettingsStringArrayType (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> > >BootOrder);
> > +      if (EFI_ERROR (Status)) {
> > +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +      }
> > +
> > +      FreePool (ConfigureLang);
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> > %s\n", __func__, Private->Uri));
> > +    }
> > +  }
> > +
> > +  //
> > +  // Handle BOOT->BOOTSOURCEOVERRIDEENABLED
> > +  //
> > +  if (ComputerSystemCs->Boot->BootSourceOverrideEnabled != NULL) {
> > +    //
> > +    // Find corresponding configure language for collection resource.
> > +    //
> > +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> > "Boot/BootSourceOverrideEnabled");
> > +    if (ConfigureLang != NULL) {
> > +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> > >BootSourceOverrideEnabled);
> > +      if (EFI_ERROR (Status)) {
> > +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +      }
> > +
> > +      FreePool (ConfigureLang);
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> > %s\n", __func__, Private->Uri));
> > +    }
> > +  }
> > +
> > +  //
> > +  // Handle BOOT->BOOTSOURCEOVERRIDEMODE
> > +  //
> > +  if (ComputerSystemCs->Boot->BootSourceOverrideMode != NULL) {
> > +    //
> > +    // Find corresponding configure language for collection resource.
> > +    //
> > +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> > "Boot/BootSourceOverrideMode");
> > +    if (ConfigureLang != NULL) {
> > +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> > >BootSourceOverrideMode);
> > +      if (EFI_ERROR (Status)) {
> > +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +      }
> > +
> > +      FreePool (ConfigureLang);
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> > %s\n", __func__, Private->Uri));
> > +    }
> > +  }
> > +
> > +  //
> > +  // Handle BOOT->BOOTSOURCEOVERRIDETARGET
> > +  //
> > +  if (ComputerSystemCs->Boot->BootSourceOverrideTarget != NULL) {
> > +    //
> > +    // Find corresponding configure language for collection resource.
> > +    //
> > +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> > "Boot/BootSourceOverrideTarget");
> > +    if (ConfigureLang != NULL) {
> > +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> > >BootSourceOverrideTarget);
> > +      if (EFI_ERROR (Status)) {
> > +        DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +      }
> > +
> > +      FreePool (ConfigureLang);
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI:
> > %s\n", __func__, Private->Uri));
> > +    }
> > +  }
> > +
> > +  //
> > +  // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE
> > +  //
> > +  if (ComputerSystemCs->Boot->UefiTargetBootSourceOverride != NULL) {
> > +    //
> > +    // Find corresponding configure language for collection resource.
> > +    //
> > +    ConfigureLang = GetConfigureLang (ComputerSystemCs->odata_id,
> > "Boot/UefiTargetBootSourceOverride");
> > +    if (ConfigureLang != NULL) {
> > +      Status = ApplyFeatureSettingsStringType (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot-
> > >UefiTargetBootSourceOverride);
> > +      if (EFI_ERROR (Status)) {
> > +        DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +      }
> > +
> > +      FreePool (ConfigureLang);
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI:
> > %s\n", __func__, Private->Uri));
> > +    }
> > +  }
> > +
> > +ON_RELEASE:
> > +
> > +  //
> > +  // Release resource.
> > +  //
> > +  Private->JsonStructProtocol->DestoryStructure (
> > +                                 Private->JsonStructProtocol,
> > +                                 (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
> > +                                 );
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +EFI_STATUS
> > +ProvisioningComputerSystemProperties (
> > +  IN  EFI_REST_JSON_STRUCTURE_PROTOCOL  *JsonStructProtocol,
> > +  IN  CHAR8                             *InputJson,
> > +  IN  CHAR8                             *ResourceId OPTIONAL,
> > +  IN  EFI_STRING                        ConfigureLang,
> > +  IN  BOOLEAN                           ProvisionMode,
> > +  OUT CHAR8                             **ResultJson
> > +  )
> > +{
> > +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystem;
> > +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS  *ComputerSystemCs;
> > +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0     *ComputerSystemEmpty;
> > +  EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS
> *ComputerSystemCsEmpty;
> > +  EFI_STATUS                             Status;
> > +  BOOLEAN                                PropertyChanged;
> > +  CHAR8                                  *AsciiStringValue;
> > +  CHAR8                                  **AsciiStringArrayValue;
> > +  UINTN                                  ArraySize;
> > +
> > +  if ((JsonStructProtocol == NULL) || (ResultJson == NULL) ||
> IS_EMPTY_STRING
> > (InputJson) || IS_EMPTY_STRING (ConfigureLang)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s with: %s\n",
> __func__,
> > ConfigureLang, (ProvisionMode ? L"Provision resource" : L"Update
> resource")));
> > +
> > +  *ResultJson     = NULL;
> > +  PropertyChanged = FALSE;
> > +
> > +  ComputerSystem = NULL;
> > +  Status         = JsonStructProtocol->ToStructure (
> > +                                         JsonStructProtocol,
> > +                                         NULL,
> > +                                         InputJson,
> > +                                         (EFI_REST_JSON_STRUCTURE_HEADER
> > **)&ComputerSystem
> > +                                         );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__,
> Status));
> > +    return Status;
> > +  }
> > +
> > +  ComputerSystemEmpty = NULL;
> > +  Status              = JsonStructProtocol->ToStructure (
> > +                                              JsonStructProtocol,
> > +                                              NULL,
> > +                                              ComputerSystemEmptyJson,
> > +                                              (EFI_REST_JSON_STRUCTURE_HEADER
> > **)&ComputerSystemEmpty
> > +                                              );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__,
> Status));
> > +    return Status;
> > +  }
> > +
> > +  ComputerSystemCs = ComputerSystem->ComputerSystem;
> > +  //
> > +  // Initial an empty ComputerSystemCS
> > +  //
> > +  ComputerSystemCsEmpty = ComputerSystemEmpty->ComputerSystem;
> > +
> > +  //
> > +  // Handle BOOT
> > +  //
> > +  if (ComputerSystemCs->Boot != NULL) {
> > +    //
> > +    // Handle BOOT->BOOTNEXT
> > +    //
> > +    if (PropertyChecker (ComputerSystemCs->Boot->BootNext,
> ProvisionMode)) {
> > +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, L"Boot/BootNext", ConfigureLang);
> > +      if (AsciiStringValue != NULL) {
> > +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> >BootNext,
> > AsciiStringValue) != 0)) {
> > +          ComputerSystemCsEmpty->Boot->BootNext = AsciiStringValue;
> > +          PropertyChanged                       = TRUE;
> > +        }
> > +      }
> > +    }
> > +
> > +    //
> > +    // Handle BOOT->BOOTORDER
> > +    //
> > +    if (PropertyChecker (ComputerSystemCs->Boot->BootOrder,
> ProvisionMode)) {
> > +      AsciiStringArrayValue = GetPropertyStringArrayValue
> (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, L"Boot/BootOrder", ConfigureLang,
> &ArraySize);
> > +      if (AsciiStringArrayValue != NULL) {
> > +        if (ProvisionMode || !CompareRedfishStringArrayValues
> > (ComputerSystemCs->Boot->BootOrder, AsciiStringArrayValue, ArraySize)) {
> > +          AddRedfishCharArray (&ComputerSystemCsEmpty->Boot-
> >BootOrder,
> > AsciiStringArrayValue, ArraySize);
> > +          PropertyChanged = TRUE;
> > +        }
> > +      }
> > +    }
> > +
> > +    //
> > +    // Handle BOOT->BOOTSOURCEOVERRIDEENABLED
> > +    //
> > +    if (PropertyChecker (ComputerSystemCs->Boot-
> >BootSourceOverrideEnabled,
> > ProvisionMode)) {
> > +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideEnabled",
> > ConfigureLang);
> > +      if (AsciiStringValue != NULL) {
> > +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> > >BootSourceOverrideEnabled, AsciiStringValue) != 0)) {
> > +          ComputerSystemCsEmpty->Boot->BootSourceOverrideEnabled =
> > AsciiStringValue;
> > +          PropertyChanged                                        = TRUE;
> > +        }
> > +      }
> > +    }
> > +
> > +    //
> > +    // Handle BOOT->BOOTSOURCEOVERRIDEMODE
> > +    //
> > +    if (PropertyChecker (ComputerSystemCs->Boot-
> >BootSourceOverrideMode,
> > ProvisionMode)) {
> > +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideMode",
> > ConfigureLang);
> > +      if (AsciiStringValue != NULL) {
> > +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> > >BootSourceOverrideMode, AsciiStringValue) != 0)) {
> > +          ComputerSystemCsEmpty->Boot->BootSourceOverrideMode =
> > AsciiStringValue;
> > +          PropertyChanged                                     = TRUE;
> > +        }
> > +      }
> > +    }
> > +
> > +    //
> > +    // Handle BOOT->BOOTSOURCEOVERRIDETARGET
> > +    //
> > +    if (PropertyChecker (ComputerSystemCs->Boot-
> >BootSourceOverrideTarget,
> > ProvisionMode)) {
> > +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideTarget",
> > ConfigureLang);
> > +      if (AsciiStringValue != NULL) {
> > +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> > >BootSourceOverrideTarget, AsciiStringValue) != 0)) {
> > +          ComputerSystemCsEmpty->Boot->BootSourceOverrideTarget =
> > AsciiStringValue;
> > +          PropertyChanged                                       = TRUE;
> > +        }
> > +      }
> > +    }
> > +
> > +    //
> > +    // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE
> > +    //
> > +    if (PropertyChecker (ComputerSystemCs->Boot-
> > >UefiTargetBootSourceOverride, ProvisionMode)) {
> > +      AsciiStringValue = GetPropertyStringValue (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, L"Boot/UefiTargetBootSourceOverride",
> > ConfigureLang);
> > +      if (AsciiStringValue != NULL) {
> > +        if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot-
> > >UefiTargetBootSourceOverride, AsciiStringValue) != 0)) {
> > +          ComputerSystemCsEmpty->Boot->UefiTargetBootSourceOverride =
> > AsciiStringValue;
> > +          PropertyChanged                                           = TRUE;
> > +        }
> > +      }
> > +    }
> > +  }
> > +
> > +  //
> > +  // Convert C structure back to JSON text.
> > +  //
> > +  Status = JsonStructProtocol->ToJson (
> > +                                 JsonStructProtocol,
> > +                                 (EFI_REST_JSON_STRUCTURE_HEADER
> > *)ComputerSystemEmpty,
> > +                                 ResultJson
> > +                                 );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status));
> > +    return Status;
> > +  }
> > +
> > +  if (PropertyChanged) {
> > +    // Remove Redfish unchangeable properties.
> > +    Status = RedfishRemoveUnchangeableProperties (ResultJson);
> > +    if (EFI_ERROR (Status)) {
> > +      DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable
> > properties from ResultJson.\n", __func__));
> > +      *ResultJson = NULL;
> > +      return Status;
> > +    }
> > +  }
> > +
> > +  //
> > +  // Release resource.
> > +  //
> > +  JsonStructProtocol->DestoryStructure (
> > +                        JsonStructProtocol,
> > +                        (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem
> > +                        );
> > +
> > +  //
> > +  // Free memory allocated for Computersystem empty CS
> > +  //
> > +  if (ComputerSystemCsEmpty->Boot->BootOrder != NULL) {
> > +    DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder,
> > ArraySize);
> > +  }
> > +
> > +  JsonStructProtocol->DestoryStructure (
> > +                        JsonStructProtocol,
> > +                        (EFI_REST_JSON_STRUCTURE_HEADER
> *)ComputerSystemEmpty
> > +                        );
> > +  return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND);
> > +}
> > +
> > +EFI_STATUS
> > +ProvisioningComputerSystemResource (
> > +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> > +  IN  UINTN                            Index,
> > +  IN  EFI_STRING                       ConfigureLang
> > +  )
> > +{
> > +  CHAR8       *Json;
> > +  CHAR8       *JsonWithAddendum;
> > +  EFI_STATUS  Status;
> > +  EFI_STRING  NewResourceLocation;
> > +  CHAR8       *EtagStr;
> > +  CHAR8       ResourceId[16];
> > +
> > +  if (IS_EMPTY_STRING (ConfigureLang) || (Private == NULL)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  EtagStr = NULL;
> > +  AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index);
> > +
> > +  Status = ProvisioningComputerSystemProperties (
> > +             Private->JsonStructProtocol,
> > +             ComputerSystemEmptyJson,
> > +             ResourceId,
> > +             ConfigureLang,
> > +             TRUE,
> > +             &Json
> > +             );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: provisioning resource for %s failed: %r\n",
> > __func__, ConfigureLang, Status));
> > +    return Status;
> > +  }
> > +
> > +  //
> > +  // Check and see if platform has OEM data or not
> > +  //
> > +  Status = RedfishGetOemData (
> > +             Private->Uri,
> > +             RESOURCE_SCHEMA,
> > +             RESOURCE_SCHEMA_VERSION,
> > +             Json,
> > +             &JsonWithAddendum
> > +             );
> > +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> > +    FreePool (Json);
> > +    Json             = JsonWithAddendum;
> > +    JsonWithAddendum = NULL;
> > +  }
> > +
> > +  //
> > +  // Check and see if platform has addendum data or not
> > +  //
> > +  Status = RedfishGetAddendumData (
> > +             Private->Uri,
> > +             RESOURCE_SCHEMA,
> > +             RESOURCE_SCHEMA_VERSION,
> > +             Json,
> > +             &JsonWithAddendum
> > +             );
> > +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> > +    FreePool (Json);
> > +    Json             = JsonWithAddendum;
> > +    JsonWithAddendum = NULL;
> > +  }
> > +
> > +  Status = CreatePayloadToPostResource (Private->RedfishService, Private-
> > >Payload, Json, &NewResourceLocation, &EtagStr);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s
> failed:
> > %r\n", __func__, ConfigureLang, Status));
> > +    goto RELEASE_RESOURCE;
> > +  }
> > +
> > +  ASSERT (NewResourceLocation != NULL);
> > +
> > +  //
> > +  // Keep location of new resource.
> > +  //
> > +  if (NewResourceLocation != NULL) {
> > +    RedfishSetRedfishUri (ConfigureLang, NewResourceLocation);
> > +  }
> > +
> > +RELEASE_RESOURCE:
> > +
> > +  if (EtagStr != NULL) {
> > +    FreePool (EtagStr);
> > +  }
> > +
> > +  if (NewResourceLocation != NULL) {
> > +    FreePool (NewResourceLocation);
> > +  }
> > +
> > +  if (Json != NULL) {
> > +    FreePool (Json);
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +EFI_STATUS
> > +ProvisioningComputerSystemResources (
> > +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private
> > +  )
> > +{
> > +  UINTN                                        Index;
> > +  EFI_STATUS                                   Status;
> > +  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST
> > UnifiedConfigureLangList;
> > +
> > +  if (Private == NULL) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang
> > (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION,
> > REDPATH_ARRAY_PATTERN, &UnifiedConfigureLangList);
> > +  if (EFI_ERROR (Status) || (UnifiedConfigureLangList.Count == 0)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: No HII question found with configure
> > language: %s: %r\n", __func__, REDPATH_ARRAY_PATTERN, Status));
> > +    return EFI_NOT_FOUND;
> > +  }
> > +
> > +  //
> > +  // Set the configuration language in the
> > RESOURCE_INFORMATION_EXCHANGE.
> > +  // This information is sent back to the parent resource (e.g. the collection
> > driver).
> > +  //
> > +  EdkIIRedfishResourceSetConfigureLang
> > (mRedfishResourceConfigProtocolHandle, &UnifiedConfigureLangList);
> > +
> > +  for (Index = 0; Index < UnifiedConfigureLangList.Count; Index++) {
> > +    DEBUG ((DEBUG_MANAGEABILITY, "[%d] create ComputerSystem
> resource
> > from: %s\n", UnifiedConfigureLangList.List[Index].Index,
> > UnifiedConfigureLangList.List[Index].ConfigureLang));
> > +    ProvisioningComputerSystemResource (Private,
> > UnifiedConfigureLangList.List[Index].Index,
> > UnifiedConfigureLangList.List[Index].ConfigureLang);
> > +    FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang);
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +EFI_STATUS
> > +ProvisioningComputerSystemExistResource (
> > +  IN  REDFISH_RESOURCE_COMMON_PRIVATE  *Private
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  EFI_STRING  ConfigureLang;
> > +  CHAR8       *Json;
> > +  CHAR8       *JsonWithAddendum;
> > +
> > +  if (Private == NULL) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  Json          = NULL;
> > +  ConfigureLang = NULL;
> > +
> > +  ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
> > +  if (ConfigureLang == NULL) {
> > +    return EFI_NOT_FOUND;
> > +  }
> > +
> > +  Status = ProvisioningComputerSystemProperties (
> > +             Private->JsonStructProtocol,
> > +             ComputerSystemEmptyJson,
> > +             NULL,
> > +             ConfigureLang,
> > +             TRUE,
> > +             &Json
> > +             );
> > +  if (EFI_ERROR (Status)) {
> > +    if (Status == EFI_NOT_FOUND) {
> > +      DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource
> for
> > %s ignored. Nothing changed\n", __func__, ConfigureLang));
> > +      Status = EFI_SUCCESS;
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a: provisioning existing resource for %s
> failed:
> > %r\n", __func__, ConfigureLang, Status));
> > +    }
> > +
> > +    goto ON_RELEASE;
> > +  }
> > +
> > +  //
> > +  // Check and see if platform has OEM data or not
> > +  //
> > +  Status = RedfishGetOemData (
> > +             Private->Uri,
> > +             RESOURCE_SCHEMA,
> > +             RESOURCE_SCHEMA_VERSION,
> > +             Json,
> > +             &JsonWithAddendum
> > +             );
> > +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> > +    FreePool (Json);
> > +    Json             = JsonWithAddendum;
> > +    JsonWithAddendum = NULL;
> > +  }
> > +
> > +  //
> > +  // Check and see if platform has addendum data or not
> > +  //
> > +  Status = RedfishGetAddendumData (
> > +             Private->Uri,
> > +             RESOURCE_SCHEMA,
> > +             RESOURCE_SCHEMA_VERSION,
> > +             Json,
> > +             &JsonWithAddendum
> > +             );
> > +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> > +    FreePool (Json);
> > +    Json             = JsonWithAddendum;
> > +    JsonWithAddendum = NULL;
> > +  }
> > +
> > +  DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for
> > %s\n", __func__, ConfigureLang));
> > +
> > +  //
> > +  // PUT back to instance
> > +  //
> > +  Status = CreatePayloadToPatchResource (Private->RedfishService, Private-
> > >Payload, Json, NULL);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +  }
> > +
> > +ON_RELEASE:
> > +
> > +  if (Json != NULL) {
> > +    FreePool (Json);
> > +  }
> > +
> > +  if (ConfigureLang != NULL) {
> > +    FreePool (ConfigureLang);
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Provisioning redfish resource by given URI.
> > +
> > +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> > instance.
> > +  @param[in]   ResourceExist       TRUE if resource exists, PUT method will be
> > used.
> > +                                   FALSE if resource does not exist POST method is used.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +RedfishProvisioningResourceCommon (
> > +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> > +  IN     BOOLEAN                          ResourceExist
> > +  )
> > +{
> > +  if (Private == NULL) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  return (ResourceExist ? ProvisioningComputerSystemExistResource
> (Private) :
> > ProvisioningComputerSystemResources (Private));
> > +}
> > +
> > +/**
> > +  Check resource from given URI.
> > +
> > +  @param[in]   This                Pointer to
> > REDFISH_RESOURCE_COMMON_PRIVATE instance.
> > +  @param[in]   Json                The JSON to consume.
> > +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +RedfishCheckResourceCommon (
> > +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> > +  IN     CHAR8                            *Json,
> > +  IN     CHAR8                            *HeaderEtag OPTIONAL
> > +  )
> > +{
> > +  UINTN       Index;
> > +  EFI_STATUS  Status;
> > +  EFI_STRING  *ConfigureLangList;
> > +  UINTN       Count;
> > +  EFI_STRING  Property;
> > +
> > +  if ((Private == NULL) || IS_EMPTY_STRING (Json)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  //
> > +  // Check ETAG to see if we need to check it
> > +  //
> > +  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
> > +    //
> > +    // No change
> > +    //
> > +    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore
> > check action\n", __func__, Private->Uri));
> > +    return EFI_SUCCESS;
> > +  }
> > +
> > +  Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA,
> > RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN,
> &ConfigureLangList,
> > &Count);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: failed: %r\n", __func__, Status));
> > +    return Status;
> > +  }
> > +
> > +  if (Count == 0) {
> > +    return EFI_UNSUPPORTED;
> > +  }
> > +
> > +  Status = EFI_SUCCESS;
> > +  for (Index = 0; Index < Count; Index++) {
> > +    Property = GetPropertyFromConfigureLang (Private->Uri,
> > ConfigureLangList[Index]);
> > +    if (Property == NULL) {
> > +      continue;
> > +    }
> > +
> > +    DEBUG ((DEBUG_MANAGEABILITY, "%a: [%d] check attribute for: %s\n",
> > __func__, Index, Property));
> > +    if (!MatchPropertyWithJsonContext (Property, Json)) {
> > +      DEBUG ((DEBUG_MANAGEABILITY, "%a: property is missing: %s\n",
> > __func__, Property));
> > +      Status = EFI_NOT_FOUND;
> > +    }
> > +  }
> > +
> > +  FreePool (ConfigureLangList);
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Update resource to given URI.
> > +
> > +  @param[in]   This                Pointer to
> > REDFISH_RESOURCE_COMMON_PRIVATE instance.
> > +  @param[in]   Json                The JSON to consume.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +RedfishUpdateResourceCommon (
> > +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> > +  IN     CHAR8                            *InputJson
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  CHAR8       *Json;
> > +  CHAR8       *JsonWithAddendum;
> > +  EFI_STRING  ConfigureLang;
> > +
> > +  if ((Private == NULL) || IS_EMPTY_STRING (InputJson)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  Json          = NULL;
> > +  ConfigureLang = NULL;
> > +
> > +  ConfigureLang = RedfishGetConfigLanguage (Private->Uri);
> > +  if (ConfigureLang == NULL) {
> > +    return EFI_NOT_FOUND;
> > +  }
> > +
> > +  Status = ProvisioningComputerSystemProperties (
> > +             Private->JsonStructProtocol,
> > +             InputJson,
> > +             NULL,
> > +             ConfigureLang,
> > +             FALSE,
> > +             &Json
> > +             );
> > +  if (EFI_ERROR (Status)) {
> > +    if (Status == EFI_NOT_FOUND) {
> > +      DEBUG ((DEBUG_MANAGEABILITY, "%a: update resource for %s ignored.
> > Nothing changed\n", __func__, ConfigureLang));
> > +      Status = EFI_SUCCESS;
> > +    } else {
> > +      DEBUG ((DEBUG_ERROR, "%a: update resource for %s failed: %r\n",
> > __func__, ConfigureLang, Status));
> > +    }
> > +
> > +    goto ON_RELEASE;
> > +  }
> > +
> > +  //
> > +  // Check and see if platform has OEM data or not
> > +  //
> > +  Status = RedfishGetOemData (
> > +             Private->Uri,
> > +             RESOURCE_SCHEMA,
> > +             RESOURCE_SCHEMA_VERSION,
> > +             Json,
> > +             &JsonWithAddendum
> > +             );
> > +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> > +    FreePool (Json);
> > +    Json             = JsonWithAddendum;
> > +    JsonWithAddendum = NULL;
> > +  }
> > +
> > +  //
> > +  // Check and see if platform has addendum data or not
> > +  //
> > +  Status = RedfishGetAddendumData (
> > +             Private->Uri,
> > +             RESOURCE_SCHEMA,
> > +             RESOURCE_SCHEMA_VERSION,
> > +             Json,
> > +             &JsonWithAddendum
> > +             );
> > +  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
> > +    FreePool (Json);
> > +    Json             = JsonWithAddendum;
> > +    JsonWithAddendum = NULL;
> > +  }
> > +
> > +  DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n",
> __func__,
> > ConfigureLang));
> > +
> > +  //
> > +  // PUT back to instance
> > +  //
> > +  Status = CreatePayloadToPatchResource (Private->RedfishService, Private-
> > >Payload, Json, NULL);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n",
> __func__,
> > ConfigureLang, Status));
> > +  }
> > +
> > +ON_RELEASE:
> > +
> > +  if (Json != NULL) {
> > +    FreePool (Json);
> > +  }
> > +
> > +  if (ConfigureLang != NULL) {
> > +    FreePool (ConfigureLang);
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Identify resource from given URI.
> > +
> > +  @param[in]   This                Pointer to
> > REDFISH_RESOURCE_COMMON_PRIVATE instance.
> > +  @param[in]   Json                The JSON to consume.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +RedfishIdentifyResourceCommon (
> > +  IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> > +  IN     CHAR8                            *Json
> > +  )
> > +{
> > +  BOOLEAN                                      Supported;
> > +  EFI_STATUS                                   Status;
> > +  EFI_STRING                                   EndOfChar;
> > +  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST  ConfigLangList;
> > +
> > +  Supported = RedfishIdentifyResource (Private->Uri, Private->Json);
> > +  if (Supported) {
> > +    Status = RedfishFeatureGetUnifiedArrayTypeConfigureLang
> > (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION,
> > REDPATH_ARRAY_PATTERN, &ConfigLangList);
> > +    if (EFI_ERROR (Status)) {
> > +      DEBUG ((DEBUG_ERROR, "%a:
> > RedfishFeatureGetUnifiedArrayTypeConfigureLang failed: %r\n", __func__,
> > Status));
> > +      return Status;
> > +    }
> > +
> > +    if (ConfigLangList.Count == 0) {
> > +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
> ConfigureLang
> > found for %s\n", __func__, Private->Uri));
> > +      return EFI_SUCCESS;
> > +    }
> > +
> > +    EndOfChar = StrStr (ConfigLangList.List[0].ConfigureLang, L"}");
> > +    if (EndOfChar == NULL) {
> > +      ASSERT (FALSE);
> > +      return EFI_DEVICE_ERROR;
> > +    }
> > +
> > +    // EndOfChar = StrStr (ConfigLangList.List[0].ConfigureLang, L"}");
> > +    Status = IsRedpathArray (ConfigLangList.List[0].ConfigureLang, NULL,
> > &EndOfChar);
> > +    if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
> > +      ASSERT (FALSE);
> > +      return EFI_DEVICE_ERROR;
> > +    }
> > +
> > +    if (Status != EFI_SUCCESS) {
> > +      //
> > +      // This is not the collection redpath.
> > +      //
> > +      GetRedpathNodeByIndex (ConfigLangList.List[0].ConfigureLang, 0,
> > &EndOfChar);
> > +    }
> > +
> > +    *(++EndOfChar) = '\0';
> > +    //
> > +    // Keep URI and ConfigLang mapping
> > +    //
> > +    RedfishSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private-
> >Uri);
> > +    //
> > +    // Set the configuration language in the
> > RESOURCE_INFORMATION_EXCHANGE.
> > +    // This information is sent back to the parent resource (e.g. the collection
> > driver).
> > +    //
> > +    EdkIIRedfishResourceSetConfigureLang
> > (mRedfishResourceConfigProtocolHandle, &ConfigLangList);
> > +    DestroyConfiglanguageList (&ConfigLangList);
> > +    return EFI_SUCCESS;
> > +  }
> > +
> > +  return EFI_UNSUPPORTED;
> > +}
> > diff --git
> >
> a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSyste
> mD
> > xe.c
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSyst
> emD
> > xe.c
> > new file mode 100644
> > index 0000000000..30a0e64c64
> > --- /dev/null
> > +++
> >
> b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSyst
> emD
> > xe.c
> > @@ -0,0 +1,702 @@
> > +/** @file
> > +  Redfish feature driver implementation - ComputerSystem
> > +
> > +  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> > +  Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights
> > reserved.
> > +  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include "../Common/ComputerSystemCommon.h"
> > +
> > +extern REDFISH_RESOURCE_COMMON_PRIVATE
> *mRedfishResourcePrivate;
> > +extern EFI_HANDLE                       mRedfishResourceConfigProtocolHandle;
> > +
> > +/**
> > +  Provision redfish resource by given URI.
> > +
> > +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> > instance.
> > +  @param[in]   Uri                 Target URI to create resource.
> > +  @param[in]   PostMode            TRUE if the resource does not exist, post
> > method is used.
> > +                                   FALSE if the resource exist but property is missing, put
> > method is used.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceProvisioningResource (
> > +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> > +  IN     EFI_STRING                              Uri,
> > +  IN     BOOLEAN                                 PostMode
> > +  )
> > +{
> > +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> > +  EFI_STATUS                       Status;
> > +  REDFISH_RESPONSE                 Response;
> > +
> > +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning in %s mode\n",
> __func__,
> > (PostMode ? L"POST" : L"PATCH")));
> > +
> > +  Private =
> >
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC
> OL
> > (This);
> > +
> > +  if (Private->RedfishService == NULL) {
> > +    return EFI_NOT_READY;
> > +  }
> > +
> > +  ZeroMem (&Response, sizeof (Response));
> > +  Status = RedfishHttpGetResource (Private->RedfishService, Uri,
> &Response,
> > TRUE);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> > Uri));
> > +    return Status;
> > +  }
> > +
> > +  Private->Uri     = Uri;
> > +  Private->Payload = Response.Payload;
> > +  ASSERT (Private->Payload != NULL);
> > +
> > +  Status = RedfishProvisioningResourceCommon (Private, !PostMode);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: failed to provision resource to: %s: %r\n",
> > __func__, Uri, Status));
> > +  } else {
> > +    //
> > +    // Get latest ETag on URI and keep it in variable.
> > +    //
> > +    SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
> > +  }
> > +
> > +  //
> > +  // Release resource
> > +  //
> > +  if (Private->Payload != NULL) {
> > +    RedfishFreeResponse (
> > +      Response.StatusCode,
> > +      Response.HeaderCount,
> > +      Response.Headers,
> > +      Response.Payload
> > +      );
> > +    Private->Payload = NULL;
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Consume resource from given URI.
> > +
> > +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> > instance.
> > +  @param[in]   Uri                 The target URI to consume.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceConsumeResource (
> > +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> > +  IN     EFI_STRING                              Uri
> > +  )
> > +{
> > +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> > +  EFI_STATUS                       Status;
> > +  REDFISH_RESPONSE                 Response;
> > +  EFI_STRING                       PendingSettingUri;
> > +  REDFISH_RESPONSE                 PendingSettingResponse;
> > +  REDFISH_RESPONSE                 *ExpectedResponse;
> > +  CHAR8                            *Etag;
> > +
> > +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  Private =
> >
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC
> OL
> > (This);
> > +
> > +  if (Private->RedfishService == NULL) {
> > +    return EFI_NOT_READY;
> > +  }
> > +
> > +  ZeroMem (&Response, sizeof (Response));
> > +  Status = RedfishHttpGetResource (Private->RedfishService, Uri,
> &Response,
> > TRUE);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> > Uri));
> > +    return Status;
> > +  }
> > +
> > +  //
> > +  // Check and see if "@Redfish.Settings" exist or not.
> > +  //
> > +  ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE));
> > +  Status = GetPendingSettings (
> > +             Private->RedfishService,
> > +             Response.Payload,
> > +             &PendingSettingResponse,
> > +             &PendingSettingUri
> > +             );
> > +  if (!EFI_ERROR (Status)) {
> > +    DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n",
> > __func__, PendingSettingUri));
> > +    Private->Uri     = PendingSettingUri;
> > +    ExpectedResponse = &PendingSettingResponse;
> > +  } else {
> > +    DEBUG ((REDFISH_DEBUG_TRACE, "%a: No @Redfish.Settings is
> found\n",
> > __func__));
> > +    Private->Uri     = Uri;
> > +    ExpectedResponse = &Response;
> > +  }
> > +
> > +  Private->Payload = ExpectedResponse->Payload;
> > +  ASSERT (Private->Payload != NULL);
> > +
> > +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private-
> >Payload),
> > EDKII_JSON_COMPACT);
> > +  ASSERT (Private->Json != NULL);
> > +
> > +  //
> > +  // Find etag in HTTP response header
> > +  //
> > +  Etag = NULL;
> > +  GetHttpResponseEtag (ExpectedResponse, &Etag);
> > +  Status = RedfishConsumeResourceCommon (Private, Private->Json, Etag);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s:
> %r\n",
> > __func__, Private->Uri, Status));
> > +  }
> > +
> > +  //
> > +  // Release resource
> > +  //
> > +  if (Etag != NULL) {
> > +    FreePool (Etag);
> > +  }
> > +
> > +  //
> > +  // Release resource
> > +  //
> > +  if (Private->Payload != NULL) {
> > +    if (Response.Payload != NULL) {
> > +      RedfishFreeResponse (
> > +        Response.StatusCode,
> > +        Response.HeaderCount,
> > +        Response.Headers,
> > +        Response.Payload
> > +        );
> > +    }
> > +
> > +    if (PendingSettingResponse.Payload != NULL) {
> > +      RedfishFreeResponse (
> > +        PendingSettingResponse.StatusCode,
> > +        PendingSettingResponse.HeaderCount,
> > +        PendingSettingResponse.Headers,
> > +        PendingSettingResponse.Payload
> > +        );
> > +    }
> > +
> > +    Private->Payload = NULL;
> > +  }
> > +
> > +  if (Private->Json != NULL) {
> > +    FreePool (Private->Json);
> > +    Private->Json = NULL;
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Get information about this protocol.
> > +
> > +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> > instance.
> > +  @param[out]  Schema              Supported schema.
> > +  @param[out]  Major               Supported major number.
> > +  @param[out]  Minor               Supported minor number.
> > +  @param[out]  Errata              Supported errata number.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceGetInfo (
> > +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> > +  OUT    REDFISH_SCHEMA_INFO                     *Info
> > +  )
> > +{
> > +  if ((This == NULL) || (Info == NULL)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  AsciiStrCpyS (Info->Schema, REDFISH_SCHEMA_STRING_SIZE,
> > RESOURCE_SCHEMA);
> > +  AsciiStrCpyS (Info->Major, REDFISH_SCHEMA_VERSION_SIZE,
> > RESOURCE_SCHEMA_MAJOR);
> > +  AsciiStrCpyS (Info->Minor, REDFISH_SCHEMA_VERSION_SIZE,
> > RESOURCE_SCHEMA_MINOR);
> > +  AsciiStrCpyS (Info->Errata, REDFISH_SCHEMA_VERSION_SIZE,
> > RESOURCE_SCHEMA_ERRATA);
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/**
> > +  Update resource to given URI.
> > +
> > +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> > instance.
> > +  @param[in]   Uri                 The target URI to consume.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceUpdate (
> > +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> > +  IN     EFI_STRING                              Uri
> > +  )
> > +{
> > +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> > +  EFI_STATUS                       Status;
> > +  REDFISH_RESPONSE                 Response;
> > +
> > +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  Private =
> >
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC
> OL
> > (This);
> > +
> > +  if (Private->RedfishService == NULL) {
> > +    return EFI_NOT_READY;
> > +  }
> > +
> > +  ZeroMem (&Response, sizeof (Response));
> > +  Status = RedfishHttpGetResource (Private->RedfishService, Uri,
> &Response,
> > TRUE);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> > Uri));
> > +    return Status;
> > +  }
> > +
> > +  Private->Uri     = Uri;
> > +  Private->Payload = Response.Payload;
> > +  ASSERT (Private->Payload != NULL);
> > +
> > +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private-
> >Payload),
> > EDKII_JSON_COMPACT);
> > +  ASSERT (Private->Json != NULL);
> > +
> > +  Status = RedfishUpdateResourceCommon (Private, Private->Json);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: failed to update resource to: %s: %r\n",
> > __func__, Uri, Status));
> > +  } else {
> > +    //
> > +    // Get latest ETag on URI and keep it in variable.
> > +    //
> > +    SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
> > +  }
> > +
> > +  //
> > +  // Release resource
> > +  //
> > +  if (Private->Payload != NULL) {
> > +    RedfishFreeResponse (
> > +      Response.StatusCode,
> > +      Response.HeaderCount,
> > +      Response.Headers,
> > +      Response.Payload
> > +      );
> > +    RedfishHttpResetResource (Uri);
> > +    Private->Payload = NULL;
> > +  }
> > +
> > +  if (Private->Json != NULL) {
> > +    FreePool (Private->Json);
> > +    Private->Json = NULL;
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Check resource on given URI.
> > +
> > +  @param[in]   This                Pointer to EFI_HP_REDFISH_HII_PROTOCOL
> > instance.
> > +  @param[in]   Uri                 The target URI to consume.
> > +
> > +  @retval EFI_SUCCESS              Value is returned successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceCheck (
> > +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> > +  IN     EFI_STRING                              Uri
> > +  )
> > +{
> > +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> > +  EFI_STATUS                       Status;
> > +  REDFISH_RESPONSE                 Response;
> > +  CHAR8                            *Etag;
> > +
> > +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  Private =
> >
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC
> OL
> > (This);
> > +
> > +  if (Private->RedfishService == NULL) {
> > +    return EFI_NOT_READY;
> > +  }
> > +
> > +  ZeroMem (&Response, sizeof (Response));
> > +  Status = RedfishHttpGetResource (Private->RedfishService, Uri,
> &Response,
> > TRUE);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> > Uri));
> > +    return Status;
> > +  }
> > +
> > +  Private->Uri     = Uri;
> > +  Private->Payload = Response.Payload;
> > +  ASSERT (Private->Payload != NULL);
> > +
> > +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private-
> >Payload),
> > EDKII_JSON_COMPACT);
> > +  ASSERT (Private->Json != NULL);
> > +
> > +  //
> > +  // Find etag in HTTP response header
> > +  //
> > +  Etag = NULL;
> > +  GetHttpResponseEtag (&Response, &Etag);
> > +  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: failed to check resource from: %s: %r\n",
> > __func__, Uri, Status));
> > +  }
> > +
> > +  //
> > +  // Release resource
> > +  //
> > +  if (Etag != NULL) {
> > +    FreePool (Etag);
> > +  }
> > +
> > +  if (Private->Payload != NULL) {
> > +    RedfishFreeResponse (
> > +      Response.StatusCode,
> > +      Response.HeaderCount,
> > +      Response.Headers,
> > +      Response.Payload
> > +      );
> > +    Private->Payload = NULL;
> > +  }
> > +
> > +  if (Private->Json != NULL) {
> > +    FreePool (Private->Json);
> > +    Private->Json = NULL;
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  Identify resource on given URI.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL instance.
> > +  @param[in]   Uri                 The target URI to consume.
> > +
> > +  @retval EFI_SUCCESS              This is target resource which we want to
> handle.
> > +  @retval EFI_UNSUPPORTED          This is not the target resource.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceIdentify (
> > +  IN     EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  *This,
> > +  IN     EFI_STRING                              Uri
> > +  )
> > +{
> > +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> > +  EFI_STATUS                       Status;
> > +  REDFISH_RESPONSE                 Response;
> > +
> > +  if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
> > +    return EFI_INVALID_PARAMETER;
> > +  }
> > +
> > +  Private =
> >
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC
> OL
> > (This);
> > +
> > +  if (Private->RedfishService == NULL) {
> > +    return EFI_NOT_READY;
> > +  }
> > +
> > +  ZeroMem (&Response, sizeof (Response));
> > +  Status = RedfishHttpGetResource (Private->RedfishService, Uri,
> &Response,
> > TRUE);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__,
> > Uri));
> > +    return Status;
> > +  }
> > +
> > +  Private->Uri     = Uri;
> > +  Private->Payload = Response.Payload;
> > +  ASSERT (Private->Payload != NULL);
> > +
> > +  Private->Json = JsonDumpString (RedfishJsonInPayload (Private-
> >Payload),
> > EDKII_JSON_COMPACT);
> > +  ASSERT (Private->Json != NULL);
> > +
> > +  Status = RedfishIdentifyResourceCommon (Private, Private->Json);
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: identify %s failed: %r\n", __func__, Uri,
> > Status));
> > +  }
> > +
> > +  //
> > +  // Release resource
> > +  //
> > +  if (Private->Payload != NULL) {
> > +    RedfishFreeResponse (
> > +      Response.StatusCode,
> > +      Response.HeaderCount,
> > +      Response.Headers,
> > +      Response.Payload
> > +      );
> > +    Private->Payload = NULL;
> > +  }
> > +
> > +  if (Private->Json != NULL) {
> > +    FreePool (Private->Json);
> > +    Private->Json = NULL;
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL  mRedfishResourceConfig
> = {
> > +  RedfishResourceProvisioningResource,
> > +  RedfishResourceConsumeResource,
> > +  RedfishResourceUpdate,
> > +  RedfishResourceCheck,
> > +  RedfishResourceIdentify,
> > +  RedfishResourceGetInfo
> > +};
> > +
> > +/**
> > +  Initialize a Redfish configure handler.
> > +
> > +  This function will be called by the Redfish config driver to initialize each
> Redfish
> > configure
> > +  handler.
> > +
> > +  @param[in]   This                     Pointer to
> > EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance.
> > +  @param[in]   RedfishConfigServiceInfo Redfish service information.
> > +
> > +  @retval EFI_SUCCESS                  The handler has been initialized successfully.
> > +  @retval EFI_DEVICE_ERROR             Failed to create or configure the REST EX
> > protocol instance.
> > +  @retval EFI_ALREADY_STARTED          This handler has already been
> initialized.
> > +  @retval Other                        Error happens during the initialization.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceInit (
> > +  IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *This,
> > +  IN  REDFISH_CONFIG_SERVICE_INFORMATION
> *RedfishConfigServiceInfo
> > +  )
> > +{
> > +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> > +
> > +  Private =
> >
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL
> > (This);
> > +
> > +  Private->RedfishService = RedfishCreateService (RedfishConfigServiceInfo);
> > +  if (Private->RedfishService == NULL) {
> > +    return EFI_DEVICE_ERROR;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +/**
> > +  Stop a Redfish configure handler.
> > +
> > +  @param[in]   This                Pointer to
> > EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance.
> > +
> > +  @retval EFI_SUCCESS              This handler has been stoped successfully.
> > +  @retval Others                   Some error happened.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceStop (
> > +  IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *This
> > +  )
> > +{
> > +  REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
> > +
> > +  Private =
> >
> REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL
> > (This);
> > +
> > +  if (Private->Event != NULL) {
> > +    gBS->CloseEvent (Private->Event);
> > +    Private->Event = NULL;
> > +  }
> > +
> > +  if (Private->RedfishService != NULL) {
> > +    RedfishCleanupService (Private->RedfishService);
> > +    Private->RedfishService = NULL;
> > +  }
> > +
> > +  if (Private->Payload != NULL) {
> > +    RedfishCleanupPayload (Private->Payload);
> > +    Private->Payload = NULL;
> > +  }
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> > +EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  mRedfishConfigHandler = {
> > +  RedfishResourceInit,
> > +  RedfishResourceStop
> > +};
> > +
> > +/**
> > +  Callback function when gEfiRestJsonStructureProtocolGuid is installed.
> > +
> > +  @param[in] Event    Event whose notification function is being invoked.
> > +  @param[in] Context  Pointer to the notification function's context.
> > +**/
> > +VOID
> > +EFIAPI
> > +EfiRestJasonStructureProtocolIsReady (
> > +  IN  EFI_EVENT  Event,
> > +  IN  VOID       *Context
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +
> > +  if (mRedfishResourcePrivate == NULL) {
> > +    return;
> > +  }
> > +
> > +  if (mRedfishResourcePrivate->JsonStructProtocol != NULL) {
> > +    return;
> > +  }
> > +
> > +  Status = gBS->LocateProtocol (
> > +                  &gEfiRestJsonStructureProtocolGuid,
> > +                  NULL,
> > +                  (VOID **)&mRedfishResourcePrivate->JsonStructProtocol
> > +                  );
> > +  if (EFI_ERROR (Status)) {
> > +    DEBUG ((DEBUG_ERROR, "%a: failed to locate
> > gEfiRestJsonStructureProtocolGuid: %r\n", __func__, Status));
> > +  }
> > +
> > +  gBS->CloseEvent (Event);
> > +}
> > +
> > +/**
> > +  Unloads an image.
> > +
> > +  @param  ImageHandle           Handle that identifies the image to be
> unloaded.
> > +
> > +  @retval EFI_SUCCESS           The image has been unloaded.
> > +  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image
> handle.
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceUnload (
> > +  IN EFI_HANDLE  ImageHandle
> > +  )
> > +{
> > +  EFI_STATUS                             Status;
> > +  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *ConfigHandler;
> > +
> > +  if (mRedfishResourcePrivate == NULL) {
> > +    return EFI_NOT_READY;
> > +  }
> > +
> > +  ConfigHandler = NULL;
> > +
> > +  //
> > +  // Firstly, find ConfigHandler Protocol interface in this ImageHandle.
> > +  //
> > +  Status = gBS->OpenProtocol (
> > +                  ImageHandle,
> > +                  &gEdkIIRedfishConfigHandlerProtocolGuid,
> > +                  (VOID **)&ConfigHandler,
> > +                  NULL,
> > +                  NULL,
> > +                  EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
> > +                  );
> > +  if (EFI_ERROR (Status) || (ConfigHandler == NULL)) {
> > +    return Status;
> > +  }
> > +
> > +  ConfigHandler->Stop (ConfigHandler);
> > +
> > +  //
> > +  // Last, uninstall ConfigHandler Protocol and resource protocol.
> > +  //
> > +  Status = gBS->UninstallMultipleProtocolInterfaces (
> > +                  ImageHandle,
> > +                  &gEdkIIRedfishConfigHandlerProtocolGuid,
> > +                  ConfigHandler,
> > +                  &gEdkIIRedfishResourceConfigProtocolGuid,
> > +                  &mRedfishResourcePrivate->RedfishResourceConfig,
> > +                  NULL
> > +                  );
> > +
> > +  FreePool (mRedfishResourcePrivate);
> > +  mRedfishResourcePrivate = NULL;
> > +
> > +  return Status;
> > +}
> > +
> > +/**
> > +  This is the declaration of an EFI image entry point. This entry point is
> > +  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers
> including
> > +  both device drivers and bus drivers. It initialize the global variables and
> > +  publish the driver binding protocol.
> > +
> > +  @param[in]   ImageHandle      The firmware allocated handle for the UEFI
> > image.
> > +  @param[in]   SystemTable      A pointer to the EFI System Table.
> > +
> > +  @retval EFI_SUCCESS           The operation completed successfully.
> > +  @retval Others                Other errors as indicated.
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +RedfishResourceEntryPoint (
> > +  IN EFI_HANDLE        ImageHandle,
> > +  IN EFI_SYSTEM_TABLE  *SystemTable
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  VOID        *Registration;
> > +
> > +  if (mRedfishResourcePrivate != NULL) {
> > +    return EFI_ALREADY_STARTED;
> > +  }
> > +
> > +  mRedfishResourceConfigProtocolHandle = ImageHandle;
> > +
> > +  mRedfishResourcePrivate = AllocateZeroPool (sizeof
> > (REDFISH_RESOURCE_COMMON_PRIVATE));
> > +  CopyMem (&mRedfishResourcePrivate->ConfigHandler,
> > &mRedfishConfigHandler, sizeof
> > (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL));
> > +  CopyMem (&mRedfishResourcePrivate->RedfishResourceConfig,
> > &mRedfishResourceConfig, sizeof
> > (EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL));
> > +
> > +  //
> > +  // Publish config handler protocol and resource protocol.
> > +  //
> > +  Status = gBS->InstallMultipleProtocolInterfaces (
> > +                  &ImageHandle,
> > +                  &gEdkIIRedfishConfigHandlerProtocolGuid,
> > +                  &mRedfishResourcePrivate->ConfigHandler,
> > +                  &gEdkIIRedfishResourceConfigProtocolGuid,
> > +                  &mRedfishResourcePrivate->RedfishResourceConfig,
> > +                  NULL
> > +                  );
> > +
> > +  EfiCreateProtocolNotifyEvent (
> > +    &gEfiRestJsonStructureProtocolGuid,
> > +    TPL_CALLBACK,
> > +    EfiRestJasonStructureProtocolIsReady,
> > +    NULL,
> > +    &Registration
> > +    );
> > +
> > +  return Status;
> > +}
> > --
> > 2.37.1.windows.1
> >
> >
> >
> > 
> >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114488): https://edk2.groups.io/g/devel/message/114488
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26  2:20 ` Nickle Wang via groups.io
  2024-01-26  2:32   ` Chang, Abner via groups.io
@ 2024-01-26 13:55   ` Mike Maslenkin
  2024-01-26 14:03     ` Chang, Abner via groups.io
  1 sibling, 1 reply; 9+ messages in thread
From: Mike Maslenkin @ 2024-01-26 13:55 UTC (permalink / raw)
  To: devel, Nickle Wang; +Cc: abner.chang@amd.com, Igor Kulchytskyy

Hi Abner,

> On 26. 1. 2024., at 05:20, Nickle Wang via groups.io <nicklew=nvidia.com@groups.io> wrote:
> 
> Hi Abner,
> 
> Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.
> 
>> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish ConfigureLang
>> found for %s\n", __func__, Private->Uri));
> 
> Regards,
> Nickle

There are two issues in this string. The second one is incorrect  %s format used for Private->Uri.
This issue exists in V3 not only in the line mentioned above.

Regards,
Mike.

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114612): https://edk2.groups.io/g/devel/message/114612
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26 13:55   ` Mike Maslenkin
@ 2024-01-26 14:03     ` Chang, Abner via groups.io
  2024-01-26 14:11       ` Mike Maslenkin
  0 siblings, 1 reply; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-26 14:03 UTC (permalink / raw)
  To: M M, devel@edk2.groups.io, Nickle Wang; +Cc: Igor Kulchytskyy

[AMD Official Use Only - General]

Hi Mike,
I can't identify the issue on %s as Private->Uri is defined as EFI_STRING, or I miss something?

Thanks
Abner

> -----Original Message-----
> From: M M <mike.maslenkin@gmail.com>
> Sent: Friday, January 26, 2024 9:55 PM
> To: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>
> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> > On 26. 1. 2024., at 05:20, Nickle Wang via groups.io
> <nicklew=nvidia.com@groups.io> wrote:
> >
> > Hi Abner,
> >
> > Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.
> >
> >> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
> ConfigureLang
> >> found for %s\n", __func__, Private->Uri));
> >
> > Regards,
> > Nickle
>
> There are two issues in this string. The second one is incorrect  %s format used
> for Private->Uri.
> This issue exists in V3 not only in the line mentioned above.
>
> Regards,
> Mike.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114614): https://edk2.groups.io/g/devel/message/114614
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26 14:03     ` Chang, Abner via groups.io
@ 2024-01-26 14:11       ` Mike Maslenkin
  2024-01-26 14:13         ` Chang, Abner via groups.io
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Maslenkin @ 2024-01-26 14:11 UTC (permalink / raw)
  To: Chang, Abner; +Cc: devel@edk2.groups.io, Nickle Wang, Igor Kulchytskyy

You are right.

Sorry for the noise!

No problems here.
I mixed up with tags in my editor while looked into patch.

Regards,
Mike

> On 26. 1. 2024., at 17:03, Chang, Abner <Abner.Chang@amd.com> wrote:
> 
> [AMD Official Use Only - General]
> 
> Hi Mike,
> I can't identify the issue on %s as Private->Uri is defined as EFI_STRING, or I miss something?
> 
> Thanks
> Abner
> 
>> -----Original Message-----
>> From: M M <mike.maslenkin@gmail.com>
>> Sent: Friday, January 26, 2024 9:55 PM
>> To: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>
>> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
>> <igork@ami.com>
>> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
>> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>> 
>> Caution: This message originated from an External Source. Use proper caution
>> when opening attachments, clicking links, or responding.
>> 
>> 
>> Hi Abner,
>> 
>>> On 26. 1. 2024., at 05:20, Nickle Wang via groups.io
>> <nicklew=nvidia.com@groups.io> wrote:
>>> 
>>> Hi Abner,
>>> 
>>> Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.
>>> 
>>>> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
>> ConfigureLang
>>>> found for %s\n", __func__, Private->Uri));
>>> 
>>> Regards,
>>> Nickle
>> 
>> There are two issues in this string. The second one is incorrect  %s format used
>> for Private->Uri.
>> This issue exists in V3 not only in the line mentioned above.
>> 
>> Regards,
>> Mike.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114615): https://edk2.groups.io/g/devel/message/114615
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26 14:11       ` Mike Maslenkin
@ 2024-01-26 14:13         ` Chang, Abner via groups.io
  2024-01-26 15:41           ` Mike Maslenkin
  0 siblings, 1 reply; 9+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-26 14:13 UTC (permalink / raw)
  To: M M; +Cc: devel@edk2.groups.io, Nickle Wang, Igor Kulchytskyy

[AMD Official Use Only - General]

It is no problem. 😊 Thank you Mike for looking into this patch.
Abner

> -----Original Message-----
> From: M M <mike.maslenkin@gmail.com>
> Sent: Friday, January 26, 2024 10:11 PM
> To: Chang, Abner <Abner.Chang@amd.com>
> Cc: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>; Igor
> Kulchytskyy <igork@ami.com>
> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> You are right.
>
> Sorry for the noise!
>
> No problems here.
> I mixed up with tags in my editor while looked into patch.
>
> Regards,
> Mike
>
> > On 26. 1. 2024., at 17:03, Chang, Abner <Abner.Chang@amd.com> wrote:
> >
> > [AMD Official Use Only - General]
> >
> > Hi Mike,
> > I can't identify the issue on %s as Private->Uri is defined as EFI_STRING, or I
> miss something?
> >
> > Thanks
> > Abner
> >
> >> -----Original Message-----
> >> From: M M <mike.maslenkin@gmail.com>
> >> Sent: Friday, January 26, 2024 9:55 PM
> >> To: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>
> >> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> >> <igork@ami.com>
> >> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
> >> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
> >>
> >> Caution: This message originated from an External Source. Use proper
> caution
> >> when opening attachments, clicking links, or responding.
> >>
> >>
> >> Hi Abner,
> >>
> >>> On 26. 1. 2024., at 05:20, Nickle Wang via groups.io
> >> <nicklew=nvidia.com@groups.io> wrote:
> >>>
> >>> Hi Abner,
> >>>
> >>> Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.
> >>>
> >>>> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
> >> ConfigureLang
> >>>> found for %s\n", __func__, Private->Uri));
> >>>
> >>> Regards,
> >>> Nickle
> >>
> >> There are two issues in this string. The second one is incorrect  %s format
> used
> >> for Private->Uri.
> >> This issue exists in V3 not only in the line mentioned above.
> >>
> >> Regards,
> >> Mike.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114616): https://edk2.groups.io/g/devel/message/114616
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26 14:13         ` Chang, Abner via groups.io
@ 2024-01-26 15:41           ` Mike Maslenkin
  2024-01-30  7:58             ` Nickle Wang via groups.io
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Maslenkin @ 2024-01-26 15:41 UTC (permalink / raw)
  To: Chang, Abner; +Cc: devel@edk2.groups.io, Nickle Wang, Igor Kulchytskyy

[-- Attachment #1: Type: text/plain, Size: 5094 bytes --]

BTW did you consider to remove this Private->Uri someday at all ?
I tried to remove it, but since it declared in a common header for all redfish client feature drivers
those changes was huge comparing to a small memory leak I tried to fix.
And now such pattern spreads into new feature drivers. 
In short: there is no need to cache this value in Private->Uri, but pass it as an argument down to stack in EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL implementation.
I think it just small design flaw. 

The code I'm talking about:
+  //
+  // Check and see if "@Redfish.Settings" exist or not.
+  //
+  ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE));
+  Status = GetPendingSettings (
+             Private->RedfishService,
+             Response.Payload,
+             &PendingSettingResponse,
+             &PendingSettingUri
+             );
+  if (!EFI_ERROR (Status)) {
+    DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
+    Private->Uri     = PendingSettingUri;
+    ExpectedResponse = &PendingSettingResponse;
+  } else {
+    DEBUG ((REDFISH_DEBUG_TRACE, "%a: No @Redfish.Settings is found\n", __func__));
+    Private->Uri     = Uri;
+    ExpectedResponse = &Response;
+  }

In this pattern PendingSettingUri is leaked, since Private->Uri belongs to caller and never released.

But... in fact it is not true for Feature/Bios driver, and actually leaked resource is original Private->Uri string.

This is because these EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL function called by
HandleResource() function, which in turns called from here:
  //
  // Initialize collection path
  //
  Private->Uri = RedfishGetUri (ResourceUri);
  if (Private->Uri == NULL) {
    ASSERT (FALSE);
    FreePool (ResourceUri);
    return EFI_OUT_OF_RESOURCES;
  }

  Status = HandleResource (Private, Private->Uri);
  if (EFI_ERROR (Status)) {
    DEBUG ((DEBUG_ERROR, "%a, process external resource: %a failed: %r\n", __func__, Private->Uri, Status));
  }

  FreePool (Private->Uri);


Too many "Private->Uri" with a different value. 

PS: Funny, just pay attention to the log trace above - %a used for Private->Uri. Probably it was one of the factors 
induced me to write previous message :)

Regards,
Mike.


> On 26. 1. 2024., at 17:13, Chang, Abner <Abner.Chang@amd.com> wrote:
> 
> [AMD Official Use Only - General]
> 
> It is no problem. 😊 Thank you Mike for looking into this patch.
> Abner
> 
>> -----Original Message-----
>> From: M M <mike.maslenkin@gmail.com>
>> Sent: Friday, January 26, 2024 10:11 PM
>> To: Chang, Abner <Abner.Chang@amd.com>
>> Cc: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>; Igor
>> Kulchytskyy <igork@ami.com>
>> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
>> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>> 
>> Caution: This message originated from an External Source. Use proper caution
>> when opening attachments, clicking links, or responding.
>> 
>> 
>> You are right.
>> 
>> Sorry for the noise!
>> 
>> No problems here.
>> I mixed up with tags in my editor while looked into patch.
>> 
>> Regards,
>> Mike
>> 
>>> On 26. 1. 2024., at 17:03, Chang, Abner <Abner.Chang@amd.com> wrote:
>>> 
>>> [AMD Official Use Only - General]
>>> 
>>> Hi Mike,
>>> I can't identify the issue on %s as Private->Uri is defined as EFI_STRING, or I
>> miss something?
>>> 
>>> Thanks
>>> Abner
>>> 
>>>> -----Original Message-----
>>>> From: M M <mike.maslenkin@gmail.com>
>>>> Sent: Friday, January 26, 2024 9:55 PM
>>>> To: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>
>>>> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
>>>> <igork@ami.com>
>>>> Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
>>>> RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
>>>> 
>>>> Caution: This message originated from an External Source. Use proper
>> caution
>>>> when opening attachments, clicking links, or responding.
>>>> 
>>>> 
>>>> Hi Abner,
>>>> 
>>>>> On 26. 1. 2024., at 05:20, Nickle Wang via groups.io
>>>> <nicklew=nvidia.com@groups.io> wrote:
>>>>> 
>>>>> Hi Abner,
>>>>> 
>>>>> Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.
>>>>> 
>>>>>> +      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
>>>> ConfigureLang
>>>>>> found for %s\n", __func__, Private->Uri));
>>>>> 
>>>>> Regards,
>>>>> Nickle
>>>> 
>>>> There are two issues in this string. The second one is incorrect  %s format
>> used
>>>> for Private->Uri.
>>>> This issue exists in V3 not only in the line mentioned above.
>>>> 
>>>> Regards,
>>>> Mike.
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114618): https://edk2.groups.io/g/devel/message/114618
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 14944 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver
  2024-01-26 15:41           ` Mike Maslenkin
@ 2024-01-30  7:58             ` Nickle Wang via groups.io
  0 siblings, 0 replies; 9+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-30  7:58 UTC (permalink / raw)
  To: M M, Chang, Abner; +Cc: devel@edk2.groups.io, Igor Kulchytskyy

[-- Attachment #1: Type: text/plain, Size: 6624 bytes --]

Hi Mike,

How about we add code to release “PendingSettingUri” at the end of RedfishResourceConsumeResource(). I think this would help to address memory leak issue. And we keep “Private->Uri” to be just the reference to “Uri” from caller and we don’t release “Private->Uri”. Caller always has responsibility to release memory it allocated.

Then, I like to modify below code to match my logic above:

  //
  // Initialize collection path
  //
  CollectionUri = RedfishGetUri (ResourceUri);
  if (CollectionUri == NULL) {
    ASSERT (FALSE);
    FreePool (ResourceUri);
    return EFI_OUT_OF_RESOURCES;
  }

  Status = HandleResource (Private, CollectionUri);
  if (EFI_ERROR (Status)) {
    DEBUG ((DEBUG_ERROR, "%a, process external resource: %a failed: %r\n", __func__, CollectionUri, Status));
  }

  FreePool (CollectionUri);


In this way, we don’ have huge changes to fix memory leak issue as you mentioned. (removing Private->Uri) Please let me know if this makes sense to you or not.

Thanks,
Nickle

From: M M <mike.maslenkin@gmail.com>
Sent: Friday, January 26, 2024 11:41 PM
To: Chang, Abner <Abner.Chang@amd.com>
Cc: devel@edk2.groups.io; Nickle Wang <nicklew@nvidia.com>; Igor Kulchytskyy <igork@ami.com>
Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver

External email: Use caution opening links or attachments

BTW did you consider to remove this Private->Uri someday at all ?
I tried to remove it, but since it declared in a common header for all redfish client feature drivers
those changes was huge comparing to a small memory leak I tried to fix.
And now such pattern spreads into new feature drivers.
In short: there is no need to cache this value in Private->Uri, but pass it as an argument down to stack in EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL implementation.
I think it just small design flaw.

The code I'm talking about:
+  //
+  // Check and see if "@Redfish.Settings" exist or not.
+  //
+  ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE));
+  Status = GetPendingSettings (
+             Private->RedfishService,
+             Response.Payload,
+             &PendingSettingResponse,
+             &PendingSettingUri
+             );
+  if (!EFI_ERROR (Status)) {
+    DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
+    Private->Uri     = PendingSettingUri;
+    ExpectedResponse = &PendingSettingResponse;
+  } else {
+    DEBUG ((REDFISH_DEBUG_TRACE, "%a: No @Redfish.Settings is found\n", __func__));
+    Private->Uri     = Uri;
+    ExpectedResponse = &Response;
+  }

In this pattern PendingSettingUri is leaked, since Private->Uri belongs to caller and never released.

But... in fact it is not true for Feature/Bios driver, and actually leaked resource is original Private->Uri string.

This is because these EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL function called by
HandleResource() function, which in turns called from here:
  //
  // Initialize collection path
  //
  Private->Uri = RedfishGetUri (ResourceUri);
  if (Private->Uri == NULL) {
    ASSERT (FALSE);
    FreePool (ResourceUri);
    return EFI_OUT_OF_RESOURCES;
  }

  Status = HandleResource (Private, Private->Uri);
  if (EFI_ERROR (Status)) {
    DEBUG ((DEBUG_ERROR, "%a, process external resource: %a failed: %r\n", __func__, Private->Uri, Status));
  }

  FreePool (Private->Uri);


Too many "Private->Uri" with a different value.

PS: Funny, just pay attention to the log trace above - %a used for Private->Uri. Probably it was one of the factors
induced me to write previous message :)

Regards,
Mike.



On 26. 1. 2024., at 17:13, Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>> wrote:

[AMD Official Use Only - General]

It is no problem. 😊 Thank you Mike for looking into this patch.
Abner


-----Original Message-----
From: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Friday, January 26, 2024 10:11 PM
To: Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>; Igor
Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver

Caution: This message originated from an External Source. Use proper caution
when opening attachments, clicking links, or responding.


You are right.

Sorry for the noise!

No problems here.
I mixed up with tags in my editor while looked into patch.

Regards,
Mike


On 26. 1. 2024., at 17:03, Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>> wrote:

[AMD Official Use Only - General]

Hi Mike,
I can't identify the issue on %s as Private->Uri is defined as EFI_STRING, or I
miss something?


Thanks
Abner


-----Original Message-----
From: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Friday, January 26, 2024 9:55 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Cc: Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>>; Igor Kulchytskyy
<igork@ami.com<mailto:igork@ami.com>>
Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2]
RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver

Caution: This message originated from an External Source. Use proper
caution

when opening attachments, clicking links, or responding.


Hi Abner,


On 26. 1. 2024., at 05:20, Nickle Wang via groups.io<http://groups.io/>
<nicklew=nvidia.com@groups.io<mailto:nicklew=nvidia.com@groups.io>> wrote:


Hi Abner,

Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call.


+      DEBUG ((DEBUG_MANAGEABILITY, "  No platform Redfish
ConfigureLang

found for %s\n", __func__, Private->Uri));

Regards,
Nickle

There are two issues in this string. The second one is incorrect  %s format
used

for Private->Uri.
This issue exists in V3 not only in the line mentioned above.

Regards,
Mike.




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114765): https://edk2.groups.io/g/devel/message/114765
Mute This Topic: https://groups.io/mt/103967446/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 23610 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-01-30  7:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-26  1:00 [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver Chang, Abner via groups.io
2024-01-26  2:20 ` Nickle Wang via groups.io
2024-01-26  2:32   ` Chang, Abner via groups.io
2024-01-26 13:55   ` Mike Maslenkin
2024-01-26 14:03     ` Chang, Abner via groups.io
2024-01-26 14:11       ` Mike Maslenkin
2024-01-26 14:13         ` Chang, Abner via groups.io
2024-01-26 15:41           ` Mike Maslenkin
2024-01-30  7:58             ` Nickle Wang via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox