From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.13330.1684467285383183507 for ; Thu, 18 May 2023 20:34:45 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bSg75Kf1; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: isaac.w.oram@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684467285; x=1716003285; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=JxL2COFJYQN6veN9imdZN47aYeTqrI4Mi7WSJSzh+Jc=; b=bSg75Kf1jucJj2SbVcmzYQW0uuNrZeeOMiRdPT9CLCxqDUvjb5+YzFMT VSB8Nss7PLfQDnWBTXVt5Q5iwnQjLfI7cZGh+V9pHIiKhEHmwEtVP+3tV l3vvwvf2aZ4N+yla6zv7g/Pl3hFSvWBFsTVcMiuI3cNvcSM601tZhRyjK DvvKg/JZ8sA8QPKWMlfqe8NFUz/Z5c+MLY7oc5oX2+O8juh24nYY2JD/j Ymq0+qyz6t4xkB4W2vvQFM/stWeLH2ZqxEX/JoDtJRfcjc9BlClYhoj/U 4zhkLoivMyEukLK2Z8nlrDu6j7wDJrmbU1e6hHHUzpEWdHfXBLxQbnOVb w==; X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="415731507" X-IronPort-AV: E=Sophos;i="6.00,175,1681196400"; d="scan'208";a="415731507" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2023 20:34:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="876693353" X-IronPort-AV: E=Sophos;i="6.00,175,1681196400"; d="scan'208";a="876693353" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga005.jf.intel.com with ESMTP; 18 May 2023 20:34:20 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 18 May 2023 20:34:20 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 18 May 2023 20:34:20 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Thu, 18 May 2023 20:34:20 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Thu, 18 May 2023 20:34:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwH3gt8x3rVEMSi14o5yGcP8NFyPwZgcxCMdfc5Vfpx9RLzUMJPP/iyNA6NXG0mfvBqameiHTv30AOtc7ZuKzzGdgMyvujDAooxLt1vlC/3iWqOnX/ZyYbDZ7x+7PmB6DlyjOxzbb0EmYAX3HNbHkyKONLQWziYBq+XUG+P4zgF7Jad09hMRBliwgWGVc0ys6nUO8x/u0SDWFtHIlR56NNzOBYBu7fwQRT1acm3YLJ9y1aCpilF52wmJ1i+OYvdAGjKn2ZHgMtmSLdQ+9IIesQPtCVH5Xk1Cuc0ejI7W5VSl4alobhIm6dRiyw24Om9iBgaMdHP5Ky1cfpZAbDFL/A== 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=Hgvf6TSMhswWL7ND8N4VtqzoZpspx1DG07AVKWnjVkk=; b=dfyBZoOAnXwypfZ2dNLykuAe2f2TUjO3LXb/Y8KgoTxdAKFUp4gaQ0VulPIxxOPrcVFqMgTv2iDCXil+GFDlyhuUPZmedzMEXkBzGHavI0QjmSL4Ey1N1jFbto+sTypXLG51LtN2cmTOQQwlE+sFusliWwQNrsQVMSCeXFu79txoMIVJ7kCBAjwx67Z2Z1ERpQlNf+JEN9GzlMFJA8PJidYaDMpUGZdLEtsyiXZ+04HUzofjVhYHEgIooPWhJOyItw+hCgzKLkBvd4+sikQZLGceqn+EmcM2c2JbjkTbj8IZNwpMJ5VJOuRkWMxb3ny+k+ju//v6D3ozXe8ua0TYIA== 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 Received: from SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by SA3PR11MB8048.namprd11.prod.outlook.com (2603:10b6:806:2fd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Fri, 19 May 2023 03:34:17 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::6979:a90f:e224:41c5]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::6979:a90f:e224:41c5%4]) with mapi id 15.20.6387.030; Fri, 19 May 2023 03:34:17 +0000 From: "Isaac Oram" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Abdul Lateef Attar , Nickle Wang , Tinh Nguyen Subject: Re: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiFrb: IPMI FRB Driver Thread-Topic: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiFrb: IPMI FRB Driver Thread-Index: AQHZhZcu6dgZbRjiv0mievNBlj18RK9g+XyA Date: Fri, 19 May 2023 03:34:17 +0000 Message-ID: References: <20230513123327.1496-1-abner.chang@amd.com> In-Reply-To: <20230513123327.1496-1-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR11MB5801:EE_|SA3PR11MB8048:EE_ x-ms-office365-filtering-correlation-id: 89865034-6d07-463b-a6e4-08db5819ecc7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 09rBxx7gKLpv5RciUD+jqqcSDXx+BJUHRrjJdrBvNa8H8jzfX0VGKr7oJl52eUwD3Be1Da5M5FOi2aXh+MYNrisDIWb2jwR4RoDDu2vbzR6ebMR9clBIw/iwUvc5xi5HhDMbgVHRWgpEdFTfYjN/JN90A3dIiwN4jKEHbkRDRbHN10wHsvXqGRagBX1Q1pYfd1ciNijXXF5CkuIk8yb7r1GWBv97Y8bMKWVQZ5hl48M+CvpuLhM9iH1bEAkkwKcW/HSOaOlU3u7OBgZsskf8yVrx1nTaCHZuCmcBxB68RUvFSpvxzclBRb2r1a6kV7zVXNbXUVn9MDQ30a3BNqfqqKqzftUoSx5Ykt9TmnKxatU6DR02HGb15mBfOA6eNzpfR36IWRng1zmnzPTqk5xfuRmlyor8pqfldy7riz1Nm3rNRkf+z0CeqdYmzRJkPN1LXd4Gnj6kX9Ccl/ryFf/Zbg1b5AwTot+YWPQxV0q2/7e5IiTt6bYiYROM0wZhWXXLt+KYi08z/0JHYkp2+BPLzJM4XfI0aLVCUyoF1s9Tln/99MVgbUYCI9nDOsZQ0Szm5Yo2Nd4zRtb7VApIk81cTQVuH0/6YuZ9PqE6oKvEEZQ845oP/9ut5lUoboaVUp/N x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB5801.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(346002)(396003)(366004)(39860400002)(136003)(451199021)(66556008)(66946007)(66446008)(76116006)(66476007)(64756008)(478600001)(19627235002)(4326008)(110136005)(54906003)(316002)(7696005)(33656002)(86362001)(38070700005)(6506007)(9686003)(83380400001)(26005)(53546011)(5660300002)(71200400001)(30864003)(52536014)(55016003)(2906002)(8676002)(8936002)(186003)(122000001)(82960400001)(41300700001)(38100700002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?2lGXVqKE91+3xfMaCO5mVnJkP5/7o8qOtzkPaxMZIx12uzRX7q1AuCYJ48YE?= =?us-ascii?Q?lK0+YuRijbiZMWdCL+O9cHCDgO83Np5ja0H5uXJ0beT85rihKHSLdlm/uix7?= =?us-ascii?Q?TxleCvTk/Im+SIM0LsZSMrn20rqPySaAjBqZyJlP6gHjQx0RYD3SqlXNSkA/?= =?us-ascii?Q?mLy9s/OId9UUY6t/CdBRRGeXUtaOXQYPxd62PyNeppIh+LSKrh4vIJRzqPTX?= =?us-ascii?Q?BqiKVAMJ2qmV3DNMDyeadvbkL2SyiHUAZGxT1Kw5T3uRUCzYMSCm5Z5npait?= =?us-ascii?Q?8qJP+bVSQ5FmMKg4Nf0J+D78hFmQhxxuQX/mcTlWLlta+yO5EWTzB3urrngk?= =?us-ascii?Q?uojPB5AugjVuyPAG1MCPlwxhRDnYm8V+KvdEgExkUbscylJ5QZlWAEPi8DPI?= =?us-ascii?Q?6h2o9gHhYTvX+lif6+tBYivH9kyjE2gqg4oigU3Do6uBmEJTKi6izdgtRZt5?= =?us-ascii?Q?TSVF/w5Juz6mY+/hXgCzURhPz/TSlfG4MunD1ph16FCkVg29t+bipUKzXtrb?= =?us-ascii?Q?e08CWsDmmdaPnIa0FhSsxlF7jiyIsSdEQxihZ1SfUukYqVSt81N4Fl1IEsQZ?= =?us-ascii?Q?xLXlh21tupjM1FzOISwxHJtrDn7fm74kXmsKFD4PlYnKtuTuZDIdW5FTxy8v?= =?us-ascii?Q?EUaxpPYJVwQXbov9j2uQF52s4dolXvcR/VH7FvkJ+uKYgpkl/skM8I7TBqAQ?= =?us-ascii?Q?QLPQcL1Vz9u11PSqBh6B1QFoNkTVEzVEJ+0QLx+uZD1/tKGKJ/LxZz1ZrfO3?= =?us-ascii?Q?/z3geyd+m4CMFpQpvVY8vPpE7xWbYoYSZtfVD2kddcA4iTsTHmSJoTK6ncTP?= =?us-ascii?Q?pzvsauMAYs3KpNWExwpLmW7VB2cwQABEgKO66IzCgB9HOYUKe64iul+nu767?= =?us-ascii?Q?/3zBHeJdfapPG/NOPMT45Xe5CwteJPo8uA632w5pgI9brKlwkjPCq4JwSvmK?= =?us-ascii?Q?tU4gDMc3eDw4XffQZ4TMQO6ZyeFsrmyoMEU5KfLlnqSGFu2nGoW5FEePj5JN?= =?us-ascii?Q?LRV0SYdPeIDS5sZmXiVqmihozcSZpNYcYFhnXXwKBcW0TBwModqsNblGUd4A?= =?us-ascii?Q?bHmte9HgTlZcApcz6kaANkuITuN9sH6BFN1XYqVxQ/lu5HBaT8MjoFvWaHGT?= =?us-ascii?Q?460U7/k48n5vuyIE3niKUXzPFTgXz0vjhKq72Lbf1bLpP63pAlTQJ4nS7dVM?= =?us-ascii?Q?aKIfFxgYSrxEPMnURxwO3UWT1c64H0IL9iJjxcacFENbsjL7vlQ+/kWNkNBn?= =?us-ascii?Q?b4jNYAVXZg5do2WurOIXid29YvveooqBQSWHCs+tkcCY7BG/ecgW8wY3zrMn?= =?us-ascii?Q?NJKDMF7C+eLA04WTbKVpyzI7C2m0iB8is4O+uPejQFoeUFo+/fFIIuvZuuHM?= =?us-ascii?Q?stgWpQGogQ4whjD/qqo9UndUC2T2t/cp56pIiOiR73Ns85kcCzNsGVO31Dse?= =?us-ascii?Q?ZZD0yUK6rdF7pn4jIcNx52WBJ4eGZBKVGQqmWnRqLDnPNpIAsAOTxI4+FzVy?= =?us-ascii?Q?Lrc0XcD1nN7Yh11m15mj+lcckG1xrumk3g064i6mzbhSYzodWNbRjVxdep6R?= =?us-ascii?Q?S3r2p932EdQd3fWSZRzcu6slXp5XAi2Qpd3CcSPJ?= 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: 89865034-6d07-463b-a6e4-08db5819ecc7 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2023 03:34:17.2597 (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: bXgIOCpT45tZ2zqzZ/asgapN6flLWTljESIYSXwZCEzWkLG4GLulKH/b796KKx1RquVwpd5Sf7CnHI8mYufZTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR11MB8048 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Isaac Oram Typo in "wtchdog" and "Failt". Can be fixed prior to commit. -----Original Message----- From: abner.chang@amd.com =20 Sent: Saturday, May 13, 2023 5:33 AM To: devel@edk2.groups.io Cc: Oram, Isaac W ; Abdul Lateef Attar ; Nickle Wang ; Tinh Nguyen Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiFrb: IPMI FRB Dri= ver From: Abner Chang IpmiFrb is cloned from edk2-platforms/Features/Intel/OutOfBandManagement/ IpmiFeaturePkg/Frb in order to consolidate edk2 system manageability support in one place. Uncustify is applied to C files and no functionalities are changed in this = patch. We will still keep the one under IpmiFeaturePkg/Frb until the reference to = this instance are removed from platforms. Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Tinh Nguyen --- .../ManageabilityPkg/ManageabilityPkg.dec | 5 + .../Universal/IpmiFrb/FrbDxe.inf | 37 +++ .../Universal/IpmiFrb/FrbPei.inf | 37 +++ .../Universal/IpmiFrb/FrbDxe.c | 212 ++++++++++++++++++ .../Universal/IpmiFrb/FrbPei.c | 87 +++++++ 5 files changed, 378 insertions(+) create mode 100644 Features/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.inf create mode 100644 Features/ManageabilityPkg/Universal/IpmiFrb/FrbPei.inf create mode 100644 Features/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.c create mode 100644 Features/ManageabilityPkg/Universal/IpmiFrb/FrbPei.c diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/Mana= geabilityPkg/ManageabilityPkg.dec index 38813c5f48..b0ca01094a 100644 --- a/Features/ManageabilityPkg/ManageabilityPkg.dec +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec @@ -80,3 +80,8 @@ gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BOOL= EAN|0x10000005 gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEna= ble|FALSE|BOOLEAN|0x10000006 =20 +[PcdsDynamic, PcdsDynamicEx] + =20 +gManageabilityPkgTokenSpaceGuid.PcdFRB2EnabledFlag|TRUE|BOOLEAN|0x20000 +001 + ## This is the timeout value in milliseconds, default set to 360=20 +milliseconds + # @Prompt IPMI Fault Resilient Booting timeout value in milliseconds. + =20 +gManageabilityPkgTokenSpaceGuid.PcdFRBTimeoutValue|360|UINT16|0x2000000 +2 diff --git a/Features/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.inf b/Featu= res/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.inf new file mode 100644 index 0000000000..ae57fe7697 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.inf @@ -0,0 +1,37 @@ +### @file +# Component description file for IPMI FRB. +# +# Copyright (c) 2018 - 2019, Intel Corporation. All rights=20 +reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ### + +[defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D FrbDxe + FILE_GUID =3D A142CEE5-99D5-4ECF-943E-D8F0DE3052AA + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D FrbDxeEntryPoint + +[Sources] + FrbDxe.c + +[Packages] + ManageabilityPkg/ManageabilityPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + UefiLib + BaseMemoryLib + DebugLib + IpmiCommandLib + MemoryAllocationLib + PcdLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Depex] + TRUE diff --git a/Features/ManageabilityPkg/Universal/IpmiFrb/FrbPei.inf b/Featu= res/ManageabilityPkg/Universal/IpmiFrb/FrbPei.inf new file mode 100644 index 0000000000..89d633f32e --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiFrb/FrbPei.inf @@ -0,0 +1,37 @@ +### @file +# Component description file for IPMI FRB PEIM. +# +# Copyright (c) 2018 - 2019, Intel Corporation. All rights=20 +reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ### + +[defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D FrbPei + FILE_GUID =3D 7CAAE1A7-0B37-4EEA-A432-2F203DA6F288 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeFrbPei + +[Sources] + FrbPei.c + +[Packages] + ManageabilityPkg/ManageabilityPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + IpmiCommandLib + PcdLib + PeimEntryPoint + +[Pcd] + gManageabilityPkgTokenSpaceGuid.PcdFRB2EnabledFlag + gManageabilityPkgTokenSpaceGuid.PcdFRBTimeoutValue + +[Depex] + TRUE diff --git a/Features/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.c b/Feature= s/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.c new file mode 100644 index 0000000000..46f741eed1 --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.c @@ -0,0 +1,212 @@ +/** @file + IPMI Fault Resilient Booting Driver. + +Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include #include =20 +#include #include + +/** + This routine disables the specified FRB timer. + + @retval EFI_STATUS EFI_SUCCESS FRB timer was disabled + EFI_ABORTED Timer was already stopped + EFI_UNSUPPORTED This type of FRB timer is not suppo= rted. + +**/ +EFI_STATUS +EfiDisableFrb ( + VOID + ) +{ + EFI_STATUS Status; + IPMI_SET_WATCHDOG_TIMER_REQUEST SetWatchdogTimer; + UINT8 CompletionCode; + IPMI_GET_WATCHDOG_TIMER_RESPONSE GetWatchdogTimer; + + Status =3D IpmiGetWatchdogTimer (&GetWatchdogTimer); if (EFI_ERROR=20 + (Status)) { + return Status; + } + + // + // Check if timer is still running, if not abort disable routine. + // + if (GetWatchdogTimer.TimerUse.Bits.TimerRunning =3D=3D 0) { + return EFI_ABORTED; + } + + ZeroMem (&SetWatchdogTimer, sizeof (SetWatchdogTimer)); // // Just=20 + flip the Timer Use bit. This should release the timer. + // + SetWatchdogTimer.TimerUse.Bits.TimerRunning =3D 0; + SetWatchdogTimer.TimerUse.Bits.TimerUse =3D IPMI_WATCHDOG_TIMER_B= IOS_FRB2; + SetWatchdogTimer.TimerUseExpirationFlagsClear &=3D ~BIT2; =20 + SetWatchdogTimer.TimerUseExpirationFlagsClear |=3D BIT1 | BIT4; + + Status =3D IpmiSetWatchdogTimer (&SetWatchdogTimer, &CompletionCode); + return Status; +} + +/** + This function disables FRB2. This function gets called each time the + EFI_EVENT_SIGNAL_READY_TO_BOOT gets signaled + + @param[in] Event The handle of callback event. + @param[in] Context This should be NULL means no context associated + with this event. + +**/ +VOID +EFIAPI +DisableFRB2Handler ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + DEBUG ((DEBUG_ERROR, "!!! enter DisableFRB2Handler()!!!\n")); + + EfiDisableFrb (); +} + +/** + This function checks the Watchdog timer expiration flags and + report the kind of watchdog timeout occurred to the Error + Manager. + + @retval EFI_STATUS EFI_SUCCESS Timeout status is checked and cleared. + EFI_ERROR There was an error when check and clear + timeout status. + +**/ +EFI_STATUS +CheckForAndReportErrors ( + VOID + ) +{ + EFI_STATUS Status; + IPMI_GET_WATCHDOG_TIMER_RESPONSE GetWatchdogTimer; + IPMI_SET_WATCHDOG_TIMER_REQUEST SetWatchdogTimer; + UINT8 CompletionCode; + + // + // Get the Watchdog timer info to find out what kind of timer expiration= occurred. + // + Status =3D IpmiGetWatchdogTimer (&GetWatchdogTimer); if (EFI_ERROR=20 + (Status)) { + return Status; + } + + // + // If FRB2 Failure occurred, report it to the error manager and log a SE= L. + // + if ((GetWatchdogTimer.TimerUseExpirationFlagsClear & BIT1) !=3D 0) { + // + // Report the FRB2 time-out error + // + } else if ((GetWatchdogTimer.TimerUseExpirationFlagsClear & BIT3) !=3D 0= ) { + // + // Report the OS Watchdog timer failure + // + } + + // + // Need to clear Timer expiration flags after checking. + // + ZeroMem (&SetWatchdogTimer, sizeof (SetWatchdogTimer)); + SetWatchdogTimer.TimerUse =3D GetWatchdogTimer.Time= rUse; + SetWatchdogTimer.TimerActions =3D GetWatchdogTimer.Time= rActions; + SetWatchdogTimer.PretimeoutInterval =3D GetWatchdogTimer.Pret= imeoutInterval; + SetWatchdogTimer.TimerUseExpirationFlagsClear =3D GetWatchdogTimer.Time= rUseExpirationFlagsClear; + SetWatchdogTimer.InitialCountdownValue =3D GetWatchdogTimer.Init= ialCountdownValue; + SetWatchdogTimer.TimerUse.Bits.TimerRunning =3D 1; + SetWatchdogTimer.TimerUseExpirationFlagsClear |=3D BIT1 | BIT2 | BIT3; + + Status =3D IpmiSetWatchdogTimer (&SetWatchdogTimer, &CompletionCode); + + return Status; +} + +/** + This routine is built only when DEBUG_MODE is enabled. It is used + to report the status of FRB2 when the FRB2 driver is installed. + + @retval EFI_STATUS EFI_SUCCESS All info was retrieved and reported + EFI_ERROR There was an error during info retrieva= l + +**/ +EFI_STATUS +ReportFrb2Status ( + VOID + ) +{ + EFI_STATUS Status; + IPMI_GET_WATCHDOG_TIMER_RESPONSE GetWatchdogTimer; + + // + // Get the Watchdog timer info to find out what kind of timer expiration= occurred. + // + Status =3D IpmiGetWatchdogTimer (&GetWatchdogTimer); if (EFI_ERROR=20 + (Status)) { + DEBUG ((DEBUG_INFO, "Failed to get Watchdog Timer info from BMC.\n")); + return Status; + } + + // + // Check if timer is running, report status to DEBUG_MODE output. + // + if (GetWatchdogTimer.TimerUse.Bits.TimerRunning =3D=3D 1) { + DEBUG ((DEBUG_INFO, "FRB2 Timer is running.\n")); } else { + DEBUG ((DEBUG_INFO, "FRB2 Timer is not running.\n")); } + + return EFI_SUCCESS; +} + +/** + The entry point of the Ipmi Fault Resilient Booting DXE driver. + + @param[in] ImageHandle - Handle of this driver image @param[in]=20 + SystemTable - Table containing standard EFI services + + @retval EFI_SUCCESS - IPMI Protocol is installed successfully. + @retval Otherwise - Other errors. + +**/ +EFI_STATUS +EFIAPI +FrbDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_EVENT ReadyToBootEvent; + EFI_STATUS Status; + + CheckForAndReportErrors (); + ReportFrb2Status (); + + // + // Register the event to Disable FRB2 before Boot. + // + Status =3D EfiCreateEventReadyToBootEx ( + TPL_NOTIFY, + DisableFRB2Handler, + NULL, + &ReadyToBootEvent + ); + + return Status; +} diff --git a/Features/ManageabilityPkg/Universal/IpmiFrb/FrbPei.c b/Feature= s/ManageabilityPkg/Universal/IpmiFrb/FrbPei.c new file mode 100644 index 0000000000..431cac17bc --- /dev/null +++ b/Features/ManageabilityPkg/Universal/IpmiFrb/FrbPei.c @@ -0,0 +1,87 @@ +/** @file + IPMI Fault Resilient Booting (FRB) PEIM. + +Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include + +/** + This function sets wtchdog timer for Failt Resilient Booting + according to Frb2Enabled. + + @param [in] Frb2Enabled Whether to enable FRB2 timeout + +**/ +VOID +SetWatchDogTimer ( + IN BOOLEAN Frb2Enabled + ) +{ + EFI_STATUS Status; + IPMI_SET_WATCHDOG_TIMER_REQUEST FrbTimer; + IPMI_GET_WATCHDOG_TIMER_RESPONSE GetWatchdogTimer; + UINT8 CompletionCode; + + Status =3D IpmiGetWatchdogTimer (&GetWatchdogTimer); if (EFI_ERROR=20 + (Status)) { + return; + } + + if (Frb2Enabled) { + ZeroMem (&FrbTimer, sizeof (FrbTimer)); + // Byte 1 + FrbTimer.TimerUse.Bits.TimerUse =3D IPMI_WATCHDOG_TIMER_BIOS_FRB2; + // Byte 2 + FrbTimer.TimerActions.Uint8 =3D 0; // NormalBoot, NoTimeOutInterrup= t. i.e no action when BMC watchdog timeout + // Byte 3 + FrbTimer.PretimeoutInterval =3D 0; + // Byte 4 + FrbTimer.TimerUseExpirationFlagsClear |=3D BIT1; // set=20 + Frb2ExpirationFlag + + // Data Byte 5/6 + FrbTimer.InitialCountdownValue =3D PcdGet16 (PcdFRBTimeoutValue) *=20 + 10; + + // Set BMC watchdog timer + Status =3D IpmiSetWatchdogTimer (&FrbTimer, &CompletionCode); + Status =3D IpmiResetWatchdogTimer (&CompletionCode); + } +} + +/** + The entry point of the Ipmi Fault Resilient Booting PEIM. + + @param [in] FileHandle Handle of the file being invoked. + @param [in] PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS Indicates that Ipmi initialization completed succe= ssfully. + @retval Others Indicates that Ipmi initialization could not compl= ete successfully. + +**/ +EFI_STATUS +EFIAPI +InitializeFrbPei ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + BOOLEAN Frb2Enabled; + + // + // If we are booting with defaults, then make sure FRB2 is enabled. + // + Frb2Enabled =3D PcdGetBool (PcdFRB2EnabledFlag); + + SetWatchDogTimer (Frb2Enabled); + + return EFI_SUCCESS; +} -- 2.37.1.windows.1