From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.100]) by mx.groups.io with SMTP id smtpd.web09.5408.1622023896924357261 for ; Wed, 26 May 2021 03:11:37 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=r/66ouBs; spf=pass (domain: os.amperecomputing.com, ip: 40.107.220.100, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hWAJ82pXNw9nuWYwLnQwpTd4p5WA1Oihu6Vh6xegE04LPx31/S3lHsM1VtwnQnAvsCAy9ZhW6pCkKY7nY40PxX7WE94ELaFy9R7pa6MvCzcJz7e2I6caqIUmobBiYyS9hSB+oxp0aUupULP0uzd+8ziRn13+HroJenaAA4cmQ2VQrO5N//0ExJAShA8utEs4pJfVJavz6A3QgAiJzQkeaHgOmr5TVgrf/i/hoJMz2u4Qs14xYpzPXTP2q6CLx5EQTvqpLyDtK5wdrzQuzEt7jDZ2+jEvxz+zgsXpsjb24LWnJwbyvyb2afa2IG+cfChpfpKQpLovyt6uBCF1HelMhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Emvh+GQ2MKojj0V1cpI89QHcy7zVx8la7DFBMSy4Z4o=; b=CRM266OdAEkEQ06mcWct+JIycZjAMl7+yAOUp7xaY2n9RRwzB/C9TBx2u/0sgjPS2VNKLR3n3pxGF4wukrDjToQ2RtIbN7GII3uGxyFuPE9pgGJFJ3K7PrGxe+ssVyqoeaYaRs2ZELbBJkV6u2Xn7a73Qs9ijhYKDCd4ci4Ck4Eh3VpVUzePJl/o/nGZr+ZG+N+wbar+ZhwYmPJuF8wmnRL2Wd7ymwcxDm2jTuppd90jcov8OjF+DW2Jijtr2KewcnbWMk0R4STkT1Mb7tP1CJy9rJchd159+IvjXTltDZZeUaG9ZNliHj2m3FekeSTRGk5F9Ax6ahLXC/6gLqTxZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Emvh+GQ2MKojj0V1cpI89QHcy7zVx8la7DFBMSy4Z4o=; b=r/66ouBsoEZXgY6sJiC+J5L9obCKBSbO1mCi3xbjAUlc55NMCuu/REs9b4jiXegUN0CnVQteklU+EbKa+V1oVgnrOJNc8uwRPq87kIzQiDQpxgtOTlGPtcW3o9/QmjXYx9Lvw8zuEtu2Dp4oYR97duX12F2g3DSTNNHULkT1YUs= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM5PR0101MB3067.prod.exchangelabs.com (2603:10b6:4:31::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Wed, 26 May 2021 10:11:35 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::60d2:86dd:1f1c:51dd]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::60d2:86dd:1f1c:51dd%7]) with mapi id 15.20.4173.020; Wed, 26 May 2021 10:11:35 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: Quan Nguyen , Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [edk2-platforms][PATCH v2 08/32] AmpereAltraPkg: Add BootProgress support Date: Wed, 26 May 2021 17:07:00 +0700 Message-ID: <20210526100724.5359-10-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210526100724.5359-1-nhi@os.amperecomputing.com> References: <20210526100724.5359-1-nhi@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR04CA0008.apcprd04.prod.outlook.com (2603:1096:203:d0::18) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (118.69.219.201) by HKAPR04CA0008.apcprd04.prod.outlook.com (2603:1096:203:d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 26 May 2021 10:11:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a892c7a6-fdb4-4c76-3bbe-08d9202ea4a3 X-MS-TrafficTypeDiagnostic: DM5PR0101MB3067: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q3wGTC6Hn6phasgckQ9vxo+WpA03wScmQyPB76UKKI+zhJad2sHCdTZjTspE1Svh9kPPeQgC+HijfeHa84r++vCgU/Fz8yHV0qFGxRPH/HGPfuJPHtvoWLWf19asU2G6+ZdNrc/DxRaBCrxSOqa2cEtYtrixspww6tgKqyfLqO8LKj5kn17xnIWmWpnZkZ/9v/PSuwZggI+8G4JxNgeXVWEdRtrtI+HAt0BZ8lY+AKOY3IfNcjEsZVqPG7VSCajU5r3+xOhYVhDdGpeKNYpx+2HgWZHw51bO3G+9jBe6kqYBVlHtzhbYi7HXQbkun0HUyWZF0UMewxYI5++sY/5Psl7LN3rzqxi+Kt6NGVA3so6n1lBHPgOHedpFwanjupUWqa4ZHU+vZJKdZ2TCpbWEPC/NZyjnn/A3pQ9+DyxwKyjpOg4BsUoengzKhIBG1DoFHdYYxGvL5LQP2idwyDOvCH9oOezl1TPI8aaWr+hwgI33NVMv0qn+EDR9WCVovD6vtDiToAa+NfaAyeMYgcPK+OsLgEkMni5x/AMc/aOmTtRqpnlpG4EW1DZfXvC5p0vUWxLVbECx/b+RemA2bUvzisa7zAB2ZKVgLe8LccLI1ERiXP2ahw9k5gJFbE0aeaEhIIife7VBx0ik7DqLAEuGi2yc6hdSoO5MTCKh9pDbN4k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5849.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(39850400004)(396003)(346002)(136003)(376002)(366004)(4326008)(26005)(6666004)(1076003)(2616005)(38350700002)(6506007)(83380400001)(86362001)(2906002)(6486002)(8676002)(30864003)(956004)(52116002)(8936002)(186003)(54906003)(66556008)(6916009)(66476007)(6512007)(66946007)(38100700002)(5660300002)(16526019)(478600001)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?xfhb9rE6XO+ttm9+JGdzmIc5GeLbWp0xjnLjSdOFgQENyoecouSEu9VpYxmO?= =?us-ascii?Q?cImXrbo1YelxPJunWihhcOmrGdMvC+xPEj2fWQ5LG8BRh565aPWzGkxPHXqk?= =?us-ascii?Q?/OKdt2moaom71+0JyLxBF2I1xgwnveP6cuYQ8JxpjvjnYAW/d5kyO4oVNasz?= =?us-ascii?Q?k5qOdBJeFW4R64PuwbzuxFzVkOJhcIjuZBtIVaMO45gwL6dtDOUyh0N2uDD4?= =?us-ascii?Q?PjjFw9IRPEQlGzN9mVthoRGUE9la96ktroU01LVpDULsz6ap4shYX7J9sTlL?= =?us-ascii?Q?RoHEo7ERJH7/m6nNcDQ7EUxOVZFYL7WH1kpBSGcQ8OVhFZ+ywQ01dSz0OWCk?= =?us-ascii?Q?IMKap6tMQUYiGn3jAMbrqyFlaUMbMeVqw4BmOAtAa+Trsg4E0wmD6ewKU2gX?= =?us-ascii?Q?/Y+o2FgQsehwM52WFYFlmS19OFn73fM4gbgW7CnSurvdUjbXndneDnIozdf9?= =?us-ascii?Q?3a/hcFV68Xl+0AKWhchVPBI8D3Eb+Fxm0a5UNexGSW15XflwuzZzdukGEtNE?= =?us-ascii?Q?NzOPBUSYKEC/thked5exmTU5Ti/lkC260A3VK9623+TAIna+3/rnKwxMfkhI?= =?us-ascii?Q?WhHu/j7qj2OR8eDOcUcPR2W6lqugFxLGjUN5iA+mVSWB+o9QiSCVKuB9516w?= =?us-ascii?Q?tPc87et1Ij72z//K9D5e+JQx6z/J4+BMtAlDs6GPakYxzNarD48hx1nWzskX?= =?us-ascii?Q?mgDPpyqe6ObA++MHaTXCMzjZGvEGNkY9bSjkQMt1K4WoKF4NlG+q2OmZ8Cdi?= =?us-ascii?Q?AAjDswCS6jilTSPkk5UO1apDHku3H/5+CftJEIjDy6lGcFJn2IQAqfNw6JiY?= =?us-ascii?Q?1AwlY2p9iOl74feujg8bZlSEK3ft+V6yvE1ooP1e8Zg8rB2ihb9qA/iHxzAg?= =?us-ascii?Q?WL/c2j6t6YO+T5hO/ckRZdc/7TZXT8Omcf8LjrctjCBf/4AGpaYVK1ODqnmc?= =?us-ascii?Q?HvEzGYpcTnkpr9ZtE6aYkKMlmF1HUzXH5y81aoATwrqQvunWtpSW3O9swkPd?= =?us-ascii?Q?PopLdN07ZD/YakSb5uJgf49v6+sXxTY3ERzuQ5ezm7c4qhiVkJ0/0fVcSYpa?= =?us-ascii?Q?N5+K5IqGIuxBkk5pKsrfVDwbKxHaPIbafwBTua8VQ/8s48W8J93I6Bnr6lql?= =?us-ascii?Q?FRipP1Jjs0cPJBrsKkFQikXyLs8vSLKHHtd98d3Ax7uDhHNzOvlso9tt0Oc/?= =?us-ascii?Q?eQTixgrIBGYMaoXuITvmqsH5oSf5gY6zCm+3l0l7pJ6SwcM4V5Fqr79fLl2B?= =?us-ascii?Q?AUosoeRmsROsUA4Rdykx9h46zCHZFqUGhaKxJI3OcRL9TZ0Zb5DlKPjoAYen?= =?us-ascii?Q?dOc/793clB18E8U3Tq+gM4Op?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: a892c7a6-fdb4-4c76-3bbe-08d9202ea4a3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2021 10:11:35.4180 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: w3g/fko6aaeAll4rSw2jxzMx0P2XHBupaIrj0PlYkJVqco4kHiqvIb/4QWyY8f13kP+JpguJuB7p7jQBwZPTHuhX7dulJpWxcKSsQ7GGTVc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0101MB3067 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 --- Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc = | 2 + Platform/Ampere/JadePkg/Jade.fdf = | 2 + Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootPro= gressDxe.inf | 51 +++++ Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootPr= ogressPeim.inf | 49 +++++ Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootPro= gressDxe.c | 211 ++++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootPr= ogressPeim.c | 210 +++++++++++++++++++ Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootPro= gressDxe.uni | 16 ++ Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootPr= ogressPeim.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/ReportStatusCodeRouter= Pei.inf MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf + Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/Boot= ProgressPeim.inf =20 # # DXE Phase modules @@ -539,6 +540,7 @@ [Components.common] } MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCod= eRouterRuntimeDxe.inf MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRun= timeDxe.inf + Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/BootP= rogressDxe.inf =20 # # PCD diff --git a/Platform/Ampere/JadePkg/Jade.fdf b/Platform/Ampere/JadePkg/Jad= e.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/MmCommunica= tionPei.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/ReportStatu= sCodeRouterRuntimeDxe.inf INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandle= rRuntimeDxe.inf + INF Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/B= ootProgressDxe.inf =20 # # PI DXE Drivers producing Architectural Protocols (EFI Services) diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgres= sDxe/BootProgressDxe.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgre= ss/BootProgressDxe/BootProgressDxe.inf new file mode 100644 index 000000000000..2211a213a6df --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/Bo= otProgressDxe.inf @@ -0,0 +1,51 @@ +## @file +# This module installs Boot Progress Dxe. +# +# This module registers report status code listener to report boot progre= ss +# to SMpro. +# +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D BootProgressDxe + MODULE_UNI_FILE =3D BootProgressDxe.uni + FILE_GUID =3D 6E12F248-F0C1-11EA-B37C-9798918A2163 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D BootProgressDxeEntryPoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/BootProgres= sPeim/BootProgressPeim.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProg= ress/BootProgressPeim/BootProgressPeim.inf new file mode 100644 index 000000000000..1dd0ec31ac37 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/B= ootProgressPeim.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 progre= ss +# 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 =3D 0x0001001B + BASE_NAME =3D BootProgressPeim + MODULE_UNI_FILE =3D BootProgressPeim.uni + FILE_GUID =3D 2E8A3B3E-F26C-11EA-BDE5-6726AD8F88BD + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D BootProgressPeiEntryPoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/BootProgres= sDxe/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/Bo= otProgressDxe.c @@ -0,0 +1,211 @@ +/** @file + + This module installs Boot Progress Dxe that report boot progress to SMpr= o. + + This module registers report status code listener to report boot progres= s + 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 =3D 0, + BOOT_START =3D 1, + BOOT_COMPLETE =3D 2, + BOOT_FAILED =3D 3, +}; + +UINT32 DxeProgressCode[] =3D { + (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=C2=A0 + (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_EV= ENT), // 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[] =3D { + (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 =3D NULL; + +STATIC UINT8 mBootstate =3D BOOT_START; + +STATIC +BOOLEAN +StatusCodeFilter ( + UINT32 *Map, + EFI_STATUS_CODE_VALUE Value + ) +{ + UINTN Index =3D 0; + + while (Map[Index] !=3D 0) { + if (Map[Index] =3D=3D 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 hardwa= re or software entity. + This included information about the clas= s and subclass that is used to + classify the entity as well as an operat= ion. + @param[in] Instance The enumeration of a hardware or softwar= e entity within + the system. Valid instance numbers start= with 1. + @param[in] CallerId This optional parameter may be used to i= dentify the caller. + This parameter allows the status code dr= iver to apply different rules to + different callers. + @param[in] Data This optional parameter may be used to p= ass 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 =3D FALSE; + BOOLEAN IsError =3D FALSE; + + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_PROGRESS_CODE) { + IsProgress =3D StatusCodeFilter (DxeProgressCode, Value); + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_ERROR_CODE)= { + IsError =3D StatusCodeFilter (DxeErrorCode, Value); + } else { + return EFI_SUCCESS; + } + + if (!IsProgress && !IsError) { + return EFI_SUCCESS; + } + + DEBUG (( + DEBUG_INFO, + "BootProgressDxe: CodeType=3D0x%X Value=3D0x%X Instance=3D0x%X CallerI= dGuid=3D%g Data=3D%p\n", + CodeType, + Value, + Instance, + CallerId, + Data + )); + + if (IsError) { + mBootstate =3D BOOT_FAILED; + } else if (Value =3D=3D (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_R= EADY_TO_BOOT_EVENT)) { + /* Set boot complete when reach to ReadyToBoot event */ + mBootstate =3D BOOT_COMPLETE; + } + + MailboxMsgSetBootProgress (0, mBootstate, Value); + + if (Value =3D=3D (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT= _SERVICES) && + mRscHandlerProtocol !=3D 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 ima= ge. + @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 =3D 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 =3D mRscHandlerProtocol->Register (BootProgressListenerDxe, TPL= _HIGH_LEVEL); + } + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgres= sPeim/BootProgressPeim.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgre= ss/BootProgressPeim/BootProgressPeim.c new file mode 100644 index 000000000000..c677e27a00ce --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/B= ootProgressPeim.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 progres= s + 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 =3D 0, + BOOT_START =3D 1, + BOOT_COMPLETE =3D 2, + BOOT_FAILED =3D 3, +}; + +UINT32 PeiProgressStatusCode[] =3D { + // 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), // Mem= ory 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 Cor= e is started + // Recovery + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_RECOVERY_AUTO), // Recovery co= ndition triggered by firmware (Auto recovery) + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_RECOVERY_USER), // Recovery co= ndition triggered by user (Forced recovery) + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_RECOVERY_BEGIN), // Recovery pr= ocess started + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_CAPSULE_LOAD), // Recovery fi= rmware image is found + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_CAPSULE_START), // Recovery fi= rmware image is loaded + // S3 + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_S3_BOOT_SCRIPT), // S3 Boot Scr= ipt execution + (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE), // OS S3 wake = vector call + 0 // Must end wi= th 0 +}; + +UINT32 PeiErrorStatusCode[] =3D { + // Regular boot + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_INVALID_TYPE), // Me= mory initialization error. Invalid memory type + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_INVALID_SPEED), // Me= mory initialization error. Incompatible memory speed + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_SPD_FAIL), // Me= mory initialization error. SPD reading has failed + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_INVALID_SIZE), // Me= mory initialization error. Invalid memory size + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_MISMATCH), // Me= mory initialization error. Memory modules do not match + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_NONE_DETECTED), // Me= mory initialization error. No usable memory detected + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_MEMORY_EC_NONE_USEFUL), // Me= mory initialization error. No usable memory detected + (EFI_COMPUTING_UNIT_MEMORY | EFI_CU_EC_NON_SPECIFIC), // Un= specified memory initialization error. + (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_EC_MEMORY_NOT_INSTALLED), // Me= mory not installed + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_INVALID_TYPE), // In= valid CPU type + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_INVALID_SPEED), // In= valid CPU Speed + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_MISMATCH), // CP= U mismatch + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST), // CP= U self test failed + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_CACHE), // po= ssible CPU cache error + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_INTERNAL), // In= ternal CPU error + (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_EC_NON_SPECIFIC), // In= ternal CPU error + (EFI_SOFTWARE_PEI_SERVICE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE), // re= set 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 =3D BOOT_START; + +STATIC +BOOLEAN +StatusCodeFilter ( + UINT32 *Map, + EFI_STATUS_CODE_VALUE Value + ) +{ + UINTN Index =3D 0; + + while (Map[Index] !=3D 0) { + if (Map[Index] =3D=3D Value) { + return TRUE; + } + Index++; + } + + return FALSE; +} + +/** + Report status code listener for PEI. This is used to record the boot pro= gress info + and report it to SMpro. + + @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVI= CES 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 hardwa= re or software entity. + This included information about the clas= s and subclass that is used to + classify the entity as well as an operat= ion. + @param[in] Instance The enumeration of a hardware or softwar= e entity within + the system. Valid instance numbers start= with 1. + @param[in] CallerId This optional parameter may be used to i= dentify the caller. + This parameter allows the status code dr= iver to apply different rules to + different callers. + @param[in] Data This optional parameter may be used to p= ass 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 =3D FALSE; + BOOLEAN IsError =3D FALSE; + + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_PROGRESS_CODE) { + IsProgress =3D StatusCodeFilter (PeiProgressStatusCode, Value); + } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_ERROR_CODE)= { + IsError =3D StatusCodeFilter (PeiErrorStatusCode, Value); + } else { + return EFI_SUCCESS; + } + + // No interested status found + if (!IsProgress && !IsError) { + return EFI_SUCCESS; + } + + DEBUG (( + DEBUG_INFO, + "BootProgressPeim: CodeType=3D0x%X Value=3D0x%X Instance=3D0x%X Caller= IdGuid=3D%g Data=3D%p\n", + CodeType, + Value, + Instance, + CallerId, + Data + )); + + if (IsError) { + mBootstate =3D 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 Progres= s 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 successful= ly. + +**/ +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 =3D PeiServicesLocatePpi ( + &gEfiPeiRscHandlerPpiGuid, + 0, + NULL, + (VOID **)&RscHandler + ); + ASSERT_EFI_ERROR (Status); + + if (!EFI_ERROR (Status)) { + Status =3D RscHandler->Register (BootProgressListenerPei); + } + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgres= sDxe/BootProgressDxe.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgre= ss/BootProgressDxe/BootProgressDxe.uni new file mode 100644 index 000000000000..492e85404631 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressDxe/Bo= otProgressDxe.uni @@ -0,0 +1,16 @@ +// +// This module installs Boot Progress Dxe that report boot progress to SMp= ro. +// +// This module registers report status code listener to report boot progre= ss +// 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 Pro= gress Driver" + +#string STR_MODULE_DESCRIPTION #language en-US "This module regis= ters report status code listener to collect and report boot progress to SMp= ro." diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgres= sPeim/BootProgressPeim.uni b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProg= ress/BootProgressPeim/BootProgressPeim.uni new file mode 100644 index 000000000000..0371fc4f9a80 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/B= ootProgressPeim.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 progre= ss +// 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 c= ode listener to collect boot progress information and post to SCP." --=20 2.17.1