From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.116]) by mx.groups.io with SMTP id smtpd.web11.69993.1684082843591289958 for ; Sun, 14 May 2023 09:47:23 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="no key for verify" header.i=@amperemail.onmicrosoft.com header.s=selector1-amperemail-onmicrosoft-com header.b=GwfH9gBu; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.116, mailfrom: tinhnguyen@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cFuNUACWIkTP5mCw6kYNiMYMdKQQcXSq1PvRbyq4NAWgiE7kIo2xV85+OXneGW/iJ4pTyLPuiXrTkKHWCqpxjTnvSWAAhY6zpUsB1m66t+wHybcaFO75WUtvgBkVo/p1ahtnIau8LObK2IjxNOW4n6ZKD31nl+LRLpP836onAzFPWzbmy0kCYu3H0EBMAmSnyoVimIJvbkPCOVlSh3rwkL42z35E8ax1GUTWLWWQke13ehvWpkmVUT7DII3zgp2VP1nOykun/GuoYyH/8eqryx06h+IHpp12M+UCofCWPJwgY8p/+sGz+22o7S7x1a5ZVPcqDRUR9/yfAGljhIPWgg== 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=E6HMeKr9f2BWktPRriRDOptxqRdBUVxP6Hum19Jl51c=; b=k7V4AsKT88mS51Ro+WkvpOELxFgr0yueuXrjfHKuhIdbOELfsWGERcUDJ/Vf9A09VujDeA4LZH4/vcKB/SF+hD+yz0OH/Ypo3rl9mGE6ZaDTXGnpa1ikd9zfp4t3uaJFs+pZ9B1DmIt5F2E9Ub1cGaPNTz3vg/DyPPUIAUlu7Y1o810N9oE/X5OHpTQUDQkXvl6/PaMuso9M6ZLgyw0de8j6OFAEPpGFbdm5XtUebM+tvvXe9T8XWZW+4r9h6vaoiZtk/Xfku5LFWACByJ7QuoZTic76VJqlhUjWc/qEprIwzjtUuAQsB4VqxM71ZqxKtaKZutVu0WaATnhycOyABA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=amperemail.onmicrosoft.com; dkim=pass header.d=amperemail.onmicrosoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amperemail.onmicrosoft.com; s=selector1-amperemail-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E6HMeKr9f2BWktPRriRDOptxqRdBUVxP6Hum19Jl51c=; b=GwfH9gBuGyPGX+LTJFxcvebj+gtoCpciUtLo/bLPIEqKgeWp7EyX81fE2M70P0zMby4H4nQJ99s+2dU88sJlS72Pwmo+XaXh0zmfaaGcsXXphgZ39zM56v6PraveqVpDOzqHcwjkxVgPyRpih2CSYM4VmcJb4W11bK2iSyxjpaQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amperemail.onmicrosoft.com; Received: from DM5PR0102MB3336.prod.exchangelabs.com (2603:10b6:4:9f::11) by BL0PR0102MB3457.prod.exchangelabs.com (2603:10b6:207:39::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.30; Sun, 14 May 2023 16:47:18 +0000 Received: from DM5PR0102MB3336.prod.exchangelabs.com ([fe80::fefc:e2a9:e823:fe42]) by DM5PR0102MB3336.prod.exchangelabs.com ([fe80::fefc:e2a9:e823:fe42%6]) with mapi id 15.20.6387.020; Sun, 14 May 2023 16:47:18 +0000 Message-ID: Date: Sun, 14 May 2023 23:47:08 +0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiFrb: IPMI FRB Driver To: abner.chang@amd.com, devel@edk2.groups.io Cc: Isaac Oram , Abdul Lateef Attar , Nickle Wang , Tinh Nguyen References: <20230513123327.1496-1-abner.chang@amd.com> From: "Tinh Nguyen" In-Reply-To: <20230513123327.1496-1-abner.chang@amd.com> X-ClientProxiedBy: SG2PR01CA0130.apcprd01.prod.exchangelabs.com (2603:1096:4:40::34) To DM5PR0102MB3336.prod.exchangelabs.com (2603:10b6:4:9f::11) Return-Path: tinhnguyen@os.amperecomputing.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3336:EE_|BL0PR0102MB3457:EE_ X-MS-Office365-Filtering-Correlation-Id: ebd5d5d3-64b7-46ff-867a-08db549ae0e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7GkFgEIKnaAFbI2/VRdPEAjTrew6Wjf8Q0FOtp1uylFBYsrYD4BL2NuaiyVGPyH7u/5yDVFYxXmth5exAmKsS4gUflT98jreLNzXzTAdQhEZ74C5LsbiPeaXY3RAJkjWm+t2TdA4oI4uop+jILY3wQtiUs8C2YeGWzXcd2dpU+N+rpLKJ8fGVBI3QLU50pIRixAoUFu5dBuFhTgRYJBv/w0FD+1zfxK4PxPPOZO7i8F2k6X9l/L+uF7ltQD8K7ctAkKRs8HDxL2V6qMxeVUTPtOy/+1eYX+c9laCCjTT9xzgWypcBoCPPERPrHV/XyUh8C0OKhyPSjBjVCU9AG3KpQvTZrHfJ+tEtHwZqiWHNASY++c7ZCUbFWeWI3Tx9BArjYxr1LtYHRzxWRnSYR9H3UEi5t7Zp4+YeOglEJ2PykKi8FxWzy5xDEcCdubNXjA2rhUFzWGi1R9QvBGtlOlSp7eBDtLhrQB1kTXDZwX6sUwqYkXzR5gQOmlbrsbOrWMdKpG1qT8FxeVIJznNbddFVe7h8bKnfnQbniNitykw11wTex4RHAqFYxoKfe+3MFyyiyq4WcAwMRWmWeo13ZV6sxu14L42k5SkgDNKkbl1fHse4LL15PSr8ruF1YOoLBXf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR0102MB3336.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(396003)(39840400004)(346002)(376002)(136003)(451199021)(54906003)(19627235002)(316002)(66946007)(66556008)(66476007)(4326008)(478600001)(6486002)(6666004)(8936002)(8676002)(5660300002)(41300700001)(30864003)(2906002)(83170400001)(31696002)(38100700002)(2616005)(26005)(107886003)(186003)(53546011)(6512007)(6506007)(83380400001)(42882007)(31686004)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OXZSRjE0L1JLZnM5dHpWOWd6WlNXM0xzVU9haDJTQWplcG9Xdzc4LzVTcTlF?= =?utf-8?B?Z2NiY1BDOWtYeFM1MElWYVJXRFA1blJ2Zjl3cnpQQzRQbkt2UG8wWmwzY3BN?= =?utf-8?B?Vit3T1ora2lrRWRLdUFRbDNFKzNjSkwxYjR3MzJPM1gxVmIvNW95YTdFUFR4?= =?utf-8?B?dEV2S2tZS0ZaREdWS3dCTVZxY1JRL2NXV2ZZQXFZTXlubnhXbHNDTnNGWDJG?= =?utf-8?B?dGc5VFk2YTY4Y3A3dVNVdTlNTE9Ga25JNGZhOHFYSGdmZEVkeXBkTXd1WW9Y?= =?utf-8?B?Nm9hY2lOTEhoMGFteWtwdlJjWHRHUlpHcTNmTmNFbEYyeUloNHhPay9kOENT?= =?utf-8?B?ZEtQWVJRMHpEWjN4VTF6d1hyUTdLNFpvSWs4MXFVR1JSb05wTGQxMm9BcERs?= =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: amperemail.onmicrosoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebd5d5d3-64b7-46ff-867a-08db549ae0e1 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3336.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2023 16:47:18.1077 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AQn7S3Sm9RvKjFCml4cdYB9ejRJl2w4v2VFW6+CU4voyyHb5mf3quPyo1sCaaHPNnKwMBU2BmVPKDjD+qGaqaC3OCqUYAKy0k9aK755beRmcRr2y1T+22kQNiAApdZHb X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR0102MB3457 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reviewed-by: Tinh Nguyen There is a minor typo that I commented on below. On 13/05/2023 19:33, abner.chang@amd.com wrote: > 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/ManageabilityPkg/ManageabilityPkg.dec > index 38813c5f48..b0ca01094a 100644 > --- a/Features/ManageabilityPkg/ManageabilityPkg.dec > +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec > @@ -80,3 +80,8 @@ > gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BOOLEAN|0x10000005 > gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|FALSE|BOOLEAN|0x10000006 > > +[PcdsDynamic, PcdsDynamicEx] > + gManageabilityPkgTokenSpaceGuid.PcdFRB2EnabledFlag|TRUE|BOOLEAN|0x20000001 > + ## 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|0x20000002 > diff --git a/Features/ManageabilityPkg/Universal/IpmiFrb/FrbDxe.inf b/Features/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 = 0x00010005 > + BASE_NAME = FrbDxe > + FILE_GUID = A142CEE5-99D5-4ECF-943E-D8F0DE3052AA > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT = 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/Features/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 = 0x00010005 > + BASE_NAME = FrbPei > + FILE_GUID = 7CAAE1A7-0B37-4EEA-A432-2F203DA6F288 > + MODULE_TYPE = PEIM > + VERSION_STRING = 1.0 > + ENTRY_POINT = 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/Features/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 supported. > + > +**/ > +EFI_STATUS > +EfiDisableFrb ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + IPMI_SET_WATCHDOG_TIMER_REQUEST SetWatchdogTimer; > + UINT8 CompletionCode; > + IPMI_GET_WATCHDOG_TIMER_RESPONSE GetWatchdogTimer; > + > + Status = IpmiGetWatchdogTimer (&GetWatchdogTimer); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // > + // Check if timer is still running, if not abort disable routine. > + // > + if (GetWatchdogTimer.TimerUse.Bits.TimerRunning == 0) { > + return EFI_ABORTED; > + } > + > + ZeroMem (&SetWatchdogTimer, sizeof (SetWatchdogTimer)); > + // > + // Just flip the Timer Use bit. This should release the timer. > + // > + SetWatchdogTimer.TimerUse.Bits.TimerRunning = 0; > + SetWatchdogTimer.TimerUse.Bits.TimerUse = IPMI_WATCHDOG_TIMER_BIOS_FRB2; > + SetWatchdogTimer.TimerUseExpirationFlagsClear &= ~BIT2; > + SetWatchdogTimer.TimerUseExpirationFlagsClear |= BIT1 | BIT4; > + > + Status = 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 = IpmiGetWatchdogTimer (&GetWatchdogTimer); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // > + // If FRB2 Failure occurred, report it to the error manager and log a SEL. > + // > + if ((GetWatchdogTimer.TimerUseExpirationFlagsClear & BIT1) != 0) { > + // > + // Report the FRB2 time-out error > + // > + } else if ((GetWatchdogTimer.TimerUseExpirationFlagsClear & BIT3) != 0) { > + // > + // Report the OS Watchdog timer failure > + // > + } > + > + // > + // Need to clear Timer expiration flags after checking. > + // > + ZeroMem (&SetWatchdogTimer, sizeof (SetWatchdogTimer)); > + SetWatchdogTimer.TimerUse = GetWatchdogTimer.TimerUse; > + SetWatchdogTimer.TimerActions = GetWatchdogTimer.TimerActions; > + SetWatchdogTimer.PretimeoutInterval = GetWatchdogTimer.PretimeoutInterval; > + SetWatchdogTimer.TimerUseExpirationFlagsClear = GetWatchdogTimer.TimerUseExpirationFlagsClear; > + SetWatchdogTimer.InitialCountdownValue = GetWatchdogTimer.InitialCountdownValue; > + SetWatchdogTimer.TimerUse.Bits.TimerRunning = 1; > + SetWatchdogTimer.TimerUseExpirationFlagsClear |= BIT1 | BIT2 | BIT3; > + > + Status = 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 retrieval > + > +**/ > +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 = 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 == 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 = EfiCreateEventReadyToBootEx ( > + TPL_NOTIFY, > + DisableFRB2Handler, > + NULL, > + &ReadyToBootEvent > + ); > + > + return Status; > +} > diff --git a/Features/ManageabilityPkg/Universal/IpmiFrb/FrbPei.c b/Features/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 watchdog > + 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 = IpmiGetWatchdogTimer (&GetWatchdogTimer); > + if (EFI_ERROR (Status)) { > + return; > + } > + > + if (Frb2Enabled) { > + ZeroMem (&FrbTimer, sizeof (FrbTimer)); > + // Byte 1 > + FrbTimer.TimerUse.Bits.TimerUse = IPMI_WATCHDOG_TIMER_BIOS_FRB2; > + // Byte 2 > + FrbTimer.TimerActions.Uint8 = 0; // NormalBoot, NoTimeOutInterrupt. i.e no action when BMC watchdog timeout > + // Byte 3 > + FrbTimer.PretimeoutInterval = 0; > + // Byte 4 > + FrbTimer.TimerUseExpirationFlagsClear |= BIT1; // set Frb2ExpirationFlag > + > + // Data Byte 5/6 > + FrbTimer.InitialCountdownValue = PcdGet16 (PcdFRBTimeoutValue) * 10; > + > + // Set BMC watchdog timer > + Status = IpmiSetWatchdogTimer (&FrbTimer, &CompletionCode); > + Status = 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 successfully. > + @retval Others Indicates that Ipmi initialization could not complete 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 = PcdGetBool (PcdFRB2EnabledFlag); > + > + SetWatchDogTimer (Frb2Enabled); > + > + return EFI_SUCCESS; > +}