From nobody Mon Apr 29 09:53:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61123+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61123+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1591864873; cv=none; d=zohomail.com; s=zohoarc; b=IWuSXwcbX7cisJ9RVYg2zj7tO6BO1RPBe3GsYWij4BhhoP2P6+eji5ssQDNA0fXF3DOlmLq47gdqNlRr8TLXqgoEvR5KoC5DQf/Py+1pgDclzNZYyzJzSGq0ZZfXo+ywjOq0X0Z9CSEFKFdpoMIICdnFehFOP90m8Zyk5fIo/rE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591864873; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Jy7c2NSNS+i/T8Qb9Bjxw+BkZAr+DdbBHTYLbxgqxDg=; b=lC69rczX6DsaxPUMZAUIumiiFDCxiRWI7tHRYOSd/cU5Bkhx+GASmfRWUWs8d/pWVgYUrno8zsueToCWwjTUjiID5BY/LX3nWepd8HTY5AHvS7PD/oVVeIc2BVZccHKGwR37sxotLAfHnPWslW/MDpxUc2Nk0e0pKLYetxDqwTw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61123+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591864873452118.7029241780433; Thu, 11 Jun 2020 01:41:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id w57sYY1788612x2hpWX5G3zD; Thu, 11 Jun 2020 01:41:12 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.3205.1591864871944473130 for ; Thu, 11 Jun 2020 01:41:12 -0700 IronPort-SDR: PynMFq7Clo8USA1xqam12wS7teJrpce/3XLWBd+HgZ3CrCYQa5SDSQxY8/tcEurE9MOeC4cvm/ TpOGQEVKhgfQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 01:41:11 -0700 IronPort-SDR: jyozmNrBax7IXrEiMqhiPVzLDMU91ZIY9OfYYMVxYcT2Q8agnU18WhMZv8S93V057OEPNaIGhT QTzEZ6ya35lw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="380325760" X-Received: from shwdejointlab96.ccr.corp.intel.com ([10.239.134.144]) by fmsmga001.fm.intel.com with ESMTP; 11 Jun 2020 01:41:09 -0700 From: "Tan, Ming" To: devel@edk2.groups.io Cc: Eric Dong , Liming Gao Subject: [edk2-devel] [PATCH v4] Features/Intel/BeepDebugFeaturePkg: add it. Date: Thu, 11 Jun 2020 16:40:24 +0800 Message-Id: <20200611084024.29755-1-ming.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,ming.tan@intel.com X-Gm-Message-State: N0uD5LQKfhHG120qtcdNLBVzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591864872; bh=vA3KSRexF41cYjqCNAUQ6+BgYdudzkMBIAEPjdNUBwg=; h=Cc:Date:From:Reply-To:Subject:To; b=lhxXf+6LAbvFVtrG5SpD0vhuQVvhYABcuNOnH5qDg+Wm+Z5AFLPjE1BGc1zwZOtUiAP tEvb32sG0+WB6HjfKSErgOX32G2T2JhQsKqY55D/e1QLAFHG40j63ypUXP4uO6PDpdvq6 pgIF+hSKdppoYjwD8QPFn2dPyN9MPO/sGwU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2792 The BeepDebugFeaturePkg include some useful beep debug libraries, such as get beep value from status code and beep. It provide a library BeepStatusCodeHandlerLib used by edk2 StatusCodeHandler.efi, used to do beep if needed. It also provide a library of BeepMap lib, it map the status code to beep value. A library of Beep lib is needed by platform, and this pkg has a Null implementation. Cc: Eric Dong Cc: Liming Gao Signed-off-by: Ming Tan --- V4: Change Include/BeepDebugFeature.dsc, make it can be included in platfor= m dsc file. V3: Modify according the Eric's review comments. V2: Delete the last empty line in BeepDebugFeaturePkg/Library/BeepMapLib/Be= epMapLib.inf .../BeepDebugFeaturePkg.dec | 36 +++ .../BeepDebugFeaturePkg.dsc | 30 ++ .../Include/BeepDebugFeature.dsc | 193 +++++++++++++ .../Include/Library/BeepLib.h | 33 +++ .../Include/Library/BeepMapLib.h | 32 +++ .../Library/BeepLib/BeepLibNull.c | 37 +++ .../Library/BeepLib/BeepLibNull.inf | 26 ++ .../Library/BeepMapLib/BeepMapLib.c | 116 ++++++++ .../Library/BeepMapLib/BeepMapLib.inf | 27 ++ .../BeepMapLib/PlatformStatusCodesInternal.h | 270 ++++++++++++++++++ .../PeiBeepStatusCodeHandlerLib.c | 101 +++++++ .../PeiBeepStatusCodeHandlerLib.inf | 52 ++++ .../RuntimeDxeBeepStatusCodeHandlerLib.c | 183 ++++++++++++ .../RuntimeDxeBeepStatusCodeHandlerLib.inf | 54 ++++ .../SmmBeepStatusCodeHandlerLib.c | 139 +++++++++ .../SmmBeepStatusCodeHandlerLib.inf | 52 ++++ .../Debugging/BeepDebugFeaturePkg/Readme.md | 126 ++++++++ 17 files changed, 1507 insertions(+) create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugF= eaturePkg.dec create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugF= eaturePkg.dsc create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Be= epDebugFeature.dsc create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Li= brary/BeepLib.h create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Li= brary/BeepMapLib.h create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epLib/BeepLibNull.c create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epLib/BeepLibNull.inf create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epMapLib/BeepMapLib.c create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epMapLib/BeepMapLib.inf create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epMapLib/PlatformStatusCodesInternal.h create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epStatusCodeHandlerLib/PeiBeepStatusCodeHandlerLib.c create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epStatusCodeHandlerLib/PeiBeepStatusCodeHandlerLib.inf create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epStatusCodeHandlerLib/RuntimeDxeBeepStatusCodeHandlerLib.c create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epStatusCodeHandlerLib/RuntimeDxeBeepStatusCodeHandlerLib.inf create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epStatusCodeHandlerLib/SmmBeepStatusCodeHandlerLib.c create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Be= epStatusCodeHandlerLib/SmmBeepStatusCodeHandlerLib.inf create mode 100644 Features/Intel/Debugging/BeepDebugFeaturePkg/Readme.md diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeatureP= kg.dec b/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.d= ec new file mode 100644 index 0000000000..4f4b36b091 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec @@ -0,0 +1,36 @@ +## @file +# This package provides Beep Debug feature. +# This package should only depend on EDK II Core packages, IntelSiliconPkg= , and MinPlatformPkg. +# +# The DEC files are used by the utilities that parse DSC and +# INF files to generate AutoGen.c and AutoGen.h files +# for the build infrastructure. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010017 + PACKAGE_NAME =3D BeepDebugFeaturePkg + PACKAGE_GUID =3D DD88CEBB-E68F-4155-B754-D11E4FDF008D + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include + +[LibraryClasses] + ## @libraryclass Provide the function to map the status code to bee= p value. + BeepMapLib|Include/Library/BeepMapLib.h + + ## @libraryclass Provide the function to do the real beep. + BeepLib|Include/Library/BeepLib.h + +[Guids] + gBeepDebugFeaturePkgTokenSpaceGuid =3D {0x54f56fb5, 0xea0e, 0x4518, {0= xa0, 0x3e, 0x1b, 0xeb, 0x56, 0x94, 0xd2, 0x16}} + +[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] + # Beep is a legacy feature, disabled it by default + gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep|FALSE|BOOLEAN|0x= 00000001 diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeatureP= kg.dsc b/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.d= sc new file mode 100644 index 0000000000..47254f9974 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/BeepDebugFeaturePkg.dsc @@ -0,0 +1,30 @@ +## @file +# This package provides Beep Debug feature. +# This package should only depend on EDK II Core packages, IntelSiliconPkg= , and MinPlatformPkg. +# +# The DEC files are used by the utilities that parse DSC and +# INF files to generate AutoGen.c and AutoGen.h files +# for the build infrastructure. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + PLATFORM_NAME =3D BeepDebugFeaturePkg + PLATFORM_GUID =3D D716EDF2-77BB-4536-9C64-4D7EEF0F3896 + PLATFORM_VERSION =3D 0.1 + DSC_SPECIFICATION =3D 0x00010005 + OUTPUT_DIRECTORY =3D Build/$(PLATFORM_NAME) + SUPPORTED_ARCHITECTURES =3D IA32|X64 + BUILD_TARGETS =3D DEBUG|RELEASE|NOOPT + SKUID_IDENTIFIER =3D DEFAULT + PEI_ARCH =3D IA32 + DXE_ARCH =3D X64 + +# +# This package always builds the feature. +# +!include Include/BeepDebugFeature.dsc diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/BeepDebug= Feature.dsc b/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/BeepDebu= gFeature.dsc new file mode 100644 index 0000000000..1ae5ad76af --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/BeepDebugFeature= .dsc @@ -0,0 +1,193 @@ +## @file +# This package provides Beep Debug feature. +# This file should be included into another package DSC file to build this= feature. +# +# The DEC files are used by the utilities that parse DSC and +# INF files to generate AutoGen.c and AutoGen.h files +# for the build infrastructure. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +##########################################################################= ###### +# +# Defines Section - statements that will be processed to create a Makefile. +# +##########################################################################= ###### +[Defines] +!ifndef $(PEI_ARCH) + !error "PEI_ARCH must be specified to build this feature!" +!endif +!ifndef $(DXE_ARCH) + !error "DXE_ARCH must be specified to build this feature!" +!endif + +##########################################################################= ###### +# +# PCD Section - list of PCD Entries modified by the feature. +# +##########################################################################= ###### +[PcdsDynamicDefault] + gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep|TRUE + +##########################################################################= ###### +# +# Library Class section - list of all Library Classes needed by this featu= re. +# +##########################################################################= ###### +[LibraryClasses] + ####################################### + # Edk2 Packages + ####################################### + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplat= e.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/U= efiRuntimeServicesTableLib.inf + PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf + OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull= .inf + + BeepLib|BeepDebugFeaturePkg/Library/BeepLib/BeepLibNull.inf + + ##################################### + # Beep Debug Feature Package + ##################################### + BeepMapLib|BeepDebugFeaturePkg/Library/BeepMapLib/BeepMapLib.inf + +[LibraryClasses.common.PEIM] + ####################################### + # Edk2 Packages + ####################################### + HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf + MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAlloc= ationLib.inf + PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/= PeiServicesTablePointerLibIdt.inf + +[LibraryClasses.IA32.PEIM,LibraryClasses.IA32.PEI_CORE,LibraryClasses.IA32= .SEC] + ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiRepor= tStatusCodeLib.inf + +[LibraryClasses.common.DXE_DRIVER] + ####################################### + # Edk2 Packages + ####################################### + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf + +[LibraryClasses.common.DXE_RUNTIME_DRIVER] + ####################################### + # Edk2 Packages + ####################################### + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf + UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf + ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/R= untimeDxeReportStatusCodeLib.inf + +[LibraryClasses.common.UEFI_DRIVER] + ####################################### + # Edk2 Packages + ####################################### + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf + +[LibraryClasses.X64.DXE_SMM_DRIVER] + ####################################### + # Edk2 Packages + ####################################### + SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableL= ib.inf + MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAlloc= ationLib.inf + SmmIoLib|MdePkg/Library/SmmIoLib/SmmIoLib.inf + SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf + ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmRepor= tStatusCodeLib.inf + +##########################################################################= ###### +# +# Component section - list of all components that need built for this feat= ure. +# +# Note: The EDK II DSC file is not used to specify how compiled binary ima= ges get placed +# into firmware volume images. This section is just a list of module= s to compile from +# source into UEFI-compliant binaries. +# It is the FDF file that contains information on combining binary f= iles into firmware +# volume images, whose concept is beyond UEFI and is described in PI= specification. +# There may also be modules listed in this section that are not requ= ired in the FDF file, +# When a module listed here is excluded from FDF file, then UEFI-com= pliant binary will be +# generated for it, but the binary will not be put into any firmware= volume. +# +##########################################################################= ###### +# +# Feature PEI Components +# + +# @todo: Change below line to [Components.$(PEI_ARCH)] after https://bugzi= lla.tianocore.org/show_bug.cgi?id=3D2308 +# is completed. +[Components.IA32] + ##################################### + # Beep Debug Feature Package + ##################################### + + # Add library instances here that are not included in package components= and should be tested + # in the package build. + BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/PeiBeepStatusCodeHa= ndlerLib.inf + + # The following is an example for used with StatusCodeHandler: +# MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf { +# +# NULL|BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/PeiBeepSta= tusCodeHandlerLib.inf +# } + + # Add components here that should be included in the package build. + +# +# Feature DXE Components +# + +# @todo: Change below line to [Components.$(DXE_ARCH)] after https://bugzi= lla.tianocore.org/show_bug.cgi?id=3D2308 +# is completed. +[Components.X64] + ##################################### + # Beep Debug Feature Package + ##################################### + + # Add library instances here that are not included in package components= and should be tested + # in the package build. + BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/RuntimeDxeBeepStatu= sCodeHandlerLib.inf + BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/SmmBeepStatusCodeHa= ndlerLib.inf + + # The following is an example for used with StatusCodeHandler: +# MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRun= timeDxe.inf { +# +# NULL|BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/RuntimeDxe= BeepStatusCodeHandlerLib.inf +# } + +# MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf { +# +# NULL|BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/SmmBeepSta= tusCodeHandlerLib.inf +# } + + # Add components here that should be included in the package build. + +##########################################################################= ######################### +# +# BuildOptions Section - Define the module specific tool chain flags that = should be used as +# the default flags for a module. These flags are a= ppended to any +# standard flags that are defined by the build proc= ess. They can be +# applied for any modules or only those modules wit= h the specific +# module style (EDK or EDKII) specified in [Compone= nts] section. +# +# For advanced features, it is recommended to enabl= e [BuildOptions] in +# the applicable INF file so it does not affect the= whole board package +# build when this DSC file is active. +# +##########################################################################= ######################### +[BuildOptions] diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Library/B= eepLib.h b/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Library/Bee= pLib.h new file mode 100644 index 0000000000..f768acc557 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Library/BeepLib.h @@ -0,0 +1,33 @@ +/** @file + Provides services to send progress/error codes to Beep device. + + Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __BEEP_LIB_H__ +#define __BEEP_LIB_H__ + +/** + Sends a 32-bit value to Beep device. + + Sends the 32-bit value specified by Value to Beep device, and returns Va= lue. + Some implementations of this library function may perform I/O operations + directly to Beep device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventua= lly + display the 32-bit value on the status reporting device. + + Beep() must actively prevent recursion. If Beep() is called while + processing another Post Code Library function, then + Beep() must return Value immediately. + + @param Value Beep count. +**/ +VOID +EFIAPI +Beep ( + IN UINT32 Value + ); + +#endif diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Library/B= eepMapLib.h b/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Library/= BeepMapLib.h new file mode 100644 index 0000000000..7600d72ecd --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Include/Library/BeepMapL= ib.h @@ -0,0 +1,32 @@ +/** @file + This library class provides Platform Beep Map. + + Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __BEEP_MAP_LIB__ +#define __BEEP_MAP_LIB__ + +/** + Get BeepValue from status code type and value. + + @param CodeType Indicates the type of status code being reporte= d. + @param Value Describes the current status of a hardware or + software entity. This includes information abou= t the class and + subclass that is used to classify the entity as= well as an operation. + For progress codes, the operation is the curren= t activity. + For error codes, it is the exception.For debug = codes,it is not defined at this time. + + @return BeepValue + +**/ +UINT32 +EFIAPI +GetBeepValueFromStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value + ); + +#endif diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepLib/B= eepLibNull.c b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepLib= /BeepLibNull.c new file mode 100644 index 0000000000..a0bd946b50 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepLib/BeepLibN= ull.c @@ -0,0 +1,37 @@ +/** @file + BeepLib Null implementation. + + Copyright (c) 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +/** + NULL implemented of Beep() function, just return directly. + Normal Beep() function will do the following: + + Sends a 32-bit value to Beep device. + + Sends the 32-bit value specified by Value to Beep device, and returns Va= lue. + Some implementations of this library function may perform I/O operations + directly to Beep device. Other implementations may send Value to + ReportStatusCode(), and the status code reporting mechanism will eventua= lly + display the 32-bit value on the status reporting device. + + Beep() must actively prevent recursion. If Beep() is called while + processing another Post Code Library function, then + Beep() must return Value immediately. + + @param Value Beep count. +**/ +VOID +EFIAPI +Beep ( + IN UINT32 Value + ) +{ + return; +} diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepLib/B= eepLibNull.inf b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepL= ib/BeepLibNull.inf new file mode 100644 index 0000000000..7f84dad082 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepLib/BeepLibN= ull.inf @@ -0,0 +1,26 @@ +## @file +# Instance of Platform Beep Null Library. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D BeepLib + FILE_GUID =3D 319F24D8-9F3E-4BEC-B1C4-C54BE51F3FC2 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D BeepLib +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Packages] + MdePkg/MdePkg.dec + +[Sources] + BeepLibNull.c diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepMapLi= b/BeepMapLib.c b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepM= apLib/BeepMapLib.c new file mode 100644 index 0000000000..26c32dfd9b --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepMapLib/BeepM= apLib.c @@ -0,0 +1,116 @@ +/** @file + BeepMap implementation. + + Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include "PlatformStatusCodesInternal.h" + +STATUS_CODE_TO_DATA_MAP mBeepProgressMap[] =3D { + // + // PEI + // + // Recovery + { PEI_RECOVERY_STARTED, 2 }, + + // + // DXE + // + + {0,0} +}; + +STATUS_CODE_TO_DATA_MAP mBeepErrorMap[] =3D { + // + // PEI + // + // Regular boot + { PEI_MEMORY_NOT_DETECTED, 1 }, + { PEI_MEMORY_INSTALLED_TWICE, 1 }, + { PEI_DXEIPL_NOT_FOUND, 3 }, + { PEI_DXE_CORE_NOT_FOUND, 3 }, + { PEI_RESET_NOT_AVAILABLE, 7 }, + // Recovery + { PEI_RECOVERY_FAILED, 4 }, + // S3 Resume + { PEI_S3_RESUME_FAILED, 4 }, + + // + // DXE + // + { DXE_ARCH_PROTOCOL_NOT_AVAILABLE, 4 }, + { DXE_NO_CON_OUT, 5 }, + { DXE_NO_CON_IN, 5 }, + { DXE_INVALID_PASSWORD, 1 }, + { DXE_FLASH_UPDATE_FAILED, 6 }, + { DXE_RESET_NOT_AVAILABLE, 7 }, + + {0,0} +}; + +STATUS_CODE_TO_DATA_MAP *mBeepStatusCodesMap[] =3D { + //#define EFI_PROGRESS_CODE 0x00000001 + mBeepProgressMap, + //#define EFI_ERROR_CODE 0x00000002 + mBeepErrorMap + //#define EFI_DEBUG_CODE 0x00000003 +}; + +/** + Find the beep data from status code value. + + @param Map The map used to find in. + @param Value The status code value. + + @return BeepValue 0 for not found. + +**/ +UINT32 +FindBeepData ( + IN STATUS_CODE_TO_DATA_MAP *Map, + IN EFI_STATUS_CODE_VALUE Value + ) +{ + while (Map->Value !=3D 0) { + if (Map->Value =3D=3D Value) { + return Map->Data; + } + Map++; + } + return 0; +} + +/** + Get BeepValue from status code type and value. + + @param CodeType Indicates the type of status code being reporte= d. + @param Value Describes the current status of a hardware or + software entity. This includes information abou= t the class and + subclass that is used to classify the entity as= well as an operation. + For progress codes, the operation is the curren= t activity. + For error codes, it is the exception.For debug = codes,it is not defined at this time. + + @return BeepValue +**/ +UINT32 +EFIAPI +GetBeepValueFromStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value + ) +{ + UINT32 CodeTypeIndex; + + CodeTypeIndex =3D STATUS_CODE_TYPE (CodeType) - 1; + + if (CodeTypeIndex >=3D sizeof (mBeepStatusCodesMap) / sizeof(mBeepStatus= CodesMap[0])) { + return 0; + } + + return FindBeepData (mBeepStatusCodesMap[CodeTypeIndex], Value); +} diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepMapLi= b/BeepMapLib.inf b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/Bee= pMapLib/BeepMapLib.inf new file mode 100644 index 0000000000..b957eee07b --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepMapLib/BeepM= apLib.inf @@ -0,0 +1,27 @@ +## @file +# Instance of Beep Map Library. +# +# Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D BeepMapLib + FILE_GUID =3D 8BAFA82F-DA9E-4cce-8FA2-9DA189D7246D + VERSION_STRING =3D 2.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D BeepMapLib +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Packages] + MdePkg/MdePkg.dec + +[Sources] + BeepMapLib.c + PlatformStatusCodesInternal.h diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepMapLi= b/PlatformStatusCodesInternal.h b/Features/Intel/Debugging/BeepDebugFeature= Pkg/Library/BeepMapLib/PlatformStatusCodesInternal.h new file mode 100644 index 0000000000..a36134c933 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepMapLib/Platf= ormStatusCodesInternal.h @@ -0,0 +1,270 @@ +/** @file + Beep status code definition. + + Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __PLATFORM_STATUS_CODES_INTERNAL_H__ +#define __PLATFORM_STATUS_CODES_INTERNAL_H__ + +#include + +typedef struct{ + EFI_STATUS_CODE_VALUE Value; + UINT32 Data; +} STATUS_CODE_TO_DATA_MAP; + +// +// Enable PEI/DXE status code +// +#define PEI_STATUS_CODE 1 +#define DXE_STATUS_CODE 1 + +#define STATUS_CODE_TYPE(Type) ((Type)&EFI_STATUS_CODE_TYPE= _MASK) +#define STATUS_CODE_CLASS(Value) ((Value)&EFI_STATUS_CODE_CLA= SS_MASK) + +//Progress/Error codes +#define PEI_CORE_STARTED (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PEI_CORE_PC_ENTRY_POINT) +#define PEI_RESET_NOT_AVAILABLE (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PS_EC_RESET_NOT_AVAILABLE) +#define PEI_DXEIPL_NOT_FOUND (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PEI_CORE_EC_DXEIPL_NOT_FOUND) +#define PEI_DXE_CORE_NOT_FOUND (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PEI_CORE_EC_DXE_CORRUPT) +#define PEI_S3_RESUME_ERROR (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PEI_EC_S3_RESUME_FAILED) +#define PEI_RECOVERY_FAILED (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PEI_EC_RECOVERY_FAILED) +#define DXE_CORE_STARTED (EFI_SOFTWARE_DXE_CORE | EFI= _SW_DXE_CORE_PC_ENTRY_POINT) + +//#define DXE_EXIT_BOOT_SERVICES_BEGIN 0xF8 +#define DXE_EXIT_BOOT_SERVICES_END (EFI_SOFTWARE_EFI_BOOT_SERVI= CE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES) + +// Reported by CPU PEIM +#define PEI_CAR_CPU_INIT (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_PC_POWER_ON_INIT) + +// Reported by NB PEIM +//#define PEI_CAR_NB_INIT (EFI_COMPUTING_UNIT_CHIPSE= T | EFI_CU_CHIPSET_NORTH_INIT) + +// Reported by SB PEIM +//#define PEI_CAR_SB_INIT (EFI_COMPUTING_UNIT_CHIPSE= T | EFI_CU_CHIPSET_PC_SOUTH_INIT) + +//Reported by Memory Detection PEIM +#define PEI_MEMORY_SPD_READ (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_PC_SPD_READ) +#define PEI_MEMORY_PRESENCE_DETECT (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_PC_PRESENCE_DETECT) +#define PEI_MEMORY_TIMING (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_PC_TIMING) +#define PEI_MEMORY_CONFIGURING (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_PC_CONFIGURING) +#define PEI_MEMORY_OPTIMIZING (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_PC_OPTIMIZING) +#define PEI_MEMORY_INIT (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_PC_INIT) +#define PEI_MEMORY_TEST (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_PC_TEST) +#define PEI_MEMORY_INVALID_TYPE (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_INVALID_TYPE) +#define PEI_MEMORY_INVALID_SPEED (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_INVALID_SPEED) +#define PEI_MEMORY_SPD_FAIL (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_SPD_FAIL) +#define PEI_MEMORY_INVALID_SIZE (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_INVALID_SIZE) +#define PEI_MEMORY_MISMATCH (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_MISMATCH) +#define PEI_MEMORY_S3_RESUME_FAILED (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_S3_RESUME_FAIL) +#define PEI_MEMORY_NOT_DETECTED (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_NONE_DETECTED) +#define PEI_MEMORY_NONE_USEFUL (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_NONE_USEFUL) +#define PEI_MEMORY_ERROR (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_EC_NON_SPECIFIC) +#define PEI_MEMORY_INSTALLED (EFI_SOFTWARE_PEI_SERVICE |= EFI_SW_PS_PC_INSTALL_PEI_MEMORY) +#define PEI_MEMORY_NOT_INSTALLED (EFI_SOFTWARE_PEI_SERVICE |= EFI_SW_PEI_CORE_EC_MEMORY_NOT_INSTALLED) +#define PEI_MEMORY_INSTALLED_TWICE (EFI_SOFTWARE_PEI_SERVICE |= EFI_SW_PS_EC_MEMORY_INSTALLED_TWICE) + +//Reported by CPU PEIM +#define PEI_CPU_INIT (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_PC_INIT_BEGIN) +#define PEI_CPU_CACHE_INIT (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_PC_CACHE_INIT) +#define PEI_CPU_BSP_SELECT (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_PC_BSP_SELECT) +#define PEI_CPU_AP_INIT (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_PC_AP_INIT) +#define PEI_CPU_SMM_INIT (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_PC_SMM_INIT) +#define PEI_CPU_INVALID_TYPE (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_INVALID_TYPE) +#define PEI_CPU_INVALID_SPEED (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_INVALID_SPEED) +#define PEI_CPU_MISMATCH (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_MISMATCH) +#define PEI_CPU_SELF_TEST_FAILED (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_SELF_TEST) +#define PEI_CPU_CACHE_ERROR (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_CACHE) +#define PEI_CPU_MICROCODE_UPDATE_FAILED (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_MICROCODE_UPDATE) +#define PEI_CPU_NO_MICROCODE (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_NO_MICROCODE_UPDATE) +//If non of the errors above apply use this one +#define PEI_CPU_INTERNAL_ERROR (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_INTERNAL) +//Generic CPU error. It should only be used if non of the errors above app= ly +#define PEI_CPU_ERROR (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_EC_NON_SPECIFIC) + +// Reported by NB PEIM +#define PEI_MEM_NB_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_PEI_MEM_NB_INIT) +// Reported by SB PEIM +#define PEI_MEM_SB_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_PEI_MEM_SB_INIT) + +//Reported by PEIM which detected forced or auto recovery condition +#define PEI_RECOVERY_AUTO (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_PC_RECOVERY_AUTO) +#define PEI_RECOVERY_USER (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_PC_RECOVERY_USER) + +//Reported by DXE IPL +#define PEI_RECOVERY_PPI_NOT_FOUND (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_EC_RECOVERY_PPI_NOT_FOUND) +#define PEI_S3_RESUME_PPI_NOT_FOUND (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_EC_S3_RESUME_PPI_NOT_FOUND) +#define PEI_S3_RESUME_FAILED (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_EC_S3_RESUME_FAILED) + +//Reported by Recovery PEIM +#define PEI_RECOVERY_STARTED (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_PC_RECOVERY_BEGIN) +#define PEI_RECOVERY_CAPSULE_FOUND (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_PC_CAPSULE_LOAD) +#define PEI_RECOVERY_NO_CAPSULE (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_EC_NO_RECOVERY_CAPSULE) +#define PEI_RECOVERY_CAPSULE_LOADED (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_PC_CAPSULE_START) +#define PEI_RECOVERY_INVALID_CAPSULE (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_EC_INVALID_CAPSULE_DESCRIPTOR) + +//Reported by S3 Resume PEIM +#define PEI_S3_BOOT_SCRIPT (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_PC_S3_BOOT_SCRIPT) +#define PEI_S3_OS_WAKE (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_PC_OS_WAKE) +#define PEI_S3_BOOT_SCRIPT_ERROR (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_EC_S3_BOOT_SCRIPT_ERROR) +#define PEI_S3_OS_WAKE_ERROR (EFI_SOFTWARE_PEI_MODULE | E= FI_SW_PEI_EC_S3_OS_WAKE_ERROR) + +#define PEI_PEIM_STARTED (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PC_INIT_BEGIN) +#define PEI_PEIM_ENDED (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PC_INIT_END) + +//Reported by DXE IPL +#define PEI_DXE_IPL_STARTED (EFI_SOFTWARE_PEI_CORE | EFI= _SW_PEI_CORE_PC_HANDOFF_TO_NEXT) + +//Reported by PEIM which installs Reset PPI +#define PEI_RESET_SYSTEM (EFI_SOFTWARE_PEI_SERVICE | = EFI_SW_PS_PC_RESET_SYSTEM) + +//Reported by the PEIM or DXE driver which detected the error +#define GENERIC_MEMORY_CORRECTABLE_ERROR (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_CORRECTABLE) +#define GENERIC_MEMORY_UNCORRECTABLE_ERROR (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_UNCORRECTABLE) + +//Reported by Flash Update DXE driver +#define DXE_FLASH_UPDATE_FAILED (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_UPDATE_FAIL) + +//Reported by the PEIM or DXE driver which detected the error +#define GENERIC_CPU_THERMAL_ERROR (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_THERMAL) +#define GENERIC_CPU_LOW_VOLTAGE (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_LOW_VOLTAGE) +#define GENERIC_CPU_HIGH_VOLTAGE (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_HIGH_VOLTAGE) +#define GENERIC_CPU_CORRECTABLE_ERROR (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_CORRECTABLE) +#define GENERIC_CPU_UNCORRECTABLE_ERROR (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_UNCORRECTABLE) +#define GENERIC_BAD_DATE_TIME_ERROR (EFI_SOFTWARE_UNSPECIFIED | = EFI_SW_EC_BAD_DATE_TIME) +#define GENERIC_MEMORY_SIZE_DECREASE (EFI_COMPUTING_UNIT_MEMORY |= EFI_CU_MEMORY_EC_MISMATCH) + +//Reported by DXE Core +#define DXE_DRIVER_STARTED (EFI_SOFTWARE_EFI_DXE_SERVIC= E | EFI_SW_PC_INIT_BEGIN) +#define DXE_DRIVER_ENED (EFI_SOFTWARE_DXE_CORE | EFI= _SW_PC_INIT_END) +#define DXE_ARCH_PROTOCOLS_AVAILABLE (EFI_SOFTWARE_DXE_CORE | EFI= _SW_DXE_CORE_PC_ARCH_READY) +#define DXE_DRIVER_CONNECTED (EFI_SOFTWARE_DXE_CORE | EFI= _SW_DXE_CORE_PC_START_DRIVER) +#define DXE_ARCH_PROTOCOL_NOT_AVAILABLE (EFI_SOFTWARE_DXE_CORE | EFI= _SW_DXE_CORE_EC_NO_ARCH) + +//Reported by DXE CPU driver +#define DXE_CPU_SELF_TEST_FAILED (EFI_COMPUTING_UNIT_HOST_PRO= CESSOR | EFI_CU_HP_EC_SELF_TEST) + +//Reported by PCI Host Bridge driver +#define DXE_NB_HB_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_DXE_HB_INIT ) + +// Reported by NB Driver +#define DXE_NB_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_DXE_NB_INIT ) +#define DXE_NB_SMM_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_DXE_NB_SMM_INIT ) +#define DXE_NB_ERROR (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_EC_DXE_NB_ERROR ) + +// Reported by SB Driver(s) +#define DXE_SBRUN_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_DXE_SB_RT_INIT ) +#define DXE_SB_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_DXE_SB_INIT ) +#define DXE_SB_SMM_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_DXE_SB_SMM_INIT ) +#define DXE_SB_DEVICES_INIT (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_PC_DXE_SB_DEVICES_INIT ) +#define DXE_SB_BAD_BATTERY (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_EC_BAD_BATTERY) +#define DXE_SB_ERROR (EFI_COMPUTING_UNIT_CHIPSET = | EFI_CHIPSET_EC_DXE_SB_ERROR ) + +//Reported by DXE Core +#define DXE_BDS_STARTED (EFI_SOFTWARE_DXE_CORE | EFI= _SW_DXE_CORE_PC_HANDOFF_TO_NEXT) + +//Reported by BDS +//#define DXE_BDS_CONNECT_DRIVERS (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS) + +//Reported by Boot Manager +#define DXE_READY_TO_BOOT (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT) + +//Reported by DXE Core +#define DXE_EXIT_BOOT_SERVICES (EFI_SOFTWARE_EFI_BOOT_SERVI= CE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES) +#define DXE_EXIT_BOOT_SERVICES_EVENT (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_PC_EXIT_BOOT_SERVICES_EVENT) + +//Reported by driver that installs Runtime AP +#define RT_SET_VIRTUAL_ADDRESS_MAP_BEGIN (EFI_SOFTWARE_EFI_RUNTIME_SE= RVICE | EFI_SW_RS_PC_SET_VIRTUAL_ADDRESS_MAP) +#define RT_SET_VIRTUAL_ADDRESS_MAP_END (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_PC_VIRTUAL_ADDRESS_CHANGE_EVENT) + +//Reported by CSM +#define DXE_LEGACY_OPROM_INIT (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_PC_LEGACY_OPROM_INIT) +#define DXE_LEGACY_BOOT (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT) +#define DXE_LEGACY_OPROM_NO_SPACE (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_EC_LEGACY_OPROM_NO_SPACE) + +//Reported by SETUP +//#define DXE_SETUP_VERIFYING_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD) +#define DXE_SETUP_START (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_PC_USER_SETUP) +#define DXE_SETUP_INPUT_WAIT (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_PC_INPUT_WAIT) +#define DXE_INVALID_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_EC_INVALID_PASSWORD) +#define DXE_INVALID_IDE_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_EC_INVALID_IDE_PASSWORD) +#define DXE_BOOT_OPTION_LOAD_ERROR (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR) +#define DXE_BOOT_OPTION_FAILED (EFI_SOFTWARE_DXE_BS_DRIVER = | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED) + +//Reported by a Driver that installs Reset AP +#define DXE_RESET_SYSTEM (EFI_SOFTWARE_EFI_RUNTIME_SE= RVICE | EFI_SW_RS_PC_RESET_SYSTEM) +#define DXE_RESET_NOT_AVAILABLE (EFI_SOFTWARE_EFI_RUNTIME_SE= RVICE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE) + +// Reported by PCI bus driver +#define DXE_PCI_BUS_BEGIN (EFI_IO_BUS_PCI | EFI_IOB_PC= _INIT) +#define DXE_PCI_BUS_ENUM (EFI_IO_BUS_PCI | EFI_IOB_PC= I_PC_BUS_ENUM) +#define DXE_PCI_BUS_HPC_INIT (EFI_IO_BUS_PCI | EFI_IOB_PC= I_PC_HPC_INIT) +#define DXE_PCI_BUS_REQUEST_RESOURCES (EFI_IO_BUS_PCI | EFI_IOB_PC= I_PC_RES_ALLOC) +#define DXE_PCI_BUS_ASSIGN_RESOURCES (EFI_IO_BUS_PCI | EFI_IOB_PC= _ENABLE) +#define DXE_PCI_BUS_HOTPLUG (EFI_IO_BUS_PCI | EFI_IOB_PC= _HOTPLUG) +#define DXE_PCI_BUS_OUT_OF_RESOURCES (EFI_IO_BUS_PCI | EFI_IOB_EC= _RESOURCE_CONFLICT) + +// Reported by USB bus driver +#define DXE_USB_BEGIN (EFI_IO_BUS_USB | EFI_IOB_PC= _INIT) +#define DXE_USB_RESET (EFI_IO_BUS_USB | EFI_IOB_PC= _RESET) +#define DXE_USB_DETECT (EFI_IO_BUS_USB | EFI_IOB_PC= _DETECT) +#define DXE_USB_ENABLE (EFI_IO_BUS_USB | EFI_IOB_PC= _ENABLE) +#define DXE_USB_HOTPLUG (EFI_IO_BUS_USB | EFI_IOB_PC= _HOTPLUG) + +//Reported by IDE bus driver +#define DXE_IDE_BEGIN (EFI_IO_BUS_ATA_ATAPI | EFI_= IOB_PC_INIT) +#define DXE_IDE_RESET (EFI_IO_BUS_ATA_ATAPI | EFI_= IOB_PC_RESET) +#define DXE_IDE_DETECT (EFI_IO_BUS_ATA_ATAPI | EFI_= IOB_PC_DETECT) +#define DXE_IDE_ENABLE (EFI_IO_BUS_ATA_ATAPI | EFI_= IOB_PC_ENABLE) +#define DXE_IDE_SMART_ERROR (EFI_IO_BUS_ATA_ATAPI | EFI_= IOB_ATA_BUS_SMART_OVERTHRESHOLD) +#define DXE_IDE_CONTROLLER_ERROR (EFI_IO_BUS_ATA_ATAPI | EFI_= IOB_EC_CONTROLLER_ERROR) +#define DXE_IDE_DEVICE_FAILURE (EFI_IO_BUS_ATA_ATAPI | EFI_= IOB_EC_INTERFACE_ERROR) + +// Reported by SCSI bus driver +#define DXE_SCSI_BEGIN (EFI_IO_BUS_SCSI | EFI_IOB_P= C_INIT) +#define DXE_SCSI_RESET (EFI_IO_BUS_SCSI | EFI_IOB_P= C_RESET) +#define DXE_SCSI_DETECT (EFI_IO_BUS_SCSI | EFI_IOB_P= C_DETECT) +#define DXE_SCSI_ENABLE (EFI_IO_BUS_SCSI | EFI_IOB_P= C_ENABLE) + +// Reported by Super I/O driver +#define DXE_SIO_INIT (EFI_IO_BUS_LPC | EFI_IOB_PC= _INIT) + +// Reported by Keyboard driver +#define DXE_KEYBOARD_INIT (EFI_PERIPHERAL_KEYBOARD | E= FI_P_PC_INIT) +#define DXE_KEYBOARD_RESET (EFI_PERIPHERAL_KEYBOARD | E= FI_P_PC_RESET) +#define DXE_KEYBOARD_DISABLE (EFI_PERIPHERAL_KEYBOARD | E= FI_P_PC_DISABLE) +#define DXE_KEYBOARD_DETECT (EFI_PERIPHERAL_KEYBOARD | E= FI_P_PC_PRESENCE_DETECT) +#define DXE_KEYBOARD_ENABLE (EFI_PERIPHERAL_KEYBOARD | E= FI_P_PC_ENABLE) +#define DXE_KEYBOARD_CLEAR_BUFFER (EFI_PERIPHERAL_KEYBOARD | E= FI_P_KEYBOARD_PC_CLEAR_BUFFER) +#define DXE_KEYBOARD_SELF_TEST (EFI_PERIPHERAL_KEYBOARD | E= FI_P_KEYBOARD_PC_SELF_TEST) + +// Reported by Mouse driver +#define DXE_MOUSE_INIT (EFI_PERIPHERAL_MOUSE | EFI_= P_PC_INIT) +#define DXE_MOUSE_RESET (EFI_PERIPHERAL_MOUSE | EFI_= P_PC_RESET) +#define DXE_MOUSE_DISABLE (EFI_PERIPHERAL_MOUSE | EFI_= P_PC_DISABLE) +#define DXE_MOUSE_DETECT (EFI_PERIPHERAL_MOUSE | EFI_= P_PC_PRESENCE_DETECT) +#define DXE_MOUSE_ENABLE (EFI_PERIPHERAL_MOUSE | EFI_= P_PC_ENABLE) + +// Reported by Mass Storage drivers +#define DXE_FIXED_MEDIA_INIT (EFI_PERIPHERAL_FIXED_MEDIA = | EFI_P_PC_INIT) +#define DXE_FIXED_MEDIA_RESET (EFI_PERIPHERAL_FIXED_MEDIA = | EFI_P_PC_RESET) +#define DXE_FIXED_MEDIA_DISABLE (EFI_PERIPHERAL_FIXED_MEDIA = | EFI_P_PC_DISABLE) +#define DXE_FIXED_MEDIA_DETECT (EFI_PERIPHERAL_FIXED_MEDIA = | EFI_P_PC_PRESENCE_DETECT) +#define DXE_FIXED_MEDIA_ENABLE (EFI_PERIPHERAL_FIXED_MEDIA = | EFI_P_PC_ENABLE) +#define DXE_REMOVABLE_MEDIA_INIT (EFI_PERIPHERAL_REMOVABLE_ME= DIA | EFI_P_PC_INIT) +#define DXE_REMOVABLE_MEDIA_RESET (EFI_PERIPHERAL_REMOVABLE_ME= DIA | EFI_P_PC_RESET) +#define DXE_REMOVABLE_MEDIA_DISABLE (EFI_PERIPHERAL_REMOVABLE_ME= DIA | EFI_P_PC_DISABLE) +#define DXE_REMOVABLE_MEDIA_DETECT (EFI_PERIPHERAL_REMOVABLE_ME= DIA | EFI_P_PC_PRESENCE_DETECT) +#define DXE_REMOVABLE_MEDIA_ENABLE (EFI_PERIPHERAL_REMOVABLE_ME= DIA | EFI_P_PC_ENABLE) + + +// Reported by BDS +#define DXE_CON_OUT_CONNECT (EFI_PERIPHERAL_LOCAL_CONSOL= E | EFI_P_PC_INIT) +#define DXE_CON_IN_CONNECT (EFI_PERIPHERAL_KEYBOARD | E= FI_P_PC_INIT) +#define DXE_NO_CON_OUT (EFI_PERIPHERAL_LOCAL_CONSOL= E | EFI_P_EC_NOT_DETECTED) +#define DXE_NO_CON_IN (EFI_PERIPHERAL_KEYBOARD | E= FI_P_EC_NOT_DETECTED) + +#endif diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatu= sCodeHandlerLib/PeiBeepStatusCodeHandlerLib.c b/Features/Intel/Debugging/Be= epDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/PeiBeepStatusCodeHandler= Lib.c new file mode 100644 index 0000000000..a29d948951 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatusCodeHa= ndlerLib/PeiBeepStatusCodeHandlerLib.c @@ -0,0 +1,101 @@ +/** @file + Beep status code implementation. + + Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include +#include + +/** + Convert status code value to the times of beep. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES tab= le published by the PEI Foundation. + @param CodeType Indicates the type of status code being reporte= d. + @param Value Describes the current status of a hardware or + software entity. This includes information abou= t the class and + subclass that is used to classify the entity as= well as an operation. + For progress codes, the operation is the curren= t activity. + For error codes, it is the exception.For debug = codes,it is not defined at this time. + @param Instance The enumeration of a hardware or software entit= y within + the system. A system may contain multiple entit= ies that match a class/subclass + pairing. The instance differentiates between th= em. An instance of 0 indicates + that instance information is unavailable, not m= eaningful, or not relevant. + Valid instance numbers start with 1. + @param 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 Data This optional parameter may be used to pass add= itional data. + + @retval EFI_SUCCESS Status code reported to beep successfully. + +**/ +EFI_STATUS +EFIAPI +BeepStatusCodeReportWorker ( + 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 OPTIONAL + ) +{ + UINT32 BeepValue; + + BeepValue =3D GetBeepValueFromStatusCode (CodeType, Value); + if (BeepValue !=3D 0) { + Beep (BeepValue); + } + + return EFI_SUCCESS; +} + +/** + Constructor function of PeiBeepStatusCodeHandlerLib. + + This function is the constructor function of this Beep Status Code Handl= er Library for PEI Phase. + It check whether need beep, and register it to gEfiPeiRscHandlerPpiGuid. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCESS The entry point of DXE IPL PEIM executes successfull= y. + +**/ +RETURN_STATUS +EFIAPI +PeiBeepStatusCodeHandlerLibConstructor ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_PEI_RSC_HANDLER_PPI *RscHandlerPpi; + + if (!PcdGetBool (PcdStatusCodeUseBeep)) { + return RETURN_SUCCESS; + } + + Status =3D PeiServicesLocatePpi ( + &gEfiPeiRscHandlerPpiGuid, + 0, + NULL, + (VOID **) &RscHandlerPpi + ); + ASSERT_EFI_ERROR (Status); + + Status =3D RscHandlerPpi->Register (BeepStatusCodeReportWorker); + ASSERT_EFI_ERROR (Status); + + return RETURN_SUCCESS; +} diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatu= sCodeHandlerLib/PeiBeepStatusCodeHandlerLib.inf b/Features/Intel/Debugging/= BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/PeiBeepStatusCodeHandl= erLib.inf new file mode 100644 index 0000000000..6b3371f219 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatusCodeHa= ndlerLib/PeiBeepStatusCodeHandlerLib.inf @@ -0,0 +1,52 @@ +## @file +# Beep status code implementation. +# +# Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# vendor. This file may not be modified, except as allowed by +# additional terms of your license agreement. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiBeepStatusCodeHandlerLib + FILE_GUID =3D C4210E71-0A38-4728-8D25-4876348AA380 + MODULE_TYPE =3D PEIM + CONSTRUCTOR =3D PeiBeepStatusCodeHandlerLibConstructor + LIBRARY_CLASS =3D StatusCodeHandlerLib|SEC PEIM PEI_COR + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC (EBC is only for bui= ld) +# + +[Sources] + PeiBeepStatusCodeHandlerLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec + +[LibraryClasses] + PeiServicesLib + PcdLib + HobLib + ReportStatusCodeLib + PrintLib + DebugLib + BaseMemoryLib + BeepMapLib + BeepLib + +[Pcd] + gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep ##= CONSUMES + +[Ppis] + gEfiPeiRscHandlerPpiGuid ## CONSUMES + +[Depex] + TRUE diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatu= sCodeHandlerLib/RuntimeDxeBeepStatusCodeHandlerLib.c b/Features/Intel/Debug= ging/BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/RuntimeDxeBeepSta= tusCodeHandlerLib.c new file mode 100644 index 0000000000..18654b40f4 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatusCodeHa= ndlerLib/RuntimeDxeBeepStatusCodeHandlerLib.c @@ -0,0 +1,183 @@ +/** @file + Beep status code implementation. + + Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol =3D NULL; +EFI_EVENT mExitBootServicesEvent =3D NULL; + +/** + Convert status code value to the times of beep. + + @param CodeType Indicates the type of status code being reporte= d. + @param Value Describes the current status of a hardware or + software entity. This includes information abou= t the class and + subclass that is used to classify the entity as= well as an operation. + For progress codes, the operation is the curren= t activity. + For error codes, it is the exception.For debug = codes,it is not defined at this time. + @param Instance The enumeration of a hardware or software entit= y within + the system. A system may contain multiple entit= ies that match a class/subclass + pairing. The instance differentiates between th= em. An instance of 0 indicates + that instance information is unavailable, not m= eaningful, or not relevant. + Valid instance numbers start with 1. + @param 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 Data This optional parameter may be used to pass add= itional data. + + @retval EFI_SUCCESS Status code reported to beep successfully. + +**/ +EFI_STATUS +EFIAPI +BeepStatusCodeReportWorker ( + 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 OPTIONAL + ) +{ + UINT32 BeepValue; + + BeepValue =3D GetBeepValueFromStatusCode (CodeType, Value); + if (BeepValue !=3D 0) { + Beep (BeepValue); + } + + return EFI_SUCCESS; +} + +/** + Unregister status code callback functions only available at boot time fr= om + report status code router when exiting boot services. + + @param Event Event whose notification function is being invoked. + @param Context Pointer to the notification function's context, wh= ich is + always zero in current implementation. + +**/ +VOID +EFIAPI +UnregisterBeepBootTimeHandlers ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + if (PcdGetBool (PcdStatusCodeUseBeep)) { + mRscHandlerProtocol->Unregister (BeepStatusCodeReportWorker); + } +} + +/** + Register status code callback function only when Report Status Code prot= ocol + is installed. + + @param Event Event whose notification function is being invoked. + @param Context Pointer to the notification function's context, wh= ich is + always zero in current implementation. + +**/ +VOID +EFIAPI +RegisterBeepBootTimeHandlers ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + + Status =3D gBS->LocateProtocol ( + &gEfiRscHandlerProtocolGuid, + NULL, + (VOID **) &mRscHandlerProtocol + ); + ASSERT_EFI_ERROR (Status); + + mRscHandlerProtocol->Register (BeepStatusCodeReportWorker, TPL_HIGH_LEVE= L); + ASSERT_EFI_ERROR (Status); + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + UnregisterBeepBootTimeHandlers, + NULL, + &gEfiEventExitBootServicesGuid, + &mExitBootServicesEvent + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Constructor function of RuntimeDxeBeepStatusCodeHandlerLib. + + This function allocates memory for extended status code data, caches + the report status code service, and registers events. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +RuntimeDxeBeepStatusCodeHandlerLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_EVENT RegisterStatusCodeHandlerEvent; + VOID *Registration; + + if (!PcdGetBool (PcdStatusCodeUseBeep)) { + return EFI_SUCCESS; + } + + Status =3D gBS->LocateProtocol ( + &gEfiRscHandlerProtocolGuid, + NULL, + (VOID **) &mRscHandlerProtocol + ); + + if (!EFI_ERROR (Status)) { + RegisterBeepBootTimeHandlers (NULL, NULL); + } else { + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + RegisterBeepBootTimeHandlers, + NULL, + &RegisterStatusCodeHandlerEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Register for protocol notifications on this event + // + Status =3D gBS->RegisterProtocolNotify ( + &gEfiRscHandlerProtocolGuid, + RegisterStatusCodeHandlerEvent, + &Registration + ); + ASSERT_EFI_ERROR (Status); + } + + return EFI_SUCCESS; +} diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatu= sCodeHandlerLib/RuntimeDxeBeepStatusCodeHandlerLib.inf b/Features/Intel/Deb= ugging/BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/RuntimeDxeBeepS= tatusCodeHandlerLib.inf new file mode 100644 index 0000000000..bf1e3a4792 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatusCodeHa= ndlerLib/RuntimeDxeBeepStatusCodeHandlerLib.inf @@ -0,0 +1,54 @@ +## @file +# Beep status code implementation. +# +# Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# vendor. This file may not be modified, except as allowed by +# additional terms of your license agreement. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D RuntimeDxeBeepStatusCodeHandlerLib + FILE_GUID =3D D05F43CE-7C70-4663-848F-8265C311A8A5 + MODULE_TYPE =3D DXE_RUNTIME_DRIVER + VERSION_STRING =3D 1.0 + CONSTRUCTOR =3D RuntimeDxeBeepStatusCodeHandlerLibCon= structor + LIBRARY_CLASS =3D StatusCodeHandlerLib|DXE_RUNTIME_DRIV= ER + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC (EBC is only for bui= ld) +# + +[Sources] + RuntimeDxeBeepStatusCodeHandlerLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + BaseMemoryLib + PcdLib + DevicePathLib + UefiRuntimeLib + ReportStatusCodeLib + BeepMapLib + BeepLib + +[Pcd] + gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep ##= CONSUMES + +[Protocols] + gEfiRscHandlerProtocolGuid ## CONSUMES + +[Depex] + TRUE diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatu= sCodeHandlerLib/SmmBeepStatusCodeHandlerLib.c b/Features/Intel/Debugging/Be= epDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/SmmBeepStatusCodeHandler= Lib.c new file mode 100644 index 0000000000..6528994b05 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatusCodeHa= ndlerLib/SmmBeepStatusCodeHandlerLib.c @@ -0,0 +1,139 @@ +/** @file + Beep status code implementation. + + Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/** + Convert status code value to the times of beep. + + @param CodeType Indicates the type of status code being reporte= d. + @param Value Describes the current status of a hardware or + software entity. This includes information abou= t the class and + subclass that is used to classify the entity as= well as an operation. + For progress codes, the operation is the curren= t activity. + For error codes, it is the exception.For debug = codes,it is not defined at this time. + @param Instance The enumeration of a hardware or software entit= y within + the system. A system may contain multiple entit= ies that match a class/subclass + pairing. The instance differentiates between th= em. An instance of 0 indicates + that instance information is unavailable, not m= eaningful, or not relevant. + Valid instance numbers start with 1. + @param 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 Data This optional parameter may be used to pass add= itional data. + + @retval EFI_SUCCESS Status code reported to beep successfully. + +**/ +EFI_STATUS +EFIAPI +BeepStatusCodeReportWorker ( + 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 OPTIONAL + ) +{ + UINT32 BeepValue; + + BeepValue =3D GetBeepValueFromStatusCode (CodeType, Value); + if (BeepValue !=3D 0) { + Beep (BeepValue); + } + + return EFI_SUCCESS; +} + +/** + Register status code callback function only when Report Status Code prot= ocol + is installed. + + @param Protocol Points to the protocol's unique identifier. + @param Interface Points to the interface instance. + @param Handle The handle on which the interface was installed. + + @retval EFI_SUCCESS Notification runs successfully. + +**/ +EFI_STATUS +EFIAPI +RegisterBeepBootTimeHandlers ( + IN CONST EFI_GUID *Protocol, + IN VOID *Interface, + IN EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + EFI_SMM_RSC_HANDLER_PROTOCOL *RscHandlerProtocol; + + Status =3D gSmst->SmmLocateProtocol ( + &gEfiSmmRscHandlerProtocolGuid, + NULL, + (VOID **) &RscHandlerProtocol + ); + ASSERT_EFI_ERROR (Status); + + RscHandlerProtocol->Register (BeepStatusCodeReportWorker); + + return EFI_SUCCESS; +} + +/** + Constructor function of SmmBeepStatusCodeHandlerLib. + + This function allocates memory for extended status code data, caches + the report status code service, and registers events. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmmBeepStatusCodeHandlerLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + VOID *Registration; + EFI_SMM_RSC_HANDLER_PROTOCOL *RscHandlerProtocol; + + if (!PcdGetBool (PcdStatusCodeUseBeep)) { + return EFI_SUCCESS; + } + + Status =3D gSmst->SmmLocateProtocol ( + &gEfiSmmRscHandlerProtocolGuid, + NULL, + (VOID **) &RscHandlerProtocol + ); + if (!EFI_ERROR (Status)) { + RegisterBeepBootTimeHandlers (NULL, NULL, NULL); + } else { + gSmst->SmmRegisterProtocolNotify ( + &gEfiSmmRscHandlerProtocolGuid, + RegisterBeepBootTimeHandlers, + &Registration + ); + } + + return EFI_SUCCESS; +} diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatu= sCodeHandlerLib/SmmBeepStatusCodeHandlerLib.inf b/Features/Intel/Debugging/= BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/SmmBeepStatusCodeHandl= erLib.inf new file mode 100644 index 0000000000..03f9c37330 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Library/BeepStatusCodeHa= ndlerLib/SmmBeepStatusCodeHandlerLib.inf @@ -0,0 +1,52 @@ +## @file +# Beep status code implementation. +# +# Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# vendor. This file may not be modified, except as allowed by +# additional terms of your license agreement. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SmmBeepStatusCodeHandlerLib + FILE_GUID =3D 2E2BC2D4-572D-4663-9A1E-FB52FA30922A + MODULE_TYPE =3D DXE_SMM_DRIVER + VERSION_STRING =3D 1.0 + CONSTRUCTOR =3D SmmBeepStatusCodeHandlerLibConstructor + LIBRARY_CLASS =3D StatusCodeHandlerLib|DXE_SMM_DRIVER + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC (EBC is only for bui= ld) +# + +[Sources] + SmmBeepStatusCodeHandlerLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + BeepDebugFeaturePkg/BeepDebugFeaturePkg.dec + +[LibraryClasses] + PcdLib + BaseMemoryLib + SmmServicesTableLib + DebugLib + MemoryAllocationLib + ReportStatusCodeLib + BeepMapLib + BeepLib + +[Pcd] + gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep ##= CONSUMES + +[Protocols] + gEfiSmmRscHandlerProtocolGuid ## CONSUMES + +[Depex] + TRUE diff --git a/Features/Intel/Debugging/BeepDebugFeaturePkg/Readme.md b/Featu= res/Intel/Debugging/BeepDebugFeaturePkg/Readme.md new file mode 100644 index 0000000000..12ae2c1582 --- /dev/null +++ b/Features/Intel/Debugging/BeepDebugFeaturePkg/Readme.md @@ -0,0 +1,126 @@ +# Overview +* **Feature Name:** Beep Debug +* **PI Phase(s) Supported:** PEI, DXE, SMM +* **SMM Required?** Yes + +More Information: + +## Purpose +The BeepDebugFeaturePkg include some useful beep debug libraries, such as = get beep value from status code and beep. +This is an important capability in firmware development to get and analyze= the early error when there is not serial port. + + +# High-Level Theory of Operation +It provide a library BeepStatusCodeHandlerLib used by edk2 StatusCodeHandl= er.efi, used to do beep if needed. +It also provide a library of BeepMap lib, it map the status code to beep v= alue. +A library of Beep lib is needed by platform, and this pkg has a Null imple= mentation. + +In the library contstructor function, BeepStatusCodeHandlerLib register th= e call back function for ReportStatusCode. +When called, it call GetBeepFromStatusCode() in BeepMapLib to get beep val= ue from status code, and call Beep() in BeepLib to beep. + +BeepStatusCodeHandlerLib include 3 libraries for PEI, RuntimeDxe, SMM: +* PeiBeepStatusCodeHandlerLib +* RuntimeDxeBeepStatusCodeHandlerLib +* SmmBeepStatusCodeHandlerLib + +## Firmware Volumes +Linked with StatusCodeHandler.efi, and make sure put the StatusCodeHandler= .efi after the ReportStatusCodeRouter.efi. + +## Modules +* BeepStatusCodeHandlerLib +* BeepMapLib +* BeepLibNull + +## BeepStatusCodeHandlerLib +This library register the call back function for ReportStatusCode, and get +beep valude from status code, and do beep. + +## BeepMapLib +This library provide a function to get beep value from status code. + +## Key Functions +* In PeiBeepStatusCodeHandlerLib: + EFI_STATUS + EFIAPI + BeepStatusCodeReportWorker ( + 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 OPTIONAL + ) + +* In RuntimeDxeBeepStatusCodeHandlerLib: + EFI_STATUS + EFIAPI + BeepStatusCodeReportWorker ( + 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 OPTIONAL + ) + +* In SmmBeepStatusCodeHandlerLib: + EFI_STATUS + EFIAPI + BeepStatusCodeReportWorker ( + 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 OPTIONAL + ) + +* In BeepMapLib: + UINT32 + EFIAPI + GetBeepValueFromStatusCode ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value + ) + +* In BeepLib: + VOID + EFIAPI + Beep ( + IN UINT32 Value + ) + +## Configuration +* Link the library to StatusCodeHandler.efi. + Example: + MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerR= untimeDxe.inf { + + BeepDebugFeaturePkg/Library/BeepStatusCodeHandlerLib/RuntimeDxeBeepS= tatusCodeHandlerLib.inf + } + Refer to BeepDebugFeaturePkg.dsc for other example. +* Config pcd gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep + In platform .dsc file, need to config the type of gBeepDebugFeaturePkgTo= kenSpaceGuid.PcdStatusCodeUseBeep. + Use PcdsFixedAtBuild to save binary size, and use PcdsDynamic if want to= enable/disable in runtime. +* Implemented platform's special BeepMapLib if needed. +* Provide the platform's special BeepLib. +* Make sure put the StatusCodeHandler.efi after the ReportStatusCodeRouter= .efi. + +## Data Flows +Status Code (ReportStatusCode) -> Beep Value (GetBeepValueFromStatusCode). + +## Control Flows +ReportStatusCode() -> BeepStatusCodeReportWorker() -> GetBeepValueFromStat= usCode() -> Beep() + +## Build Flows +There is not special build flows. + +## Test Point Results +Verify the post code shown is correct. + +## Functional Exit Criteria +N/A + +## Feature Enabling Checklist +* Set the PCD gBeepDebugFeaturePkgTokenSpaceGuid.PcdStatusCodeUseBeep to T= RUE. +* Plug out all the memory, check can here the beep. + +## Common Optimizations +* Implemented platform's special BeepMapLib if needed. --=20 2.24.0.windows.2 -=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 (#61123): https://edk2.groups.io/g/devel/message/61123 Mute This Topic: https://groups.io/mt/74814540/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-