From nobody Thu May 2 02:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82811+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82811+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1635429919; cv=none; d=zohomail.com; s=zohoarc; b=Sx9pLjuvrA3v8WMsYkCEjuUJTaupgis6YPalc0GFanieaoH1jBgtVH/DGnp2hJVvQDjhTrBMVFkKvSYjEtZKkdvSKUw5LPIxeyC1KiM4MQMuEN8ST9MY4B3Gk9zt/8y5qs1d8FsEXzhWbQerruww4bPtdw0KuTYcGbFsRET6rXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635429919; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=I/j3aUR1HCfZMbEYTqdtuI5TNu6i6nNdt1wVAmGVZEY=; b=LrCwzR1bvuBu9hdLCDi7M4PvsWu3RFQa3++hlJdvvUk6HDX8GeH+w0f/PsYdOyO7F+PW98w31rIEgrif714EiOc6hW0Uymeu2u2cCDrFajdDb1bT4l7CvsbmhG6S9Uk07MOrClHwydHjomlVsqntCsZys7V1H0IsFQPf6WcC2/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82811+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1635429919833181.19630478079068; Thu, 28 Oct 2021 07:05:19 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id PCsMYY1788612xMCVETJ3GBy; Thu, 28 Oct 2021 07:05:19 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web12.13280.1635429910668331426 for ; Thu, 28 Oct 2021 07:05:18 -0700 X-Received: from pps.filterd (m0150241.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19SB2Aw8014280; Thu, 28 Oct 2021 14:04:45 GMT X-Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0a-002e3701.pphosted.com with ESMTP id 3by52tkv56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Oct 2021 14:04:44 +0000 X-Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id 40C7962; Thu, 28 Oct 2021 14:04:43 +0000 (UTC) X-Received: from SAC2XFT1JT.asiapacific.hpqcorp.net (unknown [10.43.62.133]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id B30E33F; Thu, 28 Oct 2021 14:04:41 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: nickle.wang@hpe.com, Liming Gao Subject: [edk2-devel] [PATCH] edk2-staging/RedfishClientPkg: Add a sample of feature driver Date: Thu, 28 Oct 2021 22:04:40 +0800 Message-Id: <20211028140440.108700-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: JbKrhyXfTulb0icyeJz2wqCk6OQKpFwV X-Proofpoint-GUID: JbKrhyXfTulb0icyeJz2wqCk6OQKpFwV X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@hpe.com X-Gm-Message-State: FNTt5z2mgBfso1JEb3Pf8lxHx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1635429919; bh=+79sQAnQFiajDTCqdMqwujtdon4lfsLMaNhV2FAMUVY=; h=Cc:Date:From:Reply-To:Subject:To; b=ngYCYlsvbcfT15+jW0zfPYwhJ+PlVCbFTbt6HUDThILKLWmShHOkodpMUOSLR2jTKti 7kk8TO9as12ySHoJvdERRZyO/ggIxYlAsJ28CYib+/Ofi8EQFdHavavII1HuymsaMDXYZ SFxkxaJKIX85/akYmx8j9DXwUTk7xecVuxI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1635429948706100002 Content-Type: text/plain; charset="utf-8" (The feature drivers suppose are tool-generated. We commit the memory one as the sample implementation.) This is the sample EDKII Redfish feature driver for Redfish Memory and Memory collection property. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Liming Gao --- .../RedfishClientComponents.dsc.inc | 2 + .../Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf | 48 + .../RedfishMemoryCollectionDxe.inf | 53 + .../V1_7_1/Common/RedfishMemoryCommon.h | 27 + .../RedfishMemoryCollectionDxe.h | 18 + .../V1_7_1/Common/RedfishMemoryCommon.c | 2342 +++++++++++++++++ .../Memory/V1_7_1/Dxe/RedfishMemoryDxe.c | 553 ++++ .../RedfishMemoryCollectionDxe.c | 652 +++++ RedfishClientPkg/RedfishClient.fdf.inc | 2 + 9 files changed, 3697 insertions(+) create mode 100644 RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemo= ryDxe.inf create mode 100644 RedfishClientPkg/Features/RedfishMemoryCollectionDxe/Re= dfishMemoryCollectionDxe.inf create mode 100644 RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishM= emoryCommon.h create mode 100644 RedfishClientPkg/Features/RedfishMemoryCollectionDxe/Re= dfishMemoryCollectionDxe.h create mode 100644 RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishM= emoryCommon.c create mode 100644 RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemo= ryDxe.c create mode 100644 RedfishClientPkg/Features/RedfishMemoryCollectionDxe/Re= dfishMemoryCollectionDxe.c diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index fda4ceb747e..ed64a76fbd2 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -21,3 +21,5 @@ !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc !endif =20 + RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf + RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCollec= tionDxe.inf \ No newline at end of file diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.i= nf b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf new file mode 100644 index 00000000000..30746adaedd --- /dev/null +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf @@ -0,0 +1,48 @@ +## @file +# +# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D RedfishMemoryDxe + FILE_GUID =3D f5594d13-ca13-485f-ac3a-80c5074dd8c0 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D RedfishResourceEntryPoint + UNLOAD_IMAGE =3D RedfishResourceUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ../Common/RedfishMemoryCommon.h + ../Common/RedfishMemoryCommon.c + RedfishMemoryDxe.c + +[LibraryClasses] + BaseMemoryLib + DebugLib + RedfishLib + RedfishFeatureUtilityLib + UefiLib + UefiDriverEntryPoint + +[Protocols] + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED + gEfiRestJsonStructureProtocolGuid ## CONSUMED + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + +[Depex] + TRUE \ No newline at end of file diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.inf b/RedfishClientPkg/Features/RedfishMemoryCollectionDx= e/RedfishMemoryCollectionDxe.inf new file mode 100644 index 00000000000..e7bcf49bdbe --- /dev/null +++ b/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.inf @@ -0,0 +1,53 @@ +## @file +# +# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D RedfishMemoryCollectionDxe + FILE_GUID =3D 9323359C-11E2-49BC-B501-D6280B6DAE1A + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D RedfishCollectionEntryPoint + UNLOAD_IMAGE =3D RedfishCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RedfishMemoryCollectionDxe.h + RedfishMemoryCollectionDxe.c + +[LibraryClasses] + DebugLib + BaseMemoryLib + ConverterCommonLib + MemoryAllocationLib + RedfishFeatureUtilityLib + RedfishLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + +[Protocols] + gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMED + gEfiRestJsonStructureProtocolGuid ## CONSUMED + gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMED + gEdkIIRedfishFeatureProtocolGuid ## CONSUMED + +[Guids] + gEfiEventReadyToBootGuid + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + +[Depex] + TRUE \ No newline at end of file diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCo= mmon.h b/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCommon= .h new file mode 100644 index 00000000000..e2a4f45681a --- /dev/null +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCommon.h @@ -0,0 +1,27 @@ +/** @file + + Redfish feature driver implementation - internal header file + (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EFI_REDFISH_MEMORY_COMMON_H_ +#define EFI_REDFISH_MEMORY_COMMON_H_ + +#include +#include + +// +// Schema information. +// +#define RESOURCE_SCHEMA "Memory" +#define RESOURCE_SCHEMA_MAJOR "1" +#define RESOURCE_SCHEMA_MINOR "7" +#define RESOURCE_SCHEMA_ERRATA "1" +#define RESOURCE_SCHEMA_VERSION "v1_7_1" +#define REDPATH_ARRAY_PATTERN L"/Memory/{.*}/" +#define REDPATH_ARRAY_PREFIX L"/Memory/" +#define RESOURCE_SCHEMA_FULL "x-uefi-redfish-Memory.v1_7_1" + +#endif \ No newline at end of file diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.h b/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/= RedfishMemoryCollectionDxe.h new file mode 100644 index 00000000000..83ca8369415 --- /dev/null +++ b/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.h @@ -0,0 +1,18 @@ +/** @file + Redfish feature driver implementation - internal header file + + (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EFI_REDFISH_MEMORY_COLLECTION_H_ +#define EFI_REDFISH_MEMORY_COLLECTION_H_ + +#include +#include + +#define REDFISH_SCHEMA_NAME "Memory" +#define REDFISH_MANAGED_URI L"/redfish/v1/systems/{1}/memory" +#endif diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCo= mmon.c b/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCommon= .c new file mode 100644 index 00000000000..11f738f71c1 --- /dev/null +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCommon.c @@ -0,0 +1,2342 @@ +/** @file + Redfish feature driver implementation - common functions + + (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "RedfishMemoryCommon.h" + +CHAR8 MemoryEmptyJson[] =3D "{\"@odata.id\": \"\", \"@odata.type\": \"#Mem= ory.v1_7_1.Memory\", \"Id\": \"\", \"Name\": \"\"}"; + +REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate =3D NULL; + +EFI_STATUS +RedfishConsumeResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *MemoryJson + ) +{ + EFI_STATUS Status; + EFI_REDFISH_MEMORY_V1_7_1 *Memory; + EFI_REDFISH_MEMORY_V1_7_1_CS *MemoryCs; + EFI_STRING ConfigureLang; + CHAR8 *Arraykey; + CHAR8 *EtagInDb; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (MemoryJson)) { + return EFI_INVALID_PARAMETER; + } + + Memory=3D NULL; + MemoryCs =3D NULL; + ConfigureLang =3D NULL; + Arraykey =3D NULL; + EtagInDb =3D NULL; + + Status =3D Private->JsonStructProtocol->ToStructure ( + Private->JsonStructProtocol, + NULL, + MemoryJson, + (EFI_REST_JSON_STRUCTURE_HEADER = **)&Memory + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return Status; + } + + MemoryCs =3D Memory->Memory; + + // + // Check ETAG to see if we need to consume it + // + EtagInDb =3D GetEtagWithUri (Private->Uri); + if (EtagInDb !=3D NULL && MemoryCs->odata_etag !=3D NULL) { + if (AsciiStrCmp (EtagInDb, MemoryCs->odata_etag) =3D=3D 0) { + // + // No change + // + DEBUG ((DEBUG_INFO, "%a, ETAG: [%a] no change, ignore consume action= \n", __FUNCTION__, EtagInDb)); + goto ON_RELEASE; + } + } + + // + // Find array key from URI + // + Status =3D GetArraykeyFromUri (Private->Uri, &Arraykey); + if (EFI_ERROR (Status)) { + ASSERT (FALSE); + return Status; + } + + // + // Handle ALLOCATIONALIGNMENTMIB + // + if (MemoryCs->AllocationAlignmentMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "AllocationAlignmentMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->AllocationAlignmentMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle ALLOCATIONINCREMENTMIB + // + if (MemoryCs->AllocationIncrementMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "AllocationIncrementMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->AllocationIncrementMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle BASEMODULETYPE + // + if (MemoryCs->BaseModuleType !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "BaseModuleType", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->BaseModuleType); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle BUSWIDTHBITS + // + if (MemoryCs->BusWidthBits !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "BusWidthBits", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->BusWidthBits); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle CACHESIZEMIB + // + if (MemoryCs->CacheSizeMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "CacheSizeMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->CacheSizeMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle CAPACITYMIB + // + if (MemoryCs->CapacityMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "CapacityMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->CapacityMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle CONFIGURATIONLOCKED + // + if (MemoryCs->ConfigurationLocked !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ConfigurationLocked", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->ConfigurationLocked); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle DATAWIDTHBITS + // + if (MemoryCs->DataWidthBits !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "DataWidthBits", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->DataWidthBits); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle DEVICEID + // + if (MemoryCs->DeviceID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "DeviceID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->DeviceID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle DEVICELOCATOR + // + if (MemoryCs->DeviceLocator !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "DeviceLocator", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->DeviceLocator); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle ERRORCORRECTION + // + if (MemoryCs->ErrorCorrection !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ErrorCorrection", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->ErrorCorrection); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle FIRMWAREAPIVERSION + // + if (MemoryCs->FirmwareApiVersion !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "FirmwareApiVersion", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->FirmwareApiVersion); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle FIRMWAREREVISION + // + if (MemoryCs->FirmwareRevision !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "FirmwareRevision", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->FirmwareRevision); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle ISRANKSPAREENABLED + // + if (MemoryCs->IsRankSpareEnabled !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "IsRankSpareEnabled", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->IsRankSpareEnabled); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle ISSPAREDEVICEENABLED + // + if (MemoryCs->IsSpareDeviceEnabled !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "IsSpareDeviceEnabled", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->IsSpareDeviceEnabled); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle LOGICALSIZEMIB + // + if (MemoryCs->LogicalSizeMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "LogicalSizeMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->LogicalSizeMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MANUFACTURER + // + if (MemoryCs->Manufacturer !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "Manufacturer", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->Manufacturer); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYDEVICETYPE + // + if (MemoryCs->MemoryDeviceType !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryDeviceType", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemoryDeviceType); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYLOCATION + // + if(MemoryCs->MemoryLocation =3D=3D NULL) { + MemoryCs->MemoryLocation =3D AllocateZeroPool (sizeof (RedfishMemory_V= 1_7_1_MemoryLocation_CS)); + ASSERT (MemoryCs->MemoryLocation !=3D NULL); + } + + // + // Handle MEMORYLOCATION->CHANNEL + // + if (MemoryCs->MemoryLocation->Channel !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/Channel", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->Channel); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYLOCATION->MEMORYCONTROLLER + // + if (MemoryCs->MemoryLocation->MemoryController !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/MemoryController", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->MemoryCo= ntroller); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYLOCATION->SLOT + // + if (MemoryCs->MemoryLocation->Slot !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/Slot", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->Slot); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYLOCATION->SOCKET + // + if (MemoryCs->MemoryLocation->Socket !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/Socket", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->Socket); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYSUBSYSTEMCONTROLLERMANUFACTURERID + // + if (MemoryCs->MemorySubsystemControllerManufacturerID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemorySubsystemControllerManufacturerID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemorySubsystemControllerManufact= urerID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYSUBSYSTEMCONTROLLERPRODUCTID + // + if (MemoryCs->MemorySubsystemControllerProductID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemorySubsystemControllerProductID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemorySubsystemControllerProductI= D); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MEMORYTYPE + // + if (MemoryCs->MemoryType !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryType", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemoryType); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MODULEMANUFACTURERID + // + if (MemoryCs->ModuleManufacturerID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ModuleManufacturerID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->ModuleManufacturerID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle MODULEPRODUCTID + // + if (MemoryCs->ModuleProductID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ModuleProductID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->ModuleProductID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle NONVOLATILESIZEMIB + // + if (MemoryCs->NonVolatileSizeMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "NonVolatileSizeMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->NonVolatileSizeMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle OPERATINGSPEEDMHZ + // + if (MemoryCs->OperatingSpeedMhz !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "OperatingSpeedMhz", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->OperatingSpeedMhz); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle PARTNUMBER + // + if (MemoryCs->PartNumber !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PartNumber", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->PartNumber); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle PERSISTENTREGIONNUMBERLIMIT + // + if (MemoryCs->PersistentRegionNumberLimit !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PersistentRegionNumberLimit", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PersistentRegionNumberLi= mit); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle PERSISTENTREGIONSIZELIMITMIB + // + if (MemoryCs->PersistentRegionSizeLimitMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PersistentRegionSizeLimitMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PersistentRegionSizeLimi= tMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle PERSISTENTREGIONSIZEMAXMIB + // + if (MemoryCs->PersistentRegionSizeMaxMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PersistentRegionSizeMaxMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PersistentRegionSizeMaxM= iB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle POWERMANAGEMENTPOLICY + // + if(MemoryCs->PowerManagementPolicy =3D=3D NULL) { + MemoryCs->PowerManagementPolicy =3D AllocateZeroPool (sizeof (RedfishM= emory_V1_7_1_PowerManagementPolicy_CS)); + ASSERT (MemoryCs->PowerManagementPolicy !=3D NULL); + } + + // + // Handle POWERMANAGEMENTPOLICY->AVERAGEPOWERBUDGETMILLIWATTS + // + if (MemoryCs->PowerManagementPolicy->AveragePowerBudgetMilliWatts !=3D N= ULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/AveragePowerBudgetMilliWatts", Arraykey= ); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PowerManagementPolicy->A= veragePowerBudgetMilliWatts); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle POWERMANAGEMENTPOLICY->MAXTDPMILLIWATTS + // + if (MemoryCs->PowerManagementPolicy->MaxTDPMilliWatts !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/MaxTDPMilliWatts", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PowerManagementPolicy->M= axTDPMilliWatts); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle POWERMANAGEMENTPOLICY->PEAKPOWERBUDGETMILLIWATTS + // + if (MemoryCs->PowerManagementPolicy->PeakPowerBudgetMilliWatts !=3D NULL= ) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/PeakPowerBudgetMilliWatts", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PowerManagementPolicy->P= eakPowerBudgetMilliWatts); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle POWERMANAGEMENTPOLICY->POLICYENABLED + // + if (MemoryCs->PowerManagementPolicy->PolicyEnabled !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/PolicyEnabled", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->PowerManagementPolicy-= >PolicyEnabled); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle RANKCOUNT + // + if (MemoryCs->RankCount !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "RankCount", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->RankCount); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SECURITYCAPABILITIES + // + if(MemoryCs->SecurityCapabilities =3D=3D NULL) { + MemoryCs->SecurityCapabilities =3D AllocateZeroPool (sizeof (RedfishMe= mory_V1_7_1_SecurityCapabilities_CS)); + ASSERT (MemoryCs->SecurityCapabilities !=3D NULL); + } + + // + // Handle SECURITYCAPABILITIES->CONFIGURATIONLOCKCAPABLE + // + if (MemoryCs->SecurityCapabilities->ConfigurationLockCapable !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/ConfigurationLockCapable", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->SecurityCapabilities->= ConfigurationLockCapable); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SECURITYCAPABILITIES->DATALOCKCAPABLE + // + if (MemoryCs->SecurityCapabilities->DataLockCapable !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/DataLockCapable", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->SecurityCapabilities->= DataLockCapable); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SECURITYCAPABILITIES->MAXPASSPHRASECOUNT + // + if (MemoryCs->SecurityCapabilities->MaxPassphraseCount !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/MaxPassphraseCount", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->SecurityCapabilities->Ma= xPassphraseCount); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SECURITYCAPABILITIES->PASSPHRASECAPABLE + // + if (MemoryCs->SecurityCapabilities->PassphraseCapable !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/PassphraseCapable", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->SecurityCapabilities->= PassphraseCapable); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SECURITYCAPABILITIES->PASSPHRASELOCKLIMIT + // + if (MemoryCs->SecurityCapabilities->PassphraseLockLimit !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/PassphraseLockLimit", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->SecurityCapabilities->Pa= ssphraseLockLimit); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SECURITYSTATE + // + if (MemoryCs->SecurityState !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityState", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SecurityState); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SERIALNUMBER + // + if (MemoryCs->SerialNumber !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SerialNumber", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SerialNumber); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SPAREDEVICECOUNT + // + if (MemoryCs->SpareDeviceCount !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SpareDeviceCount", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->SpareDeviceCount); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SUBSYSTEMDEVICEID + // + if (MemoryCs->SubsystemDeviceID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SubsystemDeviceID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SubsystemDeviceID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle SUBSYSTEMVENDORID + // + if (MemoryCs->SubsystemVendorID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SubsystemVendorID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SubsystemVendorID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle VENDORID + // + if (MemoryCs->VendorID !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VendorID", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->VendorID); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle VOLATILEREGIONNUMBERLIMIT + // + if (MemoryCs->VolatileRegionNumberLimit !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileRegionNumberLimit", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileRegionNumberLimi= t); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle VOLATILEREGIONSIZELIMITMIB + // + if (MemoryCs->VolatileRegionSizeLimitMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileRegionSizeLimitMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileRegionSizeLimitM= iB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle VOLATILEREGIONSIZEMAXMIB + // + if (MemoryCs->VolatileRegionSizeMaxMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileRegionSizeMaxMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileRegionSizeMaxMiB= ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + // + // Handle VOLATILESIZEMIB + // + if (MemoryCs->VolatileSizeMiB !=3D NULL) { + // + // Find corresponding redpath for collection resource. + // + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileSizeMiB", Arraykey); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileSizeMiB); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + } + } + + + + // +ON_RELEASE: + + // + // Release resource. + // + if (EtagInDb !=3D NULL) { + FreePool (EtagInDb); + } + + if (Arraykey !=3D NULL) { + FreePool (Arraykey); + } + + Private->JsonStructProtocol->DestoryStructure ( + Private->JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)Memory + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +ProvisioningMemoryProperties ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, + IN CHAR8 *IputJson, + IN CHAR8 *ResourceId, OPTIONAL + IN EFI_STRING ConfigureLang, + IN BOOLEAN ProvisionMode, + OUT CHAR8 **ResultJson + ) +{ + EFI_REDFISH_MEMORY_V1_7_1 *Memory; + EFI_REDFISH_MEMORY_V1_7_1_CS *MemoryCs; + EFI_STATUS Status; + INT64 *NumericValue; + INT32 *IntegerValue; + BOOLEAN *BooleanValue; + CHAR8 *AsciiStringValue; + BOOLEAN PropertyChanged; + BOOLEAN UnusedProperty; + + if (JsonStructProtocol =3D=3D NULL || ResultJson =3D=3D NULL || IS_EMPTY= _STRING (IputJson) || IS_EMPTY_STRING (ConfigureLang)) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s with: %s\n", __FUNCTIO= N__, ConfigureLang, (ProvisionMode ? L"Provision all resource" : L"Provisio= n existing resource"))); + + *ResultJson =3D NULL; + PropertyChanged =3D FALSE; + UnusedProperty =3D TRUE; + + Memory =3D NULL; + Status =3D JsonStructProtocol->ToStructure ( + JsonStructProtocol, + NULL, + IputJson, + (EFI_REST_JSON_STRUCTURE_HEADER **)&Memory + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure failure: %r\n", __FUNCTION__, St= atus)); + return Status; + } + + MemoryCs =3D Memory->Memory; + + // + // ID + // + if (MemoryCs->Id =3D=3D NULL && !IS_EMPTY_STRING (ResourceId)) { + MemoryCs->Id =3D AllocateCopyPool (AsciiStrSize (ResourceId), Resource= Id); + } + + // + // Handle ALLOCATIONALIGNMENTMIB + // + if (PropertyChecker (MemoryCs->AllocationAlignmentMiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"AllocationAlignmentMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->AllocationAlignmentMiB !=3D *Numeric= Value) { + MemoryCs->AllocationAlignmentMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle ALLOCATIONINCREMENTMIB + // + if (PropertyChecker (MemoryCs->AllocationIncrementMiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"AllocationIncrementMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->AllocationIncrementMiB !=3D *Numeric= Value) { + MemoryCs->AllocationIncrementMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle BASEMODULETYPE + // + if (PropertyChecker (MemoryCs->BaseModuleType, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"BaseModuleType", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->BaseModuleType, AsciiStr= ingValue) !=3D 0) { + MemoryCs->BaseModuleType =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle BUSWIDTHBITS + // + if (PropertyChecker (MemoryCs->BusWidthBits, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"BusWidthBits", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->BusWidthBits !=3D *NumericValue) { + MemoryCs->BusWidthBits =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle CACHESIZEMIB + // + if (PropertyChecker (MemoryCs->CacheSizeMiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"CacheSizeMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->CacheSizeMiB !=3D *NumericValue) { + MemoryCs->CacheSizeMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle CAPACITYMIB + // + if (PropertyChecker (MemoryCs->CapacityMiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"CapacityMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->CapacityMiB !=3D *NumericValue) { + MemoryCs->CapacityMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle CONFIGURATIONLOCKED + // + if (PropertyChecker (MemoryCs->ConfigurationLocked, ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"ConfigurationLocked", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->ConfigurationLocked !=3D *BooleanVal= ue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->ConfigurationLocked =3D IntegerValue; + } + } + } + } + + // + // Handle DATAWIDTHBITS + // + if (PropertyChecker (MemoryCs->DataWidthBits, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"DataWidthBits", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->DataWidthBits !=3D *NumericValue) { + MemoryCs->DataWidthBits =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle DEVICEID + // + if (PropertyChecker (MemoryCs->DeviceID, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"DeviceID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->DeviceID, AsciiStringVal= ue) !=3D 0) { + MemoryCs->DeviceID =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle DEVICELOCATOR + // + if (PropertyChecker (MemoryCs->DeviceLocator, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"DeviceLocator", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->DeviceLocator, AsciiStri= ngValue) !=3D 0) { + MemoryCs->DeviceLocator =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle ERRORCORRECTION + // + if (PropertyChecker (MemoryCs->ErrorCorrection, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"ErrorCorrection", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->ErrorCorrection, AsciiSt= ringValue) !=3D 0) { + MemoryCs->ErrorCorrection =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle FIRMWAREAPIVERSION + // + if (PropertyChecker (MemoryCs->FirmwareApiVersion, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"FirmwareApiVersion", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->FirmwareApiVersion, Asci= iStringValue) !=3D 0) { + MemoryCs->FirmwareApiVersion =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle FIRMWAREREVISION + // + if (PropertyChecker (MemoryCs->FirmwareRevision, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"FirmwareRevision", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->FirmwareRevision, AsciiS= tringValue) !=3D 0) { + MemoryCs->FirmwareRevision =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle ISRANKSPAREENABLED + // + if (PropertyChecker (MemoryCs->IsRankSpareEnabled, ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"IsRankSpareEnabled", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->IsRankSpareEnabled !=3D *BooleanValu= e) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->IsRankSpareEnabled =3D IntegerValue; + } + } + } + } + + // + // Handle ISSPAREDEVICEENABLED + // + if (PropertyChecker (MemoryCs->IsSpareDeviceEnabled, ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"IsSpareDeviceEnabled", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->IsSpareDeviceEnabled !=3D *BooleanVa= lue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->IsSpareDeviceEnabled =3D IntegerValue; + } + } + } + } + + // + // Handle LOGICALSIZEMIB + // + if (PropertyChecker (MemoryCs->LogicalSizeMiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"LogicalSizeMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->LogicalSizeMiB !=3D *NumericValue) { + MemoryCs->LogicalSizeMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle MANUFACTURER + // + if (PropertyChecker (MemoryCs->Manufacturer, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"Manufacturer", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->Manufacturer, AsciiStrin= gValue) !=3D 0) { + MemoryCs->Manufacturer =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle MEMORYDEVICETYPE + // + if (PropertyChecker (MemoryCs->MemoryDeviceType, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"MemoryDeviceType", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->MemoryDeviceType, AsciiS= tringValue) !=3D 0) { + MemoryCs->MemoryDeviceType =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle MEMORYLOCATION + // + if(MemoryCs->MemoryLocation =3D=3D NULL) { + MemoryCs->MemoryLocation =3D AllocateZeroPool (sizeof (RedfishMemory_V= 1_7_1_MemoryLocation_CS)); + ASSERT (MemoryCs->MemoryLocation !=3D NULL); + UnusedProperty =3D TRUE; + } else { + UnusedProperty =3D FALSE; + } + + // + // Handle MEMORYLOCATION->CHANNEL + // + if (PropertyChecker (MemoryCs->MemoryLocation->Channel, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"MemoryLocation/Channel", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->Channel !=3D *Numeri= cValue) { + MemoryCs->MemoryLocation->Channel =3D NumericValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + // + // Handle MEMORYLOCATION->MEMORYCONTROLLER + // + if (PropertyChecker (MemoryCs->MemoryLocation->MemoryController, Provisi= onMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"MemoryLocation/MemoryController", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->MemoryController != =3D *NumericValue) { + MemoryCs->MemoryLocation->MemoryController =3D NumericValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + // + // Handle MEMORYLOCATION->SLOT + // + if (PropertyChecker (MemoryCs->MemoryLocation->Slot, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"MemoryLocation/Slot", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->Slot !=3D *NumericVa= lue) { + MemoryCs->MemoryLocation->Slot =3D NumericValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + // + // Handle MEMORYLOCATION->SOCKET + // + if (PropertyChecker (MemoryCs->MemoryLocation->Socket, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"MemoryLocation/Socket", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->Socket !=3D *Numeric= Value) { + MemoryCs->MemoryLocation->Socket =3D NumericValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + if (UnusedProperty) { + FreePool (MemoryCs->MemoryLocation); + MemoryCs->MemoryLocation =3D NULL; + } + + // + // Handle MEMORYSUBSYSTEMCONTROLLERMANUFACTURERID + // + if (PropertyChecker (MemoryCs->MemorySubsystemControllerManufacturerID, = ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"MemorySubsystemControllerManufacturerID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->MemorySubsystemControlle= rManufacturerID, AsciiStringValue) !=3D 0) { + MemoryCs->MemorySubsystemControllerManufacturerID =3D AsciiStringV= alue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle MEMORYSUBSYSTEMCONTROLLERPRODUCTID + // + if (PropertyChecker (MemoryCs->MemorySubsystemControllerProductID, Provi= sionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"MemorySubsystemControllerProductID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->MemorySubsystemControlle= rProductID, AsciiStringValue) !=3D 0) { + MemoryCs->MemorySubsystemControllerProductID =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle MEMORYTYPE + // + if (PropertyChecker (MemoryCs->MemoryType, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"MemoryType", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->MemoryType, AsciiStringV= alue) !=3D 0) { + MemoryCs->MemoryType =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle MODULEMANUFACTURERID + // + if (PropertyChecker (MemoryCs->ModuleManufacturerID, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"ModuleManufacturerID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->ModuleManufacturerID, As= ciiStringValue) !=3D 0) { + MemoryCs->ModuleManufacturerID =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle MODULEPRODUCTID + // + if (PropertyChecker (MemoryCs->ModuleProductID, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"ModuleProductID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->ModuleProductID, AsciiSt= ringValue) !=3D 0) { + MemoryCs->ModuleProductID =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle NONVOLATILESIZEMIB + // + if (PropertyChecker (MemoryCs->NonVolatileSizeMiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"NonVolatileSizeMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->NonVolatileSizeMiB !=3D *NumericValu= e) { + MemoryCs->NonVolatileSizeMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle OPERATINGSPEEDMHZ + // + if (PropertyChecker (MemoryCs->OperatingSpeedMhz, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"OperatingSpeedMhz", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->OperatingSpeedMhz !=3D *NumericValue= ) { + MemoryCs->OperatingSpeedMhz =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle PARTNUMBER + // + if (PropertyChecker (MemoryCs->PartNumber, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"PartNumber", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->PartNumber, AsciiStringV= alue) !=3D 0) { + MemoryCs->PartNumber =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle PERSISTENTREGIONNUMBERLIMIT + // + if (PropertyChecker (MemoryCs->PersistentRegionNumberLimit, ProvisionMod= e)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"PersistentRegionNumberLimit", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PersistentRegionNumberLimit !=3D *Nu= mericValue) { + MemoryCs->PersistentRegionNumberLimit =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle PERSISTENTREGIONSIZELIMITMIB + // + if (PropertyChecker (MemoryCs->PersistentRegionSizeLimitMiB, ProvisionMo= de)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"PersistentRegionSizeLimitMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PersistentRegionSizeLimitMiB !=3D *N= umericValue) { + MemoryCs->PersistentRegionSizeLimitMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle PERSISTENTREGIONSIZEMAXMIB + // + if (PropertyChecker (MemoryCs->PersistentRegionSizeMaxMiB, ProvisionMode= )) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"PersistentRegionSizeMaxMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PersistentRegionSizeMaxMiB !=3D *Num= ericValue) { + MemoryCs->PersistentRegionSizeMaxMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle POWERMANAGEMENTPOLICY + // + if(MemoryCs->PowerManagementPolicy =3D=3D NULL) { + MemoryCs->PowerManagementPolicy =3D AllocateZeroPool (sizeof (RedfishM= emory_V1_7_1_PowerManagementPolicy_CS)); + ASSERT (MemoryCs->PowerManagementPolicy !=3D NULL); + UnusedProperty =3D TRUE; + } else { + UnusedProperty =3D FALSE; + } + + // + // Handle POWERMANAGEMENTPOLICY->AVERAGEPOWERBUDGETMILLIWATTS + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->AveragePowerBudget= MilliWatts, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"PowerManagementPolicy/AveragePowerBudgetMilliWatts", Config= ureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->AveragePowerB= udgetMilliWatts !=3D *NumericValue) { + MemoryCs->PowerManagementPolicy->AveragePowerBudgetMilliWatts =3D = NumericValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + // + // Handle POWERMANAGEMENTPOLICY->MAXTDPMILLIWATTS + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->MaxTDPMilliWatts, = ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"PowerManagementPolicy/MaxTDPMilliWatts", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->MaxTDPMilliWa= tts !=3D *NumericValue) { + MemoryCs->PowerManagementPolicy->MaxTDPMilliWatts =3D NumericValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + // + // Handle POWERMANAGEMENTPOLICY->PEAKPOWERBUDGETMILLIWATTS + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->PeakPowerBudgetMil= liWatts, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"PowerManagementPolicy/PeakPowerBudgetMilliWatts", Configure= Lang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->PeakPowerBudg= etMilliWatts !=3D *NumericValue) { + MemoryCs->PowerManagementPolicy->PeakPowerBudgetMilliWatts =3D Num= ericValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + // + // Handle POWERMANAGEMENTPOLICY->POLICYENABLED + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->PolicyEnabled, Pro= visionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"PowerManagementPolicy/PolicyEnabled", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->PolicyEnabled= !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->PowerManagementPolicy->PolicyEnabled =3D IntegerValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + } + + if (UnusedProperty) { + FreePool (MemoryCs->PowerManagementPolicy); + MemoryCs->PowerManagementPolicy =3D NULL; + } + + // + // Handle RANKCOUNT + // + if (PropertyChecker (MemoryCs->RankCount, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"RankCount", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->RankCount !=3D *NumericValue) { + MemoryCs->RankCount =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle SECURITYCAPABILITIES + // + if(MemoryCs->SecurityCapabilities =3D=3D NULL) { + MemoryCs->SecurityCapabilities =3D AllocateZeroPool (sizeof (RedfishMe= mory_V1_7_1_SecurityCapabilities_CS)); + ASSERT (MemoryCs->SecurityCapabilities !=3D NULL); + UnusedProperty =3D TRUE; + } else { + UnusedProperty =3D FALSE; + } + + // + // Handle SECURITYCAPABILITIES->CONFIGURATIONLOCKCAPABLE + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->ConfigurationLockCa= pable, ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"SecurityCapabilities/ConfigurationLockCapable", ConfigureLa= ng); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->ConfigurationL= ockCapable !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->SecurityCapabilities->ConfigurationLockCapable =3D Int= egerValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + } + + // + // Handle SECURITYCAPABILITIES->DATALOCKCAPABLE + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->DataLockCapable, Pr= ovisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"SecurityCapabilities/DataLockCapable", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->DataLockCapabl= e !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->SecurityCapabilities->DataLockCapable =3D IntegerValue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + } + + // + // Handle SECURITYCAPABILITIES->MAXPASSPHRASECOUNT + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->MaxPassphraseCount,= ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"SecurityCapabilities/MaxPassphraseCount", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->MaxPassphraseC= ount !=3D *NumericValue) { + MemoryCs->SecurityCapabilities->MaxPassphraseCount =3D NumericValu= e; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + // + // Handle SECURITYCAPABILITIES->PASSPHRASECAPABLE + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->PassphraseCapable, = ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"SecurityCapabilities/PassphraseCapable", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->PassphraseCapa= ble !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->SecurityCapabilities->PassphraseCapable =3D IntegerVal= ue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + } + + // + // Handle SECURITYCAPABILITIES->PASSPHRASELOCKLIMIT + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->PassphraseLockLimit= , ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"SecurityCapabilities/PassphraseLockLimit", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->PassphraseLock= Limit !=3D *NumericValue) { + MemoryCs->SecurityCapabilities->PassphraseLockLimit =3D NumericVal= ue; + PropertyChanged =3D TRUE; + UnusedProperty =3D FALSE; + } + } + } + + if (UnusedProperty) { + FreePool (MemoryCs->SecurityCapabilities); + MemoryCs->SecurityCapabilities =3D NULL; + } + + // + // Handle SECURITYSTATE + // + if (PropertyChecker (MemoryCs->SecurityState, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SecurityState", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->SecurityState, AsciiStri= ngValue) !=3D 0) { + MemoryCs->SecurityState =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle SERIALNUMBER + // + if (PropertyChecker (MemoryCs->SerialNumber, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SerialNumber", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->SerialNumber, AsciiStrin= gValue) !=3D 0) { + MemoryCs->SerialNumber =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle SPAREDEVICECOUNT + // + if (PropertyChecker (MemoryCs->SpareDeviceCount, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"SpareDeviceCount", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SpareDeviceCount !=3D *NumericValue)= { + MemoryCs->SpareDeviceCount =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle SUBSYSTEMDEVICEID + // + if (PropertyChecker (MemoryCs->SubsystemDeviceID, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SubsystemDeviceID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->SubsystemDeviceID, Ascii= StringValue) !=3D 0) { + MemoryCs->SubsystemDeviceID =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle SUBSYSTEMVENDORID + // + if (PropertyChecker (MemoryCs->SubsystemVendorID, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SubsystemVendorID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->SubsystemVendorID, Ascii= StringValue) !=3D 0) { + MemoryCs->SubsystemVendorID =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle VENDORID + // + if (PropertyChecker (MemoryCs->VendorID, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"VendorID", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (MemoryCs->VendorID, AsciiStringVal= ue) !=3D 0) { + MemoryCs->VendorID =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle VOLATILEREGIONNUMBERLIMIT + // + if (PropertyChecker (MemoryCs->VolatileRegionNumberLimit, ProvisionMode)= ) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"VolatileRegionNumberLimit", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->VolatileRegionNumberLimit !=3D *Nume= ricValue) { + MemoryCs->VolatileRegionNumberLimit =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle VOLATILEREGIONSIZELIMITMIB + // + if (PropertyChecker (MemoryCs->VolatileRegionSizeLimitMiB, ProvisionMode= )) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"VolatileRegionSizeLimitMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->VolatileRegionSizeLimitMiB !=3D *Num= ericValue) { + MemoryCs->VolatileRegionSizeLimitMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle VOLATILEREGIONSIZEMAXMIB + // + if (PropertyChecker (MemoryCs->VolatileRegionSizeMaxMiB, ProvisionMode))= { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"VolatileRegionSizeMaxMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->VolatileRegionSizeMaxMiB !=3D *Numer= icValue) { + MemoryCs->VolatileRegionSizeMaxMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + // + // Handle VOLATILESIZEMIB + // + if (PropertyChecker (MemoryCs->VolatileSizeMiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_SC= HEMA_VERSION, L"VolatileSizeMiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->VolatileSizeMiB !=3D *NumericValue) { + MemoryCs->VolatileSizeMiB =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + + + + // + // Convert C structure back to JSON text. + // + Status =3D JsonStructProtocol->ToJson ( + JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)Memory, + ResultJson + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToJson() failed: %r\n", __FUNCTION__, Status= )); + return Status; + } + + // + // Release resource. + // + JsonStructProtocol->DestoryStructure ( + JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)Memory + ); + + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); +} + +EFI_STATUS +ProvisioningMemoryResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN UINTN Index, + IN EFI_STRING ConfigureLang + ) +{ + CHAR8 *MemoryJson; + EFI_STATUS Status; + CHAR8 *NewResourceLocation; + CHAR8 *NewKey; + CHAR8 *EtagStr; + CHAR8 ResourceId[16]; + CHAR8 NewUri[255]; + + if (IS_EMPTY_STRING (ConfigureLang) || Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index); + + Status =3D ProvisioningMemoryProperties ( + Private->JsonStructProtocol, + MemoryEmptyJson, + ResourceId, + ConfigureLang, + TRUE, + &MemoryJson + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, provisioning resource for %s failed: %r\n", = __FUNCTION__, ConfigureLang, Status)); + return Status; + } + + Status =3D CreatePayloadToPostResource (Private->RedfishService, Private= ->Payload, MemoryJson, &NewResourceLocation, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, post memory resource for %s failed: %r\n", _= _FUNCTION__, ConfigureLang, Status)); + goto RELEASE_RESOURCE; + } + + NewUri[0] =3D '\0'; + + // + // Keep location of new resource. + // + if (NewResourceLocation !=3D NULL) { + // + // Find key + // + NewKey =3D AsciiStrStr (NewResourceLocation, RESOURCE_SCHEMA); + if (NewKey !=3D NULL) { + NewKey +=3D 6; + // + // skip '/' + // + if (NewKey[0] =3D=3D '/') { + NewKey++; + } + SetConfigureLangWithkey (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, N= ewKey, Index); + AsciiSPrint (NewUri, sizeof (NewUri), "%a[%a]", Private->Uri, NewKey= ); + FreePool (NewResourceLocation); + } + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, NewUri); + FreePool (EtagStr); + } + +RELEASE_RESOURCE: + + FreePool (MemoryJson); + + return Status; +} + +EFI_STATUS +ProvisioningMemoryResources ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private + ) +{ + UINTN Index; + EFI_STATUS Status; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST UnifiedConfigureLangList; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D RedfishFeatureGetUnifiedArrayTypeConfigureLang (RESOURCE_SCHE= MA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &UnifiedConfigureLangLi= st); + if (EFI_ERROR (Status) || UnifiedConfigureLangList.Count =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a, No HII question found with redpath: %s: %r\n= ", __FUNCTION__, REDPATH_ARRAY_PATTERN, Status)); + return EFI_NOT_FOUND; + } + + for (Index =3D 0; Index < UnifiedConfigureLangList.Count; Index++) { + DEBUG ((DEBUG_INFO, "[%d] create memory resource from: %s\n", UnifiedC= onfigureLangList.List[Index].Index, UnifiedConfigureLangList.List[Index].Co= nfigureLang)); + ProvisioningMemoryResource (Private, UnifiedConfigureLangList.List[Ind= ex].Index, UnifiedConfigureLangList.List[Index].ConfigureLang); + FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang); + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +ProvisioningMemoryExistResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private + ) +{ + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Payload= ), EDKII_JSON_COMPACT); + ASSERT (Private->Json !=3D NULL); + + return RedfishUpdateResourceCommon (Private, Private->Json); +} + +/** + 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 wil= l be used. + FALSE if resource does not exist POST m= ethod 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + return (ResourceExist ? ProvisioningMemoryExistResource (Private) : Prov= isioningMemoryResources (Private)); +} + +/** + Check resource from given URI. + + @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV= ATE instance. + @param[in] Json The JSON to consume. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishCheckResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *Json + ) +{ + UINTN Index; + EFI_STATUS Status; + EFI_STRING *ConfigureLangList; + UINTN Count; + EFI_STRING Property; + CHAR8 *PropertyAscii; + UINTN BuffSize; + CHAR8 *Match; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (Json)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA, RESOU= RCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigureLangList, &Count); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, BiosConfigToRedfishGetConfigureLangRegex fai= led: %r\n", __FUNCTION__, Status)); + return Status; + } + + if (Count =3D=3D 0) { + return EFI_NOT_FOUND; + } + + Status =3D EFI_SUCCESS; + for (Index =3D 0; Index < Count; Index++) { + + Property =3D GetPropertyFromConfigureLang (ConfigureLangList[Index]); + if (Property =3D=3D NULL) { + continue; + } + + DEBUG ((DEBUG_INFO, "[%d] check resource from: %s\n", Index, Property)= ); + + BuffSize =3D StrLen (Property) + 1; + PropertyAscii =3D AllocatePool (BuffSize); + UnicodeStrToAsciiStrS (Property, PropertyAscii, BuffSize); + + // + // check to see if it is partial match. + // + Match =3D AsciiStrStr (Json, PropertyAscii); + if (Match =3D=3D NULL || AsciiStrnCmp (Match, PropertyAscii, AsciiStrL= en (PropertyAscii)) !=3D 0) { + Status =3D EFI_NOT_FOUND; + DEBUG ((DEBUG_ERROR, "%a, property %a is missing\n", __FUNCTION__, P= ropertyAscii)); + } + + FreePool (PropertyAscii); + } + + FreePool (ConfigureLangList); + + return Status; +} + + +/** + Update resource to given URI. + + @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV= ATE 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 *Json + ) +{ + EFI_STATUS Status; + CHAR8 *MemoryJson; + CHAR8 *ArrayKey; + EFI_STRING ConfigureLang; + CHAR8 *EtagStr; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (Json)) { + return EFI_INVALID_PARAMETER; + } + + MemoryJson =3D NULL; + ConfigureLang =3D NULL; + ArrayKey =3D NULL; + + Status =3D GetArraykeyFromUri (Private->Uri, &ArrayKey); + if (EFI_ERROR (Status)) { + return Status; + } + + ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCHEM= A_VERSION, NULL, ArrayKey); + if (ConfigureLang =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Status =3D ProvisioningMemoryProperties ( + Private->JsonStructProtocol, + Json, + NULL, + ConfigureLang, + FALSE, + &MemoryJson + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_NOT_FOUND) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, update resource for %s ignored. No= thing changed\n", __FUNCTION__, ConfigureLang)); + } else { + DEBUG ((DEBUG_ERROR, "%a, update resource for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + goto ON_RELEASE; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, update resource for %s\n", __FUNCTION_= _, ConfigureLang)); + // + // PUT back to instance + // + Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, MemoryJson, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, post memory resource for %s failed: %r\n", _= _FUNCTION__, ConfigureLang, Status)); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, Private->Uri); + FreePool (EtagStr); + } + +ON_RELEASE: + + if (MemoryJson !=3D NULL) { + FreePool (MemoryJson); + } + + if (ConfigureLang !=3D NULL) { + FreePool (ConfigureLang); + } + + if (ArrayKey !=3D NULL) { + FreePool (ArrayKey); + } + + return Status; +} \ No newline at end of file diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.c= b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.c new file mode 100644 index 00000000000..d1fbf2c2377 --- /dev/null +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.c @@ -0,0 +1,553 @@ +/** @file + Redfish feature driver implementation - Memory + + (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "../Common/RedfishMemoryCommon.h" + +extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate; + +/** + Provising 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, po= st method is used. + FALSE if the resource exist but propert= y is missing, put method is used. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishResourceProvisioningResource ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN CHAR8 *Uri, + IN BOOLEAN PostMode + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + + if (This =3D=3D NULL || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + if (!PostMode) { + return EFI_UNSUPPORTED; + } + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); + + if (Private->RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + return Status; + } + + Private->Uri =3D Uri; + Private->Payload =3D Response.Payload; + ASSERT (Private->Payload !=3D NULL); + + Status =3D RedfishProvisioningResourceCommon (Private, FALSE); + + // + // Release resource + // + if (Private->Payload !=3D NULL) { + RedfishFreeResponse ( + Response.StatusCode, + Response.HeaderCount, + Response.Headers, + Response.Payload + ); + Private->Payload =3D 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 +RedfishResourceConsumeResource ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN CHAR8 *Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + + if (This =3D=3D NULL || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); + + if (Private->RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + return Status; + } + + Private->Uri =3D Uri; + Private->Payload =3D Response.Payload; + ASSERT (Private->Payload !=3D NULL); + + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Payload= ), EDKII_JSON_COMPACT); + ASSERT (Private->Json !=3D NULL); + + Status =3D RedfishConsumeResourceCommon (Private, Private->Json); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to consume resource from: %a %r\n", _= _FUNCTION__, Uri, Status)); + } + + // + // Release resource + // + if (Private->Payload !=3D NULL) { + RedfishFreeResponse ( + Response.StatusCode, + Response.HeaderCount, + Response.Headers, + Response.Payload + ); + Private->Payload =3D NULL; + } + + if (Private->Json !=3D NULL) { + FreePool (Private->Json); + Private->Json =3D 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 +RedfishResourceGetInfo ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + OUT REDFISH_SCHEMA_INFO *Info + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + + if (This =3D=3D NULL || Info =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); + + 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 +RedfishResourceUpdate ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN CHAR8 *Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + + if (This =3D=3D NULL || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); + + if (Private->RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + return Status; + } + + Private->Uri =3D Uri; + Private->Payload =3D Response.Payload; + ASSERT (Private->Payload !=3D NULL); + + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Payload= ), EDKII_JSON_COMPACT); + ASSERT (Private->Json !=3D NULL); + + Status =3D RedfishUpdateResourceCommon (Private, Private->Json); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to update resource from: %a %r\n", __= FUNCTION__, Uri, Status)); + } + + // + // Release resource + // + if (Private->Payload !=3D NULL) { + RedfishFreeResponse ( + Response.StatusCode, + Response.HeaderCount, + Response.Headers, + Response.Payload + ); + Private->Payload =3D NULL; + } + + if (Private->Json !=3D NULL) { + FreePool (Private->Json); + Private->Json =3D 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 +RedfishResourceCheck ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN CHAR8 *Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + + if (This =3D=3D NULL || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); + + if (Private->RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + return Status; + } + + Private->Uri =3D Uri; + Private->Payload =3D Response.Payload; + ASSERT (Private->Payload !=3D NULL); + + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Payload= ), EDKII_JSON_COMPACT); + ASSERT (Private->Json !=3D NULL); + + Status =3D RedfishCheckResourceCommon (Private, Private->Json); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %a %r\n", __F= UNCTION__, Uri, Status)); + } + + // + // Release resource + // + if (Private->Payload !=3D NULL) { + RedfishFreeResponse ( + Response.StatusCode, + Response.HeaderCount, + Response.Headers, + Response.Payload + ); + Private->Payload =3D NULL; + } + + if (Private->Json !=3D NULL) { + FreePool (Private->Json); + Private->Json =3D NULL; + } + + return Status; +} + +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL mRedfishResourceConfig =3D { + RedfishResourceProvisioningResource, + RedfishResourceConsumeResource, + RedfishResourceUpdate, + RedfishResourceCheck, + 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_HA= NDLER_PROTOCOL instance. + @param[in] RedfishConfigServiceInfo Redfish service informaion. + + @retval EFI_SUCCESS The handler has been initialized su= ccessfully. + @retval EFI_DEVICE_ERROR Failed to create or configure the R= EST EX protocol instance. + @retval EFI_ALREADY_STARTED This handler has already been initi= alized. + @retval Other Error happens during the initializa= tion. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceInit ( + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This, + IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL (T= his); + + Private->RedfishService =3D RedfishCreateService (RedfishConfigServiceIn= fo); + if (Private->RedfishService =3D=3D 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 successful= ly. + @retval Others Some error happened. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceStop ( + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL (T= his); + + if (Private->Event !=3D NULL) { + gBS->CloseEvent (Private->Event); + Private->Event =3D NULL; + } + + if (Private->RedfishService !=3D NULL) { + RedfishCleanupService (Private->RedfishService); + Private->RedfishService =3D NULL; + } + + if (Private->Payload !=3D NULL) { + RedfishCleanupPayload (Private->Payload); + Private->Payload =3D NULL; + } + + return EFI_SUCCESS; +} + +EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL mRedfishConfigHandler =3D { + 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 =3D=3D NULL) { + return; + } + + if (mRedfishResourcePrivate->JsonStructProtocol !=3D NULL) { + return; + } + + Status =3D gBS->LocateProtocol ( + &gEfiRestJsonStructureProtocolGuid, + NULL, + (VOID **)&mRedfishResourcePrivate->JsonStructProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to locate gEfiRestJsonStructureProtoc= olGuid: %r\n", __FUNCTION__, Status)); + } + + gBS->CloseEvent (Event); +} + +/** + Unloads an image. + + @param ImageHandle Handle that identifies the image to be unl= oaded. + + @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 =3D=3D NULL) { + return EFI_NOT_READY; + } + + ConfigHandler =3D NULL; + + // + // Firstly, find ConfigHandler Protocol interface in this ImageHandle. + // + Status =3D gBS->OpenProtocol ( + ImageHandle, + &gEdkIIRedfishConfigHandlerProtocolGuid, + (VOID **) &ConfigHandler, + NULL, + NULL, + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL + ); + if (EFI_ERROR (Status) || ConfigHandler =3D=3D NULL) { + return Status; + } + + ConfigHandler->Stop (ConfigHandler); + + // + // Last, uninstall ConfigHandler Protocol and resource protocol. + // + Status =3D gBS->UninstallMultipleProtocolInterfaces ( + ImageHandle, + &gEdkIIRedfishConfigHandlerProtocolGuid, + ConfigHandler, + &gEdkIIRedfishResourceConfigProtocolGuid, + &mRedfishResourcePrivate->RedfishResourceConfig, + NULL + ); + + FreePool (mRedfishResourcePrivate); + mRedfishResourcePrivate =3D 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 includ= ing + 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 EFI_ACCESS_DENIED EFI_ISCSI_INITIATOR_NAME_PROTOCOL was inst= alled unexpectedly. + @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 !=3D NULL) { + return EFI_ALREADY_STARTED; + } + + mRedfishResourcePrivate =3D AllocateZeroPool (sizeof (REDFISH_RESOURCE_C= OMMON_PRIVATE)); + CopyMem (&mRedfishResourcePrivate->ConfigHandler, &mRedfishConfigHandler= , sizeof (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL)); + CopyMem (&mRedfishResourcePrivate->RedfishResourceConfig, &mRedfishResou= rceConfig, sizeof (EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL)); + + // + // Publish config handler protocol and resource protocol. + // + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &ImageHandle, + &gEdkIIRedfishConfigHandlerProtocolGuid, + &mRedfishResourcePrivate->ConfigHandler, + &gEdkIIRedfishResourceConfigProtocolGuid, + &mRedfishResourcePrivate->RedfishResourceConfig, + NULL + ); + + EfiCreateProtocolNotifyEvent ( + &gEfiRestJsonStructureProtocolGuid, + TPL_CALLBACK, + EfiRestJasonStructureProtocolIsReady, + NULL, + &Registration + ); + + return Status; +} diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.c b/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/= RedfishMemoryCollectionDxe.c new file mode 100644 index 00000000000..d97f0f161ee --- /dev/null +++ b/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.c @@ -0,0 +1,652 @@ +/** @file + Redfish feature driver implementation - memory collection + + (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "RedfishMemoryCollectionDxe.h" + +REDFISH_COLLECTION_PRIVATE *mRedfishCollectionPrivate =3D NULL; + +EFI_STATUS +ProcessResource ( + IN REDFISH_COLLECTION_PRIVATE *Private, + IN CHAR8 *Uri + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol; + REDFISH_SCHEMA_INFO SchemaInfo; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %a\n", __FUNCTIO= N__, Uri)); + + Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, &SchemaInfo); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %a %r= \n", __FUNCTION__, Uri, Status)); + return Status; + } + + RedfishResrouceProtocol =3D GetRedfishResourceConfigProtocol ( + SchemaInfo.Schema, + SchemaInfo.Major, + SchemaInfo.Minor, + SchemaInfo.Errata + ); + if (RedfishResrouceProtocol =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + + // + // Check and see if target property exist or not even when collection me= meber exists. + // If not, we sill do provision. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %a\n", __FUNCTION__, Uri)); + Status =3D RedfishResrouceProtocol->Check ( + RedfishResrouceProtocol, + Uri + ); + if (EFI_ERROR (Status)) { + // + // The target property does not exist, do the provision to create prop= erty. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %a\n", __FUNCTION__, Ur= i)); + Status =3D RedfishResrouceProtocol->Provisioning ( + RedfishResrouceProtocol, + Uri, + FALSE + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", = __FUNCTION__, Status)); + } + + return Status; + } + + // + // Consume first. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %a\n", __FUNCTION__, Uri)); + Status =3D RedfishResrouceProtocol->Consume ( + RedfishResrouceProtocol, + Uri + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %a %r\n", __= FUNCTION__, Uri, Status)); + } + + // + // Patch. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %a\n", __FUNCTION__, Uri)); + Status =3D RedfishResrouceProtocol->Update ( + RedfishResrouceProtocol, + Uri + ); + + return Status; +} + +EFI_STATUS +ProcessCollection ( + IN REDFISH_COLLECTION_PRIVATE *Private + ) +{ + EFI_STATUS Status; + EFI_REDFISH_MEMORYCOLLECTION *Memory; + EFI_REDFISH_MEMORYCOLLECTION_CS *CollectionCs; + RedfishCS_Link *List; + RedfishCS_Header *Header; + RedfishCS_Type_Uri_Data *UriData; + CHAR8 *ConfigureLang; + UINTN Size; + UINTN Count; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Private->JsonStructProtocol =3D=3D NULL || Private->CollectionJson = =3D=3D NULL) { + return EFI_NOT_READY; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %a\n", __FUNCT= ION__, Private->CollectionPath)); + + // + // Convert JSON text to C structure. + // + Status =3D Private->JsonStructProtocol->ToStructure ( + Private->JsonStructProtocol, + NULL, + Private->CollectionJson, + (EFI_REST_JSON_STRUCTURE_HEADER = **)&Memory + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return Status; + } + + CollectionCs =3D Memory->MemoryCollection; + + if (*CollectionCs->Membersodata_count =3D=3D 0) { + return EFI_NOT_FOUND; + } + + if (IsLinkEmpty (&CollectionCs->Members)) { + return EFI_NOT_FOUND; + } + + Count =3D 0; + List =3D GetFirstLink (&CollectionCs->Members); + while (TRUE) { + + Header =3D (RedfishCS_Header *)List; + if (Header->ResourceType =3D=3D RedfishCS_Type_Uri) { + UriData =3D (RedfishCS_Type_Uri_Data *)Header; + + ++Count; + Size =3D AsciiStrLen (Private->CollectionPath) + 5; + ConfigureLang =3D AllocatePool (Size); + ASSERT (ConfigureLang !=3D NULL); + AsciiSPrint (ConfigureLang, Size, "%a[%d]", Private->CollectionPath,= Count); + + Status =3D ProcessResource (Private, ConfigureLang); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, process memory resource: %a failed: %r\n= ", __FUNCTION__, UriData->Uri, Status)); + } + } + + if (IsLinkAtEnd (&CollectionCs->Members, List)) { + break; + } + + List =3D GetNextLink (&CollectionCs->Members, List); + } + + // + // Release resource. + // + Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Memory); + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateCollection ( + IN REDFISH_COLLECTION_PRIVATE *Private + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol; + REDFISH_SCHEMA_INFO SchemaInfo; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %a= \n", __FUNCTION__, Private->CollectionPath)); + + Status =3D GetSupportedSchemaVersion (REDFISH_SCHEMA_NAME, &SchemaInfo); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to find supported schema from HII dat= abase: %r\n", __FUNCTION__, Status)); + return Status; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a %a.%a.%a\n", __FU= NCTION__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo= .Errata)); + + RedfishResrouceProtocol =3D GetRedfishResourceConfigProtocol (SchemaInfo= .Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Errata); + if (RedfishResrouceProtocol =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + + Status =3D RedfishResrouceProtocol->Provisioning ( + RedfishResrouceProtocol, + Private->CollectionPath, + TRUE + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %a %r\n", __F= UNCTION__, Private->CollectionPath, Status)); + } + + return Status; +} + +EFI_STATUS +ReleaseCollectionResource ( + IN REDFISH_COLLECTION_PRIVATE *Private + ) +{ + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Release resource + // + if (Private->RedResponse.Payload !=3D NULL) { + RedfishFreeResponse ( + Private->RedResponse.StatusCode, + Private->RedResponse.HeaderCount, + Private->RedResponse.Headers, + Private->RedResponse.Payload + ); + Private->RedResponse.StatusCode =3D NULL; + Private->RedResponse.HeaderCount =3D 0; + Private->RedResponse.Headers =3D NULL; + Private->RedResponse.Payload =3D NULL; + } + + if (Private->CollectionJson !=3D NULL) { + FreePool (Private->CollectionJson); + Private->CollectionJson =3D NULL; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +CollectionHandler ( + IN REDFISH_COLLECTION_PRIVATE *Private + ) +{ + EFI_STATUS Status; + CHAR8 *SystemRootPath; + CHAR8 *PathBuffer; + UINTN BufferSize; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + SystemRootPath =3D NULL; + PathBuffer =3D NULL; + + SystemRootPath =3D RedfishGetSystemRootPath (); + if (SystemRootPath =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, can not find system root path\n", __FUNCTION= __)); + return EFI_DEVICE_ERROR; + } + + BufferSize =3D AsciiStrSize (SystemRootPath) + AsciiStrSize (REDFISH_SCH= EMA_NAME); + PathBuffer =3D AllocatePool (BufferSize); + if (PathBuffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_RELEASE; + } + + AsciiSPrint (PathBuffer, BufferSize, "%a/%a", SystemRootPath, REDFISH_SC= HEMA_NAME); + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %a\n", __FUNCTI= ON__, PathBuffer)); + + // + // Initialize collection path + // + Private->CollectionPath =3D RedfishBuildPathWithSystemUuid (PathBuffer, = TRUE, NULL); + if (Private->CollectionPath =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_RELEASE; + } + + // + // Query collection from Redfish service. + // + Status =3D GetResourceByPath (Private->RedfishService, Private->Collecti= onPath, &Private->RedResponse); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %a :%r\n", __FU= NCTION__, Private->CollectionPath, Status)); + goto ON_RELEASE; + } + + Private->CollectionPayload =3D Private->RedResponse.Payload; + ASSERT (Private->CollectionPayload !=3D NULL); + + Private->CollectionJson =3D JsonDumpString (RedfishJsonInPayload (Privat= e->CollectionPayload), EDKII_JSON_COMPACT); + ASSERT (Private->CollectionJson !=3D NULL); + + Status =3D ProcessCollection (Private); + if (EFI_ERROR (Status) && Status =3D=3D EFI_NOT_FOUND) { + Status =3D CreateCollection (Private); + } + +ON_RELEASE: + + if (SystemRootPath !=3D NULL) { + FreePool (SystemRootPath); + } + + if (PathBuffer !=3D NULL) { + FreePool (PathBuffer); + } + + ReleaseCollectionResource (Private); + + return Status; +} + +/** + The callback function provided by Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROT= OCOL instance. + @param[in] FeatureAction The action Redfish feature driver sho= uld take. + @param[in] Context The context of Redfish feature driver. + @param[in,out] InformationReturned The pointer to retrive the pointer to + FEATURE_RETURNED_INFOMATION. The memo= ry block of this + information should be freed by caller. + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. + +**/ +EFI_STATUS +EFIAPI +RedfishCollectionFeatureCallback ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN FEATURE_CALLBACK_ACTION FeatureAction, + IN VOID *Context, + IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned + ) +{ + EFI_STATUS Status; + REDFISH_SERVICE RedfishService; + REDFISH_COLLECTION_PRIVATE *Private; + + if (FeatureAction !=3D CallbackActionStartOperation) { + return EFI_UNSUPPORTED; + } + + Private =3D (REDFISH_COLLECTION_PRIVATE *)Context; + + RedfishService =3D Private->RedfishService; + if (RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + Status =3D CollectionHandler (Private); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, CollectionHandler failure: %r\n", __FUNCTION= __, Status)); + } + + return EFI_SUCCESS; +} + +/** + 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_HA= NDLER_PROTOCOL instance. + @param[in] RedfishConfigServiceInfo Redfish service informaion. + + @retval EFI_SUCCESS The handler has been initialized su= ccessfully. + @retval EFI_DEVICE_ERROR Failed to create or configure the R= EST EX protocol instance. + @retval EFI_ALREADY_STARTED This handler has already been initi= alized. + @retval Other Error happens during the initializa= tion. + +**/ +EFI_STATUS +EFIAPI +RedfishCollectionInit ( + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This, + IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo + ) +{ + REDFISH_COLLECTION_PRIVATE *Private; + + Private =3D REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL (This); + + Private->RedfishService =3D RedfishCreateService (RedfishConfigServiceIn= fo); + if (Private->RedfishService =3D=3D 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 successful= ly. + @retval Others Some error happened. + +**/ +EFI_STATUS +EFIAPI +RedfishCollectionStop ( + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This + ) +{ + REDFISH_COLLECTION_PRIVATE *Private; + + Private =3D REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL (This); + + if (Private->RedfishService !=3D NULL) { + RedfishCleanupService (Private->RedfishService); + Private->RedfishService =3D NULL; + } + + ReleaseCollectionResource (Private); + + if (Private->FeatureProtocol !=3D NULL) { + Private->FeatureProtocol->Unregister ( + Private->FeatureProtocol, + REDFISH_MANAGED_URI, + NULL + ); + } + + return EFI_SUCCESS; +} + +/** + 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 (mRedfishCollectionPrivate =3D=3D NULL) { + return; + } + + if (mRedfishCollectionPrivate->JsonStructProtocol !=3D NULL) { + return; + } + + Status =3D gBS->LocateProtocol ( + &gEfiRestJsonStructureProtocolGuid, + NULL, + (VOID **)&mRedfishCollectionPrivate->JsonStructProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to locate gEfiRestJsonStructureProtoc= olGuid: %r\n", __FUNCTION__, Status)); + } + + gBS->CloseEvent (Event); +} + +/** + Callback function when gEdkIIRedfishFeatureProtocolGuid is installed. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. +**/ +VOID +EFIAPI +EdkIIRedfishFeatureProtocolIsReady + ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol; + + if (mRedfishCollectionPrivate =3D=3D NULL) { + return; + } + + if (mRedfishCollectionPrivate->FeatureProtocol !=3D NULL) { + return; + } + + Status =3D gBS->LocateProtocol ( + &gEdkIIRedfishFeatureProtocolGuid, + NULL, + (VOID **)&FeatureProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to locate gEdkIIRedfishFeatureProtoco= lGuid: %r\n", __FUNCTION__, Status)); + gBS->CloseEvent (Event); + return; + } + + Status =3D FeatureProtocol->Register ( + FeatureProtocol, + REDFISH_MANAGED_URI, + RedfishCollectionFeatureCallback, + (VOID *)mRedfishCollectionPrivate + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to register %s: %r\n", __FUNCTION__, = REDFISH_MANAGED_URI, Status)); + } + + mRedfishCollectionPrivate->FeatureProtocol =3D FeatureProtocol; + + gBS->CloseEvent (Event); +} + +/** + Unloads an image. + + @param ImageHandle Handle that identifies the image to be unl= oaded. + + @retval EFI_SUCCESS The image has been unloaded. + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +EFI_STATUS +EFIAPI +RedfishCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; + + if (mRedfishCollectionPrivate =3D=3D NULL) { + return EFI_NOT_READY; + } + + ConfigHandler =3D NULL; + + // + // Firstly, find ConfigHandler Protocol interface in this ImageHandle. + // + Status =3D gBS->OpenProtocol ( + ImageHandle, + &gEdkIIRedfishConfigHandlerProtocolGuid, + (VOID **) &ConfigHandler, + NULL, + NULL, + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL + ); + if (EFI_ERROR (Status) || ConfigHandler =3D=3D NULL) { + return Status; + } + + ConfigHandler->Stop (ConfigHandler); + + // + // Last, uninstall ConfigHandler Protocol. + // + Status =3D gBS->UninstallMultipleProtocolInterfaces ( + ImageHandle, + &gEdkIIRedfishConfigHandlerProtocolGuid, + ConfigHandler, + NULL + ); + + FreePool (mRedfishCollectionPrivate); + mRedfishCollectionPrivate =3D NULL; + + return Status; +} + +EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL mRedfishConfigHandler =3D { + RedfishCollectionInit, + RedfishCollectionStop +}; + +/** + 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 includ= ing + 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 EFI_ACCESS_DENIED EFI_ISCSI_INITIATOR_NAME_PROTOCOL was inst= alled unexpectedly. + @retval Others Other errors as indicated. +**/ +EFI_STATUS +EFIAPI +RedfishCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + VOID *Registration; + + if (mRedfishCollectionPrivate !=3D NULL) { + return EFI_ALREADY_STARTED; + } + + mRedfishCollectionPrivate =3D AllocateZeroPool (sizeof (REDFISH_COLLECTI= ON_PRIVATE)); + CopyMem (&mRedfishCollectionPrivate->ConfigHandler, &mRedfishConfigHandl= er, sizeof (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL)); + + Status =3D gBS->InstallProtocolInterface ( + &ImageHandle, + &gEdkIIRedfishConfigHandlerProtocolGuid, + EFI_NATIVE_INTERFACE, + &mRedfishCollectionPrivate->ConfigHandler + ); + + EfiCreateProtocolNotifyEvent ( + &gEfiRestJsonStructureProtocolGuid, + TPL_CALLBACK, + EfiRestJasonStructureProtocolIsReady, + NULL, + &Registration + ); + + EfiCreateProtocolNotifyEvent ( + &gEdkIIRedfishFeatureProtocolGuid, + TPL_CALLBACK, + EdkIIRedfishFeatureProtocolIsReady, + NULL, + &Registration + ); + + return Status; +} diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index f1adc7a8397..cc0da2611cd 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -13,4 +13,6 @@ !if $(REDFISH_CLIENT) =3D=3D TRUE INF RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf INF RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf + INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf + INF RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCo= llectionDxe.inf !endif --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82811): https://edk2.groups.io/g/devel/message/82811 Mute This Topic: https://groups.io/mt/86652838/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-