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 7DCDDAC0C3B for ; Thu, 4 Jan 2024 08:16:46 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=PCiSvI9tmXE7hxrNkiXwMWyoFLaW6guOS5NX/LiymVI=; 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=1704356205; v=1; b=GlHvBJQC36IACDmh2HIZ4ODYNMB0O1zI6sDhlxkuA18DpV9uuyf0jZQP/GTjvjOvCjZ6GwC/ klIT0nWZ0C1HtbXE3U5zPHdrIf0FSJUwJEeUZGkSDCJPLXIZ11kkJNalBYrp2LsBKmvlqjyV/c9 OBEXIRaXU9R9jStdpu4lrJqU= X-Received: by 127.0.0.2 with SMTP id 3QaSYY7687511xhWAV5KQwIU; Thu, 04 Jan 2024 00:16:45 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.85]) by mx.groups.io with SMTP id smtpd.web11.49628.1704356204338583903 for ; Thu, 04 Jan 2024 00:16:44 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S8GKM7+5SsZxhGCs1fyDaJwbRF9xjR/wV75Fd6jJ5xKIZ2G7eyQsB2s0wnQtWPVWFPamD3efC7iBx/tEMAivmHbYoSF72h+Hz8geifyXmnYaHTCfLV/LuyNvq1FF4OdG3YYun/gnXymz36+u6BiGeVvJ+zaHTx0jV5bw6Igfdg4EcmJukeJbNUBtgEy6q5Qdavvzw2LUxpMRbT3cJMZhcR+CaABHcigupSE2iQyyg6LTs4VZV9kENhnwoOV4+Sek/Ew1f4Cne9PQh7V7zbiawKm4zqbKBTuFtk5y/lTAN+e5JPmR/Rk3d7o44V1KuGMXToHvvadFuTqYkCxZRqW0Dw== 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=4miZuMKiUj31JgCh8sPgxxXw0n65N7atx0swMOItJkQ=; b=jpSAwVANn6M+r/AFHFPMZPl33wHMSm0OiB6gV+i2RsRINkWvTCSiEkWgVXflJMLtL0hlvzzT+ny4Zo0xWWknKBOBstyTOfUZhaYe95WwJ+w3M5xSPmav2K38gir04IOxUpxZcFYWKXKuiMuhzOlTpfxfth+rQ7kvYugKt4bbyOaBDjOUAVOb6OLgGqN9AiJ3H8ur5dSegs2A/C46nSzNkNCoo/1mWheWsKihB11H4DewkJjs3UFGQqgLig2bHc4Rn+1Ce2cpQEYEpfW4cjtGMrUN1fzaTulloIn8UpNyQFtEz+M4zVyzOhaWgWM3MxaFwptALEMO1l261gmagNwCnw== 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:40 +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:40 +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 3/4] RedfishClientPkg/Features: introduce boot option collection Thread-Topic: [edk2-redfish-client][PATCH 3/4] RedfishClientPkg/Features: introduce boot option collection Thread-Index: AQHaPsxB4XxWRPTnDkCtfJcciZAL97DJTxBA Date: Thu, 4 Jan 2024 08:16:40 +0000 Message-ID: References: <20240104050932.70704-1-nicklew@nvidia.com> In-Reply-To: <20240104050932.70704-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=c54dbe97-d74d-41f3-b54f-f4be96aa3436;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:34Z;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: fc55dd67-8a5a-427a-30f2-08dc0cfd7ad1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 4YOxi2IpxHqAjAUn7gvyF2pBNt+0ObLJy88RY6zobzHE0DRAqX9iGixSeBIqGJ1RHpNpYLBbwPjDzSOHBovvcaRE1ZMgN1nrIv82kVJC/3l9VGuQPgh8KP3t8/yuZU7tk/ACzBUCmugW+TOCTb/aZhjnKxNvi4PV6sxYkPO9GtxrkZvh9IikhnNWh6Uf8SmWAGZfcFI4qNE/A8ZJMGRhONV+/S14odndwbODCp15hSaj+0mptAnltSIuuZA2mQPrvo1sSb/k9Q71aPI6aAFEKxkEACtn1Hb6UgwNmyEqsi2FOJCE9sXd9+rmnxfX2KYnn9FNtqn5T9L5rnMGh/1VWI2JEhZaci72KIk1AorxB6rFo+mVw17Ful8tUkwMPkBmpzJrdKx94/mH3XGUR9WbkFooTF3h/lTYylPjzObMIPrQNGVNMTNz5Wh9Gwly3Gdkt5f3cu9Sl9l2Phc1Gi4jKGPOTTQMi9rHsRGvcVdd8m9QUMkyot/I+P6YqZDb/T74ieC5d/vT+P9B7ns0toSF/5Zjx1Iq2mHgViKA2/I2p7bIFfhSg6TPeCeM9r9Ove+G1uDyYXf/fwOP2jx3lhOeVvVJEw3p1JHc6i1SO9NrzVfyV5CuQQFlF3ey2ZGpjfCMvzb6xoPYhLILFzqZoTP95rMsiNPwqnDtEG1q9kJYBVUs+6pkO7I4PTfivOxpGgA7 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?q4CHViFCy1+iWPkHvmBNMBh19qQM8eE4ki5vFmJZRPv1vYmWlezr3F3hb/Tq?= =?us-ascii?Q?1X6fXsWklKKkrq77Ai0tiy/ghljbQlTuwzbUvBu/fmV5mc6JLxErvam7y+/W?= =?us-ascii?Q?62QZJpSuDupWz9id7pcmbhZQ27DT1metXbMG0Ky/CqY2azmV3ivqVzmz3qNu?= =?us-ascii?Q?Nwm43dIGobqTC6m994CZSuXZzMGEOV1HDDXHXjV3e+0dG7mgRzAXEGSZlgq8?= =?us-ascii?Q?Fcl6p93gQMRXFpRZ98o7w3GsOW+XyLbEsu3kqyCPRymihnNkFfsrBxe6CC6E?= =?us-ascii?Q?OYmT36QDo3LMdBOivUTA6/MHIv7UopDct/B6RCkAVmgGKZn1K0Cq2zXkqFyw?= =?us-ascii?Q?2cgdAfWlDWghFXfOlmIk9NxG1BbhE+HNrNQLqQGMrh7S6tKFx40t3auyJpFs?= =?us-ascii?Q?TfyFvkq5njPizLKS2iWjixWswpvaLNk9xNsqOIkGI9l7ebzISnknkUmRr0/P?= =?us-ascii?Q?QP9WhVyTo5kCLnq0MMij5xD/64PYzDMq5ZNUKM+ifmd3/l+WRuyfLqRO1sHq?= =?us-ascii?Q?84EVNkJDAxqc4CT3ZSwZzEkgSrqp5soAvIkmkO+z800cBNYNPQRhHhaqeHYO?= =?us-ascii?Q?iMuv/Rli8LCqR6Ke3LDl47d1gH/kpOT4YP+JPEyRi7wScJ/6GbWEWLIBSYgj?= =?us-ascii?Q?TGhGPigvXeAQlNbebo/5jYOtEnmSGOZQoFgIxQHEHRmx1Nyz2kaA8JKm0g2q?= =?us-ascii?Q?Or7Vbh1Lfx45UU4wQ4YouiajLiDd6GV2AzspV6geZ+tqKV0HfZSi4hZKsdai?= =?us-ascii?Q?vYX5bWUf8Kf+wPunTcWuEEnT83/RGURrvYzfRvfykAAWJcKuLR9iF7skC5RP?= =?us-ascii?Q?b8BhJQjlNnO/4yO/SBQk0PMJ2NDXrXg1fJyOZ8fVAOQQ9G5BnIsawjbWHbAH?= =?us-ascii?Q?PRHqStmdSMgs/NOaF7BelXWwVUoeAE5/KIn4zaaq522eZSbTKsT9c1Q9SR2R?= =?us-ascii?Q?RQZRMwyG9eSpSxXTgag/ACAHwlVldCWvuE4z4930CLFAf3CWiBFrm96eTMQH?= =?us-ascii?Q?i3lLdjoxniOHc5gz7mWjHt7r5zj+YO8l+RHZwKXBhnPpDCKAlilLFFFoL1MU?= =?us-ascii?Q?XnLt1SlB27uicK/PJo/HRMamoY1WLzgTiEkbRlvqhHAOzkgICFQ7+xTFb6ku?= =?us-ascii?Q?Dx3pQ2lcKMxOUq3BHVtWOIUW/BdoMGgaiU2hEaWEDoQhvmfm49Qc1oUeAoIQ?= =?us-ascii?Q?daKd8tILX61VjvCqANyRLjLweqnGKF5L6/zpRi7+IWnrjFTU3s1dG+2y0tRu?= =?us-ascii?Q?k5X2T5TmIoxWTlNuiGuUmyYySwVARVjd4xZQktAR6Z7taavNLqBKhyWmkNX8?= =?us-ascii?Q?gTUZwycbxpDTQG12Jyxr94OYydGYbAD5igMTBdb0j/THHAUJwXycXEpgPiX0?= =?us-ascii?Q?qupTUZ/lD57p9RRcNc2FEt/AHZBM/i6rjB/4hbBy8X/tCEDADmqGX0Vm5fbX?= =?us-ascii?Q?o7Wk26mZY6gu/6Lh0EWXgM4p8c9FtNJg5iUGIeiDOMJrUr0ddFEv/Wx+upy1?= =?us-ascii?Q?eKwpqr8z6l/h2YB1kz5kgHN9QkyQyOZgaPxKhEN9mHx00Y5WvlTHcBdBuCbb?= =?us-ascii?Q?n/QfB7dv5JjlCHoCrSU=3D?= 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: fc55dd67-8a5a-427a-30f2-08dc0cfd7ad1 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2024 08:16:40.6360 (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: VvsL8J3ZP98jAsZVwD15WpV0M8JL/Sz9zsgoWz9jXo6hvQEWx/33010Gq00Lh7NqzDLBrjx8HNny3ubHP/4aog== 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: 9F9W9TXaNtK0MRoNyiQitLFpx7686176AA= 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=GlHvBJQC; 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 3/4] RedfishClientPkg/Features: > introduce boot option collection > > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. > > > Introduce Redfish boot option collection driver and library. > This is to support Redfish resource at: > /redfish/v1/Systems/SYSTEM_ID/BootOptions > > Signed-off-by: Nickle Wang > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nick Ramirez > --- > .../RedfishClientComponents.dsc.inc | 4 +- > RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + > .../BootOptionCollectionDxe.inf | 60 ++ > .../BootOptionCollectionDxe.h | 33 + > .../BootOptionCollectionDxe.c | 858 ++++++++++++++++++ > RedfishClientPkg/RedfishClient.fdf.inc | 4 +- > 6 files changed, 958 insertions(+), 2 deletions(-) > create mode 100644 > RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.in > f > create mode 100644 > RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.h > create mode 100644 > RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.c > > diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc > b/RedfishClientPkg/RedfishClientComponents.dsc.inc > index 0e27198a..300f2e21 100644 > --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc > +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc > @@ -7,7 +7,7 @@ > # "RedfishClientDefines.dsc.inc". > # > # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> -# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -32,6 +32,7 @@ > } > > RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystem > CollectionDxe.inf > RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf > + > RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.in > f > > !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc > > @@ -43,3 +44,4 @@ > > RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSyst > em_V1_5_0_Dxe.inf > > 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 > diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > index 572f426e..f961d697 100644 > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > @@ -23,6 +23,7 @@ > > ComputerSystemV1_5_0Lib|RedfishClientPkg/ConverterLib/edk2library/Com > puterSystem/v1_5_0/Lib.inf > > 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 > # > # Above modules should be pulled in by build tool. > # > diff --git > a/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .inf > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .inf > new file mode 100644 > index 00000000..7977fa46 > --- /dev/null > +++ > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .inf > @@ -0,0 +1,60 @@ > +## @file > +# > +# Redfish BootOptionCollection collection driver. > +# > +# (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 BootOptionCollectionDxe > + FILE_GUID =3D C66FAB8D-38D0-424D-86F4-F3A37204F7D7 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + ENTRY_POINT =3D RedfishCollectionEntryPoint > + UNLOAD_IMAGE =3D RedfishCollectionUnload > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + RedfishPkg/RedfishPkg.dec > + RedfishClientPkg/RedfishClientPkg.dec > + > +[Sources] > + BootOptionCollectionDxe.h > + BootOptionCollectionDxe.c > + > +[LibraryClasses] > + DebugLib > + BaseMemoryLib > + ConverterCommonLib > + MemoryAllocationLib > + RedfishFeatureUtilityLib > + RedfishLib > + UefiLib > + UefiDriverEntryPoint > + UefiBootServicesTableLib > + EdkIIRedfishResourceConfigLib > + RedfishVersionLib > + RedfishHttpCacheLib > + UefiBootManagerLib > + DevicePathLib > + > +[Protocols] > + gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMED > + gEfiRestJsonStructureProtocolGuid ## CONSUMED > + gEdkIIRedfishFeatureProtocolGuid ## CONSUMED > + > +[Guids] > + > +[Pcd] > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize > + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize > + > +[Depex] > + TRUE > diff --git > a/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .h > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .h > new file mode 100644 > index 00000000..52488ed1 > --- /dev/null > +++ > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .h > @@ -0,0 +1,33 @@ > +/** @file > + > + Redfish feature driver implementation - internal header 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 > + > +**/ > + > +#ifndef EFI_REDFISH_BOOT_OPTION_COLLECTION_H_ > +#define EFI_REDFISH_BOOT_OPTION_COLLECTION_H_ > + > +#include > +#include > +#include > > +#include > + > +#define REDFISH_SCHEMA_NAME "BootOption" > +#define REDFISH_SCHEMA_MAJOR "1" > +#define REDFISH_SCHEMA_MINOR "0" > +#define REDFISH_SCHEMA_ERRATA "4" > +#define REDFISH_MANAGED_URI L"Systems/{}/BootOpt= ions" > +#define MAX_URI_LENGTH 256 > +#define REDFISH_BOOT_OPTION_REFERENCE_NAME > "BootOptionReference" > +#define REDFISH_BOOT_OPTION_PREFIX "Boot" > +#define REDFISH_BOOT_OPTION_PREFIX_LEN 0x04 > +#define REDFISH_BOOT_OPTION_NUM_LEN 0x04 > +#define REDFISH_BOOT_OPTION_PARAMETER "?name=3D" > +#define REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE DEBUG_INFO > + > +#endif > diff --git > a/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .c > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .c > new file mode 100644 > index 00000000..54cabcbe > --- /dev/null > +++ > b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe > .c > @@ -0,0 +1,858 @@ > +/** @file > + > + Redfish feature driver implementation - BootOptionCollection > + > + (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 > + > +**/ > + > +#include "BootOptionCollectionDxe.h" > + > +REDFISH_COLLECTION_PRIVATE *mRedfishCollectionPrivate =3D NULL; > + > +/** > + Process specific member in collection. > + > + @param[in] Private Pointer to private instance. > + @param[in] Uri URI to this member. > + > + @retval EFI_SUCCESS collection member is handled successfu= lly. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +HandleResource ( > + IN REDFISH_COLLECTION_PRIVATE *Private, > + IN EFI_STRING Uri > + ) > +{ > + EFI_STATUS Status; > + REDFISH_SCHEMA_INFO SchemaInfo; > + EFI_STRING ConfigLang; > + BOOLEAN SystemRestDetected; > + > + if ((Private =3D=3D NULL) || IS_EMPTY_STRING (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Resource match > + // > + > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > process resource for: %s\n", __func__, Uri)); > + > + Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private- > >JsonStructProtocol, Uri, &SchemaInfo); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get schema information from: %s > %r\n", __func__, Uri, Status)); > + return Status; > + } > + > + // > + // Check and see if this is target resource that we want to handle. > + // Some resource is handled by other provider so we have to make sure = this > first. > + // > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > Identify for %s\n", __func__, Uri)); > + SystemRestDetected =3D FALSE; > + ConfigLang =3D RedfishGetConfigLanguage (Uri); > + if (ConfigLang =3D=3D NULL) { > + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Pri= vate- > >InformationExchange); > + if (EFI_ERROR (Status)) { > + if (Status =3D=3D EFI_UNSUPPORTED) { > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > \"%s\" is not handled by us\n", __func__, Uri)); > + return EFI_SUCCESS; > + } else if (Status =3D=3D EFI_NOT_FOUND) { > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > \"%s\" has nothing to handle\n", __func__, Uri)); > + return EFI_SUCCESS; > + } > + > + DEBUG ((DEBUG_ERROR, "%a: fail to identify resource: \"%s\": %r\n"= , > __func__, Uri, Status)); > + return Status; > + } > + > + // > + // When there is no history record in UEFI variable, this is first b= oot or > + // system is reset by defaulting command. The pending setting on BMC > may be > + // a stale value so we will ignore pending settings in BMC. > + // > + SystemRestDetected =3D TRUE; > + } else { > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > history record found: %s\n", __func__, ConfigLang)); > + FreePool (ConfigLang); > + } > + > + // > + // Check and see if target property exist or not even when collection > member exists. > + // If not, we sill do provision. > + // > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a Check > for %s\n", __func__, Uri)); > + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri); > + if (EFI_ERROR (Status)) { > + if (Status =3D=3D EFI_UNSUPPORTED) { > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > \"%s\" is not handled by us\n", __func__, Uri)); > + return EFI_ABORTED; > + } > + > + // > + // The target property does not exist, do the provision to create pr= operty. > + // > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a > provision for %s\n", __func__, Uri)); > + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, > Private->InformationExchange, FALSE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to provision with GET mode: %r\n"= , > __func__, Status)); > + } > + > + return Status; > + } > + > + // > + // Consume first. > + // > + if (SystemRestDetected) { > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a > system has been reset to default setting. ignore pending settings because= they > may be stale values\n", __func__)); > + } else { > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a > consume for %s\n", __func__, Uri)); > + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to consume resource for: %s: %r\n= ", > __func__, Uri, Status)); > + } > + } > + > + // > + // Patch. > + // > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a > update for %s\n", __func__, Uri)); > + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to update resource for: %s: %r\n", > __func__, Uri, Status)); > + } > + > + return Status; > +} > + > +/** > + This function get boot option number from given Uri and mark the boot > option > + in BootOptions array as processed. > + > + @param[in] RedfishService Pointer Redfish service. > + @param[in] BootOptions Boot option array. > + @param[in] BootOptionCount Number of boot option in BootOptions > array. > + @param[in] Uri The URI to get boot option information= . > + > + @retval EFI_SUCCESS Boot option is marked successfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +MarkBootOptionProcessed ( > + IN REDFISH_SERVICE RedfishService, > + IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, > + IN UINTN BootOptionCount, > + IN EFI_STRING Uri > + ) > +{ > + UINTN Index; > + REDFISH_RESPONSE Response; > + EDKII_JSON_VALUE JsonValue; > + EDKII_JSON_VALUE BootOptionReference; > + EFI_STATUS Status; > + CONST CHAR8 *BootReferenceString; > + UINTN OptionNumber; > + > + if ((BootOptions =3D=3D NULL) || (BootOptionCount =3D=3D 0) || IS_EMPT= Y_STRING > (Uri)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Get boot option reference attribute > + // > + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); > + Status =3D RedfishHttpGetResource (RedfishService, Uri, &Response, TRU= E); > + if (EFI_ERROR (Status) || (Response.Payload =3D=3D NULL)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to get resource from %s: %r", > __func__, Uri, Status)); > + return Status; > + } > + > + JsonValue =3D RedfishJsonInPayload (Response.Payload); > + if (!JsonValueIsObject (JsonValue)) { > + Status =3D EFI_NOT_FOUND; > + goto ON_RELEASE; > + } > + > + BootOptionReference =3D JsonObjectGetValue (JsonValueGetObject > (JsonValue), REDFISH_BOOT_OPTION_REFERENCE_NAME); > + if (!JsonValueIsString (BootOptionReference)) { > + Status =3D EFI_NOT_FOUND; > + goto ON_RELEASE; > + } > + > + BootReferenceString =3D JsonValueGetAsciiString (BootOptionReference); > + if (BootReferenceString =3D=3D NULL) { > + Status =3D EFI_NOT_FOUND; > + goto ON_RELEASE; > + } > + > + if (AsciiStrnCmp (BootReferenceString, REDFISH_BOOT_OPTION_PREFIX, > REDFISH_BOOT_OPTION_PREFIX_LEN) !=3D 0) { > + Status =3D EFI_NOT_FOUND; > + goto ON_RELEASE; > + } > + > + OptionNumber =3D AsciiStrHexToUintn (&BootReferenceString[4]); > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: boot > option number: 0x%x in %s\n", __func__, OptionNumber, Uri)); > + > + Status =3D EFI_NOT_FOUND; > + for (Index =3D 0; Index < BootOptionCount; Index++) { > + if (BootOptions[Index].OptionNumber =3D=3D OptionNumber) { > + BootOptions[Index].Status =3D EFI_ALREADY_STARTED; > + Status =3D EFI_SUCCESS; > + break; > + } > + } > + > +ON_RELEASE: > + > + RedfishFreeResponse ( > + Response.StatusCode, > + Response.HeaderCount, > + Response.Headers, > + Response.Payload > + ); > + > + return Status; > +} > + > +/** > + Create new member to collection resource. > + > + @param[in] Private Pointer to private instance. > + @param[in] BootOption The boot option which will be updated to BMC. > + > + @retval EFI_SUCCESS New collection member is created succe= ssfully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +CreateCollectionResource ( > + IN REDFISH_COLLECTION_PRIVATE *Private, > + IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption > + ) > +{ > + EFI_STATUS Status; > + REDFISH_SCHEMA_INFO SchemaInfo; > + EFI_STRING BootOptionUri; > + UINTN UriSize; > + > + if ((Private =3D=3D NULL) || (BootOption =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + UriSize =3D (StrLen (Private->CollectionUri) + > REDFISH_BOOT_OPTION_PREFIX_LEN + REDFISH_BOOT_OPTION_NUM_LEN + > sizeof (REDFISH_BOOT_OPTION_PARAMETER) + 1) * sizeof (CHAR16); > + BootOptionUri =3D AllocateZeroPool (UriSize); > + if (BootOptionUri =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + // > + // Build URI with query parameter to deliver the boot option name > + // > + UnicodeSPrint (BootOptionUri, UriSize, L"%s%a%a%04X", Private- > >CollectionUri, REDFISH_BOOT_OPTION_PARAMETER, > REDFISH_BOOT_OPTION_PREFIX, BootOption->OptionNumber); > + > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > create resource for collection for: %s\n", __func__, BootOptionUri)); > + > + AsciiStrCpyS (SchemaInfo.Schema, REDFISH_SCHEMA_STRING_SIZE, > REDFISH_SCHEMA_NAME); > + AsciiStrCpyS (SchemaInfo.Major, REDFISH_SCHEMA_VERSION_SIZE, > REDFISH_SCHEMA_MAJOR); > + AsciiStrCpyS (SchemaInfo.Minor, REDFISH_SCHEMA_VERSION_SIZE, > REDFISH_SCHEMA_MINOR); > + AsciiStrCpyS (SchemaInfo.Errata, REDFISH_SCHEMA_VERSION_SIZE, > REDFISH_SCHEMA_ERRATA); > + > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > supported schema: %a %a.%a.%a\n", __func__, SchemaInfo.Schema, > SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Errata)); > + > + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, > BootOptionUri, Private->InformationExchange, TRUE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to create resource for: %s: %r\n", > __func__, BootOptionUri, Status)); > + } > + > + return Status; > +} > + > +/** > + Process members in collection resource. > + > + @param[in] Private Pointer to private instance. > + > + @retval EFI_SUCCESS collection members are handled success= fully. > + @retval Others Errors occur. > + > +**/ > +EFI_STATUS > +HandleCollectionResource ( > + IN REDFISH_COLLECTION_PRIVATE *Private > + ) > +{ > + EFI_STATUS Status; > + EFI_REDFISH_BOOTOPTIONCOLLECTION *Collection; > + EFI_REDFISH_BOOTOPTIONCOLLECTION_CS *CollectionCs; > + RedfishCS_Link *List; > + RedfishCS_Header *Header; > + RedfishCS_Type_Uri_Data *UriData; > + EFI_STRING MemberUri; > + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > + UINTN BootOptionCount; > + UINTN Index; > + BOOLEAN IsLegacyOption; > + > + if (Private =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + if ((Private->JsonStructProtocol =3D=3D NULL) || (Private->CollectionJ= son =3D=3D > NULL)) { > + return EFI_NOT_READY; > + } > + > + // > + // Load boot options in system. > + // > + BootOptions =3D EfiBootManagerGetLoadOptions (&BootOptionCount, > LoadOptionTypeBoot); > + > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > process collection for: %s\n", __func__, Private->CollectionUri)); > + > + // > + // Convert JSON text to C structure. > + // > + Status =3D Private->JsonStructProtocol->ToStructure ( > + Private->JsonStructProtocol, > + NULL, > + Private->CollectionJson, > + (EFI_REST_JSON_STRUCTURE_HEADE= R **)&Collection > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, > Status)); > + return Status; > + } > + > + CollectionCs =3D Collection->BootOptionCollection; > + > + // > + // Handle existing resources. > + // > + if ((*CollectionCs->Membersodata_count > 0) && !IsLinkEmpty > (&CollectionCs->Members)) { > + List =3D GetFirstLink (&CollectionCs->Members); > + while (TRUE) { > + Header =3D (RedfishCS_Header *)List; > + > + if (Header->ResourceType =3D=3D RedfishCS_Type_Uri) { > + UriData =3D (RedfishCS_Type_Uri_Data *)Header; > + MemberUri =3D NULL; > + MemberUri =3D StrAsciiToUnicode (UriData->Uri); > + > + ASSERT (MemberUri !=3D NULL); > + > + if (MemberUri !=3D NULL) { > + Status =3D HandleResource (Private, MemberUri); > + if (EFI_ERROR (Status)) { > + if (Status !=3D EFI_ABORTED) { > + DEBUG ((DEBUG_ERROR, "%a: process BootOptionCollection > resource: %a failed: %r\n", __func__, UriData->Uri, Status)); > + } > + } > + > + // > + // This boot option is processed. > + // > + if (Status !=3D EFI_ABORTED) { > + Status =3D MarkBootOptionProcessed (Private->RedfishService, > BootOptions, BootOptionCount, MemberUri); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: mark boot option: %a failed: %r\= n", > __func__, UriData->Uri, Status)); > + } > + } > + > + FreePool (MemberUri); > + } > + } > + > + if (IsLinkAtEnd (&CollectionCs->Members, List)) { > + break; > + } > + > + List =3D GetNextLink (&CollectionCs->Members, List); > + } > + } > + > + // > + // Handle new resources. > + // > + for (Index =3D 0; Index < BootOptionCount; Index++) { > + // > + // This boot option is handled already. > + // > + if (BootOptions[Index].Status =3D=3D EFI_ALREADY_STARTED) { > + continue; > + } > + > + // > + // Don't display hidden boot options, but retain inactive ones. > + // > + if ((BootOptions[Index].Attributes & LOAD_OPTION_HIDDEN) !=3D 0) { > + continue; > + } > + > + // > + // Group the legacy boot option in the sub title created dynamically > + // > + IsLegacyOption =3D (BOOLEAN)((DevicePathType > (BootOptions[Index].FilePath) =3D=3D BBS_DEVICE_PATH) && > + (DevicePathSubType (BootOptions[Index].Fi= lePath) =3D=3D > BBS_BBS_DP) > + ); > + > + // > + // Don't display legacy boot options > + // > + if (IsLegacyOption) { > + continue; > + } > + > + Status =3D CreateCollectionResource (Private, &BootOptions[Index]); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: can not create resource for: %s\n", > __func__, BootOptions[Index].Description)); > + } > + } > + > + // > + // Release resource. > + // > + Private->JsonStructProtocol->DestoryStructure (Private- > >JsonStructProtocol, (EFI_REST_JSON_STRUCTURE_HEADER *)Collection); > + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); > + > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +ReleaseCollectionResource ( > + IN REDFISH_COLLECTION_PRIVATE *Private > + ) > +{ > + if (Private =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Release resource > + // > + if (Private->Response.Payload !=3D NULL) { > + RedfishFreeResponse ( > + Private->Response.StatusCode, > + Private->Response.HeaderCount, > + Private->Response.Headers, > + Private->Response.Payload > + ); > + Private->Response.StatusCode =3D NULL; > + Private->Response.HeaderCount =3D 0; > + Private->Response.Headers =3D NULL; > + Private->Response.Payload =3D NULL; > + } > + > + if (Private->CollectionJson !=3D NULL) { > + FreePool (Private->CollectionJson); > + Private->CollectionJson =3D NULL; > + } > + > + if (Private->RedfishVersion !=3D NULL) { > + FreePool (Private->RedfishVersion); > + Private->RedfishVersion =3D NULL; > + } > + > + return EFI_SUCCESS; > +} > + > +EFI_STATUS > +CollectionHandler ( > + IN REDFISH_COLLECTION_PRIVATE *Private > + ) > +{ > + EFI_STATUS Status; > + > + if (Private =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: > collection handler for %s\n", __func__, Private->CollectionUri)); > + > + // > + // Query collection from Redfish service. > + // > + Status =3D RedfishHttpGetResource (Private->RedfishService, Private- > >CollectionUri, &Private->Response, TRUE); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: unable to get resource from: %s :%r\n", > __func__, Private->CollectionUri, Status)); > + goto ON_RELEASE; > + } > + > + Private->CollectionPayload =3D Private->Response.Payload; > + ASSERT (Private->CollectionPayload !=3D NULL); > + > + Private->CollectionJson =3D JsonDumpString (RedfishJsonInPayload (Priv= ate- > >CollectionPayload), EDKII_JSON_COMPACT); > + ASSERT (Private->CollectionJson !=3D NULL); > + > + Status =3D HandleCollectionResource (Private); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: unable to handle collection resource at: > %s :%r\n", __func__, Private->CollectionUri, Status)); > + } > + > +ON_RELEASE: > + > + ReleaseCollectionResource (Private); > + > + return Status; > +} > + > +/** > + The callback function provided by Redfish Feature driver. > + > + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PR= OTOCOL > instance. > + @param[in] FeatureAction The action Redfish feature driver s= hould > take. > + @param[in] Uri The collection URI. > + @param[in] Context The context of Redfish feature driv= er. > + @param[in,out] InformationExchange The pointer to > RESOURCE_INFORMATION_EXCHANGE > + > + @retval EFI_SUCCESS Redfish feature driver callback is ex= ecuted > successfully. > + @retval Others Some errors happened. > + > + @retval EFI_SUCCESS Redfish feature driver callback is ex= ecuted > successfully. > + @retval Others Some errors happened. > + > +**/ > +EFI_STATUS > +EFIAPI > +RedfishCollectionFeatureCallback ( > + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, > + IN FEATURE_CALLBACK_ACTION FeatureAction, > + IN VOID *Context, > + IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange > + ) > +{ > + EFI_STATUS Status; > + REDFISH_SERVICE RedfishService; > + REDFISH_COLLECTION_PRIVATE *Private; > + EFI_STRING ResourceUri; > + > + if (FeatureAction !=3D CallbackActionStartOperation) { > + return EFI_UNSUPPORTED; > + } > + > + Private =3D (REDFISH_COLLECTION_PRIVATE *)Context; > + > + RedfishService =3D Private->RedfishService; > + if (RedfishService =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: no Redfish service configured\n", > __func__)); > + return EFI_NOT_READY; > + } > + > + // > + // Save in private structure. > + // > + Private->InformationExchange =3D InformationExchange; > + > + // > + // Find Redfish version on BMC > + // > + Private->RedfishVersion =3D RedfishGetVersion (RedfishService); > + > + // > + // Create the full URI from Redfish service root. > + // > + ResourceUri =3D (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof > (CHAR16)); > + if (ResourceUri =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for full URI.\n", > __func__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion); > + StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange- > >SendInformation.FullUri); > + > + // > + // Initialize collection path > + // > + Private->CollectionUri =3D RedfishGetUri (ResourceUri); > + if (Private->CollectionUri =3D=3D NULL) { > + ASSERT (FALSE); > + return EFI_OUT_OF_RESOURCES; > + } > + > + Status =3D CollectionHandler (Private); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: CollectionHandler failure: %r\n", __func__= , > Status)); > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + 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 > +RedfishCollectionInit ( > + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This, > + IN REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo > + ) > +{ > + REDFISH_COLLECTION_PRIVATE *Private; > + > + Private =3D REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL (This); > + > + Private->RedfishService =3D RedfishCreateService (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 > +RedfishCollectionStop ( > + IN EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This > + ) > +{ > + REDFISH_COLLECTION_PRIVATE *Private; > + > + Private =3D REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL (This); > + > + if (Private->RedfishService !=3D NULL) { > + RedfishCleanupService (Private->RedfishService); > + Private->RedfishService =3D NULL; > + } > + > + ReleaseCollectionResource (Private); > + > + if (Private->FeatureProtocol !=3D NULL) { > + Private->FeatureProtocol->Unregister ( > + Private->FeatureProtocol, > + REDFISH_MANAGED_URI, > + NULL > + ); > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + Callback function when gEfiRestJsonStructureProtocolGuid is installed. > + > + @param[in] Event Event whose notification function is being invoked= . > + @param[in] Context Pointer to the notification function's context. > +**/ > +VOID > +EFIAPI > +EfiRestJasonStructureProtocolIsReady ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + EFI_STATUS Status; > + > + if (mRedfishCollectionPrivate =3D=3D NULL) { > + return; > + } > + > + if (mRedfishCollectionPrivate->JsonStructProtocol !=3D NULL) { > + return; > + } > + > + Status =3D gBS->LocateProtocol ( > + &gEfiRestJsonStructureProtocolGuid, > + NULL, > + (VOID **)&mRedfishCollectionPrivate->JsonStructProtoco= l > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to locate > gEfiRestJsonStructureProtocolGuid: %r\n", __func__, Status)); > + } > + > + gBS->CloseEvent (Event); > +} > + > +/** > + Callback function when gEdkIIRedfishFeatureProtocolGuid is installed. > + > + @param[in] Event Event whose notification function is being invoked= . > + @param[in] Context Pointer to the notification function's context. > +**/ > +VOID > +EFIAPI > +EdkIIRedfishFeatureProtocolIsReady ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol; > + > + if (mRedfishCollectionPrivate =3D=3D NULL) { > + return; > + } > + > + if (mRedfishCollectionPrivate->FeatureProtocol !=3D NULL) { > + return; > + } > + > + Status =3D gBS->LocateProtocol ( > + &gEdkIIRedfishFeatureProtocolGuid, > + NULL, > + (VOID **)&FeatureProtocol > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to locate > gEdkIIRedfishFeatureProtocolGuid: %r\n", __func__, Status)); > + gBS->CloseEvent (Event); > + return; > + } > + > + Status =3D FeatureProtocol->Register ( > + FeatureProtocol, > + REDFISH_MANAGED_URI, > + RedfishCollectionFeatureCallback, > + (VOID *)mRedfishCollectionPrivate > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: failed to register %s: %r\n", __func__, > REDFISH_MANAGED_URI, Status)); > + } > + > + mRedfishCollectionPrivate->FeatureProtocol =3D FeatureProtocol; > + > + 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 > +RedfishCollectionUnload ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status; > + EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler; > + > + if (mRedfishCollectionPrivate =3D=3D NULL) { > + return EFI_NOT_READY; > + } > + > + ConfigHandler =3D NULL; > + > + // > + // Firstly, find ConfigHandler Protocol interface in this ImageHandle. > + // > + Status =3D gBS->OpenProtocol ( > + ImageHandle, > + &gEdkIIRedfishConfigHandlerProtocolGuid, > + (VOID **)&ConfigHandler, > + NULL, > + NULL, > + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL > + ); > + if (EFI_ERROR (Status) || (ConfigHandler =3D=3D NULL)) { > + return Status; > + } > + > + ConfigHandler->Stop (ConfigHandler); > + > + // > + // Last, uninstall ConfigHandler Protocol. > + // > + Status =3D gBS->UninstallMultipleProtocolInterfaces ( > + ImageHandle, > + &gEdkIIRedfishConfigHandlerProtocolGuid, > + ConfigHandler, > + NULL > + ); > + > + FreePool (mRedfishCollectionPrivate); > + mRedfishCollectionPrivate =3D NULL; > + > + return Status; > +} > + > +EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL mRedfishConfigHandler =3D { > + RedfishCollectionInit, > + RedfishCollectionStop > +}; > + > +/** > + This is the declaration of an EFI image entry point. This entry point = is > + the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers 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 EFI_ACCESS_DENIED EFI_ISCSI_INITIATOR_NAME_PROTOCOL > was installed unexpectedly. > + @retval Others Other errors as indicated. > +**/ > +EFI_STATUS > +EFIAPI > +RedfishCollectionEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + VOID *Registration; > + > + if (mRedfishCollectionPrivate !=3D NULL) { > + return EFI_ALREADY_STARTED; > + } > + > + mRedfishCollectionPrivate =3D AllocateZeroPool (sizeof > (REDFISH_COLLECTION_PRIVATE)); > + CopyMem (&mRedfishCollectionPrivate->ConfigHandler, > &mRedfishConfigHandler, sizeof > (EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL)); > + > + Status =3D gBS->InstallProtocolInterface ( > + &ImageHandle, > + &gEdkIIRedfishConfigHandlerProtocolGuid, > + EFI_NATIVE_INTERFACE, > + &mRedfishCollectionPrivate->ConfigHandler > + ); > + > + EfiCreateProtocolNotifyEvent ( > + &gEfiRestJsonStructureProtocolGuid, > + TPL_CALLBACK, > + EfiRestJasonStructureProtocolIsReady, > + NULL, > + &Registration > + ); > + > + EfiCreateProtocolNotifyEvent ( > + &gEdkIIRedfishFeatureProtocolGuid, > + TPL_CALLBACK, > + EdkIIRedfishFeatureProtocolIsReady, > + NULL, > + &Registration > + ); > + > + return Status; > +} > diff --git a/RedfishClientPkg/RedfishClient.fdf.inc > b/RedfishClientPkg/RedfishClient.fdf.inc > index afa6555a..b8619417 100644 > --- a/RedfishClientPkg/RedfishClient.fdf.inc > +++ b/RedfishClientPkg/RedfishClient.fdf.inc > @@ -6,7 +6,7 @@ > # to be built in the firmware volume. > # > # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> -# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -23,6 +23,7 @@ > INF RedfishClientPkg/HiiToRedfishMemoryDxe/HiiToRedfishMemoryDxe.inf > INF RedfishClientPkg/HiiToRedfishBootDxe/HiiToRedfishBootDxe.inf > INF RedfishClientPkg/HiiToRedfishBiosDxe/HiiToRedfishBiosDxe.inf > + INF > RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDxe.in > f > > !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc > # > @@ -33,4 +34,5 @@ > INF > RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSyst > em_V1_5_0_Dxe.inf > 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 > !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 (#113145): https://edk2.groups.io/g/devel/message/113145 Mute This Topic: https://groups.io/mt/103517655/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-