From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web08.10715.1633521593590668542 for ; Wed, 06 Oct 2021 04:59:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Ror917f6; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0913d10296=daniel.schaefer@hpe.com) Received: from pps.filterd (m0134422.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1969Vwd0032536; Wed, 6 Oct 2021 11:59:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=pps0720; bh=UDEwG4PL9uRPd/MRnAmn6s754X94Br2aa2QG9akSlJI=; b=Ror917f6Dj80H9FQdj+i7UQ3sxb5AYkuYrMqeyOz4RSaKNv879As6VU9LDcMw24aAMQk F9hzd1mXBNYaY8B6BVjBpdLw/nFReMtiWpQWx5C6LAHyfvCZDmwpD/Y2mwFKA4SqHoaD jsUsWxSScwTc4NpqsTJzXJUyf1QclV9IXAKqAMWSYaa40iUW5El+qGHUN0VUOrYrXKma fDbrtIS/PNPcFrRn/AIHlpWx6Qq4/a/HoyRDkwJcchb3ourhAkxTSmiMaUt7CfFBJW+K gdfu7WWHI3YKD8oEOgEuDWVMhGMXyjLHd0cWZ5TFSp+DVBL8YIkoy0kQ4eCoPOsF+isR uQ== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 3bh5myb3pt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Oct 2021 11:59:53 +0000 Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id 4C5A89B; Wed, 6 Oct 2021 11:59:52 +0000 (UTC) Received: from G9W8672.americas.hpqcorp.net (16.220.49.31) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 6 Oct 2021 11:59:52 +0000 Received: from G1W8106.americas.hpqcorp.net (16.193.72.61) by G9W8672.americas.hpqcorp.net (16.220.49.31) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 6 Oct 2021 11:59:30 +0000 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (15.241.52.11) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Wed, 6 Oct 2021 11:59:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHugTeDmLMSYzz7PZr2GSMBe18KS2Yz2QZYnV/IY9OfC9Jul63hVFKKamdNjmGOG0OYQs3mZZ2PyERdD5re8isynbd7SBp7NibXOU/NM//lsu/n/0alfSEnnUuYktzHYULRClDAtG1Kn2tfYQqYTy7RWjdTlulQjPBCdsLwcNAPFx/lViBW1J0k3JC1hff8mHp00CXHrh+vVb5sxnskNf5NDnB2yT9D2VMq9+Q4HS2cvVP9zIOYJb9Hq8YExPUr1PDU+VhSORi5jrAQcqVtJ2cv8OGR9DOQO+W8H01HHPrBcYYFna9MKGSTX8FaeXonFPvXKapXwK3qkQBgGKFb+7g== 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=UDEwG4PL9uRPd/MRnAmn6s754X94Br2aa2QG9akSlJI=; b=Wz3htKQa2rgdF5SKshAW3ZFkVKW3gxAlMOZB1/63n98ZWfgYDyDXYYrdZkqz44U9LnNXSkGwCHD8wXqYl5q4aPcHfqXHJngfHdyruvW/qir8ZxJcD8FyFvaFdmYY69jfRMezILA94mRW6DRw26wn5iNn2cixAolvP2DgVuBaRqRFOvbHpfDgCCeyPzRUAqS4kK0uUP2U54eg1VcOeVfNjSgziNVIHvyBfg7OtOJHo5n4+eyTg+Ipf3qDQrd50P/wAZOdav7F3RQAetzAWBS1eCL42qOXezHxAWgvzdkTmNunfOqyEzztPtUSGdvA0NhU0B22FEvsQsEpW8xUq7RnMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) by DF4PR8401MB1034.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7613::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Wed, 6 Oct 2021 11:59:26 +0000 Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::597f:4786:f1d6:8469]) by DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::597f:4786:f1d6:8469%3]) with mapi id 15.20.4566.023; Wed, 6 Oct 2021 11:59:26 +0000 From: "Daniel Schaefer" To: CC: Abner Chang , Sunil V L Subject: [[edk2-platforms] PATCH v2 12/14] RISC-V: Switch to latest OpenSBI Date: Wed, 6 Oct 2021 19:58:34 +0800 Message-ID: <20211006115836.3641776-5-daniel.schaefer@hpe.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211006115836.3641776-1-daniel.schaefer@hpe.com> References: <20211006115836.3641776-1-daniel.schaefer@hpe.com> X-ClientProxiedBy: HK2PR02CA0159.apcprd02.prod.outlook.com (2603:1096:201:1f::19) To DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) MIME-Version: 1.0 Received: from localhost.localdomain (123.193.59.220) by HK2PR02CA0159.apcprd02.prod.outlook.com (2603:1096:201:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Wed, 6 Oct 2021 11:59:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9238a20-7fd1-46de-5453-08d988c0beb8 X-MS-TrafficTypeDiagnostic: DF4PR8401MB1034: 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: BCL:0; X-Microsoft-Antispam-Message-Info: MvbJ3JpejA6onClwiIL3E4Qha2fEVCB2iXt3Bl3nc1vOKYr6V6rfN6KefXptE5gJb4HizJM2a9UPVd4bNzNGx57/cKYPRk2YC9Ufefb/o25isYqxWJFmyMc9Dmbb/V+Bx23QDBDOIxMy/PhUVx/G+t6xInnj897TI7Fk7mfggw92c9b4GoBi+qe+0tNQOtJeeLisLa8aakIhEFcOKziv4qM/XEqbPkrrTqs5vryIUztXxujbZ4amdtHyiJsYs0NR/yPj3JL3MfB2yp9Ndh+YQThAaZA407oJpRn0BjRoD6ubUngwepVY7yI05LWwhgD838+cxcioeO26s/voTh0UVShqpaV8BOi9uKQANMSH8Iv/dkcoXV0Bs2rynq1XwV1t1n9TOMFRvlDBhVRscmrVxxx4EvMbjxzcfVRSkiGM/MHMajrEWaEUJbq+49yx44mRWpY3CZna9lL42kS3W8acllTb9KjWIBMo5xuMTyXpSoPnvjalQ8r2vSJhvSh87Xxai/sfK+31XmSsd+m/E9QgheahmDsr+ebRCgVoU0cQ7lmmiwuFU12Fzet3zGG/6xe0pG8C5y//HctIbnqltejTm0vCus5/JERLb84LNprHcso8U58AjoEPQYD8q2c2fBj5YYkfuXO5op4zs5tX3s4KoaWbu57+3a1O7ePO3XSWmCXFL0P6tP4t1OzxwPRBL5GS9RSY4FWrg31hoslRekVenQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(366004)(186003)(6506007)(956004)(316002)(26005)(52116002)(6916009)(8676002)(8936002)(5660300002)(6486002)(508600001)(83380400001)(30864003)(6666004)(66556008)(66476007)(38350700002)(6512007)(38100700002)(86362001)(36756003)(4326008)(2906002)(54906003)(2616005)(1076003)(66946007)(44832011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tjCS0cQUA9SoEsvQtAct22rZkiERfuu+TvNY8x/bFsWkuAyfofUrmtj7qm0b?= =?us-ascii?Q?rS6WJG7wfi+7ijBXUoPCO2dOpQyjCv904VA57jwQI64fjJ5dn76/hyOscjE+?= =?us-ascii?Q?SgZZx72V9H+MvwKbIpL7eFUKEePmVgg6/2pfqq8VznxBvO3KrF15R+REjoF3?= =?us-ascii?Q?27WvtPsAnG2nOdwwnAMcmV9K3MzNffEe15R5exzYWJUGYMU0rCn67Hq7YeF7?= =?us-ascii?Q?89OVw01i1aNZnsuFq/vcBOhoxZxsteBTRUbDQEuDjroGRouqPMHP6Q2xbmQb?= =?us-ascii?Q?a0Fzws8Rt+AMzi0xNDZIJEg3bewvPnHY485iVpttQn0kL59SUB14UzXv8npi?= =?us-ascii?Q?rE/MvZ0mqwKqJaaB0xCL0/yi2fPJXwQwP5cXFdmL94DbBO95QlTb0q/mZG66?= =?us-ascii?Q?MoLQrMo+PvlHt6OlfzJtcy33jh4FKO+8R2Jhio/F3rpUU8GQ/HRVmHlVhJM8?= =?us-ascii?Q?50SzkTCUaSADBJc4KVsxBpQUADNrCuuPBSkeuERKyp+igDfGR1Y8sj/ltJlq?= =?us-ascii?Q?4QpTIaxuXoCDqN0C8wjQ3P+o2PW1CY/6HWt7IHXpjMVdcV+h/7vZeSt21Jfm?= =?us-ascii?Q?e0L8D/Pt5tbtVahrtsD6Q/FxAp61YdF5CA/DoplHDhW1zBvlWUFz/v9zfkS3?= =?us-ascii?Q?zaV5dh0+lwKIGi5yn+ZqSrHE70SeGVmhoxNjYCDSD+Ekhe2FEDqUWLZvcMkR?= =?us-ascii?Q?qeHVmZs6JmTYX+QXbfasuj+ZKBZYU9fEstH/pyirog5vsqw40xUmxTVGBTbA?= =?us-ascii?Q?1hbKH918J5jxwCLykrXsiTvqeUNeb810MOaivuInTTadfG9p92BlwWetIkc0?= =?us-ascii?Q?UBFdZc+KzeExhJKexA3LA0Hfpx6T61aj7/9GAYdO9JVrPFK6zFXYKcuNvziL?= =?us-ascii?Q?MuVx0bYvn/0AWMIDqp7F+eqc3mxkHE1o+6+5KD5dY/PJKSq1yGibCeT+5c2g?= =?us-ascii?Q?LWimxGFD1P+jr6opgACcP472jjgTG7r+9Klbq4L4g6OPGfbH8FKKGl4gJTN+?= =?us-ascii?Q?PEOtP2VNJMSVjdbc9DQrq+UJFy4bdTi89ImlAs+gQphexbbmP/34YY8ltmW5?= =?us-ascii?Q?YKDyJIPGa7t8XQlRsa35HbLZkZ2pRS14YTjcKL2hr4fFAMTYus0IxJtML5yu?= =?us-ascii?Q?goo5KGxy4e+sbg+mAVEv9gY/y2ElpSlpLuR/Vk+CiiNw3S9+11so3t3k0Zmx?= =?us-ascii?Q?15jhPFIRBiHNaJaB9+xpsaUoMWsgNnnaATvMV//7fqMlJjWHWhA+BnjizmJo?= =?us-ascii?Q?ZKpH63MYAcDtTrsMwlzvmxUwWvkrtv8XTVMA9vRUcDbA30LP08f4fU5SuZfY?= =?us-ascii?Q?ThthVbD6K6R29Mk6cpFwMyJs?= X-MS-Exchange-CrossTenant-Network-Message-Id: d9238a20-7fd1-46de-5453-08d988c0beb8 X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 11:59:26.6344 (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: tXNdGc1LMLEmw8ZinFRkZXh1Eo5VjtowpWDli9XjOm1kXVbEkXh9ea8/OrN7JntH6R2ZBW6IqdTC4yubwV9ecQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB1034 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: 9CfeXFfJh-_AINh7nzItqSbfHu3smRoq X-Proofpoint-ORIG-GUID: 9CfeXFfJh-_AINh7nzItqSbfHu3smRoq X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-06_02,2021-10-06_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110060075 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Cc: Daniel Schaefer Cc: Abner Chang Cc: Sunil V L Signed-off-by: Daniel Schaefer --- Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platform.c = | 27 ++++--- Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S = | 2 + 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/FreedomU540HiFiveUnleashedBoard/Library/Opensb= iPlatformLib/PlatformOverride.h | 5 +- Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.c = | 81 +++++++++++++++++++- Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h = | 1 + Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h = | 1 + Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf = | 13 +++- 10 files changed, 128 insertions(+), 67 deletions(-) diff --git a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Pla= tform.c b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platfo= rm.c index e78d811f4c..b7e39d19c1 100644 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platform.c +++ b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibNull/Platform.c @@ -14,31 +14,38 @@ #include =0D =0D const struct sbi_platform_operations platform_ops =3D {=0D - .pmp_region_count =3D NULL,=0D - .pmp_region_info =3D NULL,=0D + .early_init =3D NULL,=0D .final_init =3D NULL,=0D + .early_exit =3D NULL,=0D + .final_exit =3D NULL,=0D + .domains_root_regions =3D NULL,=0D + .domains_init =3D NULL,=0D .console_putc =3D NULL,=0D .console_getc =3D NULL,=0D .console_init =3D NULL,=0D .irqchip_init =3D NULL,=0D + .irqchip_exit =3D NULL,=0D .ipi_send =3D NULL,=0D .ipi_clear =3D NULL,=0D .ipi_init =3D NULL,=0D + .ipi_exit =3D NULL,=0D + .get_tlbr_flush_limit =3D NULL,=0D .timer_value =3D NULL,=0D .timer_event_stop =3D NULL,=0D .timer_event_start =3D NULL,=0D .timer_init =3D NULL,=0D - .system_reboot =3D NULL,=0D - .system_shutdown =3D NULL=0D + .timer_exit =3D NULL,=0D + .system_reset_check =3D NULL,=0D + .system_reset =3D NULL,=0D };=0D =0D -const struct sbi_platform platform =3D {=0D - .opensbi_version =3D OPENSBI_VERSION, // The O= penSBI version this platform table is built bassed on.=0D - .platform_version =3D SBI_PLATFORM_VERSION(0x0000, 0x0000), // SBI P= latform version 1.0=0D - .name =3D "NULL platform",=0D +struct sbi_platform platform =3D {=0D + .opensbi_version =3D OPENSBI_VERSION,=0D + .platform_version =3D SBI_PLATFORM_VERSION(0x0, 0x01),=0D + .name =3D "NULL Platform",=0D .features =3D 0,=0D .hart_count =3D 0,=0D + .hart_index2id =3D 0,=0D .hart_stack_size =3D 0,=0D - .disabled_hart_mask =3D 0,=0D - .platform_ops_addr =3D 0=0D + .platform_ops_addr =3D 0,=0D };=0D diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S b= /Platform/RISC-V/PlatformPkg/Universal/Sec/Riscv64/SecEntry.S index 0e3940180d..a8157c896e 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=0D .align 3=0D =0D + .globl _start_warm=0D +=0D ASM_FUNC (_ModuleEntryPoint)=0D /*=0D * Jump to warm-boot if this is not the selected core booting,=0D diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c b/Platform= /RISC-V/PlatformPkg/Universal/Sec/SecMain.c index 0af0b4bac8..e9f030f352 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=0D #include // Reference to header file in opensbi=0D #include // Reference to header file in opensbi=0D +#include // Reference to header file in opensbi=0D =0D //=0D // Indicates the boot hart (PcdBootHartId) OpenSBI initialization is done.= =0D @@ -434,7 +435,7 @@ EFI_STATUS EFIAPI TemporaryRamDone ( STATIC int SbiEcallFirmwareHandler (=0D IN unsigned long ExtId,=0D IN unsigned long FuncId,=0D - IN unsigned long *Args,=0D + IN CONST struct sbi_trap_regs *TrapRegs,=0D OUT unsigned long *OutVal,=0D OUT struct sbi_trap_info *OutTrap=0D )=0D @@ -446,7 +447,7 @@ STATIC int SbiEcallFirmwareHandler ( *OutVal =3D (unsigned long) sbi_scratch_thishart_ptr();=0D break;=0D case SBI_EXT_FW_MSCRATCH_HARTID_FUNC:=0D - *OutVal =3D (unsigned long) sbi_hartid_to_scratch (Args[0]);=0D + *OutVal =3D (unsigned long) sbi_hartid_to_scratch (TrapRegs->a0);=0D break;=0D default:=0D Ret =3D SBI_ENOTSUPP;=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/Library/Open= sbiPlatformLib/Platform.c b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Boa= rd/Library/OpensbiPlatformLib/Platform.c index ed4b1550bc..b346eccaf0 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;=0D }=0D =0D -static u32 U500_pmp_region_count(u32 hartid)=0D -{=0D - return 1;=0D -}=0D -=0D -static int U500_pmp_region_info(u32 hartid, u32 index,=0D - ulong *prot, ulong *addr, ulong *log2size)=0D -{=0D - int ret =3D 0;=0D -=0D - switch (index) {=0D - case 0:=0D - *prot =3D PMP_R | PMP_W | PMP_X;=0D - *addr =3D 0;=0D - *log2size =3D __riscv_xlen;=0D - break;=0D - default:=0D - ret =3D -1;=0D - break;=0D - };=0D -=0D - return ret;=0D -}=0D -=0D static int U500_console_init(void)=0D {=0D unsigned long peri_in_freq;=0D @@ -196,15 +172,12 @@ static int U500_timer_init(bool cold_boot) */=0D static u32 u500_hart_index2id[U500_BOOTABLE_HART_COUNT] =3D {0, 1, 2, 3};= =0D =0D -static int U500_system_reset(u32 type)=0D +static void U500_system_reset(u32 type, u32 second_param)=0D {=0D /* For now nothing to do. */=0D - return 0;=0D }=0D =0D const struct sbi_platform_operations platform_ops =3D {=0D - .pmp_region_count =3D U500_pmp_region_count,=0D - .pmp_region_info =3D U500_pmp_region_info,=0D .final_init =3D U500_final_init,=0D .console_putc =3D sifive_uart_putc,=0D .console_getc =3D sifive_uart_getc,=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/Platform.c b/Platform/SiFive/U5SeriesPkg/FreedomU5= 40HiFiveUnleashedBoard/Library/OpensbiPlatformLib/Platform.c index 4deb048566..2f51e45d58 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 =0D #include =0D #include =0D +#include =0D +#include =0D #include =0D #include =0D #include =0D @@ -71,7 +73,7 @@ unsigned long fw_platform_init(unsigned long arg0, unsign= ed long arg1, unsigned long arg2, unsigned long arg3,=0D unsigned long arg4)=0D {=0D - const char *model, *mmu_type;=0D + const char *model;=0D void *fdt =3D (void *)arg1;=0D u32 hartid, hart_count =3D 0;=0D int rc, root_offset, cpus_offset, cpu_offset, len;=0D @@ -101,10 +103,6 @@ unsigned long fw_platform_init(unsigned long arg0, uns= igned long arg1, if (SBI_HARTMASK_MAX_BITS <=3D hartid)=0D continue;=0D =0D - mmu_type =3D fdt_getprop(fdt, cpu_offset, "mmu-type", &len);=0D - if (!mmu_type || !len)=0D - hartid =3D -1U;=0D -=0D generic_hart_index2id[hart_count++] =3D hartid;=0D }=0D =0D @@ -152,6 +150,7 @@ static int generic_final_init(bool cold_boot) =0D fdt_cpu_fixup(fdt);=0D fdt_fixups(fdt);=0D + fdt_domain_fixup(fdt);=0D =0D if (generic_plat && generic_plat->fdt_fixup) {=0D rc =3D generic_plat->fdt_fixup(fdt, generic_plat_match);=0D @@ -174,6 +173,11 @@ static void generic_final_exit(void) generic_plat->final_exit(generic_plat_match);=0D }=0D =0D +static int generic_domains_init(void)=0D +{=0D + return fdt_domains_populate(sbi_scratch_thishart_arg1_ptr());=0D +}=0D +=0D static u64 generic_tlbr_flush_limit(void)=0D {=0D if (generic_plat && generic_plat->tlbr_flush_limit)=0D @@ -181,35 +185,20 @@ static u64 generic_tlbr_flush_limit(void) return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT;=0D }=0D =0D -static int generic_system_reset(u32 reset_type)=0D -{=0D - if (generic_plat && generic_plat->system_reset)=0D - return generic_plat->system_reset(reset_type,=0D - generic_plat_match);=0D - return fdt_system_reset(reset_type);=0D -}=0D -=0D const struct sbi_platform_operations platform_ops =3D {=0D .early_init =3D generic_early_init,=0D .final_init =3D generic_final_init,=0D .early_exit =3D generic_early_exit,=0D .final_exit =3D generic_final_exit,=0D - .console_putc =3D fdt_serial_putc,=0D - .console_getc =3D fdt_serial_getc,=0D + .domains_init =3D generic_domains_init,=0D .console_init =3D fdt_serial_init,=0D .irqchip_init =3D fdt_irqchip_init,=0D .irqchip_exit =3D fdt_irqchip_exit,=0D - .ipi_send =3D fdt_ipi_send,=0D - .ipi_clear =3D fdt_ipi_clear,=0D .ipi_init =3D fdt_ipi_init,=0D .ipi_exit =3D fdt_ipi_exit,=0D .get_tlbr_flush_limit =3D generic_tlbr_flush_limit,=0D - .timer_value =3D fdt_timer_value,=0D - .timer_event_stop =3D fdt_timer_event_stop,=0D - .timer_event_start =3D fdt_timer_event_start,=0D .timer_init =3D fdt_timer_init,=0D .timer_exit =3D fdt_timer_exit,=0D - .system_reset =3D generic_system_reset,=0D };=0D =0D struct sbi_platform platform =3D {=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/PlatformOverride.h b/Platform/SiFive/U5SeriesPkg/F= reedomU540HiFiveUnleashedBoard/Library/OpensbiPlatformLib/PlatformOverride.h index 8a53cdf9ac..77a90d645e 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/PlatformOverride.h +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/PlatformOverride.h @@ -20,7 +20,10 @@ struct platform_override { 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 (*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); }; =20 diff --git a/Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.= c b/Platform/SiFive/U5SeriesPkg/Library/SerialIoLib/SerialPortLib.c index e98c8523a3..7bc73a0b82 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=0D #define UART_IP_RXWM 0x02=0D =0D +=0D +#define UART_REG_TXFIFO 0=0D +#define UART_REG_RXFIFO 1=0D +#define UART_REG_TXCTRL 2=0D +#define UART_REG_RXCTRL 3=0D +#define UART_REG_IE 4=0D +#define UART_REG_IP 5=0D +#define UART_REG_DIV 6=0D +=0D +#define UART_TXFIFO_FULL 0x80000000=0D +#define UART_RXFIFO_EMPTY 0x80000000=0D +#define UART_RXFIFO_DATA 0x000000ff=0D +#define UART_TXCTRL_TXEN 0x1=0D +#define UART_RXCTRL_RXEN 0x1=0D +=0D //---------------------------------------------=0D // UART Settings=0D //---------------------------------------------=0D @@ -28,6 +43,68 @@ =0D BOOLEAN Initiated =3D FALSE;=0D =0D +/**=0D + Get value from serial port register.=0D +=0D + @param RegIndex Register index=0D +=0D + @retval Vale returned from from serial port.=0D +=0D +**/=0D +UINT32 GetReg (=0D + IN UINT32 RegIndex=0D + )=0D +{=0D + return MmioRead32 (FixedPcdGet32(PcdU5UartBase) + (RegIndex * 0x4));=0D +}=0D +=0D +/**=0D + Set serial port register.=0D +=0D + @param RegIndex Register index=0D + @param Value Value write to Register=0D +=0D +**/=0D +VOID SetReg (=0D + IN UINT32 RegIndex,=0D + IN UINT32 Value=0D + )=0D +{=0D + MmioWrite32 (Value, FixedPcdGet32(PcdU5UartBase) + (RegIndex * 0x4));=0D +}=0D +=0D +/**=0D + Character output to serial port.=0D +=0D + @param Ch The character to serial port.=0D +=0D +**/=0D +VOID SifiveUartPutChar (=0D + IN UINT8 Ch=0D + )=0D +{=0D + while (GetReg (UART_REG_TXFIFO) & UART_TXFIFO_FULL);=0D +=0D + SetReg (UART_REG_TXFIFO, Ch);=0D +}=0D +=0D +/**=0D + Get character from serial port.=0D +=0D + @retval character The character from serial port.=0D +=0D +**/=0D +UINT32 SifiveUartGetChar (VOID)=0D +{=0D + UINT32 Ret;=0D +=0D + Ret =3D GetReg (UART_REG_RXFIFO);=0D + if (!(Ret & UART_RXFIFO_EMPTY)) {=0D + return Ret & UART_RXFIFO_DATA;=0D + }=0D + return -1;=0D +}=0D +=0D /**=0D Initialize the serial device hardware.=0D =0D @@ -88,7 +165,7 @@ SerialPortWrite ( }=0D =0D for(Index =3D 0; Index < NumberOfBytes; Index ++) {=0D - sifive_uart_putc (Buffer [Index]);=0D + SifiveUartPutChar (Buffer [Index]);=0D }=0D =0D return Index;=0D @@ -119,7 +196,7 @@ SerialPortRead ( }=0D =0D for (Index =3D 0; Index < NumberOfBytes; Index ++) {=0D - Buffer [Index] =3D (UINT8)sifive_uart_getc ();=0D + Buffer [Index] =3D (UINT8)SifiveUartGetChar ();=0D }=0D =0D return Index;=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h = b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h index f81ea06b05..66a87cb8c3 100644 --- a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h +++ b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVEdk2SbiLib.h @@ -16,6 +16,7 @@ #include =0D #include =0D #include =0D +#include =0D =0D //=0D // EDK2 OpenSBI Firmware extension.=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Include/OpensbiTypes.h b/Silicon/R= ISC-V/ProcessorPkg/Include/OpensbiTypes.h index 00c374f24a..bbf74e2a82 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; =0D #define __packed __attribute__((packed))=0D #define __noreturn __attribute__((noreturn))=0D +#define __aligned(x) __attribute__((aligned(x)))=0D =0D #if defined(__GNUC__) || defined(__clang__)=0D #define likely(x) __builtin_expect((x), 1)=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpens= biLib.inf b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensb= iLib.inf index 71cc76444e..e40a797896 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=0D opensbi/lib/sbi/sbi_bitops.c=0D opensbi/lib/sbi/sbi_console.c=0D + opensbi/lib/sbi/sbi_domain.c=0D opensbi/lib/sbi/sbi_ecall.c=0D opensbi/lib/sbi/sbi_ecall_base.c=0D opensbi/lib/sbi/sbi_ecall_hsm.c=0D @@ -51,27 +52,33 @@ =0D opensbi/lib/utils/fdt/fdt_helper.c=0D opensbi/lib/utils/fdt/fdt_fixup.c=0D + opensbi/lib/utils/fdt/fdt_domain.c=0D opensbi/lib/utils/ipi/fdt_ipi.c=0D - opensbi/lib/utils/ipi/fdt_ipi_clint.c=0D + opensbi/lib/utils/ipi/aclint_mswi.c=0D + opensbi/lib/utils/ipi/fdt_ipi_mswi.c=0D opensbi/lib/utils/irqchip/fdt_irqchip.c=0D opensbi/lib/utils/irqchip/fdt_irqchip_plic.c=0D opensbi/lib/utils/irqchip/plic.c=0D opensbi/lib/utils/reset/fdt_reset.c=0D opensbi/lib/utils/reset/fdt_reset_htif.c=0D opensbi/lib/utils/reset/fdt_reset_sifive.c=0D + opensbi/lib/utils/reset/fdt_reset_thead.c=0D + opensbi/lib/utils/reset/fdt_reset_thead_asm.S=0D opensbi/lib/utils/serial/fdt_serial.c=0D opensbi/lib/utils/serial/fdt_serial_htif.c=0D opensbi/lib/utils/serial/fdt_serial_shakti.c=0D opensbi/lib/utils/serial/fdt_serial_sifive.c=0D opensbi/lib/utils/serial/fdt_serial_uart8250.c=0D + opensbi/lib/utils/serial/fdt_serial_gaisler.c=0D + opensbi/lib/utils/serial/gaisler-uart.c=0D opensbi/lib/utils/serial/shakti-uart.c=0D opensbi/lib/utils/serial/sifive-uart.c=0D opensbi/lib/utils/serial/uart8250.c=0D - opensbi/lib/utils/sys/clint.c=0D opensbi/lib/utils/sys/htif.c=0D opensbi/lib/utils/sys/sifive_test.c=0D opensbi/lib/utils/timer/fdt_timer.c=0D - opensbi/lib/utils/timer/fdt_timer_clint.c=0D + opensbi/lib/utils/timer/aclint_mtimer.c=0D + opensbi/lib/utils/timer/fdt_timer_mtimer.c=0D =0D [Packages]=0D EmbeddedPkg/EmbeddedPkg.dec # For libfdt.=0D --=20 2.33.0