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 CD27B7803CC for ; Wed, 2 Aug 2023 17:27:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=0zf5TzsH6BmKr1yGdow3mlUP9soemd/nqJTpJ7Wj6Wc=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1690997250; v=1; b=RoCxlu3VdIdXqWFconlk/Tu/E3PuIdLOTv3f8Im7lwx0ULYa2G6ANxoK53y9OJY+Zzxvn+Zc lZzaDQsACWLH3kxzHlDatZrou6Whef/9+lK89DCYPOVhqNfVvVdndo7779hsam0n08I8FkcaAdP QPLeE1rYuoD88Mj5HAj/ctgc= X-Received: by 127.0.0.2 with SMTP id VLQkYY7687511xHiRKKqBevQ; Wed, 02 Aug 2023 10:27:30 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.2385.1690997249891993495 for ; Wed, 02 Aug 2023 10:27:30 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="367112857" X-IronPort-AV: E=Sophos;i="6.01,249,1684825200"; d="scan'208";a="367112857" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2023 10:26:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="872592240" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga001.fm.intel.com with ESMTP; 02 Aug 2023 10:26:53 -0700 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 2 Aug 2023 10:26:50 -0700 X-Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 2 Aug 2023 10:26:50 -0700 X-Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Wed, 2 Aug 2023 10:26:50 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.175) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Wed, 2 Aug 2023 10:26:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P7jqDGcNqIn4BTvXT5ILx0S8LVSUd+IruWA3cfTy3qP2GFSOoH8yOi0BN2+9ZZ4D6BR9BjqEgb8MY7eT9MIru5B8r5XIlyHx2e8YQwp3PhjRfu4HZoTItSZ+aHTGfX2r9Xh9Q1h720B7ni4W4DMbH0taNFJSC7IvucWBFid92VE8AHxBNyX+kiR4uUoQKudnkKO/SEHrmmMmxkM4dT6MXLgskxcpQ2qm6x0kq2T1L9+rhEEUGvSxxzu3wbmmgb4GapUPwHUxgdppg5MAAidrC8G7/SZjDAc8BFCwmgc0yN+xFdkSEVb3c6h/UDzWMgCywKPEg8p0RwF2bhelUIALWA== 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=dfvZJ5KzdIdQeua/5tWaRvjjWJ0OEj0gSv6MZoIVQmc=; b=iJJSg5Ay/0v6IScVh43Ua5eqCwzG5+PKyWc7OsUS+8clfPSSMpQDRhmhyW4Zp1s7FGLzgGH0ClHX4+P+Zmd8hAzev8i6Y9J4BaB3OOZ5pWgBLLlmoEabPZbAXKt4O+Atq5Om7oq0P1ARUFFsbnasM4qls+jo29w7s6KZP+Bh2sW6rqQyQBjrqkcaweGxM9Fr9DuScP2l9aN2viyC6VM8RcMEE0vyIU84HHJ7breaFqHkFxyXj2oGngIOr+YMDpwp43a5pKOD24QN7Jd8ZDUtGXbmMEc4+9W3r1ixPotFhKgju9U0ekOzFrlJocpwDzDgFyq1TZoJNwoUQjfZzs1pdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by IA0PR11MB7308.namprd11.prod.outlook.com (2603:10b6:208:436::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 17:26:41 +0000 X-Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::e73d:eff:289:2d9]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::e73d:eff:289:2d9%4]) with mapi id 15.20.6631.045; Wed, 2 Aug 2023 17:26:41 +0000 From: "Isaac Oram" To: "devel@edk2.groups.io" , "arunk@ami.com" CC: "Desimone, Nathaniel L" , "Ramkumar Krishnamoorthi" , "Gao, Liming" Subject: Re: [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: AQHZvw3ivyhCvjex10iV0C1qM8z3Xa/XTt/A Date: Wed, 2 Aug 2023 17:26:41 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR11MB5801:EE_|IA0PR11MB7308:EE_ x-ms-office365-filtering-correlation-id: b83f1c90-6ad5-48be-9b3b-08db937da2f9 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: bSsfyd0wC6soBdWYnmYOF0umBbIVJsvMYQqEMmMu+iwiEhqaGIjYJ9yw5HcuGRIdYO5t1WzpNCked86Qh4cFahQ1ka95BZeMRV7W5Cnsst2SLVeY3CeB+cmVqsS0bc2EEjuedjbxYRuhF3JFDXw0ytcTf6cy7limsacy9IAKrm/cNf3lOEy/7lgyJWlBgMl8i2kDlj6wFN0zevq065raH4DsgDYMj0CKDS/IECR+aqK0nijHnWWchvI7vr16cuga36akB8wRdwcp2aZRshta3ecJYY7gIAD2P+jTJlsX+Vu+umUM24+Q19Y+UlRo+L0Z3z2eZYWp8T7BP2I8nf94RfrtWMPhaq2U8mBE6xpou3AM0lNL+UtEPxm8k3jQmjZ3XYSZzJ7896Zce31HKZbuI78VzUHW5/tTd72jl5aZEhaqTL2YHpE5JoonktHDVy04fLwF/r4d0FOZO/265r06LBhf78sAB0EakWvstwmsobbjHG/MzVmXxd4Cgwwdsx8R/fNCnleoyUdJIxnB6wqnQE+DjQ0BopPztsylR0cSjaqeYE6yT+0pVU/L5qZ5ZaxAP18FKGGKLj5MnJn8KNbErlKtTELfu9cf6bMwtsHnmicFcHFnBllANdhsgyOJa+eDIryDevIbiauKBLCN0Kmagw== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?7gAiRGryCuyD4kt8rPuxRY95rbrdtBAGuOQxyR+IcO5PeqlOgXaSjrvVw7OE?= =?us-ascii?Q?GvA3M7fSerW2plHXdXTCkTXaqR0zgzU0K3fPYU4H5PhABKpsZ9IKxva0Ybbp?= =?us-ascii?Q?TWXuB1Rrb3o4RMpcBjiBG5/wF+c9JSappROP4LUiwnYPgS9udU7kiu1FTpKv?= =?us-ascii?Q?rt09wuw9Pcs0hJlACqDw34Imd7xlwtNbOm/ewHZx94n8SSeQjvZycde0I0jq?= =?us-ascii?Q?7ju4W3XB1s7FLxfVwKItBsL1CEG4Gw9xncPlaw3DuAAyMht/cNU1S7Km6BiJ?= =?us-ascii?Q?djiFqCMHVkV859XP0uklwCKq68/DV1hZpu3A/y3mseLfzVmnIw3r4H/wdq/Z?= =?us-ascii?Q?yG0HthzGIB0A16eVRajhVOWhFAshcnS3yDrGkre27LfRz90nujiXB0+LXSk+?= =?us-ascii?Q?is59km2IZ/+5LrVwpbv+QSTX3sOvWwJ0aacQ54o76JCR9HpHjiLqWdLW8oNH?= =?us-ascii?Q?dxoK+fCmWmnP0028d2uq+gWakbNJHA9yC4vvhV62V8PCdSfTY1XAKMrWhTvz?= =?us-ascii?Q?puK17/EoDh77szAIaxPFuLS4bpljyN+4FayGHFq1xxfksLuvH4Z3wsbDu6Ij?= =?us-ascii?Q?K+bKBfagDrO45F7yBhI9YB+IjBC4U6vcd6JVfq3a1h282I978W31ECQ742dH?= =?us-ascii?Q?O0UFa9ZjQWv+A+AmccSX6elG3yrh+1HThlmfP8OGy0Av2MvAADFDFtTjIU8Y?= =?us-ascii?Q?m9B8D7drbhbuovradsCDtVxIj6/uZn6YCBQSuZuj/0rFTK3ncKi1o22ZbrSI?= =?us-ascii?Q?fJc8cMtnk4JluhfncrbUhs0fGCvxdz8M0nJkTCnfZ+JnlzZw33JTOEufW+nK?= =?us-ascii?Q?aHy2+Plp9d1TUVuUUh616nJN39njxip0PNeHGZJiYOj62Wzew+crlSCqZaYK?= =?us-ascii?Q?k9Z900imhY8s2SxTNj/97UdNc15APdXOIbF/XTycTAhPfgOV2T6S8uLyrJDE?= =?us-ascii?Q?SdTDaZzbaYOMFLsmRFJSLjwsNlOPIWY4j6i1ojUcw3DSIuDCaJm1lmyf9AfE?= =?us-ascii?Q?LcSY+OgYTIaOcI2xml5T5SE01ZPuW0OP0BzMSn5jrwG3+LxBuVs3RKXkjOL7?= =?us-ascii?Q?B6rkHXlU/nwOgQdem1vRpH9wz5Ng94x1gXV6O9VBX2v00ocanYriOfrJaE0i?= =?us-ascii?Q?H0BcCV5ljPIoymVrF6Rfni0VrOdfgRnjp+F7kQUDlM9/XiA4nzzcivM8JBU6?= =?us-ascii?Q?ggnNRSdjQFZ4tIkcmGJgSjEUb9c47BXH01XGRsATI9U+Ym0kHipUlxTEOsvr?= =?us-ascii?Q?zxtNnXf4yyL/Z6x8vVttcIu3eGIBgLi16MTGAqNBNbYGuVtEN5ywyo6b81Eb?= =?us-ascii?Q?kApZ09RyMmXUEINHGhsZVWLmeyO0ZizNaEPuxKydCEmYb2VmGSP+1hpwANr2?= =?us-ascii?Q?UDFDUYOlGsfyabFnQoPDRdj3P4KNWnUFwDSO3b59qXvfVTWPQirAxaKry50z?= =?us-ascii?Q?yyrmxdFAz6RaafSSkPACZw4PWSyS8XEuWUpCTDIqt1vxgwsqzT9gLP7giRKI?= =?us-ascii?Q?rhKk9UJSAyPqWT8kXyjNIH73TgDQpMej1YIwuJ7hXmV1WUmeiM6k7fuL4Q8t?= =?us-ascii?Q?CGthkm904pGTa3Gg+1ANuhbQQq6Y3leWH9uEUB+Z?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB5801.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b83f1c90-6ad5-48be-9b3b-08db937da2f9 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2023 17:26:41.7412 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: pD2kbCiCWzIuQscXwlAbOHyoQtPA/IvIDocYkc2i0M71iQeR3KpCUcsEc0GbxmSWsyBYVGs6szkyomZyFcjWSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7308 X-OriginatorOrg: intel.com 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,isaac.w.oram@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: eGzeGLu2hc8rwfhtTstBa4AFx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" 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=RoCxlu3V; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=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 Reviewed-by: Isaac Oram -----Original Message----- From: devel@edk2.groups.io On Behalf Of Arun K via g= roups.io Sent: Tuesday, July 25, 2023 8:37 AM To: devel@edk2.groups.io; Arun K Cc: Oram, Isaac W ; Desimone, Nathaniel L ; Ramkumar Krishnamoorthi ; Gao, = Liming Subject: [edk2-devel][edk2-platforms][PATCH V5-2] IpmiFeaturePkg:Provided m= ultiple IPMI interface support in DXE and SMM 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 (#107464): https://edk2.groups.io/g/devel/message/107464 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-