From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by mx.groups.io with SMTP id smtpd.web08.6483.1622849277792185606 for ; Fri, 04 Jun 2021 16:27:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=qnn0Yf0/; spf=pass (domain: nuviainc.com, ip: 209.85.221.54, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f54.google.com with SMTP id l2so10810698wrw.6 for ; Fri, 04 Jun 2021 16:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=aEPK1WplNS4ukmn+wSrY3iz8ZgryMBZQSQcJjJOMxGI=; b=qnn0Yf0/O79TX12FJsuxZVDHGvC87vkISr1g2Fx1Knw/ep9GzRbX+Flir4is5trJ6n k2HXBM59QvAJcU54mhfZqx+mieChuxX6k/k0x4yaHZKzURlsY3SpG/RySJNZpeVNzRNm lslKb+jnlb+crDdF93WfUJ36l0IY96pCNetioR6Ugu2VeztBp4ydAX0GdpK/Cx0zkMi0 m7ETso5cME4g6r9RObE+8a04QgKcfU/0ABST1gOOupUqH9PikyYYBQdKZHOrk/f2Dej9 Cf912pewV/sOz4M0wJMI3vk4kXwiD5dgYb2Y7b1JjXa8CdDVg5JIUUT90lURmIQYMJPi ePBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=aEPK1WplNS4ukmn+wSrY3iz8ZgryMBZQSQcJjJOMxGI=; b=SKs720nhlqgks6S43iQ70LBDSbJFw6CG4xrK38r+DS3pZzgi1HwxO0fzyZ8QRtROZE UhVnJX4J1NjuKNqUXbmjv5sE7pmXM/XtF26j9HNrsLAy61Tz08S3p1ML0ngPGSE4GGxd nmahNkuK9B4RYoxn9vWCTjwCkMIaq46bT16V2FI8ReMDmssNR+0QxNF0IZ9BHNTdWsgh M6fvGxgyy1pgtjqDOQ8v8HPwn+Bgorj1iB8Ig5IhTOGhrYqFaPfrbrHTZa10EK3goyR2 xoELr4GZCLYHD9ptYjrgveVP2GocJDf8GTl/qPuCck5p+E41eKoqhtiZEEe3kn+IzJJv tZcA== X-Gm-Message-State: AOAM532gD3LD4Wz35o0Pc6ckt1bo3jdCGAecge2UVoAowwNVqszsOsMO WZJak4oVqsj79a7s/r1QLlUQuA== X-Google-Smtp-Source: ABdhPJwb35GoAEPsGU5pT53wn2hVQ9MlgxQ9vh+aGz3/UNxrCM9XdQija7bpjR83T8Zkbe3TtB9wyA== X-Received: by 2002:a5d:58c8:: with SMTP id o8mr5956396wrf.299.1622849276088; Fri, 04 Jun 2021 16:27:56 -0700 (PDT) Return-Path: Received: from leviathan (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id r2sm8066252wrv.39.2021.06.04.16.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 16:27:55 -0700 (PDT) Date: Sat, 5 Jun 2021 00:27:53 +0100 From: "Leif Lindholm" To: Nhi Pham Cc: devel@edk2.groups.io, Quan Nguyen , Thang Nguyen , Chuong Tran , Phong Vo , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: Re: [edk2-platforms][PATCH v2 08/32] AmpereAltraPkg: Add BootProgress support Message-ID: <20210604232753.pc5gu5ggitiyqfqo@leviathan> References: <20210526100724.5359-1-nhi@os.amperecomputing.com> <20210526100724.5359-10-nhi@os.amperecomputing.com> MIME-Version: 1.0 In-Reply-To: <20210526100724.5359-10-nhi@os.amperecomputing.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, May 26, 2021 at 17:07:00 +0700, Nhi Pham wrote: > From: Quan Nguyen > > BootProgress will send 32-bit UEFI Status Code via doorbell to report > its progress status. > Currently support reporting Progress Status Code and Error Status Code > only. Other types of Status Code are ignored. > > Cc: Thang Nguyen > Cc: Chuong Tran > Cc: Phong Vo > Cc: Leif Lindholm > Cc: Michael D Kinney > Cc: Ard Biesheuvel > Cc: Nate DeSimone > > Signed-off-by: Quan Nguyen This looks like something that would be a good target to commonalise between platforms in the future. But for now: Reviewed-by: Leif Lindholm / Leif > --- > Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc | 2 + > Platform/Ampere/JadePkg/Jade.fdf | 2 + > Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.inf | 51 +++++ > Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.inf | 49 +++++ > Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.c | 211 ++++++++++++++++++++ > Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.c | 210 +++++++++++++++++++ > Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.uni | 16 ++ > Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.uni | 18 ++ > 8 files changed, 559 insertions(+) > > diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc > index 9f19f495fad2..9f75da6f05ad 100755 > --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc > +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc > @@ -529,6 +529,7 @@ [Components.common] > } > MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf > MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf > + Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.inf > > # > # DXE Phase modules > @@ -539,6 +540,7 @@ [Components.common] > } > MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf > MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf > + Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.inf > > # > # PCD > diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jade.fdf > index 80a86d7c1156..1857296a8ea5 100755 > --- a/Platform/Ampere/JadePkg/Jade.fdf > +++ b/Platform/Ampere/JadePkg/Jade.fdf > @@ -102,6 +102,7 @@ [FV.FVMAIN_COMPACT] > INF Silicon/Ampere/AmpereAltraPkg/Drivers/ATFHobPei/ATFHobPeim.inf > INF Silicon/Ampere/AmpereAltraPkg/Drivers/MemoryInitPeim/MemoryInitPeim.inf > INF Silicon/Ampere/AmpereAltraPkg/Drivers/MmCommunicationPei/MmCommunicationPei.inf > + INF Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.inf > INF ArmPkg/Drivers/CpuPei/CpuPei.inf > INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf > INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf > @@ -149,6 +150,7 @@ [FV.FvMain] > INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf > INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf > INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf > + INF Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.inf > > # > # PI DXE Drivers producing Architectural Protocols (EFI Services) > diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.inf > new file mode 100644 > index 000000000000..2211a213a6df > --- /dev/null > +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.inf > @@ -0,0 +1,51 @@ > +## @file > +# This module installs Boot Progress Dxe. > +# > +# This module registers report status code listener to report boot progress > +# to SMpro. > +# > +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x0001001B > + BASE_NAME = BootProgressDxe > + MODULE_UNI_FILE = BootProgressDxe.uni > + FILE_GUID = 6E12F248-F0C1-11EA-B37C-9798918A2163 > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + ENTRY_POINT = BootProgressDxeEntryPoint > + > +# > +# The following information is for reference only and not required by the build tools. > +# > +# VALID_ARCHITECTURES = AARCH64 > +# > + > +[Sources] > + BootProgressDxe.c > + > +[Packages] > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec > + > +[LibraryClasses] > + AmpereCpuLib > + BaseLib > + DebugLib > + DxeServicesLib > + SystemFirmwareInterfaceLib > + UefiBootServicesTableLib > + UefiDriverEntryPoint > + UefiLib > + UefiRuntimeServicesTableLib > + > +[Protocols] > + gEfiRscHandlerProtocolGuid ## CONSUMES > + > +[Depex] > + gEfiRscHandlerProtocolGuid > diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.inf > new file mode 100644 > index 000000000000..1dd0ec31ac37 > --- /dev/null > +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.inf > @@ -0,0 +1,49 @@ > +## @file > +# Boot Progress Pei Module. > +# > +# Updates to SCP with Boot Progress information during boot. > +# > +# This module register report status code listener to collect boot progress > +# information and keep SCP posted. > +# > +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x0001001B > + BASE_NAME = BootProgressPeim > + MODULE_UNI_FILE = BootProgressPeim.uni > + FILE_GUID = 2E8A3B3E-F26C-11EA-BDE5-6726AD8F88BD > + MODULE_TYPE = PEIM > + VERSION_STRING = 1.0 > + ENTRY_POINT = BootProgressPeiEntryPoint > + > +# > +# The following information is for reference only and not required by the build tools. > +# > +# VALID_ARCHITECTURES = AARCH64 > +# > + > +[Sources] > + BootProgressPeim.c > + > +[Packages] > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > + PeiServicesLib > + PeimEntryPoint > + SystemFirmwareInterfaceLib > + > +[Ppis] > + gEfiPeiRscHandlerPpiGuid ## CONSUMES > + > +[Depex] > + gEfiPeiRscHandlerPpiGuid > diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.c > new file mode 100644 > index 000000000000..f87a4d53179f > --- /dev/null > +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.c > @@ -0,0 +1,211 @@ > +/** @file > + > + This module installs Boot Progress Dxe that report boot progress to SMpro. > + > + This module registers report status code listener to report boot progress > + to SMpro. > + > + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +typedef struct { > + UINT8 Byte; > + EFI_STATUS_CODE_VALUE Value; > +} STATUS_CODE_TO_CHECKPOINT; > + > +enum BOOT_PROGRESS_STATE { > + BOOT_NOTSTART = 0, > + BOOT_START = 1, > + BOOT_COMPLETE = 2, > + BOOT_FAILED = 3, > +}; > + > +UINT32 DxeProgressCode[] = { > + (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT), // DXE Core is started > + (EFI_COMPUTING_UNIT_CHIPSET | EFI_CHIPSET_PC_DXE_HB_INIT), // PCI host bridge initialization > + (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT), // Boot Device Selection (BDS) phase is started  > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS), // Driver connecting is started > + (EFI_IO_BUS_PCI | EFI_IOB_PC_INIT), // PCI Bus initialization is started > + (EFI_IO_BUS_PCI | EFI_IOB_PCI_HPC_INIT), // PCI Bus Hot Plug Controller Initialization > + (EFI_IO_BUS_PCI | EFI_IOB_PCI_BUS_ENUM), // PCI Bus Enumeration > + (EFI_IO_BUS_PCI | EFI_IOB_PCI_RES_ALLOC), // PCI Bus Request Resources > + (EFI_IO_BUS_PCI | EFI_IOB_PC_ENABLE), // PCI Bus Assign Resources > + (EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_INIT), // Console Output devices connect > + (EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_INIT), // Console input devices connect > + (EFI_IO_BUS_LPC | EFI_IOB_PC_INIT), // Super IO Initialization > + (EFI_IO_BUS_USB | EFI_IOB_PC_INIT), // USB initialization is started > + (EFI_IO_BUS_USB | EFI_IOB_PC_RESET), // USB Reset > + (EFI_IO_BUS_USB | EFI_IOB_PC_DETECT), // USB Detect > + (EFI_IO_BUS_USB | EFI_IOB_PC_ENABLE), // USB Enable > + (EFI_IO_BUS_SCSI | EFI_IOB_PC_INIT), // SCSI initialization is started > + (EFI_IO_BUS_SCSI | EFI_IOB_PC_RESET), // SCSI Reset > + (EFI_IO_BUS_SCSI | EFI_IOB_PC_DETECT), // SCSI Detect > + (EFI_IO_BUS_SCSI | EFI_IOB_PC_ENABLE), // SCSI Enable > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD), // Setup Verifying Password > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP), // Start of Setup > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT), // Setup Input Wait > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT), // Ready To Boot event > + (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES), // Exit Boot Services event > + (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_SET_VIRTUAL_ADDRESS_MAP), // Runtime Set Virtual Address MAP Begin > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_VIRTUAL_ADDRESS_CHANGE_EVENT), // Runtime Set Virtual Address MAP End > + (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM), // System Reset > + (EFI_IO_BUS_USB | EFI_IOB_PC_HOTPLUG), // USB hot plug > + (EFI_IO_BUS_PCI | EFI_IOB_PC_HOTPLUG), // PCI bus hot plug > + 0 // Must ended by 0 > +}; > + > +UINT32 DxeErrorCode[] = { > + (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_EC_NO_ARCH), // Some of the Architectural Protocols are not available > + (EFI_IO_BUS_PCI | EFI_IOB_EC_RESOURCE_CONFLICT), // PCI resource allocation error. Out of Resources > + (EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_NOT_DETECTED), // No Console Output Devices are found > + (EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED), // No Console Input Devices are found > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_INVALID_PASSWORD), // Invalid password > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR), // Error loading Boot Option (LoadImage returned error) > + (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED), // Boot Option is failed (StartImage returned error) > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_UPDATE_FAIL), // Flash update is failed > + (EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE), // Reset protocol is not available > + 0 // Must end by 0 > +}; > + > +EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL; > + > +STATIC UINT8 mBootstate = BOOT_START; > + > +STATIC > +BOOLEAN > +StatusCodeFilter ( > + UINT32 *Map, > + EFI_STATUS_CODE_VALUE Value > + ) > +{ > + UINTN Index = 0; > + > + while (Map[Index] != 0) { > + if (Map[Index] == Value) { > + return TRUE; > + } > + Index++; > + } > + return FALSE; > +} > + > +/** > + Report status code listener of Boot Progress Dxe. > + > + @param[in] CodeType Indicates the type of status code being reported. > + @param[in] Value Describes the current status of a hardware or software entity. > + This included information about the class and subclass that is used to > + classify the entity as well as an operation. > + @param[in] Instance The enumeration of a hardware or software entity within > + the system. Valid instance numbers start with 1. > + @param[in] CallerId This optional parameter may be used to identify the caller. > + This parameter allows the status code driver to apply different rules to > + different callers. > + @param[in] Data This optional parameter may be used to pass additional data. > + > + @retval EFI_SUCCESS Status code is what we expected. > + @retval EFI_UNSUPPORTED Status code not supported. > + > +**/ > +EFI_STATUS > +EFIAPI > +BootProgressListenerDxe ( > + IN EFI_STATUS_CODE_TYPE CodeType, > + IN EFI_STATUS_CODE_VALUE Value, > + IN UINT32 Instance, > + IN EFI_GUID *CallerId, > + IN EFI_STATUS_CODE_DATA *Data > + ) > +{ > + BOOLEAN IsProgress = FALSE; > + BOOLEAN IsError = FALSE; > + > + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) { > + IsProgress = StatusCodeFilter (DxeProgressCode, Value); > + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { > + IsError = StatusCodeFilter (DxeErrorCode, Value); > + } else { > + return EFI_SUCCESS; > + } > + > + if (!IsProgress && !IsError) { > + return EFI_SUCCESS; > + } > + > + DEBUG (( > + DEBUG_INFO, > + "BootProgressDxe: CodeType=0x%X Value=0x%X Instance=0x%X CallerIdGuid=%g Data=%p\n", > + CodeType, > + Value, > + Instance, > + CallerId, > + Data > + )); > + > + if (IsError) { > + mBootstate = BOOT_FAILED; > + } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)) { > + /* Set boot complete when reach to ReadyToBoot event */ > + mBootstate = BOOT_COMPLETE; > + } > + > + MailboxMsgSetBootProgress (0, mBootstate, Value); > + > + if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES) && > + mRscHandlerProtocol != NULL) > + { > + mRscHandlerProtocol->Unregister (BootProgressListenerDxe); > + } > + > + return EFI_SUCCESS; > +} > + > + > +/** > + The module Entry Point of the Firmware Performance Data Table DXE driver. > + > + @param[in] ImageHandle The firmware allocated handle for the EFI image. > + @param[in] SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The entry point is executed successfully. > + @retval Other Some error occurs when executing this entry point. > + > +**/ > +EFI_STATUS > +EFIAPI > +BootProgressDxeEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + > + // > + // Get Report Status Code Handler Protocol. > + // > + Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID **)&mRscHandlerProtocol); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Register report status code listener for OS Loader load and start. > + // > + if (!EFI_ERROR (Status)) { > + Status = mRscHandlerProtocol->Register (BootProgressListenerDxe, TPL_HIGH_LEVEL); > + } > + ASSERT_EFI_ERROR (Status); > + > + return EFI_SUCCESS; > +} > diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.c > new file mode 100644 > index 000000000000..c677e27a00ce > --- /dev/null > +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.c > @@ -0,0 +1,210 @@ > +/** @file > + > + This module installs Boot Progress Pei to report boot progress to SMpro. > + > + This module registers report status code listener to report boot progress > + to SMpro. > + > + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +enum BOOT_PROGRESS_STATE { > + BOOT_NOTSTART = 0, > + BOOT_START = 1, > + BOOT_COMPLETE = 2, > + BOOT_FAILED = 3, > +}; > + > +UINT32 PeiProgressStatusCode[] = { > + // Regular boot > + (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_PC_ENTRY_POINT), // PEI Core is started > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_POWER_ON_INIT), // Pre-memory CPU initialization is started > + (EFI_SOFTWARE_PEI_SERVICE | EFI_SW_PS_PC_INSTALL_PEI_MEMORY), // Memory Installed > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_PC_INIT_BEGIN), // CPU post-memory initialization is started > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_CACHE_INIT), // CPU post-memory initialization. Cache initialization > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_AP_INIT), // CPU post-memory initialization. Application Processor(s) (AP) initialization > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_BSP_SELECT), // CPU post-memory initialization. Boot Strap Processor (BSP) selection > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_SMM_INIT), // CPU post-memory initialization. System Management Mode (SMM) initialization > + // DXE IPL is started > + (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT), // DXE IPL is started > + // DXE Core is started > + (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT), // DXE Core is started > + // Recovery > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_RECOVERY_AUTO), // Recovery condition triggered by firmware (Auto recovery) > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_RECOVERY_USER), // Recovery condition triggered by user (Forced recovery) > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_RECOVERY_BEGIN), // Recovery process started > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_CAPSULE_LOAD), // Recovery firmware image is found > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_CAPSULE_START), // Recovery firmware image is loaded > + // S3 > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_S3_BOOT_SCRIPT), // S3 Boot Script execution > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE), // OS S3 wake vector call > + 0 // Must end with 0 > +}; > + > +UINT32 PeiErrorStatusCode[] = { > + // Regular boot > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_INVALID_TYPE), // Memory initialization error. Invalid memory type > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_INVALID_SPEED), // Memory initialization error. Incompatible memory speed > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_SPD_FAIL), // Memory initialization error. SPD reading has failed > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_INVALID_SIZE), // Memory initialization error. Invalid memory size > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_MISMATCH), // Memory initialization error. Memory modules do not match > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_NONE_DETECTED), // Memory initialization error. No usable memory detected > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_NONE_USEFUL), // Memory initialization error. No usable memory detected > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_EC_NON_SPECIFIC), // Unspecified memory initialization error. > + (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_EC_MEMORY_NOT_INSTALLED), // Memory not installed > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_INVALID_TYPE), // Invalid CPU type > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_INVALID_SPEED), // Invalid CPU Speed > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_MISMATCH), // CPU mismatch > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST), // CPU self test failed > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_CACHE), // possible CPU cache error > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_INTERNAL), // Internal CPU error > + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_EC_NON_SPECIFIC), // Internal CPU error > + (EFI_SOFTWARE_PEI_SERVICE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE), // reset PPI is not available > + // Recovery > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_RECOVERY_PPI_NOT_FOUND), // Recovery PPI is not available > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_NO_RECOVERY_CAPSULE), // Recovery capsule is not found > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_INVALID_CAPSULE_DESCRIPTOR), // Invalid recovery capsule > + // S3 Resume > + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_S3_RESUME_FAIL), // S3 Resume Failed > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_RESUME_PPI_NOT_FOUND), // S3 Resume PPI not found > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_BOOT_SCRIPT_ERROR), // S3 Resume Boot Script Error > + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_EC_S3_OS_WAKE_ERROR), // S3 OS Wake Error > + 0 > +}; > + > +// Should always be BOOT_START when start > +STATIC UINT8 mBootstate = BOOT_START; > + > +STATIC > +BOOLEAN > +StatusCodeFilter ( > + UINT32 *Map, > + EFI_STATUS_CODE_VALUE Value > + ) > +{ > + UINTN Index = 0; > + > + while (Map[Index] != 0) { > + if (Map[Index] == Value) { > + return TRUE; > + } > + Index++; > + } > + > + return FALSE; > +} > + > +/** > + Report status code listener for PEI. This is used to record the boot progress info > + and report it to SMpro. > + > + @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. > + @param[in] CodeType Indicates the type of status code being reported. > + @param[in] Value Describes the current status of a hardware or software entity. > + This included information about the class and subclass that is used to > + classify the entity as well as an operation. > + @param[in] Instance The enumeration of a hardware or software entity within > + the system. Valid instance numbers start with 1. > + @param[in] CallerId This optional parameter may be used to identify the caller. > + This parameter allows the status code driver to apply different rules to > + different callers. > + @param[in] Data This optional parameter may be used to pass additional data. > + > + @retval EFI_SUCCESS Status code is what we expected. > + @retval EFI_UNSUPPORTED Status code not supported. > + > +**/ > +EFI_STATUS > +EFIAPI > +BootProgressListenerPei ( > + IN CONST EFI_PEI_SERVICES **PeiServices, > + IN EFI_STATUS_CODE_TYPE CodeType, > + IN EFI_STATUS_CODE_VALUE Value, > + IN UINT32 Instance, > + IN CONST EFI_GUID *CallerId, > + IN CONST EFI_STATUS_CODE_DATA *Data > + ) > +{ > + BOOLEAN IsProgress = FALSE; > + BOOLEAN IsError = FALSE; > + > + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) { > + IsProgress = StatusCodeFilter (PeiProgressStatusCode, Value); > + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { > + IsError = StatusCodeFilter (PeiErrorStatusCode, Value); > + } else { > + return EFI_SUCCESS; > + } > + > + // No interested status found > + if (!IsProgress && !IsError) { > + return EFI_SUCCESS; > + } > + > + DEBUG (( > + DEBUG_INFO, > + "BootProgressPeim: CodeType=0x%X Value=0x%X Instance=0x%X CallerIdGuid=%g Data=%p\n", > + CodeType, > + Value, > + Instance, > + CallerId, > + Data > + )); > + > + if (IsError) { > + mBootstate = BOOT_FAILED; > + } > + > + MailboxMsgSetBootProgress (0, mBootstate, Value); > + > + return EFI_SUCCESS; > +} > + > +/** > + Main entry for Boot Progress PEIM. > + > + This routine is to register report status code listener for Boot Progress PEIM. > + > + @param[in] FileHandle Handle of the file being invoked. > + @param[in] PeiServices Pointer to PEI Services table. > + > + @retval EFI_SUCCESS Report status code listener is registered successfully. > + > +**/ > +EFI_STATUS > +EFIAPI > +BootProgressPeiEntryPoint ( > + IN EFI_PEI_FILE_HANDLE FileHandle, > + IN CONST EFI_PEI_SERVICES **PeiServices > + ) > +{ > + EFI_STATUS Status; > + EFI_PEI_RSC_HANDLER_PPI *RscHandler; > + > + Status = PeiServicesLocatePpi ( > + &gEfiPeiRscHandlerPpiGuid, > + 0, > + NULL, > + (VOID **)&RscHandler > + ); > + ASSERT_EFI_ERROR (Status); > + > + if (!EFI_ERROR (Status)) { > + Status = RscHandler->Register (BootProgressListenerPei); > + } > + ASSERT_EFI_ERROR (Status); > + > + return EFI_SUCCESS; > +} > diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.uni > new file mode 100644 > index 000000000000..492e85404631 > --- /dev/null > +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootProgressDxe.uni > @@ -0,0 +1,16 @@ > +// > +// This module installs Boot Progress Dxe that report boot progress to SMpro. > +// > +// This module registers report status code listener to report boot progress > +// for SMpro. > +// > +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// > + > + > +#string STR_MODULE_ABSTRACT #language en-US "Installs Boot Progress Driver" > + > +#string STR_MODULE_DESCRIPTION #language en-US "This module registers report status code listener to collect and report boot progress to SMpro." > diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.uni > new file mode 100644 > index 000000000000..0371fc4f9a80 > --- /dev/null > +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.uni > @@ -0,0 +1,18 @@ > +// > +// Boot Progress Pei Module. > +// > +// Updates to SCP with Boot Progress information during boot > +// > +// This module register report status code listener to collect boot progress > +// information and keep SCP posted. > +// > +// Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// > + > + > +#string STR_MODULE_ABSTRACT #language en-US "Boot Progress Pei Module." > + > +#string STR_MODULE_DESCRIPTION #language en-US "Updates SCP with boot progress information during boot. This module register report status code listener to collect boot progress information and post to SCP." > -- > 2.17.1 >