From nobody Mon Feb 9 21:37:07 2026 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+78229+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+78229+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1627401015; cv=none; d=zohomail.com; s=zohoarc; b=mcmMuOrjYscKvL9YW2rdSNIH1ATkrM8hiOETofyvb8B/xFqFjqu7cIx2fvqLOYYdLwOhHAAjtG9WkeW72VnwYAS1imCpd+c9uNfKSZu2EY7y5BJH84nz1NhOUMm4WV69MnxeUqBS6MEdvhafgGBxBP2CvvI+D/JbbA08hiUyKJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627401015; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=Y4w7bL+zN2ktdk4SKZR2eYegggNMl3wW9XuUnj8dvD8=; b=H2i6L3ZN2hGP3Jt3eW+GoliDu8rNQcYcvzWe6VFLYIdMZ9ItlS2yOcuoSrISAL8mQq6vjQrVFHP3tT8v4QzHI6tsr6JYIDepJfnWMuSo+Xc75r9yWyEXU7K0NG90dYlZBMzJKibS13eORBaoQ7CUO8rr4CPAObgiX6JrNNk7iUg= 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+78229+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 1627401015809475.8128848382556; Tue, 27 Jul 2021 08:50:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 19ICYY1788612xQf20U7K2Kc; Tue, 27 Jul 2021 08:50:15 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web08.3122.1627401014803601224 for ; Tue, 27 Jul 2021 08:50:15 -0700 X-Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16RFm1sa014604; Tue, 27 Jul 2021 15:50:03 GMT X-Received: from g9t5008.houston.hpe.com (g9t5008.houston.hpe.com [15.241.48.72]) by mx0b-002e3701.pphosted.com with ESMTP id 3a236dgj3a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Jul 2021 15:50:02 +0000 X-Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g9t5008.houston.hpe.com (Postfix) with ESMTP id DCD5A4F; Tue, 27 Jul 2021 15:49:59 +0000 (UTC) X-Received: from abner-virtual-machine.asiapacific.hpqcorp.net (abner-virtual-machine.asiapacific.hpqcorp.net [15.119.210.153]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id 06B1348; Tue, 27 Jul 2021 15:49:58 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Nickle Wang , Liming Gao Subject: [edk2-devel] [staging/edk2-redfish-client RedfishFeatureCore PATCH 2/3] RedfishClientPkg/RedfishFeatureCoreDxe: Redfish Feature Core DXE driver Date: Tue, 27 Jul 2021 22:54:41 +0800 Message-Id: <20210727145442.22840-3-abner.chang@hpe.com> In-Reply-To: <20210727145442.22840-1-abner.chang@hpe.com> References: <20210727145442.22840-1-abner.chang@hpe.com> X-Proofpoint-ORIG-GUID: gAr2ZwSX83nt-zSj2oq_ax8qVUThbt36 X-Proofpoint-GUID: gAr2ZwSX83nt-zSj2oq_ax8qVUThbt36 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: YRRnM6LJKAw8rRdFiMS5jviPx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1627401015; bh=BblS1/oJlGd6q168Gv0IXuWcfcrejRUGyAaO/7coK9w=; h=Cc:Date:From:Reply-To:Subject:To; b=a4kmRID1aBtapow89FDqSF7P73haY5FFOytelmNwbD8uwiDeNGRF3XhQ16POf6w3w8+ zWR4Elw6oI0UJxSSD3//cpe66QmKcymy9btYrdoBuLpwz59aPIYl942rvFiBvqkpdXXF6 kxTl4klSutAYzKDMbnAHOWSuz0d2Ky7fr5A= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1627401017757100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" EDKII Redfish Feature Core DXE driver provides the protocol interface to the auto-generated Redfish feature driver to register itself for the Redfish resource URI it manages. Refer to the Readme.md for the details. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Liming Gao --- RedfishClientPkg/RedfishClientPkg.dec | 13 +- .../RedfishClientComponents.dsc.inc | 2 + RedfishClientPkg/RedfishClient.fdf.inc | 1 + .../RedfishFeatureCoreDxe.inf | 49 +++ .../Include/Protocol/EdkIIRedfishFeature.h | 116 ++++++ .../RedfishFeatureCoreDxe.h | 43 ++ .../RedfishFeatureCoreDxe.c | 382 ++++++++++++++++++ RedfishClientPkg/Readme.md | 36 ++ 8 files changed, 641 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCo= reDxe.inf create mode 100644 RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h create mode 100644 RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCo= reDxe.h create mode 100644 RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCo= reDxe.c diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 4038a47bd5..6da0468e65 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -15,10 +15,21 @@ [Includes] Include =20 - [LibraryClasses] =20 [Protocols] + ## Include/Protocol/EdkIIRedfishFeature.h + gEdkIIRedfishFeatureProtocolGuid =3D { 0x785CC694, 0x4930, 0xEFBF, { 0x2= A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0xAA, 0x34 } } =20 [Guids] gEfiRedfishClientPkgTokenSpaceGuid =3D { 0x8c444dae, 0x728b, 0x48ee, = { 0x9e, 0x19, 0x8f, 0x0a, 0x3d, 0x4e, 0x9c, 0xc8 } } + +[PcdsFixedAtBuild] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|UINT= 32|0x10000001 + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|UINT= 32|0x10000002 + # + # gEfiEventReadyToBootGuid is the default event to startup Redfish featu= re drivers. + # { 0x7CE88FB3, 0x4BD7, 0x4679, { 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, 0x= 0D, 0x2B }} + # + gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEv= entGuid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8, = 0xD8, 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x10000003 + diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index 0648fa9d54..e4e2619bfb 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -13,4 +13,6 @@ ## =20 !if $(REDFISH_CLIENT) =3D=3D TRUE + RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf !endif + diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 4f0714004e..d4c5874787 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -11,4 +11,5 @@ # ## !if $(REDFISH_CLIENT) =3D=3D TRUE + INF RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf !endif diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.i= nf b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf new file mode 100644 index 0000000000..5a2cd7fecc --- /dev/null +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf @@ -0,0 +1,49 @@ +## @file +# RedfishFeatureCoreDxe is the DXE driver which provides +# EdkIIRedfishFeatureCoreProtocol to EDK2 Redfish Feature +# drivers for the registration. +# +# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001000b + BASE_NAME =3D RedfishFeatureCoreDxe + FILE_GUID =3D 1E01A624-4161-F1F1-25BC-D28E77420D8E + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D RedfishFeatureCoreEntryPoint + +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 RISCV64 +# + +[Sources] + RedfishFeatureCoreDxe.c + RedfishFeatureCoreDxe.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + PrintLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gEdkIIRedfishFeatureProtocolGuid ## BY_START + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEv= entGuid + +[Depex] + TRUE diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h b/Redf= ishClientPkg/Include/Protocol/EdkIIRedfishFeature.h new file mode 100644 index 0000000000..036622128d --- /dev/null +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h @@ -0,0 +1,116 @@ +/** @file + This file defines the EDKII_REDFISH_FEATURE_PROTOCOL interface. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_FEATURE_H_ +#define EDKII_REDFISH_FEATURE_H_ + +typedef struct _EDKII_REDFISH_FEATURE_PROTOCOL EDKII_REDFISH_FEATURE_PROTO= COL; + +#define EDKII_REDFISH_FEATURE_PROTOCOL_GUID \ + { \ + 0x785CC694, 0x4930, 0xEFBF, { 0x2A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0x= AA, 0x34 } \ + } + +typedef enum { + CallbackActionNone =3D 0, ///< Invalid action + CallbackActionStartOperation, ///< Start the operations on Redfish resou= rce + CallbackActionMax +} FEATURE_CALLBACK_ACTION; + +typedef enum { + InformationTypeNone =3D 0, ///< Invalid information. + InformationTypeCollectionMemberUri, ///< URI to the new created collecti= on member. + InformationTypeMax +} FEATURE_RETURNED_INFORMATION_TYPE; + +typedef struct { + FEATURE_RETURNED_INFORMATION_TYPE Type; +} FEATURE_RETURNED_INFORMATION; + +/** + The callback function provided by Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROT= OCOL instance. + @param[in] FeatureAction The action Redfish feature driver sho= uld take. + @param[in] Context The context of Redfish feature driver. + @param[in,out] InformationReturned The pointer to retrive the pointer to + FEATURE_RETURNED_INFOMATION. The memo= ry block of this + information should be freed by caller. + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *REDFISH_FEATURE_CALLBACK) ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN FEATURE_CALLBACK_ACTION FeatureAction, + IN VOID *Context, + IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned +); +/** + The registration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + @param[in] Callback Callback routine associated with this r= egistration that + provided by Redfish feature driver to e= xecute the action + on Redfish resource which is managed by= this Redfish + feature driver. + @param[in] Context The context of the registering feature = driver. The pointer + to the conext is delivered through call= back function. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *REDFISH_FEATURE_REGISTER) ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN REDFISH_FEATURE_CALLBACK Callback, + IN VOID *Context +); + +/** + The unregistration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + @param[in] Context The context used for the previous featu= re driver + registration. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *REDFISH_FEATURE_UNREGISTER) ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN VOID *Context +); + +struct _EDKII_REDFISH_FEATURE_PROTOCOL { + REDFISH_FEATURE_REGISTER Register; + REDFISH_FEATURE_UNREGISTER Unregister; +}; + +extern EFI_GUID gEdkIIRedfishFeatureProtocolGuid; + +#endif diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h new file mode 100644 index 0000000000..7b1778b038 --- /dev/null +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h @@ -0,0 +1,43 @@ +/** @file + Definitions of RedfishFeatureCoreDxe + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#ifndef EDKII_REDFISH_FEATURE_CORE_DXE_H_ +#define EDKII_REDFISH_FEATURE_CORE_DXE_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#define MaxNodeNameLength 64 +#define NodeSeperator L'/' +#define NodeIsCollectionLeftBracket '{' +#define NodeIsCollectionRightBracket '}' + +typedef struct _REDFISH_FEATURE_INTERNAL_DATA REDFISH_FEATURE_INTERNAL_DAT= A; +struct _REDFISH_FEATURE_INTERNAL_DATA { + REDFISH_FEATURE_INTERNAL_DATA *SiblingList; ///< Next same level in hier= archy of resource URI. + REDFISH_FEATURE_INTERNAL_DATA *ChildList; ///< Next level in hierarchy= of resource URI. + EFI_STRING NodeName; ///< Name of the node in hierarchy= of resource URI. + REDFISH_FEATURE_CALLBACK Callback; ///< Callback function of Redfish = feature driver. + VOID *Context; ///< Context of feature driver. + FEATURE_RETURNED_INFORMATION *ReturnedInformation; ///< Information retu= rned from Redfish feature driver. + UINT32 Flags; +}; +#define REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTION 0x00000001 + +typedef struct { + EDKII_REDFISH_FEATURE_PROTOCOL *This; + FEATURE_CALLBACK_ACTION Action; +} REDFISH_FEATURE_STARTUP_CONTEXT; +#endif diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c new file mode 100644 index 0000000000..e5dcc3de8e --- /dev/null +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c @@ -0,0 +1,382 @@ +/** @file + RedfishFeatureCoreDxe produces EdkIIRedfishFeatureCoreProtocol + for EDK2 Redfish Feature driver registration. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +EFI_EVENT mEdkIIRedfishFeatureDriverStartupEvent; +REDFISH_FEATURE_STARTUP_CONTEXT mFeatureDriverStartupContext; +REDFISH_FEATURE_INTERNAL_DATA *ResourceUriNodeList; + +/** + Startup child feature drivers and it's sibing feature drivers. + + @param[in] HeadList Head list of this feature driver + @param[in] ThisFeatureDriverList This feature driver list. + @param[in] StartupContext Start up information + +**/ +VOID +StartUpFeatureDriver ( + IN REDFISH_FEATURE_INTERNAL_DATA *ThisFeatureDriverList, + IN REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext +) +{ + EFI_STATUS Status; + REDFISH_FEATURE_INTERNAL_DATA *ThisList; + + ThisList =3D ThisFeatureDriverList; + while (TRUE) { + if (ThisList->Callback !=3D NULL) { + Status =3D ThisList->Callback( + StartupContext->This, + StartupContext->Action, + ThisList->Context, + &ThisList->ReturnedInformation + ); + if (EFI_ERROR (Status)) { + DEBUG((DEBUG_ERROR, "%a: Callback to EDK2 Redfish feature driver f= ail.", __FUNCTION__)); + } + } + if (ThisList->ChildList !=3D NULL) { + StartUpFeatureDriver (ThisList->ChildList, StartupContext); + } + // + // Check sibling Redfish feature driver. + // + if (ThisList->SiblingList =3D=3D NULL) { + break; + } + // + // Go next sibling Redfish feature driver. + // + ThisList =3D ThisList->SiblingList; + }; +} + +/** + Callback routine when mEdkIIRedfishFeatureDriverStartupEvent + is signaled. + + @param[in] Event Event whose notification function is b= eing invoked. + @param[in] Context The pointer to the notification functi= on's context, + which is implementation-dependent. + +**/ +VOID +RedfishFeatureDriverStartup( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext; + + StartupContext =3D (REDFISH_FEATURE_STARTUP_CONTEXT *)Context; + // + // Invoke EDK2 Redfish feature driver callback to start up + // the Redfish operations. + // + if (ResourceUriNodeList =3D=3D NULL) { + return; + } + // + // Invoke the callback by the hierarchy level + // + StartUpFeatureDriver (ResourceUriNodeList, StartupContext); +} + +/** + Create new internal data instance. + + @param[in,out] PtrToNewInternalData Pointer to receive new instance of + REDFISH_FEATURE_INTERNAL_DATA. + @param[in] NodeName Name of URI node. + + @retval EFI_SUCCESS New entry is inserted successfully. + @retval EFI_INVALID_PARAMETER Improper given parameters. + @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure. + +**/ +EFI_STATUS +NewInternalInstance ( + IN OUT REDFISH_FEATURE_INTERNAL_DATA **PtrToNewInternalData, + IN EFI_STRING NodeName + ) +{ + REDFISH_FEATURE_INTERNAL_DATA *NewInternalData; + + if (PtrToNewInternalData =3D=3D NULL || NodeName =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: Inproper given parameters\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + *PtrToNewInternalData =3D NULL; + NewInternalData =3D AllocateZeroPool (sizeof (REDFISH_FEATURE_INTERNAL_D= ATA)); + if (NewInternalData =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: No memory for REDFISH_FEATURE_INTERNAL_DATA\n= ", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + NewInternalData->NodeName =3D AllocateZeroPool (StrSize (NodeName)); + StrnCpyS (NewInternalData->NodeName, StrSize (NodeName), (CONST CHAR16 *= )NodeName, StrLen (NodeName)); + NewInternalData->SiblingList =3D NULL; + NewInternalData->ChildList =3D NULL; + if (NodeName[0] =3D=3D (UINT16)NodeIsCollectionLeftBracket && + NodeName [StrLen (NodeName) - 1] =3D=3D (UINT16)NodeIsCollectionRigh= tBracket) { + NewInternalData->Flags |=3D REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTIO= N; + } + *PtrToNewInternalData =3D NewInternalData; + return EFI_SUCCESS; +} + +/** + Insert the URI node into internal data structure + + @param[in] HeadEntryToInsert The head entry to start the searching. + @param[in] NodeName Name of URI node. + @param[in] NextNodeEntry Pointer to receive the pointer of next h= ead + entry for inserting the follow up nodes. + The returned LIST_ENTRY is the address of + ChildList link list. + @retval EFI_SUCCESS New entry is inserted successfully. + @retval EFI_INVALID_PARAMETER Improper given parameters. + @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure. + +**/ +EFI_STATUS +InsertRedfishFeatureUriNode ( + IN REDFISH_FEATURE_INTERNAL_DATA *HeadEntryToInsert, + IN EFI_STRING NodeName, + IN OUT REDFISH_FEATURE_INTERNAL_DATA **NextNodeEntry + ) +{ + EFI_STATUS Status; + REDFISH_FEATURE_INTERNAL_DATA *NewInternalData; + REDFISH_FEATURE_INTERNAL_DATA *ThisInternalData; + REDFISH_FEATURE_INTERNAL_DATA *SiblingList; + + if (NodeName =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: Node name is NULL.\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + if (NextNodeEntry =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: NextNodeEntry can't be NULL.\n", __FUNCTION__= )); + return EFI_INVALID_PARAMETER; + } + + if (HeadEntryToInsert =3D=3D NULL || HeadEntryToInsert->ChildList =3D=3D= NULL) { + Status =3D NewInternalInstance (&NewInternalData, NodeName); + if (EFI_ERROR (Status)) { + return Status; + } + if (HeadEntryToInsert =3D=3D NULL) { + ResourceUriNodeList =3D NewInternalData; + } else { + HeadEntryToInsert->ChildList =3D NewInternalData; + } + *NextNodeEntry =3D NewInternalData; + return EFI_SUCCESS; + } + // + // Go through sibling list to find the entry. + // + ThisInternalData =3D HeadEntryToInsert; + SiblingList =3D ThisInternalData->SiblingList; + while (TRUE) { + if (StrCmp((CONST CHAR16 *)ThisInternalData->NodeName, (CONST CHAR16 *= )NodeName) =3D=3D 0) { + *NextNodeEntry =3D ThisInternalData->ChildList; + return EFI_SUCCESS; + } + // + // If sibing exist? + // + if (SiblingList =3D=3D NULL) { + Status =3D NewInternalInstance (&NewInternalData, NodeName); + if (EFI_ERROR (Status)) { + return Status; + } + ThisInternalData->SiblingList =3D NewInternalData; + *NextNodeEntry =3D NewInternalData->ChildList; + return EFI_SUCCESS; + } + SiblingList =3D SiblingList->SiblingList; + }; + return EFI_SUCCESS; +} + +/** + The registration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + e.g. "ServiceRoot/" - Managed by Servic= eRoot feature driver + "ServiceRoot/Systems[]/" - Managed= by ComputerSystemCollection feature driver + "ServiceRoot/Systems[1]/" - Manage= d by ComputerSystem feature driver + "ServiceRoot/Systems[2]/Bios/" - M= anaged by Bios feature driver + @param[in] Callback Callback routine associated with this r= egistration that + provided by Redfish feature driver to e= xecute the action + on Redfish resource which is managed by= this Redfish + feature driver. + @param[in] Context The context of the registering feature = driver. The pointer + to the conext is delivered through call= back function. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval EFI_INVALID_PARAMETER Improper given parameters or fail to re= gister + feature driver. + @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure. + @retval Others Some error happened. + +**/ +EFI_STATUS +EFIAPI +RedfishFeatureRegister ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN REDFISH_FEATURE_CALLBACK Callback, + IN VOID *Context +) +{ + CHAR16 NodeName [MaxNodeNameLength]; + EFI_STATUS Status; + UINTN Index; + UINTN AnchorIndex; + UINTN UriLength; + REDFISH_FEATURE_INTERNAL_DATA *ThisUriNode; + + if (FeatureManagedUri =3D=3D NULL || Callback =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: The given parameter is invalid\n", __FUNCTION= __)); + return EFI_INVALID_PARAMETER; + } + // + // Walk through URI which managed by this EDK2 Redfish feature driver. + // + UriLength =3D StrLen (FeatureManagedUri) + 1; // Add one NULL for the la= st node. + Index =3D 0; + AnchorIndex =3D 0; + ThisUriNode =3D ResourceUriNodeList; + do { + if ((Index - AnchorIndex + 1) >=3D MaxNodeNameLength) { // Increase on= e for the NULL terminator + DEBUG((DEBUG_ERROR, "%a: the length of node name is >=3D MaxNodeName= Length\n", __FUNCTION__)); + ASSERT (FALSE); + } + NodeName[Index - AnchorIndex] =3D *(FeatureManagedUri + Index); + if (NodeName [Index - AnchorIndex] =3D=3D NodeSeperator || NodeName [I= ndex - AnchorIndex] =3D=3D (CHAR16)0) { + NodeName [Index - AnchorIndex] =3D 0; + AnchorIndex =3D Index + 1; + // + // Insert node + // + if (StrLen(NodeName) !=3D 0) { + Status =3D InsertRedfishFeatureUriNode(ThisUriNode, NodeName, &Thi= sUriNode); + if (EFI_ERROR (Status)) { + return Status; + } + } + } + Index ++; + } while ((Index < UriLength)); + + if (ThisUriNode =3D=3D NULL) { + // + // No URI node was created + // + DEBUG((DEBUG_ERROR, "%a: No URI node is added\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + // + // Add feature driver info to internal data instance. + // + ThisUriNode->Callback =3D Callback; + ThisUriNode->Context =3D Context; + return EFI_SUCCESS; +} + +/** + The unregistration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + @param[in] Context The context used for the previous featu= re driver + registration. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +RedfishFeatureUnregister ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN VOID *Context +) +{ + return EFI_UNSUPPORTED; +} + +EDKII_REDFISH_FEATURE_PROTOCOL mRedfishFeatureProtocol =3D { + RedfishFeatureRegister, + RedfishFeatureUnregister +}; + +/** + Main entry for this driver. + + @param ImageHandle Image handle this driver. + @param SystemTable Pointer to SystemTable. + + @retval EFI_SUCESS This function always complete successfully. + +**/ +EFI_STATUS +EFIAPI +RedfishFeatureCoreEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + EFI_GUID *EventGuid; + + Handle =3D NULL; + ResourceUriNodeList =3D NULL; + EventGuid =3D (EFI_GUID *)PcdGetPtr (PcdEdkIIRedfishFeatureDriverStartup= EventGuid); + + ZeroMem ((VOID *)&mFeatureDriverStartupContext, sizeof (REDFISH_FEATURE_= STARTUP_CONTEXT)); + mFeatureDriverStartupContext.This =3D &mRedfishFeatureProtocol; + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + RedfishFeatureDriverStartup, + (CONST VOID *)&mFeatureDriverStartupContext, + EventGuid, + &mEdkIIRedfishFeatureDriverStartupEvent + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Install the RedfishCredentialProtocol onto Handle. + // + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gEdkIIRedfishFeatureProtocolGuid, + &mRedfishFeatureProtocol, + NULL + ); + return Status; +} diff --git a/RedfishClientPkg/Readme.md b/RedfishClientPkg/Readme.md index 9e56fb9039..18a27633cf 100644 --- a/RedfishClientPkg/Readme.md +++ b/RedfishClientPkg/Readme.md @@ -119,6 +119,42 @@ struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL { For those Non-EDK2 HII-based platform configuration formats, the driver in= stance can provide its own implementation to get or set the platform configuratio= ns. =20 +### EDKII Redfish Feature Core DXE Driver ***[[12]](#[0])*** +EDKII Redfish Feature Core DXE driver provides the protocol interface to +the auto-generated Redfish feature driver to register itself for the +Redfish resource URI it manages. + +```C +struct _EDKII_REDFISH_FEATURE_PROTOCOL { + REDFISH_FEATURE_REGISTER Register; + REDFISH_FEATURE_UNREGISTER Unregister; +}; +``` + +Redfish Feature Core DXE driver records the +URI according to the URI hierarchy, and then it starts up the Redfish +feature drivers based on the hierarchy when the particular event +***[[11]](#[0])*** is triggered. This makes sure the upper-level Redfish +resource is built up before the lower-level resource. For example, +ComputerSystem resource must be ready before the Memory resource managed +by MemoryCollection because the Memory resource is part of ComputerSystem +resource. + +### Start-Up Event to Trigger EDKII Redfish Feature Core ***[[11]](#[0])*** +This is an EFI event for triggering EDKII Redfish Feature Core to travel +URIs in the database and execute the callback that registered by Redfish f= eature +drivers. The event GUID is defined in below PCD and is default set to +**gEfiEventReadyToBootGuid**. + +```C +PcdEdkIIRedfishFeatureDriverStartupEventGuid +``` + +This PCD can be overridden to any events based on the platform +implementation. EDKII Redfish Feature Core can be triggered earlier, +for example before the BDS or in the early DXE phase if the platform provi= des +the EFI REST EX protocol which is available before the BDS phase. + ### EDK2 HII VFR Form ***[[8]](#[0])*** According to **UEFI spec 2.9 section 35.6 Form Browser Protocol**, **EFI_HII_REST_STYLE_FORMSET_GUID** is used on HII form to indicate that H= II --=20 2.17.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 (#78229): https://edk2.groups.io/g/devel/message/78229 Mute This Topic: https://groups.io/mt/84484823/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-