From nobody Wed May 15 05:35:36 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+106004+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+106004+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686558554364776.7005985268619; Mon, 12 Jun 2023 01:29:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id x2jSYY1788612x7GAomxQ0CC; Mon, 12 Jun 2023 01:29:13 -0700 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web10.54086.1686558553183663350 for ; Mon, 12 Jun 2023 01:29:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PoCnXPB0m6sMFZansmfHwAIT9sIatCYOyfzM/F3NFZBUequSnzeNl18/ElKOTJaIy7LAbVvMyLpTviD32pTxB7NVeXYucE/1XeE3tZM6b4eMo8DGd0yEBYt2deI63nIY6/A4jC5/pohKH7m8ej86y9HcOpP1PnAbjKtEhsIcWLIcqA0Ux1cQV2aWHO9sLE30AWNJSjVyX72pXWtUPfGCk24XT9Xty8yJiI5XUSSF9X4KI4Lt4irWHudGozYslvjcaLSIL/N6aK+BaFbEJon7KYkeBastKWqy4wQ/2SzTThebNGz55jVtgfqCHyUt85mao3LOQW2XAux8ynvtrAKwXg== 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=OVhU9mB/WbR8lKVhgABwBaQjZjoZ4Tzh//e//8SPUmw=; b=h7J/oTYCCTVindPPN8yovK30cHojIpad2uTllnHKKGz2+z76GSpajSB3Y8uMROC0YWva1cH8EstIgvik+J+5DiLiFlvE5R5gPavAxWs72KLPUgMKc2K8H+rgvpwqq4718J/PRfs0aSdTeX8pi2tpOXz/g0zvwCOOFgSsfT9YTBh1NA+4hDF8ma5VmyeX4siUUitnwoyTNEOMR7Mlz5b+Bx1zPcIFFr8UB+NnCp+hFLedfzlqZ9Yoob1bHYEZB+MHC7e0307ZRnIy5wj3r3SWXwMKwXCvsRTRDVSDMkrOg38TZyhCkoYGxitcBl/nKs6xJRzcW9BPZyTN0xtCltVmlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from PH0PR10MB5403.namprd10.prod.outlook.com (2603:10b6:510:e3::17) by CH3PR10MB7833.namprd10.prod.outlook.com (2603:10b6:610:1ad::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Mon, 12 Jun 2023 08:29:08 +0000 X-Received: from PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::720f:ab76:4f7d:a185]) by PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::720f:ab76:4f7d:a185%5]) with mapi id 15.20.6455.030; Mon, 12 Jun 2023 08:29:08 +0000 From: "Arun K via groups.io" To: "devel@edk2.groups.io" , Arun K CC: "isaac.w.oram@intel.com" , "nathaniel.l.desimone@intel.com" , Ramkumar Krishnamoorthi , Liming Gao Subject: [edk2-devel][edk2-platforms][PATCH V2-2] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Topic: [edk2-devel][edk2-platforms][PATCH V2-2] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Index: AQHZnQf1r17tLLO8y0SIiOJNJJ/5xw== Date: Mon, 12 Jun 2023 08:29:08 +0000 Message-ID: <530105e97dd9ccec7a0bd9ed4522ba8c26dbb31f.1686552898.git.arunk@ami.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR10MB5403:EE_|CH3PR10MB7833:EE_ x-ms-office365-filtering-correlation-id: 840eb4a4-3abd-4c3c-b305-08db6b1f1787 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: F6Z1lLquA6Vac4UZVU4+u+8lW77++tMnPrhrmtYtetEEpjjxEpX5JhD5WPzTNi+2PR4DhMSFczLyCFBTRJ0i/xQ9EeX1hTnsQZCwulS3ooumCpFhTE8L6KS/vOVBsExfF509YPDRb1XufS7prRqLf1ii7Z/Z392fsk9RX1ykNJ3chMsWIXPLK4rymLJ6Q8nag3r0H+g92Ju0EG+etikGGKGrVLDZZA7PC7t70IdLLaGsrLgH5QRTcaFxuD6drFcAVdIwf6BokU2PlQuETRzwGEesoUrSCz6dd3zKZDahsijzpMJBSyudxqaStTaBhiVl3VJVfmFcCyVuGUfxDrmc/pykrUxeZJ5ESeBitTbDT7J6s9fJu4foc+x6nEXDaoGWluYzarhMOam39r/b3YDyH6hcIbh9E28bCqrU/lXEhqD5mvvdLlVc4M+6632ibCnf05EbsJB3uhG5zFrpdTctYUtctmhtmbNvEK75SvkQkLIdlcLfT+gyC/l8J5ZLBpj4vwgeyke3euPi3XMxguqygAmnc/QNgO/QwUmEV3C+aaigYIAr3tIbaIfywPo2FM0L7MBL+wCtI5RfWorkHhago1RlS655uauUu3PIdHXLcG7YtpcsVm3+ytLv66ECHTQE x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?UfKxdsHLQD63nrbDsmJN24faC8RWV9Gaemw6JkMrLUCvtmkcOKkVDUBne8?= =?iso-8859-1?Q?/AmZXTHGplwdFSmWqT7/6s1ptlH78AVC6sbAFl6Pj4/nRKBvQoLSQUrjDM?= =?iso-8859-1?Q?enxQUFo6AGXMLLcu4aX9UeGG2MREfByjKKMVYhuXHWqEpUaDmkBKrQ6LXB?= =?iso-8859-1?Q?CzrFygHbyY2Q56yLpL+U699HG0/qMCQke8DOk2KhM4nFQ9+zpL7pSjbZQl?= =?iso-8859-1?Q?G5kaZIq3zpsXVVIiPBfrLTwkqq9P/0dORVLNG36qalwSAUT3dLW3QgjKAi?= =?iso-8859-1?Q?ea+2CBfwlWSJTd4OlGcV3Nmi/V20BXcxusf5LRR2PVgHrhXZObLDg2Rsn6?= =?iso-8859-1?Q?8HUl1hjOfQVRGjZumekFQxudCiGO+sqDlIW+PBBLfOqkv5EIYKKMSM+PKH?= =?iso-8859-1?Q?hozSjzMzF6pYI1nwn3HuWzO39N/DzcByM8kq59eHAo4IFSCorJiIjKj9MB?= =?iso-8859-1?Q?AiqRTi7OqxeoeZ3C3s/pdin7bfs22DAuQUNg0ny+WYe6OY86ps1/TTx7uE?= =?iso-8859-1?Q?D0Yl5C5j48Ij+pq0okdb9gtRcxk8nzCgHi9WdUYpPDmno9gxCx2mND66oP?= =?iso-8859-1?Q?0qdDFOjebclni8/e7FSGgWV7wXtS1+xpyJ3o3+wGKGB1QzCZJG00Wbg2Ob?= =?iso-8859-1?Q?IE67rTttJn6C/NqBOGdtYmbnLTiU5Ld6/Ab7PGY3tnEiE4tq2HUwjk4EIs?= =?iso-8859-1?Q?cuSQSRsq5SgVkt7+ZiM9gWo946LhHSR27pf+XcALqCZf13LevrTe8s6kdW?= =?iso-8859-1?Q?mFKSXVsI2RB7MIgU2+SP9pgl4x4hnBmapHyFY8wrMSBD1jmP62bYgJLjph?= =?iso-8859-1?Q?CZpgCBeI9Xte8wOg35+e6VrzIO0EjSyWol+I9YyJf+7uyPpq0gFlBfDut/?= =?iso-8859-1?Q?fM2u6HKeWW68rQg/kOiqCfFkKtXoYAdhuJG1V400FGQ/vQrrqo6k0wGUSP?= =?iso-8859-1?Q?K8ZDpNmxW3HvDSiVg+ayTB8PHA4apWLtiVyBWroHTR6QYkEKH1bdS9CnM+?= =?iso-8859-1?Q?ncEHS6jzd+LNDpzPX+Uzb/YvibYM9f2L7cEMQK8DLnEUXeyxKkJXuu4ArM?= =?iso-8859-1?Q?wYD4HbuKMVFasW2dnxwo1CZ3a3BubGxzjj9/wmWg7hj8ZMzRlAQbGDQFOw?= =?iso-8859-1?Q?G5sz9OhC2vWdrJhraNny5OzxkBdIx7a4lOhoNWvSayfVmwx/ddaseqX3zY?= =?iso-8859-1?Q?arNxmaTQnoppOs8Sc7fRv+0bwFMtJVE4WlC/vemuhnwloDKtE7adwgu+nK?= =?iso-8859-1?Q?xEXocCHnIwiLRIYLrHpwzTfHi1m5965VRnB2KGvl807xXCyhRIfuwFrkky?= =?iso-8859-1?Q?1I98dfpW3M2YVAxFzcMHsf8Wm0CLiMkZ64TRlqXKMzSWkmp30VkZU9akCP?= =?iso-8859-1?Q?nMZo+038fskkPC1tRwDN2dn4agoZOaLU0dMQW5joxG4mNB29PsJ7FjM6UU?= =?iso-8859-1?Q?nSx00MLqVD3MJ4ATRuc26Ldj02TRFpWS4GCm3MdxqG4KOR7/+a7UN4PVq9?= =?iso-8859-1?Q?VF83HAdNTBnazoKO3nmC/I9D5TF+zs/QvXftkytBemqTu0LGNXoyM6iGKJ?= =?iso-8859-1?Q?GHvhN2kc+26sVizBKGIV0y7s/uzCIHH8+3pUNZsFDhZiPkp8QDEi4TX4Q7?= =?iso-8859-1?Q?pdN3Za3jZQPT9BiZ0Hvp9/8gvIXjqz0IfW?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5403.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 840eb4a4-3abd-4c3c-b305-08db6b1f1787 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2023 08:29:08.5594 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W6rV3dJpWRRiKLsXnR7twh0dnQrjRnuJFrd6k3QTblTQjWYa9Y1AjQH3+Mf/yW0t X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7833 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,arunk@ami.com X-Gm-Message-State: svUQOYlABOQqxRJD4Cc4XY3Lx1787277AA= Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1686558553; bh=0hzB5TH0stTWeGp29/lzNtExkOGfmWHT5weZr6vSHIs=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=S9oMNVUXy2jSsEsVfuDYg/VURa/kVXRBgtZSL1xTm+tU0n4AV4Vs5SnjEpKI+oE2a4c QJUhmbzVxIiJpf0GYR7UJDs007NsHREziwhQLZ9eFUOeuZD2FMnXBm3Wl8Z7Ll/ScnGLK M036y3q6hWxpG+SrbmRqvEi/7K46PtDLzxU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686558556262100003 Content-Type: text/plain; charset="utf-8" Created IpmiTransport2 PPI/Protocol to support multiple IPMI BMC Interface support such as KCS/BT/SSIF with 2 API's IpmiSubmitCommand2 & IpmiSubmitCommand2Ex. IpmiSubmitCommand2 - This API use the default interface (PcdDefaultSystemInterface) to send IPMI command. IpmiSubmitCommand2Ex - This API use the specific interface type to send IPMI command which is passed as an argument. Cc: Isaac Oram Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Arun K --- .../GenericIpmi/Pei/PeiGenericIpmi.c | 295 ++++++++++++++---- .../GenericIpmi/Pei/PeiGenericIpmi.h | 3 + .../GenericIpmi/Pei/PeiGenericIpmi.inf | 16 + .../GenericIpmi/Pei/PeiIpmiBmc.c | 3 +- .../GenericIpmi/Pei/PeiIpmiBmc.h | 9 + .../GenericIpmi/Pei/PeiIpmiBmcDef.h | 11 + .../IpmiFeaturePkg/Include/IpmiFeature.dsc | 15 + 7 files changed, 285 insertions(+), 67 deletions(-) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Ge= nericIpmi/Pei/PeiGenericIpmi.c index e8b99b6900..e0378d61d4 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= GenericIpmi.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= GenericIpmi.c @@ -3,6 +3,7 @@ @copyright Copyright 2017 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -10,10 +11,143 @@ #include "PeiGenericIpmi.h" #include #include +#include //////////////////////////////////////////////////////////////////////////= ///// -// Function Implementations -// + +/** + Initialize the API and parameters for IPMI Transport2 Instance + + @param[in] IpmiInstance Pointer to IPMI Instance + + @return VOID + +**/ +VOID +InitIpmiTransport2 ( + IN PEI_IPMI_BMC_INSTANCE_DATA *IpmiInstance + ) +{ + IpmiInstance->IpmiTransport2Ppi.InterfaceType =3D FixedPcdGet8= (PcdDefaultSystemInterface); + IpmiInstance->IpmiTransport2Ppi.IpmiTransport2BmcStatus =3D BmcStatusOk; + IpmiInstance->IpmiTransport2Ppi.IpmiSubmitCommand2 =3D PeiIpmiSendC= ommand2; + IpmiInstance->IpmiTransport2Ppi.IpmiSubmitCommand2Ex =3D PeiIpmiSendC= ommand2Ex; + +#if BtInterfaceSupport + if (!EFI_ERROR (PlatformIpmiIoRangeSet(FixedPcdGet16(PcdBtControlPort)))= ) { + InitBtInterfaceData (&IpmiInstance->IpmiTransport2Ppi); + } +#endif + +#if SsifInterfaceSupport + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2Ppi); +#endif + +#if IpmbInterfaceSupport + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2Ppi); +#endif +} + +/** + Notify callback function for interfaces. + + @param[in] PeiServices Describes the list of possible PEI + Services. + @param[in] NotifyDescriptor Pointer to notify descriptor. + @param[in] Ppi Pointer to Ppi. + + @return EFI_STATUS Status of Notify call back. + @retval EFI_NOT_FOUND Ipmi hob is not found. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. + @retval EFI_SUCCESS Interface is initialized and installed + Ipmi Ppi successfully. + @retval Others Error status while installing Ppi. +**/ +EFI_STATUS +EFIAPI +NotifyCallback ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) +{ + EFI_STATUS Status; + PEI_IPMI_BMC_INSTANCE_DATA *IpmiInstance; + PEI_IPMI_DATA_HOB *IpmiInstancePtrHob; + EFI_HOB_GUID_TYPE *GuidHob; + IPMI_INTERFACE_STATE InterfaceState; + + InterfaceState =3D IpmiInterfaceNotReady; + + GuidHob =3D GetFirstGuidHob (&gPeiIpmiHobGuid); + ASSERT (GuidHob !=3D NULL); + if (GuidHob =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + IpmiInstancePtrHob =3D (PEI_IPMI_DATA_HOB *) GET_GUID_HOB_DATA(GuidHob); + IpmiInstance =3D (PEI_IPMI_BMC_INSTANCE_DATA*) IpmiInstancePtrHob-= >IpmiInstance; + +#if SsifInterfaceSupport + InitSsifInterfaceData(&IpmiInstance->IpmiTransport2Ppi); + + if (IpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState =3D=3D= IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } +#endif + +#if IpmbInterfaceSupport + InitIpmbInterfaceData(&IpmiInstance->IpmiTransport2Ppi); + + if (IpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState =3D=3D= IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } +#endif + // Default Interface data should be initialized to install Ipmi Transpor= t2 Protocol. + if (InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_UNSUPPORTED; + } + + Status =3D PeiServicesInstallPpi (&IpmiInstance->PeiIpmi2BmcDataDesc); + return Status; +} + +/** + Registers callback for Ppi. + + @param[in] PeiServices Describes the list of possible PEI Services. + @param[in] PpiGuid Pointer to Ppi guid to register call back. + + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. + @retval Others Status of NotifyPpi(). +**/ +EFI_STATUS +RegisterPpiCallback ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_GUID *PpiGuid + ) +{ + EFI_STATUS Status; + EFI_PEI_NOTIFY_DESCRIPTOR *PpiNotifyDesc; + + if ((PpiGuid =3D=3D NULL) || + ((PpiGuid !=3D NULL) && IsZeroBuffer(PpiGuid, sizeof (EFI_GUID)))) { + return EFI_INVALID_PARAMETER; + } + + PpiNotifyDesc =3D (EFI_PEI_NOTIFY_DESCRIPTOR*) AllocateZeroPool (sizeof = (EFI_PEI_NOTIFY_DESCRIPTOR)); + if (PpiNotifyDesc =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + PpiNotifyDesc->Flags =3D EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_P= EI_PPI_DESCRIPTOR_TERMINATE_LIST; + PpiNotifyDesc->Guid =3D PpiGuid; + PpiNotifyDesc->Notify =3D NotifyCallback; + + Status =3D (*PeiServices)->NotifyPpi (PeiServices, PpiNotifyDesc); + return Status; +} /*************************************************************************= **** @brief @@ -31,8 +165,12 @@ PeiInitializeIpmiKcsPhysicalLayer ( { EFI_STATUS Status; PEI_IPMI_BMC_INSTANCE_DATA *mIpmiInstance; + PEI_IPMI_DATA_HOB *IpmiInstancePtrHob; + IPMI_INTERFACE_STATE InterfaceState; + UINT8 Index; - mIpmiInstance =3D NULL; + mIpmiInstance =3D NULL; + InterfaceState =3D IpmiInterfaceNotReady; // // Send Pre-Boot signal to BMC @@ -60,6 +198,18 @@ PeiInitializeIpmiKcsPhysicalLayer ( return EFI_OUT_OF_RESOURCES; } + + // Create Guided hob to pass IPMI Instance data pointer to notify functi= ons. + IpmiInstancePtrHob =3D BuildGuidHob (&gPeiIpmiHobGuid, sizeof(PEI_IPMI_D= ATA_HOB)); + if (IpmiInstancePtrHob =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to create Hob guid for IPMI Instance!!!= \n")); + FreePool (mIpmiInstance); + return EFI_OUT_OF_RESOURCES; + } + + IpmiInstancePtrHob->IpmiInstance =3D (UINTN)mIpmiInstance; + IpmiInstancePtrHob->PreMemIpmiDataHobPtr =3D IpmiInstancePtrHob; + // // Calibrate TSC Counter. Stall for 10ms, then multiply the resulting n= umber of // ticks in that period by 100 to get the number of ticks in a 1 second = timeout @@ -83,6 +233,7 @@ PeiInitializeIpmiKcsPhysicalLayer ( mIpmiInstance->PeiIpmiBmcDataDesc.Guid =3D &gPeiIpmiTransportPp= iGuid; mIpmiInstance->PeiIpmiBmcDataDesc.Ppi =3D &mIpmiInstance->Ipmi= TransportPpi; +#if KcsInterfaceSupport // // Get the Device ID and check if the system is in Force Update mode. // @@ -94,19 +245,85 @@ PeiInitializeIpmiKcsPhysicalLayer ( // // Do not continue initialization if the BMC is in Force Update Mode. // - if (mIpmiInstance->BmcStatus =3D=3D BMC_UPDATE_IN_PROGRESS || mIpmiInsta= nce->BmcStatus =3D=3D BMC_HARDFAIL) { - return EFI_UNSUPPORTED; + if (mIpmiInstance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS && mIpmiInstanc= e->BmcStatus !=3D BMC_HARDFAIL) { + Status =3D PeiServicesInstallPpi (&mIpmiInstance->PeiIpmiBmcDataDesc= ); + if (EFI_ERROR (Status)) { + return Status; + } + } +#endif + + InitIpmiTransport2(mIpmiInstance); + + // Check interface data initialized successfully else register notify pr= otocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + + switch (Index) { + +#if KcsInterfaceSupport + case SysInterfaceKcs: + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiIn= stance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; + mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceS= tate =3D IpmiInterfaceInitialized; + Status =3D CheckSelfTestByInterfaceType( + &mIpmiInstance->IpmiTransport2Pp= i, + &BmcStatus, + SysInterfaceKcs); + if (!EFI_ERROR (Status) && (BmcStatus !=3D BmcStatusHard= Fail)) { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterf= aceState =3D IpmiInterfaceInitError; + } + } + break; +#endif + +#if BtInterfaceSupport + case SysInterfaceBt: + if (mIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceS= tate =3D=3D IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } + break; +#endif + +#if SsifInterfaceSupport + case SysInterfaceSsif: + if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.Interfac= eState =3D=3D IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.I= nterfaceState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D RegisterPpiCallback (PeiServices, &mIpmiInsta= nce->IpmiTransport2Ppi.Interface.Ssif.SsifInterfaceApiGuid); + } + break; +#endif + +#if IpmbInterfaceSupport + case SysInterfaceIpmb: + if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.Interfac= eState =3D=3D IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.I= nterfaceState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D RegisterPpiCallback (PeiServices, &mIpmiInsta= nce->IpmiTransport2Ppi.Interface.Ipmb.IpmbInterfaceApiGuid); + } + break; +#endif + default: + break; + } } - // - // Just produce PPI - // - Status =3D PeiServicesInstallPpi (&mIpmiInstance->PeiIpmiBmcDataDesc); - if (EFI_ERROR (Status)) { - return Status; + // Any one of the Interface data should be initialized to install Ipmi T= ransport2 Protocol. + if (InterfaceState !=3D IpmiInterfaceInitialized) { + DEBUG ((DEBUG_INFO, "Interface not ready yet. \n")); + return EFI_SUCCESS; } - return EFI_SUCCESS; + mIpmiInstance->PeiIpmi2BmcDataDesc.Flags =3D EFI_PEI_PPI_DESCRIPTOR_PPI= | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; + mIpmiInstance->PeiIpmi2BmcDataDesc.Guid =3D &gPeiIpmiTransport2PpiGuid; + mIpmiInstance->PeiIpmi2BmcDataDesc.Ppi =3D &mIpmiInstance->IpmiTransp= ort2Ppi; + + Status =3D PeiServicesInstallPpi (&mIpmiInstance->PeiIpmi2BmcDataDesc); + return Status; } /*************************************************************************= **** @@ -176,60 +393,6 @@ PeimIpmiInterfaceInit ( } // PeimIpmiInterfaceInit() -EFI_STATUS -PeiIpmiSendCommand ( - IN PEI_IPMI_TRANSPORT_PPI *This, - IN UINT8 NetFunction, - IN UINT8 Lun, - IN UINT8 Command, - IN UINT8 *CommandData, - IN UINT32 CommandDataSize, - IN OUT UINT8 *ResponseData, - IN OUT UINT32 *ResponseDataSize - ) -/*++ - -Routine Description: - - Send Ipmi Command in the right mode: HECI or KCS, to the - appropiate device, ME or BMC. - -Arguments: - - This - Pointer to IPMI protocol instance - NetFunction - Net Function of command to send - Lun - LUN of command to send - Command - IPMI command to send - CommandData - Pointer to command data buffer, if needed - CommandDataSize - Size of command data buffer - ResponseData - Pointer to response data buffer - ResponseDataSize - Pointer to response data buffer size - -Returns: - - EFI_INVALID_PARAMETER - One of the input values is bad - EFI_DEVICE_ERROR - IPMI command failed - EFI_BUFFER_TOO_SMALL - Response buffer is too small - EFI_UNSUPPORTED - Command is not supported by BMC - EFI_SUCCESS - Command completed successfully - ---*/ -{ - // - // This Will be unchanged ( BMC/KCS style ) - // - return PeiIpmiSendCommandToBmc ( - This, - NetFunction, - Lun, - Command, - CommandData, - (UINT8) CommandDataSize, - ResponseData, - (UINT8 *) ResponseDataSize, - NULL - ); -} // IpmiSendCommand() EFI_STATUS PeiGetIpmiBmcStatus ( diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiGenericIpmi.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Ge= nericIpmi/Pei/PeiGenericIpmi.h index d31af85325..59b26b6c86 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= GenericIpmi.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= GenericIpmi.h @@ -3,6 +3,7 @@ @copyright Copyright 2017 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -23,7 +24,9 @@ #include #include #include +#include +#include "PeiIpmiHooks.h" #include "PeiIpmiBmcDef.h" #include "PeiIpmiBmc.h" diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= GenericIpmi/Pei/PeiGenericIpmi.inf index a646161ce1..555b2e5e6c 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= GenericIpmi.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= GenericIpmi.inf @@ -3,6 +3,7 @@ # # @copyright # Copyright 2017 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -30,6 +31,8 @@ PeiIpmiBmcDef.h PeiGenericIpmi.c PeiGenericIpmi.h + PeiIpmiHooks.c + PeiIpmiHooks.h [Packages] MdePkg/MdePkg.dec @@ -44,17 +47,30 @@ ReportStatusCodeLib TimerLib IpmiPlatformHookLib + HobLib + BmcCommonInterfaceLib + BtInterfaceLib + SsifInterfaceLib + IpmbInterfaceLib [Guids] + gPeiIpmiHobGuid [Ppis] gPeiIpmiTransportPpiGuid #ALWAYS PRODUCE + gPeiIpmiTransport2PpiGuid [Pcd] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer gIpmiFeaturePkgTokenSpaceGuid.PcdSioMailboxBaseAddress gIpmiFeaturePkgTokenSpaceGuid.PcdSignalPreBootToBmc + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort [Depex] TRUE diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiIpmiBmc.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Generi= cIpmi/Pei/PeiIpmiBmc.c index dbe25421ae..38ec98c959 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiBmc.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiBmc.c @@ -3,6 +3,7 @@ @copyright Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -235,7 +236,7 @@ Returns: EFI_STATUS -PeiIpmiBmcStatus ( +IpmiBmcStatus ( IN PEI_IPMI_TRANSPORT_PPI *This, OUT BMC_STATUS *BmcStatus, OUT SM_COM_ADDRESS *ComAddress, diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiIpmiBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Generi= cIpmi/Pei/PeiIpmiBmc.h index 40b9429e84..51ba65966a 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiBmc.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiBmc.h @@ -3,6 +3,7 @@ @copyright Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -35,4 +36,12 @@ SM_IPMI_BMC_SIGNATURE \ ) +#define INSTANCE_FROM_PEI_IPMI_TRANSPORT2_THIS(a) \ + CR ( \ + a, \ + PEI_IPMI_BMC_INSTANCE_DATA, \ + IpmiTransport2Ppi, \ + SM_IPMI_BMC_SIGNATURE \ + ) + #endif // _PEI_IPMI_BMC_H_ diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiIpmiBmcDef.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gen= ericIpmi/Pei/PeiIpmiBmcDef.h index fc9fbacf1a..24ef17eadb 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiBmcDef.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiBmcDef.h @@ -3,6 +3,7 @@ @copyright Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -10,6 +11,8 @@ #define _PEI_IPMI_COMMON_BMC_H_ #include +#include +#include "ServerManagement.h" #define MAX_TEMP_DATA 160 #define BMC_SLAVE_ADDRESS 0x20 @@ -54,7 +57,9 @@ typedef struct { UINT8 SoftErrorCount; UINT16 IpmiIoBase; PEI_IPMI_TRANSPORT_PPI IpmiTransportPpi; + IPMI_TRANSPORT2 IpmiTransport2Ppi; EFI_PEI_PPI_DESCRIPTOR PeiIpmiBmcDataDesc; + EFI_PEI_PPI_DESCRIPTOR PeiIpmi2BmcDataDesc; } PEI_IPMI_BMC_INSTANCE_DATA; // @@ -151,5 +156,11 @@ Returns: --*/ ; +typedef struct _PEI_IPMI_DATA_HOB PEI_IPMI_DATA_HOB; + +struct _PEI_IPMI_DATA_HOB { + UINTN IpmiInstance; /// IpmiInstance po= inter. + PEI_IPMI_DATA_HOB *PreMemIpmiDataHobPtr; ///< HOB Data point= er before Memory discovered +}; #endif //_PEI_IPMI_COMMON_BMC_H_ diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipmi= Feature.dsc b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipm= iFeature.dsc index 237a4fc006..0401974b82 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature= .dsc +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature= .dsc @@ -7,6 +7,7 @@ # for the build infrastructure. # # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -41,10 +42,24 @@ [LibraryClasses.common.PEI_CORE,LibraryClasses.common.PEIM] IpmiBaseLib|IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf + SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/PeiSsifInterfaceLib.inf + IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/PeiIpmbInterfaceLib.inf [LibraryClasses.common.DXE_DRIVER,LibraryClasses.common.UEFI_DRIVER] IpmiBaseLib|IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf +[LibraryClasses.common] + BmcCommonInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Bm= cCommonInterfaceLib.inf + BtInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/BtInterfa= ceLib/BtInterfaceLib.inf + +[LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_DRIVE= R] + SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/DxeSsifInterfaceLib.inf + IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/DxeIpmbInterfaceLib.inf + +[LibraryClasses.common.DXE_SMM_DRIVER] + SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/SmmSsifInterfaceLib.inf + IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/SmmIpmbInterfaceLib.inf + ##########################################################################= ###### # # Component section - list of all components that need built for this feat= ure. -- 2.38.1.windows.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission. -=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 (#106004): https://edk2.groups.io/g/devel/message/106004 Mute This Topic: https://groups.io/mt/99478861/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-