From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 0ED30740032 for ; Tue, 25 Jul 2023 15:35:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=sbUX8ISqHUBDrpsz++/xb+khZyW0AlsGIbQqFsVME/g=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:Accept-Language:X-MS-Has-Attach:X-MS-TNEF-Correlator:x-ms-publictraffictype:x-ms-traffictypediagnostic:x-ms-office365-filtering-correlation-id:x-ms-exchange-senderadcheck:x-ms-exchange-antispam-relay:x-microsoft-antispam-message-info:x-ms-exchange-antispam-messagedata-chunkcount:x-ms-exchange-antispam-messagedata-0:MIME-Version:X-OriginatorOrg:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-originalarrivaltime:X-MS-Exchange-CrossTenant-fromentityheader:X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype:X-MS-Exchange-CrossTenant-userprincipalname:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscr ibe:X-Gm-Message-State:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1690299346; v=1; b=IxPuc+DWyk4PYj+Omn5k4LKNnJZSXChz5HfNgOwTb4VQua1tkfmnCphHDeRxiZTdSjyq12cb WxMrNILDvTH2Q3lOQaO8DAYwCIlUOE03kcwyeC8wlbX2jIQ6kr67Kfa/YKn+kxoIylVi8KDB2BZ nVIwSZlgMNqBEN4ushKW62X4= X-Received: by 127.0.0.2 with SMTP id lpQwYY7687511xkrRHu5c088; Tue, 25 Jul 2023 08:35:46 -0700 X-Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.40]) by mx.groups.io with SMTP id smtpd.web11.23553.1690299345186330918 for ; Tue, 25 Jul 2023 08:35:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kmfoz1WlHdkhxvA4N0byt/iZlx288F63rWzW63g2e14x3b7eIBp3NHJubeNOxUbvZDSsphwo2e7MyZNmdokhNi8EByQoq3C4ItR/9itsvZFDjFD8GX63OZqdb2th67AHIq2LVi+/t+AFo4E4zN4NFzB3DrzFltX/S+1h9zjHOlwQRUI/45NRQe1clAlhm3cYhFXHtZMjVTnO0IgKCqCU9+9CSYPPoU6T6c7q6KJs0Y+A/3wLtmXbqsmXElWFKV7BbCurU9JxQh7dNKUDApgVR98aM4jKeVNGf9yD0StX/crooncaau7F4LE+bWUDbjCpMDFqsfhNi6lOCW0BWUxDIg== 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=YjaGE/5zgGZ3EY/j0aM952pLLiOaV+vtsUHRTRfcN1g=; b=l5jTk/IAcjRYKu81mOrR59NiZGszA1xAbeFOOPNUufmZf9olVRNjaeHmT7f7RO+KF1aSgyK4RW36p43hd4GAbXzpIAcFsKSg0MWywePboBy9K23j7m+mO53i3fPTq0eOp4zDivyhs6FpNTS78JUpfvum6ZCZlvZht7tyw/dC3v0vlruIC5AGqowlgmeJfdvrADiyuStykpdPvwuHacZayXnxy0xJ7KXwkkpYBMT6EIbB+sqtnM60YbxW+J9tWSOktRmn4lhxTUhcIQw9N36PgBMmWmgVUYLFXkeepnONeS4rwvF2KNM206l7XGy7r7zYM108qtNCLSj2yjw4o0TMmQ== 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 PH7PR10MB6059.namprd10.prod.outlook.com (2603:10b6:510:1fd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Tue, 25 Jul 2023 15:35:39 +0000 X-Received: from PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::7d8c:5b29:553f:3a95]) by PH0PR10MB5403.namprd10.prod.outlook.com ([fe80::7d8c:5b29:553f:3a95%5]) with mapi id 15.20.6609.032; Tue, 25 Jul 2023 15:35:38 +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 V5-1] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Topic: [edk2-devel][edk2-platforms][PATCH V5-1] IpmiFeaturePkg:Provided multiple IPMI interface support in PEI Thread-Index: AQHZvw2pBV7q4nuhUUqpg/qVKBWYDg== Date: Tue, 25 Jul 2023 15:35:38 +0000 Message-ID: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR10MB5403:EE_|PH7PR10MB6059:EE_ x-ms-office365-filtering-correlation-id: 39571c85-6570-4f55-e08d-08db8d24cc14 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: +plSkUy17/MIKr1vxkXurzYuaIa718eh5Hqf9ipeFB/sSF3eC48AThCT7FMpEX3BIHXaKJvoyje3HABSfnL1ijvu5FCm4vayJ3fHNGWEs5QcX6gyrMrlWTkaEcmVc+lPDwcospRGgylzQYMTO6qJVvEPmg520cPWLnJUr5SZ5XkV5Dy0Ae4Wi22q838GJlK9uxqqxNULhHC0KybpK5UVuNy5wbLRlKjTpCxqrlCl4+L7B/6DSIXxVC8/K/UGe3IPZV4j0fucq8IY9pFbwlKGIc+ODmZh5p2wCQ5vzLOw1P49FROir9dm0faemybyOGlZazNfRrGHhp6mfz9NQcVmaffRwTLXXDF2d1wzqP1rIATlVUcw9G2D2wq003j5JkDuXQIBX1RL+vFH5nJzbQSwi/amLeq+f862CY1f8+gAJIztjLAdUz7g/l8imZpyeeSiv8oltSn5u++cOKPdW4zGflEfnTBDRTjTlJhvTvZS/Ooz+mrb9YSnOd6A0fX/jboYrVwlRmg83mx14AhbE63ULpZe31D0RLCQRMyTcaqzwk7jfqn4i63XKg09w9nyakB3yztx71FY3UXuXH53SgHYrDf0CApKniW7nYIx8BTE26l5XskD1y3pDVmDw6BAw/Zi x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?TOUzgaxMRL2qKR1i2F4YSBBdJlfVDXyFpOhyTJSBgzrT5rHl0MqoQXeL+I?= =?iso-8859-1?Q?g0yH36E06vfdvlvk/TXk5tnTS0Veui/rBpYxJHFNn1Po9iCzByuh7nCXNg?= =?iso-8859-1?Q?diSn652r4RRAOT76Cf2h/pC2A8GYlqivSyduRmGLJRg9i+0CkxDtKckWb4?= =?iso-8859-1?Q?K48LMdXenh6IGj3AA+MYUT7HdbvXsyvtoMF098TWRIx9UP1Nin4zCkWXze?= =?iso-8859-1?Q?OtW8xbaTEJm52NgUfQDq6fy3n/k//iARYcCv0+ktXugiMziveRvVsPlvFt?= =?iso-8859-1?Q?FQUasHV8/qiYymdru4upgS2g6+3Cm0xmvvxR3T4CZX7JlLUasVmfSoyXci?= =?iso-8859-1?Q?NO7QE+o58tsn8k8vvgu6kcU4Pk7wHA2DAzGRMahRkqEoL5VrIZ66HfFkDL?= =?iso-8859-1?Q?sP/kYPDYkMKmOdiRR2ApsT6M/9ekE1H1ZgZP5AYB/Kz8PqZmNoasTUi7Lx?= =?iso-8859-1?Q?A2ge9Iflat/3barbIVeWTLRp0wcgLC7P58zc6bTL2uFBHlZEDdZb7LYh8W?= =?iso-8859-1?Q?/L0hfRDwXLwpc03u6vD+DNovWV3f8PD/v2rXDer+iEaoT6Mua5hLI3IsuV?= =?iso-8859-1?Q?eSEIfFhPR06lrQ3Mpej61+0vio1uzU73vJ17iswfF0UdMP2CDIKlZknAsu?= =?iso-8859-1?Q?hQQeTq9OeWzTKDmW5X3S66EpUcJLHBiyahns/dnLldaqgrmw9CkeJIVCFY?= =?iso-8859-1?Q?mxMMEhB2OhqwV5QAdmR56cz9CDMGsPNYXoYmgoF/61+udRWNyQvUiX2Qr9?= =?iso-8859-1?Q?XL6fjZ5yrQ2SlvB3ndJRJIk7f9rxntqeO5mMXNrUmbsLiR4kTZhuszXAOj?= =?iso-8859-1?Q?guQhipgVXFBvwSnMZWdBwjyXTtG8kQvZm9tDfHWlLNM4LKWcxwxHDkYRBL?= =?iso-8859-1?Q?ZJq1TKE2Wz+x2JtwY5mAgJi89iUmvqGWpKMsBSSYVD2cBzviBOw73k/e/W?= =?iso-8859-1?Q?kvIFVYBvUFOl3h+SzEOw4Yvg9Y199k1sGLU6X8NSx/ybFKfieI538jOQU/?= =?iso-8859-1?Q?DwJSAaUGJyCjCInIjoMs7863Lexn41lcriZ04an1P/fcdk0z3JdvZl+BMq?= =?iso-8859-1?Q?HZKP8KrhEmR4VxTNcMSDjD3jgdfnv6ejKrrColeeKolNJnnSoZuZjRVcKG?= =?iso-8859-1?Q?4cGygtNUnsovz2oZGTgChefNfQFCTLegUg0BGa1zlpD3Mj97Nycnt3Sovf?= =?iso-8859-1?Q?WNKQG1lR66td8Q0b+MI+QMPEmo0fM+lqWs+JUh7/YdmKmD4Uj7CY/PlXJk?= =?iso-8859-1?Q?glHBcBh2a+PY4lOzBbqh1igbRSdN92yOmfBuFhH4BOjGE/mlHu0bT5LMTO?= =?iso-8859-1?Q?Kx1sZ8JxWXEGtRxLX/ucAFPsFGP6AwBB2Y9YpgUjqCiINu8meDHAA9Laq4?= =?iso-8859-1?Q?zdbw6OLgu0uGpBdOmYGLin8Ac9U+pkvnSL5YUOwehMHvjublZwrY8PK5Jh?= =?iso-8859-1?Q?kwStzFjG/7PVe5/BtNT2Ws57WSpE6h8RFsyCa+7XHLqqFwkzEojLestn0o?= =?iso-8859-1?Q?dJfvIlc2N0VAjpLNtubqonZuCvDVXEIqlO3oObWkxBUbhm0gKsA2oFGJTT?= =?iso-8859-1?Q?bCDfk0PDJu5JBlvcni3yBfbvjtAVWIk6TkCsHIwsqEHghCGzOdSNi9x9O9?= =?iso-8859-1?Q?Y1WjOzFqbCXwk=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: 39571c85-6570-4f55-e08d-08db8d24cc14 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2023 15:35:38.5087 (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: 901x8x+fJgwUuwANDOEBnPZtTIDmuuRquCFCZV7mNfvcQ96PicFm/y51EzWQTELP X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6059 Precedence: Bulk 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 List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: gSDpk6NsZdkYE6vQQfkTaHjCx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=IxPuc+DW; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") 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 | 550 +++++++++++++----- .../GenericIpmi/Pei/PeiGenericIpmi.h | 75 ++- .../GenericIpmi/Pei/PeiGenericIpmi.inf | 17 + .../GenericIpmi/Pei/PeiIpmiBmc.c | 117 ++-- .../GenericIpmi/Pei/PeiIpmiBmc.h | 11 +- .../GenericIpmi/Pei/PeiIpmiBmcDef.h | 86 +-- .../GenericIpmi/Pei/PeiIpmiHooks.c | 346 +++++++++++ .../GenericIpmi/Pei/PeiIpmiHooks.h | 218 +++++++ 8 files changed, 1159 insertions(+), 261 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..61e7ce4ecd 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,208 @@ #include "PeiGenericIpmi.h" #include #include +#include //////////////////////////////////////////////////////////////////////////= ///// -// Function Implementations -// + +static EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList =3D { + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINAT= E_LIST, + &gEfiPeiMemoryDiscoveredPpiGuid, + UpdateIpmiInstancePtr +}; + +/** + 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 (PcdBtControlPor= t)))) { + InitBtInterfaceData (&IpmiInstance->IpmiTransport2Ppi); + } + } + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2Ppi); + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2Ppi); + } +} + +/*++ + +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; + } + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2Ppi); + + if (IpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState =3D= =3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + } + + // 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; +} + +/*++ + +Routine Description: + After memory is discovered, update the IPMI Instance pointer in Hob. + +Arguments: + PeiServices - Describes the list of possible PEI Services. + NotifyDescriptor - PPointer to notify descriptor.. + Ppi - Pointer to Ppi. + +Returns: + Status + +--*/ +EFI_STATUS +EFIAPI +UpdateIpmiInstancePtr ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) +{ + PEI_IPMI_BMC_INSTANCE_DATA *IpmiInstance; + PEI_IPMI_DATA_HOB *IpmiInstancePtrHob; + EFI_HOB_GUID_TYPE *GuidHob; + + 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 (!IpmiInstance) { + return EFI_ABORTED; + } + + DEBUG ((DEBUG_INFO, "IpmiInstance Signature in CAR Memory: %x\n", IpmiIn= stance->Signature)); + + if ((UINTN)IpmiInstancePtrHob >=3D (UINTN)IpmiInstancePtrHob->PreMemIpmi= DataHobPtr) { + IpmiInstance =3D (PEI_IPMI_BMC_INSTANCE_DATA *)((UINT8 *)IpmiInstance = + \ + (UINTN)((UINTN)IpmiInsta= ncePtrHob - (UINTN)IpmiInstancePtrHob->PreMemIpmiDataHobPtr)); + } else { + IpmiInstance =3D (PEI_IPMI_BMC_INSTANCE_DATA *)((UINT8 *)IpmiInstance = - \ + (UINTN)((UINTN)IpmiInsta= ncePtrHob->PreMemIpmiDataHobPtr - (UINTN)IpmiInstancePtrHob)); + } + + IpmiInstancePtrHob->IpmiInstance =3D (UINTN)IpmiInstance; + DEBUG ((DEBUG_INFO, "IpmiInstance Signature after Permanent Memory disco= vered: %x\n", IpmiInstance->Signature)); + return EFI_SUCCESS; +} /*************************************************************************= **** @brief @@ -26,13 +225,17 @@ EFI_STATUS EFIAPI PeiInitializeIpmiKcsPhysicalLayer ( - IN CONST EFI_PEI_SERVICES **PeiServices + IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; - PEI_IPMI_BMC_INSTANCE_DATA *mIpmiInstance; + 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 @@ -50,63 +253,166 @@ PeiInitializeIpmiKcsPhysicalLayer ( // Status =3D PlatformIpmiIoRangeSet (PcdGet16 (PcdIpmiIoBaseAddress)); DEBUG ((DEBUG_INFO, "IPMI Peim:PlatformIpmiIoRangeSet - %r!\n", Status))= ; - if (EFI_ERROR(Status)) { + if (EFI_ERROR (Status)) { return Status; } mIpmiInstance =3D AllocateZeroPool (sizeof (PEI_IPMI_BMC_INSTANCE_DATA))= ; if (mIpmiInstance =3D=3D NULL) { - DEBUG ((EFI_D_ERROR,"IPMI Peim:EFI_OUT_OF_RESOURCES of memory allocati= on\n")); + DEBUG ((EFI_D_ERROR, "IPMI Peim:EFI_OUT_OF_RESOURCES of memory allocat= ion\n")); return EFI_OUT_OF_RESOURCES; } + if ((FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) || (FixedPcdGet8 (= PcdSsifInterfaceSupport) =3D=3D 1)) { + // Create Guided hob to pass IPMI Instance data pointer to notify func= tions. + IpmiInstancePtrHob =3D BuildGuidHob (&gPeiIpmiHobGuid, sizeof (PEI_IPM= I_DATA_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; + + // Check for Memory initialization + Status =3D (*PeiServices)->LocatePpi ( + PeiServices, + &gEfiPeiMemoryDiscoveredPpiGuid, + 0, + NULL, + NULL + ); + + if (EFI_ERROR (Status)) { + /* Register Memory discovered PPI call back to update HOB with new + IpmiInstance pointer.*/ + Status =3D (*PeiServices)->NotifyPpi (PeiServices, &mNotifyList); + if (EFI_ERROR (Status)) { + FreePool (mIpmiInstance); + return Status; + } + } + } + // // 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 // - DEBUG ((DEBUG_INFO,"IPMI Peim:IPMI STACK Initialization\n")); + DEBUG ((DEBUG_INFO, "IPMI Peim:IPMI STACK Initialization\n")); mIpmiInstance->KcsTimeoutPeriod =3D (BMC_KCS_TIMEOUT_PEI *1000*1000) / K= CS_DELAY_UNIT_PEI; - DEBUG ((EFI_D_INFO,"IPMI Peim:KcsTimeoutPeriod =3D 0x%x\n", mIpmiInstanc= e->KcsTimeoutPeriod)); + DEBUG ((EFI_D_INFO, "IPMI Peim:KcsTimeoutPeriod =3D 0x%x\n", mIpmiInstan= ce->KcsTimeoutPeriod)); // // Initialize IPMI IO Base. // - mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiI= oBaseAddress); - DEBUG ((EFI_D_INFO,"IPMI Peim:IpmiIoBase=3D0x%x\n",mIpmiInstance->IpmiIo= Base)); + mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiIoBaseAddress); + DEBUG ((EFI_D_INFO, "IPMI Peim:IpmiIoBase=3D0x%x\n", mIpmiInstance->Ipmi= IoBase)); mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNAT= URE; mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; mIpmiInstance->BmcStatus =3D BMC_NOTREADY; mIpmiInstance->IpmiTransportPpi.IpmiSubmitCommand =3D PeiIpmiSendCommand= ; mIpmiInstance->IpmiTransportPpi.GetBmcStatus =3D PeiGetIpmiBmcStatu= s; - mIpmiInstance->PeiIpmiBmcDataDesc.Flags =3D EFI_PEI_PPI_DESCRIPT= OR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; - mIpmiInstance->PeiIpmiBmcDataDesc.Guid =3D &gPeiIpmiTransportPp= iGuid; - mIpmiInstance->PeiIpmiBmcDataDesc.Ppi =3D &mIpmiInstance->Ipmi= TransportPpi; + mIpmiInstance->PeiIpmiBmcDataDesc.Flags =3D EFI_PEI_PPI_DESCRIPTOR_PPI |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; + mIpmiInstance->PeiIpmiBmcDataDesc.Guid =3D &gPeiIpmiTransportPpiGuid; + mIpmiInstance->PeiIpmiBmcDataDesc.Ppi =3D &mIpmiInstance->IpmiTranspor= tPpi; - // - // Get the Device ID and check if the system is in Force Update mode. - // - Status =3D GetDeviceId (mIpmiInstance); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR,"IPMI Peim:Get BMC Device Id Failed. Status=3D%r\n= ",Status)); + if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) { + // + // Get the Device ID and check if the system is in Force Update mode. + // + Status =3D GetDeviceId (mIpmiInstance); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "IPMI Peim:Get BMC Device Id Failed. Status=3D%= r\n", Status)); + } + + // + // Do not continue initialization if the BMC is in Force Update Mode. + // + if ((mIpmiInstance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS) && (mIpmiIn= stance->BmcStatus !=3D BMC_HARDFAIL)) { + Status =3D PeiServicesInstallPpi (&mIpmiInstance->PeiIpmiBmcDataDesc= ); + if (EFI_ERROR (Status)) { + return Status; + } + } } - // - // 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; + 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) && (mIpmiInstan= ce->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; + mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState = =3D IpmiInterfaceInitialized; + Status = =3D CheckSelfTestByInterfaceType ( + = &mIpmiInstance->IpmiTransport2Ppi, + = &BmcStatus, + = SysInterfaceKcs + = ); + if (!EFI_ERROR (Status) && (BmcStatus !=3D BmcStatusHardFail))= { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + mIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState= =3D IpmiInterfaceInitError; + } + } + + break; + } + + if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) { + case SysInterfaceBt: + if (mIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceState= =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + break; + } + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + case SysInterfaceSsif: + if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceSta= te =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.Inter= faceState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D RegisterPpiCallback (PeiServices, &mIpmiInstance->I= pmiTransport2Ppi.Interface.Ssif.SsifInterfaceApiGuid); + } + + break; + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + case SysInterfaceIpmb: + if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceSta= te =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.Inter= faceState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D RegisterPpiCallback (PeiServices, &mIpmiInstance->I= pmiTransport2Ppi.Interface.Ipmb.IpmbInterfaceApiGuid); + } + + break; + } + + 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->IpmiTranspo= rt2Ppi; + + Status =3D PeiServicesInstallPpi (&mIpmiInstance->PeiIpmi2BmcDataDesc); + return Status; } /*************************************************************************= **** @@ -119,29 +425,29 @@ PeiInitializeIpmiKcsPhysicalLayer ( **/ EFI_STATUS SendPreBootSignaltoBmc ( - IN CONST EFI_PEI_SERVICES **PeiServices + IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; - EFI_PEI_CPU_IO_PPI *CpuIoPpi; - UINT32 ProvisionPort =3D 0; - UINT8 PreBoot =3D 0; + EFI_STATUS Status; + EFI_PEI_CPU_IO_PPI *CpuIoPpi; + UINT32 ProvisionPort =3D 0; + UINT8 PreBoot =3D 0; // // Locate CpuIo service // - CpuIoPpi =3D (**PeiServices).CpuIo; + CpuIoPpi =3D (**PeiServices).CpuIo; ProvisionPort =3D PcdGet32 (PcdSioMailboxBaseAddress) + MBXDAT_B; - PreBoot =3D 0x01;// PRE-BOOT + PreBoot =3D 0x01;// PRE-BOOT Status =3D CpuIoPpi->Io.Write ( - PeiServices, - CpuIoPpi, - EfiPeiCpuIoWidthUint8, - ProvisionPort, - 1, - &PreBoot - ); + PeiServices, + CpuIoPpi, + EfiPeiCpuIoWidthUint8, + ProvisionPort, + 1, + &PreBoot + ); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "SendPreBootSignaltoBmc () Write PRE-BOOT Status= =3D%r\n", Status)); return Status; @@ -175,68 +481,13 @@ PeimIpmiInterfaceInit ( return Status; } // 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 ( - IN PEI_IPMI_TRANSPORT_PPI *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress + IN PEI_IPMI_TRANSPORT_PPI *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress ) + /*++ Routine Description: @@ -256,18 +507,18 @@ Returns: --*/ { return PeiIpmiBmcStatus ( - This, - BmcStatus, - ComAddress, - NULL - ); + This, + BmcStatus, + ComAddress, + NULL + ); } - EFI_STATUS GetDeviceId ( - IN PEI_IPMI_BMC_INSTANCE_DATA *mIpmiInstance + IN PEI_IPMI_BMC_INSTANCE_DATA *mIpmiInstance ) + /*++ Routine Description: @@ -284,11 +535,11 @@ Returns: --*/ { - EFI_STATUS Status; - UINT32 DataSize; - SM_CTRL_INFO *pBmcInfo; - UINTN Retries; - UINT8 TempData[MAX_TEMP_DATA]; + EFI_STATUS Status; + UINT32 DataSize; + SM_CTRL_INFO *pBmcInfo; + UINTN Retries; + UINT8 TempData[MAX_TEMP_DATA]; // // Set up a loop to retry for up to PcdIpmiBmcReadyDelayTimer seconds. C= alculate retries not timeout @@ -300,32 +551,41 @@ Returns: // Get the device ID information for the BMC. // DataSize =3D sizeof (TempData); - while (EFI_ERROR (Status =3D PeiIpmiSendCommand ( - &mIpmiInstance->IpmiTransportPpi, - IPMI_NETFN_APP, - 0, - IPMI_APP_GET_DEVICE_ID, - NULL, - 0, - TempData, - &DataSize - ))) { - DEBUG ((EFI_D_ERROR, "[IPMI] BMC does not respond (status: %r), %d ret= ries left\n", - Status, Retries)); + while (EFI_ERROR ( + Status =3D PeiIpmiSendCommand ( + &mIpmiInstance->IpmiTrans= portPpi, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ) + )) + { + DEBUG ( + (EFI_D_ERROR, "[IPMI] BMC does not respond (status: %r), %d ret= ries left\n", + Status, Retries) + ); if (Retries-- =3D=3D 0) { ReportStatusCode (EFI_ERROR_CODE | EFI_ERROR_MAJOR, EFI_COMPUTING_UN= IT_FIRMWARE_PROCESSOR | EFI_CU_FP_EC_COMM_ERROR); mIpmiInstance->BmcStatus =3D BMC_HARDFAIL; return Status; } + // // Handle the case that BMC FW still not enable KCS channel after AC c= ycle. just stall 1 second // MicroSecondDelay (1*1000*1000); } - pBmcInfo =3D (SM_CTRL_INFO*) &TempData[0]; - DEBUG ((DEBUG_INFO, "[IPMI PEI] BMC Device ID: 0x%02X, firmware version:= %d.%02X UpdateMode:%x\n", - pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBmcInfo->MinorF= irmwareRev, pBmcInfo->UpdateMode)); + + pBmcInfo =3D (SM_CTRL_INFO *)&TempData[0]; + DEBUG ( + (DEBUG_INFO, "[IPMI PEI] BMC Device ID: 0x%02X, firmware version:= %d.%02X UpdateMode:%x\n", + pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBmcInfo->MinorF= irmwareRev, pBmcInfo->UpdateMode) + ); // // In OpenBMC, UpdateMode: the bit 7 of byte 4 in get device id command = is used for the BMC status: // 0 means BMC is ready, 1 means BMC is not ready. @@ -339,20 +599,20 @@ Returns: // Updatemode =3D 1 mean BMC is not ready, continue waiting. // while (Retries-- !=3D 0) { - MicroSecondDelay(1*1000*1000); //delay 1 seconds - DEBUG ((DEBUG_INFO, "[IPMI PEI] UpdateMode Retries:%x \n",Retries)); + MicroSecondDelay (1*1000*1000); // delay 1 seconds + DEBUG ((DEBUG_INFO, "[IPMI PEI] UpdateMode Retries:%x \n", Retries))= ; Status =3D PeiIpmiSendCommand ( - &mIpmiInstance->IpmiTransportPpi, - IPMI_NETFN_APP, - 0, - IPMI_APP_GET_DEVICE_ID, - NULL, - 0, - TempData, - &DataSize - ); + &mIpmiInstance->IpmiTransportPpi, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ); if (!EFI_ERROR (Status)) { - pBmcInfo =3D (SM_CTRL_INFO*) &TempData[0]; + pBmcInfo =3D (SM_CTRL_INFO *)&TempData[0]; DEBUG ((DEBUG_INFO, "[IPMI PEI] UpdateMode Retries:%x pBmcInfo->= UpdateMode:%x\n", Retries, pBmcInfo->UpdateMode)); if (pBmcInfo->UpdateMode =3D=3D BMC_READY) { mIpmiInstance->BmcStatus =3D BMC_OK; diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiGenericIpmi.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Ge= nericIpmi/Pei/PeiGenericIpmi.h index d31af85325..2d566aa9d5 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,49 +24,53 @@ #include #include #include +#include +#include "PeiIpmiHooks.h" #include "PeiIpmiBmcDef.h" #include "PeiIpmiBmc.h" // // Prototypes // -#define MBXDAT_B 0x0B -#define BMC_KCS_TIMEOUT_PEI 5 // [s] Single KSC request = timeout -#define KCS_DELAY_UNIT_PEI 1000 // [s] Each KSC IO delay -#define IPMI_DEFAULT_IO_BASE 0xCA2 +#define MBXDAT_B 0x0B +#define BMC_KCS_TIMEOUT_PEI 5 // [s] Single KSC request = timeout +#define KCS_DELAY_UNIT_PEI 1000 // [s] Each KSC IO delay +#define IPMI_DEFAULT_IO_BASE 0xCA2 // // Internal(hook) function list // EFI_STATUS SendPreBootSignaltoBmc ( - IN CONST EFI_PEI_SERVICES **PeiServices + IN CONST EFI_PEI_SERVICES **PeiServices ) - /*++ + +/*++ Routine Description: - Send Pre-Boot signal to BMC +Send Pre-Boot signal to BMC Arguments: - PeiServices - General purpose services available to every PEIM= . +PeiServices - General purpose services available to every PEIM. Returns: - EFI_SUCCESS - Success +EFI_SUCCESS - Success --*/ ; 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 + 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: @@ -92,10 +97,11 @@ Returns: EFI_STATUS PeiGetIpmiBmcStatus ( - IN PEI_IPMI_TRANSPORT_PPI *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress + IN PEI_IPMI_TRANSPORT_PPI *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress ) + /*++ Routine Description: @@ -116,8 +122,9 @@ Returns: // EFI_STATUS GetDeviceId ( - IN PEI_IPMI_BMC_INSTANCE_DATA *mIpmiInstance + IN PEI_IPMI_BMC_INSTANCE_DATA *mIpmiInstance ) + /*++ Routine Description: @@ -134,5 +141,29 @@ Returns: --*/ ; -#endif //_PEI_IPMI_INIT_H_ +EFI_STATUS +EFIAPI +UpdateIpmiInstancePtr ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) + +/*++ + +Routine Description: + After memory is discovered, update the IPMI Instance pointer in Hob. + +Arguments: + PeiServices - Describes the list of possible PEI Services. + NotifyDescriptor - PPointer to notify descriptor.. + Ppi - Pointer to Ppi. + +Returns: + Status + +--*/ +; + +#endif //_PEI_IPMI_INIT_H_ diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Pei/PeiGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= GenericIpmi/Pei/PeiGenericIpmi.inf index a646161ce1..3a73180ce6 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,31 @@ ReportStatusCodeLib TimerLib IpmiPlatformHookLib + HobLib + BmcCommonInterfaceLib + BtInterfaceLib + SsifInterfaceLib + IpmbInterfaceLib [Guids] + gPeiIpmiHobGuid [Ppis] gPeiIpmiTransportPpiGuid #ALWAYS PRODUCE + gPeiIpmiTransport2PpiGuid + gEfiPeiMemoryDiscoveredPpiGuid #CONSUMES [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..f5a933d35c --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/Pei= IpmiHooks.c @@ -0,0 +1,346 @@ +/** @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) && + ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfa= ceKcs) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState =3D= =3D IpmiInterfaceInitialized))) + { + return PeiIpmiSendCommand ( + &PeiIpmiInstance->IpmiTransportPpi, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + if ((FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) && + ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfa= ceBt) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Bt.InterfaceState =3D= =3D IpmiInterfaceInitialized))) + { + return IpmiBtSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + if ((FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) && + ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfa= ceSsif) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Ssif.InterfaceState = =3D=3D IpmiInterfaceInitialized))) + { + return IpmiSsifSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + if ((FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) && + ((PeiIpmiInstance->IpmiTransport2Ppi.InterfaceType =3D=3D SysInterfa= ceIpmb) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.Ipmb.InterfaceState = =3D=3D IpmiInterfaceInitialized))) + { + return IpmiIpmbSendCommandToBmc ( + &PeiIpmiInstance->IpmiTransport2Ppi, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + 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) && + ((InterfaceType =3D=3D SysInterfaceKcs) && + (PeiIpmiInstance->IpmiTransport2Ppi.Interface.KcsInterfaceState =3D= =3D IpmiInterfaceInitialized))) + { + return PeiIpmiSendCommand ( + &PeiIpmiInstance->IpmiTransportPpi, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + if ((FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) && + ((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 + ); + } + + if ((FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) && + ((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 + ); + } + + if ((FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) && + ((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 + ); + } + + 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= . -=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 (#107247): https://edk2.groups.io/g/devel/message/107247 Mute This Topic: https://groups.io/mt/100352666/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-