From nobody Sat Feb 7 08:27:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82282+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82282+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=hpe.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634615456904324.89096022237095; Mon, 18 Oct 2021 20:50:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ncL5YY1788612xJucxgBkh1n; Mon, 18 Oct 2021 20:50:56 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.5140.1634615450454460452 for ; Mon, 18 Oct 2021 20:50:55 -0700 X-Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19J1WKVn006476; Tue, 19 Oct 2021 03:50:50 GMT X-Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) by mx0a-002e3701.pphosted.com with ESMTP id 3bs5guyn0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Oct 2021 03:50:49 +0000 X-Received: from G1W8108.americas.hpqcorp.net (g1w8108.austin.hp.com [16.193.72.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2354.austin.hpe.com (Postfix) with ESMTPS id 5850DC6; Tue, 19 Oct 2021 03:50:49 +0000 (UTC) X-Received: from G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) by G1W8108.americas.hpqcorp.net (2002:10c1:483c::10c1:483c) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 19 Oct 2021 03:50:49 +0000 X-Received: from NAM02-BN1-obe.outbound.protection.outlook.com (15.241.52.10) by G9W8456.americas.hpqcorp.net (16.216.161.95) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Tue, 19 Oct 2021 03:50:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kLPxeq9IEZ4n0yOATYO7K8ttxZYtRzKrmRaSm69BuMR72NBw2o4KvDnoO+UTEksBz2XWAJykbp+nX5QyuAXzdzLokLlEMR8/mcE+048v7SYs+80k+h6yeL2RIBfflVhpSPABpED/Xk88ii4UnhVlzPvpQ8kjOUTcmLBHEL6+luAOVs8kaTVV9vCPyDLrRdOSYKyg9XupvCQt3UkPjnkVTx8w/WnoKN/w5dH4ut9L+ARsIozN/xaVV9u4jDrSkjx7b+cGPxaMiYxpTIo+Dnz8zlax9IOPFukburLmVMhl5O7vhSGsI8bkdkg36wKTq74zf8YU3tLXQNf7qIiajJpt7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/jrPqnVvZ+6fTJPPs6SzBBxmC3stWpKfZxGoMc0/A+I=; b=ac1UIwKtESWHHXSfO0PL5ghyp4vBr9MDPY+k74vN0sxp5fC/PyRsE5JJdSIH2pAq3avzxElKeb4l6T+JPkmTh8jlAo42dIaAzF1XcwKoHJcz5UcUZ9JebAt8aD10pHFrbUixpjCdwbCR8fzRCXEiHFzTwlV4WwWUAAVPz6qfat2uc7ZFsaisri+T3kadaVWumQWpD7B70pUH4Lr/i2GQzJChhBIaFoZ0t9NGdWMJmIl1lj7e6kkJFIeahm9dGHzQtoNqNr/gPB60lvXJ2eL8vn5epeN1zg3QYiYNWVnNkZoy45dfR3qVFRgAYDYNYnqbCpSwy0ddAahc8Hgk2hXWLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none X-Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) by DF4PR8401MB0921.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Tue, 19 Oct 2021 03:50:47 +0000 X-Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::597f:4786:f1d6:8469]) by DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::597f:4786:f1d6:8469%3]) with mapi id 15.20.4608.018; Tue, 19 Oct 2021 03:50:47 +0000 From: "Daniel Schaefer" To: CC: Daniel Schaefer , Abner Chang , Sunil V L Subject: [edk2-devel] [edk2-platforms] [PATCH v3 13/14] RISC-V: Implement ResetSystem RT call Date: Tue, 19 Oct 2021 11:48:48 +0800 Message-ID: <20211019034849.16847-14-daniel.schaefer@hpe.com> In-Reply-To: <20211019034849.16847-1-daniel.schaefer@hpe.com> References: <20211019034849.16847-1-daniel.schaefer@hpe.com> X-ClientProxiedBy: SG2PR03CA0134.apcprd03.prod.outlook.com (2603:1096:4:c8::7) To DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) MIME-Version: 1.0 X-Received: from zbook-nix.wireless.hpe.com (15.211.146.34) by SG2PR03CA0134.apcprd03.prod.outlook.com (2603:1096:4:c8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.11 via Frontend Transport; Tue, 19 Oct 2021 03:50:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 26b8d0f1-8f49-4b50-b60c-08d992b3a27b X-MS-TrafficTypeDiagnostic: DF4PR8401MB0921: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:174; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: n7CkJONq2LwBDVmi/13CxbvwbRCj0QAT/W6l2SR0iyyS7g3LdiEEe2woS0CcgXOKlPhfq99lVSlfzwvBqMV/QC/jSS1HOPNR3Iskj5KAgvnUXukShYUoLlMX7emsbDOF1awgXwRKfK3POtspaxii1+6nD552aa+KsodMSmoqxTg/7G1w8hE6eVd43gmnWZKYDL5aBr2Qf3xIVZZgJSVArw/ESa43piik9hhVm1ax1YCTPW2yAiNasIOeCwcZLrxVVtdxOjq5bCfTdP5p42ojQa6M8TSuctczosNJ1jJJ5uO9vflAuGYfcqVfNVytUPv/+k+XWOm0Tfyg6A8QNQaZKsFTI/q6fGcioG9m2DmG/bdnz8I1cM9QPEGNLlRvpb3G4bSCi+5zDP46rK45Uyrxz+XMfFaDSVZxI8Xiz+wwaQ7B2VeY52gENw0H6JKk5MU3H3cUORr6cklWnVoZb0zcqElcznrg4PW3nvoKa+gVocT6maenXIsiqYqw0ie8HIWwKQVokbP0fKapeeRtqxEahBIAaA1lY09UvIf8yjWxx8ldmKzitzEL5W/UypX15R679a3a3fykbElnJZiliFBg8GtvzQO8Q7dgnvXK8gGB+09tDFW5Qknb4C4LOMywqXOuV7vyktI0Hb14hq9/tWOKxRjKgkMfGXX82bQHroH8ZZ09wzB/WxMAp1egKLTjJrDq4tqHpZgpiukr6GpinZBzHQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JWurnslLsSX/gwkWxwvru2SXDNM5xJxoHiZdQ4cUU9vul72Z08eI02ataP43?= =?us-ascii?Q?AIxRhZQgxdVv54FN2BlSoc3C2xCwyWWTG6dMcrSwbjLV0xm5wNQa2sOtYwvF?= =?us-ascii?Q?PeFbenkaXrbuZMavvbvTfVcIIPbPBNfvQd9aGOvDMSErcgDqvZwNK2LhusYZ?= =?us-ascii?Q?tr5iV6dWhTNtxoeWgRcsnPEMMtb1YrsLbOJ7ef8Fo9DOnHgfN7P5nB6DJd2X?= =?us-ascii?Q?QfoyjdWowsq9lJV6EY2/wcBnEE/rFDDg3puiBW8S6ga7MrBeFANg88BycBcJ?= =?us-ascii?Q?jixwX6MZe6uG8H2m6zq8hWDcKoPjd7xo830DB0qyYHmJi+llvFILZXYpeElV?= =?us-ascii?Q?WymIP67NSveAHhg9BPM6jvg76bevGTPVvewLcWFsA36+yKJ+t8surf3NzLk7?= =?us-ascii?Q?KRmdfCXxCctISSkhy4PPwijX5JeBvvEcn8Hq6JqX8mgrQtXqURiupYIuo0qk?= =?us-ascii?Q?vsjcIf/MXmeuPioN0ST37hZBiJLUqk0wBowq7oqgQrqXXhBySK35xgnfzNea?= =?us-ascii?Q?HtJNsOo/lWyZ+xGquMFafXQ76H5QWSVmOBDXGLvaj5cr/aJdpYvhtHqbUoOt?= =?us-ascii?Q?tYzzjPeAPbbFhBYD12e/73VsDOTfexd/aZUfAI1hk8FTRYGsTLyNudDbC6E+?= =?us-ascii?Q?Ee/ysM01XAsE0+rihIwiJA4/QEMnezNNiCVxIoxc0EGJSVUhBYWPaRV9tO7L?= =?us-ascii?Q?NEe7VtavKUtrz/CLM4uJxh/Z0JJaXrnssSfaoLA6/MxGFrUMpy7xrMsyPNF0?= =?us-ascii?Q?RxvNUmcrjr/+5a35AFXOHx40yWLQWBvRqR0EvFssltxS3LuX4Hn+NaMCmcSd?= =?us-ascii?Q?79fgc00hbN62WNablZNhlykYn52MyTGXxsFWYdaRJnL2q2yIJJ+dOdR2/sJH?= =?us-ascii?Q?CKjzJdTRYwWnQYt0xHqtZf8JXahsberd6ic+wuLQNUyRZBQ+4yFaRWUOhplu?= =?us-ascii?Q?qywjsp4VPW63veM/cZ7nxDhe5Oi33jbXFz0NcJcxh7YEZcmwEpT5WqoAvDnd?= =?us-ascii?Q?7jbOasRlD+cmrBDRA1exnmTL8zgmPH3JxQOgy4R41MBs4LibaaUfCkhds0E8?= =?us-ascii?Q?ZQDggiP/1LmD0oTX0q9QuSkxlRdzD3brqvKUCvoqLdQdMlOW4qUdpm1hb/0T?= =?us-ascii?Q?y/6eipEWbeHtlR2Dab6lLof+nNC/AyoPpO63P1QRXT/VMVpTyqE/taHP+cyS?= =?us-ascii?Q?gHPd11ShcnonlC4qgVbsx2o7PAUisYJyGvziaRw8fnIxrykNaVqVh8Bj1rkc?= =?us-ascii?Q?dHPVB+Y6mQRBheNvoNrj6HIyMCyb3rTMIkveg2AIF3bwaWqsDunUnd/xA2n4?= =?us-ascii?Q?GueqkeqW19LLQd4EkvXPLOzl?= X-MS-Exchange-CrossTenant-Network-Message-Id: 26b8d0f1-8f49-4b50-b60c-08d992b3a27b X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 03:50:47.5142 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: k2E3jh+X/20eijGdKghvPcD4iZctpZvOu3l2ndROI5Sj58gQztoncLrq5tNN9IN5Yt/6YiTr3Ew/tU6+392yjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0921 X-OriginatorOrg: hpe.com X-Proofpoint-ORIG-GUID: Lp-6kBmLqELUF_MWjS4o8ta6jGAj4E0P X-Proofpoint-GUID: Lp-6kBmLqELUF_MWjS4o8ta6jGAj4E0P X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,daniel.schaefer@hpe.com X-Gm-Message-State: sf2NCaDNLN9s4o9iwIKrcMPSx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634615456; bh=7o65t3w5e9E3FDank7FlEZl1YITEbDCAt84smU9Q+ac=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=SWcYBE2QPX7wdU1XHBnNkP05Dggna4I5wCDZG4MNyzkeN2uAtk19ZZbFm4Ee8isH/uw X3HbKR/C+GYYJuIZYfW0gmM1ToAJTwND9QW6KVg9zoVTWfzcozpBuTvB6Gnz8yyOHXsgE Tb5hbgtw1pA0c340eC2PddpFM99SUaw0a2I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634615457784100004 Content-Type: text/plain; charset="utf-8" Cc: Daniel Schaefer Cc: Abner Chang Cc: Sunil V L Reviewed-by: Abner Chang Signed-off-by: Daniel Schaefer --- Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc | 1= 2 +- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc | 1= 2 +- Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf | 3= 3 +++++ Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h | 3= 8 +++++- Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c | 12= 8 ++++++++++++++++++++ Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.c | 4= 4 ++++++- Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi | = 2 +- 7 files changed, 256 insertions(+), 13 deletions(-) diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/P= latform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc index 1dc6405a20f0..f14511120e89 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc +++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc @@ -237,12 +237,13 @@ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/R= untimeDxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf -!endif + ResetSystemLib|Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetS= ystemLib.inf UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf +!ifdef $(DEBUG_ON_SERIAL_PORT) + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf +!else + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +!endif !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf !endif @@ -452,6 +453,7 @@ # Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf =20 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U5= 40.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.d= sc index cc62ad05212a..18a482aba611 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc @@ -244,12 +244,13 @@ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/R= untimeDxeReportStatusCodeLib.inf -!ifdef $(DEBUG_ON_SERIAL_PORT) - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf -!else - DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf -!endif + ResetSystemLib|Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetS= ystemLib.inf UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf +!ifdef $(DEBUG_ON_SERIAL_PORT) + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf +!else + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf +!endif !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf !endif @@ -458,6 +459,7 @@ # Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf =20 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { diff --git a/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystem= Lib.inf b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib= .inf new file mode 100644 index 000000000000..f876ae20560b --- /dev/null +++ b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf @@ -0,0 +1,33 @@ +## @file +# Library instance for ResetSystem library class for RISC-V using SBI eca= lls +# +# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D ResetSystemLib + FILE_GUID =3D 3eff6057-1116-4dcb-837e-c0ef1a120ab1 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ResetSystemLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D RISCV64 +# + +[Sources] + ResetSystemLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec + +[LibraryClasses] + DebugLib + RiscVEdk2SbiLib diff --git a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h = b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h index 66a87cb8c38f..88d957f002eb 100644 --- a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h +++ b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h @@ -1,7 +1,7 @@ /** @file Library to call the RISC-V SBI ecalls =20 - Copyright (c) 2020, Hewlett Packard Development LP. All rights reserved.=
+ Copyright (c) 2021, Hewlett Packard Development LP. All rights reserved.=
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -474,6 +474,42 @@ SbiRemoteHfenceVvma ( IN UINTN Size ); =20 +/// +/// Firmware System Reset (SRST) Extension +/// + +/** + Reset the system + + The System Reset Extension provides a function that allow the supervisor + software to request system-level reboot or shutdown. The term "system" r= efers + to the world-view of supervisor software and the underlying SBI + implementation could be machine mode firmware or hypervisor. + + Valid parameters for ResetType and ResetReason are defined in sbi_ecall_= interface.h + + #define SBI_SRST_RESET_TYPE_SHUTDOWN 0x0 + #define SBI_SRST_RESET_TYPE_COLD_REBOOT 0x1 + #define SBI_SRST_RESET_TYPE_WARM_REBOOT 0x2 + + #define SBI_SRST_RESET_REASON_NONE 0x0 + #define SBI_SRST_RESET_REASON_SYSFAIL 0x1 + + When the call is successful, it will not return. + + @param[in] ResetType Typ of reset: Shutdown, cold-, or warm-= reset. + @param[in] ResetReason Why the system resets. No reason or sys= tem failure. + @retval EFI_INVALID_PARAMETER Either ResetType or ResetReason is inva= lid. + @retval EFI_UNSUPPORTED ResetType is valid but not implemented = on the platform. + @retval EFI_DEVICE_ERROR Unknown error. +**/ +EFI_STATUS +EFIAPI +SbiSystemReset ( + IN UINTN ResetType, + IN UINTN ResetReason + ); + /// /// Vendor Specific extension space: Extension Ids 0x09000000 through 0x09= FFFFFF /// diff --git a/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystem= Lib.c b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c new file mode 100644 index 000000000000..67e40151d171 --- /dev/null +++ b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c @@ -0,0 +1,128 @@ +/** @file + Reset System Library functions for RISC-V + + Copyright (c) 2021, Hewlett Packard Development LP. All rights reserved.=
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +/** + This function causes a system-wide reset (cold reset), in which + all circuitry within the system returns to its initial state. This type = of reset + is asynchronous to system operation and operates without regard to + cycle boundaries. + + If this function returns, it means that the system does not support cold= reset. +**/ +VOID +EFIAPI +ResetCold ( + VOID + ) +{ + // Warm Reset via SBI ecall + SbiSystemReset (SBI_SRST_RESET_TYPE_COLD_REBOOT, SBI_SRST_RESET_REASON_N= ONE); +} + +/** + This function causes a system-wide initialization (warm reset), in which= all processors + are set to their initial state. Pending cycles are not corrupted. + + If this function returns, it means that the system does not support warm= reset. +**/ +VOID +EFIAPI +ResetWarm ( + VOID + ) +{ + // Warm Reset via SBI ecall + SbiSystemReset (SBI_SRST_RESET_TYPE_WARM_REBOOT, SBI_SRST_RESET_REASON_N= ONE); +} + +/** + This function causes the system to enter a power state equivalent + to the ACPI G2/S5 or G3 states. + + If this function returns, it means that the system does not support shut= down reset. +**/ +VOID +EFIAPI +ResetShutdown ( + VOID + ) +{ + // Shut down via SBI ecall + SbiSystemReset (SBI_SRST_RESET_TYPE_SHUTDOWN, SBI_SRST_RESET_REASON_NONE= ); +} + +/** + This function causes a systemwide reset. The exact type of the reset is + defined by the EFI_GUID that follows the Null-terminated Unicode string = passed + into ResetData. If the platform does not recognize the EFI_GUID in Reset= Data + the platform must pick a supported reset type to perform. The platform m= ay + optionally log the parameters from any non-normal reset that occurs. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData The data buffer starts with a Null-terminated str= ing, + followed by the EFI_GUID. +**/ +VOID +EFIAPI +ResetPlatformSpecific ( + IN UINTN DataSize, + IN VOID *ResetData + ) +{ + // + // Can map to OpenSBI vendor or platform specific reset type. + // + return; +} + +/** + The ResetSystem function resets the entire platform. + + @param[in] ResetType The type of reset to perform. + @param[in] ResetStatus The status code for the reset. + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm,= or EfiResetShutdown + the data buffer starts with a Null-terminated = string, optionally + followed by additional binary data. The string= is a description + that the caller may use to further indicate th= e reason for the + system reset. +**/ +VOID +EFIAPI +ResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL + ) +{ + switch (ResetType) { + case EfiResetWarm: + ResetWarm (); + break; + + case EfiResetCold: + ResetCold (); + break; + + case EfiResetShutdown: + ResetShutdown (); + return; + + case EfiResetPlatformSpecific: + ResetPlatformSpecific (DataSize, ResetData); + return; + + default: + return; + } +} diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2S= biLib.c b/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiL= ib.c index 9bbeaaec3f7a..319526ed8f9f 100644 --- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.c +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.c @@ -15,7 +15,7 @@ - SbiLegacyRemoteSfenceVmaAsid -> Use SbiRemoteSfenceVmaAsid - SbiLegacyShutdown -> Wait for new System Reset extension =20 - Copyright (c) 2020, Hewlett Packard Development LP. All rights reserved.=
+ Copyright (c) 2021, Hewlett Packard Development LP. All rights reserved.=
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @par Revision Reference: @@ -715,6 +715,48 @@ SbiRemoteHFenceVvma ( return TranslateError (Ret.Error); } =20 +/** + Reset the system + + The System Reset Extension provides a function that allow the supervisor + software to request system-level reboot or shutdown. The term "system" r= efers + to the world-view of supervisor software and the underlying SBI + implementation could be machine mode firmware or hypervisor. + + Valid parameters for ResetType and ResetReason are defined in sbi_ecall_= interface.h + + #define SBI_SRST_RESET_TYPE_SHUTDOWN 0x0 + #define SBI_SRST_RESET_TYPE_COLD_REBOOT 0x1 + #define SBI_SRST_RESET_TYPE_WARM_REBOOT 0x2 + + #define SBI_SRST_RESET_REASON_NONE 0x0 + #define SBI_SRST_RESET_REASON_SYSFAIL 0x1 + + When the call is successful, it will not return. + + @param[in] ResetType Typ of reset: Shutdown, cold-, or warm-= reset. + @param[in] ResetReason Why the system resets. No reason or sys= tem failure. + @retval EFI_INVALID_PARAMETER Either ResetType or ResetReason is inva= lid. + @retval EFI_UNSUPPORTED ResetType is valid but not implemented = on the platform. + @retval EFI_DEVICE_ERROR Unknown error. +**/ +EFI_STATUS +EFIAPI +SbiSystemReset ( + IN UINTN ResetType, + IN UINTN ResetReason + ) +{ + SbiRet Ret =3D SbiCall ( + SBI_EXT_SRST, + SBI_EXT_SRST_RESET, + 2, + ResetType, + ResetReason + ); + return TranslateError (Ret.Error); +} + // // SBI interface function for the vendor extension // diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi b/= Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi index a731c7e36988..937caee08331 160000 --- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi @@ -1 +1 @@ -Subproject commit a731c7e36988c3308e1978ecde491f2f6182d490 +Subproject commit 937caee0833115f69d697ca190001ba0aa5c7368 --=20 2.31.1 -=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 (#82282): https://edk2.groups.io/g/devel/message/82282 Mute This Topic: https://groups.io/mt/86432336/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-