From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.43]) by mx.groups.io with SMTP id smtpd.web10.34543.1688395368376505953 for ; Mon, 03 Jul 2023 07:42:49 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ami.com header.s=selector1 header.b=PUWbAN0/; spf=pass (domain: ami.com, ip: 40.107.237.43, mailfrom: arunk@ami.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KEfprS8FZeXuhowgUL+OxANRYSroMh/EV78ppc06xqVlAjSNsvyawnxxP1fxOaDGd/JsncjZb2jRDa2Q6pQfUL+gPubwD2nK70+S43+wDPyL2mxP1wi7AGRpzAuTuRIbZ8KweQZTGhb5JyYvDK1HYZDWkjDbi6jpA19wGpsfREjoHr395EwdiuREOeY+ksbsk27q7qrU3EZoC0xjXlNpPr0Hcf9REk4pHgBcanHCHOGw/iLyMfDN/HahlUIdNurqyh7kldCsWaFTVKzYevZWmmX96J7Yjd36mzMmeWS/kysDqfp+G0NMWx9TlK+oyto97sDQYqz+LG6dqUVV++2Lew== 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=irml1+DdoSoC1hS0+uAa5Ye6/EceBUM7HLO2VTMDLmA=; b=erNoYvHFbaPngMnbgK1YnamCFs/6BWT2h+AhL4W+wHNdpYKctdq6Ibhgmu0J+omvwgufBInbpv/xOyj/XDoskJ2CY3jcnQgtWuyp+5ClQKy0JWAkwRpVjdlrI0UONgs8mc4xC3PdyDoBkSUiqyglLRLWKY4D/Y9dTfN0RDZIyF1Fu6FKBijdCm51CLCSscnzhHeTyDFzktjxJzeBP4ueVCuVX/wSM7u4GsFNLfetwyxol0yOFbvR7G5U9M65vDuQ7keMd3P0PROFiXlwRWN+K85Mg+gTGF8Z2DRuZiFZpi2w+ZHwBVivnGUGMcBaGSLNwL7TDqyGCW8PYX6KkJB0jA== 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=irml1+DdoSoC1hS0+uAa5Ye6/EceBUM7HLO2VTMDLmA=; b=PUWbAN0/j2DssZJ8u+vi9uC9AL82DBs8ZfRTxZYhBbV+qh2z/uu1nZueY1s6iEDV2RtHJ99O6cZw7nSS1Bg+zYp2Sg+ZdvETnyauHs7Gs/XUfyLAbGQNSs9Tz38TeAb6hJdJk+1UqYWcUq3TqzsjBb3Y8ealPBg29wqd3XBijpo= Received: from PH0PR10MB5403.namprd10.prod.outlook.com (2603:10b6:510:e3::17) by LV3PR10MB7961.namprd10.prod.outlook.com (2603:10b6:408:21d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Mon, 3 Jul 2023 14:42:44 +0000 Received: from PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::a30c:64b7:c3a0:fff7]) by PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::a30c:64b7:c3a0:fff7%4]) with mapi id 15.20.6544.024; Mon, 3 Jul 2023 14:42:44 +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 V4-1] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Topic: [edk2-devel][edk2-platforms][PATCH V4-1] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Index: AQHZrbyg8/Y91Qo2aEmVpv7ttENW8Q== Date: Mon, 3 Jul 2023 14:42:43 +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_|LV3PR10MB7961:EE_ x-ms-office365-filtering-correlation-id: c5aeaa31-4227-4c58-92ee-08db7bd3c2b4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JdY4Qw7fD9TCx6OcBPlR7+6PCE+mme8ayRELfZaklGqatYWOTV5PflYWGhrsfgWFax9VmnOx3tgoysjr9STSppg2hsFKRdvlIQsOWxFq9/bKwKNdLtvovfVt3GWJ0rQJIBoJ3wwOmoTyI/lI4N/8MGpl3Q59KBecevR3tcU0P9QRndPoocAvLOtlgUVKbGhlu/BV5YPvf0ifx+kl0xKNgMZzlBSFU3R/VXRBd9CHhdtvgnmUZ96Gou1fKrnp7bKtdyER6YqJgqBr5DpFel4WlT71Bv2d8rH5DDSom4Hleiu/eII+3fdN+7TiEt9n4XrR41Xnb++LwjACNr7pJPYq4Pp5Mg47EldKGK21Xls1/D18Toshk9/3+JKnu3E6RaHcx6HGgUXZ88jnMOR70AvNPY5lXt5+F6iAm6r/HJC590XMXd+GRaQFDJ8bpO2O3mCyWfrNq1hQA4MLo57iFS/QvVMY6x/rwwbqmVCYPZylq0ag8ZzSXXUNECDTju/ddWZehAPJJWlUKMYiC95uJrEC6CpdGe48aO/d+VQs25LJ02T1IKzE0CcjauUY7aFc/ix0zi82gpKkDM2OGEiRaGnUfKEK5S6v2cs8VsBOsWHWDl1A0NOmux4u/U/3ETO42WTc 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)(366004)(376002)(396003)(346002)(136003)(39850400004)(451199021)(7049001)(36756003)(30864003)(5660300002)(8936002)(66476007)(41300700001)(8676002)(66446008)(66556008)(38070700005)(316002)(86362001)(64756008)(76116006)(91956017)(4326008)(122000001)(38100700002)(66946007)(19627235002)(6506007)(6512007)(55236004)(26005)(2906002)(40140700001)(186003)(71200400001)(6486002)(478600001)(54906003)(110136005)(83380400001)(2616005)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?AN2E7anwn6CK2lJyZPpsHD6LycBqZaRmFg0P53SrL9kZ8NL2QKbKqZarS3?= =?iso-8859-1?Q?JI5lXFX/5TDrZGVjAS2Y/lsXPTtMnpavG7OnRQG6WLdzj2pFASaaZBEoyU?= =?iso-8859-1?Q?lxiQ5JgmAd7Z8jzjryO983H2PKWgUSkYHJMx2eoIIS7GsBgIAGp4BMGy+8?= =?iso-8859-1?Q?QZsg4Qu9RzR1JK5aqOwjK2FpJpYyNfPMKfR0+NKtQt/FgILjKHf/54sJ4Z?= =?iso-8859-1?Q?DSwdrEHQdrcsrEtSbKBXsT2KZcGaXzxsGxaIOsUg8AJw++QqqiA2zAHcF6?= =?iso-8859-1?Q?EK17poBFfAtg+va82Vk24T6MxVQNiFuep4KuzR5HPdon4aZRhLmZQohXQO?= =?iso-8859-1?Q?jDeknOaeFHthFE1pjZveooKi8YVli7jeXv9YM95YlkpqFZKzeGLI3wM75L?= =?iso-8859-1?Q?aQLpKWe5s//uFBULNbgz6I9w4ImA0jydnHpAju6y7XloQdpYYjSpIHSqSP?= =?iso-8859-1?Q?NF6pEr4fU4rELjdP2vgSjq2E4SvCvSUSjz2EDN4ebIdTRJdFuBrMsY9OYQ?= =?iso-8859-1?Q?zWDAXKH+sG0YQiQgduvVbUVamAanxaDluMTiM7xgd13w3ipijPvDpl/X4u?= =?iso-8859-1?Q?zkMnLDPi4PUAEl+gtvjV0Dd+xnNNXRK6Z7jRUV9g7n+z1d8iTHILwOdXpO?= =?iso-8859-1?Q?qZrbdH6iih6iFqONdc37a1fDTlL5gCjcxSsw8F8rtlKNEXJKIOtFYmBwX9?= =?iso-8859-1?Q?fly23M8/DA2HNNesSWRUZTWiCD+6CyHN4UW86rJpafX+YcDuC0hsWxPGMr?= =?iso-8859-1?Q?ExirhqbErX/B2NcOB7qXNiBJyoysO4ZKoJHKrvZg/ASSix4xAR9YjKipX9?= =?iso-8859-1?Q?TEiY4u9EgpBVEZb4WfczdChdKvZRnv6790iWG3fCm7ByT0a0eHfZcRs5y5?= =?iso-8859-1?Q?BpU3Y97WYZBL3lSW7i3czT5BCFh7Mn3XmwhLtYH3Hxb58WHArQyqgGtcSs?= =?iso-8859-1?Q?uUdUZGvrgAtliuc8GEqK17KsT5F5HCGaAYL8NmRhq0YwomE4YiMmcexcBB?= =?iso-8859-1?Q?KSAUubn7K/ZcYc2UdRscTE6+5D6c95LEK1Rplqtsdh+E0Sx6T5iXw+cDtE?= =?iso-8859-1?Q?O1AogWu7qnoRJCV7+tzvhfDyo5Mjq704G+TojkYxgaTSHKgsZOoo2Uom/B?= =?iso-8859-1?Q?euhwLxmvW8lzBjkXYluxGfiLQMi6ftYb4UipK3mIyR04lvgo1nq+Y41PPW?= =?iso-8859-1?Q?Yd2CRkJ6s0/a5YuHYcetlwJiK8Fa4MBhnkQLeEZ12i11FgNWBNf2JG3Tzj?= =?iso-8859-1?Q?fbPlZZLPj28QA28HGzG2KXjzAedxsnZOhJvm2C+sHVPtTGF8sZVnSSN8kH?= =?iso-8859-1?Q?LCPck393sGPj5pCCcBkNSnusdyAM+T8Ts/sE944+PB5INAhvGM+xyydwZJ?= =?iso-8859-1?Q?7PHthK4s+LxL0rnQNFbPO4aLZamtihiROnhy4sJFf5dxrzd8uCvw21XreP?= =?iso-8859-1?Q?37+i8N60iWgKmLrECOuqSEdJSrCmLBsRsYSD8wO4h5yWH7BeMygkbQ/V7G?= =?iso-8859-1?Q?Hvw7K/7FwXALLoXemdvvqTUPY2A0L/TjGUFHhq9f62CdGx3NTW2+MkxZ0T?= =?iso-8859-1?Q?KlIwbCkS/cAPRFKPmd2W0bHDxjYxWI9fmggSuX2Eoam1n4QKuAb0AY6RoA?= =?iso-8859-1?Q?5YP1G2809rCfA=3D?= 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: c5aeaa31-4227-4c58-92ee-08db7bd3c2b4 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2023 14:42:43.7894 (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: QmLbT/yPuqlILE550C7T8e+rwg1a5tqJsS5Tsr91BnOdJqzDY+RXqlqua52GkAAl X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7961 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/IPMB 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 | 117 +++--- .../GenericIpmi/Pei/PeiIpmiBmc.h | 11 +- .../GenericIpmi/Pei/PeiIpmiBmcDef.h | 86 +++-- .../GenericIpmi/Pei/PeiIpmiHooks.c | 363 ++++++++++++++++++ .../GenericIpmi/Pei/PeiIpmiHooks.h | 218 +++++++++++ 8 files changed, 949 insertions(+), 160 deletions(-) create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gener= icIpmi/Pei/PeiIpmiHooks.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gener= icIpmi/Pei/PeiIpmiHooks.h diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Ge= nericIpmi/Pei/PeiGenericIpmi.c index e8b99b6900..04ebfb6f23 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 (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + if (!EFI_ERROR (PlatformIpmiIoRangeSet(FixedPcdGet16(PcdBtControlPort)))= ) { + InitBtInterfaceData (&IpmiInstance->IpmiTransport2Ppi); + } +#endif + +#if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2Ppi); +#endif + +#if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2Ppi); +#endif +} +/*++ + +Routine Description: + Notify callback function for interfaces. + +Arguments: + PeiServices - Describes the list of possible PEI Services. + NotifyDescriptor - Pointer to notify descriptor. + Ppi - Pointer to Ppi. + +Returns: + Status + +--*/ +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 (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + InitSsifInterfaceData(&IpmiInstance->IpmiTransport2Ppi); + + if (IpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState =3D=3D= IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } +#endif + +#if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + 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; +} +/*++ + +Routine Description: + Registers callback for Ppi. + +Arguments: + PeiServices - Describes the list of possible PEI Services. + PpiGuid - Pointer to Ppi guid to register call back. + +Returns: + Status + +--*/ +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 (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) // // 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 (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + 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 (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + case SysInterfaceBt: + if (mIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceS= tate =3D=3D IpmiInterfaceInitialized){ + InterfaceState =3D IpmiInterfaceInitialized; + } + break; +#endif + +#if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + 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 (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + 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..01901764a9 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 **/ @@ -10,9 +11,10 @@ EFI_STATUS UpdateErrorStatus ( - IN UINT8 BmcError, - PEI_IPMI_BMC_INSTANCE_DATA *IpmiInstance + IN UINT8 BmcError, + PEI_IPMI_BMC_INSTANCE_DATA *IpmiInstance ) + /*++ Routine Description: @@ -55,16 +57,17 @@ Returns: EFI_STATUS PeiIpmiSendCommandToBmc ( - IN PEI_IPMI_TRANSPORT_PPI *This, - IN UINT8 NetFunction, - IN UINT8 Lun, - IN UINT8 Command, - IN UINT8 *CommandData, - IN UINT8 CommandDataSize, - IN OUT UINT8 *ResponseData, - IN OUT UINT8 *ResponseDataSize, - IN VOID *Context + IN PEI_IPMI_TRANSPORT_PPI *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT8 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT8 *ResponseDataSize, + IN VOID *Context ) + /*++ Routine Description: @@ -108,15 +111,15 @@ Returns: // response data. Since the command format is different from the respon= se // format, the buffer is cast to both structure definitions. // - IpmiCommand =3D (IPMI_COMMAND*) TempData; - IpmiResponse =3D (IPMI_RESPONSE*) TempData; + IpmiCommand =3D (IPMI_COMMAND *)TempData; + IpmiResponse =3D (IPMI_RESPONSE *)TempData; // // Send IPMI command to BMC // - IpmiCommand->Lun =3D Lun; - IpmiCommand->NetFunction =3D NetFunction; - IpmiCommand->Command =3D Command; + IpmiCommand->Lun =3D Lun; + IpmiCommand->NetFunction =3D NetFunction; + IpmiCommand->Command =3D Command; // // Ensure that the buffer is valid before attempting to copy the command= data @@ -128,19 +131,19 @@ Returns: } CopyMem ( - IpmiCommand->CommandData, - CommandData, - CommandDataSize - ); + IpmiCommand->CommandData, + CommandData, + CommandDataSize + ); } Status =3D SendDataToBmcPort ( - IpmiInstance->KcsTimeoutPeriod, - IpmiInstance->IpmiIoBase, - Context, - (UINT8 *) IpmiCommand, - (CommandDataSize + IPMI_COMMAND_HEADER_SIZE) - ); + IpmiInstance->KcsTimeoutPeriod, + IpmiInstance->IpmiIoBase, + Context, + (UINT8 *)IpmiCommand, + (CommandDataSize + IPMI_COMMAND_HEADER_SIZE) + ); if (Status !=3D EFI_SUCCESS) { IpmiInstance->BmcStatus =3D BMC_SOFTFAIL; @@ -153,13 +156,13 @@ Returns: // Get Response to IPMI Command from BMC. // DataSize =3D MAX_TEMP_DATA; - Status =3D ReceiveBmcDataFromPort ( - IpmiInstance->KcsTimeoutPeriod, - IpmiInstance->IpmiIoBase, - Context, - (UINT8 *) IpmiResponse, - &DataSize - ); + Status =3D ReceiveBmcDataFromPort ( + IpmiInstance->KcsTimeoutPeriod, + IpmiInstance->IpmiIoBase, + Context, + (UINT8 *)IpmiResponse, + &DataSize + ); if (Status !=3D EFI_SUCCESS) { IpmiInstance->BmcStatus =3D BMC_SOFTFAIL; @@ -169,15 +172,16 @@ Returns: } if ((IpmiResponse->CompletionCode !=3D COMP_CODE_NORMAL) && - (IpmiInstance->BmcStatus =3D=3D BMC_UPDATE_IN_PROGRESS)) { + (IpmiInstance->BmcStatus =3D=3D BMC_UPDATE_IN_PROGRESS)) + { // // If the completion code is not normal and the BMC is in Force Update // mode, then update the error status and return EFI_UNSUPPORTED. // UpdateErrorStatus ( - IpmiResponse->CompletionCode, - IpmiInstance - ); + IpmiResponse->CompletionCode, + IpmiInstance + ); return EFI_UNSUPPORTED; } else if (IpmiResponse->CompletionCode !=3D COMP_CODE_NORMAL) { // @@ -185,9 +189,9 @@ Returns: // is not normal, then update the error status and return device error= . // UpdateErrorStatus ( - IpmiResponse->CompletionCode, - IpmiInstance - ); + IpmiResponse->CompletionCode, + IpmiInstance + ); return EFI_DEVICE_ERROR; } @@ -215,32 +219,33 @@ Returns: // *ResponseDataSize =3D DataSize - IPMI_RESPONSE_HEADER_SIZE; CopyMem ( - ResponseData, - IpmiResponse->ResponseData, - *ResponseDataSize - ); + ResponseData, + IpmiResponse->ResponseData, + *ResponseDataSize + ); // // Add completion code in response data to meet the requirement of IPMI = spec 2.0 // *ResponseDataSize +=3D 1; // Add one byte for Completion Code for (Index =3D 1; Index < *ResponseDataSize; Index++) { - ResponseData [*ResponseDataSize - Index] =3D ResponseData [*ResponseDa= taSize - (Index + 1)]; + ResponseData[*ResponseDataSize - Index] =3D ResponseData[*ResponseData= Size - (Index + 1)]; } - ResponseData [0] =3D IpmiResponse->CompletionCode; + + ResponseData[0] =3D IpmiResponse->CompletionCode; IpmiInstance->BmcStatus =3D BMC_OK; return EFI_SUCCESS; } - EFI_STATUS -PeiIpmiBmcStatus ( - IN PEI_IPMI_TRANSPORT_PPI *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress, - IN VOID *Context +IpmiBmcStatus ( + IN PEI_IPMI_TRANSPORT_PPI *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress, + IN VOID *Context ) + /*++ Routine Description: @@ -268,10 +273,10 @@ Returns: IpmiInstance->BmcStatus =3D BMC_HARDFAIL; } - *BmcStatus =3D IpmiInstance->BmcStatus; - ComAddress->ChannelType =3D SmBmc; - ComAddress->Address.BmcAddress.LunAddress =3D 0x0; - ComAddress->Address.BmcAddress.SlaveAddress =3D IpmiInstance->SlaveAddre= ss; + *BmcStatus =3D IpmiInstance->BmcStatu= s; + ComAddress->ChannelType =3D SmBmc; + ComAddress->Address.BmcAddress.LunAddress =3D 0x0; + ComAddress->Address.BmcAddress.SlaveAddress =3D IpmiInstance->SlaveAdd= ress; ComAddress->Address.BmcAddress.ChannelAddress =3D 0x0; return EFI_SUCCESS; diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiIpmiBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Generi= cIpmi/Pei/PeiIpmiBmc.h index 40b9429e84..5f61ae6ccc 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 **/ @@ -25,7 +26,7 @@ // // IPMI Instance signature // -#define SM_IPMI_BMC_SIGNATURE SIGNATURE_32 ('i', 'p', 'm', 'i') +#define SM_IPMI_BMC_SIGNATURE SIGNATURE_32 ('i', 'p', 'm', 'i') #define INSTANCE_FROM_PEI_SM_IPMI_BMC_THIS(a) \ CR ( \ @@ -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..db29fa7fdc 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,11 +11,13 @@ #define _PEI_IPMI_COMMON_BMC_H_ #include +#include +#include "ServerManagement.h" -#define MAX_TEMP_DATA 160 -#define BMC_SLAVE_ADDRESS 0x20 -#define MAX_SOFT_COUNT 10 -#define COMP_CODE_NORMAL 0x00 +#define MAX_TEMP_DATA 160 +#define BMC_SLAVE_ADDRESS 0x20 +#define MAX_SOFT_COUNT 10 +#define COMP_CODE_NORMAL 0x00 // // IPMI command completion codes to check for in the UpdateErrorStatus rou= tine. @@ -46,15 +49,17 @@ // Pei Ipmi instance data // typedef struct { - UINTN Signature; - UINT64 KcsTimeoutPeriod; - UINT8 SlaveAddress; - BMC_STATUS BmcStatus; - UINT64 ErrorStatus; - UINT8 SoftErrorCount; - UINT16 IpmiIoBase; - PEI_IPMI_TRANSPORT_PPI IpmiTransportPpi; - EFI_PEI_PPI_DESCRIPTOR PeiIpmiBmcDataDesc; + UINTN Signature; + UINT64 KcsTimeoutPeriod; + UINT8 SlaveAddress; + BMC_STATUS BmcStatus; + UINT64 ErrorStatus; + 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; // @@ -63,38 +68,39 @@ typedef struct { #define IPMI_COMMAND_HEADER_SIZE 2 typedef struct { - UINT8 Lun : 2; - UINT8 NetFunction : 6; - UINT8 Command; - UINT8 CommandData[MAX_TEMP_DATA - IPMI_COMMAND_HEADER_SIZE]; + UINT8 Lun : 2; + UINT8 NetFunction : 6; + UINT8 Command; + UINT8 CommandData[MAX_TEMP_DATA - IPMI_COMMAND_HEADER_SIZE]; } IPMI_COMMAND; // // Structure of IPMI Command response buffer // -#define IPMI_RESPONSE_HEADER_SIZE 3 +#define IPMI_RESPONSE_HEADER_SIZE 3 typedef struct { - UINT8 Lun : 2; - UINT8 NetFunction : 6; - UINT8 Command; - UINT8 CompletionCode; - UINT8 ResponseData[MAX_TEMP_DATA - IPMI_RESPONSE_HEADER_SIZE]; + UINT8 Lun : 2; + UINT8 NetFunction : 6; + UINT8 Command; + UINT8 CompletionCode; + UINT8 ResponseData[MAX_TEMP_DATA - IPMI_RESPONSE_HEADER_SIZE]; } IPMI_RESPONSE; #pragma pack() EFI_STATUS PeiIpmiSendCommandToBmc ( - IN PEI_IPMI_TRANSPORT_PPI *This, - IN UINT8 NetFunction, - IN UINT8 Lun, - IN UINT8 Command, - IN UINT8 *CommandData, - IN UINT8 CommandDataSize, - IN OUT UINT8 *ResponseData, - IN OUT UINT8 *ResponseDataSize, - IN VOID *Context + IN PEI_IPMI_TRANSPORT_PPI *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT8 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT8 *ResponseDataSize, + IN VOID *Context ) + /*++ Routine Description: @@ -123,14 +129,14 @@ Returns: --*/ ; - EFI_STATUS PeiIpmiBmcStatus ( - IN PEI_IPMI_TRANSPORT_PPI *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress, - IN VOID *Context + IN PEI_IPMI_TRANSPORT_PPI *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress, + IN VOID *Context ) + /*++ Routine Description: @@ -151,5 +157,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/GenericIpmi/= Pei/PeiIpmiHooks.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Pei/PeiIpmiHooks.c new file mode 100644 index 0000000000..947287aa56 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiHooks.c @@ -0,0 +1,363 @@ +/** @file + IPMI common hook functions + + @copyright + Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include + +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 + +--*/ +{ + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // This Will be unchanged ( BMC/KCS style ) + // + return PeiIpmiSendCommandToBmc ( + This, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); +} // IpmiSendCommand() + +EFI_STATUS +PeiIpmiSendCommand2 ( + IN IPMI_TRANSPORT2 *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: + + This API use the default interface (PcdDefaultSystemInterface) to send I= PMI command + in the right mode 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 + +--*/ +{ + PEI_IPMI_BMC_INSTANCE_DATA *PeiIpmiInstance; + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + PeiIpmiInstance =3D INSTANCE_FROM_PEI_IPMI_TRANSPORT2_THIS (This); + + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + if ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfac= eKcs) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState =3D= =3D IpmiInterfaceInitialized)) + { + return PeiIpmiSendCommand ( + &PeiIpmiInstance->IpmiTransportPpi, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + #endif + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + if ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfac= eBt) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceState =3D= =3D IpmiInterfaceInitialized)) + { + return IpmiBtSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + if ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfac= eSsif) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState = =3D=3D IpmiInterfaceInitialized)) + { + return IpmiSsifSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + if ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfac= eIpmb) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState = =3D=3D IpmiInterfaceInitialized)) + { + return IpmiIpmbSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + return EFI_UNSUPPORTED; +} // IpmiSendCommand() + +EFI_STATUS +PeiIpmiSendCommand2Ex ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ) +{ + /*++ + Routine Description: + + This API use the specific interface type to send IPMI command + in the right mode 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 + InterfaceType - BMC Interface type. + + 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 + + --*/ + + PEI_IPMI_BMC_INSTANCE_DATA *PeiIpmiInstance; + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + PeiIpmiInstance =3D INSTANCE_FROM_PEI_IPMI_TRANSPORT2_THIS (This); + + #if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) + if ((InterfaceType =3D=3D SysInterfaceKcs) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState =3D= =3D IpmiInterfaceInitialized)) + { + return PeiIpmiSendCommand ( + &PeiIpmiInstance->IpmiTransportPpi, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + #endif + + #if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) + + if ((InterfaceType =3D=3D SysInterfaceBt) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceState =3D= =3D IpmiInterfaceInitialized)) + { + return IpmiBtSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) + + if ((InterfaceType =3D=3D SysInterfaceSsif) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState = =3D=3D IpmiInterfaceInitialized)) + { + return IpmiSsifSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + #if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) + if ((InterfaceType =3D=3D SysInterfaceIpmb) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState = =3D=3D IpmiInterfaceInitialized)) + { + return IpmiIpmbSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + #endif + + return EFI_UNSUPPORTED; +} + +EFI_STATUS +PeiIpmiBmcStatus ( + IN PEI_IPMI_TRANSPORT_PPI *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress, + IN VOID *Context + ) + +/*++ + +Routine Description: + + Updates the BMC status and returns the Com Address + +Arguments: + + This - Pointer to IPMI protocol instance + BmcStatus - BMC status + ComAddress - Com Address + +Returns: + + EFI_SUCCESS - Success + +--*/ +{ + if ((This =3D=3D NULL) || (BmcStatus =3D=3D NULL) || (ComAddress =3D=3D = NULL)) { + return EFI_INVALID_PARAMETER; + } + + return IpmiBmcStatus ( + This, + BmcStatus, + ComAddress, + NULL + ); +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiIpmiHooks.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Pei/PeiIpmiHooks.h new file mode 100644 index 0000000000..25be1fd94a --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiHooks.h @@ -0,0 +1,218 @@ +/** @file + IPMI common hook functions head file + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _IPMI_HOOKS_H +#define _IPMI_HOOKS_H + +#include +#include +#include +#include +#include +#include +#include + +// +// Internal(hook) function list +// + +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 + +--*/ +; + +EFI_STATUS +PeiIpmiSendCommand2 ( + IN IPMI_TRANSPORT2 *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: + + This API use the default interface (PcdDefaultSystemInterface) to send I= PMI command + in the right mode 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 + +--*/ +; + +EFI_STATUS +PeiIpmiSendCommand2Ex ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT32 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT32 *ResponseDataSize, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ); + +EFI_STATUS +PeiIpmiSendCommandToBMC ( + IN PEI_IPMI_TRANSPORT_PPI *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT8 CommandDataSize, + IN OUT UINT8 *ResponseData, + IN OUT UINT8 *ResponseDataSize, + IN VOID *Context + ) + +/*++ +Routine Description: + + This API use the specific interface type to send IPMI command + in the right mode 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 + InterfaceType - BMC Interface type. + +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 + +--*/ +; + +EFI_STATUS +PeiIpmiBmcStatus ( + IN PEI_IPMI_TRANSPORT_PPI *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress, + IN VOID *Context + ) + +/*++ + +Routine Description: + + Updates the BMC status and returns the Com Address + +Arguments: + + This - Pointer to IPMI protocol instance + BmcStatus - BMC status + ComAddress - Com Address + Context - Context + +Returns: + + EFI_SUCCESS - Success + +--*/ +; + +EFI_STATUS +IpmiBmcStatus ( + IN PEI_IPMI_TRANSPORT_PPI *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress, + IN VOID *Context + ) + +/*++ + +Routine Description: + + Updates the BMC status and returns the Com Address + +Arguments: + + This - Pointer to IPMI protocol instance + BmcStatus - BMC status + ComAddress - Com Address + Context - Context + +Returns: + + EFI_SUCCESS - Success + +--*/ +; + +#endif -- 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= .