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 064CCD80888 for ; Mon, 11 Dec 2023 21:17:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Fo4u6o2LqVe9bNsUao9z3/Oh1ZuUiAZ7vxCr+1GUvIw=; 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=1702329474; v=1; b=r3GEKTxQcL7MydiVyopmo4UjrHpukYp8cG4wbakXXD5GWfACeXz8ln59nEza5QMwbSGXmcVL xsg3fP+5cFP2tEy2UGESoFwyGUXeyIEP3ZPbdChtVPQrq0l/l6CARXCJE7PoNmktuGbwhdbXHeO jSrnzSxVhO65bNPmliwdHrb0= X-Received: by 127.0.0.2 with SMTP id NkobYY7687511xrfzU00BcbC; Mon, 11 Dec 2023 13:17:54 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.3304.1702329473715464259 for ; Mon, 11 Dec 2023 13:17:53 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="398559951" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="398559951" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 13:16:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="1104626282" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="1104626282" X-Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Dec 2023 13:16:22 -0800 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Dec 2023 13:16:20 -0800 X-Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) 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.35 via Frontend Transport; Mon, 11 Dec 2023 13:16:20 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Dec 2023 13:16:19 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XH5Eo/cHSoWiIKi9Z0HEt+r4DZT5OmT+U+uUwn2v7L24zJ2HLKmz+fGeovSnDOiCuZPiuQIyeKsvkJN45a13fILHx/Uh6Z8ehHEb7/cVHFSb6OBrB0zOI43roU+y65GyK7z/9MI7mjOIy7855pZw6kceV10Z093GC3xwYM3WM9jA8VA+NH3i82N9mmod8RuxfaQQ1Qlt9HfR5XipdoQMET75tdUHoNUEcArtBZLqctxf7DFEWB6PZqxCFHZylS+sLzNDqkOVt+hgNGC0OF4cTZhhC4Bky3f2NwJ0bWDoFh7Q6Zp2rHOD4Gtv4bXz2gV6RaxiDQhoX5euiFRgiFUDYA== 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=YczBi9OiG9Wsv0M9bLWEZUs6zVkN4PdVSJa9nZvr3DY=; b=d1p2cWltLR0ZdwijI5Tp+HWP1GSbvw+ozUr6YeUnyyAiTu1HnI51Rh9zkQ2po0SP2Ewe8UH7QPOtkGlT12e4mgnNBQsPC7DcYaLBHH5x/m/Ok+hLCwb8QmJz4C7SCpg831+vmAW9VQt1QzERz2nw/zmCcfUVsp+hHFaTHSn8sAdd6X9ASjoy33bpEk3ZVDfgjC9Modl30znsMJK0VuuWazAEIOVBXYL2/5fi6BnUyj6QtFeXuGLAZKd9NhN6uAziLno9K9Ra80IgzuIB1UPMRNMd4zXxgyzu04nyA/pxzSw+L/6kW16DULjM4q4MJURKdplYtmGR9rMzBgMSyR44Hw== 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 MW4PR11MB5821.namprd11.prod.outlook.com (2603:10b6:303:184::5) by BN9PR11MB5275.namprd11.prod.outlook.com (2603:10b6:408:134::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 21:16:16 +0000 X-Received: from MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::ced7:2db7:4cae:ab0]) by MW4PR11MB5821.namprd11.prod.outlook.com ([fe80::ced7:2db7:4cae:ab0%7]) with mapi id 15.20.7068.031; Mon, 11 Dec 2023 21:16:16 +0000 From: "Nate DeSimone" To: "Huang, Li-Xia" , "devel@edk2.groups.io" CC: Abner Chang Subject: Re: [edk2-devel] [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Sync change from SMM Thread-Topic: [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Sync change from SMM Thread-Index: AQHaKBHNKt2XvGrj+0yW3IWDiDHuqLCknlgA Date: Mon, 11 Dec 2023 21:16:16 +0000 Message-ID: References: <20231206065936.7518-1-lisa.huang@intel.com> In-Reply-To: <20231206065936.7518-1-lisa.huang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB5821:EE_|BN9PR11MB5275:EE_ x-ms-office365-filtering-correlation-id: 4ccd923c-1bdd-4bb8-3d8c-08dbfa8e6969 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: yogfDLuDQYHew2tcu3XlEqRXbIZYbzG+cK5nHYUwuyuhI5/Q1wkiNDuCOt6fdNwYGNWodirYFVDmWm2Xz9w5XMhj2l+obbj5QD6w6DJO332btFgQmeRy2v+0qjmyqX6pZwj4Qyz7vijwsgVKIIEfZvORsyYQy2JwGB98eCkiKCYpbCzZ3EJisDXOvtyWy1lQSaDDqE8/V0MSciHBP2YpqdiUknzQIHHG36Q1V0i5+EviQ4wh9XHEQoTwsVwtt8hfJENXtUJIXgoFv1K3OtOjIZnFITlrKObctK2NbPHj87XVwIuMp5034ba0T5Qo43VoseKGvgJcv1UZ55f4QqCj2zW0lERLNb30SwjuzlelU705cJJPo+NEA7o7UZNVsmJ5X8/YC4BVHX/UGvU/KMu/JtM7GFxItOhI9vKlbltCPWHwlbCULn7Pur7RAmsm8Ylskvc+7iBFS2/uiusUcRyK2jgeTfgnwokf4K7I2lCvsrkfBoOntEE5HEXjmKIZH7VaMReh32lCrSqRQN7dssePC2EmqYe4JytAPTLVq5FSHKVVafaOE9uoEO0UIjZOSicLtNKEsaEbGQedrK99UEQ/foFZ4KofgDmqdbXn4hw6Zs8QkNxTEX0OGjev2auZyZ57 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?q2JJopFff2QIZxWOSxOFXkg4QvC4Hgw43RwChMGwwllvExLM4C8dmditRXvO?= =?us-ascii?Q?VIiN+uA44xfaEmpN+b1PqwXSt3NDUwXSalp6wYQUiYr31t906HSkGKAPNPao?= =?us-ascii?Q?jZbcLwg3SFoCuZ2hP6wp35mKiV/Wk496wDm9dxb3I2FXatE4/qLJm2KRc6E9?= =?us-ascii?Q?+/jFzgVNv6nryUIRzeOpkavr9B9j+ORmb4uzejKpH7EmpXz0IuNptBGCyLKC?= =?us-ascii?Q?yosHcCRP/32J6vi47AqFs+nyRgmyh/YmTVmVsiRVftLxHbnPEYXxfaASRZs0?= =?us-ascii?Q?NuGdybUdIloFekb/3VIyZDUZ9TPa+xxfos/T4YPLebZavjcqCoxvW7K8foZV?= =?us-ascii?Q?j6QgabJHEKwCnu8uzsSXv8Yme7GqoDl2/D5EID9K0xh+bHeeSc5En1rq/hjs?= =?us-ascii?Q?u053OEJmwuLqAwZtw5VDBa0skU0QDC/Paa12XXO116h4X2zuO7IG1Ro0HvJl?= =?us-ascii?Q?ywEjh7yn9c+jhyk32TxmfAgU7QHW6JiRW8XQmEGcgenZq6rMXaiB/hvtrDO5?= =?us-ascii?Q?QNxNjZW22YWcGVXziQsiThrVwFR9tld1jB7DOG7eu1oRqwxA8RfSpsrPsJp5?= =?us-ascii?Q?5kmZuiu5d0eZsjE6x6NUCwbjs4XEDLjHqqDTpYaWUTGVb2OfYTR1Ktau4R6P?= =?us-ascii?Q?RW8mrRlRcYDKgLQnXmxgGurrVPXexK5LQnnSgH4r13x9cRjLwD7ZL+rlCYTI?= =?us-ascii?Q?maGlKbBLLWokAgYTIgfM2KEgizqzj0J7uUj5I3NE0Lzrq+JnCwlH56Z6e1xg?= =?us-ascii?Q?jLp3Ph57O20yeeJiif9dmnWepljzL+bW4GYZJlUWC49bTH9BX8ixxE9RditH?= =?us-ascii?Q?VdnjiACck5pMz/n7BPybbLMxgN9bijBgyJSElddb5NbFydrF4b67y/I2Hgk/?= =?us-ascii?Q?OzpvhLSwWEwHCTRe8rnz5V2luB0xol4CXHLQvfiH/WkoKZhH5plLIoB/Pl5D?= =?us-ascii?Q?dm+7kdu1OWs2D8dgB5nOqRy3N2fSA4QqtUtdGMaZpWymWZadrKjk8BC6NGuH?= =?us-ascii?Q?4kkHKxmiPlQmV0xFPJfnMvy0hzN3raR8tYMPlqhQ7Oz/O4y1wPD+03u7LLn7?= =?us-ascii?Q?H1WPUKv1sySvTgLoXc/ltnQF57vSBUdyS62eFElVVQ4jyJmFsyBG6jTpiA2L?= =?us-ascii?Q?Ng2T0RCLvVauu5/7FPnaY/L75CnG3hXUg6j13GsrqI1bzxDoEb9tpQ8HYnRz?= =?us-ascii?Q?4Xn/SAXII116n3ZFYEajAmmmJr0+0NeJ9UpPUCZVWEf4Zh2vhsx859+7LZtP?= =?us-ascii?Q?O/XYIOCQb3TW8diN1dlXLk+CFp9171akvy9gkUTSMqBERgbPYY/OTKjty68g?= =?us-ascii?Q?TnIlFQfcfBhDbhdWX+ik03dIs1hfjp4luZzoWB+vXC0I9TTPSGsQYnKeaRFI?= =?us-ascii?Q?gbzEgugdNuzZ4U+dcdTHH9M3YZCi7G7c0gg6Q8RSzNDgRg3BF5iX0elJ2d/J?= =?us-ascii?Q?DWByILyq69QwoYqsod5KkyzDjOzHI6t6z03KfK9bBe+A35g1MSQt8ZJ4UDpx?= =?us-ascii?Q?l8fSd8NsR/hlooljMJfWQX8QnqBlf+3qMVlng65UNbnx7fcthPgqytnQ/ypq?= =?us-ascii?Q?15aYlRVTMeZ8KGL3tz+5X+LbjA5y4uRKn5y+d/8Lo6DbZKErpWo2dCOkHDOI?= =?us-ascii?Q?Og=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5821.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ccd923c-1bdd-4bb8-3d8c-08dbfa8e6969 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Dec 2023 21:16:16.3750 (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: mMYN7SBmI2tVNNDl9uB7C2spzCM3E0eYyLeaFSZaupF25/jwqceI6t3wnjgPeHk/Gft7FODLKsBA+zJ/bkUZTE1ofd6QA8cSpUkjZxCEDMs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5275 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,nathaniel.l.desimone@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: otbHsMlf6ElrwQqP1kRvrhi9x7686176AA= 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=r3GEKTxQ; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Pushed as 7afba0. -----Original Message----- From: Huang, Li-Xia =20 Sent: Tuesday, December 5, 2023 11:00 PM To: devel@edk2.groups.io Cc: Abner Chang ; Desimone, Nathaniel L Subject: [PATCH v1 1/1] IpmiFeaturePkg/GenericIpmi: Sync change from SMM Sync change from SMM to StandaloneMm GenericIpmi driver. Update SmmIpmbInterface and SmmSsifInterface Lib to support MM_STANDALONE. = And Format code with uncrustify. Cc: Abner Chang Cc: Nate DeSimone Signed-off-by: Lixia Huang --- Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm= /StandaloneMmGenericIpmi.c | 315 +++++++++++++++++--= - Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceComm= onAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.c | 4 +- Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceComm= onAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c | 64 ++-- Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm= /StandaloneMmGenericIpmi.inf | 10 + Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature.dsc = | 2 +- Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceComm= onAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.inf | 4 +- Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceComm= onAccess/SsifInterfaceLib/SmmSsifInterfaceLib.inf | 4 +- 7 files changed, 326 insertions(+), 77 deletions(-) diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= StandaloneMm/StandaloneMmGenericIpmi.c b/Features/Intel/OutOfBandManagement= /IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c index d808e2517c99..1b9841e4b745 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Standal= oneMm/StandaloneMmGenericIpmi.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan +++ daloneMm/StandaloneMmGenericIpmi.c @@ -19,17 +19,157 @@ #include #include #include +#include #include #include "IpmiHooks.h" #include "IpmiBmcCommon.h" #include "IpmiBmc.h" =20 -IPMI_BMC_INSTANCE_DATA *mIpmiInstance; -EFI_HANDLE mHandle; +IPMI_BMC_INSTANCE_DATA *mIpmiInstance; +EFI_HANDLE mIpmiTransportHandle; +EFI_HANDLE mIpmiTransport2Handle; =20 /** + +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) { + mIpmiTransport2Handle =3D NULL; + Status =3D gMmst->MmInstallProtocolInterface ( + &mIpmiTransport2Handle, + &gSmmIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); } + + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; +} + +/** + +Routine Description: + Registers Protocol call back. + +Arguments: + ProtocolGuid - Pointer to Protocol GUID to register call back. + +Returns: + Status. + +**/ +EFI_STATUS +MmRegisterProtocolCallback ( + IN EFI_GUID *ProtocolGuid + ) +{ + EFI_STATUS Status; + VOID *Registration; + + if ((ProtocolGuid =3D=3D NULL) || + ((ProtocolGuid !=3D NULL) && IsZeroBuffer (ProtocolGuid, sizeof=20 + (EFI_GUID)))) { + return EFI_INVALID_PARAMETER; + } + + Status =3D gMmst->MmRegisterProtocolNotify ( + ProtocolGuid, + SmmNotifyCallback, + &Registration + ); + return Status; +} + +EFI_STATUS +SmmInitializeIpmiKcsPhysicalLayer ( + VOID + ) + +/** + Routine Description: - Setup and initialize the BMC for the SMM phase. In order to verify the = BMC is functioning + Setup and initialize the BMC for the DXE phase. In order to verify=20 + the BMC is functioning as expected, the BMC Selftest is performed. The results are then checke= d and any errors are reported to the error manager. Errors are collected throughout this rou= tine and reported just prior to installing the driver. If there are more errors than MAX_= SOFT_COUNT, then they @@ -43,25 +183,27 @@ Returns: EFI_SUCCESS - Successful driver initialization =20 **/ -EFI_STATUS -SmmInitializeIpmiKcsPhysicalLayer ( - VOID - ) { - EFI_STATUS Status; + EFI_STATUS Status; + UINT8 ErrorCount; + IPMI_INTERFACE_STATE InterfaceState; + UINT8 Index; =20 - DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer entry \n")); + DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer entry \n")); + ErrorCount =3D 0; + InterfaceState =3D IpmiInterfaceNotReady; =20 Status =3D gMmst->MmAllocatePool ( EfiRuntimeServicesData, sizeof (IPMI_BMC_INSTANCE_DATA), - (VOID **)&mIpmiInstance); - - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "mIpmiInstance mem alloc failed - 0x%x\n", Status= )); - return Status; + (VOID **)&mIpmiInstance + ); + ASSERT (mIpmiInstance !=3D NULL); + if (mIpmiInstance =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "ERROR!! Null Pointer returned by AllocateZeroPoo= l ()\n")); + 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. // @@ -70,23 +212,110 @@ SmmInitializeIpmiKcsPhysicalLayer ( // // 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 FixedPcdGet16 (Pcd= IpmiSmmIoBaseAddress); - 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; - - mHandle =3D NULL; - Status =3D gMmst->MmInstallProtocolInterface ( - &mHandle, - &gSmmIpmiTransportProtocolGuid, - EFI_NATIVE_INTERFACE, - &mIpmiInstance->IpmiTransport - ); - ASSERT_EFI_ERROR (Status); - - DEBUG ((DEBUG_INFO,"SmmInitializeIpmiKcsPhysicalLayer exit \n")); + mIpmiInstance->IpmiIoBase =3D FixedPcdGet16 (PcdI= pmiSmmIoBaseAddress); + 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.. + // To improve performance, we're going to comment it. + // + + mIpmiTransportHandle =3D NULL; + Status =3D gMmst->MmInstallProtocolInterface ( + &mIpmiTransportHandle, + &gSmmIpmiTransportProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport + ); + ASSERT_EFI_ERROR (Status); + } + + InitIpmiTransport2 (mIpmiInstance); + + // Check interface data initialized successfully else register notify = protocol. + for (Index =3D SysInterfaceKcs; Index < SysInterfaceMax; Index++) { + switch (Index) { + case SysInterfaceKcs: + if (FixedPcdGet8 (PcdKcsInterfaceSupport) =3D=3D 1) { + 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; + + case SysInterfaceBt: + if (FixedPcdGet8 (PcdBtInterfaceSupport) =3D=3D 1) { + if (mIpmiInstance->IpmiTransport2.Interface.Bt.InterfaceState = =3D=3D IpmiInterfaceInitialized) { + InterfaceState =3D IpmiInterfaceInitialized; + } + } + + break; + + case SysInterfaceSsif: + if (FixedPcdGet8 (PcdSsifInterfaceSupport) =3D=3D 1) { + 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 MmRegisterProtocolCallback (&mIpmiInstance->IpmiT= ransport2.Interface.Ssif.SsifInterfaceApiGuid); + } + } + + break; + + case SysInterfaceIpmb: + if (FixedPcdGet8 (PcdIpmbInterfaceSupport) =3D=3D 1) { + 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 MmRegisterProtocolCallback (&mIpmiInstance->IpmiT= ransport2.Interface.Ipmb.IpmbInterfaceApiGuid); + } + } + + break; + + default: + break; + } + } + + // Default Interface data should be initialized to install Ipmi Transp= ort2 Protocol. + if (InterfaceState =3D=3D IpmiInterfaceInitialized) { + mIpmiTransport2Handle =3D NULL; + Status =3D gMmst->MmInstallProtocolInterface ( + &mIpmiTransport2Handle, + &gSmmIpmiTransport2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &mIpmiInstance->IpmiTransport2 + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IPMI Transport2 protocol install Status =3D = %r \n", Status)); + } + } + + DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer exit \n")); =20 return EFI_SUCCESS; } @@ -104,8 +333,8 @@ SmmInitializeIpmiKcsPhysicalLayer ( **/ EFI_STATUS I= nitializeGenericIpmiStandaloneMm ( - IN EFI_HANDLE ImageHandle, - IN EFI_MM_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable ) { SmmInitializeIpmiKcsPhysicalLayer (); @@ -124,21 +353,31 @@ InitializeGe= nericIpmiStandaloneMm ( EFI_STATUS EFIAPI GenericIpmiStandaloneMmUnload = ( - IN EFI_HANDLE ImageHandle + IN EFI_HANDLE ImageHandle ) { - EFI_STATUS Status; + EFI_STATUS Status; =20 Status =3D EFI_SUCCESS; if (mIpmiInstance !=3D NULL) { - if (mHandle !=3D NULL) { + if (mIpmiTransportHandle !=3D NULL) { Status =3D gMmst->MmUninstallProtocolInterface ( - mHandle, + mIpmiTransportHandle, &gSmmIpmiTransportProtocolGuid, &mIpmiInstance->IpmiTransport ); ASSERT_EFI_ERROR (Status); } + + if (mIpmiTransport2Handle !=3D NULL) { + Status =3D gMmst->MmUninstallProtocolInterface ( + mIpmiTransport2Handle, + &gSmmIpmiTransport2ProtocolGuid, + &mIpmiInstance->IpmiTransport2 + ); + ASSERT_EFI_ERROR (Status); + } + gMmst->MmFreePool (mIpmiInstance); } =20 diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.c b/Features/Inte= l/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbI= nterfaceLib/SmmIpmbInterfaceLib.c index b5d63353e403..589ea81a72c1 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInter +++ faceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.c @@ -8,7 +8,7 @@ **/ =20 #include -#include +#include #include #include #include @@ -76,7 +76,7 @@ IpmiGetI2cApiPtr= ( IpmiTransport2->Interface.Ipmb.IpmbInterfaceApiGuid =3D gEfiI2cMasterPro= tocolGuid; =20 // Locate the I2C SMM Protocol for Communication. - Status =3D gSmst->SmmLocateProtocol ( + Status =3D gMmst->MmLocateProtocol ( &gEfiI2cMasterProtocolGuid, NULL, (VOID **)&I2cMasterTransmit diff --gi= t a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceC= ommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c b/Features/Intel/OutOfBa= ndManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInterfaceL= ib/SmmSsifInterfaceLib.c index e784631909ce..1f50977c31be 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInter +++ faceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c @@ -8,7 +8,7 @@ **/ =20 #include -#include +#include #include #include #include @@ -54,14 +54,14 @@ IpmiS= mbusSendCommand ( =20 if (EfiSmbusHcProtocol !=3D NULL) { Status =3D EfiSmbusHcProtocol->Execute ( - EfiSmbusHcProtocol, - SlaveAddress, - Command, - Operation, - PecCheck, - Length, - Buffer - ); + EfiSmbusHcProtocol, + SlaveAddress, + Command, + Operation, + PecCheck, + Length, + Buffer + ); } =20 DEBUG ((DEBUG_INFO, "%a EfiSmbusHcProtocol->Execute Status =3D %r\n", __= func__, Status)); @@ -95,13 +95,13 @@ IpmiGetSmbusApiPtr ( IpmiTransport2->Interface.Ssif.SsifInterfaceApiGuid =3D gEfiSmbusHcProto= colGuid; HandleCount =3D 0; =20 - Status =3D gSmst->SmmLocateHandle ( - ByProtocol, - &gEfiSmbusHcProtocolGuid, - NULL, - &HandleCount, - HandleBuffer - ); + Status =3D gMmst->MmLocateHandle ( + ByProtocol, + &gEfiSmbusHcProtocolGuid, + NULL, + &HandleCount, + HandleBuffer + ); if (EFI_ERROR (Status) && (Status =3D=3D EFI_BUFFER_TOO_SMALL)) { // Allocate memory for Handle buffer HandleBuffer =3D AllocateZeroPool (HandleCount); @@ -109,13 +109,13 @@= IpmiGetSmbusApiPtr ( return EFI_NOT_FOUND; } =20 - Status =3D gSmst->SmmLocateHandle ( - ByProtocol, - &gEfiSmbusHcProtocolGuid, - NULL, - &HandleCount, - HandleBuffer - ); + Status =3D gMmst->MmLocateHandle ( + ByProtocol, + &gEfiSmbusHcProtocolGuid, + NULL, + &HandleCount, + HandleBuffer + ); if (EFI_ERROR (Status)) { // Free HandleBuffer memory FreePool (HandleBuffer); @@ -124,11 +124,11 @@ IpmiGetSmbusApiPtr ( } =20 for (Index =3D 0; Index < HandleCount; Index++) { - Status =3D gSmst->SmmHandleProtocol ( - HandleBuffer[Index], - &gEfiSmbusHcProtocolGuid, - (VOID **)&EfiSmbusHcProtocol - ); + Status =3D gMmst->MmHandleProtocol ( + HandleBuffer[Index], + &gEfiSmbusHcProtocolGuid, + (VOID **)&EfiSmbusHcProtocol + ); if (EFI_ERROR (Status)) { continue; } @@ -137,10 +137,10 @@ IpmiGetSmbusApiPtr ( IpmiTransport2->Interface.Ssif.SsifInterfaceApiPtr =3D (UINTN)EfiSmbus= HcProtocol; =20 Status =3D CheckSelfTestByInterfaceType ( - IpmiTransport2, - &BmcStatus, - SysInterfaceSsif - ); + IpmiTransport2, + &BmcStatus, + SysInterfaceSsif + ); if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceInitE= rror; continue; diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/= StandaloneMm/StandaloneMmGenericIpmi.inf b/Features/Intel/OutOfBandManageme= nt/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.inf index 170e0a8d136b..e4abc4db29fe 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Standal= oneMm/StandaloneMmGenericIpmi.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Stan +++ daloneMm/StandaloneMmGenericIpmi.inf @@ -38,14 +38,24 @@ IoLib ReportStatusCodeLib TimerLib + BmcCommonInterfaceLib + BtInterfaceLib + SsifInterfaceLib + IpmbInterfaceLib =20 [Protocols] gSmmIpmiTransportProtocolGuid # PROTOCOL ALWAYS_PROD= UCED + gSmmIpmiTransport2ProtocolGuid # PROTOCOL ALWAYS_PROD= UCED =20 [Guids] =20 [Pcd] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiSmmIoBaseAddress + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport =20 [Depex] gIpmiTransportProtocolGuid diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipmi= Feature.dsc b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipm= iFeature.dsc index cfdfc916a464..c9c76565c672 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature= .dsc +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeat +++ ure.dsc @@ -57,7 +57,7 @@ SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/DxeSsifInterfaceLib.inf IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/DxeIpmbInterfaceLib.inf =20 -[LibraryClasses.common.DXE_SMM_DRIVER] +[LibraryClasses.common.DXE_SMM_DRIVER,LibraryClasses.common.MM_STANDALO +NE] IpmiBaseLib|IpmiFeaturePkg/Library/SmmIpmiBaseLib/SmmIpmiBaseLib.inf SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/SmmSsifInterfaceLib.inf IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/SmmIpmbInterfaceLib.inf diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.inf b/Features/In= tel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ipm= bInterfaceLib/SmmIpmbInterfaceLib.inf index 5030d5659dc2..32e72bef9bc1 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInter +++ faceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.inf @@ -14,7 +14,7 @@ FILE_GUID =3D C39F9DC3-37C7-41C1-BE05-8C1524493947 MODULE_TYPE =3D DXE_SMM_DRIVER VERSION_STRING =3D 1.1 - LIBRARY_CLASS =3D IpmbInterfaceLib | DXE_SMM_DRIVER + LIBRARY_CLASS =3D IpmbInterfaceLib | DXE_SMM_DRIVER MM_STANDALONE =20 [Sources] SmmIpmbInterfaceLib.c @@ -27,7 +27,7 @@ [LibraryClasses] DebugLib BaseMemoryLib - SmmServicesTableLib + MmServicesTableLib BmcCommonInterfaceLib =20 [Protocols] diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.inf b/Features/In= tel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ssi= fInterfaceLib/SmmSsifInterfaceLib.inf index b1fb44241c37..8ff1a2cf927e 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.inf +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInter +++ faceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.inf @@ -14,7 +14,7 @@ FILE_GUID =3D DB817B63-FA26-44FA-BF84-8D48596F982B MODULE_TYPE =3D DXE_SMM_DRIVER VERSION_STRING =3D 1.1 - LIBRARY_CLASS =3D SsifInterfaceLib | DXE_SMM_DRIVER + LIBRARY_CLASS =3D SsifInterfaceLib | DXE_SMM_DRIVER MM_STANDALONE =20 [Sources] SmmSsifInterfaceLib.c @@ -26,7 +26,7 @@ IpmiFeaturePkg/IpmiFeaturePkg.dec =20 [LibraryClasses] - SmmServicesTableLib + MmServicesTableLib MemoryAllocationLib BmcCommonInterfaceLib =20 -- 2.26.2.windows.1 -=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 (#112329): https://edk2.groups.io/g/devel/message/112329 Mute This Topic: https://groups.io/mt/103008784/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-