From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.87]) by mx.groups.io with SMTP id smtpd.web10.6135.1681366878569039410 for ; Wed, 12 Apr 2023 23:21:18 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=A3dva6ZK; 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.94.87, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZDIg5cKCa+3CNbVRleGlhze5DSbOrD6WOmNW7opC8RD+hXTtPuP6NOAjKqkxMZSdDCKEKFOshkLITG8b8e/5wXRY68/SBn0Xnys5va+WWD5U9/scnqtAwj7ktFu7suJC0lpaNTloX39T0XoJLFhT0t/f0qUPW9jZMHlxYnCRX5SzTNrB8BhN2X0OkDa+3fWchhQhnTldhqLGh3Wzkw5HAYyYLfJX8Oa1z3iHoxYrzPQ6k/NyHP9pTY5nn0EZQ9wJp0pCxTaiPjwT4uVQl14l14UJQCEcRJqzDjPzJWBh6r2FVOaFseh2nlN8kpNunZlqt133AYoIQqnT2NQx9WaSMw== 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=5ITjhizbDTbOXxOzhazUf5+s9vDDHqNrKPKouwSzAJc=; b=Nn6IyZLZ+Mfofwg2ZrCR99p6dG4kLrhXsijOy5YHIun5c3UQbePoaJXo1d1O833wlJnY/Eh4mS9ofhjmVeawChPiVh1FBYCkcWWFsrXjle/kZc1/aGTWiJhE/IOjnGcpu1Ddvt2XfDzCiCDFIO876V9QTe8S16FPVR7eqnxvKnpKcvygZ4OOchKIY6mIDO8Ck5E/EbqYCqc/l49Rc4Wr1BVIkoX03kF6dtTnUL3EOJ6VxMEQYOAvS8enbLjcnOl2DL/lFuZx7nS4LWkJLoECxxnCWfitK6caSi3+jjvSKPnjebmJRM+6IHQAwXlkq7zJOnjW0uvNbghdIOjy3zh6Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=5ITjhizbDTbOXxOzhazUf5+s9vDDHqNrKPKouwSzAJc=; b=A3dva6ZKCilDSS6T3WjbjRUHJg8+qYtkZ2I3403JdVboy6rpLf7dn1CsIqsarl4oc6to/WLea2G88tonj4kCVyiy7lzodao4Xe8SL1DwX7oGrToeODBE5u3aCBdYeFW24HaDh+vUrf+gh77QYNZbiUZ19baucabQjURPCjq7VJa4l8mvAHNKwBpp+4er4lmtKq3T6aH7dCaoMcV33AQyNb/sKAIKQPEHoEqmTpv9VRVlqu24ny6oPdajIPAXm9rdUwbhloANgnlKkZPUHBljV1AGwmEfJvAiNU7imn7XdUuxcqIUqv8f9efNaCb0hnC3eWTV+tEJqiABvFcDHkOW9Q== Received: from MW4PR03CA0247.namprd03.prod.outlook.com (2603:10b6:303:b4::12) by BL1PR12MB5223.namprd12.prod.outlook.com (2603:10b6:208:315::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Thu, 13 Apr 2023 06:21:15 +0000 Received: from CO1NAM11FT065.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::e9) by MW4PR03CA0247.outlook.office365.com (2603:10b6:303:b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Thu, 13 Apr 2023 06:21:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT065.mail.protection.outlook.com (10.13.174.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.31 via Frontend Transport; Thu, 13 Apr 2023 06:21:14 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 12 Apr 2023 23:21:04 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 12 Apr 2023 23:21:02 -0700 Received: from NV-CL38DL3.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 12 Apr 2023 23:21:01 -0700 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [PATCH 4/5] RedfishPkg: Helper library of EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL Date: Thu, 13 Apr 2023 14:21:01 +0800 Message-ID: <20230413062101.1746-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: CO1NAM11FT065:EE_|BL1PR12MB5223:EE_ X-MS-Office365-Filtering-Correlation-Id: 1498c744-e9be-4b30-0c20-08db3be748a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: niUVwEfr1CcRmYbRH58QtXwJVItmFCb73sdmw8Sl6e37f72bCVmW7NhAbtHgPjdqWy2JrhFz8zQhN1vRpU/sUg858MTIlv6sDaKuPJSvfBekif3z4jdlGc86FiGvOfLcslbRiPJeVe8G1Gmcoo3LAg3+ToBIgvuaG8hP5soS1UI0sw85wD8dqDRTJ8/2TBjkKeP6KHjxIkdK9wKnZ6Tfv00s2gHvp9m0t1T0F2BNnG9Ec/kD/NmxQG4Ih0BmjsoEn/TUD+Akf0enrVlp35QKICzjdty17Ax31M4gb9L/rRaguaR3XI1/AJBndF1uxGG7EazN3pjHFEXliyRObNqfEgfy/7Rl5Ox55WFnLSNvNhZ0IBike+OF2pjK6OMD/wdpWdBFoDhGhFOdo3w6733B64bb3WaMMwec0/tPNAO2kYWvbG/bFq0N+nERiRuyJ5tdUl3io1CxRJ0NzewUKqyY521ZolCZcD+0Vf8SHzUoKHeBpOUYcOR8DtphDnI2HhTb/3GMMWKAXZnWawFwGSX9W/pzFLIfp61zHZOF3LNU3z+VGPXxJtbUaWXNDunWoHStUV7uvt7MhQkH+lQtQ91r3T8Nq5KEJxYc0/puyVnW2ohD07w9ERI7P6/voUQgwlVe26T/A36TFXaLIzxqvzWkN4iNm7fqP0FHNJrraJj7ZC5RnB8g0a4SOCNpxRI/fsWGnHy5TSig9g3paq0lcGSag4PEx7XqEBZ8oK1sywcOyfrZYFTMFMVSlaUEyNo8bMeJxc8cPJVWH5J9gtUabI4XnL9vFxXzuW4HCk1z4FYt/8A= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(136003)(346002)(396003)(451199021)(40470700004)(46966006)(36840700001)(47076005)(336012)(2616005)(426003)(82310400005)(86362001)(2906002)(30864003)(83380400001)(356005)(40480700001)(34020700004)(7636003)(36860700001)(82740400003)(36756003)(40460700003)(7696005)(41300700001)(70206006)(70586007)(4326008)(6916009)(8676002)(8936002)(5660300002)(316002)(478600001)(54906003)(107886003)(1076003)(26005)(186003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2023 06:21:14.4445 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1498c744-e9be-4b30-0c20-08db3be748a6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5223 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 --- RedfishPkg/RedfishPkg.dec | 5 + .../RedfishPlatformConfigLib.inf | 41 +++ .../Library/RedfishPlatformConfigLib.h | 143 ++++++++ .../RedfishPlatformConfigInternal.h | 31 ++ .../RedfishPlatformConfigLib.c | 310 ++++++++++++++++++ 5 files changed, 530 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..a000dc72cbd0 --- /dev/null +++ b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigInte= rnal.h @@ -0,0 +1,31 @@ +/** @file + Internal function header for Redfish Platform Config Library. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + 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 + +typedef struct { + EFI_EVENT ProtocolEvent; // Protocol not= ification event. + VOID *Registration; // Protocol not= ification 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..3d16f7c08bf3 --- /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", __FUNCTION__, 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", _= _FUNCTION__)); + } + + 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