From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.71]) by mx.groups.io with SMTP id smtpd.web10.58094.1686574395094772678 for ; Mon, 12 Jun 2023 05:53:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ami.com header.s=selector1 header.b=ksMYoyEC; spf=pass (domain: ami.com, ip: 40.107.102.71, mailfrom: arunk@ami.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=chrA5lX2/U8OjlgROcYnfZMXljUDK754W1zhysQcLNj09Xon4Y+QMX4mynxTTUqtwW0AJrdyx18o1HX1c9ZnnxYF1zrIh2/EKHJjC2RAmMo9+5F5ZBUtfQJLC6zs/n6jzZkI2oYdLjeSI+VNb5jqaOA4vKOwimpowUXYX+ughc8g63cSFxquQnM7uVm0Xvd+uzIJsBH+WIQEnQVJ8VXMGkhDTSBljZKeDwv64gD4JavcZCoUdP3U8zxAU9LkVhl37CnshhzZv8R/QVInZHz8umgQKNZtqsdsf7Jsjh32oBnfZCnKXG6t9J1kliWVCQPe7b13htkEPOzxfBqYlTE/Zw== 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=K99ijwL6TdTFDT8xbHHCLcoFu4oyw/SKtmo6Nr5Yc8U=; b=hZ61snusQCZP8DyxZ4sWKveAOphdW5wgLsycq52Vk+0DB9pc6v7Ebl8RiT03iHXcNumKAzrGjzCjgUDg/o8fPY7T++ZQESjuUOcvA6JBzy5UjpEGLg1alhn+etQmfamI+1E+jpjP0ZFXhru4lFiLxUjpNT0dWSb8YgjkcuFy3FQefbz0iP902l/RDA9fFWM+7255g0g1rz3OsfXl3SHFwg2oZFv04VZICFtLNdUSUz/cDDZ9/aXde1QxjhzKtB703zLkzWyq38axOpkpT1c8/wLfORH7DxyipzlCCI6RltMVhhgByRG87NJgpM9fcokQJPuImr+ulUZoQ9pZjDEY6w== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ami.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K99ijwL6TdTFDT8xbHHCLcoFu4oyw/SKtmo6Nr5Yc8U=; b=ksMYoyECYCLdHdGRQcokc1vAdAkm622glno4DgG8C9HrEdsClLGDYw2WyGe/VX5Ir6h9Wr0fRGooUQCP1B9TKndqo0DJ4Wga8qhyo4AiN1uy3R5Ar58r9+s3nAHHlNjDrU4muyhrUFZ4apxSdk4KoJoeWOYNJV46JgAEZ3jcUmo= Received: from PH0PR10MB5403.namprd10.prod.outlook.com (2603:10b6:510:e3::17) by CH0PR10MB7498.namprd10.prod.outlook.com (2603:10b6:610:18e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.29; Mon, 12 Jun 2023 12:53:12 +0000 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 12:53:12 +0000 From: "Arun K" 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 V3-2] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Topic: [edk2-devel][edk2-platforms][PATCH V3-2] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Index: AQHZnSzYJVYKgs5XHUmlHzu5wHmCRQ== Date: Mon, 12 Jun 2023 12:53:12 +0000 Message-ID: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ami.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR10MB5403:EE_|CH0PR10MB7498:EE_ x-ms-office365-filtering-correlation-id: b3a77df7-a93e-4022-3218-08db6b43fb35 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PtkD9/HMEk+yMO4xsvD+3ayQiQuc7/TQ4JAYvxNDOxpSh8JFB/pGK9KmERcxXznu1FUJvdY0d50h3ls4g9Tma/SZ9XMSBAxyltTW6WkQfl7qP/Ub62A/yJfbGch6N0BTTk2O81qidozUm+S1g09e4eQ8OOCd0/JLeTysNKPgSRZVw7dpW58Z7PlMrGhdJW+RsfO7gjfhzZF6T5GHTAyx3EubNMqkXnZju4/NUGcLsGC8fUAZgjlVkRGUwOW4dk/QdNZ1wfc0SdL3uvhWk/VMtT9TAJyt7l27OiV2Y54xwpWqyuXcCBo5LGZ0ClhZDvp6knxkJl3LFzqYWzVBfjnwSpCxIFAS0KpVHb/sAmOJHL1CLsZFwchg/jKwdFp59fxmot9hvGc1J50eQMJ7jnPIv7m4jxvifK4jYgmLXjZf/rIMqyB3AjJ2biYm5FFG0TWzFN6ttGEOe0aKCNE3on1jA7t8RxxgpDwfy+SvZPRgG9V4ZR6LsOL50kZV/zPbMfrNrxZXd5soaSUIQgZNjhBzjKPOnXB2Qjd+zhKfoh7xDf7XB5c3reReVC57uKOzfacAjIZ0P3Yx8vLAIk2/xFJBP5jOahZk4J07sZrlkg6+MK7rHBvM5niL6CMndH7pJsjj x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5403.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39850400004)(396003)(366004)(136003)(346002)(376002)(451199021)(38070700005)(86362001)(40140700001)(36756003)(66556008)(19627235002)(110136005)(54906003)(478600001)(4326008)(316002)(71200400001)(64756008)(66946007)(91956017)(66476007)(66446008)(76116006)(6486002)(8936002)(8676002)(41300700001)(5660300002)(30864003)(2906002)(38100700002)(122000001)(2616005)(6506007)(26005)(6512007)(186003)(83380400001)(7049001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?qHwWnzEd5YZ5cjY2coEVZPxTyb+Pic19499I9ZfSxWuqIjT/xTl2nKwFOW?= =?iso-8859-1?Q?sPwCZ0o/co+g7R5GINheSGhP23YxFgklzH7378T5rxzRpmXd7GuM1uPy9i?= =?iso-8859-1?Q?c9uLbBydru0akUdlYz6mzbwIk8zXYVggYR1l+bcrcPQdW1ojGyW/pcCY11?= =?iso-8859-1?Q?nA0F1EH3jCrm+dGTWW5FVi2Z84Pqh50n0i29TxAvtOGLnJqXukq0AiZx8+?= =?iso-8859-1?Q?7R/n0qdNNaRL8DjC+UTsYctHuIANESlAWQsTx/VWK2ljh/tGQD4W4HrtCI?= =?iso-8859-1?Q?pVprDNaoWzTTsHbT9pju4UD5jrE1CdjjGLvCDUStywOX/ItIBo+eXNSQae?= =?iso-8859-1?Q?tFPvnQ0d0dfvdukNdUouF+CWQpQ7yIaYeTz1b/nENpBqFtT5zJgOO//3Pi?= =?iso-8859-1?Q?I20uHQ8/ds4bP8Tm35XBiw2cTN1iaqCqWJMzTn8JuUj4hG9tIEQ5Rg5GWa?= =?iso-8859-1?Q?BEUUhR8cg7OW2S+rRS3A61k8RxTTP9/QH4UNYRE1WL/ou2HIjazrae8Ezh?= =?iso-8859-1?Q?dza/DbUccAW5sHhfxDEB4a1fqo+z9dX0f7Nfc39lIYvKGIdS4iVw2Qr2+y?= =?iso-8859-1?Q?/o939Q2bO0J0LqtmUgBJmpoG3e8gYalo7AKy1nZ415kZ+rTkfg7IeAwb8+?= =?iso-8859-1?Q?vq2nTzvZrN5YEVortH2NWowRhqADxkZffMT1EIwBZft2q6FULTs1GKMfGp?= =?iso-8859-1?Q?mKkHCI9fU7qKSjunnLl1T+AndLUKSo/WN3FnOUOfI32PlGyDXHQOd4M3Zm?= =?iso-8859-1?Q?loyjkZ9vgmvwSpozqCMqIwXyU2U4uManFBzEu8yU1sUgUO9yL11cJ8qItj?= =?iso-8859-1?Q?z2D9L0AQO8myUwA86oWnVNQ9CjaF8wkay8Mszcy8NY2DfLTjUOJRv+H0po?= =?iso-8859-1?Q?Ljc6z5X0rrvT5DFQknwLc/hpkLZaYGos40l6ysB196eXLYj4LCxsKYSYxg?= =?iso-8859-1?Q?OAKzK/jTjEoSNPDkdR6O35bQRgtW/SaihaYU/2xolX3kWcxNZ+cbrS7dvK?= =?iso-8859-1?Q?qnRxBjBpSwqHkwVcbBVjTm4Ux9i0wXoE77VCEbJqG6syBL76tHpwka56yU?= =?iso-8859-1?Q?6tqdQUs2jtv/8FMw1jHGWJ48ThhsXGLgV0OJEpyrymDvekmon8w2/KHqYy?= =?iso-8859-1?Q?+nldmwWa+xHp9ubggb5KPTIJRR/ho9DU+RB4Ke+R8SGs41DB7IrnDHGSy/?= =?iso-8859-1?Q?FtPVH2lUwS8B0Y9K+6ujQMZSCjxKiWqPBYdC+RwVvU5x5l5xzk72DbtiT7?= =?iso-8859-1?Q?ZzSq+4CkyGwPx2JXHvvODP01iFFRdLkm+95Jj4jhw6pp+Ilrt+rLXit5Mj?= =?iso-8859-1?Q?q7dMtM2zzblvjQSxWzko1xhx7y/xeswBUBR5Vt1CY6usGsDh/UFyGufGoh?= =?iso-8859-1?Q?iyMtaQTvZXGROEu4zIpsOhfh1DV/4Me4DIZr4N0cXasyeGD7xNq/GGmt5t?= =?iso-8859-1?Q?D10tKHY/EAof7v+dakMBy+H4qywANt6/a0GL4i1k3DtUKz3w+j0xP+C+OZ?= =?iso-8859-1?Q?v/1J3CRUa63GOn5ZhOYmualPSNlDWXuwe06RaFB+Xo/p/YonvS/pG5xS/Y?= =?iso-8859-1?Q?1TIzJd8NnQX4HNlQFlhBb507Aoj1w0iNqu1YjrgSYPHM/VS87Q7pGDPLzW?= =?iso-8859-1?Q?WcTJbrO5JQT3I/NPLW3lpPiAwl6a7Q1Ftv?= 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: b3a77df7-a93e-4022-3218-08db6b43fb35 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2023 12:53:12.4168 (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: p4B84FIkwCk/M/09by0Ymh48SlThCrKXg6QS+U+v8VKJM6bEJNoFlsTVBLOeiSiM X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7498 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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= .