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 C34BB740032 for ; Wed, 2 Aug 2023 17:27:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=rvGNu1/5vosC2eoZYaziyYL+7PnyVm60AP/6Zyhy0dY=; 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=1690997278; v=1; b=JPjeYCSQ5hjZUZ6WICeYOVttZIcCgmmyzTyb5YazNhWUuQchMozhtBAKa55GlOOue3XL1I7+ KSFUCXn+8IiOhr1ZUlXFMvWx7gViuHNzKC9LgT8qegUpWUKdHzM6qilOtSIiUsIICFG+IXYovrT zRzo/+XLkkPGys3EEXHVc62c= X-Received: by 127.0.0.2 with SMTP id 1MAxYY7687511xMBLSdtPWDL; Wed, 02 Aug 2023 10:27:58 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.2400.1690997277811056911 for ; Wed, 02 Aug 2023 10:27:58 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="354563159" X-IronPort-AV: E=Sophos;i="6.01,249,1684825200"; d="scan'208";a="354563159" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2023 10:27:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10790"; a="732458399" X-IronPort-AV: E=Sophos;i="6.01,249,1684825200"; d="scan'208";a="732458399" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP; 02 Aug 2023 10:27:13 -0700 X-Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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:27:13 -0700 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) 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:27:13 -0700 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.168) by edgegateway.intel.com (192.55.55.70) 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:27:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bHVhKO+zNLYyGZwmS4nY1BrcB3q1S5sR9WZaE6pBjaETVDHvI1hsGtbEG3ISPfEGdFq9qWzEABvSdCVmAwEjOixhdbsGzBJGarjkVzCuGNZ17y3xLLTFGNu3kYvqwN5Olnixf04fJsqPu/QPo1m4xEHBAOrvN2Hblx553wCq3sJo4clHh0GcubKNJKr5jUzC0tYqnyZjcvlAb8Ki1jgsoAy4HuXEYrdENwFLl5ZhOuWa4NRHMFkycpKuzIUYhcS+JH4bjKckdEYPRwOsyYUk3cP49xBy2jYnLdS5QwhDvIyuvlzztwsp+NJBEq4t1fEL7+xnK9ULRGL3qu/v7ApgOg== 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=AJ2UOFvT41VI4army92Df42NNadMRVDv3ByWoT/ueSo=; b=mQIRVqI7qRkCG1r6zPYvZP2XeokBnSj8BIYI7xF6hCpHS6D8hnMXBsK/jwTQ4gY+kKv+3DMLEN7Qod5T8YhM1Abe28UzEDREgJmiXqmGk3E3liXevqv39qpuiVZx3AT5zUSuC+WmUzhPMdSTrEXYeQAJ9eqOpGb+oyKm90krgSIQrkAnIOa1vi2Ea8UWeJ7d9l6mXEzbKDw+nMlrekvPwo3VnEl1AKWlFurXWDjWo6+J9IYXyNERx6F5/ILyfcv/R5Hv1Z10v2hp2oRoeZ0QzjE3Z8J6k0RSuomKzA6ewhnXJv19Vw84psIVmhFVUVIlvZ61GBk99OmhOtmYq3GXRQ== 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 SA2PR11MB4954.namprd11.prod.outlook.com (2603:10b6:806:11b::17) 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:27:03 +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:27:03 +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-3] IpmiFeaturePkg:Provided multiple IPMI interface support in Library Thread-Topic: [edk2-devel][edk2-platforms][PATCH V5-3] IpmiFeaturePkg:Provided multiple IPMI interface support in Library Thread-Index: AQHZvw30lk0cZIpWR0m67Sq/2kRASa/XTu7w Date: Wed, 2 Aug 2023 17:27:03 +0000 Message-ID: References: <900c2b8fa85bc8c44a0a1bb21bfdcc2c4c7992da.1690298861.git.arunk@ami.com> In-Reply-To: <900c2b8fa85bc8c44a0a1bb21bfdcc2c4c7992da.1690298861.git.arunk@ami.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR11MB5801:EE_|SA2PR11MB4954:EE_ x-ms-office365-filtering-correlation-id: d5f9276b-21ae-43d1-fbaa-08db937db009 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: lIBsB1iOTpvF5rfD+IhqJnjehbeuiN/IBhythNh5Z9ST53EwbdnRcTU4G46RoGeLZX0sVuZSxtG0Kixk/xfhsX/5HjVI7l5ywHHtHu4oO2Syp9VXs8BZ6H/FYP0Pj+aQzS2QswW58uAs/hBM5E7bTN7RPQtB+YEdB7qB7Qqzd/7tCz4kVcv0r/k1cqTevp7grVMaf246fXu03UBDd7IPims9OkE+oiVbKZn/BVGgl5gxSYprA0QRw7d3mHOt6HwO05IvHFnTCuVDLghhzX/P/QJ+4ovhaTaZKiUcxaGHmpzLKWNbcdBSRtycIfDckj23DaV06114kEvLKQSp4gGgdZnwbi7onncJ1BFX+hQTWK/PNUclavuWiUN1fp9sjyrwI+KfW14P8lthycAIHCeAsjBubXccIRNmS+60/+tntbrF+FmGs05aC6l+zFEyfmFbN7Gz89xhKrGxOoUqYI+1D2z/zaXEypCTmb8Vlj5mTZjul1wlHfYYXZoeLwvMfarovj28fMAyienUaPx6PP+CvR/kzEl4eJvbqEgwNNO+fbAqUFYPI8v+Wn0EnNX/jZi2XeSVc3VkHLlLwabwdWk0ZsNFyO0xYPcnR/iwIn/9x3AsXLjwQdIDpZWN0zAIQ57OcrEfWptxVzoGlc4GOkDchDGrgsopiIPJ+daWatg4sxg= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?fNtajo/4iCBoOVqa57gyeymf8mQLa/CNZb2/HsYWpmtAYUdHjPdNiBaaGX47?= =?us-ascii?Q?lFiss+Fs52wjcUS83s5SBUz8AK5PmH6BFDXcIOzE36K7PpxUZhYdlT3SRdtX?= =?us-ascii?Q?3N9UfSV1g6tTPx+Zlnd2gCbcKiVaAcb6QqwssLayg/U9R9RoTzPKb/4CDlKR?= =?us-ascii?Q?dmhNtg7sTum4a25unVSIVL22q09t1JSSrlqY2041F/N17p3Qkbbur9CsTL3O?= =?us-ascii?Q?N1Q7hPv5oaBq3LCtQCXG4CsUc2mdXIhQryxRO976UsD45T7sDlv/kDHo2TAt?= =?us-ascii?Q?3oyirTSH6Aqth3idjuQTqUxRvEeTbviM1hMuPP88+HG2ZKW28N73HskE4c1i?= =?us-ascii?Q?VMVCEA7yfugKu+KnH45hdZIF3BPthPvQFYnAUjk9BEi9DHH4ZZNgEjw7GJ11?= =?us-ascii?Q?dDwqTTGkop922ausD7sKoaHVsZmqRa3+2PUHMxw0ObhrkUnXSKF5KAcC4REq?= =?us-ascii?Q?kJ3z+/f74ActHvuXfY7FQBxGz2OvFZUp71fiVluZANKxs9UYz6pb4NquHILR?= =?us-ascii?Q?WN2cE1O2vEWsFys/3GbBSerTGZ9UmSTUrqwmM4IA+RChgIhgw/uAjZBsYZ56?= =?us-ascii?Q?BrF9uEe72DU0nMMBjW6rlBuACjidMQtXxA+0jXmAe3XbKqgjGhbIIYErjPg7?= =?us-ascii?Q?Q1s7iiRgVxQkaITTXYLa9TvZcRRi+GyZGqPc9ceU9GDpEhG9eJZaGwigyqgx?= =?us-ascii?Q?sYX5g/YbR1mxlpJ4ZlWNJKxS12eGRBqmlIg50PJvtChNectsGOuv9qPW5j7z?= =?us-ascii?Q?ZBQhxpLz7WuM7XlLAshENvb7/QIQvbHsMp3PSWX9b1lz7hNKv/xI6c2xqp33?= =?us-ascii?Q?SYHwo90GcxXtQVj6QGQABlRo/7efUZvIb0NW6QznfsbNYpfCCXQh3hyarP87?= =?us-ascii?Q?An9VEhLf+6cp6dDdF4ot64S7iAD1PN0NqDFMXAR1WuzW+sGzN9n98PSwagUY?= =?us-ascii?Q?RGGAOPXx2DyIHbo+Oikeem3IAA3fy0hZAw7iC2fGBUD1ZAwx48wCLaIoKIqz?= =?us-ascii?Q?SJCAKd0oNdv9OLZ39bK78E4E4iCr9aClYAbumRnj7CN33lfgSix/9dFkX5MJ?= =?us-ascii?Q?UiArRhkmVaPSfp10y4KiJq2ASKiMbr3+iFse9mWpAhHNlOKgQG5KTzqJ7okL?= =?us-ascii?Q?OtyhIDBPlAXtGEfJ7Nn1YnIgq6C8VU9c8CVPIr7xmdFetKbReOfBfZpipm4J?= =?us-ascii?Q?OSX4iUWkMZQR/blWk5wsEGYtiFDxfuiIGJZiTYP2y4GDFjmyQ1oNpPvgXJJQ?= =?us-ascii?Q?ga5KdeKCG6ZAftW0VZxZFqAP9jbXJVrBNMGTikeGby9SMPDf6G0uBsdhePMR?= =?us-ascii?Q?8+bPOH7yrtT5jNa7mHRXNLvwzkNnjG0gbY34AkYniiUcBLb0XaUOOYReTBDH?= =?us-ascii?Q?hWMYcgsHDnKYRF8cXaM+CWhvjuHG9xKfiddceeOSTEQH7X7CPsLSXKvKXCRo?= =?us-ascii?Q?3gzPS6zkeTI6twC03KmKcZtJKgUWfUQDUmkzP7De5AaExq6dA+a7iCwseFY3?= =?us-ascii?Q?t8nuP1x3SIjF/QIuvIQ+VAKMy6aIDQ0jCH4/i+mY8Uie4ra22rrPZLUJ+G8a?= =?us-ascii?Q?lxqCsY3skkVPk6w7StF1EvMqzTQ0AuXiVzePrOm3?= 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: d5f9276b-21ae-43d1-fbaa-08db937db009 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Aug 2023 17:27:03.6290 (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: wrtos6WPqh8ALehf7zO+GdfuK6WnUVuhXX6gYTf5QyX8eIz4WdiCGb9lBMlArer8YVGEGsLf5mrI5xnicPCyNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4954 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: cJtLMI02PAAsXMTni0mevlQax7686176AA= 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=JPjeYCSQ; 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; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") 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:38 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-3] IpmiFeaturePkg:Provided m= ultiple IPMI interface support in Library 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 --- .../IpmiFeaturePkg/Include/IpmiFeature.dsc | 15 + .../Include/IpmiNetFnAppDefinitions.h | 239 +++++++ .../Include/IpmiTransport2Definitions.h | 152 +++++ .../Include/Library/BmcCommonInterfaceLib.h | 227 +++++++ .../Include/Library/BtInterfaceLib.h | 78 +++ .../Include/Library/IpmbInterfaceLib.h | 94 +++ .../Include/Library/SsifInterfaceLib.h | 169 +++++ .../Include/Ppi/IpmiTransport2Ppi.h | 23 + .../Include/Protocol/IpmiTransport2Protocol.h | 29 + .../IpmiFeaturePkg/IpmiFeaturePkg.dec | 61 ++ .../BmcCommonInterfaceLib.c | 256 ++++++++ .../BmcCommonInterfaceLib.inf | 26 + .../BtInterfaceLib/BtInterfaceLib.c | 605 ++++++++++++++++++ .../BtInterfaceLib/BtInterfaceLib.inf | 39 ++ .../IpmbInterfaceLib/DxeIpmbInterfaceLib.c | 103 +++ .../IpmbInterfaceLib/DxeIpmbInterfaceLib.inf | 38 ++ .../IpmbInterfaceLib/IpmbInterfaceLibCommon.c | 378 +++++++++++ .../IpmbInterfaceLib/PeiIpmbInterfaceLib.c | 108 ++++ .../IpmbInterfaceLib/PeiIpmbInterfaceLib.inf | 38 ++ .../IpmbInterfaceLib/SmmIpmbInterfaceLib.c | 104 +++ .../IpmbInterfaceLib/SmmIpmbInterfaceLib.inf | 37 ++ .../SsifInterfaceLib/DxeSsifInterfaceLib.c | 137 ++++ .../SsifInterfaceLib/DxeSsifInterfaceLib.inf | 40 ++ .../SsifInterfaceLib/PeiSsifInterfaceLib.c | 128 ++++ .../SsifInterfaceLib/PeiSsifInterfaceLib.inf | 41 ++ .../SsifInterfaceLib/SmmSsifInterfaceLib.c | 156 +++++ .../SsifInterfaceLib/SmmSsifInterfaceLib.inf | 40 ++ .../SsifInterfaceLib/SsifInterfaceLibCommon.c | 577 +++++++++++++++++ .../IpmiFeaturePkg/Readme.md | 24 + 29 files changed, 3962 insertions(+) create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/IpmiNetFnAppDefinitions.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/IpmiTransport2Definitions.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/Library/BmcCommonInterfaceLib.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/Library/BtInterfaceLib.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/Library/IpmbInterfaceLib.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/Library/SsifInterfaceLib.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/Ppi/IpmiTransport2Ppi.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inclu= de/Protocol/IpmiTransport2Protocol.h create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/BmcCommonInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/BmcCommonInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/BtInterfaceLib/BtInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/BtInterfaceLib/BtInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/IpmbInterfaceLib/DxeIpmbInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/IpmbInterfaceLib/DxeIpmbInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/IpmbInterfaceLib/IpmbInterfaceLibCommon.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/IpmbInterfaceLib/PeiIpmbInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/IpmbInterfaceLib/PeiIpmbInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/SsifInterfaceLib/DxeSsifInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/SsifInterfaceLib/DxeSsifInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/SsifInterfaceLib/PeiSsifInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/SsifInterfaceLib/PeiSsifInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.inf create mode 100644 Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Libra= ry/BmcInterfaceCommonAccess/SsifInterfaceLib/SsifInterfaceLibCommon.c diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipmi= Feature.dsc b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipm= iFeature.dsc index 237a4fc006..0401974b82 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature= .dsc +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiFeature= .dsc @@ -7,6 +7,7 @@ # for the build infrastructure. # # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -41,10 +42,24 @@ [LibraryClasses.common.PEI_CORE,LibraryClasses.common.PEIM] IpmiBaseLib|IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf + SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/PeiSsifInterfaceLib.inf + IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/PeiIpmbInterfaceLib.inf [LibraryClasses.common.DXE_DRIVER,LibraryClasses.common.UEFI_DRIVER] IpmiBaseLib|IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf +[LibraryClasses.common] + BmcCommonInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Bm= cCommonInterfaceLib.inf + BtInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/BtInterfa= ceLib/BtInterfaceLib.inf + +[LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_DRIVE= R] + SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/DxeSsifInterfaceLib.inf + IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/DxeIpmbInterfaceLib.inf + +[LibraryClasses.common.DXE_SMM_DRIVER] + SsifInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifInt= erfaceLib/SmmSsifInterfaceLib.inf + IpmbInterfaceLib|IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbInt= erfaceLib/SmmIpmbInterfaceLib.inf + ##########################################################################= ###### # # Component section - list of all components that need built for this feat= ure. diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipmi= NetFnAppDefinitions.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/I= nclude/IpmiNetFnAppDefinitions.h new file mode 100644 index 0000000000..7ee6fb1ff3 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiNetFnAp= pDefinitions.h @@ -0,0 +1,239 @@ +/** @file IpmiNetFnAppDefinitions.h + Ipmi NetFn Application additional commands and its structures. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _IPMI_NETFN_APP_DEFINITIONS_H_ +#define _IPMI_NETFN_APP_DEFINITIONS_H_ + +#include + +#define IPMI_SPEC_VERSION_1_5 0x51 +#define IPMI_SPEC_VERSION_2_0 0x02 +#define IPMI_APP_SELFTEST_RESERVED 0xFF + +#pragma pack(1) + +/** + Get Bmc global enables command response. +*/ +typedef struct { + /// Completion code. + UINT8 CompletionCode; + UINT8 ReceiveMsgQueueInterrupt : 1; ///< Receive Message Queue Int= errupt. + UINT8 EventMsgBufferFullInterrupt : 1; ///< Event Message Buffer Full= Interrupt. + UINT8 EventMsgBuffer : 1; ///< Event Message Buffer. + UINT8 SystemEventLogging : 1; ///< System Event Logging. + UINT8 Reserved : 1; ///< Reserved. + UINT8 OEM0 : 1; ///< OEM0 interrupt. + UINT8 OEM1 : 1; ///< OEM1 interrupt. + UINT8 OEM2 : 1; ///< OEM2 interrupt. +} GET_BMC_GLOBAL_ENABLES_RESPONSE; + +/** + Channel access type. + */ +typedef enum { + ChannelAccessTypeReserved0, ///< Reserved0 + ChannelAccessTypeNonVolatile, ///< NonVolatile + ChannelAccessTypePresentVolatileSetting, ///< PresentVolatileSetting + ChannelAccessTypeReserved1 ///< Reserved1 +} CHANNEL_ACCESS_TYPE; + +/** + Channel access modes. +*/ +typedef enum { + ChannelAccessModeDisabled, ///< Disabled Channel Access Mode. + ChannelAccessModePreBootOnly, ///< Pre-Boot Only Channel Access Mo= de. + ChannelAccessModeAlwaysAvailable, ///< Always Available Channel Access= Mode. + ChannelAccessModeShared ///< Shared Channel Access Mode. +} CHANNEL_ACCESS_MODES; + +/** + SSIF read/write support. +*/ +typedef enum { + SsifSinglePartRw, ///< Single Part read-write. + SsifMultiPartRw, ///< Multi Part read-write. + SsifMultiPartRwWithMiddle, ///< Multi Part read-write With Middle. + SsifReserved ///< Reserved. +} SSIF_READ_WRITE_SUPPORT; + +/** + Channnel states. +*/ +typedef enum { + DisbleChannel =3D 0, ///< Disble Channel. + EnableChannel, ///< Enable Channel. + GetChannelState, ///< Get Channel State. + ChannelStateReserved ///< Channel State Reserved. +} CHANNEL_STATE; + +/** + Enable message channel command request structure. +*/ +typedef struct { + UINT8 ChannelNumber : 4; /// Channel Number. + UINT8 Reserved1 : 4; ///< Reserved. + UINT8 ChannelState : 2; ///< Channel State. + UINT8 Reserved2 : 6; ///< Reserved. +} IPMI_ENABLE_MESSAGE_CHANNEL_REQUEST; + +/** + Enable message channel command response structure. +*/ +typedef struct { + UINT8 CompletionCode; /// Completion code. + UINT8 ChannelNumber : 4; ///< Channel Number. + UINT8 Reserved1 : 4; ///< Reserved. + UINT8 ChannelState : 1; ///< Channel State. + UINT8 Reserved2 : 7; ///< Reserved. +} IPMI_ENABLE_MESSAGE_CHANNEL_RESPONSE; + +/** + Set System Info Parameters Command. +*/ +#define IPMI_APP_SET_SYSTEM_INFO 0x58 + +/** + System Info String Encoding. +*/ +typedef enum { + SysInfoAscii, ///< Ascii + SysInfoUtf8, ///< Utf8 + SysInfoUnicode ///< Unicode +} SYSTEM_INFO_STRING_ENCODING; + +/** + System parameter selector. +*/ +typedef enum { + SysInfoSetInProgress, ///< SetInProgress. + SysInfoFirmwareVersion, ///< FirmwareVersion. + SysInfoSystemName, ///< SystemName. + SysInfoPrimaryOsName, ///< PrimaryOsName. + SysInfoPresentOsName, ///< PresentOsName. + SysInfoPresentOsVersion, ///< PresentOsVersion. + SysInfoBmcUrl, ///< BmcUrl. + SysInfoHyperviserUrl, ///< HyperviserUrl. +} SYSTEM_INFO_PARAMETER_SELECTOR; + +/** + System info set state. +*/ +typedef enum { + SysInfoStateSetComplete, ///< SetComplete. + SysInfoStateSetInProgress, ///< SetInProgress. + SysInfoStateCommitWrite, ///< StateCommitWrite. + SysInfoStateReserved, ///< StateReserved. +} SYSTEM_INFO_SET_STATE; + +/** + Set system info parameter command request Structure. +*/ +typedef struct { + UINT8 ParamSelector; /// Parameter selector. + UINT8 SetSelector; ///< Data 1 + UINT8 Data[16]; ///< Data 2:17 +} SET_SYSTEM_INFO_REQUEST; + +/** + Get System Info Parameters Command. +*/ +#define IPMI_APP_GET_SYSTEM_INFO 0x59 + +/** + Get system info Command request Structure. +*/ +typedef struct { + UINT8 Reserved : 7; /// Reserved. + UINT8 GetParam : 1; ///< Get Parameter. + UINT8 ParamSelector; ///< Parameter Selector. + UINT8 SetSelector; ///< Set selector. + UINT8 BlockSelector; ///< Block selector. +} GET_SYSTEM_INFO_REQUEST; + +/** + Get system info command response Structure. +*/ +typedef struct { + UINT8 CompletionCode; /// Completion code. + UINT8 ParamRevision; /// Parameter Revision + union { + struct { + UINT8 State : 2; ///< State. + UINT8 Reserved : 6; ///< Reserved. + } Progress; + UINT8 SetSelector; ///< Set Selector. + } Data1; + UINT8 Data[16]; ///< Data 2:17. +} GET_SYSTEM_INFO_RESPONSE; + +/** + Get system Guid Command response Structure. +*/ +typedef struct { + UINT8 CompletionCode; /// Completion code. + UINT8 Node[6]; ///< Node. + UINT8 Clock[2]; ///< Clock. + UINT16 Time_High; ///< Time High. + UINT16 Time_Mid; ///< Time Middle. + UINT32 Time_Low; ///< Time Low. +} GET_SYSTEM_GUID_RESPONSE; + +/** + Get Bt interface Capability Command response Structure. +*/ +typedef struct { + UINT8 CompletionCode; /// Completion code. + UINT8 OutstaningReq; ///< Number of outstanding requests supp= orted. + UINT8 InputBuffSize; ///< Input (request) buffer message size= in bytes. + UINT8 OutputBuffSize; ///< Output (response) buffer message si= ze in bytes. + UINT8 BmcReqToResTime; ///< BMC Request-to-Response time, in se= conds. + UINT8 RecommandedRetires; ///< Recommended retries (1 based +} IPMI_BT_INTERFACE_CAPABILITY_RES; + +/** + Get System interface Capability Command request Structure. +*/ +typedef struct { + UINT8 SystemInterfaceType : 4; /// System Interface Type 0h =3D S= SIF,1h =3D KCS ,2h =3D SMIC. + UINT8 Reserved : 4; ///< Reserved. +} IPMI_GET_SYSTEM_INTERFACE_CAPABILITY_REQ; + +/** + Get System interface Capability Command response Structure. +*/ +typedef struct { + UINT8 CompletionCode; /// Completion code. + UINT8 Reserved; ///< Reserved. + UINT8 SsifVersion : 3; ///< Ssif Version. + UINT8 PecSupport : 1; ///< Pec Support. + UINT8 Reserved1 : 2; ///< Reserved. + UINT8 TransactionSupport : 2; ///< Transaction Support. + UINT8 InputMessageSize; ///< Input Message Size. + UINT8 OutputMessageSize; ///< Output Message Size. +} IPMI_GET_SYSTEM_INTERFACE_CAPABILITY_RES; + +/** + Get BMC global Enable Command response Structure. +*/ +typedef struct { + UINT8 CompletionCode; /// Completion code. + UINT8 ReceiveMsgQueueInterrupt : 1; ///< Receive Message Queue= Interrupt Enable bit. + UINT8 EventMsgBufferFullInterrupt : 1; ///< Event Message Buffer = Full Interrupt Enable bit. + UINT8 EventMsgBuffer : 1; ///< Event Message Buffer = Enable bit. + UINT8 SystemEventLogging : 1; ///< System Event Logging = Enable bit. + UINT8 Reserved : 1; ///< Reserved. + UINT8 OEM0 : 1; ///< oem0 Enable bit. + UINT8 OEM1 : 1; ///< oem1 Enable bit. + UINT8 OEM2 : 1; ///< Oem2 Enable bit. +} IPMI_BMC_GLOBAL_ENABLES_RES; +#pragma pack() + +#endif // #ifndef _IPMI_NETFN_APP_DEFINITIONS_H_ diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ipmi= Transport2Definitions.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg= /Include/IpmiTransport2Definitions.h new file mode 100644 index 0000000000..74b4d8743e --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/IpmiTranspo= rt2Definitions.h @@ -0,0 +1,152 @@ +/** @file IpmiTransport2Definitions.h + Bmc Common interface library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _IPMI_TRANSPORT2_DEFINITIONS_H_ +#define _IPMI_TRANSPORT2_DEFINITIONS_H_ + +typedef struct _IPMI_TRANSPORT2 IPMI_TRANSPORT2; + +/** @internal + BT Interface. +*/ +typedef struct { + UINT8 InterfaceState; /// Interface state. + UINT16 CtrlPort; ///< Control port. + UINT16 ComBuffer; ///< Communication buffer port. + UINT16 IntMaskPort; ///< Interrupt mask port. + UINTN MmioBaseAddress; ///< Mmio base address. + UINTN BaseAddressRange; ///< Mmio base address range to + ///< differentiate port address. + UINT8 AccessType; ///< Access type - IO or MMIO. + UINT32 BtRetryCount; ///< Delay counter for retry. + UINT8 BtSoftErrorCount; ///< Soft error count. + BOOLEAN BtTransportLocked; ///< Interface lock. + UINT8 HosttoBmcBufferSize; ///< Host to Bmc Buffer Size. + UINT8 BmctoHostBufferSize; ///< Bmc to Host Buffer Size. +} BT_SYSTEM_INTERFACE; + +/** @internal + SSIF Interface. +*/ +typedef struct { + UINT8 InterfaceState; /// Interface state. + EFI_GUID SsifInterfaceApiGuid; ///< Smbus instance guid. + UINTN SsifInterfaceApiPtr; ///< Smbus instance pointer. + UINT8 RwSupport; ///< Read-write support. + UINT16 SsifRetryCounter; ///< Retry counter. + BOOLEAN PecSupport; ///< Packet Error Check support. + BOOLEAN SmbAlertSupport; ///< Smbus alert support. + UINT8 SsifSoftErrorCount; ///< Soft error count. + BOOLEAN SsifTransportLocked; ///< Interface lock. +} SSIF_SYSTEM_INTERFACE; + +/** @internal + IPMB Interface. +*/ +typedef struct { + /// Interface state. + UINT8 InterfaceState; + EFI_GUID IpmbInterfaceApiGuid; ///< Ipmb instance guid. + UINTN IpmbInterfaceApiPtr; ///< Ipmb instance pointer. + UINT8 IpmbSoftErrorCount; ///< Soft error count. + BOOLEAN IpmbTransportLocked; ///< Interface lock. +} IPMB_SYSTEM_INTERFACE; + +/** @internal + System Interface. +*/ +typedef struct { + UINT8 KcsInterfaceState; + BT_SYSTEM_INTERFACE Bt; ///< Bt interface. + SSIF_SYSTEM_INTERFACE Ssif; ///< Ssif interface. + IPMB_SYSTEM_INTERFACE Ipmb; +} IPMI_SYSTEM_INTERFACE; + +/** @inrernal + Ipmi Interface Access Type. +*/ +typedef enum { + IpmiMmioAccess, ///< Mmio Access. + IpmiIoAccess ///< Io Access. +} IPMI_ACCESS_TYPE; + +/** @internal + Host to BMC Interface Type. +*/ +typedef enum { + SysInterfaceUnknown, ///< Unknown interface type. + SysInterfaceKcs, ///< Kcs interface. + SysInterfaceSmic, ///< Smic interface. + SysInterfaceBt, ///< Bt interface. + SysInterfaceSsif, ///< Ssif interface. + SysInterfaceIpmb, ///< Ipmb interface. + SysInterfaceMax ///< Maximum interface type. +} SYSTEM_INTERFACE_TYPE; + +/** @internal + BMC Interface status. +*/ +typedef enum { + BmcStatusOk, ///< Bmc status Ok. + BmcStatusSoftFail, ///< Bmc status Soft fail. + BmcStatusHardFail, ///< Bmc status Hard fail. + BmcStatusUpdateInProgress ///< Bmc status Update in progress. +} BMC_INTERFACE_STATUS; + +/** @internal + Ipmi Interface state. +*/ +typedef enum { + IpmiInterfaceNotReady, ///< Interface Not Ready. + IpmiInterfaceInitialized, ///< Interface Initialized. + IpmiInterfaceInitError, ///< Interface Initialization Error. +} IPMI_INTERFACE_STATE; + +// +// IPMI Function Prototypes +// +typedef + EFI_STATUS +(EFIAPI *IPMI_SEND_COMMAND2)( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunct= ion, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *Command= Data, + IN UINT32 CommandD= ataSize, + OUT UINT8 *Respons= eData, + OUT UINT32 *Respons= eDataSize + ); + +typedef + EFI_STATUS +(EFIAPI *IPMI_SEND_COMMAND2Ex)( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFun= ction, + IN UINT8 Lun, + IN UINT8 Comman= d, + IN UINT8 *Comma= ndData, + IN UINT32 Comman= dDataSize, + OUT UINT8 *Respo= nseData, + OUT UINT32 *Respo= nseDataSize, + IN SYSTEM_INTERFACE_TYPE Interf= aceType + ); + +struct _IPMI_TRANSPORT2 { + UINT64 Revision; + IPMI_SEND_COMMAND2 IpmiSubmitCommand2; + IPMI_SEND_COMMAND2Ex IpmiSubmitCommand2Ex; + IPMI_SYSTEM_INTERFACE Interface; ///< System interface= . + SYSTEM_INTERFACE_TYPE InterfaceType; ///< Bmc Interface Ty= pe. + BMC_INTERFACE_STATUS IpmiTransport2BmcStatus; + EFI_HANDLE IpmiHandle; + UINT8 CompletionCode; +}; + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Libr= ary/BmcCommonInterfaceLib.h b/Features/Intel/OutOfBandManagement/IpmiFeatur= ePkg/Include/Library/BmcCommonInterfaceLib.h new file mode 100644 index 0000000000..54f7b3c1c3 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/Bmc= CommonInterfaceLib.h @@ -0,0 +1,227 @@ +/** @file BmcCommonInterfaceLib.h + Bmc Common interface library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _BMC_COMMON_INTERFACE_LIB_H_ +#define _BMC_COMMON_INTERFACE_LIB_H_ + +#include +#include +#include + +#define IPMI_APP_SELFTEST_RESERVED 0xFF + +#define IPMI_GET_SET_IN_PROGRESS_RETRY_COUNT 10 +#define IPMI_BIT_CLEAR 0 +#define IPMI_SELECTOR_NONE 0 +#define IPMI_CLEAR_FLAG 0 +#define IPMI_SET_FLAG 1 +#define IPMI_STALL 1000 +#define MIN_TO_100MS 60 * 10 +#define MAX_BMC_CMD_FAIL_COUNT 10 + +// Completion code macros. +#define IPMI_COMPLETION_CODE_SUCCESS 0x00 +#define IPMI_COMPLETION_CODE_DEVICE_SPECIFIC_START 0x01 +#define IPMI_COMPLETION_CODE_DEVICE_SPECIFIC_END 0x7E +#define IPMI_COMPLETION_CODE_COMMAND_SPECIFIC_START 0x80 +#define IPMI_COMPLETION_CODE_COMMAND_SPECIFIC_END 0xBE +#define IPMI_MAX_SOFT_COUNT 10 + +#define IPMI_MAX_BT_CMD_DATA_SIZE 0xFF + +#define IPMI_ERROR_COMPLETION_CODE(a) !((a =3D=3D IPMI_COMPLETION_CODE_SU= CCESS) || \ + ((a >=3D IPMI_COMPLETION_CODE= _DEVICE_SPECIFIC_START) && \ + (a <=3D IPMI_COMPLETION_CODE= _DEVICE_SPECIFIC_END)) || \ + ((a >=3D IPMI_COMPLETION_CODE= _COMMAND_SPECIFIC_START) && \ + (a <=3D IPMI_COMPLETION_CODE= _COMMAND_SPECIFIC_END)) \ + ) + +/*++ + +Routine Description: + Read 8 bit data from BMC port based on access type. + +Arguments: + AccessType - Specifies MMIO or IO access. + Address - Specifies Address to read. + +Returns: + UINT8 - Data read. + +--*/ +UINT8 +IpmiBmcRead8 ( + IN UINT8 AccessType, + IN UINTN Address + ); + +/*++ + +Routine Description: + Write 8 bit data to BMC port based on access type. + +Arguments: + AccessType - Specifies MMIO or IO access. + Address - Specifies Address to write. + Data - Specifies data to be written. + +Returns: + UINT8 - Data written. + +--*/ +UINT8 +IpmiBmcWrite8 ( + IN UINT8 AccessType, + IN UINTN Address, + IN UINT8 Data + ); + +/*++ + +Routine Description: + Acquire the lock to use the IPMI transport. + +Arguments: + Lock - Pointer to Lock. + +Returns: + VOID - Returns nothing. + +--*/ +VOID +IpmiTransportAcquireLock ( + OUT BOOLEAN *Lock + ); + +/*++ + +Routine Description: + Release the lock of IPMI transport. + +Arguments: + Lock - Pointer to Lock. + +Returns: + VOID - Returns nothing. + +--*/ +VOID +IpmiTransportReleaseLock ( + OUT BOOLEAN *Lock + ); + +/*++ + +Routine Description: + Returns the Lock state of IPMI transport. + +Arguments: + Lock - Pointer to Lock. + +Returns: + TRUE - IPMI transport is in lock state. + FALSE - IPMI transport is in release state. +--*/ +BOOLEAN +IpmiIsIpmiTransportlocked ( + IN BOOLEAN *Lock + ); + +/*++ + +Routine Description: + Updates the SoftErrorCount of specific interface based on the BMC Error = input. + +Arguments: + BmcError - BMC Error. + Interface - Interface pointer to update soft error count. + InterfaceType - Interface type to communicate. + +Returns: + EFI_SUCCESS - Updated SoftErrorCount of specific interface. + EFI_INVALID_PARAMETER - Invalid Interface pointer or Interface type. +--*/ +EFI_STATUS +IpmiUpdateSoftErrorCount ( + IN UINT8 BmcError, + IN OUT IPMI_SYSTEM_INTERFACE *Interface, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ); + +/*++ + +Routine Description: + Check the BMC Interface self test for the specified Interface. + +Arguments: + IpmiTransport2 - IPMI Interface pointer. + BmcStatus - BMC Interface status. + InterfaceType - Interface type to communicate. + +Returns: + EFI_SUCCESS - BMC self test command success. + EFI_INVALID_PARAMETER - Invalid Interface pointer or Interface type. +--*/ +EFI_STATUS +CheckSelfTestByInterfaceType ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2, + IN OUT BMC_INTERFACE_STATUS *BmcStatus, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ); + +/*++ + +Routine Description: + Initialize BT interface specific data. + +Arguments: + IpmiTransport2 - IPMI transport2 protocol pointer. + +Returns: + Status. +--*/ +EFI_STATUS +InitBtInterfaceData ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +/*++ + +Routine Description: + Initialize SSIF interface specific data. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Return status while initializing interface. +--*/ +EFI_STATUS +InitSsifInterfaceData ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +/*++ + +Routine Description: + Initialize IPMB interface specific data. + +Arguments: + IpmiTransport2 - Pointer to IPMI Transport2 instance. + +Returns: + EFI_SUCCESS - Interface is successfully initialized. + Others - Error status while initializing interface. +--*/ +EFI_STATUS +InitIpmbInterfaceData ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Libr= ary/BtInterfaceLib.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/In= clude/Library/BtInterfaceLib.h new file mode 100644 index 0000000000..e9697e7b49 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/BtI= nterfaceLib.h @@ -0,0 +1,78 @@ +/** @file BtInterfaceLib.h + BT interface common macros and declarations. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _BT_INTERFACE_LIB_H_ +#define _BT_INTERFACE_LIB_H_ + +#include +#include + +#define IPMI_MAX_BT_CMD_DATA_SIZE 0xFF +#define IPMI_CLR_WR_PTR_BIT 0x01 +#define IPMI_CLR_RD_PTR_BIT 0x02 +#define IPMI_H2B_ATN_BIT 0x04 +#define IPMI_B2H_ATN_BIT 0x08 +#define IPMI_H_BUSY 0x40 +#define IPMI_B_BUSY_BIT 0x80 + +/*++ + +Routine Description: + BT interface send command implementation. + +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. + Context - NULL here. + +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 +IpmiBtSendCommandToBmc ( + IN IPMI_TRANSPORT2 *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: + Execute the Get BT Interface Capability command and update the input + and output buffer value of IPMI transport2. + +Arguments: + IpmiTransport2 - IPMI transport2 protocol Instance. + +Returns: + VOID - Nothing. +--*/ +VOID +GetBtInterfaceCapability ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Libr= ary/IpmbInterfaceLib.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= Include/Library/IpmbInterfaceLib.h new file mode 100644 index 0000000000..6d6af297c0 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/Ipm= bInterfaceLib.h @@ -0,0 +1,94 @@ +/** @file IpmbInterfaceLib.h + IPMB interface common function declarations and macros. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _IPMB_INTERFACE_LIB_H_ +#define _IPMB_INTERFACE_LIB_H_ + +#include +#include +#include + +#define IPMI_MAX_IPMB_CMD_DATA_SIZE 0xFF +#define IPMI_READ_FLAG 1 +#define IPMI_WRITE_FLAG 0 +#define IPMI_SEQ_NO 0 // IPMB Message Sequence Number. + +/*++ + +Routine Description: + Locate I2c Ppi/Protocol instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Status returned from functions used. +--*/ +EFI_STATUS +IpmiGetI2cApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +/*++ + +Routine Description: + Send IPMI command through IPMB interface. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - I2C device slave address. + RequestPacket - Pointer to an EFI_I2C_REQUEST_PACKET structure describin= g the I2C transaction. + +Returns: + Status - Status of the Send I2c command. +--*/ +EFI_STATUS +IpmiI2cSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN UINTN SlaveAddress, + IN EFI_I2C_REQUEST_PACKET *RequestPacket + ); + +/*++ + +Routine Description: + IPMB interface send command implementation. + +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. + Context - NULL here. + +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 +IpmiIpmbSendCommandToBmc ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT8 CommandDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT8 *ResponseDataSize, + IN VOID *Context + ); + +#endif // #ifndef _IPMB_INTERFACE_LIB_H diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Libr= ary/SsifInterfaceLib.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/= Include/Library/SsifInterfaceLib.h new file mode 100644 index 0000000000..c7682436c3 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Library/Ssi= fInterfaceLib.h @@ -0,0 +1,169 @@ +/** @file SsifInterfaceLib.h + SSIF interface common function declarations and macros. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _SSIF_INTERFACE_LIB_H +#define _SSIF_INTERFACE_LIB_H + +#include +#include +#include +#include + +#define IPMI_MAX_SSIF_CMD_DATA_SIZE 0xFF +#define IPMI_SMBUS_BLOCK_LENGTH 0x20 + +// Smbus Write Commands. +#define IPMI_SMBUS_SINGLE_WRITE_CMD 0x2 +#define IPMI_SMBUS_MULTI_WRITE_START_CMD 0x6 +#define IPMI_SMBUS_MULTI_WRITE_MIDDLE_CMD 0x7 +#define IPMI_SMBUS_MULTI_WRITE_END_CMD 0x8 + +// Smbus Read Commands. +#define IPMI_SMBUS_SINGLE_READ_CMD 0x3 +#define IPMI_SMBUS_MULTI_READ_START_CMD SMBUS_SINGLE_READ_CMD +#define IPMI_SMBUS_MULTI_READ_MIDDLE_CMD 0x9 +#define IPMI_SMBUS_MULTI_READ_END_CMD 0x9 +#define IPMI_SMBUS_MULTI_READ_RETRY_CMD 0xA + +#define IPMI_MULTI_READ_ZEROTH_STRT_BIT 0x0 +#define IPMI_MULTI_READ_FIRST_STRT_BIT 0x1 + +/*++ + +Routine Description: + Check the SMBUS alert pin status function. + +Arguments: + VOID - Nothing. + +Returns: + TRUE - Alert pin status is set. + FALSE - Alert pin status is not set. +--*/ +typedef BOOLEAN (SSIF_ALERT_PIN_CHECK) ( + VOID + ); + +/*++ + +Routine Description: + Execute the Get System Interface Capability command and update the RwSup= port + and PecSupport of Ipmi Instance. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + VOID - Nothing. +--*/ +VOID +GetSystemInterfaceCapability ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +/*++ + +Routine Description: + Execute the Get Global Enable command to get receive message queue inter= rupt. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + VOID - Nothing. +--*/ +VOID +GetGlobalEnables ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +/*++ + +Routine Description: + Locate Smbus instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Status returned while locating SMBUS instance. +--*/ +EFI_STATUS +IpmiGetSmbusApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ); + +/*++ + +Routine Description: + Send IPMI command through SMBUS instance. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - The SMBUS hardware address. + Command - This command is transmitted by the SMBus host controller= to the SMBus slave device.. + Operation - Operation to be performed. + PecCheck - Defines if Packet Error Code (PEC) checking is required = for this operation. + Length - Signifies the number of bytes that this operation will d= o. + Buffer - Contains the value of data to execute to + the SMBus slave device. The length of this buffer is ide= ntified by Length. + +Returns: + EFI_NOT_FOUND - SMBUS instance is not found. + Others - Return status of the SMBUS Execute operation. +--*/ +EFI_STATUS +IpmiSmbusSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ); + +/*++ + +Routine Description: + SSIF interface Ipmi send command Implementation + +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. + Context - NULL here. + +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 +IpmiSsifSendCommandToBmc ( + IN IPMI_TRANSPORT2 *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 + ); + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/= IpmiTransport2Ppi.h b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Inc= lude/Ppi/IpmiTransport2Ppi.h new file mode 100644 index 0000000000..a408474e90 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Ppi/IpmiTra= nsport2Ppi.h @@ -0,0 +1,23 @@ +/** @file + IPMI Ttransport2 PPI Header File. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _IPMI_TRANSPORT2_PPI_H_ +#define _IPMI_TRANSPORT2_PPI_H_ + +#include +#include + +#define PEI_IPMI_TRANSPORT2_PPI_GUID \ + { \ + 0x8122CEBD, 0xF4FD, 0x4EA8, 0x97, 0x6C, 0xF0, 0x30, 0xAD, 0xDC, 0x4C, = 0xB4 \ + } + +extern EFI_GUID gPeiIpmiTransport2PpiGuid; + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Prot= ocol/IpmiTransport2Protocol.h b/Features/Intel/OutOfBandManagement/IpmiFeat= urePkg/Include/Protocol/IpmiTransport2Protocol.h new file mode 100644 index 0000000000..c8db92b49a --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/Protocol/Ip= miTransport2Protocol.h @@ -0,0 +1,29 @@ +/** @file IpmiTransport2Protocol.h + IpmiTransport2 Protocol Header File. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _IPMI2_TRANSPORT2_PROTO_H_ +#define _IPMI2_TRANSPORT2_PROTO_H_ + +#include +#include + +#define IPMI_TRANSPORT2_PROTOCOL_GUID \ + { \ + 0x4a1d0e66, 0x5271, 0x4e22, { 0x83, 0xfe, 0x90, 0x92, 0x1b, 0x74, 0x82= , 0x13 } \ + } + +#define SMM_IPMI_TRANSPORT2_PROTOCOL_GUID \ + { \ + 0x1dbd1503, 0xa60, 0x4230, { 0xaa, 0xa3, 0x80, 0x16, 0xd8, 0xc3, 0xde,= 0x2f } \ + } + +extern EFI_GUID gIpmiTransport2ProtocolGuid; +extern EFI_GUID gSmmIpmiTransport2ProtocolGuid; + +#endif diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeatureP= kg.dec b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.d= ec index 8c1b902446..5df71300cb 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/IpmiFeaturePkg.dec @@ -9,6 +9,7 @@ # # Copyright (c) 2019-2021, Intel Corporation. All rights reserved.
# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -43,16 +44,36 @@ # IpmiBaseLib|Include/Library/IpmiBaseLib.h + ## @libraryclass Provides generic functions among all interfaces. + # + BmcCommonInterfaceLib|Include/Library/BmcCommonInterfaceLib.h + + ## @libraryclass Provides generic functions among BT interface. + # + BtInterfaceLib|Include/Library/BtInterfaceLib.h + + ## @libraryclass Provides generic functions among SSIF interface. + # + SsifInterfaceLib|Include/Library/SsifInterfaceLib.h + + ## @libraryclass Provides generic functions among IPMB interface. + # + IpmbInterfaceLib|Include/Library/IpmbInterfaceLib.h + [Guids] gIpmiFeaturePkgTokenSpaceGuid =3D {0xc05283f6, 0xd6a8, 0x48f3, {0x9b, = 0x59, 0xfb, 0xca, 0x71, 0x32, 0x0f, 0x12}} + gPeiIpmiHobGuid =3D {0xcb4d3e13, 0x1e34, 0x4373, {0x8a, 0= x81, 0xe9, 0x0, 0x10, 0xf1, 0xdb, 0xa4}} [Ppis] gPeiIpmiTransportPpiGuid =3D {0x7bf5fecc, 0xc5b5, 0x4b25, {0x81, 0x1b, 0= xb4, 0xb5, 0xb, 0x28, 0x79, 0xf7}} + gPeiIpmiTransport2PpiGuid =3D {0x8122CEBD, 0xF4FD, 0x4EA8, { 0x97, 0x6C,= 0xF0, 0x30, 0xAD, 0xDC, 0x4C, 0xB4 }} [Protocols] gIpmiTransportProtocolGuid =3D {0x6bb945e8, 0x3743, 0x433e, {0xb9, 0x0e= , 0x29, 0xb3, 0x0d, 0x5d, 0xc6, 0x30}} gSmmIpmiTransportProtocolGuid =3D {0x8bb070f1, 0xa8f3, 0x471d, {0x86, 0= x16, 0x77, 0x4b, 0xa3, 0xf4, 0x30, 0xa0}} gEfiVideoPrintProtocolGuid =3D {0x3dbf3e06, 0x9d0c, 0x40d3, {0xb2, 0= x17, 0x45, 0x5f, 0x33, 0x9e, 0x29, 0x09}} + gIpmiTransport2ProtocolGuid =3D { 0x4A1D0E66, 0x5271, 0x4E22, { 0x83, 0x= FE, 0x90, 0x92, 0x1B, 0x74, 0x82, 0x13 }} + gSmmIpmiTransport2ProtocolGuid =3D { 0x1DBD1503, 0x0A60, 0x4230, { 0xAA,= 0xA3, 0x80, 0x16, 0xD8, 0xC3, 0xDE, 0x2F }} [PcdsFeatureFlag] gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE|BOOLEAN|0xA0000= 001 @@ -61,6 +82,46 @@ gIpmiFeaturePkgTokenSpaceGuid.PcdMaxSOLChannels|3|UINT8|0xF0000001 #When True, BIOS will send a Pre-Boot signal to BMC gIpmiFeaturePkgTokenSpaceGuid.PcdSignalPreBootToBmc|FALSE|BOOLEAN|0xF000= 0002 + #typedef enum { + # SysInterfaceUnknown, // Unknown interface type. + # SysInterfaceKcs, // Kcs interface =3D 1. + # SysInterfaceSmic, // Smic interface =3D 2. + # SysInterfaceBt, // Bt interface =3D 3. + # SysInterfaceSsif, // Ssif interface =3D 4. + # SysInterfaceMax // Maximum interface type. + #} SYSTEM_INTERFACE_TYPE; + #While selecting Default Interface type, the respective Interface Suppor= t should need to be Enabled, else the IPMI will be unsupported. + #Example, for SysInterfaceKcs, PcdKcsInterfaceSupport Should be enable. + gIpmiFeaturePkgTokenSpaceGuid.PcdDefaultSystemInterface|1|UINT8|0xF00000= 03 + + #BT Base address, retry counter and delay parameters + gIpmiFeaturePkgTokenSpaceGuid.PcdBtCommandRetryCounter|0x0004E400|UINT32= |0xF0000004 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort|0xE4|UINT16|0xF0000005 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferPort|0xE5|UINT16|0xF0000006 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtDelayPerRetry|15|UINT32|0xF0000007 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterruptMaskPort|0xE6|UINT16|0xF0000= 008 + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferSize|0x40|UINT8|0xF0000009 + + #SSIF slave address, retry counter and delay parameters + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifSlaveAddress|0x10|UINT16|0xF000000A + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay|0xCB20|UINT32|0= xF000000B + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifCommandtRetryCounter|0x5|UINT16|0xF= 000000C + + #Interface access type for BMC communication. 0-MMIO, 1-IO + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiDefaultAccessType|1|UINT8|0xF000000= D + gIpmiFeaturePkgTokenSpaceGuid.PcdMmioBaseAddress|0x0|UINT32|0xF000000E + gIpmiFeaturePkgTokenSpaceGuid.PcdBaseAddressRange|0x0|UINT32|0xF000000F + + gIpmiFeaturePkgTokenSpaceGuid.PcdBmcSlaveAddress|0x20|UINT32|0xF0000010 + + #Interface access support for KCS + gIpmiFeaturePkgTokenSpaceGuid.PcdKcsInterfaceSupport|0|UINT8|0xF0000011 + #Interface access support for BT + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterfaceSupport|0|UINT8|0xF0000012 + #Interface access support for SSIF + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifInterfaceSupport|0|UINT8|0xF0000013 + #Interface access support for IPMB + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmbInterfaceSupport|0|UINT8|0xF0000014 [PcdsDynamic, PcdsDynamicEx] gIpmiFeaturePkgTokenSpaceGuid.PcdFRB2EnabledFlag|TRUE|BOOLEAN|0xD0000001 diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/BmcCommonInterfaceLib.c b/Features/Intel/OutOfBandMana= gement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/BmcCommonInterfaceLi= b.c new file mode 100644 index 0000000000..6ef5efdac9 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/BmcCommonInterfaceLib.c @@ -0,0 +1,256 @@ +/** @file BmcCommonInterfaceLib.c + BmcCommonInterfaceLib generic functions for all interfaces. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + Read 8 bit data from BMC port based on access type. + +Arguments: + AccessType - Specifies MMIO or IO access. + Address - Specifies Address to read. + +Returns: + UINT8 - Data read. + +--*/ +UINT8 +IpmiBmcRead8 ( + IN UINT8 AccessType, + IN UINTN Address + ) +{ + if (AccessType =3D=3D IpmiIoAccess) { + return IoRead8 (Address); + } else { + return MmioRead8 (Address); + } +} + +/*++ + +Routine Description: + Write 8 bit data to BMC port based on access type. + +Arguments: + AccessType - Specifies MMIO or IO access. + Address - Specifies Address to write. + Data - Specifies data to be written. + +Returns: + UINT8 - Data written. + +--*/ +UINT8 +IpmiBmcWrite8 ( + IN UINT8 AccessType, + IN UINTN Address, + IN UINT8 Data + ) +{ + if (AccessType =3D=3D IpmiIoAccess) { + return IoWrite8 ( + Address, + Data + ); + } else { + return MmioWrite8 ( + Address, + Data + ); + } +} + +/*++ + +Routine Description: + Acquire the lock to use the IPMI transport. + +Arguments: + Lock - Pointer to Lock. + +Returns: + VOID - Returns nothing. + +--*/ +VOID +IpmiTransportAcquireLock ( + OUT BOOLEAN *Lock + ) +{ + *Lock =3D TRUE; +} + +/*++ + +Routine Description: + Release the lock of IPMI transport. + +Arguments: + Lock - Pointer to Lock. + +Returns: + VOID - Returns nothing. + +--*/ +VOID +IpmiTransportReleaseLock ( + OUT BOOLEAN *Lock + ) +{ + *Lock =3D FALSE; +} + +/*++ + +Routine Description: + Returns the Lock state of IPMI transport. + +Arguments: + Lock - Pointer to Lock. + +Returns: + TRUE - IPMI transport is in lock state. + FALSE - IPMI transport is in release state. +--*/ +BOOLEAN +IpmiIsIpmiTransportlocked ( + IN BOOLEAN *Lock + ) +{ + return *Lock; +} + +/*++ + +Routine Description: + Updates the SoftErrorCount of specific interface based on the BMC Error = input. + +Arguments: + BmcError - BMC Error. + Interface - Interface pointer to update soft error count. + InterfaceType - Interface type to communicate. + +Returns: + EFI_SUCCESS - Updated SoftErrorCount of specific interface. + EFI_INVALID_PARAMETER - Invalid Interface pointer or Interface type. +--*/ +EFI_STATUS +IpmiUpdateSoftErrorCount ( + IN UINT8 BmcError, + IN OUT IPMI_SYSTEM_INTERFACE *Interface, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ) +{ + UINT8 Errors[] =3D { 0xC0, 0xC3, 0xC4, 0xC9, 0xCE, 0xCF, 0xFF, 0x00 }; + UINT8 Index =3D 0; + + if ((Interface =3D=3D NULL) || (InterfaceType <=3D SysInterfaceUnknown) = || + (InterfaceType >=3D SysInterfaceMax)) + { + return EFI_INVALID_PARAMETER; + } + + while (Errors[Index] !=3D 0) { + if (Errors[Index] =3D=3D BmcError) { + switch (InterfaceType) { + case SysInterfaceBt: + Interface->Bt.BtSoftErrorCount++; + break; + + case SysInterfaceSsif: + Interface->Ssif.SsifSoftErrorCount++; + break; + + default: + break; + } + } + + Index++; + } + + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Check the BMC Interface self test for the specified Interface. + +Arguments: + IpmiTransport2 - IPMI Interface pointer. + BmcStatus - BMC Interface status. + InterfaceType - Interface type to communicate. + +Returns: + EFI_SUCCESS - BMC self test command success. + EFI_INVALID_PARAMETER - Invalid Interface pointer or Interface type. +--*/ +EFI_STATUS +CheckSelfTestByInterfaceType ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2, + IN OUT BMC_INTERFACE_STATUS *BmcStatus, + IN SYSTEM_INTERFACE_TYPE InterfaceType + ) +{ + EFI_STATUS Status; + IPMI_SELF_TEST_RESULT_RESPONSE BstStatus; + UINT32 ResponseDataSize; + + if ((IpmiTransport2 =3D=3D NULL) || (BmcStatus =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + ResponseDataSize =3D sizeof (IPMI_SELF_TEST_RESULT_RESPONSE); + + Status =3D IpmiTransport2->IpmiSubmitCommand2Ex ( + IpmiTransport2, + IPMI_NETFN_APP, + BMC_LUN, + IPMI_APP_GET_SELFTEST_RES= ULTS, + NULL, + 0, + (UINT8 *)&BstStatus, + &ResponseDataSize, + InterfaceType + ); + if (EFI_ERROR (Status)) { + *BmcStatus =3D BmcStatusHardFail; + return Status; + } + + if (BstStatus.CompletionCode =3D=3D IPMI_COMPLETION_CODE_SUCCESS) { + /* Check the self test results. Cases 55h - 58h are Ipmi defined + test results. Additional Cases are device specific test results.*/ + switch (BstStatus.Result) { + case IPMI_APP_SELFTEST_NO_ERROR: // 0x55 + case IPMI_APP_SELFTEST_NOT_IMPLEMENTED: // 0x56 + case IPMI_APP_SELFTEST_RESERVED: // 0xFF + *BmcStatus =3D BmcStatusOk; + break; + + case IPMI_APP_SELFTEST_ERROR: // 0x57 + *BmcStatus =3D BmcStatusSoftFail; + break; + + default: // 0x58 and Other Device Specific Hardware Error. + *BmcStatus =3D BmcStatusHardFail; + break; + } + } + + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/BmcCommonInterfaceLib.inf b/Features/Intel/OutOfBandMa= nagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/BmcCommonInterface= Lib.inf new file mode 100644 index 0000000000..33bb360c41 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/BmcCommonInterfaceLib.inf @@ -0,0 +1,26 @@ +## @file BmcCommonInterfaceLib.inf +# +# INF description file for BmcCommonInterfaceLib Library. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BmcCommonInterfaceLib + FILE_GUID =3D D86308F8-5246-4B2F-AC25-E3D17170D6EF + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.1 + LIBRARY_CLASS =3D BmcCommonInterfaceLib + +[Sources] + BmcCommonInterfaceLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/BtInterfaceLib/BtInterfaceLib.c b/Features/Intel/OutOf= BandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/BtInterfaceL= ib/BtInterfaceLib.c new file mode 100644 index 0000000000..37501758ad --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/BtInterfaceLib/BtInterfaceLib.c @@ -0,0 +1,605 @@ +/** @file BtInterfaceLib.c + BT Transport implementation library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include + +#define IPMI_BT_DELAY_PER_RETRY FixedPcdGet32 (PcdBtDelayPerRetry) + +/*++ + +Routine Description: + Get the BT interface port addresses based on access type. + +Arguments: + Interface - Pointer to System interface. + BtCtrlPort - Pointer to BT control port. + BtComBufferPort - Pointer to BT communication buffer port. + +Returns: + VOID - Nothing. + +--*/ +VOID +GetBtPortAddresses ( + IN IPMI_SYSTEM_INTERFACE *Interface, + OUT UINTN *BtCtrlPort, + OUT UINTN *BtComBufferPort + ) +{ + // Update Bt Ports based on Interface AccessType. + if (Interface->Bt.AccessType =3D=3D IpmiIoAccess) { + *BtCtrlPort =3D (UINTN)Interface->Bt.CtrlPort; + *BtComBufferPort =3D (UINTN)Interface->Bt.ComBuffer; + } else { + *BtCtrlPort =3D Interface->Bt.MmioBaseAddress; + *BtComBufferPort =3D *BtCtrlPort + Interface->Bt.BaseAddressRange; + } +} + +/*++ + +Routine Description: + Sends the command to BT interface BMC port. + +Arguments: + Interface - Pointer to System interface. + Context - NULL here. + Data - Pointer to command data that will be sent to BMC along with = Command. + DataSize - Size of the command data. + +Returns: + EFI_NOT_READY - Interface is not ready to send data. + EFI_SUCCESS - Command sent to BMC successfully. +--*/ +EFI_STATUS +SendDataToBtBmcPort ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN VOID *Context, + IN UINT8 *Data, + IN UINT8 DataSize + ) +{ + UINT8 BtCntlData; + UINT8 Index; + UINT32 Retry; + UINTN BtCtrlPort; + UINTN BtComBufferPort; + IPMI_ACCESS_TYPE AccessType; + UINT8 TempDataSize; + BOOLEAN MultipleDataSend; + UINT32 BtRetryCount; + + MultipleDataSend =3D FALSE; + BtRetryCount =3D Interface->Bt.BtRetryCount; + AccessType =3D Interface->Bt.AccessType; + + // Get Bt Ports addresses. + GetBtPortAddresses ( + Interface, + &BtCtrlPort, + &BtComBufferPort + ); + + do { + /* Wait for B_BUSY bit to clear (BMC ready to accept a request). + Default delay for each retry is 15 micro seconds.*/ + for (Retry =3D 0; Retry < BtRetryCount; Retry++) { + BtCntlData =3D IpmiBmcRead8 ( + AccessType, + BtCtrlPort + ); + if (!(BtCntlData & IPMI_B_BUSY_BIT)) { + break; + } + + MicroSecondDelay (IPMI_BT_DELAY_PER_RETRY); + } + + if (Retry =3D=3D BtRetryCount) { + return EFI_TIMEOUT; + } + + // Wait for H2B_ATN bit to clear (Acknowledgment of previous commands)= . + for (Retry =3D 0; Retry < BtRetryCount; Retry++) { + BtCntlData =3D IpmiBmcRead8 ( + AccessType, + BtCtrlPort + ); + if (!(BtCntlData & IPMI_H2B_ATN_BIT)) { + break; + } + + MicroSecondDelay (IPMI_BT_DELAY_PER_RETRY); + } + + if (Retry =3D=3D BtRetryCount) { + return EFI_TIMEOUT; + } + + // Set CLR_WR_PTR. + BtCntlData =3D IPMI_CLR_WR_PTR_BIT; + IpmiBmcWrite8 ( + AccessType, + BtCtrlPort, + BtCntlData + ); + + if (DataSize > Interface->Bt.HosttoBmcBufferSize ) { + TempDataSize =3D Interface->Bt.HosttoBmcBufferSize; + MultipleDataSend =3D TRUE; + } else { + TempDataSize =3D DataSize; + MultipleDataSend =3D FALSE; + } + + // Send each message byte out (write data to HOST2BMC buffer). + for (Index =3D 0; Index < TempDataSize; Index++) { + IpmiBmcWrite8 ( + AccessType, + BtComBufferPort, + *(Data + Index) + ); + } + + // Set H2B_ATN bit to inform BMC that data is available. + BtCntlData =3D IPMI_H2B_ATN_BIT; + IpmiBmcWrite8 ( + AccessType, + BtCtrlPort, + BtCntlData + ); + + // Command data size greater than available Input buffer size. + if (MultipleDataSend) { + Data =3D Data + TempDataSize; + DataSize -=3D TempDataSize; + + for (Retry =3D 0; Retry < BtRetryCount; Retry++) { + BtCntlData =3D IpmiBmcRead8 ( + AccessType, + BtCtrlPort + ); + if ((BtCntlData & IPMI_B_BUSY_BIT)) { + break; + } + + MicroSecondDelay (IPMI_BT_DELAY_PER_RETRY); + } + + if (Retry =3D=3D BtRetryCount) { + return EFI_TIMEOUT; + } + } + } while (MultipleDataSend); + + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Receives the Data from BT interface BMC port. + +Arguments: + Interface - Pointer to System interface. + Context - NULL here. + Data - Pointer to response data that is received from BMC. + DataSize - Size of the response data. + +Returns: + EFI_NOT_READY - Interface is not ready to receive data. + EFI_SUCCESS - Data received from BMC successfully. + EFI_INVALID_PARAMETER - Invalid parameter. +--*/ +EFI_STATUS +ReceiveBmcDataFromBtPort ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN VOID *Context, + OUT UINT8 *Data, + OUT UINT8 *DataSize + ) +{ + UINT8 BtCntlData; + UINT8 Length; + UINT8 TempDataSize; + UINT8 Index; + UINT32 Retry; + UINTN BtCtrlPort; + UINTN BtComBufferPort; + IPMI_ACCESS_TYPE AccessType; + BOOLEAN MultipleDataReceive; + UINT32 BtRetryCount; + + Length =3D 0; + MultipleDataReceive =3D FALSE; + BtRetryCount =3D Interface->Bt.BtRetryCount; + AccessType =3D Interface->Bt.AccessType; + + // Get Bt Ports addresses. + GetBtPortAddresses ( + Interface, + &BtCtrlPort, + &BtComBufferPort + ); + do { + /* Wait for B2H_ATN bit to be set,signaling data is available for host= . + Default delay for each retry is 15 micro seconds.*/ + for (Retry =3D 0; Retry < BtRetryCount; Retry++) { + BtCntlData =3D IpmiBmcRead8 ( + AccessType, + BtCtrlPort + ); + if (BtCntlData & IPMI_B2H_ATN_BIT) { + break; + } + + MicroSecondDelay (IPMI_BT_DELAY_PER_RETRY); + } + + if (Retry =3D=3D BtRetryCount) { + return EFI_TIMEOUT; + } + + // Set H_BUSY bit, indicating host is in process of reading data from = interface. + BtCntlData =3D IpmiBmcRead8 ( + AccessType, + BtCtrlPort + ); + if (!(BtCntlData & IPMI_H_BUSY)) { + BtCntlData =3D IPMI_H_BUSY; // most bits are rw1c, so cle= ar them. + IpmiBmcWrite8 ( + AccessType, + BtCtrlPort, + BtCntlData + ); + } + + // Clear B2H_ATN bit,to acknowledge receipt of message response. + BtCntlData =3D IPMI_B2H_ATN_BIT; // Most bits are rw1c, so clear= them. + IpmiBmcWrite8 ( + AccessType, + BtCtrlPort, + BtCntlData + ); + + // Set CLR_RD_PTR bit. + BtCntlData =3D IPMI_CLR_RD_PTR_BIT; // Most bits are rw1c, so clear= them. + IpmiBmcWrite8 ( + AccessType, + BtCtrlPort, + BtCntlData + ); + + if (!Length) { + // Read the data bytes from BMC. + Length =3D IpmiBmcRead8 ( + AccessType, + BtComBufferPort + ); + if (Length =3D=3D 0x00) { + return EFI_INVALID_PARAMETER; + } + + IpmiBmcWrite8 ( + AccessType, + BtCtrlPort, + BtCntlData + ); + + *DataSize =3D Length; + // Increment Length to include length field + Length++; + } + + if (Length > Interface->Bt.BmctoHostBufferSize) { + TempDataSize =3D Interface->Bt.BmctoHostBufferSize; + MultipleDataReceive =3D TRUE; + } else { + TempDataSize =3D Length; + MultipleDataReceive =3D FALSE; + } + + for (Index =3D 0; Index < TempDataSize; Index++) { + *(Data + Index) =3D IpmiBmcRead8 ( + AccessType, + BtComBufferPort + ); + } + + // Clear H_BUSY bit indicating host is done reading data from BMC. + BtCntlData =3D IpmiBmcRead8 ( + AccessType, + BtCtrlPort + ); + if (BtCntlData & IPMI_H_BUSY) { + BtCntlData =3D IPMI_H_BUSY; // Most bits are rw1c, so cle= ar them. + IpmiBmcWrite8 ( + AccessType, + BtCtrlPort, + BtCntlData + ); + } + + if (MultipleDataReceive) { + Data =3D Data + TempDataSize; + Length -=3D TempDataSize; + } + } while (MultipleDataReceive); + + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + BT interface send command implementation. + +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. + Context - NULL here. + +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 +IpmiBtSendCommandToBmc ( + IN IPMI_TRANSPORT2 *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 + ) +{ + UINT8 DataSize; + EFI_STATUS Status; + UINT8 Seq; + UINT8 CmdDataBuffer[IPMI_MAX_BT_CMD_DATA_SIZE]; + IPMI_SYSTEM_INTERFACE Interface; + + Seq =3D 0; + Interface =3D This->Interface; + + if (Interface.Bt.InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_NOT_READY; + } + + if (((CommandData =3D=3D NULL) && (CommandDataSize !=3D 0)) || (This =3D= =3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + if ((ResponseDataSize =3D=3D NULL) || ((ResponseData =3D=3D NULL) && *Re= sponseDataSize)) { + return EFI_INVALID_PARAMETER; + } + + if (IpmiIsIpmiTransportlocked (&Interface.Bt.BtTransportLocked)) { + return EFI_ACCESS_DENIED; + } else { + IpmiTransportAcquireLock (&Interface.Bt.BtTransportLocked); + } + + CmdDataBuffer[0] =3D (UINT8)CommandDataSize + 0x03; + CmdDataBuffer[1] =3D (UINT8)((NetFunction << 2) | (Lun & 0xfc)); + CmdDataBuffer[2] =3D Seq; + CmdDataBuffer[3] =3D Command; + + if (CommandDataSize > 0) { + if (CommandData =3D=3D NULL) { + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + return EFI_INVALID_PARAMETER; + } + + if (CommandDataSize <=3D (IPMI_MAX_BT_CMD_DATA_SIZE - 4)) { + CopyMem ( + &CmdDataBuffer[4], + CommandData, + CommandDataSize + ); + } else { + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + return EFI_BAD_BUFFER_SIZE; + } + } + + Status =3D SendDataToBtBmcPort ( + &Interface, + Context, + CmdDataBuffer, + (UINT8)(CommandDataSize + 4) + ); + + if (Status !=3D EFI_SUCCESS) { + Interface.Bt.BtSoftErrorCount++; + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + return Status; + } + + DataSize =3D IPMI_MAX_BT_CMD_DATA_SIZE; + + Status =3D ReceiveBmcDataFromBtPort ( + &Interface, + Context, + CmdDataBuffer, + &DataSize + ); + + if (Status !=3D EFI_SUCCESS) { + Interface.Bt.BtSoftErrorCount++; + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + return Status; + } + + if (IPMI_ERROR_COMPLETION_CODE (CmdDataBuffer[4])) { + IpmiUpdateSoftErrorCount ( + CmdDataBuffer[4], + &Interface, + This->InterfaceType + ); + + // Write completion code into return buffer if ipmi command returns an= error. + if (*ResponseDataSize) { + if (ResponseData) { + *ResponseData =3D CmdDataBuffer[4]; + } + + *ResponseDataSize =3D 1; + } + + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + return EFI_DEVICE_ERROR; + } + + if (DataSize < 4) { + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + return EFI_DEVICE_ERROR; + } + + if ((DataSize - 3) > *((UINT8 *)ResponseDataSize)) { + *ResponseDataSize =3D (UINT8)(DataSize - 3); + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + return EFI_BUFFER_TOO_SMALL; + } + + // Copying the response data into ResponseData buffer. + CopyMem ( + ResponseData, + &CmdDataBuffer[4], + (DataSize - 3) + ); + *ResponseDataSize =3D (UINT8)(DataSize - 3); + + IpmiTransportReleaseLock (&Interface.Bt.BtTransportLocked); + + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Execute the Get BT Interface Capability command and update the input + and output buffer value of IPMI transport2. + +Arguments: + IpmiTransport2 - IPMI transport2 protocol Instance. + +Returns: + VOID - Nothing. +--*/ +VOID +GetBtInterfaceCapability ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + IPMI_BT_INTERFACE_CAPABILITY_RES Responsedata; + UINT32 ResponseSize; + + ResponseSize =3D sizeof (IPMI_BT_INTERFACE_CAPABILITY_RES); + + Status =3D IpmiTransport2->IpmiSubmitCommand2 ( + IpmiTransport2, + IPMI_NETFN_APP, + BMC_LUN, + IPMI_APP_GET_BT_INTERFACE_C= APABILITY, + NULL, + 0, + (UINT8 *)&Responsedata, + &ResponseSize + ); + + if (EFI_ERROR (Status) || Responsedata.CompletionCode) { + DEBUG ((DEBUG_ERROR, " IPMI_APP_GET_BT_INTERFACE_CAPABILITY Status: %r= Completion code: %x\n", Status, Responsedata.CompletionCode)); + return; + } + + IpmiTransport2->Interface.Bt.HosttoBmcBufferSize =3D Responsedata.InputB= uffSize; + IpmiTransport2->Interface.Bt.BmctoHostBufferSize =3D Responsedata.Output= BuffSize; + + DEBUG ((DEBUG_ERROR, " InputBuffSize:%x OutBuffSize%x BtRetry %x Status= %r \n", IpmiTransport2->Interface.Bt.HosttoBmcBufferSize, IpmiTransport2->= Interface.Bt.BmctoHostBufferSize, Responsedata.RecommandedRetires, Status))= ; + + return; +} + +/*++ + +Routine Description: + Initialize BT interface specific data. + +Arguments: + IpmiTransport2 - IPMI transport2 protocol pointer. + +Returns: + Status. +--*/ +EFI_STATUS +InitBtInterfaceData ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + BMC_INTERFACE_STATUS BmcStatus; + EFI_STATUS Status; + + if (IpmiTransport2->Interface.Bt.InterfaceState =3D=3D IpmiInterfaceInit= ialized) { + return EFI_SUCCESS; + } + + IpmiTransport2->Interface.Bt.CtrlPort =3D FixedPcdGet16 (PcdB= tControlPort); // BT Control Port + IpmiTransport2->Interface.Bt.ComBuffer =3D FixedPcdGet16 (PcdB= tBufferPort); // BT Buffer Port + IpmiTransport2->Interface.Bt.IntMaskPort =3D FixedPcdGet16 (PcdB= tInterruptMaskPort); // BT IntMask Port + IpmiTransport2->Interface.Bt.BtRetryCount =3D FixedPcdGet32 (PcdB= tCommandRetryCounter); // BT retry count + IpmiTransport2->Interface.Bt.HosttoBmcBufferSize =3D FixedPcdGet8 (PcdBt= BufferSize); // Host to Bmc Buffer Size. + IpmiTransport2->Interface.Bt.BmctoHostBufferSize =3D FixedPcdGet8 (PcdBt= BufferSize); // Bmc to Host Buffer Size. + + if (FixedPcdGet8 (PcdIpmiDefaultAccessType)) { + IpmiTransport2->Interface.Bt.AccessType =3D IpmiIoAccess; + IpmiTransport2->Interface.Bt.MmioBaseAddress =3D 0; + IpmiTransport2->Interface.Bt.BaseAddressRange =3D 0; + } else { + IpmiTransport2->Interface.Bt.AccessType =3D IpmiMmioAccess; + IpmiTransport2->Interface.Bt.MmioBaseAddress =3D FixedPcdGet64 (PcdMm= ioBaseAddress); + IpmiTransport2->Interface.Bt.BaseAddressRange =3D FixedPcdGet64 (PcdBa= seAddressRange); + } + + IpmiTransportReleaseLock (&IpmiTransport2->Interface.Bt.BtTransportLocke= d); + IpmiTransport2->Interface.Bt.InterfaceState =3D IpmiInterfaceInitialized= ; + + Status =3D CheckSelfTestByInterfaceType ( + IpmiTransport2, + &BmcStatus, + SysInterfaceBt + ); + if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { + IpmiTransport2->Interface.Bt.InterfaceState =3D IpmiInterfaceInitError= ; + return Status; + } + + GetBtInterfaceCapability (IpmiTransport2); + + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/BtInterfaceLib/BtInterfaceLib.inf b/Features/Intel/Out= OfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/BtInterfac= eLib/BtInterfaceLib.inf new file mode 100644 index 0000000000..1dd4386204 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/BtInterfaceLib/BtInterfaceLib.inf @@ -0,0 +1,39 @@ +## @file BtInterfaceLib.inf +# +# INF description file for BtInterfaceLib common library. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BtInterfaceLib + FILE_GUID =3D DAFB6AEE-0275-45E4-A33C-E3348149C5BF + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.1 + LIBRARY_CLASS =3D BtInterfaceLib + +[Sources] + BtInterfaceLib.c + +[Packages] + MdePkg/MdePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + TimerLib + BmcCommonInterfaceLib + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdBtCommandRetryCounter + gIpmiFeaturePkgTokenSpaceGuid.PcdBtControlPort + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferPort + gIpmiFeaturePkgTokenSpaceGuid.PcdBtDelayPerRetry + gIpmiFeaturePkgTokenSpaceGuid.PcdBtInterruptMaskPort + gIpmiFeaturePkgTokenSpaceGuid.PcdBtBufferSize + gIpmiFeaturePkgTokenSpaceGuid.PcdBaseAddressRange + gIpmiFeaturePkgTokenSpaceGuid.PcdMmioBaseAddress + gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiDefaultAccessType diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/IpmbInterfaceLib/DxeIpmbInterfaceLib.c b/Features/Inte= l/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbI= nterfaceLib/DxeIpmbInterfaceLib.c new file mode 100644 index 0000000000..80a3a1afe9 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/DxeIpmbInterfaceLib.c @@ -0,0 +1,103 @@ +/** @file DxeIpmbInterfaceLib.c + IPMB Transport Dxe phase Implementation library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + Send IPMI command through IPMB interface. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - I2C device slave address. + RequestPacket - Pointer to an EFI_I2C_REQUEST_PACKET structure describin= g the I2C transaction. + +Returns: + Status - Status of the Send I2c command. +--*/ +EFI_STATUS +IpmiI2cSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN UINTN SlaveAddress, + IN EFI_I2C_REQUEST_PACKET *RequestPacket + ) +{ + EFI_STATUS Status =3D EFI_NOT_FOUND; + EFI_I2C_MASTER_PROTOCOL *I2cMasterTransmit =3D NULL; + + I2cMasterTransmit =3D (EFI_I2C_MASTER_PROTOCOL *)Interface->Ipmb.IpmbInt= erfaceApiPtr; + + if (I2cMasterTransmit !=3D NULL) { + Status =3D I2cMasterTransmit->StartRequest ( + I2cMasterTransmit, + SlaveAddress, + RequestPacket, + NULL, + NULL + ); + } + + DEBUG ((DEBUG_INFO, "I2cMasterTransmit->StartRequest Status =3D %r\n", S= tatus)); + return Status; +} + +/*++ + +Routine Description: + Locate I2c Ppi/Protocol instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Status returned from functions used. +--*/ +EFI_STATUS +IpmiGetI2cApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + EFI_I2C_MASTER_PROTOCOL *I2cMasterTransmit =3D NULL; + BMC_INTERFACE_STATUS BmcStatus; + + IpmiTransport2->Interface.Ipmb.IpmbInterfaceApiGuid =3D gEfiI2cMasterPro= tocolGuid; + + // Locate the I2C DXE Protocol for Communication. + Status =3D gBS->LocateProtocol ( + &gEfiI2cMasterProtocolGuid, + NULL, + (VOID **)&I2cMasterTransmit + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInit= ialized; + IpmiTransport2->Interface.Ipmb.IpmbInterfaceApiPtr =3D (UINTN)I2cMasterT= ransmit; + + Status =3D CheckSelfTestByInterfaceType ( + IpmiTransport2, + &BmcStatus, + SysInterfaceIpmb + ); + if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInitErr= or; + } + + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/IpmbInterfaceLib/DxeIpmbInterfaceLib.inf b/Features/In= tel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ipm= bInterfaceLib/DxeIpmbInterfaceLib.inf new file mode 100644 index 0000000000..641d7213d4 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/DxeIpmbInterfaceLib.inf @@ -0,0 +1,38 @@ +## @file DxeIpmbInterfaceLib.inf +# +# INF description file for IpmbInterfaceLib Library for DXE and UEFI driv= ers. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DxeIpmbInterfaceLib + FILE_GUID =3D 9068B213-4E53-427E-863C-8C7423509035 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.1 + LIBRARY_CLASS =3D IpmbInterfaceLib | DXE_DRIVER DXE_RUNTIME_DRIVER U= EFI_DRIVER UEFI_APPLICATION + +[Sources] + DxeIpmbInterfaceLib.c + IpmbInterfaceLibCommon.c + +[Packages] + MdePkg/MdePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + DebugLib + BaseMemoryLib + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + BmcCommonInterfaceLib + +[Protocols] + gEfiI2cMasterProtocolGuid + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdBmcSlaveAddress diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/IpmbInterfaceLib/IpmbInterfaceLibCommon.c b/Features/I= ntel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ip= mbInterfaceLib/IpmbInterfaceLibCommon.c new file mode 100644 index 0000000000..3837bf8ceb --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/IpmbInterfaceLibCommon.c @@ -0,0 +1,378 @@ +/** @file IpmbInterfaceLibCommon.c + IPMB Transport implementation common library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include + +#define IPMI_BMC_SLAVE_ADDRESS FixedPcdGet32 (PcdBmcSlaveAddress) + +/*++ + +Routine Description: + Verify the data integrity using checksum of BMC response data. + +Arguments: + ResponseData - Response data from BMC. + ResponseSize - Data size of response data. + +Returns: + EFI_SUCCESS - Data integrity is valid. + EFI_INVALID_PARAMETER - Invalid parameter. +--*/ +EFI_STATUS +CheckDataValidity ( + IN UINT8 *ResponseData, + IN UINT8 ResponseSize + ) +{ + UINT8 Index; + UINT8 CheckSum =3D 0; + UINT8 DataSum =3D 0; + + // Calculate header checksum. + for (Index =3D 0; Index < 2; Index++) { + DataSum +=3D ResponseData[Index]; + } + + // Verify header checksum. + CheckSum =3D (UINT8)(0x100 - DataSum); + if (CheckSum !=3D ResponseData[2]) { + return EFI_INVALID_PARAMETER; + } + + DataSum =3D 0; + + // Calculate information checksum. + for (Index =3D 3; Index < (ResponseSize - 1); Index++) { + DataSum +=3D ResponseData[Index]; + } + + // Verify information checksum. + CheckSum =3D (UINT8)(0x100 - DataSum); + if (CheckSum !=3D ResponseData[ResponseSize - 1]) { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Sends the command/data to IPMB interface. + +Arguments: + Interface - Pointer to System interface. + Context - NULL here. + Data - Pointer to command data that will be sent to BMC along with= Command. + DataSize - Size of the command data. + +Returns: + EFI_STATUS - Status returned from I2C send command. +--*/ +EFI_STATUS +SendDataToIpmbBmcPort ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN VOID *Context, + IN UINT8 *Data, + IN UINT8 DataSize + ) +{ + EFI_STATUS Status; + EFI_I2C_REQUEST_PACKET Packet; + + // Pack command data. + Packet.Operation[0].Buffer =3D Data; + Packet.Operation[0].LengthInBytes =3D DataSize; + Packet.Operation[0].Flags =3D IPMI_WRITE_FLAG; + + // Call the StartRequest function. + Status =3D IpmiI2cSendCommand ( + Interface, + IPMI_BMC_SLAVE_ADDRESS, + &Packet + ); + + return Status; +} + +/*++ + +Routine Description: + Receives the data from IPMB interface. + +Arguments: + Interface - Pointer to System interface. + Context - NULL here. + Data - Pointer to response data that is received from BMC. + DataSize - Size of the response data. + +Returns: + EFI_STATUS - Status returned from I2C send command. +--*/ +EFI_STATUS +ReceiveBmcDataFromIpmbPort ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN VOID *Context, + OUT UINT8 *Data, + OUT UINT8 *DataSize + ) +{ + EFI_STATUS Status; + EFI_I2C_REQUEST_PACKET Packet; + + // Pack command data. + Packet.Operation[0].Buffer =3D Data; + Packet.Operation[0].Flags =3D IPMI_READ_FLAG; + + // Call the StartRequest function. + Status =3D IpmiI2cSendCommand ( + Interface, + IPMI_BMC_SLAVE_ADDRESS, + &Packet + ); + + if (!EFI_ERROR (Status)) { + *DataSize =3D (UINT8)Packet.Operation[0].LengthInBytes; + } + + return Status; +} + +/*++ + +Routine Description: + IPMB interface send command implementation. + +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. + Context - NULL here. + +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 +IpmiIpmbSendCommandToBmc ( + IN IPMI_TRANSPORT2 *This, + IN UINT8 NetFunction, + IN UINT8 Lun, + IN UINT8 Command, + IN UINT8 *CommandData, + IN UINT8 CommandDataSize, + OUT UINT8 *ResponseData, + IN OUT UINT8 *ResponseDataSize, + IN VOID *Context + ) +{ + EFI_STATUS Status; + UINT8 DataSize; + UINT8 DataSum =3D 0; + UINT8 CheckSum =3D 0; + UINT8 Index; + UINT8 CmdDataBuffer[IPMI_MAX_IPMB_CMD_DATA_SIZE]; + IPMI_SYSTEM_INTERFACE Interface; + + Interface =3D This->Interface; + + if (Interface.Ipmb.InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_NOT_READY; + } + + if (!ResponseDataSize || (!ResponseData && *ResponseDataSize)) { + return EFI_INVALID_PARAMETER; + } + + if (IpmiIsIpmiTransportlocked (&Interface.Ipmb.IpmbTransportLocked)) { + return EFI_ACCESS_DENIED; + } else { + IpmiTransportAcquireLock (&Interface.Ipmb.IpmbTransportLocked); + } + + if (Interface.Ipmb.IpmbSoftErrorCount >=3D MAX_BMC_CMD_FAIL_COUNT) { + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return EFI_NOT_READY; + } + + /* Request Packet format. + | Slave Address | Netfun/Lun | CheckSum (Check Sum of previous data) + | Slave Address | Seq No | Command | Data 1..N + | CheckSum (Check Sum of previous data).*/ + CmdDataBuffer[0] =3D IPMI_BMC_SLAVE_ADDRESS; + CmdDataBuffer[1] =3D (UINT8)((NetFunction << 2) | (Lun & 0x03)); + + DataSum +=3D CmdDataBuffer[1] + IPMI_BMC_SLAVE_ADDRESS; + CheckSum =3D (UINT8)(0x100 - DataSum); + DataSum =3D 0; + + CmdDataBuffer[2] =3D CheckSum; + + CmdDataBuffer[3] =3D IPMI_BMC_SLAVE_ADDRESS; + DataSum +=3D IPMI_BMC_SLAVE_ADDRESS; + + CmdDataBuffer[4] =3D IPMI_SEQ_NO; + DataSum +=3D IPMI_SEQ_NO; + + CmdDataBuffer[5] =3D Command; + DataSum +=3D Command; + + if (CommandDataSize > 0) { + if (CommandData =3D=3D NULL) { + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return EFI_INVALID_PARAMETER; + } + + // Last data will be Checksum so limiting the Max command data to < IP= MI_MAX_IPMB_CMD_DATA_SIZE - 6 + if (CommandDataSize < (IPMI_MAX_IPMB_CMD_DATA_SIZE - 6)) { + CopyMem ( + &CmdDataBuffer[6], + CommandData, + CommandDataSize + ); + } else { + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return EFI_BAD_BUFFER_SIZE; + } + + for (Index =3D 0; Index < CommandDataSize; Index++) { + DataSum +=3D CmdDataBuffer[6 + Index]; + } + } + + CheckSum =3D (UINT8)(0x100 - DataSum); // Find the checksum for = the packing data. + CmdDataBuffer[6] =3D CheckSum; // Update the checksum. + + if ((Status =3D SendDataToIpmbBmcPort ( + &Interface, + Context, + CmdDataBuffer, + (UINT8)(CommandDataSize + 7) + )) !=3D EFI_SUCCESS) + { + Interface.Ipmb.IpmbSoftErrorCount++; + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return Status; + } + + DataSize =3D IPMI_MAX_IPMB_CMD_DATA_SIZE; + if ((Status =3D ReceiveBmcDataFromIpmbPort ( + &Interface, + Context, + CmdDataBuffer, + &DataSize + )) !=3D EFI_SUCCESS) + { + Interface.Ipmb.IpmbSoftErrorCount++; + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return Status; + } + + /* Response Packet format. + | Slave Address | Netfun/Lun | CheckSum (Check Sum of previous data) + | Slave Address | Seq No | Command | Completion code| Data 1..N + | CheckSum (Check Sum of previous data).*/ + + // Calculate and verify checksum. + Status =3D CheckDataValidity ( + CmdDataBuffer, + DataSize + ); + if (EFI_ERROR (Status)) { + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return Status; + } + + if (IPMI_ERROR_COMPLETION_CODE (CmdDataBuffer[6])) { + IpmiUpdateSoftErrorCount ( + CmdDataBuffer[6], + &Interface, + This->InterfaceType + ); + // Write completion code into return buffer if an IPMI command returns= an error + if (*ResponseDataSize) { + if (ResponseData) { + *ResponseData =3D CmdDataBuffer[6]; + } + + *ResponseDataSize =3D 1; + } + + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return EFI_DEVICE_ERROR; + } + + if (DataSize < 8) { + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return EFI_DEVICE_ERROR; + } + + if ((DataSize - 7) > *((UINT8 *)ResponseDataSize)) { + *ResponseDataSize =3D (UINT8)(DataSize - 7); + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return EFI_BUFFER_TOO_SMALL; + } + + // Copying the response data into ResponseData buffer. + CopyMem ( + ResponseData, + &CmdDataBuffer[6], + (DataSize - 7) + ); + *ResponseDataSize =3D (UINT8)(DataSize - 7); + + IpmiTransportReleaseLock (&Interface.Ipmb.IpmbTransportLocked); + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Initialize IPMB interface specific data. + +Arguments: + IpmiTransport2 - Pointer to IPMI Transport2 instance. + +Returns: + EFI_SUCCESS - Interface is successfully initialized. + Others - Error status while initializing interface. +--*/ +EFI_STATUS +InitIpmbInterfaceData ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status =3D EFI_SUCCESS; + + if (IpmiTransport2->Interface.Ipmb.InterfaceState =3D=3D IpmiInterfaceIn= itialized) { + return Status; + } + + Status =3D IpmiGetI2cApiPtr (IpmiTransport2); + + if (EFI_ERROR (Status)) { + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInitErr= or; + return Status; + } + + IpmiTransportReleaseLock (&IpmiTransport2->Interface.Ipmb.IpmbTransportL= ocked); + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInitializ= ed; + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/IpmbInterfaceLib/PeiIpmbInterfaceLib.c b/Features/Inte= l/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/IpmbI= nterfaceLib/PeiIpmbInterfaceLib.c new file mode 100644 index 0000000000..ff57c2c688 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/PeiIpmbInterfaceLib.c @@ -0,0 +1,108 @@ +/** @file PeiIpmbInterfaceLib.c + IPMB Transport Pei phase implementation library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + Send IPMI command through IPMB interface. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - I2C device slave address. + RequestPacket - Pointer to an EFI_I2C_REQUEST_PACKET structure describin= g the I2C transaction. +Returns: + EFI_STATUS - Status of the Send I2c command. +--*/ +EFI_STATUS +IpmiI2cSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN UINTN SlaveAddress, + IN EFI_I2C_REQUEST_PACKET *RequestPacket + ) +{ + EFI_STATUS Status =3D EFI_NOT_FOUND; + EFI_PEI_I2C_MASTER_PPI *I2cMasterTransmit =3D NULL; + + I2cMasterTransmit =3D (EFI_PEI_I2C_MASTER_PPI *)Interface->Ipmb.IpmbInte= rfaceApiPtr; + + if (I2cMasterTransmit !=3D NULL) { + Status =3D I2cMasterTransmit->StartRequest ( + I2cMasterTransmit, + SlaveAddress, + RequestPacket + ); + } + + DEBUG ((DEBUG_INFO, "%a I2cMasterTransmit->StartRequest Status =3D %r\n"= , __FUNCTION__, Status)); + + return Status; +} + +/*++ + +Routine Description: + Locate I2c Ppi/Protocol instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 Instance. + +Returns: + EFI_STATUS - Status returned from functions used. +--*/ +EFI_STATUS +IpmiGetI2cApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + CONST EFI_PEI_SERVICES **PeiServices; + EFI_PEI_I2C_MASTER_PPI *I2cMasterTransmit =3D NULL; + BMC_INTERFACE_STATUS BmcStatus; + + PeiServices =3D GetPeiServicesTablePointer (); + + IpmiTransport2->Interface.Ipmb.IpmbInterfaceApiGuid =3D gEfiPeiI2cMaster= PpiGuid; + + // Locate the I2C PPI for Communication. + Status =3D (*PeiServices)->LocatePpi ( + PeiServices, + &gEfiPeiI2cMasterPpiGuid, + 0, + NULL, + (VOID **)&I2cMasterTransmit + ); + + DEBUG ((DEBUG_INFO, "%a (*PeiServices)->LocatePpi gEfiPeiI2cMasterPpiGui= d Status =3D %r\n", __FUNCTION__, Status)); + + if (EFI_ERROR (Status)) { + return Status; + } + + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInit= ialized; + IpmiTransport2->Interface.Ipmb.IpmbInterfaceApiPtr =3D (UINTN)I2cMasterT= ransmit; + + Status =3D CheckSelfTestByInterfaceType ( + IpmiTransport2, + &BmcStatus, + SysInterfaceIpmb + ); + + if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInitErr= or; + } + + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/IpmbInterfaceLib/PeiIpmbInterfaceLib.inf b/Features/In= tel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ipm= bInterfaceLib/PeiIpmbInterfaceLib.inf new file mode 100644 index 0000000000..85b19d74c8 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/PeiIpmbInterfaceLib.inf @@ -0,0 +1,38 @@ +## @file PeiIpmbInterfaceLib.inf +# +# INF description file for IpmbInterfacePeiLib Library for PEIMs. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiIpmbInterfaceLib + FILE_GUID =3D 843DBE4E-4750-4335-9094-58645D897D62 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.1 + LIBRARY_CLASS =3D IpmbInterfaceLib | PEIM + +[Sources] + PeiIpmbInterfaceLib.c + IpmbInterfaceLibCommon.c + +[Packages] + MdePkg/MdePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + HobLib + DebugLib + BaseMemoryLib + PeiServicesTablePointerLib + BmcCommonInterfaceLib + +[Ppis] + gEfiPeiI2cMasterPpiGuid + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdBmcSlaveAddress 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 new file mode 100644 index 0000000000..222b161d3a --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.c @@ -0,0 +1,104 @@ +/** @file SmmIpmbInterfaceLib.c + IPMB Transport Smm phase implementation library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + Send IPMI command through IPMB interface. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - I2C device slave address. + RequestPacket - Pointer to an EFI_I2C_REQUEST_PACKET structure describin= g the I2C transaction. + +Returns: + Status - Status of the Send I2c command. +--*/ +EFI_STATUS +IpmiI2cSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN UINTN SlaveAddress, + IN EFI_I2C_REQUEST_PACKET *RequestPacket + ) +{ + EFI_STATUS Status =3D EFI_NOT_FOUND; + EFI_I2C_MASTER_PROTOCOL *I2cMasterTransmit =3D NULL; + + I2cMasterTransmit =3D (EFI_I2C_MASTER_PROTOCOL *)Interface->Ipmb.IpmbInt= erfaceApiPtr; + + if (I2cMasterTransmit !=3D NULL) { + Status =3D I2cMasterTransmit->StartRequest ( + I2cMasterTransmit, + SlaveAddress, + RequestPacket, + NULL, + NULL + ); + } + + DEBUG ((DEBUG_INFO, "%a I2cMasterTransmit->StartRequest Status =3D %r\n"= , __FUNCTION__, Status)); + + return Status; +} + +/*++ + +Routine Description: + Locate I2c Ppi/Protocol instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Status returned from functions used. +--*/ +EFI_STATUS +IpmiGetI2cApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + EFI_I2C_MASTER_PROTOCOL *I2cMasterTransmit =3D NULL; + BMC_INTERFACE_STATUS BmcStatus; + + IpmiTransport2->Interface.Ipmb.IpmbInterfaceApiGuid =3D gEfiI2cMasterPro= tocolGuid; + + // Locate the I2C SMM Protocol for Communication. + Status =3D gSmst->SmmLocateProtocol ( + &gEfiI2cMasterProtocolGuid, + NULL, + (VOID **)&I2cMasterTransmit + ); + + DEBUG ((DEBUG_INFO, "%a SmmLocateProtocol gEfiI2cMasterProtocolGuid Stat= us =3D %r\n", __FUNCTION__, Status)); + + if (EFI_ERROR (Status)) { + return Status; + } + + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInit= ialized; + IpmiTransport2->Interface.Ipmb.IpmbInterfaceApiPtr =3D (UINTN)I2cMasterT= ransmit; + + Status =3D CheckSelfTestByInterfaceType ( + IpmiTransport2, + &BmcStatus, + SysInterfaceIpmb + ); + if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { + IpmiTransport2->Interface.Ipmb.InterfaceState =3D IpmiInterfaceInitErr= or; + } + + return Status; +} 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 new file mode 100644 index 0000000000..2d3c089ef2 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/IpmbInterfaceLib/SmmIpmbInterfaceLib.inf @@ -0,0 +1,37 @@ +## @file SmmAmiIpmbInterfaceLib.inf +# +# INF description file for SmmAmiIpmbInterfaceLib Library for DXE SMM dri= vers. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SmmIpmbInterfaceLib + 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 + +[Sources] + SmmIpmbInterfaceLib.c + IpmbInterfaceLibCommon.c + +[Packages] + MdePkg/MdePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + DebugLib + BaseMemoryLib + SmmServicesTableLib + BmcCommonInterfaceLib + +[Protocols] + gEfiI2cMasterProtocolGuid + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdBmcSlaveAddress diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/SsifInterfaceLib/DxeSsifInterfaceLib.c b/Features/Inte= l/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifI= nterfaceLib/DxeSsifInterfaceLib.c new file mode 100644 index 0000000000..9867672a41 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/DxeSsifInterfaceLib.c @@ -0,0 +1,137 @@ +/** @file DxeSsifInterfaceLib.c + SSIF Transport Dxe phase Implementation library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + Send IPMI command through SMBUS instance. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - The SMBUS hardware address. + Command - This command is transmitted by the SMBus host controller= to the SMBus slave device.. + Operation - Operation to be performed. + PecCheck - Defines if Packet Error Code (PEC) checking is required = for this operation. + Length - Signifies the number of bytes that this operation will d= o. + Buffer - Contains the value of data to execute to + the SMBus slave device. The length of this buffer is ide= ntified by Length. + +Returns: + EFI_NOT_FOUND - SMBUS instance is not found. + Others - Return status of the SMBUS Execute operation. +--*/ +EFI_STATUS +IpmiSmbusSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + EFI_SMBUS_HC_PROTOCOL *EfiSmbusHcProtocol; + + Status =3D EFI_NOT_FOUND; + EfiSmbusHcProtocol =3D (EFI_SMBUS_HC_PROTOCOL *)Interface->Ssif.SsifInte= rfaceApiPtr; + + if (EfiSmbusHcProtocol !=3D NULL) { + Status =3D EfiSmbusHcProtocol->Execute ( + EfiSmbusHcProtocol, + SlaveAddress, + Command, + Operation, + PecCheck, + Length, + Buffer + ); + } + + DEBUG ((DEBUG_INFO, "EfiSmbusHcProtocol->Execute Status =3D %r\n", Statu= s)); + return Status; +} + +/*++ + +Routine Description: + Locate Smbus instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Status returned while locating SMBUS instance. +--*/ +EFI_STATUS +IpmiGetSmbusApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + EFI_SMBUS_HC_PROTOCOL *EfiSmbusHcProtocol; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINTN Index; + BMC_INTERFACE_STATUS BmcStatus; + + IpmiTransport2->Interface.Ssif.SsifInterfaceApiGuid =3D gEfiSmbusHcProto= colGuid; + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiSmbusHcProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + + for (Index =3D 0; Index < HandleCount; Index++) { + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiSmbusHcProtocolGuid, + (VOID **)&EfiSmbusHcProtocol + ); + if (EFI_ERROR (Status)) { + continue; + } + + IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceIn= itialized; + IpmiTransport2->Interface.Ssif.SsifInterfaceApiPtr =3D (UINTN)EfiSmbus= HcProtocol; + + Status =3D CheckSelfTestByInterfaceType ( + IpmiTransport2, + &BmcStatus, + SysInterfaceSsif + ); + if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { + IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceInitE= rror; + continue; + } + + GetSystemInterfaceCapability (IpmiTransport2); + GetGlobalEnables (IpmiTransport2); + break; + } + + FreePool (HandleBuffer); + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/SsifInterfaceLib/DxeSsifInterfaceLib.inf b/Features/In= tel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ssi= fInterfaceLib/DxeSsifInterfaceLib.inf new file mode 100644 index 0000000000..d9120b220c --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/DxeSsifInterfaceLib.inf @@ -0,0 +1,40 @@ +## @file DxeSsifInterfaceLib.inf +# +# INF description file for SsifInterfaceLib Library for DXE and UEFI driv= ers. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DxeSsifInterfaceLib + FILE_GUID =3D AD66E7C3-FE13-4849-970E-118347FFE857 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.1 + LIBRARY_CLASS =3D SsifInterfaceLib | DXE_DRIVER DXE_RUNTIME_DRIVER U= EFI_DRIVER UEFI_APPLICATION + +[Sources] + DxeSsifInterfaceLib.c + SsifInterfaceLibCommon.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + UefiLib + MemoryAllocationLib + BmcCommonInterfaceLib + +[Protocols] + gEfiSmbusHcProtocolGuid + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifSlaveAddress + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifCommandtRetryCounter + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/SsifInterfaceLib/PeiSsifInterfaceLib.c b/Features/Inte= l/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifI= nterfaceLib/PeiSsifInterfaceLib.c new file mode 100644 index 0000000000..e522add31e --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/PeiSsifInterfaceLib.c @@ -0,0 +1,128 @@ +/** @file PeiSsifInterfaceLib.c + SSIF Transport Pei phase Implementation library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + Send IPMI command through SMBUS instance. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - The SMBUS hardware address. + Command - This command is transmitted by the SMBus host controller= to the SMBus slave device.. + Operation - Operation to be performed. + PecCheck - Defines if Packet Error Code (PEC) checking is required = for this operation. + Length - Signifies the number of bytes that this operation will d= o. + Buffer - Contains the value of data to execute to + the SMBus slave device. The length of this buffer is ide= ntified by Length. + +Returns: + EFI_NOT_FOUND - SMBUS instance is not found. + Others - Return status of the SMBUS Execute operation. +--*/ +EFI_STATUS +IpmiSmbusSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + EFI_PEI_SMBUS2_PPI *EfiPeiSmbus2Ppi; + + Status =3D EFI_NOT_FOUND; + EfiPeiSmbus2Ppi =3D (EFI_PEI_SMBUS2_PPI *)Interface->Ssif.SsifInterfaceA= piPtr; + + if (EfiPeiSmbus2Ppi !=3D NULL) { + Status =3D EfiPeiSmbus2Ppi->Execute ( + EfiPeiSmbus2Ppi, + SlaveAddress, + Command, + Operation, + PecCheck, + Length, + Buffer + ); + } + + DEBUG ((DEBUG_INFO, "%a EfiPeiSmbus2Ppi->Execute Status =3D %r\n", __FUN= CTION__, Status)); + return Status; +} + +/*++ + +Routine Description: + Locate Smbus instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Status returned while locating SMBUS instance. +--*/ +EFI_STATUS +IpmiGetSmbusApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + UINTN Instance; + CONST EFI_PEI_SERVICES **PeiServices; + EFI_PEI_SMBUS2_PPI *EfiPeiSmbus2Ppi; + BMC_INTERFACE_STATUS BmcStatus; + + PeiServices =3D GetPeiServicesTablePointer (); + + IpmiTransport2->Interface.Ssif.SsifInterfaceApiGuid =3D gEfiPeiSmbus2Ppi= Guid; + + // Traverse all Smbus2 PPI instances and find the right instance for SSI= F. + for (Instance =3D 0; ; Instance++) { + // Locate the Smbus Ppi. + Status =3D (*PeiServices)->LocatePpi ( + PeiServices, + &gEfiPeiSmbus2PpiGuid, + Instance, + NULL, + (VOID **)&EfiPeiSmbus2Ppi + ); + if (EFI_ERROR (Status)) { + break; + } + + IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceIn= itialized; + IpmiTransport2->Interface.Ssif.SsifInterfaceApiPtr =3D (UINTN)EfiPeiSm= bus2Ppi; + + Status =3D CheckSelfTestByInterfaceType ( + IpmiTransport2, + &BmcStatus, + SysInterfaceSsif + ); + if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { + IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceInitE= rror; + continue; + } + + GetSystemInterfaceCapability (IpmiTransport2); + GetGlobalEnables (IpmiTransport2); + break; + } + + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/SsifInterfaceLib/PeiSsifInterfaceLib.inf b/Features/In= tel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ssi= fInterfaceLib/PeiSsifInterfaceLib.inf new file mode 100644 index 0000000000..b3aad43671 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/PeiSsifInterfaceLib.inf @@ -0,0 +1,41 @@ +## @file PeiSsifInterfaceLib.inf +# +# INF description file for SsifInterfaceLib Library for PEIMs. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiSsifInterfaceLib + FILE_GUID =3D EDA631E3-DC66-4120-BADF-B6BA73B6ABD4 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.1 + LIBRARY_CLASS =3D SsifInterfaceLib | PEIM + +[Sources] + PeiSsifInterfaceLib.c + SsifInterfaceLibCommon.c + +[Packages] + MdePkg/MdePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + DebugLib + TimerLib + BaseMemoryLib + PeiServicesTablePointerLib + BmcCommonInterfaceLib + +[Ppis] + gEfiPeiSmbus2PpiGuid + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifSlaveAddress + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifCommandtRetryCounter + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c b/Features/Inte= l/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/SsifI= nterfaceLib/SmmSsifInterfaceLib.c new file mode 100644 index 0000000000..8ca07658e9 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.c @@ -0,0 +1,156 @@ +/** @file SmmSsifInterfaceLib.c + SSIF Transport SMM phase Implementation library functions. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + Send IPMI command through SMBUS instance. + +Arguments: + Interface - Pointer to System interface. + SlaveAddress - The SMBUS hardware address. + Command - This command is transmitted by the SMBus host controller= to the SMBus slave device.. + Operation - Operation to be performed. + PecCheck - Defines if Packet Error Code (PEC) checking is required = for this operation. + Length - Signifies the number of bytes that this operation will d= o. + Buffer - Contains the value of data to execute to + the SMBus slave device. The length of this buffer is ide= ntified by Length. + +Returns: + EFI_NOT_FOUND - SMBUS instance is not found. + Others - Return status of the SMBUS Execute operation. +--*/ +EFI_STATUS +IpmiSmbusSendCommand ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress, + IN EFI_SMBUS_DEVICE_COMMAND Command, + IN EFI_SMBUS_OPERATION Operation, + IN BOOLEAN PecCheck, + IN OUT UINTN *Length, + IN OUT VOID *Buffer + ) +{ + EFI_STATUS Status; + EFI_SMBUS_HC_PROTOCOL *EfiSmbusHcProtocol; + + Status =3D EFI_NOT_FOUND; + EfiSmbusHcProtocol =3D (EFI_SMBUS_HC_PROTOCOL *)Interface->Ssif.SsifInte= rfaceApiPtr; + + if (EfiSmbusHcProtocol !=3D NULL) { + Status =3D EfiSmbusHcProtocol->Execute ( + EfiSmbusHcProtocol, + SlaveAddress, + Command, + Operation, + PecCheck, + Length, + Buffer + ); + } + + DEBUG ((DEBUG_INFO, "%a EfiSmbusHcProtocol->Execute Status =3D %r\n", __= FUNCTION__, Status)); + + return Status; +} + +/*++ + +Routine Description: + Locate Smbus instance and initialize interface pointer. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Status returned while locating SMBUS instance. +--*/ +EFI_STATUS +IpmiGetSmbusApiPtr ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + EFI_SMBUS_HC_PROTOCOL *EfiSmbusHcProtocol; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer =3D NULL; + UINTN Index; + BMC_INTERFACE_STATUS BmcStatus; + + IpmiTransport2->Interface.Ssif.SsifInterfaceApiGuid =3D gEfiSmbusHcProto= colGuid; + HandleCount =3D 0; + + Status =3D gSmst->SmmLocateHandle ( + 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); + if (HandleBuffer =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + Status =3D gSmst->SmmLocateHandle ( + ByProtocol, + &gEfiSmbusHcProtocolGuid, + NULL, + &HandleCount, + HandleBuffer + ); + if (EFI_ERROR (Status)) { + // Free HandleBuffer memory + FreePool (HandleBuffer); + return EFI_NOT_FOUND; + } + } + + for (Index =3D 0; Index < HandleCount; Index++) { + Status =3D gSmst->SmmHandleProtocol ( + HandleBuffer[Index], + &gEfiSmbusHcProtocolGuid, + (VOID **)&EfiSmbusHcProtocol + ); + if (EFI_ERROR (Status)) { + continue; + } + + IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceIn= itialized; + IpmiTransport2->Interface.Ssif.SsifInterfaceApiPtr =3D (UINTN)EfiSmbus= HcProtocol; + + Status =3D CheckSelfTestByInterfaceType ( + IpmiTransport2, + &BmcStatus, + SysInterfaceSsif + ); + if (EFI_ERROR (Status) || (BmcStatus =3D=3D BmcStatusHardFail)) { + IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceInitE= rror; + continue; + } + + GetSystemInterfaceCapability (IpmiTransport2); + GetGlobalEnables (IpmiTransport2); + break; + } + + FreePool (HandleBuffer); + return Status; +} 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 new file mode 100644 index 0000000000..a7e25647e2 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/SmmSsifInterfaceLib.inf @@ -0,0 +1,40 @@ +## @file SmmSsifInterfaceLib.inf +# +# INF description file for SsifInterfaceLib Library for DXE SMM drivers. +# +# @copyright +# Copyright 2016 - 2021 Intel Corporation.
+# Copyright (c) 1985 - 2023, American Megatrends International LLC.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SmmSsifInterfaceLib + 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 + +[Sources] + SmmSsifInterfaceLib.c + SsifInterfaceLibCommon.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + IpmiFeaturePkg/IpmiFeaturePkg.dec + +[LibraryClasses] + SmmServicesTableLib + MemoryAllocationLib + BmcCommonInterfaceLib + +[Protocols] + gEfiSmbusHcProtocolGuid + +[Pcd] + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifSlaveAddress + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifCommandtRetryCounter + gIpmiFeaturePkgTokenSpaceGuid.PcdSsifRequestRetriesDelay diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcI= nterfaceCommonAccess/SsifInterfaceLib/SsifInterfaceLibCommon.c b/Features/I= ntel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfaceCommonAccess/Ss= ifInterfaceLib/SsifInterfaceLibCommon.c new file mode 100644 index 0000000000..c4ea35f570 --- /dev/null +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/BmcInterfac= eCommonAccess/SsifInterfaceLib/SsifInterfaceLibCommon.c @@ -0,0 +1,577 @@ +/** @file SsifInterfaceLibCommon.c + SSIF Transport Implementation common functions and variables. + + @copyright + Copyright 2016 - 2021 Intel Corporation.
+ Copyright (c) 1985 - 2023, American Megatrends International LLC.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include + +SSIF_ALERT_PIN_CHECK *gSsifAlertPinCheckHookList[] =3D +{ + NULL +}; + +/*++ + +Routine Description: + Check the SMBUS alert pin status function. + +Arguments: + VOID - Nothing. + +Returns: + TRUE - Alert pin status is set. + FALSE - Alert pin status is not set. +--*/ +BOOLEAN +CheckAlertPinHook ( + VOID + ) +{ + BOOLEAN CheckAlertSignal =3D FALSE; + UINTN Index; + + for (Index =3D 0; gSsifAlertPinCheckHookList[Index]; Index++) { + CheckAlertSignal =3D gSsifAlertPinCheckHookList[Index](); + } + + return CheckAlertSignal; +} + +/*++ + +Routine Description: + Sends the command/data to SSIF interface. + +Arguments: + Interface - Pointer to System interface.. + Context - NULL here. + Data - Pointer to command data that will be sent to BMC along with= Command. + DataSize - Size of the command data. + +Returns: + EFI_STATUS - Status returned from Smbus send command. +--*/ +EFI_STATUS +SendDataToSsifBmcPort ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN VOID *Context, + IN UINT8 *Data, + IN UINT8 DataSize + ) +{ + EFI_STATUS Status; + EFI_SMBUS_DEVICE_ADDRESS BmcAddress; + UINTN IpmiWriteCommand; + UINT8 IpmiData[IPMI_SMBUS_BLOCK_LENGTH]; + UINTN DataLength; + UINT8 DataIndex; + BOOLEAN PECSupport; + UINT8 RetryCount; + UINT8 OriginalDataSize; + + DataLength =3D DataSize; + DataIndex =3D 0; + RetryCount =3D 0; + OriginalDataSize =3D DataSize; + PECSupport =3D Interface->Ssif.PecSupport; + BmcAddress.SmbusDeviceAddress =3D FixedPcdGet16 (PcdSsifSlaveAddress); + ZeroMem (IpmiData, sizeof (IpmiData)); + + do { + if (OriginalDataSize =3D=3D DataSize) { + if (DataSize <=3D IPMI_SMBUS_BLOCK_LENGTH) { + // Working single writes start. + DataLength =3D DataSize; + IpmiWriteCommand =3D IPMI_SMBUS_SINGLE_WRITE_CMD; + CopyMem ( + IpmiData, + &Data[DataIndex*IPMI_SMBUS_BLOCK_LENGTH], + DataLength + ); + } else { + // Working multi-part writes start. + IpmiWriteCommand =3D IPMI_SMBUS_MULTI_WRITE_START_CMD; + DataLength =3D IPMI_SMBUS_BLOCK_LENGTH; + CopyMem ( + IpmiData, + &Data[DataIndex*IPMI_SMBUS_BLOCK_LENGTH], + DataLength + ); + } + } else { + if (DataSize > IPMI_SMBUS_BLOCK_LENGTH) { + // Working multi-part writes middle. + IpmiWriteCommand =3D IPMI_SMBUS_MULTI_WRITE_MIDDLE_CMD; + DataLength =3D IPMI_SMBUS_BLOCK_LENGTH; + CopyMem ( + IpmiData, + &Data[DataIndex*IPMI_SMBUS_BLOCK_LENGTH], + DataLength + ); + } else { + // Working multi-part writes end. + IpmiWriteCommand =3D IPMI_SMBUS_MULTI_WRITE_END_CMD; + DataLength =3D DataSize; + CopyMem ( + IpmiData, + &Data[DataIndex*IPMI_SMBUS_BLOCK_LENGTH], + DataLength + ); + } + } + + Status =3D IpmiSmbusSendCommand ( + Interface, + BmcAddress, + IpmiWriteCommand, + EfiSmbusWriteBlock, + PECSupport, + &DataLength, + IpmiData + ); + if (!EFI_ERROR (Status)) { + if (DataSize >=3D IPMI_SMBUS_BLOCK_LENGTH) { + RetryCount =3D 0; + DataSize -=3D IPMI_SMBUS_BLOCK_LENGTH; + DataIndex++; + } else { + DataSize =3D 0; + } + } else { + if (RetryCount =3D=3D Interface->Ssif.SsifRetryCounter) { + break; + } else { + RetryCount++; + // Failed retries delay about 60ms to 250ms. + MicroSecondDelay (FixedPcdGet32 (PcdSsifRequestRetriesDelay)); + + /* If the Multi-part write fails, then try to write the + data from the beginning.*/ + if (IpmiWriteCommand !=3D IPMI_SMBUS_SINGLE_WRITE_CMD) { + DataSize =3D OriginalDataSize; + DataIndex =3D 0; + } + } + } + } while (DataSize); + + return Status; +} + +/*++ + +Routine Description: + Receives the Data from BMC port. + +Arguments: + Interface - Pointer to System interface.. + Context - NULL here. + Data - Pointer to response data that is received from BMC. + DataSize - Size of the response data. + +Returns: + EFI_STATUS - Status returned from Smbus send command. +--*/ +EFI_STATUS +ReceiveBmcDataFromSsifPort ( + IN IPMI_SYSTEM_INTERFACE *Interface, + IN VOID *Context, + OUT UINT8 *Data, + OUT UINT8 *DataSize + ) +{ + EFI_STATUS Status; + EFI_SMBUS_DEVICE_ADDRESS BmcAddress; + UINTN IpmiReadCommand; + UINT8 IpmiData[IPMI_SMBUS_BLOCK_LENGTH]; + UINTN DataLength; + BOOLEAN PECSupport; + UINT8 RetryCount; + UINT8 OriginalDataSize; + + DataLength =3D *DataSize; + RetryCount =3D 0; + OriginalDataSize =3D *DataSize; + PECSupport =3D Interface->Ssif.PecSupport; + BmcAddress.SmbusDeviceAddress =3D FixedPcdGet16 (PcdSsifSlaveAddress); + IpmiReadCommand =3D IPMI_SMBUS_SINGLE_READ_CMD; + + while (RetryCount <=3D Interface->Ssif.SsifRetryCounter) { + Status =3D IpmiSmbusSendCommand ( + Interface, + BmcAddress, + IpmiReadCommand, + EfiSmbusReadBlock, + PECSupport, + &DataLength, + (VOID *)IpmiData + ); + if (EFI_ERROR (Status)) { + RetryCount++; + // Failed retries delay about 60ms to 250ms. + MicroSecondDelay (FixedPcdGet32 (PcdSsifRequestRetriesDelay)); + + /* If the Multi-part Read command fails, then try to read the + data from the beginning.*/ + if (IpmiReadCommand !=3D IPMI_SMBUS_SINGLE_READ_CMD) { + IpmiReadCommand =3D IPMI_SMBUS_SINGLE_READ_CMD; + } + + DataLength =3D OriginalDataSize; + continue; + } + + if (IpmiReadCommand =3D=3D IPMI_SMBUS_SINGLE_READ_CMD) { + if ((IpmiData[0] =3D=3D IPMI_MULTI_READ_ZEROTH_STRT_BIT) && + (IpmiData[1] =3D=3D IPMI_MULTI_READ_FIRST_STRT_BIT)) + { + // Working multi-part reads start. + CopyMem ( + Data, + &IpmiData[2], + DataLength-2 + ); + *DataSize =3D (UINT8)DataLength-2; + IpmiReadCommand =3D IPMI_SMBUS_MULTI_READ_MIDDLE_CMD; + } else { + // Working single reads start. + CopyMem ( + Data, + IpmiData, + DataLength + ); + *DataSize =3D (UINT8)DataLength; + break; + } + } else { + if (IpmiData[0] =3D=3D 0xFF) { + // Working multi-part reads end. + CopyMem ( + &Data[*DataSize], + &IpmiData[1], + DataLength-1 + ); + *DataSize +=3D (UINT8)DataLength-1; + break; + } else { + // Working multi-part reads middle. + CopyMem ( + &Data[*DataSize], + &IpmiData[1], + DataLength-1 + ); + *DataSize +=3D (UINT8)DataLength-1; + IpmiReadCommand =3D IPMI_SMBUS_MULTI_READ_MIDDLE_CMD; + } + } + } + + return Status; +} + +/*++ + +Routine Description: + SSIF interface Ipmi send command Implementation + +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. + Context - NULL here. + +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 +IpmiSsifSendCommandToBmc ( + IN IPMI_TRANSPORT2 *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 + ) +{ + EFI_STATUS Status; + UINT8 DataSize; + UINT8 CmdDataBuffer[IPMI_MAX_SSIF_CMD_DATA_SIZE]; + IPMI_SYSTEM_INTERFACE Interface; + + Interface =3D This->Interface; + + if (Interface.Ssif.InterfaceState !=3D IpmiInterfaceInitialized) { + return EFI_NOT_READY; + } + + if (((CommandData =3D=3D NULL) && (CommandDataSize !=3D 0)) || (This =3D= =3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + if ((ResponseDataSize =3D=3D NULL) || ((ResponseData =3D=3D NULL) && *Re= sponseDataSize)) { + return EFI_INVALID_PARAMETER; + } + + if (IpmiIsIpmiTransportlocked (&Interface.Ssif.SsifTransportLocked)) { + return EFI_ACCESS_DENIED; + } else { + IpmiTransportAcquireLock (&Interface.Ssif.SsifTransportLocked); + } + + // Check the SSIF interface multi-part reads/writes supported. + // Block length include Command data, NetFn, and Command parameter. + if (((Interface.Ssif.RwSupport =3D=3D SsifSinglePartRw) && + ((CommandDataSize + 2) > IPMI_SMBUS_BLOCK_LENGTH)) || + ((Interface.Ssif.RwSupport =3D=3D SsifMultiPartRw) && + ((CommandDataSize + 2) > (2*IPMI_SMBUS_BLOCK_LENGTH))) || + ((Interface.Ssif.RwSupport =3D=3D SsifMultiPartRwWithMiddle) && + ((CommandDataSize + 2) > IPMI_MAX_SSIF_CMD_DATA_SIZE))) + { + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_INVALID_PARAMETER; + } + + if (Interface.Ssif.SsifSoftErrorCount >=3D MAX_BMC_CMD_FAIL_COUNT) { + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_NOT_READY; + } + + CmdDataBuffer[0] =3D (UINT8)((NetFunction << 2) | (Lun & 0x03)); + CmdDataBuffer[1] =3D Command; + + if (CommandDataSize > 0) { + if (CommandData =3D=3D NULL) { + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_INVALID_PARAMETER; + } + + if (CommandDataSize <=3D (IPMI_MAX_SSIF_CMD_DATA_SIZE - 2)) { + CopyMem ( + &CmdDataBuffer[2], + CommandData, + CommandDataSize + ); + } else { + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_BAD_BUFFER_SIZE; + } + } + + Status =3D SendDataToSsifBmcPort ( + &Interface, + Context, + CmdDataBuffer, + (UINT8)(CommandDataSize + 2) + ); + + if (Status !=3D EFI_SUCCESS) { + Interface.Ssif.SsifSoftErrorCount++; + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return Status; + } + + // Hook to check smbus alert pin. + if (Interface.Ssif.SmbAlertSupport) { + if (!CheckAlertPinHook ()) { + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_DEVICE_ERROR; + } + } else { + MicroSecondDelay (FixedPcdGet32 (PcdSsifRequestRetriesDelay)); + } + + DataSize =3D IPMI_SMBUS_BLOCK_LENGTH; + + Status =3D ReceiveBmcDataFromSsifPort ( + &Interface, + Context, + CmdDataBuffer, + &DataSize + ); + if (Status !=3D EFI_SUCCESS) { + Interface.Ssif.SsifSoftErrorCount++; + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return Status; + } + + if (IPMI_ERROR_COMPLETION_CODE (CmdDataBuffer[2])) { + IpmiUpdateSoftErrorCount ( + CmdDataBuffer[2], + &Interface, + This->InterfaceType + ); + // Write completion code into return buffer if ipmi command returns an= error. + if (*ResponseDataSize) { + if (ResponseData) { + *ResponseData =3D CmdDataBuffer[2]; + } + + *ResponseDataSize =3D 1; + } + + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_DEVICE_ERROR; + } + + if (DataSize < 3) { + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_DEVICE_ERROR; + } + + if ((DataSize - 2) > *((UINT8 *)ResponseDataSize)) { + *ResponseDataSize =3D (UINT8)(DataSize - 3); + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_BUFFER_TOO_SMALL; + } + + // Copying the response data into ResponseData buffer. + CopyMem ( + ResponseData, + &CmdDataBuffer[2], + (DataSize - 2) + ); + *ResponseDataSize =3D (UINT8)(DataSize - 2); + + IpmiTransportReleaseLock (&Interface.Ssif.SsifTransportLocked); + return EFI_SUCCESS; +} + +/*++ + +Routine Description: + Execute the Get System Interface Capability command and update the RwSup= port + and PecSupport of Ipmi Instance. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + VOID - Nothing. +--*/ +VOID +GetSystemInterfaceCapability ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + IPMI_GET_SYSTEM_INTERFACE_CAPABILITY_REQ GetSystemInterfaceCapabilityCm= d; + IPMI_GET_SYSTEM_INTERFACE_CAPABILITY_RES GetSsifInterfaceCapability; + UINT32 DataSize =3D sizeof (GetSsifIn= terfaceCapability); + + GetSystemInterfaceCapabilityCmd.SystemInterfaceType =3D 0x0; // SSIF + GetSystemInterfaceCapabilityCmd.Reserved =3D 0x0; + + Status =3D IpmiTransport2->IpmiSubmitCommand2 ( + IpmiTransport2, + IPMI_NETFN_APP, + BMC_LUN, + IPMI_APP_GET_SYSTEM_INTERFA= CE_CAPABILITIES, + (UINT8 *)&GetSystemInterfac= eCapabilityCmd, + sizeof (GetSystemInterfaceC= apabilityCmd), + (UINT8 *)&GetSsifInterfaceC= apability, + &DataSize + ); + if (!EFI_ERROR (Status)) { + IpmiTransport2->Interface.Ssif.RwSupport =3D GetSsifInterfaceCapabili= ty.TransactionSupport; + IpmiTransport2->Interface.Ssif.PecSupport =3D GetSsifInterfaceCapabili= ty.PecSupport; + } +} + +/*++ + +Routine Description: + Execute the Get Global Enable command to get receive message queue inter= rupt. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + VOID - Nothing. +--*/ +VOID +GetGlobalEnables ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status; + IPMI_BMC_GLOBAL_ENABLES_RES BmcGlobalEnables; + UINT32 ResponseDataSize =3D sizeof (BmcGlobalEnabl= es); + + // + // Get Global Enable Information. + // + Status =3D IpmiTransport2->IpmiSubmitCommand2 ( + IpmiTransport2, + IPMI_NETFN_APP, + BMC_LUN, + IPMI_APP_GET_BMC_GLOBAL_ENA= BLES, + NULL, + 0, + (UINT8 *)(&BmcGlobalEnables= ), + &ResponseDataSize + ); + if (!EFI_ERROR (Status)) { + // + // Set Smb alert pin based on ReceiveMsgQueueInterrupt bit + // + IpmiTransport2->Interface.Ssif.SmbAlertSupport =3D BmcGlobalEnables.Re= ceiveMsgQueueInterrupt; + } +} + +/*++ + +Routine Description: + Initialize SSIF interface specific data. + +Arguments: + IpmiTransport2 - Pointer to IPMI transport2 instance. + +Returns: + Status - Return status while initializing interface. +--*/ +EFI_STATUS +InitSsifInterfaceData ( + IN OUT IPMI_TRANSPORT2 *IpmiTransport2 + ) +{ + EFI_STATUS Status =3D EFI_SUCCESS; + + if (IpmiTransport2->Interface.Ssif.InterfaceState =3D=3D IpmiInterfaceIn= itialized) { + return Status; + } + + IpmiTransport2->Interface.Ssif.SsifRetryCounter =3D FixedPcdGet16 (PcdSs= ifCommandtRetryCounter); + IpmiTransport2->Interface.Ssif.PecSupport =3D FALSE; + IpmiTransport2->Interface.Ssif.RwSupport =3D 0x0; // SSIF mu= lti-part reads/writes support. + IpmiTransport2->Interface.Ssif.SmbAlertSupport =3D FALSE; // SMB ale= rt pin support. + + Status =3D IpmiGetSmbusApiPtr (IpmiTransport2); + if (EFI_ERROR (Status)) { + IpmiTransport2->Interface.Ssif.InterfaceState =3D IpmiInterfaceInitErr= or; + return Status; + } + + IpmiTransportReleaseLock (&IpmiTransport2->Interface.Ssif.SsifTransportL= ocked); + return Status; +} diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md b/= Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md index 7551fcc64f..7380022a2a 100644 --- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md +++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Readme.md @@ -35,6 +35,18 @@ to better understand the module source code. Each library in the feature should have a section that describes the libra= ry in a level of detail that is useful to better understand the library source code. +#BmcInterfaceCommonAccess +This Library provides the common API's functions among the different Inter= faces such as BT, SSIF,and IPMB interface. + +#BtInterfaceLib +This Library provides the API's function for the BT interface. + +#IpmbInterfaceLib +This Library provides the API's function for the IPMB/I2C interface. + +#SsifInterfaceLib +This Function provides the API's function for the SSIF interface. + ## Key Functions *_TODO_* A bulleted list of key functions for interacting with the feature. @@ -42,6 +54,14 @@ A bulleted list of key functions for interacting with th= e feature. Not all features need to be listed. Only functions exposed through externa= l interfaces that are important for feature users to be aware of. +* Some BMC may have various interface support, in this case IpmiTransport2= Protocol will check the available interfaces Supports +and initialize the Interface API for IPMI communication. it will check for= multiple interfaces such as KCS,BT,SSIF and IPMB/I2C interface. +* PcdDefaultSystemInterface, helps to select the default Interface type to= communicate with BMC. +IpmiSubmitCommand2 API will send the IPMI command via by selected PcdDefau= ltSystemInterface Type. +* We can able to send the IPMI command via the specific Interface type thr= ough IpmiSubmitCommand2Ex. +* In case if the platform BMC doesn't have any interface support, we can d= isable the +respective Interface support(PcdKcsInterfaceSupport,PcdBtInterfaceSupport,= PcdSsifInterfaceSupport and PcdIpmbInterfaceSupport) + ## Configuration *_TODO_* Information that is useful for configuring the feature. @@ -49,6 +69,10 @@ Information that is useful for configuring the feature. Not all configuration options need to be listed. This section is used to p= rovide more background on configuration options than possible elsewhere. +* While selecting Default Interface type on PcdDefaultSystemInterface, the= respective Interface Support should need to be Enabled, +else the IpmiTransport2Protocol will be unsupported. Example, for SysInter= faceKcs on PcdDefaultSystemInterface, PcdKcsInterfaceSupport Should be enab= le. + + ## Data Flows *_TODO_* Architecturally defined data structures and flows for the feature. -- 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 (#107466): https://edk2.groups.io/g/devel/message/107466 Mute This Topic: https://groups.io/mt/100352699/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-