From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.40]) by mx.groups.io with SMTP id smtpd.web11.80153.1684120051735964220 for ; Sun, 14 May 2023 20:07:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=kwdyDbnR; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.94.40, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z5o7aGwWVU95iJ5nbwRynZkv/LuBt9z15+NRtNMWS0CSvXmShg1EwOz9n+Y3wcYWLCIy6dT8IgU3I8i0rStYEQlL38ulBKD19wAqYYCFQ7GmGJ2cwgnlZajDKsRrOewMb3tYDLKy7Gub+Ax1fmmrR2+oXpOIc9jgsKUtDGQgehifGtZxZ9FXU0kvFWN88EF/UTkMMkV89NsgDBmGmSKAYfglKa+2sNE0aUR3xcP5xpTZT+/8x78OpP20h0/7LoVoVSaq+oCXdbxduhUIfaURWz0W2jcyeaJnpxCPKgo+emo3Hr92HVM1BauxxH9hvwAKCqvj+njCOy0LZv5fBz9Zyw== 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=VrAdNf8hzaKGAXuTzXSF159F6jfyzlu6eBw1+sw0kV0=; b=ZkxvYCPJpIPqvTEOUZ9S/dwmU4R9IKpNfMvhpdjLJgBUutWBpSx9vxbNTFx59JVLFNoATt0/IugJZuJOlc3rpcXuCWjWrj0UG6cvZluz7zJZGsy10LcG8h3HwCNNkx4bkL7V09sxH57rZRe4qaFPLKxRaPzKGZmYdblewI7tGD9zudS4kGB2lxkpk6EwCzhRhWAE8YqgR4Upp66W5i3PlwCq7vy49yaVXY4CJ02gH07hpibuXNuHjVEpYVd1+nfK1o/+0ySfQHCIKQFIQ2xX3QoXYcKnYf4UPS5uR2dM4jtQjU37cDgyBSdSgfgfXbKit7nvSTSImUq7wEqt12xcyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VrAdNf8hzaKGAXuTzXSF159F6jfyzlu6eBw1+sw0kV0=; b=kwdyDbnRXCDaLQuI/oxEnXe5L0oa3Dzk53pYrKpcl03+08vwNREzR7ppv9Vv3X8r9GxY006uAIvPfGVFlcmO3COEGoUo+gN7mehXnz6SvhGPQkTpVIAgVbBKfKXHr6GG1do1Jkfj2/zZBUVomcZHzqf9rSnksfIQqpJHVlzjwdc= Received: from PH7PR12MB6466.namprd12.prod.outlook.com (2603:10b6:510:1f6::22) by DS0PR12MB9057.namprd12.prod.outlook.com (2603:10b6:8:c7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.29; Mon, 15 May 2023 03:07:28 +0000 Received: from PH7PR12MB6466.namprd12.prod.outlook.com ([fe80::9837:e9ae:f203:bb7f]) by PH7PR12MB6466.namprd12.prod.outlook.com ([fe80::9837:e9ae:f203:bb7f%6]) with mapi id 15.20.6387.020; Mon, 15 May 2023 03:07:27 +0000 From: "Attar, AbdulLateef (Abdul Lateef)" To: "Chang, Abner" , "devel@edk2.groups.io" CC: Isaac Oram , 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: AQHZhZcqHp2xL7zVpEu2o5jpq4jqjK9aqYUg Date: Mon, 15 May 2023 03:07:27 +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: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=8ce77f54-046c-4d84-9366-3b9bf94512fe;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-05-15T03:07:15Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR12MB6466:EE_|DS0PR12MB9057:EE_ x-ms-office365-filtering-correlation-id: 8a1dcfae-9f46-4b7a-f3e9-08db54f183a2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8m/z6xmKbQ7aCN1htRnUNwdeqxIDkc1QOxylW0VbSaYaKKBt+aDWJF86elEzzPzSRNWTuyTJErGc0LSHte7ChMEs75arx+KHAdOZ02EdPJw5UNpibubT1nn6iFttTQZmTAKGFmSNG+Cfi1UrEVx3SJxKkxerM5HW1XPZL76mvdHnntEM17MDBSj11lHzSeCJiGv2Ee1jVjU9CGafUZtIwBm6FSbBYBCLNmE+XVDJkT5fbJo7H6WB8VXbQYTtNNTBo+/dAE2mWXvPzb1lDrKvEO2VFKWZNpnI/z5lw8M9p9Khpkh5WhJZEEvDBXsWkeaYnLd+nhkY+zG9w8oNxx0xBfHUL3l93F3X8I7CVXfbpdEUXROCZU8mARsolOWtfPrkb7B91cCuMUiaSeKT9lgOYOelxbPgw/GwhH2QshI5FsHFx1gB+VvBkOEAAA7juQ+yvjIT7XGmze/7eks+WXTPmhw19l6qB1gE4vmSNaKu3JLp/ZKSm7OgnSkHWLQCdZK9/Ze5U4QPX5XekV/rHfrhI+6vr1CX9Nm5NQGShS6FyHe8HcAJW8f4vmIXWmcjQEfVSMKSPoAP0/Ie2Py8I9IU1VGPOCgOSa0Fl1AGbgXEp5TM8JA6V0v33VGs02ciRl0V x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB6466.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(366004)(376002)(396003)(451199021)(30864003)(2906002)(71200400001)(38100700002)(55016003)(122000001)(53546011)(26005)(186003)(83380400001)(9686003)(6506007)(33656002)(86362001)(8676002)(8936002)(41300700001)(5660300002)(52536014)(110136005)(7696005)(478600001)(19627235002)(38070700005)(76116006)(66946007)(66556008)(316002)(4326008)(66446008)(66476007)(54906003)(64756008);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ncamJq/cSxRFsd3Gu1v21Pg4vGDGi/RBaoR3g8kl7C1dqA8tuAuKZl7NCE7F?= =?us-ascii?Q?Pn/hDYwZK9/WRZ09Uw1wZAGM3JLG2TAW/08EwXvK6QOfZf8iThM6refgvTsJ?= =?us-ascii?Q?UomO05l31m3c+EWSWrsnr1+BMvmryYMC44EvurP7SSXmFRPpuq6RPiV1glda?= =?us-ascii?Q?otHxckpZ76hwqlHIlSYutvmL0w9cBPg2nwFnba5kv7tAhWRFOCTEarNK2uHn?= =?us-ascii?Q?YSteYxH71OQc9XcUTxjuGu3NxD1Fv9GDqiEkSSgyYom/dnMeX+aUEO/8uduD?= =?us-ascii?Q?m8bzJVwtCv8FodYhsQicK8o3fTN0uiYNHsFnqP899XEkHVwct7GGTfLzciKs?= =?us-ascii?Q?eKPwfhMXas0196cCxODLj7wneQmOyife1hS5CPT8TLbMScHUepjQVMPmNOcN?= =?us-ascii?Q?LZwZELHg188Bd6V/YQbhc9Jg4LN2sJ4o4nWyc9Bg+XgCUPMXAIOxkVESwD4D?= =?us-ascii?Q?gFp4QeCIGdsTvT/6p09/NfDUVTLKgRWXK7dKnBNBFZESL2AZmavgjLt1xk94?= =?us-ascii?Q?tNun6unnzrsFozdOSnsT45cVJVB58CLIxgaG6dnd4pg5dlRJEicjl8CWRx+m?= =?us-ascii?Q?zu1nLPEBmhZKWdY9AALzGB5kPYhBj+xUmd4xHoQH9onBIZp2kF8AMCS0ssro?= =?us-ascii?Q?Cj9p21PYPJwW/qzXuPis7VgRRNOfgyqZafKzhsmDDnz1z2cQXwVEmj7VjGbv?= =?us-ascii?Q?A/FN5dckDEnBlD7SmK5vNcShdovU4A1FPG1yb/4di/Q04eUOQoWQei8NNkbu?= =?us-ascii?Q?UKvZ1prLh6f1f3++RDy3J7ES9S/4h42vTx/Dc7ONfs5LzeZJs6PxXvPqtdRK?= =?us-ascii?Q?KZeG5fyJazZq08XNVbGx5GJCz235kTBwNU5naV8vpl/LWNYQzUPMdfwe8dQc?= =?us-ascii?Q?h7QwLNLJXh9mFlAPJqp6hKdpAGhyB/tgqmy2o/drtCQQxki8MwWZpnU5CgYE?= =?us-ascii?Q?wcFUulhcAd/oCh69UqlBByTb2C6Ud/qZOYiXjLFB/5uDdeYCw3Pzj6b9pc0Y?= =?us-ascii?Q?FgAQrCXZ6bms5+QkE5rQnm7fZYyo3PhY0SqORFY/iKEhfrMizjuU8KkFofkM?= =?us-ascii?Q?WlhzsdcFj0c4IiNH7miSaTN6a1ydTsO/fHXWGnRZfTdgBi6aNk2q4erc/cz2?= =?us-ascii?Q?imhCthtJCuXYj0VMK2AfqNqn5ZAF7eS14wOL+9q4Tt+vUJPdHo2g4rMPBW1e?= =?us-ascii?Q?EX83dL2HUMV8Wb8AqB4GdaEJXs9XID1Z2Ka8pGqNNwGCqAMlTrKK5WzdfmiV?= =?us-ascii?Q?+JdDoYGU+6sxo8tUJrxqq1pSPj6scQUWSVQvmf4hASF7Z/m+EIcOYRfJWonw?= =?us-ascii?Q?5VONiF7dUa0WKXoiqx0Z2GfWA35QIMBBsWlcGYLJsTZSlbiWnRBL531H388J?= =?us-ascii?Q?ANMcg4hMozPPs79vAqUowwO5qDQuyGDMIiiEU/qfcmsL4xGY4WW8I98cVjpR?= =?us-ascii?Q?hOh4WLyLZrhx21AAGkLK8067/d0axz7IsraOXcdYatTKC0JDBaJSbE68IKFq?= =?us-ascii?Q?NqEsqWa4/zhL+Y4A2VdQUelcfR6W1vTr3ctXksoCjQhLDB78U2RqoFx/j1n6?= =?us-ascii?Q?KaYWaZPLAGuWy81ggpw=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB6466.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a1dcfae-9f46-4b7a-f3e9-08db54f183a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 May 2023 03:07:27.5159 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Y4/EoP4M1JaNTQuY3ecDGWlLK25mmr93xxEfNM00sYBLc9GbHzPjd06JPgjgnWyHPwzT2uZKVk33IrioFxiEtw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9057 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abdul Lateef Attar -----Original Message----- From: Chang, Abner Sent: 13 May 2023 18:03 To: devel@edk2.groups.io Cc: Isaac Oram ; Attar, AbdulLateef (Abdul Lateef) = ; 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 +[PcdsDynamic, PcdsDynamicEx] + +gManageabilityPkgTokenSpaceGuid.PcdFRB2EnabledFlag|TRUE|BOOLEAN|0x20000 +001 + ## This is the timeout value in milliseconds, default set to 360 +milliseconds + # @Prompt IPMI Fault Resilient Booting timeout value in milliseconds. + +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 +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 +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 +#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 + (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 + 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; + 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 + (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 + (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] + 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 + (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 + Frb2ExpirationFlag + + // Data Byte 5/6 + FrbTimer.InitialCountdownValue =3D PcdGet16 (PcdFRBTimeoutValue) * + 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