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 8BBB7941A13 for ; Tue, 25 Jul 2023 15:37:22 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ERMUv24EbXsGgdT4k81sbQXgvJICVDRF/ERGcNIFIMU=; 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=1690299441; v=1; b=RJq1iae96WeJc2PIBbmaQ3+aiX3q8SBRRRJFdISJzAYWXXcAJHQL4Oa4/80HRoHeols38veX oI1mUeEUHoC4j7DX0uNey+iXhh+AyS8myFRHZVX26pAsqGNwO1YuBv+m/mGvurM/WZGRNj5zQ4R 2PzuY3rgG25J4Tsjja+Df2pk= X-Received: by 127.0.0.2 with SMTP id icTEYY7687511xajCOcyWlmr; Tue, 25 Jul 2023 08:37:21 -0700 X-Received: from NAM02-BN1-obe.outbound.protection.outlook.com (NAM02-BN1-obe.outbound.protection.outlook.com [40.107.212.53]) by mx.groups.io with SMTP id smtpd.web11.23585.1690299440250654783 for ; Tue, 25 Jul 2023 08:37:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TN+qruHEF1yDlxQkveYyAgJjYZeLsIhgWC/OZ2ppguSnPbaKdx04OCKTsyl2z+8FjHxn5j1PWFXS+cewEaiKBxljkjHDbbrhTrIbJAg7UN2M+sMy6+lZMSM2IAd7PeRlyrPOSrFEP3x2n7JoS/dePP2Zs66JT4ILm6ENVuz8Hy2NmUTTCR0AOwm0azaVkhdfrCPW74/yi2Ic/ttGpw9oYwqOEvSO4iZp3IsMUHbdOjP8KvlDyWsdbfAkNZ1Lmq42Hd27BYMORk7IgLEMQdCzSVd+cenO5Ze8VAbJjlcJEoxwrmtkuKYQ7yDqMpAb0QzCqdihgjK+xyJb+Gy3oJ742w== 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=mL7943aRQ+Rm046f5OKZkf2FuFUmPYog94PPlup/8GA=; b=JKJW1Qq5PNQ3P15A5pcuorJFw4HuHkaNYpyodGlB+IPhP2FbCjpGo6S5ZlmmrbE9EaYlofdWdqiiUQser897ZECm+YDD8vDwkhKIKdAwHo+DRFrX0QiZEy4olSyG2k/0tJ7t+Scw6VjbPBsBw59lMTan2eSCB2w/LMZs+IgRs2YUzs/Bu5tR+HAS9WeqzAaN2TAMrdfbBLACG56hMaXf0st5xBvV0seYGJehDS3cBcpH3paeVbFU+VjWltls8qNivngjXpWcMKnu0jo4mDY16oUgBmpNTnWi3xouhZQA7U29ucvhM1jncJkghhFk7EBTliGW45n0cTtS1sf/kNQlVA== 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 IA0PR10MB7325.namprd10.prod.outlook.com (2603:10b6:208:407::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.31; Tue, 25 Jul 2023 15:37:15 +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:37:14 +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-2] IpmiFeaturePkg:Provided multiple IPMI interface support in DXE and SMM Thread-Topic: [edk2-devel][edk2-platforms][PATCH V5-2] IpmiFeaturePkg:Provided multiple IPMI interface support in DXE and SMM Thread-Index: AQHZvw3ivyhCvjex10iV0C1qM8z3XQ== Date: Tue, 25 Jul 2023 15:37:14 +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_|IA0PR10MB7325:EE_ x-ms-office365-filtering-correlation-id: 50045b1f-1226-41dd-4d06-08db8d250586 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: Y9X5us296z7I0Nrfnlh0DmxpFZ09LOmS7rjBsBGqpJ6CD3bKfViTuBeiF6+PWVFX3+EAd4AWoBbqfgkhWtxARdHGKZ+Bc9L0vbu4yOezomyc6y83n2SXkXs26Llr+ZGmeqjeQbVwYayC+4n1k2HBslIp5tnY6H45D4arJefxSWqp1RE0T/4gRvUMVFCU6n8shgR5KeahCdpSHl+PGJmjSGqvWfCbrXxiRACiZMveS9vgHkKVQMroe4hdmwPrKEvLELoQ0oIhdTfA/Hmy3mo7P0QVh6QVz+EDreSA/veswCoqeEjeblJt65KApsgIXPokhzP1pSOKaTy4BToMLrXnovZnvo1LY0PGMfbj0r7AJOvVXlMxapxqFpPUKUKghSx+R9n9PJ6iAyFe4z8YGPQ9FwvvxA7sQUOutjsf1W6XarQzHqRRfp7TBUMvU/0gu57gtkj9RGU4cAyqSR++eb5KKDbhiXdilP2RyV5Z9i6jUJ3/FsrOnap3O9biD+p126hlyYVCoI8V27bqNzHAm73m9vS0xzMXDQS1gf1b4ECxtp/v/AqkXdWvZ2g3g0ivzGkC4W8/Kup0b01y4clqRaqsx0bOlFBL32osg67xm0T9Bb1BKONUGRqFJL+5OSgAIrMb x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?V+ohxPUwTJyRZYhXi4JQyyxnYwlOntFhrjhiqCo87ivQvLdIbOsZL/cKbR?= =?iso-8859-1?Q?xMVOH51pdWEsCJqEN/Y1jh1K/8PNlJIciJDHKEtICY3XngrhsKHEQKo74B?= =?iso-8859-1?Q?I1IXv1ecI9UJV3c9qA+NIoL/mACzb7a5ZaKVPa81gfHQZsFMJuPFEOtSSL?= =?iso-8859-1?Q?ruJMLUaSmIMsG4ZLnE4cV0xFt6q9PXU4RIoS7FP/+tT6U1cB5pn2LrbG1a?= =?iso-8859-1?Q?a0nPFDvR665BcpvBukQ8j1lg1LVnEtI/YkwCFQtorovOofpcz9Nec9jcuk?= =?iso-8859-1?Q?UOnAOPbf5fic/Kp0CTj/jzCos8JUluS+SdwBwGl6orCTpZZ85OQkbgdr6G?= =?iso-8859-1?Q?HF0Ca/BMvpMOs4duSnxPS7i6Q57Nt1Fh0pvChpk4vheXKV9ZE/0kMjptp9?= =?iso-8859-1?Q?v/xRe+jPrOUCQQpUr138vDASJWr5kYv3kNw76cviDTw/FnsFPyHEpfeESd?= =?iso-8859-1?Q?VnDs73fqkzlsOnpxC6Yef/k5a1Qg4/6JE4I/jCK6hcTGqGShSYBXkcZeqf?= =?iso-8859-1?Q?FD1u2xd+bixxCekgQsmUY7y0AtkzA1CQabvGOK15bjH/V39Yl9KrI/8boP?= =?iso-8859-1?Q?+VJeuVxjxQR3gk+FV48G4Kq3n3rHMV9jjIRFnT09x+6DeEwNF6TlF2Yod/?= =?iso-8859-1?Q?bNxU91TofDVIm1dTvZ0UfOjZCXtdqxXvYWZbrww7QHZcrJTUka4/kBPbsD?= =?iso-8859-1?Q?RGAj/eYYFudmhm1LrE6CGDJH4f4ZD9r7uN6QPdFlHbv4tQ+7M+vzpslIp8?= =?iso-8859-1?Q?upZfvqpe/HvMMN9OlAehCFSS3eu04bkCHzyaPbfzZa+xe85mVg8m9DWlUC?= =?iso-8859-1?Q?zCZLWF8khlco77UgHJS5zl9A8ClyoNIc4QDORIOqN56oN9ODAievx7VDe/?= =?iso-8859-1?Q?AtP+U2fVYFYifj6JPfcJjGsflCYTKBZTnyjEZeyGsDXh02g0r81kIAZxkU?= =?iso-8859-1?Q?PEmaxfPBOnDn74wQ6yoykVQVXPYHMwRJTeWrqPBboeaQfBvnmZILuRb9bf?= =?iso-8859-1?Q?Pp6wkcAvocaX6uF0GhR388Epy+APBmvEnZNmCAlfxtr68+dByJtOnGizu3?= =?iso-8859-1?Q?9fRQ7yLTajc1e2FHk6uqz00mel4fG+N4u45c//Zpfsa08BwM9L9p3lju/H?= =?iso-8859-1?Q?FV4yLC//JLADn3wHGZXLsivj4X/xw8Uu6Z5KJUq9GLDV1pWhf3fPzh8UBl?= =?iso-8859-1?Q?RQPAQTvlAPCbLAFmx8yn9vX63Hj/Hidjy4HSCFurLTazxX1q1QeXF+R/rt?= =?iso-8859-1?Q?MPIzHhZhtjYn44QkkhSBr3SPVdyVGMSEVK9Tii54YJqiMLjSf7hasoD1sC?= =?iso-8859-1?Q?SVqQa/sUtwTPNDkn3CBkloqfCBMHDNF1SGsnG9lJIzLlnDokqbkNQPHojW?= =?iso-8859-1?Q?erB9MQ3nJtbW2aqTwOvs0RJVcpIC7xkEAJXypq7KAyuyL881I75tTtmdkj?= =?iso-8859-1?Q?S68D9fyx/op2fyB8f09e2nrjlzYubyQZqRlLsFIcPWLMygVDKr2kOFetv+?= =?iso-8859-1?Q?hhIzKlMbU1dPlH8+3WgPDcfXFSy+T1iQNkVaMjmKcVxf2N5fQgfuPPMDmM?= =?iso-8859-1?Q?zyTFnaYh3nDYRyLkp4sA3Rn0ucLtb1Z+WBd2EwsRzbI2p73wk9iD5ZwQW6?= =?iso-8859-1?Q?EPxeXOpcbXEnNNYoIPBeAW796iqD9Otgac?= 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: 50045b1f-1226-41dd-4d06-08db8d250586 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2023 15:37:14.8556 (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: cSq1aSAoFcoiXkRLdZ9K4NbHX1teecdO7FeQCcm9NKaxmcASOdIkaFq8RgLjbvqi X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB7325 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: PhkMVejw8wguGGqQaUkexKLax7686176AA= 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=RJq1iae9; 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 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/Common/IpmiBmc.h | 13 +- .../GenericIpmi/Common/IpmiBmcCommon.h | 82 +-- .../GenericIpmi/Common/IpmiHooks.c | 298 ++++++++++- .../GenericIpmi/Common/IpmiHooks.h | 119 ++++- .../GenericIpmi/Dxe/GenericIpmi.inf | 14 +- .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c | 505 +++++++++++++----- .../GenericIpmi/Smm/SmmGenericIpmi.c | 351 +++++++++--- .../GenericIpmi/Smm/SmmGenericIpmi.inf | 12 + 8 files changed, 1117 insertions(+), 277 deletions(-) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiBmc.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Generi= cIpmi/Common/IpmiBmc.h index d306a085e5..76ee988623 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmc.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmc.h @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -21,17 +22,17 @@ #include #include #include +#include #include "IpmiBmcCommon.h" #include "KcsBmc.h" - #define BMC_KCS_TIMEOUT 5 // [s] Single KSC request timeout // // 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 IPMI_SEND_COMMAND_MAX_RETRY 3 // Number of retries #define INSTANCE_FROM_SM_IPMI_BMC_THIS(a) \ CR ( \ @@ -41,4 +42,12 @@ SM_IPMI_BMC_SIGNATURE \ ) +#define INSTANCE_FROM_IPMI_TRANSPORT2_THIS(a) \ + CR ( \ + a, \ + IPMI_BMC_INSTANCE_DATA, \ + IpmiTransport2, \ + SM_IPMI_BMC_SIGNATURE \ + ) + #endif // _IPMI_BMC_H_ diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiBmcCommon.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= GenericIpmi/Common/IpmiBmcCommon.h index 06eab62aae..faf6cc6685 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmcCommon.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiBmcCommon.h @@ -3,16 +3,17 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _IPMI_COMMON_BMC_H_ #define _IPMI_COMMON_BMC_H_ -#define MAX_TEMP_DATA 255 // 160 Modified to increase number of bytes = transfered per command -#define BMC_SLAVE_ADDRESS 0x20 -#define MAX_SOFT_COUNT 10 -#define COMP_CODE_NORMAL 0x00 +#define MAX_TEMP_DATA 255// 160 Modified to increase number of bytes = transfered per command +#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. @@ -33,8 +34,8 @@ // D4h C Insufficient privilege, in KCS channel this indicates KCS Policy = Control Mode is Deny All. // In authenticated channels this indicates invalid authentication/privile= ge. // -#define COMP_INSUFFICIENT_PRIVILEGE 0xD4 -#define COMP_CODE_UNSPECIFIED 0xFF +#define COMP_INSUFFICIENT_PRIVILEGE 0xD4 +#define COMP_CODE_UNSPECIFIED 0xFF #define COMPLETION_CODES \ { \ @@ -47,15 +48,16 @@ // Dxe Ipmi instance data // typedef struct { - UINTN Signature; - UINT64 KcsTimeoutPeriod; - UINT8 SlaveAddress; - BMC_STATUS BmcStatus; - UINT64 ErrorStatus; - UINT8 SoftErrorCount; - UINT16 IpmiIoBase; - IPMI_TRANSPORT IpmiTransport; - EFI_HANDLE IpmiSmmHandle; + UINTN Signature; + UINT64 KcsTimeoutPeriod; + UINT8 SlaveAddress; + BMC_STATUS BmcStatus; + UINT64 ErrorStatus; + UINT8 SoftErrorCount; + UINT16 IpmiIoBase; + IPMI_TRANSPORT IpmiTransport; + IPMI_TRANSPORT2 IpmiTransport2; + EFI_HANDLE IpmiSmmHandle; } IPMI_BMC_INSTANCE_DATA; // @@ -64,38 +66,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; EFI_STATUS EFIAPI IpmiSendCommandToBmc ( - IN IPMI_TRANSPORT *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 IPMI_TRANSPORT *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: @@ -124,15 +127,15 @@ Returns: --*/ ; - EFI_STATUS EFIAPI IpmiBmcStatus ( - IN IPMI_TRANSPORT *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress, - IN VOID *Context + IN IPMI_TRANSPORT *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress, + IN VOID *Context ) + /*++ Routine Description: @@ -157,6 +160,7 @@ VOID GetDeviceSpecificTestResults ( IN IPMI_BMC_INSTANCE_DATA *IpmiInstance ) + /*++ Routine Description: diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiHooks.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Common/IpmiHooks.c index b2788e5a4c..57577b1b35 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.c @@ -3,6 +3,7 @@ @copyright Copyright 2014 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -11,15 +12,16 @@ EFI_STATUS EFIAPI IpmiSendCommand ( - IN IPMI_TRANSPORT *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 IPMI_TRANSPORT *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: @@ -48,29 +50,269 @@ Returns: --*/ { + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + // // This Will be unchanged ( BMC/KCS style ) // return IpmiSendCommandToBmc ( - This, - NetFunction, - Lun, - Command, - CommandData, - (UINT8) CommandDataSize, - ResponseData, - (UINT8*) ResponseDataSize, - NULL - ); + This, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); } // IpmiSendCommand() +EFI_STATUS +EFIAPI +IpmiSendCommand2 ( + 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 + +--*/ +{ + IPMI_BMC_INSTANCE_DATA *IpmiInstance; + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + IpmiInstance =3D INSTANCE_FROM_IPMI_TRANSPORT2_THIS (This); + + if ((FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) && + ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceKcs)= && + (IpmiInstance->IpmiTransport2.Interface.KcsInterfaceState =3D=3D Ip= miInterfaceInitialized))) + { + return IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + if ((FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) && + ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceBt) = && + (IpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState =3D=3D Ip= miInterfaceInitialized))) + { + return IpmiBtSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + if ((FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) && + ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceSsif= ) && + (IpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D = IpmiInterfaceInitialized))) + { + return IpmiSsifSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + if ((FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) && + ((IpmiInstance->IpmiTransport2.InterfaceType =3D=3D SysInterfaceIpmb= ) && + (IpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D = IpmiInterfaceInitialized))) + { + return IpmiIpmbSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + return EFI_UNSUPPORTED; +} // IpmiSendCommand2() + +EFI_STATUS +EFIAPI +IpmiSendCommand2Ex ( + 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 + + --*/ + + IPMI_BMC_INSTANCE_DATA *IpmiInstance; + + if (This =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + IpmiInstance =3D INSTANCE_FROM_IPMI_TRANSPORT2_THIS (This); + + if ((FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) && + ((InterfaceType =3D=3D SysInterfaceKcs) && (IpmiInstance->IpmiTransp= ort2.Interface.KcsInterfaceState =3D=3D IpmiInterfaceInitialized))) + { + return IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + NetFunction, + Lun, + Command, + CommandData, + CommandDataSize, + ResponseData, + ResponseDataSize + ); + } + + if ((FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) && + ((InterfaceType =3D=3D SysInterfaceBt) && (IpmiInstance->IpmiTranspo= rt2.Interface.Bt.InterfaceState =3D=3D IpmiInterfaceInitialized))) + { + return IpmiBtSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + if ((FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) && + ((InterfaceType =3D=3D SysInterfaceSsif) && (IpmiInstance->IpmiTrans= port2.Interface.Ssif.InterfaceState =3D=3D IpmiInterfaceInitialized))) + { + return IpmiSsifSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + if ((FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) && + ((InterfaceType =3D=3D SysInterfaceIpmb) && (IpmiInstance->IpmiTrans= port2.Interface.Ipmb.InterfaceState =3D=3D IpmiInterfaceInitialized))) + { + return IpmiIpmbSendCommandToBmc ( + &IpmiInstance->IpmiTransport2, + NetFunction, + Lun, + Command, + CommandData, + (UINT8)CommandDataSize, + ResponseData, + (UINT8 *)ResponseDataSize, + NULL + ); + } + + return EFI_UNSUPPORTED; +} + EFI_STATUS EFIAPI IpmiGetBmcStatus ( - IN IPMI_TRANSPORT *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress + IN IPMI_TRANSPORT *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress ) + /*++ Routine Description: @@ -89,10 +331,14 @@ Returns: --*/ { + if ((This =3D=3D NULL) || (BmcStatus =3D=3D NULL) || (ComAddress =3D=3D = NULL)) { + return EFI_INVALID_PARAMETER; + } + return IpmiBmcStatus ( - This, - BmcStatus, - ComAddress, - NULL - ); + This, + BmcStatus, + ComAddress, + NULL + ); } diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Common/IpmiHooks.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gene= ricIpmi/Common/IpmiHooks.h index 823cc08c61..a3985588c3 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.h +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Common/= IpmiHooks.h @@ -3,13 +3,21 @@ @copyright Copyright 2014 - 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 "IpmiBmc.h" +#include +#include +#include +#include +#include +#include +#include +#include // // Internal(hook) function list @@ -17,15 +25,16 @@ EFI_STATUS EFIAPI IpmiSendCommand ( - IN IPMI_TRANSPORT *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 IPMI_TRANSPORT *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: @@ -54,13 +63,99 @@ Returns: --*/ ; +EFI_STATUS +EFIAPI +IpmiSendCommand2 ( + 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 +EFIAPI +IpmiSendCommand2Ex ( + 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 + +--*/ +; + EFI_STATUS EFIAPI IpmiGetBmcStatus ( - IN IPMI_TRANSPORT *This, - OUT BMC_STATUS *BmcStatus, - OUT SM_COM_ADDRESS *ComAddress + IN IPMI_TRANSPORT *This, + OUT BMC_STATUS *BmcStatus, + OUT SM_COM_ADDRESS *ComAddress ) + /*++ Routine Description: diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Dxe/GenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Gen= ericIpmi/Dxe/GenericIpmi.inf index 8d80aeb6b5..1564ceb08a 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Gen= ericIpmi.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Gen= ericIpmi.inf @@ -3,6 +3,7 @@ # # @copyright # Copyright 2010 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -49,16 +50,25 @@ IoLib ReportStatusCodeLib TimerLib + BmcCommonInterfaceLib + BtInterfaceLib + SsifInterfaceLib + IpmbInterfaceLib [Protocols] gIpmiTransportProtocolGuid # PROTOCOL ALWAYS_PRODUCED gEfiVideoPrintProtocolGuid - -[Guids] + gIpmiTransport2ProtocolGuid [Pcd] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiIoBaseAddress gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort [Depex] gEfiRuntimeArchProtocolGuid AND diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Dxe/IpmiInit.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericI= pmi/Dxe/IpmiInit.c index c333ca2e06..d836e36b4e 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Ipm= iInit.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/Ipm= iInit.c @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -13,25 +14,26 @@ #include "IpmiBmc.h" #include "IpmiPhysicalLayer.h" #include +#include #ifdef FAST_VIDEO_SUPPORT #include #endif #include - /*************************************************************************= ***** * Local variables */ -IPMI_BMC_INSTANCE_DATA *mIpmiInstance =3D NULL; -EFI_HANDLE mImageHandle; +IPMI_BMC_INSTANCE_DATA *mIpmiInstance =3D NULL; +EFI_HANDLE mImageHandle; // // Specific test interface // VOID GetDeviceSpecificTestResults ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance ) + /*++ Routine Description: @@ -54,10 +56,11 @@ Returns: EFI_STATUS GetSelfTest ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, - IN EFI_STATUS_CODE_VALUE StatusCodeValue[], - IN OUT UINT8 *ErrorCount + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, + IN EFI_STATUS_CODE_VALUE StatusCodeValue[], + IN OUT UINT8 *ErrorCount ) + /*++ Routine Description: @@ -86,13 +89,13 @@ Returns: BOOLEAN bResultFlag =3D FALSE; UINT8 TempData[MAX_TEMP_DATA]; - IPMI_SELF_TEST_RESULT_RESPONSE *SelfTestResult; + IPMI_SELF_TEST_RESULT_RESPONSE *SelfTestResult; // // Get the SELF TEST Results. // // - //Note: If BMC PcdIpmiBmcReadyDelayTimer < BMC_KCS_TIMEOUT, it need set = Retries as 1. Otherwise it will make SELT failure, caused by below conditio= n (EFI_ERROR(Status) || Retries =3D=3D 0) + // Note: If BMC PcdIpmiBmcReadyDelayTimer < BMC_KCS_TIMEOUT, it need set= Retries as 1. Otherwise it will make SELT failure, caused by below conditi= on (EFI_ERROR(Status) || Retries =3D=3D 0) // if (PcdGet8 (PcdIpmiBmcReadyDelayTimer) < BMC_KCS_TIMEOUT) { Retries =3D 1; @@ -102,20 +105,20 @@ Returns: DataSize =3D sizeof (TempData); - SelfTestResult =3D (IPMI_SELF_TEST_RESULT_RESPONSE *) &TempData[0]; + SelfTestResult =3D (IPMI_SELF_TEST_RESULT_RESPONSE *)&TempData[0= ]; SelfTestResult->Result =3D 0; do { Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, - 0, - IPMI_APP_GET_SELFTEST_RESULTS, - NULL, - 0, - TempData, - &DataSize - ); + &IpmiInstance->IpmiTransport, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_SELFTEST_RESULTS, + NULL, + 0, + TempData, + &DataSize + ); if (Status =3D=3D EFI_SUCCESS) { switch (SelfTestResult->Result) { case IPMI_APP_SELFTEST_NO_ERROR: @@ -127,7 +130,7 @@ Returns: default: break; - } //switch + } // switch if (bResultFlag) { break; @@ -140,7 +143,7 @@ Returns: // // If Status indicates a Device error, then the BMC is not responding, s= o send an error. // - if (EFI_ERROR (Status) || Retries =3D=3D 0) { + if (EFI_ERROR (Status) || (Retries =3D=3D 0)) { DEBUG ((EFI_D_ERROR, "\n[IPMI] BMC self-test does not respond (status= : %r)!\n\n", Status)); if (*ErrorCount < MAX_SOFT_COUNT) { StatusCodeValue[*ErrorCount] =3D EFI_COMPUTING_UNIT_FIRMWARE_PROCESS= OR | EFI_CU_FP_EC_COMM_ERROR; @@ -155,12 +158,14 @@ Returns: // Copy the Self test results to Error Status. Data will be copied as= long as it // does not exceed the size of the ErrorStatus variable. // - for (Index =3D 0, TempPtr =3D (UINT8 *) &IpmiInstance->ErrorStatus; + for (Index =3D 0, TempPtr =3D (UINT8 *)&IpmiInstance->ErrorStatus; (Index < DataSize) && (Index < sizeof (IpmiInstance->ErrorStatus)= ); Index++, TempPtr++ - ) { + ) + { *TempPtr =3D TempData[Index]; } + // // Check the IPMI defined self test results. // Additional Cases are device specific test results. @@ -182,6 +187,7 @@ Returns: } else { IpmiInstance->BmcStatus =3D BMC_SOFTFAIL; } + // // Check if SDR repository is empty and report it if it is. // @@ -191,6 +197,7 @@ Returns: (*ErrorCount)++; } } + break; case IPMI_APP_SELFTEST_FATAL_HW_ERROR: @@ -221,13 +228,13 @@ Returns: return EFI_SUCCESS; } // GetSelfTest() - EFI_STATUS GetDeviceId ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, - IN EFI_STATUS_CODE_VALUE StatusCodeValue[ ], - IN OUT UINT8 *ErrorCount + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, + IN EFI_STATUS_CODE_VALUE StatusCodeValue[], + IN OUT UINT8 *ErrorCount ) + /*++ Routine Description: @@ -244,25 +251,25 @@ Returns: --*/ { - EFI_STATUS Status; - UINT32 DataSize; - SM_CTRL_INFO *pBmcInfo; - IPMI_MSG_GET_BMC_EXEC_RSP *pBmcExecContext; - UINT32 Retries; - UINT8 TempData[MAX_TEMP_DATA]; - -#ifdef FAST_VIDEO_SUPPORT - EFI_VIDEOPRINT_PROTOCOL *VideoPrintProtocol; - EFI_STATUS VideoPrintStatus; -#endif - -#ifdef FAST_VIDEO_SUPPORT + EFI_STATUS Status; + UINT32 DataSize; + SM_CTRL_INFO *pBmcInfo; + IPMI_MSG_GET_BMC_EXEC_RSP *pBmcExecContext; + UINT32 Retries; + UINT8 TempData[MAX_TEMP_DATA]; + + #ifdef FAST_VIDEO_SUPPORT + EFI_VIDEOPRINT_PROTOCOL *VideoPrintProtocol; + EFI_STATUS VideoPrintStatus; + #endif + + #ifdef FAST_VIDEO_SUPPORT VideoPrintStatus =3D gBS->LocateProtocol ( - &gEfiVideoPrintProtocolGuid, - NULL, - &VideoPrintProtocol - ); -#endif + &gEfiVideoPrintProtocolGuid, + NULL, + &VideoPrintProtocol + ); + #endif // // Set up a loop to retry for up to PcdIpmiBmcReadyDelayTimer seconds. C= alculate retries not timeout @@ -274,28 +281,38 @@ Returns: // Get the device ID information for the BMC. // DataSize =3D sizeof (TempData); - while (EFI_ERROR (Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, 0, - IPMI_APP_GET_DEVICE_ID, - NULL, 0, - TempData, &DataSize)) - ) { - DEBUG ((DEBUG_ERROR, "[IPMI] BMC does not respond by Get BMC DID (stat= us: %r), %d retries left, ResponseData: 0x%lx\n", - Status, Retries, TempData)); + while (EFI_ERROR ( + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport= , + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ) + ) + ) + { + DEBUG ( + (DEBUG_ERROR, "[IPMI] BMC does not respond by Get BMC DID (stat= us: %r), %d retries left, ResponseData: 0x%lx\n", + Status, Retries, TempData) + ); if (Retries-- =3D=3D 0) { IpmiInstance->BmcStatus =3D BMC_HARDFAIL; return Status; } + // - //Handle the case that BMC FW still not enable KCS channel after AC cy= cle. just stall 1 second + // 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 ((EFI_D_ERROR, "[IPMI] BMC Device ID: 0x%02X, firmware version: %d= .%02X UpdateMode:%x\n", pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBm= cInfo->MinorFirmwareRev,pBmcInfo->UpdateMode)); + pBmcInfo =3D (SM_CTRL_INFO *)&TempData[0]; + DEBUG ((EFI_D_ERROR, "[IPMI] BMC Device ID: 0x%02X, firmware version: %d= .%02X UpdateMode:%x\n", pBmcInfo->DeviceId, pBmcInfo->MajorFirmwareRev, pBm= cInfo->MinorFirmwareRev, 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. @@ -306,18 +323,22 @@ Returns: return EFI_SUCCESS; } else { DataSize =3D sizeof (TempData); - Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_FIRMWARE, 0, - IPMI_GET_BMC_EXECUTION_CONTEXT, - NULL, 0, - TempData, &DataSize - ); - - pBmcExecContext =3D (IPMI_MSG_GET_BMC_EXEC_RSP*)&TempData[0]; + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + IPMI_NETFN_FIRMWARE, + 0, + IPMI_GET_BMC_EXECUTION_CONTEXT, + NULL, + 0, + TempData, + &DataSize + ); + + pBmcExecContext =3D (IPMI_MSG_GET_BMC_EXEC_RSP *)&TempData[0]; DEBUG ((DEBUG_INFO, "[IPMI] Operational status of BMC: 0x%x\n", pBmcEx= ecContext->CurrentExecutionContext)); if ((pBmcExecContext->CurrentExecutionContext =3D=3D IPMI_BMC_IN_FORCE= D_UPDATE_MODE) && - !EFI_ERROR (Status)) { + !EFI_ERROR (Status)) + { DEBUG ((DEBUG_ERROR, "[IPMI] BMC in Forced Update mode, skip waiting= for BMC_READY.\n")); IpmiInstance->BmcStatus =3D BMC_UPDATE_IN_PROGRESS; } else { @@ -325,32 +346,174 @@ Returns: // Updatemode =3D 1 mean BMC is not ready, continue waiting. // while (Retries-- !=3D 0) { - MicroSecondDelay(1*1000*1000); //delay 1 seconds - DEBUG ((EFI_D_ERROR, "[IPMI] UpdateMode Retries: %d \n",Retries)); + MicroSecondDelay (1*1000*1000); // delay 1 seconds + DEBUG ((EFI_D_ERROR, "[IPMI] UpdateMode Retries: %d \n", Retries))= ; DataSize =3D sizeof (TempData); - Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, 0, - IPMI_APP_GET_DEVICE_ID, - NULL, 0, - TempData, &DataSize - ); + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ); if (!EFI_ERROR (Status)) { - pBmcInfo =3D (SM_CTRL_INFO*)&TempData[0]; - DEBUG ((DEBUG_ERROR, "[IPMI] UpdateMode Retries: %d pBmcInfo->= UpdateMode:%x, Status: %r, Response Data: 0x%lx\n",Retries, pBmcInfo->Updat= eMode, Status, TempData)); + pBmcInfo =3D (SM_CTRL_INFO *)&TempData[0]; + DEBUG ((DEBUG_ERROR, "[IPMI] UpdateMode Retries: %d pBmcInfo->= UpdateMode:%x, Status: %r, Response Data: 0x%lx\n", Retries, pBmcInfo->Upda= teMode, Status, TempData)); if (pBmcInfo->UpdateMode =3D=3D BMC_READY) { mIpmiInstance->BmcStatus =3D BMC_OK; return EFI_SUCCESS; } } } + mIpmiInstance->BmcStatus =3D BMC_HARDFAIL; } } + return Status; } // GetDeviceId() +/*++ + +Routine Description: + Initialize the API and parameters for IPMI Transport2 Instance + +Arguments: + IpmiInstance - Pointer to IPMI Instance. + +Returns: + VOID + +--*/ +VOID +InitIpmiTransport2 ( + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance + ) +{ + IpmiInstance->IpmiTransport2.InterfaceType =3D FixedPcdGet8 (P= cdDefaultSystemInterface); + IpmiInstance->IpmiTransport2.IpmiTransport2BmcStatus =3D BmcStatusOk; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2 =3D IpmiSendCommand= 2; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2Ex =3D IpmiSendCommand= 2Ex; + + if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) { + InitBtInterfaceData (&IpmiInstance->IpmiTransport2); + } + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2); + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2); + } +} + +/*++ + +Routine Description: + Notify call back function. + +Arguments: + Event - Event which caused this handler. + Context - Context passed during Event Handler registration. + +Returns: + VOID + +--*/ +VOID +EFIAPI +DxeNotifyCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + IPMI_INTERFACE_STATE InterfaceState; + EFI_HANDLE Handle; + + InterfaceState =3D IpmiInterfaceNotReady; + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + InitSsifInterfaceData (&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D= IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + InitIpmbInterfaceData (&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.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; + } + + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); + ASSERT_EFI_ERROR (Status); +} + +/*++ + +Routine Description: + Registers protocol notify call back. + +Arguments: + ProtocolGuid - Pointer to Protocol Guid to register call back. + +Returns: + Status + +--*/ +EFI_STATUS +DxeRegisterProtocolCallback ( + IN EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + EFI_EVENT NotifyEvent; + VOID *Registration; + + if ((ProtocolGuid =3D=3D NULL) || + ((ProtocolGuid !=3D NULL) && IsZeroBuffer (ProtocolGuid, sizeof (EFI= _GUID)))) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + DxeNotifyCallback, + NULL, + &NotifyEvent + ); + + if (!EFI_ERROR (Status)) { + Status =3D gBS->RegisterProtocolNotify ( + ProtocolGuid, + NotifyEvent, + &Registration + ); + } + + return Status; +} /** This function initializes KCS interface to BMC. @@ -368,18 +531,20 @@ Returns: **/ EFI_STATUS InitializeIpmiKcsPhysicalLayer ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; UINT8 ErrorCount; EFI_HANDLE Handle; UINT8 Index; + IPMI_INTERFACE_STATE InterfaceState =3D IpmiInterfaceNotReady; EFI_STATUS_CODE_VALUE StatusCodeValue[MAX_SOFT_COUNT]; - ErrorCount =3D 0; + ErrorCount =3D 0; mImageHandle =3D ImageHandle; + ZeroMem (StatusCodeValue, MAX_SOFT_COUNT); mIpmiInstance =3D AllocateZeroPool (sizeof (*mIpmiInstance)); if (mIpmiInstance =3D=3D NULL) { @@ -396,66 +561,150 @@ InitializeIpmiKcsPhysicalLayer ( // Initialize the KCS transaction timeout. // mIpmiInstance->KcsTimeoutPeriod =3D (BMC_KCS_TIMEOUT * 1000*1000) / KC= S_DELAY_UNIT; - DEBUG ((EFI_D_ERROR, "[IPMI] mIpmiInstance->KcsTimeoutPeriod: 0x%lx\n"= ,mIpmiInstance->KcsTimeoutPeriod)); + DEBUG ((EFI_D_ERROR, "[IPMI] mIpmiInstance->KcsTimeoutPeriod: 0x%lx\n"= , mIpmiInstance->KcsTimeoutPeriod)); // // Initialize IPMI IO Base. // - mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiI= oBaseAddress); - mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNAT= URE; - mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; - mIpmiInstance->BmcStatus =3D BMC_NOTREADY; - mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; - mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; + mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiIoBaseAddress); + mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNATURE; + mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; + mIpmiInstance->BmcStatus =3D BMC_NOTREADY; + + if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) { + mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; + mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; - // - // Get the Device ID and check if the system is in Force Update mode. - // - Status =3D GetDeviceId ( - mIpmiInstance, - StatusCodeValue, - &ErrorCount - ); - // - // Do not continue initialization if the BMC is in Force Update Mode. - // - if ((mIpmiInstance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS) && - (mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL)) { // - // Get the SELF TEST Results. + // Get the Device ID and check if the system is in Force Update mode= . // - Status =3D GetSelfTest ( - mIpmiInstance, - StatusCodeValue, - &ErrorCount - ); + Status =3D GetDeviceId ( + mIpmiInstance, + StatusCodeValue, + &ErrorCount + ); + // + // Do not continue initialization if the BMC is in Force Update Mode= . + // + if ((mIpmiInstance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS) && + (mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL)) + { + // + // Get the SELF TEST Results. + // + Status =3D GetSelfTest ( + mIpmiInstance, + StatusCodeValue, + &ErrorCount + ); + } + + // + // iterate through the errors reporting them to the error manager. + // + for (Index =3D 0; Index < ErrorCount; Index++) { + ReportStatusCode ( + EFI_ERROR_CODE | EFI_ERROR_MAJOR, + StatusCodeValue[Index] + ); + } + + // + // Now install the Protocol if the BMC is not in a HardFail State an= d not in Force Update mode + // + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiInstance->= BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gIpmiTransportProtocolGui= d, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransp= ort + ); + ASSERT_EFI_ERROR (Status); + } } - // - // iterate through the errors reporting them to the error manager. - // - for (Index =3D 0; Index < ErrorCount; Index++) { - ReportStatusCode ( - EFI_ERROR_CODE | EFI_ERROR_MAJOR, - StatusCodeValue[Index] - ); + // Initialise the IPMI transport2 + InitIpmiTransport2 (mIpmiInstance); + + // Check interface data initialized successfully else register notify = protocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + switch (Index) { + if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) { + case SysInterfaceKcs: + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiInst= ance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = =3D IpmiInterfaceInitialized; + Status = =3D CheckSelfTestByInterfaceType ( + = &mIpmiInstance->IpmiTransport2, + = &BmcStatus, + = SysInterfaceKcs + = ); + if (!EFI_ERROR (Status) && (BmcStatus !=3D BmcStatusHardFail= )) { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = =3D IpmiInterfaceInitError; + } + } + + break; + } + + if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) { + case SysInterfaceBt: + if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + break; + } + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + case SysInterfaceSsif: + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceStat= e =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.Interf= aceState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D DxeRegisterProtocolCallback ( + &mIpmiInstance->IpmiTr= ansport2.Interface.Ssif.SsifInterfaceApiGuid + ); + } + + break; + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + case SysInterfaceIpmb: + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceStat= e =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.Interf= aceState =3D=3D IpmiInterfaceInitError) { + // Register Protocol notify for I2C Protocol. + Status =3D DxeRegisterProtocolCallback ( + &mIpmiInstance->IpmiTr= ansport2.Interface.Ipmb.IpmbInterfaceApiGuid + ); + } + + break; + } + + default: + break; + } } - // - // Now install the Protocol if the BMC is not in a HardFail State and = not in Force Update mode - // - if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiInstance->Bm= cStatus !=3D BMC_UPDATE_IN_PROGRESS)) { - Handle =3D NULL; - Status =3D gBS->InstallProtocolInterface ( - &Handle, - &gIpmiTransportProtocolGuid, - EFI_NATIVE_INTERFACE, - &mIpmiInstance->IpmiTransport - ); - ASSERT_EFI_ERROR (Status); + // Any one of the Interface data should be initialized to install IPMI= Transport2 Protocol. + if (InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_SUCCESS; } + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); + ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; } } // InitializeIpmiKcsPhysicalLayer() - diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Smm/SmmGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Ge= nericIpmi/Smm/SmmGenericIpmi.c index 1af2d18f79..350bc74003 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.c @@ -3,6 +3,7 @@ @copyright Copyright 1999 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -24,17 +25,18 @@ #include "IpmiBmcCommon.h" #include "IpmiBmc.h" #include +#include -IPMI_BMC_INSTANCE_DATA *mIpmiInstance; -EFI_HANDLE mImageHandle; - +IPMI_BMC_INSTANCE_DATA *mIpmiInstance; +EFI_HANDLE mImageHandle; EFI_STATUS GetDeviceId ( - IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, - IN EFI_STATUS_CODE_VALUE StatusCodeValue[ ], - IN OUT UINT8 *ErrorCount + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance, + IN EFI_STATUS_CODE_VALUE StatusCodeValue[], + IN OUT UINT8 *ErrorCount ) + /*++ Routine Description: @@ -51,12 +53,12 @@ Returns: --*/ { - EFI_STATUS Status; - UINT32 DataSize; - SM_CTRL_INFO *ControllerInfo; - UINT8 TimeOut; - UINT8 Retries; - UINT8 TempData[MAX_TEMP_DATA]; + EFI_STATUS Status; + UINT32 DataSize; + SM_CTRL_INFO *ControllerInfo; + UINT8 TimeOut; + UINT8 Retries; + UINT8 TempData[MAX_TEMP_DATA]; TimeOut =3D 0; Retries =3D PcdGet8 (PcdIpmiBmcReadyDelayTimer); @@ -66,16 +68,16 @@ Returns: // Get the device ID information for the BMC. // DataSize =3D MAX_TEMP_DATA; - Status =3D IpmiSendCommand ( - &IpmiInstance->IpmiTransport, - IPMI_NETFN_APP, - 0, - IPMI_APP_GET_DEVICE_ID, - NULL, - 0, - TempData, - &DataSize - ); + Status =3D IpmiSendCommand ( + &IpmiInstance->IpmiTransport, + IPMI_NETFN_APP, + 0, + IPMI_APP_GET_DEVICE_ID, + NULL, + 0, + TempData, + &DataSize + ); if (Status =3D=3D EFI_SUCCESS) { DEBUG ((EFI_D_INFO, "IPMI: SendCommand success!\n")); break; @@ -84,10 +86,10 @@ Returns: // Display message and retry. // DEBUG ( - (EFI_D_ERROR | EFI_D_INFO, - "IPMI: Waiting for BMC (KCS 0x%x)...\n", - IpmiInstance->IpmiIoBase) - ); + (EFI_D_ERROR | EFI_D_INFO, + "IPMI: Waiting for BMC (KCS 0x%x)...\n", + IpmiInstance->IpmiIoBase) + ); MicroSecondDelay (500 * 1000); TimeOut++; } @@ -97,7 +99,7 @@ Returns: // If there is no error then proceed to check the data returned by the B= MC // if (!EFI_ERROR (Status)) { - ControllerInfo =3D (SM_CTRL_INFO *) TempData; + ControllerInfo =3D (SM_CTRL_INFO *)TempData; // // If the controller is in Update Mode and the maximum number of error= s has not been exceeded, then // save the error code to the StatusCode array and increment the count= er. Set the BMC Status to indicate @@ -115,11 +117,143 @@ Returns: return Status; } +/*++ + +Routine Description: + Initialize the API and parameters for IPMI Transport2 Instance + +Arguments: + IpmiInstance - Pointer to IPMI Instance. + +Returns: + VOID - Nothing. + +--*/ +VOID +InitIpmiTransport2 ( + IN IPMI_BMC_INSTANCE_DATA *IpmiInstance + ) +{ + IpmiInstance->IpmiTransport2.InterfaceType =3D FixedPcdGet8 (P= cdDefaultSystemInterface); + IpmiInstance->IpmiTransport2.IpmiTransport2BmcStatus =3D BmcStatusOk; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2 =3D IpmiSendCommand= 2; + IpmiInstance->IpmiTransport2.IpmiSubmitCommand2Ex =3D IpmiSendCommand= 2Ex; + + if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) { + InitBtInterfaceData (&IpmiInstance->IpmiTransport2); + } + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + InitSsifInterfaceData (&IpmiInstance->IpmiTransport2); + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + InitIpmbInterfaceData (&IpmiInstance->IpmiTransport2); + } +} + +/*++ + +Routine Description: + Notify call back to initialize the interfaces and install SMM IPMI + protocol. + +Arguments: + Protocol - Pointer to the protocol guid. + Interface - Pointer to the protocol instance. + Handle - Handle on which the protocol is installed. + +Returns: + Status of Notify call back. + +--*/ +EFI_STATUS +EFIAPI +SmmNotifyCallback ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + IPMI_INTERFACE_STATE InterfaceState; + + InterfaceState =3D IpmiInterfaceNotReady; + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + InitSsifInterfaceData (&mIpmiInstance->IpmiTransport2); + + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceState =3D=3D= IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + InitIpmbInterfaceData (&mIpmiInstance->IpmiTransport2); + } + + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceState =3D=3D I= pmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + if (InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_SUCCESS; + } + + // Default Interface data should be initialized to install Ipmi Transpor= t2 Protocol. + if (InterfaceState =3D=3D IpmiInterfaceInitialized) { + Handle =3D NULL; + Status =3D gSmst->SmmInstallProtocolInterface ( + &Handle, + &gSmmIpmiTransport2Protoc= olGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTrans= port2 + ); + } + + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Registers Protocol call back. + +Arguments: + ProtocolGuid - Pointer to Protocol GUID to register call back. + +Returns: + Status. + +--*/ +EFI_STATUS +SmmRegisterProtocolCallback ( + IN EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + VOID *Registration; + + if ((ProtocolGuid =3D=3D NULL) || + ((ProtocolGuid !=3D NULL) && IsZeroBuffer (ProtocolGuid, sizeof (EFI= _GUID)))) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D gSmst->SmmRegisterProtocolNotify ( + ProtocolGuid, + SmmNotifyCallback, + &Registration + ); + return Status; +} + EFI_STATUS SmmInitializeIpmiKcsPhysicalLayer ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) + /*++ Routine Description: @@ -138,14 +272,17 @@ Returns: --*/ { - EFI_STATUS Status; - UINT8 ErrorCount; - EFI_HANDLE Handle; - EFI_STATUS_CODE_VALUE StatusCodeValue[MAX_SOFT_COUNT]; + EFI_STATUS Status; + UINT8 ErrorCount; + EFI_HANDLE Handle; + EFI_STATUS_CODE_VALUE StatusCodeValue[MAX_SOFT_COUNT]; + IPMI_INTERFACE_STATE InterfaceState; + UINT8 Index; - DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n")); - ErrorCount =3D 0; - mImageHandle =3D ImageHandle; + DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer entry \n")); + ErrorCount =3D 0; + mImageHandle =3D ImageHandle; + InterfaceState =3D IpmiInterfaceNotReady; mIpmiInstance =3D AllocateZeroPool (sizeof (IPMI_BMC_INSTANCE_DATA)); ASSERT (mIpmiInstance !=3D NULL); @@ -154,7 +291,6 @@ Returns: ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES); return EFI_OUT_OF_RESOURCES; } else { - // // Initialize the KCS transaction timeout. Assume delay unit is 1000 u= s. // @@ -163,36 +299,115 @@ Returns: // // Initialize IPMI IO Base, we still use SMS IO base to get device ID = and Seltest result since SMM IF may have different cmds supported // - mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiS= mmIoBaseAddress); - mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNAT= URE; - mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; - mIpmiInstance->BmcStatus =3D BMC_NOTREADY; - mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; - mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; - - DEBUG ((DEBUG_INFO,"IPMI: Waiting for Getting BMC DID in SMM \n")); - // - // Get the Device ID and check if the system is in Force Update mode. - // - // Just obey the Spec.. - // If we want to improve performance, we're going to comment it. - // - Status =3D GetDeviceId ( - mIpmiInstance, - StatusCodeValue, - &ErrorCount - ); - ASSERT_EFI_ERROR (Status); - Handle =3D NULL; - Status =3D gSmst->SmmInstallProtocolInterface ( - &Handle, - &gSmmIpmiTransportProtocolGuid, - EFI_NATIVE_INTERFACE, - &mIpmiInstance->IpmiTransport - ); - ASSERT_EFI_ERROR (Status); + mIpmiInstance->IpmiIoBase =3D PcdGet16 (PcdIpmiSm= mIoBaseAddress); + mIpmiInstance->Signature =3D SM_IPMI_BMC_SIGNATU= RE; + mIpmiInstance->SlaveAddress =3D BMC_SLAVE_ADDRESS; + mIpmiInstance->BmcStatus =3D BMC_NOTREADY; + mIpmiInstance->IpmiTransport.IpmiSubmitCommand =3D IpmiSendCommand; + mIpmiInstance->IpmiTransport.GetBmcStatus =3D IpmiGetBmcStatus; + + if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) { + DEBUG ((DEBUG_INFO, "IPMI: Waiting for Getting BMC DID in SMM \n")); + // + // Get the Device ID and check if the system is in Force Update mode= . + // + // Just obey the Spec.. + // If we want to improve performance, we're going to comment it. + // + Status =3D GetDeviceId ( + mIpmiInstance, + StatusCodeValue, + &ErrorCount + ); + ASSERT_EFI_ERROR (Status); + Handle =3D NULL; + Status =3D gSmst->SmmInstallProtocolInterface ( + &Handle, + &gSmmIpmiTransportProto= colGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTra= nsport + ); + ASSERT_EFI_ERROR (Status); + } + + InitIpmiTransport2 (mIpmiInstance); + + // Check interface data initialized successfully else register notify = protocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + switch (Index) { + if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) { + case SysInterfaceKcs: + if ((mIpmiInstance->BmcStatus !=3D BMC_HARDFAIL) && (mIpmiInst= ance->BmcStatus !=3D BMC_UPDATE_IN_PROGRESS)) { + BMC_INTERFACE_STATUS BmcStatus; + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = =3D IpmiInterfaceInitialized; + Status = =3D CheckSelfTestByInterfaceType ( + = &mIpmiInstance->IpmiTransport2, + = &BmcStatus, + = SysInterfaceKcs + = ); + if (!EFI_ERROR (Status) && (BmcStatus !=3D BmcStatusHardFail= )) { + InterfaceState =3D IpmiInterfaceInitialized; + } else { + mIpmiInstance->IpmiTransport2.Interface.KcsInterfaceState = =3D IpmiInterfaceInitError; + } + } + + break; + } + + if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) { + case SysInterfaceBt: + if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + + break; + } + + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + case SysInterfaceSsif: + if (mIpmiInstance->IpmiTransport2.Interface.Ssif.InterfaceStat= e =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ssif.Interf= aceState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D SmmRegisterProtocolCallback (&mIpmiInstance->Ipmi= Transport2.Interface.Ssif.SsifInterfaceApiGuid); + } + + break; + } + + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + case SysInterfaceIpmb: + if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.InterfaceStat= e =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } else if (mIpmiInstance->IpmiTransport2.Interface.Ipmb.Interf= aceState =3D=3D IpmiInterfaceInitError) { + // Register protocol notify for SMBUS Protocol. + Status =3D SmmRegisterProtocolCallback (&mIpmiInstance->Ipmi= Transport2.Interface.Ipmb.IpmbInterfaceApiGuid); + } + + break; + } + + default: + break; + } + } + + // Default Interface data should be initialized to install Ipmi Transp= ort2 Protocol. + if (InterfaceState =3D=3D IpmiInterfaceInitialized) { + Handle =3D NULL; + Status =3D gSmst->SmmInstallProtocolInterface ( + &Handle, + &gSmmIpmiTransport2Prot= ocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTra= nsport2 + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IPMI Transport2 protocol install Status =3D = %r \n", Status)); + } + } - DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n")); + DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer exit \n")); return EFI_SUCCESS; } @@ -200,8 +415,8 @@ Returns: EFI_STATUS InitializeSmmGenericIpmi ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { SmmInitializeIpmiKcsPhysicalLayer (ImageHandle, SystemTable); diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= Smm/SmmGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= GenericIpmi/Smm/SmmGenericIpmi.inf index f430195d1e..12dc17ae84 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Smm/Smm= GenericIpmi.inf @@ -3,6 +3,7 @@ # # @copyright # Copyright 2010 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -39,15 +40,26 @@ IoLib ReportStatusCodeLib TimerLib + BmcCommonInterfaceLib + BtInterfaceLib + SsifInterfaceLib + IpmbInterfaceLib [Protocols] gSmmIpmiTransportProtocolGuid # PROTOCOL ALWAYS_PROD= UCED + gSmmIpmiTransport2ProtocolGuid # PROTOCOL ALWAYS_PROD= UCED [Guids] [Pcd] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSmmIoBaseAddress gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiBmcReadyDelayTimer + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport [Depex] gIpmiTransportProtocolGuid -- 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 (#107248): https://edk2.groups.io/g/devel/message/107248 Mute This Topic: https://groups.io/mt/100352689/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-