From nobody Fri May 3 08:05:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60464+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60464+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 web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1590772022582406.5843939482713; Fri, 29 May 2020 10:07:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OmBzYY1788612xYqn9vvogla; Fri, 29 May 2020 10:07:02 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web11.1204.1590772021642188227 for ; Fri, 29 May 2020 10:07:01 -0700 X-Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04TH6M4o030535; Fri, 29 May 2020 17:07:00 GMT X-Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com with ESMTP id 31agx9udex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 May 2020 17:07:00 +0000 X-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 g2t2353.austin.hpe.com (Postfix) with ESMTPS id 05A359F; Fri, 29 May 2020 17:07:00 +0000 (UTC) X-Received: from G2W6311.americas.hpqcorp.net (2002:10c5:4035::10c5:4035) by G1W8106.americas.hpqcorp.net (2002:10c1:483d::10c1:483d) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 29 May 2020 17:06:36 +0000 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (15.241.52.12) by G2W6311.americas.hpqcorp.net (16.197.64.53) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 29 May 2020 17:06:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OJm3Vnxb9EJwKN+IA41nfxwwEYq/VIUSo/TLNTxAEWc44WU5uVu0xdjz9c9jLS/dUGYtswAFSW6c4AGXE+RQ8BqUwIav10TIoNrc1/FNEU9SW68FJEGfc9Fb/i5L3ScoKLmMISnb6tnMJEF5lysRoZbo7sXyjb4UEFsQEBik4iAeqEDpyIqXE49BcUI5fxcPm+XBVNqvbUJBQNElHtf7NyT3M+7UjD37+KFT/XtsAtX4vOBly55/3AIiSSvgFflQrMOWPSjhG62j8NbS+FFWb3sNZGPNnWpGBfRnDdtREc0I6FJYcfchevsIx2teufeM0GlYo7vPRlcmiA8tvXJUQg== 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=aPoWOT9P5n1yIdfs4K+BhWQjsQKzYsfC6SYphEywNgw=; b=NwrLLUPtDTIRhGEedrh/+/lby2b5wydcKoSZa80YGNMkVqFSPcPhRqIfn9fPtPjHPg7zcTJ8oVuAHzCCUYE4g77n4SRg7gRcDbHQlVvfiWb/99A9MM+IvnTDBsJTSkn5U0mxx/R3qCdvPHN2vErpj8HSr9SOQnaTtbTXqnpUH45fnx0u6T9SRNyMPeFzGwaM93eYFGwfxfL49DBVgQiWXsgb3VwRksxty3nTlqHTvcT2n5Gyi00WPRSmFBMy0O+MFEsbUHxUE1DnmkxQAYEcZjceSFNWiOJNg9Vt5W/bFYoc4uRoBJOrEiGyzMhdJ5x8c8If01h5Hy7OxYcFQCDwKg== 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 DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::10) by DF4PR8401MB0441.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19; Fri, 29 May 2020 17:06:35 +0000 X-Received: from DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c4c5:a5a7:6deb:da30]) by DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c4c5:a5a7:6deb:da30%9]) with mapi id 15.20.3021.030; Fri, 29 May 2020 17:06:35 +0000 From: "Daniel Schaefer" To: CC: Leif Lindholm , Abner Chang , Gilbert Chen , Michael D Kinney Subject: [edk2-devel] [PATCH v3 1/3] ProcessorPkg/RiscVOpensbLib: Add opensbi submodule Date: Fri, 29 May 2020 19:06:20 +0200 Message-ID: <20200529170622.32610-2-daniel.schaefer@hpe.com> In-Reply-To: <20200529170622.32610-1-daniel.schaefer@hpe.com> References: <20200529170622.32610-1-daniel.schaefer@hpe.com> X-ClientProxiedBy: AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) To DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::10) X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from x360-nix.fritz.box (93.215.216.32) by AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Fri, 29 May 2020 17:06:33 +0000 X-Originating-IP: [93.215.216.32] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5c6504fe-1cb3-4c4f-d475-08d803f2a48e X-MS-TrafficTypeDiagnostic: DF4PR8401MB0441: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: P4S84mSM3pczrsZgbv6hiL/uXOdf/5JjG/C+Lz6uw/t6GuzkkvJAIySyLJocCJCqiuyngCF2mwauelIjiDZjx4+JSRdQn5y7e++xJVPHuXi93ctj2GsiKkByl5JjWPUuFE0NVtBv7h/btFJEEQ7Crtfz8hTr47bgzdEcjddSssA4vtlWRWr/Qq1t3Okp9Qpr1Nd2EPsXaVqHiczZlGW/XdHUViWZ+NtUDs+HnsKKSRV2tuT8TtxIcANxF8EpdGpZcp4+WJ8JVyG55uRPKHq8TCecn+A4gfaOu9zVKWjI+MEobj8E71s4Lfp8HqvzbSnE6kyU7wZ3d6fWYBgrbl+NT6GwMApRFyfGJ5RaMVWZ5QyYAipAVyEImh684tCOKw2rxolrEN0DsSwzaEj+SkP1tw== X-MS-Exchange-AntiSpam-MessageData: gGOAo4VfEwBEPx4E/21qBSvmnPve4DIkir50QIHZ5N9CRmStCVG8cPXL7CSMgoAFTFUkC9Yp/EDSGeIvgh6FgeJj+0A10zGoQ1e8nCkSon1VFeWrrtJxwZUYzOmpYAdmcZyfbxD0F5H+98/yiEgnwNpVy2yim0371m+2lpEDjhWfuZXgmR0N/CXwA9qhjgR4/gyGGNHxRkZ3zz7NUVbH1O1HfkKb4ELzSGk2cy/Z39QOZiX5U4e9e6jXDqK0r9uweDu1fSk+isz2E+EM/P2f6m7Ht6FlCRr+rgQqWuJLsh3ixVDfHPkNc3bhg+XpcvfQs65iRw0jqqophdxK6/4Lyx4PAHWzDJI1dC/GDQzgZdePxX9usVToS1UDUAQXbWvaFeaLUh0k5Jn0Y8LmPYsdYxwFX2cf7E4ZSVQHh+MAvuHud/GIQ+E69WlaqTM3WLKvo54rg+DFd7DEi7J8LSU5AJKa1UWENegQg7ItddQZ3P6hg/m4i/mWX4i/I3VqOZJg X-MS-Exchange-CrossTenant-Network-Message-Id: 5c6504fe-1cb3-4c4f-d475-08d803f2a48e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 17:06:35.2827 (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: q5DWi8I7imXkKeDBsijCrtfeNQYHCg0Q8fQCbb2sCDt3vveAkOJNx2MxL2zC/9oCsCsdKklEim/0ArkOMVTXUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0441 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,daniel.schaefer@hpe.com X-Gm-Message-State: ILxhb7jY9gezug76F84fJ5zkx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590772022; bh=MP7qwlozY67dxXyK6ityqGkDFxpkANmMweScPtS7Xj8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Cj5PtyQDNnX3nLqtzx5zjkBkxsiOOwa+h6Oq6DI57xY8lxPzQls3QabZwtmDMhFcwlW l2DyaZprWb9YIgZtpMdUUn5hUZnfwimJ7V/BbfkXJJbKdYiueYrrZQaPd2DISwi8Tze/9 3KUOYshHEPWRH6XK5lxfQ0QYt5NUzRpqUm4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add submodule opensbi under Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbLlib. The current supported opensbi version for RISC-V edk2 port is tags/v0.6. Signed-off-by: Daniel Schaefer Reviewed-by: Leif Lindholm Cc: Leif Lindholm Cc: Abner Chang Cc: Gilbert Chen Cc: Michael D Kinney --- .gitmodules | 3 ++ Readme.md | 36 +++++++++= +++++++++++ Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi | 1 + 3 files changed, 40 insertions(+) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..88aafaf15820 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi"] + path =3D Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi + url =3D https://github.com/riscv/opensbi diff --git a/Readme.md b/Readme.md index ea9492240adb..6227fd5a0cfd 100644 --- a/Readme.md +++ b/Readme.md @@ -10,6 +10,10 @@ The majority of the content in the EDK II open source pr= oject uses a [BSD-2-Clause Plus Patent License](License.txt). Additional details on ED= K II open source project code contributions can be found in the edk2 repository [Readme.md](https://github.com/tianocore/edk2/blob/master/Readme.md). +The EDK II Platforms open source project contains the following components= that +are covered by additional licenses: + +- [`Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi`](https://= github.com/riscv/opensbi/blob/master/COPYING.BSD) =20 # INDEX * [Overview](#overview) @@ -263,3 +267,35 @@ For more information, see the # Maintainers =20 See [Maintainers.txt](Maintainers.txt). + +# Submodules + +Submodule in EDK II Platforms is allowed but submodule chain should be avo= ided +as possible as we can. Currently EDK II Platforms contains the following +submodules + +- Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi + +To get a full, buildable EDK II repository, use following steps of git com= mand + +```bash + git clone https://github.com/tianocore/edk2-platforms.git + cd edk2-platforms + git submodule update --init + cd .. +``` + +If there's update for submodules, use following git commands to get the la= test +submodules code. + +```bash + cd edk2-platforms + git pull + git submodule update +``` + +Note: When cloning submodule repos, '--recursive' option is not recommende= d. +EDK II Platforms itself will not use any code/feature from submodules in a= bove +submodules. So using '--recursive' adds a dependency on being able to reach +servers we do not actually want any code from, as well as needlessly +downloading code we will not use. diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi b/= Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi new file mode 160000 index 000000000000..ac5e821d50be --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi @@ -0,0 +1 @@ +Subproject commit ac5e821d50be631f26274765a59bc1b444ffd862 --=20 2.26.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 (#60464): https://edk2.groups.io/g/devel/message/60464 Mute This Topic: https://groups.io/mt/74548552/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- From nobody Fri May 3 08:05:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60462+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60462+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 web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1590772000829432.34578921671925; Fri, 29 May 2020 10:06:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BKOPYY1788612xdv34KdTKAq; Fri, 29 May 2020 10:06:40 -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.1226.1590771999701679761 for ; Fri, 29 May 2020 10:06:39 -0700 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04TH3T7f011341; Fri, 29 May 2020 17:06:39 GMT X-Received: from g9t5008.houston.hpe.com (g9t5008.houston.hpe.com [15.241.48.72]) by mx0a-002e3701.pphosted.com with ESMTP id 31arnjetes-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 May 2020 17:06:39 +0000 X-Received: from G9W8456.americas.hpqcorp.net (exchangepmrr1.us.hpecorp.net [16.216.161.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g9t5008.houston.hpe.com (Postfix) with ESMTPS id BBD7756; Fri, 29 May 2020 17:06:38 +0000 (UTC) X-Received: from G4W9119.americas.hpqcorp.net (2002:10d2:14d6::10d2:14d6) by G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 29 May 2020 17:06:38 +0000 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (15.241.52.13) by G4W9119.americas.hpqcorp.net (16.210.20.214) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 29 May 2020 17:06:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zz6GdwGhakwTADpCS4bgp0vhdez5CY9MuOZyZ5LrNBFLRifsIINnsVuoWAgeJZgJSQEdlPPmsrA3bXrhFsevaEuBh+IrmnFqUnDVQ9ocqBTJX/VtPkCYKmIr6ayFmXBppSCiQ+me3KmUGv3R/0Nnqgztbb1H9DQOgW5Qiv9YsUtEPcTop5FP8KcZ36g2y+MiZaFNt/hGb9aqk/CaVEenH4CQrpWDYTt8Qmah87Zu5ztX6gdss41x206Nd3OHkOb1zkvM5EyMwaLaDienFTMZ9uI4o5m1UzQ70nHJAFOhN4Ws5pxXmGf+HhRGFHKbc3/Gf5EVsajTSbFADBfrinhZvw== 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=IoKHwfpxVuFMWrDxoP5P8iOwJoDRlnm26lQeS6Uikg8=; b=HYiwoEOhmnK0wId2zm7KX/PzBB7KEalDQTpT5KGHWB336DySFc9tpe+FIbloOjarrgKDNUpK83/Hx3PlzBrAC74y83Q54n4S/6D4KRci8zGZoC/2WlWxfxlRkNN6e+q5gy7KmVltwszxcmQgrxiCcgD1yBwFtTzgP5k4aEu0CTEVSUk/INP/z9WINhpdJp597hBn0c40QkTY27wy87t3uYMPTh5gbZTJEk3EQrwMejaBWfoFKMVCp+D3YHQQ9SKUnV32qj068RYbLa14t3LEGTOlLQYgbnE/AgrUg9ZjIbmU8U4KN/8en7NJuCChOstDZlaXZ9C8KZYAjWf+zGkFWQ== 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 DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::10) by DF4PR8401MB0441.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19; Fri, 29 May 2020 17:06:37 +0000 X-Received: from DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c4c5:a5a7:6deb:da30]) by DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c4c5:a5a7:6deb:da30%9]) with mapi id 15.20.3021.030; Fri, 29 May 2020 17:06:37 +0000 From: "Daniel Schaefer" To: CC: Gilbert Chen , Leif Lindholm , Abner Chang , Michael D Kinney Subject: [edk2-devel] [PATCH v3 2/3] ProcessorPkg/Library: Add RiscVOpensbiLib Date: Fri, 29 May 2020 19:06:21 +0200 Message-ID: <20200529170622.32610-3-daniel.schaefer@hpe.com> In-Reply-To: <20200529170622.32610-1-daniel.schaefer@hpe.com> References: <20200529170622.32610-1-daniel.schaefer@hpe.com> X-ClientProxiedBy: AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) To DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from x360-nix.fritz.box (93.215.216.32) by AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Fri, 29 May 2020 17:06:35 +0000 X-Originating-IP: [93.215.216.32] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1abdf59d-5c1e-47ec-460f-08d803f2a577 X-MS-TrafficTypeDiagnostic: DF4PR8401MB0441: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: J3Ijb/MZFKZydISS1kx/1PSjgIEH9UsjNfNn/vleGP/KRZcyumbzZ8IARp3GkbOYCuq+4B2sojA9TMkGoGzCRepkJ70EB4U4EZCMWDMQ83LFmhZ6UfPhnsNl+AvcgZ8lkHQ9W7CgML7hmAI5tIHiMBgjj0lsOl07WEbRAhx9aKeDr3M8tPxRdLHOri2h7ZcRdqnsSLbD/e4FtmQNH4bBudPO/KfIxNRZRlrI24FQaRSOwEeseCANsKzBba/prijlncj+DnDI3U8EYT2a390UItxaNEhYTCgJGp0pFvY+WDxC7u8Z9vSnicuY+sptqOqm5foJs6zlwRy+jzdO4tFQ8TXhVzHpz+ufhUefX8eSl0PRmBHtyLVb7q5pgW8dYR1E X-MS-Exchange-AntiSpam-MessageData: OxeGcAC+2W8dX05+xXpL3yx4SHNxLjJO17Wi8CPwfj4cS+5VwzjNDFiivKO++BNC2Z6Vojyb2o9B6Az9oJmgFAloHX3QInyNo2MTc+AOojwVqx1LS6DBDpgBew8ZsQ0LLLEastHMwZK6KSCYTYchn+ot5X6cWk1o9KtG4Vm2e4E1kgn92rhqyfKcHqEwII5EVeghjb/GrRGgTtovoATPT7jSLf05yOgPRTKGSo7mfG1vNN8GDay4iSDGznB+DQmNtpIpKczcYkAHRMLf48+Ay7loPQvNvwnUoQZapddBRgRMGxVTzPKChIgtXDTZCqkGaA+TUTssES5PskjhK+9W5XydOmPgGtu5adhJGQwPQlZksKEH/d3g691DHHfQH9qpce15svjUWkz5JBQ2tzC79Q4Lxk+YzvT5ugPks6xr1jKN4QyD+5bsgmCAOcARr9/TEgVJgc1v7iYdwN4SDxsjRoqMdUPMXnmBd6h3KVa4kIwMf/4NUZeyonuHmaUNGZuF X-MS-Exchange-CrossTenant-Network-Message-Id: 1abdf59d-5c1e-47ec-460f-08d803f2a577 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 17:06:36.9210 (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: sJ1E9xh0bhGsHTWjvrPPbC9hFOiIlXR0dW8gDUG0lvm1/AZHXtDHNm0SgOlQ0qWdRtlyw1G7AgWqRJwwQBS7aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0441 X-OriginatorOrg: hpe.com X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,daniel.schaefer@hpe.com X-Gm-Message-State: E2cc4yHmBYYTAgvKYnLeGkEox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590772000; bh=MzU0/S3twVGImvXp5awc8CbGY3uXeOWjvE1ESJlSdac=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=TphmNHsf6wT97LzdO/ed8Vv+dXgqsiU+8XKiJG3CwFhkM9KtjMVkKow+HKyjlABlw/h /VzIm9PY0GN3Kbc/cAFUvEUbanm4kR1Gp8EvDsL35bCHM4ZTPrjKoR1CHbV9C0SaR/uTg puU2/xxf1bHlG8GwmlhmXvmWT4wyY/wc2sQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" EDK2 RISC-V OpenSBI library which pull in external source files under RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi to the build process. Signed-off-by: Abner Chang Co-authored-by: Daniel Schaefer Co-authored-by: Gilbert Chen Reviewed-by: Leif Lindholm Cc: Leif Lindholm Cc: Gilbert Chen Cc: Abner Chang Cc: Daniel Schaefer Cc: Michael D Kinney --- Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf | = 52 +++++++++++++ Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h | = 81 ++++++++++++++++++++ Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h | = 75 ++++++++++++++++++ 3 files changed, 208 insertions(+) diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpens= biLib.inf b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensb= iLib.inf new file mode 100644 index 000000000000..14e29dc0aa62 --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.i= nf @@ -0,0 +1,52 @@ +## @file +# RISC-V Opensbi Library Instance. +# +# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001b + BASE_NAME =3D RiscVOpensbiLib + FILE_GUID =3D 6EF0C812-66F6-11E9-93CE-3F5D5F0DF0A7 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RiscVOpensbiLib + +[Sources] + opensbi/lib/sbi/riscv_asm.c + opensbi/lib/sbi/riscv_atomic.c + opensbi/lib/sbi/riscv_hardfp.S + opensbi/lib/sbi/riscv_locks.c + opensbi/lib/sbi/sbi_console.c + opensbi/lib/sbi/sbi_ecall.c + opensbi/lib/sbi/sbi_ecall_vendor.c + opensbi/lib/sbi/sbi_ecall_replace.c + opensbi/lib/sbi/sbi_ecall_legacy.c + opensbi/lib/sbi/sbi_ecall_base.c + opensbi/lib/sbi/sbi_emulate_csr.c + opensbi/lib/sbi/sbi_fifo.c + opensbi/lib/sbi/sbi_hart.c + opensbi/lib/sbi/sbi_hfence.S + opensbi/lib/sbi/sbi_illegal_insn.c + opensbi/lib/sbi/sbi_init.c + opensbi/lib/sbi/sbi_ipi.c + opensbi/lib/sbi/sbi_misaligned_ldst.c + opensbi/lib/sbi/sbi_scratch.c + opensbi/lib/sbi/sbi_string.c + opensbi/lib/sbi/sbi_system.c + opensbi/lib/sbi/sbi_timer.c + opensbi/lib/sbi/sbi_tlb.c + opensbi/lib/sbi/sbi_trap.c + opensbi/lib/sbi/sbi_unpriv.c + opensbi/lib/utils/sys/clint.c + opensbi/lib/utils/irqchip/plic.c + opensbi/lib/utils/serial/sifive-uart.c + opensbi/lib/utils/serial/uart8250.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec # For libfdt. + MdePkg/MdePkg.dec + Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec diff --git a/Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpen= sbi.h b/Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h new file mode 100644 index 000000000000..7d3b4a371c2d --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Include/IndustryStandard/RiscVOpensbi.h @@ -0,0 +1,81 @@ +/** @file + SBI inline function calls. + + Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All right= s reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDK2_SBI_H_ +#define EDK2_SBI_H_ + +#include +#include +#include +#include +#include +#include +#include + +// Translation from OpenSBI constants to SBI names +#define SBI_SUCCESS SBI_OK +#define SBI_ERR_FAILED SBI_EFAIL +#define SBI_ERR_NOT_SUPPORTED SBI_ENOTSUPP +#define SBI_ERR_INVALID_PARAM SBI_EINVAL +#define SBI_ERR_DENIED SBI_DENIED +#define SBI_ERR_INVALID_ADDRESS SBI_INVALID_ADDR +// Currently improperly defined in upstream OpenSBI +#define SBI_ERR_ALREADY_AVAILABLE -6 + +// Included in OpenSBI 0.7 +// Can be removed, once we upgrade +#define SBI_EXT_HSM 0x48534D +#define SBI_EXT_HSM_HART_START 0x0 +#define SBI_EXT_HSM_HART_STOP 0x1 +#define SBI_EXT_HSM_HART_GET_STATUS 0x2 + +// +// Below two definitions should be defined in OpenSBI. +// Submitted to upstream, waiting for merge and release. +// +#define SBI_EXT_FIRMWARE_CODE_BASE_START 0x0A000000 +#define SBI_EXT_FIRMWARE_CODE_BASE_END 0x0AFFFFFF + +#define RISC_V_MAX_HART_SUPPORTED 16 + +typedef +VOID +(EFIAPI *RISCV_HART_SWITCH_MODE)( + IN UINTN FuncArg0, + IN UINTN FuncArg1, + IN UINTN NextAddr, + IN UINTN NextMode, + IN BOOLEAN NextVirt + ); + +// +// Keep the structure member in 64-bit alignment. +// +typedef struct { + UINT64 IsaExtensionSupported; // The ISA extension th= is core supported. + RISCV_UINT128 MachineVendorId; // Machine vendor ID + RISCV_UINT128 MachineArchId; // Machine Architecture= ID + RISCV_UINT128 MachineImplId; // Machine Implementati= on ID + RISCV_HART_SWITCH_MODE HartSwitchMode; // OpenSBI's function t= o switch the mode of a hart +} EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC; +#define FIRMWARE_CONTEXT_HART_SPECIFIC_SIZE (64 * 8) // This is the size = of EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC + // structure. Referr= ed by both C code and assembly code. + +typedef struct { + VOID *PeiServiceTable; // PEI Service table + EFI_RISCV_FIRMWARE_CONTEXT_HART_SPECIFIC *HartSpecific[RISC_V_MAX_HART_= SUPPORTED]; +} EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT; + +// +// Typedefs of OpenSBI type to make them conform to EDK2 coding guidelines +// +typedef struct sbi_scratch SBI_SCRATCH; +typedef struct sbi_platform SBI_PLATFORM; + +#endif diff --git a/Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h b/Silicon/R= ISC-V/ProcessorPkg/Include/OpensbiTypes.h new file mode 100644 index 000000000000..7f85d28193e1 --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h @@ -0,0 +1,75 @@ +/** @file + RISC-V OpesbSBI header file reference. + + Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All right= s reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#ifndef EDK2_SBI_TYPES_H_ +#define EDK2_SBI_TYPES_H_ + +#include + +typedef INT8 s8; +typedef UINT8 u8; +typedef UINT8 uint8_t; + +typedef INT16 s16; +typedef UINT16 u16; +typedef INT16 int16_t; +typedef UINT16 uint16_t; + +typedef INT32 s32; +typedef UINT32 u32; +typedef INT32 int32_t; +typedef UINT32 uint32_t; + +typedef INT64 s64; +typedef UINT64 u64; +typedef INT64 int64_t; +typedef UINT64 uint64_t; + +// PRILX is not used in EDK2 but we need to define it here because when +// defining our own types, this constant is not defined but used by OpenSB= I. +#define PRILX "016lx" + +typedef BOOLEAN bool; +typedef unsigned long ulong; +typedef UINT64 uintptr_t; +typedef UINT64 size_t; +typedef INT64 ssize_t; +typedef UINT64 virtual_addr_t; +typedef UINT64 virtual_size_t; +typedef UINT64 physical_addr_t; +typedef UINT64 physical_size_t; + +#define __packed __attribute__((packed)) +#define __noreturn __attribute__((noreturn)) + +#if defined(__GNUC__) || defined(__clang__) + #define likely(x) __builtin_expect((x), 1) + #define unlikely(x) __builtin_expect((x), 0) +#else + #define likely(x) (x) + #define unlikely(x) (x) +#endif + +#undef offsetof +#ifdef __compiler_offsetof +#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE,MEMBER) +#else +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + +#define container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member) * __mptr =3D (ptr); \ + (type *)((char *)__mptr - offsetof(type, member)); }) + +#define CLAMP(a, lo, hi) MIN(MAX(a, lo), hi) +#define ROUNDUP(a, b) ((((a)-1) / (b) + 1) * (b)) +#define ROUNDDOWN(a, b) ((a) / (b) * (b)) + +/* clang-format on */ + +#endif --=20 2.26.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 (#60462): https://edk2.groups.io/g/devel/message/60462 Mute This Topic: https://groups.io/mt/74548540/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- From nobody Fri May 3 08:05:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60463+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60463+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 web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1590772004377179.3041559997613; Fri, 29 May 2020 10:06:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 72XQYY1788612xrc7AlUA1Mj; Fri, 29 May 2020 10:06:44 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.1197.1590772003422380037 for ; Fri, 29 May 2020 10:06:43 -0700 X-Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04TGwPml020403; Fri, 29 May 2020 17:06:43 GMT X-Received: from g9t5008.houston.hpe.com (g9t5008.houston.hpe.com [15.241.48.72]) by mx0b-002e3701.pphosted.com with ESMTP id 31b1swjef0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 May 2020 17:06:42 +0000 X-Received: from G9W8456.americas.hpqcorp.net (g9w8456.houston.hp.com [16.216.161.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g9t5008.houston.hpe.com (Postfix) with ESMTPS id 1F23C62; Fri, 29 May 2020 17:06:42 +0000 (UTC) X-Received: from G1W8107.americas.hpqcorp.net (2002:10c1:483b::10c1:483b) by G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 29 May 2020 17:06:41 +0000 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (15.241.52.13) by G1W8107.americas.hpqcorp.net (16.193.72.59) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Fri, 29 May 2020 17:06:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m5Dp5tg6WT7F2ov0D38PpDZP5SrIk26FR09ee3lJDlQ7V2BREd4XJRPYoiH+pyGu6GhRpaD/B/mdIrGuGUmQMN3v3fR31pXIM/poMPIYEGT63ytZmMTg4HzvGeQ1Xl7Y5A3p9cGEsJN+tbzLFofPgPocNKs3sAkMpBwHUsdW5ey/hFUb5Xl17OTOhKh99bNLLfH2q2+Gw6FGpGUzIRL5XqvUNKjH33JVdrKBjuOjTb55NAzAaGp879nWRWR8LD94b3uiS94xNCBoTpLx2DN/4awl3pxw/OJmf2cBQL7gqz+7BkB7/xlXSwL8Rh5gWCqgSbhCDCqgENpd173qD71GYg== 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=o77TKZLgWPQb/AqhTjIzFqoFeO381xB6ilpqMv8r8T0=; b=ArP9nUb50+DkH1hx5lNHMWetCrGdzywtjdTJ6qwH4CxuxQeqe98VcOq+b8pp1MPzDXK664qPxNUpoLprJOBpFJ3BiwSmQEuGYi+RGOWSGpvjkcOfFD0jc8X1CzSJsOYU17PMOSTk5bEDoY/7ypE1Lh/HUWZoplfGhhlMsTzK0aE/t8tIj4gaSGKmhNAeu9A1eCQ78UrSVAsH/5m1O1MfeIG8zdMyXl3gpecU55OWoHXAu06aNum+3AGMaUDQ3J3xG8ENPmhG1ieBIRE7WOHRpD2jeI1w3CSgasT5xtNzQgZA9K+HRu8hy4Hd9cUA/eZF9Z+9VUbrs2IRA6K3JEOZpA== 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 DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::10) by DF4PR8401MB0441.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19; Fri, 29 May 2020 17:06:38 +0000 X-Received: from DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c4c5:a5a7:6deb:da30]) by DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c4c5:a5a7:6deb:da30%9]) with mapi id 15.20.3021.030; Fri, 29 May 2020 17:06:38 +0000 From: "Daniel Schaefer" To: CC: Leif Lindholm , Gilbert Chen , Abner Chang , Michael D Kinney Subject: [edk2-devel] [PATCH v3 3/3] ProcessorPkg/Library: Add RiscVEdk2SbiLib Date: Fri, 29 May 2020 19:06:22 +0200 Message-ID: <20200529170622.32610-4-daniel.schaefer@hpe.com> In-Reply-To: <20200529170622.32610-1-daniel.schaefer@hpe.com> References: <20200529170622.32610-1-daniel.schaefer@hpe.com> X-ClientProxiedBy: AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) To DF4PR8401MB0474.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7607::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from x360-nix.fritz.box (93.215.216.32) by AM0PR10CA0057.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Fri, 29 May 2020 17:06:37 +0000 X-Originating-IP: [93.215.216.32] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 46f047c3-27e8-4b1c-a5c2-08d803f2a670 X-MS-TrafficTypeDiagnostic: DF4PR8401MB0441: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: K99A4hmWsjtg/wy4bGPhC5JH4Hv6a44UNhF+OiJIVavZDdAXLbaIOapLuIaCyeTAvWhnSA/b0XT3NKD4znDQWEh/XT4HaZi/QYGcbTycsmS0GbAYeYhAt5Z2xiH7C2Nd2I/rmdQljDYdtC+ryBDjl0Dyk7SJ158dJPw+e/BDp/497z0bYQkJskpuxcj+N+kddovYg5EBOcUEZ0U71A0nuLxRtcKLns1UatxFe+mGeqymM/kTu6JcJNKVXacmLCH+uLSrIPzZi+M9ojnULqJ8F0w3qTgW1ZKfaoNomca5BxeJAWyUvvRHbWsakNpVsrwldVT1J2g0mjvya7bu5hIyBA== X-MS-Exchange-AntiSpam-MessageData: t/KzX+jf/k9ya2DCvYzLDAAjf9bWBjgPPDnWMQ0+Vw2xWR6uB5X3a+LrM57QnwRhC50ChpHX35gXGonNCBYSNKrfqOdwkjGTmdtElhhiM93stzSAlaC0v0CDR3a2XJlGqtiRQYJonCsAjANFEWs7nC3AG+6zUF9BHM7OM9kCYnasW3KtzfrAgHXv4YyKnWnBKBYkAagr8u53gzy5xu2eWQffQBgB7wL2VRa8i03akronEm1zO34ehz38WrncNO5Q2SBNP9vbv+opQRpuCY8g3EJjgnUatuvpz4msCDHlr1WpBXSCfAPnVSuNhpgvWlDraIMikpCdMZeFq2L0aqrxeL/ii7YEyXdfjFPq9C6SPdpZJiHxRglEmesRs6dTCnDyNJWT88DXCeiW1LLu3iZ1Rg9HUXd4Iqs5jxg5ZOMQspIKtGLgnBB1BKjj/rEZT8EcZSvpUgIcjmetc2YkBoPbz0kAnMmvAUxwZORv8wqFYBsTLWRduJojca+kp90Q/mC4 X-MS-Exchange-CrossTenant-Network-Message-Id: 46f047c3-27e8-4b1c-a5c2-08d803f2a670 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 17:06:38.5862 (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: LlqS7GFZwI65Gh71lcRrPiRE+wUfftouWIDec1kqUblRi11TEBWmpujqslO7ZfFYH1UJ/ij/GegO+TcQXQu6Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0441 X-OriginatorOrg: hpe.com X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,daniel.schaefer@hpe.com X-Gm-Message-State: y3OXV6cnKw98D8YznFGIg7iqx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1590772004; bh=44UCCuNY2HYv64bp5Vgzhdxevkvg577reQj3jiziteo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=eNN+nbLaZYOHAY3WoSliuzTFJ5gV3JgHF9VIh+OjSpPTYiZv5cuzhA77PzJx6+R9kNe OBVBIpvE5peWwYffZccT3OqYBkZwB+pDXVypo8wP2gDqgd+WKmXq0MfdEpzp7HDEfYdni HhH404pNLV92YEigQJFHE3IDdro0xduWxJc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Library provides interfaces to invoke SBI ecalls. Signed-off-by: Daniel Schaefer Cc: Leif Lindholm Cc: Gilbert Chen Cc: Abner Chang Cc: Michael D Kinney --- Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.inf | = 28 + Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h | = 563 +++++++++++++ Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.c | = 860 ++++++++++++++++++++ 3 files changed, 1451 insertions(+) diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2S= biLib.inf b/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2Sb= iLib.inf new file mode 100644 index 000000000000..665dcbf40e01 --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.i= nf @@ -0,0 +1,28 @@ +## @file +# RISC-V Library to call SBI ecalls +# +# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001b + BASE_NAME =3D RiscVEdk2SbiLib + FILE_GUID =3D 0DF1BBBD-F7E5-4E8A-BCF1-9D63D2DD9FDD + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RiscVEdk2SbiLib + +[Sources] + RiscVEdk2SbiLib.c + +[Packages] + MdePkg/MdePkg.dec + Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec + Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec + +[LibraryClasses] + BaseLib + RiscVOpensbiLib diff --git a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h = b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h new file mode 100644 index 000000000000..c1ae3176147f --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h @@ -0,0 +1,563 @@ +/** @file + Library to call the RISC-V SBI ecalls + + Copyright (c) 2020, Hewlett Packard Development LP. All rights reserved.=
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Hart - Hardware Thread, similar to a CPU core +**/ + +#ifndef RISCV_SBI_LIB_H_ +#define RISCV_SBI_LIB_H_ + +#include +#include +#include +#include + +// +// EDK2 OpenSBI Firmware extension. +// +#define SBI_EDK2_FW_EXT (SBI_EXT_FIRMWARE_CODE_BASE_START | SBI_OPENSBI_IM= PID) +// +// EDK2 OpenSBI Firmware extension functions. +// +#define SBI_EXT_FW_MSCRATCH_FUNC 0 +#define SBI_EXT_FW_MSCRATCH_HARTID_FUNC 1 + +// +// EDK2 OpenSBI firmware extension return status. +// +typedef struct { + UINTN Error; ///< SBI status code + UINTN Value; ///< Value returned +} SbiRet; + +/** + Get the implemented SBI specification version + + The minor number of the SBI specification is encoded in the low 24 bits, + with the major number encoded in the next 7 bits. Bit 32 must be 0 and = is + reserved for future expansion. + + @param[out] SpecVersion The Version of the SBI specification. +**/ +VOID +EFIAPI +SbiGetSpecVersion ( + OUT UINTN *SpecVersion + ); + +/** + Get the SBI implementation ID + + This ID is used to idenetify a specific SBI implementation in order to w= ork + around any quirks it might have. + + @param[out] ImplId The ID of the SBI implementation. +**/ +VOID +EFIAPI +SbiGetImplId ( + OUT UINTN *ImplId + ); + +/** + Get the SBI implementation version + + The version of this SBI implementation. + The encoding of this number is determined by the specific SBI implementa= tion. + + @param[out] ImplVersion The version of the SBI implementation. +**/ +VOID +EFIAPI +SbiGetImplVersion ( + OUT UINTN *ImplVersion + ); + +/** + Probe whether an SBI extension is available + + ProbeResult is set to 0 if the extension is not available or to an exten= sion + specified value if it is available. + + @param[in] ExtensionId The extension ID. + @param[out] ProbeResult The return value of the probe. +**/ +VOID +EFIAPI +SbiProbeExtension ( + IN INTN ExtensionId, + OUT INTN *ProbeResult + ); + +/** + Get the CPU's vendor ID + + Reads the mvendorid CSR. + + @param[out] MachineVendorId The CPU's vendor ID. +**/ +VOID +EFIAPI +SbiGetMachineVendorId ( + OUT UINTN *MachineVendorId + ); + +/** + Get the CPU's architecture ID + + Reads the marchid CSR. + + @param[out] MachineArchId The CPU's architecture ID. +**/ +VOID +EFIAPI +SbiGetMachineArchId ( + OUT UINTN *MachineArchId + ); + +/** + Get the CPU's implementation ID + + Reads the mimpid CSR. + + @param[out] MachineImplId The CPU's implementation ID. +**/ +VOID +EFIAPI +SbiGetMachineImplId ( + OUT UINTN *MachineImplId + ); + +/** + Politely ask the SBI to start a given hart. + + This call may return before the hart has actually started executing, if = the + SBI implementation can guarantee that the hart is actually going to star= t. + + Before the hart jumps to StartAddr, the hart MUST configure PMP if prese= nt + and switch to S-mode. + + @param[in] HartId The id of the hart to start. + @param[in] StartAddr The physical address, where the hart st= arts + executing from. + @param[in] Priv An XLEN-bit value, which will be in reg= ister + a1 when the hart starts. + @retval EFI_SUCCESS Hart was stopped and will start executi= ng from StartAddr. + @retval EFI_LOAD_ERROR StartAddr is not valid, possibly due to= following reasons: + - It is not a valid physical address. + - The address is prohibited by PMP to = run in + supervisor mode. + @retval EFI_INVALID_PARAMETER HartId is not a valid hart id + @retval EFI_ALREADY_STARTED The hart is already running. + @retval other The start request failed for unknown re= asons. +**/ +EFI_STATUS +EFIAPI +SbiHartStart ( + IN UINTN HartId, + IN UINTN StartAddr, + IN UINTN Priv + ); + +/** + Return execution of the calling hart to SBI. + + MUST be called in S-Mode with user interrupts disabled. + This call is not expected to return, unless a failure occurs. + + @retval EFI_SUCCESS Never occurs. When successful, the call= does not return. + @retval other Failed to stop hard for an unknown reas= on. +**/ +EFI_STATUS +EFIAPI +SbiHartStop ( + ); + +/** + Get the current status of a hart. + + Since harts can transition between states at any time, the status retrie= ved + by this function may already be out of date, once it returns. + + Possible values for HartStatus are: + 0: STARTED + 1: STOPPED + 2: START_REQUEST_PENDING + 3: STOP_REQUEST_PENDING + + @param[out] HartStatus The pointer in which the hart's status = is + stored. + @retval EFI_SUCCESS The operation succeeds. + @retval EFI_INVALID_PARAMETER A parameter is invalid. +**/ +EFI_STATUS +EFIAPI +SbiHartGetStatus ( + IN UINTN HartId, + OUT UINTN *HartStatus + ); + +/// +/// Timer extension +/// + +/** + Clear pending timer interrupt bit and set timer for next event after Tim= e. + + To clear the timer without scheduling a timer event, set Time to a + practically infinite value or mask the timer interrupt by clearing sie.S= TIE. + + @param[in] Time The time offset to the next scheduled t= imer interrupt. +**/ +VOID +EFIAPI +SbiSetTimer ( + IN UINT64 Time + ); + +/// +/// IPI extension +/// + +/** + Send IPI to all harts specified in the mask. + + The interrupts are registered as supervisor software interrupts at the + receiving hart. + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiSendIpi ( + IN UINTN *HartMask, + IN UINTN HartMaskBase + ); + +/// +/// Remote fence extension +/// + +/** + Instructs remote harts to execute a FENCE.I instruction. + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteFenceI ( + IN UINTN *HartMask, + IN UINTN HartMaskBase + ); + +/** + Instructs the remote harts to execute one or more SFENCE.VMA instruction= s. + + The SFENCE.VMA covers the range of virtual addresses between StartAaddr = and Size. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteSfenceVma ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size + ); + +/** + Instructs the remote harts to execute one or more SFENCE.VMA instruction= s. + + The SFENCE.VMA covers the range of virtual addresses between StartAaddr = and Size. + Covers only the given ASID. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteSfenceVmaAsid ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size, + IN UINTN Asid + ); + +/** + Instructs the remote harts to execute one or more SFENCE.GVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + Covers only the given VMID. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHfenceGvmaVmid ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size, + IN UINTN Vmid + ); + +/** + Instructs the remote harts to execute one or more SFENCE.GVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHfenceGvma ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size + ); + +/** + Instructs the remote harts to execute one or more SFENCE.VVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + Covers only the given ASID. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHfenceVvmaAsid ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size, + IN UINTN Asid + ); + +/** + Instructs the remote harts to execute one or more SFENCE.VVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHfenceVvma ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size + ); + +/// +/// Vendor Specific extension space: Extension Ids 0x09000000 through 0x09= FFFFFF +/// + +/** + Call a function in a vendor defined SBI extension + + ASSERT() if the ExtensionId is not in the designated SBI Vendor Extension + Space. + + @param[in] ExtensionId The SBI vendor extension ID. + @param[in] FunctionId The function ID to call in this extensi= on. + @param[in] NumArgs How many arguments are passed. + @param[in] ... Actual Arguments to the function. + @retval EFI_SUCCESS if the SBI function was called and it was successful + @retval EFI_INVALID_PARAMETER if NumArgs exceeds 6 + @retval others if the called SBI function returns an error +**/ +EFI_STATUS +EFIAPI +SbiVendorCall ( + IN UINTN ExtensionId, + IN UINTN FunctionId, + IN UINTN NumArgs, + ... + ); + +/// +/// Firmware SBI Extension +/// +/// This SBI Extension is defined and used by EDK2 only in order to be abl= e to +/// run PI and DXE phase in S-Mode. +/// + +/** + Get scratch space of the current hart. + + Please consider using the wrapper SbiGetFirmwareContext if you only need= to + access the firmware context. + + @param[out] ScratchSpace The scratch space pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiGetMscratch ( + OUT SBI_SCRATCH **ScratchSpace + ); + +/** + Get scratch space of the given hart id. + + @param[in] HartId The hart id. + @param[out] ScratchSpace The scratch space pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiGetMscratchHartid ( + IN UINTN HartId, + OUT SBI_SCRATCH **ScratchSpace + ); + +/** + Get firmware context of the calling hart. + + @param[out] FirmwareContext The firmware context pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiGetFirmwareContext ( + OUT EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT **FirmwareContext + ); + +/** + Set firmware context of the calling hart. + + @param[in] FirmwareContext The firmware context pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiSetFirmwareContext ( + IN EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext + ); + +#endif diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2S= biLib.c b/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiL= ib.c new file mode 100644 index 000000000000..d26adaa37ce7 --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.c @@ -0,0 +1,860 @@ +/** @file + Instance of the SBI ecall library. + + It allows calling an SBI function via an ecall from S-Mode. + + The legacy extensions are not included because they are not necessary. + They would be: + - SbiLegacySetTimer -> Use SbiSetTimer + - SbiLegacyConsolePutChar -> No replacement - Use regular UEFI func= tions + - SbiLegacyConsoleGetChar -> No replacement - Use regular UEFI func= tions + - SbiLegacyClearIpi -> Write 0 to SSIP + - SbiLegacySendIpi -> Use SbiSendIpi + - SbiLegacyRemoteFenceI -> Use SbiRemoteFenceI + - SbiLegacyRemoteSfenceVma -> Use SbiRemoteSfenceVma + - SbiLegacyRemoteSfenceVmaAsid -> Use SbiRemoteSfenceVmaAsid + - SbiLegacyShutdown -> Wait for new System Reset extension + + Copyright (c) 2020, Hewlett Packard Development LP. All rights reserved.=
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + + +/** + Call SBI call using ecall instruction. + + @param[in] ExtId SBI extension ID. + @param[in] FuncId SBI function ID. + @param[in] NumAargs Number of arguments to pass to the ecall. + @param[in] ... Argument list for the ecall. + + @retval Returns SbiRet structure with value and error code. + +**/ +STATIC +SbiRet +EFIAPI +SbiCall( + IN UINTN ExtId, + IN UINTN FuncId, + IN UINTN NumArgs, + ... +) { + UINTN I; + SbiRet Ret; + UINTN Args[6]; + VA_LIST ArgList; + VA_START(ArgList, NumArgs); + + for (I =3D 0; I < 6; I++) { + if (I < NumArgs) { + Args[I] =3D VA_ARG(ArgList, UINTN); + } else { + // Default to 0 for all arguments that are not given + Args[I] =3D 0; + } + } + + VA_END(ArgList); + + register UINTN a0 asm ("a0") =3D Args[0]; + register UINTN a1 asm ("a1") =3D Args[1]; + register UINTN a2 asm ("a2") =3D Args[2]; + register UINTN a3 asm ("a3") =3D Args[3]; + register UINTN a4 asm ("a4") =3D Args[4]; + register UINTN a5 asm ("a5") =3D Args[5]; + register UINTN a6 asm ("a6") =3D (UINTN)(FuncId); + register UINTN a7 asm ("a7") =3D (UINTN)(ExtId); + asm volatile ("ecall" \ + : "+r" (a0), "+r" (a1) \ + : "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), "r" (a7) \ + : "memory"); \ + Ret.Error =3D a0; + Ret.Value =3D a1; + return Ret; +} + +/** + Translate SBI error code to EFI status. + + @param[in] SbiError SBI error code + @retval EFI_STATUS +**/ + +STATIC +EFI_STATUS +EFIAPI +TranslateError( + IN UINTN SbiError + ) { + switch (SbiError) { + case SBI_SUCCESS: + return EFI_SUCCESS; + case SBI_ERR_FAILED: + return EFI_DEVICE_ERROR; + break; + case SBI_ERR_NOT_SUPPORTED: + return EFI_UNSUPPORTED; + break; + case SBI_ERR_INVALID_PARAM: + return EFI_INVALID_PARAMETER; + break; + case SBI_ERR_DENIED: + return EFI_ACCESS_DENIED; + break; + case SBI_ERR_INVALID_ADDRESS: + return EFI_LOAD_ERROR; + break; + case SBI_ERR_ALREADY_AVAILABLE: + return EFI_ALREADY_STARTED; + break; + default: + // + // Reaches here only if SBI has defined a new error type + // + ASSERT (FALSE); + return EFI_UNSUPPORTED; + break; + } +} + +// +// OpenSBI libraary interface function for the base extension +// + +/** + Get the implemented SBI specification version + + The minor number of the SBI specification is encoded in the low 24 bits, + with the major number encoded in the next 7 bits. Bit 32 must be 0 and = is + reserved for future expansion. + + @param[out] SpecVersion The Version of the SBI specification. +**/ +VOID +EFIAPI +SbiGetSpecVersion ( + OUT UINTN *SpecVersion + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0); + + if (!Ret.Error) { + *SpecVersion =3D (UINTN) Ret.Value; + } +} + +/** + Get the SBI implementation ID + + This ID is used to idenetify a specific SBI implementation in order to w= ork + around any quirks it might have. + + @param[out] ImplId The ID of the SBI implementation. +**/ +VOID +EFIAPI +SbiGetImplId ( + OUT UINTN *ImplId + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0); + *ImplId =3D (UINTN) Ret.Value; +} + +/** + Get the SBI implementation version + + The version of this SBI implementation. + The encoding of this number is determined by the specific SBI implementa= tion. + + @param[out] ImplVersion The version of the SBI implementation. +**/ +VOID +EFIAPI +SbiGetImplVersion ( + OUT UINTN *ImplVersion + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_VERSION, 0); + *ImplVersion =3D (UINTN) Ret.Value; +} + +/** + Probe whether an SBI extension is available + + ProbeResult is set to 0 if the extension is not available or to an exten= sion + specified value if it is available. + + @param[in] ExtensionId The extension ID. + @param[out] ProbeResult The return value of the probe. +**/ +VOID +EFIAPI +SbiProbeExtension ( + IN INTN ExtensionId, + OUT INTN *ProbeResult + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, 0); + *ProbeResult =3D (UINTN) Ret.Value; +} + +/** + Get the CPU's vendor ID + + Reads the mvendorid CSR. + + @param[out] MachineVendorId The CPU's vendor ID. +**/ +VOID +EFIAPI +SbiGetMachineVendorId ( + OUT UINTN *MachineVendorId + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_GET_MVENDORID, 0); + *MachineVendorId =3D (UINTN) Ret.Value; +} + +/** + Get the CPU's architecture ID + + Reads the marchid CSR. + + @param[out] MachineArchId The CPU's architecture ID. +**/ +VOID +EFIAPI +SbiGetMachineArchId ( + OUT UINTN *MachineArchId + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_GET_MARCHID, 0); + *MachineArchId =3D (UINTN) Ret.Value; +} + +/** + Get the CPU's architecture ID + + Reads the marchid CSR. + + @param[out] MachineImplId The CPU's implementation ID. +**/ +VOID +EFIAPI +SbiGetMachineImplId ( + OUT UINTN *MachineImplId + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_BASE, SBI_EXT_BASE_GET_MIMPID, 0); + *MachineImplId =3D (UINTN) Ret.Value; +} + +// +// SBI interface function for the hart state management extension +// + +/** + Politely ask the SBI to start a given hart. + + This call may return before the hart has actually started executing, if = the + SBI implementation can guarantee that the hart is actually going to star= t. + + Before the hart jumps to StartAddr, the hart MUST configure PMP if prese= nt + and switch to S-mode. + + @param[in] HartId The id of the hart to start. + @param[in] StartAddr The physical address, where the hart st= arts + executing from. + @param[in] Priv An XLEN-bit value, which will be in reg= ister + a1 when the hart starts. + @retval EFI_SUCCESS Hart was stopped and will start executi= ng from StartAddr. + @retval EFI_LOAD_ERROR StartAddr is not valid, possibly due to= following reasons: + - It is not a valid physical address. + - The address is prohibited by PMP to= run in + supervisor mode. + @retval EFI_INVALID_PARAMETER HartId is not a valid hart id + @retval EFI_ALREADY_STARTED The hart is already running. + @retval other The start request failed for unknown re= asons. +**/ +EFI_STATUS +EFIAPI +SbiHartStart ( + IN UINTN HartId, + IN UINTN StartAddr, + IN UINTN Priv + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_HSM, + SBI_EXT_HSM_HART_START, + 3, + HartId, + StartAddr, + Priv); + return TranslateError(Ret.Error); +} + +/** + Return execution of the calling hart to SBI. + + MUST be called in S-Mode with user interrupts disabled. + This call is not expected to return, unless a failure occurs. + + @retval EFI_SUCCESS Never occurs. When successful, the call= does not return. + @retval other Failed to stop hard for an unknown reas= on. +**/ +EFI_STATUS +EFIAPI +SbiHartStop ( + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_HSM, SBI_EXT_HSM_HART_STOP, 0); + return TranslateError(Ret.Error); +} + +/** + Get the current status of a hart. + + Since harts can transition between states at any time, the status retrie= ved + by this function may already be out of date, once it returns. + + Possible values for HartStatus are: + 0: STARTED + 1: STOPPED + 2: START_REQUEST_PENDING + 3: STOP_REQUEST_PENDING + + @param[out] HartStatus The pointer in which the hart's status = is + stored. + @retval EFI_SUCCESS The operation succeeds. + @retval EFI_INVALID_PARAMETER A parameter is invalid. +**/ +EFI_STATUS +EFIAPI +SbiHartGetStatus ( + IN UINTN HartId, + OUT UINTN *HartStatus + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_HSM, SBI_EXT_HSM_HART_GET_STATUS, 1, Har= tId); + + if (!Ret.Error) { + *HartStatus =3D (UINTN) Ret.Value; + } + + return TranslateError(Ret.Error); +} + +/** + Clear pending timer interrupt bit and set timer for next event after Tim= e. + + To clear the timer without scheduling a timer event, set Time to a + practically infinite value or mask the timer interrupt by clearing sie.S= TIE. + + @param[in] Time The time offset to the next scheduled t= imer interrupt. +**/ +VOID +EFIAPI +SbiSetTimer ( + IN UINT64 Time + ) +{ + SbiCall (SBI_EXT_TIME, SBI_EXT_TIME_SET_TIMER, 1, Time); +} + +EFI_STATUS +EFIAPI +SbiSendIpi ( + IN UINTN *HartMask, + IN UINTN HartMaskBase + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_IPI, + SBI_EXT_IPI_SEND_IPI, + 2, + (UINTN) HartMask, + HartMaskBase); + return TranslateError(Ret.Error); +} + +/** + Instructs remote harts to execute a FENCE.I instruction. + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteFenceI ( + IN UINTN *HartMask, + IN UINTN HartMaskBase + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_RFENCE, + SBI_EXT_RFENCE_REMOTE_FENCE_I, + 2, + (UINTN) HartMask, + HartMaskBase); + return TranslateError(Ret.Error); +} + +/** + Instructs the remote harts to execute one or more SFENCE.VMA instruction= s. + + The SFENCE.VMA covers the range of virtual addresses between StartAaddr = and Size. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteSfenceVma ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_RFENCE, + SBI_EXT_RFENCE_REMOTE_SFENCE_VMA, + 4, + (UINTN) HartMask, + HartMaskBase, + StartAddr, + Size); + return TranslateError(Ret.Error); +} + +/** + Instructs the remote harts to execute one or more SFENCE.VMA instruction= s. + + The SFENCE.VMA covers the range of virtual addresses between StartAaddr = and Size. + Covers only the given ASID. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteSfenceVmaAsid ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size, + IN UINTN Asid + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_RFENCE, + SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID, + 5, + (UINTN) HartMask, + HartMaskBase, + StartAddr, + Size, + Asid); + return TranslateError(Ret.Error); +} + +/** + Instructs the remote harts to execute one or more SFENCE.GVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + Covers only the given VMID. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHFenceGvmaVmid ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size, + IN UINTN Vmid + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_RFENCE, + SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA, + 5, + (UINTN) HartMask, + HartMaskBase, + StartAddr, + Size, + Vmid); + return TranslateError(Ret.Error); +} + +/** + Instructs the remote harts to execute one or more SFENCE.GVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHFenceGvma ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_RFENCE, + SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID, + 4, + (UINTN) HartMask, + HartMaskBase, + StartAddr, + Size); + return TranslateError(Ret.Error); +} + +/** + Instructs the remote harts to execute one or more SFENCE.VVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + Covers only the given ASID. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHFenceVvmaAsid ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size, + IN UINTN Asid + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_RFENCE, + SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA, + 5, + (UINTN) HartMask, + HartMaskBase, + StartAddr, + Size, + Asid); + return TranslateError(Ret.Error); +} + +/** + Instructs the remote harts to execute one or more SFENCE.VVMA instructio= ns. + + The SFENCE.GVMA covers the range of virtual addresses between StartAaddr= and Size. + This function call is only valid for harts implementing the hypervisor e= xtension. + + The remote fence function acts as a full tlb flush if * StartAddr and si= ze + are both 0 * size is equal to 2^XLEN-1 + + @param[in] HartMask Scalar bit-vector containing hart ids + @param[in] HartMaskBase The starting hartid from which the bit-= vector + must be computed. If set to -1, HartMas= k is + ignored and all harts are considered. + @param[in] StartAddr The first address of the affected range. + @param[in] Size How many addresses are affected. + @retval EFI_SUCCESS IPI was sent to all the targeted harts. + @retval EFI_LOAD_ERROR StartAddr or Size is not valid. + @retval EFI_UNSUPPORTED SBI does not implement this function or= one + of the target harts does not support the + hypervisor extension. + @retval EFI_INVALID_PARAMETER Either hart_mask_base or any of the har= tid + from hart_mask is not valid i.e. either= the + hartid is not enabled by the platform o= r is + not available to the supervisor. +**/ +EFI_STATUS +EFIAPI +SbiRemoteHFenceVvma ( + IN UINTN *HartMask, + IN UINTN HartMaskBase, + IN UINTN StartAddr, + IN UINTN Size + ) +{ + SbiRet Ret =3D SbiCall (SBI_EXT_RFENCE, + SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID, + 4, + (UINTN) HartMask, + HartMaskBase, + StartAddr, + Size); + return TranslateError(Ret.Error); +} + +// +// SBI interface function for the vendor extension +// + +/** + Call a function in a vendor defined SBI extension + + ASSERT() if the ExtensionId is not in the designated SBI Vendor Extension + Space. + + @param[in] ExtensionId The SBI vendor extension ID. + @param[in] FunctionId The function ID to call in this extensi= on. + @param[in] NumArgs How many arguments are passed. + @param[in] ... Actual Arguments to the function. + @retval EFI_SUCCESS if the SBI function was called and it was successful + @retval EFI_INVALID_PARAMETER if NumArgs exceeds 6 + @retval others if the called SBI function returns an error +**/ +EFI_STATUS +EFIAPI +SbiVendorCall ( + IN UINTN ExtensionId, + IN UINTN FunctionId, + IN UINTN NumArgs, + ... + ) +{ + SbiRet Ret; + VA_LIST Args; + VA_START(Args, NumArgs); + + ASSERT (ExtensionId >=3D 0x09000000 && ExtensionId <=3D 0x09FFFFFF); + + switch (NumArgs) { + case 0: + Ret =3D SbiCall (ExtensionId, FunctionId, NumArgs); + break; + case 1: + Ret =3D SbiCall (ExtensionId, FunctionId, NumArgs, VA_ARG(Args, UI= NTN)); + break; + case 2: + Ret =3D SbiCall (ExtensionId, FunctionId, NumArgs, VA_ARG(Args, UI= NTN), + VA_ARG(Args, UINTN)); + break; + case 3: + Ret =3D SbiCall (ExtensionId, FunctionId, NumArgs, VA_ARG(Args, UI= NTN), + VA_ARG(Args, UINTN), VA_ARG(Args, UINTN)); + break; + case 4: + Ret =3D SbiCall (ExtensionId, FunctionId, NumArgs, VA_ARG(Args, UI= NTN), + VA_ARG(Args, UINTN), VA_ARG(Args, UINTN), VA_ARG(Ar= gs, UINTN)); + break; + case 5: + Ret =3D SbiCall (ExtensionId, FunctionId, NumArgs, VA_ARG(Args, UI= NTN), + VA_ARG(Args, UINTN), VA_ARG(Args, UINTN), + VA_ARG(Args, UINTN), VA_ARG(Args, UINTN)); + break; + case 6: + Ret =3D SbiCall (ExtensionId, FunctionId, NumArgs, VA_ARG(Args, UI= NTN), + VA_ARG(Args, UINTN), VA_ARG(Args, UINTN), + VA_ARG(Args, UINTN), VA_ARG(Args, UINTN), + VA_ARG(Args, UINTN)); + break; + default: + // Too many args. In theory SBI can handle more arguments when the= y are + // passed on the stack but no SBI extension uses this, therefore i= t's + // not yet implemented here. + return EFI_INVALID_PARAMETER; + } + + VA_END(Args); + return TranslateError(Ret.Error); +} + +// +// SBI Firmware extension +// + +/** + Get scratch space of the current hart. + + Please consider using the wrapper SbiGetFirmwareContext if you only need= to + access the firmware context. + + @param[out] ScratchSpace The scratch space pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiGetMscratch ( + OUT SBI_SCRATCH **ScratchSpace + ) +{ + SbiRet Ret =3D SbiCall (SBI_EDK2_FW_EXT, SBI_EXT_FW_MSCRATCH_FUNC, 0); + + if (!Ret.Error) { + *ScratchSpace =3D (SBI_SCRATCH *) Ret.Value; + } + + return EFI_SUCCESS; +} + +/** + Get scratch space of the given hart id. + + @param[in] HartId The hart id. + @param[out] ScratchSpace The scratch space pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiGetMscratchHartid ( + IN UINTN HartId, + OUT SBI_SCRATCH **ScratchSpace + ) +{ + SbiRet Ret =3D SbiCall (SBI_EDK2_FW_EXT, + SBI_EXT_FW_MSCRATCH_HARTID_FUNC, + 1, + HartId); + + if (!Ret.Error) { + *ScratchSpace =3D (SBI_SCRATCH *) Ret.Value; + } + + return EFI_SUCCESS; +} + +/** + Get firmware context of the calling hart. + + @param[out] FirmwareContext The firmware context pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiGetFirmwareContext ( + OUT EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT **FirmwareContext + ) +{ + SBI_SCRATCH *ScratchSpace; + SBI_PLATFORM *SbiPlatform; + SbiRet Ret =3D SbiCall (SBI_EDK2_FW_EXT, SBI_EXT_FW_MSCRATCH_FUNC, 0); + + if (!Ret.Error) { + ScratchSpace =3D (SBI_SCRATCH *) Ret.Value; + SbiPlatform =3D (SBI_PLATFORM *) sbi_platform_ptr(ScratchSpace); + *FirmwareContext =3D (EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *) SbiPlatfor= m->firmware_context; + } + + return EFI_SUCCESS; +} + +/** + Set firmware context of the calling hart. + + @param[in] FirmwareContext The firmware context pointer. + @retval EFI_SUCCESS The operation succeeds. +**/ +EFI_STATUS +EFIAPI +SbiSetFirmwareContext ( + IN EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext + ) +{ + SBI_SCRATCH *ScratchSpace; + SBI_PLATFORM *SbiPlatform; + SbiRet Ret =3D SbiCall (SBI_EDK2_FW_EXT, SBI_EXT_FW_MSCRATCH_FUNC, 0); + + if (!Ret.Error) { + ScratchSpace =3D (SBI_SCRATCH *) Ret.Value; + SbiPlatform =3D (SBI_PLATFORM *) sbi_platform_ptr(ScratchSpace); + SbiPlatform->firmware_context =3D (UINTN) FirmwareContext; + } + + return EFI_SUCCESS; +} --=20 2.26.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 (#60463): https://edk2.groups.io/g/devel/message/60463 Mute This Topic: https://groups.io/mt/74548545/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-