From nobody Fri Apr 26 08:47:54 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+91869+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+91869+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885890; cv=none; d=zohomail.com; s=zohoarc; b=ZNHSJBZRwi9M+zNMHPWdxwUVYfkXvtDDmGuBWuBxwrL9gFf7Ag6ysCrmfmL9avleI5vlLmDljGs9ssuPXAOxD+zHrb2c1MrVT57FQDvMzmiYxj4HARt6KRCQyQBwrrBEq8R89AT5Z4wjm9xWBTTNhaBS61x+8nVDAkgvn0T7Sh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885890; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=9Ga+u6mYxuUG7BfNsVuee/rP7x6FWZV0P/fXMqxrUE4=; b=ZtP4hEzBFcUEueLmTNKgpeACe5wmimlLy/mkcIvy9Ssuymx3kxW5JqNmZvwrzCtir+N7VrgNd+WGoX7X8bPAlmL4ohFgu5qAJBaiLb0B97Q9afyUc8bhd7hsd/PV20Bdk4Jqogj7KEWYAnZ6EoSXAPCBs6fqrTid3W8VyTSXQ4Y= 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+91869+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 1658885890497718.4998124670836; Tue, 26 Jul 2022 18:38:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OduKYY1788612xRykrycIbPz; Tue, 26 Jul 2022 18:38:10 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.14957.1658885889056223104 for ; Tue, 26 Jul 2022 18:38:09 -0700 X-Received: from pps.filterd (m0148664.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0q5dn030516; Wed, 27 Jul 2022 01:38:07 GMT X-Received: from p1lg14881.it.hpe.com (p1lg14881.it.hpe.com [16.230.97.202]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjew9xsq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:06 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id E724C804C8B; Wed, 27 Jul 2022 01:38:05 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id A7B178052EB; Wed, 27 Jul 2022 01:38:04 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 01/15] edk2-staging/RedfishClientPkg: Introduce Redfish event library Date: Wed, 27 Jul 2022 09:37:48 +0800 Message-Id: <20220727013802.247-2-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: CsX0TUwm9BUKNrHJFgyIY-YtPF61mKbD X-Proofpoint-GUID: CsX0TUwm9BUKNrHJFgyIY-YtPF61mKbD 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,nickle.wang@hpe.com X-Gm-Message-State: 1BhZhLLqmasLR7N4roA43L2Rx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885890; bh=p908bBLltmTI4WR1hikbugSy96F+6JUmTSvyoreDu+M=; h=Cc:Date:From:Reply-To:Subject:To; b=H8TfPwMXVG2f59btWvV59gS119NLtnioUohajTFOhyzCI06jFnauEKQJqNWSGzTcx5u eHvRuYReGAFjUovnALbYbor+gqc3aqBHUz0KX7ZE0WZ3L8XpKtk0B7+A6ZRGVfwAAZ5X7 ewBk3y5WNIoJ4P2fjnoLhbNUum896nppNU4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885891020100005 Content-Type: text/plain; charset="utf-8" Add RedfishEventLib to handle Redfish event. There are two events defined in this library. One is the event before feature driver provisioning and the other one is the event after all provisioning is finished. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez --- .../Include/Guid/RedfishClientEventGroup.h | 27 ++++ .../Include/Library/RedfishEventLib.h | 77 ++++++++++ .../Library/RedfishEventLib/RedfishEventLib.c | 139 ++++++++++++++++++ .../RedfishEventLib/RedfishEventLib.inf | 42 ++++++ RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + RedfishClientPkg/RedfishClientPkg.dec | 5 + 6 files changed, 291 insertions(+) create mode 100644 RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h create mode 100644 RedfishClientPkg/Include/Library/RedfishEventLib.h create mode 100644 RedfishClientPkg/Library/RedfishEventLib/RedfishEventLi= b.c create mode 100644 RedfishClientPkg/Library/RedfishEventLib/RedfishEventLi= b.inf diff --git a/RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h b/Redf= ishClientPkg/Include/Guid/RedfishClientEventGroup.h new file mode 100644 index 0000000000..0d88dd4726 --- /dev/null +++ b/RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h @@ -0,0 +1,27 @@ +/** @file + GUID for Redfish Client Event Group GUID + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_CLIENT_EVENT_GROUP_GUID_H_ +#define REDFISH_CLIENT_EVENT_GROUP_GUID_H_ + +#define REDFISH_CLIENT_FEATURE_READY_TO_PROVISIONING_GUID \ + { \ + 0x77E4FC1C, 0x2428, 0x47EE, { 0x9E, 0xEC, 0x8B, 0x77, 0xEF, 0x9D, 0x4E= , 0xF0 } \ + } + +extern EFI_GUID gEfiRedfishClientFeatureReadyToProvisioningGuid; + +#define REDFISH_CLIENT_FEATURE_AFTER_PROVISIONING_GUID \ + { \ + 0xE547CB6F, 0x306F, 0x4226, { 0xAB, 0x70, 0xA0, 0x6E, 0x26, 0xF1, 0x2E= , 0xD0 } \ + } + +extern EFI_GUID gEfiRedfishClientFeatureAfterProvisioningGuid; + +#endif diff --git a/RedfishClientPkg/Include/Library/RedfishEventLib.h b/RedfishCl= ientPkg/Include/Library/RedfishEventLib.h new file mode 100644 index 0000000000..1f3d0acf19 --- /dev/null +++ b/RedfishClientPkg/Include/Library/RedfishEventLib.h @@ -0,0 +1,77 @@ +/** @file + This file defines the Redfish event library interface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_EVENT_LIB_H_ +#define REDFISH_EVENT_LIB_H_ + +#include + +/** + Create an EFI event before Redfish provisioning start. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateReadyToProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ); + +/** + Create an EFI event after Redfish provisioning finished. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateAfterProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ); + +/** + Signal ready to provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalReadyToProvisioningEvent ( + IN VOID + ); + +/** + Signal after provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalAfterProvisioningEvent ( + IN VOID + ); + +#endif diff --git a/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c b/R= edfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c new file mode 100644 index 0000000000..0a8483c371 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c @@ -0,0 +1,139 @@ +/** @file + Redfish event library to deliver Redfish specific event. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include + +#include +#include +#include +#include +#include + +/** + Create an EFI event before Redfish provisioning start. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateReadyToProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ) +{ + EFI_STATUS Status; + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (NotifyFunction =3D=3D NULL ? EfiEventEmptyFunction : No= tifyFunction), + NotifyContext, + &gEfiRedfishClientFeatureReadyToProvisioningGuid, + ReadyToProvisioningEvent + ); + + return Status; +} + +/** + Create an EFI event after Redfish provisioning finished. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateAfterProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ) +{ + EFI_STATUS Status; + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (NotifyFunction =3D=3D NULL ? EfiEventEmptyFunction : No= tifyFunction), + NotifyContext, + &gEfiRedfishClientFeatureAfterProvisioningGuid, + ReadyToProvisioningEvent + ); + + return Status; +} + +/** + Signal ready to provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalReadyToProvisioningEvent ( + IN VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + Status =3D CreateReadyToProvisioningEvent (NULL, NULL, &Event); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to create after provisioning event\n"= , __FUNCTION__)); + return Status; + } + + gBS->SignalEvent (Event); + gBS->CloseEvent (Event); + + return EFI_SUCCESS; +} + +/** + Signal after provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalAfterProvisioningEvent ( + IN VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + Status =3D CreateAfterProvisioningEvent (NULL, NULL, &Event); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to create after provisioning event\n"= , __FUNCTION__)); + return Status; + } + + gBS->SignalEvent (Event); + gBS->CloseEvent (Event); + + return EFI_SUCCESS; +} + diff --git a/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf b= /RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf new file mode 100644 index 0000000000..a9d475c27c --- /dev/null +++ b/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf @@ -0,0 +1,42 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishEventLib + FILE_GUID =3D C4F7E27D-2338-43EA-9D1F-D10960E36521 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishEventLib| DXE_DRIVER UEFI_DRIV= ER + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + RedfishEventLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + UefiLib + +[Protocols] + +[Pcd] + +[Guids] + gEfiRedfishClientFeatureReadyToProvisioningGuid + gEfiRedfishClientFeatureAfterProvisioningGuid diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 5467acedd0..ce1c27d884 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -28,3 +28,4 @@ RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/R= edfishContentCodingLibNull.inf ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf =20 + RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib= .inf diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 09df062dd3..39b2f5baf8 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -21,6 +21,7 @@ =20 [LibraryClasses] RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h + RedfishEventLib|Include/Library/RedfishEventLib.h =20 [LibraryClasses.Common.Private] ## @libraryclass Redfish Helper Library @@ -39,6 +40,10 @@ ## Include/Guid/RedfishClientPkgTokenSpace.h gEfiRedfishClientPkgTokenSpaceGuid =3D { 0x8c444dae, 0x728b, 0x48ee, = { 0x9e, 0x19, 0x8f, 0x0a, 0x3d, 0x4e, 0x9c, 0xc8 } } =20 + ## Include/Guid/RedfishClientEventGroup.h + gEfiRedfishClientFeatureReadyToProvisioningGuid =3D { 0x77E4FC1C, 0x2428= , 0x47EE, { 0x9E, 0xEC, 0x8B, 0x77, 0xEF, 0x9D, 0x4E, 0xF0 } } + gEfiRedfishClientFeatureAfterProvisioningGuid =3D { 0xE547CB6F, 0x306F= , 0x4226, { 0xAB, 0x70, 0xA0, 0x6E, 0x26, 0xF1, 0x2E, 0xD0 } } + [PcdsFixedAtBuild] gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|UINT= 32|0x10000001 gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|UINT= 32|0x10000002 --=20 2.32.0.windows.2 -=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 (#91869): https://edk2.groups.io/g/devel/message/91869 Mute This Topic: https://groups.io/mt/92641641/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- From nobody Fri Apr 26 08:47:54 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+91870+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+91870+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885891; cv=none; d=zohomail.com; s=zohoarc; b=eqWEWdUseh/9zV9x3g+AOgJQ91EmLenAtKLObFaT0SZ3R+anKg4waLbgeX1AsOe4KorQeL8J8Kf7zgYnztfkBTqRLOGh2ObC9K6XLjBzaJDJ7dRQ/59MmnCXn1bBtsIHrqP3CiqV1m/+Owrq/48YytQFaaGAtvzzJsaszDog9kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885891; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=7eejuBqbTI9uTWzSBI6asqMlSkXKIz1NJAwZ8R0kWTI=; b=HRqdnDBScSGOqFSsgQJiHub2ltwstgySYV/NbAMQ5OkKfnf8neTBRUUXmfWacGRyCFHLa2sXIauMfXQM4mAsF6RiEGIxhX2oa5QJ7W+AGsAOhgxZGsouHFD6ogsoMPVJBTwVPMC1o7Sp/WYbuv/n0lb/4Tdc+FcK5XFUAI8RVaU= 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+91870+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 1658885891388695.4263923128593; Tue, 26 Jul 2022 18:38:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BFf0YY1788612xxLxg65FRIl; Tue, 26 Jul 2022 18:38:11 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.14920.1658885890078041669 for ; Tue, 26 Jul 2022 18:38:10 -0700 X-Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R1RqDM028491; Wed, 27 Jul 2022 01:38:08 GMT X-Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjuqk82f2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:08 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id 8D88A800E83; Wed, 27 Jul 2022 01:38:07 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 4EC2F8052CC; Wed, 27 Jul 2022 01:38:06 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 02/15] edk2-staging/RedfishClientPkg: Introduce Redfish version library Date: Wed, 27 Jul 2022 09:37:49 +0800 Message-Id: <20220727013802.247-3-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 77A_-oOCp4jREwTIUO4jVOjHR4FABxmF X-Proofpoint-GUID: 77A_-oOCp4jREwTIUO4jVOjHR4FABxmF 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,nickle.wang@hpe.com X-Gm-Message-State: 6iVTgO8nyDBOLx3AqPWnaUMex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885891; bh=c9y4JuUO5EuJgxiHCIGYy3oRYzE4XtNj+pMb5fvSxZU=; h=Cc:Date:From:Reply-To:Subject:To; b=b4L5tNT/kim7X+TRKXmLnqbm9fcu3FCAVb/MbMd/nXqHkqgr+vA/3O94SdkFT+tcD+M lQXIVllrCFmbP0FJguBwm+n4JERn25KVCbBNrkouMRnT2babG8Ma5MZUPDe0PD62Z/2TT 4zqQTs5DlM1pTFQoWZLhCzUBKKnRxNvBdFg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885893020100011 Content-Type: text/plain; charset="utf-8" Add RedfishVersionLib in order to get Redfish version hosted at BMC. When there is trouble to get Redfish support version, the default version is retrieved from pre-defined PCD value. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez --- .../Include/Library/RedfishVersionLib.h | 30 +++ RedfishClientPkg/Include/RedfishBase.h | 21 ++ .../RedfishVersionLib/RedfishVersionLib.c | 203 ++++++++++++++++++ .../RedfishVersionLib/RedfishVersionLib.inf | 50 +++++ RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + RedfishClientPkg/RedfishClientPkg.dec | 4 +- 6 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/Include/Library/RedfishVersionLib.h create mode 100644 RedfishClientPkg/Include/RedfishBase.h create mode 100644 RedfishClientPkg/Library/RedfishVersionLib/RedfishVersi= onLib.c create mode 100644 RedfishClientPkg/Library/RedfishVersionLib/RedfishVersi= onLib.inf diff --git a/RedfishClientPkg/Include/Library/RedfishVersionLib.h b/Redfish= ClientPkg/Include/Library/RedfishVersionLib.h new file mode 100644 index 0000000000..319f22bd37 --- /dev/null +++ b/RedfishClientPkg/Include/Library/RedfishVersionLib.h @@ -0,0 +1,30 @@ +/** @file + This file defines the Redfish version Library interface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_VERSION_LIB_H_ +#define REDFISH_VERSION_LIB_H_ + +/** + Query HTTP request to BMC with given redfish service and return redfish + version information. If there is troulbe to get Redfish version on BMC, + The value of PcdDefaultRedfishVersion is returned. + + It's call responsibility to release returned buffer. + + @param[in] Service Redfish service instance + + @retval EFI_STRING Redfish version string. NULL while error occurs. + +**/ +EFI_STRING +RedfishGetVersion ( + IN REDFISH_SERVICE *Service + ); + +#endif diff --git a/RedfishClientPkg/Include/RedfishBase.h b/RedfishClientPkg/Incl= ude/RedfishBase.h new file mode 100644 index 0000000000..cf320bb0eb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishBase.h @@ -0,0 +1,21 @@ +/** @file + Redfish base header file. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EFI_REDFISH_BASE_H_ +#define EFI_REDFISH_BASE_H_ + +#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') +#define REDFISH_DEBUG_TRACE DEBUG_INFO + +/// +/// This GUID is used for an EFI Variable that stores the Redfish data. +/// +EFI_GUID mRedfishVariableGuid =3D {0x91c46a3d, 0xed1a, 0x477b, {0xa5, 0x33= , 0x87, 0x2d, 0xcd, 0xb0, 0xfc, 0xc1}}; + +#endif diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c= b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c new file mode 100644 index 0000000000..0a2ace7726 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c @@ -0,0 +1,203 @@ +/** @file + Redfish version library implementation + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define REDFISH_VERSION_DEFAULT_STRING L"v1" +#define REDFISH_ROOT_URI "/redfish" + +REDFISH_SERVICE *mCacheService; +EFI_STRING mVersionCache; +UINTN mVersionStringSize; + +/** + Cache the redfish service version for later use so we don't have to query + HTTP request everytime. + + @param[in] Service Redfish service instance + @param[in] Version Version string to cache + + @retval EFI_SUCCESS Version is saved in cache successfully. + @retval Others + +**/ +EFI_STATUS +CacheVersion ( + IN REDFISH_SERVICE *Service, + IN EFI_STRING Version + ) +{ + if (Service =3D=3D NULL || IS_EMPTY_STRING (Version)) { + return EFI_INVALID_PARAMETER; + } + + if (mCacheService =3D=3D Service) { + return EFI_ALREADY_STARTED; + } + + mCacheService =3D Service; + if (mVersionCache !=3D NULL) { + FreePool (mVersionCache); + } + + mVersionStringSize =3D StrSize (Version); + mVersionCache =3D AllocateCopyPool (mVersionStringSize, Version); + if (mVersionCache =3D=3D NULL) { + mCacheService =3D NULL; + return EFI_OUT_OF_RESOURCES; + } + + return EFI_SUCCESS; +} + +/** + Query HTTP request to BMC with given redfish service and return redfish + version information. If there is troulbe to get Redfish version on BMC, + The value of PcdDefaultRedfishVersion is returned. + + It's call responsibility to release returned buffer. + + @param[in] Service Redfish service instance + + @retval EFI_STRING Redfish version string. NULL while error occurs. + +**/ +EFI_STRING +RedfishGetVersion ( + IN REDFISH_SERVICE *Service + ) +{ + EFI_STATUS Status; + EFI_STRING VersionString; + REDFISH_RESPONSE Response; + EDKII_JSON_VALUE JsonValue; + EDKII_JSON_VALUE N; + CHAR8 *Key; + EDKII_JSON_VALUE Value; + + VersionString =3D NULL; + + if (Service =3D=3D NULL) { + goto ON_ERROR; + } + + // + // Use cache to prevent HTTP connection. + // + if (Service =3D=3D mCacheService) { + return AllocateCopyPool (mVersionStringSize, mVersionCache); + } + + // + // Get resource from redfish service. + // + Status =3D RedfishGetByUri ( + Service, + REDFISH_ROOT_URI, + &Response + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, RedfishGetByService to %a failed: %r\n", __F= UNCTION__, REDFISH_ROOT_URI, Status)); + if (Response.Payload !=3D NULL) { + RedfishDumpPayload (Response.Payload); + RedfishFreeResponse ( + NULL, + 0, + NULL, + Response.Payload + ); + Response.Payload =3D NULL; + } + + goto ON_ERROR; + } + + JsonValue =3D RedfishJsonInPayload (Response.Payload); + if (JsonValue =3D=3D NULL || !JsonValueIsObject (JsonValue)) { + goto ON_ERROR; + } + + EDKII_JSON_OBJECT_FOREACH_SAFE (JsonValue, N, Key, Value) { + if (Key[0] =3D=3D 'v' && JsonValueIsString (Value)) { + VersionString =3D JsonValueGetUnicodeString (Value); + break; + } + } + + if (VersionString !=3D NULL) { + CacheVersion (Service, VersionString); + return VersionString; + } + +ON_ERROR: + + VersionString =3D (CHAR16 *)PcdGetPtr (PcdDefaultRedfishVersion); + if (VersionString =3D=3D NULL) { + VersionString =3D REDFISH_VERSION_DEFAULT_STRING; + } + + return AllocateCopyPool (StrSize (VersionString), VersionString); +} + +/** + + Initial redfish version library instace. + + @param[in] ImageHandle The image handle. + @param[in] SystemTable The system table. + + @retval EFI_SUCEESS Install Boot manager menu success. + @retval Other Return error status. + +**/ +EFI_STATUS +EFIAPI +RedfishVersionLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + mCacheService =3D NULL; + mVersionCache =3D NULL; + mVersionStringSize =3D 0; + + return EFI_SUCCESS; +} + + +/** + Release allocated resource. + + @param[in] ImageHandle Handle that identifies the image to be unlo= aded. + @param[in] SystemTable The system table. + + @retval EFI_SUCCESS The image has been unloaded. + +**/ +EFI_STATUS +EFIAPI +RedfishVersionLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + if (mVersionCache !=3D NULL) { + FreePool (mVersionCache); + } + + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.i= nf b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf new file mode 100644 index 0000000000..34d13d64f1 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf @@ -0,0 +1,50 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishVersionLib + FILE_GUID =3D 396A7508-B611-49F7-9C81-DAD96B526B61 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishVersionLib| DXE_DRIVER + CONSTRUCTOR =3D RedfishVersionLibConstructor + DESTRUCTOR =3D RedfishVersionLibDestructor + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + RedfishVersionLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + MemoryAllocationLib + PcdLib + RedfishLib + JsonLib + +[Protocols] + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion + +[BuildOptions] + # + # NOTE: /wd4706 disables the following Visual Studio compiler warning in= Jansson: + # "C4706: assignment within conditional expression" + # + MSFT:*_*_*_CC_FLAGS =3D /wd4706 diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index ce1c27d884..1cf0406912 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -29,3 +29,4 @@ ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf =20 RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib= .inf + RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVers= ionLib.inf diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 39b2f5baf8..2ce51d14af 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -22,6 +22,7 @@ [LibraryClasses] RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h RedfishEventLib|Include/Library/RedfishEventLib.h + RedfishVersionLib|Include/Library/RedfishVersionLib.h =20 [LibraryClasses.Common.Private] ## @libraryclass Redfish Helper Library @@ -52,4 +53,5 @@ # { 0x7CE88FB3, 0x4BD7, 0x4679, { 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, 0x= 0D, 0x2B }} # gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEv= entGuid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8, = 0xD8, 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x10000003 - + ## Default Redfish version string + gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID*|= 0x10000004 --=20 2.32.0.windows.2 -=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 (#91870): https://edk2.groups.io/g/devel/message/91870 Mute This Topic: https://groups.io/mt/92641642/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- From nobody Fri Apr 26 08:47:54 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+91871+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+91871+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885893; cv=none; d=zohomail.com; s=zohoarc; b=TEvpRkiKdXVPC/8DpCHzZHqIIIr6hmBnSm2KWdLC386uurjcPCDwcdc1ySinqzR2USavQU3/vMx9F4StwJrJdDxewszwAbv098d9pRMEVFyXVs5kVmdwcPeYR4+P6A3xHJdudTFv8k0KBWQbNKGyQNPWGI94OyZpPTt2FhD3y6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885893; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=405CzEKcTSTzCqnTBsrAR4Uq6RoC/2QTWJAANRrUWsQ=; b=JWVcPskV8vQ516GHC6idE0j5NqWKFjkCcthx4Q1hTOhaQgACRrI1jXJTjqLBKWVduHaKsSf0mXPplCEaivwAhFuQcxurzVekiZ2jyAPrv069x21HYnbieOI8T/JzjwX66amj7POwi4rpfJ6JqeU292tFosx3OGnYixSH3hin7ek= 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+91871+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 1658885893718218.47372003996247; Tue, 26 Jul 2022 18:38:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id t8oIYY1788612xmIIjvoSARX; Tue, 26 Jul 2022 18:38:13 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.14830.1658885892276894525 for ; Tue, 26 Jul 2022 18:38:12 -0700 X-Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R1HJ4N012106; Wed, 27 Jul 2022 01:38:10 GMT X-Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjng32kp9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:10 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id 3698D8001A2; Wed, 27 Jul 2022 01:38:09 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id EB142804D10; Wed, 27 Jul 2022 01:38:07 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 03/15] edk2-staging/RedfishClientPkg: Update Redfish Resource Config Protocol Date: Wed, 27 Jul 2022 09:37:50 +0800 Message-Id: <20220727013802.247-4-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: zjiQyXsMMECzTPFWNS5xVh-6Y9Jd4Fi5 X-Proofpoint-ORIG-GUID: zjiQyXsMMECzTPFWNS5xVh-6Y9Jd4Fi5 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,nickle.wang@hpe.com X-Gm-Message-State: e3pS2Ju0BOfrmr9BmKKkbCT8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885893; bh=1K5rw+Hntp/E8KqBLW7/u3nz+o85QRAzqOt4H6v7mU8=; h=Cc:Date:From:Reply-To:Subject:To; b=CyUxUbByiSXMWGvHXcvf0tURSkCnmWkpLLQoRZVCsGS/Jc2xpsqBydxbf/1s+bNtAz3 7WYJlGjk1XG2ZVBPH8/xiwPqDaDuHrXjMtm52RAqbjaljmpnZ5lKJOQ5y1RICGtaX8UOX Rg4tJmv9Tlr7jufvFj10OOkLI29EzB6JeWo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885895013100013 Content-Type: text/plain; charset="utf-8" Update Redfish resource config protocol to support Identify action in order to identify remote resource and see if this is resource belongs to current owner or not. Use unicode string instead of ASCII string for all interfaces to align with HTTP interface. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez --- .../EdkIIRedfishResourceConfigProtocol.h | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceConfigPr= otocol.h b/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceConfigProt= ocol.h index d6c41dda52..574c82c442 100644 --- a/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceConfigProtocol.h +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceConfigProtocol.h @@ -1,7 +1,7 @@ /** @file This file defines the EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL interface. =20 - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -29,7 +29,7 @@ typedef EFI_STATUS (EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_PROVISIONING) ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri, + IN EFI_STRING Uri, IN BOOLEAN HttpPostMode ); =20 @@ -47,7 +47,7 @@ typedef EFI_STATUS (EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CONSUME) ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri + IN EFI_STRING Uri ); =20 =20 @@ -65,7 +65,7 @@ typedef EFI_STATUS (EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_UPDATE) ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri + IN EFI_STRING Uri ); =20 =20 @@ -83,7 +83,25 @@ typedef EFI_STATUS (EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CHECK) ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri + IN EFI_STRING Uri + ); + +/** + Identify resource on given URI. + + @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI= G_PROTOCOL instance. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS This is target resource which we want t= o handle. + @retval EFI_UNSUPPORTED This is not the target resource. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_IDENTIFY) ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN EFI_STRING Uri ); =20 // @@ -121,6 +139,7 @@ struct _EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL { EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CONSUME Consume; EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_UPDATE Update; EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_CHECK Check; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_IDENTIFY Identify; EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL_GET_INFO GetInfo; }; =20 --=20 2.32.0.windows.2 -=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 (#91871): https://edk2.groups.io/g/devel/message/91871 Mute This Topic: https://groups.io/mt/92641645/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- From nobody Fri Apr 26 08:47:54 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+91872+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+91872+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885895; cv=none; d=zohomail.com; s=zohoarc; b=BuEJob+tmuxhEw3OTQwojqWeQe5LVRQaUp7GUlBT5rbLg88iLAyysHnOyEdiv7xQGIep7gQGBdgSR+4IMVQw9+xmr27nkH+KfjjO/j3IouQJt7iCe+l8VUEGr/+zmH5gWMLpux1ybyeElNUFZs762mq87xOyfyhPdrWwY06IHb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885895; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Pm0yDgNbMrsNkYHOayDRpbyLsSmewaXzqdn+a6kFEUM=; b=l4DiNzihHg28l946shmrhSnkDAecHLcemCZe8Owb45VoMVWxGP/br1na9jS16XkriBopR33Z+EDLJVsR8djKKUTcJq1L/r9XHWPx6RpUgHUaoZLhQvDBim+rVzGb9Lu2SDjC5kSxi6JW3shGMjaOhk2/BPXgb2V6ngcTzv444+o= 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+91872+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 1658885895303398.6354145556684; Tue, 26 Jul 2022 18:38:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id u3O1YY1788612xCvq6Yxrcit; Tue, 26 Jul 2022 18:38:14 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.14831.1658885894236361633 for ; Tue, 26 Jul 2022 18:38:14 -0700 X-Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0qdgf012946; Wed, 27 Jul 2022 01:38:12 GMT X-Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjmwu2ww2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:11 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id D6D3A8001AA; Wed, 27 Jul 2022 01:38:10 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 924828058C5; Wed, 27 Jul 2022 01:38:09 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 04/15] edk2-staging/RedfishClientPkg: Introduce Redfish resource config library Date: Wed, 27 Jul 2022 09:37:51 +0800 Message-Id: <20220727013802.247-5-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: VYkuQegG4a7FWsMACxuJTghWKTJTGdMs X-Proofpoint-GUID: VYkuQegG4a7FWsMACxuJTghWKTJTGdMs 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,nickle.wang@hpe.com X-Gm-Message-State: alR7BovYdOBTIxKSlZmeKVFex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885894; bh=FuL4HYMJ0AavPck1L8JW2ZMvHi4q+CLo1R1GrGqtE7M=; h=Cc:Date:From:Reply-To:Subject:To; b=uQRNm2WGpLSVM3TdymA5CLYXfYDwAQ/7FkPSSsCTNWdo3Gi8qpdB9WclP4VdQv/ZKja Z6ZfKQXKC7/MeTKCcN0P7jEfQC9HveQ90pXzppS8D/YwxafCU2iimSXf/b8Km+2rIrlQv 4yeevF5M9WxyS6z08WAjoATu++A6tAyGU9c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885897067100017 Content-Type: text/plain; charset="utf-8" Add EdkIIRedfishResourceConfigLib in order to work with Redfish Config Protocol and do the communication between each feature drivers. Also introduce Redfish interchange data protocol to exchange data efficiently. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../Library/EdkIIRedfishResourceConfigLib.h | 163 +++++ .../Protocol/EdkIIRedfishInterchangeData.h | 52 ++ .../EdkIIRedfishResourceConfigLib.c | 593 ++++++++++++++++++ .../EdkIIRedfishResourceConfigLib.inf | 49 ++ .../RedfishFeatureUtilityInternal.h | 3 +- RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + RedfishClientPkg/RedfishClientPkg.dec | 5 +- 7 files changed, 864 insertions(+), 2 deletions(-) create mode 100644 RedfishClientPkg/Include/Library/EdkIIRedfishResourceCo= nfigLib.h create mode 100644 RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchan= geData.h create mode 100644 RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/= EdkIIRedfishResourceConfigLib.c create mode 100644 RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/= EdkIIRedfishResourceConfigLib.inf diff --git a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib= .h b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h new file mode 100644 index 0000000000..1e843ec551 --- /dev/null +++ b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h @@ -0,0 +1,163 @@ +/** @file + This file defines the EDKII resource config Library interface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_ +#define EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_ + +#include +#include +#include +#include +#include +#include +/** + Provising redfish resource by given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri Target URI to create resource. + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. + @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST method is used. + FALSE if the resource exist but some of= properties are missing, + HTTP PUT method is used. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigProvisionging ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri, + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange, + IN BOOLEAN HttpPostMode + ); + +/** + Consume resource from given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigConsume ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri + ); + + +/** + Update resource to given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigUpdate ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri + ); + + +/** + Check resource on given URI. + + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigCheck ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri + ); + +/** + Identify resource on given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri The target URI to consume. + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. + + @retval EFI_SUCCESS This is target resource which we want t= o handle. + @retval EFI_UNSUPPORTED This is not the target resource. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigIdentify ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri, + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchangeUri + ); + +/** + Set Configure language of this resource in the + RESOURCE_INFORMATION_EXCHANGE structure. + + @param[in] ConfigLangList Pointer to REDFISH_FEATURE_ARRAY_TYPE_CONFI= G_LANG_LIST. + + @retval EFI_SUCCESS Configure language is set. + @retval EFI_UNSUPPORTED EdkIIRedfishFeatureInterchangeDataProto= col is not found. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceSetConfigureLang ( + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList + ); + +/** + + Get schema information by given protocol and service instance. + + @param[in] RedfishService Pointer to Redfish service instance. + @param[in] JsonStructProtocol Json Structure protocol instance. + @param[in] Uri Target URI. + @param[out] SchemaInfo Returned schema information. + + @retval EFI_SUCCESS Schema information is returned successfu= lly. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetRedfishSchemaInfo ( + IN REDFISH_SERVICE *RedfishService, + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, + IN EFI_STRING Uri, + OUT REDFISH_SCHEMA_INFO *SchemaInfo + ); + +/** + + Get supported schema list by given specify schema name. + + @param[in] Schema Schema type name. + @param[out] SchemaInfo Returned schema information. + + @retval EFI_SUCCESS Schema information is returned successfu= lly. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetSupportedSchemaVersion ( + IN CHAR8 *Schema, + OUT REDFISH_SCHEMA_INFO *SchemaInfo + ); + +#endif diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.= h b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h new file mode 100644 index 0000000000..e8d0462fb7 --- /dev/null +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h @@ -0,0 +1,52 @@ +/** @file + This file defines the EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL in= terface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_ +#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_ + +#include + +typedef struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL EDKII_REDF= ISH_FEATURE_INTERCHANGE_DATA_PROTOCOL; + +#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL_GUID \ + { \ + 0x4B8FF71C, 0x4A7B, 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x= 00, 0x91 } \ + } + +typedef enum { + InformationTypeNone =3D 0, ///< Invalid informatio= n. + InformationTypeCollectionMemberUri, ///< URI to the new creat= ed collection member. + InformationTypeCollectionMemberConfigLanguage, ///< URI to the new creat= ed collection member. + InformationTypeMax +} RESOURCE_INFORMATION_EXCHANGE_TYPE; + +typedef struct { + RESOURCE_INFORMATION_EXCHANGE_TYPE Type; + EFI_STRING ParentUri; ///< The parent URI (in configure lan= guage) of the resource to process. + EFI_STRING PropertyName; ///< The property name of the resourc= e to process. + EFI_STRING FullUri; ///< The full URI (in configure langu= age) of the resource to process. +} RESOURCE_INFORMATION_SEND; + +typedef struct { + RESOURCE_INFORMATION_EXCHANGE_TYPE Type; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigureLanguageList; +} RESOURCE_INFORMATION_RETURNED; + +typedef struct { + RESOURCE_INFORMATION_SEND SendInformation; + RESOURCE_INFORMATION_RETURNED ReturnedInformation; +} RESOURCE_INFORMATION_EXCHANGE; + +struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL { + RESOURCE_INFORMATION_EXCHANGE *ResourceInformationExchage; +}; + +extern EFI_GUID gEdkIIRedfishFeatureInterchangeDataProtocolGuid; + +#endif diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRe= dfishResourceConfigLib.c b/RedfishClientPkg/Library/EdkIIRedfishResourceCon= figLib/EdkIIRedfishResourceConfigLib.c new file mode 100644 index 0000000000..d09da6bd67 --- /dev/null +++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.c @@ -0,0 +1,593 @@ +/** @file + Redfish resource config library implementation + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *mRedfishResourceConfigProtocol =3D= NULL; +EFI_HANDLE medfishResourceConfigProtocolHandle; +EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL mRedfishFeatureInterchange= Data; +REDFISH_SCHEMA_INFO mSchemaInfoCache; + +#define SCHEMA_NAME_PREFIX_OFFSET 15 // x-uefi-redfish- + +/** + + Get schema information by given protocol and service instance. + + @param[in] RedfishService Pointer to Redfish service instance. + @param[in] JsonStructProtocol Json Structure protocol instance. + @param[in] Uri Target URI. + @param[out] SchemaInfo Returned schema information. + + @retval EFI_SUCCESS Schema information is returned successfu= lly. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetRedfishSchemaInfo ( + IN REDFISH_SERVICE *RedfishService, + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, + IN EFI_STRING Uri, + OUT REDFISH_SCHEMA_INFO *SchemaInfo + ) +{ + EFI_STATUS Status; + REDFISH_RESPONSE Response; + REDFISH_PAYLOAD Payload; + CHAR8 *JsonText; + EFI_REST_JSON_STRUCTURE_HEADER *Header; + + if (RedfishService =3D=3D NULL || JsonStructProtocol =3D=3D NULL || IS_E= MPTY_STRING (Uri) || SchemaInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D GetResourceByUri (RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %s: %r", __FUNCT= ION__, Uri, Status)); + return Status; + } + + Payload =3D Response.Payload; + ASSERT (Payload !=3D NULL); + + JsonText =3D JsonDumpString (RedfishJsonInPayload (Payload), EDKII_JSON_= COMPACT); + ASSERT (JsonText !=3D NULL); + + // + // Convert JSON text to C structure. + // + Status =3D JsonStructProtocol->ToStructure ( + JsonStructProtocol, + NULL, + JsonText, + &Header + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return Status; + } + + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Header->J= sonRsrcIdentifier.NameSpace.ResourceTypeName); + AsciiStrCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.MajorVersion); + AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.MinorVersion); + AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, Header->= JsonRsrcIdentifier.NameSpace.ErrataVersion); + + // + // Release resource. + // + JsonStructProtocol->DestoryStructure (JsonStructProtocol, Header); + FreePool (JsonText); + RedfishFreeResponse (Response.StatusCode, Response.HeaderCount, Response= .Headers, Response.Payload); + + return EFI_SUCCESS; +} + +/** + + Get supported schema list by given specify schema name. + + @param[in] Schema Schema type name. + @param[out] SchemaInfo Returned schema information. + + @retval EFI_SUCCESS Schema information is returned successfu= lly. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetSupportedSchemaVersion ( + IN CHAR8 *Schema, + OUT REDFISH_SCHEMA_INFO *SchemaInfo + ) +{ + EFI_STATUS Status; + CHAR8 *SupportSchema; + CHAR8 *SchemaName; + UINTN Index; + UINTN Index2; + BOOLEAN Found; + + if (IS_EMPTY_STRING (Schema) || SchemaInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D RedfishPlatformConfigGetSupportedSchema (NULL, &SupportSchema= ); + if (EFI_ERROR (Status)) { + return Status; + } + + DEBUG ((DEBUG_INFO, "Supported schema: %a\n", SupportSchema)); + + Index =3D 0; + Found =3D FALSE; + SchemaName =3D SupportSchema; + while (TRUE) { + + if (SupportSchema[Index] =3D=3D ';' || SupportSchema[Index] =3D=3D '\0= ') { + if (AsciiStrnCmp (&SchemaName[SCHEMA_NAME_PREFIX_OFFSET], Schema, As= ciiStrLen (Schema)) =3D=3D 0) { + Found =3D TRUE; + SupportSchema[Index] =3D '\0'; + break; + } + + SchemaName =3D &SupportSchema[Index + 1]; + } + + if (SupportSchema[Index] =3D=3D '\0') { + break; + } + + ++Index; + } + + if (Found) { + + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Schema); + + // + // forward to '.' + // + Index =3D 0; + while (SchemaName[Index] !=3D '\0' && SchemaName[Index] !=3D '.') { + ++Index; + } + ASSERT (SchemaName[Index] !=3D '\0'); + + // + // Skip '.' and 'v' + // + Index +=3D 2; + + // + // forward to '_' + // + Index2 =3D Index; + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') { + ++Index2; + } + ASSERT (SchemaName[Index2] !=3D '\0'); + + AsciiStrnCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index)); + Index =3D Index2; + + // + // Skip '_' + // + ++Index; + + // + // forward to '_' + // + Index2 =3D Index; + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') { + ++Index2; + } + ASSERT (SchemaName[Index2] !=3D '\0'); + + AsciiStrnCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index)); + Index =3D Index2; + + // + // Skip '_' + // + ++Index; + + AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index]); + } + + FreePool (SupportSchema); + + return (Found ? EFI_SUCCESS : EFI_NOT_FOUND); +} + + +/** + + Find Redfish Resource Config Protocol that supports given schema and ver= sion. + + @param[in] Schema Schema name. + @param[out] Handle Pointer to receive the handle that has EDKII_RED= FISH_RESOURCE_CONFIG_PROTOCOL + installed on it. + + @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to proto= col + @retval NULL No protocol foun= d. + +**/ +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * +GetRedfishResourceConfigProtocol ( + IN REDFISH_SCHEMA_INFO *Schema, + OUT EFI_HANDLE *Handle OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; + UINTN Index; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *Protocol; + REDFISH_SCHEMA_INFO SchemaInfo; + BOOLEAN Found; + + if (IS_EMPTY_STRING (Schema->Schema) || + IS_EMPTY_STRING (Schema->Major) || + IS_EMPTY_STRING (Schema->Minor) || + IS_EMPTY_STRING (Schema->Errata) + ) { + return NULL; + } + + if (mRedfishResourceConfigProtocol !=3D NULL) { + if (AsciiStrCmp (Schema->Schema, mSchemaInfoCache.Schema) =3D=3D 0 && + AsciiStrCmp (Schema->Major, mSchemaInfoCache.Major) =3D=3D 0 && + AsciiStrCmp (Schema->Minor, mSchemaInfoCache.Minor) =3D=3D 0 && + AsciiStrCmp (Schema->Errata, mSchemaInfoCache.Errata) =3D=3D 0) { + if (Handle !=3D NULL) { + *Handle =3D medfishResourceConfigProtocolHandle; + } + return mRedfishResourceConfigProtocol; + } + } + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEdkIIRedfishResourceConfigProtocolGuid, + NULL, + &NumberOfHandles, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + Found =3D FALSE; + + for (Index =3D 0; Index < NumberOfHandles; Index++) { + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEdkIIRedfishResourceConfigProtocolGuid, + (VOID **) &Protocol + ); + if (EFI_ERROR (Status)) { + continue; + } + + Status =3D Protocol->GetInfo (Protocol, &SchemaInfo); + if (EFI_ERROR (Status)) { + continue; + } + + if (AsciiStrCmp (Schema->Schema, SchemaInfo.Schema) =3D=3D 0 && + AsciiStrCmp (Schema->Major, SchemaInfo.Major) =3D=3D 0 && + AsciiStrCmp (Schema->Minor, SchemaInfo.Minor) =3D=3D 0 && + AsciiStrCmp (Schema->Errata, SchemaInfo.Errata) =3D=3D 0) { + Found =3D TRUE; + break; + } + } + + if (Found) { + medfishResourceConfigProtocolHandle =3D HandleBuffer[Index]; + mRedfishResourceConfigProtocol =3D Protocol; + CopyMem (&mSchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO)); + if (Handle !=3D NULL) { + *Handle =3D HandleBuffer[Index]; + } + } + FreePool(HandleBuffer); + + return (Found ? Protocol : NULL); +} + +/** + Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL + on child feature driver handle. + + @param[in] Handle Handle to install EDKII_REDFISH_FEATURE_INTERCHANGE= _DATA_PROTOCOL. + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +InstallInterchangeDataProtocol ( + IN EFI_HANDLE Handle, + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL *Interface; + + Status =3D gBS->HandleProtocol ( + Handle, + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid, + (VOID **)&Interface + ); + if (!EFI_ERROR (Status)) { + Interface->ResourceInformationExchage =3D InformationExchange; + return EFI_SUCCESS; + } + if (Status =3D=3D EFI_UNSUPPORTED) { + mRedfishFeatureInterchangeData.ResourceInformationExchage =3D Informat= ionExchange; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid, + EFI_NATIVE_INTERFACE, + (VOID *)&mRedfishFeatureInterchangeData + ); + } + return Status; +} + +/** + Set Configure language of this resource in the + RESOURCE_INFORMATION_EXCHANGE structure. + + @param[in] ConfigLangList Pointer to REDFISH_FEATURE_ARRAY_TYPE_CONFI= G_LANG_LIST. + + @retval EFI_SUCCESS Configure language is set. + @retval EFI_UNSUPPORTED EdkIIRedfishFeatureInterchangeDataProto= col is not found. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceSetConfigureLang ( + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList + ) +{ + EFI_STATUS Status; + UINTN Index; + EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL *Interface; + + Status =3D gBS->HandleProtocol ( + medfishResourceConfigProtocolHandle, + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid, + (VOID **)&Interface + ); + if (EFI_ERROR (Status)){ + DEBUG ((DEBUG_ERROR, "%a, EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTO= COL is not installed %r", __FUNCTION__, Status)); + return Status; + } + Interface->ResourceInformationExchage->ReturnedInformation.Type =3D Info= rmationTypeCollectionMemberConfigLanguage; + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLang= uageList.Count =3D ConfigLangList->Count; + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLang= uageList.List =3D + AllocateZeroPool(sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG) * Con= figLangList->Count); + if (Interface->ResourceInformationExchage->ReturnedInformation.Configure= LanguageList.List =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEATURE_= ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + for (Index =3D 0; Index < ConfigLangList->Count; Index++) { + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLa= nguageList.List [Index].Index =3D ConfigLangList->List[Index].Index; + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLa= nguageList.List [Index].ConfigureLang =3D + (EFI_STRING)AllocateCopyPool(StrSize(ConfigLangList->List[Index].Con= figureLang), (VOID *)ConfigLangList->List[Index].ConfigureLang); + } + return EFI_SUCCESS; +} + +/** + Provising redfish resource by given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri Target URI to create resource. + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. + @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST method is used. + FALSE if the resource exist but some of= properties are missing, + HTTP PUT method is used. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigProvisionging ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri, + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange, + IN BOOLEAN HttpPostMode + ) +{ + EFI_HANDLE Handle; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + + protocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle); + if (protocol =3D=3D NULL || Handle =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + + // + // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the child + // feature driver handle. + // + InstallInterchangeDataProtocol (Handle, InformationExchange); + return protocol->Provisioning(protocol, Uri, HttpPostMode); +} + +/** + Consume resource from given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigConsume ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri + ) +{ + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + + protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (protocol =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + + return protocol->Consume (protocol, Uri); +} + + +/** + Update resource to given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigUpdate ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri + ) +{ + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + + protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (protocol =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + + return protocol->Update (protocol, Uri); +} + +/** + Check resource on given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigCheck ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri + ) +{ + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + + protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (protocol =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + + return protocol->Check (protocol, Uri); +} + +/** + Identify resource on given URI. + + @param[in] Schema Redfish schema information. + @param[in] Uri The target URI to consume. + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. + + @retval EFI_SUCCESS This is target resource which we want t= o handle. + @retval EFI_UNSUPPORTED This is not the target resource. + @retval Others Some error happened. + +**/ +EFI_STATUS +EdkIIRedfishResourceConfigIdentify ( + IN REDFISH_SCHEMA_INFO *Schema, + IN EFI_STRING Uri, + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange + ) +{ + EFI_HANDLE Handle; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + + protocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle); + if (protocol =3D=3D NULL) { + return EFI_DEVICE_ERROR; + } + + // + // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the child + // feature driver handle. + // + InstallInterchangeDataProtocol (Handle, InformationExchange); + return protocol->Identify (protocol, Uri); +} + +/** + + Initial resource config library instace. + + @param[in] ImageHandle The image handle. + @param[in] SystemTable The system table. + + @retval EFI_SUCEESS Install Boot manager menu success. + @retval Other Return error status. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceConfigConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + mRedfishResourceConfigProtocol =3D NULL; + ZeroMem (&mSchemaInfoCache, sizeof (REDFISH_SCHEMA_INFO)); + + return EFI_SUCCESS; +} + +/** + Release allocated resource. + + @param[in] ImageHandle Handle that identifies the image to be unlo= aded. + @param[in] SystemTable The system table. + + @retval EFI_SUCCESS The image has been unloaded. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceConfigDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + mRedfishResourceConfigProtocol =3D NULL; + + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRe= dfishResourceConfigLib.inf b/RedfishClientPkg/Library/EdkIIRedfishResourceC= onfigLib/EdkIIRedfishResourceConfigLib.inf new file mode 100644 index 0000000000..0da3423d26 --- /dev/null +++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.inf @@ -0,0 +1,49 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D EdkIIRedfishResourceConfigLib + FILE_GUID =3D B41884F6-693B-4ADE-9558-5C220A24A025 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D EdkIIRedfishResourceConfigLib| DXE_DR= IVER + CONSTRUCTOR =3D RedfishResourceConfigConstructor + DESTRUCTOR =3D RedfishResourceConfigDestructor + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + EdkIIRedfishResourceConfigLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + BaseMemoryLib + PcdLib + MemoryAllocationLib + RedfishFeatureUtilityLib + RedfishPlatformConfigLib + +[Protocols] + gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMES ## + gEdkIIRedfishFeatureInterchangeDataProtocolGuid ## CONSUMES ## + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityInternal.h b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/Red= fishFeatureUtilityInternal.h index b8f4df7bcd..7d38d327ef 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyInternal.h +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyInternal.h @@ -34,7 +34,8 @@ #define INDEX_STRING_SIZE 16 #define IS_EMPTY_STRING(a) (a =3D=3D NULL || a[0] =3D=3D '\0') #define INDEX_STRING L"{%d}" -#define SCHEMA_NAME_PREFIX_OFFSET 15 // x-uefi-redfish- +#define SCHEMA_NAME_PREFIX "x-uefi-redfish-" +#define SCHEMA_NAME_PREFIX_OFFSET (AsciiStrLen (SCHEMA_NAME_PREFIX)) #define REDFISH_SYSTEM_ROOT_PATH "/v1/Systems[UUID~%g]" #define MAX_CONF_LANG_LEN 128 =20 diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 1cf0406912..8acb479170 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -28,5 +28,6 @@ RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/R= edfishContentCodingLibNull.inf ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf =20 + EdkIIRedfishResourceConfigLib|RedfishClientPkg/Library/EdkIIRedfishResou= rceConfigLib/EdkIIRedfishResourceConfigLib.inf RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib= .inf RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVers= ionLib.inf diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 2ce51d14af..9d18c42c24 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -1,7 +1,7 @@ ## @file # Redfish Client Package # -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -21,6 +21,7 @@ =20 [LibraryClasses] RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h + EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConfig= Lib.h RedfishEventLib|Include/Library/RedfishEventLib.h RedfishVersionLib|Include/Library/RedfishVersionLib.h =20 @@ -36,6 +37,8 @@ gEdkIIRedfishResourceConfigProtocolGuid =3D { 0x6f164c68, 0xfb09, 0x4646= , { 0xa8, 0xd3, 0x24, 0x11, 0x5d, 0xab, 0x3e, 0xe7 } } ## Include/Protocol/EdkiiRedfishETagProtocol.h gEdkIIRedfishETagProtocolGuid =3D { 0x5706d368, 0xaf66, 0x48f5= , { 0x89, 0xfc, 0xa6, 0x61, 0xce, 0xb5, 0xa6, 0xa9 } } + ## Include/Protocol/EdkIIRedfishInterchangeData.h + gEdkIIRedfishFeatureInterchangeDataProtocolGuid =3D { 0x4B8FF71C, 0x4A7B= , 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x00, 0x91 } } =20 [Guids] ## Include/Guid/RedfishClientPkgTokenSpace.h --=20 2.32.0.windows.2 -=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 (#91872): https://edk2.groups.io/g/devel/message/91872 Mute This Topic: https://groups.io/mt/92641646/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- From nobody Fri Apr 26 08:47:54 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+91873+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+91873+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885896; cv=none; d=zohomail.com; s=zohoarc; b=CFXzYOHrYtEIA9bp0MPGhoUmK6Li/Avc3ZVtaLE5Y1LuSRoVJkzXAWnEbLm7QEcyCoHf1r53Q2yJlr5bJkdZdtDJAZU+DsqydQZ6CixYiFXQtkFilI2wXm9w3hwBuW4BUJK305W24xFXBbMxitwKf1z6xfrlIyIOQEQbx4qVo7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885896; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=OCfPnv7yqp1ACjkHW2tsWlv9DENJ+2Eg8n6bHood8uk=; b=BZJIc+uYeyumpbez+uonjIOPyodX77I1SwmDb/DGFpUlk9RRx9B62m2/yygSYpX02IAoukD99GKehUgyuc6+d8Zp+4mmpk8q1X0tTca2FaVmxug4Hg/bsAPztn5Ie3P1/HAJOndQ76sgbDEGR/j3+VSl9+JtAsnCbWVB1tIJUIY= 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+91873+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 1658885896845851.193127145405; Tue, 26 Jul 2022 18:38:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UF4pYY1788612x8OXPtAo4MH; Tue, 26 Jul 2022 18:38:16 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web11.14905.1658885895517713174 for ; Tue, 26 Jul 2022 18:38:15 -0700 X-Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R1SYGW004808; Wed, 27 Jul 2022 01:38:13 GMT X-Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjuqmr2cd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:13 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id 7A0D0D2C6; Wed, 27 Jul 2022 01:38:12 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 3B2D2804D10; Wed, 27 Jul 2022 01:38:11 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 05/15] edk2-staging/RedfishClientPkg: Introduce resource identify library Date: Wed, 27 Jul 2022 09:37:52 +0800 Message-Id: <20220727013802.247-6-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: 44i9BUbRacs1FquObYZTXweSHn4yaJJu X-Proofpoint-ORIG-GUID: 44i9BUbRacs1FquObYZTXweSHn4yaJJu 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,nickle.wang@hpe.com X-Gm-Message-State: WlRMsYlHBZku71uWAmSVlheHx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885896; bh=q02FrfihcTxNtj/1+EstNOJNtXddphk+5S6iagu9DMI=; h=Cc:Date:From:Reply-To:Subject:To; b=Vfb6Bhv0MJvmAyPq3SYYCG9walqssq16+nmi/7oGw7eoYnyDPh53oLnysyfHzw/FLjQ 7VUSgbj2eInn4bDf0Xb+41nb3MSxudOAulbJRbPh8altsPsasdtr/2lBeNau+AQSYBaoG Rq2NNSa3R38uwuv/08EhcUatN5KOW/sHO84= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885899060100023 Content-Type: text/plain; charset="utf-8" Introduce resource identify library which works with resource config protocol to identify Redfish resource. This library provides the flexibility for platform to implement its own policy and identify resource. Two library implementation are provided as demonstration code. NULL version of library accepts all Redfish resource and another implementation to computer system resource uses UUID to identify Redfish resource. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../Library/RedfishResourceIdentifyLib.h | 29 ++++ .../RedfishResourceIdentifyLibComuterSystem.c | 164 ++++++++++++++++++ ...edfishResourceIdentifyLibComuterSystem.inf | 39 +++++ .../RedfishResourceIdentifyLibNull.c | 37 ++++ .../RedfishResourceIdentifyLibNull.inf | 32 ++++ RedfishClientPkg/RedfishClientLibs.dsc.inc | 2 +- RedfishClientPkg/RedfishClientPkg.dec | 1 + 7 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/Include/Library/RedfishResourceIdentif= yLib.h create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibComu= terSystem/v1_5_0/RedfishResourceIdentifyLibComuterSystem.c create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibComu= terSystem/v1_5_0/RedfishResourceIdentifyLibComuterSystem.inf create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibNull= /RedfishResourceIdentifyLibNull.c create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibNull= /RedfishResourceIdentifyLibNull.inf diff --git a/RedfishClientPkg/Include/Library/RedfishResourceIdentifyLib.h = b/RedfishClientPkg/Include/Library/RedfishResourceIdentifyLib.h new file mode 100644 index 0000000000..91d01b7d68 --- /dev/null +++ b/RedfishClientPkg/Include/Library/RedfishResourceIdentifyLib.h @@ -0,0 +1,29 @@ +/** @file + This file defines the Redfish resource identify Library interface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_RESOURCE_IDENTIFY_LIB_H_ +#define REDFISH_RESOURCE_IDENTIFY_LIB_H_ + +/** + Identify resource from given URI and context in JSON format + + @param[in] Uri URI of given Redfish resource + @param[in] Json Context in JSON format of give Redfish resource + + @retval TRUE This is the Redfish resource that we have to handle. + @retval FALSE We don't handle this Redfish resource. + +**/ +BOOLEAN +RedfishIdentifyResource ( + IN EFI_STRING Uri, + IN CHAR8 *Json + ); + +#endif diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSyst= em/v1_5_0/RedfishResourceIdentifyLibComuterSystem.c b/RedfishClientPkg/Libr= ary/RedfishResourceIdentifyLibComuterSystem/v1_5_0/RedfishResourceIdentifyL= ibComuterSystem.c new file mode 100644 index 0000000000..e5699f194c --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSystem/v1_5= _0/RedfishResourceIdentifyLibComuterSystem.c @@ -0,0 +1,164 @@ +/** @file + Redfish resource identify library implementation for computer system ver= sion 1.5.0 + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mJsonStructProtocol =3D NULL; + +/** + Identify resource from given URI and context in JSON format + + @param[in] Uri URI of given Redfish resource + @param[in] Json Context in JSON format of give Redfish resource + + @retval TRUE This is the Redfish resource that we have to handle. + @retval FALSE We don't handle this Redfish resource. + +**/ +BOOLEAN +RedfishIdentifyResource ( + IN EFI_STRING Uri, + IN CHAR8 *Json + ) +{ + EFI_STATUS Status; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *ComputerSystem; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS *ComputerSystemCs; + EFI_GUID SystemUuid; + EFI_GUID ResourceUuid; + + if (IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Json)) { + return FALSE; + } + + if (mJsonStructProtocol =3D=3D NULL) { + return FALSE; + } + + ComputerSystem =3D NULL; + ComputerSystemCs =3D NULL; + + Status =3D mJsonStructProtocol->ToStructure ( + mJsonStructProtocol, + NULL, + Json, + (EFI_REST_JSON_STRUCTURE_HEADER **)&Comp= uterSystem + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return FALSE; + } + + ComputerSystemCs =3D ComputerSystem->ComputerSystem; + + if (IS_EMPTY_STRING (ComputerSystemCs->UUID)) { + return FALSE; + } + + Status =3D AsciiStrToGuid (ComputerSystemCs->UUID, &ResourceUuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to get resource UUID: %r\n", __FUNCTION= __, Status)); + return FALSE; + } + + Status =3D NetLibGetSystemGuid (&SystemUuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to get system UUID from SMBIOS: %r\n", = __FUNCTION__, Status)); + return FALSE; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, Identify: System: %g Resource: %g\n", = __FUNCTION__, &SystemUuid, &ResourceUuid)); + if (CompareGuid (&ResourceUuid, &SystemUuid)) { + Status =3D EFI_SUCCESS; + } else { + Status =3D EFI_UNSUPPORTED; + } + + mJsonStructProtocol->DestoryStructure ( + mJsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem + ); + + return (Status =3D=3D EFI_SUCCESS ? TRUE : FALSE); +} + +/** + 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 +RestJasonStructureProtocolIsReady + ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + + if (mJsonStructProtocol !=3D NULL) { + return; + } + + Status =3D gBS->LocateProtocol ( + &gEfiRestJsonStructureProtocolGuid, + NULL, + (VOID **)&mJsonStructProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to locate gEfiRestJsonStructureProtoc= olGuid: %r\n", __FUNCTION__, Status)); + } + + gBS->CloseEvent (Event); +} + +/** + + Install JSON protocol notification + + @param[in] ImageHandle The image handle. + @param[in] SystemTable The system table. + + @retval EFI_SUCEESS Install Boot manager menu success. + @retval Other Return error status. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceIdentifyComuterSystemConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + VOID *Registration; + + EfiCreateProtocolNotifyEvent ( + &gEfiRestJsonStructureProtocolGuid, + TPL_CALLBACK, + RestJasonStructureProtocolIsReady, + NULL, + &Registration + ); + + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSyst= em/v1_5_0/RedfishResourceIdentifyLibComuterSystem.inf b/RedfishClientPkg/Li= brary/RedfishResourceIdentifyLibComuterSystem/v1_5_0/RedfishResourceIdentif= yLibComuterSystem.inf new file mode 100644 index 0000000000..ae269b5849 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSystem/v1_5= _0/RedfishResourceIdentifyLibComuterSystem.inf @@ -0,0 +1,39 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishResourceIdentifyLibComuterSyst= em + FILE_GUID =3D 2AEE2C80-126A-44A6-877E-642F20510D13 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishResourceIdentifyLib| DXE_DRIVER + CONSTRUCTOR =3D RedfishResourceIdentifyComuterSystemC= onstructor + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + RedfishResourceIdentifyLibComuterSystem.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + NetworkPkg/NetworkPkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + UefiLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## CONSUMES diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/Redfis= hResourceIdentifyLibNull.c b/RedfishClientPkg/Library/RedfishResourceIdenti= fyLibNull/RedfishResourceIdentifyLibNull.c new file mode 100644 index 0000000000..98eb8fde47 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/RedfishResour= ceIdentifyLibNull.c @@ -0,0 +1,37 @@ +/** @file + Redfish resource identify NULL library implementation + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +/** + Identify resource from given URI and context in JSON format + + @param[in] Uri URI of given Redfish resource + @param[in] Json Context in JSON format of give Redfish resource + + @retval TRUE This is the Redfish resource that we have to handle. + @retval FALSE We don't handle this Redfish resource. + +**/ +BOOLEAN +RedfishIdentifyResource ( + IN EFI_STRING Uri, + IN CHAR8 *Json + ) +{ + if (!IS_EMPTY_STRING (Uri)) { + DEBUG ((DEBUG_VERBOSE, "%a, accept resource: %s\n", __FUNCTION__, Uri)= ); + } + + return TRUE; +} diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/Redfis= hResourceIdentifyLibNull.inf b/RedfishClientPkg/Library/RedfishResourceIden= tifyLibNull/RedfishResourceIdentifyLibNull.inf new file mode 100644 index 0000000000..9164b229ba --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/RedfishResour= ceIdentifyLibNull.inf @@ -0,0 +1,32 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishResourceIdentifyLibNull + FILE_GUID =3D 6FFD4E25-48F8-4CB6-B194-CFAB407316E1 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishResourceIdentifyLib| DXE_DRIVER + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + RedfishResourceIdentifyLibNull.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 8acb479170..413b83a732 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -27,7 +27,7 @@ RedfishPlatformConfigLib|RedfishPkg/Library/RedfishPlatformConfigLib/Red= fishPlatformConfigLib.inf RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/R= edfishContentCodingLibNull.inf ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf - + RedfishResourceIdentifyLib|RedfishClientPkg/Library/RedfishResourceIdent= ifyLibNull/RedfishResourceIdentifyLibNull.inf EdkIIRedfishResourceConfigLib|RedfishClientPkg/Library/EdkIIRedfishResou= rceConfigLib/EdkIIRedfishResourceConfigLib.inf RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib= .inf RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVers= ionLib.inf diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 9d18c42c24..c61c581213 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -21,6 +21,7 @@ =20 [LibraryClasses] RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h + RedfishResourceIdentifyLib|Include/Library/RedfishResourceIdentifyLib.h EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConfig= Lib.h RedfishEventLib|Include/Library/RedfishEventLib.h RedfishVersionLib|Include/Library/RedfishVersionLib.h --=20 2.32.0.windows.2 -=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 (#91873): https://edk2.groups.io/g/devel/message/91873 Mute This Topic: https://groups.io/mt/92641647/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- From nobody Fri Apr 26 08:47:54 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+91874+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+91874+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885898; cv=none; d=zohomail.com; s=zohoarc; b=U6jfn7gD17wA/fKd86prI0GfTeHWDvzjCXUt+nQi64qdrkF/QTjTjencBjSS+iG6at4727UzVOqGxGlGRSZaNh2NFQ9ztDE8Ej8mSt2Aa0fcUuCjpJOYtaDpEzkbpI9cLYGcNauJBiFDp3O6RZ0hi/4pEAR7dBmkw5ioEAPrS3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885898; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=QIc0/yeu2sSgoUne5/X1BaPG0tAJBnmoDa1pgnUIdXs=; b=h4kSAMsKX4HWN7oenxW22gSvUwV9N5Ka+urpKc16jsT1DvDO4BGeXXUVMiJ+MRsBOBHXm7EcGTqCOoVxX1Ahhv5UcxMxTI+ufpZZ3A3/1IAIV2JhmHCJypZsbB8SjiSWEq3/la5wLTnr+To9SDH/9BtAxcaB90qf/6DDV61eyVY= 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+91874+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 1658885898026702.6444621772873; Tue, 26 Jul 2022 18:38:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id eb4dYY1788612xhSe4h4N6bn; Tue, 26 Jul 2022 18:38:17 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.14921.1658885896903077841 for ; Tue, 26 Jul 2022 18:38:17 -0700 X-Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R1SMhN004574; Wed, 27 Jul 2022 01:38:15 GMT X-Received: from p1lg14881.it.hpe.com (p1lg14881.it.hpe.com [16.230.97.202]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjuqmr2ck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:14 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id 21FCB804C87; Wed, 27 Jul 2022 01:38:14 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id D581C804D10; Wed, 27 Jul 2022 01:38:12 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 06/15] edk2-staging/RedfishClientPkg: Introduce RedfishConfigLangMap driver Date: Wed, 27 Jul 2022 09:37:53 +0800 Message-Id: <20220727013802.247-7-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: sqqdD896OAX01Iittnrjeg5zgIhhBTiz X-Proofpoint-ORIG-GUID: sqqdD896OAX01Iittnrjeg5zgIhhBTiz 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,nickle.wang@hpe.com X-Gm-Message-State: nuHY1XbhVzA8KHcqmO31wUoZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885897; bh=YD7hN9WgtvzL0qo+d3A4dOlJ06p4c4OueWdOWiXZUTU=; h=Cc:Date:From:Reply-To:Subject:To; b=VaAXtcPJb/4BZCFv1XENP1QF8fHIZdTdBkKlmeJI8dVOPXxCkLW/pCw3aVcLEfT4BO8 Nz8cEA+exm1th+dNX+f/9G4n7ah1rw5LjA4CZYUOkl+dN0IxnUkK05tQ0hF7HxA6LqCXS 13so0MpS3Bc8TFNRWsXlrGqvwnlGk0BWUSI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885899066100024 Content-Type: text/plain; charset="utf-8" Introduce Redfish configure language map driver. This driver keeps the mapping between configure language and Redfish URI for internal use. This saves the communication time between feature drivers and Redfish service. It also provides the history records so that feature drivers can do provisioning, consuming and updating efficiently. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../EdkIIRedfishConfigLangMapProtocol.h | 88 ++ RedfishClientPkg/RedfishClient.fdf.inc | 3 +- .../RedfishClientComponents.dsc.inc | 1 + RedfishClientPkg/RedfishClientPkg.dec | 2 + .../RedfishConfigLangMapDxe.c | 810 ++++++++++++++++++ .../RedfishConfigLangMapDxe.h | 71 ++ .../RedfishConfigLangMapDxe.inf | 46 + 7 files changed, 1020 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/Include/Protocol/EdkIIRedfishConfigLan= gMapProtocol.h create mode 100644 RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigL= angMapDxe.c create mode 100644 RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigL= angMapDxe.h create mode 100644 RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigL= angMapDxe.inf diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishConfigLangMapPro= tocol.h b/RedfishClientPkg/Include/Protocol/EdkIIRedfishConfigLangMapProtoc= ol.h new file mode 100644 index 0000000000..03d18aa297 --- /dev/null +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishConfigLangMapProtocol.h @@ -0,0 +1,88 @@ +/** @file + This file defines the EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL interface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_H_ +#define EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_H_ + +typedef struct _EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL EDKII_REDFISH_CONFI= G_LANG_MAP_PROTOCOL; + +/** + Definition of REDFISH_CONFIG_LANG_MAP_GET_TYPE + **/ +typedef enum { + RedfishGetTypeUri =3D 0, + RedfishGetTypeConfigLang, + RedfishGetTypeMax +} REDFISH_CONFIG_LANG_MAP_GET_TYPE; + +/** + Get string in database by given query string. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_LAN= G_MAP_PROTOCOL instance. + @param[in] QueryStringType The type of given QueryString. + @param[in] QueryString Query string. + @param[out] ResultString Returned string mapping to give que= ry string. + + @retval EFI_SUCCESS The result is found successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter is given. + +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_GET) ( + IN EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL *This, + IN REDFISH_CONFIG_LANG_MAP_GET_TYPE QueryStringType, + IN EFI_STRING QueryString, + OUT EFI_STRING *ResultString + ); + +/** + Save URI string which maps to given ConfigLang. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_LANG_MA= P_PROTOCOL instance. + @param[in] ConfigLang Config language to set + @param[in] Uri Uri which is mapping to give ConfigLang= . If Uri is NULL, + the record will be removed. + + @retval EFI_SUCCESS Uri is saved successfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_SET) ( + IN EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL *This, + IN EFI_STRING ConfigLang, + IN EFI_STRING Uri OPTIONAL + ); + +/** + Refresh the resource map database and save database to variable. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_LANG_MA= P_PROTOCOL instance. + + @retval EFI_SUCCESS database is saved successfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_FLUSH) ( + IN EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL *This + ); + +struct _EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL { + EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_GET Get; + EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_SET Set; + EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL_FLUSH Flush; +}; + +extern EFI_GUID gEdkIIRedfishConfigLangMapProtocolGuid; + +#endif diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index d5d04e4c6c..6292de4e81 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -5,7 +5,7 @@ # by using "!include RedfishClientPkg/RedfisClientLibs.fdf.inc" to specify= the module instances # to be built in the firmware volume. # -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -13,6 +13,7 @@ !if $(REDFISH_CLIENT) =3D=3D TRUE INF RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf INF RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf + INF RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf INF RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCo= llectionDxe.inf =20 diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index b89df12c6f..ee4602fe79 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -15,6 +15,7 @@ !if $(REDFISH_CLIENT) =3D=3D TRUE RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf + RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf # # Below two modules should be pulled in by build tool. # diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index c61c581213..7bdab5be0c 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -38,6 +38,8 @@ gEdkIIRedfishResourceConfigProtocolGuid =3D { 0x6f164c68, 0xfb09, 0x4646= , { 0xa8, 0xd3, 0x24, 0x11, 0x5d, 0xab, 0x3e, 0xe7 } } ## Include/Protocol/EdkiiRedfishETagProtocol.h gEdkIIRedfishETagProtocolGuid =3D { 0x5706d368, 0xaf66, 0x48f5= , { 0x89, 0xfc, 0xa6, 0x61, 0xce, 0xb5, 0xa6, 0xa9 } } + ## Include/Protocol/EdkIIRedfishConfigLangMapProtocol.h + gEdkIIRedfishConfigLangMapProtocolGuid =3D { 0x1d9ba9fe, 0x5d5a, 0x4b= 66, {0x83, 0x5b, 0xe2, 0x5d, 0x13, 0x93, 0x4a, 0x9c } } ## Include/Protocol/EdkIIRedfishInterchangeData.h gEdkIIRedfishFeatureInterchangeDataProtocolGuid =3D { 0x4B8FF71C, 0x4A7B= , 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x00, 0x91 } } =20 diff --git a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapD= xe.c b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c new file mode 100644 index 0000000000..2762bbefab --- /dev/null +++ b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c @@ -0,0 +1,810 @@ +/** @file + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "RedfishConfigLangMapDxe.h" + +REDFISH_CONFIG_LANG_MAP_PRIVATE_DATA *mRedfishConfigLangMapPrivate =3D NU= LL; + +/** + Release REDFISH_CONFIG_LANG_MAP_RECORD resource + + @param[in] Record Pointer to REDFISH_CONFIG_LANG_MAP_RECORD instan= ce + + @retval EFI_SUCCESS REDFISH_CONFIG_LANG_MAP_RECORD is releas= ed successfully. + @retval EFI_INVALID_PARAMETER Record is NULL + +**/ +EFI_STATUS +ReleaseConfigLangMapRecord ( + IN REDFISH_CONFIG_LANG_MAP_RECORD *Record + ) +{ + if (Record =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Record->Uri !=3D NULL) { + FreePool (Record->Uri); + } + + if (Record->ConfigLang !=3D NULL) { + FreePool (Record->ConfigLang); + } + + FreePool (Record); + + return EFI_SUCCESS; +} + +/** + Create new resource map resource. + + @param[in] Uri The URI string matching to this ConfigLang. + @param[in] ConfigLang ConfigLang string. + + @retval REDFISH_CONFIG_LANG_MAP_RECORD * Pointer to newly created confi= g language map. + @retval NULL No memory available. + +**/ +REDFISH_CONFIG_LANG_MAP_RECORD * +NewConfigLangMapRecord ( + IN EFI_STRING Uri, + IN EFI_STRING ConfigLang + ) +{ + REDFISH_CONFIG_LANG_MAP_RECORD *NewRecord; + UINTN Size; + + if (IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (ConfigLang)) { + return NULL; + } + + NewRecord =3D AllocateZeroPool (sizeof (REDFISH_CONFIG_LANG_MAP_RECORD)); + if (NewRecord =3D=3D NULL) { + return NULL; + } + + Size =3D StrSize (Uri); + NewRecord->Uri =3D AllocateCopyPool (Size, Uri); + if (NewRecord->Uri =3D=3D NULL) { + goto ON_ERROR; + } + + NewRecord->Size =3D Size; + Size =3D StrSize (ConfigLang); + NewRecord->ConfigLang =3D AllocateCopyPool (Size, ConfigLang); + if (NewRecord->ConfigLang =3D=3D NULL) { + goto ON_ERROR; + } + + NewRecord->Size +=3D Size; + return NewRecord; + +ON_ERROR: + + if (NewRecord !=3D NULL) { + ReleaseConfigLangMapRecord (NewRecord); + } + + return NULL; +} + +/** + Add new config language map by given URI and ConfigLang string to specif= y List. + + @param[in] List Target config language map list to add. + @param[in] Uri The URI string matching to this ConfigLang. + @param[in] ConfigLang ConfigLang string. + + @retval EFI_SUCCESS config language map recourd is added. + @retval Others Fail to add config language map. + +**/ +EFI_STATUS +AddConfigLangMapRecord ( + IN REDFISH_CONFIG_LANG_MAP_LIST *List, + IN EFI_STRING Uri, + IN EFI_STRING ConfigLang + ) +{ + REDFISH_CONFIG_LANG_MAP_RECORD *NewRecord; + + if (List =3D=3D NULL || IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Config= Lang)) { + return EFI_INVALID_PARAMETER; + } + + NewRecord =3D NewConfigLangMapRecord (Uri, ConfigLang); + if (NewConfigLangMapRecord =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + InsertTailList (&List->Listheader, &NewRecord->List); + ++List->Count; + List->TotalSize +=3D NewRecord->Size; + + return EFI_SUCCESS; +} + +/** + Delete an config language map by given config language map instance. + + @param[in] List Target config language map list to be removed. + @param[in] Record Pointer to the instance to be deleted. + + @retval EFI_SUCCESS config language map recourd is removed. + @retval Others Fail to add config language map. + +**/ +EFI_STATUS +DeleteConfigLangMapRecord ( + IN REDFISH_CONFIG_LANG_MAP_LIST *List, + IN REDFISH_CONFIG_LANG_MAP_RECORD *Record + ) +{ + if (List =3D=3D NULL || Record =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + RemoveEntryList (&Record->List); + --List->Count; + List->TotalSize -=3D Record->Size; + + return ReleaseConfigLangMapRecord (Record); +} + +/** + Search on given ListHeader for given ConfigLang string. + + @param[in] ListHeader Target list to search. + @param[in] Query Target string to search. + @param[in] QueryIsUri Query string is URI string or not + + @retval REDFISH_CONFIG_LANG_MAP_RECORD Target in map is found. + @retval NULL No target in map with given quer= y is found. + +**/ +REDFISH_CONFIG_LANG_MAP_RECORD * +FindConfigLangMapRecord ( + IN LIST_ENTRY *ListHeader, + IN EFI_STRING Query, + IN BOOLEAN QueryIsUri + ) +{ + LIST_ENTRY *List; + REDFISH_CONFIG_LANG_MAP_RECORD *Record; + + if (IsListEmpty (ListHeader)) { + return NULL; + } + + if (IS_EMPTY_STRING (Query)) { + return NULL; + } + + Record =3D NULL; + List =3D GetFirstNode (ListHeader); + while (!IsNull (ListHeader, List)) { + Record =3D REDFISH_CONFIG_LANG_MAP_RECORD_FROM_LIST (List); + + if (QueryIsUri) { + if (StrCmp (Record->Uri, Query) =3D=3D 0) { + return Record; + } + } else { + if (StrCmp (Record->ConfigLang, Query) =3D=3D 0) { + return Record; + } + } + + List =3D GetNextNode (ListHeader, List); + } + + return NULL; +} + +#if CONFIG_LANG_MAP_DEBUG_ENABLED +/** + Debug output the config language map list. + + @param[in] ConfigLangMapList Target list to dump + @param[in] Msg Debug message string. + + @retval EFI_SUCCESS Debug dump finished. + @retval EFI_INVALID_PARAMETER ConfigLangMapList is NULL. + +**/ +EFI_STATUS +DumpConfigLangMapList ( + IN REDFISH_CONFIG_LANG_MAP_LIST *ConfigLangMapList, + IN EFI_STRING Msg + ) +{ + LIST_ENTRY *List; + REDFISH_CONFIG_LANG_MAP_RECORD *Record; + + if (ConfigLangMapList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (!IS_EMPTY_STRING (Msg)) { + DEBUG ((DEBUG_ERROR, "%s\n", Msg)); + } + + if (IsListEmpty (&ConfigLangMapList->Listheader)) { + DEBUG ((DEBUG_INFO, "ConfigLangMap list is empty\n")); + return EFI_NOT_FOUND; + } + + DEBUG ((DEBUG_INFO, "Count: %d Total Size: %d\n", ConfigLangMapList->Cou= nt, ConfigLangMapList->TotalSize)); + Record =3D NULL; + List =3D GetFirstNode (&ConfigLangMapList->Listheader); + while (!IsNull (&ConfigLangMapList->Listheader, List)) { + Record =3D REDFISH_CONFIG_LANG_MAP_RECORD_FROM_LIST (List); + + DEBUG ((DEBUG_INFO, "ConfigLang: %s Uri: %s Size: %d\n", Record->Confi= gLang, Record->Uri, Record->Size)); + + List =3D GetNextNode (&ConfigLangMapList->Listheader, List); + } + + return EFI_SUCCESS; +} + +/** + Debug output raw data buffer. + + @param[in] Buffer Debug output data buffer. + @param[in] BufferSize The size of Buffer in byte. + + @retval EFI_SUCCESS Debug dump finished. + @retval EFI_INVALID_PARAMETER Buffer is NULL. + +**/ +EFI_STATUS +DumpRawBuffer ( + IN UINT8 *Buffer, + IN UINTN BufferSize + ) +{ + UINTN Index; + CHAR16 *Seeker; + + if (Buffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Index =3D 0; + Seeker =3D (CHAR16 *)Buffer; + DEBUG ((DEBUG_ERROR, "Buffer size: %d\n", BufferSize)); + while (Seeker[Index] !=3D '\0') { + DEBUG ((DEBUG_ERROR, "(%d) %c ", (Index + 1), Seeker[Index])); + + ++Index; + } + DEBUG ((DEBUG_ERROR, "\n")); + + return EFI_SUCCESS; +} +#endif + +/** + Release all ConfigLangMap from list. + + @param[in] ConfigLangMapList The list to be released. + + @retval EFI_SUCCESS All config lang is released. + @retval EFI_INVALID_PARAMETER ConfigLangMapList is NULL. + +**/ +EFI_STATUS +ReleaseConfigLangMapList ( + IN REDFISH_CONFIG_LANG_MAP_LIST *ConfigLangMapList + ) +{ + LIST_ENTRY *List; + LIST_ENTRY *Next; + REDFISH_CONFIG_LANG_MAP_RECORD *Record; + + if (ConfigLangMapList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (IsListEmpty (&ConfigLangMapList->Listheader)) { + return EFI_SUCCESS; + } + + Record =3D NULL; + Next =3D NULL; + List =3D GetFirstNode (&ConfigLangMapList->Listheader); + while (!IsNull (&ConfigLangMapList->Listheader, List)) { + Record =3D REDFISH_CONFIG_LANG_MAP_RECORD_FROM_LIST (List); + Next =3D GetNextNode (&ConfigLangMapList->Listheader, List); + + DeleteConfigLangMapRecord (ConfigLangMapList, Record); + + List =3D Next; + } + + return EFI_SUCCESS; +} + +/** + Save config lang in list to UEFI variable. + + @param[in] ConfigLangMapList The list to be saved. + @param[in] VariableName The UEFI variable name. + + @retval EFI_SUCCESS All config lang is saved. + @retval EFI_INVALID_PARAMETER VariableName or ConfigLangMapList is NUL= L. + +**/ +EFI_STATUS +SaveConfigLangMapList ( + IN REDFISH_CONFIG_LANG_MAP_LIST *ConfigLangMapList, + IN EFI_STRING VariableName + ) +{ + LIST_ENTRY *List; + REDFISH_CONFIG_LANG_MAP_RECORD *Record; + UINT8 *VarData; + VOID *Data; + EFI_STRING Seeker; + UINTN VarSize; + UINTN StringSize; + EFI_STATUS Status; + + if (ConfigLangMapList =3D=3D NULL || IS_EMPTY_STRING (VariableName)) { + return EFI_INVALID_PARAMETER; + } + + if (IsListEmpty (&ConfigLangMapList->Listheader)) { + return EFI_SUCCESS; + } + + // + // Caculate the total size we need to keep ConfigLangMap list. + // + VarSize =3D ConfigLangMapList->TotalSize + sizeof (CHAR16); // terminato= r character + VarData =3D AllocateZeroPool (VarSize); + if (VarData =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Seeker =3D (EFI_STRING)VarData; + Record =3D NULL; + List =3D GetFirstNode (&ConfigLangMapList->Listheader); + while (!IsNull (&ConfigLangMapList->Listheader, List)) { + Record =3D REDFISH_CONFIG_LANG_MAP_RECORD_FROM_LIST (List); + + StringSize =3D StrSize (Record->Uri); + CopyMem (Seeker, Record->Uri, StringSize); + + Seeker +=3D (StringSize / sizeof (CHAR16) - 1); + *Seeker =3D '|'; + ++Seeker; + + StringSize =3D StrSize (Record->ConfigLang); + CopyMem (Seeker, Record->ConfigLang, StringSize); + + Seeker +=3D (StringSize / sizeof (CHAR16) - 1); + *Seeker =3D '\n'; + + ++Seeker; + + List =3D GetNextNode (&ConfigLangMapList->Listheader, List);; + } + + *Seeker =3D '\0'; + +#if CONFIG_LANG_MAP_DEBUG_ENABLED + DumpRawBuffer (VarData, VarSize); +#endif + + ASSERT (((UINTN)Seeker - (UINTN)VarData + sizeof (CHAR16)) =3D=3D VarSiz= e); + + // + // Check if variable exists already. If yes, remove it first. + // + Status =3D GetVariable2 ( + VariableName, + &mRedfishVariableGuid, + (VOID *)&Data, + NULL + ); + if (!EFI_ERROR (Status)) { + FreePool (Data); + gRT->SetVariable (VariableName, &mRedfishVariableGuid, VARIABLE_ATTRIB= UTE_NV_BS, 0, NULL); + } + + + return gRT->SetVariable (VariableName, &mRedfishVariableGuid, VARIABLE_A= TTRIBUTE_NV_BS, VarSize, (VOID *)VarData); +} + +/** + Read config lang map from UEFI variable if it exists. + + @param[in] ConfigLangMapList The list to be loaded. + @param[in] VariableName The UEFI variable name. + + @retval EFI_SUCCESS All config lang is read successfully. + @retval EFI_INVALID_PARAMETER VariableName or ConfigLangMapList is NUL= L. + @retval EFI_NOT_FOUND No config lang is found on UEFI variable. + +**/ +EFI_STATUS +InitialConfigLangMapList ( + IN REDFISH_CONFIG_LANG_MAP_LIST *ConfigLangMapList, + IN EFI_STRING VariableName + ) +{ + UINT8 *VarData; + EFI_STRING UriPointer; + EFI_STRING ConfigLangPointer; + EFI_STRING Seeker; + UINTN VariableSize; + EFI_STATUS Status; + + if (ConfigLangMapList =3D=3D NULL || IS_EMPTY_STRING (VariableName)) { + return EFI_INVALID_PARAMETER; + } + + // + // Check if variable exists already. + // + Status =3D GetVariable2 ( + VariableName, + &mRedfishVariableGuid, + (VOID *)&VarData, + &VariableSize + ); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + Seeker =3D (EFI_STRING)VarData; + UriPointer =3D (EFI_STRING)VarData; + ConfigLangPointer =3D (EFI_STRING)VarData; + while (*Seeker !=3D '\0') { + + // + // Find URI + // + Seeker =3D StrStr (UriPointer, L"|"); + if (Seeker =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, data corrupted\n", __FUNCTION__)); + Status =3D EFI_DEVICE_ERROR; + goto ON_ERROR; + } + + *Seeker =3D '\0'; + ConfigLangPointer =3D ++Seeker; + + // + // Find config language map + // + Seeker =3D StrStr (ConfigLangPointer, L"\n"); + if (Seeker =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, data corrupted\n", __FUNCTION__)); + Status =3D EFI_DEVICE_ERROR; + goto ON_ERROR; + } + + *Seeker =3D '\0'; + + AddConfigLangMapRecord (ConfigLangMapList, UriPointer, ConfigLangPoint= er); + + UriPointer =3D ++Seeker; + } + +#if CONFIG_LANG_MAP_DEBUG_ENABLED + DumpConfigLangMapList (ConfigLangMapList, L"Initial ConfigLangMap List f= rom Variable"); +#endif + + Status =3D EFI_SUCCESS; + +ON_ERROR: + + FreePool (VarData); + + return Status; +} + +/** + Get string in database by given query string. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_LAN= G_MAP_PROTOCOL instance. + @param[in] QueryStringType The type of given QueryString. + @param[in] QueryString Query string. + @param[out] ResultString Returned string mapping to give que= ry string. + + @retval EFI_SUCCESS The result is found successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter is given. + +**/ +EFI_STATUS +RedfishConfigLangMapGet ( + IN EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL *This, + IN REDFISH_CONFIG_LANG_MAP_GET_TYPE QueryStringType, + IN EFI_STRING QueryString, + OUT EFI_STRING *ResultString + ) +{ + REDFISH_CONFIG_LANG_MAP_RECORD *Target; + REDFISH_CONFIG_LANG_MAP_PRIVATE_DATA *Private; + EFI_STRING Result; + + if (This =3D=3D NULL || IS_EMPTY_STRING (QueryString) || ResultString = =3D=3D NULL || QueryStringType >=3D RedfishGetTypeMax) { + return EFI_INVALID_PARAMETER; + } + + Private =3D REDFISH_CONFIG_LANG_MAP_PRIVATE_FROM_THIS (This); + + *ResultString =3D NULL; + + Target =3D FindConfigLangMapRecord (&Private->ConfigLangList.Listheader,= QueryString, (QueryStringType =3D=3D RedfishGetTypeUri)); + if (Target =3D=3D NULL) { +#if CONFIG_LANG_MAP_DEBUG_ENABLED + DumpConfigLangMapList (&Private->ConfigLangList, L"EFI_NOT_FOUND"); +#endif + return EFI_NOT_FOUND; + } + + Result =3D (QueryStringType =3D=3D RedfishGetTypeUri ? Target->ConfigLan= g : Target->Uri); + *ResultString =3D AllocateCopyPool (StrSize (Result), Result); + if (*ResultString =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + return EFI_SUCCESS; +} + + +/** + Save URI string which maps to given ConfigLang. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_LANG_MA= P_PROTOCOL instance. + @param[in] ConfigLang Config language to set + @param[in] Uri Uri which is mapping to give ConfigLang= . If Uri is NULL, + the record will be removed. + + @retval EFI_SUCCESS Uri is saved successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishConfigLangMapSet ( + IN EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL *This, + IN EFI_STRING ConfigLang, + IN EFI_STRING Uri OPTIONAL + ) +{ + REDFISH_CONFIG_LANG_MAP_RECORD *Target; + REDFISH_CONFIG_LANG_MAP_PRIVATE_DATA *Private; + EFI_STATUS Status; + + if (This =3D=3D NULL || IS_EMPTY_STRING (ConfigLang)) { + return EFI_INVALID_PARAMETER; + } + + Private =3D REDFISH_CONFIG_LANG_MAP_PRIVATE_FROM_THIS (This); + + Status =3D EFI_NOT_FOUND; + Target =3D FindConfigLangMapRecord (&Private->ConfigLangList.Listheader,= ConfigLang, FALSE); + if (Target !=3D NULL) { + // + // Remove old one and create new one. + // + Status =3D DeleteConfigLangMapRecord (&Private->ConfigLangList, Target= ); + } + + // + // When Uri is NULL, it means that we want to remov this record. + // + if (Uri =3D=3D NULL) { + return Status; + } + + return AddConfigLangMapRecord (&Private->ConfigLangList, Uri, ConfigLang= ); +} + +/** + Refresh the resource map database and save database to variable. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_LANG_MA= P_PROTOCOL instance. + + @retval EFI_SUCCESS This handler has been stoped successful= ly. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishConfigLangMapFlush ( + IN EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL *This + ) +{ + REDFISH_CONFIG_LANG_MAP_PRIVATE_DATA *Private; + EFI_STATUS Status; + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Private =3D REDFISH_CONFIG_LANG_MAP_PRIVATE_FROM_THIS (This); + + Status =3D SaveConfigLangMapList (&Private->ConfigLangList, Private->Var= iableName); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, save ConfigLangMap list to variable: %s fail= ed: %r\n", __FUNCTION__, Private->VariableName, Status)); + } + + return Status; +} + +/** + Callback function executed when the ExitBootService event group is signa= led. + + @param[in] Event Event whose notification function is being invoked. + @param[out] Context Pointer to the Context buffer + +**/ +VOID +EFIAPI +RedfishConfigLangMapOnExitBootService ( + IN EFI_EVENT Event, + OUT VOID *Context + ) +{ + // + // Memory is about to be released. Keep list into variable. + // + RedfishConfigLangMapFlush (&mRedfishConfigLangMapPrivate->Protocol); +} + +/** + Unloads an image. + + @param[in] ImageHandle Handle that identifies the image to be= unloaded. + + @retval EFI_SUCCESS The image has been unloaded. + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +EFI_STATUS +EFIAPI +RedfishConfigLangMapDriverUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + + if (mRedfishConfigLangMapPrivate !=3D NULL) { + + Status =3D gBS->UninstallProtocolInterface ( + mRedfishConfigLangMapPrivate->ImageHandle, + &gEdkIIRedfishConfigLangMapProtocolGuid, + (VOID*)&mRedfishConfigLangMapPrivate->Protocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, can not uninstall gEdkIIRedfishConfigLangM= apProtocolGuid: %r\n", __FUNCTION__, Status)); + ASSERT (FALSE); + } + + ReleaseConfigLangMapList (&mRedfishConfigLangMapPrivate->ConfigLangLis= t); + + if (mRedfishConfigLangMapPrivate->VariableName !=3D NULL) { + FreePool (mRedfishConfigLangMapPrivate->VariableName); + } + + if (mRedfishConfigLangMapPrivate->ExitBootEvent !=3D NULL) { + gBS->CloseEvent (mRedfishConfigLangMapPrivate->ExitBootEvent); + } + + if (mRedfishConfigLangMapPrivate->ProvisionEvent !=3D NULL) { + gBS->CloseEvent (mRedfishConfigLangMapPrivate->ProvisionEvent); + } + + FreePool (mRedfishConfigLangMapPrivate); + mRedfishConfigLangMapPrivate =3D NULL; + } + + return EFI_SUCCESS; +} + +// +// EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL. +// +EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL mRedfishConfigLangMapProtocol =3D { + RedfishConfigLangMapGet, + RedfishConfigLangMapSet, + RedfishConfigLangMapFlush +}; + +/** + 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. + + @param[in] ImageHandle The firmware allocated handle for the UEFI= image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishConfigLangMapDriverEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + mRedfishConfigLangMapPrivate =3D AllocateZeroPool (sizeof (REDFISH_CONFI= G_LANG_MAP_PRIVATE_DATA)); + if (mRedfishConfigLangMapPrivate =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + InitializeListHead (&mRedfishConfigLangMapPrivate->ConfigLangList.Listhe= ader); + mRedfishConfigLangMapPrivate->VariableName =3D AllocateCopyPool (StrSize= (CONFIG_LANG_MAP_VARIABLE_NAME), CONFIG_LANG_MAP_VARIABLE_NAME); + if (mRedfishConfigLangMapPrivate->VariableName =3D=3D NULL) { + goto ON_ERROR; + } + + mRedfishConfigLangMapPrivate->ImageHandle =3D ImageHandle; + CopyMem (&mRedfishConfigLangMapPrivate->Protocol, &mRedfishConfigLangMap= Protocol, sizeof (EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL)); + + Status =3D gBS->InstallProtocolInterface ( + &ImageHandle, + &gEdkIIRedfishConfigLangMapProtocolGuid, + EFI_NATIVE_INTERFACE, + (VOID*)&mRedfishConfigLangMapPrivate->Protocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, can not install gEdkIIRedfishConfigLangMapPr= otocolGuid: %r\n", __FUNCTION__, Status)); + ASSERT (FALSE); + goto ON_ERROR; + } + + // + // Create Exit Boot Service event. + // + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + RedfishConfigLangMapOnExitBootService, + NULL, + &gEfiEventExitBootServicesGuid, + &mRedfishConfigLangMapPrivate->ExitBootEvent + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", = __FUNCTION__)); + goto ON_ERROR; + } + + // + // Read existing record from variable. + // + Status =3D InitialConfigLangMapList (&mRedfishConfigLangMapPrivate->Conf= igLangList, mRedfishConfigLangMapPrivate->VariableName); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a, Initial ConfigLangMap List: %r\n", __FUNCTION= __, Status)); + } + + // + // Register after provisioning event + // + Status =3D CreateAfterProvisioningEvent ( + RedfishConfigLangMapOnExitBootService, + NULL, + &mRedfishConfigLangMapPrivate->ProvisionEvent + ); + + return EFI_SUCCESS; + +ON_ERROR: + + RedfishConfigLangMapDriverUnload (ImageHandle); + + return Status; +} diff --git a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapD= xe.h b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.h new file mode 100644 index 0000000000..d053921068 --- /dev/null +++ b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.h @@ -0,0 +1,71 @@ +/** @file + Common header file for RedfishConfigLangMapDxe driver. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_CONFIG_LANG_MAP_DXE_H_ +#define REDFISH_CONFIG_LANG_MAP_DXE_H_ + +#include +#include + +// +// Libraries +// +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define CONFIG_LANG_MAP_VARIABLE_NAME L"RedfishConfigLangMap" +#define CONFIG_LANG_MAP_DEBUG_ENABLED 0x00 + +// +// Definition of REDFISH_CONFIG_LANG_MAP_RECORD +// +typedef struct { + LIST_ENTRY List; + EFI_STRING Uri; + EFI_STRING ConfigLang; + UINTN Size; +} REDFISH_CONFIG_LANG_MAP_RECORD; + +#define REDFISH_CONFIG_LANG_MAP_RECORD_FROM_LIST(a) BASE_CR (a, REDFISH_C= ONFIG_LANG_MAP_RECORD, List) + +// +// Definition of REDFISH_CONFIG_LANG_MAP_LIST +// +typedef struct { + LIST_ENTRY Listheader; + UINTN TotalSize; + UINTN Count; +} REDFISH_CONFIG_LANG_MAP_LIST; + +// +// Definition of REDFISH_CONFIG_LANG_MAP_PRIVATE_DATA +// +typedef struct { + EFI_HANDLE ImageHandle; + REDFISH_CONFIG_LANG_MAP_LIST ConfigLangList; + EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL Protocol; + EFI_STRING VariableName; + EFI_EVENT ExitBootEvent; + EFI_EVENT ProvisionEvent; +} REDFISH_CONFIG_LANG_MAP_PRIVATE_DATA; + +#define REDFISH_CONFIG_LANG_MAP_PRIVATE_FROM_THIS(a) BASE_CR (a, REDFISH_= CONFIG_LANG_MAP_PRIVATE_DATA, Protocol) + +#endif diff --git a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapD= xe.inf b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.i= nf new file mode 100644 index 0000000000..9f19533815 --- /dev/null +++ b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf @@ -0,0 +1,46 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001000b + BASE_NAME =3D RedfishConfigLangMapDxe + FILE_GUID =3D F4121E32-454D-4E51-AB4B-DAA577833E95 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D RedfishConfigLangMapDriverEntryPoint + UNLOAD_IMAGE =3D RedfishConfigLangMapDriverUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RedfishConfigLangMapDxe.h + RedfishConfigLangMapDxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + UefiLib + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + UefiDriverEntryPoint + RedfishEventLib + +[Protocols] + gEdkIIRedfishConfigLangMapProtocolGuid ## PRODUCED ## + +[Guids] + gEfiEventExitBootServicesGuid ## CONSUMED ## + +[Depex] + TRUE --=20 2.32.0.windows.2 -=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 (#91874): https://edk2.groups.io/g/devel/message/91874 Mute This Topic: https://groups.io/mt/92641648/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- From nobody Fri Apr 26 08:47:54 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+91875+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+91875+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885900; cv=none; d=zohomail.com; s=zohoarc; b=E/IIVOGxECI6JP9hiqHjFjatvpBeJBS19VPC1nK8t8Xz8Gug6jhBRwWXfq6MqxmLGshaWw8o+4d5F4K5odWC0w7gGMsTa2GZPhDv71RDe8EUGXVTn8m5srMfpQ0cCqhPGeEXV/XbmDBW6zsqoEKqr/kOed3kVGnHZp5kTKHzmd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885900; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=n0QD70xQ726tcogjzlmgGha+LKKAgZGTIdhLuanmg+I=; b=ACCoPiR1xu9V2RnmrZEaL8XGAVpp6wq/M8n/ZjGOWIGrlDOBq6uRVZoUnsjbOwUHoga32cYint8KEEFLVipffmymyRB/vX5MzzQ6qeoJ/iknQxyY9jrCp1h4GZdncdMxWIdcdQlWBG+EvH1GFImb5kFCW8lyVZBu7x4pZIvPEqw= 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+91875+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 1658885900568126.6611424758147; Tue, 26 Jul 2022 18:38:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 28kOYY1788612xaa8aJGngy8; Tue, 26 Jul 2022 18:38:20 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.14922.1658885899203891583 for ; Tue, 26 Jul 2022 18:38:19 -0700 X-Received: from pps.filterd (m0148664.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0q5Uu030585; Wed, 27 Jul 2022 01:38:16 GMT X-Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjew9xsr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:16 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14878.it.hpe.com (Postfix) with ESMTPS id BE29DD2C5; Wed, 27 Jul 2022 01:38:15 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 7DE6A8052CC; Wed, 27 Jul 2022 01:38:14 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 07/15] edk2-staging/RedfishClientPkg: Update ETag driver Date: Wed, 27 Jul 2022 09:37:54 +0800 Message-Id: <20220727013802.247-8-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: us3gKK6_xSkw9idYKijeNbfV9uZF-8EJ X-Proofpoint-GUID: us3gKK6_xSkw9idYKijeNbfV9uZF-8EJ 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,nickle.wang@hpe.com X-Gm-Message-State: F6iNSKVxtonhYU1yxkJnKBaBx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885900; bh=OQuqYpN/v3Q/GMZ6DWrr4U2JdT7hg+ISeLqew7YQEng=; h=Cc:Date:From:Reply-To:Subject:To; b=X1tnfL4j0OiB3bw+v3gBqqmx0Vln12Q1n2cVTJ4iBjtgekqu4LgC2QLSf67WAsammqz vbZrYSMTXHlh+wN0V2di64Ka5+tjroMQ66mIOu/iawYt0z2kP7JIxJP3pxN78aqbBupVj SJsX30kh451jThLK6B3l1+I948BykLrPMRM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885901035100029 Content-Type: text/plain; charset="utf-8" Update ETag driver and use specific variable GUID. Also fix the typo in comment. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- RedfishClientPkg/RedfishClientPkg.dec | 2 +- RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.c | 10 +++++----- RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 7bdab5be0c..67929341df 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -36,7 +36,7 @@ gEdkIIRedfishFeatureProtocolGuid =3D { 0x785CC694, 0x4930, 0xEFBF= , { 0x2A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0xAA, 0x34 } } ## Include/Protocol/EdkIIRedfishResourceConfigProtocol.h gEdkIIRedfishResourceConfigProtocolGuid =3D { 0x6f164c68, 0xfb09, 0x4646= , { 0xa8, 0xd3, 0x24, 0x11, 0x5d, 0xab, 0x3e, 0xe7 } } - ## Include/Protocol/EdkiiRedfishETagProtocol.h + ## Include/Protocol/EdkIIRedfishETagProtocol.h gEdkIIRedfishETagProtocolGuid =3D { 0x5706d368, 0xaf66, 0x48f5= , { 0x89, 0xfc, 0xa6, 0x61, 0xce, 0xb5, 0xa6, 0xa9 } } ## Include/Protocol/EdkIIRedfishConfigLangMapProtocol.h gEdkIIRedfishConfigLangMapProtocolGuid =3D { 0x1d9ba9fe, 0x5d5a, 0x4b= 66, {0x83, 0x5b, 0xe2, 0x5d, 0x13, 0x93, 0x4a, 0x9c } } diff --git a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.c b/RedfishClie= ntPkg/RedfishETagDxe/RedfishETagDxe.c index 73d3a8c39a..52015672f9 100644 --- a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.c +++ b/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.c @@ -1,6 +1,6 @@ /** @file =20 - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -398,17 +398,17 @@ SaveETagList ( // Status =3D GetVariable2 ( VariableName, - &gEfiCallerIdGuid, + &mRedfishVariableGuid, (VOID *)&Data, NULL ); if (!EFI_ERROR (Status)) { FreePool (Data); - gRT->SetVariable (VariableName, &gEfiCallerIdGuid, VARIABLE_ATTRIBUTE_= NV_BS, 0, NULL); + gRT->SetVariable (VariableName, &mRedfishVariableGuid, VARIABLE_ATTRIB= UTE_NV_BS, 0, NULL); } =20 =20 - return gRT->SetVariable (VariableName, &gEfiCallerIdGuid, VARIABLE_ATTRI= BUTE_NV_BS, VarSize, (VOID *)VarData); + return gRT->SetVariable (VariableName, &mRedfishVariableGuid, VARIABLE_A= TTRIBUTE_NV_BS, VarSize, (VOID *)VarData); } =20 /** @@ -444,7 +444,7 @@ InitialETagList ( // Status =3D GetVariable2 ( VariableName, - &gEfiCallerIdGuid, + &mRedfishVariableGuid, (VOID *)&VarData, &VariableSize ); diff --git a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.h b/RedfishClie= ntPkg/RedfishETagDxe/RedfishETagDxe.h index 58925b4a51..3deab377dc 100644 --- a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.h +++ b/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.h @@ -1,7 +1,7 @@ /** @file Common header file for RedfishETagDxe driver. =20 - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -11,6 +11,7 @@ #define REDFISH_ETAG_DXE_H_ =20 #include +#include =20 // // Libraries @@ -30,7 +31,6 @@ #include =20 #define ETAG_VARIABLE_NAME L"RedfishETag" -#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') #define ETAG_DEBUG_ENABLED 0x00 =20 // --=20 2.32.0.windows.2 -=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 (#91875): https://edk2.groups.io/g/devel/message/91875 Mute This Topic: https://groups.io/mt/92641649/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- From nobody Fri Apr 26 08:47:54 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+91876+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+91876+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885907; cv=none; d=zohomail.com; s=zohoarc; b=Xl2iu6n/30SMJXAx7/+aioNJMED6vSzqBoXRydIJfTyX+ZpMG+pHjnCY/TTYj+rASl4Of0jegYhaLE6PgPz5LoGN7dy8we86/M7e4Gc+MT9CpAt2eC/A77uQt4kcYvh3vK8Oja2qpZRqgEicKMViBq26ml7xPwnd4xkfMTgwFsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885907; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TMcK0xv7+bZ9OizDGGPXyz44vVh6pFscgdZw/Wuy6xQ=; b=cV5VAG5aJladty8BMgQvAQfH184hDowHr9lQydsZRDe6lzNqh0C5oJdRCshcnoVs6ZZVlG84trcwx/tsDfpPU+8/YRpoJZOp+PSnEliq7w+g+B0yNxySxxLW15Wrhx26scdkAvA3QoTiktE4DngnkHAw0sX9Vj/q91C0gE1ggLg= 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+91876+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 1658885907951810.697518704344; Tue, 26 Jul 2022 18:38:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id oXVuYY1788612xr49AcXJR7w; Tue, 26 Jul 2022 18:38:26 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.14833.1658885900063422745 for ; Tue, 26 Jul 2022 18:38:20 -0700 X-Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R1SoNg005140; Wed, 27 Jul 2022 01:38:18 GMT X-Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjuqmr2cr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:18 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id 660858001AA; Wed, 27 Jul 2022 01:38:17 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 25374804D10; Wed, 27 Jul 2022 01:38:15 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 08/15] edk2-staging/RedfishClientPkg: Update Redfish feature core driver Date: Wed, 27 Jul 2022 09:37:55 +0800 Message-Id: <20220727013802.247-9-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: Ri3y790tQ1dErDHGNeERSY1nmVvDcqUQ X-Proofpoint-ORIG-GUID: Ri3y790tQ1dErDHGNeERSY1nmVvDcqUQ 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,nickle.wang@hpe.com X-Gm-Message-State: BcL2WrEZIAtLpiZi9txvyV3dx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885906; bh=Ch8JPeK3yXCm48PWDCPXKhJPgmcRzLAkLz5QnWhefUU=; h=Cc:Date:From:Reply-To:Subject:To; b=aEK63vupqbxx5LCh/oZai09vgyh4FJNVixHosi+dLpApm9KJYiSkV8fGnX8R3+C0reE f/VayhE6J9rYMN3OfzAX0gcbwLyTbpHK/QwbUncn9xUd+cBT0Ubv/IaMYBqRVJSk3k8Yh NiwMKPGKbBSf6yWAeoXN5qtDB9D6nLIm4Dc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885909130100013 Content-Type: text/plain; charset="utf-8" Update Redfish feature core driver to support Redfish resource with multiple parents. A resource may be presented in different resource and the link in different resource point to the same location. Also add interchange data interface in feature core driver so feature core driver can talk to feature drivers directly. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../Include/Protocol/EdkIIRedfishFeature.h | 20 +- .../RedfishFeatureCoreDxe.c | 290 ++++++++++++++++-- .../RedfishFeatureCoreDxe.h | 20 +- .../RedfishFeatureCoreDxe.inf | 5 +- 4 files changed, 278 insertions(+), 57 deletions(-) diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h b/Redf= ishClientPkg/Include/Protocol/EdkIIRedfishFeature.h index 036622128d..26814c8786 100644 --- a/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h @@ -1,7 +1,7 @@ /** @file This file defines the EDKII_REDFISH_FEATURE_PROTOCOL interface. =20 - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -10,6 +10,8 @@ #ifndef EDKII_REDFISH_FEATURE_H_ #define EDKII_REDFISH_FEATURE_H_ =20 +#include + typedef struct _EDKII_REDFISH_FEATURE_PROTOCOL EDKII_REDFISH_FEATURE_PROTO= COL; =20 #define EDKII_REDFISH_FEATURE_PROTOCOL_GUID \ @@ -23,25 +25,13 @@ typedef enum { CallbackActionMax } FEATURE_CALLBACK_ACTION; =20 -typedef enum { - InformationTypeNone =3D 0, ///< Invalid information. - InformationTypeCollectionMemberUri, ///< URI to the new created collecti= on member. - InformationTypeMax -} FEATURE_RETURNED_INFORMATION_TYPE; - -typedef struct { - FEATURE_RETURNED_INFORMATION_TYPE Type; -} FEATURE_RETURNED_INFORMATION; - /** The callback function provided by Redfish Feature driver. =20 @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. + @param[in,out] ExchangeInformation The pointer to RESOURCE_INFORMATION_E= XCHANGE. =20 @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. @retval Others Some errors happened. @@ -53,7 +43,7 @@ EFI_STATUS IN EDKII_REDFISH_FEATURE_PROTOCOL *This, IN FEATURE_CALLBACK_ACTION FeatureAction, IN VOID *Context, - IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned + IN OUT RESOURCE_INFORMATION_EXCHANGE *ExchangeInformation ); /** The registration function for the Redfish Feature driver. diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c index 49e1cd6b60..3414f0c942 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c @@ -2,7 +2,7 @@ RedfishFeatureCoreDxe produces EdkIIRedfishFeatureCoreProtocol for EDK2 Redfish Feature driver registration. =20 - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -13,38 +13,188 @@ EFI_EVENT mEdkIIRedfishFeatureDriverStartupEvent; REDFISH_FEATURE_STARTUP_CONTEXT mFeatureDriverStartupContext; REDFISH_FEATURE_INTERNAL_DATA *ResourceUriNodeList; +RESOURCE_INFORMATION_EXCHANGE *mInformationExchange; + +/** + Setup the information to deliver to child feature/collection driver. + + @param[in] ThisList REDFISH_FEATURE_INTERNAL_DATA insta= nce. + @param[in] ParentConfgLanguageUri Parent configure language URI. + +**/ +EFI_STATUS +SetupExchangeInformationInfo ( + IN REDFISH_FEATURE_INTERNAL_DATA *ThisList, + IN EFI_STRING ParentConfgLanguageUri + ) +{ + ThisList->InformationExchange->SendInformation.ParentUri =3D (EFI_STRING= )AllocateZeroPool (MaxParentUriLength * sizeof (CHAR16)); + if (ThisList->InformationExchange->SendInformation.ParentUri =3D=3D NULL= ) { + return EFI_OUT_OF_RESOURCES; + } + ThisList->InformationExchange->SendInformation.PropertyName =3D (EFI_STR= ING)AllocateZeroPool(MaxNodeNameLength * sizeof (CHAR16)); + if (ThisList->InformationExchange->SendInformation.PropertyName =3D=3D N= ULL) { + return EFI_OUT_OF_RESOURCES; + } + ThisList->InformationExchange->SendInformation.FullUri =3D (EFI_STRING)A= llocateZeroPool(MaxParentUriLength * sizeof (CHAR16)); + if (ThisList->InformationExchange->SendInformation.FullUri =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Setup property name + // + StrCpyS (ThisList->InformationExchange->SendInformation.PropertyName, Ma= xNodeNameLength, ThisList->NodeName); + + // + // Setup parent config language URI + // + StrCpyS (ThisList->InformationExchange->SendInformation.ParentUri, MaxPa= rentUriLength, ParentConfgLanguageUri); + + // + // Full config language URI + // + StrCpyS (ThisList->InformationExchange->SendInformation.FullUri, + MaxParentUriLength, + ThisList->InformationExchange->SendInformation.ParentUri + ); + if (StrLen (ThisList->InformationExchange->SendInformation.FullUri) !=3D= 0) { + StrCatS (ThisList->InformationExchange->SendInformation.FullUri, MaxPa= rentUriLength, L"/"); + } + StrCatS (ThisList->InformationExchange->SendInformation.FullUri, MaxPare= ntUriLength, ThisList->InformationExchange->SendInformation.PropertyName); + return EFI_SUCCESS; +} + +/** + Destroy the exchange information. + + @param[in] ThisList REDFISH_FEATURE_INTERNAL_DATA instance. + +**/ +EFI_STATUS +DestroryExchangeInformation ( + IN REDFISH_FEATURE_INTERNAL_DATA *ThisList + ) +{ + + if (ThisList->InformationExchange !=3D NULL) { + if (ThisList->InformationExchange->SendInformation.Type =3D=3D Informa= tionTypeCollectionMemberUri) { + if (ThisList->InformationExchange->SendInformation.ParentUri !=3D NU= LL) { + FreePool (ThisList->InformationExchange->SendInformation.ParentUri= ); + ThisList->InformationExchange->SendInformation.ParentUri =3D NULL; + } + if (ThisList->InformationExchange->SendInformation.PropertyName !=3D= NULL) { + FreePool (ThisList->InformationExchange->SendInformation.PropertyN= ame); + ThisList->InformationExchange->SendInformation.PropertyName =3D NU= LL; + } + if (ThisList->InformationExchange->SendInformation.FullUri !=3D NULL= ) { + FreePool (ThisList->InformationExchange->SendInformation.FullUri); + ThisList->InformationExchange->SendInformation.FullUri =3D NULL; + } + } + + if (ThisList->InformationExchange->ReturnedInformation.Type =3D=3D Inf= ormationTypeCollectionMemberConfigLanguage) { + DestroyConfiglanguageList (&ThisList->InformationExchange->ReturnedI= nformation.ConfigureLanguageList); + } + + ThisList->InformationExchange->SendInformation.Type =3D InformationTyp= eNone; + ThisList->InformationExchange->ReturnedInformation.Type =3D Informatio= nTypeNone; + + } + return EFI_SUCCESS; +} =20 /** Startup child feature drivers and it's sibing feature drivers. =20 - @param[in] ThisFeatureDriverList This feature driver list. - @param[in] StartupContext Start up information + @param[in] ThisFeatureDriverList This feature driver list. + @param[in] CurrentConfigLanguageUri The current parent configure langua= ge URI. + @param[in] StartupContext Start up information =20 **/ VOID StartUpFeatureDriver ( IN REDFISH_FEATURE_INTERNAL_DATA *ThisFeatureDriverList, + IN EFI_STRING CurrentConfigLanguageUri, IN REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext ) { EFI_STATUS Status; + UINTN Index; REDFISH_FEATURE_INTERNAL_DATA *ThisList; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigLangList; + EFI_STRING NextParentUri; + + NextParentUri =3D (EFI_STRING)AllocateZeroPool (MaxParentUriLength * siz= eof (CHAR16)); + if (NextParentUri =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: Fail to allocate memory for parent configure = language.\n", __FUNCTION__)); + return; + } + if (CurrentConfigLanguageUri !=3D NULL) { + StrCpyS(NextParentUri, MaxParentUriLength, CurrentConfigLanguageUri); + } =20 ThisList =3D ThisFeatureDriverList; while (TRUE) { if (ThisList->Callback !=3D NULL) { - Status =3D ThisList->Callback( - StartupContext->This, - StartupContext->Action, - ThisList->Context, - &ThisList->ReturnedInformation - ); + ThisList->InformationExchange =3D mInformationExchange; + Status =3D SetupExchangeInformationInfo (ThisList, NextParentUri); + if (!EFI_ERROR (Status)) { + Status =3D ThisList->Callback( + StartupContext->This, + StartupContext->Action, + ThisList->Context, + ThisList->InformationExchange + ); + } if (EFI_ERROR (Status)) { - DEBUG((DEBUG_ERROR, "%a: Callback to EDK2 Redfish feature driver f= ail.", __FUNCTION__)); + DEBUG((DEBUG_ERROR, "%a: Callback to EDK2 Redfish feature driver f= ail: %s.\n", __FUNCTION__, ThisList->InformationExchange->SendInformation.F= ullUri)); } } - if (ThisList->ChildList !=3D NULL) { - StartUpFeatureDriver (ThisList->ChildList, StartupContext); + if (!EFI_ERROR (Status) && ThisList->Callback !=3D NULL && ThisList->C= hildList !=3D NULL) { + // + // Go through child list only when the parent node is managed by fea= ture driver. + // + if (ThisList->Flags & REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTION) { + // + // The collection driver's callback is invoked. InformationTypeCol= lectionMemberConfigLanguage + // should be returned in RESOURCE_INFORMATION_RETURNED. + // + if (ThisList->InformationExchange->ReturnedInformation.Type =3D=3D= InformationTypeCollectionMemberConfigLanguage) { + // + // Copy RESOURCE_INFORMATION_RETURNED then destroy the exchange = information. + // + CopyConfiglanguageList (&ThisList->InformationExchange->Returned= Information.ConfigureLanguageList, &ConfigLangList); + DestroryExchangeInformation(ThisList); + // + // Modify the collection instance according to the returned Info= rmationTypeCollectionMemberConfigLanguage. + // + for (Index =3D 0; Index < ConfigLangList.Count; Index ++) { + StrCatS (NextParentUri, MaxParentUriLength, ThisList->NodeName= ); + StrCatS (NextParentUri, MaxParentUriLength, NodeIsCollectionSy= mbol); + SetResourceConfigLangMemberInstance (&NextParentUri, MaxParent= UriLength, (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG *)&ConfigLangList.List[I= ndex]); + StartUpFeatureDriver(ThisList->ChildList, NextParentUri, Start= upContext); + } + DestroyConfiglanguageList (&ConfigLangList); + } else { + DEBUG((DEBUG_ERROR, "%a: No InformationTypeCollectionMemberConfi= gLanguage of %s returned.\n", __FUNCTION__, ThisList->InformationExchange->= SendInformation.FullUri)); + DEBUG((DEBUG_ERROR, "%a: Redfish service maybe not connected or = the network has problems.\n", __FUNCTION__)); + return; + } + } else { + StrCatS (NextParentUri, MaxParentUriLength, ThisList->NodeName); + StartUpFeatureDriver(ThisList->ChildList, NextParentUri, StartupCo= ntext); + } + // + // Restore the parent configure language URI for this level. + // + if (CurrentConfigLanguageUri !=3D NULL) { + StrCpyS(NextParentUri, MaxParentUriLength, CurrentConfigLanguageUr= i); + } else{ + NextParentUri [0] =3D 0; + } + } else { + DestroryExchangeInformation (ThisList); } // // Check sibling Redfish feature driver. @@ -57,6 +207,10 @@ StartUpFeatureDriver ( // ThisList =3D ThisList->SiblingList; }; + if (NextParentUri !=3D NULL) { + FreePool (NextParentUri); + } + } =20 /** @@ -85,10 +239,30 @@ RedfishFeatureDriverStartup( if (ResourceUriNodeList =3D=3D NULL) { return; } + + // + // Initial dispatcher variables. + // + mInformationExchange =3D (RESOURCE_INFORMATION_EXCHANGE *)AllocateZeroPo= ol (sizeof (RESOURCE_INFORMATION_EXCHANGE)); + if (mInformationExchange =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: Fail to allocate memory for exchange informat= ion.\n", __FUNCTION__)); + return; + } + + // + // Signal event before doing provisioning + // + SignalReadyToProvisioningEvent (); + // // Invoke the callback by the hierarchy level // - StartUpFeatureDriver (ResourceUriNodeList, StartupContext); + StartUpFeatureDriver (ResourceUriNodeList, NULL, StartupContext); + + // + // Signal event after provisioning finished + // + SignalAfterProvisioningEvent (); } =20 /** @@ -97,6 +271,8 @@ RedfishFeatureDriverStartup( @param[in,out] PtrToNewInternalData Pointer to receive new instance of REDFISH_FEATURE_INTERNAL_DATA. @param[in] NodeName Name of URI node. + @param[in] NodeIsCollection TRUE means the node to add is the c= ollection node. + Otherwise it is a resource node. =20 @retval EFI_SUCCESS New entry is inserted successfully. @retval EFI_INVALID_PARAMETER Improper given parameters. @@ -106,7 +282,8 @@ RedfishFeatureDriverStartup( EFI_STATUS NewInternalInstance ( IN OUT REDFISH_FEATURE_INTERNAL_DATA **PtrToNewInternalData, - IN EFI_STRING NodeName + IN EFI_STRING NodeName, + IN BOOLEAN NodeIsCollection ) { REDFISH_FEATURE_INTERNAL_DATA *NewInternalData; @@ -126,8 +303,7 @@ NewInternalInstance ( StrnCpyS (NewInternalData->NodeName, StrSize (NodeName), (CONST CHAR16 *= )NodeName, StrLen (NodeName)); NewInternalData->SiblingList =3D NULL; NewInternalData->ChildList =3D NULL; - if (NodeName[0] =3D=3D (UINT16)NodeIsCollectionLeftBracket && - NodeName [StrLen (NodeName) - 1] =3D=3D (UINT16)NodeIsCollectionRigh= tBracket) { + if (NodeIsCollection) { NewInternalData->Flags |=3D REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTIO= N; } *PtrToNewInternalData =3D NewInternalData; @@ -138,11 +314,15 @@ NewInternalInstance ( Insert the URI node into internal data structure =20 @param[in] HeadEntryToInsert The head entry to start the searchi= ng. + @param[in] PrevisouEntry Previsou entry. @param[in] NodeName Name of URI node. + @param[in] NodeIsCollection TRUE means the node to add is the c= ollection node. + Otherwise it is a resource node. @param[in, out] NextNodeEntry Pointer to receive the pointer of n= ext head entry for inserting the follow up n= odes. The returned LIST_ENTRY is the addr= ess of ChildList link list. + @param[out] MatchNodeEntry The matched node entry. @retval EFI_SUCCESS New entry is inserted successfully. @retval EFI_INVALID_PARAMETER Improper given parameters. @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure. @@ -151,8 +331,11 @@ NewInternalInstance ( EFI_STATUS InsertRedfishFeatureUriNode ( IN REDFISH_FEATURE_INTERNAL_DATA *HeadEntryToInsert, + IN REDFISH_FEATURE_INTERNAL_DATA **PrevisouEntry, IN EFI_STRING NodeName, - IN OUT REDFISH_FEATURE_INTERNAL_DATA **NextNodeEntry + IN BOOLEAN NodeIsCollection, + IN OUT REDFISH_FEATURE_INTERNAL_DATA **NextNodeEntry, + OUT REDFISH_FEATURE_INTERNAL_DATA **MatchNodeEntry ) { EFI_STATUS Status; @@ -160,6 +343,7 @@ InsertRedfishFeatureUriNode ( REDFISH_FEATURE_INTERNAL_DATA *ThisInternalData; REDFISH_FEATURE_INTERNAL_DATA *SiblingList; =20 + *MatchNodeEntry =3D NULL; if (NodeName =3D=3D NULL) { DEBUG((DEBUG_ERROR, "%a: Node name is NULL.\n", __FUNCTION__)); return EFI_INVALID_PARAMETER; @@ -169,17 +353,18 @@ InsertRedfishFeatureUriNode ( return EFI_INVALID_PARAMETER; } =20 - if (HeadEntryToInsert =3D=3D NULL || HeadEntryToInsert->ChildList =3D=3D= NULL) { - Status =3D NewInternalInstance (&NewInternalData, NodeName); + if (HeadEntryToInsert =3D=3D NULL) { + Status =3D NewInternalInstance (&NewInternalData, NodeName, NodeIsColl= ection); if (EFI_ERROR (Status)) { return Status; } - if (HeadEntryToInsert =3D=3D NULL) { + if (HeadEntryToInsert =3D=3D NULL && ResourceUriNodeList =3D=3D NULL) { ResourceUriNodeList =3D NewInternalData; } else { - HeadEntryToInsert->ChildList =3D NewInternalData; + (*PrevisouEntry)->ChildList =3D NewInternalData; } - *NextNodeEntry =3D NewInternalData; + *PrevisouEntry =3D NewInternalData; + *NextNodeEntry =3D NewInternalData->ChildList; return EFI_SUCCESS; } // @@ -189,22 +374,26 @@ InsertRedfishFeatureUriNode ( SiblingList =3D ThisInternalData->SiblingList; while (TRUE) { if (StrCmp((CONST CHAR16 *)ThisInternalData->NodeName, (CONST CHAR16 *= )NodeName) =3D=3D 0) { + *MatchNodeEntry =3D ThisInternalData; *NextNodeEntry =3D ThisInternalData->ChildList; + *PrevisouEntry =3D ThisInternalData; return EFI_SUCCESS; } // // If sibing exist? // if (SiblingList =3D=3D NULL) { - Status =3D NewInternalInstance (&NewInternalData, NodeName); + Status =3D NewInternalInstance (&NewInternalData, NodeName, NodeIsCo= llection); if (EFI_ERROR (Status)) { return Status; } ThisInternalData->SiblingList =3D NewInternalData; + *PrevisouEntry =3D NewInternalData; *NextNodeEntry =3D NewInternalData->ChildList; return EFI_SUCCESS; } - SiblingList =3D SiblingList->SiblingList; + ThisInternalData =3D SiblingList; + SiblingList =3D ThisInternalData->SiblingList; }; return EFI_SUCCESS; } @@ -250,7 +439,12 @@ RedfishFeatureRegister ( UINTN Index; UINTN AnchorIndex; UINTN UriLength; + BOOLEAN NewUri; REDFISH_FEATURE_INTERNAL_DATA *ThisUriNode; + REDFISH_FEATURE_INTERNAL_DATA *PreUriNode; + REDFISH_FEATURE_INTERNAL_DATA *NewUriNode; + REDFISH_FEATURE_INTERNAL_DATA *MatchNodeEntry; + BOOLEAN ItsCollection; =20 if (FeatureManagedUri =3D=3D NULL || Callback =3D=3D NULL) { DEBUG((DEBUG_ERROR, "%a: The given parameter is invalid\n", __FUNCTION= __)); @@ -263,27 +457,62 @@ RedfishFeatureRegister ( Index =3D 0; AnchorIndex =3D 0; ThisUriNode =3D ResourceUriNodeList; - do { + PreUriNode =3D ResourceUriNodeList; + NewUri =3D FALSE; + while ((Index < UriLength)) { if ((Index - AnchorIndex + 1) >=3D MaxNodeNameLength) { // Increase on= e for the NULL terminator DEBUG((DEBUG_ERROR, "%a: the length of node name is >=3D MaxNodeName= Length\n", __FUNCTION__)); ASSERT (FALSE); } NodeName[Index - AnchorIndex] =3D *(FeatureManagedUri + Index); - if (NodeName [Index - AnchorIndex] =3D=3D NodeSeperator || NodeName [I= ndex - AnchorIndex] =3D=3D (CHAR16)0) { + if (NodeName [Index - AnchorIndex] =3D=3D NodeSeperator || NodeName [I= ndex - AnchorIndex] =3D=3D UriSeperator || NodeName [Index - AnchorIndex] = =3D=3D (CHAR16)0) { + if (NodeName [Index - AnchorIndex] =3D=3D UriSeperator) { + NewUri =3D TRUE; + } NodeName [Index - AnchorIndex] =3D 0; AnchorIndex =3D Index + 1; // // Insert node // if (StrLen(NodeName) !=3D 0) { - Status =3D InsertRedfishFeatureUriNode(ThisUriNode, NodeName, &Thi= sUriNode); + ItsCollection =3D FALSE; + if ((Index + StrLen(NodeIsCollectionSymbol)) < UriLength && + *(FeatureManagedUri + Index + 1) =3D=3D NodeIsCollectionLeftBr= acket && + *(FeatureManagedUri + Index + 2) =3D=3D NodeIsCollectionRightB= racket) { + Index +=3D (StrLen(NodeIsCollectionSymbol)); + AnchorIndex +=3D (StrLen(NodeIsCollectionSymbol)); + ItsCollection =3D TRUE; + if (*(FeatureManagedUri + Index) =3D=3D UriSeperator) { + NewUri =3D TRUE;; + } + } + Status =3D InsertRedfishFeatureUriNode(ThisUriNode, &PreUriNode, N= odeName, ItsCollection, &NewUriNode, &MatchNodeEntry); if (EFI_ERROR (Status)) { return Status; } + ThisUriNode =3D NewUriNode; + } + if (NewUri || ((Index + 1) >=3D UriLength)) { + // + // Setup the callabck and restart the searching for the + // next URI. + // + if (MatchNodeEntry !=3D NULL) { + MatchNodeEntry->Callback =3D Callback; + MatchNodeEntry->Context =3D Context; + MatchNodeEntry =3D NULL; + } else { + PreUriNode->Callback =3D Callback; + PreUriNode->Context =3D Context; + } + NewUri =3D FALSE; + ThisUriNode =3D ResourceUriNodeList; + Index ++; + continue; } } Index ++; - } while ((Index < UriLength)); + }; =20 if (ThisUriNode =3D=3D NULL) { // @@ -292,11 +521,6 @@ RedfishFeatureRegister ( DEBUG((DEBUG_ERROR, "%a: No URI node is added\n", __FUNCTION__)); return EFI_INVALID_PARAMETER; } - // - // Add feature driver info to internal data instance. - // - ThisUriNode->Callback =3D Callback; - ThisUriNode->Context =3D Context; return EFI_SUCCESS; } =20 diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h index 7b1778b038..84b5e456d1 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h @@ -1,7 +1,7 @@ /** @file Definitions of RedfishFeatureCoreDxe =20 - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -16,22 +16,26 @@ #include #include #include -#include #include +#include +#include =20 #define MaxNodeNameLength 64 +#define MaxParentUriLength 512 #define NodeSeperator L'/' -#define NodeIsCollectionLeftBracket '{' -#define NodeIsCollectionRightBracket '}' +#define UriSeperator L';' +#define NodeIsCollectionLeftBracket L'{' +#define NodeIsCollectionRightBracket L'}' +#define NodeIsCollectionSymbol L"/{}" =20 typedef struct _REDFISH_FEATURE_INTERNAL_DATA REDFISH_FEATURE_INTERNAL_DAT= A; struct _REDFISH_FEATURE_INTERNAL_DATA { REDFISH_FEATURE_INTERNAL_DATA *SiblingList; ///< Next same level in hier= archy of resource URI. REDFISH_FEATURE_INTERNAL_DATA *ChildList; ///< Next level in hierarchy= of resource URI. - EFI_STRING NodeName; ///< Name of the node in hierarchy= of resource URI. - REDFISH_FEATURE_CALLBACK Callback; ///< Callback function of Redfish = feature driver. - VOID *Context; ///< Context of feature driver. - FEATURE_RETURNED_INFORMATION *ReturnedInformation; ///< Information retu= rned from Redfish feature driver. + EFI_STRING NodeName; ///< Name of the node in hie= rarchy of resource URI. + REDFISH_FEATURE_CALLBACK Callback; ///< Callback function of Re= dfish feature driver. + VOID *Context; ///< Context of feature driv= er. + RESOURCE_INFORMATION_EXCHANGE *InformationExchange; ///< Information ret= urned from Redfish feature driver. UINT32 Flags; }; #define REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTION 0x00000001 diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.i= nf b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf index 5a2cd7fecc..ddcf991006 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf @@ -3,7 +3,7 @@ # EdkIIRedfishFeatureCoreProtocol to EDK2 Redfish Feature # drivers for the registration. # -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -27,6 +27,7 @@ [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec RedfishClientPkg/RedfishClientPkg.dec =20 [LibraryClasses] @@ -35,6 +36,8 @@ DebugLib MemoryAllocationLib PrintLib + RedfishEventLib + RedfishFeatureUtilityLib UefiBootServicesTableLib UefiDriverEntryPoint UefiLib --=20 2.32.0.windows.2 -=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 (#91876): https://edk2.groups.io/g/devel/message/91876 Mute This Topic: https://groups.io/mt/92641650/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- From nobody Fri Apr 26 08:47:54 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+91877+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+91877+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885904; cv=none; d=zohomail.com; s=zohoarc; b=eQmHyAT5o/7JmrwsS/MjsBLgkv453whsTRLU2ua0+N11kQ/oyTPOFOgMia2rhHNmW6eddN8hCl8CjkOLm8QNoROJq8vdNbIauhCLJbCAyEeZUx8hp2IDI7k2xK5u4kIT3TQbUFphS1oU3GOsQUZJY1ABnnx8iRnBkKRAxoB6Iec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885904; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=EMP3N6VhhkX4FPSSf+LTDNlbSjVqTjKbGyX68Hhukbo=; b=J8qTWVN317s2S2BjG2f5CaIgulie7OwhRsFDeWyhxdXrYR3chwIQzDIBIDkesx8/WlTjYaJIVCg+rE2HS/I7qvcvXserXoes9LvtMhYCpzJATKHKgHs03CTlRD5bYte4EI/Ucm2aVO9aoPhZvcwZ1AyMU/h1+ZbuvHyAxi8Yw/s= 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+91877+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 1658885904910241.6621616250667; Tue, 26 Jul 2022 18:38:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id X3IsYY1788612x9AwKzPCFUP; Tue, 26 Jul 2022 18:38:23 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.14923.1658885902732978517 for ; Tue, 26 Jul 2022 18:38:22 -0700 X-Received: from pps.filterd (m0148664.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0q6Ab030646; Wed, 27 Jul 2022 01:38:19 GMT X-Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjew9xsrm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:19 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id 0CA2B800E80; Wed, 27 Jul 2022 01:38:19 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id C14DF804D10; Wed, 27 Jul 2022 01:38:17 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 09/15] edk2-staging/RedfishClientPkg: Update RedfishLib Date: Wed, 27 Jul 2022 09:37:56 +0800 Message-Id: <20220727013802.247-10-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> X-Proofpoint-ORIG-GUID: oNIOjEjb7CS99JWCP4A94R042-ah3Wx6 X-Proofpoint-GUID: oNIOjEjb7CS99JWCP4A94R042-ah3Wx6 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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,nickle.wang@hpe.com X-Gm-Message-State: EpdkjoHj8cDCERDsVOJKbs63x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885903; bh=YrRGjTt0h9/k/wGzT+anqWCQr9jTeufCkP01h83dbe4=; h=Cc:Date:From:Reply-To:Subject:To; b=oOTiTLgax2KP6v7ZrgEYXYuSiZCS8iQQ46u5cwV2NX3ruaSVQdklvfpSVGXMNATzppt +I9vGZFaBMz3LVinLFKm6VA9s45+IoULPwm+JrZknh+gUdUHKzdIwctoD8Y080r+jCn/I cVG9c6nyswHp+KV4E2iW8lPZhbcPTmjXQqg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885907085100004 Content-Type: text/plain; charset="utf-8" RedfishLib has no capability to return HTTP header in response. However, feature driver needs to know the information like "ETag" or "Location" in HTTP response header per Redfish specification. Add corresponding function to return HTTP header in response data. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../PrivateLibrary/RedfishLib/RedfishLib.c | 12 +- .../edk2libredfish/include/redfishPayload.h | 5 +- .../edk2libredfish/include/redfishService.h | 5 +- .../RedfishLib/edk2libredfish/src/payload.c | 90 ++- .../RedfishLib/edk2libredfish/src/service.c | 554 +++++++++++++++++- 5 files changed, 657 insertions(+), 9 deletions(-) diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c b/Redf= ishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c index 18aa4646e8..b8ca493e24 100644 --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.c @@ -3,7 +3,7 @@ (CRUD) Redfish resources and provide basic query. =20 Copyright (c) 2019, Intel Corporation. All rights reserved.
- (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -323,7 +323,7 @@ RedfishGetByUri ( =20 ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); =20 - JsonValue =3D getUriFromService (RedfishService, Uri, &RedResponse->Stat= usCode); + JsonValue =3D getUriFromServiceEx (RedfishService, Uri, &RedResponse->He= aders, &RedResponse->HeaderCount, &RedResponse->StatusCode); RedResponse->Payload =3D createRedfishPayload(JsonValue, RedfishService); =20 // @@ -541,9 +541,11 @@ RedfishPatchToPayload ( =20 ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); =20 - RedResponse->Payload =3D (REDFISH_PAYLOAD) patchPayload ( + RedResponse->Payload =3D (REDFISH_PAYLOAD) patchPayloadEx ( Target, Payload, + &RedResponse->Headers, + &RedResponse->HeaderCount, &(RedResponse->StatusCode) ); =20 @@ -607,9 +609,11 @@ RedfishPostToPayload ( =20 ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE)); =20 - RedResponse->Payload =3D (REDFISH_PAYLOAD) postPayload ( + RedResponse->Payload =3D (REDFISH_PAYLOAD) postPayloadEx ( Target, Payload, + &RedResponse->Headers, + &RedResponse->HeaderCount, &(RedResponse->StatusCode) ); =20 diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/incl= ude/redfishPayload.h b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libre= dfish/include/redfishPayload.h index 43149f3c89..be74c64297 100644 --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/red= fishPayload.h +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/red= fishPayload.h @@ -9,7 +9,7 @@ //------------------------------------------------------------------------= ---- =20 Copyright (c) 2019, Intel Corporation. All rights reserved.
- (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -29,8 +29,11 @@ redfishPayload* getPayloadByIndex(redfishPayload* payloa= d, size_t index, EFI_HTT redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* re= dpath, EFI_HTTP_STATUS_CODE** StatusCode); redfishPayload* getPayloadForPathString(redfishPayload* payload, const cha= r* string, EFI_HTTP_STATUS_CODE** StatusCode); redfishPayload* patchPayload(redfishPayload* target, redfishPayload* paylo= ad, EFI_HTTP_STATUS_CODE** StatusCode); +redfishPayload* patchPayloadEx(redfishPayload* target, redfishPayload* pay= load, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE**= StatusCode); redfishPayload* postContentToPayload(redfishPayload* target, const char* d= ata, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** Statu= sCode); +redfishPayload* postContentToPayloadEx(redfishPayload* target, const char*= data, size_t dataSize, const char* contentType, EFI_HTTP_HEADER **Headers,= UINTN *HeaderCount, EFI_HTTP_STATUS_CODE** StatusCode); redfishPayload* postPayload(redfishPayload* target, redfishPayload* payloa= d, EFI_HTTP_STATUS_CODE** StatusCode); +redfishPayload* postPayloadEx(redfishPayload* target, redfishPayload* payl= oad, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE** = StatusCode); void cleanupPayload(redfishPayload* payload); bool isPayloadCollection (redfishPayload *Payload); size_t getCollectionSize(redfishPayload* payload); diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/incl= ude/redfishService.h b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libre= dfish/include/redfishService.h index 0215caccfc..3d87fad85a 100644 --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/red= fishService.h +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/red= fishService.h @@ -9,7 +9,7 @@ //------------------------------------------------------------------------= ---- =20 Copyright (c) 2019, Intel Corporation. All rights reserved.
- (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -91,8 +91,11 @@ typedef struct { #define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001 //The Redfish Servi= ce lacks the version document (in violation of the Redfish spec) redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION= *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* = auth, unsigned int flags); json_t* getUriFromService(redfishService* service, const char* uri, EFI_HT= TP_STATUS_CODE** StatusCode); +json_t* getUriFromServiceEx(redfishService* service, const char* uri, EFI_= HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE **StatusCod= e); json_t* patchUriFromService(redfishService* service, const char* uri, cons= t char* content, EFI_HTTP_STATUS_CODE** StatusCode); +json_t* patchUriFromServiceEx(redfishService* service, const char* uri, co= nst char* content, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_= STATUS_CODE** StatusCode); json_t* postUriFromService(redfishService* service, const char* uri, const= char* content, size_t contentLength, const char* contentType, EFI_HTTP_STA= TUS_CODE** StatusCode); +json_t* postUriFromServiceEx(redfishService* service, const char* uri, con= st char* content, size_t contentLength, const char* contentType, EFI_HTTP_H= EADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE** StatusCode); json_t* deleteUriFromService(redfishService* service, const char* uri, EFI= _HTTP_STATUS_CODE** StatusCode); redfishPayload* getRedfishServiceRoot(redfishService* service, const char*= version, EFI_HTTP_STATUS_CODE** StatusCode); redfishPayload* getPayloadByPath(redfishService* service, const char* path= , EFI_HTTP_STATUS_CODE** StatusCode); diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/= payload.c b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/p= ayload.c index bd8d143c4e..8b49bec0df 100644 --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload= .c +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload= .c @@ -9,7 +9,7 @@ //------------------------------------------------------------------------= ---- =20 Copyright (c) 2019, Intel Corporation. All rights reserved.
- (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -326,6 +326,40 @@ redfishPayload* getPayloadForPathString(redfishPayload= * payload, const char* str return ret; } =20 +redfishPayload* patchPayloadEx(redfishPayload* target, redfishPayload* pay= load, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE**= StatusCode) +{ + json_t* json; + char* content; + char* uri; + + if(!target || !payload || StatusCode =3D=3D NULL) + { + return NULL; + } + + *StatusCode =3D NULL; + + json =3D json_object_get(target->json, "@odata.id"); + if(json =3D=3D NULL) + { + return NULL; + } + uri =3D strdup(json_string_value(json)); + + content =3D json_dumps(payload->json, 0); + json_decref(json); + + json =3D patchUriFromServiceEx(target->service, uri, content, Headers, H= eaderCount, StatusCode); + free(uri); + free(content); + if(json =3D=3D NULL) + { + return NULL; + } + + return createRedfishPayload(json, target->service); +} + redfishPayload* patchPayload(redfishPayload* target, redfishPayload* paylo= ad, EFI_HTTP_STATUS_CODE** StatusCode) { json_t* json; @@ -360,6 +394,38 @@ redfishPayload* patchPayload(redfishPayload* target, r= edfishPayload* payload, EF return createRedfishPayload(json, target->service); } =20 +redfishPayload* postContentToPayloadEx(redfishPayload* target, const char*= data, size_t dataSize, const char* contentType, EFI_HTTP_HEADER **Headers,= UINTN *HeaderCount, EFI_HTTP_STATUS_CODE** StatusCode) +{ + json_t* json; + char* uri; + + if(!target || !data || StatusCode =3D=3D NULL) + { + return NULL; + } + + *StatusCode =3D NULL; + + json =3D json_object_get(target->json, "@odata.id"); + if(json =3D=3D NULL) + { + json =3D json_object_get(target->json, "target"); + if(json =3D=3D NULL) + { + return NULL; + } + } + uri =3D strdup(json_string_value(json)); + json =3D postUriFromServiceEx(target->service, uri, data, dataSize, co= ntentType, Headers, HeaderCount, StatusCode); + free(uri); + if(json =3D=3D NULL) + { + return NULL; + } + + return createRedfishPayload(json, target->service); +} + redfishPayload* postContentToPayload(redfishPayload* target, const char* d= ata, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** Statu= sCode) { json_t* json; @@ -392,6 +458,28 @@ redfishPayload* postContentToPayload(redfishPayload* t= arget, const char* data, s return createRedfishPayload(json, target->service); } =20 +redfishPayload* postPayloadEx(redfishPayload* target, redfishPayload* payl= oad, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE** = StatusCode) +{ + char* content; + redfishPayload* ret; + + if(!target || !payload || StatusCode =3D=3D NULL) + { + return NULL; + } + + *StatusCode =3D NULL; + + if(!json_is_object(payload->json)) + { + return NULL; + } + content =3D payloadToString(payload, false); + ret =3D postContentToPayloadEx(target, content, strlen(content), NULL,= Headers, HeaderCount, StatusCode); + free(content); + return ret; +} + redfishPayload* postPayload(redfishPayload* target, redfishPayload* payloa= d, EFI_HTTP_STATUS_CODE** StatusCode) { char* content; diff --git a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/= service.c b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/s= ervice.c index 7713f89e6d..450fa78bbd 100644 --- a/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service= .c +++ b/RedfishClientPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service= .c @@ -9,7 +9,7 @@ //------------------------------------------------------------------------= ---- =20 Copyright (c) 2019, Intel Corporation. All rights reserved.
- (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -338,6 +338,190 @@ ON_EXIT: return ret; } =20 +EFI_HTTP_HEADER *cloneHttpHeaders(EFI_HTTP_MESSAGE *message, UINTN *Header= Count) +{ + EFI_HTTP_HEADER *Buffer; + UINTN Index; + + if (message =3D=3D NULL || HeaderCount =3D=3D NULL) { + return NULL; + } + + *HeaderCount =3D message->HeaderCount; + Buffer =3D AllocatePool (sizeof (EFI_HTTP_HEADER) * message->HeaderCoun= t); + if (Buffer =3D=3D NULL) { + return NULL; + } + + for (Index =3D 0; Index < message->HeaderCount; Index++) { + Buffer[Index].FieldName =3D AllocateCopyPool (AsciiStrSize (message->H= eaders[Index].FieldName), message->Headers[Index].FieldName); + ASSERT (Buffer[Index].FieldName !=3D NULL); + Buffer[Index].FieldValue =3D AllocateCopyPool (AsciiStrSize (message->= Headers[Index].FieldValue), message->Headers[Index].FieldValue); + ASSERT (Buffer[Index].FieldValue !=3D NULL); + } + + return Buffer; +} + +json_t* getUriFromServiceEx(redfishService* service, const char* uri, EFI_= HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE **StatusCod= e) +{ + char* url; + json_t* ret; + HTTP_IO_HEADER *HttpIoHeader =3D NULL; + EFI_STATUS Status; + EFI_HTTP_REQUEST_DATA *RequestData =3D NULL; + EFI_HTTP_MESSAGE *RequestMsg =3D NULL; + EFI_HTTP_MESSAGE ResponseMsg; + EFI_HTTP_HEADER *ContentEncodedHeader; + + if(service =3D=3D NULL || uri =3D=3D NULL || Headers =3D=3D NULL || Head= erCount =3D=3D NULL ||StatusCode =3D=3D NULL) + { + return NULL; + } + + *StatusCode =3D NULL; + *HeaderCount =3D 0; + *Headers =3D NULL; + + url =3D makeUrlForService(service, uri); + if(!url) + { + return NULL; + } + + DEBUG((DEBUG_INFO, "libredfish: getUriFromServiceEx(): %a\n", url)); + + // + // Step 1: Create HTTP request message with 4 headers: + // + HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service->= basicAuthStr) ? 6 : 5); + if (HttpIoHeader =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + if(service->sessionToken) + { + Status =3D HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->ses= sionToken); + ASSERT_EFI_ERROR (Status); + } else if (service->basicAuthStr) { + Status =3D HttpIoSetHeader (HttpIoHeader, "Authorization", service->ba= sicAuthStr); + ASSERT_EFI_ERROR (Status); + } + + Status =3D HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderVal= ue); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); + ASSERT_EFI_ERROR (Status); + + // + // Step 2: build the rest of HTTP request info. + // + RequestData =3D AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); + if (RequestData =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + RequestData->Method =3D HttpMethodGet; + RequestData->Url =3D C8ToC16 (url); + + // + // Step 3: fill in EFI_HTTP_MESSAGE + // + RequestMsg =3D AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); + if (RequestMsg =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + RequestMsg->Data.Request =3D RequestData; + RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; + RequestMsg->Headers =3D HttpIoHeader->Headers; + + ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); + + // + // Step 4: call RESTEx to get response from REST service. + // + Status =3D service->RestEx->SendReceive (service->RestEx, RequestMsg, &R= esponseMsg); + if (EFI_ERROR (Status)) { + ret =3D NULL; + goto ON_EXIT; + } + + // + // Step 5: Return the HTTP StatusCode and Body message. + // + if (ResponseMsg.Data.Response !=3D NULL) { + *StatusCode =3D AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); + if (*StatusCode =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + // + // The caller shall take the responsibility to free the buffer. + // + **StatusCode =3D ResponseMsg.Data.Response->StatusCode; + } + + if (ResponseMsg.Headers !=3D NULL) { + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); + } + + if (ResponseMsg.BodyLength !=3D 0 && ResponseMsg.Body !=3D NULL) { + // + // Check if data is encoded. + // + ContentEncodedHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, Resp= onseMsg.Headers, HTTP_HEADER_CONTENT_ENCODING); + if (ContentEncodedHeader !=3D NULL) { + // + // The content is encoded. + // + Status =3D DecodeResponseContent (ContentEncodedHeader->FieldValue, = &ResponseMsg.Body, &ResponseMsg.BodyLength); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to decompress the response conten= t %r\n.", __FUNCTION__, Status)); + ret =3D NULL; + goto ON_EXIT; + } + } + ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); + } else { + // + // There is no message body returned from server. + // + ret =3D NULL; + } + +ON_EXIT: + if (url !=3D NULL) { + free (url); + } + + if (HttpIoHeader !=3D NULL) { + HttpIoFreeHeader (HttpIoHeader); + } + + if (RequestData !=3D NULL) { + RestConfigFreeHttpRequestData (RequestData); + } + + if (RequestMsg !=3D NULL) { + FreePool (RequestMsg); + } + + RestConfigFreeHttpMessage (&ResponseMsg, FALSE); + + return ret; +} + json_t* getUriFromService(redfishService* service, const char* uri, EFI_HT= TP_STATUS_CODE** StatusCode) { char* url; @@ -491,7 +675,7 @@ ON_EXIT: return ret; } =20 -json_t* patchUriFromService(redfishService* service, const char* uri, cons= t char* content, EFI_HTTP_STATUS_CODE** StatusCode) +json_t* patchUriFromServiceEx(redfishService* service, const char* uri, co= nst char* content, EFI_HTTP_HEADER **Headers, UINTN *HeaderCount, EFI_HTTP_= STATUS_CODE** StatusCode) { char* url; json_t* ret; @@ -632,6 +816,10 @@ json_t* patchUriFromService(redfishService* service, c= onst char* uri, const char **StatusCode =3D ResponseMsg.Data.Response->StatusCode; } =20 + if (ResponseMsg.Headers !=3D NULL) { + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); + } + if (EncodedContent !=3D content) { FreePool (EncodedContent); } @@ -668,6 +856,368 @@ ON_EXIT: return ret; } =20 +json_t* patchUriFromService(redfishService* service, const char* uri, cons= t char* content, EFI_HTTP_STATUS_CODE** StatusCode) +{ + char* url; + json_t* ret; + HTTP_IO_HEADER *HttpIoHeader =3D NULL; + EFI_STATUS Status; + EFI_HTTP_REQUEST_DATA *RequestData =3D NULL; + EFI_HTTP_MESSAGE *RequestMsg =3D NULL; + EFI_HTTP_MESSAGE ResponseMsg; + CHAR8 ContentLengthStr[80]; + CHAR8 *EncodedContent; + UINTN EncodedContentLen; + + if(service =3D=3D NULL || uri =3D=3D NULL || content =3D=3D NULL || Stat= usCode =3D=3D NULL) + { + return NULL; + } + + *StatusCode =3D NULL; + + url =3D makeUrlForService(service, uri); + if(!url) + { + return NULL; + } + + DEBUG((DEBUG_INFO, "libredfish: patchUriFromService(): %a\n", url)); + + // + // Step 1: Create HTTP request message with 4 headers: + // + HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service->= basicAuthStr) ? 9 : 8); + if (HttpIoHeader =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + if(service->sessionToken) + { + Status =3D HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->ses= sionToken); + ASSERT_EFI_ERROR (Status); + } else if (service->basicAuthStr) { + Status =3D HttpIoSetHeader (HttpIoHeader, "Authorization", service->ba= sicAuthStr); + ASSERT_EFI_ERROR (Status); + } + + Status =3D HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderVal= ue); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", "application/j= son"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); + ASSERT_EFI_ERROR (Status); + + AsciiSPrint( + ContentLengthStr, + sizeof (ContentLengthStr), + "%lu", + (UINT64) strlen(content) + ); + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Length", ContentLengt= hStr); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); + ASSERT_EFI_ERROR (Status); + + // + // Step 2: build the rest of HTTP request info. + // + RequestData =3D AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); + if (RequestData =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + RequestData->Method =3D HttpMethodPatch; + RequestData->Url =3D C8ToC16 (url); + + // + // Step 3: fill in EFI_HTTP_MESSAGE + // + RequestMsg =3D AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); + if (RequestMsg =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + EncodedContent =3D (CHAR8 *)content; + EncodedContentLen =3D strlen(content); + // + // We currently only support gzip Content-Encoding. + // + Status =3D EncodeRequestContent ((CHAR8 *)HTTP_CONTENT_ENCODING_GZIP, (C= HAR8 *)content, (VOID **)&EncodedContent, &EncodedContentLen); + if (Status =3D=3D EFI_INVALID_PARAMETER) { + DEBUG((DEBUG_ERROR, "%a: Error to encode content.\n", __FUNCTION__)); + ret =3D NULL; + goto ON_EXIT; + } else if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG((DEBUG_INFO, "No content coding for %a! Use raw data instead.\n"= , HTTP_CONTENT_ENCODING_GZIP)); + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Encoding", HTTP_CON= TENT_ENCODING_IDENTITY); + ASSERT_EFI_ERROR (Status); + } else { + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Encoding", HTTP_CON= TENT_ENCODING_GZIP); + ASSERT_EFI_ERROR (Status); + } + + RequestMsg->Data.Request =3D RequestData; + RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; + RequestMsg->Headers =3D HttpIoHeader->Headers; + RequestMsg->BodyLength =3D EncodedContentLen; + RequestMsg->Body =3D (VOID*) EncodedContent; + + ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); + + // + // Step 4: call RESTEx to get response from REST service. + // + Status =3D service->RestEx->SendReceive (service->RestEx, RequestMsg, &R= esponseMsg); + if (EFI_ERROR (Status)) { + ret =3D NULL; + goto ON_EXIT; + } + + // + // Step 5: Return the HTTP StatusCode and Body message. + // + if (ResponseMsg.Data.Response !=3D NULL) { + *StatusCode =3D AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); + if (*StatusCode =3D=3D NULL) { + ret =3D NULL; + goto ON_EXIT; + } + + // + // The caller shall take the responsibility to free the buffer. + // + **StatusCode =3D ResponseMsg.Data.Response->StatusCode; + } + + if (EncodedContent !=3D content) { + FreePool (EncodedContent); + } + + + if (ResponseMsg.BodyLength !=3D 0 && ResponseMsg.Body !=3D NULL) { + ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); + } else { + // + // There is no message body returned from server. + // + ret =3D NULL; + } + +ON_EXIT: + if (url !=3D NULL) { + free (url); + } + + if (HttpIoHeader !=3D NULL) { + HttpIoFreeHeader (HttpIoHeader); + } + + if (RequestData !=3D NULL) { + RestConfigFreeHttpRequestData (RequestData); + } + + if (RequestMsg !=3D NULL) { + FreePool (RequestMsg); + } + + RestConfigFreeHttpMessage (&ResponseMsg, FALSE); + + return ret; +} + +json_t* postUriFromServiceEx(redfishService* service, const char* uri, con= st char* content, size_t contentLength, const char* contentType, EFI_HTTP_H= EADER **Headers, UINTN *HeaderCount, EFI_HTTP_STATUS_CODE** StatusCode) +{ + char* url =3D NULL; + json_t* ret; + HTTP_IO_HEADER *HttpIoHeader =3D NULL; + EFI_STATUS Status; + EFI_HTTP_REQUEST_DATA *RequestData =3D NULL; + EFI_HTTP_MESSAGE *RequestMsg =3D NULL; + EFI_HTTP_MESSAGE ResponseMsg; + CHAR8 ContentLengthStr[80]; + EFI_HTTP_HEADER *HttpHeader =3D NULL; + + ret =3D NULL; + + if(service =3D=3D NULL || uri =3D=3D NULL || content =3D=3D NULL || Stat= usCode =3D=3D NULL) + { + return NULL; + } + + *StatusCode =3D NULL; + + url =3D makeUrlForService(service, uri); + if(!url) + { + return NULL; + } + + DEBUG((DEBUG_INFO, "libredfish: postUriFromService(): %a\n", url)); + + if(contentLength =3D=3D 0) + { + contentLength =3D strlen(content); + } + + // + // Step 1: Create HTTP request message with 4 headers: + // + HttpIoHeader =3D HttpIoCreateHeader ((service->sessionToken || service->= basicAuthStr) ? 8 : 7); + if (HttpIoHeader =3D=3D NULL) { + goto ON_EXIT; + } + + if(service->sessionToken) + { + Status =3D HttpIoSetHeader (HttpIoHeader, "X-Auth-Token", service->ses= sionToken); + ASSERT_EFI_ERROR (Status); + } else if (service->basicAuthStr) { + Status =3D HttpIoSetHeader (HttpIoHeader, "Authorization", service->ba= sicAuthStr); + ASSERT_EFI_ERROR (Status); + } + + if(contentType =3D=3D NULL) { + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", "application= /json"); + ASSERT_EFI_ERROR (Status); + } else { + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Type", (CHAR8 *) co= ntentType); + ASSERT_EFI_ERROR (Status); + } + Status =3D HttpIoSetHeader (HttpIoHeader, "Host", service->HostHeaderVal= ue); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "Accept", "application/json"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "User-Agent", "libredfish"); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "Connection", "Keep-Alive"); + ASSERT_EFI_ERROR (Status); + AsciiSPrint( + ContentLengthStr, + sizeof (ContentLengthStr), + "%lu", + (UINT64) contentLength + ); + Status =3D HttpIoSetHeader (HttpIoHeader, "Content-Length", ContentLengt= hStr); + ASSERT_EFI_ERROR (Status); + Status =3D HttpIoSetHeader (HttpIoHeader, "OData-Version", "4.0"); + ASSERT_EFI_ERROR (Status); + + // + // Step 2: build the rest of HTTP request info. + // + RequestData =3D AllocateZeroPool (sizeof (EFI_HTTP_REQUEST_DATA)); + if (RequestData =3D=3D NULL) { + goto ON_EXIT; + } + + RequestData->Method =3D HttpMethodPost; + RequestData->Url =3D C8ToC16 (url); + + // + // Step 3: fill in EFI_HTTP_MESSAGE + // + RequestMsg =3D AllocateZeroPool (sizeof (EFI_HTTP_MESSAGE)); + if (RequestMsg =3D=3D NULL) { + goto ON_EXIT; + } + + RequestMsg->Data.Request =3D RequestData; + RequestMsg->HeaderCount =3D HttpIoHeader->HeaderCount; + RequestMsg->Headers =3D HttpIoHeader->Headers; + RequestMsg->BodyLength =3D contentLength; + RequestMsg->Body =3D (VOID*) content; + + ZeroMem (&ResponseMsg, sizeof (ResponseMsg)); + + // + // Step 4: call RESTEx to get response from REST service. + // + Status =3D service->RestEx->SendReceive (service->RestEx, RequestMsg, &R= esponseMsg); + if (EFI_ERROR (Status)) { + goto ON_EXIT; + } + + // + // Step 5: Return the HTTP StatusCode and Body message. + // + if (ResponseMsg.Data.Response !=3D NULL) { + *StatusCode =3D AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE)); + if (*StatusCode =3D=3D NULL) { + goto ON_EXIT; + } + + // + // The caller shall take the responsibility to free the buffer. + // + **StatusCode =3D ResponseMsg.Data.Response->StatusCode; + } + + if (ResponseMsg.Headers !=3D NULL) { + *Headers =3D cloneHttpHeaders (&ResponseMsg, HeaderCount); + } + + if (ResponseMsg.BodyLength !=3D 0 && ResponseMsg.Body !=3D NULL) { + ret =3D json_loadb (ResponseMsg.Body, ResponseMsg.BodyLength, 0, NULL); + } + + // + // Step 6: Parsing the HttpHeader to retrive the X-Auth-Token if the HTT= P StatusCode is correct. + // + if (ResponseMsg.Data.Response->StatusCode =3D=3D HTTP_STATUS_200_OK || + ResponseMsg.Data.Response->StatusCode =3D=3D HTTP_STATUS_204_NO_CONT= ENT) { + HttpHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.He= aders, "X-Auth-Token"); + if (HttpHeader !=3D NULL) { + if(service->sessionToken) + { + free(service->sessionToken); + } + service->sessionToken =3D AllocateCopyPool (AsciiStrSize (HttpHeader= ->FieldValue), HttpHeader->FieldValue); + } + + /* + // + // Below opeation seems to be unnecessary. + // Besides, the FieldValue for the Location is the full HTTP URI (Http= ://0.0.0.0:5000/XXX), so we can't use it as the + // parameter of getUriFromService () directly. + // + HttpHeader =3D HttpFindHeader (ResponseMsg.HeaderCount, ResponseMsg.He= aders, "Location"); + if (HttpHeader !=3D NULL) { + ret =3D getUriFromService(service, HttpHeader->FieldValue); + goto ON_EXIT; + } + */ + } + +ON_EXIT: + if (url !=3D NULL) { + free (url); + } + + if (HttpIoHeader !=3D NULL) { + HttpIoFreeHeader (HttpIoHeader); + } + + if (RequestData !=3D NULL) { + RestConfigFreeHttpRequestData (RequestData); + } + + if (RequestMsg !=3D NULL) { + FreePool (RequestMsg); + } + + RestConfigFreeHttpMessage (&ResponseMsg, FALSE); + + return ret; +} + json_t* postUriFromService(redfishService* service, const char* uri, const= char* content, size_t contentLength, const char* contentType, EFI_HTTP_STA= TUS_CODE** StatusCode) { char* url =3D NULL; --=20 2.32.0.windows.2 -=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 (#91877): https://edk2.groups.io/g/devel/message/91877 Mute This Topic: https://groups.io/mt/92641651/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- From nobody Fri Apr 26 08:47:54 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+91879+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+91879+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885907; cv=none; d=zohomail.com; s=zohoarc; b=VN2dgDwzQcbTBd/2GnaVsPe3nAM5C0s9ZNM9Z6qjw8l8c6o7Vk8EHTxUOBn4FkV27t2FOYPQLsu5cUqfWBD7yekPfWUmDvMO4t0gzrFSECwFdannKbDp6XXGfkkDBHM20V9VjTCWL46IXnv8kKYnh/T2PUXf1Mby9WxosoAaJp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885907; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Z8aIXDmyh0oyIdkbzwY4W/vo18EkuxEh9LkXKxokUUM=; b=bN3B0CDD/zY3ZcV3uye+9YHvnGQX6sksdnGmJLx5k4zLswsD/kQY3AVKCKlotUyrnJYuR9MagzqKNXk9tdm4S5v1h9qpBps7WYJ0xPE46p23vMmJyVAjqUpIhpyamLzViLiEGyd5fs8xqioQTs5Nt+wRq4r40HvZPXWKnFLrw5Y= 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+91879+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 1658885907047849.0707079470004; Tue, 26 Jul 2022 18:38:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TSY5YY1788612xdhKQcEMdv2; Tue, 26 Jul 2022 18:38:26 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.14834.1658885905291338878 for ; Tue, 26 Jul 2022 18:38:25 -0700 X-Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R1SnHD005126; Wed, 27 Jul 2022 01:38:22 GMT X-Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjuqmr2d0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:21 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id C5420132D1; Wed, 27 Jul 2022 01:38:20 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 6930880561B; Wed, 27 Jul 2022 01:38:19 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 10/15] edk2-staging/RedfishClientPkg: Update Redfish feature utility library Date: Wed, 27 Jul 2022 09:37:57 +0800 Message-Id: <20220727013802.247-11-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: Mz0rA1w1pHY1H59zkoTNy1ciPsInknoA X-Proofpoint-ORIG-GUID: Mz0rA1w1pHY1H59zkoTNy1ciPsInknoA 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,nickle.wang@hpe.com X-Gm-Message-State: 0HgtVugoZTv29EOn8bEe5C0mx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885906; bh=I0qCAFu/6sxVN51vt8oOMSz3C8u7cFM0DwwFwfD9DNY=; h=Cc:Date:From:Reply-To:Subject:To; b=q7WLsZKitx8lC8ONaFtypSKMDtkCJRKjOnmmjTk/hgESnUUCw+V3hKG94R1VlchRdS8 m1MFkDvfAgaIGgeOmCitF/A359RhQ6PrlbvgLwEdOaMmVfQvX8O5cMpkkd5+2C8Hv+RTt cDD/gsQRju3Vf+jodJyxHTF0dkJ9Mnx0yzU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885909200100016 Content-Type: text/plain; charset="utf-8" Update Redfish feature utility library in order to support array type of resource. Some helper functions are introduced to get Redfish data. Also expose RedfishCsCommon.h so that feature utility library can work with Redfish C data structure without redundant structure conversion. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../Library/RedfishFeatureUtilityLib.h | 756 +++- .../RedfishJsonStructure/RedfishCsCommon.h | 14 + .../RedfishFeatureUtilityInternal.h | 16 +- .../RedfishFeatureUtilityLib.c | 3662 +++++++++++++---- .../RedfishFeatureUtilityLib.inf | 20 +- 5 files changed, 3470 insertions(+), 998 deletions(-) create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RedfishCs= Common.h diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/= RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h index 50ff82c70f..1325976d8c 100644 --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h @@ -1,7 +1,7 @@ /** @file This file defines the Redfish Feature Utility Library interface. =20 - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -10,8 +10,9 @@ #ifndef REDFISH_FEATURE_UTILITY_LIB_H_ #define REDFISH_FEATURE_UTILITY_LIB_H_ =20 -#include -#include +#include +#include +#include =20 // // Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG @@ -31,10 +32,10 @@ typedef struct { =20 /** =20 - Read redfish resource by given resource path. + Read redfish resource by given resource URI. =20 @param[in] Service Redfish srvice instacne to make query. - @param[in] ResourcePath Target resource path. + @param[in] ResourceUri Target resource URI. @param[out] Response HTTP response from redfish service. =20 @retval EFI_SUCCESS Resrouce is returned successfully. @@ -42,12 +43,34 @@ typedef struct { =20 **/ EFI_STATUS -GetResourceByPath ( +GetResourceByUri ( IN REDFISH_SERVICE *Service, - IN CHAR8 *ResourcePath, + IN EFI_STRING ResourceUri, OUT REDFISH_RESPONSE *Response ); =20 +/** + + Check if this is the Redpath array. Usually the Redpath array represents + the collection member. Return + + @param[in] ConfigureLang The Redpath to check + @param[out] ArraySignatureOpen String to the open of array signat= ure. + @param[out] ArraySignatureClose String to the close of array signa= ture. + + @retval EFI_SUCCESS Index is found. + @retval EFI_NOT_FOUND The non-array configure language stri= ng is retured. + @retval EFI_INVALID_PARAMETER The format of input ConfigureLang is = wrong. + @retval Others Errors occur. + +**/ +EFI_STATUS +IsRedpathArray ( + IN EFI_STRING ConfigureLang, + OUT EFI_STRING *ArraySignatureOpen, + OUT EFI_STRING *ArraySignatureClose + ); + /** =20 Search HII database with given Configure Language pattern. Data is handl= ed and @@ -72,76 +95,142 @@ RedfishFeatureGetUnifiedArrayTypeConfigureLang ( =20 /** =20 - Get array key by parsing the URI. + Clone the configure language list. =20 - @param[in] Uri URI with array key. - @param[out] ArrayKey Array key in given URI string. + @param[in] ConfigureLangList The source REDFISH_FEATURE_ARRAY_TYPE= _CONFIG_LANG_LIST. + @param[out] DestConfigureLangList The destination REDFISH_FEATURE_ARRAY= _TYPE_CONFIG_LANG_LIST. =20 - @retval EFI_SUCCESS Array key is found. - @retval Others Errors occur. + @retval EFI_SUCCESS REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST = is copied. + @retval Others Errors occur. =20 **/ EFI_STATUS -GetArraykeyFromUri ( - IN CHAR8 *Uri, - OUT CHAR8 **ArrayKey +CopyConfiglanguageList ( + IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *SourceConfigureLangLis= t, + OUT REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *DestConfigureLangList ); =20 /** =20 - Keep configure language with given key in UEFI variable. + Get number of node from the string. Node is seperated by '/'. =20 - @param[in] Schema Schema name. - @param[in] Version Schema version. - @param[in] Key Key string. - @param[in] ConfigureLangIndex Index value. + @param[in] NodeString The node string to parse. =20 - @retval EFI_SUCCESS Data is saved in UEFI variable. - @retval Others Errors occur. + @retval UINTN Number of nodes in the string. + +**/ +UINTN +GetNumberOfRedpathNodes ( + IN EFI_STRING NodeString + ); + +/** + + Get the node string by index + + @param[in] NodeString The node string to parse. + @param[in] Index Index of the node. + @param[out] EndOfNodePtr Pointer to receive the poitner to + the last character of node string. + + @retval EFI_STRING the begining of the node string. + +**/ +EFI_STRING +GetRedpathNodeByIndex ( + IN EFI_STRING NodeString, + IN UINTN Index, + OUT EFI_STRING *EndOfNodePtr OPTIONAL + ); + +/** + + Find array index from given configure language string. + + @param[in] ConfigureLang Configure language string to parse. + @param[out] UnifiedConfigureLang The configure language in array. + @param[out] Index The array index number. + + @retval EFI_SUCCESS Index is found. + @retval EFI_NOT_FOUND The non-array configure language stri= ng is retured. + @retval EFI_INVALID_PARAMETER The format of input ConfigureLang is = wrong. + @retval Others Errors occur. =20 **/ EFI_STATUS -SetConfigureLangWithkey ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN CHAR8 *Key, - IN UINTN ConfigureLangIndex +GetArrayIndexFromArrayTypeConfigureLang ( + IN CHAR16 *ConfigureLang, + OUT CHAR16 **UnifiedConfigureLang, + OUT UINTN *Index ); =20 /** =20 - Find configure language with input key string. + Clone the configure language list. + + @param[in] ConfigureLang The pointer to configuration language. =20 - @param[in] Schema Schema name. - @param[in] Version Schema version. - @param[in] Property Property name. - @param[in] Key Key string. + @retval UINTN The index of collection member instance. + Value of 0 means no instance is found. +**/ +UINTN +ConfiglanguageGetInstanceIndex ( + IN EFI_STRING ConfigureLang + ); =20 - @retval CHAR16 * Corresponding configure langauge - @retval NULL No configure language is found +/** + + Destroy the configure language list. + + @param[in] ConfigureLangList The REDFISH_FEATURE_ARRAY_TYPE_CONFIG= _LANG_LIST + instance to destroy. + + @retval EFI_SUCCESS REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST = is copied. + @retval Others Errors occur. =20 **/ -CHAR16 * -GetConfigureLangByKey ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN CHAR8 *Property, - IN CHAR8 *Key +EFI_STATUS +DestroyConfiglanguageList ( + IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigureLangList ); =20 /** =20 - Convert HII string value to string value in JSON format. + Set the node instance. =20 - @param[in] HiiStringValue String in HII format. + @param[in] DestConfigLang Pointer to the node's configure langua= ge string. + The memory pointed by ConfigLang must = be allocated + through memory allocation interface. B= ecasue we will replace + the pointer in this function. + @param[in] MaxtLengthConfigLang The maximum length of ConfigLang. + @param[in] ConfigLangInstance Pointer to Collection member instance. =20 - @retval CHAR8 * String in JSON format. - @retval NULL Errors occur. + @retval EFI_SUCCESS The instance is inserted to the configure la= nguage. + @retval Others Errors occur. =20 **/ -CHAR8 * -ConvertHiiStringValueToJsonStringValue ( - IN EFI_STRING HiiStringValue +EFI_STATUS +SetResourceConfigLangMemberInstance ( + IN EFI_STRING *DestConfigLang, + IN UINTN MaxtLengthConfigLang, + IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG *ConfigLangInstance + ); + +/** + + Get array key by parsing the URI. + + @param[in] Uri URI with array key. + @param[out] ArrayKey Array key in given URI string. + + @retval EFI_SUCCESS Array key is found. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetArraykeyFromUri ( + IN CHAR8 *Uri, + OUT CHAR8 **ArrayKey ); =20 /** @@ -209,125 +298,157 @@ ApplyFeatureSettingsBooleanType ( =20 /** =20 - Create HTTP payload and send them to redfish service with POST method. + Apply property value to UEFI HII database in vague type. =20 - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Location Returned location string from Redfish servic= e. - @param[out] Etag Returned ETAG string from Redfish service. + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] VagueValuePtr Pointer of vague values to to set. + @param[in] NumVagueValues Number of vague values. =20 - @retval EFI_SUCCESS Data is sent to redfish service successfully. + @retval EFI_SUCCESS New value is applied successfully. @retval Others Errors occur. =20 **/ EFI_STATUS -CreatePayloadToPostResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT CHAR8 **Location, - OUT CHAR8 **Etag +ApplyFeatureSettingsVagueType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_EmptyProp_KeyValue *VagueValuePtr, + IN UINT32 NumberOfVagueValues ); =20 /** =20 - Create HTTP payload and send them to redfish service with PATCH method. + Apply property value to UEFI HII database in string array type. =20 - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Etag Returned ETAG string from Redfish service. + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] ArrayHead Head of array value. =20 - @retval EFI_SUCCESS Data is sent to redfish service successfully. + @retval EFI_SUCCESS New value is applied successfully. @retval Others Errors occur. =20 **/ EFI_STATUS -CreatePayloadToPatchResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT CHAR8 **Etag +ApplyFeatureSettingsStringArrayType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_char_Array *ArrayHead ); =20 /** =20 - Find Redfish Resource Config Protocol that supports given schema and ver= sion. + Apply property value to UEFI HII database in numeric array type (INT64). =20 - @param[in] Schema Schema name. - @param[in] Major Schema version major number. - @param[in] Minor Schema version minor number. - @param[in] Errata Schema version errata number. + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] ArrayHead Head of array value. =20 - @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to proto= col - @retval NULL No protocol foun= d. + @retval EFI_SUCCESS New value is applied successfully. + @retval Others Errors occur. =20 **/ -EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * -GetRedfishResourceConfigProtocol ( - IN CHAR8 *Schema, - IN CHAR8 *Major, - IN CHAR8 *Minor, - IN CHAR8 *Errata +EFI_STATUS +ApplyFeatureSettingsNumericArrayType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_int64_Array *ArrayHead ); =20 /** =20 - Get supported schema list by given specify schema name. + Apply property value to UEFI HII database in boolean array type (INT64). =20 - @param[in] Schema Schema type name. - @param[out] SchemaInfo Returned schema information. + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] ArrayHead Head of Redfich CS boolean array value. =20 - @retval EFI_SUCCESS Schema information is returned successfu= lly. - @retval Others Errors occur. + @retval EFI_SUCCESS New value is applied successfully. + @retval Others Errors occur. =20 **/ EFI_STATUS -GetSupportedSchemaVersion ( - IN CHAR8 *Schema, - OUT REDFISH_SCHEMA_INFO *SchemaInfo +ApplyFeatureSettingsBooleanArrayType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_bool_Array *ArrayHead ); =20 /** =20 - Return system root path + Create HTTP payload and send them to redfish service with POST method. + + @param[in] Service Redfish service. + @param[in] TargetPayload Target payload + @param[in] Json Data in JSON format. + @param[out] Location Returned location string from Redfish servic= e. + @param[out] Etag Returned ETAG string from Redfish service. =20 - @retval NULL Can not find system root path. - @retval Other System root path is returned. + @retval EFI_SUCCESS Data is sent to redfish service successfully. + @retval Others Errors occur. =20 **/ -CHAR8 * -RedfishGetSystemRootPath ( - VOID +EFI_STATUS +CreatePayloadToPostResource ( + IN REDFISH_SERVICE *Service, + IN REDFISH_PAYLOAD *TargetPayload, + IN CHAR8 *Json, + OUT EFI_STRING *Location, + OUT CHAR8 **Etag ); =20 /** =20 - Get schema information by given protocol and service instance. + Create HTTP payload and send them to redfish service with PATCH method. =20 - @param[in] RedfishService Pointer to Redfish service instance. - @param[in] JsonStructProtocol Json Structure protocol instance. - @param[in] Uri Target URI. - @param[out] SchemaInfo Returned schema information. + @param[in] Service Redfish service. + @param[in] TargetPayload Target payload + @param[in] Json Data in JSON format. + @param[out] Etag Returned ETAG string from Redfish service. =20 - @retval EFI_SUCCESS Schema information is returned successfu= lly. - @retval Others Errors occur. + @retval EFI_SUCCESS Data is sent to redfish service successfully. + @retval Others Errors occur. =20 **/ EFI_STATUS -GetRedfishSchemaInfo ( - IN REDFISH_SERVICE *RedfishService, - IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, - IN CHAR8 *Uri, - OUT REDFISH_SCHEMA_INFO *SchemaInfo +CreatePayloadToPatchResource ( + IN REDFISH_SERVICE *Service, + IN REDFISH_PAYLOAD *TargetPayload, + IN CHAR8 *Json, + OUT CHAR8 **Etag + ); + +/** + + Save Redfish URI in database for further use. + + @param[in] ConfigLang ConfigLang to save + @param[in] Uri Redfish Uri to save + + @retval EFI_INVALID_PARAMETR SystemId is NULL or EMPTY + @retval EFI_SUCCESS Redfish uri is saved + +**/ +EFI_STATUS +RedfisSetRedfishUri ( + IN EFI_STRING ConfigLang, + IN EFI_STRING Uri ); =20 /** =20 Get the property name by given Configure Langauge. =20 - @param[in] ConfigureLang Configure Language string. + @param[in] ResourceUri URI of root of resource. + @param[in] ConfigureLang Configure Language string. =20 @retval EFI_STRING Pointer to property name. @retval NULL There is error. @@ -335,6 +456,7 @@ GetRedfishSchemaInfo ( **/ EFI_STRING GetPropertyFromConfigureLang ( + IN EFI_STRING ResourceUri, IN EFI_STRING ConfigureLang ); =20 @@ -417,25 +539,6 @@ PropertyChecker ( IN BOOLEAN ProvisionMode ); =20 -/** - - Check and see if we need to do provisioning for this two properties. - - @param[in] PropertyBuffer1 Pointer to property instance 1. - @param[in] PropertyBuffer2 Pointer to property instance 2. - @param[in] ProvisionMode TRUE if we are in provision mode. FALSE ot= herwise. - - @retval TRUE Provision is required. - @retval FALSE Provision is not required. - -**/ -BOOLEAN -PropertyChecker2Parm ( - IN VOID *PropertyBuffer1, - IN VOID *PropertyBuffer2, - IN BOOLEAN ProvisionMode - ); - /** =20 Keep ETAG string and URI string in database. @@ -450,7 +553,7 @@ PropertyChecker2Parm ( EFI_STATUS SetEtagWithUri ( IN CHAR8 *EtagStr, - IN CHAR8 *Uri + IN EFI_STRING Uri ); =20 /** @@ -465,7 +568,396 @@ SetEtagWithUri ( **/ CHAR8 * GetEtagWithUri ( - IN CHAR8 *Uri + IN EFI_STRING Uri + ); + +/** + + Get @odata.id from give HTTP payload. It's call responsibility to releas= e returned buffer. + + @param[in] Payload HTTP payload + + @retval NULL Can not find @odata.id from given payloa= d. + @retval Others odata.id string is returned. + +**/ +EFI_STRING +GetOdataId ( + IN REDFISH_PAYLOAD *Payload + ); + +/** + + Return config language from given URI and prperty name. It's call respon= sibility to release returned buffer. + + @param[in] Uri The URI to match + @param[in] PropertyName The property name of resource. This is optiona= l. + + @retval NULL Can not find redfish uri. + @retval Other redfish uri is returned. + +**/ +EFI_STRING +GetConfigureLang ( + IN CHAR8 *Uri, + IN CHAR8 *PropertyName OPTIONAL + ); + +/** + + Return redfish URI by given config language. It's call responsibility to= release returned buffer. + + @param[in] ConfigLang ConfigLang to search. + + @retval NULL Can not find redfish uri. + @retval Other redfish uri is returned. + +**/ +EFI_STRING +RedfishGetUri ( + IN EFI_STRING ConfigLang + ); + +/** + + Return config language by given URI. It's call responsibility to release= returned buffer. + + @param[in] Uri Uri to search. + + @retval NULL Can not find redfish uri. + @retval Other redfish uri is returned. + +**/ +EFI_STRING +RedfishGetConfigLanguage ( + IN EFI_STRING Uri + ); + +/** + + Convert Unicode string to ASCII string. It's call responsibility to rele= ase returned buffer. + + @param[in] UnicodeStr Unicode string to convert. + + @retval CHAR8 * ASCII string returned. + @retval NULL Errors occur. + +**/ +CHAR8 * +StrUnicodeToAscii ( + IN EFI_STRING UnicodeStr + ); + +/** + + Convert ASCII string to Unicode string. It's call responsibility to rele= ase returned buffer. + + @param[in] AsciiStr ASCII string to convert. + + @retval EFI_STRING Unicode string returned. + @retval NULL Errors occur. + +**/ +EFI_STRING +StrAsciiToUnicode ( + IN CHAR8 *AsciiStr + ); + +/** + + Check and see if ETAG is identical to what we keep in system. + + @param[in] Uri URI requested + @param[in] EtagInHeader ETAG string returned from HTTP request. + @param[in] EtagInJson ETAG string in JSON body. + + @retval TRUE ETAG is identical. + @retval FALSE ETAG is changed. + +**/ +BOOLEAN +CheckEtag ( + IN EFI_STRING Uri, + IN CHAR8 *EtagInHeader, + IN CHAR8 *EtagInJson + ); + +/** + + Get the property string value in array type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] ArraySize The size of returned array. + + @retval CHAR8 ** Returned string array. NULL while error happen= s. + +**/ +CHAR8 ** +GetPropertyStringArrayValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINTN *ArraySize + ); + +/** + + Get the property numeric value in array type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] ArraySize The size of returned array. + + @retval INT64 ** Returned integer array. NULL while error happe= ns. + +**/ +INT64 * +GetPropertyNumericArrayValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINTN *ArraySize + ); + +/** + + Get the property boolean value in array type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] ArraySize The size of returned array. + + @retval BOOLEAN * Returned boolean array. NULL while error happ= ens. + +**/ +BOOLEAN * +GetPropertyBooleanArrayValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINTN *ArraySize + ); + +/** + + Get the property value in the vague type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] NumberOfValues Return the number of vague type of values + + @retval RedfishCS_EmptyProp_KeyValue The pointer to the structure + of vague type of values. + +**/ +RedfishCS_EmptyProp_KeyValue * +GetPropertyVagueValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINT32 *NumberOfValues + ); + +/** + + Free the list of empty property key values. + + @param[in] EmptyPropKeyValueListHead The head of RedfishCS_EmptyProp_K= eyValue + +**/ +VOID +FreeEmptyPropKeyValueList ( + RedfishCS_EmptyProp_KeyValue *EmptyPropKeyValueListHead + ); + +/** + + Check and see if given property is in JSON context or not + + @param[in] Property Property name string + @param[in] Json The JSON context to search. + + @retval TRUE Property is found in JSON context + @retval FALSE Property is not in JSON context + +**/ +BOOLEAN +MatchPropertyWithJsonContext ( + IN EFI_STRING Property, + IN CHAR8 *Json +); + +/** + + Create string array and append to arry node in Redfish JSON convert form= at. + + @param[in,out] Head The head of string array. + @param[in] StringArray Input string array. + @param[in] ArraySize The size of StringArray. + + @retval EFI_SUCCESS String array is created successfully. + @retval Others Error happens + +**/ +EFI_STATUS +AddRedfishCharArray ( + IN OUT RedfishCS_char_Array **Head, + IN CHAR8 **StringArray, + IN UINTN ArraySize + ); + +/** + + Create numeric array and append to arry node in Redfish JSON convert for= mat. + + @param[in,out] Head The head of string array. + @param[in] NumericArray Input numeric array. + @param[in] ArraySize The size of StringArray. + + @retval EFI_SUCCESS String array is created successfully. + @retval Others Error happens + +**/ +EFI_STATUS +AddRedfishNumericArray ( + IN OUT RedfishCS_int64_Array **Head, + IN INT64 *NumericArray, + IN UINTN ArraySize + ); + +/** + + Create boolean array and append to arry node in Redfish JSON convert for= mat. + + @param[in,out] Head The head of string array. + @param[in] BooleanArray Input boolean array. + @param[in] ArraySize The size of BooleanArray. + + @retval EFI_SUCCESS String array is created successfully. + @retval Others Error happens + +**/ +EFI_STATUS +AddRedfishBooleanArray ( + IN OUT RedfishCS_bool_Array **Head, + IN BOOLEAN *BooleanArray, + IN UINTN ArraySize + ); +/** + + Check and see if value in Redfish string array are all the same as the o= ne + from HII configuration. + + @param[in] Head The head of string array. + @param[in] StringArray Input string array. + @param[in] ArraySize The size of StringArray. + + @retval TRUE All string in Redfish array are as same as str= ing + in HII configuration array. + FALSE These two array are not identical. + +**/ +BOOLEAN +CompareRedfishStringArrayValues ( + IN RedfishCS_char_Array *Head, + IN CHAR8 **StringArray, + IN UINTN ArraySize + ); + +/** + + Check and see if value in Redfish numeric array are all the same as the = one + from HII configuration. + + @param[in] Head The head of Redfish CS numeraic array. + @param[in] NumericArray Input numeric array. + @param[in] ArraySize The size of NumericArray. + + @retval TRUE All string in Redfish array are as same as int= eger + in HII configuration array. + FALSE These two array are not identical. + +**/ +BOOLEAN +CompareRedfishNumericArrayValues ( + IN RedfishCS_int64_Array *Head, + IN INT64 *NumericArray, + IN UINTN ArraySize + ); + +/** + + Check and see if value in Redfish boolean array are all the same as the = one + from HII configuration. + + @param[in] Head The head of Redfish CS boolean array. + @param[in] BooleanArray Input boolean array. + @param[in] ArraySize The size of BooleanArray. + + @retval TRUE All string in Redfish array are as same as int= eger + in HII configuration array. + FALSE These two array are not identical. + +**/ +BOOLEAN +CompareRedfishBooleanArrayValues ( + IN RedfishCS_bool_Array *Head, + IN BOOLEAN *BooleanArray, + IN UINTN ArraySize + ); + +/** + + Check and see if any difference between two vague value set. + This is just a simple check. + + @param[in] RedfishVagueKeyValuePtr The vague key value sets on Redf= ish service. + @param[in] RedfishVagueKeyValueNumber The numebr of vague key value se= ts + @param[in] ConfigVagueKeyValuePtr The vague configuration on platf= orm. + @param[in] ConfigVagueKeyValueNumber The numebr of vague key value se= ts + + @retval TRUE All values are the same. + FALSE There is some difference. + +**/ +BOOLEAN +CompareRedfishPropertyVagueValues ( + IN RedfishCS_EmptyProp_KeyValue *RedfishVagueKeyValuePtr, + IN UINT32 RedfishVagueKeyValueNumber, + IN RedfishCS_EmptyProp_KeyValue *ConfigVagueKeyValuePtr, + IN UINT32 ConfigVagueKeyValueNumber + ); + +/** + + Find "ETag" and "Location" from either HTTP header or Redfish response. + + @param[in] Response HTTP response + @param[out] Etag String buffer to return ETag + @param[out] Location String buffer to return Location + + @retval EFI_SUCCESS Data is found and returned. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetEtagAndLocation ( + IN REDFISH_RESPONSE *Response, + OUT CHAR8 **Etag, OPTIONAL + OUT EFI_STRING *Location OPTIONAL ); =20 #endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RedfishCsCommon.= h b/RedfishClientPkg/Include/RedfishJsonStructure/RedfishCsCommon.h new file mode 100644 index 0000000000..4d0ae50fc8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RedfishCsCommon.h @@ -0,0 +1,14 @@ +/** @file + Wrapper file for RedfishCsCommon.h + + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef WRAPPER_REDFISH_CS_COMMON_H_ +#define WRAPPER_REDFISH_CS_COMMON_H_ + +#include "ConverterLib/include/RedfishCsCommon.h" + +#endif diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityInternal.h b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/Red= fishFeatureUtilityInternal.h index 7d38d327ef..38d2af52b2 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyInternal.h +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyInternal.h @@ -1,7 +1,7 @@ /** @file Common header file for RedfishFeatureUtilityLib driver. =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -11,33 +11,39 @@ #define REDFISH_FEATURE_INTERNAL_H_ =20 #include +#include + +#include =20 #include #include #include #include #include -#include -#include #include #include #include #include #include #include +#include +#include =20 #include =20 #include +#include =20 #define INDEX_VARIABLE_SIZE 64 #define INDEX_STRING_SIZE 16 -#define IS_EMPTY_STRING(a) (a =3D=3D NULL || a[0] =3D=3D '\0') #define INDEX_STRING L"{%d}" #define SCHEMA_NAME_PREFIX "x-uefi-redfish-" #define SCHEMA_NAME_PREFIX_OFFSET (AsciiStrLen (SCHEMA_NAME_PREFIX)) -#define REDFISH_SYSTEM_ROOT_PATH "/v1/Systems[UUID~%g]" +#define REDFISH_ROOT_PATH "/v1" +#define REDFISH_ROOT_PATH_UNICODE L"/v1" #define MAX_CONF_LANG_LEN 128 +#define MAX_REDFISH_URL_LEN 255 +#define REGULAR_EXPRESSION_ARRAY L"\\[.*\\]/.*" =20 #define BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_START_SIGNATURE L"{" #define BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_END_SIGNATURE L"}" diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishF= eatureUtilityLib.c index cf8696e5f0..2bd7f58f9c 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c @@ -1,7 +1,7 @@ /** @file Redfish feature utility library implementation =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -9,7 +9,34 @@ =20 #include "RedfishFeatureUtilityInternal.h" =20 -EDKII_REDFISH_ETAG_PROTOCOL *mEtagProtocol; +EDKII_REDFISH_ETAG_PROTOCOL *mEtagProtocol =3D NULL; +EDKII_REDFISH_CONFIG_LANG_MAP_PROTOCOL *mConfigLangMapProtocol =3D NULL; + + +EFI_STATUS +RedfishLocateProtocol ( + IN VOID **ProtocolInstance, + IN EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + + if (ProtocolInstance =3D=3D NULL || ProtocolGuid =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (*ProtocolInstance !=3D NULL) { + return EFI_SUCCESS; + } + + Status =3D gBS->LocateProtocol ( + ProtocolGuid, + NULL, + ProtocolInstance + ); + return Status; +} + =20 /** =20 @@ -71,227 +98,168 @@ GetArraykeyFromUri ( =20 /** =20 - Keep configure language with given key in UEFI variable. + Keep ETAG string and URI string in database. =20 - @param[in] Schema Schema name. - @param[in] Version Schema version. - @param[in] Key Key string. - @param[in] ConfigureLangIndex Index value. + @param[in] EtagStr ETAG string. + @param[in] Uri URI string. =20 - @retval EFI_SUCCESS Data is saved in UEFI variable. - @retval Others Errors occur. + @retval EFI_SUCCESS ETAG and URI are applied successfully. + @retval Others Errors occur. =20 **/ EFI_STATUS -SetConfigureLangWithkey ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN CHAR8 *Key, - IN UINTN ConfigureLangIndex +SetEtagWithUri ( + IN CHAR8 *EtagStr, + IN EFI_STRING Uri ) { - CHAR16 IndexString[INDEX_STRING_SIZE]; - CHAR16 VarName[INDEX_VARIABLE_SIZE]; - CHAR16 *VarData; - EFI_STATUS Status; - // - // Variable content. - // - UnicodeSPrint (IndexString, sizeof (IndexString), INDEX_STRING, Configur= eLangIndex); + EFI_STATUS Status; + CHAR8 *AsciiUri; =20 - // - // Variable name. - // - UnicodeSPrint (VarName, sizeof (VarName), L"%a_%a_%a", Schema, Version, = Key); + if (IS_EMPTY_STRING (EtagStr) || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } =20 - // - // Check if it exists already. - // - Status =3D GetVariable2 ( - VarName, - &gEfiCallerIdGuid, - (VOID *)&VarData, - NULL - ); - if (!EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a, remove stale data: %s\n", __FUNCTION__, VarDa= ta)); - FreePool (VarData); - gRT->SetVariable (VarName, &gEfiCallerIdGuid, VARIABLE_ATTRIBUTE_NV_BS= , 0, NULL); + Status =3D RedfishLocateProtocol ((VOID **)&mEtagProtocol, &gEdkIIRedfis= hETagProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to locate gEdkIIRedfishETagProtocolGuid= : %r\n", __FUNCTION__, Status)); + return Status; } =20 - return gRT->SetVariable (VarName, &gEfiCallerIdGuid, VARIABLE_ATTRIBUTE_= NV_BS, StrSize (IndexString), (VOID *)&IndexString); + AsciiUri =3D StrUnicodeToAscii (Uri); + if (AsciiUri =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mEtagProtocol->Set (mEtagProtocol, AsciiUri, EtagStr); + mEtagProtocol->Flush (mEtagProtocol); + + FreePool (AsciiUri); + + return EFI_SUCCESS; } =20 /** =20 - Find configure language with input key string. + Find ETAG string that refers to given URI. =20 - @param[in] Schema Schema name. - @param[in] Version Schema version. - @param[in] Property Property name. - @param[in] Key Key string. + @param[in] Uri Target URI string. =20 - @retval CHAR16 * Corresponding configure langauge - @retval NULL No configure language is found + @retval CHAR8 * ETAG string + @retval NULL No ETAG is found. =20 **/ -CHAR16 * -GetConfigureLangByKey ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN CHAR8 *Property, OPTIONAL - IN CHAR8 *Key +CHAR8 * +GetEtagWithUri ( + IN EFI_STRING Uri ) { - EFI_STATUS Status; - CHAR16 VariableName[64]; - UINTN VariableSize; - CHAR16 *CollectionIndex; - CHAR16 *ConfigureLang; - UINTN ConfigureLangLen; + EFI_STATUS Status; + CHAR8 *AsciiUri; + CHAR8 *EtagStr; =20 - if (Schema =3D=3D NULL || Version =3D=3D NULL || Key =3D=3D NULL) { + if (IS_EMPTY_STRING (Uri)) { return NULL; } =20 - CollectionIndex =3D NULL; - ConfigureLang =3D NULL; - - UnicodeSPrint (VariableName, 64, L"%a_%a_%a", Schema, Version, Key); - - Status =3D GetVariable2 ( - VariableName, - &gEfiCallerIdGuid, - (VOID *)&CollectionIndex, - &VariableSize - ); + Status =3D RedfishLocateProtocol ((VOID **)&mEtagProtocol, &gEdkIIRedfis= hETagProtocolGuid); if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to locate gEdkIIRedfishETagProtocolGuid= : %r\n", __FUNCTION__, Status)); return NULL; } =20 - ConfigureLangLen =3D AsciiStrLen (Schema) + StrLen (CollectionIndex) + (= Property =3D=3D NULL ? 0 : AsciiStrLen (Property)) + 3 + 1; - ConfigureLang =3D AllocatePool (sizeof (CHAR16) * ConfigureLangLen); - ASSERT (ConfigureLang); - - if (Property !=3D NULL) { - UnicodeSPrint (ConfigureLang, sizeof (CHAR16) * ConfigureLangLen, L"/%= a/%s/%a", Schema, CollectionIndex, Property); - } else { - UnicodeSPrint (ConfigureLang, sizeof (CHAR16) * ConfigureLangLen, L"/%= a/%s", Schema, CollectionIndex); + AsciiUri =3D StrUnicodeToAscii (Uri); + if (AsciiUri =3D=3D NULL) { + return NULL; } =20 - FreePool (CollectionIndex); - - return ConfigureLang; -} - -/** - - Keep ETAG string and URI string in database. - - @param[in] EtagStr ETAG string. - @param[in] Uri URI string. - - @retval EFI_SUCCESS ETAG and URI are applied successfully. - @retval Others Errors occur. - -**/ -EFI_STATUS -SetEtagWithUri ( - IN CHAR8 *EtagStr, - IN CHAR8 *Uri - ) -{ - EFI_STATUS Status; + Status =3D mEtagProtocol->Get (mEtagProtocol, AsciiUri, &EtagStr); =20 - if (IS_EMPTY_STRING (EtagStr) || IS_EMPTY_STRING (Uri)) { - return EFI_INVALID_PARAMETER; - } + FreePool (AsciiUri); =20 - if (mEtagProtocol =3D=3D NULL) { - Status =3D gBS->LocateProtocol ( - &gEdkIIRedfishETagProtocolGuid, - NULL, - (VOID **)&mEtagProtocol - ); - if (EFI_ERROR (Status)) { - return Status; - } + if (EFI_ERROR (Status)) { + return NULL; } =20 - mEtagProtocol->Set (mEtagProtocol, Uri, EtagStr); - mEtagProtocol->Flush (mEtagProtocol); - - return EFI_SUCCESS; + return EtagStr; } =20 /** =20 - Find ETAG string that refers to given URI. + Convert Unicode string to ASCII string. It's call responsibility to rele= ase returned buffer. =20 - @param[in] Uri Target URI string. + @param[in] UnicodeStr Unicode string to convert. =20 - @retval CHAR8 * ETAG string - @retval NULL No ETAG is found. + @retval CHAR8 * ASCII string returned. + @retval NULL Errors occur. =20 **/ CHAR8 * -GetEtagWithUri ( - IN CHAR8 *Uri +StrUnicodeToAscii ( + IN EFI_STRING UnicodeStr ) { - EFI_STATUS Status; - CHAR8 *EtagStr; + CHAR8 *AsciiStr; + UINTN AsciiStrSize; + EFI_STATUS Status; =20 - if (IS_EMPTY_STRING (Uri)) { + if (IS_EMPTY_STRING (UnicodeStr)) { return NULL; } =20 - if (mEtagProtocol =3D=3D NULL) { - Status =3D gBS->LocateProtocol ( - &gEdkIIRedfishETagProtocolGuid, - NULL, - (VOID **)&mEtagProtocol - ); - if (EFI_ERROR (Status)) { - return NULL; - } + AsciiStrSize =3D StrLen (UnicodeStr) + 1; + AsciiStr =3D AllocatePool (AsciiStrSize); + if (AsciiStr =3D=3D NULL) { + return NULL; } =20 - Status =3D mEtagProtocol->Get (mEtagProtocol, Uri, &EtagStr); + Status =3D UnicodeStrToAsciiStrS (UnicodeStr, AsciiStr, AsciiStrSize); if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "UnicodeStrToAsciiStrS failed: %r\n", Status)); + FreePool (AsciiStr); return NULL; } =20 - return EtagStr; + return AsciiStr; } =20 /** =20 - Convert HII string value to string value in JSON format. + Convert ASCII string to Unicode string. It's call responsibility to rele= ase returned buffer. =20 - @param[in] HiiStringValue String in HII format. + @param[in] AsciiStr ASCII string to convert. =20 - @retval CHAR8 * String in JSON format. + @retval EFI_STRING Unicode string returned. @retval NULL Errors occur. =20 **/ -CHAR8 * -ConvertHiiStringValueToJsonStringValue ( - IN EFI_STRING HiiStringValue +EFI_STRING +StrAsciiToUnicode ( + IN CHAR8 *AsciiStr ) { - CHAR8 *JsonValue; - UINTN JsonValueSize; + EFI_STRING UnicodeStr; + UINTN UnicodeStrSize; + EFI_STATUS Status; =20 - if (IS_EMPTY_STRING (HiiStringValue)) { + if (IS_EMPTY_STRING (AsciiStr)) { return NULL; } =20 - JsonValueSize =3D StrLen (HiiStringValue) + 1; - JsonValue =3D AllocatePool (JsonValueSize); - UnicodeStrToAsciiStrS (HiiStringValue, JsonValue, JsonValueSize); + UnicodeStrSize =3D (AsciiStrLen (AsciiStr) + 1) * sizeof (CHAR16); + UnicodeStr =3D AllocatePool (UnicodeStrSize); + if (UnicodeStr =3D=3D NULL) { + return NULL; + } + + Status =3D AsciiStrToUnicodeStrS (AsciiStr, UnicodeStr, UnicodeStrSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "t failed: %r\n", Status)); + FreePool (UnicodeStr); + return NULL; + } =20 - return JsonValue; + return UnicodeStr; } =20 /** @@ -480,997 +448,2979 @@ ApplyFeatureSettingsBooleanType ( =20 /** =20 - Read redfish resource by given resource path. + Apply property value to UEFI HII database in vague type. =20 - @param[in] Service Redfish srvice instacne to make query. - @param[in] ResourcePath Target resource path. - @param[out] Response HTTP response from redfish service. + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] VagueValuePtr Pointer of vague values to to set. + @param[in] NumVagueValues Number of vague values. =20 - @retval EFI_SUCCESS Resrouce is returned successfully. + @retval EFI_SUCCESS New value is applied successfully. @retval Others Errors occur. =20 **/ EFI_STATUS -GetResourceByPath ( - IN REDFISH_SERVICE *Service, - IN CHAR8 *ResourcePath, - OUT REDFISH_RESPONSE *Response +ApplyFeatureSettingsVagueType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_EmptyProp_KeyValue *VagueValuePtr, + IN UINT32 NumberOfVagueValues ) { - EFI_STATUS Status; - - if (Service =3D=3D NULL || Response =3D=3D NULL || IS_EMPTY_STRING (Reso= urcePath)) { + EFI_STATUS Status; + UINTN StrSize; + CHAR8 *ConfigureLangAscii; + CHAR8 *ConfigureLangKeyAscii; + EFI_STRING ConfigureKeyLang; + EDKII_REDFISH_VALUE RedfishValue; + EDKII_REDFISH_VALUE_TYPES PropertyDatatype; + RedfishCS_EmptyProp_KeyValue *CurrentVagueValuePtr; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || VagueValuePtr =3D=3D NULL || NumberOfVagueValues = =3D=3D 0) { return EFI_INVALID_PARAMETER; } =20 - // - // Get resource from redfish service. - // - Status =3D RedfishGetByService ( - Service, - ResourcePath, - Response - ); + ConfigureLangAscii =3D AllocatePool (StrLen (ConfigureLang) + 1); + if (ConfigureLangAscii =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a, Allocate memory for generate ConfigureLang o= f vague key of %a.%a %s failed: %r\n", __FUNCTION__, Schema, Version, Confi= gureLang, Status)); + return Status; + } + Status =3D UnicodeStrToAsciiStrS (ConfigureLang, ConfigureLangAscii, Str= Len (ConfigureLang) + 1); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, RedfishGetByService to %a failed: %r\n", __F= UNCTION__, ResourcePath, Status)); - if (Response->Payload !=3D NULL) { - RedfishDumpPayload (Response->Payload); - RedfishFreeResponse ( - NULL, - 0, - NULL, - Response->Payload - ); - Response->Payload =3D NULL; - } - + DEBUG ((DEBUG_ERROR, "%a, Convert the configureLang of vague key of %a= .%a %s failed: %r\n", __FUNCTION__, Schema, Version, ConfigureLang, Status)= ); return Status; } =20 + CurrentVagueValuePtr =3D VagueValuePtr; + while (CurrentVagueValuePtr !=3D NULL) { + // + // Generate ConfigureLang with the key name + // + //ConfigureKeyLang =3D GetConfigureLang (ConfigureLangAscii, CurrentVa= gueValuePtr->KeyNamePtr); + StrSize =3D AsciiStrLen (ConfigureLangAscii) + AsciiStrLen (CurrentVag= ueValuePtr->KeyNamePtr) + 2; + ConfigureLangKeyAscii =3D AllocateZeroPool (StrSize); + ConfigureKeyLang =3D AllocateZeroPool (StrSize * sizeof (CHAR16)); + if (ConfigureLangKeyAscii =3D=3D NULL || ConfigureKeyLang =3D=3D NULL)= { + DEBUG ((DEBUG_ERROR, "%a, Generate ConfigureLang of vague key of %= a.%a %s %a failed!\n", __FUNCTION__, Schema, Version, ConfigureLang, Curren= tVagueValuePtr->KeyNamePtr)); + goto ErrorContinue; + } + AsciiStrCatS(ConfigureLangKeyAscii, StrSize, ConfigureLangAscii); + AsciiStrCatS(ConfigureLangKeyAscii, StrSize, "/"); + AsciiStrCatS(ConfigureLangKeyAscii, StrSize, CurrentVagueValuePtr->Key= NamePtr); + AsciiStrToUnicodeStrS(ConfigureLangKeyAscii, ConfigureKeyLang, StrSize= ); + FreePool (ConfigureLangKeyAscii); + ConfigureLangKeyAscii =3D NULL; + // + // Initial property data type and value. + // + if (CurrentVagueValuePtr->Value->DataType =3D=3D RedfishCS_Vague_DataT= ype_String) { + PropertyDatatype =3D REDFISH_VALUE_TYPE_STRING; + } else if (CurrentVagueValuePtr->Value->DataType =3D=3D RedfishCS_Vagu= e_DataType_Bool) { + PropertyDatatype =3D REDFISH_VALUE_TYPE_BOOLEAN; + } else if (CurrentVagueValuePtr->Value->DataType =3D=3D RedfishCS_Vagu= e_DataType_Int64) { + PropertyDatatype =3D REDFISH_VALUE_TYPE_INTEGER; + } else { + DEBUG((DEBUG_ERROR, "%a, %a.%a %s Unsupported Redfish property data = type\n", __FUNCTION__, Schema, Version, ConfigureLang)); + goto ErrorContinue; + } + + // + // Get the current value from HII + // + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureKe= yLang, &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s failed: %r\n", __FUNCTION__, Sche= ma, Version, ConfigureKeyLang, Status)); + } else { + if (RedfishValue.Type !=3D PropertyDatatype) { + DEBUG((DEBUG_ERROR, "%a, %a.%a %s mismatched data type\n", __FUNCT= ION__, Schema, Version, ConfigureKeyLang)); + goto ErrorContinue; + } + if (PropertyDatatype =3D=3D REDFISH_VALUE_TYPE_STRING) { + // + // This is a string property. + // + if (AsciiStrCmp (CurrentVagueValuePtr->Value->DataValue.CharPtr, R= edfishValue.Value.Buffer) !=3D 0) { + // + // Apply settings from redfish + // + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s from %a to %a\n", __FUNC= TION__, Schema, Version, ConfigureKeyLang, RedfishValue.Value.Buffer, Curre= ntVagueValuePtr->Value->DataValue.CharPtr)); + FreePool (RedfishValue.Value.Buffer); + RedfishValue.Value.Buffer =3D CurrentVagueValuePtr->Value->DataV= alue.CharPtr; + Status =3D RedfishPlatformConfigSetValue (Schema, Version, Confi= gureKeyLang, RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply %a to %a failed: %r\n", __FUNC= TION__, ConfigureKeyLang, CurrentVagueValuePtr->Value->DataValue.CharPtr, S= tatus)); + } + } else { + DEBUG ((DEBUG_INFO, "%a, %a.%a %s value is: %a\n", __FUNCTION__,= Schema, Version, ConfigureKeyLang, RedfishValue.Value.Buffer, Status)); + } + } else if (PropertyDatatype =3D=3D REDFISH_VALUE_TYPE_BOOLEAN) { + // + // This is a boolean property. + // + if (RedfishValue.Value.Boolean !=3D *CurrentVagueValuePtr->Value->= DataValue.BoolPtr) { + // + // Apply settings from redfish + // + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s from %a to %a\n", + __FUNCTION__, + Schema, + Version, + ConfigureKeyLang, + (RedfishValue.Value.Boolean ? "True" : "False"), + (*CurrentVagueValuePtr->Value->DataValue.BoolPtr ? "True= " : "False"))); + + RedfishValue.Value.Boolean =3D (BOOLEAN)*CurrentVagueValuePtr->V= alue->DataValue.BoolPtr; + Status =3D RedfishPlatformConfigSetValue (Schema, Version, Confi= gureKeyLang, RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply %s to %a failed: %r\n", __FUNC= TION__, ConfigureKeyLang, (*CurrentVagueValuePtr->Value->DataValue.BoolPtr = ? "True" : "False"), Status)); + } + } else { + DEBUG ((DEBUG_INFO, "%a, %a.%a %s value is: %a\n", __FUNCTION__,= Schema, Version, ConfigureKeyLang, (RedfishValue.Value.Boolean ? "True" : = "False"), Status)); + } + } else if (PropertyDatatype =3D=3D REDFISH_VALUE_TYPE_INTEGER) { + // + // This is a integer property. + // + if (RedfishValue.Value.Integer !=3D *CurrentVagueValuePtr->Value->= DataValue.Int64Ptr) { + // + // Apply settings from redfish + // + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s from 0x%x to 0x%x\n", __= FUNCTION__, Schema, Version, ConfigureKeyLang, RedfishValue.Value.Integer, = *CurrentVagueValuePtr->Value->DataValue.Int64Ptr)); + + RedfishValue.Value.Integer =3D (INT64)*CurrentVagueValuePtr->Val= ue->DataValue.Int64Ptr; + Status =3D RedfishPlatformConfigSetValue (Schema, Version, Confi= gureKeyLang, RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply %s to 0x%x failed: %r\n", __FU= NCTION__, ConfigureKeyLang, *CurrentVagueValuePtr->Value->DataValue.Int64Pt= r, Status)); + } + } else { + DEBUG ((DEBUG_INFO, "%a, %a.%a %s value is: 0x%x\n", __FUNCTION_= _, Schema, Version, ConfigureKeyLang, RedfishValue.Value.Integer, Status)); + } + } else { + DEBUG((DEBUG_ERROR, "%a, %a.%a %s Unsupported Redfish property dat= a type\n", __FUNCTION__, Schema, Version, ConfigureLang)); + goto ErrorContinue; + } + } + +ErrorContinue:; + if (ConfigureLangKeyAscii !=3D NULL) { + FreePool (ConfigureLangKeyAscii); + ConfigureLangKeyAscii =3D NULL; + } + if (ConfigureKeyLang !=3D NULL) { + FreePool (ConfigureKeyLang); + ConfigureKeyLang =3D NULL; + } + CurrentVagueValuePtr =3D CurrentVagueValuePtr->NextKeyValuePtr; + }; + + if (ConfigureLangAscii !=3D NULL) { + FreePool (ConfigureLangAscii); + } + if (ConfigureLangKeyAscii !=3D NULL) { + FreePool (ConfigureLangKeyAscii); + } + if (ConfigureKeyLang !=3D NULL) { + FreePool (ConfigureKeyLang); + } return EFI_SUCCESS; } =20 /** =20 - Find array index from given configure language string. - - @param[in] ConfigureLang Configure language string to parse. - @param[out] UnifiedConfigureLang The configure language in array. - @param[out] Index The array index number. + Release the memory in RedfishValue while value type is array. =20 - @retval EFI_SUCCESS Index is found. - @retval Others Errors occur. + @param[in] RedfishValue Pointer to Redfish value =20 **/ -EFI_STATUS -GetArrayIndexFromArrayTypeConfigureLang ( - IN CHAR16 *ConfigureLang, - OUT CHAR16 **UnifiedConfigureLang, - OUT UINTN *Index +VOID +FreeArrayTypeRedfishValue ( + EDKII_REDFISH_VALUE *RedfishValue ) { - CHAR16 *TmpConfigureLang; - CHAR16 *IndexString; - CHAR16 *TmpString; - - if (ConfigureLang =3D=3D NULL || UnifiedConfigureLang =3D=3D NULL || Ind= ex =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - TmpConfigureLang =3D AllocateCopyPool (StrSize (ConfigureLang), Configur= eLang); - if (TmpConfigureLang =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } + UINTN Index; =20 - // - // looking for index signature "{"" - // - IndexString =3D StrStr (TmpConfigureLang, BIOS_CONFIG_TO_REDFISH_REDPATH= _ARRAY_START_SIGNATURE); - if (IndexString =3D=3D NULL) { - return EFI_NOT_FOUND; + if (RedfishValue =3D=3D NULL) { + return; } =20 - // - // Skip "{" - // - TmpString =3D IndexString + StrLen (BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY= _START_SIGNATURE); - - // - // Looking for "}" - // - TmpString =3D StrStr (TmpString, BIOS_CONFIG_TO_REDFISH_REDPATH_ARRAY_EN= D_SIGNATURE); - if (TmpString =3D=3D NULL) { - return EFI_NOT_FOUND; + if (RedfishValue->Type !=3D REDFISH_VALUE_TYPE_INTEGER_ARRAY && RedfishV= alue->Type !=3D REDFISH_VALUE_TYPE_STRING_ARRAY) { + return; } =20 - // - // Append '\0' for converting decimal string to integer. - // - TmpString[0] =3D '\0'; + switch (RedfishValue->Type) { + case REDFISH_VALUE_TYPE_STRING_ARRAY: + for (Index =3D 0; Index < RedfishValue->ArrayCount; Index++) { + FreePool (RedfishValue->Value.StringArray[Index]); + } + FreePool (RedfishValue->Value.StringArray); + RedfishValue->Value.StringArray =3D NULL; + break; =20 - // - // Convert decimal string to integer - // - *Index =3D StrDecimalToUintn (IndexString + StrLen (BIOS_CONFIG_TO_REDFI= SH_REDPATH_ARRAY_START_SIGNATURE)); + case REDFISH_VALUE_TYPE_INTEGER_ARRAY: + FreePool (RedfishValue->Value.IntegerArray); + RedfishValue->Value.IntegerArray =3D NULL; + break; =20 - // - // Resotre the '}' character and remove rest of string. - // - TmpString[0] =3D L'}'; - TmpString[1] =3D '\0'; + case REDFISH_VALUE_TYPE_BOOLEAN_ARRAY: + FreePool (RedfishValue->Value.BooleanArray); + RedfishValue->Value.BooleanArray =3D NULL; + break; =20 - *UnifiedConfigureLang =3D TmpConfigureLang; + default: + return; + } =20 - return EFI_SUCCESS; + RedfishValue->ArrayCount =3D 0; } =20 + /** =20 - Search HII database with given Configure Language pattern. Data is handl= ed and - returned in array. + Apply property value to UEFI HII database in string array type. =20 - @param[in] Schema The schema to search. - @param[in] Version The schema version. - @param[in] Pattern Configure Language pattern to sear= ch. - @param[out] UnifiedConfigureLangList The data returned by HII database. + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] ArrayHead Head of array value. =20 - @retval EFI_SUCCESS Data is found and returned. + @retval EFI_SUCCESS New value is applied successfully. @retval Others Errors occur. =20 **/ EFI_STATUS -RedfishFeatureGetUnifiedArrayTypeConfigureLang ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING Pattern, OPTIONAL - OUT REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *UnifiedConfigureLan= gList +ApplyFeatureSettingsStringArrayType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_char_Array *ArrayHead ) { - EFI_STATUS Status; - EFI_STRING *ConfigureLangList; - UINTN Count; - UINTN Index; - UINTN Index2; - UINTN ArrayIndex; - EFI_STRING UnifiedConfigureLang; - BOOLEAN Duplicated; - REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG UnifiedConfigureLangPool[BIOS_CON= FIG_TO_REDFISH_REDPATH_POOL_SIZE]; + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + UINTN Index; + RedfishCS_char_Array *Buffer; =20 - if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || UnifiedConf= igureLangList =3D=3D NULL) { + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || ArrayHead =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - UnifiedConfigureLangList->Count =3D 0; - UnifiedConfigureLangList->List =3D NULL; - ZeroMem (UnifiedConfigureLangPool, sizeof (UnifiedConfigureLangPool)); - - Status =3D RedfishPlatformConfigGetConfigureLang (Schema, Version, Patte= rn, &ConfigureLangList, &Count); + // + // Get the current value from HII + // + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= , &RedfishValue); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, RedfishFeatureGetConfigureLangRegex failed: = %r\n", __FUNCTION__, Status)); - return Status; - } + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s failed: %r\n", __FUNCTION__, Schema= , Version, ConfigureLang, Status)); + } else { =20 - if (Count =3D=3D 0) { - return EFI_NOT_FOUND; + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_STRING_ARRAY) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n= ", __FUNCTION__, Schema, Version, ConfigureLang)); + return EFI_DEVICE_ERROR; + } + + // + // If there is no change in array, do nothing + // + if (!CompareRedfishStringArrayValues (ArrayHead, RedfishValue.Value.St= ringArray, RedfishValue.ArrayCount)) { + // + // Apply settings from redfish + // + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s for array\n", __FUNCTION__, = Schema, Version, ConfigureLang)); + FreeArrayTypeRedfishValue (&RedfishValue); + + // + // Convert array from RedfishCS_char_Array to EDKII_REDFISH_VALUE + // + RedfishValue.ArrayCount =3D 0; + Buffer =3D ArrayHead; + while (Buffer !=3D NULL) { + RedfishValue.ArrayCount +=3D 1; + Buffer =3D Buffer->Next; + } + + // + // Allocate pool for new values + // + RedfishValue.Value.StringArray =3D AllocatePool (RedfishValue.ArrayC= ount *sizeof (CHAR8 *)); + if (RedfishValue.Value.StringArray =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + + Buffer =3D ArrayHead; + Index =3D 0; + while (Buffer !=3D NULL) { + RedfishValue.Value.StringArray[Index] =3D AllocateCopyPool (AsciiS= trSize (Buffer->ArrayValue), Buffer->ArrayValue); + if (RedfishValue.Value.StringArray[Index] =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + Buffer =3D Buffer->Next; + Index++; + } + + ASSERT (Index <=3D RedfishValue.ArrayCount); + + Status =3D RedfishPlatformConfigSetValue (Schema, Version, Configure= Lang, RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply %s array failed: %r\n", __FUNCTION= __, ConfigureLang, Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s array value has no change\n", __F= UNCTION__, Schema, Version, ConfigureLang)); + } } =20 - for (Index =3D 0; Index < Count; Index++) { - Status =3D GetArrayIndexFromArrayTypeConfigureLang (ConfigureLangList[= Index], &UnifiedConfigureLang, &ArrayIndex); - if (EFI_ERROR (Status)) { - ASSERT (FALSE); - continue; + return Status; +} + +/** + + Apply property value to UEFI HII database in numeric array type (INT64). + + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] ArrayHead Head of array value. + + @retval EFI_SUCCESS New value is applied successfully. + @retval Others Errors occur. + +**/ +EFI_STATUS +ApplyFeatureSettingsNumericArrayType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_int64_Array *ArrayHead + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + UINTN Index; + RedfishCS_int64_Array *Buffer; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || ArrayHead =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Get the current value from HII + // + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= , &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s failed: %r\n", __FUNCTION__, Schema= , Version, ConfigureLang, Status)); + } else { + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_INTEGER_ARRAY) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n"= , __FUNCTION__, Schema, Version, ConfigureLang)); + return EFI_DEVICE_ERROR; } =20 // - // Check if this configure language is duplicated. + // If there is no change in array, do nothing // - Duplicated =3D FALSE; - for (Index2 =3D 0; Index2 < BIOS_CONFIG_TO_REDFISH_REDPATH_POOL_SIZE; = Index2++) { - if (UnifiedConfigureLangPool[Index2].ConfigureLang =3D=3D NULL) { - break; + if (!CompareRedfishNumericArrayValues (ArrayHead, RedfishValue.Value.I= ntegerArray, RedfishValue.ArrayCount)) { + // + // Apply settings from redfish + // + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s for array\n", __FUNCTION__, = Schema, Version, ConfigureLang)); + FreeArrayTypeRedfishValue (&RedfishValue); + + // + // Convert array from RedfishCS_int64_Array to EDKII_REDFISH_VALUE + // + RedfishValue.ArrayCount =3D 0; + Buffer =3D ArrayHead; + while (Buffer !=3D NULL) { + RedfishValue.ArrayCount +=3D 1; + Buffer =3D Buffer->Next; + } + + // + // Allocate pool for new values + // + RedfishValue.Value.IntegerArray =3D AllocatePool (RedfishValue.Array= Count * sizeof (INT64)); + if (RedfishValue.Value.IntegerArray =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + + Buffer =3D ArrayHead; + Index =3D 0; + while (Buffer !=3D NULL) { + RedfishValue.Value.IntegerArray[Index] =3D (INT64)*Buffer->ArrayVa= lue; + Buffer =3D Buffer->Next; + Index++; + } + + ASSERT (Index <=3D RedfishValue.ArrayCount); + + Status =3D RedfishPlatformConfigSetValue (Schema, Version, Configure= Lang, RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply %s array failed: %r\n", __FUNCTION= __, ConfigureLang, Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s array value has no change\n", __F= UNCTION__, Schema, Version, ConfigureLang)); + } + } + + return Status; +} + +/** + + Apply property value to UEFI HII database in boolean array type (INT64). + + @param[in] Schema Property schema. + @param[in] Version Property schema version. + @param[in] ConfigureLang Configure language refers to this property. + @param[in] ArrayHead Head of Redfich CS boolean array value. + + @retval EFI_SUCCESS New value is applied successfully. + @retval Others Errors occur. + +**/ +EFI_STATUS +ApplyFeatureSettingsBooleanArrayType ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN RedfishCS_bool_Array *ArrayHead + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + UINTN Index; + RedfishCS_bool_Array *Buffer; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || ArrayHead =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Get the current value from HII + // + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= , &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s failed: %r\n", __FUNCTION__, Schema= , Version, ConfigureLang, Status)); + } else { + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_BOOLEAN_ARRAY) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n"= , __FUNCTION__, Schema, Version, ConfigureLang)); + return EFI_DEVICE_ERROR; + } + + // + // If there is no change in array, do nothing + // + if (!CompareRedfishBooleanArrayValues (ArrayHead, RedfishValue.Value.B= ooleanArray, RedfishValue.ArrayCount)) { + // + // Apply settings from redfish + // + DEBUG ((DEBUG_INFO, "%a, %a.%a apply %s for array\n", __FUNCTION__, = Schema, Version, ConfigureLang)); + FreeArrayTypeRedfishValue (&RedfishValue); + + // + // Convert array from RedfishCS_int64_Array to EDKII_REDFISH_VALUE + // + RedfishValue.ArrayCount =3D 0; + Buffer =3D ArrayHead; + while (Buffer !=3D NULL) { + RedfishValue.ArrayCount +=3D 1; + Buffer =3D Buffer->Next; + } + + // + // Allocate pool for new values + // + RedfishValue.Value.BooleanArray =3D AllocatePool (RedfishValue.Array= Count * sizeof (BOOLEAN)); + if (RedfishValue.Value.BooleanArray =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + + Buffer =3D ArrayHead; + Index =3D 0; + while (Buffer !=3D NULL) { + RedfishValue.Value.BooleanArray[Index] =3D (BOOLEAN)*Buffer->Array= Value; + Buffer =3D Buffer->Next; + Index++; + } + + ASSERT (Index <=3D RedfishValue.ArrayCount); + + Status =3D RedfishPlatformConfigSetValue (Schema, Version, Configure= Lang, RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply %s array failed: %r\n", __FUNCTION= __, ConfigureLang, Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s array value has no change\n", __F= UNCTION__, Schema, Version, ConfigureLang)); + } + } + + return Status; +} + +/** + + Read redfish resource by given resource URI. + + @param[in] Service Redfish srvice instacne to make query. + @param[in] ResourceUri Target resource URI. + @param[out] Response HTTP response from redfish service. + + @retval EFI_SUCCESS Resrouce is returned successfully. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetResourceByUri ( + IN REDFISH_SERVICE *Service, + IN EFI_STRING ResourceUri, + OUT REDFISH_RESPONSE *Response + ) +{ + EFI_STATUS Status; + CHAR8 *AsciiResourceUri; + + if (Service =3D=3D NULL || Response =3D=3D NULL || IS_EMPTY_STRING (Reso= urceUri)) { + return EFI_INVALID_PARAMETER; + } + + AsciiResourceUri =3D StrUnicodeToAscii (ResourceUri); + if (AsciiResourceUri =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Get resource from redfish service. + // + Status =3D RedfishGetByUri ( + Service, + AsciiResourceUri, + Response + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, RedfishGetByUri to %a failed: %r\n", __FUNCT= ION__, AsciiResourceUri, Status)); + if (Response->Payload !=3D NULL) { + RedfishDumpPayload (Response->Payload); + RedfishFreeResponse ( + NULL, + 0, + NULL, + Response->Payload + ); + Response->Payload =3D NULL; + } + } + + if (AsciiResourceUri !=3D NULL) { + FreePool (AsciiResourceUri); + } + + return Status; +} + +/** + + Check if this is the Redpath array. Usually the Redpath array represents + the collection member. Return + + @param[in] ConfigureLang The Redpath to check + @param[out] ArraySignatureOpen String to the open of array signat= ure. + @param[out] ArraySignatureClose String to the close of array signa= ture. + + @retval EFI_SUCCESS Index is found. + @retval EFI_NOT_FOUND The non-array configure language stri= ng is retured. + @retval EFI_INVALID_PARAMETER The format of input ConfigureLang is = wrong. + @retval Others Errors occur. + +**/ +EFI_STATUS +IsRedpathArray ( + IN EFI_STRING ConfigureLang, + OUT EFI_STRING *ArraySignatureOpen OPTIONAL, + OUT EFI_STRING *ArraySignatureClose OPTIONAL + ) +{ + CHAR16 *IndexString; + + if (ConfigureLang =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + if (ArraySignatureOpen !=3D NULL) { + *ArraySignatureOpen =3D NULL; + } + if (ArraySignatureClose !=3D NULL) { + *ArraySignatureClose =3D NULL; + } + + // + // looking for index signature "{"" + // + IndexString =3D StrStr (ConfigureLang, BIOS_CONFIG_TO_REDFISH_REDPATH_AR= RAY_START_SIGNATURE); + if (IndexString !=3D NULL) { + if (ArraySignatureOpen !=3D NULL) { + *ArraySignatureOpen =3D IndexString; + } + // + // Skip "{" + // + IndexString =3D IndexString + StrLen (BIOS_CONFIG_TO_REDFISH_REDPATH_A= RRAY_START_SIGNATURE); + // + // Looking for "}" + // + IndexString =3D StrStr (IndexString, BIOS_CONFIG_TO_REDFISH_REDPATH_AR= RAY_END_SIGNATURE); + if (IndexString =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + if (ArraySignatureClose !=3D NULL) { + *ArraySignatureClose =3D IndexString; + } + return EFI_SUCCESS; + } + return EFI_NOT_FOUND; +} + +/** + + Get number of node from the string. Node is seperated by '/'. + + @param[in] NodeString The node string to parse. + + @retval UINTN Number of nodes in the string. + +**/ +UINTN +GetNumberOfRedpathNodes ( + IN EFI_STRING NodeString + ) +{ + UINTN Index; + UINTN NumberNodes; + UINTN StringLen; + + NumberNodes =3D 0; + StringLen =3D StrLen (NodeString); + Index =3D 1; // ConfigLang always starts with '/'. + while (Index < StringLen) { + if (*(NodeString + Index) =3D=3D L'/') { + NumberNodes ++; + } + Index ++; + }; + NumberNodes ++; + + return (NumberNodes); +} + +/** + + Get the node string by index + + @param[in] NodeString The node string to parse. + @param[in] Index Zero-based index of the node. + @param[out] EndOfNodePtr Pointer to receive the poitner to + the last character of node string. + + @retval EFI_STRING the begining of the node string. + +**/ +EFI_STRING +GetRedpathNodeByIndex ( + IN EFI_STRING NodeString, + IN UINTN Index, + OUT EFI_STRING *EndOfNodePtr OPTIONAL + ) +{ + UINTN NumberNodes; + UINTN StringLen; + UINTN StringIndex; + EFI_STRING NodeStart; + EFI_STRING NodeEnd; + + NumberNodes =3D 0; + StringLen =3D StrLen (NodeString); + StringIndex =3D 1; // ConfigLang always starts with '/'. + NodeStart =3D NodeString; + if (EndOfNodePtr !=3D NULL) { + *EndOfNodePtr =3D NULL; + } + while (StringIndex < StringLen) { + if (*(NodeString + StringIndex) =3D=3D L'/') { + NodeEnd =3D NodeString + StringIndex - 1; + if (NumberNodes =3D=3D Index) { + if (EndOfNodePtr !=3D NULL) { + *EndOfNodePtr =3D NodeEnd; + } + return NodeStart; + } else { + NodeStart =3D NodeString + StringIndex + 1; } + } + StringIndex ++; + }; + return (NULL); +} + +/** + + Find array index from given configure language string. + + @param[in] ConfigureLang Configure language string to parse. + @param[out] UnifiedConfigureLang The configure language in array. + @param[out] Index The array index number. + + @retval EFI_SUCCESS Index is found. + @retval EFI_NOT_FOUND The non-array configure language stri= ng is retured. + @retval EFI_INVALID_PARAMETER The format of input ConfigureLang is = wrong. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetArrayIndexFromArrayTypeConfigureLang ( + IN CHAR16 *ConfigureLang, + OUT CHAR16 **UnifiedConfigureLang, + OUT UINTN *Index + ) +{ + EFI_STATUS Status; + CHAR16 *TmpConfigureLang; + CHAR16 *ArrayOpenStr; + CHAR16 *ArrayCloseStr; + INTN StringIndex; + + if (ConfigureLang =3D=3D NULL || UnifiedConfigureLang =3D=3D NULL || Ind= ex =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + TmpConfigureLang =3D AllocateCopyPool (StrSize (ConfigureLang), Configur= eLang); + if (TmpConfigureLang =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status =3D IsRedpathArray (TmpConfigureLang, &ArrayOpenStr, &ArrayCloseS= tr); + if (!EFI_ERROR (Status)) { + // + // Append '\0' for converting decimal string to integer. + // + ArrayCloseStr[0] =3D '\0'; + + // + // Convert decimal string to integer + // + *Index =3D StrDecimalToUintn (ArrayOpenStr + StrLen (BIOS_CONFIG_TO_RE= DFISH_REDPATH_ARRAY_START_SIGNATURE)); + + // + // Resotre the '}' character and remove rest of string. + // + ArrayCloseStr[0] =3D L'}'; + ArrayCloseStr[1] =3D '\0'; + *UnifiedConfigureLang =3D TmpConfigureLang; + } else { + if (Status =3D=3D EFI_NOT_FOUND) { + // + // This is not the redpath array. Search "/" for the parent root. + // + *Index =3D 0; + StringIndex =3D StrLen (TmpConfigureLang) - 1; + while (StringIndex >=3D 0 && *(TmpConfigureLang + StringIndex) !=3D = '/') { + StringIndex --; + }; + if (StringIndex >=3D 0 ) { + *(TmpConfigureLang + StringIndex) =3D '\0'; + *UnifiedConfigureLang =3D TmpConfigureLang; + Status =3D EFI_SUCCESS; + } else { + Status =3D EFI_INVALID_PARAMETER; + } + } + } + return Status; +} + +/** + + Clone the configure language list. + + @param[in] ConfigureLangList The source REDFISH_FEATURE_ARRAY_TYPE= _CONFIG_LANG_LIST. + @param[out] DestConfigureLangList The destination REDFISH_FEATURE_ARRAY= _TYPE_CONFIG_LANG_LIST. + + @retval EFI_SUCCESS REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST = is copied. + @retval Others Errors occur. + +**/ +EFI_STATUS +CopyConfiglanguageList ( + IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *SourceConfigureLangLis= t, + OUT REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *DestConfigureLangList + ) +{ + UINTN Index; + + if (SourceConfigureLangList =3D=3D NULL || DestConfigureLangList =3D=3D = NULL) { + return EFI_INVALID_PARAMETER; + } + DestConfigureLangList->Count =3D SourceConfigureLangList->Count; + DestConfigureLangList->List =3D + (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG *)AllocateZeroPool (sizeof (= REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG) * DestConfigureLangList->Count); + if (DestConfigureLangList->List =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEATURE_= ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + for (Index =3D 0; Index < SourceConfigureLangList->Count; Index++) { + DestConfigureLangList->List [Index].Index =3D SourceConfigureLangList-= >List[Index].Index; + DestConfigureLangList->List [Index].ConfigureLang =3D + (EFI_STRING)AllocateCopyPool(StrSize(SourceConfigureLangList->List[I= ndex].ConfigureLang), (VOID *)SourceConfigureLangList->List[Index].Configur= eLang); + } + return EFI_SUCCESS; +} + +/** + + Clone the configure language list. + + @param[in] ConfigureLang The pointer to configuration language. + + @retval UINTN The index of collection member instance. + Value of 0 means no instance is found. +**/ +UINTN +ConfiglanguageGetInstanceIndex ( + IN EFI_STRING ConfigureLang + ) +{ + INTN LeftBracketIndex; + INTN RightBracketIndex; + INTN Index; + UINT64 Instance; + EFI_STATUS Status; + + if (ConfigureLang =3D=3D NULL) { + return 0; + } + LeftBracketIndex =3D 0; + RightBracketIndex =3D 0; + Index =3D StrLen (ConfigureLang) - 1; + while (Index >=3D 0) { + if (*(ConfigureLang + Index) =3D=3D L'{') { + LeftBracketIndex =3D Index; + break; + } + if (*(ConfigureLang + Index) =3D=3D L'}') { + RightBracketIndex =3D Index; + } + Index --; + }; + if ((RightBracketIndex - LeftBracketIndex) <=3D 1) { + return 0; + } + *(ConfigureLang + RightBracketIndex) =3D 0; + Status =3D StrDecimalToUint64S (ConfigureLang + LeftBracketIndex + 1, NU= LL, &Instance); + if (EFI_ERROR(Status)) { + Instance =3D 0; + } + // + // Restore right curly bracket. + // + *(ConfigureLang + RightBracketIndex) =3D L'}'; + return (UINTN)Instance; +} + +/** + + Destroy the configure language list. + + @param[in] ConfigureLangList The REDFISH_FEATURE_ARRAY_TYPE_CONFIG= _LANG_LIST + instance to destroy. + + @retval EFI_SUCCESS REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST = is copied. + @retval Others Errors occur. + +**/ +EFI_STATUS +DestroyConfiglanguageList ( + IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigureLangList + ) +{ + UINTN Index; + + if (ConfigureLangList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + if (ConfigureLangList->List !=3D NULL) { + for (Index =3D 0; Index < ConfigureLangList->Count; Index++) { + if (ConfigureLangList->List [Index].ConfigureLang !=3D NULL) { + FreePool (ConfigureLangList->List [Index].ConfigureLang); + } + } + FreePool (ConfigureLangList->List); + ConfigureLangList->List =3D NULL; + } + + return EFI_SUCCESS; +} + +/** + + Set the node instance. + + @param[in] DestConfigLang Pointer to the node's configure langua= ge string. + The memory pointed by ConfigLang must = be allocated + through memory allocation interface. B= ecasue we will replace + the pointer in this function. + @param[in] MaxtLengthConfigLang The maximum length of ConfigLang. + @param[in] ConfigLangInstance Pointer to Collection member instance. + + @retval EFI_SUCCESS The instance is inserted to the configure la= nguage. + @retval Others Errors occur. + +**/ +EFI_STATUS +SetResourceConfigLangMemberInstance ( + IN EFI_STRING *DestConfigLang, + IN UINTN MaxtLengthConfigLang, + IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG *ConfigLangInstance + ) +{ + EFI_STRING ThisConfigLang; + EFI_STRING NewConfigLang; + CHAR16 InstanceStr [10]; + INTN Index; + UINTN Length; + UINTN MaxStrLength; + + if (DestConfigLang =3D=3D NULL || ConfigLangInstance =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + UnicodeSPrint ((CHAR16 *)&InstanceStr, 10, L"%d", ConfigLangInstance->In= dex); + + ThisConfigLang =3D *DestConfigLang; + if (ThisConfigLang [0] =3D=3D 0) { + // + // Return ConfigLangInstance->ConfigureLang + // + if (ConfigLangInstance->ConfigureLang =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } else { + StrCatS(*DestConfigLang, MaxtLengthConfigLang, ConfigLangInstance->C= onfigureLang); + return EFI_SUCCESS; + } + } + + MaxStrLength =3D StrSize (ThisConfigLang) + StrSize ((EFI_STRING)&Instan= ceStr); + NewConfigLang =3D ThisConfigLang; + if (MaxtLengthConfigLang < MaxStrLength) { + NewConfigLang =3D (EFI_STRING)AllocateZeroPool(MaxStrLength); + if (NewConfigLang =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for NewConfigLang.= \n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + } + // + // Search the last "{" + // + Index =3D StrLen (ThisConfigLang) - 1; + while ((ThisConfigLang[Index] !=3D '{') && (Index >=3D 0)) { + Index --; + }; + if (Index =3D=3D -1) { + if (NewConfigLang !=3D ThisConfigLang) { + FreePool(NewConfigLang); + } + return EFI_NOT_FOUND; + } + + // + // Copy the string to a new string. + // + Length =3D 0; + while (Index >=3D 0) { + NewConfigLang [Index] =3D ThisConfigLang[Index]; + Index --; + Length ++; + }; + UnicodeSPrint ((CHAR16 *)(NewConfigLang + Length), MaxStrLength, L"%d", = ConfigLangInstance->Index); + StrCatS (NewConfigLang, MaxStrLength, L"}"); + if (NewConfigLang !=3D ThisConfigLang) { + FreePool (ThisConfigLang); + } + *DestConfigLang =3D NewConfigLang; + return EFI_SUCCESS; +} + +/** + + Search HII database with given Configure Language pattern. Data is handl= ed and + returned in array. + + @param[in] Schema The schema to search. + @param[in] Version The schema version. + @param[in] Pattern Configure Language pattern to sear= ch. + @param[out] UnifiedConfigureLangList The data returned by HII database. + + @retval EFI_SUCCESS Data is found and returned. + @retval Others Errors occur. + +**/ +EFI_STATUS +RedfishFeatureGetUnifiedArrayTypeConfigureLang ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING Pattern, OPTIONAL + OUT REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *UnifiedConfigureLan= gList + ) +{ + EFI_STATUS Status; + EFI_STRING *ConfigureLangList; + UINTN Count; + UINTN Index; + UINTN Index2; + UINTN ArrayIndex; + EFI_STRING UnifiedConfigureLang; + BOOLEAN Duplicated; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG UnifiedConfigureLangPool[BIOS_CON= FIG_TO_REDFISH_REDPATH_POOL_SIZE]; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || UnifiedConf= igureLangList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + UnifiedConfigureLangList->Count =3D 0; + UnifiedConfigureLangList->List =3D NULL; + ZeroMem (UnifiedConfigureLangPool, sizeof (UnifiedConfigureLangPool)); + + Status =3D RedfishPlatformConfigGetConfigureLang (Schema, Version, Patte= rn, &ConfigureLangList, &Count); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, RedfishFeatureGetConfigureLangRegex failed: = %r\n", __FUNCTION__, Status)); + return Status; + } + + if (Count =3D=3D 0) { + return EFI_NOT_FOUND; + } + + for (Index =3D 0; Index < Count; Index++) { + Status =3D GetArrayIndexFromArrayTypeConfigureLang (ConfigureLangList[= Index], &UnifiedConfigureLang, &ArrayIndex); + if (EFI_ERROR (Status) && Status =3D=3D EFI_INVALID_PARAMETER) { + ASSERT (FALSE); + continue; + } + + // + // Check if this configure language is duplicated. + // + Duplicated =3D FALSE; + for (Index2 =3D 0; Index2 < BIOS_CONFIG_TO_REDFISH_REDPATH_POOL_SIZE; = Index2++) { + if (UnifiedConfigureLangPool[Index2].ConfigureLang =3D=3D NULL) { + break; + } + + if (StrCmp (UnifiedConfigureLangPool[Index2].ConfigureLang, UnifiedC= onfigureLang) =3D=3D 0) { + Duplicated =3D TRUE; + break; + } + } + + if (Duplicated) { + FreePool (UnifiedConfigureLang); + continue; + } + + if (UnifiedConfigureLangList->Count >=3D BIOS_CONFIG_TO_REDFISH_REDPAT= H_POOL_SIZE) { + FreePool (UnifiedConfigureLang); + Status =3D EFI_BUFFER_TOO_SMALL; + break; + } + + // + // New configure language. Keep it in Pool + // + + UnifiedConfigureLangPool[UnifiedConfigureLangList->Count].ConfigureLan= g =3D UnifiedConfigureLang; + UnifiedConfigureLangPool[UnifiedConfigureLangList->Count].Index =3D Ar= rayIndex; + ++UnifiedConfigureLangList->Count; + } + + FreePool (ConfigureLangList); + + // + // Prepare the result to caller. + // + UnifiedConfigureLangList->List =3D AllocateCopyPool (sizeof (REDFISH_FEA= TURE_ARRAY_TYPE_CONFIG_LANG) * UnifiedConfigureLangList->Count, UnifiedConf= igureLangPool); + + return Status; +} + +/** + + Find "ETag" and "Location" from either HTTP header or Redfish response. + + @param[in] Response HTTP response + @param[out] Etag String buffer to return ETag + @param[out] Location String buffer to return Location + + @retval EFI_SUCCESS Data is found and returned. + @retval Others Errors occur. + +**/ +EFI_STATUS +GetEtagAndLocation ( + IN REDFISH_RESPONSE *Response, + OUT CHAR8 **Etag, OPTIONAL + OUT EFI_STRING *Location OPTIONAL + ) +{ + EDKII_JSON_VALUE JsonValue; + EDKII_JSON_VALUE OdataValue; + CHAR8 *OdataString; + CHAR8 *AsciiLocation; + EFI_HTTP_HEADER *Header; + EFI_STATUS Status; + + if (Response =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Etag =3D=3D NULL && Location =3D=3D NULL) { + return EFI_SUCCESS; + } + + Status =3D EFI_SUCCESS; + + if (Etag !=3D NULL) { + *Etag =3D NULL; + + if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { + Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers,= HTTP_HEADER_ETAG); + if (Header !=3D NULL) { + *Etag =3D AllocateCopyPool (AsciiStrSize (Header->FieldValue), Hea= der->FieldValue); + ASSERT (*Etag !=3D NULL); + } + } + + // + // No header is returned. Search payload for location. + // + if (*Etag =3D=3D NULL && Response->Payload !=3D NULL) { + JsonValue =3D RedfishJsonInPayload (Response->Payload); + if (JsonValue !=3D NULL) { + OdataValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue),= "@odata.etag"); + if (OdataValue !=3D NULL) { + OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataValue); + if (OdataString !=3D NULL) { + *Etag =3D AllocateCopyPool (AsciiStrSize (OdataString), OdataS= tring); + ASSERT (*Etag !=3D NULL); + } + } + + JsonValueFree (JsonValue); + } + } + + if (*Etag =3D=3D NULL) { + Status =3D EFI_NOT_FOUND; + } + } + + if (Location !=3D NULL) { + *Location =3D NULL; + + if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { + Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers,= HTTP_HEADER_LOCATION); + if (Header !=3D NULL) { + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (Header->FieldVal= ue), Header->FieldValue); + ASSERT (AsciiLocation !=3D NULL); + } + } + + // + // No header is returned. Search payload for location. + // + if (*Location =3D=3D NULL && Response->Payload !=3D NULL) { + JsonValue =3D RedfishJsonInPayload (Response->Payload); + if (JsonValue !=3D NULL) { + OdataValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue),= "@odata.id"); + if (OdataValue !=3D NULL) { + OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataValue); + if (OdataString !=3D NULL) { + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (OdataString)= , OdataString); + ASSERT (AsciiLocation !=3D NULL); + } + } + + JsonValueFree (JsonValue); + } + } + + if (AsciiLocation !=3D NULL) { + *Location =3D StrAsciiToUnicode (AsciiLocation); + FreePool (AsciiLocation); + } else { + Status =3D EFI_NOT_FOUND; + } + } + + return Status; +} +/** + + Create HTTP payload and send them to redfish service with PATCH method. + + @param[in] Service Redfish service. + @param[in] TargetPayload Target payload + @param[in] Json Data in JSON format. + @param[out] Etag Returned ETAG string from Redfish service. + + @retval EFI_SUCCESS Data is sent to redfish service successfully. + @retval Others Errors occur. + +**/ +EFI_STATUS +CreatePayloadToPatchResource ( + IN REDFISH_SERVICE *Service, + IN REDFISH_PAYLOAD *TargetPayload, + IN CHAR8 *Json, + OUT CHAR8 **Etag + ) +{ + REDFISH_PAYLOAD Payload; + EDKII_JSON_VALUE ResourceJsonValue; + REDFISH_RESPONSE PostResponse; + EFI_STATUS Status; + + if (Service =3D=3D NULL || TargetPayload =3D=3D NULL || IS_EMPTY_STRING = (Json) || Etag =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + ResourceJsonValue =3D JsonLoadString (Json, 0, NULL); + Payload =3D RedfishCreatePayload (ResourceJsonValue, Service); + if (Payload =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from JSON va= lue!\n",__FUNCTION__, __LINE__)); + Status =3D EFI_DEVICE_ERROR; + goto EXIT_FREE_JSON_VALUE; + } + + ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); + Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PostResponse); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a:%d Failed to PATCH payload to Redfish service= .\n",__FUNCTION__, __LINE__)); + goto EXIT_FREE_JSON_VALUE; + } + + // + // Find ETag + // + Status =3D GetEtagAndLocation (&PostResponse, Etag, NULL); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + } + + RedfishFreeResponse ( + PostResponse.StatusCode, + PostResponse.HeaderCount, + PostResponse.Headers, + PostResponse.Payload + ); + +EXIT_FREE_JSON_VALUE: + if (Payload !=3D NULL) { + RedfishCleanupPayload (Payload); + } + + JsonValueFree (ResourceJsonValue); + + return Status; +} + +/** + + Create HTTP payload and send them to redfish service with POST method. + + @param[in] Service Redfish service. + @param[in] TargetPayload Target payload + @param[in] Json Data in JSON format. + @param[out] Location Returned location string from Redfish servic= e. + @param[out] Etag Returned ETAG string from Redfish service. + + @retval EFI_SUCCESS Data is sent to redfish service successfully. + @retval Others Errors occur. + +**/ +EFI_STATUS +CreatePayloadToPostResource ( + IN REDFISH_SERVICE *Service, + IN REDFISH_PAYLOAD *TargetPayload, + IN CHAR8 *Json, + OUT EFI_STRING *Location, + OUT CHAR8 **Etag + ) +{ + REDFISH_PAYLOAD Payload; + EDKII_JSON_VALUE ResourceJsonValue; + REDFISH_RESPONSE PostResponse; + EFI_STATUS Status; + + if (Service =3D=3D NULL || TargetPayload =3D=3D NULL || IS_EMPTY_STRING = (Json) || Location =3D=3D NULL || Etag =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + ResourceJsonValue =3D JsonLoadString (Json, 0, NULL); + Payload =3D RedfishCreatePayload (ResourceJsonValue, Service); + if (Payload =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from JSON va= lue!\n",__FUNCTION__, __LINE__)); + Status =3D EFI_DEVICE_ERROR; + goto EXIT_FREE_JSON_VALUE; + } + + ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); + Status =3D RedfishPostToPayload (TargetPayload, Payload, &PostResponse); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a:%d Failed to POST Attribute Registry to Redfi= sh service.\n",__FUNCTION__, __LINE__)); + goto EXIT_FREE_JSON_VALUE; + } + + // + // per Redfish spec. the URL of new eresource will be returned in "Locat= ion" header. + // + Status =3D GetEtagAndLocation (&PostResponse, Etag, Location); + if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + } + + RedfishFreeResponse ( + PostResponse.StatusCode, + PostResponse.HeaderCount, + PostResponse.Headers, + PostResponse.Payload + ); + + RedfishCleanupPayload (Payload); + +EXIT_FREE_JSON_VALUE: + JsonValueFree (ResourceJsonValue); + + return Status; +} + +/** + + Return redfish URI by given config language. It's call responsibility to= release returned buffer. + + @param[in] ConfigLang ConfigLang to search. + + @retval NULL Can not find redfish uri. + @retval Other redfish uri is returned. + +**/ +EFI_STRING +RedfishGetUri ( + IN EFI_STRING ConfigLang + ) +{ + EFI_STATUS Status; + EFI_STRING Target; + EFI_STRING Found; + EFI_STRING TempStr; + EFI_STRING ResultStr; + EFI_STRING Head; + EFI_STRING CloseBracket; + UINTN TempStrSize; + UINTN RemainingLen; + UINTN ConfigLangLen; + + Status =3D RedfishLocateProtocol ((VOID **)&mConfigLangMapProtocol, &gEd= kIIRedfishConfigLangMapProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to locate gEdkIIRedfishConfigLangMapPro= tocolGuid: %r\n", __FUNCTION__, Status)); + return NULL; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, Get: %s\n", __FUNCTION__, ConfigLang)); + + CloseBracket =3D StrStr (ConfigLang, L"{"); + if (CloseBracket =3D=3D NULL) { + return AllocateCopyPool (StrSize (ConfigLang), ConfigLang); + } + + // + // Remove leading "/v1" or "/redfish/v1" because we don't code + // configure language in this way. + // + Head =3D StrStr (ConfigLang, REDFISH_ROOT_PATH_UNICODE); + if (Head =3D=3D NULL) { + Head =3D ConfigLang; + } else { + Head +=3D 3; + } + + ResultStr =3D AllocateZeroPool (sizeof (CHAR16) * MAX_REDFISH_URL_LEN); + if (ResultStr =3D=3D NULL) { + return NULL; + } + + // + // Go though ConfigLang and replace each {} with URL + // + do { + ConfigLangLen =3D StrLen (Head); + Target =3D CloseBracket; + + // + // Look for next ConfigLang + // + do { + Target +=3D 1; + } while (*Target !=3D '\0' && *Target !=3D '}'); + + // + // Invalid format. No '}' found + // + if (*Target =3D=3D '\0') { + DEBUG ((DEBUG_ERROR, "%a, invalid format: %s\n", __FUNCTION__, Confi= gLang)); + return NULL; + } + + // + // Copy current ConfigLang to temporary string and do a query + // + Target +=3D 1; + RemainingLen =3D StrLen (Target); + TempStrSize =3D (ConfigLangLen - RemainingLen + 1) * sizeof (CHAR16); + TempStr =3D AllocateCopyPool (TempStrSize, Head); + if (TempStr =3D=3D NULL) { + return NULL; + } + TempStr[ConfigLangLen - RemainingLen] =3D '\0'; + + Status =3D mConfigLangMapProtocol->Get ( + mConfigLangMapProtocol, + RedfishGetTypeConfigLang, + TempStr, + &Found + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, Can not find: %s\n", __FUNCTION__, TempStr= )); + return NULL; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, Found: %s\n", __FUNCTION__, Found)); + + // + // Keep result in final string pool + // + StrCatS (ResultStr, MAX_REDFISH_URL_LEN, Found); + FreePool (TempStr); + + // + // Prepare for next ConfigLang + // + Head =3D Target; + CloseBracket =3D StrStr (Head, L"{"); + } while (CloseBracket !=3D NULL); + + // + // String which has no ConfigLang remaining + // + if (Head !=3D '\0') { + StrCatS (ResultStr, MAX_REDFISH_URL_LEN, Head); + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, return: %s\n", __FUNCTION__, ResultStr= )); + + return ResultStr; +} + +/** + + Return config language by given URI. It's call responsibility to release= returned buffer. + + @param[in] Uri Uri to search. + + @retval NULL Can not find redfish uri. + @retval Other redfish uri is returned. + +**/ +EFI_STRING +RedfishGetConfigLanguage ( + IN EFI_STRING Uri + ) +{ + EFI_STATUS Status; + EFI_STRING ConfigLang; + + if (IS_EMPTY_STRING (Uri)) { + return NULL; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, search config lang for URI: %s\n", __F= UNCTION__, Uri)); + + Status =3D RedfishLocateProtocol ((VOID **)&mConfigLangMapProtocol, &gEd= kIIRedfishConfigLangMapProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to locate gEdkIIRedfishConfigLangMapPro= tocolGuid: %r\n", __FUNCTION__, Status)); + return NULL; + } + + ConfigLang =3D NULL; + Status =3D mConfigLangMapProtocol->Get ( + mConfigLangMapProtocol, + RedfishGetTypeUri, + Uri, + &ConfigLang + ); + + + return ConfigLang; +} + +/** + + Return config language from given URI and prperty name. It's call respon= sibility to release returned buffer. + + @param[in] Uri The URI to match + @param[in] PropertyName The property name of resource. This is optiona= l. + + @retval NULL Can not find redfish uri. + @retval Other redfish uri is returned. + +**/ +EFI_STRING +GetConfigureLang ( + IN CHAR8 *Uri, + IN CHAR8 *PropertyName OPTIONAL + ) +{ + EFI_STRING ConfigLang; + UINTN StringSize; + EFI_STRING ResultStr; + EFI_STRING UnicodeUri; + EFI_STATUS Status; + + if (IS_EMPTY_STRING (Uri)) { + return NULL; + } + + StringSize =3D AsciiStrSize (Uri); + UnicodeUri =3D AllocatePool (StringSize * sizeof (CHAR16)); + if (UnicodeUri =3D=3D NULL) { + return NULL; + } + + Status =3D AsciiStrToUnicodeStrS (Uri, UnicodeUri, StringSize); + if (EFI_ERROR (Status)) { + return NULL; + } + + ConfigLang =3D RedfishGetConfigLanguage (UnicodeUri); + if (ConfigLang =3D=3D NULL) { + return NULL; + } + + if (IS_EMPTY_STRING (PropertyName)) { + return ConfigLang; + } + + StringSize =3D StrSize (ConfigLang) + ((AsciiStrLen (PropertyName) + 1) = * sizeof (CHAR16)); + ResultStr =3D AllocatePool (StringSize); + if (ResultStr =3D=3D NULL) { + return NULL; + } + + UnicodeSPrint (ResultStr, StringSize, L"%s/%a", ConfigLang, PropertyName= ); + + return ResultStr; +} + +/** + + Save Redfish URI in database for further use. + + @param[in] ConfigLang ConfigLang to save + @param[in] Uri Redfish Uri to save + + @retval EFI_INVALID_PARAMETR SystemId is NULL or EMPTY + @retval EFI_SUCCESS Redfish uri is saved + +**/ +EFI_STATUS +RedfisSetRedfishUri ( + IN EFI_STRING ConfigLang, + IN EFI_STRING Uri + ) +{ + EFI_STATUS Status; + + if (IS_EMPTY_STRING (ConfigLang) || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D RedfishLocateProtocol ((VOID **)&mConfigLangMapProtocol, &gEd= kIIRedfishConfigLangMapProtocolGuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to locate gEdkIIRedfishConfigLangMapPro= tocolGuid: %r\n", __FUNCTION__, Status)); + return Status; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, Saved: %s -> %s\n", __FUNCTION__, Conf= igLang, Uri)); + + return mConfigLangMapProtocol->Set (mConfigLangMapProtocol, ConfigLang, = Uri); +} + +/** + + Get @odata.id from give HTTP payload. It's call responsibility to releas= e returned buffer. + + @param[in] Payload HTTP payload + + @retval NULL Can not find @odata.id from given payloa= d. + @retval Others odata.id string is returned. + +**/ +EFI_STRING +GetOdataId ( + IN REDFISH_PAYLOAD *Payload + ) +{ + EDKII_JSON_VALUE *JsonValue; + EDKII_JSON_VALUE *OdataId; + EFI_STRING OdataIdString; + + if (Payload =3D=3D NULL) { + return NULL; + } + + JsonValue =3D RedfishJsonInPayload (Payload); + if (!JsonValueIsObject (JsonValue)) { + return NULL; + } + + OdataId =3D JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.= id"); + if (!JsonValueIsString (OdataId)) { + return NULL; + } + + OdataIdString =3D JsonValueGetUnicodeString (OdataId); + if (OdataIdString =3D=3D NULL) { + return NULL; + } + + return AllocateCopyPool (StrSize (OdataIdString), OdataIdString); +} + + +/** + + Get the property name by given Configure Langauge. + + @param[in] ResourceUri URI of root of resource. + @param[in] ConfigureLang Configure Language string. + + @retval EFI_STRING Pointer to property name. + @retval NULL There is error. + +**/ +EFI_STRING +GetPropertyFromConfigureLang ( + IN EFI_STRING ResourceUri, + IN EFI_STRING ConfigureLang + ) +{ + EFI_STATUS Status; + EFI_STRING TempString; + + if (ConfigureLang =3D=3D NULL || ResourceUri =3D=3D NULL) { + return NULL; + } + + Status =3D IsRedpathArray (ConfigureLang, NULL, &TempString); + if (!EFI_ERROR(Status)) { + TempString +=3D 2; // Advance two characters for '}' and '/' + return TempString; + } + if (Status !=3D EFI_NOT_FOUND) { + return NULL; + } + // + // The ConigLang has no '{}' + // + if (GetNumberOfRedpathNodes (ConfigureLang) =3D=3D 1) { + return NULL; + } + + if (GetRedpathNodeByIndex (ConfigureLang, 0, &TempString) =3D=3D NULL) { + return NULL; + } + // + // Advance two characters to the starting + // pointer of next node. + // + return TempString + 2; +} + +/** + + Get the property value in string type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + + @retval CHAR8* Pointer to the CHAR8 buffer. + @retval NULL There is error. + +**/ +CHAR8 * +GetPropertyStringValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + EFI_STRING ConfigureLangBuffer; + UINTN BufferSize; + CHAR8 *AsciiStringValue; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { + return NULL; + } + + // + // Configure Language buffer. + // + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; + ConfigureLangBuffer =3D AllocatePool (BufferSize); + if (ConfigureLangBuffer =3D=3D NULL) { + return NULL; + } + + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); + return NULL; + } + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_STRING) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string type\n", __FUNC= TION__, Schema, Version, ConfigureLang)); + return NULL; + } + + AsciiStringValue =3D AllocateCopyPool (AsciiStrSize (RedfishValue.Value.= Buffer), RedfishValue.Value.Buffer); + ASSERT (AsciiStringValue !=3D NULL); + + return AsciiStringValue; +} + +/** + + Get the property value in numeric type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + + @retval INT64* Pointer to the INT64 value. + @retval NULL There is error. + +**/ +INT64 * +GetPropertyNumericValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + EFI_STRING ConfigureLangBuffer; + UINTN BufferSize; + INT64 *ResultValue; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { + return NULL; + } + + // + // Configure Language buffer. + // + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; + ConfigureLangBuffer =3D AllocatePool (BufferSize); + if (ConfigureLangBuffer =3D=3D NULL) { + return NULL; + } + + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); + return NULL; + } + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_INTEGER) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not numeric type\n", __FUN= CTION__, Schema, Version, ConfigureLang)); + return NULL; + } + + ResultValue =3D AllocatePool (sizeof (INT64)); + ASSERT (ResultValue !=3D NULL); + if (ResultValue =3D=3D NULL) { + return NULL; + } + + *ResultValue =3D RedfishValue.Value.Integer; + + return ResultValue; +} + +/** + + Get the property value in Boolean type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + + @retval BOOLEAN Boolean value returned by this property. + +**/ +BOOLEAN * +GetPropertyBooleanValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + EFI_STRING ConfigureLangBuffer; + UINTN BufferSize; + BOOLEAN *ResultValue; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { + return NULL; + } + + // + // Configure Language buffer. + // + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; + ConfigureLangBuffer =3D AllocatePool (BufferSize); + if (ConfigureLangBuffer =3D=3D NULL) { + return NULL; + } + + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); + return NULL; + } + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_BOOLEAN) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not boolean type\n", __FUN= CTION__, Schema, Version, ConfigureLang)); + return NULL; + } + + ResultValue =3D AllocatePool (sizeof (BOOLEAN)); + ASSERT (ResultValue !=3D NULL); + if (ResultValue =3D=3D NULL) { + return NULL; + } + + *ResultValue =3D RedfishValue.Value.Boolean; + + return ResultValue; +} + +/** + + Return the last string of configure language. Any modification to return= ed + string will change ConfigureLanguage. + + @param[in] ConfigureLanguage Configure language string + + @retval EFI_STRING Attribute name is returned + @retval NULL Error occurs + +**/ +EFI_STRING +GetAttributeNameFromConfigLanguage ( + IN EFI_STRING ConfigureLanguage + ) +{ + UINTN StringLen; + UINTN Index; + + if (IS_EMPTY_STRING (ConfigureLanguage)) { + return NULL; + } + + StringLen =3D StrLen (ConfigureLanguage); + for (Index =3D StringLen - 1; Index >=3D 0; Index--) { + if (ConfigureLanguage[Index] =3D=3D '/') { + return &ConfigureLanguage[Index + 1]; + } + } + + return NULL; +} + +/** + + Get the property string value in array type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] ArraySize The size of returned array. + + @retval CHAR8 ** Returned string array. NULL while error happen= s. + +**/ +CHAR8 ** +GetPropertyStringArrayValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINTN *ArraySize + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + EFI_STRING ConfigureLangBuffer; + UINTN BufferSize; + CHAR8 **StringArray; + UINTN Index; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName) || ArraySize =3D=3D = NULL) { + return NULL; + } + + *ArraySize =3D 0; + + // + // Configure Language buffer. + // + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; + ConfigureLangBuffer =3D AllocatePool (BufferSize); + if (ConfigureLangBuffer =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__)); + return NULL; + } + + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); + return NULL; + } + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_STRING_ARRAY) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n", = __FUNCTION__, Schema, Version, ConfigureLang)); + return NULL; + } + + StringArray =3D AllocatePool (sizeof (CHAR8 *) * RedfishValue.ArrayCount= ); + if (StringArray =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__)); + return NULL; + } + + *ArraySize =3D RedfishValue.ArrayCount; + for (Index =3D 0; Index < RedfishValue.ArrayCount; Index++) { + StringArray[Index] =3D RedfishValue.Value.StringArray[Index]; + } + + return StringArray; +} + +/** + + Get the property numeric value in array type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] ArraySize The size of returned array. + + @retval INT64 * Returned integer array. NULL while error happen= s. + +**/ +INT64 * +GetPropertyNumericArrayValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINTN *ArraySize + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + EFI_STRING ConfigureLangBuffer; + UINTN BufferSize; + INT64 *IntegerArray; + UINTN Index; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName) || ArraySize =3D=3D = NULL) { + return NULL; + } + + *ArraySize =3D 0; + + // + // Configure Language buffer. + // + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; + ConfigureLangBuffer =3D AllocatePool (BufferSize); + if (ConfigureLangBuffer =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__)); + return NULL; + } + + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); + return NULL; + } + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_INTEGER_ARRAY) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n", = __FUNCTION__, Schema, Version, ConfigureLang)); + return NULL; + } + + IntegerArray =3D AllocatePool (sizeof (INT64) * RedfishValue.ArrayCount); + if (IntegerArray =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__)); + return NULL; + } + + *ArraySize =3D RedfishValue.ArrayCount; + for (Index =3D 0; Index < RedfishValue.ArrayCount; Index++) { + IntegerArray[Index] =3D RedfishValue.Value.IntegerArray[Index]; + } + + return IntegerArray; +} + +/** + + Get the property boolean value in array type. + + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] ArraySize The size of returned array. + + @retval BOOLEAN * Returned boolean array. NULL while error happ= ens. + +**/ +BOOLEAN * +GetPropertyBooleanArrayValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINTN *ArraySize + ) +{ + EFI_STATUS Status; + EDKII_REDFISH_VALUE RedfishValue; + EFI_STRING ConfigureLangBuffer; + UINTN BufferSize; + BOOLEAN *BooleanArray; + UINTN Index; + + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName) || ArraySize =3D=3D = NULL) { + return NULL; + } + + *ArraySize =3D 0; + + // + // Configure Language buffer. + // + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; + ConfigureLangBuffer =3D AllocatePool (BufferSize); + if (ConfigureLangBuffer =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__)); + return NULL; + } + + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); + Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); + return NULL; + } + + if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_BOOLEAN_ARRAY) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string array type\n", = __FUNCTION__, Schema, Version, ConfigureLang)); + return NULL; + } + + BooleanArray =3D AllocatePool (sizeof (INT64) * RedfishValue.ArrayCount); + if (BooleanArray =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, out of resource\n", __FUNCTION__)); + return NULL; + } + + *ArraySize =3D RedfishValue.ArrayCount; + for (Index =3D 0; Index < RedfishValue.ArrayCount; Index++) { + BooleanArray[Index] =3D RedfishValue.Value.BooleanArray[Index]; + } + + return BooleanArray; +} + +/** + + Free the list of empty property key values. + + @param[in] EmptyPropKeyValueListHead The head of RedfishCS_EmptyProp_K= eyValue + +**/ +VOID +FreeEmptyPropKeyValueList ( + RedfishCS_EmptyProp_KeyValue *EmptyPropKeyValueListHead + ) +{ + RedfishCS_EmptyProp_KeyValue *NextEmptyPropKeyValueList; =20 - if (StrCmp (UnifiedConfigureLangPool[Index2].ConfigureLang, UnifiedC= onfigureLang) =3D=3D 0) { - Duplicated =3D TRUE; - break; - } + while (EmptyPropKeyValueListHead !=3D NULL) { + NextEmptyPropKeyValueList =3D EmptyPropKeyValueListHead->NextKeyValueP= tr; + if (EmptyPropKeyValueListHead->Value->DataValue.CharPtr !=3D NULL) { + FreePool(EmptyPropKeyValueListHead->Value->DataValue.CharPtr); } - - if (Duplicated) { - FreePool (UnifiedConfigureLang); - continue; + if (EmptyPropKeyValueListHead->Value !=3D NULL) { + FreePool(EmptyPropKeyValueListHead->Value); } - - if (UnifiedConfigureLangList->Count >=3D BIOS_CONFIG_TO_REDFISH_REDPAT= H_POOL_SIZE) { - FreePool (UnifiedConfigureLang); - Status =3D EFI_BUFFER_TOO_SMALL; - break; + if (EmptyPropKeyValueListHead->KeyNamePtr !=3D NULL) { + FreePool(EmptyPropKeyValueListHead->KeyNamePtr); } + FreePool (EmptyPropKeyValueListHead); + EmptyPropKeyValueListHead =3D NextEmptyPropKeyValueList; + }; +} =20 - // - // New configure language. Keep it in Pool - // +/** =20 - UnifiedConfigureLangPool[UnifiedConfigureLangList->Count].ConfigureLan= g =3D UnifiedConfigureLang; - UnifiedConfigureLangPool[UnifiedConfigureLangList->Count].Index =3D Ar= rayIndex; - ++UnifiedConfigureLangList->Count; - } + Create a new entry of RedfishCS_EmptyProp_KeyValue =20 - FreePool (ConfigureLangList); + @param[in] KeyName The key name. + @param[in] RedfishValue Redfish vale of this key. =20 - // - // Prepare the result to caller. - // - UnifiedConfigureLangList->List =3D AllocateCopyPool (sizeof (REDFISH_FEA= TURE_ARRAY_TYPE_CONFIG_LANG) * UnifiedConfigureLangList->Count, UnifiedConf= igureLangPool); +* @retval RedfishCS_EmptyProp_KeyValue Return the new RedfishCS_Empt= yProp_KeyValue. +* NULL means no new entry is cr= eated. =20 - return Status; +**/ +RedfishCS_EmptyProp_KeyValue * +NewEmptyPropKeyValueFromRedfishValue ( + IN EFI_STRING KeyName, + IN EDKII_REDFISH_VALUE *RedfishValue + ) +{ + RedfishCS_EmptyProp_KeyValue *EmptyPropKeyValue; + RedfishCS_Vague *VagueValue; + RedfishCS_char *KeyNameChar; + VOID *Data; + UINTN DataSize; + INT32 Bool32; + + KeyNameChar =3D StrUnicodeToAscii(KeyName); + if (KeyNameChar =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Failed to convert unicode to ASCII.\n", __FU= NCTION__)); + return NULL; + } + EmptyPropKeyValue =3D (RedfishCS_EmptyProp_KeyValue *)AllocateZeroPool (= sizeof (RedfishCS_EmptyProp_KeyValue)); + if (EmptyPropKeyValue =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Failed to allocate memory for EmptyPropKeyVa= lue\n", __FUNCTION__)); + return NULL; + } + VagueValue =3D (RedfishCS_Vague *)AllocateZeroPool (sizeof (RedfishCS_Va= gue)); + if (VagueValue =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Failed to allocate memory for VagueValue\n",= __FUNCTION__)); + FreePool (EmptyPropKeyValue); + return NULL; + } + + if (RedfishValue->Type =3D=3D REDFISH_VALUE_TYPE_BOOLEAN) { + VagueValue->DataType =3D RedfishCS_Vague_DataType_Bool; + DataSize =3D sizeof (BOOLEAN); + // + // Redfish JSON to C strcuture converter uses + // "int" for the BOOLEAN. + // + Bool32 =3D (INT32)RedfishValue->Value.Boolean; + Data =3D (VOID *)&Bool32; + } else if (RedfishValue->Type =3D=3D REDFISH_VALUE_TYPE_INTEGER) { + VagueValue->DataType =3D RedfishCS_Vague_DataType_Int64; + DataSize =3D sizeof (INT64); + Data =3D (VOID *)&RedfishValue->Value.Integer; + } else if (RedfishValue->Type =3D=3D REDFISH_VALUE_TYPE_STRING) { + VagueValue->DataType =3D RedfishCS_Vague_DataType_String; + DataSize =3D AsciiStrSize(RedfishValue->Value.Buffer); + Data =3D (VOID *)RedfishValue->Value.Buffer; + } else { + DEBUG ((DEBUG_ERROR, "%a, wrong type of RedfishValue: %x\n", __FUNCTIO= N__, RedfishValue->Type)); + FreePool (VagueValue); + FreePool (EmptyPropKeyValue); + return NULL; + } + VagueValue->DataValue.CharPtr =3D (RedfishCS_char *)AllocateCopyPool(Dat= aSize, Data); + EmptyPropKeyValue->Value =3D VagueValue; + EmptyPropKeyValue->KeyNamePtr =3D KeyNameChar; + return EmptyPropKeyValue; } =20 /** =20 - Create HTTP payload and send them to redfish service with PATCH method. + Get the property value in the vague type. =20 - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Etag Returned ETAG string from Redfish service. + @param[in] Schema Schema of this property. + @param[in] Version Schema version. + @param[in] PropertyName Property name. + @param[in] ConfigureLang Configure Language of this property. + @param[out] NumberOfValues Return the number of vague type of values =20 - @retval EFI_SUCCESS Data is sent to redfish service successfully. - @retval Others Errors occur. + @retval RedfishCS_EmptyProp_KeyValue The pointer to the structure + of vague type of values. =20 **/ -EFI_STATUS -CreatePayloadToPatchResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT CHAR8 **Etag +RedfishCS_EmptyProp_KeyValue * +GetPropertyVagueValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING PropertyName, + IN EFI_STRING ConfigureLang, + OUT UINT32 *NumberOfValues ) { - REDFISH_PAYLOAD Payload; - EDKII_JSON_VALUE ResourceJsonValue; - REDFISH_RESPONSE PostResponse; - EFI_STATUS Status; - UINTN Index; - EDKII_JSON_VALUE JsonValue; - EDKII_JSON_VALUE OdataIdValue; - CHAR8 *OdataIdString; + EFI_STATUS Status; + RedfishCS_EmptyProp_KeyValue *EmptyPropKeyValueList; + RedfishCS_EmptyProp_KeyValue *PreEmptyPropKeyValueList; + RedfishCS_EmptyProp_KeyValue *FirstEmptyPropKeyValueList; + EDKII_REDFISH_VALUE RedfishValue; + EFI_STRING ConfigureLangBuffer; + EFI_STRING KeyName; + EFI_STRING *ConfigureLangList; + EFI_STRING SearchPattern; + UINTN BufferSize; + UINTN ConfigListCount; + UINTN ConfigListCountIndex; =20 - if (Service =3D=3D NULL || TargetPayload =3D=3D NULL || IS_EMPTY_STRING = (Json) || Etag =3D=3D NULL) { - return EFI_INVALID_PARAMETER; + if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { + return NULL; } =20 - ResourceJsonValue =3D JsonLoadString (Json, 0, NULL); - Payload =3D RedfishCreatePayload (ResourceJsonValue, Service); - if (Payload =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from JSON va= lue!\n",__FUNCTION__, __LINE__)); - Status =3D EFI_DEVICE_ERROR; - goto EXIT_FREE_JSON_VALUE; + // + // Configure Language buffer. + // + BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; + ConfigureLangBuffer =3D AllocatePool (BufferSize); + if (ConfigureLangBuffer =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Failed to allocate memory for ConfigureLangB= uffer\n", __FUNCTION__)); + return NULL; } + UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); =20 - ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); - Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PostResponse); + // + // Initial search pattern + // + BufferSize =3D (StrLen (ConfigureLangBuffer) + StrLen (L"/.*") + 1) * si= zeof (CHAR16); // Increase one for the NULL terminator. + SearchPattern =3D AllocatePool (BufferSize); + if (SearchPattern =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Failed to allocate memory for SearchPattern\= n", __FUNCTION__)); + FreePool (ConfigureLangBuffer); + return NULL; + } + BufferSize =3D BufferSize / sizeof (CHAR16); + StrCpyS (SearchPattern, BufferSize, ConfigureLangBuffer); + StrCatS (SearchPattern, BufferSize, L"/.*"); + Status =3D RedfishPlatformConfigGetConfigureLang (Schema, Version, Searc= hPattern, &ConfigureLangList, &ConfigListCount); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to PATCH payload to Redfish service= .\n",__FUNCTION__, __LINE__)); - goto EXIT_FREE_JSON_VALUE; + DEBUG ((DEBUG_ERROR, "%a, %a.%a Get configure language of vague type v= alues of %s failed: %r\n", __FUNCTION__, Schema, Version, ConfigureLangBuff= er, Status)); + goto ErrorLeave; } =20 - // - // Keep etag. + // Build up the list of RedfishCS_EmptyProp_KeyValue. // - *Etag =3D NULL; - if (*PostResponse.StatusCode =3D=3D HTTP_STATUS_200_OK) { - if (PostResponse.HeaderCount !=3D 0) { - for (Index =3D 0; Index < PostResponse.HeaderCount; Index++) { - if (AsciiStrnCmp (PostResponse.Headers[Index].FieldName, "ETag", 4= ) =3D=3D 0) { - *Etag =3D AllocateCopyPool (AsciiStrSize (PostResponse.Headers[I= ndex].FieldValue), PostResponse.Headers[Index].FieldValue); - } - } - } else if (PostResponse.Payload !=3D NULL) { - // - // No header is returned. Search payload for location. - // - JsonValue =3D RedfishJsonInPayload (PostResponse.Payload); - if (JsonValue !=3D NULL) { - OdataIdValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue= ), "@odata.etag"); - if (OdataIdValue !=3D NULL) { - OdataIdString =3D (CHAR8 *)JsonValueGetAsciiString (OdataIdValue= ); - if (OdataIdString !=3D NULL) { - *Etag =3D AllocateCopyPool (AsciiStrSize (OdataIdString), Odat= aIdString); - } - } - } + ConfigListCountIndex =3D 0; + PreEmptyPropKeyValueList =3D NULL; + FirstEmptyPropKeyValueList =3D NULL; + while (ConfigListCountIndex < ConfigListCount) { + Status =3D RedfishPlatformConfigGetValue(Schema, Version, ConfigureLan= gList [ConfigListCountIndex], &RedfishValue); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed:= %r\n", __FUNCTION__, Schema, Version, ConfigureLangList [ConfigListCountIn= dex], Status)); + goto ErrorLeave; } - } - - RedfishFreeResponse ( - PostResponse.StatusCode, - PostResponse.HeaderCount, - PostResponse.Headers, - PostResponse.Payload - ); + // + // Get the key name. + // + KeyName =3D GetAttributeNameFromConfigLanguage (ConfigureLangList [Con= figListCountIndex]); + // + // Create an entry of RedfishCS_EmptyProp_KeyValue. + // + EmptyPropKeyValueList =3D NewEmptyPropKeyValueFromRedfishValue (KeyNam= e, &RedfishValue); + if (EmptyPropKeyValueList =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Failed to create an entry of EmptyPropKeyV= alueList\n", __FUNCTION__)); + ConfigListCountIndex ++; + continue; + } + // + // Link the RedfishCS_EmptyProp_KeyValue list. + // + if (PreEmptyPropKeyValueList !=3D NULL) { + PreEmptyPropKeyValueList->NextKeyValuePtr =3D EmptyPropKeyValueList; + } else { + FirstEmptyPropKeyValueList =3D EmptyPropKeyValueList; + } + PreEmptyPropKeyValueList =3D EmptyPropKeyValueList; + ConfigListCountIndex ++; + }; + goto LeaveFunction; =20 -EXIT_FREE_JSON_VALUE: - if (Payload !=3D NULL) { - RedfishCleanupPayload (Payload); +ErrorLeave:; + if (FirstEmptyPropKeyValueList !=3D NULL) { + FreeEmptyPropKeyValueList (FirstEmptyPropKeyValueList); } + FirstEmptyPropKeyValueList =3D NULL; =20 - JsonValueFree (ResourceJsonValue); +LeaveFunction: + if (SearchPattern !=3D NULL) { + FreePool (SearchPattern); + } + if (ConfigureLangBuffer !=3D NULL) { + FreePool (ConfigureLangBuffer); + } + FreePool (ConfigureLangList); =20 - return Status; + *NumberOfValues =3D (UINT32)ConfigListCount; + return FirstEmptyPropKeyValueList; } =20 /** =20 - Create HTTP payload and send them to redfish service with POST method. + Check and see if we need to do provisioning for this property. =20 - @param[in] Service Redfish service. - @param[in] TargetPayload Target payload - @param[in] Json Data in JSON format. - @param[out] Location Returned location string from Redfish servic= e. - @param[out] Etag Returned ETAG string from Redfish service. + @param[in] PropertyBuffer Pointer to property instance. + @param[in] ProvisionMode TRUE if we are in provision mode. FALSE oth= erwise. =20 - @retval EFI_SUCCESS Data is sent to redfish service successfully. - @retval Others Errors occur. + @retval TRUE Provision is required. + @retval FALSE Provision is not required. =20 **/ -EFI_STATUS -CreatePayloadToPostResource ( - IN REDFISH_SERVICE *Service, - IN REDFISH_PAYLOAD *TargetPayload, - IN CHAR8 *Json, - OUT CHAR8 **Location, - OUT CHAR8 **Etag +BOOLEAN +PropertyChecker ( + IN VOID *PropertyBuffer, + IN BOOLEAN ProvisionMode ) { - REDFISH_PAYLOAD Payload; - EDKII_JSON_VALUE ResourceJsonValue; - REDFISH_RESPONSE PostResponse; - EFI_STATUS Status; - UINTN Index; - EDKII_JSON_VALUE JsonValue; - EDKII_JSON_VALUE OdataIdValue; - CHAR8 *OdataIdString; + if (ProvisionMode) { + return TRUE; + } =20 - if (Service =3D=3D NULL || TargetPayload =3D=3D NULL || IS_EMPTY_STRING = (Json) || Location =3D=3D NULL || Etag =3D=3D NULL) { - return EFI_INVALID_PARAMETER; + if (!ProvisionMode && PropertyBuffer !=3D NULL) { + return TRUE; } =20 - ResourceJsonValue =3D JsonLoadString (Json, 0, NULL); - Payload =3D RedfishCreatePayload (ResourceJsonValue, Service); - if (Payload =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to create JSON payload from JSON va= lue!\n",__FUNCTION__, __LINE__)); - Status =3D EFI_DEVICE_ERROR; - goto EXIT_FREE_JSON_VALUE; + return FALSE; +} + +/** + + Check and see if ETAG is identical to what we keep in system. + + @param[in] Uri URI requested + @param[in] EtagInHeader ETAG string returned from HTTP request. + @param[in] EtagInJson ETAG string in JSON body. + + @retval TRUE ETAG is identical. + @retval FALSE ETAG is changed. + +**/ +BOOLEAN +CheckEtag ( + IN EFI_STRING Uri, + IN CHAR8 *EtagInHeader, + IN CHAR8 *EtagInJson + ) +{ + CHAR8 *EtagInDb; + + if (IS_EMPTY_STRING (Uri)) { + return FALSE; } =20 - ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); - Status =3D RedfishPostToPayload (TargetPayload, Payload, &PostResponse); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a:%d Failed to POST Attribute Registry to Redfi= sh service.\n",__FUNCTION__, __LINE__)); - goto EXIT_FREE_JSON_VALUE; + if (IS_EMPTY_STRING (EtagInHeader) && IS_EMPTY_STRING (EtagInJson)) { + return FALSE; } =20 // - // per Redfish spec. the URL of new eresource will be returned in "Locat= ion" header. + // Check ETAG to see if we need to consume it // - *Location =3D NULL; - *Etag =3D NULL; - if (*PostResponse.StatusCode =3D=3D HTTP_STATUS_200_OK) { - if (PostResponse.HeaderCount !=3D 0) { - for (Index =3D 0; Index < PostResponse.HeaderCount; Index++) { - if (AsciiStrnCmp (PostResponse.Headers[Index].FieldName, "Location= ", 8) =3D=3D 0) { - *Location =3D AllocateCopyPool (AsciiStrSize (PostResponse.Heade= rs[Index].FieldValue), PostResponse.Headers[Index].FieldValue); - } else if (AsciiStrnCmp (PostResponse.Headers[Index].FieldName, "E= Tag", 4) =3D=3D 0) { - *Etag =3D AllocateCopyPool (AsciiStrSize (PostResponse.Headers[I= ndex].FieldValue), PostResponse.Headers[Index].FieldValue); - } - } - } else if (PostResponse.Payload !=3D NULL) { - // - // No header is returned. Search payload for location. - // - JsonValue =3D RedfishJsonInPayload (PostResponse.Payload); - if (JsonValue !=3D NULL) { - OdataIdValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue= ), "@odata.id"); - if (OdataIdValue !=3D NULL) { - OdataIdString =3D (CHAR8 *)JsonValueGetAsciiString (OdataIdValue= ); - if (OdataIdString !=3D NULL) { - *Location =3D AllocateCopyPool (AsciiStrSize (OdataIdString), = OdataIdString); - } - } + EtagInDb =3D NULL; + EtagInDb =3D GetEtagWithUri (Uri); + if (EtagInDb =3D=3D NULL) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, no ETAG record cound be found for: %= s\n", __FUNCTION__, Uri)); + return FALSE; + } =20 - OdataIdValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue= ), "@odata.etag"); - if (OdataIdValue !=3D NULL) { - OdataIdString =3D (CHAR8 *)JsonValueGetAsciiString (OdataIdValue= ); - if (OdataIdString !=3D NULL) { - *Etag =3D AllocateCopyPool (AsciiStrSize (OdataIdString), Odat= aIdString); - } - } - } + if (EtagInHeader !=3D NULL) { + if (AsciiStrCmp (EtagInDb, EtagInHeader) =3D=3D 0) { + FreePool (EtagInDb); + return TRUE; } } =20 - // - // This is not expected as service does not follow spec. - // - if (*Location =3D=3D NULL) { - Status =3D EFI_DEVICE_ERROR; + if (EtagInJson !=3D NULL) { + if (AsciiStrCmp (EtagInDb, EtagInJson) =3D=3D 0) { + FreePool (EtagInDb); + return TRUE; + } } =20 - RedfishFreeResponse ( - PostResponse.StatusCode, - PostResponse.HeaderCount, - PostResponse.Headers, - PostResponse.Payload - ); - - RedfishCleanupPayload (Payload); - -EXIT_FREE_JSON_VALUE: - JsonValueFree (JsonValue); - JsonValueFree (ResourceJsonValue); + FreePool (EtagInDb); =20 - return Status; + return FALSE; } =20 /** + Check and see if given ObjectName can be found in JsonObj or not =20 - Find Redfish Resource Config Protocol that supports given schema and ver= sion. + @param[in] JsonObj JSON object to search + @param[in] ObjectName Object name =20 - @param[in] Schema Schema name. - @param[in] Major Schema version major number. - @param[in] Minor Schema version minor number. - @param[in] Errata Schema version errata number. - - @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to proto= col - @retval NULL No protocol foun= d. + @retval EDKII_JSON_VALUE * Pointer to Json object is found. NULL ot= herwise. =20 **/ -EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * -GetRedfishResourceConfigProtocol ( - IN CHAR8 *Schema, - IN CHAR8 *Major, - IN CHAR8 *Minor, - IN CHAR8 *Errata +EDKII_JSON_VALUE * +MatchJsonObject ( + IN EDKII_JSON_VALUE *JsonObj, + IN CHAR8 *ObjectName ) { - EFI_STATUS Status; - EFI_HANDLE *HandleBuffer; - UINTN NumberOfHandles; - UINTN Index; - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *Protocol; - REDFISH_SCHEMA_INFO SchemaInfo; - BOOLEAN Found; + EDKII_JSON_VALUE N; + CHAR8 *Key; + EDKII_JSON_VALUE Value; =20 - if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Major) || IS_EMPTY_STRI= NG (Minor) || IS_EMPTY_STRING (Errata)) { + if (JsonObj =3D=3D NULL || IS_EMPTY_STRING (ObjectName)) { return NULL; } =20 - Status =3D gBS->LocateHandleBuffer ( - ByProtocol, - &gEdkIIRedfishResourceConfigProtocolGuid, - NULL, - &NumberOfHandles, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { + if (!JsonValueIsObject (JsonObj)) { return NULL; } =20 - Found =3D FALSE; - - for (Index =3D 0; Index < NumberOfHandles; Index++) { - Status =3D gBS->HandleProtocol ( - HandleBuffer[Index], - &gEdkIIRedfishResourceConfigProtocolGuid, - (VOID **) &Protocol - ); - if (EFI_ERROR (Status)) { - continue; - } - - Status =3D Protocol->GetInfo (Protocol, &SchemaInfo); - if (EFI_ERROR (Status)) { - continue; + EDKII_JSON_OBJECT_FOREACH_SAFE (JsonObj, N, Key, Value) { + if (AsciiStrCmp (Key, ObjectName) =3D=3D 0) { + return Value; } - - if (AsciiStrCmp (Schema, SchemaInfo.Schema) =3D=3D 0 && - AsciiStrCmp (Major, SchemaInfo.Major) =3D=3D 0 && - AsciiStrCmp (Minor, SchemaInfo.Minor) =3D=3D 0 && - AsciiStrCmp (Errata, SchemaInfo.Errata) =3D=3D 0) { - Found =3D TRUE; - break; - } } =20 - FreePool (HandleBuffer); - - return (Found ? Protocol : NULL); + return NULL; } =20 /** =20 - Get supported schema list by given specify schema name. + Check and see if given property is in JSON context or not =20 - @param[in] Schema Schema type name. - @param[out] SchemaInfo Returned schema information. + @param[in] Property Property name string + @param[in] Json The JSON context to search. =20 - @retval EFI_SUCCESS Schema information is returned successfu= lly. - @retval Others Errors occur. + @retval TRUE Property is found in JSON context + @retval FALSE Property is not in JSON context =20 **/ -EFI_STATUS -GetSupportedSchemaVersion ( - IN CHAR8 *Schema, - OUT REDFISH_SCHEMA_INFO *SchemaInfo +BOOLEAN +MatchPropertyWithJsonContext ( + IN EFI_STRING Property, + IN CHAR8 *Json ) { - EFI_STATUS Status; - CHAR8 *SupportSchema; - CHAR8 *SchemaName; - UINTN Index; - UINTN Index2; - BOOLEAN Found; + CHAR8 *AsciiProperty; + CHAR8 *PropertyNode; + UINTN Index; + EDKII_JSON_VALUE *JsonObj; + EDKII_JSON_VALUE *MatchObj; + EDKII_JSON_TYPE JsonType; =20 - if (IS_EMPTY_STRING (Schema) || SchemaInfo =3D=3D NULL) { - return EFI_INVALID_PARAMETER; + if (IS_EMPTY_STRING (Property) || IS_EMPTY_STRING (Json)) { + return FALSE; } =20 - Status =3D RedfishPlatformConfigGetSupportedSchema (NULL, &SupportSchema= ); - if (EFI_ERROR (Status)) { - return Status; + JsonObj =3D JsonLoadString (Json, 0, NULL); + if (JsonObj =3D=3D NULL || !JsonValueIsObject (JsonObj)) { + return FALSE; } =20 - DEBUG ((DEBUG_INFO, "Supported schema: %a\n", SupportSchema)); - - Index =3D 0; - Found =3D FALSE; - SchemaName =3D SupportSchema; - while (TRUE) { - - if (SupportSchema[Index] =3D=3D ';' || SupportSchema[Index] =3D=3D '\0= ') { - if (AsciiStrnCmp (&SchemaName[SCHEMA_NAME_PREFIX_OFFSET], Schema, As= ciiStrLen (Schema)) =3D=3D 0) { - Found =3D TRUE; - SupportSchema[Index] =3D '\0'; - break; - } - - SchemaName =3D &SupportSchema[Index + 1]; - } - - if (SupportSchema[Index] =3D=3D '\0') { - break; - } - - ++Index; + AsciiProperty =3D StrUnicodeToAscii (Property); + if (AsciiProperty =3D=3D NULL) { + return FALSE; } =20 - if (Found) { - - AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Schema); - - // - // forward to '.' - // - Index =3D 0; - while (SchemaName[Index] !=3D '\0' && SchemaName[Index] !=3D '.') { - ++Index; - } - ASSERT (SchemaName[Index] !=3D '\0'); + Index =3D 0; + PropertyNode =3D AsciiProperty; + MatchObj =3D JsonObj; =20 - // - // Skip '.' and 'v' - // - Index +=3D 2; + // + // Walk through property and find corresponding object in JSON input + // + while (AsciiProperty[Index] !=3D '\0') { =20 - // - // forward to '_' - // - Index2 =3D Index; - while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') { - ++Index2; + if (AsciiProperty[Index] =3D=3D '/') { + AsciiProperty[Index] =3D '\0'; + MatchObj =3D MatchJsonObject (MatchObj, PropertyNode); + if (MatchObj =3D=3D NULL) { + PropertyNode =3D NULL; + break; + } + + PropertyNode =3D &AsciiProperty[Index + 1]; } - ASSERT (SchemaName[Index2] !=3D '\0'); =20 - AsciiStrnCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index)); - Index =3D Index2; + Index++; + } =20 - // - // Skip '_' - // - ++Index; + if (PropertyNode !=3D NULL) { + MatchObj =3D MatchJsonObject (MatchObj, PropertyNode); + } =20 + // + // Value check + // + if (MatchObj !=3D NULL) { // - // forward to '_' + // If object has empty value, treat it as not matching // - Index2 =3D Index; - while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') { - ++Index2; + JsonType =3D JsonGetType (MatchObj); + switch (JsonType) { + case EdkiiJsonTypeObject: + if (JsonValueIsNull (MatchObj)) { + MatchObj =3D NULL; + } + break; + case EdkiiJsonTypeArray: + if (JsonArrayCount (MatchObj) =3D=3D 0) { + MatchObj =3D NULL; + } + break; + case EdkiiJsonTypeString: + if (IS_EMPTY_STRING (JsonValueGetString (MatchObj))) { + MatchObj =3D NULL; + } + break; + case EdkiiJsonTypeNull: + MatchObj =3D NULL; + break; + default: + break; } - ASSERT (SchemaName[Index2] !=3D '\0'); - - AsciiStrnCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index)); - Index =3D Index2; - - // - // Skip '_' - // - ++Index; - - AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index]); } =20 - FreePool (SupportSchema); - - return (Found ? EFI_SUCCESS : EFI_NOT_FOUND); -} - -/** - - Return system root path. This is dummy function now. + FreePool (AsciiProperty); =20 - @retval NULL Can not find system root path. - @retval Other System root path is returned. - -**/ -CHAR8 * -RedfishGetSystemRootPath ( - VOID - ) -{ - return AllocateCopyPool (AsciiStrSize (REDFISH_SYSTEM_ROOT_PATH), REDFIS= H_SYSTEM_ROOT_PATH); + return (MatchObj =3D=3D NULL ? FALSE : TRUE); } =20 /** =20 - Get schema information by given protocol and service instance. + Create string array and append to arry node in Redfish JSON convert form= at. =20 - @param[in] RedfishService Pointer to Redfish service instance. - @param[in] JsonStructProtocol Json Structure protocol instance. - @param[in] Uri Target URI. - @param[out] SchemaInfo Returned schema information. + @param[in,out] Head The head of string array. + @param[in] StringArray Input string array. + @param[in] ArraySize The size of StringArray. =20 - @retval EFI_SUCCESS Schema information is returned successfu= lly. - @retval Others Errors occur. + @retval EFI_SUCCESS String array is created successfully. + @retval Others Error happens =20 **/ EFI_STATUS -GetRedfishSchemaInfo ( - IN REDFISH_SERVICE *RedfishService, - IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, - IN CHAR8 *Uri, - OUT REDFISH_SCHEMA_INFO *SchemaInfo +AddRedfishCharArray ( + IN OUT RedfishCS_char_Array **Head, + IN CHAR8 **StringArray, + IN UINTN ArraySize ) { - EFI_STATUS Status; - REDFISH_RESPONSE Response; - REDFISH_PAYLOAD Payload; - CHAR8 *JsonText; - EFI_REST_JSON_STRUCTURE_HEADER *Header; + UINTN Index; + RedfishCS_char_Array *CharArrayBuffer; + RedfishCS_char_Array *PreArrayBuffer; =20 - if (RedfishService =3D=3D NULL || JsonStructProtocol =3D=3D NULL || IS_E= MPTY_STRING (Uri) || SchemaInfo =3D=3D NULL) { + if (Head =3D=3D NULL || StringArray =3D=3D NULL || ArraySize =3D=3D 0) { return EFI_INVALID_PARAMETER; } =20 - Status =3D GetResourceByPath (RedfishService, Uri, &Response); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %a %r", __FUNCTI= ON__, Uri, Status)); - return Status; - } - - Payload =3D Response.Payload; - ASSERT (Payload !=3D NULL); + PreArrayBuffer =3D NULL; + for (Index =3D 0; Index < ArraySize; Index++) { + CharArrayBuffer =3D AllocatePool (sizeof (RedfishCS_char_Array)); + if (CharArrayBuffer =3D=3D NULL) { + ASSERT (CharArrayBuffer !=3D NULL); + continue; + } =20 - JsonText =3D JsonDumpString (RedfishJsonInPayload (Payload), EDKII_JSON_= COMPACT); - ASSERT (JsonText !=3D NULL); + if (Index =3D=3D 0) { + *Head =3D CharArrayBuffer; + } =20 - // - // Convert JSON text to C structure. - // - Status =3D JsonStructProtocol->ToStructure ( - JsonStructProtocol, - NULL, - JsonText, - &Header - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); - return Status; + CharArrayBuffer->ArrayValue =3D StringArray[Index]; + CharArrayBuffer->Next =3D NULL; + if (PreArrayBuffer !=3D NULL) { + PreArrayBuffer->Next =3D CharArrayBuffer; + } + PreArrayBuffer =3D CharArrayBuffer; } =20 - AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Header->J= sonRsrcIdentifier.NameSpace.ResourceTypeName); - AsciiStrCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.MajorVersion); - AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.MinorVersion); - AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, Header->= JsonRsrcIdentifier.NameSpace.ErrataVersion); - - // - // Release resource. - // - JsonStructProtocol->DestoryStructure (JsonStructProtocol, Header); - FreePool (JsonText); - RedfishFreeResponse (Response.StatusCode, Response.HeaderCount, Response= .Headers, Response.Payload); - return EFI_SUCCESS; } =20 /** =20 - Get the property name by given Configure Langauge. + Create numeric array and append to arry node in Redfish JSON convert for= mat. =20 - @param[in] ConfigureLang Configure Language string. + @param[in,out] Head The head of string array. + @param[in] NumericArray Input numeric array. + @param[in] ArraySize The size of NumericArray. =20 - @retval EFI_STRING Pointer to property name. - @retval NULL There is error. + @retval EFI_SUCCESS String array is created successfully. + @retval Others Error happens =20 **/ -EFI_STRING -GetPropertyFromConfigureLang ( - IN EFI_STRING ConfigureLang +EFI_STATUS +AddRedfishNumericArray ( + IN OUT RedfishCS_int64_Array **Head, + IN INT64 *NumericArray, + IN UINTN ArraySize ) { - EFI_STRING Property; - UINTN Index; + UINTN Index; + RedfishCS_int64_Array *NumericArrayBuffer; + RedfishCS_int64_Array *PreArrayBuffer; =20 - if (ConfigureLang =3D=3D NULL) { - return NULL; + if (Head =3D=3D NULL || NumericArray =3D=3D NULL || ArraySize =3D=3D 0) { + return EFI_INVALID_PARAMETER; } =20 - Index =3D 0; - Property =3D ConfigureLang; - - while (ConfigureLang[Index] !=3D '\0') { - if (ConfigureLang[Index] =3D=3D L'/') { - Property =3D &ConfigureLang[Index]; + PreArrayBuffer =3D NULL; + for (Index =3D 0; Index < ArraySize; Index++) { + NumericArrayBuffer =3D AllocatePool (sizeof (RedfishCS_int64_Array)); + if (NumericArrayBuffer =3D=3D NULL) { + ASSERT (NumericArrayBuffer !=3D NULL); + continue; } =20 - ++Index; + if (Index =3D=3D 0) { + *Head =3D NumericArrayBuffer; + } + NumericArrayBuffer->ArrayValue =3D AllocatePool (sizeof (RedfishCS_in= t64)); + if (NumericArrayBuffer->ArrayValue =3D=3D NULL) { + ASSERT (NumericArrayBuffer->ArrayValue !=3D NULL); + continue; + } + *NumericArrayBuffer->ArrayValue =3D NumericArray[Index]; + NumericArrayBuffer->Next =3D NULL; + if (PreArrayBuffer !=3D NULL) { + PreArrayBuffer->Next =3D NumericArrayBuffer; + } + PreArrayBuffer =3D NumericArrayBuffer; } =20 - ++Property; - - return Property; + return EFI_SUCCESS; } =20 /** =20 - Get the property value in string type. + Create boolean array and append to arry node in Redfish JSON convert for= mat. =20 - @param[in] Schema Schema of this property. - @param[in] Version Schema version. - @param[in] PropertyName Property name. - @param[in] ConfigureLang Configure Language of this property. + @param[in,out] Head The head of string array. + @param[in] BooleanArray Input boolean array. + @param[in] ArraySize The size of BooleanArray. =20 - @retval CHAR8* Pointer to the CHAR8 buffer. - @retval NULL There is error. + @retval EFI_SUCCESS String array is created successfully. + @retval Others Error happens =20 **/ -CHAR8 * -GetPropertyStringValue ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING PropertyName, - IN EFI_STRING ConfigureLang +EFI_STATUS +AddRedfishBooleanArray ( + IN OUT RedfishCS_bool_Array **Head, + IN BOOLEAN *BooleanArray, + IN UINTN ArraySize ) { - EFI_STATUS Status; - EDKII_REDFISH_VALUE RedfishValue; - EFI_STRING ConfigureLangBuffer; - UINTN BufferSize; - CHAR8 *AsciiStringValue; + UINTN Index; + RedfishCS_bool_Array *BooleanArrayBuffer; + RedfishCS_bool_Array *PreArrayBuffer; =20 - if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { - return NULL; + if (Head =3D=3D NULL || BooleanArrayBuffer =3D=3D NULL || ArraySize =3D= =3D 0) { + return EFI_INVALID_PARAMETER; } =20 - // - // Configure Language buffer. - // - BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; - ConfigureLangBuffer =3D AllocatePool (BufferSize); - if (ConfigureLangBuffer =3D=3D NULL) { - return NULL; - } + PreArrayBuffer =3D NULL; + for (Index =3D 0; Index < ArraySize; Index++) { + BooleanArrayBuffer =3D AllocatePool (sizeof (RedfishCS_bool_Array)); + if (BooleanArrayBuffer =3D=3D NULL) { + ASSERT (BooleanArrayBuffer !=3D NULL); + continue; + } =20 - UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); - Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); - return NULL; - } + if (Index =3D=3D 0) { + *Head =3D BooleanArrayBuffer; + } =20 - if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_STRING) { - DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not string type\n", __FUNC= TION__, Schema, Version, ConfigureLang)); - return NULL; + BooleanArrayBuffer->ArrayValue =3D AllocatePool (sizeof (RedfishCS_bo= ol)); + if (BooleanArrayBuffer->ArrayValue =3D=3D NULL) { + ASSERT (BooleanArrayBuffer->ArrayValue !=3D NULL); + continue; + } + *BooleanArrayBuffer->ArrayValue =3D BooleanArray[Index]; + BooleanArrayBuffer->Next =3D NULL; + if (PreArrayBuffer !=3D NULL) { + PreArrayBuffer->Next =3D BooleanArrayBuffer; + } + PreArrayBuffer =3D BooleanArrayBuffer; } =20 - AsciiStringValue =3D AllocateCopyPool (AsciiStrSize (RedfishValue.Value.= Buffer), RedfishValue.Value.Buffer); - ASSERT (AsciiStringValue !=3D NULL); - - return AsciiStringValue; + return EFI_SUCCESS; } =20 /** =20 - Get the property value in numeric type. + Check and see if value in Redfish string array are all the same as the o= ne + from HII configuration. =20 - @param[in] Schema Schema of this property. - @param[in] Version Schema version. - @param[in] PropertyName Property name. - @param[in] ConfigureLang Configure Language of this property. + @param[in] Head The head of string array. + @param[in] StringArray Input string array. + @param[in] ArraySize The size of StringArray. =20 - @retval INT64* Pointer to the INT64 value. - @retval NULL There is error. + @retval TRUE All string in Redfish array are as same as str= ing + in HII configuration array. + FALSE These two array are not identical. =20 **/ -INT64 * -GetPropertyNumericValue ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING PropertyName, - IN EFI_STRING ConfigureLang +BOOLEAN +CompareRedfishStringArrayValues ( + IN RedfishCS_char_Array *Head, + IN CHAR8 **StringArray, + IN UINTN ArraySize ) { - EFI_STATUS Status; - EDKII_REDFISH_VALUE RedfishValue; - EFI_STRING ConfigureLangBuffer; - UINTN BufferSize; - INT64 *ResultValue; + UINTN Index; + RedfishCS_char_Array *CharArrayBuffer; =20 - if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { - return NULL; + if (Head =3D=3D NULL || StringArray =3D=3D NULL || ArraySize =3D=3D 0) { + return FALSE; } =20 - // - // Configure Language buffer. - // - BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; - ConfigureLangBuffer =3D AllocatePool (BufferSize); - if (ConfigureLangBuffer =3D=3D NULL) { - return NULL; - } + CharArrayBuffer =3D Head; + Index =3D 0; + while (CharArrayBuffer !=3D NULL && Index < ArraySize) { =20 - UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); - Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); - return NULL; - } + if (AsciiStrCmp (StringArray[Index], CharArrayBuffer->ArrayValue) !=3D= 0) { + break; + } =20 - if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_INTEGER) { - DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not numeric type\n", __FUN= CTION__, Schema, Version, ConfigureLang)); - return NULL; + Index++; + CharArrayBuffer =3D CharArrayBuffer->Next; } =20 - ResultValue =3D AllocatePool (sizeof (INT64)); - ASSERT (ResultValue !=3D NULL); - if (ResultValue =3D=3D NULL) { - return NULL; + if (CharArrayBuffer !=3D NULL || Index < ArraySize) { + return FALSE; } =20 - *ResultValue =3D RedfishValue.Value.Integer; - - return ResultValue; + return TRUE; } =20 /** =20 - Get the property value in Boolean type. + Check and see if value in Redfish numeric array are all the same as the = one + from HII configuration. =20 - @param[in] Schema Schema of this property. - @param[in] Version Schema version. - @param[in] PropertyName Property name. - @param[in] ConfigureLang Configure Language of this property. + @param[in] Head The head of Redfish CS numeraic array. + @param[in] NumericArray Input numeric array. + @param[in] ArraySize The size of NumericArray. =20 - @retval BOOLEAN Boolean value returned by this property. + @retval TRUE All string in Redfish array are as same as int= eger + in HII configuration array. + FALSE These two array are not identical. =20 **/ -BOOLEAN * -GetPropertyBooleanValue ( - IN CHAR8 *Schema, - IN CHAR8 *Version, - IN EFI_STRING PropertyName, - IN EFI_STRING ConfigureLang +BOOLEAN +CompareRedfishNumericArrayValues ( + IN RedfishCS_int64_Array *Head, + IN INT64 *NumericArray, + IN UINTN ArraySize ) { - EFI_STATUS Status; - EDKII_REDFISH_VALUE RedfishValue; - EFI_STRING ConfigureLangBuffer; - UINTN BufferSize; - BOOLEAN *ResultValue; - - if (IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Version) || IS_EMPTY_ST= RING (ConfigureLang) || IS_EMPTY_STRING (PropertyName)) { - return NULL; - } + UINTN Index; + RedfishCS_int64_Array *NumericArrayBuffer; =20 - // - // Configure Language buffer. - // - BufferSize =3D sizeof (CHAR16) * MAX_CONF_LANG_LEN; - ConfigureLangBuffer =3D AllocatePool (BufferSize); - if (ConfigureLangBuffer =3D=3D NULL) { - return NULL; + if (Head =3D=3D NULL || NumericArray =3D=3D NULL || ArraySize =3D=3D 0) { + return FALSE; } =20 - UnicodeSPrint (ConfigureLangBuffer, BufferSize, L"%s/%s", ConfigureLang,= PropertyName); - Status =3D RedfishPlatformConfigGetValue (Schema, Version, ConfigureLang= Buffer, &RedfishValue); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, %a.%a query current setting for %s failed: %= r\n", __FUNCTION__, Schema, Version, ConfigureLangBuffer, Status)); - return NULL; - } + NumericArrayBuffer =3D Head; + Index =3D 0; + while (NumericArrayBuffer !=3D NULL && Index < ArraySize) { + if (NumericArray[Index] !=3D *NumericArrayBuffer->ArrayValue) { + break; + } =20 - if (RedfishValue.Type !=3D REDFISH_VALUE_TYPE_BOOLEAN) { - DEBUG ((DEBUG_ERROR, "%a, %a.%a %s value is not boolean type\n", __FUN= CTION__, Schema, Version, ConfigureLang)); - return NULL; + Index++; + NumericArrayBuffer =3D NumericArrayBuffer->Next; } =20 - ResultValue =3D AllocatePool (sizeof (BOOLEAN)); - ASSERT (ResultValue !=3D NULL); - if (ResultValue =3D=3D NULL) { - return NULL; + if (NumericArrayBuffer !=3D NULL || Index < ArraySize) { + return FALSE; } =20 - *ResultValue =3D RedfishValue.Value.Boolean; - - return ResultValue; + return TRUE; } =20 /** =20 - Check and see if we need to do provisioning for this property. + Check and see if value in Redfish boolean array are all the same as the = one + from HII configuration. =20 - @param[in] PropertyBuffer Pointer to property instance. - @param[in] ProvisionMode TRUE if we are in provision mode. FALSE oth= erwise. + @param[in] Head The head of Redfish CS boolean array. + @param[in] BooleanArray Input boolean array. + @param[in] ArraySize The size of BooleanArray. =20 - @retval TRUE Provision is required. - @retval FALSE Provision is not required. + @retval TRUE All string in Redfish array are as same as int= eger + in HII configuration array. + FALSE These two array are not identical. =20 **/ BOOLEAN -PropertyChecker ( - IN VOID *PropertyBuffer, - IN BOOLEAN ProvisionMode +CompareRedfishBooleanArrayValues ( + IN RedfishCS_bool_Array *Head, + IN BOOLEAN *BooleanArray, + IN UINTN ArraySize ) { - if (ProvisionMode && PropertyBuffer =3D=3D NULL) { - return TRUE; + UINTN Index; + RedfishCS_bool_Array *BooleanArrayBuffer; + + if (Head =3D=3D NULL || BooleanArray =3D=3D NULL || ArraySize =3D=3D 0) { + return FALSE; } =20 - if (!ProvisionMode && PropertyBuffer !=3D NULL) { - return TRUE; + BooleanArrayBuffer =3D Head; + Index =3D 0; + while (BooleanArrayBuffer !=3D NULL && Index < ArraySize) { + if (BooleanArray[Index] !=3D *BooleanArrayBuffer->ArrayValue) { + break; + } + + Index++; + BooleanArrayBuffer =3D BooleanArrayBuffer->Next; } =20 - return FALSE; + if (BooleanArrayBuffer !=3D NULL || Index < ArraySize) { + return FALSE; + } + + return TRUE; } =20 /** =20 - Check and see if we need to do provisioning for this two properties. + Check and see if any difference between two vague value set. + This is just a simple check. =20 - @param[in] PropertyBuffer1 Pointer to property instance 1. - @param[in] PropertyBuffer2 Pointer to property instance 2. - @param[in] ProvisionMode TRUE if we are in provision mode. FALSE ot= herwise. + @param[in] RedfishVagueKeyValuePtr The vague key value sets on Redf= ish service. + @param[in] RedfishVagueKeyValueNumber The numebr of vague key value se= ts + @param[in] ConfigVagueKeyValuePtr The vague configuration on platf= orm. + @param[in] ConfigVagueKeyValueNumber The numebr of vague key value se= ts =20 - @retval TRUE Provision is required. - @retval FALSE Provision is not required. + @retval TRUE All values are the same. + FALSE There is some difference. =20 **/ BOOLEAN -PropertyChecker2Parm ( - IN VOID *PropertyBuffer1, - IN VOID *PropertyBuffer2, - IN BOOLEAN ProvisionMode +CompareRedfishPropertyVagueValues ( + IN RedfishCS_EmptyProp_KeyValue *RedfishVagueKeyValuePtr, + IN UINT32 RedfishVagueKeyValueNumber, + IN RedfishCS_EmptyProp_KeyValue *ConfigVagueKeyValuePtr, + IN UINT32 ConfigVagueKeyValueNumber ) -{ - if (ProvisionMode && (PropertyBuffer1 =3D=3D NULL || PropertyBuffer2 =3D= =3D NULL)) { - return TRUE; - } + { + RedfishCS_EmptyProp_KeyValue *ThisConfigVagueKeyValuePtr; + RedfishCS_EmptyProp_KeyValue *ThisRedfishVagueKeyValuePtr; =20 - if (!ProvisionMode && PropertyBuffer1 !=3D NULL && PropertyBuffer2 !=3D = NULL) { - return TRUE; + if (RedfishVagueKeyValueNumber !=3D ConfigVagueKeyValueNumber) { + return FALSE; } =20 - return FALSE; + ThisConfigVagueKeyValuePtr =3D ConfigVagueKeyValuePtr; + // + // Loop through all key/value on system. + // + while (ThisConfigVagueKeyValuePtr !=3D NULL) { + ThisRedfishVagueKeyValuePtr =3D RedfishVagueKeyValuePtr; + // + // Loop through all key/value on Redfish service.. + // + while (ThisRedfishVagueKeyValuePtr !=3D NULL) { + if (AsciiStrCmp(ThisConfigVagueKeyValuePtr->KeyNamePtr, ThisRedfishV= agueKeyValuePtr->KeyNamePtr) =3D=3D 0) { + // + // Check the type of value. + // + if (ThisConfigVagueKeyValuePtr->Value->DataType !=3D ThisRedfishVa= gueKeyValuePtr->Value->DataType) { + return FALSE; + } + // + // Check the value. + // + if (ThisConfigVagueKeyValuePtr->Value->DataType =3D=3D RedfishCS_V= ague_DataType_String) { + // + // Is the string identical? + // + if (AsciiStrCmp (ThisConfigVagueKeyValuePtr->Value->DataValue.Ch= arPtr, + ThisRedfishVagueKeyValuePtr->Value->DataValue.C= harPtr + ) =3D=3D 0) { + break; + } else{ + return FALSE; + } + } else if (ThisConfigVagueKeyValuePtr->Value->DataType =3D=3D Redf= ishCS_Vague_DataType_Int64) { + if (*ThisConfigVagueKeyValuePtr->Value->DataValue.Int64Ptr =3D= =3D *ThisRedfishVagueKeyValuePtr->Value->DataValue.Int64Ptr) { + break; + } else { + return FALSE; + } + } else if (ThisConfigVagueKeyValuePtr->Value->DataType =3D=3D Redf= ishCS_Vague_DataType_Bool) { + if ((UINT8)*ThisConfigVagueKeyValuePtr->Value->DataValue.BoolPtr= =3D=3D (UINT8)*ThisRedfishVagueKeyValuePtr->Value->DataValue.BoolPtr) { + break; + } else { + return FALSE; + } + } else { + return FALSE; + } + } + ThisRedfishVagueKeyValuePtr =3D ThisRedfishVagueKeyValuePtr->NextKey= ValuePtr; + }; + if (ThisRedfishVagueKeyValuePtr =3D=3D NULL) { + // + // No matched key name. Threat these two vague value set is differen= t. + // + return FALSE; + } + ThisConfigVagueKeyValuePtr =3D ThisConfigVagueKeyValuePtr->NextKeyValu= ePtr; + }; + return TRUE; } =20 /** diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/Redfis= hFeatureUtilityLib.inf index f9f283fdcc..84f338e680 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf @@ -1,6 +1,6 @@ ## @file # -# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -27,6 +27,7 @@ [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + NetworkPkg/NetworkPkg.dec RedfishPkg/RedfishPkg.dec RedfishClientPkg/RedfishClientPkg.dec =20 @@ -35,16 +36,25 @@ BaseMemoryLib DebugLib MemoryAllocationLib - PrintLib RedfishLib RedfishPlatformConfigLib UefiLib UefiBootServicesTableLib UefiRuntimeServicesTableLib + PrintLib + HttpLib =20 [Protocols] - gEdkIIRedfishETagProtocolGuid ## CONSUMED ## + gEdkIIRedfishETagProtocolGuid ## CONSUMED ## + gEdkIIRedfishConfigLangMapProtocolGuid ## CONSUMED ## =20 [Pcd] - gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize - gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + +[Guids] + +[BuildOptions] + # + # NOTE: /wd4706 disables the following Visual Studio compiler warning in= Jansson: + # "C4706: assignment within conditional expression" + # + MSFT:*_*_*_CC_FLAGS =3D /wd4706 --=20 2.32.0.windows.2 -=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 (#91879): https://edk2.groups.io/g/devel/message/91879 Mute This Topic: https://groups.io/mt/92641653/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- From nobody Fri Apr 26 08:47:54 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+91878+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+91878+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885906; cv=none; d=zohomail.com; s=zohoarc; b=JJyyiGEJgFhfCh95pLfRU6mnJeET3DfEfqi0Cf79pNCMZ6DiQ9V40pF7uDBIINkwqlrsDS6aMfVmLMzvCNDNVZdIEVHdh54dR4UQtZA6WLwSpoQggc3A7EtKdfJjWQnOvhySOS1TbpGsbtI9DebseTWVI/9KmiCA6awQS+T9OzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885906; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=QhpOdNpSr0RPu44rgd0wbrUddIyAKOnR5zHcaSgKi7E=; b=OxpBP9O+7VERftt3TQ/ntdrn17TAQqJorVXp+5kH7kQ1LgLN9PUyMSn8OiuUaLnX9k2ccQmzRIoyhzG7xdUywYE6/uiHz7NFMYg9vut/sLT4A0ghLrEKfT1vOaga5+IPOR/gRxZtChgZV1eJyUU/MPOmY1wKZC8zBB/WwpNJPt0= 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+91878+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 1658885906197166.72609042153272; Tue, 26 Jul 2022 18:38:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4qAQYY1788612xbdfRFVGMny; Tue, 26 Jul 2022 18:38:25 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.14963.1658885905077353803 for ; Tue, 26 Jul 2022 18:38:25 -0700 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0ra2v017862; Wed, 27 Jul 2022 01:38:23 GMT X-Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3hjqhjsm4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:22 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id 66D0CD2C8; Wed, 27 Jul 2022 01:38:22 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 29C84804D07; Wed, 27 Jul 2022 01:38:20 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 11/15] edk2-staging/RedfishClientPkg: Rename RedfishMemoryCollection driver Date: Wed, 27 Jul 2022 09:37:58 +0800 Message-Id: <20220727013802.247-12-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: y0wycKWxxKKKB6jJ7gPmWuKbtglBM4-V X-Proofpoint-ORIG-GUID: y0wycKWxxKKKB6jJ7gPmWuKbtglBM4-V 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,nickle.wang@hpe.com X-Gm-Message-State: TcJH9oKet2RZGBVSFIqWEGEjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885905; bh=HXytc6FOV3GSMlpLx2qTkU8GArXTPk7WvoL5AvBaC8Q=; h=Cc:Date:From:Reply-To:Subject:To; b=u4Ls/Z9zgOHG5dOgg9XqtrTQSsQamp1FRK7TG3xzhAOS6FP144aeZR9nvvnvqTZV+kN xVVJxXp776ryJ49Tv5qG4bSS+1kLfeIvHszkw2ug4Z/pt1sjFTXZDxmsaIv59UT9Ne/D4 adhXBv9g66BYl93jqn5xxizhMfuDhCNKca4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885907070100003 Content-Type: text/plain; charset="utf-8" Rename RedfishMemoryCollectionDxe by removing Redfish prefix. Update memory collection driver to support "Identify" action and also have code refactoring to support Redfish operation. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../MemoryCollectionDxe.c} | 259 +++++++++--------- .../MemoryCollectionDxe.h} | 7 +- .../MemoryCollectionDxe.inf} | 19 +- .../Include/RedfishCollectionCommon.h | 14 +- RedfishClientPkg/RedfishClient.fdf.inc | 2 +- .../RedfishClientComponents.dsc.inc | 2 +- 6 files changed, 164 insertions(+), 139 deletions(-) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.c =3D> MemoryCollectionDxe/MemoryCollectionDxe.c} (66%) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.h =3D> MemoryCollectionDxe/MemoryCollectionDxe.h} (64%) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.inf =3D> MemoryCollectionDxe/MemoryCollectionDxe.inf} (71%) diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.c b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryC= ollectionDxe.c similarity index 66% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.c rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .c index d97f0f161e..43426a78af 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.c +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c @@ -1,67 +1,98 @@ /** @file - Redfish feature driver implementation - memory collection =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ Redfish feature driver implementation - MemoryCollection + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include "RedfishMemoryCollectionDxe.h" +#include "MemoryCollectionDxe.h" =20 REDFISH_COLLECTION_PRIVATE *mRedfishCollectionPrivate =3D NULL; =20 EFI_STATUS -ProcessResource ( +HandleResource ( IN REDFISH_COLLECTION_PRIVATE *Private, - IN CHAR8 *Uri + IN EFI_STRING Uri ) { - EFI_STATUS Status; - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol; - REDFISH_SCHEMA_INFO SchemaInfo; + EFI_STATUS Status; + REDFISH_SCHEMA_INFO SchemaInfo; + EFI_STRING ConfigLang; + EFI_STRING ReturnedConfigLang; + UINTN Index; =20 if (Private =3D=3D NULL || IS_EMPTY_STRING (Uri)) { return EFI_INVALID_PARAMETER; } =20 - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %a\n", __FUNCTIO= N__, Uri)); + // + // Resource match + // + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\n", __FUNCTIO= N__, Uri)); =20 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)); + DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %s %r= \n", __FUNCTION__, Uri, Status)); return Status; } + // + // Check and see if this is target resource that we want to handle. + // Some resource is handled by other provider so we have to make sure th= is first. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%s Identify for %s\n", __FUNCTION__, Uri)); + ConfigLang =3D RedfishGetConfigLanguage (Uri); + if (ConfigLang =3D=3D NULL) { + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_INFO, "%a, \"%s\" is not handled by us\n", __FUNCTIO= N__, Uri)); + return EFI_SUCCESS; + } =20 - RedfishResrouceProtocol =3D GetRedfishResourceConfigProtocol ( - SchemaInfo.Schema, - SchemaInfo.Major, - SchemaInfo.Minor, - SchemaInfo.Errata - ); - if (RedfishResrouceProtocol =3D=3D NULL) { - return EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "%a, fail to identify resource: \"%s\": %r\n", = __FUNCTION__, Uri, Status)); + return Status; + } + } else { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, history record found: %s\n", __FUNCT= ION__, ConfigLang)); + // + // Set exchange information + // + Status =3D GetArrayIndexFromArrayTypeConfigureLang (ConfigLang, &Retur= nedConfigLang, &Index); + if (!EFI_ERROR (Status) || Status =3D=3D EFI_NOT_FOUND) { + Private->InformationExchange->ReturnedInformation.Type =3D Informati= onTypeCollectionMemberConfigLanguage; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.Count =3D 1; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List =3D + AllocateZeroPool(sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG)); + + if (Private->InformationExchange->ReturnedInformation.ConfigureLangu= ageList.List =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEAT= URE_ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List [Index].Index =3D Index; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List [Index].ConfigureLang =3D + (EFI_STRING)AllocateCopyPool(StrSize(ReturnedConfigLang), (VOID = *)ReturnedConfigLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, GetArrayIndexFromArrayTypeConfigureLang fa= il: %r\n", __FUNCTION__, Status)); + } + FreePool (ConfigLang); } =20 // // 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 - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, 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 - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __FUNCTION__, Ur= i)); + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, = Private->InformationExchange, FALSE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", = __FUNCTION__, Status)); } @@ -72,41 +103,36 @@ ProcessResource ( // // Consume first. // - DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %a\n", __FUNCTION__, Uri)); - Status =3D RedfishResrouceProtocol->Consume ( - RedfishResrouceProtocol, - Uri - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %a %r\n", __= FUNCTION__, Uri, Status)); + DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %s: %r\n", _= _FUNCTION__, Uri, Status)); } =20 // // Patch. // - DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %a\n", __FUNCTION__, Uri)); - Status =3D RedfishResrouceProtocol->Update ( - RedfishResrouceProtocol, - Uri - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to update resoruce for: %s: %r\n", __= FUNCTION__, Uri, Status)); + } =20 return Status; } =20 EFI_STATUS -ProcessCollection ( +HandleCollectionResource ( IN REDFISH_COLLECTION_PRIVATE *Private ) { EFI_STATUS Status; - EFI_REDFISH_MEMORYCOLLECTION *Memory; + EFI_REDFISH_MEMORYCOLLECTION *Collection; EFI_REDFISH_MEMORYCOLLECTION_CS *CollectionCs; RedfishCS_Link *List; RedfishCS_Header *Header; RedfishCS_Type_Uri_Data *UriData; - CHAR8 *ConfigureLang; - UINTN Size; - UINTN Count; + EFI_STRING MemberUri; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -116,7 +142,7 @@ ProcessCollection ( return EFI_NOT_READY; } =20 - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %a\n", __FUNCT= ION__, Private->CollectionPath)); + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %s\n", __FUNCT= ION__, Private->CollectionUri)); =20 // // Convert JSON text to C structure. @@ -125,14 +151,14 @@ ProcessCollection ( Private->JsonStructProtocol, NULL, Private->CollectionJson, - (EFI_REST_JSON_STRUCTURE_HEADER = **)&Memory + (EFI_REST_JSON_STRUCTURE_HEADER = **)&Collection ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); return Status; } =20 - CollectionCs =3D Memory->MemoryCollection; + CollectionCs =3D Collection->MemoryCollection; =20 if (*CollectionCs->Membersodata_count =3D=3D 0) { return EFI_NOT_FOUND; @@ -142,23 +168,22 @@ ProcessCollection ( return EFI_NOT_FOUND; } =20 - Count =3D 0; List =3D GetFirstLink (&CollectionCs->Members); while (TRUE) { =20 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)); + MemberUri =3D NULL; + MemberUri =3D StrAsciiToUnicode (UriData->Uri); + ASSERT (MemberUri !=3D NULL); + if (MemberUri !=3D NULL) { + Status =3D HandleResource (Private, MemberUri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, process MemoryCollection resource: %a = failed: %r\n", __FUNCTION__, UriData->Uri, Status)); + } + + FreePool (MemberUri); } } =20 @@ -172,25 +197,24 @@ ProcessCollection ( // // Release resource. // - Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Memory); + Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Collection); =20 return EFI_SUCCESS; } =20 EFI_STATUS -CreateCollection ( +CreateCollectionResource ( IN REDFISH_COLLECTION_PRIVATE *Private ) { EFI_STATUS Status; - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol; REDFISH_SCHEMA_INFO SchemaInfo; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %a= \n", __FUNCTION__, Private->CollectionPath)); + DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %s= \n", __FUNCTION__, Private->CollectionUri)); =20 Status =3D GetSupportedSchemaVersion (REDFISH_SCHEMA_NAME, &SchemaInfo); if (EFI_ERROR (Status)) { @@ -200,18 +224,9 @@ CreateCollection ( =20 DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a %a.%a.%a\n", __FU= NCTION__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo= .Errata)); =20 - 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 - ); + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Private= ->CollectionUri, Private->InformationExchange, TRUE); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %a %r\n", __F= UNCTION__, Private->CollectionPath, Status)); + DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %s: %r\n", __= FUNCTION__, Private->CollectionUri, Status)); } =20 return Status; @@ -248,6 +263,11 @@ ReleaseCollectionResource ( Private->CollectionJson =3D NULL; } =20 + if (Private->RedfishVersion !=3D NULL) { + FreePool (Private->RedfishVersion); + Private->RedfishVersion =3D NULL; + } + return EFI_SUCCESS; } =20 @@ -257,49 +277,19 @@ CollectionHandler ( ) { EFI_STATUS Status; - CHAR8 *SystemRootPath; - CHAR8 *PathBuffer; - UINTN BufferSize; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - 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; - } + DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %s\n", __FUNCTI= ON__, Private->CollectionUri)); =20 // // Query collection from Redfish service. // - Status =3D GetResourceByPath (Private->RedfishService, Private->Collecti= onPath, &Private->RedResponse); + Status =3D GetResourceByUri (Private->RedfishService, Private->Collectio= nUri, &Private->RedResponse); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %a :%r\n", __FU= NCTION__, Private->CollectionPath, Status)); + DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %s :%r\n", __FU= NCTION__, Private->CollectionUri, Status)); goto ON_RELEASE; } =20 @@ -309,21 +299,13 @@ CollectionHandler ( Private->CollectionJson =3D JsonDumpString (RedfishJsonInPayload (Privat= e->CollectionPayload), EDKII_JSON_COMPACT); ASSERT (Private->CollectionJson !=3D NULL); =20 - Status =3D ProcessCollection (Private); + Status =3D HandleCollectionResource (Private); if (EFI_ERROR (Status) && Status =3D=3D EFI_NOT_FOUND) { - Status =3D CreateCollection (Private); + Status =3D CreateCollectionResource (Private); } =20 ON_RELEASE: =20 - if (SystemRootPath !=3D NULL) { - FreePool (SystemRootPath); - } - - if (PathBuffer !=3D NULL) { - FreePool (PathBuffer); - } - ReleaseCollectionResource (Private); =20 return Status; @@ -334,10 +316,12 @@ ON_RELEASE: =20 @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROT= OCOL instance. @param[in] FeatureAction The action Redfish feature driver sho= uld take. + @param[in] Uri The collection URI. @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. + @param[in,out] InformationExchange The pointer to RESOURCE_INFORMATION_E= XCHANGE + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. =20 @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. @retval Others Some errors happened. @@ -349,12 +333,13 @@ RedfishCollectionFeatureCallback ( IN EDKII_REDFISH_FEATURE_PROTOCOL *This, IN FEATURE_CALLBACK_ACTION FeatureAction, IN VOID *Context, - IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned + IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange ) { EFI_STATUS Status; REDFISH_SERVICE RedfishService; REDFISH_COLLECTION_PRIVATE *Private; + EFI_STRING ResourceUri; =20 if (FeatureAction !=3D CallbackActionStartOperation) { return EFI_UNSUPPORTED; @@ -367,6 +352,36 @@ RedfishCollectionFeatureCallback ( return EFI_NOT_READY; } =20 + // + // Save in private structure. + // + Private->InformationExchange =3D InformationExchange; + + // + // Find Redfish version on BMC + // + Private->RedfishVersion =3D RedfishGetVersion (RedfishService); + + // + // Create the full URI from Redfish service root. + // + ResourceUri =3D (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof(CH= AR16)); + if (ResourceUri =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for full URI.\n", __= FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion); + StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange->SendInformati= on.FullUri); + + // + // Initialize collection path + // + Private->CollectionUri =3D RedfishGetUri (ResourceUri); + if (Private->CollectionUri =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + Status =3D CollectionHandler (Private); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, CollectionHandler failure: %r\n", __FUNCTION= __, Status)); @@ -549,7 +564,7 @@ RedfishCollectionUnload ( ) { EFI_STATUS Status; - EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; + EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; =20 if (mRedfishCollectionPrivate =3D=3D NULL) { return EFI_NOT_READY; diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.h b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryC= ollectionDxe.h similarity index 64% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.h rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .h index 83ca836941..75b4a123ff 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.h +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.h @@ -1,7 +1,8 @@ /** @file + Redfish feature driver implementation - internal header file =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -14,5 +15,7 @@ #include =20 #define REDFISH_SCHEMA_NAME "Memory" -#define REDFISH_MANAGED_URI L"/redfish/v1/systems/{1}/memory" +#define REDFISH_MANAGED_URI L"Chassis/{}/Memory/{};Systems/{}/= Memory/{}" +#define MAX_URI_LENGTH 256 + #endif diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.inf b/RedfishClientPkg/Features/MemoryCollectionDxe/Memor= yCollectionDxe.inf similarity index 71% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.inf rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .inf index e7bcf49bdb..05e05712e7 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.inf +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf @@ -1,15 +1,18 @@ ## @file # -# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+# Redfish MemoryCollection collection driver. +# +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ## =20 + [Defines] INF_VERSION =3D 0x00010005 - BASE_NAME =3D RedfishMemoryCollectionDxe - FILE_GUID =3D 9323359C-11E2-49BC-B501-D6280B6DAE1A + BASE_NAME =3D MemoryCollectionDxe + FILE_GUID =3D 22facf8f-a007-462c-9be4-638043a26858 MODULE_TYPE =3D DXE_DRIVER VERSION_STRING =3D 1.0 ENTRY_POINT =3D RedfishCollectionEntryPoint @@ -22,8 +25,8 @@ RedfishClientPkg/RedfishClientPkg.dec =20 [Sources] - RedfishMemoryCollectionDxe.h - RedfishMemoryCollectionDxe.c + MemoryCollectionDxe.h + MemoryCollectionDxe.c =20 [LibraryClasses] DebugLib @@ -35,19 +38,19 @@ UefiLib UefiDriverEntryPoint UefiBootServicesTableLib + EdkIIRedfishResourceConfigLib + RedfishVersionLib =20 [Protocols] gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMED gEfiRestJsonStructureProtocolGuid ## CONSUMED - gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMED gEdkIIRedfishFeatureProtocolGuid ## CONSUMED =20 [Guids] - gEfiEventReadyToBootGuid =20 [Pcd] gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize =20 [Depex] - TRUE \ No newline at end of file + TRUE diff --git a/RedfishClientPkg/Include/RedfishCollectionCommon.h b/RedfishCl= ientPkg/Include/RedfishCollectionCommon.h index 05a0f672f3..d4adcedd1f 100644 --- a/RedfishClientPkg/Include/RedfishCollectionCommon.h +++ b/RedfishClientPkg/Include/RedfishCollectionCommon.h @@ -1,7 +1,7 @@ /** @file Redfish feature driver collection common header file. =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -10,6 +10,8 @@ #ifndef EFI_REDFISH_COLLECTION_COMMON_H_ #define EFI_REDFISH_COLLECTION_COMMON_H_ =20 +#include + // // Libraries // @@ -22,28 +24,30 @@ #include #include #include +#include +#include =20 // // Protocols // #include -#include #include #include #include =20 -#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D = '\0') -#define REDFISH_DEBUG_TRACE DEBUG_INFO +#define REDFISH_MAX_COLLECTION_INDEX_LEN 8 =20 typedef struct _REDFISH_COLLECTION_PRIVATE { EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol; EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol; REDFISH_SERVICE RedfishService; + RESOURCE_INFORMATION_EXCHANGE *InformationExchange; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL ConfigHandler; - CHAR8 *CollectionPath; + EFI_STRING CollectionUri; CHAR8 *CollectionJson; REDFISH_PAYLOAD CollectionPayload; REDFISH_RESPONSE RedResponse; + EFI_STRING RedfishVersion; } REDFISH_COLLECTION_PRIVATE; =20 #define REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL(This) \ diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 6292de4e81..3619d2a20f 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -15,7 +15,7 @@ INF RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf INF RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf - INF RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCo= llectionDxe.inf + INF RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc # diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index ee4602fe79..5f1aff3c4b 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -20,7 +20,7 @@ # Below two modules should be pulled in by build tool. # RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf - RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCollec= tionDxe.inf + RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc =20 --=20 2.32.0.windows.2 -=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 (#91878): https://edk2.groups.io/g/devel/message/91878 Mute This Topic: https://groups.io/mt/92641652/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- From nobody Fri Apr 26 08:47:54 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+91880+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+91880+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885908; cv=none; d=zohomail.com; s=zohoarc; b=FSyKWZHMzvKrR9wd/lceSyJcKCM1FahPeFTAdvwAVLWJcVTTCz6UzbAnYz4Rhw+EJyLgmxkxQMav6sS/uiywccMJuVT3siLjzgA+r1FmqR/qVGG/HKO98RqJQIS05q1VTjCn6Tr4mwlUdlb8rrLhV1Jq0BJVQjN3p3f3bR/yFQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885908; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qWaRbOyribOyTPls0/sTaxfsJ/PJdKFt+Pc2bJM5D0k=; b=A9RZuAgpJLH7zcf6trhWFDWgOT8OVSEx4eBfVLGfTrgbpp1DRXkIxyRgI1c/Q1XnyFG/jgkXG2gH5dLhJL4xh3lXNBKlvAOm6tcjrLvQNoE9qggNBlq9+WY1+4tjFMnfjTqfm9wkltSsTVMx8oNLpcugThw/o8su9ECj8sMIbIk= 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+91880+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 1658885908170515.4277871335034; Tue, 26 Jul 2022 18:38:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XSEwYY1788612xQJvfIlffg6; Tue, 26 Jul 2022 18:38:27 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web08.15038.1658885906952750972 for ; Tue, 26 Jul 2022 18:38:27 -0700 X-Received: from pps.filterd (m0150241.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0rCdf009998; Wed, 27 Jul 2022 01:38:25 GMT X-Received: from p1lg14881.it.hpe.com (p1lg14881.it.hpe.com [16.230.97.202]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3hjqes1n30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:24 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id 27B1B804C83; Wed, 27 Jul 2022 01:38:24 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id C65928052CC; Wed, 27 Jul 2022 01:38:22 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 12/15] edk2-staging/RedfishClientPkg: Rename Memory feature driver Date: Wed, 27 Jul 2022 09:37:59 +0800 Message-Id: <20220727013802.247-13-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> X-Proofpoint-GUID: GqcrwJ28E9NKyvVH1Pd6oyhoSdRbJzee X-Proofpoint-ORIG-GUID: GqcrwJ28E9NKyvVH1Pd6oyhoSdRbJzee X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 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,nickle.wang@hpe.com X-Gm-Message-State: mgUqX3g8dFbItefLAJc9SAVDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885907; bh=XaorIK59cUqK5lb/l6LrIRMXw1KKiyXjXR69AutXQqY=; h=Cc:Date:From:Reply-To:Subject:To; b=N+cqL3M3Efi8xoLHEa1TsglFo07/1BN4KsXj0w8XcbAQeIxBzmbBaWzx69VpVwzPbHU RtvfM7C3xkLtV8lfpjL000E7py0I0u9mgMwIRjwbk4TsULVMtrYXXz/mH3SCmDHF5sut3 9z/LZElU0d9h21ynlBexa+ScNFWCWm8xkUM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885909178100014 Content-Type: text/plain; charset="utf-8" Rename Memory driver by removing Redfish prefix. Update memory feature driver and support all properties under Memory schema. Also support "Identify" action in this driver. Corresponding changes are made to honor newly introduced library and protocol. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../{RedfishMemoryCommon.c =3D> MemoryCommon.c} | 1194 ++++++++++------- .../{RedfishMemoryCommon.h =3D> MemoryCommon.h} | 2 +- .../Dxe/{RedfishMemoryDxe.c =3D> MemoryDxe.c} | 138 +- .../{RedfishMemoryDxe.inf =3D> MemoryDxe.inf} | 21 +- .../Include/RedfishResourceCommon.h | 38 +- RedfishClientPkg/RedfishClient.fdf.inc | 2 +- .../RedfishClientComponents.dsc.inc | 2 +- 7 files changed, 839 insertions(+), 558 deletions(-) rename RedfishClientPkg/Features/Memory/V1_7_1/Common/{RedfishMemoryCommon= .c =3D> MemoryCommon.c} (64%) rename RedfishClientPkg/Features/Memory/V1_7_1/Common/{RedfishMemoryCommon= .h =3D> MemoryCommon.h} (89%) rename RedfishClientPkg/Features/Memory/V1_7_1/Dxe/{RedfishMemoryDxe.c =3D= > MemoryDxe.c} (75%) rename RedfishClientPkg/Features/Memory/V1_7_1/Dxe/{RedfishMemoryDxe.inf = =3D> MemoryDxe.inf} (57%) diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCo= mmon.c b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c similarity index 64% rename from RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCom= mon.c rename to RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c index 11f738f71c..745c5f9847 100644 --- a/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCommon.c +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c @@ -1,45 +1,54 @@ /** @file Redfish feature driver implementation - common functions =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include "RedfishMemoryCommon.h" +#include "MemoryCommon.h" =20 CHAR8 MemoryEmptyJson[] =3D "{\"@odata.id\": \"\", \"@odata.type\": \"#Mem= ory.v1_7_1.Memory\", \"Id\": \"\", \"Name\": \"\"}"; =20 REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate =3D NULL; =20 +/** + Consume resource from given URI. + + @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV= ATE instance. + @param[in] Json The JSON to consume. + @param[in] HeaderEtag The Etag string returned in HTTP header. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ EFI_STATUS RedfishConsumeResourceCommon ( IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, - IN CHAR8 *MemoryJson + IN CHAR8 *Json, + IN CHAR8 *HeaderEtag OPTIONAL ) { - EFI_STATUS Status; + 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; + EFI_STRING ConfigureLang; + =20 - if (Private =3D=3D NULL || IS_EMPTY_STRING (MemoryJson)) { + if (Private =3D=3D NULL || IS_EMPTY_STRING (Json)) { return EFI_INVALID_PARAMETER; } =20 - Memory=3D NULL; + Memory =3D NULL; MemoryCs =3D NULL; ConfigureLang =3D NULL; - Arraykey =3D NULL; - EtagInDb =3D NULL; =20 Status =3D Private->JsonStructProtocol->ToStructure ( Private->JsonStructProtocol, NULL, - MemoryJson, + Json, (EFI_REST_JSON_STRUCTURE_HEADER = **)&Memory ); if (EFI_ERROR (Status)) { @@ -52,24 +61,13 @@ RedfishConsumeResourceCommon ( // // 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; + if (CheckEtag (Private->Uri, HeaderEtag, MemoryCs->odata_etag)) { + // + // No change + // + DEBUG ((DEBUG_INFO, "%a, ETAG: %s has no change, ignore consume action= \n", __FUNCTION__, Private->Uri)); + Status =3D EFI_ALREADY_STARTED; + goto ON_RELEASE; } =20 // @@ -77,9 +75,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->AllocationAlignmentMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "AllocationAlignmentMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "AllocationAli= gnmentMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->AllocationAlignmentMiB); if (EFI_ERROR (Status)) { @@ -88,7 +86,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -97,9 +95,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->AllocationIncrementMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "AllocationIncrementMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "AllocationInc= rementMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->AllocationIncrementMiB); if (EFI_ERROR (Status)) { @@ -108,18 +106,42 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle ALLOWEDSPEEDSMHZ + // + if (MemoryCs->AllowedSpeedsMHz !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "AllowedSpeeds= MHz"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericArrayType (RESOURCE_SCHEMA, RE= SOURCE_SCHEMA_VERSION, ConfigureLang, MemoryCs->AllowedSpeedsMHz); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 + // + // ASSEMBLY will be handled by feature driver. + // + // // Handle BASEMODULETYPE // if (MemoryCs->BaseModuleType !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "BaseModuleType", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "BaseModuleTyp= e"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->BaseModuleType); if (EFI_ERROR (Status)) { @@ -128,7 +150,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -137,9 +159,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->BusWidthBits !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "BusWidthBits", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "BusWidthBits"= ); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->BusWidthBits); if (EFI_ERROR (Status)) { @@ -148,7 +170,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -157,9 +179,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->CacheSizeMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "CacheSizeMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "CacheSizeMiB"= ); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->CacheSizeMiB); if (EFI_ERROR (Status)) { @@ -168,7 +190,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -177,9 +199,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->CapacityMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "CapacityMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "CapacityMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->CapacityMiB); if (EFI_ERROR (Status)) { @@ -188,7 +210,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -197,9 +219,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->ConfigurationLocked !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ConfigurationLocked", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "Configuration= Locked"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->ConfigurationLocked); if (EFI_ERROR (Status)) { @@ -208,7 +230,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -217,9 +239,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->DataWidthBits !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "DataWidthBits", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "DataWidthBits= "); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->DataWidthBits); if (EFI_ERROR (Status)) { @@ -228,7 +250,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -237,9 +259,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->DeviceID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "DeviceID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "DeviceID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->DeviceID); if (EFI_ERROR (Status)) { @@ -248,7 +270,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -257,9 +279,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->DeviceLocator !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "DeviceLocator", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "DeviceLocator= "); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->DeviceLocator); if (EFI_ERROR (Status)) { @@ -268,7 +290,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -277,9 +299,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->ErrorCorrection !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ErrorCorrection", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "ErrorCorrecti= on"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->ErrorCorrection); if (EFI_ERROR (Status)) { @@ -288,7 +310,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -297,9 +319,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->FirmwareApiVersion !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "FirmwareApiVersion", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "FirmwareApiVe= rsion"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->FirmwareApiVersion); if (EFI_ERROR (Status)) { @@ -308,7 +330,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -317,9 +339,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->FirmwareRevision !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "FirmwareRevision", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "FirmwareRevis= ion"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->FirmwareRevision); if (EFI_ERROR (Status)) { @@ -328,7 +350,27 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle FUNCTIONCLASSES + // + if (MemoryCs->FunctionClasses !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "FunctionClass= es"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringArrayType (RESOURCE_SCHEMA, RES= OURCE_SCHEMA_VERSION, ConfigureLang, MemoryCs->FunctionClasses); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -337,9 +379,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->IsRankSpareEnabled !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "IsRankSpareEnabled", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "IsRankSpareEn= abled"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->IsRankSpareEnabled); if (EFI_ERROR (Status)) { @@ -348,7 +390,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -357,9 +399,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->IsSpareDeviceEnabled !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "IsSpareDeviceEnabled", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "IsSpareDevice= Enabled"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->IsSpareDeviceEnabled); if (EFI_ERROR (Status)) { @@ -368,18 +410,22 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 + // + // LOCATION is not handled. Defined in http://redfish.dmtf.org/schemas/v= 1/Resource.json + // + // // Handle LOGICALSIZEMIB // if (MemoryCs->LogicalSizeMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "LogicalSizeMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "LogicalSizeMi= B"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->LogicalSizeMiB); if (EFI_ERROR (Status)) { @@ -388,7 +434,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -397,9 +443,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->Manufacturer !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "Manufacturer", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "Manufacturer"= ); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->Manufacturer); if (EFI_ERROR (Status)) { @@ -408,7 +454,27 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle MAXTDPMILLIWATTS + // + if (MemoryCs->MaxTDPMilliWatts !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MaxTDPMilliWa= tts"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericArrayType (RESOURCE_SCHEMA, RE= SOURCE_SCHEMA_VERSION, ConfigureLang, MemoryCs->MaxTDPMilliWatts); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -417,9 +483,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->MemoryDeviceType !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryDeviceType", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemoryDeviceT= ype"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemoryDeviceType); if (EFI_ERROR (Status)) { @@ -428,14 +494,14 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 // // Handle MEMORYLOCATION // - if(MemoryCs->MemoryLocation =3D=3D NULL) { + if (MemoryCs->MemoryLocation =3D=3D NULL) { MemoryCs->MemoryLocation =3D AllocateZeroPool (sizeof (RedfishMemory_V= 1_7_1_MemoryLocation_CS)); ASSERT (MemoryCs->MemoryLocation !=3D NULL); } @@ -445,9 +511,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->MemoryLocation->Channel !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/Channel", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemoryLocatio= n/Channel"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->Channel); if (EFI_ERROR (Status)) { @@ -456,7 +522,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -465,9 +531,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->MemoryLocation->MemoryController !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/MemoryController", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemoryLocatio= n/MemoryController"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->MemoryCo= ntroller); if (EFI_ERROR (Status)) { @@ -476,7 +542,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -485,9 +551,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->MemoryLocation->Slot !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/Slot", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemoryLocatio= n/Slot"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->Slot); if (EFI_ERROR (Status)) { @@ -496,7 +562,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -505,9 +571,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->MemoryLocation->Socket !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryLocation/Socket", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemoryLocatio= n/Socket"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->MemoryLocation->Socket); if (EFI_ERROR (Status)) { @@ -516,18 +582,26 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 + // + // Handle MEMORYMEDIA + // +// +// ****** Warning ****** +// Unsupported array type: +// + // // Handle MEMORYSUBSYSTEMCONTROLLERMANUFACTURERID // if (MemoryCs->MemorySubsystemControllerManufacturerID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemorySubsystemControllerManufacturerID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemorySubsyst= emControllerManufacturerID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemorySubsystemControllerManufact= urerID); if (EFI_ERROR (Status)) { @@ -536,7 +610,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -545,9 +619,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->MemorySubsystemControllerProductID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemorySubsystemControllerProductID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemorySubsyst= emControllerProductID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemorySubsystemControllerProductI= D); if (EFI_ERROR (Status)) { @@ -556,7 +630,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -565,9 +639,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->MemoryType !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "MemoryType", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "MemoryType"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->MemoryType); if (EFI_ERROR (Status)) { @@ -576,18 +650,22 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 + // + // METRICS will be handled by feature driver. + // + // // Handle MODULEMANUFACTURERID // if (MemoryCs->ModuleManufacturerID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ModuleManufacturerID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "ModuleManufac= turerID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->ModuleManufacturerID); if (EFI_ERROR (Status)) { @@ -596,7 +674,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -605,9 +683,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->ModuleProductID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "ModuleProductID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "ModuleProduct= ID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->ModuleProductID); if (EFI_ERROR (Status)) { @@ -616,7 +694,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -625,9 +703,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->NonVolatileSizeMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "NonVolatileSizeMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "NonVolatileSi= zeMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->NonVolatileSizeMiB); if (EFI_ERROR (Status)) { @@ -636,18 +714,26 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 + // + // Handle OPERATINGMEMORYMODES + // +// +// ****** Warning ****** +// Unsupported array type: +// + // // Handle OPERATINGSPEEDMHZ // if (MemoryCs->OperatingSpeedMhz !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "OperatingSpeedMhz", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "OperatingSpee= dMhz"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->OperatingSpeedMhz); if (EFI_ERROR (Status)) { @@ -656,7 +742,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -665,9 +751,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PartNumber !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PartNumber", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PartNumber"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->PartNumber); if (EFI_ERROR (Status)) { @@ -676,7 +762,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -685,9 +771,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PersistentRegionNumberLimit !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PersistentRegionNumberLimit", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PersistentReg= ionNumberLimit"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PersistentRegionNumberLi= mit); if (EFI_ERROR (Status)) { @@ -696,7 +782,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -705,9 +791,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PersistentRegionSizeLimitMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PersistentRegionSizeLimitMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PersistentReg= ionSizeLimitMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PersistentRegionSizeLimi= tMiB); if (EFI_ERROR (Status)) { @@ -716,7 +802,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -725,9 +811,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PersistentRegionSizeMaxMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PersistentRegionSizeMaxMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PersistentReg= ionSizeMaxMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PersistentRegionSizeMaxM= iB); if (EFI_ERROR (Status)) { @@ -736,14 +822,14 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 // // Handle POWERMANAGEMENTPOLICY // - if(MemoryCs->PowerManagementPolicy =3D=3D NULL) { + if (MemoryCs->PowerManagementPolicy =3D=3D NULL) { MemoryCs->PowerManagementPolicy =3D AllocateZeroPool (sizeof (RedfishM= emory_V1_7_1_PowerManagementPolicy_CS)); ASSERT (MemoryCs->PowerManagementPolicy !=3D NULL); } @@ -753,9 +839,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PowerManagementPolicy->AveragePowerBudgetMilliWatts !=3D N= ULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/AveragePowerBudgetMilliWatts", Arraykey= ); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PowerManageme= ntPolicy/AveragePowerBudgetMilliWatts"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PowerManagementPolicy->A= veragePowerBudgetMilliWatts); if (EFI_ERROR (Status)) { @@ -764,7 +850,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -773,9 +859,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PowerManagementPolicy->MaxTDPMilliWatts !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/MaxTDPMilliWatts", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PowerManageme= ntPolicy/MaxTDPMilliWatts"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PowerManagementPolicy->M= axTDPMilliWatts); if (EFI_ERROR (Status)) { @@ -784,7 +870,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -793,9 +879,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PowerManagementPolicy->PeakPowerBudgetMilliWatts !=3D NULL= ) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/PeakPowerBudgetMilliWatts", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PowerManageme= ntPolicy/PeakPowerBudgetMilliWatts"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->PowerManagementPolicy->P= eakPowerBudgetMilliWatts); if (EFI_ERROR (Status)) { @@ -804,7 +890,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -813,9 +899,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->PowerManagementPolicy->PolicyEnabled !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "PowerManagementPolicy/PolicyEnabled", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "PowerManageme= ntPolicy/PolicyEnabled"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->PowerManagementPolicy-= >PolicyEnabled); if (EFI_ERROR (Status)) { @@ -824,7 +910,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -833,9 +919,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->RankCount !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "RankCount", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "RankCount"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->RankCount); if (EFI_ERROR (Status)) { @@ -844,14 +930,22 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 + // + // Handle REGIONS + // +// +// ****** Warning ****** +// Unsupported array type: +// + // // Handle SECURITYCAPABILITIES // - if(MemoryCs->SecurityCapabilities =3D=3D NULL) { + if (MemoryCs->SecurityCapabilities =3D=3D NULL) { MemoryCs->SecurityCapabilities =3D AllocateZeroPool (sizeof (RedfishMe= mory_V1_7_1_SecurityCapabilities_CS)); ASSERT (MemoryCs->SecurityCapabilities !=3D NULL); } @@ -861,9 +955,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SecurityCapabilities->ConfigurationLockCapable !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/ConfigurationLockCapable", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SecurityCapab= ilities/ConfigurationLockCapable"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->SecurityCapabilities->= ConfigurationLockCapable); if (EFI_ERROR (Status)) { @@ -872,7 +966,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -881,9 +975,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SecurityCapabilities->DataLockCapable !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/DataLockCapable", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SecurityCapab= ilities/DataLockCapable"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->SecurityCapabilities->= DataLockCapable); if (EFI_ERROR (Status)) { @@ -892,7 +986,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -901,9 +995,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SecurityCapabilities->MaxPassphraseCount !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/MaxPassphraseCount", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SecurityCapab= ilities/MaxPassphraseCount"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->SecurityCapabilities->Ma= xPassphraseCount); if (EFI_ERROR (Status)) { @@ -912,7 +1006,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -921,9 +1015,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SecurityCapabilities->PassphraseCapable !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/PassphraseCapable", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SecurityCapab= ilities/PassphraseCapable"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*MemoryCs->SecurityCapabilities->= PassphraseCapable); if (EFI_ERROR (Status)) { @@ -932,7 +1026,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -941,9 +1035,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SecurityCapabilities->PassphraseLockLimit !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityCapabilities/PassphraseLockLimit", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SecurityCapab= ilities/PassphraseLockLimit"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->SecurityCapabilities->Pa= ssphraseLockLimit); if (EFI_ERROR (Status)) { @@ -952,18 +1046,26 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 + // + // Handle SECURITYCAPABILITIES->SECURITYSTATES + // +// +// ****** Warning ****** +// Unsupported array type: +// + // // Handle SECURITYSTATE // if (MemoryCs->SecurityState !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SecurityState", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SecurityState= "); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SecurityState); if (EFI_ERROR (Status)) { @@ -972,7 +1074,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -981,9 +1083,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SerialNumber !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SerialNumber", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SerialNumber"= ); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SerialNumber); if (EFI_ERROR (Status)) { @@ -992,7 +1094,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1001,9 +1103,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SpareDeviceCount !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SpareDeviceCount", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SpareDeviceCo= unt"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->SpareDeviceCount); if (EFI_ERROR (Status)) { @@ -1012,7 +1114,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1021,9 +1123,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SubsystemDeviceID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SubsystemDeviceID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SubsystemDevi= ceID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SubsystemDeviceID); if (EFI_ERROR (Status)) { @@ -1032,7 +1134,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1041,9 +1143,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->SubsystemVendorID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "SubsystemVendorID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "SubsystemVend= orID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->SubsystemVendorID); if (EFI_ERROR (Status)) { @@ -1052,7 +1154,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1061,9 +1163,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->VendorID !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VendorID", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "VendorID"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, MemoryCs->VendorID); if (EFI_ERROR (Status)) { @@ -1072,7 +1174,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1081,9 +1183,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->VolatileRegionNumberLimit !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileRegionNumberLimit", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "VolatileRegio= nNumberLimit"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileRegionNumberLimi= t); if (EFI_ERROR (Status)) { @@ -1092,7 +1194,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1101,9 +1203,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->VolatileRegionSizeLimitMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileRegionSizeLimitMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "VolatileRegio= nSizeLimitMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileRegionSizeLimitM= iB); if (EFI_ERROR (Status)) { @@ -1112,7 +1214,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1121,9 +1223,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->VolatileRegionSizeMaxMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileRegionSizeMaxMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "VolatileRegio= nSizeMaxMiB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileRegionSizeMaxMiB= ); if (EFI_ERROR (Status)) { @@ -1132,7 +1234,7 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 @@ -1141,9 +1243,9 @@ RedfishConsumeResourceCommon ( // if (MemoryCs->VolatileSizeMiB !=3D NULL) { // - // Find corresponding redpath for collection resource. + // Find corresponding configure language for collection resource. // - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCH= EMA_VERSION, "VolatileSizeMiB", Arraykey); + ConfigureLang =3D GetConfigureLang (MemoryCs->odata_id, "VolatileSizeM= iB"); if (ConfigureLang !=3D NULL) { Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*MemoryCs->VolatileSizeMiB); if (EFI_ERROR (Status)) { @@ -1152,26 +1254,16 @@ RedfishConsumeResourceCommon ( =20 FreePool (ConfigureLang); } else { - DEBUG ((DEBUG_ERROR, "%a, can not get configure language for key: %a= \n", __FUNCTION__, Arraykey)); + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); } } =20 =20 - - // ON_RELEASE: =20 // // 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 @@ -1183,7 +1275,7 @@ ON_RELEASE: EFI_STATUS ProvisioningMemoryProperties ( IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, - IN CHAR8 *IputJson, + IN CHAR8 *InputJson, IN CHAR8 *ResourceId, OPTIONAL IN EFI_STRING ConfigureLang, IN BOOLEAN ProvisionMode, @@ -1193,28 +1285,31 @@ ProvisioningMemoryProperties ( EFI_REDFISH_MEMORY_V1_7_1 *Memory; EFI_REDFISH_MEMORY_V1_7_1_CS *MemoryCs; EFI_STATUS Status; + BOOLEAN PropertyChanged; INT64 *NumericValue; - INT32 *IntegerValue; - BOOLEAN *BooleanValue; + INT64 *NumericArrayValue; + UINTN ArraySize; CHAR8 *AsciiStringValue; - BOOLEAN PropertyChanged; - BOOLEAN UnusedProperty; + BOOLEAN *BooleanValue; + INT32 *IntegerValue; + CHAR8 **AsciiStringArrayValue; + =20 - if (JsonStructProtocol =3D=3D NULL || ResultJson =3D=3D NULL || IS_EMPTY= _STRING (IputJson) || IS_EMPTY_STRING (ConfigureLang)) { + + if (JsonStructProtocol =3D=3D NULL || ResultJson =3D=3D NULL || IS_EMPTY= _STRING (InputJson) || IS_EMPTY_STRING (ConfigureLang)) { return EFI_INVALID_PARAMETER; } =20 - DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s with: %s\n", __FUNCTIO= N__, ConfigureLang, (ProvisionMode ? L"Provision all resource" : L"Provisio= n existing resource"))); + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s with: %s\n", __FUNCTIO= N__, ConfigureLang, (ProvisionMode ? L"Provision resource" : L"Update resou= rce"))); =20 *ResultJson =3D NULL; PropertyChanged =3D FALSE; - UnusedProperty =3D TRUE; =20 Memory =3D NULL; Status =3D JsonStructProtocol->ToStructure ( JsonStructProtocol, NULL, - IputJson, + InputJson, (EFI_REST_JSON_STRUCTURE_HEADER **)&Memory ); if (EFI_ERROR (Status)) { @@ -1243,7 +1338,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle ALLOCATIONINCREMENTMIB // @@ -1256,7 +1350,18 @@ ProvisioningMemoryProperties ( } } } - + // + // Handle ALLOWEDSPEEDSMHZ + // + if (PropertyChecker (MemoryCs->AllowedSpeedsMHz, ProvisionMode)) { + NumericArrayValue =3D GetPropertyNumericArrayValue (RESOURCE_SCHEMA, R= ESOURCE_SCHEMA_VERSION, L"AllowedSpeedsMHz", ConfigureLang, &ArraySize); + if (NumericArrayValue !=3D NULL) { + if (ProvisionMode || !CompareRedfishNumericArrayValues (MemoryCs->Al= lowedSpeedsMHz, NumericArrayValue, ArraySize)) { + AddRedfishNumericArray (&MemoryCs->AllowedSpeedsMHz, NumericArrayV= alue, ArraySize); + PropertyChanged =3D TRUE; + } + } + } // // Handle BASEMODULETYPE // @@ -1269,7 +1374,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle BUSWIDTHBITS // @@ -1282,7 +1386,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle CACHESIZEMIB // @@ -1295,7 +1398,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle CAPACITYMIB // @@ -1308,7 +1410,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle CONFIGURATIONLOCKED // @@ -1320,11 +1421,11 @@ ProvisioningMemoryProperties ( if (IntegerValue !=3D NULL) { *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); MemoryCs->ConfigurationLocked =3D IntegerValue; + PropertyChanged =3D TRUE; } } } } - // // Handle DATAWIDTHBITS // @@ -1337,7 +1438,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle DEVICEID // @@ -1350,7 +1450,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle DEVICELOCATOR // @@ -1363,7 +1462,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle ERRORCORRECTION // @@ -1376,7 +1474,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle FIRMWAREAPIVERSION // @@ -1389,7 +1486,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle FIRMWAREREVISION // @@ -1402,7 +1498,18 @@ ProvisioningMemoryProperties ( } } } - + // + // Handle FUNCTIONCLASSES + // + if (PropertyChecker (MemoryCs->FunctionClasses, ProvisionMode)) { + AsciiStringArrayValue =3D GetPropertyStringArrayValue (RESOURCE_SCHEMA= , RESOURCE_SCHEMA_VERSION, L"FunctionClasses", ConfigureLang, &ArraySize); + if (AsciiStringArrayValue !=3D NULL) { + if (ProvisionMode || !CompareRedfishStringArrayValues (MemoryCs->Fun= ctionClasses, AsciiStringArrayValue, ArraySize)) { + AddRedfishCharArray (&MemoryCs->FunctionClasses, AsciiStringArrayV= alue, ArraySize); + PropertyChanged =3D TRUE; + } + } + } // // Handle ISRANKSPAREENABLED // @@ -1414,11 +1521,11 @@ ProvisioningMemoryProperties ( if (IntegerValue !=3D NULL) { *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); MemoryCs->IsRankSpareEnabled =3D IntegerValue; + PropertyChanged =3D TRUE; } } } } - // // Handle ISSPAREDEVICEENABLED // @@ -1430,11 +1537,11 @@ ProvisioningMemoryProperties ( if (IntegerValue !=3D NULL) { *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); MemoryCs->IsSpareDeviceEnabled =3D IntegerValue; + PropertyChanged =3D TRUE; } } } } - // // Handle LOGICALSIZEMIB // @@ -1447,7 +1554,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle MANUFACTURER // @@ -1460,7 +1566,18 @@ ProvisioningMemoryProperties ( } } } - + // + // Handle MAXTDPMILLIWATTS + // + if (PropertyChecker (MemoryCs->MaxTDPMilliWatts, ProvisionMode)) { + NumericArrayValue =3D GetPropertyNumericArrayValue (RESOURCE_SCHEMA, R= ESOURCE_SCHEMA_VERSION, L"MaxTDPMilliWatts", ConfigureLang, &ArraySize); + if (NumericArrayValue !=3D NULL) { + if (ProvisionMode || !CompareRedfishNumericArrayValues (MemoryCs->Ma= xTDPMilliWatts, NumericArrayValue, ArraySize)) { + AddRedfishNumericArray (&MemoryCs->MaxTDPMilliWatts, NumericArrayV= alue, ArraySize); + PropertyChanged =3D TRUE; + } + } + } // // Handle MEMORYDEVICETYPE // @@ -1473,78 +1590,66 @@ ProvisioningMemoryProperties ( } } } - // // 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; + if (MemoryCs->MemoryLocation !=3D NULL) { + // + // Handle MEMORYLOCATION->CHANNEL + // + if (PropertyChecker (MemoryCs->MemoryLocation->Channel, ProvisionMode)= ) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"MemoryLocation/Channel", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->Channel !=3D *Nume= ricValue) { + MemoryCs->MemoryLocation->Channel =3D NumericValue; + PropertyChanged =3D TRUE; + } } } - } - - // - // 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->MEMORYCONTROLLER + // + if (PropertyChecker (MemoryCs->MemoryLocation->MemoryController, Provi= sionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"MemoryLocation/MemoryController", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->MemoryController != =3D *NumericValue) { + MemoryCs->MemoryLocation->MemoryController =3D NumericValue; + PropertyChanged =3D TRUE; + } } } - } - - // - // 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->SLOT + // + if (PropertyChecker (MemoryCs->MemoryLocation->Slot, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"MemoryLocation/Slot", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->Slot !=3D *Numeric= Value) { + MemoryCs->MemoryLocation->Slot =3D NumericValue; + PropertyChanged =3D TRUE; + } } } - } - - // - // 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; + // + // Handle MEMORYLOCATION->SOCKET + // + if (PropertyChecker (MemoryCs->MemoryLocation->Socket, ProvisionMode))= { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"MemoryLocation/Socket", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->MemoryLocation->Socket !=3D *Numer= icValue) { + MemoryCs->MemoryLocation->Socket =3D NumericValue; + PropertyChanged =3D TRUE; + } } } } =20 - if (UnusedProperty) { - FreePool (MemoryCs->MemoryLocation); - MemoryCs->MemoryLocation =3D NULL; - } + // + // Handle MEMORYMEDIA + // +//// ****** Warning ****** +// Unsupported array type: +// =20 // // Handle MEMORYSUBSYSTEMCONTROLLERMANUFACTURERID @@ -1558,7 +1663,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle MEMORYSUBSYSTEMCONTROLLERPRODUCTID // @@ -1571,7 +1675,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle MEMORYTYPE // @@ -1584,7 +1687,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle MODULEMANUFACTURERID // @@ -1597,7 +1699,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle MODULEPRODUCTID // @@ -1610,7 +1711,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle NONVOLATILESIZEMIB // @@ -1623,6 +1723,12 @@ ProvisioningMemoryProperties ( } } } + // + // Handle OPERATINGMEMORYMODES + // +//// ****** Warning ****** +// Unsupported array type: +// =20 // // Handle OPERATINGSPEEDMHZ @@ -1636,7 +1742,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle PARTNUMBER // @@ -1649,7 +1754,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle PERSISTENTREGIONNUMBERLIMIT // @@ -1662,7 +1766,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle PERSISTENTREGIONSIZELIMITMIB // @@ -1675,7 +1778,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle PERSISTENTREGIONSIZEMAXMIB // @@ -1688,83 +1790,64 @@ ProvisioningMemoryProperties ( } } } - // // 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; + if (MemoryCs->PowerManagementPolicy !=3D NULL) { + // + // Handle POWERMANAGEMENTPOLICY->AVERAGEPOWERBUDGETMILLIWATTS + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->AveragePowerBudg= etMilliWatts, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"PowerManagementPolicy/AveragePowerBudgetMilliWatts", Conf= igureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->AveragePowe= rBudgetMilliWatts !=3D *NumericValue) { + MemoryCs->PowerManagementPolicy->AveragePowerBudgetMilliWatts = =3D NumericValue; + PropertyChanged =3D TRUE; + } } } - } - - // - // 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->MAXTDPMILLIWATTS + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->MaxTDPMilliWatts= , ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"PowerManagementPolicy/MaxTDPMilliWatts", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->MaxTDPMilli= Watts !=3D *NumericValue) { + MemoryCs->PowerManagementPolicy->MaxTDPMilliWatts =3D NumericVal= ue; + PropertyChanged =3D TRUE; + } } } - } - - // - // 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->PEAKPOWERBUDGETMILLIWATTS + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->PeakPowerBudgetM= illiWatts, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"PowerManagementPolicy/PeakPowerBudgetMilliWatts", Configu= reLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->PeakPowerBu= dgetMilliWatts !=3D *NumericValue) { + MemoryCs->PowerManagementPolicy->PeakPowerBudgetMilliWatts =3D N= umericValue; + PropertyChanged =3D TRUE; + } } } - } - - // - // 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; + // + // Handle POWERMANAGEMENTPOLICY->POLICYENABLED + // + if (PropertyChecker (MemoryCs->PowerManagementPolicy->PolicyEnabled, P= rovisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"PowerManagementPolicy/PolicyEnabled", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->PowerManagementPolicy->PolicyEnabl= ed !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->PowerManagementPolicy->PolicyEnabled =3D IntegerValu= e; + PropertyChanged =3D TRUE; + } } } } } =20 - if (UnusedProperty) { - FreePool (MemoryCs->PowerManagementPolicy); - MemoryCs->PowerManagementPolicy =3D NULL; - } - // // Handle RANKCOUNT // @@ -1777,103 +1860,96 @@ ProvisioningMemoryProperties ( } } } - // - // Handle SECURITYCAPABILITIES + // Handle REGIONS // - 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; - } +//// ****** Warning ****** +// Unsupported array type: +// =20 // - // Handle SECURITYCAPABILITIES->CONFIGURATIONLOCKCAPABLE + // Handle SECURITYCAPABILITIES // - 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; + if (MemoryCs->SecurityCapabilities !=3D NULL) { + // + // Handle SECURITYCAPABILITIES->CONFIGURATIONLOCKCAPABLE + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->ConfigurationLock= Capable, ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"SecurityCapabilities/ConfigurationLockCapable", Configure= Lang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->Configuratio= nLockCapable !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->SecurityCapabilities->ConfigurationLockCapable =3D I= ntegerValue; + PropertyChanged =3D TRUE; + } } } } - } - - // - // 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; + // + // Handle SECURITYCAPABILITIES->DATALOCKCAPABLE + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->DataLockCapable, = ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"SecurityCapabilities/DataLockCapable", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->DataLockCapa= ble !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->SecurityCapabilities->DataLockCapable =3D IntegerVal= ue; + PropertyChanged =3D TRUE; + } + } + } + } + // + // Handle SECURITYCAPABILITIES->MAXPASSPHRASECOUNT + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->MaxPassphraseCoun= t, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"SecurityCapabilities/MaxPassphraseCount", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->MaxPassphras= eCount !=3D *NumericValue) { + MemoryCs->SecurityCapabilities->MaxPassphraseCount =3D NumericVa= lue; 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_= SCHEMA_VERSION, L"SecurityCapabilities/PassphraseCapable", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->PassphraseCa= pable !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + MemoryCs->SecurityCapabilities->PassphraseCapable =3D IntegerV= alue; + PropertyChanged =3D TRUE; + } + } } } - } - - // - // 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; + // + // Handle SECURITYCAPABILITIES->PASSPHRASELOCKLIMIT + // + if (PropertyChecker (MemoryCs->SecurityCapabilities->PassphraseLockLim= it, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"SecurityCapabilities/PassphraseLockLimit", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *MemoryCs->SecurityCapabilities->PassphraseLo= ckLimit !=3D *NumericValue) { + MemoryCs->SecurityCapabilities->PassphraseLockLimit =3D NumericV= alue; PropertyChanged =3D TRUE; - UnusedProperty =3D FALSE; } } } - } - - // - // Handle SECURITYCAPABILITIES->PASSPHRASELOCKLIMIT + // + // Handle SECURITYCAPABILITIES->SECURITYSTATES + // + //// ****** Warning ****** + // Unsupported array type: // - 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; - } - } - } =20 - if (UnusedProperty) { - FreePool (MemoryCs->SecurityCapabilities); - MemoryCs->SecurityCapabilities =3D NULL; } =20 // @@ -1888,7 +1964,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle SERIALNUMBER // @@ -1901,7 +1976,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle SPAREDEVICECOUNT // @@ -1914,7 +1988,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle SUBSYSTEMDEVICEID // @@ -1927,7 +2000,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle SUBSYSTEMVENDORID // @@ -1940,7 +2012,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle VENDORID // @@ -1953,7 +2024,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle VOLATILEREGIONNUMBERLIMIT // @@ -1966,7 +2036,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle VOLATILEREGIONSIZELIMITMIB // @@ -1979,7 +2048,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle VOLATILEREGIONSIZEMAXMIB // @@ -1992,7 +2060,6 @@ ProvisioningMemoryProperties ( } } } - // // Handle VOLATILESIZEMIB // @@ -2006,8 +2073,6 @@ ProvisioningMemoryProperties ( } } =20 - - // // Convert C structure back to JSON text. // @@ -2039,18 +2104,17 @@ ProvisioningMemoryResource ( IN EFI_STRING ConfigureLang ) { - CHAR8 *MemoryJson; + CHAR8 *Json; EFI_STATUS Status; - CHAR8 *NewResourceLocation; - CHAR8 *NewKey; + EFI_STRING NewResourceLocation; CHAR8 *EtagStr; CHAR8 ResourceId[16]; - CHAR8 NewUri[255]; =20 if (IS_EMPTY_STRING (ConfigureLang) || Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 + EtagStr =3D NULL; AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index); =20 Status =3D ProvisioningMemoryProperties ( @@ -2059,54 +2123,45 @@ ProvisioningMemoryResource ( ResourceId, ConfigureLang, TRUE, - &MemoryJson + &Json ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, provisioning resource for %s failed: %r\n", = __FUNCTION__, ConfigureLang, Status)); return Status; } =20 - Status =3D CreatePayloadToPostResource (Private->RedfishService, Private= ->Payload, MemoryJson, &NewResourceLocation, &EtagStr); + Status =3D CreatePayloadToPostResource (Private->RedfishService, Private= ->Payload, Json, &NewResourceLocation, &EtagStr); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, post memory resource for %s failed: %r\n", _= _FUNCTION__, ConfigureLang, Status)); + DEBUG ((DEBUG_ERROR, "%a, post Memory resource for %s failed: %r\n", _= _FUNCTION__, ConfigureLang, Status)); goto RELEASE_RESOURCE; } =20 - NewUri[0] =3D '\0'; + ASSERT (NewResourceLocation !=3D NULL); =20 // // 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); - } + RedfisSetRedfishUri (ConfigureLang, NewResourceLocation); } =20 // // Handle Etag // if (EtagStr !=3D NULL) { - SetEtagWithUri (EtagStr, NewUri); + SetEtagWithUri (EtagStr, NewResourceLocation); FreePool (EtagStr); } =20 RELEASE_RESOURCE: =20 - FreePool (MemoryJson); + if (NewResourceLocation !=3D NULL) { + FreePool (NewResourceLocation); + } + + if (Json !=3D NULL) { + FreePool (Json); + } =20 return Status; } @@ -2126,12 +2181,17 @@ ProvisioningMemoryResources ( =20 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)); + DEBUG ((DEBUG_ERROR, "%a, No HII question found with configure languag= e: %s: %r\n", __FUNCTION__, REDPATH_ARRAY_PATTERN, Status)); return EFI_NOT_FOUND; } + // + // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE. + // This information is sent back to the parent resource (e.g. the collec= tion driver). + // + EdkIIRedfishResourceSetConfigureLang (&UnifiedConfigureLangList); =20 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)); + 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); } @@ -2145,14 +2205,69 @@ ProvisioningMemoryExistResource ( IN REDFISH_RESOURCE_COMMON_PRIVATE *Private ) { + EFI_STATUS Status; + EFI_STRING ConfigureLang; + CHAR8 *EtagStr; + CHAR8 *Json; + if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Payload= ), EDKII_JSON_COMPACT); - ASSERT (Private->Json !=3D NULL); + EtagStr =3D NULL; + Json =3D NULL; + ConfigureLang =3D NULL; + + ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); + if (ConfigureLang =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Status =3D ProvisioningMemoryProperties ( + Private->JsonStructProtocol, + MemoryEmptyJson, + NULL, + ConfigureLang, + TRUE, + &Json + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_NOT_FOUND) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for= %s ignored. Nothing changed\n", __FUNCTION__, ConfigureLang)); + } else { + DEBUG ((DEBUG_ERROR, "%a, provisioning existing resource for %s fail= ed: %r\n", __FUNCTION__, ConfigureLang, Status)); + } + goto ON_RELEASE; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for %s\= n", __FUNCTION__, ConfigureLang)); + // + // PUT back to instance + // + Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __FUNCT= ION__, ConfigureLang, Status)); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, Private->Uri); + FreePool (EtagStr); + } + +ON_RELEASE: =20 - return RedfishUpdateResourceCommon (Private, Private->Json); + if (Json !=3D NULL) { + FreePool (Json); + } + + if (ConfigureLang !=3D NULL) { + FreePool (ConfigureLang); + } + + return Status; } =20 /** @@ -2200,9 +2315,6 @@ RedfishCheckResourceCommon ( EFI_STRING *ConfigureLangList; UINTN Count; EFI_STRING Property; - CHAR8 *PropertyAscii; - UINTN BuffSize; - CHAR8 *Match; =20 if (Private =3D=3D NULL || IS_EMPTY_STRING (Json)) { return EFI_INVALID_PARAMETER; @@ -2221,27 +2333,16 @@ RedfishCheckResourceCommon ( Status =3D EFI_SUCCESS; for (Index =3D 0; Index < Count; Index++) { =20 - Property =3D GetPropertyFromConfigureLang (ConfigureLangList[Index]); + Property =3D GetPropertyFromConfigureLang (Private->Uri, ConfigureLang= List[Index]); if (Property =3D=3D NULL) { continue; } =20 - 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) { + DEBUG ((DEBUG_INFO, "%a, [%d] check attribute for: %s\n", __FUNCTION__= , Index, Property)); + if (!MatchPropertyWithJsonContext (Property, Json)) { + DEBUG ((DEBUG_INFO, "%a, property is missing: %s\n", __FUNCTION__, P= roperty)); Status =3D EFI_NOT_FOUND; - DEBUG ((DEBUG_ERROR, "%a, property %a is missing\n", __FUNCTION__, P= ropertyAscii)); } - - FreePool (PropertyAscii); } =20 FreePool (ConfigureLangList); @@ -2249,7 +2350,6 @@ RedfishCheckResourceCommon ( return Status; } =20 - /** Update resource to given URI. =20 @@ -2263,40 +2363,34 @@ RedfishCheckResourceCommon ( EFI_STATUS RedfishUpdateResourceCommon ( IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, - IN CHAR8 *Json + IN CHAR8 *InputJson ) { EFI_STATUS Status; - CHAR8 *MemoryJson; - CHAR8 *ArrayKey; + CHAR8 *Json; EFI_STRING ConfigureLang; CHAR8 *EtagStr; =20 - if (Private =3D=3D NULL || IS_EMPTY_STRING (Json)) { + if (Private =3D=3D NULL || IS_EMPTY_STRING (InputJson)) { return EFI_INVALID_PARAMETER; } =20 - MemoryJson =3D NULL; + EtagStr =3D NULL; + Json =3D NULL; ConfigureLang =3D NULL; - ArrayKey =3D NULL; =20 - Status =3D GetArraykeyFromUri (Private->Uri, &ArrayKey); - if (EFI_ERROR (Status)) { - return Status; - } - - ConfigureLang =3D GetConfigureLangByKey (RESOURCE_SCHEMA, RESOURCE_SCHEM= A_VERSION, NULL, ArrayKey); + ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); if (ConfigureLang =3D=3D NULL) { return EFI_NOT_FOUND; } =20 Status =3D ProvisioningMemoryProperties ( Private->JsonStructProtocol, - Json, + InputJson, NULL, ConfigureLang, FALSE, - &MemoryJson + &Json ); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND) { @@ -2311,9 +2405,9 @@ RedfishUpdateResourceCommon ( // // PUT back to instance // - Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, MemoryJson, &EtagStr); + Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, &EtagStr); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, post memory resource for %s failed: %r\n", _= _FUNCTION__, ConfigureLang, Status)); + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __FUNCT= ION__, ConfigureLang, Status)); } =20 // @@ -2326,17 +2420,81 @@ RedfishUpdateResourceCommon ( =20 ON_RELEASE: =20 - if (MemoryJson !=3D NULL) { - FreePool (MemoryJson); + if (Json !=3D NULL) { + FreePool (Json); } =20 if (ConfigureLang !=3D NULL) { FreePool (ConfigureLang); } =20 - if (ArrayKey !=3D NULL) { - FreePool (ArrayKey); + return Status; +} + +/** + Identify 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 +RedfishIdentifyResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *Json + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + EFI_STRING EndOfChar; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigLangList; + + Supported =3D RedfishIdentifyResource (Private->Uri, Private->Json); + if (Supported) { + Status =3D RedfishFeatureGetUnifiedArrayTypeConfigureLang (RESOURCE_SC= HEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigLangList); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, BiosConfigToRedfishGetConfigureLangRegex f= ailed: %r\n", __FUNCTION__, Status)); + return Status; + } + + if (ConfigLangList.Count =3D=3D 0) { + return EFI_SUCCESS; + } + + EndOfChar =3D StrStr (ConfigLangList.List[0].ConfigureLang, L"}"); + if (EndOfChar =3D=3D NULL) { + ASSERT (FALSE); + return EFI_DEVICE_ERROR; + } + + //EndOfChar =3D StrStr (ConfigLangList.List[0].ConfigureLang, L"}"); + Status =3D IsRedpathArray (ConfigLangList.List[0].ConfigureLang, NULL,= &EndOfChar); + if (EFI_ERROR (Status) && Status !=3D EFI_NOT_FOUND) { + ASSERT (FALSE); + return EFI_DEVICE_ERROR; + } + if (Status !=3D EFI_SUCCESS) { + // + // This is not the collection redpath. + // + GetRedpathNodeByIndex (ConfigLangList.List[0].ConfigureLang, 0, &End= OfChar); + } + *(++EndOfChar) =3D '\0'; + // + // Keep URI and ConfigLang mapping + // + RedfisSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private->Ur= i); + // + // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE. + // This information is sent back to the parent resource (e.g. the coll= ection driver). + // + EdkIIRedfishResourceSetConfigureLang (&ConfigLangList); + DestroyConfiglanguageList (&ConfigLangList); + return EFI_SUCCESS; } =20 - return Status; + return EFI_UNSUPPORTED; } \ 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/MemoryCommon.h similarity index 89% rename from RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCom= mon.h rename to RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.h index e2a4f45681..05c58b3553 100644 --- a/RedfishClientPkg/Features/Memory/V1_7_1/Common/RedfishMemoryCommon.h +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.h @@ -20,7 +20,7 @@ #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_PATTERN L"/Memory/\\{.*\\}/" #define REDPATH_ARRAY_PREFIX L"/Memory/" #define RESOURCE_SCHEMA_FULL "x-uefi-redfish-Memory.v1_7_1" =20 diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.c= b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c similarity index 75% rename from RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.c rename to RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c index d1fbf2c237..0a9d344d6f 100644 --- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.c +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c @@ -1,16 +1,18 @@ /** @file Redfish feature driver implementation - Memory =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include "../Common/RedfishMemoryCommon.h" +#include "../Common/MemoryCommon.h" =20 extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate; =20 +EFI_HANDLE medfishResourceConfigProtocolHandle; + /** Provising redfish resource by given URI. =20 @@ -26,8 +28,8 @@ extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourceP= rivate; EFI_STATUS RedfishResourceProvisioningResource ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri, - IN BOOLEAN PostMode + IN EFI_STRING Uri, + IN BOOLEAN PostMode ) { REDFISH_RESOURCE_COMMON_PRIVATE *Private; @@ -38,9 +40,7 @@ RedfishResourceProvisioningResource ( return EFI_INVALID_PARAMETER; } =20 - if (!PostMode) { - return EFI_UNSUPPORTED; - } + DEBUG ((DEBUG_INFO, "%a, provisioning in %s mode\n", __FUNCTION__, (Post= Mode ? L"POST" : L"PATCH"))); =20 Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); =20 @@ -48,9 +48,9 @@ RedfishResourceProvisioningResource ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __FUNCTION_= _, Uri)); return Status; } =20 @@ -58,7 +58,7 @@ RedfishResourceProvisioningResource ( Private->Payload =3D Response.Payload; ASSERT (Private->Payload !=3D NULL); =20 - Status =3D RedfishProvisioningResourceCommon (Private, FALSE); + Status =3D RedfishProvisioningResourceCommon (Private, !PostMode); =20 // // Release resource @@ -89,12 +89,13 @@ RedfishResourceProvisioningResource ( EFI_STATUS RedfishResourceConsumeResource ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri + IN EFI_STRING Uri ) { REDFISH_RESOURCE_COMMON_PRIVATE *Private; EFI_STATUS Status; REDFISH_RESPONSE Response; + CHAR8 *Etag; =20 if (This =3D=3D NULL || IS_EMPTY_STRING (Uri)) { return EFI_INVALID_PARAMETER; @@ -106,9 +107,9 @@ RedfishResourceConsumeResource ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __FUNCTION_= _, Uri)); return Status; } =20 @@ -119,9 +120,27 @@ RedfishResourceConsumeResource ( Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Payload= ), EDKII_JSON_COMPACT); ASSERT (Private->Json !=3D NULL); =20 - Status =3D RedfishConsumeResourceCommon (Private, Private->Json); + // + // Find etag in HTTP response header + // + Etag =3D NULL; + Status =3D GetEtagAndLocation (&Response, &Etag, NULL); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to consume resource from: %a %r\n", _= _FUNCTION__, Uri, Status)); + DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __FU= NCTION__)); + } + + Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag); + if (EFI_ERROR (Status)) { + if (Status !=3D EFI_ALREADY_STARTED) { + DEBUG ((DEBUG_ERROR, "%a, failed to consume resource from: %s: %r\n"= , __FUNCTION__, Uri, Status)); + } + } else { + // + // Keep etag after consuming pending settings. + // + if (Etag !=3D NULL) { + SetEtagWithUri (Etag, Private->Uri); + } } =20 // @@ -193,7 +212,7 @@ RedfishResourceGetInfo ( EFI_STATUS RedfishResourceUpdate ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri + IN EFI_STRING Uri ) { REDFISH_RESOURCE_COMMON_PRIVATE *Private; @@ -210,9 +229,9 @@ RedfishResourceUpdate ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __FUNCTION_= _, Uri)); return Status; } =20 @@ -225,7 +244,7 @@ RedfishResourceUpdate ( =20 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)); + DEBUG ((DEBUG_ERROR, "%a, failed to update resource from: %s: %r\n", _= _FUNCTION__, Uri, Status)); } =20 // @@ -262,7 +281,7 @@ RedfishResourceUpdate ( EFI_STATUS RedfishResourceCheck ( IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, - IN CHAR8 *Uri + IN EFI_STRING Uri ) { REDFISH_RESOURCE_COMMON_PRIVATE *Private; @@ -279,9 +298,9 @@ RedfishResourceCheck ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByPath (Private->RedfishService, Uri, &Response); + Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, get resource from: %a failed\n", __FUNCTION_= _, Uri)); + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __FUNCTION_= _, Uri)); return Status; } =20 @@ -294,7 +313,7 @@ RedfishResourceCheck ( =20 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)); + DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __= FUNCTION__, Uri, Status)); } =20 // @@ -318,11 +337,82 @@ RedfishResourceCheck ( return Status; } =20 +/** + Identify resource on given URI. + + @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI= G_PROTOCOL instance. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS This is target resource which we want t= o handle. + @retval EFI_UNSUPPORTED This is not the target resource. + @retval Others Some error happened. + +**/ + +EFI_STATUS +RedfishResourceIdentify ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN EFI_STRING Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + + if (This =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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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 RedfishIdentifyResourceCommon (Private, Private->Json); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, identify %s failed: %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; +} + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL mRedfishResourceConfig =3D { RedfishResourceProvisioningResource, RedfishResourceConsumeResource, RedfishResourceUpdate, RedfishResourceCheck, + RedfishResourceIdentify, RedfishResourceGetInfo }; =20 @@ -525,6 +615,8 @@ RedfishResourceEntryPoint ( return EFI_ALREADY_STARTED; } =20 + medfishResourceConfigProtocolHandle =3D ImageHandle; + 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)); diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.i= nf b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf similarity index 57% rename from RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf rename to RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf index 30746adaed..ae2e8e8f74 100644 --- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf @@ -1,6 +1,6 @@ ## @file # -# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -9,8 +9,8 @@ =20 [Defines] INF_VERSION =3D 0x00010005 - BASE_NAME =3D RedfishMemoryDxe - FILE_GUID =3D f5594d13-ca13-485f-ac3a-80c5074dd8c0 + BASE_NAME =3D MemoryDxe + FILE_GUID =3D 69a1a994-ec14-4dd0-ba0d-d1b51b7bab51 MODULE_TYPE =3D DXE_DRIVER VERSION_STRING =3D 1.0 ENTRY_POINT =3D RedfishResourceEntryPoint @@ -23,22 +23,25 @@ RedfishClientPkg/RedfishClientPkg.dec =20 [Sources] - ../Common/RedfishMemoryCommon.h - ../Common/RedfishMemoryCommon.c - RedfishMemoryDxe.c + ../Common/MemoryCommon.h + ../Common/MemoryCommon.c + MemoryDxe.c =20 [LibraryClasses] BaseMemoryLib DebugLib + EdkIIRedfishResourceConfigLib RedfishLib RedfishFeatureUtilityLib + RedfishResourceIdentifyLib UefiLib UefiDriverEntryPoint =20 + [Protocols] - gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED - gEfiRestJsonStructureProtocolGuid ## CONSUMED - gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED + gEfiRestJsonStructureProtocolGuid ## CONSUMED + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED =20 [Pcd] gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize diff --git a/RedfishClientPkg/Include/RedfishResourceCommon.h b/RedfishClie= ntPkg/Include/RedfishResourceCommon.h index 1ba992bb69..af4b809121 100644 --- a/RedfishClientPkg/Include/RedfishResourceCommon.h +++ b/RedfishClientPkg/Include/RedfishResourceCommon.h @@ -1,7 +1,7 @@ /** @file Redfish feature driver common header file. =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -11,8 +11,8 @@ #define EFI_REDFISH_RESOURCE_COMMON_H_ =20 #define MAX_RED_PATH_LEN 128 -#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') -#define REDFISH_DEBUG_TRACE DEBUG_INFO + +#include =20 // // Libraries @@ -23,14 +23,18 @@ #include #include #include +#include #include #include #include #include +#include +#include =20 // // Protocols // +#include #include #include #include @@ -43,9 +47,15 @@ typedef struct _REDFISH_RESOURCE_COMMON_PRIVATE { EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL RedfishResourceConfig; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL ConfigHandler; EFI_EVENT Event; - CHAR8 *Uri; + EFI_STRING Uri; CHAR8 *Json; REDFISH_PAYLOAD Payload; + // + // Below are used for the external resource. + // + EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol; + RESOURCE_INFORMATION_EXCHANGE *InformationExchange; + EFI_STRING RedfishVersion; } REDFISH_RESOURCE_COMMON_PRIVATE; =20 #define REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_CONFIG_PROTOCOL(This) \ @@ -60,6 +70,7 @@ typedef struct _REDFISH_RESOURCE_COMMON_PRIVATE { =20 @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV= ATE instance. @param[in] Json The JSON to consume. + @param[in] HeaderEtag The Etag string returned in HTTP header. =20 @retval EFI_SUCCESS Value is returned successfully. @retval Others Some error happened. @@ -68,7 +79,8 @@ typedef struct _REDFISH_RESOURCE_COMMON_PRIVATE { EFI_STATUS RedfishConsumeResourceCommon ( IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, - IN CHAR8 *Json + IN CHAR8 *Json, + IN CHAR8 *HeaderEtag OPTIONAL ); =20 /** @@ -120,4 +132,20 @@ RedfishUpdateResourceCommon ( IN CHAR8 *Json ); =20 +/** + Identify 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 +RedfishIdentifyResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *Json + ); + #endif diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 3619d2a20f..5c4b9670b0 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -14,7 +14,7 @@ INF RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf INF RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf INF RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf - INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf + INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf INF RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index 5f1aff3c4b..031d87558e 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -19,7 +19,7 @@ # # Below two modules should be pulled in by build tool. # - RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf + RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc --=20 2.32.0.windows.2 -=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 (#91880): https://edk2.groups.io/g/devel/message/91880 Mute This Topic: https://groups.io/mt/92641654/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- From nobody Fri Apr 26 08:47:54 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+91881+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+91881+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885909; cv=none; d=zohomail.com; s=zohoarc; b=N8U7KqVxqlJ1xs5FY0peJKKRcVzgukuH1OGlKJFaiNiZMSCCxCgq9RuvDe7XRCzlnXJBd4DLO0L+XYC4nLb4diKtgTBqY0+JGA45CjIf735/nBRLnQpaQTbtkeLXOqWhEn08CR5SQj49np3fhtUJu/gxh564Bho8ULFpVcMZ0KA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885909; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=+aqaKRXWTJ5hzhywLWuVRRg+9VI7Z0qMbbOCqC0V75I=; b=bEEiZNAMfs5Hs1qyZybs8ADWf5aIjZP01DN9wKwrpZzH70dtgABd2AH8ohV8MyuKkXFtjqZeDvYqc9Wvm9FRk65TlTEBwetHYAs+DuXMJsjRem7uoncPk+am2asD6hj9CondCd2du7uL5jg5CRb2js5BoeMyeWiAzH7nks7E5TI= 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+91881+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 1658885909297340.8335787777579; Tue, 26 Jul 2022 18:38:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KRzMYY1788612xeLob1OyRdf; Tue, 26 Jul 2022 18:38:28 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.14908.1658885908288083363 for ; Tue, 26 Jul 2022 18:38:28 -0700 X-Received: from pps.filterd (m0150241.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0rCAX009899; Wed, 27 Jul 2022 01:38:26 GMT X-Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3hjqes1n32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:26 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14878.it.hpe.com (Postfix) with ESMTPS id AF504D2C2; Wed, 27 Jul 2022 01:38:25 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 6DBB48058C5; Wed, 27 Jul 2022 01:38:24 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 13/15] edk2-staging/RedfishClientPkg: Introduce Computer System collection driver Date: Wed, 27 Jul 2022 09:38:00 +0800 Message-Id: <20220727013802.247-14-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: 3axbaDxwmkEOqmibqjWngfQxvPjpNI8G X-Proofpoint-ORIG-GUID: 3axbaDxwmkEOqmibqjWngfQxvPjpNI8G 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,nickle.wang@hpe.com X-Gm-Message-State: giJwUwWCPjhQFkbA4PWxN13ix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885908; bh=/5NU+4qVGoW4WF/HOn3q+WEed1cIoN3VJJtzBWWBuaM=; h=Cc:Date:From:Reply-To:Subject:To; b=jjSbru/DcygilWX4iZc12uQ+cq+UXXs5QhaDGUx3+UfOefg96YNzxgjFS1z9LJExS1V Y7Y8i7P31nivLrEsppoiew7+qyvlCufb7BWDPsyPSEFEY+MVwNyPe18RC5vsJjpywud+y Fkw5xZzEGJrnL9q8zuTQBlOOSTvyaYaL6go= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885911094100023 Content-Type: text/plain; charset="utf-8" Introduce new feature driver to support Computer System Collection schema. Update corresponding FDF and DSC file to enable this feature driver. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../ComputerSystemCollectionDxe.c | 667 ++++++++++++++++++ .../ComputerSystemCollectionDxe.h | 21 + .../ComputerSystemCollectionDxe.inf | 56 ++ RedfishClientPkg/RedfishClient.fdf.inc | 2 + .../RedfishClientComponents.dsc.inc | 2 + RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + 6 files changed, 749 insertions(+) create mode 100644 RedfishClientPkg/Features/ComputerSystemCollectionDxe/C= omputerSystemCollectionDxe.c create mode 100644 RedfishClientPkg/Features/ComputerSystemCollectionDxe/C= omputerSystemCollectionDxe.h create mode 100644 RedfishClientPkg/Features/ComputerSystemCollectionDxe/C= omputerSystemCollectionDxe.inf diff --git a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/Computer= SystemCollectionDxe.c b/RedfishClientPkg/Features/ComputerSystemCollectionD= xe/ComputerSystemCollectionDxe.c new file mode 100644 index 0000000000..dbf5ab3395 --- /dev/null +++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC= ollectionDxe.c @@ -0,0 +1,667 @@ +/** @file + + Redfish feature driver implementation - ComputerSystemCollection + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "ComputerSystemCollectionDxe.h" + +REDFISH_COLLECTION_PRIVATE *mRedfishCollectionPrivate =3D NULL; + +EFI_STATUS +HandleResource ( + IN REDFISH_COLLECTION_PRIVATE *Private, + IN EFI_STRING Uri + ) +{ + EFI_STATUS Status; + REDFISH_SCHEMA_INFO SchemaInfo; + EFI_STRING ConfigLang; + EFI_STRING ReturnedConfigLang; + UINTN Index; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + // + // Resource match + // + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\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: %s %r= \n", __FUNCTION__, Uri, Status)); + return Status; + } + // + // Check and see if this is target resource that we want to handle. + // Some resource is handled by other provider so we have to make sure th= is first. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%s Identify for %s\n", __FUNCTION__, Uri)); + ConfigLang =3D RedfishGetConfigLanguage (Uri); + if (ConfigLang =3D=3D NULL) { + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_INFO, "%a, \"%s\" is not handled by us\n", __FUNCTIO= N__, Uri)); + return EFI_SUCCESS; + } + + DEBUG ((DEBUG_ERROR, "%a, fail to identify resource: \"%s\": %r\n", = __FUNCTION__, Uri, Status)); + return Status; + } + } else { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, history record found: %s\n", __FUNCT= ION__, ConfigLang)); + // + // Set exchange information + // + Status =3D GetArrayIndexFromArrayTypeConfigureLang (ConfigLang, &Retur= nedConfigLang, &Index); + if (!EFI_ERROR (Status) || Status =3D=3D EFI_NOT_FOUND) { + Private->InformationExchange->ReturnedInformation.Type =3D Informati= onTypeCollectionMemberConfigLanguage; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.Count =3D 1; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List =3D + AllocateZeroPool(sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG)); + + if (Private->InformationExchange->ReturnedInformation.ConfigureLangu= ageList.List =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEAT= URE_ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List [0].Index =3D Index; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List [0].ConfigureLang =3D + (EFI_STRING)AllocateCopyPool(StrSize(ReturnedConfigLang), (VOID = *)ReturnedConfigLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, GetArrayIndexFromArrayTypeConfigureLang fa= il: %r\n", __FUNCTION__, Status)); + } + FreePool (ConfigLang); + } + + // + // 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 %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, 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 %s\n", __FUNCTION__, Ur= i)); + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, = Private->InformationExchange, 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 %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %s: %r\n", _= _FUNCTION__, Uri, Status)); + } + + // + // Patch. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to update resoruce for: %s: %r\n", __= FUNCTION__, Uri, Status)); + } + + return Status; +} + +EFI_STATUS +HandleCollectionResource ( + IN REDFISH_COLLECTION_PRIVATE *Private + ) +{ + EFI_STATUS Status; + EFI_REDFISH_COMPUTERSYSTEMCOLLECTION *Collection; + EFI_REDFISH_COMPUTERSYSTEMCOLLECTION_CS *CollectionCs; + RedfishCS_Link *List; + RedfishCS_Header *Header; + RedfishCS_Type_Uri_Data *UriData; + EFI_STRING MemberUri; + + 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: %s\n", __FUNCT= ION__, Private->CollectionUri)); + + // + // Convert JSON text to C structure. + // + Status =3D Private->JsonStructProtocol->ToStructure ( + Private->JsonStructProtocol, + NULL, + Private->CollectionJson, + (EFI_REST_JSON_STRUCTURE_HEADER = **)&Collection + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return Status; + } + + CollectionCs =3D Collection->ComputerSystemCollection; + + if (*CollectionCs->Membersodata_count =3D=3D 0) { + return EFI_NOT_FOUND; + } + + if (IsLinkEmpty (&CollectionCs->Members)) { + return EFI_NOT_FOUND; + } + + 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; + MemberUri =3D NULL; + MemberUri =3D StrAsciiToUnicode (UriData->Uri); + ASSERT (MemberUri !=3D NULL); + if (MemberUri !=3D NULL) { + Status =3D HandleResource (Private, MemberUri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, process ComputerSystemCollection resou= rce: %a failed: %r\n", __FUNCTION__, UriData->Uri, Status)); + } + + FreePool (MemberUri); + } + } + + 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 *)Collection); + + return EFI_SUCCESS; +} + +EFI_STATUS +CreateCollectionResource ( + IN REDFISH_COLLECTION_PRIVATE *Private + ) +{ + EFI_STATUS Status; + REDFISH_SCHEMA_INFO SchemaInfo; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %s= \n", __FUNCTION__, Private->CollectionUri)); + + 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)); + + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Private= ->CollectionUri, Private->InformationExchange, TRUE); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %s: %r\n", __= FUNCTION__, Private->CollectionUri, 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; + } + + if (Private->RedfishVersion !=3D NULL) { + FreePool (Private->RedfishVersion); + Private->RedfishVersion =3D NULL; + } + + return EFI_SUCCESS; +} + +EFI_STATUS +CollectionHandler ( + IN REDFISH_COLLECTION_PRIVATE *Private + ) +{ + EFI_STATUS Status; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %s\n", __FUNCTI= ON__, Private->CollectionUri)); + + // + // Query collection from Redfish service. + // + Status =3D GetResourceByUri (Private->RedfishService, Private->Collectio= nUri, &Private->RedResponse); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %s :%r\n", __FU= NCTION__, Private->CollectionUri, 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 HandleCollectionResource (Private); + if (EFI_ERROR (Status) && Status =3D=3D EFI_NOT_FOUND) { + Status =3D CreateCollectionResource (Private); + } + +ON_RELEASE: + + 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] Uri The collection URI. + @param[in] Context The context of Redfish feature driver. + @param[in,out] InformationExchange The pointer to RESOURCE_INFORMATION_E= XCHANGE + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. + + @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 RESOURCE_INFORMATION_EXCHANGE *InformationExchange + ) +{ + EFI_STATUS Status; + REDFISH_SERVICE RedfishService; + REDFISH_COLLECTION_PRIVATE *Private; + EFI_STRING ResourceUri; + + 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; + } + + // + // Save in private structure. + // + Private->InformationExchange =3D InformationExchange; + + // + // Find Redfish version on BMC + // + Private->RedfishVersion =3D RedfishGetVersion (RedfishService); + + // + // Create the full URI from Redfish service root. + // + ResourceUri =3D (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof(CH= AR16)); + if (ResourceUri =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for full URI.\n", __= FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion); + StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange->SendInformati= on.FullUri); + + // + // Initialize collection path + // + Private->CollectionUri =3D RedfishGetUri (ResourceUri); + if (Private->CollectionUri =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + + 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/Features/ComputerSystemCollectionDxe/Computer= SystemCollectionDxe.h b/RedfishClientPkg/Features/ComputerSystemCollectionD= xe/ComputerSystemCollectionDxe.h new file mode 100644 index 0000000000..a4778c1012 --- /dev/null +++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC= ollectionDxe.h @@ -0,0 +1,21 @@ +/** @file + + Redfish feature driver implementation - internal header file + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EFI_REDFISH_COMPUTERSYSTEM_COLLECTION_H_ +#define EFI_REDFISH_COMPUTERSYSTEM_COLLECTION_H_ + +#include +#include + +#define REDFISH_SCHEMA_NAME "ComputerSystem" +#define REDFISH_MANAGED_URI L"Systems/{}" +#define MAX_URI_LENGTH 256 + +#endif diff --git a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/Computer= SystemCollectionDxe.inf b/RedfishClientPkg/Features/ComputerSystemCollectio= nDxe/ComputerSystemCollectionDxe.inf new file mode 100644 index 0000000000..107d6c0769 --- /dev/null +++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC= ollectionDxe.inf @@ -0,0 +1,56 @@ +## @file +# +# Redfish ComputerSystemCollection collection driver. +# +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D ComputerSystemCollectionDxe + FILE_GUID =3D df883f2e-9f58-4514-9cc9-06cbe6f63073 + 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] + ComputerSystemCollectionDxe.h + ComputerSystemCollectionDxe.c + +[LibraryClasses] + DebugLib + BaseMemoryLib + ConverterCommonLib + MemoryAllocationLib + RedfishFeatureUtilityLib + RedfishLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + EdkIIRedfishResourceConfigLib + RedfishVersionLib + +[Protocols] + gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMED + gEfiRestJsonStructureProtocolGuid ## CONSUMED + gEdkIIRedfishFeatureProtocolGuid ## CONSUMED + +[Guids] + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + +[Depex] + TRUE diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 5c4b9670b0..7d5de56591 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -16,6 +16,7 @@ INF RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf INF RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf + INF RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystem= CollectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc # @@ -23,4 +24,5 @@ # INF RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf INF RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_= Dxe.inf + INF RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerS= ystemCollection_Dxe.inf !endif diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index 031d87558e..d4a33385f6 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -21,6 +21,7 @@ # RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf + RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemColl= ectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc =20 @@ -30,3 +31,4 @@ RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_Dxe.= inf !endif + RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSyste= mCollection_Dxe.inf diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 413b83a732..21595613f5 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -19,6 +19,7 @@ # MemoryV1_7_1Lib|RedfishClientPkg/ConverterLib/edk2library/Memory/v1_7_1/= Lib.inf MemoryCollectionLib|RedfishClientPkg/ConverterLib/edk2library/MemoryColl= ection/Lib.inf + ComputerSystemCollectionLib|RedfishClientPkg/ConverterLib/edk2library/Co= mputerSystemCollection/Lib.inf =20 NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf HttpLib|NetworkPkg/Library/DxeHttpLib/DxeHttpLib.inf --=20 2.32.0.windows.2 -=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 (#91881): https://edk2.groups.io/g/devel/message/91881 Mute This Topic: https://groups.io/mt/92641655/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- From nobody Fri Apr 26 08:47:54 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+91882+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+91882+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885910; cv=none; d=zohomail.com; s=zohoarc; b=esdN1zny5BpPVclQB8YOKeGvgs+PvRSuTeWqlRos9rHrjeaZ6Xspp2V2iflPG3xwsZmNhz9Z/SAkJd/hFFznGXvFzuu4LrwtTDwFWwUDpJb8lvb8XwFKi76UNdKrEgU4NVieFKsvAuTsZa1N0ogIZ5xTQ3uyZv6qAP//L6zd7MM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885910; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=e4aGNFSL+r0Qr0lVfXtCraD2tzrZbgRtHxF0CcI1K9I=; b=IpHihGmNP3TEF2jtnPP+j2UMxE3WKch6DUrnVpHTrSqC5QRPk7rYaWrqwBjvcsJdSaDe514/e9ARPPynKh2eJscbTUqX1JlOgINBqv85tRFqVxXb/gQ1K40iOSpTlJSxihMVXGw0tjY6Flgo83L7nqPgCtdsuoOFdr/cYo+0CKs= 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+91882+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 1658885910731292.5961116836547; Tue, 26 Jul 2022 18:38:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Y0BKYY1788612x0KwqdU49xQ; Tue, 26 Jul 2022 18:38:30 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web08.15039.1658885909762532215 for ; Tue, 26 Jul 2022 18:38:29 -0700 X-Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R1UcYT002115; Wed, 27 Jul 2022 01:38:28 GMT X-Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hjurp02cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:27 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id 53F5A132DA; Wed, 27 Jul 2022 01:38:27 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 15ADB803A92; Wed, 27 Jul 2022 01:38:25 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 14/15] edk2-staging/RedfishClientPkg: Introduce Computer System feature driver Date: Wed, 27 Jul 2022 09:38:01 +0800 Message-Id: <20220727013802.247-15-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: qSkTBy9N5n-3t02xn5tp2323YMxdT6Us X-Proofpoint-ORIG-GUID: qSkTBy9N5n-3t02xn5tp2323YMxdT6Us 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,nickle.wang@hpe.com X-Gm-Message-State: QxOqmHrhjBHax9uzLje91URJx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885910; bh=qw5evtW+NTwcdijTdPytGpU6nEJXifgEaMhQ1ZUkS0E=; h=Cc:Date:From:Reply-To:Subject:To; b=MXnMN9q6XClFdCm9lI1kQs2YhZ3z2IRRIY/E8afoKSkr+s/NMgjbC0EYu1SfU7kvIwt QMa5Mo5ZiLBIjdPoZBoX9YGYMfgFE158u1jX3GKUFH79+luQ8jeKyonheoFyMbVv/oPT3 eARHR9zA1h5zHRSq1mN3QbH6U5Z8ZnqDFOA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885911139100024 Content-Type: text/plain; charset="utf-8" Introduce new feature driver to support Computer System version 1.5.0 schema. Update corresponding FDF and DSC file to enable this feature driver. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../v1_5_0/Common/ComputerSystemCommon.c | 1614 +++++++++++++++++ .../v1_5_0/Common/ComputerSystemCommon.h | 27 + .../v1_5_0/Dxe/ComputerSystemDxe.c | 645 +++++++ .../v1_5_0/Dxe/ComputerSystemDxe.inf | 51 + RedfishClientPkg/RedfishClient.fdf.inc | 2 + .../RedfishClientComponents.dsc.inc | 7 +- RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + 7 files changed, 2346 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/= ComputerSystemCommon.c create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/= ComputerSystemCommon.h create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/Com= puterSystemDxe.c create mode 100644 RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/Com= puterSystemDxe.inf diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Compute= rSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Co= mputerSystemCommon.c new file mode 100644 index 0000000000..0a9c746f3b --- /dev/null +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystem= Common.c @@ -0,0 +1,1614 @@ +/** @file + Redfish feature driver implementation - common functions + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "ComputerSystemCommon.h" + +CHAR8 ComputerSystemEmptyJson[] =3D "{\"@odata.id\": \"\", \"@odata.type\"= : \"#ComputerSystem.v1_5_0.ComputerSystem\", \"Id\": \"\", \"Name\": \"\", = \"Boot\":{}}"; + +REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate =3D NULL; + +/** + Consume resource from given URI. + + @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV= ATE instance. + @param[in] Json The JSON to consume. + @param[in] HeaderEtag The Etag string returned in HTTP header. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishConsumeResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *Json, + IN CHAR8 *HeaderEtag OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *ComputerSystem; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS *ComputerSystemCs; + EFI_STRING ConfigureLang; + + + if (Private =3D=3D NULL || IS_EMPTY_STRING (Json)) { + return EFI_INVALID_PARAMETER; + } + + ComputerSystem =3D NULL; + ComputerSystemCs =3D NULL; + ConfigureLang =3D NULL; + + Status =3D Private->JsonStructProtocol->ToStructure ( + Private->JsonStructProtocol, + NULL, + Json, + (EFI_REST_JSON_STRUCTURE_HEADER = **)&ComputerSystem + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return Status; + } + + ComputerSystemCs =3D ComputerSystem->ComputerSystem; + + // + // Check ETAG to see if we need to consume it + // + if (CheckEtag (Private->Uri, HeaderEtag, NULL)) { + // + // No change + // + DEBUG ((DEBUG_INFO, "%a, ETAG: %s has no change, ignore consume action= \n", __FUNCTION__, Private->Uri)); + Status =3D EFI_ALREADY_STARTED; + goto ON_RELEASE; + } + + // + // Handle ASSETTAG + // + if (ComputerSystemCs->AssetTag !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Asset= Tag"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->AssetTag); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // BIOS will be handled by feature driver. + // + + // + // Handle BIOSVERSION + // + if (ComputerSystemCs->BiosVersion !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "BiosV= ersion"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->BiosVersion); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle BOOT + // + if (ComputerSystemCs->Boot =3D=3D NULL) { + ComputerSystemCs->Boot =3D AllocateZeroPool (sizeof (RedfishComputerSy= stem_V1_5_0_Boot_CS)); + ASSERT (ComputerSystemCs->Boot !=3D NULL); + } + + // + // Handle BOOT->BOOTNEXT + // + if (ComputerSystemCs->Boot->BootNext !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Boot/= BootNext"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootNext); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __FU= NCTION__, ConfigureLang, Status)); + } + + FreePool (ConfigureLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle BOOT->BOOTORDER + // + if (ComputerSystemCs->Boot->BootOrder !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Boot/= BootOrder"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringArrayType (RESOURCE_SCHEMA, RES= OURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootOrder); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle BOOT->BOOTSOURCEOVERRIDEENABLED + // + if (ComputerSystemCs->Boot->BootSourceOverrideEnabled !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Boot/= BootSourceOverrideEnabled"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootSourceOverrideE= nabled); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle BOOT->BOOTSOURCEOVERRIDEMODE + // + if (ComputerSystemCs->Boot->BootSourceOverrideMode !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Boot/= BootSourceOverrideMode"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootSourceOverrideM= ode); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle BOOT->BOOTSOURCEOVERRIDETARGET + // + if (ComputerSystemCs->Boot->BootSourceOverrideTarget !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Boot/= BootSourceOverrideTarget"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->BootSourceOverrideT= arget); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE + // + if (ComputerSystemCs->Boot->UefiTargetBootSourceOverride !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Boot/= UefiTargetBootSourceOverride"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot->UefiTargetBootSourc= eOverride); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // ETHERNETINTERFACES will be handled by collection driver. + // + + // + // Handle HOSTNAME + // + if (ComputerSystemCs->HostName !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "HostN= ame"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->HostName); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle HOSTWATCHDOGTIMER + // + if (ComputerSystemCs->HostWatchdogTimer =3D=3D NULL) { + ComputerSystemCs->HostWatchdogTimer =3D AllocateZeroPool (sizeof (Redf= ishComputerSystem_V1_5_0_WatchdogTimer_CS)); + ASSERT (ComputerSystemCs->HostWatchdogTimer !=3D NULL); + } + + // + // Handle HOSTWATCHDOGTIMER->FUNCTIONENABLED + // + if (ComputerSystemCs->HostWatchdogTimer->FunctionEnabled !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "HostW= atchdogTimer/FunctionEnabled"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsBooleanType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (BOOLEAN)*ComputerSystemCs->HostWatchdogTi= mer->FunctionEnabled); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle HOSTWATCHDOGTIMER->TIMEOUTACTION + // + if (ComputerSystemCs->HostWatchdogTimer->TimeoutAction !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "HostW= atchdogTimer/TimeoutAction"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->HostWatchdogTimer->Timeou= tAction); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle HOSTWATCHDOGTIMER->WARNINGACTION + // + if (ComputerSystemCs->HostWatchdogTimer->WarningAction !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "HostW= atchdogTimer/WarningAction"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->HostWatchdogTimer->Warnin= gAction); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle HOSTEDSERVICES + // + if (ComputerSystemCs->HostedServices =3D=3D NULL) { + ComputerSystemCs->HostedServices =3D AllocateZeroPool (sizeof (Redfish= ComputerSystem_V1_5_0_HostedServices_CS)); + ASSERT (ComputerSystemCs->HostedServices !=3D NULL); + } + + // + // Handle HOSTINGROLES + // +// +// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle INDICATORLED + // + if (ComputerSystemCs->IndicatorLED !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Indic= atorLED"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->IndicatorLED); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // LOGSERVICES will be handled by collection driver. + // + + // + // Handle MANUFACTURER + // + if (ComputerSystemCs->Manufacturer !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Manuf= acturer"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // MEMORY will be handled by collection driver. + // + + // + // Handle MEMORYSUMMARY + // + if (ComputerSystemCs->MemorySummary =3D=3D NULL) { + ComputerSystemCs->MemorySummary =3D AllocateZeroPool (sizeof (RedfishC= omputerSystem_V1_5_0_MemorySummary_CS)); + ASSERT (ComputerSystemCs->MemorySummary !=3D NULL); + } + + // + // Handle MEMORYSUMMARY->MEMORYMIRRORING + // + if (ComputerSystemCs->MemorySummary->MemoryMirroring !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Memor= ySummary/MemoryMirroring"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->MemorySummary->MemoryMirr= oring); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle MEMORYSUMMARY->TOTALSYSTEMMEMORYGIB + // + if (ComputerSystemCs->MemorySummary->TotalSystemMemoryGiB !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Memor= ySummary/TotalSystemMemoryGiB"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*ComputerSystemCs->MemorySummary->T= otalSystemMemoryGiB); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle MEMORYSUMMARY->TOTALSYSTEMPERSISTENTMEMORYGIB + // + if (ComputerSystemCs->MemorySummary->TotalSystemPersistentMemoryGiB !=3D= NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Memor= ySummary/TotalSystemPersistentMemoryGiB"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*ComputerSystemCs->MemorySummary->T= otalSystemPersistentMemoryGiB); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle MODEL + // + if (ComputerSystemCs->Model !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Model= "); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Model); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // NETWORKINTERFACES will be handled by collection driver. + // + + // + // Handle PCIEDEVICES + // +// +// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle PCIEFUNCTIONS + // +// +// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle PARTNUMBER + // + if (ComputerSystemCs->PartNumber !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "PartN= umber"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle POWERSTATE + // + if (ComputerSystemCs->PowerState !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Power= State"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->PowerState); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle PROCESSORSUMMARY + // + if (ComputerSystemCs->ProcessorSummary =3D=3D NULL) { + ComputerSystemCs->ProcessorSummary =3D AllocateZeroPool (sizeof (Redfi= shComputerSystem_V1_5_0_ProcessorSummary_CS)); + ASSERT (ComputerSystemCs->ProcessorSummary !=3D NULL); + } + + // + // Handle PROCESSORSUMMARY->COUNT + // + if (ComputerSystemCs->ProcessorSummary->Count !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Proce= ssorSummary/Count"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*ComputerSystemCs->ProcessorSummary= ->Count); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle PROCESSORSUMMARY->LOGICALPROCESSORCOUNT + // + if (ComputerSystemCs->ProcessorSummary->LogicalProcessorCount !=3D NULL)= { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Proce= ssorSummary/LogicalProcessorCount"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsNumericType (RESOURCE_SCHEMA, RESOURC= E_SCHEMA_VERSION, ConfigureLang, (UINTN)*ComputerSystemCs->ProcessorSummary= ->LogicalProcessorCount); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle PROCESSORSUMMARY->MODEL + // + if (ComputerSystemCs->ProcessorSummary->Model !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Proce= ssorSummary/Model"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->ProcessorSummary->Model); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // PROCESSORS will be handled by collection driver. + // + + // + // Handle REDUNDANCY + // +// +// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle SKU + // + if (ComputerSystemCs->SKU !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "SKU"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->SKU); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // SECUREBOOT will be handled by feature driver. + // + + // + // Handle SERIALNUMBER + // + if (ComputerSystemCs->SerialNumber !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Seria= lNumber"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // SIMPLESTORAGE will be handled by collection driver. + // + + // + // STORAGE will be handled by collection driver. + // + + // + // Handle SUBMODEL + // + if (ComputerSystemCs->SubModel !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "SubMo= del"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->SubModel); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle SYSTEMTYPE + // + if (ComputerSystemCs->SystemType !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (ComputerSystemCs->odata_id, "Syste= mType"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->SystemType); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle TRUSTEDMODULES + // +// +// ****** Warning ****** +// Unsupported array type: +// + + +ON_RELEASE: + + // + // Release resource. + // + Private->JsonStructProtocol->DestoryStructure ( + Private->JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)Compute= rSystem + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +ProvisioningComputerSystemProperties ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, + IN CHAR8 *InputJson, + IN CHAR8 *ResourceId, OPTIONAL + IN EFI_STRING ConfigureLang, + IN BOOLEAN ProvisionMode, + OUT CHAR8 **ResultJson + ) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *ComputerSystem; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS *ComputerSystemCs; + EFI_STATUS Status; + BOOLEAN PropertyChanged; + CHAR8 *AsciiStringValue; + CHAR8 **AsciiStringArrayValue; + UINTN ArraySize; + BOOLEAN *BooleanValue; + INT32 *IntegerValue; + INT64 *NumericValue; + + + + if (JsonStructProtocol =3D=3D NULL || ResultJson =3D=3D NULL || IS_EMPTY= _STRING (InputJson) || 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 resource" : L"Update resou= rce"))); + + *ResultJson =3D NULL; + PropertyChanged =3D FALSE; + + ComputerSystem =3D NULL; + Status =3D JsonStructProtocol->ToStructure ( + JsonStructProtocol, + NULL, + InputJson, + (EFI_REST_JSON_STRUCTURE_HEADER **)&Compu= terSystem + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure failure: %r\n", __FUNCTION__, St= atus)); + return Status; + } + + ComputerSystemCs =3D ComputerSystem->ComputerSystem; + + // + // ID + // + if (ComputerSystemCs->Id =3D=3D NULL && !IS_EMPTY_STRING (ResourceId)) { + ComputerSystemCs->Id =3D AllocateCopyPool (AsciiStrSize (ResourceId), = ResourceId); + } + + // + // Handle ASSETTAG + // + if (PropertyChecker (ComputerSystemCs->AssetTag, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"AssetTag", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->AssetTag, AsciiS= tringValue) !=3D 0) { + ComputerSystemCs->AssetTag =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle BIOSVERSION + // + if (PropertyChecker (ComputerSystemCs->BiosVersion, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"BiosVersion", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->BiosVersion, Asc= iiStringValue) !=3D 0) { + ComputerSystemCs->BiosVersion =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle BOOT + // + if (ComputerSystemCs->Boot !=3D NULL) { + // + // Handle BOOT->BOOTNEXT + // + if (PropertyChecker (ComputerSystemCs->Boot->BootNext, ProvisionMode))= { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"Boot/BootNext", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->Boot->BootNext= , AsciiStringValue) !=3D 0) { + ComputerSystemCs->Boot->BootNext =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle BOOT->BOOTORDER + // + if (PropertyChecker (ComputerSystemCs->Boot->BootOrder, ProvisionMode)= ) { + AsciiStringArrayValue =3D GetPropertyStringArrayValue (RESOURCE_SCHE= MA, RESOURCE_SCHEMA_VERSION, L"Boot/BootOrder", ConfigureLang, &ArraySize); + if (AsciiStringArrayValue !=3D NULL) { + if (ProvisionMode || !CompareRedfishStringArrayValues (ComputerSys= temCs->Boot->BootOrder, AsciiStringArrayValue, ArraySize)) { + AddRedfishCharArray (&ComputerSystemCs->Boot->BootOrder, AsciiSt= ringArrayValue, ArraySize); + PropertyChanged =3D TRUE; + } + } + } + // + // Handle BOOT->BOOTSOURCEOVERRIDEENABLED + // + if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideEnabled= , ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"Boot/BootSourceOverrideEnabled", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->Boot->BootSour= ceOverrideEnabled, AsciiStringValue) !=3D 0) { + ComputerSystemCs->Boot->BootSourceOverrideEnabled =3D AsciiStrin= gValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle BOOT->BOOTSOURCEOVERRIDEMODE + // + if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideMode, P= rovisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"Boot/BootSourceOverrideMode", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->Boot->BootSour= ceOverrideMode, AsciiStringValue) !=3D 0) { + ComputerSystemCs->Boot->BootSourceOverrideMode =3D AsciiStringVa= lue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle BOOT->BOOTSOURCEOVERRIDETARGET + // + if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideTarget,= ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"Boot/BootSourceOverrideTarget", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->Boot->BootSour= ceOverrideTarget, AsciiStringValue) !=3D 0) { + ComputerSystemCs->Boot->BootSourceOverrideTarget =3D AsciiString= Value; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE + // + if (PropertyChecker (ComputerSystemCs->Boot->UefiTargetBootSourceOverr= ide, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"Boot/UefiTargetBootSourceOverride", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->Boot->UefiTarg= etBootSourceOverride, AsciiStringValue) !=3D 0) { + ComputerSystemCs->Boot->UefiTargetBootSourceOverride =3D AsciiSt= ringValue; + PropertyChanged =3D TRUE; + } + } + } + } + + // + // Handle HOSTNAME + // + if (PropertyChecker (ComputerSystemCs->HostName, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"HostName", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->HostName, AsciiS= tringValue) !=3D 0) { + ComputerSystemCs->HostName =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle HOSTWATCHDOGTIMER + // + if (ComputerSystemCs->HostWatchdogTimer !=3D NULL) { + // + // Handle HOSTWATCHDOGTIMER->FUNCTIONENABLED + // + if (PropertyChecker (ComputerSystemCs->HostWatchdogTimer->FunctionEnab= led, ProvisionMode)) { + BooleanValue =3D GetPropertyBooleanValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"HostWatchdogTimer/FunctionEnabled", ConfigureLang); + if (BooleanValue !=3D NULL) { + if (ProvisionMode || *ComputerSystemCs->HostWatchdogTimer->Functio= nEnabled !=3D *BooleanValue) { + IntegerValue =3D AllocatePool (sizeof (*IntegerValue)); + if (IntegerValue !=3D NULL) { + *IntegerValue =3D (BooleanValue ? 0x01 : 0x00); + ComputerSystemCs->HostWatchdogTimer->FunctionEnabled =3D Integ= erValue; + PropertyChanged =3D TRUE; + } + } + } + } + // + // Handle HOSTWATCHDOGTIMER->TIMEOUTACTION + // + if (PropertyChecker (ComputerSystemCs->HostWatchdogTimer->TimeoutActio= n, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"HostWatchdogTimer/TimeoutAction", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->HostWatchdogTi= mer->TimeoutAction, AsciiStringValue) !=3D 0) { + ComputerSystemCs->HostWatchdogTimer->TimeoutAction =3D AsciiStri= ngValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle HOSTWATCHDOGTIMER->WARNINGACTION + // + if (PropertyChecker (ComputerSystemCs->HostWatchdogTimer->WarningActio= n, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"HostWatchdogTimer/WarningAction", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->HostWatchdogTi= mer->WarningAction, AsciiStringValue) !=3D 0) { + ComputerSystemCs->HostWatchdogTimer->WarningAction =3D AsciiStri= ngValue; + PropertyChanged =3D TRUE; + } + } + } + } + + // + // Handle HOSTEDSERVICES + // + if (ComputerSystemCs->HostedServices !=3D NULL) { + } + + // + // Handle HOSTINGROLES + // +//// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle INDICATORLED + // + if (PropertyChecker (ComputerSystemCs->IndicatorLED, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"IndicatorLED", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->IndicatorLED, As= ciiStringValue) !=3D 0) { + ComputerSystemCs->IndicatorLED =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle MANUFACTURER + // + if (PropertyChecker (ComputerSystemCs->Manufacturer, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"Manufacturer", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->Manufacturer, As= ciiStringValue) !=3D 0) { + ComputerSystemCs->Manufacturer =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle MEMORYSUMMARY + // + if (ComputerSystemCs->MemorySummary !=3D NULL) { + // + // Handle MEMORYSUMMARY->MEMORYMIRRORING + // + if (PropertyChecker (ComputerSystemCs->MemorySummary->MemoryMirroring,= ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"MemorySummary/MemoryMirroring", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->MemorySummary-= >MemoryMirroring, AsciiStringValue) !=3D 0) { + ComputerSystemCs->MemorySummary->MemoryMirroring =3D AsciiString= Value; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle MEMORYSUMMARY->TOTALSYSTEMMEMORYGIB + // + if (PropertyChecker (ComputerSystemCs->MemorySummary->TotalSystemMemor= yGiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"MemorySummary/TotalSystemMemoryGiB", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *ComputerSystemCs->MemorySummary->TotalSystem= MemoryGiB !=3D *NumericValue) { + ComputerSystemCs->MemorySummary->TotalSystemMemoryGiB =3D Numeri= cValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle MEMORYSUMMARY->TOTALSYSTEMPERSISTENTMEMORYGIB + // + if (PropertyChecker (ComputerSystemCs->MemorySummary->TotalSystemPersi= stentMemoryGiB, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"MemorySummary/TotalSystemPersistentMemoryGiB", ConfigureL= ang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *ComputerSystemCs->MemorySummary->TotalSystem= PersistentMemoryGiB !=3D *NumericValue) { + ComputerSystemCs->MemorySummary->TotalSystemPersistentMemoryGiB = =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + } + + // + // Handle MODEL + // + if (PropertyChecker (ComputerSystemCs->Model, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"Model", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->Model, AsciiStri= ngValue) !=3D 0) { + ComputerSystemCs->Model =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle PCIEDEVICES + // +//// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle PCIEFUNCTIONS + // +//// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle PARTNUMBER + // + if (PropertyChecker (ComputerSystemCs->PartNumber, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"PartNumber", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->PartNumber, Asci= iStringValue) !=3D 0) { + ComputerSystemCs->PartNumber =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle POWERSTATE + // + if (PropertyChecker (ComputerSystemCs->PowerState, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"PowerState", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->PowerState, Asci= iStringValue) !=3D 0) { + ComputerSystemCs->PowerState =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle PROCESSORSUMMARY + // + if (ComputerSystemCs->ProcessorSummary !=3D NULL) { + // + // Handle PROCESSORSUMMARY->COUNT + // + if (PropertyChecker (ComputerSystemCs->ProcessorSummary->Count, Provis= ionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"ProcessorSummary/Count", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *ComputerSystemCs->ProcessorSummary->Count != =3D *NumericValue) { + ComputerSystemCs->ProcessorSummary->Count =3D NumericValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle PROCESSORSUMMARY->LOGICALPROCESSORCOUNT + // + if (PropertyChecker (ComputerSystemCs->ProcessorSummary->LogicalProces= sorCount, ProvisionMode)) { + NumericValue =3D GetPropertyNumericValue (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, L"ProcessorSummary/LogicalProcessorCount", ConfigureLang); + if (NumericValue !=3D NULL) { + if (ProvisionMode || *ComputerSystemCs->ProcessorSummary->LogicalP= rocessorCount !=3D *NumericValue) { + ComputerSystemCs->ProcessorSummary->LogicalProcessorCount =3D Nu= mericValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle PROCESSORSUMMARY->MODEL + // + if (PropertyChecker (ComputerSystemCs->ProcessorSummary->Model, Provis= ionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOUR= CE_SCHEMA_VERSION, L"ProcessorSummary/Model", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->ProcessorSumma= ry->Model, AsciiStringValue) !=3D 0) { + ComputerSystemCs->ProcessorSummary->Model =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + } + + // + // Handle REDUNDANCY + // +//// ****** Warning ****** +// Unsupported array type: +// + + // + // Handle SKU + // + if (PropertyChecker (ComputerSystemCs->SKU, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SKU", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->SKU, AsciiString= Value) !=3D 0) { + ComputerSystemCs->SKU =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle SERIALNUMBER + // + if (PropertyChecker (ComputerSystemCs->SerialNumber, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SerialNumber", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->SerialNumber, As= ciiStringValue) !=3D 0) { + ComputerSystemCs->SerialNumber =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle SUBMODEL + // + if (PropertyChecker (ComputerSystemCs->SubModel, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SubModel", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->SubModel, AsciiS= tringValue) !=3D 0) { + ComputerSystemCs->SubModel =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle SYSTEMTYPE + // + if (PropertyChecker (ComputerSystemCs->SystemType, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"SystemType", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (ComputerSystemCs->SystemType, Asci= iStringValue) !=3D 0) { + ComputerSystemCs->SystemType =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle TRUSTEDMODULES + // +//// ****** Warning ****** +// Unsupported array type: +// + + + // + // Convert C structure back to JSON text. + // + Status =3D JsonStructProtocol->ToJson ( + JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)Compute= rSystem, + 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 *)ComputerSystem + ); + + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); +} + +EFI_STATUS +ProvisioningComputerSystemResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN UINTN Index, + IN EFI_STRING ConfigureLang + ) +{ + CHAR8 *Json; + EFI_STATUS Status; + EFI_STRING NewResourceLocation; + CHAR8 *EtagStr; + CHAR8 ResourceId[16]; + + if (IS_EMPTY_STRING (ConfigureLang) || Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + EtagStr =3D NULL; + AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index); + + Status =3D ProvisioningComputerSystemProperties ( + Private->JsonStructProtocol, + ComputerSystemEmptyJson, + ResourceId, + ConfigureLang, + TRUE, + &Json + ); + 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, Json, &NewResourceLocation, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, post ComputerSystem resource for %s failed: = %r\n", __FUNCTION__, ConfigureLang, Status)); + goto RELEASE_RESOURCE; + } + + ASSERT (NewResourceLocation !=3D NULL); + + // + // Keep location of new resource. + // + if (NewResourceLocation !=3D NULL) { + RedfisSetRedfishUri (ConfigureLang, NewResourceLocation); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, NewResourceLocation); + FreePool (EtagStr); + } + +RELEASE_RESOURCE: + + if (NewResourceLocation !=3D NULL) { + FreePool (NewResourceLocation); + } + + if (Json !=3D NULL) { + FreePool (Json); + } + + return Status; +} + +EFI_STATUS +ProvisioningComputerSystemResources ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private + ) +{ + UINTN Index; + EFI_STATUS Status; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST UnifiedConfigureLangList; + + if (Private =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 configure languag= e: %s: %r\n", __FUNCTION__, REDPATH_ARRAY_PATTERN, Status)); + return EFI_NOT_FOUND; + } + // + // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE. + // This information is sent back to the parent resource (e.g. the collec= tion driver). + // + EdkIIRedfishResourceSetConfigureLang (&UnifiedConfigureLangList); + + for (Index =3D 0; Index < UnifiedConfigureLangList.Count; Index++) { + DEBUG ((DEBUG_INFO, "[%d] create ComputerSystem resource from: %s\n", = UnifiedConfigureLangList.List[Index].Index, UnifiedConfigureLangList.List[I= ndex].ConfigureLang)); + ProvisioningComputerSystemResource (Private, UnifiedConfigureLangList.= List[Index].Index, UnifiedConfigureLangList.List[Index].ConfigureLang); + FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang); + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +ProvisioningComputerSystemExistResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private + ) +{ + EFI_STATUS Status; + EFI_STRING ConfigureLang; + CHAR8 *EtagStr; + CHAR8 *Json; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + EtagStr =3D NULL; + Json =3D NULL; + ConfigureLang =3D NULL; + + ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); + if (ConfigureLang =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Status =3D ProvisioningComputerSystemProperties ( + Private->JsonStructProtocol, + ComputerSystemEmptyJson, + NULL, + ConfigureLang, + TRUE, + &Json + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_NOT_FOUND) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for= %s ignored. Nothing changed\n", __FUNCTION__, ConfigureLang)); + } else { + DEBUG ((DEBUG_ERROR, "%a, provisioning existing resource for %s fail= ed: %r\n", __FUNCTION__, ConfigureLang, Status)); + } + goto ON_RELEASE; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for %s\= n", __FUNCTION__, ConfigureLang)); + // + // PUT back to instance + // + Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __FUNCT= ION__, ConfigureLang, Status)); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, Private->Uri); + FreePool (EtagStr); + } + +ON_RELEASE: + + if (Json !=3D NULL) { + FreePool (Json); + } + + if (ConfigureLang !=3D NULL) { + FreePool (ConfigureLang); + } + + return Status; +} + +/** + Provisioning redfish resource by given URI. + + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL = instance. + @param[in] ResourceExist TRUE if resource exists, PUT method 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 ? ProvisioningComputerSystemExistResource (Private= ) : ProvisioningComputerSystemResources (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; + + 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 (Private->Uri, ConfigureLang= List[Index]); + if (Property =3D=3D NULL) { + continue; + } + + DEBUG ((DEBUG_INFO, "%a, [%d] check attribute for: %s\n", __FUNCTION__= , Index, Property)); + if (!MatchPropertyWithJsonContext (Property, Json)) { + DEBUG ((DEBUG_INFO, "%a, property is missing: %s\n", __FUNCTION__, P= roperty)); + Status =3D EFI_NOT_FOUND; + } + } + + 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 *InputJson + ) +{ + EFI_STATUS Status; + CHAR8 *Json; + EFI_STRING ConfigureLang; + CHAR8 *EtagStr; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (InputJson)) { + return EFI_INVALID_PARAMETER; + } + + EtagStr =3D NULL; + Json =3D NULL; + ConfigureLang =3D NULL; + + ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); + if (ConfigureLang =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Status =3D ProvisioningComputerSystemProperties ( + Private->JsonStructProtocol, + InputJson, + NULL, + ConfigureLang, + FALSE, + &Json + ); + 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, Json, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __FUNCT= ION__, ConfigureLang, Status)); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, Private->Uri); + FreePool (EtagStr); + } + +ON_RELEASE: + + if (Json !=3D NULL) { + FreePool (Json); + } + + if (ConfigureLang !=3D NULL) { + FreePool (ConfigureLang); + } + + return Status; +} + +/** + Identify 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 +RedfishIdentifyResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *Json + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + EFI_STRING EndOfChar; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigLangList; + + Supported =3D RedfishIdentifyResource (Private->Uri, Private->Json); + if (Supported) { + Status =3D RedfishFeatureGetUnifiedArrayTypeConfigureLang (RESOURCE_SC= HEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigLangList); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, BiosConfigToRedfishGetConfigureLangRegex f= ailed: %r\n", __FUNCTION__, Status)); + return Status; + } + + if (ConfigLangList.Count =3D=3D 0) { + return EFI_SUCCESS; + } + + EndOfChar =3D StrStr (ConfigLangList.List[0].ConfigureLang, L"}"); + if (EndOfChar =3D=3D NULL) { + ASSERT (FALSE); + return EFI_DEVICE_ERROR; + } + + //EndOfChar =3D StrStr (ConfigLangList.List[0].ConfigureLang, L"}"); + Status =3D IsRedpathArray (ConfigLangList.List[0].ConfigureLang, NULL,= &EndOfChar); + if (EFI_ERROR (Status) && Status !=3D EFI_NOT_FOUND) { + ASSERT (FALSE); + return EFI_DEVICE_ERROR; + } + if (Status !=3D EFI_SUCCESS) { + // + // This is not the collection redpath. + // + GetRedpathNodeByIndex (ConfigLangList.List[0].ConfigureLang, 0, &End= OfChar); + } + *(++EndOfChar) =3D '\0'; + // + // Keep URI and ConfigLang mapping + // + RedfisSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private->Ur= i); + // + // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE. + // This information is sent back to the parent resource (e.g. the coll= ection driver). + // + EdkIIRedfishResourceSetConfigureLang (&ConfigLangList); + DestroyConfiglanguageList (&ConfigLangList); + return EFI_SUCCESS; + } + + return EFI_UNSUPPORTED; +} diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Compute= rSystemCommon.h b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Co= mputerSystemCommon.h new file mode 100644 index 0000000000..64efc7fd99 --- /dev/null +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystem= Common.h @@ -0,0 +1,27 @@ +/** @file + + Redfish feature driver implementation - internal header file + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_ +#define EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_ + +#include +#include + +// +// Schema information. +// +#define RESOURCE_SCHEMA "ComputerSystem" +#define RESOURCE_SCHEMA_MAJOR "1" +#define RESOURCE_SCHEMA_MINOR "5" +#define RESOURCE_SCHEMA_ERRATA "0" +#define RESOURCE_SCHEMA_VERSION "v1_5_0" +#define REDPATH_ARRAY_PATTERN L"/Systems/\\{.*\\}/" +#define REDPATH_ARRAY_PREFIX L"/Systems/" +#define RESOURCE_SCHEMA_FULL "x-uefi-redfish-ComputerSystem.v1_5_0" + +#endif diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSy= stemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSys= temDxe.c new file mode 100644 index 0000000000..c2a638d7c0 --- /dev/null +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .c @@ -0,0 +1,645 @@ +/** @file + Redfish feature driver implementation - ComputerSystem + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "../Common/ComputerSystemCommon.h" + +extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate; + +EFI_HANDLE medfishResourceConfigProtocolHandle; + +/** + 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 EFI_STRING 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; + } + + DEBUG ((DEBUG_INFO, "%a, provisioning in %s mode\n", __FUNCTION__, (Post= Mode ? L"POST" : L"PATCH"))); + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); + + if (Private->RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __FUNCTION_= _, Uri)); + return Status; + } + + Private->Uri =3D Uri; + Private->Payload =3D Response.Payload; + ASSERT (Private->Payload !=3D NULL); + + Status =3D RedfishProvisioningResourceCommon (Private, !PostMode); + + // + // 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 EFI_STRING Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + CHAR8 *Etag; + + 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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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); + + // + // Find etag in HTTP response header + // + Etag =3D NULL; + Status =3D GetEtagAndLocation (&Response, &Etag, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __FU= NCTION__)); + } + + Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag); + if (EFI_ERROR (Status)) { + if (Status !=3D EFI_ALREADY_STARTED) { + DEBUG ((DEBUG_ERROR, "%a, failed to consume resource from: %s: %r\n"= , __FUNCTION__, Uri, Status)); + } + } else { + // + // Keep etag after consuming pending settings. + // + if (Etag !=3D NULL) { + SetEtagWithUri (Etag, Private->Uri); + } + } + + // + // 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 EFI_STRING 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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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: %s: %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 EFI_STRING 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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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: %s: %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; +} + +/** + Identify resource on given URI. + + @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI= G_PROTOCOL instance. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS This is target resource which we want t= o handle. + @retval EFI_UNSUPPORTED This is not the target resource. + @retval Others Some error happened. + +**/ + +EFI_STATUS +RedfishResourceIdentify ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN EFI_STRING Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + + if (This =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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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 RedfishIdentifyResourceCommon (Private, Private->Json); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, identify %s failed: %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; +} + +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL mRedfishResourceConfig =3D { + RedfishResourceProvisioningResource, + RedfishResourceConsumeResource, + RedfishResourceUpdate, + RedfishResourceCheck, + RedfishResourceIdentify, + RedfishResourceGetInfo +}; + +/** + Initialize a Redfish configure handler. + + This function will be called by the Redfish config driver to initialize = each Redfish configure + handler. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_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; + } + + medfishResourceConfigProtocolHandle =3D ImageHandle; + + 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/ComputerSystem/v1_5_0/Dxe/ComputerSy= stemDxe.inf b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerS= ystemDxe.inf new file mode 100644 index 0000000000..67412f5f31 --- /dev/null +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .inf @@ -0,0 +1,51 @@ +## @file +# +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D ComputerSystemDxe + FILE_GUID =3D 584bae05-d78d-4df9-b5e9-3e987a99480a + 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/ComputerSystemCommon.h + ../Common/ComputerSystemCommon.c + ComputerSystemDxe.c + +[LibraryClasses] + BaseMemoryLib + DebugLib + EdkIIRedfishResourceConfigLib + RedfishLib + RedfishFeatureUtilityLib + RedfishResourceIdentifyLib + UefiLib + UefiDriverEntryPoint + + +[Protocols] + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED + gEfiRestJsonStructureProtocolGuid ## CONSUMED + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + +[Depex] + TRUE diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 7d5de56591..90240efbf7 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -16,6 +16,7 @@ INF RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf INF RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf + INF RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDx= e.inf INF RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystem= CollectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc @@ -24,5 +25,6 @@ # INF RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf INF RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_= Dxe.inf + INF RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSyst= em_V1_5_0_Dxe.inf INF RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerS= ystemCollection_Dxe.inf !endif diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index d4a33385f6..084796e4b5 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -16,11 +16,16 @@ RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf +!endif # # Below two modules should be pulled in by build tool. # RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf + RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.in= f { + + RedfishResourceIdentifyLib|RedfishClientPkg/Library/RedfishResourceI= dentifyLibComuterSystem/v1_5_0/RedfishResourceIdentifyLibComuterSystem.inf + } RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemColl= ectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc @@ -30,5 +35,5 @@ # RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_Dxe.= inf -!endif + RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSystem_V= 1_5_0_Dxe.inf RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSyste= mCollection_Dxe.inf diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 21595613f5..05ad09ef5e 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -19,6 +19,7 @@ # MemoryV1_7_1Lib|RedfishClientPkg/ConverterLib/edk2library/Memory/v1_7_1/= Lib.inf MemoryCollectionLib|RedfishClientPkg/ConverterLib/edk2library/MemoryColl= ection/Lib.inf + ComputerSystemV1_5_0Lib|RedfishClientPkg/ConverterLib/edk2library/Comput= erSystem/v1_5_0/Lib.inf ComputerSystemCollectionLib|RedfishClientPkg/ConverterLib/edk2library/Co= mputerSystemCollection/Lib.inf =20 NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf --=20 2.32.0.windows.2 -=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 (#91882): https://edk2.groups.io/g/devel/message/91882 Mute This Topic: https://groups.io/mt/92641656/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- From nobody Fri Apr 26 08:47:54 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+91883+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+91883+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658885912; cv=none; d=zohomail.com; s=zohoarc; b=T2Yk5CiMUgmRdTk7To1OaM8QsoFLJ3wgc4VMGHumWJJpxFd7Y4eybtjMn2XpGhqZE8hWpAuPuK5syUHaR1xwF8SZktF5vOsnW6TtKJABeLHAT05w+wmjwgAGrIlN1nnMZgIyMvgtAhK7PJf/OiAZrXs+ShfBBDjwicovOSdubEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658885912; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=J0UoCjxwqr7lGjP1WefAe327JL9Ut7qaGiNBQpCVQHE=; b=mF4Fxuzznahx+qot9IHar1ZbdZbbq8EXT8s6VNwGrudKYOMnXGD+h16SieIHIQx9p35w9aWVMkLfrtcGg2VVDCthZuFJzJS4EeJdmerKJb0CZ64MgslrJUzryxjbjjVBdAWTMu/mzyn4fLFL5imICrzsllbicks//TS8WlgT35w= 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+91883+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 1658885912273681.9943301356041; Tue, 26 Jul 2022 18:38:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id hcx4YY1788612xt0umj9NjIp; Tue, 26 Jul 2022 18:38:31 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.14965.1658885911226123375 for ; Tue, 26 Jul 2022 18:38:31 -0700 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26R0sj2Z019781; Wed, 27 Jul 2022 01:38:29 GMT X-Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3hjqhjsm57-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jul 2022 01:38:29 +0000 X-Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id F118E8001A2; Wed, 27 Jul 2022 01:38:28 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id B0D17804D10; Wed, 27 Jul 2022 01:38:27 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v3 15/15] edk2-staging/RedfishClientPkg: Introduce Bios feature driver Date: Wed, 27 Jul 2022 09:38:02 +0800 Message-Id: <20220727013802.247-16-nickle.wang@hpe.com> In-Reply-To: <20220727013802.247-1-nickle.wang@hpe.com> References: <20220727013802.247-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: baY7iIkASXif3AtWcpYLKiTz1yqN8cuO X-Proofpoint-ORIG-GUID: baY7iIkASXif3AtWcpYLKiTz1yqN8cuO 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,nickle.wang@hpe.com X-Gm-Message-State: 7geQuEKXqYcdgXDkC1IRMVafx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658885911; bh=HVfYIBhilWmL/2Urq7BBEQ9bRDwefMgPs6Nrj/lcrfE=; h=Cc:Date:From:Reply-To:Subject:To; b=gRmwBkwBas18+V+lDcDf9WuVyJgLIgw4rwE2z7lAHiJbPqhOW87otn9At6Cg0YhIqw2 42Fn9HTc3voKExspkx4YrOkUJ1AkS4MfkObvNsyQ+CbKW6Cq9Stg1KpunHA8ac+JG77tJ IryEjTSfNsn8boSGVoj47LhQKBrJYhM7Jws= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658885913118100029 Content-Type: text/plain; charset="utf-8" Introduce new feature driver to support Bios version 1.0.9 schema. Update corresponding FDF and DSC file to enable this feature driver. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../Features/Bios/v1_0_9/Common/BiosCommon.c | 741 ++++++++++++++++ .../Features/Bios/v1_0_9/Common/BiosCommon.h | 30 + .../Features/Bios/v1_0_9/Dxe/BiosDxe.c | 789 ++++++++++++++++++ .../Features/Bios/v1_0_9/Dxe/BiosDxe.inf | 52 ++ RedfishClientPkg/RedfishClient.fdf.inc | 2 + .../RedfishClientComponents.dsc.inc | 2 + RedfishClientPkg/RedfishClientLibs.dsc.inc | 6 +- 7 files changed, 1621 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon= .c create mode 100644 RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon= .h create mode 100644 RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c create mode 100644 RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c b/Re= dfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c new file mode 100644 index 0000000000..d910d0d8a9 --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c @@ -0,0 +1,741 @@ +/** @file + Redfish feature driver implementation - common functions + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "BiosCommon.h" + +CHAR8 BiosEmptyJson[] =3D "{\"@odata.id\": \"\", \"@odata.type\": \"#Bios.= v1_0_9.Bios\", \"Id\": \"\", \"Name\": \"\", \"Attributes\":{}}"; + +REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate =3D NULL; + +/** + Consume resource from given URI. + + @param[in] This Pointer to REDFISH_RESOURCE_COMMON_PRIV= ATE instance. + @param[in] Json The JSON to consume. + @param[in] HeaderEtag The Etag string returned in HTTP header. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishConsumeResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *Json, + IN CHAR8 *HeaderEtag OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_REDFISH_BIOS_V1_0_9 *Bios; + EFI_REDFISH_BIOS_V1_0_9_CS *BiosCs; + EFI_STRING ConfigureLang; + RedfishCS_Type_EmptyProp_CS_Data *EmptyPropCs; + + + if (Private =3D=3D NULL || IS_EMPTY_STRING (Json)) { + return EFI_INVALID_PARAMETER; + } + + Bios =3D NULL; + BiosCs =3D NULL; + ConfigureLang =3D NULL; + + Status =3D Private->JsonStructProtocol->ToStructure ( + Private->JsonStructProtocol, + NULL, + Json, + (EFI_REST_JSON_STRUCTURE_HEADER = **)&Bios + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return Status; + } + + BiosCs =3D Bios->Bios; + + // + // Check ETAG to see if we need to consume it + // + if (CheckEtag (Private->Uri, HeaderEtag, BiosCs->odata_etag)) { + // + // No change + // + DEBUG ((DEBUG_INFO, "%a, ETAG: %s has no change, ignore consume action= \n", __FUNCTION__, Private->Uri)); + Status =3D EFI_ALREADY_STARTED; + goto ON_RELEASE; + } + + // + // Handle ATTRIBUTEREGISTRY + // + if (BiosCs->AttributeRegistry !=3D NULL) { + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (BiosCs->odata_id, "AttributeRegist= ry"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsStringType (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, ConfigureLang, BiosCs->AttributeRegistry); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + // + // Handle ATTRIBUTES + // + if (BiosCs->Attributes =3D=3D NULL) { + BiosCs->Attributes =3D AllocateZeroPool (sizeof (RedfishBios_V1_0_9_At= tributes_CS)); + ASSERT (BiosCs->Attributes !=3D NULL); + } + + // + // Handle ATTRIBUTES->EmptyProperty + // + if (BiosCs->Attributes !=3D NULL) { + // + // Validate empty property. + // + if (BiosCs->Attributes->Prop.ForwardLink =3D=3D &BiosCs->Attributes->P= rop) { + goto ON_RELEASE; + } + EmptyPropCs =3D (RedfishCS_Type_EmptyProp_CS_Data *)BiosCs->Attributes= ->Prop.ForwardLink; + if (EmptyPropCs->Header.ResourceType =3D=3D RedfishCS_Type_JSON) { + DEBUG ((DEBUG_ERROR, "%a, Empty property with RedfishCS_Type_JSON ty= pe resource is not supported yet. (%s)\n", __FUNCTION__, Private->Uri)); + goto ON_RELEASE; + } + // + // Find corresponding configure language for collection resource. + // + ConfigureLang =3D GetConfigureLang (BiosCs->odata_id, "Attributes"); + if (ConfigureLang !=3D NULL) { + Status =3D ApplyFeatureSettingsVagueType (RESOURCE_SCHEMA, RESOURCE_= SCHEMA_VERSION, ConfigureLang, EmptyPropCs->KeyValuePtr, EmptyPropCs->NunmO= fProperties); + 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 URI: %s= \n", __FUNCTION__, Private->Uri)); + } + } + + +ON_RELEASE: + + // + // Release resource. + // + Private->JsonStructProtocol->DestoryStructure ( + Private->JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)Bios + ); + + return EFI_SUCCESS; +} + +EFI_STATUS +ProvisioningBiosProperties ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, + IN CHAR8 *InputJson, + IN CHAR8 *ResourceId, OPTIONAL + IN EFI_STRING ConfigureLang, + IN BOOLEAN ProvisionMode, + OUT CHAR8 **ResultJson + ) +{ + EFI_REDFISH_BIOS_V1_0_9 *Bios; + EFI_REDFISH_BIOS_V1_0_9_CS *BiosCs; + EFI_STATUS Status; + BOOLEAN PropertyChanged; + CHAR8 *AsciiStringValue; + RedfishCS_EmptyProp_KeyValue *PropertyVagueValues; + UINT32 VagueValueNumber; + + + + if (JsonStructProtocol =3D=3D NULL || ResultJson =3D=3D NULL || IS_EMPTY= _STRING (InputJson) || 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 resource" : L"Update resou= rce"))); + + *ResultJson =3D NULL; + PropertyChanged =3D FALSE; + + Bios =3D NULL; + Status =3D JsonStructProtocol->ToStructure ( + JsonStructProtocol, + NULL, + InputJson, + (EFI_REST_JSON_STRUCTURE_HEADER **)&Bios + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure failure: %r\n", __FUNCTION__, St= atus)); + return Status; + } + + BiosCs =3D Bios->Bios; + + // + // ID + // + if (BiosCs->Id =3D=3D NULL && !IS_EMPTY_STRING (ResourceId)) { + BiosCs->Id =3D AllocateCopyPool (AsciiStrSize (ResourceId), ResourceId= ); + } + + // + // Handle ATTRIBUTEREGISTRY + // + if (PropertyChecker (BiosCs->AttributeRegistry, ProvisionMode)) { + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, RESOURCE= _SCHEMA_VERSION, L"AttributeRegistry", ConfigureLang); + if (AsciiStringValue !=3D NULL) { + if (ProvisionMode || AsciiStrCmp (BiosCs->AttributeRegistry, AsciiSt= ringValue) !=3D 0) { + BiosCs->AttributeRegistry =3D AsciiStringValue; + PropertyChanged =3D TRUE; + } + } + } + // + // Handle ATTRIBUTES + // + if (BiosCs->Attributes !=3D NULL) { + // + // Handle ATTRIBUTES + // + if (PropertyChecker (BiosCs->Attributes, ProvisionMode)) { + PropertyVagueValues =3D GetPropertyVagueValue (RESOURCE_SCHEMA, RESO= URCE_SCHEMA_VERSION, L"Attributes", ConfigureLang, &VagueValueNumber); + if (PropertyVagueValues !=3D NULL) { + if (ProvisionMode || !CompareRedfishPropertyVagueValues ( + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs= ->Attributes->Prop.ForwardLink)->KeyValuePtr, + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs= ->Attributes->Prop.ForwardLink)->NunmOfProperties, + PropertyVagueValues, + VagueValueNumber)) { + // + // Use the properties on system to replace the one on Redfish se= rvice. + // + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs->Attributes->Prop.Fo= rwardLink)->KeyValuePtr =3D PropertyVagueValues; + ((RedfishCS_Type_EmptyProp_CS_Data *)BiosCs->Attributes->Prop.Fo= rwardLink)->NunmOfProperties =3D VagueValueNumber; + PropertyChanged =3D TRUE; + } + } + } + } + + + // + // Convert C structure back to JSON text. + // + Status =3D JsonStructProtocol->ToJson ( + JsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)Bios, + 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 *)Bios + ); + + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); +} + +EFI_STATUS +ProvisioningBiosResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN UINTN Index, + IN EFI_STRING ConfigureLang + ) +{ + CHAR8 *Json; + EFI_STATUS Status; + EFI_STRING NewResourceLocation; + CHAR8 *EtagStr; + CHAR8 ResourceId[16]; + + if (IS_EMPTY_STRING (ConfigureLang) || Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + EtagStr =3D NULL; + AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index); + + Status =3D ProvisioningBiosProperties ( + Private->JsonStructProtocol, + BiosEmptyJson, + ResourceId, + ConfigureLang, + TRUE, + &Json + ); + 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, Json, &NewResourceLocation, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", __F= UNCTION__, ConfigureLang, Status)); + goto RELEASE_RESOURCE; + } + + ASSERT (NewResourceLocation !=3D NULL); + + // + // Keep location of new resource. + // + if (NewResourceLocation !=3D NULL) { + RedfisSetRedfishUri (ConfigureLang, NewResourceLocation); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, NewResourceLocation); + FreePool (EtagStr); + } + +RELEASE_RESOURCE: + + if (NewResourceLocation !=3D NULL) { + FreePool (NewResourceLocation); + } + + if (Json !=3D NULL) { + FreePool (Json); + } + + return Status; +} + +EFI_STATUS +ProvisioningBiosResources ( + 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 configure languag= e: %s: %r\n", __FUNCTION__, REDPATH_ARRAY_PATTERN, Status)); + return EFI_NOT_FOUND; + } + // + // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE. + // This information is sent back to the parent resource (e.g. the collec= tion driver). + // + EdkIIRedfishResourceSetConfigureLang (&UnifiedConfigureLangList); + + for (Index =3D 0; Index < UnifiedConfigureLangList.Count; Index++) { + DEBUG ((DEBUG_INFO, "[%d] create Bios resource from: %s\n", UnifiedCon= figureLangList.List[Index].Index, UnifiedConfigureLangList.List[Index].Conf= igureLang)); + ProvisioningBiosResource (Private, UnifiedConfigureLangList.List[Index= ].Index, UnifiedConfigureLangList.List[Index].ConfigureLang); + FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang); + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +ProvisioningBiosExistResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private + ) +{ + EFI_STATUS Status; + EFI_STRING ConfigureLang; + CHAR8 *EtagStr; + CHAR8 *Json; + + if (Private =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + EtagStr =3D NULL; + Json =3D NULL; + ConfigureLang =3D NULL; + + ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); + if (ConfigureLang =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Status =3D ProvisioningBiosProperties ( + Private->JsonStructProtocol, + BiosEmptyJson, + NULL, + ConfigureLang, + TRUE, + &Json + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_NOT_FOUND) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for= %s ignored. Nothing changed\n", __FUNCTION__, ConfigureLang)); + } else { + DEBUG ((DEBUG_ERROR, "%a, provisioning existing resource for %s fail= ed: %r\n", __FUNCTION__, ConfigureLang, Status)); + } + goto ON_RELEASE; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for %s\= n", __FUNCTION__, ConfigureLang)); + // + // PUT back to instance + // + Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __FUNCT= ION__, ConfigureLang, Status)); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, Private->Uri); + FreePool (EtagStr); + } + +ON_RELEASE: + + if (Json !=3D NULL) { + FreePool (Json); + } + + if (ConfigureLang !=3D NULL) { + FreePool (ConfigureLang); + } + + return Status; +} + +/** + Provisioning redfish resource by given URI. + + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCOL = instance. + @param[in] ResourceExist TRUE if resource exists, PUT method 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 ? ProvisioningBiosExistResource (Private) : Provis= ioningBiosResources (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; + + 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 (Private->Uri, ConfigureLang= List[Index]); + if (Property =3D=3D NULL) { + continue; + } + + DEBUG ((DEBUG_INFO, "%a, [%d] check attribute for: %s\n", __FUNCTION__= , Index, Property)); + if (!MatchPropertyWithJsonContext (Property, Json)) { + DEBUG ((DEBUG_INFO, "%a, property is missing: %s\n", __FUNCTION__, P= roperty)); + Status =3D EFI_NOT_FOUND; + } + } + + 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 *InputJson + ) +{ + EFI_STATUS Status; + CHAR8 *Json; + EFI_STRING ConfigureLang; + CHAR8 *EtagStr; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (InputJson)) { + return EFI_INVALID_PARAMETER; + } + + EtagStr =3D NULL; + Json =3D NULL; + ConfigureLang =3D NULL; + + ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); + if (ConfigureLang =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Status =3D ProvisioningBiosProperties ( + Private->JsonStructProtocol, + InputJson, + NULL, + ConfigureLang, + FALSE, + &Json + ); + 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, Json, &EtagStr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, patch resource for %s failed: %r\n", __FUNCT= ION__, ConfigureLang, Status)); + } + + // + // Handle Etag + // + if (EtagStr !=3D NULL) { + SetEtagWithUri (EtagStr, Private->Uri); + FreePool (EtagStr); + } + +ON_RELEASE: + + if (Json !=3D NULL) { + FreePool (Json); + } + + if (ConfigureLang !=3D NULL) { + FreePool (ConfigureLang); + } + + return Status; +} + +/** + Identify 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 +RedfishIdentifyResourceCommon ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN CHAR8 *Json + ) +{ + BOOLEAN Supported; + EFI_STATUS Status; + EFI_STRING EndOfChar; + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigLangList; + + Supported =3D RedfishIdentifyResource (Private->Uri, Private->Json); + if (Supported) { + Status =3D RedfishFeatureGetUnifiedArrayTypeConfigureLang (RESOURCE_SC= HEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigLangList); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, BiosConfigToRedfishGetConfigureLangRegex f= ailed: %r\n", __FUNCTION__, Status)); + return Status; + } + + if (ConfigLangList.Count =3D=3D 0) { + return EFI_SUCCESS; + } + + //EndOfChar =3D StrStr (ConfigLangList.List[0].ConfigureLang, L"}"); + Status =3D IsRedpathArray (ConfigLangList.List[0].ConfigureLang, NULL,= &EndOfChar); + if (EFI_ERROR (Status) && Status !=3D EFI_NOT_FOUND) { + ASSERT (FALSE); + return EFI_DEVICE_ERROR; + } + if (Status !=3D EFI_SUCCESS) { + // + // This is not the collection redpath. + // + GetRedpathNodeByIndex (ConfigLangList.List[0].ConfigureLang, 0, &End= OfChar); + } + *(++EndOfChar) =3D '\0'; + // + // Keep URI and ConfigLang mapping + // + RedfisSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private->Ur= i); + // + // Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE. + // This information is sent back to the parent resource (e.g. the coll= ection driver). + // + EdkIIRedfishResourceSetConfigureLang (&ConfigLangList); + DestroyConfiglanguageList (&ConfigLangList); + return EFI_SUCCESS; + } + + return EFI_UNSUPPORTED; +} + +EFI_STATUS +HandleResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN EFI_STRING Uri + ) +{ + EFI_STATUS Status; + REDFISH_SCHEMA_INFO SchemaInfo; + EFI_STRING ConfigLang; + + if (Private =3D=3D NULL || IS_EMPTY_STRING (Uri)) { + return EFI_INVALID_PARAMETER; + } + + // + // Resource match + // + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\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: %s %r= \n", __FUNCTION__, Uri, Status)); + return Status; + } + // + // Check and see if this is target resource that we want to handle. + // Some resource is handled by other provider so we have to make sure th= is first. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%s Identify for %s\n", __FUNCTION__, Uri)); + ConfigLang =3D RedfishGetConfigLanguage (Uri); + if (ConfigLang =3D=3D NULL) { + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_INFO, "%a, \"%s\" is not handled by us\n", __FUNCTIO= N__, Uri)); + return EFI_SUCCESS; + } + + DEBUG ((DEBUG_ERROR, "%a, fail to identify resource: \"%s\": %r\n", = __FUNCTION__, Uri, Status)); + return Status; + } + } else { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, history record found: %s\n", __FUNCT= ION__, ConfigLang)); + FreePool (ConfigLang); + } + + // + // 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 %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, 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 %s\n", __FUNCTION__, Ur= i)); + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, = Private->InformationExchange, 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 %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %s: %r\n", _= _FUNCTION__, Uri, Status)); + } + + // + // Patch. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to update resoruce for: %s: %r\n", __= FUNCTION__, Uri, Status)); + } + + return Status; +} diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.h b/Re= dfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.h new file mode 100644 index 0000000000..321ded7637 --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.h @@ -0,0 +1,30 @@ +/** @file + + Redfish feature driver implementation - internal header file + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EFI_REDFISH_BIOS_COMMON_H_ +#define EFI_REDFISH_BIOS_COMMON_H_ + +#include +#include + +// +// Schema information. +// +#define REDFISH_MANAGED_URI L"Systems/{}/Bios" +#define MAX_URI_LENGTH 256 +#define RESOURCE_SCHEMA "Bios" +#define RESOURCE_SCHEMA_MAJOR "1" +#define RESOURCE_SCHEMA_MINOR "0" +#define RESOURCE_SCHEMA_ERRATA "9" +#define RESOURCE_SCHEMA_VERSION "v1_0_9" +#define REDPATH_ARRAY_PATTERN L"/Bios/.*" +#define REDPATH_ARRAY_PREFIX L"/Bios/" +#define RESOURCE_SCHEMA_FULL "x-uefi-redfish-Bios.v1_0_9" +#define REDFISH_SCHEMA_NAME "ComputerSystem" + +#endif diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c b/RedfishC= lientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c new file mode 100644 index 0000000000..a478061cde --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c @@ -0,0 +1,789 @@ +/** @file + Redfish feature driver implementation - Bios + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "../Common/BiosCommon.h" + +extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate; + +EFI_STATUS +HandleResource ( + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, + IN EFI_STRING Uri + ); + +EFI_HANDLE medfishResourceConfigProtocolHandle; + +/** + 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 EFI_STRING 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; + } + + DEBUG ((DEBUG_INFO, "%a, provisioning in %s mode\n", __FUNCTION__, (Post= Mode ? L"POST" : L"PATCH"))); + + Private =3D REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL = (This); + + if (Private->RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __FUNCTION_= _, Uri)); + return Status; + } + + Private->Uri =3D Uri; + Private->Payload =3D Response.Payload; + ASSERT (Private->Payload !=3D NULL); + + Status =3D RedfishProvisioningResourceCommon (Private, !PostMode); + + // + // 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 EFI_STRING Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + CHAR8 *Etag; + + 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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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); + + // + // Find etag in HTTP response header + // + Etag =3D NULL; + Status =3D GetEtagAndLocation (&Response, &Etag, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __FU= NCTION__)); + } + + Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag); + if (EFI_ERROR (Status)) { + if (Status !=3D EFI_ALREADY_STARTED) { + DEBUG ((DEBUG_ERROR, "%a, failed to consume resource from: %s: %r\n"= , __FUNCTION__, Uri, Status)); + } + } else { + // + // Keep etag after consuming pending settings. + // + if (Etag !=3D NULL) { + SetEtagWithUri (Etag, Private->Uri); + } + } + + // + // 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 EFI_STRING 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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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: %s: %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 EFI_STRING 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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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: %s: %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; +} + +/** + Identify resource on given URI. + + @param[in] This Pointer to EDKII_REDFISH_RESOURCE_CONFI= G_PROTOCOL instance. + @param[in] Uri The target URI to consume. + + @retval EFI_SUCCESS This is target resource which we want t= o handle. + @retval EFI_UNSUPPORTED This is not the target resource. + @retval Others Some error happened. + +**/ + +EFI_STATUS +RedfishResourceIdentify ( + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, + IN EFI_STRING Uri + ) +{ + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STATUS Status; + REDFISH_RESPONSE Response; + + if (This =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 GetResourceByUri (Private->RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, get resource from: %s 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 RedfishIdentifyResourceCommon (Private, Private->Json); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, identify %s failed: %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; +} + +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL mRedfishResourceConfig =3D { + RedfishResourceProvisioningResource, + RedfishResourceConsumeResource, + RedfishResourceUpdate, + RedfishResourceCheck, + RedfishResourceIdentify, + RedfishResourceGetInfo +}; + +/** + Initialize a Redfish configure handler. + + This function will be called by the Redfish config driver to initialize = each Redfish configure + handler. + + @param[in] This Pointer to EDKII_REDFISH_CONFIG_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; +} + +/** + 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] Uri The collection URI. + @param[in] Context The context of Redfish feature driver. + @param[in,out] InformationExchange The pointer to RESOURCE_INFORMATION_E= XCHANGE + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalResourceResourceFeatureCallback ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN FEATURE_CALLBACK_ACTION FeatureAction, + IN VOID *Context, + IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange + ) +{ + EFI_STATUS Status; + REDFISH_SERVICE RedfishService; + REDFISH_RESOURCE_COMMON_PRIVATE *Private; + EFI_STRING ResourceUri; + + if (FeatureAction !=3D CallbackActionStartOperation) { + return EFI_UNSUPPORTED; + } + + Private =3D (REDFISH_RESOURCE_COMMON_PRIVATE *)Context; + + RedfishService =3D Private->RedfishService; + if (RedfishService =3D=3D NULL) { + return EFI_NOT_READY; + } + + // + // Save in private structure. + // + Private->InformationExchange =3D InformationExchange; + + // + // Find Redfish version on BMC + // + Private->RedfishVersion =3D RedfishGetVersion (RedfishService); + + // + // Create the full URI from Redfish service root. + // + ResourceUri =3D (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof(CH= AR16)); + if (ResourceUri =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for full URI.\n", __= FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion); + StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange->SendInformati= on.FullUri); + + // + // Initialize collection path + // + Private->Uri =3D RedfishGetUri (ResourceUri); + if (Private->Uri =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + + Status =3D HandleResource (Private, Private->Uri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, process external resource: %a failed: %r\n",= __FUNCTION__, Private->Uri, Status)); + } + + FreePool (Private->Uri); + return Status; +} + +/** + 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 (mRedfishResourcePrivate =3D=3D NULL) { + return; + } + + if (mRedfishResourcePrivate->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, + RedfishExternalResourceResourceFeatureCallba= ck, + (VOID *)mRedfishResourcePrivate + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to register %s: %r\n", __FUNCTION__, = REDFISH_MANAGED_URI, Status)); + } + + mRedfishResourcePrivate->FeatureProtocol =3D FeatureProtocol; + + gBS->CloseEvent (Event); +} + +/** + 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; + } + + medfishResourceConfigProtocolHandle =3D ImageHandle; + + 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 + ); + + EfiCreateProtocolNotifyEvent ( + &gEdkIIRedfishFeatureProtocolGuid, + TPL_CALLBACK, + EdkIIRedfishFeatureProtocolIsReady, + (VOID *)mRedfishResourcePrivate, + &Registration + ); + + return Status; +} diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf b/Redfis= hClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf new file mode 100644 index 0000000000..8c01a3b877 --- /dev/null +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf @@ -0,0 +1,52 @@ +## @file +# +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BiosDxe + FILE_GUID =3D d6c99bb0-ca18-45aa-8be6-a60c3ba5ecd8 + 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/BiosCommon.h + ../Common/BiosCommon.c + BiosDxe.c + +[LibraryClasses] + BaseMemoryLib + DebugLib + EdkIIRedfishResourceConfigLib + RedfishLib + RedfishFeatureUtilityLib + RedfishVersionLib + RedfishResourceIdentifyLib + UefiLib + UefiDriverEntryPoint + +[Protocols] + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED + gEfiRestJsonStructureProtocolGuid ## CONSUMED + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED + gEdkIIRedfishFeatureProtocolGuid ## CONSUMED + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize + +[Depex] + TRUE diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 90240efbf7..fa4e53898b 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -18,6 +18,7 @@ INF RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf INF RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDx= e.inf INF RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystem= CollectionDxe.inf + INF RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc # @@ -27,4 +28,5 @@ INF RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_= Dxe.inf INF RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSyst= em_V1_5_0_Dxe.inf INF RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerS= ystemCollection_Dxe.inf + INF RedfishClientPkg/Converter/Bios/v1_0_9/RedfishBios_V1_0_9_Dxe.inf !endif diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index 084796e4b5..e83f4bc9bf 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -27,6 +27,7 @@ RedfishResourceIdentifyLib|RedfishClientPkg/Library/RedfishResourceI= dentifyLibComuterSystem/v1_5_0/RedfishResourceIdentifyLibComuterSystem.inf } RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemColl= ectionDxe.inf + RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc =20 @@ -37,3 +38,4 @@ RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_Dxe.= inf RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSystem_V= 1_5_0_Dxe.inf RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSyste= mCollection_Dxe.inf + RedfishClientPkg/Converter/Bios/v1_0_9/RedfishBios_V1_0_9_Dxe.inf diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 05ad09ef5e..fe0c4b0885 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -15,12 +15,16 @@ !endif =20 # - # Below two modules should be pulled in by build tool. + # Below modules should be pulled in by build tool. # MemoryV1_7_1Lib|RedfishClientPkg/ConverterLib/edk2library/Memory/v1_7_1/= Lib.inf MemoryCollectionLib|RedfishClientPkg/ConverterLib/edk2library/MemoryColl= ection/Lib.inf ComputerSystemV1_5_0Lib|RedfishClientPkg/ConverterLib/edk2library/Comput= erSystem/v1_5_0/Lib.inf ComputerSystemCollectionLib|RedfishClientPkg/ConverterLib/edk2library/Co= mputerSystemCollection/Lib.inf + BiosV1_0_9Lib|RedfishClientPkg/ConverterLib/edk2library/Bios/v1_0_9/Lib.= inf + # + # Above modules should be pulled in by build tool. + # =20 NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf HttpLib|NetworkPkg/Library/DxeHttpLib/DxeHttpLib.inf --=20 2.32.0.windows.2 -=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 (#91883): https://edk2.groups.io/g/devel/message/91883 Mute This Topic: https://groups.io/mt/92641659/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-