From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web11.10874.1633521573714810941 for ; Wed, 06 Oct 2021 04:59:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Br/KnxkA; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0913d10296=daniel.schaefer@hpe.com) Received: from pps.filterd (m0134425.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1969tIVB018186; Wed, 6 Oct 2021 11:59:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=pps0720; bh=kX074/u2vlVu5a/16VyR3mYWHH1OTJ8mtNEdxQMFp9g=; b=Br/KnxkAzXIV2V691EYqm1npuoO117D0SAxdHYnQyNLl7qU2h4xc+pnzAf/1h902Da5n zWsz6oRq6il+82j8ICsyXIFYdYf7q57sbNnkLMNubVASt6LGh7uyPFSX4bT+ihJON9sI xZt1wUIAPcCHIkxucGebZCK7TFSCshhVQcvxbli+XkIqicl65K7I5GAAqm0uBQQ5S9qT bEe56S7HEnOiFaVDr8EfVKkcnFRjjJcFwrm6SfcVAGkAfMw74Z6JeXW1tyaHFEYOQOup q5Qkd6x4uvQIVFz1IyPGp8qPoewAmm0UW08B/FCnAV3kIpY0OlQChwZmvDbMMXz3bBbv Cg== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 3bgwqgx9gs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Oct 2021 11:59:32 +0000 Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id F36B5B0; Wed, 6 Oct 2021 11:59:31 +0000 (UTC) Received: from G9W8673.americas.hpqcorp.net (16.220.49.32) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 6 Oct 2021 11:59:31 +0000 Received: from G1W8106.americas.hpqcorp.net (16.193.72.61) by G9W8673.americas.hpqcorp.net (16.220.49.32) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 6 Oct 2021 11:59:31 +0000 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (15.241.52.11) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Wed, 6 Oct 2021 11:59:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VnqTqoPdqF8z9V+wsK0JnQWULzZpzIOUYrJBe4lc1sqlTQhrvWoyL1kE9V4tfEKI5FE17WC2eC3ntvBw7cAGHTVGefJA6RmD6S/+LrSk8QMdR28SmyCuphBkFByoDhmrhUZuMlUxOAOll02XgieaV30+N0C8cwdqyqcH9uUL8syEF5pc7bEao/sCdfQfuAzfyKaLnP25QMGOiICL445AsEhjS78Vhij5ADe1qEVb2j4gxh5F9bySP5edmdDO4rxPuUpMAcZdoCLkMcOFwAhN/jROenZntyFSJ23XwYm+UfwaaylZ2uzkP/AAcqp65DCDHCBp7QUCCfwVB+Cocbms3w== 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=kX074/u2vlVu5a/16VyR3mYWHH1OTJ8mtNEdxQMFp9g=; b=A8ceAy2zarXnrT0UWH/YUz0KIZ+u+WF3DUN2XDGzNIBcfAe4HnhR5cGigBddkb6+sniyqqlzzna1sjRFYiJLS/OPQGO1I8uFuOuwaCW7pJt/Q2rqPIVihHk8jJLqEsoG7U4ND312MwxBRmffGr51DqK1HuDXctXzJ9JpDhzYhyL4ebJ7XV3x0vl/D2m6DB3hc1N+S8/mJkG+SFbgV7tHSarnmOkAbmIpJ1VWGeoRmoThQwctmotOGyT5tjguADZB2ZrsHVJW82OiMyosn9lDSODcVmDPPF9z3v+iDi4BamCvjh+Ay45p8sTIj5L7suBBFIVl+k/F7aJfRdgAsAYJPg== 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 Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) by DF4PR8401MB1034.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7613::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Wed, 6 Oct 2021 11:59:28 +0000 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.4566.023; Wed, 6 Oct 2021 11:59:28 +0000 From: "Daniel Schaefer" To: CC: Abner Chang , Sunil V L Subject: [edk2-platforms][PATCH v2 13/14] RISC-V: Implement ResetSystem RT call Date: Wed, 6 Oct 2021 19:58:35 +0800 Message-ID: <20211006115836.3641776-6-daniel.schaefer@hpe.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211006115836.3641776-1-daniel.schaefer@hpe.com> References: <20211006115836.3641776-1-daniel.schaefer@hpe.com> X-ClientProxiedBy: HK2PR02CA0159.apcprd02.prod.outlook.com (2603:1096:201:1f::19) To DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) MIME-Version: 1.0 Received: from localhost.localdomain (123.193.59.220) by HK2PR02CA0159.apcprd02.prod.outlook.com (2603:1096:201:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Wed, 6 Oct 2021 11:59:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 873abc15-1a46-484b-ccb2-08d988c0bfc0 X-MS-TrafficTypeDiagnostic: DF4PR8401MB1034: 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: BCL:0; X-Microsoft-Antispam-Message-Info: 8Pz+9yoRG4h3xAgSqPJ5Ixgtmi0xyz1MeJf/EMuTxxw0lVOV3u4CpxFaMi+gMDw7F26SDJySX9QqAKViXo2kG1wCLRlmXDYB3t+yO/nRfAFWPlOrLU79sNpXcyy2hCmIbs+00qNgjc9oXOzHSQ4WTzSfQHpK8bWNxzJ5sPj1w4hzepe/2ExZwjAPzxkNtnGyxHK0fWhHJkFnqV2JBbBrUqJVtEv3oM20+K25q0GYYOCqQA3HqM4y4j5Qu/lIkpJjXzJD4wfB2nrRTvzxg13C2vuvFaaIQTSNlpg/UOQ38yg02BnBp2ImaJEt7OiJm74o3oxBtffPWE0w9xMVBjn9emeZSES5GcOnPa+YfWuemg0gnfeeEnHKvvtR91UNLuNQ4VAB3n9j0eewc5V450/OXzJhxg1xsIQ6yN0Zj9bKxcuB4+Ze782Lyu19/o9pXyFbWnP/mkDDOfaI2LD0tRl73Lrl/ngwk9xxp2JgOr+6CkB1rKHK3XngTOSLHOo42ppI3HgG6cXnosAzg8PinlRk9hZTrpeBE+uwfhaIzWHP083oOUEy87gwh+7Ccq+XtVEDgKiBdt0iuzsdF1hvepebaSLa4eG7l9ywCCbkVUW+BkPQv67J1KlIaI0yZQ96XywVMdpBDCaImh7Hv3a4xiHsRXj0/F6JkCVt12hyVNsQ48eNlQte6H4pbSSytEzGFedn8Qmmj50XUwVF8DGBzf+M3Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(366004)(186003)(6506007)(956004)(316002)(26005)(52116002)(6916009)(8676002)(8936002)(5660300002)(6486002)(508600001)(83380400001)(30864003)(6666004)(66556008)(66476007)(38350700002)(6512007)(38100700002)(86362001)(36756003)(4326008)(2906002)(54906003)(2616005)(1076003)(66946007)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7HY9JWFR2SDVVAlB8H3wpAvAo4+F1oLcB0qcN2yXlR9kQRxXPYNqumzTLBfd?= =?us-ascii?Q?LnS1lS7hP5Z0kXJ4rvqEeDbozi+tWxuXttCg9NaP0LUVZWhdiggukNZc7Omt?= =?us-ascii?Q?ibH7ZXNo/2JsUwD5uaJFSTW2UTm760n5ZlfjH1kOUK+czMsQ3E3NQMzyMWPL?= =?us-ascii?Q?JBnsHSIqmMNtB5LJQeJKTPZ7GSki1Yt2fcrE/2tLp9gNu4sqza8ywoaovP3U?= =?us-ascii?Q?gpBzaAaFyNMGw8EJQFJYUlHK6qCJ3zOn1xSGnGeK5+iSM4Iduu/ZDIFuOAO7?= =?us-ascii?Q?eZEz3ojRpM01AqwACR0251fAtb2GtHUWabQ5+Pe6oxwX4vnOkheXpsd5oanP?= =?us-ascii?Q?YOVEXewEnkHsjfjvv32eGjZkRNhT+f0YF0OeXBRahWoHCPoDG3S9PVfSXk/9?= =?us-ascii?Q?pULT0uURLZqBlGYhLpH6wS7psGsHZiYjMdys8SckSYCfa5qjWos9yOWgfPdc?= =?us-ascii?Q?fI3zrHsAegs8cCCB1xIC7HUCGqEsfNhZKvXR3xu55SHQmTkywiKfa+xLVrcn?= =?us-ascii?Q?bzfZ8odhkCF2U7DkXODp9AF2KKTKeE62WsFtDxje7WCllotyQSO5+Lbqk06Z?= =?us-ascii?Q?DWpXUp1130t3ZCII+BkowdvQSjaMw7sXGrJy4MdrTECkmUj5TjdyHsu7SyIL?= =?us-ascii?Q?WFrN9S+yutTvhtJm2m3bECewE/PVEtGEq78olu2SbElx/MmXvV9IaOAR0jI8?= =?us-ascii?Q?ClzPUSswK2VlR4XO0zxGNXBGuj4xJctq/ViZVCXTtHtuxK1yZqPu/5njLgYM?= =?us-ascii?Q?TYSlgSC5ZRoYSzwQreS8JHE0RJCqHCWcTFNxlLZEPEgrTOLLqS7tDQ+4JPmf?= =?us-ascii?Q?136pQsWY4BWEUWFNWAL7JTKN9FKcKmkKMRwDMQGoHVAk4XZH9RQ8vsMVWv6V?= =?us-ascii?Q?+1dEWvaZVHK2QbIZs3sU/hLl+5DokA2vbQ8OOIB6pHg1QiSKdy5wl46H169g?= =?us-ascii?Q?lniYRd4vSJGJXWVQpvJpXyvSioVtSOwazIoODXKxYWy7r2yAb3IOQx1tqNWN?= =?us-ascii?Q?Awf7Rx5IO7pXgF2G9I5yklYRE8kBrxmbYFBJP7dRUypoZcTn3xDfLxV+HRIQ?= =?us-ascii?Q?9pH+aFOs/tTXcxW7/DxZaH3sB5LXAj0Ur7Lymc7A+e84ePCdzTjrnuFgg02x?= =?us-ascii?Q?2aCDry52Dd6XXV00MzqHsr/QKrEOFpQGDyGydBpW/GSXHI0rPOy3sj5wxmj6?= =?us-ascii?Q?MJVqe2H15eCZyZ+ji53huWFbwz+vBuEoS2tB5hqiSdZ9U22CliwiBXCOSimk?= =?us-ascii?Q?YEIDuDcr/gJ1M7pTDMXV/8RzJGJEDBn17uq6O6fn68w1uxGEtA4tsZoMy+z0?= =?us-ascii?Q?bPXVkt4BvU/IFj63zrEu/4f3?= X-MS-Exchange-CrossTenant-Network-Message-Id: 873abc15-1a46-484b-ccb2-08d988c0bfc0 X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 11:59:28.3467 (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: dLOIzDhWbzGrPaGM2PQMcsrnt9bLIg1ZRxi6lPXiPc/6SI2tBk9bxygegrzBSteSixBNSm5GVzv0GzgmyIvC0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB1034 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: vxp4pgWrFjOnUeioXNRYOeK-cP5khnyr X-Proofpoint-ORIG-GUID: vxp4pgWrFjOnUeioXNRYOeK-cP5khnyr X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-06_02,2021-10-06_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110060075 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Cc: Daniel Schaefer Cc: Abner Chang Cc: Sunil V L Signed-off-by: Daniel Schaefer --- Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c | 12= 8 ++++++++++++++++++++ Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf | 3= 3 +++++ Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc | 1= 2 +- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc | 1= 2 +- Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h | 3= 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/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystem= Lib.c b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c new file mode 100644 index 0000000000..646073c106 --- /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/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystem= Lib.inf b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib= .inf new file mode 100644 index 0000000000..33db9fb6d8 --- /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/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/P= latform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc index 1dc6405a20..f14511120e 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= =0D MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf=0D ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/R= untimeDxeReportStatusCodeLib.inf=0D -!ifdef $(DEBUG_ON_SERIAL_PORT)=0D - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in= f=0D -!else=0D - DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf=0D -!endif=0D + ResetSystemLib|Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetS= ystemLib.inf=0D UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf=0D +!ifdef $(DEBUG_ON_SERIAL_PORT)=0D + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in= f=0D +!else=0D + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf=0D +!endif=0D !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE=0D BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf=0D !endif=0D @@ -452,6 +453,7 @@ #=0D Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf=0D Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf=0D + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf=0D =0D MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf=0D MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U5= 40.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.d= sc index cc62ad0521..18a482aba6 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= =0D MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf=0D ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/R= untimeDxeReportStatusCodeLib.inf=0D -!ifdef $(DEBUG_ON_SERIAL_PORT)=0D - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in= f=0D -!else=0D - DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf=0D -!endif=0D + ResetSystemLib|Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetS= ystemLib.inf=0D UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf=0D +!ifdef $(DEBUG_ON_SERIAL_PORT)=0D + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in= f=0D +!else=0D + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf=0D +!endif=0D !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE=0D BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf=0D !endif=0D @@ -458,6 +459,7 @@ #=0D Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf=0D Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf=0D + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf=0D =0D MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf=0D MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h = b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h index 66a87cb8c3..88d957f002 100644 --- a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h +++ b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h @@ -1,7 +1,7 @@ /** @file=0D Library to call the RISC-V SBI ecalls=0D =0D - Copyright (c) 2020, Hewlett Packard Development LP. All rights reserved.=
=0D + Copyright (c) 2021, Hewlett Packard Development LP. All rights reserved.=
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -474,6 +474,42 @@ SbiRemoteHfenceVvma ( IN UINTN Size=0D );=0D =0D +///=0D +/// Firmware System Reset (SRST) Extension=0D +///=0D +=0D +/**=0D + Reset the system=0D +=0D + The System Reset Extension provides a function that allow the supervisor= =0D + software to request system-level reboot or shutdown. The term "system" r= efers=0D + to the world-view of supervisor software and the underlying SBI=0D + implementation could be machine mode firmware or hypervisor.=0D +=0D + Valid parameters for ResetType and ResetReason are defined in sbi_ecall_= interface.h=0D +=0D + #define SBI_SRST_RESET_TYPE_SHUTDOWN 0x0=0D + #define SBI_SRST_RESET_TYPE_COLD_REBOOT 0x1=0D + #define SBI_SRST_RESET_TYPE_WARM_REBOOT 0x2=0D +=0D + #define SBI_SRST_RESET_REASON_NONE 0x0=0D + #define SBI_SRST_RESET_REASON_SYSFAIL 0x1=0D +=0D + When the call is successful, it will not return.=0D +=0D + @param[in] ResetType Typ of reset: Shutdown, cold-, or warm-= reset.=0D + @param[in] ResetReason Why the system resets. No reason or sys= tem failure.=0D + @retval EFI_INVALID_PARAMETER Either ResetType or ResetReason is inva= lid.=0D + @retval EFI_UNSUPPORTED ResetType is valid but not implemented = on the platform.=0D + @retval EFI_DEVICE_ERROR Unknown error.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SbiSystemReset (=0D + IN UINTN ResetType,=0D + IN UINTN ResetReason=0D + );=0D +=0D ///=0D /// Vendor Specific extension space: Extension Ids 0x09000000 through 0x09= FFFFFF=0D ///=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2S= biLib.c b/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiL= ib.c index 9bbeaaec3f..319526ed8f 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=0D - SbiLegacyShutdown -> Wait for new System Reset extension=0D =0D - Copyright (c) 2020, Hewlett Packard Development LP. All rights reserved.=
=0D + Copyright (c) 2021, Hewlett Packard Development LP. All rights reserved.=
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @par Revision Reference:=0D @@ -715,6 +715,48 @@ SbiRemoteHFenceVvma ( return TranslateError (Ret.Error);=0D }=0D =0D +/**=0D + Reset the system=0D +=0D + The System Reset Extension provides a function that allow the supervisor= =0D + software to request system-level reboot or shutdown. The term "system" r= efers=0D + to the world-view of supervisor software and the underlying SBI=0D + implementation could be machine mode firmware or hypervisor.=0D +=0D + Valid parameters for ResetType and ResetReason are defined in sbi_ecall_= interface.h=0D +=0D + #define SBI_SRST_RESET_TYPE_SHUTDOWN 0x0=0D + #define SBI_SRST_RESET_TYPE_COLD_REBOOT 0x1=0D + #define SBI_SRST_RESET_TYPE_WARM_REBOOT 0x2=0D +=0D + #define SBI_SRST_RESET_REASON_NONE 0x0=0D + #define SBI_SRST_RESET_REASON_SYSFAIL 0x1=0D +=0D + When the call is successful, it will not return.=0D +=0D + @param[in] ResetType Typ of reset: Shutdown, cold-, or warm-= reset.=0D + @param[in] ResetReason Why the system resets. No reason or sys= tem failure.=0D + @retval EFI_INVALID_PARAMETER Either ResetType or ResetReason is inva= lid.=0D + @retval EFI_UNSUPPORTED ResetType is valid but not implemented = on the platform.=0D + @retval EFI_DEVICE_ERROR Unknown error.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SbiSystemReset (=0D + IN UINTN ResetType,=0D + IN UINTN ResetReason=0D + )=0D +{=0D + SbiRet Ret =3D SbiCall (=0D + SBI_EXT_SRST,=0D + SBI_EXT_SRST_RESET,=0D + 2,=0D + ResetType,=0D + ResetReason=0D + );=0D + return TranslateError (Ret.Error);=0D +}=0D +=0D //=0D // SBI interface function for the vendor extension=0D //=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi b/= Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi index a731c7e369..937caee083 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.33.0