From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.86]) by mx.groups.io with SMTP id smtpd.web11.33217.1681895390571083303 for ; Wed, 19 Apr 2023 02:09:50 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=VKHCnW2L; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.244.86, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SG0fCTgAZO3TZKQ8wL5fhyIr1vKSK9s5DXWtHiaI1aeUZOp0QQag0ss+gx9NBCi+36hCS33AjKX8Ihhp4WNCwhI8O5M6FaL6U1yRaw1BWMuSayjGgnlq71zyDlX7UUQxvYYT/DPHJx20kBomur6BYu1dd8z0I+ALwbRen+Hr8C+HunfzOsaSgrLTPTuuENqdSVUpT3a18ypG38h9na91sFuOhjcaZLlnOygwVWAQWhjSFOFLzx4trqmFm54B5by2X4S3yKoqaAqlsKpg2R6lNDdcTx8c4elAPF4nOI4/xwd7SuiMcLGZEtX2Sae+fgc6ZiQIKDyvJShCFBMgC45CBw== 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=f9ris+aQZUdmlkMWf/pxrFPJi0EmxmMEei8msrTUEzY=; b=IpHI8o7h+RKzi9KTTjCJp1w/WeeZElnNpcnPx0YWz0ag9Uj8PtoK9FpfcPkFZFdlX6KUZ+CHIgg9ULEH8U63sme2lnHxu1n6gKgpzVT2MhF0N7ZabrqQWDIXEG32YIfod9T++M4P/rsGajZxUdRufmJ/QOGgOR0u4JWjZ9YPbATIHOU0dlY/L0dnSwte33HTWLEG/Mbl5JPvKBchdcfVSWEGR4HyV8nCGaPrfSdQJOxVx3ruJSd5DHX6b3umh4Im2T8/CZ9RisofqIw4oyEhdFD+/KhT2ZQsuLxBIpwOnyCh5uMcruZ10XCAShq3d1SKUAFW/H3UxMGsupL0jlZwIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f9ris+aQZUdmlkMWf/pxrFPJi0EmxmMEei8msrTUEzY=; b=VKHCnW2Lu4e8i2fdAKiP3NxQYgnmNxXopcDd5jqUn1DN4BrMr7MkGocvTmKrJJke06daVNxgC7KQS3znBnUPZcBhY9TwunNH2wOajqEplPrBwa+94JGXw6qbxDkT4vFkbZCFfk7GmpHngxOZxTaNNVZKHl9ShZv47QHjX3BBZjAltx7BY9rDHksxaxaQMcE7dEuQVPIJdbWVug6M6DczAhPJvXfrQVw8C84pgIBOBZj8PG0zkA7OexPrURO7aoaYgpRyBOUy0NEDYxdZiVagwuzp0rYGYErmRGEsNaTRjlyAd7cAd8xD1gVSKm+jHNCOsznub4CrwtLqhBLKho+59w== Received: from MW4PR04CA0133.namprd04.prod.outlook.com (2603:10b6:303:84::18) by MN2PR12MB4456.namprd12.prod.outlook.com (2603:10b6:208:266::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Wed, 19 Apr 2023 09:09:47 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::6) by MW4PR04CA0133.outlook.office365.com (2603:10b6:303:84::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22 via Frontend Transport; Wed, 19 Apr 2023 09:09:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22 via Frontend Transport; Wed, 19 Apr 2023 09:09:47 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 19 Apr 2023 02:09:42 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 19 Apr 2023 02:09:42 -0700 Received: from NV-CL38DL3.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 19 Apr 2023 02:09:41 -0700 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [PATCH v3 4/5] RedfishPkg: Helper library of EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL Date: Wed, 19 Apr 2023 17:09:40 +0800 Message-ID: <20230419090940.235-1-nicklew@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Return-Path: nicklew@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT013:EE_|MN2PR12MB4456:EE_ X-MS-Office365-Filtering-Correlation-Id: 766ee4ac-81b5-48fb-406d-08db40b5d2bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5V1pqr//uLuSsKQAX9WwIA+99CevV7YaPYWDnU+llJR1otbLUtT+LtjkvHLi8Ahf1cJxHPFaq5cs56g6iRxHLfEkmd7CkCLG0Hy1Kzpy8DtdZjbj51mEzsTavfmWmgQ4R2XMNp51Nei0T1ZacgtxwOpggy3dgka/OhIb2TYYrjqymPKsCOPVMui40vGFN8moA8u34fIGNjKFKJJj18ul82MwCMYwhTjvzT6iaacEO5+hrfwoBfdrkWt7x66sjdlXs6OQSqtvuhw3KBt6Qh3fikKo+jLOl+BqNJ3F4ffSoLwFMvJfqakMarojDh5JbmYxKdjHMqAat0Xpd+iLiTl5Xk3aTlq+tFqZOAFInY7Qfn2oBEIfZPgq4jnz0gTM24JDFLS71VGVMmyKRNfX9u0zuv2fB2B/baGcuit9ZMVzCiplePq9EoZnAzY2xju7MVlPSHEO4PEhB9cMN1Y7cFILIYUS8PPyvB8AvdFND0gmcxA3ju6g4K2Iau1L6VyWAzXhsL8g9k/ZifuvTEydMPoDcXFR8O5cP24PsdSNChNWLdk3jpigfn8Aydk3/kpbkEAqG6GPB9+iSTcGUdU42l1B/dCTJstbWjdmE++bgpIaX82L2VyhFcgGq5KPM3d1ZF7UGo1fhRUHNj8czPmNvV7/PXmDIjKeAGgyIOv7rwBJL3aHn4aY+RD+XWIVxpvdRdIiWKOTH5BXdAGlLPNI7Efk/0dIsei2UeutcYpGeE1n0iTdnk1ls8K56qOkjeJvtMb+iC2q1acjG5sfgLS52qzRSpWLDU9vYSLdYD0d29Fi3tg= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(346002)(136003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(54906003)(40480700001)(7696005)(478600001)(34070700002)(83380400001)(356005)(316002)(82740400003)(7636003)(41300700001)(4326008)(336012)(426003)(6916009)(47076005)(186003)(2616005)(70206006)(36860700001)(107886003)(70586007)(26005)(1076003)(5660300002)(30864003)(2906002)(8936002)(8676002)(40460700003)(86362001)(36756003)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2023 09:09:47.0839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 766ee4ac-81b5-48fb-406d-08db40b5d2bd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4456 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This is the helper library for using EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez Reviewed-by: Abner Chang --- RedfishPkg/RedfishPkg.dec | 5 + .../RedfishPlatformConfigLib.inf | 41 +++ .../Library/RedfishPlatformConfigLib.h | 143 ++++++++ .../RedfishPlatformConfigInternal.h | 35 ++ .../RedfishPlatformConfigLib.c | 310 ++++++++++++++++++ 5 files changed, 534 insertions(+) create mode 100644 RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlat= formConfigLib.inf create mode 100644 RedfishPkg/Include/Library/RedfishPlatformConfigLib.h create mode 100644 RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlat= formConfigInternal.h create mode 100644 RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlat= formConfigLib.c diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec index e2892ce9cec1..cdb1528cedc9 100644 --- a/RedfishPkg/RedfishPkg.dec +++ b/RedfishPkg/RedfishPkg.dec @@ -64,6 +64,11 @@ # HiiUtilityLib|Include/Library/HiiUtilityLib.h =20 + ## @libraryclass Provides the library functions to access Redfish Plat= form + # Config protocol. + # + RedfishPlatformConfigLib|Include/Library/RedfishPlatformConfigLib.h + [LibraryClasses.Common.Private] ## @libraryclass Provides the private C runtime library functions. # CRT library is currently used by edk2 JsonLib (open source diff --git a/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformCon= figLib.inf b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformCon= figLib.inf new file mode 100644 index 000000000000..2258609a1c91 --- /dev/null +++ b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.= inf @@ -0,0 +1,41 @@ +## @file +# Library for Redfish Platform Config Protocol +# +# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishPlatformConfigLib + FILE_GUID =3D C920FD62-21AC-4638-B9F5-9612942290F6 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishPlatformConfigLib| DXE_DRIVER = DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER + CONSTRUCTOR =3D RedfishPlatformConfigLibConstructor + DESTRUCTOR =3D RedfishPlatformConfigLibDestructor + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC RISCV64 +# + +[Sources] + RedfishPlatformConfigLib.c + RedfishPlatformConfigInternal.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiLib + +[Protocols] + gEdkIIRedfishPlatformConfigProtocolGuid diff --git a/RedfishPkg/Include/Library/RedfishPlatformConfigLib.h b/Redfis= hPkg/Include/Library/RedfishPlatformConfigLib.h new file mode 100644 index 000000000000..51a186163994 --- /dev/null +++ b/RedfishPkg/Include/Library/RedfishPlatformConfigLib.h @@ -0,0 +1,143 @@ +/** @file + Definitions of RedfishPlatformConfigLib + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_PLATFORM_CONFIG_LIB_H_ +#define REDFISH_PLATFORM_CONFIG_LIB_H_ + +#include + +/** + Get Redfish value with the given Schema and Configure Language. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[out] Value The returned value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + OUT EDKII_REDFISH_VALUE *Value + ); + +/** + Set Redfish value with the given Schema and Configure Language. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[in] Value The value to set. + + @retval EFI_SUCCESS Value is returned successfully. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigSetValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN EDKII_REDFISH_VALUE Value + ); + +/** + Get the list of Configure Language from platform configuration by the gi= ven Schema and Pattern. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] Pattern The target Configure Language pattern. + @param[out] ConfigureLangList The list of Configure Language. + @param[out] Count The number of Configure Language in Con= figureLangList. + + @retval EFI_SUCCESS ConfigureLangList is returned successfu= lly. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetConfigureLang ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING Pattern, + OUT EFI_STRING **ConfigureLangList, + OUT UINTN *Count + ); + +/** + Get the list of supported Redfish schema from platform configuration. + + @param[out] SupportedSchema The supported schema list which is sepa= rated by ';'. + For example: "x-uefi-redfish-Memory.v1_= 7_1;x-uefi-redfish-Boot.v1_0_1" + The SupportedSchema is allocated by the= callee. It's caller's + responsibility to free this buffer usin= g FreePool(). + + @retval EFI_SUCCESS Schema is returned successfully. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +EFIAPI +RedfishPlatformConfigGetSupportedSchema ( + OUT CHAR8 **SupportedSchema + ); + +/** + Get Redfish attribute value with the given Schema and Configure Language= . + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[out] AttributeValue The attribute value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetAttribute ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + OUT EDKII_REDFISH_ATTRIBUTE *AttributeValue + ); + +/** + Get Redfish default value with the given Schema and Configure Language. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[in] DefaultClass The UEFI defined default class. + Please refer to UEFI spec. 33.2.5.8 "de= faults" for details. + @param[out] Value The returned value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetDefaultValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN UINT16 DefaultClass, + OUT EDKII_REDFISH_VALUE *Value + ); + +#endif diff --git a/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformCon= figInternal.h b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatform= ConfigInternal.h new file mode 100644 index 000000000000..061e7f4a453c --- /dev/null +++ b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigInte= rnal.h @@ -0,0 +1,35 @@ +/** @file + Internal function header for Redfish Platform Config Library. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_PLATFORM_CONFIG_H_ +#define REDFISH_PLATFORM_CONFIG_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +/// +/// Definition of REDFISH_PLATFORM_CONFIG_LIB_PRIVATE +/// +typedef struct { + EFI_EVENT ProtocolEvent; ///< Protocol n= otification event. + VOID *Registration; ///< Protocol n= otification registration. + EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL *Protocol; +} REDFISH_PLATFORM_CONFIG_LIB_PRIVATE; + +#endif diff --git a/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformCon= figLib.c b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfi= gLib.c new file mode 100644 index 000000000000..3500b6aa8fb4 --- /dev/null +++ b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.= c @@ -0,0 +1,310 @@ +/** @file + Wrapper function to support Redfish Platform Config protocol. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "RedfishPlatformConfigInternal.h" + +REDFISH_PLATFORM_CONFIG_LIB_PRIVATE mRedfishPlatformConfigLibPrivate; + +/** + Get Redfish value with the given Schema and Configure Language. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[out] Value The returned value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + OUT EDKII_REDFISH_VALUE *Value + ) +{ + if (mRedfishPlatformConfigLibPrivate.Protocol =3D=3D NULL) { + return EFI_NOT_READY; + } + + return mRedfishPlatformConfigLibPrivate.Protocol->GetValue ( + mRedfishPlatformConf= igLibPrivate.Protocol, + Schema, + Version, + ConfigureLang, + Value + ); +} + +/** + Get Redfish attribute value with the given Schema and Configure Language= . + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[out] AttributeValue The attribute value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetAttribute ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + OUT EDKII_REDFISH_ATTRIBUTE *AttributeValue + ) +{ + if (mRedfishPlatformConfigLibPrivate.Protocol =3D=3D NULL) { + return EFI_NOT_READY; + } + + return mRedfishPlatformConfigLibPrivate.Protocol->GetAttribute ( + mRedfishPlatformConf= igLibPrivate.Protocol, + Schema, + Version, + ConfigureLang, + AttributeValue + ); +} + +/** + Get Redfish default value with the given Schema and Configure Language. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[in] DefaultClass The UEFI defined default class. + Please refer to UEFI spec. 33.2.5.8 "de= faults" for details. + @param[out] Value The returned value. + + @retval EFI_SUCCESS Value is returned successfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetDefaultValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN UINT16 DefaultClass, + OUT EDKII_REDFISH_VALUE *Value + ) +{ + if (mRedfishPlatformConfigLibPrivate.Protocol =3D=3D NULL) { + return EFI_NOT_READY; + } + + return mRedfishPlatformConfigLibPrivate.Protocol->GetDefaultValue ( + mRedfishPlatformConf= igLibPrivate.Protocol, + Schema, + Version, + ConfigureLang, + DefaultClass, + Value + ); +} + +/** + Set Redfish value with the given Schema and Configure Language. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] ConfigureLang The target value which match this confi= gure Language. + @param[in] Value The value to set. + + @retval EFI_SUCCESS Value is returned successfully. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigSetValue ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING ConfigureLang, + IN EDKII_REDFISH_VALUE Value + ) +{ + if (mRedfishPlatformConfigLibPrivate.Protocol =3D=3D NULL) { + return EFI_NOT_READY; + } + + return mRedfishPlatformConfigLibPrivate.Protocol->SetValue ( + mRedfishPlatformConf= igLibPrivate.Protocol, + Schema, + Version, + ConfigureLang, + Value + ); +} + +/** + Get the list of Configure Language from platform configuration by the gi= ven Schema and Pattern. + + @param[in] Schema The Redfish schema to query. + @param[in] Version The Redfish version to query. + @param[in] Pattern The target Configure Language pattern. + @param[out] ConfigureLangList The list of Configure Language. + @param[out] Count The number of Configure Language in Con= figureLangList. + + @retval EFI_SUCCESS ConfigureLangList is returned successfu= lly. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishPlatformConfigGetConfigureLang ( + IN CHAR8 *Schema, + IN CHAR8 *Version, + IN EFI_STRING Pattern, + OUT EFI_STRING **ConfigureLangList, + OUT UINTN *Count + ) +{ + if (mRedfishPlatformConfigLibPrivate.Protocol =3D=3D NULL) { + return EFI_NOT_READY; + } + + return mRedfishPlatformConfigLibPrivate.Protocol->GetConfigureLang ( + mRedfishPlatformConf= igLibPrivate.Protocol, + Schema, + Version, + Pattern, + ConfigureLangList, + Count + ); +} + +/** + Get the list of supported Redfish schema from platform configuration. + + @param[out] SupportedSchema The supported schema list which is sepa= rated by ';'. + For example: "x-uefi-redfish-Memory.v1_= 7_1;x-uefi-redfish-Boot.v1_0_1" + The SupportedSchema is allocated by the= callee. It's caller's + responsibility to free this buffer usin= g FreePool(). + + @retval EFI_SUCCESS Schema is returned successfully. + @retval EFI_NOT_READY Redfish Platform Config protocol is not= ready. + @retval Others Some error happened. + +**/ +EFI_STATUS +EFIAPI +RedfishPlatformConfigGetSupportedSchema ( + OUT CHAR8 **SupportedSchema + ) +{ + if (mRedfishPlatformConfigLibPrivate.Protocol =3D=3D NULL) { + return EFI_NOT_READY; + } + + return mRedfishPlatformConfigLibPrivate.Protocol->GetSupportedSchema ( + mRedfishPlatformConf= igLibPrivate.Protocol, + SupportedSchema + ); +} + +/** + This is a EFI_REDFISH_PLATFORM_CONFIG_PROTOCOL notification event handle= r. + + Install HII package notification. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. + +**/ +VOID +EFIAPI +RedfishPlatformConfigProtocolInstalled ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + + // + // Locate EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL. + // + Status =3D gBS->LocateProtocol ( + &gEdkIIRedfishPlatformConfigProtocolGuid, + NULL, + (VOID **)&mRedfishPlatformConfigLibPrivate.Protocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: locate EDKII_REDFISH_PLATFORM_CONFIG_PROTOCO= L failure: %r\n", __func__, Status)); + return; + } + + gBS->CloseEvent (Event); + mRedfishPlatformConfigLibPrivate.ProtocolEvent =3D NULL; +} + +/** + + Create protocol listener and wait for Redfish Platform Config protocol. + + @param ImageHandle The image handle. + @param SystemTable The system table. + + @retval EFI_SUCCESS Protocol listener is registered successfully. + +**/ +EFI_STATUS +EFIAPI +RedfishPlatformConfigLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + ZeroMem (&mRedfishPlatformConfigLibPrivate, sizeof (REDFISH_PLATFORM_CON= FIG_LIB_PRIVATE)); + mRedfishPlatformConfigLibPrivate.ProtocolEvent =3D EfiCreateProtocolNoti= fyEvent ( + &gEdkIIRedfishPlatfor= mConfigProtocolGuid, + TPL_CALLBACK, + RedfishPlatformConfig= ProtocolInstalled, + NULL, + &mRedfishPlatformConf= igLibPrivate.Registration + ); + if (mRedfishPlatformConfigLibPrivate.ProtocolEvent =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: failed to create protocol notify event\n", _= _func__)); + } + + return EFI_SUCCESS; +} + +/** + Unloads the application and its installed protocol. + + @param ImageHandle Handle that identifies the image to be unloaded= . + @param SystemTable The system table. + + @retval EFI_SUCCESS The image has been unloaded. + +**/ +EFI_STATUS +EFIAPI +RedfishPlatformConfigLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + if (mRedfishPlatformConfigLibPrivate.ProtocolEvent !=3D NULL) { + gBS->CloseEvent (mRedfishPlatformConfigLibPrivate.ProtocolEvent); + mRedfishPlatformConfigLibPrivate.ProtocolEvent =3D NULL; + } + + mRedfishPlatformConfigLibPrivate.Protocol =3D NULL; + + return EFI_SUCCESS; +} --=20 2.17.1