From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.57164.1675699347852501842 for ; Mon, 06 Feb 2023 08:02:27 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=n3OXhU6g; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: andrei.warkentin@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675699347; x=1707235347; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=I1t5oMhYQUd7v408sB8/qGw6aIpWuoaaBoYQEZHthtM=; b=n3OXhU6gwtEgsROXUKPIoSzVfavK8v0irVLywYeTxXKQ4nyBfYCB6w2P VltLh1w3P4MDIDuS/abudCZ+GSvMHY5L3cZuXgyNGuT4fiuwIpibBlrmn bNqZDOQsW+9KRymbYZ93hvgOjBDY00bcOiWnfct95F/P0zJOHvAhsCYBw B3aZzZgnRZVZ3Az+D0BJGOYb6tIm8CRvJzz1PcCHgISQXA+4t2yE7Yusg qQqvPIhGSdJgFXjb2WS7nMFwxapEQNO2pJnUrhxYUVZbsw5MCzsjikD5O uvLUce9Y3VDItgBq0N/xPApsdGkcZotsAtbeFAzmTmlA27C48vLTeAXJl w==; X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="308883209" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="308883209" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2023 08:02:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="840399434" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="840399434" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga005.jf.intel.com with ESMTP; 06 Feb 2023 08:02:02 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 6 Feb 2023 08:02:01 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Mon, 6 Feb 2023 08:02:01 -0800 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.44) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Mon, 6 Feb 2023 08:02:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BXPsNMXYvFtwJWBplk6vTDL+8kxYYffRHdlgSTzfHHKuDsj4P+VWwOJc4OOZmE+OjM59k9lXGYgFX4a0sJOzXE0DSVjb8XLAOtEes9eH8sAMtt87ZWKMkvBLS0ewdo+OQNdldV3wnuqHOI2n3iOd9RjFjcuno0PLaiQLiTtDXxA22NVYgrBUybCAgjcf6j6jwQ5fTGKt0QeMrpT1rrpcHk3L56YYuqgSrmWXcvkA2IrJLyC/yiAQ71HTXzmYId00pXk8+iezHNMhbY+MSDMqXR9PepCcBkwTeCNGl06SrfVCjJBsbvxGFfq2hzn9Mi+4ERYwX2C2kL8LsoL+9VoLnw== 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=V5klS50FqXpnbU/T9Qm8dnn/G1hFmTz2Rx2v80zHjEo=; b=SOeRAWFcuwMKS4P9T6qNqrU3IqhtOQn+WsoV2gR9oUBzTmgd06lc6i/aUyhxW1ggpOSIfZdjWdooSNg1jwZc8C5uR77Sg6gteHJ6OpN3kkZtytmqfBNu96lMz72jNRT8mmkUD+52SeAALYfylmLhFF3a0V1vO5mn8Y6OWZq2iQBRgz+4qqtACva7HuyZOU9sGCH7kthdJkLzAKDH01y+OgTZg49E3nCJjQUwMYkuNecBoynkqlmfpcbRGLOTttNDcyBfw1uZ+sBMBVt6WhE+SPzNHCrBrTOalSkBEcBKYfvUG7aBy1Otjm+7hLRZbP3tsNwhOXg/MvIosR/OaJz3Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH8PR11MB6856.namprd11.prod.outlook.com (2603:10b6:510:22b::7) by CH3PR11MB7938.namprd11.prod.outlook.com (2603:10b6:610:12f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 16:01:59 +0000 Received: from PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::9dba:633a:320c:87b]) by PH8PR11MB6856.namprd11.prod.outlook.com ([fe80::9dba:633a:320c:87b%5]) with mapi id 15.20.6064.032; Mon, 6 Feb 2023 16:01:59 +0000 From: "Andrei Warkentin" To: "devel@edk2.groups.io" , "sunilvl@ventanamicro.com" CC: Ard Biesheuvel , "Yao, Jiewen" , "Justen, Jordan L" , "Gerd Hoffmann" , Abner Chang Subject: Re: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V7 15/20] OvmfPkg/RiscVVirt: Add ResetSystemLib library Thread-Topic: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V7 15/20] OvmfPkg/RiscVVirt: Add ResetSystemLib library Thread-Index: AQHZM01pIRZAFMwqj0O6DuSDGizydK7CIhFQ Date: Mon, 6 Feb 2023 16:01:59 +0000 Message-ID: References: <20230128191807.2080547-1-sunilvl@ventanamicro.com> <20230128191807.2080547-16-sunilvl@ventanamicro.com> In-Reply-To: <20230128191807.2080547-16-sunilvl@ventanamicro.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH8PR11MB6856:EE_|CH3PR11MB7938:EE_ x-ms-office365-filtering-correlation-id: 1bec15a4-c9c1-4f02-c02d-08db085b7a73 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ep/wPLm8x++ZMplzJmdXlMsa8VyvyEyxN6VEnq9dLYndUhGqOkmuT60FCyvOC6oNMmGKr8CqLtubGOL4xe5Vr7RaDKlQLY4wVCuJaeVHQupPn0tUJj16vNGsbgq+YuDEdKeRjFi1fitRELp+RRg/Z70Vexr6aNCb91UyhCqZYCLyIkhC1XO3EUgTIN+u51N9bvU0et0jYX3ERiJkl7QUy19Xvm9xy+2WqlCkg9K7iSyDybhR3kkyDlaqrhNzwt7Fa6QOlG9tnB5EO70O5TWQjex+OqM6uJpE9TgbJIhRgQAcwncQUkXJAHTl/KUHWo9LU7IGwinMppl2QQIGRczSXUv6xcIV3Z2byAWHkX1eT7jfisSpbf1fX+48wQOeLc7JS/APJ1zzKF+grNB0tPbw/2URICiQKWm6DNptCxpGboCheZ+6V5qQJv6oAhrBC6EHDY990VvK/ILNPRZqRVxgBNVX6htvPM5ORrt1qfl88FYnXrg56BQTJ6MFaPFG/JZat8QB7ZLYrfPb32jqKevEKJOdXcvNJnwPh9EAO8fD9ebprDQQpV7Fi/AW6YVWVt94nHVWVfhCumu3aU0wDOnrnL9KDpumhbMA21p/m3p0j6TQrNgh2O9RZq5Pg1Lt3I+Qe2lumJOJqOiraC7/0aAVkzi3ARKz11dsC2MMPNQ5/7khhnzXpoh33aZfzUwJI+fKVSoZfQm8uFtSacu4TyyWf5zADazJlMgDsaMYaz7LC3TAm37sTjU5MjDWL2GR/Inve395Xu0B+eF8xi40JLE9gQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH8PR11MB6856.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(366004)(346002)(136003)(39860400002)(396003)(376002)(451199018)(66899018)(478600001)(52536014)(33656002)(86362001)(8936002)(41300700001)(66556008)(66446008)(64756008)(76116006)(66476007)(8676002)(66946007)(5660300002)(4326008)(2906002)(82960400001)(38100700002)(38070700005)(122000001)(316002)(7696005)(71200400001)(966005)(53546011)(54906003)(55016003)(110136005)(6506007)(186003)(9686003)(26005)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?pYa2pnqeBhoWSXV0R/F/gGsoswcZ20eR3+Lti4BWdrzKYzsVYoMkhNOodGBZ?= =?us-ascii?Q?LBmMb1fMSStCAJyjdg+YlG47QzqRxT7yJNefIqlzhFZlFZXxaIdMsaXCke2H?= =?us-ascii?Q?6V+OsDfoO0dve7GuRfV1HMTYhRRFzMZYsfohIvvs1rUhhY5+cNAE6513Z7Dy?= =?us-ascii?Q?zrlVRUfDMWjPCa/glDO7hcdWH97dONsqTkz3Z5v1zqCd9oZs5C0ORlfIUWD7?= =?us-ascii?Q?lBg4Peiwhfnv2sQeGLkSb8EtHb0fheyqyY92tdh3quZ5rD2Gbd1+NgHhl4DR?= =?us-ascii?Q?AGB9GOhVcZ0r4iDleFMH9VGSEzGUjJ/hug/XnHx8TqNMHAC8cnofZS2+tFWw?= =?us-ascii?Q?eEBHVhkqh03i5jHrcaNm3sr+WvJdCaXBiBNvTbBbx0XOUEanb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oedYI5iXr2jhTZmvYGJMRpHGMXynBKziViKTUuVzmreDW+oy6XsPByo8CIvL?= =?us-ascii?Q?GMH0OrrV9dpYijK6TZRXTGPrncuak+tB8SG4kM1ZvPRUSXU0g3ePjc0G6jwy?= =?us-ascii?Q?xocmYlyNmyOUVplsP/oRPkIqYkLRSx4ANv8ml/+m//5CqevXGKURCf2ooSnJ?= =?us-ascii?Q?rzugu+pGEphafyPemYoNhF1xV7SQ4mgnQ+8bs/LEDwr7M4h2agDkf5XHYcqf?= =?us-ascii?Q?sSiRnr6NF0ABO2spXxJOpR8TXHu4FdAo8kK23+jNUXBgbwOxnPyRIXluwKoG?= =?us-ascii?Q?JwDgeazFedkNH6cOU9AvYNSvKKllL6OsTF0soMHDMWiGZYtASFrJne6EJk+b?= =?us-ascii?Q?Fw=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH8PR11MB6856.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bec15a4-c9c1-4f02-c02d-08db085b7a73 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Feb 2023 16:01:59.1884 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: P4R9NGkb0LG88WO0NPUnBODFL7vEx8lOa1d4EQKz6yDHw3oHWm49rPH0KVJ4r1ZdvWWsB70STIXiTN8KosZmiB3rqeFhcjAS3eCL9BAljmw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB7938 Return-Path: andrei.warkentin@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Andrei Warkentin -----Original Message----- From: devel@edk2.groups.io On Behalf Of Sunil V L Sent: Saturday, January 28, 2023 1:18 PM To: devel@edk2.groups.io Cc: Ard Biesheuvel ; Yao, Jiewen ; Justen, Jordan L ; Gerd Hoffmann ; Abner Chang Subject: [edk2-devel] [edk2-staging/RiscV64QemuVirt PATCH V7 15/20] OvmfPkg= /RiscVVirt: Add ResetSystemLib library RISC-V Qemu virt uses SBI calls to implement the reset. Add the base class library. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Signed-off-by: Sunil V L Acked-by: Abner Chang --- OvmfPkg/RiscVVirt/Library/ResetSystemLib/BaseResetSystemLib.inf | 38 ++++= ++ OvmfPkg/RiscVVirt/Library/ResetSystemLib/ResetSystemLib.c | 128 ++++= ++++++++++++++++ 2 files changed, 166 insertions(+) diff --git a/OvmfPkg/RiscVVirt/Library/ResetSystemLib/BaseResetSystemLib.in= f b/OvmfPkg/RiscVVirt/Library/ResetSystemLib/BaseResetSystemLib.inf new file mode 100644 index 000000000000..c3fa6bd99b52 --- /dev/null +++ b/OvmfPkg/RiscVVirt/Library/ResetSystemLib/BaseResetSystemLib.inf @@ -0,0 +1,38 @@ +## @file +# Base library instance for ResetSystem library class for RISC-V # # =20 +Copyright (c) 2022, Ventana Micro Systems Inc. All rights reserved.
=20 +# # SPDX-License-Identifier: BSD-2-Clause-Patent # ## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D BaseResetSystemLib + FILE_GUID =3D AB45A200-769D-4C10-B0D6-5E1FF5EEBF31 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ResetSystemLib + +# +# The following information is for reference only and not required by=20 +the build # tools. +# +# VALID_ARCHITECTURES =3D RISCV64 +# + +[Sources] + ResetSystemLib.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + IoLib + TimerLib + RiscVSbiLib diff --git a/OvmfPkg/RiscVVirt/Library/ResetSystemLib/ResetSystemLib.c b/Ov= mfPkg/RiscVVirt/Library/ResetSystemLib/ResetSystemLib.c new file mode 100644 index 000000000000..14f7653aa8de --- /dev/null +++ b/OvmfPkg/RiscVVirt/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=20 + 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=20 +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,=20 +SBI_SRST_RESET_REASON_NONE); } + +/** + This function causes a system-wide initialization (warm reset), in=20 +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,=20 +SBI_SRST_RESET_REASON_NONE); } + +/** + 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,=20 +SBI_SRST_RESET_REASON_NONE); } + +/** + This function causes a systemwide reset. The exact type of the reset=20 +is + defined by the EFI_GUID that follows the Null-terminated Unicode=20 +string passed + into ResetData. If the platform does not recognize the EFI_GUID in=20 +ResetData + the platform must pick a supported reset type to perform. The=20 +platform may + 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; + } +} -- 2.38.0