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 CF7B1940EF2 for ; Fri, 26 Jan 2024 02:20:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=iSX53NVaqRmTVLXqHRTs4xoW2v+lxmaQ7S9/4x9WjBc=; 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=1706235649; v=1; b=n+6UkOtLAH5FykrL+fWtZ5sBVNWCatWOOKpeabcVSiWWDHl3FrqExCi2chZcdgETUKrngWBq Zt5jDj9RGGdU72AkbOgHIMv0aTA4qcCj/54teBCGOi1luO7LrxhB2IvXVTeTLMBSu9N4HI1+TTe xR+IL/NWZCqBgIw0X5zOOPJs= X-Received: by 127.0.0.2 with SMTP id uIg4YY7687511x5E2u3dmcqY; Thu, 25 Jan 2024 18:20:49 -0800 X-Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.59]) by mx.groups.io with SMTP id smtpd.web10.6297.1706235648635284903 for ; Thu, 25 Jan 2024 18:20:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CYedQEv3InDYN8wvlo4f5XXg8y0anVPWlhdlzwe8uxJSeRC3q4yjW4PYQO1TZRqnL9K26MKrQttbRQOxOem2TQvnaqJNNs6WFAkF1X3go+tR7VmCKuT18Pk6AaZ9lwsgojgOdHVROIA2sA9dl6bX/0GPArBYtCA69jjSphJ9UY+hl9fqxaQmhJRTXAJ294nnOQzNfYk5hSkqA6FXRs0sWy3WiuKmeQ5EnF0KMUYlTE6VRDzrixwSX9DqJAEIQV4wNF7UHcxVHcC+yHztM5y5cHWidzg+11U5M2ucdZvWJiH1NycGYoS4PRTS4kDlpToP/dXVdVGXBfGERzpu4VNq3A== 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=Gh2EMqYP5Z5+MuQMdUdIiSO9vule1zPyx68Cpkb8GIY=; b=ao+SOft31UBMSWMRLTy16tpxl3x6gK2Oh/dzYgSM85c0PPKZ+1TJS9KGFi+zcw2c2NZPxBR+X3NAkdxdiIbAvluigRVUtZyGj0/h6jzw5VpmVLvAL8luPbsVTv/3fDDr60pdl9HRuwxezN2wj8ha/CejK8aZw/Mj5kcw6vlRNhJ0hyQbmktscZTc4FpUu3aC1NwW3kmbnvCgk0cO0uf+WlqJIHKWGI7egH17bFMYaPpd8+nxNQWuZCq4C00LxbMFClz7o1HWa1tYiWe7UF6lX4FBvf2u7hDMwJ9HbQ8nl8OUQLjtfjfS/c96AXHGr16eaQoP8oCf02i4MYMZXXe96w== 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 SA0PR12MB4463.namprd12.prod.outlook.com (2603:10b6:806:92::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 02:20:44 +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:20:44 +0000 From: "Nickle Wang via groups.io" To: "devel@edk2.groups.io" , "abner.chang@amd.com" CC: Igor Kulchytskyy Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver Thread-Topic: [edk2-devel] [edk2-redfish-client][PATCH V2] RedfishClientPkg/FeatureDriver: ComputerSystem_1_13_0 driver Thread-Index: AQHaT/Maj0KN7p8rDkyl9xEQDMZI6bDrXGbQ Date: Fri, 26 Jan 2024 02:20:44 +0000 Message-ID: References: <20240126010023.958-1-abner.chang@amd.com> In-Reply-To: <20240126010023.958-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_|SA0PR12MB4463:EE_ x-ms-office365-filtering-correlation-id: 0b06151e-da51-463f-d77f-08dc1e15666a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: Cny7c7/f2pYLWAgoXmOwOPUpRi5Qhr0FrR6oddqGUMnQG+7MBGH2DVqKd0UgLCnhqcqJbcYwfu1YybG5LeSPz9b+YYy8isohHDuMmVEvltnKLtH/pmWDNqWrP39aM/LefcUazLfCod+bRezizXaflAAkV83VbaLYH1J/gJCi4Ru41+ZQsbUVwF2zZEAlriTVLckEC9YMyRiaYqON/VuIL4qDMpQAHcr3b7hJd+xajaWWMzOdmlg/cBWfD/YYTlCiI2xDTNgxRKnDu2I1ZGSFDY5CottEXJyoIysImLNe4JbkaTZmq1q49j3suN3lUx+1mRW8SO8gnNHrA8TlS7CrM39FRtrV3NhMPFihgHZEFMQVV1Zur/wbzFeU2FkgqQVs1DYFBQSGPaY1y+0BPgWXLoat2gW6ai80byyzijx7apQ0iU4YFkgZDF+RXsnzLQKOBTGhJtfTIVBtHPpOIxYvyiF4GxXwb8Aq4a27Y2L81oDEadb51EORm7v2gdbUGYOsPiiOBhCe+7X9yWa/zyUgZWZKdUvsXlDdbY0IyHJe3rGpms5Mf3GCkJ4tHaUHc7c6FPqqNcYyXcKP3DO8KL9uOGird1s4mTNMyh9nCtjaLNBOJFKjb2a+nstrFXfdCmjKvmtU3tpiMwdeMixh7JYRAcIaGHTqGEvdP/lHFmJXjDY= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?gfS+7zLnVlCSWHzDWyebAGmP6y8Slo68ws9i9BALVqeiwtfupXU6MpyK3SS3?= =?us-ascii?Q?0QghG7WYBFsSM8Cx3Dj3IciLjEZnbWS98fYrV9XxWzlCR9cfyJMitBaQNlog?= =?us-ascii?Q?I5xSSvbUDDX0OLk8NtzS3xqnUTT1MJpGTJ0lubWnICCJP+GoedL4k6R8at5z?= =?us-ascii?Q?J9uNu8MQFhGHExBAY/sw5c+Cl5EH356tcIrDrYWlEle3xm3ReE76JzanD9ZF?= =?us-ascii?Q?FifwXJlAw8HXYazE6kxO4LUA0gxv4wcAPjUVg2IzjBl7zCy4stBCafcE2m+b?= =?us-ascii?Q?lhu3ocOvTfgMIf1rvUym28QqeC+ASbRmxZv+beOzzyIstge986bbDB/P3zk6?= =?us-ascii?Q?WdseOTiMLAofzkw+XvC6t2Cz+xTizhhddqgcEVcprswe347xhISvVUMzNthn?= =?us-ascii?Q?R/AnOjoCJpktp73hwd+AA1gCDDZpzBj+w3x7bRgDK4f99NBWJx6XW091wP7k?= =?us-ascii?Q?VaGBU90c/k/MextbEvzhR+6eGhYgkZ2A1du3vEssLEurrPF9ps2dibCkStFz?= =?us-ascii?Q?obzG5DVl+gjox3JrodoSrug9HxirQpjysTTjcHZT9Z1s2wavDg3rbo/AaPPF?= =?us-ascii?Q?3gAoSObCoqIuYWiUlxNWcZNsY68r24DwGhIlnsD/dl6mzUBicJ+MlIb0JT/3?= =?us-ascii?Q?bdPCEn0Cpnz7lyz09sjzSk0+iOEIVdgwz3xZ6or/Dx/tKm4Zv6msJPyaW/By?= =?us-ascii?Q?qFmYOtJIuFWgnbLuPpSVMuQMUEQkuIjh+fHWvnYWEKWjzFcKYe33ZYAgY+Hm?= =?us-ascii?Q?W8qU/3zhTxRLAtsUqMd4HJ3vH2p3TI8Ao+mZJsO7YXyEmJk+OeSzKkAr3LzQ?= =?us-ascii?Q?jizUsb63LfYuiU980FJJM7fkoaRrhzUBBKBr4zQFoFImytb3MdPU0JT5Iu9N?= =?us-ascii?Q?p5D3xEP0y5CqU4WUNHYq3G42tGUnUl5jHRu6x2cLDAGXKHatPUJVvjla0lPD?= =?us-ascii?Q?sULZVUEX1Wb4LnxV1ci3bjkuwfg4TGjmSrDq4Rgw2EGfotb5N3oNOw8tveaz?= =?us-ascii?Q?4dKFcXbIm7zz+ue/ANMve9zwx8vPRo6cHQraHsD8V2v4eL1G3Cu2n/AEcrX2?= =?us-ascii?Q?U/par6MXqDJuKFYov3HxmpXkO86Cw/HCVPuVEDgiXcXnEVkjlFH+DTya++aI?= =?us-ascii?Q?A5bOhfoxh6xMi07Nicf7qRUPFvNeuuGaxzHNPmSy/V+/SYCr1VZFS3OLIljW?= =?us-ascii?Q?LJXg8/OatEQKQvSyzZnqszZnRMD8dHAEpPr26ur0U4w8ydDIKDCdotlKQm04?= =?us-ascii?Q?vplDOqXEG3UdrvM250dR5ZzR98LP5CN1ZODzjNRQs4P91xOX8Kfx542zNsU/?= =?us-ascii?Q?Z4eju1uXyHrYIYg8rQWEN+dDGAseu+0OqfWiY3jVRPIRw21uO1NdfBa6S3kG?= =?us-ascii?Q?GgQ70KCSaHT6vjhrSKxQli4bUJwPvFWwIN/bJlxLlcKBdbzgvohuR/a7tkDm?= =?us-ascii?Q?X/PoyMIZ6S+vXdIUA6uSBEyyGCaWMUTnOD6mzu6SodzBdRwjKRcVCwzOYOrY?= =?us-ascii?Q?yA9wTwtYjAxAw0Hr6zul+mvXq2dl/9r220COTY/f74NaotxtH4CL6QMrkPSU?= =?us-ascii?Q?q7OFPPeUWmUr1SAawVGraS9QqHCfNAKeuu4Mdc1KhaxXyopc/bWkas28SeUT?= =?us-ascii?Q?n37su+F27Arh+bW0M+1+3QEDqGHC18kvUkMe0p7NOb08?= 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: 0b06151e-da51-463f-d77f-08dc1e15666a X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jan 2024 02:20:44.0892 (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: aMr3voXucEk9qK4lur2xllT6bb3bwF1e9VczEBOEXE5aEz3JyHfVcHyp6lQqjJeeAPaVwYJJbQZs+jVf5cWGSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4463 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: pDse7rSSKVG3kcUV99wv70zpx7686176AA= 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=n+6UkOtL; 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 Hi Abner, Same minor issue as 1_5_0. Please add "%a:" to below DEBUG call. > + DEBUG ((DEBUG_MANAGEABILITY, " No platform Redfish ConfigureLang > found for %s\n", __func__, Private->Uri)); Regards, Nickle > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Chang, Abn= er > via groups.io > Sent: Friday, January 26, 2024 9:00 AM > To: devel@edk2.groups.io > Cc: Nickle Wang ; Igor Kulchytskyy > Subject: [edk2-devel] [edk2-redfish-client][PATCH V2] > 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..6bc5cb358e > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.inf > @@ -0,0 +1,53 @@ > +## @file > +# > +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> +# 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..c9c8512881 > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.h > @@ -0,0 +1,29 @@ > +/** @file > + > + Redfish feature driver implementation - internal header file > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + 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..bc24c49206 > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.c > @@ -0,0 +1,899 @@ > +/** @file > + Redfish feature driver implementation - common functions > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + 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, " No platform Redfish ConfigureLang > 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..30a0e64c64 > --- /dev/null > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemD > xe.c > @@ -0,0 +1,702 @@ > +/** @file > + Redfish feature driver implementation - ComputerSystem > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + 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 >=20 >=20 >=20 >=20 >=20 -=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 (#114485): https://edk2.groups.io/g/devel/message/114485 Mute This Topic: https://groups.io/mt/103967446/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-