From nobody Sat Feb 7 08:27:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82278+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82278+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=hpe.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 163461545380531.77299242946185; Mon, 18 Oct 2021 20:50:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TofIYY1788612xgDKJCXTFxP; Mon, 18 Oct 2021 20:50:53 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web09.5150.1634615448302611590 for ; Mon, 18 Oct 2021 20:50:52 -0700 X-Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19J11v6j010180; Tue, 19 Oct 2021 03:50:48 GMT X-Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0a-002e3701.pphosted.com with ESMTP id 3bs5guyn09-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Oct 2021 03:50:47 +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 g4t3426.houston.hpe.com (Postfix) with ESMTPS id EA16F6E; Tue, 19 Oct 2021 03:50:46 +0000 (UTC) X-Received: from G9W8453.americas.hpqcorp.net (2002:10d8:a0d3::10d8:a0d3) by G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 19 Oct 2021 03:50:46 +0000 X-Received: from NAM02-BN1-obe.outbound.protection.outlook.com (15.241.52.10) by G9W8453.americas.hpqcorp.net (16.216.160.211) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Tue, 19 Oct 2021 03:50:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AjL0k8sDvYKdCdIxVvW/IYbq9furPZnI0RgQ8Rh2lHsbgYq+WI7DNiUYAq7mV52sqM84u//n2soWaJlyJm2eBGos27S1tv/wswOJcjvKUghS5PaTi6ap40UN0XFWVwCHtBDtPCdJNx7ZQLE0pTtSf8dMMU9Qj8296juve4srUDG+0ktAvVi0jv0jgfJrUxH3TPIe//hX4vIrrOykieEwR1BfJoE57paBwr4bCdzdj4W++rUCKDYlaFNfmYFJwQLonEtAxZewOoVllOBEW2gBaKIh62rA+GFAKsR1uMYJHTiD6aXhssK3xAo5LPRxzoJQVc5iHf+xXOCe2t7mgji0lA== 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=PT11H1cWoiOGspHAjIh6vGe6tsJlJMyOShyZO6RGYCw=; b=akbmSQdwIM02Gde1v1K5glZVQN4P+YchhJVgDJ3kGQGNaM0TfQ1OapiI1NBbBuzxzCwn6wT2hOfomAS53WqjVOZxe6U44dhlYnR5fgK9ZzZq6cZn2lKzEekLnT7fPfwPhejeNyqhXdz3x607fEGy0F1lJmbhW2vyuKGDwXE2SXdP9oG1pH5sPyBmxx7xm1GZydfLH2wP8tf8lT+DhhDUq4usj6YCsJuukHViP8wZGGygdTORW7LK+FhGncVbnXq6rZliA0hxLpwucZ2/jEDy+lGpKPcnxvb/lvIYevabk5PKsE71DQC1XD3GIWv4WUufOr3AkhVk+rD/5h+oG/+wqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none X-Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) by DF4PR8401MB0921.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Tue, 19 Oct 2021 03:50:45 +0000 X-Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::597f:4786:f1d6:8469]) by DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::597f:4786:f1d6:8469%3]) with mapi id 15.20.4608.018; Tue, 19 Oct 2021 03:50:45 +0000 From: "Daniel Schaefer" To: CC: Daniel Schaefer , Abner Chang , Sunil V L Subject: [edk2-devel] [edk2-platforms] [PATCH v3 12/14] RISC-V: Switch to latest OpenSBI Date: Tue, 19 Oct 2021 11:48:47 +0800 Message-ID: <20211019034849.16847-13-daniel.schaefer@hpe.com> In-Reply-To: <20211019034849.16847-1-daniel.schaefer@hpe.com> References: <20211019034849.16847-1-daniel.schaefer@hpe.com> X-ClientProxiedBy: SG2PR03CA0134.apcprd03.prod.outlook.com (2603:1096:4:c8::7) To DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) MIME-Version: 1.0 X-Received: from zbook-nix.wireless.hpe.com (15.211.146.34) by SG2PR03CA0134.apcprd03.prod.outlook.com (2603:1096:4:c8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.11 via Frontend Transport; Tue, 19 Oct 2021 03:50:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 24333843-b4d7-4a12-5be2-08d992b3a104 X-MS-TrafficTypeDiagnostic: DF4PR8401MB0921: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: RYqn174HqKVCZgCJ9l4zw6B6Q+k7QdibC0EjC2YTnyDEbmHHgo/Uw/PcIFAZzzfMH2p36FwJNUYO0HgB+YQqO6TbcqnbHf/hsiaoDj00jFOOzI3MxUW+WIeIlrz598q8zr+jE66HGK2poJaMBkpl/neK1j4tfkmNRUhDpQAUzFofwp0ZSQ/bDFwBYgtpFxX8N8ECDE9XZKNjllWU2vrTEfTwOAK53yq1p7TroZ/X5vwudkNT43cYdUJQdgB6IKgpJkiJBQiO8vPRQlG5qnwt9663IujDOwsF84PUaV3v07efPMi5+k8ssUsRQwtUtayvLSY0kQE77QeEILdhipoTZe8A0Okk9TOqtk4c45ReDaSqtZUfoXnOUgIA1fMI4uG/iCMQHMIe84tvlKbvOTBiQ+QsKyW++Z4HIMS6GIo1fxRCsrybLpnOaie4Bf9mJ3GCDBnNz9vFYDnPTyLxmFamjS/R59ixHtNbY81ygEvC2XPhkHEfSqGKz8KZ92gB+VqNVIMI/wV1f/HpiTor8iOhSjEi0Lak+Dy9M+69umTAnQS4+cV4f3gcbhj3sxCJkOAixDLx7wsZ01bSbkdp8kh3cOlPlCo9bewggh8B+Pt5cYUG2ciJmIwy/Nugk/r2hiG27BXG98IeG4wb3ljjGTDoo6rB0W9fiRfWKKm7zN4rPgMvBUjY1Yc+2Rwb/sC2XSaQT7rnYwz+ViEeJRPVCnOXWg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?rgkYMcqe6bA+Zentgk79u3GSVJSHwalTFkzBfjahGEOemnTpZM4wpoekiHn7?= =?us-ascii?Q?S/N9XAJaIcKKFQF2v+EOJYNT4NziLKqz1qFngS5JXUZ/kqX3PnjCK0teXLkp?= =?us-ascii?Q?iRXhGP9JIXVuvmu/NMox1qp3QpDdkuhL2VG54TK72704fxrCSuGaGW5xOLVQ?= =?us-ascii?Q?GlWwTNKKnNuKbZyHBKDv3fzKlIOs/8E0CwChSoMwcjsrhVqtkhhQPeODwrsg?= =?us-ascii?Q?Rg2VekiXm4+O2EZ9rc3Y6vfsvc3fa57Uc27+qf2VU+e4PcPKHPEIf7OLmHfH?= =?us-ascii?Q?rMD2PKCiK1Yt10SvjQ7eQUE2PSlTYjUZXNn4Z9BKaSu/aawj84c7vlK2PU11?= =?us-ascii?Q?BlaC95TcCjG2gJKoPSEBwFMwCS8J/7CBFzir7TzM9bJgjXd9zu1wu0DAQBxt?= =?us-ascii?Q?lPWl3Wu/OCSIpZrfnLmMiYLBT+p3AQQCa413sRc/CcGL0ae0yqOnMKkJinpn?= =?us-ascii?Q?qRMPene8ejnnkztAHfWGcgkl/kqPbypu+VW5hKFEQNPFsu0ZYnRsta1sL6UJ?= =?us-ascii?Q?nKSsU3Cv1VwmKQZjIt9bXg1nr++UWZxaJxfb+mMneNFj9jBPvip8+c8gXckY?= =?us-ascii?Q?dN9QzRcwF9vLYkNY4E3RuilwmaOJL02YJYbExx9wNP2SkbiX7jlu3Z1hzsqN?= =?us-ascii?Q?u+M/fta3ahbYlgwQHFZOEBVKmdm7PGDsUJsabK3yfPbB5vnN9RQKXqc/3X6U?= =?us-ascii?Q?qWTAjGrDgYRfc3DuRr9YuYsCqP1F2n15ZvU2/NV8QeduOcLpctL8wWPwCing?= =?us-ascii?Q?8a85VXyDpJ83pRu9a6+PNg9bElVNkh/yO4kZjnNnFbrSyo275boTUjzbPP6p?= =?us-ascii?Q?eabMxwknNv3ifEe18VPCm5XaxOU9N34s4jqOIsmboDvfT9RC4Q0m+NElFvBe?= =?us-ascii?Q?Gk7NWR1S9TUvFuSwBE3BiLekDCW07dkH7NQctLlyIzqtOQUWA8oNaYbYwpzc?= =?us-ascii?Q?t4Tz/Rdfs99xtH+OnIkRpcMiq4mbTDQrQ1ofVtm9l/R2N/X2l6fKejlgCqXU?= =?us-ascii?Q?kSRpy90HKvvXTgy2h6uyCqGMMjjHLsDB7C6KecahPE+TP+IxSOZZNJT9ID8n?= =?us-ascii?Q?xPi70XaUe7ROpFqcbaqZ+qQroap3nxW3kOZhtc3YBTmmYrSuvTvZE6+sw36L?= =?us-ascii?Q?mPYdGzNlHS1XMMxRkkCmcFWXKVaUhooXqKn7R1zfzSFIDTWtywBZ8yTjhOSy?= =?us-ascii?Q?jkjVEAFVTF2m86rdnvQiuDTmc0/j/0leRX+Btbdqph6/eLcHEzzVE4HX73OT?= =?us-ascii?Q?sRe0AFEehdmT2aRd/2ayDztEPvuJAXNpVB2euUWLFkWz7rk/ZpujG9kLKPb/?= =?us-ascii?Q?UMQzV971TvDKHzEciDnLTv5b?= X-MS-Exchange-CrossTenant-Network-Message-Id: 24333843-b4d7-4a12-5be2-08d992b3a104 X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 03:50:45.0373 (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: CvrLUg8Jqre2PeYc2QvRbAXmaF1JTuXEuA6jD4rAtDOb6p2Haz1IRkg3wOCBMZulal99DldkIEYMppmeVsChPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0921 X-OriginatorOrg: hpe.com X-Proofpoint-ORIG-GUID: OYoS0Uw-79lakwbISy16UVEf62ei-WQ8 X-Proofpoint-GUID: OYoS0Uw-79lakwbISy16UVEf62ei-WQ8 X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,daniel.schaefer@hpe.com X-Gm-Message-State: V52gjDzu3390jaM0ZQsg1cmtx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634615453; bh=InGfgwAChALcuKu0UNwrRwAebDzJwLZ1zJTRjwdBrwY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=GPu4e5oXf499sheoF05Lt+9mRN+N3TvhPEVnQZsxuFn3lXJ09eazhTT8hueTllcAWlw QDakpCbWzmXu+mH/bQA8OQCYN4afJ68HEKN8mc1HAfErjuQutmVK1IzlAFj0Er/agyMMV q/ITNbOemUcKz9h3kcIkvMfAPKcta6eS8FQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634615455602100011 Content-Type: text/plain; charset="utf-8" Cc: Daniel Schaefer Cc: Abner Chang Cc: Sunil V L Reviewed-by: Abner Chang Signed-off-by: Daniel Schaefer --- Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf = | 13 +++- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/Opensb= iPlatformLib/PlatformOverride.h | 57 +++++++------- Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h = | 1 + Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h = | 1 + Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platform.c = | 27 ++++--- Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c = | 5 +- Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlatformL= ib/Platform.c | 29 +------ Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/Opensb= iPlatformLib/Platform.c | 31 +++----- Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.c = | 81 +++++++++++++++++++- Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S = | 2 + 10 files changed, 154 insertions(+), 93 deletions(-) diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpens= biLib.inf b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensb= iLib.inf index 71cc76444eef..e40a797896be 100644 --- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.i= nf +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.i= nf @@ -23,6 +23,7 @@ opensbi/lib/sbi/sbi_bitmap.c opensbi/lib/sbi/sbi_bitops.c opensbi/lib/sbi/sbi_console.c + opensbi/lib/sbi/sbi_domain.c opensbi/lib/sbi/sbi_ecall.c opensbi/lib/sbi/sbi_ecall_base.c opensbi/lib/sbi/sbi_ecall_hsm.c @@ -51,27 +52,33 @@ =20 opensbi/lib/utils/fdt/fdt_helper.c opensbi/lib/utils/fdt/fdt_fixup.c + opensbi/lib/utils/fdt/fdt_domain.c opensbi/lib/utils/ipi/fdt_ipi.c - opensbi/lib/utils/ipi/fdt_ipi_clint.c + opensbi/lib/utils/ipi/aclint_mswi.c + opensbi/lib/utils/ipi/fdt_ipi_mswi.c opensbi/lib/utils/irqchip/fdt_irqchip.c opensbi/lib/utils/irqchip/fdt_irqchip_plic.c opensbi/lib/utils/irqchip/plic.c opensbi/lib/utils/reset/fdt_reset.c opensbi/lib/utils/reset/fdt_reset_htif.c opensbi/lib/utils/reset/fdt_reset_sifive.c + opensbi/lib/utils/reset/fdt_reset_thead.c + opensbi/lib/utils/reset/fdt_reset_thead_asm.S opensbi/lib/utils/serial/fdt_serial.c opensbi/lib/utils/serial/fdt_serial_htif.c opensbi/lib/utils/serial/fdt_serial_shakti.c opensbi/lib/utils/serial/fdt_serial_sifive.c opensbi/lib/utils/serial/fdt_serial_uart8250.c + opensbi/lib/utils/serial/fdt_serial_gaisler.c + opensbi/lib/utils/serial/gaisler-uart.c opensbi/lib/utils/serial/shakti-uart.c opensbi/lib/utils/serial/sifive-uart.c opensbi/lib/utils/serial/uart8250.c - opensbi/lib/utils/sys/clint.c opensbi/lib/utils/sys/htif.c opensbi/lib/utils/sys/sifive_test.c opensbi/lib/utils/timer/fdt_timer.c - opensbi/lib/utils/timer/fdt_timer_clint.c + opensbi/lib/utils/timer/aclint_mtimer.c + opensbi/lib/utils/timer/fdt_timer_mtimer.c =20 [Packages] EmbeddedPkg/EmbeddedPkg.dec # For libfdt. diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/PlatformOverride.h b/Platform/SiFive/U5SeriesPkg/F= reedomU540HiFiveUnleashedBoard/Library/OpensbiPlatformLib/PlatformOverride.h index 9b6fcdc15f45..467ebbd4b889 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/PlatformOverride.h +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/PlatformOverride.h @@ -1,27 +1,30 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2020 Western Digital Corporation or its affiliates. - * - * Authors: - * Anup Patel - */ - -#ifndef __PLATFORM_OVERRIDE_H__ -#define __PLATFORM_OVERRIDE_H__ - -#include - -struct platform_override { - const struct fdt_match *match_table; - u64 (*features)(const struct fdt_match *match); - u64 (*tlbr_flush_limit)(const struct fdt_match *match); - int (*early_init)(bool cold_boot, const struct fdt_match *match); - int (*final_init)(bool cold_boot, const struct fdt_match *match); - void (*early_exit)(const struct fdt_match *match); - void (*final_exit)(const struct fdt_match *match); - int (*system_reset)(u32 reset_type, const struct fdt_match *match); - int (*fdt_fixup)(void *fdt, const struct fdt_match *match); -}; - -#endif +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#ifndef __PLATFORM_OVERRIDE_H__ +#define __PLATFORM_OVERRIDE_H__ + +#include + +struct platform_override { + const struct fdt_match *match_table; + u64 (*features)(const struct fdt_match *match); + u64 (*tlbr_flush_limit)(const struct fdt_match *match); + int (*early_init)(bool cold_boot, const struct fdt_match *match); + int (*final_init)(bool cold_boot, const struct fdt_match *match); + void (*early_exit)(const struct fdt_match *match); + void (*final_exit)(const struct fdt_match *match); + int (*system_reset_check)(u32 reset_type, u32 reset_reason, + const struct fdt_match *match); + void (*system_reset)(u32 reset_type, u32 reset_reason, + const struct fdt_match *match); + int (*fdt_fixup)(void *fdt, const struct fdt_match *match); +}; + +#endif diff --git a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h = b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h index f81ea06b05b0..66a87cb8c38f 100644 --- a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h +++ b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h @@ -16,6 +16,7 @@ #include #include #include +#include =20 // // EDK2 OpenSBI Firmware extension. diff --git a/Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h b/Silicon/R= ISC-V/ProcessorPkg/Include/OpensbiTypes.h index 00c374f24a85..bbf74e2a82fe 100644 --- a/Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h +++ b/Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h @@ -49,6 +49,7 @@ typedef UINT64 physical_size_t; =20 #define __packed __attribute__((packed)) #define __noreturn __attribute__((noreturn)) +#define __aligned(x) __attribute__((aligned(x))) =20 #if defined(__GNUC__) || defined(__clang__) #define likely(x) __builtin_expect((x), 1) diff --git a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Pla= tform.c b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platfo= rm.c index e78d811f4c3d..b7e39d19c16f 100644 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platform.c +++ b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platform.c @@ -14,31 +14,38 @@ #include =20 const struct sbi_platform_operations platform_ops =3D { - .pmp_region_count =3D NULL, - .pmp_region_info =3D NULL, + .early_init =3D NULL, .final_init =3D NULL, + .early_exit =3D NULL, + .final_exit =3D NULL, + .domains_root_regions =3D NULL, + .domains_init =3D NULL, .console_putc =3D NULL, .console_getc =3D NULL, .console_init =3D NULL, .irqchip_init =3D NULL, + .irqchip_exit =3D NULL, .ipi_send =3D NULL, .ipi_clear =3D NULL, .ipi_init =3D NULL, + .ipi_exit =3D NULL, + .get_tlbr_flush_limit =3D NULL, .timer_value =3D NULL, .timer_event_stop =3D NULL, .timer_event_start =3D NULL, .timer_init =3D NULL, - .system_reboot =3D NULL, - .system_shutdown =3D NULL + .timer_exit =3D NULL, + .system_reset_check =3D NULL, + .system_reset =3D NULL, }; =20 -const struct sbi_platform platform =3D { - .opensbi_version =3D OPENSBI_VERSION, // The O= penSBI version this platform table is built bassed on. - .platform_version =3D SBI_PLATFORM_VERSION(0x0000, 0x0000), // SBI P= latform version 1.0 - .name =3D "NULL platform", +struct sbi_platform platform =3D { + .opensbi_version =3D OPENSBI_VERSION, + .platform_version =3D SBI_PLATFORM_VERSION(0x0, 0x01), + .name =3D "NULL Platform", .features =3D 0, .hart_count =3D 0, + .hart_index2id =3D 0, .hart_stack_size =3D 0, - .disabled_hart_mask =3D 0, - .platform_ops_addr =3D 0 + .platform_ops_addr =3D 0, }; diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c b/Platform= /RISC-V/PlatformPkg/Universal/Sec/SecMain.c index 0af0b4bac831..e9f030f35280 100644 --- a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c +++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c @@ -21,6 +21,7 @@ #include // Reference to header file in opensbi #include // Reference to header file in opensbi #include // Reference to header file in opensbi +#include // Reference to header file in opensbi =20 // // Indicates the boot hart (PcdBootHartId) OpenSBI initialization is done. @@ -434,7 +435,7 @@ EFI_STATUS EFIAPI TemporaryRamDone ( STATIC int SbiEcallFirmwareHandler ( IN unsigned long ExtId, IN unsigned long FuncId, - IN unsigned long *Args, + IN CONST struct sbi_trap_regs *TrapRegs, OUT unsigned long *OutVal, OUT struct sbi_trap_info *OutTrap ) @@ -446,7 +447,7 @@ STATIC int SbiEcallFirmwareHandler ( *OutVal =3D (unsigned long) sbi_scratch_thishart_ptr(); break; case SBI_EXT_FW_MSCRATCH_HARTID_FUNC: - *OutVal =3D (unsigned long) sbi_hartid_to_scratch (Args[0]); + *OutVal =3D (unsigned long) sbi_hartid_to_scratch (TrapRegs->a0); break; default: Ret =3D SBI_ENOTSUPP; diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/Open= sbiPlatformLib/Platform.c b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Boa= rd/Library/OpensbiPlatformLib/Platform.c index ed4b1550bca9..b346eccaf0c8 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlat= formLib/Platform.c +++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/OpensbiPlat= formLib/Platform.c @@ -111,30 +111,6 @@ static int U500_final_init(bool cold_boot) return 0; } =20 -static u32 U500_pmp_region_count(u32 hartid) -{ - return 1; -} - -static int U500_pmp_region_info(u32 hartid, u32 index, - ulong *prot, ulong *addr, ulong *log2size) -{ - int ret =3D 0; - - switch (index) { - case 0: - *prot =3D PMP_R | PMP_W | PMP_X; - *addr =3D 0; - *log2size =3D __riscv_xlen; - break; - default: - ret =3D -1; - break; - }; - - return ret; -} - static int U500_console_init(void) { unsigned long peri_in_freq; @@ -196,15 +172,12 @@ static int U500_timer_init(bool cold_boot) */ static u32 u500_hart_index2id[U500_BOOTABLE_HART_COUNT] =3D {0, 1, 2, 3}; =20 -static int U500_system_reset(u32 type) +static void U500_system_reset(u32 type, u32 second_param) { /* For now nothing to do. */ - return 0; } =20 const struct sbi_platform_operations platform_ops =3D { - .pmp_region_count =3D U500_pmp_region_count, - .pmp_region_info =3D U500_pmp_region_info, .final_init =3D U500_final_init, .console_putc =3D sifive_uart_putc, .console_getc =3D sifive_uart_getc, diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/Platform.c b/Platform/SiFive/U5SeriesPkg/FreedomU5= 40HiFiveUnleashedBoard/Library/OpensbiPlatformLib/Platform.c index fe6e2a8c943a..ac76f073ab53 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/Platform.c +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/Platform.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -71,7 +73,7 @@ unsigned long fw_platform_init(unsigned long arg0, unsign= ed long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4) { - const char *model, *mmu_type; + const char *model; void *fdt =3D (void *)arg1; u32 hartid, hart_count =3D 0; int rc, root_offset, cpus_offset, cpu_offset, len; @@ -101,10 +103,6 @@ unsigned long fw_platform_init(unsigned long arg0, uns= igned long arg1, if (SBI_HARTMASK_MAX_BITS <=3D hartid) continue; =20 - mmu_type =3D fdt_getprop(fdt, cpu_offset, "mmu-type", &len); - if (!mmu_type || !len) - hartid =3D -1U; - generic_hart_index2id[hart_count++] =3D hartid; } =20 @@ -152,6 +150,7 @@ static int generic_final_init(bool cold_boot) =20 fdt_cpu_fixup(fdt); fdt_fixups(fdt); + fdt_domain_fixup(fdt); =20 if (generic_plat && generic_plat->fdt_fixup) { rc =3D generic_plat->fdt_fixup(fdt, generic_plat_match); @@ -174,6 +173,11 @@ static void generic_final_exit(void) generic_plat->final_exit(generic_plat_match); } =20 +static int generic_domains_init(void) +{ + return fdt_domains_populate(sbi_scratch_thishart_arg1_ptr()); +} + static u64 generic_tlbr_flush_limit(void) { if (generic_plat && generic_plat->tlbr_flush_limit) @@ -181,35 +185,20 @@ static u64 generic_tlbr_flush_limit(void) return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT; } =20 -static int generic_system_reset(u32 reset_type) -{ - if (generic_plat && generic_plat->system_reset) - return generic_plat->system_reset(reset_type, - generic_plat_match); - return fdt_system_reset(reset_type); -} - const struct sbi_platform_operations platform_ops =3D { .early_init =3D generic_early_init, .final_init =3D generic_final_init, .early_exit =3D generic_early_exit, .final_exit =3D generic_final_exit, - .console_putc =3D fdt_serial_putc, - .console_getc =3D fdt_serial_getc, + .domains_init =3D generic_domains_init, .console_init =3D fdt_serial_init, .irqchip_init =3D fdt_irqchip_init, .irqchip_exit =3D fdt_irqchip_exit, - .ipi_send =3D fdt_ipi_send, - .ipi_clear =3D fdt_ipi_clear, .ipi_init =3D fdt_ipi_init, .ipi_exit =3D fdt_ipi_exit, .get_tlbr_flush_limit =3D generic_tlbr_flush_limit, - .timer_value =3D fdt_timer_value, - .timer_event_stop =3D fdt_timer_event_stop, - .timer_event_start =3D fdt_timer_event_start, .timer_init =3D fdt_timer_init, .timer_exit =3D fdt_timer_exit, - .system_reset =3D generic_system_reset, }; =20 struct sbi_platform platform =3D { diff --git a/Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.= c b/Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.c index e98c8523a3f3..7bc73a0b82de 100644 --- a/Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.c +++ b/Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.c @@ -19,6 +19,21 @@ #define UART_REG_IP 5 #define UART_IP_RXWM 0x02 =20 + +#define UART_REG_TXFIFO 0 +#define UART_REG_RXFIFO 1 +#define UART_REG_TXCTRL 2 +#define UART_REG_RXCTRL 3 +#define UART_REG_IE 4 +#define UART_REG_IP 5 +#define UART_REG_DIV 6 + +#define UART_TXFIFO_FULL 0x80000000 +#define UART_RXFIFO_EMPTY 0x80000000 +#define UART_RXFIFO_DATA 0x000000ff +#define UART_TXCTRL_TXEN 0x1 +#define UART_RXCTRL_RXEN 0x1 + //--------------------------------------------- // UART Settings //--------------------------------------------- @@ -28,6 +43,68 @@ =20 BOOLEAN Initiated =3D FALSE; =20 +/** + Get value from serial port register. + + @param RegIndex Register index + + @retval Vale returned from from serial port. + +**/ +UINT32 GetReg ( + IN UINT32 RegIndex + ) +{ + return MmioRead32 (FixedPcdGet32(PcdU5UartBase) + (RegIndex * 0x4)); +} + +/** + Set serial port register. + + @param RegIndex Register index + @param Value Value write to Register + +**/ +VOID SetReg ( + IN UINT32 RegIndex, + IN UINT32 Value + ) +{ + MmioWrite32 (Value, FixedPcdGet32(PcdU5UartBase) + (RegIndex * 0x4)); +} + +/** + Character output to serial port. + + @param Ch The character to serial port. + +**/ +VOID SifiveUartPutChar ( + IN UINT8 Ch + ) +{ + while (GetReg (UART_REG_TXFIFO) & UART_TXFIFO_FULL); + + SetReg (UART_REG_TXFIFO, Ch); +} + +/** + Get character from serial port. + + @retval character The character from serial port. + +**/ +UINT32 SifiveUartGetChar (VOID) +{ + UINT32 Ret; + + Ret =3D GetReg (UART_REG_RXFIFO); + if (!(Ret & UART_RXFIFO_EMPTY)) { + return Ret & UART_RXFIFO_DATA; + } + return -1; +} + /** Initialize the serial device hardware. =20 @@ -88,7 +165,7 @@ SerialPortWrite ( } =20 for(Index =3D 0; Index < NumberOfBytes; Index ++) { - sifive_uart_putc (Buffer [Index]); + SifiveUartPutChar (Buffer [Index]); } =20 return Index; @@ -119,7 +196,7 @@ SerialPortRead ( } =20 for (Index =3D 0; Index < NumberOfBytes; Index ++) { - Buffer [Index] =3D (UINT8)sifive_uart_getc (); + Buffer [Index] =3D (UINT8)SifiveUartGetChar (); } =20 return Index; diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S b= /Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S index 0e3940180d44..a8157c896e6f 100644 --- a/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S +++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S @@ -21,6 +21,8 @@ .text .align 3 =20 + .globl _start_warm + ASM_FUNC (_ModuleEntryPoint) /* * Jump to warm-boot if this is not the selected core booting, --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82278): https://edk2.groups.io/g/devel/message/82278 Mute This Topic: https://groups.io/mt/86432330/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-