From nobody Sat May 18 23:44:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82769+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82769+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1635382929; cv=none; d=zohomail.com; s=zohoarc; b=gpu591LOyEQ1PxF1XzZf6WO3vt1Yuh4X2rGVa9eBq+VL/kguWSiV7u/EpHBem03q8jwCta/eqm4z/Vp31q2kFj3eqCYFtNLHtCt9kVBrvQgkpMRFmIh9kOnO9a8DI2pasLa8olvXVwXbRqNXx6i8IHUKCM/3x/SeMzcVvDlVi78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635382929; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=mBsyztuR5YZNfggLuX/KvZCYQy9v/khz30yVP53VVhs=; b=ldan1WAhijXn5EkW7Wc/008L/LWUqY8q53k2GNaKMP4pNFGk/V/gfDin6lV6ewmQ8Ggyfk/lICsNVVT6FzJ/HMNc/JTG+3FT2MA3K+nPeNicIxJGhEGRNYCWXOJIOvO5UZOHlnbtIr6O4EeesW/LhDYzKyDv24m4qQkhLdnu1iI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82769+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 163538292946889.77343029424605; Wed, 27 Oct 2021 18:02:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id pUQxYY1788612x2KaTjLnBlO; Wed, 27 Oct 2021 18:02:08 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.5120.1635382916388413401 for ; Wed, 27 Oct 2021 18:02:08 -0700 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19RLtK0f031886; Thu, 28 Oct 2021 01:00:31 GMT X-Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0a-002e3701.pphosted.com with ESMTP id 3by7cud2d8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Oct 2021 01:00:31 +0000 X-Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3425.houston.hpe.com (Postfix) with ESMTP id E26E0B8; Thu, 28 Oct 2021 01:00:30 +0000 (UTC) X-Received: from SAC2XFT1JT.asiapacific.hpqcorp.net (unknown [10.43.62.133]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id ABFD34C; Thu, 28 Oct 2021 01:00:29 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: nickle.wang@hpe.com, Liming Gao Subject: [edk2-devel] [PATCH] edk2-staging/RedfishPkg: Helper library of EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL Date: Thu, 28 Oct 2021 09:00:27 +0800 Message-Id: <20211028010028.36020-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: CVjYbC_0bfX7fK-h5QIrLKgjzGp0q1td X-Proofpoint-GUID: CVjYbC_0bfX7fK-h5QIrLKgjzGp0q1td X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: 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@hpe.com X-Gm-Message-State: HVSo8ZwMYuPbxdTrWP4k6ij9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1635382928; bh=gvjoOCcEUnydu4mgugzgna16eb8u1jmcJEKYuzn+evU=; h=Cc:Date:From:Reply-To:Subject:To; b=EkGo1gOswwR+kcNyMujAJJqdKIxA6HIvmVj37w6GBFeZjta7HlvnuTdOMue7RfY+vYG iHB6eXBbEEvSoadouqyXEX800j04r+hCmAl5W/O22hyB6rgPGeUJ9vDnZvYadwCGfJ/84 RKSIVaI8dTyYZcfi2ORr/UHFOBCWid7u4sQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1635382930398100001 Content-Type: text/plain; charset="utf-8" This is the helper library for using EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Liming Gao --- RedfishPkg/RedfishPkg.dec | 5 + .../RedfishPlatformConfigLib.inf | 41 +++ .../Library/RedfishPlatformConfigLib.h | 101 ++++++++ .../RedfishPlatformConfigInternal.h | 31 +++ .../RedfishPlatformConfigLib.c | 243 ++++++++++++++++++ 5 files changed, 421 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 eac219ccbb9..71f99066962 100644 --- a/RedfishPkg/RedfishPkg.dec +++ b/RedfishPkg/RedfishPkg.dec @@ -55,6 +55,11 @@ # RedfishContentCodingLib|Include/Library/RedfishContentCodingLib.h =20 + ## @libraryclass Provides the library functions to access Redfish Plat= form + # Config protocol. + # + RedfishPlatformConfigLib|Include/Library/RedfishPlatformConfigLib.h + ## @libraryclass Provides the library functions to parse IFR binary da= ta. # HiiUtilityLib|Include/Library/HiiUtilityLib.h diff --git a/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformCon= figLib.inf b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformCon= figLib.inf new file mode 100644 index 00000000000..5ad8d22087d --- /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 00000000000..ebe2329fd9a --- /dev/null +++ b/RedfishPkg/Include/Library/RedfishPlatformConfigLib.h @@ -0,0 +1,101 @@ +/** @file + Definitinos of RedfishPlatformConfigLib + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + 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] RedpathList 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 on = the give HII handle. + + @param[in] HiiHandle The target handle to search. If handle = is NULL, + this function return all schema from HI= I database. + @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 ( + IN EFI_HII_HANDLE HiiHandle, OPTIONAL + OUT CHAR8 **SupportedSchema + ); + +#endif diff --git a/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformCon= figInternal.h b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatform= ConfigInternal.h new file mode 100644 index 00000000000..8745faa0327 --- /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 00000000000..eb2c64b0e60 --- /dev/null +++ b/RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.c @@ -0,0 +1,243 @@ +/** @file + Wrapper function to support Redfish Platform Config protocol. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + 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 + ); +} + +/** + 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] RedpathList 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 paltform configuration on = give HII handle. + + @param[in] HiiHandle The target handle to search. If handle = is NULL, + this function return all schema from HI= I database. + @param[out] SupportedSchema The supported schema list which is sepa= rated by ';'. + 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 ( + IN EFI_HII_HANDLE HiiHandle OPTIONAL, + OUT CHAR8 **SupportedSchema + ) +{ + if (mRedfishPlatformConfigLibPrivate.Protocol =3D=3D NULL) { + return EFI_NOT_READY; + } + + return mRedfishPlatformConfigLibPrivate.Protocol->GetSupportedSchema ( + mRedfishPlatformConf= igLibPrivate.Protocol, + HiiHandle, + 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 prottocol listener and wait for Redfish Platform Config protocol. + + @param ImageHandle The image handle. + @param SystemTable The system table. + + @retval EFI_SUCEESS 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 ( + &gEdkIIRedfishPlatform= ConfigProtocolGuid, + TPL_CALLBACK, + RedfishPlatformConfigP= rotocolInstalled, + NULL, + &mRedfishPlatformConfi= gLibPrivate.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; +} \ No newline at end of file --=20 2.21.0.windows.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 (#82769): https://edk2.groups.io/g/devel/message/82769 Mute This Topic: https://groups.io/mt/86642905/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-