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 89FAC7803DF for ; Thu, 4 Jan 2024 08:16:49 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=1Xou1Ff0KWnaAmOKPaHlUXZ0vFFDL2xcK5/UAng3q5s=; 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:msip_labels: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=1704356208; v=1; b=tZBCKgse4poVdb+aWAXUY7J8TYD14NHiOgwowtZ1SCd25t6LlEanLw5NLstBFPKzoZO/tZeQ aqYWaxsyREoKKFg7eNha9KRFSbi+kPf4KaoA4aJ4BuDrVYNKkdmSYIZugH/yxLtdxRY0pk17H48 bEB3Fb+uC51XHBYJVRV1f3Wo= X-Received: by 127.0.0.2 with SMTP id waa0YY7687511x1ApQZcpGDI; Thu, 04 Jan 2024 00:16:48 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.48]) by mx.groups.io with SMTP id smtpd.web10.49831.1704356207269833593 for ; Thu, 04 Jan 2024 00:16:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PEDZdTPuDBaIVgoTZhzKmGCy6+gzuAw5Qe8YvojK54ffpcbsCTwKBvl0NzgyJYy2sDCwvXE8ext6WVSRCzZ9kwrs7hXjXczpeeIC8H6ruZQaucvjptrCI9Fs5lYgEVnDGfayP6M4n/7f7XPoTSpPPEA1gi8Qz7sBkBKSNb1+Lr5AqL1hAtOrR1pFl+r7xXrCIrVMwuuYQb9sOYS4SI2dj1UzlWarGxJnewRbuZyYvRvkn91BI9u8A1PIpHVrkZYle0cYr7IIYQXExZ5KZEg8U2VkorvLB76OoqeyMs11tC/Z9NnzlPGLUqR+m1EEqPwaB6j033/AbMtmcgrCYHJxGA== 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=uSndgNiYMzN2TkjIveoKkkYMN/kJk0GBeq7KqzPohIo=; b=VnP+7nHclZwtX8YRRUxRPvtLRVUlwJnLV7TAhN2ZcV80m1jKiympAWELVdJ2gVVrUAE7tuYoFVJ0Ro21HnmoU/B4hH3dUSgb19oeLPSIn5WL3ZB8QoYZ20vW5yByufUc9gP2PSXcj2y2l/q97MkREewh9j3joZBv0cQwwypS0P2g/17GqNzgte7TdwSpHfx5w3BNZOfN0QGwcgef73pOEl6DJvfTQM5JlZLzZ9yFbHs5XR+XhRy071BMWq8jjygpNWIVVxhb93IBTk0uB0rCWQx0UU4uceyONO72vOFfASrVpkf/pyuGmz1Xzw+AVUeVWX30n3HvlaKuwKiYX25iHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by CY8PR12MB7194.namprd12.prod.outlook.com (2603:10b6:930:5a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.15; Thu, 4 Jan 2024 08:16:44 +0000 X-Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::91d9:e679:32a3:dd05]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::91d9:e679:32a3:dd05%5]) with mapi id 15.20.7159.013; Thu, 4 Jan 2024 08:16:43 +0000 From: "Chang, Abner via groups.io" To: Nickle Wang , "devel@edk2.groups.io" CC: Igor Kulchytskyy , Nick Ramirez Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH 4/4] RedfishClientPkg/Features: introduce boot option Thread-Topic: [edk2-redfish-client][PATCH 4/4] RedfishClientPkg/Features: introduce boot option Thread-Index: AQHaPsxIhp8qg5c/t0uqLtNX4ZyaOLDJTxYQ Date: Thu, 4 Jan 2024 08:16:43 +0000 Message-ID: References: <20240104050939.70774-1-nicklew@nvidia.com> In-Reply-To: <20240104050939.70774-1-nicklew@nvidia.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=9299fe5f-ed7e-4430-b212-d4ab41bf9379;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2024-01-04T08:16:39Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|CY8PR12MB7194:EE_ x-ms-office365-filtering-correlation-id: 8c9365ec-7b23-4e2c-8915-08dc0cfd7cc3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: Z8ptJhOKjcqfOicOJKnnyAv7nX3tI3Jn4TReZrX6YUsUpgDD+7UxOm+/VCUy7JoPAHHpjva1YRGm1JdOh1E2eHU1cROPG731jO9nOr3vsFh7CQw9Jj0wDkjO8jqRRGJI9Y5gtP1ojA439Cr4uCq8MX4B2toMTKQnjNst/HhLvL2Foe0Ci4gTruM4Zxtg9X4KqxwfTWr+668vahQu65Q8SAROVTLjVeml0rTYlNO3PphT0JOPCch+urWp8QlCrFs5f/T5Eadb1vzeSm9/FGela9VSIxkUz6/FZnRizwYTFWLbSzZB0SrB8q6exAsCfwQy34Gk9ykDm3GA2c8Vi7+kii6k4j3aoa5oPRMkOMabCMqhLDXC6wcq3u2j7Sxy1cQH6uInSJzCQJX7ncaxfGmNrWF7Tk92rHPfo8+MA3fmhP0P3HE5QbkZVwc3GP7PGQdM//rUINyje+u5275Scen78qaf1yWNdcMPP1FIIebYYmvQRC8D6eA2V/GMhNXxpjx4j8h+J93mfTknJDBvagKqDKHcXm9AkK0c6EDsCEH7SvAA5j59ZqtFy3Uv2jekaKYpXM1HsH433j9I65eC+sYISvJxJeOlRSDGf/x1/Jd1+Vz8gc+7ilH7NwNQp2GDaT+z5LD/JeLrXYg0D2r2wPss+7qqgOBqTr6XYmccW1PtUJaAhPLMe1WPScuKRi/73e0V x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Emw0N7d4HWXmKfQMX5DZ1s2t1rc1EN3oeW/P1NwlhBIclF1N8EW6Hb9YlCJ5?= =?us-ascii?Q?O2Q4LVghuGoyx0o10BQqSTusK3XZoavuloqWSQ7Zi5zlZW9SgOxFdDpUghvG?= =?us-ascii?Q?5/5Sr1X573zQTsbJ510USRfQvZmVxoI13FGZM+c2iuYD0iTO72YPe/wXpeXo?= =?us-ascii?Q?0fPe8uFgbuzUyTtX6XJT/YV5WiFSKOjD1BjLFqCWu8Zj7XI/Q1ZBuqU28CwE?= =?us-ascii?Q?GDevGN2YXzdvcadK5zgs8AMX2SpzUMb3dGBr3jTwaFzSC5WlKntBCVFlLVlD?= =?us-ascii?Q?egP8odxgshrPyx1egf5y06D8i3HWCLsJiNgJOBQgwjHxBCleZd+8kwZvX6yf?= =?us-ascii?Q?2vE8D1rMT9CScKL6p8MJNoDjbT60+R2wu0ABAWHwjgs+HBZ/udWcVXfQpLZ4?= =?us-ascii?Q?iJwzv+S1df9vPDjEymWp6VK4yQWoIxYAbqJaidciMrMhV/wgX7GHHkjmEymd?= =?us-ascii?Q?ynRumX24Ys5R7VDC951oNV4A3eJNnazeY/ipZO/Rtk7nA0k2kaCFTwxzAJ+E?= =?us-ascii?Q?I3O6FyYXtHNpxIbvFZy/5qQ/ru8Pp6yj46lJs00+362CHwMqxYd/ZkU/5JTc?= =?us-ascii?Q?xhIq3/vvD5Qc9udFBt9bUL4n8PGlo+aQGds4/vE7KDwFttr6gspWFL6iSY+s?= =?us-ascii?Q?nmw8W14o0Era8itd6MPGJr0mrsn+YwEFRnkHHKBIjKBV9sDLvKt6MGW5NVb1?= =?us-ascii?Q?KLBbo+Xuz4jixUCBdbjRDiocXNGhfE61k0n1CB1ov+NiY2RXgqUnHrCWlu1n?= =?us-ascii?Q?qkp2qso5JBkeWETDGHVFqWmymNEridpqlFgos28N8phBTKqpUieIlxT0ZtPN?= =?us-ascii?Q?RYYbC7/30tCkjIvP2X6Z0aE6xMcv/3zktxciamfBKyQB1/sdcfEm0zlXHm8K?= =?us-ascii?Q?vCgWy/t1Vyo/keDQuDXy+qa6YNF9ctQ1nuPmCJpup08YDaI69h27zY9StTus?= =?us-ascii?Q?ZiejzqvNlOY7+Kkvdbsdo5UCkSBShzNEfnNZMpTnF4RXD6zpHOIukl/3aueK?= =?us-ascii?Q?aVU4z2Gx42q5ewD1p1GG+SC0nB4RSkqBimYAYgfZatmy60XZG9L/jF3er6QC?= =?us-ascii?Q?zytaBySA47boSnnCFSvkDOy9wBmUSQ0jCKFP0QlSKNR7KtAVvNpesOVOVgU5?= =?us-ascii?Q?L3heP95QS1I2osMod727XWIpz3u2EIwLxgxRpQstZTuZUdx0t1SwLzLsWRYv?= =?us-ascii?Q?IcKonRjISUwU61hrW6cUpRe9xyEt5cvQGjYDdJPWAeyRHLbO/5oVlYmTUvWz?= =?us-ascii?Q?IWsNaJAG2T7qmAQ+AtNHYuqku+RkIGHr+lKzTKfO6UwHolXOXi5B9q8J44XJ?= =?us-ascii?Q?ADTtmcAX1jOjiZCRlCA2qhbG90MJkW1fJ4yrFCZuijys2dHt7G6C/21W3+WX?= =?us-ascii?Q?oo+o01iGkG5Jyg066LxiJ6taJC0yHfgIiq6lvCY3FRpdLK50NNA9f/BA9TQG?= =?us-ascii?Q?W51TvY7G3fgH6PMgfN1cdzbzlOKzj1qGdn1gsZbNFH2c92Ya7FksoDdKrBme?= =?us-ascii?Q?wW0OmRun/+27bIPWQ1QhmwXi9gmh9fKKNjTIlp9J8A2ca/8Xg9DhEaJGauSO?= =?us-ascii?Q?eU3aRoeR8GynC2HTa7hu2QYyMpSWSt5BWYF0DMgM?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c9365ec-7b23-4e2c-8915-08dc0cfd7cc3 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2024 08:16:43.8594 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: NSHU6i1HDcPViMlbcP+WZKuqGpOOe8y4bFwR+nZzLkvj3sck5QEBdRYTzuhAVXILnBYF8MnbfpUDMt8fZZ2DDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7194 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,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: kcev8K7Q8x55tt18s6ND24Udx7686176AA= 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=tZBCKgse; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); 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 [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Nickle Wang > Sent: Thursday, January 4, 2024 1:10 PM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Igor Kulchytskyy > ; Nick Ramirez > Subject: [edk2-redfish-client][PATCH 4/4] RedfishClientPkg/Features: > introduce boot option > > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. > > > - Introduce Redfish boot option driver and library. > This is to support Redfish resource at: > /redfish/v1/Systems/SYSTEM_ID/BootOptions > - Make ETag parameter as optional parameter in > CreatePayloadToPatchResource function. > > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nick Ramirez > --- > .../RedfishClientComponents.dsc.inc | 2 + > RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + > .../BootOption/v1_0_4/Dxe/BootOptionDxe.inf | 56 ++ > .../v1_0_4/Common/BootOptionCommon.h | 33 + > .../v1_0_4/Common/BootOptionCommon.c | 799 > ++++++++++++++++++ > .../BootOption/v1_0_4/Dxe/BootOptionDxe.c | 701 +++++++++++++++ > .../RedfishFeatureUtilityLib.c | 4 +- > RedfishClientPkg/RedfishClient.fdf.inc | 2 + > 8 files changed, 1596 insertions(+), 2 deletions(-) > create mode 100644 > RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf > create mode 100644 > RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionComm > on.h > create mode 100644 > RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionComm > on.c > create mode 100644 > RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > > diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc > b/RedfishClientPkg/RedfishClientComponents.dsc.inc > index 300f2e21..ae2a4b02 100644 > --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc > +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc > @@ -33,6 +33,7 @@ > > RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystem > CollectionDxe.inf > RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > > RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.in > f > + RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf > > !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc > > @@ -45,3 +46,4 @@ > > RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSys > temCollection_Dxe.inf > RedfishClientPkg/Converter/Bios/v1_0_9/RedfishBios_V1_0_9_Dxe.inf > > RedfishClientPkg/Converter/BootOptionCollection/RedfishBootOptionCollecti > on_Dxe.inf > + > RedfishClientPkg/Converter/BootOption/v1_0_4/RedfishBootOption_V1_0_ > 4_Dxe.inf > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index f961d697..9c7889d2 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -24,6 +24,7 @@ > > ComputerSystemCollectionLib|RedfishClientPkg/ConverterLib/edk2library/Co > mputerSystemCollection/Lib.inf > > BiosV1_0_9Lib|RedfishClientPkg/ConverterLib/edk2library/Bios/v1_0_9/Lib.i > nf > > BootOptionCollectionLib|RedfishClientPkg/ConverterLib/edk2library/BootOp > tionCollection/Lib.inf > + > BootOptionV1_0_4Lib|RedfishClientPkg/ConverterLib/edk2library/BootOptio > n/v1_0_4/Lib.inf > # > # Above modules should be pulled in by build tool. > # > diff --git > a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf > b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf > new file mode 100644 > index 00000000..00c1c5bb > --- /dev/null > +++ > b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf > @@ -0,0 +1,56 @@ > +## @file > +# > +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D BootOptionDxe > + FILE_GUID =3D 66F61747-ECF2-48E6-A221-D210C6382195 > + 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/BootOptionCommon.h > + ../Common/BootOptionCommon.c > + BootOptionDxe.c > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + EdkIIRedfishResourceConfigLib > + RedfishLib > + RedfishFeatureUtilityLib > + RedfishResourceIdentifyLib > + UefiLib > + UefiDriverEntryPoint > + RedfishAddendumLib > + RedfishHttpCacheLib > + UefiBootManagerLib > + DevicePathLib > + BaseLib > + > +[Protocols] > + gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED > + gEfiRestJsonStructureProtocolGuid ## CONSUMED > + gEdkIIRedfishResourceConfigProtocolGuid ## PRODUCED > + > +[Pcd] > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize > + > +[Depex] > + TRUE > diff --git > a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > mon.h > b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > mon.h > new file mode 100644 > index 00000000..83babf16 > --- /dev/null > +++ > b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > mon.h > @@ -0,0 +1,33 @@ > +/** @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_BOOT_OPTION_COMMON_H_ > +#define EFI_REDFISH_BOOT_OPTION_COMMON_H_ > + > +#include > +#include > +#include > +#include > > +#include > + > +// > +// Schema information. > +// > +#define RESOURCE_SCHEMA "BootOption" > +#define RESOURCE_SCHEMA_MAJOR "1" > +#define RESOURCE_SCHEMA_MINOR "0" > +#define RESOURCE_SCHEMA_ERRATA "4" > +#define RESOURCE_SCHEMA_VERSION "v1_0_4" > +#define REDPATH_ARRAY_PATTERN L"/BootOptions/\\{.*\\}/" > +#define REDPATH_ARRAY_PREFIX L"/BootOptions/" > +#define RESOURCE_SCHEMA_FULL "x-uefi-redfish- > BootOption.v1_0_4" > +#define REDFISH_BOOT_OPTION_PARAMETER L"?name=3D" > +#define REDFISH_BOOT_OPTION_DEBUG_TRACE DEBUG_INFO > +#endif > diff --git > a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > mon.c > b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > mon.c > new file mode 100644 > index 00000000..0d4c2162 > --- /dev/null > +++ > b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCom > mon.c > @@ -0,0 +1,799 @@ > +/** @file > + Redfish feature driver implementation - common functions > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include "BootOptionCommon.h" > + > +CHAR8 BootOptionEmptyJson[] =3D "{\"@odata.id\": \"\", \"@odata.type\": > \"#BootOption.v1_0_4.BootOption\", \"Id\": \"\", \"Name\": \"\", > \"BootOptionEnabled\": false, \"BootOptionReference\": \"\", > \"Description\":\"\", \"DisplayName\": \"\", \"UefiDevicePath\":\"\"}"; > + > +REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate =3D > NULL; > + > +/** > + Get boot option variable name from BootOptionReference attribute in Bo= ot > Option resource. > + It's caller's responsibility to release BootOptionName by calling Free= Pool(). > + > + @param[in] BootOptionCs Pointer to boot option structure. > + @param[in] BootOptionName Boot option name read from boot option > resource. > + > + @retval EFI_SUCCESS Boot option name is read successfully. > + @retval Others Some error happened. > + > +**/ > +EFI_STATUS > +GetBootOptionNameFromRedfish ( > + IN EFI_REDFISH_BOOTOPTION_V1_0_4_CS *BootOptionCs, > + OUT EFI_STRING *BootOptionName > + ) > +{ > + if ((BootOptionCs =3D=3D NULL) || (BootOptionName =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + *BootOptionName =3D NULL; > + > + if (BootOptionCs->BootOptionReference =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Missing BootOptionReference attribute > which is mandatory attribute, ignore this!\n", __func__)); > + return EFI_PROTOCOL_ERROR; > + } > + > + *BootOptionName =3D StrAsciiToUnicode (BootOptionCs- > >BootOptionReference); > + if (*BootOptionName =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + 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_BOOTOPTION_V1_0_4 *BootOption; > + EFI_REDFISH_BOOTOPTION_V1_0_4_CS *BootOptionCs; > + EFI_BOOT_MANAGER_LOAD_OPTION LoadOption; > + BOOLEAN LoadOptionEnabled; > + EFI_STRING BootOptionName; > + > + if ((Private =3D=3D NULL) || IS_EMPTY_STRING (Json)) { > + return EFI_INVALID_PARAMETER; > + } > + > + BootOption =3D NULL; > + BootOptionCs =3D NULL; > + BootOptionName =3D NULL; > + > + Status =3D Private->JsonStructProtocol->ToStructure ( > + Private->JsonStructProtocol, > + NULL, > + Json, > + (EFI_REST_JSON_STRUCTURE_HEADE= R **)&BootOption > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, > Status)); > + return Status; > + } > + > + BootOptionCs =3D BootOption->BootOption; > + > + // > + // Check ETAG to see if we need to consume it > + // > + if (CheckEtag (Private->Uri, HeaderEtag, NULL)) { > + // > + // No change > + // > + DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: ETAG: %s has no > change, ignore consume action\n", __func__, Private->Uri)); > + Status =3D EFI_SUCCESS; > + goto ON_RELEASE; > + } > + > + // > + // Get boot option variable name from Redfish. > + // > + Status =3D GetBootOptionNameFromRedfish (BootOptionCs, > &BootOptionName); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: can not get boot option name: %r\n", > __func__, Status)); > + goto ON_RELEASE; > + } > + > + // > + // Find corresponding Boot#### boot option. > + // > + Status =3D EfiBootManagerVariableToLoadOption (BootOptionName, > &LoadOption); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: can not load boot option: %s\n", __func__, > BootOptionName)); > + goto ON_RELEASE; > + } > + > + // > + // BootOptionEnabled is the only attribute that is not read-only. > + // > + if (BootOptionCs->BootOptionEnabled !=3D NULL) { > + LoadOptionEnabled =3D ((LoadOption.Attributes & LOAD_OPTION_ACTIVE) > =3D=3D LOAD_OPTION_ACTIVE); > + > + if (*BootOptionCs->BootOptionEnabled !=3D LoadOptionEnabled) { > + if (*BootOptionCs->BootOptionEnabled) { > + LoadOption.Attributes |=3D LOAD_OPTION_ACTIVE; > + } else { > + LoadOption.Attributes &=3D ~LOAD_OPTION_ACTIVE; > + } > + > + // > + // Save to variable. > + // > + Status =3D EfiBootManagerLoadOptionToVariable (&LoadOption); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: can not %a boot option: %s: %r", > __func__, (*BootOptionCs->BootOptionEnabled ? "enable" : "disable"), > BootOptionName, Status)); > + } > + } > + } > + > + EfiBootManagerFreeLoadOption (&LoadOption); > + > +ON_RELEASE: > + > + // > + // Release resource. > + // > + Private->JsonStructProtocol->DestoryStructure ( > + Private->JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)BootO= ption > + ); > + > + if (BootOptionName !=3D NULL) { > + FreePool (BootOptionName); > + } > + > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +ProvisioningBootOptionProperties ( > + 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_BOOTOPTION_V1_0_4 *BootOption; > + EFI_REDFISH_BOOTOPTION_V1_0_4_CS *BootOptionCs; > + EFI_STATUS Status; > + BOOLEAN PropertyChanged; > + EFI_BOOT_MANAGER_LOAD_OPTION LoadOption; > + EFI_STRING DevicePathString; > + BOOLEAN LoadOptionEnabled; > + CHAR8 *AsciiStringValue; > + > + if ((JsonStructProtocol =3D=3D NULL) || (ResultJson =3D=3D NULL) || > IS_EMPTY_STRING (InputJson) || IS_EMPTY_STRING (ConfigureLang)) { > + return EFI_INVALID_PARAMETER; > + } > + > + DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: provision for %s > with: %s\n", __func__, ConfigureLang, (ProvisionMode ? L"Provision > resource" : L"Update resource"))); > + > + *ResultJson =3D NULL; > + PropertyChanged =3D FALSE; > + DevicePathString =3D NULL; > + AsciiStringValue =3D NULL; > + BootOption =3D NULL; > + > + Status =3D JsonStructProtocol->ToStructure ( > + JsonStructProtocol, > + NULL, > + InputJson, > + (EFI_REST_JSON_STRUCTURE_HEADER **)&Boo= tOption > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, > Status)); > + return Status; > + } > + > + BootOptionCs =3D BootOption->BootOption; > + > + // > + // Find corresponding Boot#### boot option. > + // > + Status =3D EfiBootManagerVariableToLoadOption (ConfigureLang, > &LoadOption); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: can not load boot option: %s\n", __func__, > ConfigureLang)); > + goto ON_RELEASE; > + } > + > + // > + // ID > + // > + if (BootOptionCs->Id !=3D NULL) { > + BootOptionCs->Id =3D NULL; > + } > + > + // > + // Name > + // > + if (BootOptionCs->Name !=3D NULL) { > + BootOptionCs->Name =3D NULL; > + } > + > + // > + // BootOptionEnabled > + // > + if (PropertyChecker (BootOptionCs->BootOptionEnabled, ProvisionMode)) = { > + LoadOptionEnabled =3D ((LoadOption.Attributes & LOAD_OPTION_ACTIVE) > =3D=3D LOAD_OPTION_ACTIVE); > + if (*BootOptionCs->BootOptionEnabled !=3D LoadOptionEnabled) { > + *BootOptionCs->BootOptionEnabled =3D LoadOptionEnabled; > + PropertyChanged =3D TRUE; > + } > + } > + > + // > + // BootOptionReference > + // > + if (PropertyChecker (BootOptionCs->BootOptionReference, > ProvisionMode)) { > + AsciiStringValue =3D StrUnicodeToAscii (ConfigureLang); > + if (AsciiStringValue !=3D NULL) { > + if ((BootOptionCs->BootOptionReference =3D=3D NULL) || (AsciiStrCm= p > (AsciiStringValue, BootOptionCs->BootOptionReference) !=3D 0)) { > + BootOptionCs->BootOptionReference =3D AsciiStringValue; > + PropertyChanged =3D TRUE; > + } else { > + FreePool (AsciiStringValue); > + AsciiStringValue =3D NULL; > + BootOptionCs->BootOptionReference =3D NULL; > + } > + } > + } > + > + // > + // Description > + // > + if (PropertyChecker (BootOptionCs->Description, ProvisionMode)) { > + AsciiStringValue =3D StrUnicodeToAscii (LoadOption.Description); > + if (AsciiStringValue !=3D NULL) { > + if ((BootOptionCs->Description =3D=3D NULL) || (AsciiStrCmp > (AsciiStringValue, BootOptionCs->Description) !=3D 0)) { > + BootOptionCs->Description =3D AsciiStringValue; > + PropertyChanged =3D TRUE; > + } else { > + FreePool (AsciiStringValue); > + AsciiStringValue =3D NULL; > + BootOptionCs->Description =3D NULL; > + } > + } > + } > + > + // > + // DisplayName > + // > + if (PropertyChecker (BootOptionCs->DisplayName, ProvisionMode)) { > + AsciiStringValue =3D StrUnicodeToAscii (LoadOption.Description); > + if (AsciiStringValue !=3D NULL) { > + if ((BootOptionCs->DisplayName =3D=3D NULL) || (AsciiStrCmp > (AsciiStringValue, BootOptionCs->DisplayName) !=3D 0)) { > + BootOptionCs->DisplayName =3D AsciiStringValue; > + PropertyChanged =3D TRUE; > + } else { > + FreePool (AsciiStringValue); > + AsciiStringValue =3D NULL; > + BootOptionCs->DisplayName =3D NULL; > + } > + } > + } > + > + // > + // UefiDevicePath > + // > + if (PropertyChecker (BootOptionCs->UefiDevicePath, ProvisionMode)) { > + DevicePathString =3D ConvertDevicePathToText (LoadOption.FilePath, T= RUE, > FALSE); > + if (DevicePathString !=3D NULL) { > + AsciiStringValue =3D StrUnicodeToAscii (DevicePathString); > + if (AsciiStringValue !=3D NULL) { > + if ((BootOptionCs->UefiDevicePath =3D=3D NULL) || (AsciiStrCmp > (AsciiStringValue, BootOptionCs->UefiDevicePath) !=3D 0)) { > + BootOptionCs->UefiDevicePath =3D AsciiStringValue; > + PropertyChanged =3D TRUE; > + } else { > + FreePool (AsciiStringValue); > + AsciiStringValue =3D NULL; > + BootOptionCs->UefiDevicePath =3D NULL; > + } > + } > + > + FreePool (DevicePathString); > + } > + } > + > + EfiBootManagerFreeLoadOption (&LoadOption); > + > +ON_RELEASE: > + > + // > + // Convert C structure back to JSON text. > + // > + Status =3D JsonStructProtocol->ToJson ( > + JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)BootO= ption, > + ResultJson > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status))= ; > + return Status; > + } > + > + // > + // Release resource. > + // > + JsonStructProtocol->DestoryStructure ( > + JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)BootOption > + ); > + > + return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); > +} > + > +/** > + 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 > + ) > +{ > + CHAR8 *Json; > + CHAR8 *JsonWithAddendum; > + EFI_STATUS Status; > + EFI_STRING NewResourceLocation; > + EFI_STRING BootOptionName; > + REDFISH_RESPONSE Response; > + > + if (Private =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + Json =3D NULL; > + JsonWithAddendum =3D NULL; > + NewResourceLocation =3D NULL; > + BootOptionName =3D NULL; > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + > + if (ResourceExist) { > + DEBUG ((DEBUG_ERROR, "%a: dose not support the exist boot option > resource\n")); > + return EFI_UNSUPPORTED; > + } > + > + // > + // Get boot option name from URI. The name is in the query parameter: > "?name=3D" > + // > + BootOptionName =3D StrStr (Private->Uri, > REDFISH_BOOT_OPTION_PARAMETER); > + if (BootOptionName =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: can not get boot option name in: %s\n", > __func__, Private->Uri)); > + return EFI_DEVICE_ERROR; > + } > + > + BootOptionName[0] =3D '\0'; > + > + BootOptionName +=3D StrLen (REDFISH_BOOT_OPTION_PARAMETER); > + if (BootOptionName[0] =3D=3D '\0') { > + DEBUG ((DEBUG_ERROR, "%a: empty boot option name in: %s\n", > __func__, Private->Uri)); > + return EFI_DEVICE_ERROR; > + } > + > + Status =3D ProvisioningBootOptionProperties ( > + Private->JsonStructProtocol, > + BootOptionEmptyJson, > + NULL, > + BootOptionName, > + TRUE, > + &Json > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: provisioning resource for %s failed: %r\n"= , > __func__, BootOptionName, 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, NULL, NULL); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: post BootOption resource for %s failed: > %r\n", __func__, BootOptionName, Status)); > + goto RELEASE_RESOURCE; > + } > + > + // > + // per Redfish spec. the URL of new resource will be returned in "Loca= tion" > header. > + // > + Status =3D GetEtagAndLocation (&Response, NULL, &NewResourceLocation); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __func__, > Status)); > + goto RELEASE_RESOURCE; > + } > + > + // > + // Keep location of new resource. > + // > + if (NewResourceLocation !=3D NULL) { > + DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: Location: %s\n", > __func__, NewResourceLocation)); > + RedfishSetRedfishUri (BootOptionName, NewResourceLocation); > + } > + > +RELEASE_RESOURCE: > + > + if (NewResourceLocation !=3D NULL) { > + FreePool (NewResourceLocation); > + } > + > + if (Json !=3D NULL) { > + FreePool (Json); > + } > + > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + > + return Status; > +} > + > +/** > + 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 > + ) > +{ > + EFI_STATUS Status; > + EFI_REDFISH_BOOTOPTION_V1_0_4 *BootOption; > + EFI_REDFISH_BOOTOPTION_V1_0_4_CS *BootOptionCs; > + EFI_STRING BootOptionName; > + EFI_BOOT_MANAGER_LOAD_OPTION LoadOption; > + REDFISH_RESPONSE Response; > + BOOLEAN DeleteResourceRequired; > + EFI_STRING DevicePathString; > + CHAR8 *DevicePathAsciiString; > + CHAR8 *AsciiUri; > + > + if ((Private =3D=3D NULL) || IS_EMPTY_STRING (Json)) { > + return EFI_INVALID_PARAMETER; > + } > + > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + DevicePathString =3D NULL; > + DevicePathAsciiString =3D NULL; > + DeleteResourceRequired =3D FALSE; > + BootOptionName =3D NULL; > + BootOption =3D NULL; > + AsciiUri =3D NULL; > + Response.Payload =3D NULL; > + Status =3D Private->JsonStructProtocol->ToStructure ( > + Private->JsonS= tructProtocol, > + NULL, > + Json, > + (EFI_REST_JSON= _STRUCTURE_HEADER > **)&BootOption > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, > Status)); > + return Status; > + } > + > + BootOptionCs =3D BootOption->BootOption; > + > + // > + // Get boot option variable name from Redfish. > + // > + Status =3D GetBootOptionNameFromRedfish (BootOptionCs, > &BootOptionName); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: can not get boot option name: %r\n", > __func__, Status)); > + goto ON_RELEASE; > + } > + > + // > + // Find corresponding Boot#### boot option. > + // > + Status =3D EfiBootManagerVariableToLoadOption (BootOptionName, > &LoadOption); > + if (!EFI_ERROR (Status)) { > + // > + // Check the UefiDevicePath > + // > + if (BootOptionCs->UefiDevicePath !=3D NULL) { > + DevicePathString =3D ConvertDevicePathToText (LoadOption.FilePath,= TRUE, > FALSE); > + if (DevicePathString !=3D NULL) { > + DevicePathAsciiString =3D StrUnicodeToAscii (DevicePathString); > + if (DevicePathAsciiString !=3D NULL) { > + if (AsciiStrCmp (DevicePathAsciiString, BootOptionCs- > >UefiDevicePath) !=3D 0) { > + // > + // The device path of this boot option is not the one in sys= tem. > + // > + DeleteResourceRequired =3D TRUE; > + } > + > + FreePool (DevicePathAsciiString); > + } > + > + FreePool (DevicePathString); > + } else { > + DeleteResourceRequired =3D TRUE; > + } > + } > + > + EfiBootManagerFreeLoadOption (&LoadOption); > + } else { > + DeleteResourceRequired =3D TRUE; > + } > + > + // > + // This boot option is deleted in system. Remove it from BMC too. > + // > + if (DeleteResourceRequired) { > + DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: boot option %s is > deleted in system. Delete %s\n", __func__, BootOptionName, Private->Uri))= ; > + AsciiUri =3D StrUnicodeToAscii (Private->Uri); > + if (AsciiUri =3D=3D NULL) { > + Status =3D EFI_OUT_OF_RESOURCES; > + goto ON_RELEASE; > + } > + > + Status =3D RedfishDeleteByUri (Private->RedfishService, AsciiUri, > &Response); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: can not delete %s: %r\n", __func__, > Private->Uri, Status)); > + } > + > + // > + // We delete this resource. So this is not the resource that we supp= orted. > + // Return EFI_UNSUPPORTED and caller will ignore this resource. > + // > + Status =3D EFI_UNSUPPORTED; > + } else { > + // > + // This is the boot option in system and we need further processing = to it. > + // > + Status =3D EFI_SUCCESS; > + > + // > + // If configure language is missing due to default settings, > + // create the record because this is the boot option that we > + // handle. > + // > + if (RedfishGetConfigLanguage (Private->Uri) =3D=3D NULL) { > + RedfishSetRedfishUri (BootOptionName, Private->Uri); > + } > + } > + > +ON_RELEASE: > + > + // > + // Release resource > + // > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + > + // > + // Release resource. > + // > + Private->JsonStructProtocol->DestoryStructure ( > + Private->JsonStructProtocol, > + (EFI_REST_JSON_STRUCTURE_HEADER *)BootO= ption > + ); > + > + if (BootOptionName !=3D NULL) { > + FreePool (BootOptionName); > + } > + > + if (AsciiUri !=3D NULL) { > + FreePool (AsciiUri); > + } > + > + 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; > + REDFISH_RESPONSE Response; > + > + if ((Private =3D=3D NULL) || IS_EMPTY_STRING (InputJson)) { > + return EFI_INVALID_PARAMETER; > + } > + > + Json =3D NULL; > + ConfigureLang =3D NULL; > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + > + ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); > + if (ConfigureLang =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } > + > + Status =3D ProvisioningBootOptionProperties ( > + Private->JsonStructProtocol, > + InputJson, > + NULL, > + ConfigureLang, > + FALSE, > + &Json > + ); > + if (EFI_ERROR (Status)) { > + if (Status =3D=3D EFI_NOT_FOUND) { > + DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%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_BOOT_OPTION_DEBUG_TRACE, "%a: update resource for > %s\n", __func__, ConfigureLang)); > + > + // > + // PATCH 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", > __func__, ConfigureLang, Status)); > + } > + > +ON_RELEASE: > + > + if (Json !=3D NULL) { > + FreePool (Json); > + } > + > + if (ConfigureLang !=3D NULL) { > + FreePool (ConfigureLang); > + } > + > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + > + 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; > + > + Supported =3D RedfishIdentifyResource (Private->Uri, Private->Json); > + if (Supported) { > + return EFI_SUCCESS; > + } > + > + return EFI_UNSUPPORTED; > +} > diff --git > a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > new file mode 100644 > index 00000000..ba090c51 > --- /dev/null > +++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c > @@ -0,0 +1,701 @@ > +/** @file > + Redfish feature driver implementation - BootOption > + > + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include "../Common/BootOptionCommon.h" > + > +extern REDFISH_RESOURCE_COMMON_PRIVATE > *mRedfishResourcePrivate; > + > +EFI_HANDLE mRedfishResourceConfigProtocolHandle; > + > +/** > + 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 ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: provisioning in %s > mode\n", __func__, (PostMode ? L"POST" : L"PATCH"))); > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + Private =3D > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC > OL (This); > + > + if (Private->RedfishService =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + > + 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. > + // > + RedfishHttpResetResource (Private->Uri); > + SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE); > + } > + > + 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_PROTOC > OL (This); > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE)); > + > + if (Private->RedfishService =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + > + 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. > + // > + Status =3D GetPendingSettings ( > + Private->RedfishService, > + Response.Payload, > + &PendingSettingResponse, > + &PendingSettingUri > + ); > + if (!EFI_ERROR (Status)) { > + DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: @Redfish.Settings > found: %s\n", __func__, PendingSettingUri)); > + Private->Uri =3D PendingSettingUri; > + ExpectedResponse =3D &PendingSettingResponse; > + } else { > + 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; > + Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > + 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); > + } > + > + if (Private->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; > + } > + > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + Private =3D > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC > OL (This); > + > + if (Private->RedfishService =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + > + 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. > + // > + RedfishHttpResetResource (Private->Uri); > + 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; > + } > + > + 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; > + } > + > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + Private =3D > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC > OL (This); > + > + if (Private->RedfishService =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + > + 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; > + Status =3D GetEtagAndLocation (&Response, &Etag, NULL); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", > __func__)); > + } > + > + Status =3D RedfishCheckResourceCommon (Private, Private->Json, Etag); > + if (EFI_ERROR (Status)) { > + DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%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; > + } > + > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + Private =3D > REDFISH_RESOURCE_COMMON_PRIVATE_DATA_FROM_RESOURCE_PROTOC > OL (This); > + > + if (Private->RedfishService =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + > + 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 ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%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 > initialized. > + @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 > unloaded. > + > + @retval EFI_SUCCESS The image has been unloaded. > + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishResourceUnload ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; > + > + if (mRedfishResourcePrivate =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; > +} > diff --git > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib. > c > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib. > c > index cad91a41..1c2d40f6 100644 > --- > a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib. > c > +++ > b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib. > c > @@ -1856,7 +1856,7 @@ CreatePayloadToPatchResource ( > IN REDFISH_SERVICE *Service, > IN REDFISH_PAYLOAD *TargetPayload, > IN CHAR8 *Json, > - OUT CHAR8 **Etag > + OUT CHAR8 **Etag OPTIONAL > ) > { > REDFISH_PAYLOAD Payload; > @@ -1864,7 +1864,7 @@ CreatePayloadToPatchResource ( > REDFISH_RESPONSE PostResponse; > EFI_STATUS Status; > > - if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_S= TRING (Json) > || (Etag =3D=3D NULL)) { > + if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_S= TRING > (Json)) { > return EFI_INVALID_PARAMETER; > } > > diff --git a/RedfishClientPkg/RedfishClient.fdf.inc > b/RedfishClientPkg/RedfishClient.fdf.inc > index b8619417..59b8acba 100644 > --- a/RedfishClientPkg/RedfishClient.fdf.inc > +++ b/RedfishClientPkg/RedfishClient.fdf.inc > @@ -24,6 +24,7 @@ > INF RedfishClientPkg/HiiToRedfishBootDxe/HiiToRedfishBootDxe.inf > INF RedfishClientPkg/HiiToRedfishBiosDxe/HiiToRedfishBiosDxe.inf > INF > RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.in > f > + INF > RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf > > !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc > # > @@ -35,4 +36,5 @@ > INF > RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSys > temCollection_Dxe.inf > INF RedfishClientPkg/Converter/Bios/v1_0_9/RedfishBios_V1_0_9_Dxe.inf > INF > RedfishClientPkg/Converter/BootOptionCollection/RedfishBootOptionCollecti > on_Dxe.inf > + INF > RedfishClientPkg/Converter/BootOption/v1_0_4/RedfishBootOption_V1_0_ > 4_Dxe.inf > !endif > -- > 2.34.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 (#113146): https://edk2.groups.io/g/devel/message/113146 Mute This Topic: https://groups.io/mt/103517656/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-