From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E5BB3940EF2 for ; Fri, 26 Jan 2024 02:45:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=eVoi0D7uIBtM0vE1/ByjVqVX/XpByrj+IaRpLGnFcWs=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706237120; v=1; b=XvUQhKB99T5hcQD9hZyjInV6DLEZweIe1BVFJAsWqUa6SClmDeQYKN+pDRI9vCn40RZFHnZS iPnVl9nluSGCpuHAUNkJxqLl1aMwoXgN9JC8D8msxJ9Mb2ZQPil8a9eUxGbw0zpIm6m8qmYU9xM QBzUqTDamQ3Po+vWqvwy6AB8= X-Received: by 127.0.0.2 with SMTP id JzA2YY7687511x0dxKIiAV9l; Thu, 25 Jan 2024 18:45:20 -0800 X-Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.62]) by mx.groups.io with SMTP id smtpd.web10.6811.1706237119540842484 for ; Thu, 25 Jan 2024 18:45:19 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TYt7aB99wjvar+U8NjLu1ASAxRcTSXhCKQP3yG7pL0dhMerW6KE2z8b8u8wuHjvIgLSs3KxfNM7dk1eRkV4Eglb/4156bOC/dgyOoikl0OZywkjADO+vHCn2hJTvTZd9ieNQfNNXgkGxClQP+hvnwb4eD+0PmJEyMs8FVpoG7ghPRcgdTzHvBTd+XAOXxrg7HU5+8Ulf+1QQ5RRa9r5WYYxe5quSxJpJEKwNw84WPDiNYgRZRCdqtunwATnbDu0h7hM4lvYYKnPeVIRutU8s/CRSZzIgf5BiklbO77ODaBVupUMoYy//iegZuQalODlXOUDfsDMfZcZrAYRzCw9m3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kNq+O+8NsuIzkZbWpTKLbxi654bDjZY4xw+oroemr/4=; b=IyHYK26nzd2MlxSWUuZ5eIcVuEsgSzJlMc2X4kIexmdlwXrR7F1GaxzKtuxjlUphOLs73P3bui9kDQGVjNxkHSAgqZ7ICX6kQrAGPl7XJSOeV4jLHSH+nic3yojic49DjGITK5p8D4DkxsLNfN8PKcYFDuNdb2PmnBTLT/zgNtKtZHpynB6xTHNd6w8mTqsBPpR3YmrnVJP/mQU3sn9giCV5h7RJyMcy/K5JjQD4PX8jKvEprjShJA8IuIrtf2v0QaAhEKqk92FVnSVOMbKik+jk1lmzt0CqdNJPZPTfcCtfNjLXHkeaWBCdd0qxTwuNQB6Zpy40sjDQI/EsVK9ZTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by SA1PR12MB7443.namprd12.prod.outlook.com (2603:10b6:806:2b7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Fri, 26 Jan 2024 02:45:15 +0000 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::aa79:3ab0:fbcd:d61b]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::aa79:3ab0:fbcd:d61b%5]) with mapi id 15.20.7228.027; Fri, 26 Jan 2024 02:45:15 +0000 From: "Nickle Wang via groups.io" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Igor Kulchytskyy Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V3] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver Thread-Topic: [edk2-redfish-client][PATCH V3] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver Thread-Index: AQHaT//TExbmG8xOP0GmEDLVa2TP+LDrY0mA Date: Fri, 26 Jan 2024 02:45:15 +0000 Message-ID: References: <20240126023130.1293-1-abner.chang@amd.com> In-Reply-To: <20240126023130.1293-1-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|SA1PR12MB7443:EE_ x-ms-office365-filtering-correlation-id: 68453176-a96c-4b02-cc07-08dc1e18d366 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 5gSI6Vb0yp+76veWNt6O1xIL+UBidlN2kbA1sVyXmag8Vec1H0vE60b87O43SX//Pf5MntBBWTJDr+yOKeUeaXZ6llQnBpXSrOAvL2xO/p6iOnsO8tbIbe8ZLVI5UUpkX+G0f0KDG3i8Wm3r8PLT3DOG5qdDPQpNr8dzS6pEnhcRfi/p0UvkkNplc/faB1gsOCgP6Uc19721prDHm/vQZOZpE6N5B1kB33x5RhlcV+4ToDGPoI8/vyKprUfz2NVhXvs0t3s1/KydNOi8wJOP95mH1J+rWSzFjWTBoagvomcLyrxQwgisf+YMaTPiW357myYGJIVyMP6Ivu+c6mBOoD0VzPFBNoa9JQ/RVTioPNQvCjIsmPpHwQY/Ia2yVydAauGr0jJFRCMxW0454DfO4BXyOn/bNFJX+nht87nuYtHvlqSGzkOrQ4r7Yhva31GUvOWQl1WbR57ZRdkA5lHCoQjEvVftO3aQAIJyHf5i1OqJQ5XiJh76aX1Zbr5IMn3QoNoLm4POvc0aeQZSu3NinKlRJQO9p0LBrpzJcm8DmFTnnnysqX7rgRT03eZTHc1fZ00Kii1D/JGc3/feypCMUkrRQ93+1n6LKQ5oeSwqq18KxvHnuQIeGRg52CNEr+Bv8Ct7d2B/78FyNfQwg+Y8IumYISTdLHJPo/UQ2sxFQxxIVdwjM3kSP+Mf8xlu5A8m x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?k7iP6NSED8Ti0khQSl+0Hl6/h8EgsLXqPLHDWNbeSNbxIzIHosDgTXJOFvcY?= =?us-ascii?Q?0dRu85AcJrVVF8Jt5D6j7S7KCy2db0a/TSfg4KIMIYFLs99nQUQHPuDUOIoR?= =?us-ascii?Q?edPel5YX/c1iCHiE/bphUQoeFrRcsUXHh0gPkzbNZMMiLXQDcxyCQrY+X6ki?= =?us-ascii?Q?LsAZ/1OlSIQnUSwSBKM3KYW9kSuYSpV72rWDnQ/2OKYoDF2JU+kFdarD+6U1?= =?us-ascii?Q?Yv75JLCGFobqJ3RFXZXRCtfu44/j5K/oTpDSbPckGLjmNg1+fkX7p1RgyIyU?= =?us-ascii?Q?1TS9AbM0Gptm70KSbE1YiYzAw4ey7ahxHtanl88kCr9nkGx7fG6v+JskH9dx?= =?us-ascii?Q?I3eMSsT5km3ocnZCur5GD1cYiG6pDvjvlZ+ceQJEBfMmaHuCq+u35bQy4rCh?= =?us-ascii?Q?VNLQL3Qh4ucwcwKdy+6NEl+e25DkSttZGk1BPm6FL3/9jeu3Q7ZmgLrj95mi?= =?us-ascii?Q?w7r/69dFdcpgBgOLbLCZOnq9fo/NyqeameBEBV6mZHMza76VvhPCNTIUfkbT?= =?us-ascii?Q?GKzqEzUlFAWvhCDFSNW96A2JJBez3VmaycJC8m6KgT+4ljhu5CSeR5g9JBME?= =?us-ascii?Q?KDnrV5PimMBBLSOLdBEQr1qX4avHbpwKUEun5rg2RBtPT1WRy/7xGOP/4UMV?= =?us-ascii?Q?++MWsTBxeI+TA4AZboB94s6lguuyPSFoUYSVl26xOH/JOEiv1LQ+LXQwtnF/?= =?us-ascii?Q?KkCkFmwbdUp6x4o4Lc1XWRT/mq1U0Eig6Gzl5d7CZUqvwoUsXHg1tMLhc7wG?= =?us-ascii?Q?qTs49lZGr9GPIriZkEo3otLKTQ2SgoEOpIzVbsML61ZydxcyS9GQiUDPm6wQ?= =?us-ascii?Q?lI69j6Wv1mCSYYx3hu+MpNCgFABuW9u5njBig8zIT0HjdVKwPd+4qTWAXCSd?= =?us-ascii?Q?Adw9qtfvanX/5cn7t8uORK78bx8nXsgXox0iNbUjSvzt5FOxq4g42hdPNATk?= =?us-ascii?Q?4h600RFsVOvuTnmCvo9S2fXGDBA8hIiJYUoy+B/2EqwBQvwSic1e/L0S9Mk+?= =?us-ascii?Q?md2aPVF3J9RtWRqie4USn1ZcgsxMlPC+tLmSdTWpBlkX5SyoVn8QRAu2aNAK?= =?us-ascii?Q?5nEDm1gUcDVVw0Z1MhmWR9COFrKHIukYtnCqVmncba/2PAAjCD1WK8CGRS/N?= =?us-ascii?Q?A3MmURMXis5ZAzq6WenNN6hNe1Y7ntVMDvc3zKOb9jAMjhI0OJG0ve1gFlis?= =?us-ascii?Q?S4A4BADhnh4BNAXRILEPhAgqAt56SqWA01nAy7ypetdak6tMN/J1xewUuRhz?= =?us-ascii?Q?E3F2kxYeJbE1hQ5EjMXuATkzX7lfnuKsPbSv8UZYNFETOz8YB4YqhP68yio5?= =?us-ascii?Q?pNfwu1l0pTpURBfcGWCnCRWpisiPMnUbLEOeTmvebb9w5nawyubKtfUWcPyl?= =?us-ascii?Q?7m5xipJUBJEb0licIDKfuvch/BslfAje/8bhztnU2ZjpLfTMBINgqOJy4z9D?= =?us-ascii?Q?6FCcQeJLO1hBA1EmVq9V+RJCQW41OEOQXO+qsMYxnPh3y8CWFoWMFzSZoIXV?= =?us-ascii?Q?jDXJ2uBJbgpRUABNXAzUmwoOX4XmONKJem9Wg8H68NvfVQirJPoBd44YV3AN?= =?us-ascii?Q?WrHy6o4sv8tmvj2JD/PZoAuH/zsoK66Lmf1HIdG4lpvDOzWeWqOioI1z01gQ?= =?us-ascii?Q?NYJKc6iRfSYUXPOFC0OpzgWSVlK00fvGxO3YY42TfGOz?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68453176-a96c-4b02-cc07-08dc1e18d366 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jan 2024 02:45:15.3930 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7Qd5MTQCHDrBQVfTbMdRFIPumsHWz4mITWGJcggmZGNlKFTnp7M2ZuM9nFAHZgWwHti1Ctv8dARXIipM0R4Rdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7443 Precedence: Bulk 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 8j9tZ9EHjfCMwYN0ox3cXibax7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=XvUQhKB9; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Nickle Wang Regards, Nickle > -----Original Message----- > From: abner.chang@amd.com > Sent: Friday, January 26, 2024 10:32 AM > To: devel@edk2.groups.io > Cc: Nickle Wang ; Igor Kulchytskyy > Subject: [edk2-redfish-client][PATCH V3] RedfishClientPkg/FeatureDriver: > ComputerSystem_1_13_0 driver >=20 > External email: Use caution opening links or attachments >=20 >=20 > From: Abner Chang >=20 > Initial version of edk2 Redfish feature of > Redfish schema ComputerSystem_1_13_0. This driver > handles ComputerSystem Boot properties but not all. >=20 > Signed-off-by: Abner Chang > Cc: Nickle Wang > Cc: Igor Kulchytskyy > --- > .../v1_13_0/Dxe/ComputerSystemDxe.inf | 53 ++ > .../v1_13_0/Common/ComputerSystemCommon.h | 29 + > .../v1_13_0/Common/ComputerSystemCommon.c | 899 > ++++++++++++++++++ > .../v1_13_0/Dxe/ComputerSystemDxe.c | 702 ++++++++++++++ > 4 files changed, 1683 insertions(+) > create mode 100644 > RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe. > inf > create mode 100644 > RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste > mCommon.h > create mode 100644 > RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste > mCommon.c > create mode 100644 > RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDxe. > c >=20 > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.inf > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.inf > new file mode 100644 > index 0000000000..be1c2164d8 > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.inf > @@ -0,0 +1,53 @@ > +## @file > +# > +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reser= ved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D ComputerSystemDxe > + FILE_GUID =3D D94362A1-C358-4059-B014-F07D1AE04F16 > + 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 > + RedfishAddendumLib > + RedfishHttpCacheLib > + > +[Protocols] > + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED > + gEfiRestJsonStructureProtocolGuid ## CONSUMED > + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED > + > +[Pcd] > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize > + > +[Depex] > + TRUE > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.h > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.h > new file mode 100644 > index 0000000000..7b83d2939c > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.h > @@ -0,0 +1,29 @@ > +/** @file > + > + Redfish feature driver implementation - internal header file > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_ > +#define EFI_REDFISH_COMPUTERSYSTEM_COMMON_H_ > + > +#include > > > +#include > + > +// > +// Schema information. > +// > +#define RESOURCE_SCHEMA "ComputerSystem" > +#define RESOURCE_SCHEMA_MAJOR "1" > +#define RESOURCE_SCHEMA_MINOR "13" > +#define RESOURCE_SCHEMA_ERRATA "0" > +#define RESOURCE_SCHEMA_VERSION "v1_13_0" > +#define REDPATH_ARRAY_PATTERN L"/Systems/\\{.*\\}/" > +#define REDPATH_ARRAY_PREFIX L"/Systems/" > +#define RESOURCE_SCHEMA_FULL "x-uefi-redfish- > ComputerSystem.v1_13_0" > + > +#endif > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.c > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.c > new file mode 100644 > index 0000000000..cee6c8bf9b > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.c > @@ -0,0 +1,899 @@ > +/** @file > + Redfish feature driver implementation - common functions > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserv= ed. > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include "ComputerSystemCommon.h" > + > +CHAR8 ComputerSystemEmptyJson[] =3D "{\"@odata.id\": \"\", \"@odata.typ= e\": > \"#ComputerSystem.v1_13_0.ComputerSystem\", \"Id\": \"\", \"Name\": \"\", > \"Boot\":{}}"; > + > +REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = =3D > NULL; > +EFI_HANDLE mRedfishResourceConfigProtocolHandle = =3D NULL; > + > +/** > + Consume resource from given URI. > + > + @param[in] This Pointer to > REDFISH_RESOURCE_COMMON_PRIVATE instance. > + @param[in] Json The JSON to consume. > + @param[in] HeaderEtag The Etag string returned in HTTP head= er. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishConsumeResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *Json, > + IN CHAR8 *HeaderEtag OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 *ComputerSystem; > + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS *ComputerSystemCs; > + EFI_STRING ConfigureLang; > + > + if ((Private =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_HEADE= R > **)&ComputerSystem > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, Sta= tus)); > + 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_MANAGEABILITY, "%a: ETAG: %s has no change, ignore > consume action\n", __func__, Private->Uri)); > + Status =3D EFI_SUCCESS; > + goto ON_RELEASE; > + } > + > + // > + // Handle BOOT > + // > + if (ComputerSystemCs->Boot =3D=3D NULL) { > + ComputerSystemCs->Boot =3D AllocateZeroPool (sizeof > (RedfishComputerSystem_V1_13_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", __= func__, > ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: > %s\n", __func__, Private->Uri)); > + } > + } > + > + // > + // Handle BOOT->BOOTORDER > + // > + if (ComputerSystemCs->Boot->BootOrder !=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, > RESOURCE_SCHEMA_VERSION, ConfigureLang, ComputerSystemCs->Boot- > >BootOrder); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __= func__, > ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: > %s\n", __func__, Private->Uri)); > + } > + } > + > + // > + // Handle BOOT->BOOTSOURCEOVERRIDEENABLED > + // > + if (ComputerSystemCs->Boot->BootSourceOverrideEnabled !=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- > >BootSourceOverrideEnabled); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __= func__, > ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: > %s\n", __func__, Private->Uri)); > + } > + } > + > + // > + // Handle BOOT->BOOTSOURCEOVERRIDEMODE > + // > + if (ComputerSystemCs->Boot->BootSourceOverrideMode !=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- > >BootSourceOverrideMode); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __= func__, > ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: > %s\n", __func__, Private->Uri)); > + } > + } > + > + // > + // Handle BOOT->BOOTSOURCEOVERRIDETARGET > + // > + if (ComputerSystemCs->Boot->BootSourceOverrideTarget !=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- > >BootSourceOverrideTarget); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a, apply setting for %s failed: %r\n", __= func__, > ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a, can not get configure language for URI: > %s\n", __func__, Private->Uri)); > + } > + } > + > + // > + // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE > + // > + if (ComputerSystemCs->Boot->UefiTargetBootSourceOverride !=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- > >UefiTargetBootSourceOverride); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: apply setting for %s failed: %r\n", __= func__, > ConfigureLang, Status)); > + } > + > + FreePool (ConfigureLang); > + } else { > + DEBUG ((DEBUG_ERROR, "%a: can not get configure language for URI: > %s\n", __func__, Private->Uri)); > + } > + } > + > +ON_RELEASE: > + > + // > + // Release resource. > + // > + Private->JsonStructProtocol->DestoryStructure ( > + Private->JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)Compu= terSystem > + ); > + > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +ProvisioningComputerSystemProperties ( > + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, > + IN CHAR8 *InputJson, > + IN CHAR8 *ResourceId OPTIONAL, > + IN EFI_STRING ConfigureLang, > + IN BOOLEAN ProvisionMode, > + OUT CHAR8 **ResultJson > + ) > +{ > + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 *ComputerSystem; > + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS *ComputerSystemCs; > + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 *ComputerSystemEmpty; > + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS *ComputerSystemCsEmpty; > + EFI_STATUS Status; > + BOOLEAN PropertyChanged; > + CHAR8 *AsciiStringValue; > + CHAR8 **AsciiStringArrayValue; > + UINTN ArraySize; > + > + if ((JsonStructProtocol =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", __func_= _, > ConfigureLang, (ProvisionMode ? L"Provision resource" : L"Update resource= "))); > + > + *ResultJson =3D NULL; > + PropertyChanged =3D FALSE; > + > + ComputerSystem =3D NULL; > + Status =3D JsonStructProtocol->ToStructure ( > + JsonStructProtocol, > + NULL, > + InputJson, > + (EFI_REST_JSON_STRUCTURE_HEADER > **)&ComputerSystem > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Stat= us)); > + return Status; > + } > + > + ComputerSystemEmpty =3D NULL; > + Status =3D JsonStructProtocol->ToStructure ( > + JsonStructProtocol, > + NULL, > + ComputerSystemEmptyJson, > + (EFI_REST_JSON_STRUCTURE_H= EADER > **)&ComputerSystemEmpty > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Stat= us)); > + return Status; > + } > + > + ComputerSystemCs =3D ComputerSystem->ComputerSystem; > + // > + // Initial an empty ComputerSystemCS > + // > + ComputerSystemCsEmpty =3D ComputerSystemEmpty->ComputerSystem; > + > + // > + // Handle BOOT > + // > + if (ComputerSystemCs->Boot !=3D NULL) { > + // > + // Handle BOOT->BOOTNEXT > + // > + if (PropertyChecker (ComputerSystemCs->Boot->BootNext, ProvisionMode= )) { > + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, L"Boot/BootNext", ConfigureLang); > + if (AsciiStringValue !=3D NULL) { > + if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot->BootN= ext, > AsciiStringValue) !=3D 0)) { > + ComputerSystemCsEmpty->Boot->BootNext =3D AsciiStringValue; > + PropertyChanged =3D TRUE; > + } > + } > + } > + > + // > + // Handle BOOT->BOOTORDER > + // > + if (PropertyChecker (ComputerSystemCs->Boot->BootOrder, ProvisionMod= e)) { > + AsciiStringArrayValue =3D GetPropertyStringArrayValue (RESOURCE_SC= HEMA, > RESOURCE_SCHEMA_VERSION, L"Boot/BootOrder", ConfigureLang, &ArraySize); > + if (AsciiStringArrayValue !=3D NULL) { > + if (ProvisionMode || !CompareRedfishStringArrayValues > (ComputerSystemCs->Boot->BootOrder, AsciiStringArrayValue, ArraySize)) { > + AddRedfishCharArray (&ComputerSystemCsEmpty->Boot->BootOrder, > AsciiStringArrayValue, ArraySize); > + PropertyChanged =3D TRUE; > + } > + } > + } > + > + // > + // Handle BOOT->BOOTSOURCEOVERRIDEENABLED > + // > + if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideEnabl= ed, > ProvisionMode)) { > + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideEnabled", > ConfigureLang); > + if (AsciiStringValue !=3D NULL) { > + if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot- > >BootSourceOverrideEnabled, AsciiStringValue) !=3D 0)) { > + ComputerSystemCsEmpty->Boot->BootSourceOverrideEnabled =3D > AsciiStringValue; > + PropertyChanged =3D TRU= E; > + } > + } > + } > + > + // > + // Handle BOOT->BOOTSOURCEOVERRIDEMODE > + // > + if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideMode, > ProvisionMode)) { > + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideMode", > ConfigureLang); > + if (AsciiStringValue !=3D NULL) { > + if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot- > >BootSourceOverrideMode, AsciiStringValue) !=3D 0)) { > + ComputerSystemCsEmpty->Boot->BootSourceOverrideMode =3D > AsciiStringValue; > + PropertyChanged =3D TRUE; > + } > + } > + } > + > + // > + // Handle BOOT->BOOTSOURCEOVERRIDETARGET > + // > + if (PropertyChecker (ComputerSystemCs->Boot->BootSourceOverrideTarge= t, > ProvisionMode)) { > + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, L"Boot/BootSourceOverrideTarget", > ConfigureLang); > + if (AsciiStringValue !=3D NULL) { > + if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot- > >BootSourceOverrideTarget, AsciiStringValue) !=3D 0)) { > + ComputerSystemCsEmpty->Boot->BootSourceOverrideTarget =3D > AsciiStringValue; > + PropertyChanged =3D TRUE= ; > + } > + } > + } > + > + // > + // Handle BOOT->UEFITARGETBOOTSOURCEOVERRIDE > + // > + if (PropertyChecker (ComputerSystemCs->Boot- > >UefiTargetBootSourceOverride, ProvisionMode)) { > + AsciiStringValue =3D GetPropertyStringValue (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, L"Boot/UefiTargetBootSourceOverride", > ConfigureLang); > + if (AsciiStringValue !=3D NULL) { > + if (ProvisionMode || (AsciiStrCmp (ComputerSystemCs->Boot- > >UefiTargetBootSourceOverride, AsciiStringValue) !=3D 0)) { > + ComputerSystemCsEmpty->Boot->UefiTargetBootSourceOverride =3D > AsciiStringValue; > + PropertyChanged =3D = TRUE; > + } > + } > + } > + } > + > + // > + // Convert C structure back to JSON text. > + // > + Status =3D JsonStructProtocol->ToJson ( > + JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER > *)ComputerSystemEmpty, > + ResultJson > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status))= ; > + return Status; > + } > + > + if (PropertyChanged) { > + // Remove Redfish unchangeable properties. > + Status =3D RedfishRemoveUnchangeableProperties (ResultJson); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable > properties from ResultJson.\n", __func__)); > + *ResultJson =3D NULL; > + return Status; > + } > + } > + > + // > + // Release resource. > + // > + JsonStructProtocol->DestoryStructure ( > + JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem > + ); > + > + // > + // Free memory allocated for Computersystem empty CS > + // > + if (ComputerSystemCsEmpty->Boot->BootOrder !=3D NULL) { > + DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, > ArraySize); > + } > + > + JsonStructProtocol->DestoryStructure ( > + JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem= Empty > + ); > + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); > +} > + > +EFI_STATUS > +ProvisioningComputerSystemResource ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN UINTN Index, > + IN EFI_STRING ConfigureLang > + ) > +{ > + CHAR8 *Json; > + CHAR8 *JsonWithAddendum; > + EFI_STATUS Status; > + EFI_STRING NewResourceLocation; > + CHAR8 *EtagStr; > + CHAR8 ResourceId[16]; > + > + if (IS_EMPTY_STRING (ConfigureLang) || (Private =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"= , > __func__, ConfigureLang, Status)); > + return Status; > + } > + > + // > + // Check and see if platform has OEM data or not > + // > + Status =3D RedfishGetOemData ( > + Private->Uri, > + RESOURCE_SCHEMA, > + RESOURCE_SCHEMA_VERSION, > + Json, > + &JsonWithAddendum > + ); > + if (!EFI_ERROR (Status) && (JsonWithAddendum !=3D NULL)) { > + FreePool (Json); > + Json =3D JsonWithAddendum; > + JsonWithAddendum =3D NULL; > + } > + > + // > + // Check and see if platform has addendum data or not > + // > + Status =3D RedfishGetAddendumData ( > + Private->Uri, > + RESOURCE_SCHEMA, > + RESOURCE_SCHEMA_VERSION, > + Json, > + &JsonWithAddendum > + ); > + if (!EFI_ERROR (Status) && (JsonWithAddendum !=3D NULL)) { > + FreePool (Json); > + Json =3D JsonWithAddendum; > + JsonWithAddendum =3D NULL; > + } > + > + Status =3D CreatePayloadToPostResource (Private->RedfishService, Priva= te- > >Payload, Json, &NewResourceLocation, &EtagStr); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s failed= : > %r\n", __func__, ConfigureLang, Status)); > + goto RELEASE_RESOURCE; > + } > + > + ASSERT (NewResourceLocation !=3D NULL); > + > + // > + // Keep location of new resource. > + // > + if (NewResourceLocation !=3D NULL) { > + RedfishSetRedfishUri (ConfigureLang, NewResourceLocation); > + } > + > +RELEASE_RESOURCE: > + > + if (EtagStr !=3D NULL) { > + FreePool (EtagStr); > + } > + > + 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_SCHEMA, RESOURCE_SCHEMA_VERSION, > REDPATH_ARRAY_PATTERN, &UnifiedConfigureLangList); > + if (EFI_ERROR (Status) || (UnifiedConfigureLangList.Count =3D=3D 0)) { > + DEBUG ((DEBUG_ERROR, "%a: No HII question found with configure > language: %s: %r\n", __func__, REDPATH_ARRAY_PATTERN, Status)); > + return EFI_NOT_FOUND; > + } > + > + // > + // Set the configuration language in the > RESOURCE_INFORMATION_EXCHANGE. > + // This information is sent back to the parent resource (e.g. the coll= ection > driver). > + // > + EdkIIRedfishResourceSetConfigureLang > (mRedfishResourceConfigProtocolHandle, &UnifiedConfigureLangList); > + > + for (Index =3D 0; Index < UnifiedConfigureLangList.Count; Index++) { > + DEBUG ((DEBUG_MANAGEABILITY, "[%d] create ComputerSystem resource > from: %s\n", UnifiedConfigureLangList.List[Index].Index, > UnifiedConfigureLangList.List[Index].ConfigureLang)); > + ProvisioningComputerSystemResource (Private, > UnifiedConfigureLangList.List[Index].Index, > UnifiedConfigureLangList.List[Index].ConfigureLang); > + FreePool (UnifiedConfigureLangList.List[Index].ConfigureLang); > + } > + > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +ProvisioningComputerSystemExistResource ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private > + ) > +{ > + EFI_STATUS Status; > + EFI_STRING ConfigureLang; > + CHAR8 *Json; > + CHAR8 *JsonWithAddendum; > + > + if (Private =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + 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 ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource f= or > %s ignored. Nothing changed\n", __func__, ConfigureLang)); > + Status =3D EFI_SUCCESS; > + } else { > + DEBUG ((DEBUG_ERROR, "%a: provisioning existing resource for %s fa= iled: > %r\n", __func__, ConfigureLang, Status)); > + } > + > + goto ON_RELEASE; > + } > + > + // > + // Check and see if platform has OEM data or not > + // > + Status =3D RedfishGetOemData ( > + Private->Uri, > + RESOURCE_SCHEMA, > + RESOURCE_SCHEMA_VERSION, > + Json, > + &JsonWithAddendum > + ); > + if (!EFI_ERROR (Status) && (JsonWithAddendum !=3D NULL)) { > + FreePool (Json); > + Json =3D JsonWithAddendum; > + JsonWithAddendum =3D NULL; > + } > + > + // > + // Check and see if platform has addendum data or not > + // > + Status =3D RedfishGetAddendumData ( > + Private->Uri, > + RESOURCE_SCHEMA, > + RESOURCE_SCHEMA_VERSION, > + Json, > + &JsonWithAddendum > + ); > + if (!EFI_ERROR (Status) && (JsonWithAddendum !=3D NULL)) { > + FreePool (Json); > + Json =3D JsonWithAddendum; > + JsonWithAddendum =3D NULL; > + } > + > + DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for > %s\n", __func__, ConfigureLang)); > + > + // > + // PUT back to instance > + // > + Status =3D CreatePayloadToPatchResource (Private->RedfishService, Priv= ate- > >Payload, Json, NULL); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __fun= c__, > ConfigureLang, Status)); > + } > + > +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_PROTOCO= L > instance. > + @param[in] ResourceExist TRUE if resource exists, PUT method w= ill be > used. > + FALSE if resource does not exist POST= method is used. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishProvisioningResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN BOOLEAN ResourceExist > + ) > +{ > + if (Private =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + return (ResourceExist ? ProvisioningComputerSystemExistResource (Priva= te) : > ProvisioningComputerSystemResources (Private)); > +} > + > +/** > + Check resource from given URI. > + > + @param[in] This Pointer to > REDFISH_RESOURCE_COMMON_PRIVATE instance. > + @param[in] Json The JSON to consume. > + @param[in] HeaderEtag The Etag string returned in HTTP head= er. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishCheckResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *Json, > + IN CHAR8 *HeaderEtag OPTIONAL > + ) > +{ > + UINTN Index; > + EFI_STATUS Status; > + EFI_STRING *ConfigureLangList; > + UINTN Count; > + EFI_STRING Property; > + > + if ((Private =3D=3D NULL) || IS_EMPTY_STRING (Json)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Check ETAG to see if we need to check it > + // > + if (CheckEtag (Private->Uri, HeaderEtag, NULL)) { > + // > + // No change > + // > + DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore > check action\n", __func__, Private->Uri)); > + return EFI_SUCCESS; > + } > + > + Status =3D RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA, > RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigureLangList, > &Count); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed: %r\n", __func__, Status)); > + return Status; > + } > + > + if (Count =3D=3D 0) { > + return EFI_UNSUPPORTED; > + } > + > + Status =3D EFI_SUCCESS; > + for (Index =3D 0; Index < Count; Index++) { > + Property =3D GetPropertyFromConfigureLang (Private->Uri, > ConfigureLangList[Index]); > + if (Property =3D=3D NULL) { > + continue; > + } > + > + DEBUG ((DEBUG_MANAGEABILITY, "%a: [%d] check attribute for: %s\n", > __func__, Index, Property)); > + if (!MatchPropertyWithJsonContext (Property, Json)) { > + DEBUG ((DEBUG_MANAGEABILITY, "%a: property is missing: %s\n", > __func__, Property)); > + Status =3D EFI_NOT_FOUND; > + } > + } > + > + FreePool (ConfigureLangList); > + > + return Status; > +} > + > +/** > + Update resource to given URI. > + > + @param[in] This Pointer to > REDFISH_RESOURCE_COMMON_PRIVATE instance. > + @param[in] Json The JSON to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishUpdateResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *InputJson > + ) > +{ > + EFI_STATUS Status; > + CHAR8 *Json; > + CHAR8 *JsonWithAddendum; > + EFI_STRING ConfigureLang; > + > + if ((Private =3D=3D NULL) || IS_EMPTY_STRING (InputJson)) { > + return EFI_INVALID_PARAMETER; > + } > + > + 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 ((DEBUG_MANAGEABILITY, "%a: update resource for %s ignored. > Nothing changed\n", __func__, ConfigureLang)); > + Status =3D EFI_SUCCESS; > + } else { > + DEBUG ((DEBUG_ERROR, "%a: update resource for %s failed: %r\n", > __func__, ConfigureLang, Status)); > + } > + > + goto ON_RELEASE; > + } > + > + // > + // Check and see if platform has OEM data or not > + // > + Status =3D RedfishGetOemData ( > + Private->Uri, > + RESOURCE_SCHEMA, > + RESOURCE_SCHEMA_VERSION, > + Json, > + &JsonWithAddendum > + ); > + if (!EFI_ERROR (Status) && (JsonWithAddendum !=3D NULL)) { > + FreePool (Json); > + Json =3D JsonWithAddendum; > + JsonWithAddendum =3D NULL; > + } > + > + // > + // Check and see if platform has addendum data or not > + // > + Status =3D RedfishGetAddendumData ( > + Private->Uri, > + RESOURCE_SCHEMA, > + RESOURCE_SCHEMA_VERSION, > + Json, > + &JsonWithAddendum > + ); > + if (!EFI_ERROR (Status) && (JsonWithAddendum !=3D NULL)) { > + FreePool (Json); > + Json =3D JsonWithAddendum; > + JsonWithAddendum =3D NULL; > + } > + > + DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __func__, > ConfigureLang)); > + > + // > + // PUT back to instance > + // > + Status =3D CreatePayloadToPatchResource (Private->RedfishService, Priv= ate- > >Payload, Json, NULL); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __fun= c__, > ConfigureLang, Status)); > + } > + > +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_PRIVATE instance. > + @param[in] Json The JSON to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +RedfishIdentifyResourceCommon ( > + IN REDFISH_RESOURCE_COMMON_PRIVATE *Private, > + IN CHAR8 *Json > + ) > +{ > + BOOLEAN Supported; > + EFI_STATUS Status; > + EFI_STRING EndOfChar; > + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigLangList; > + > + Supported =3D RedfishIdentifyResource (Private->Uri, Private->Json); > + if (Supported) { > + Status =3D RedfishFeatureGetUnifiedArrayTypeConfigureLang > (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, > REDPATH_ARRAY_PATTERN, &ConfigLangList); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: > RedfishFeatureGetUnifiedArrayTypeConfigureLang failed: %r\n", __func__, > Status)); > + return Status; > + } > + > + if (ConfigLangList.Count =3D=3D 0) { > + DEBUG ((DEBUG_MANAGEABILITY, "%a No platform Redfish ConfigureLan= g > found for %s\n", __func__, Private->Uri)); > + 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, NUL= L, > &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, > &EndOfChar); > + } > + > + *(++EndOfChar) =3D '\0'; > + // > + // Keep URI and ConfigLang mapping > + // > + RedfishSetRedfishUri (ConfigLangList.List[0].ConfigureLang, Private-= >Uri); > + // > + // Set the configuration language in the > RESOURCE_INFORMATION_EXCHANGE. > + // This information is sent back to the parent resource (e.g. the co= llection > driver). > + // > + EdkIIRedfishResourceSetConfigureLang > (mRedfishResourceConfigProtocolHandle, &ConfigLangList); > + DestroyConfiglanguageList (&ConfigLangList); > + return EFI_SUCCESS; > + } > + > + return EFI_UNSUPPORTED; > +} > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > new file mode 100644 > index 0000000000..174a8176a8 > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > @@ -0,0 +1,702 @@ > +/** @file > + Redfish feature driver implementation - ComputerSystem > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include "../Common/ComputerSystemCommon.h" > + > +extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate; > +extern EFI_HANDLE mRedfishResourceConfigProtocolHa= ndle; > + > +/** > + Provision redfish resource by given URI. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCO= L > instance. > + @param[in] Uri Target URI to create resource. > + @param[in] PostMode TRUE if the resource does not exist, = post > method is used. > + FALSE if the resource exist but prope= rty is missing, put > method is used. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceProvisioningResource ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri, > + IN BOOLEAN PostMode > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + > + if ((This =3D=3D NULL) || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning in %s mode\n", __func__= , > (PostMode ? L"POST" : L"PATCH"))); > + > + Private =3D > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOCOL > (This); > + > + if (Private->RedfishService =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + > + ZeroMem (&Response, sizeof (Response)); > + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Resp= onse, > TRUE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, > Uri)); > + return Status; > + } > + > + Private->Uri =3D Uri; > + Private->Payload =3D Response.Payload; > + ASSERT (Private->Payload !=3D NULL); > + > + Status =3D RedfishProvisioningResourceCommon (Private, !PostMode); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to provision resource to: %s: %r\n"= , > __func__, Uri, Status)); > + } else { > + // > + // Get latest ETag on URI and keep it in variable. > + // > + SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE); > + } > + > + // > + // Release resource > + // > + if (Private->Payload !=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_PROTOCO= L > instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceConsumeResource ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + EFI_STRING PendingSettingUri; > + REDFISH_RESPONSE PendingSettingResponse; > + REDFISH_RESPONSE *ExpectedResponse; > + CHAR8 *Etag; > + > + if ((This =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; > + } > + > + ZeroMem (&Response, sizeof (Response)); > + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Resp= onse, > TRUE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, > Uri)); > + return Status; > + } > + > + // > + // Check and see if "@Redfish.Settings" exist or not. > + // > + ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE)); > + Status =3D GetPendingSettings ( > + Private->RedfishService, > + Response.Payload, > + &PendingSettingResponse, > + &PendingSettingUri > + ); > + if (!EFI_ERROR (Status)) { > + DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", > __func__, PendingSettingUri)); > + Private->Uri =3D PendingSettingUri; > + ExpectedResponse =3D &PendingSettingResponse; > + } else { > + DEBUG ((REDFISH_DEBUG_TRACE, "%a: No @Redfish.Settings is found\n", > __func__)); > + Private->Uri =3D Uri; > + ExpectedResponse =3D &Response; > + } > + > + Private->Payload =3D ExpectedResponse->Payload; > + ASSERT (Private->Payload !=3D NULL); > + > + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Paylo= ad), > EDKII_JSON_COMPACT); > + ASSERT (Private->Json !=3D NULL); > + > + // > + // Find etag in HTTP response header > + // > + Etag =3D NULL; > + GetHttpResponseEtag (ExpectedResponse, &Etag); > + Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag)= ; > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n"= , > __func__, Private->Uri, Status)); > + } > + > + // > + // Release resource > + // > + if (Etag !=3D NULL) { > + FreePool (Etag); > + } > + > + // > + // Release resource > + // > + if (Private->Payload !=3D NULL) { > + if (Response.Payload !=3D NULL) { > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + } > + > + if (PendingSettingResponse.Payload !=3D NULL) { > + RedfishFreeResponse ( > + PendingSettingResponse.StatusCode, > + PendingSettingResponse.HeaderCount, > + PendingSettingResponse.Headers, > + PendingSettingResponse.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_PROTOCO= L > instance. > + @param[out] Schema Supported schema. > + @param[out] Major Supported major number. > + @param[out] Minor Supported minor number. > + @param[out] Errata Supported errata number. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceGetInfo ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + OUT REDFISH_SCHEMA_INFO *Info > + ) > +{ > + if ((This =3D=3D NULL) || (Info =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + AsciiStrCpyS (Info->Schema, REDFISH_SCHEMA_STRING_SIZE, > RESOURCE_SCHEMA); > + AsciiStrCpyS (Info->Major, REDFISH_SCHEMA_VERSION_SIZE, > RESOURCE_SCHEMA_MAJOR); > + AsciiStrCpyS (Info->Minor, REDFISH_SCHEMA_VERSION_SIZE, > RESOURCE_SCHEMA_MINOR); > + AsciiStrCpyS (Info->Errata, REDFISH_SCHEMA_VERSION_SIZE, > RESOURCE_SCHEMA_ERRATA); > + > + return EFI_SUCCESS; > +} > + > +/** > + Update resource to given URI. > + > + @param[in] This Pointer to EFI_HP_REDFISH_HII_PROTOCO= L > instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceUpdate ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + > + if ((This =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; > + } > + > + ZeroMem (&Response, sizeof (Response)); > + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Resp= onse, > TRUE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, > Uri)); > + return Status; > + } > + > + Private->Uri =3D Uri; > + Private->Payload =3D Response.Payload; > + ASSERT (Private->Payload !=3D NULL); > + > + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Paylo= ad), > 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 to: %s: %r\n", > __func__, Uri, Status)); > + } else { > + // > + // Get latest ETag on URI and keep it in variable. > + // > + SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE); > + } > + > + // > + // Release resource > + // > + if (Private->Payload !=3D NULL) { > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + RedfishHttpResetResource (Uri); > + 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_PROTOCO= L > instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS Value is returned successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceCheck ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + CHAR8 *Etag; > + > + if ((This =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; > + } > + > + ZeroMem (&Response, sizeof (Response)); > + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Resp= onse, > TRUE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, > Uri)); > + return Status; > + } > + > + Private->Uri =3D Uri; > + Private->Payload =3D Response.Payload; > + ASSERT (Private->Payload !=3D NULL); > + > + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Paylo= ad), > EDKII_JSON_COMPACT); > + ASSERT (Private->Json !=3D NULL); > + > + // > + // Find etag in HTTP response header > + // > + Etag =3D NULL; > + GetHttpResponseEtag (&Response, &Etag); > + Status =3D RedfishCheckResourceCommon (Private, Private->Json, Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to check resource from: %s: %r\n", > __func__, Uri, Status)); > + } > + > + // > + // Release resource > + // > + if (Etag !=3D NULL) { > + FreePool (Etag); > + } > + > + 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_CONFIG_PROTOCOL instance. > + @param[in] Uri The target URI to consume. > + > + @retval EFI_SUCCESS This is target resource which we want= to handle. > + @retval EFI_UNSUPPORTED This is not the target resource. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceIdentify ( > + IN EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *This, > + IN EFI_STRING Uri > + ) > +{ > + REDFISH_RESOURCE_COMMON_PRIVATE *Private; > + EFI_STATUS Status; > + REDFISH_RESPONSE Response; > + > + if ((This =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; > + } > + > + ZeroMem (&Response, sizeof (Response)); > + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Resp= onse, > TRUE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, > Uri)); > + return Status; > + } > + > + Private->Uri =3D Uri; > + Private->Payload =3D Response.Payload; > + ASSERT (Private->Payload !=3D NULL); > + > + Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Paylo= ad), > 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", __func__, 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 initializ= e each Redfish > configure > + handler. > + > + @param[in] This Pointer to > EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL instance. > + @param[in] RedfishConfigServiceInfo Redfish service information. > + > + @retval EFI_SUCCESS The handler has been initialized = successfully. > + @retval EFI_DEVICE_ERROR Failed to create or configure the= REST EX > protocol instance. > + @retval EFI_ALREADY_STARTED This handler has already been ini= tialized. > + @retval Other Error happens during the initiali= zation. > + > +**/ > +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 > (This); > + > + Private->RedfishService =3D RedfishCreateService (RedfishConfigService= Info); > + 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 successf= ully. > + @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 > (This); > + > + 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 > gEfiRestJsonStructureProtocolGuid: %r\n", __func__, Status)); > + } > + > + gBS->CloseEvent (Event); > +} > + > +/** > + Unloads an image. > + > + @param ImageHandle Handle that identifies the image to be u= nloaded. > + > + @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 incl= uding > + both device drivers and bus drivers. It initialize the global variable= s and > + publish the driver binding protocol. > + > + @param[in] ImageHandle The firmware allocated handle for the UE= FI > image. > + @param[in] SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The operation completed successfully. > + @retval Others Other errors as indicated. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + VOID *Registration; > + > + if (mRedfishResourcePrivate !=3D NULL) { > + return EFI_ALREADY_STARTED; > + } > + > + mRedfishResourceConfigProtocolHandle =3D ImageHandle; > + > + mRedfishResourcePrivate =3D AllocateZeroPool (sizeof > (REDFISH_RESOURCE_COMMON_PRIVATE)); > + CopyMem (&mRedfishResourcePrivate->ConfigHandler, > &mRedfishConfigHandler, sizeof > (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL)); > + CopyMem (&mRedfishResourcePrivate->RedfishResourceConfig, > &mRedfishResourceConfig, sizeof > (EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL)); > + > + // > + // Publish config handler protocol and resource protocol. > + // > + Status =3D gBS->InstallMultipleProtocolInterfaces ( > + &ImageHandle, > + &gEdkIIRedfishConfigHandlerProtocolGuid, > + &mRedfishResourcePrivate->ConfigHandler, > + &gEdkIIRedfishResourceConfigProtocolGuid, > + &mRedfishResourcePrivate->RedfishResourceConfig, > + NULL > + ); > + > + EfiCreateProtocolNotifyEvent ( > + &gEfiRestJsonStructureProtocolGuid, > + TPL_CALLBACK, > + EfiRestJasonStructureProtocolIsReady, > + NULL, > + &Registration > + ); > + > + return Status; > +} > -- > 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114490): https://edk2.groups.io/g/devel/message/114490 Mute This Topic: https://groups.io/mt/103968994/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-