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.web12.5089.1634615445384358726 for ; Mon, 18 Oct 2021 20:50:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=CZYiClHP; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=092675a635=daniel.schaefer@hpe.com) Received: from pps.filterd (m0134421.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19J2WFCL009534; Tue, 19 Oct 2021 03:50:45 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=3aM8UCyEG71LBEB90gAlzDR47HR8bzjfDqP3di6h/pI=; b=CZYiClHP9jfyzHbcMUo9bfRrRQ+hlj3qDb/c26/MddFVxbK1lexv0tIAj+j/RWguu5qT S5z045a+BbtmDtDmdgIE7lVV9+MIjsLM47ZB6jSa07nBpb0Nj6OFvFSSmcPo+w8gPGJA 2HduEWdIgP1FcJt94HqWHxPrPJLSFCU5Xm9j2zOX2L6KfgtGxJYF8/uTxCNAhr3zLou3 yuW3aXxQh4xLoyTf6yjMfhp0ja2BKDGqBasFRSy19/koelwdTs3RlSYZTj6n0BsbYMgM I1tiblQpdEM0049fwGqw/wXcDCDk3II12SU9+3ANgxDxccgj53XdVRXSoFczvfrSvui/ Rg== Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0b-002e3701.pphosted.com with ESMTP id 3bsd6x3c8q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Oct 2021 03:50:44 +0000 Received: from G9W8455.americas.hpqcorp.net (exchangepmrr1.us.hpecorp.net [16.216.161.94]) (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 452A260; Tue, 19 Oct 2021 03:50:44 +0000 (UTC) Received: from G9W8455.americas.hpqcorp.net (2002:10d8:a15e::10d8:a15e) by G9W8455.americas.hpqcorp.net (2002:10d8:a15e::10d8:a15e) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 19 Oct 2021 03:50:44 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (15.241.52.13) by G9W8455.americas.hpqcorp.net (16.216.161.94) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Tue, 19 Oct 2021 03:50:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AnOnKkt2+ATB/Jms35h+ZmBsDtaQ0vwcZkIqKYRb1UpVZXudvodLRU2Ux/mu7yL+2/WKyAuox6sB11jTdvYO7tALO/WIBe4DJmn98gg83/2Di4Vc+Q+rTpGHNK66m0rrtJ2mame3MszK8YH7qjuXDxOg47qlObETIi2JbavzLedwfC0jz7z9yD0UXhT3QpWEcyeRn2QCcrwaGmXoIKxzmkbv/4mEGDiXF/OE5qL6ZzXuiM5S8EMje1fGpB8fLOWUJMHRIt1fhisGC1jIV50jwpuSpbsEJHsODXpe6ShAOuvkIOakAzVSgD2LHRm2wO91mt6bpG/bHbnv7ne+NEtkSQ== 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=3aM8UCyEG71LBEB90gAlzDR47HR8bzjfDqP3di6h/pI=; b=cTmcKhSi8Zg5udpvT2cYsheAQpvYTZP+OKGXmV1FD+6UedXvk+BnaFATjDeBUTUwuXj/EuPL098Jh/zPMhT5qS1G3d8AqRP4VoKQuS8s0oVsVSC371IoUrZvfw0MfLk4Dh1/8SS5i7JlE7WW5BTD14XOODxtHHIYnNt8FjSQxnAVmGyZmaBXbME1AZ1sH272Jv7ZEqL8nkRA5/5s+8y+BQ1BqmetrSFMjCj+M1YaTxIkiGFld95K1bK4z/22vLUs7MPeNU04d2E0VvsjOR43EmWq3rJMlAXaZZtk9+113hikvTpSbzkLoJ472QKLxOGuCRl9ffRlgthwLiBD9Spmhw== 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 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:42 +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.4608.018; Tue, 19 Oct 2021 03:50:42 +0000 From: "Daniel Schaefer" To: CC: Daniel Schaefer , Abner Chang , Sunil V L Subject: [edk2-platforms] [PATCH v3 11/14] U5SeriesPkg: Switch to generic OpenSBI platform Date: Tue, 19 Oct 2021 11:48:46 +0800 Message-ID: <20211019034849.16847-12-daniel.schaefer@hpe.com> X-Mailer: git-send-email 2.31.1 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 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:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d14c0d11-e54b-4044-439f-08d992b39f78 X-MS-TrafficTypeDiagnostic: DF4PR8401MB0921: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o36HHQzLF2y5TTZIjWBn4R9ZRpAFVcJN+lC9i8UARHoGBMG6M8saaQ5sdzxiW6HpgMPBY4gokAC7HntAGU0u0VXCzDTTZTT7+LVUidZRgA2wGFHHA24z02e9kYRrG7/orJDJu7dUkkBh8tARTXZpry/p4XIrqLD+wSpI1DyNEgmGxgMDRgvgbEyttuS0AnFGsXp/MXHTH5bKuq7cTeTFEd3oOPXgYH6ohFR2MHEyut/CvEvoetw7Y8k7MwPhy1MrqU0kpsxFom7taPCSrXfqpyl88Lp4dIo/7RIJU+mp5wIdLez7QaRG96Ayi8MTI+8IwjwK94Sa1mBhHMeabFcS/5Rg+bNEhAb1bB2JzmaJ7SzUA2kZBEOAxQhY4XfizTIivDiPcKmtD7ZxmTrxs4CNvdwz5n4AxGzqnlDJVitupjy2IcePb8m7XOLDup9TcuDpcVX9o/7QYe7KRx8Epsmotywl176xLwuFZ1U73QABAYJcp5C1jVuNH8ehRV3YKWsDMjL94Ur6cH1fJ33VyvP39vFhIackg1F0HgpOK1kU1zTSWofWi1dFzD+b38nT+3KwmQxI7Mt3ztS4TCvEuINcWmGe5umuOoDaDQGlVpkQij9X6PEbKYz9CjENXOtPir5KbAb3l8AOHreYWrYqIjw0/6VaXI3jGWvEcqG/+FKr0Oelo3xZc7psqHh/GhKU4RaYoaQDeYpmerQU4rcEon+wq27K3MZq24HSoA8HAwA3tI0= 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)(6916009)(956004)(8676002)(54906003)(26005)(66946007)(186003)(66556008)(2616005)(4326008)(30864003)(5660300002)(7696005)(316002)(83380400001)(36756003)(8936002)(6486002)(508600001)(66476007)(86362001)(52116002)(44832011)(82960400001)(2906002)(1076003)(38350700002)(38100700002)(41533002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?g3zZlnsthgolREvnlR7BaHFw4gWupvHgbapfMTjlS0DMsZu1nnzF64RsOxRD?= =?us-ascii?Q?VXpTC6XVyTjiwbvNW4CxASXh7Uup5vBY4wUihBz94tkHfqBWa4XzfuhyZDos?= =?us-ascii?Q?IvkU+/r7VAaWIWUSoup1cWeXvaFabyvM2ByE3VrE28MK1OLpou8k2Q+woVhy?= =?us-ascii?Q?ehYMwGFkOpyybRxIUGum0Jze3+KzG0O60B13g2p8U3zAZfV5pStgvZq6KYrp?= =?us-ascii?Q?9fu6S4sv4dfaXVjMKWA57QZDG4meMg0373J6dIQ1jOMmERxVKSKfWzhPcldh?= =?us-ascii?Q?V1b69PH4ctvUWPP7witRxBCw/CwSFmPd9+/8YS2A/wpMlDlKeiah8rnibVQg?= =?us-ascii?Q?HWrNSHn9aAVJPbBjm8cThp2YsFC/jvAh3o2D3fy1WPP/GchD1tqLkFj9GTyJ?= =?us-ascii?Q?xm/QJAzMsWj0GBeQ2yZmNOFP4eExh1iXvOy5c6zcO5Nvt0DqajAhlNHBLR91?= =?us-ascii?Q?xl9QZ+hGQrtWfuhheaSJJeIxz8lmRoJCGlKzQuvIHEW15fqiCiIbg9y04ub/?= =?us-ascii?Q?bQ06nWqTMD/Kblq86Qf0oCZFlcLDIKYAW4m7Ryuav1+59BvVfQu+OOMy009J?= =?us-ascii?Q?7c6Dr4dkKZrx0c9Kc9v6ki13EHOD1fRLxIhhOMbXrpmQRPoAxGVt83Fj5M+O?= =?us-ascii?Q?KH9LynH6/HaQoZrywxuyLXJFdzQ5FiRUKox1D00rH3MyszxGTsS5MShB6n4j?= =?us-ascii?Q?39rkj9JKC0KMCmHgJ6TgpzmKPYLG8syFU9i3Gfs8BcgFmakc0xPhAEyYs9Zl?= =?us-ascii?Q?27eaZfZTY84QbUVGTD2KFG580Q/gyHfOAkF7tqeLmMkR9UD3QdxcR5MhkBUj?= =?us-ascii?Q?eXPBkdDn/z3mvv+ADEASadPhLocVfIyIbU0M/P01cArLzau6Nsk6oG51L9Oi?= =?us-ascii?Q?MmpOz0vkzp6kU/ItvSs9lWLdkRlm5U9lw/XTaV1boZgmoLZSDEQZmFDkFYsM?= =?us-ascii?Q?ghxKHeu0bnsjl9+KWEfgKpOjb9EFK4c4NZalHRfg38VJdgkxj+462qb0tZBV?= =?us-ascii?Q?CH+7qSy6oW3BL0O9KSRAX3EfyuXtyARZgbDulC6A4zWTNBfq1ph3xykyk1XH?= =?us-ascii?Q?RIUpuU+9b/dW+6s9fWOzGVrDODXQXtphgPeSMiMA3RNl3cp9auJCLLYlushZ?= =?us-ascii?Q?GJ+svb+8J4QV5vJeXZ31kliE62lONhw/fQtM/lGp5LXR3Qh7zaAYGSG9Xask?= =?us-ascii?Q?AMF4/U4PptkNx9F311s3ACkSKgqO2vrKn+gwU98Y8p4FwpSzNrwNt6JA1u3d?= =?us-ascii?Q?X08162OcnjT9uaEJ0BD39I7GgFeV70cs43qWu4RQArjnRMBcCDRhtR6XfBr6?= =?us-ascii?Q?FuJ093G5mzaUvMc0xjFeop7C?= X-MS-Exchange-CrossTenant-Network-Message-Id: d14c0d11-e54b-4044-439f-08d992b39f78 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:42.5564 (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: oGWckzR8GSAQNLDOyTVP+W2wqrhl0VXNWSP71QRzviOQBaj8MNmA2GMEyDx/Ba3+Nq/cq1LAZy9UqRHUGPFGNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0921 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: 5mMDh2CByZL6O96XuRFs08pt3frl4vpX X-Proofpoint-ORIG-GUID: 5mMDh2CByZL6O96XuRFs08pt3frl4vpX X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-18_07,2021-10-18_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 bulkscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110190019 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain New platform files require more space in SEC. Behavior is determined not by source code but by device tree. Cc: Daniel Schaefer Cc: Abner Chang Cc: Sunil V L Reviewed-by: Abner Chang Signed-off-by: Daniel Schaefer --- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/Opensb= iPlatformLib/OpensbiPlatformLib.inf | 2 + Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/Opensb= iPlatformLib/PlatformOverride.h | 27 ++ Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/Opensb= iPlatformLib/Platform.c | 390 ++++++++++---------- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/Opensb= iPlatformLib/SifiveFu540.c | 47 +++ Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf.inc = | 6 +- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf.inc = | 6 +- 6 files changed, 281 insertions(+), 197 deletions(-) diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/OpensbiPlatformLib.inf b/Platform/SiFive/U5SeriesP= kg/FreedomU540HiFiveUnleashedBoard/Library/OpensbiPlatformLib/OpensbiPlatfo= rmLib.inf index 317aaceb2519..f9f2073a5ba4 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/OpensbiPlatformLib.inf +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/OpensbiPlatformLib.inf @@ -25,6 +25,8 @@ =0D [Sources]=0D Platform.c=0D + SifiveFu540.c=0D + PlatformOverride.h=0D =0D [Packages]=0D EmbeddedPkg/EmbeddedPkg.dec=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/PlatformOverride.h b/Platform/SiFive/U5SeriesPkg/F= reedomU540HiFiveUnleashedBoard/Library/OpensbiPlatformLib/PlatformOverride.h new file mode 100644 index 000000000000..9b6fcdc15f45 --- /dev/null +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/PlatformOverride.h @@ -0,0 +1,27 @@ +/*=0D + * SPDX-License-Identifier: BSD-2-Clause=0D + *=0D + * Copyright (c) 2020 Western Digital Corporation or its affiliates.=0D + *=0D + * Authors:=0D + * Anup Patel =0D + */=0D +=0D +#ifndef __PLATFORM_OVERRIDE_H__=0D +#define __PLATFORM_OVERRIDE_H__=0D +=0D +#include =0D +=0D +struct platform_override {=0D + const struct fdt_match *match_table;=0D + u64 (*features)(const struct fdt_match *match);=0D + u64 (*tlbr_flush_limit)(const struct fdt_match *match);=0D + int (*early_init)(bool cold_boot, const struct fdt_match *match);=0D + int (*final_init)(bool cold_boot, const struct fdt_match *match);=0D + void (*early_exit)(const struct fdt_match *match);=0D + void (*final_exit)(const struct fdt_match *match);=0D + int (*system_reset)(u32 reset_type, const struct fdt_match *match);=0D + int (*fdt_fixup)(void *fdt, const struct fdt_match *match);=0D +};=0D +=0D +#endif=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/Platform.c b/Platform/SiFive/U5SeriesPkg/FreedomU5= 40HiFiveUnleashedBoard/Library/OpensbiPlatformLib/Platform.c index aa6274be965b..fe6e2a8c943a 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/Platform.c +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/Platform.c @@ -1,216 +1,224 @@ /*=0D - *=0D - * Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
=0D - *=0D * SPDX-License-Identifier: BSD-2-Clause=0D *=0D - * Copyright (c) 2019 Western Digital Corporation or its affiliates.=0D + * Copyright (c) 2020 Western Digital Corporation or its affiliates.=0D *=0D * Authors:=0D - * Atish Patra =0D + * Anup Patel =0D */=0D =0D #include =0D +#include =0D #include =0D -#include =0D -#include =0D -#include =0D -#include =0D +#include =0D #include =0D +#include =0D #include =0D -#include =0D -#include =0D -#include =0D -#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D =0D -#define U540_HART_COUNT FixedPcdGet32(PcdHartCount)=0D -#define U540_BOOTABLE_HART_COUNT FixedPcdGet32(PcdBootableHartNumber)=0D -#define U540_HART_STACK_SIZE FixedPcdGet32(PcdOpenSbiStackSize)=0D -#define U540_BOOT_HART_ID FixedPcdGet32(PcdBootHartId)=0D +extern const struct platform_override sifive_fu540;=0D =0D -#define U540_SYS_CLK FixedPcdGet32(PcdU5PlatformSystemClock)= =0D -=0D -#define U540_PLIC_ADDR 0xc000000=0D -#define U540_PLIC_NUM_SOURCES 0x35=0D -#define U540_PLIC_NUM_PRIORITIES 7=0D -=0D -#define U540_UART_ADDR FixedPcdGet32(PcdU5UartBase)=0D -=0D -#define U540_UART_BAUDRATE 115200=0D -=0D -/* PRCI clock related macros */=0D -//TODO: Do we need a separate driver for this ?=0D -#define U540_PRCI_BASE_ADDR 0x10000000=0D -#define U540_PRCI_CLKMUXSTATUSREG 0x002C=0D -#define U540_PRCI_CLKMUX_STATUS_TLCLKSEL (0x1 << 1)=0D -=0D -/* Full tlb flush always */=0D -#define U540_TLB_RANGE_FLUSH_LIMIT 0=0D -=0D -unsigned long log2roundup(unsigned long x);=0D -=0D -static struct plic_data plic =3D {=0D - .addr =3D U540_PLIC_ADDR,=0D - .num_src =3D U540_PLIC_NUM_SOURCES,=0D +static const struct platform_override *special_platforms[] =3D {=0D + &sifive_fu540,=0D };=0D =0D -static struct clint_data clint =3D {=0D - .addr =3D CLINT_REG_BASE_ADDR,=0D - .first_hartid =3D 0,=0D - .hart_count =3D U540_HART_COUNT,=0D - .has_64bit_mmio =3D TRUE,=0D -};=0D -=0D -static void U540_modify_dt(void *fdt)=0D -{=0D - fdt_cpu_fixup(fdt);=0D -=0D - fdt_fixups(fdt);=0D -=0D - /*=0D - * SiFive Freedom U540 has an erratum that prevents S-mode software=0D - * to access a PMP protected region using 1GB page table mapping, so=0D - * always add the no-map attribute on this platform.=0D - */=0D - fdt_reserved_memory_nomap_fixup(fdt);=0D -}=0D -=0D -static int U540_final_init(bool cold_boot)=0D -{=0D - void *fdt;=0D - struct sbi_scratch *ThisScratch;=0D -=0D - if (!cold_boot)=0D - return 0;=0D -=0D - fdt =3D sbi_scratch_thishart_arg1_ptr();=0D - U540_modify_dt(fdt);=0D - //=0D - // Set PMP of firmware regions to R and X. We will lock this in the en= d of PEI.=0D - // This region only protects SEC, PEI and Scratch buffer.=0D - //=0D - ThisScratch =3D sbi_scratch_thishart_ptr ();=0D - pmp_set(0, PMP_R | PMP_X | PMP_W, ThisScratch->fw_start, log2roundup (= ThisScratch->fw_size));=0D - return 0;=0D -}=0D -=0D -static u32 U540_pmp_region_count(u32 hartid)=0D -{=0D - return 1;=0D -}=0D -=0D -static int U540_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 U540_console_init(void)=0D -{=0D - unsigned long peri_in_freq;=0D -=0D - peri_in_freq =3D U540_SYS_CLK/2;=0D - return sifive_uart_init(U540_UART_ADDR, peri_in_freq, U540_UART_BAUDRA= TE);=0D -}=0D -=0D -static int U540_irqchip_init(bool cold_boot)=0D -{=0D - int rc;=0D - u32 hartid =3D current_hartid();=0D -=0D - if (cold_boot) {=0D - rc =3D plic_cold_irqchip_init(&plic);=0D - if (rc)=0D - return rc;=0D - }=0D -=0D - return plic_warm_irqchip_init(&plic,=0D - (hartid) ? (2 * hartid - 1) : 0,=0D - (hartid) ? (2 * hartid) : -1);=0D -}=0D -=0D -static int U540_ipi_init(bool cold_boot)=0D -{=0D - int rc;=0D -=0D - if (cold_boot) {=0D - rc =3D clint_cold_ipi_init(&clint);=0D - if (rc)=0D - return rc;=0D -=0D - }=0D -=0D - return clint_warm_ipi_init();=0D -}=0D -=0D -static u64 U540_get_tlbr_flush_limit(void)=0D -{=0D - return U540_TLB_RANGE_FLUSH_LIMIT;=0D -}=0D -=0D -static int U540_timer_init(bool cold_boot)=0D -{=0D - int rc;=0D -=0D - if (cold_boot) {=0D - rc =3D clint_cold_timer_init(&clint, NULL);=0D - if (rc)=0D - return rc;=0D - }=0D -=0D - return clint_warm_timer_init();=0D -}=0D -/**=0D - * The U540 SoC has 5 HARTs, Boot HART ID is determined by=0D - * PcdBootHartId.=0D +static const struct platform_override *generic_plat =3D NULL;=0D +static const struct fdt_match *generic_plat_match =3D NULL;=0D +=0D +static void fw_platform_lookup_special(void *fdt, int root_offset)=0D +{=0D + int pos, noff;=0D + const struct platform_override *plat;=0D + const struct fdt_match *match;=0D +=0D + for (pos =3D 0; pos < array_size(special_platforms); pos++) {=0D + plat =3D special_platforms[pos];=0D + if (!plat->match_table)=0D + continue;=0D +=0D + noff =3D fdt_find_match(fdt, -1, plat->match_table, &match);=0D + if (noff < 0)=0D + continue;=0D +=0D + generic_plat =3D plat;=0D + generic_plat_match =3D match;=0D + break;=0D + }=0D +}=0D +=0D +extern struct sbi_platform platform;=0D +static u32 generic_hart_index2id[SBI_HARTMASK_MAX_BITS] =3D { 0 };=0D +=0D +/*=0D + * The fw_platform_init() function is called very early on the boot HART=0D + * OpenSBI reference firmwares so that platform specific code get chance=0D + * to update "platform" instance before it is used.=0D + *=0D + * The arguments passed to fw_platform_init() function are boot time state= =0D + * of A0 to A4 register. The "arg0" will be boot HART id and "arg1" will=0D + * be address of FDT passed by previous booting stage.=0D + *=0D + * The return value of fw_platform_init() function is the FDT location. If= =0D + * FDT is unchanged (or FDT is modified in-place) then fw_platform_init()= =0D + * can always return the original FDT location (i.e. 'arg1') unmodified.=0D */=0D -static u32 U540_hart_index2id[U540_BOOTABLE_HART_COUNT] =3D {1, 2, 3, 4};= =0D +unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,=0D + unsigned long arg2, unsigned long arg3,=0D + unsigned long arg4)=0D +{=0D + const char *model, *mmu_type;=0D + void *fdt =3D (void *)arg1;=0D + u32 hartid, hart_count =3D 0;=0D + int rc, root_offset, cpus_offset, cpu_offset, len;=0D +=0D + root_offset =3D fdt_path_offset(fdt, "/");=0D + if (root_offset < 0)=0D + goto fail;=0D +=0D + fw_platform_lookup_special(fdt, root_offset);=0D +=0D + model =3D fdt_getprop(fdt, root_offset, "model", &len);=0D + if (model)=0D + sbi_strncpy(platform.name, model, sizeof(platform.name));=0D +=0D + if (generic_plat && generic_plat->features)=0D + platform.features =3D generic_plat->features(generic_plat_match);=0D +=0D + cpus_offset =3D fdt_path_offset(fdt, "/cpus");=0D + if (cpus_offset < 0)=0D + goto fail;=0D +=0D + fdt_for_each_subnode(cpu_offset, fdt, cpus_offset) {=0D + rc =3D fdt_parse_hart_id(fdt, cpu_offset, &hartid);=0D + if (rc)=0D + continue;=0D +=0D + 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 -static int U540_system_reset(u32 type)=0D + generic_hart_index2id[hart_count++] =3D hartid;=0D + }=0D +=0D + platform.hart_count =3D hart_count;=0D +=0D + /* Return original FDT pointer */=0D + return arg1;=0D +=0D +fail:=0D + while (1)=0D + wfi();=0D +}=0D +=0D +static int generic_early_init(bool cold_boot)=0D {=0D - /* For now nothing to do. */=0D + int rc;=0D +=0D + if (generic_plat && generic_plat->early_init) {=0D + rc =3D generic_plat->early_init(cold_boot, generic_plat_match);=0D + if (rc)=0D + return rc;=0D + }=0D +=0D + if (!cold_boot)=0D return 0;=0D +=0D + return fdt_reset_init();=0D +}=0D +=0D +static int generic_final_init(bool cold_boot)=0D +{=0D + void *fdt;=0D + int rc;=0D +=0D + if (generic_plat && generic_plat->final_init) {=0D + rc =3D generic_plat->final_init(cold_boot, generic_plat_match);=0D + if (rc)=0D + return rc;=0D + }=0D +=0D + if (!cold_boot)=0D + return 0;=0D +=0D + fdt =3D sbi_scratch_thishart_arg1_ptr();=0D +=0D + fdt_cpu_fixup(fdt);=0D + fdt_fixups(fdt);=0D +=0D + if (generic_plat && generic_plat->fdt_fixup) {=0D + rc =3D generic_plat->fdt_fixup(fdt, generic_plat_match);=0D + if (rc)=0D + return rc;=0D + }=0D +=0D + return 0;=0D +}=0D +=0D +static void generic_early_exit(void)=0D +{=0D + if (generic_plat && generic_plat->early_exit)=0D + generic_plat->early_exit(generic_plat_match);=0D +}=0D +=0D +static void generic_final_exit(void)=0D +{=0D + if (generic_plat && generic_plat->final_exit)=0D + generic_plat->final_exit(generic_plat_match);=0D +}=0D +=0D +static u64 generic_tlbr_flush_limit(void)=0D +{=0D + if (generic_plat && generic_plat->tlbr_flush_limit)=0D + return generic_plat->tlbr_flush_limit(generic_plat_match);=0D + 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 - .pmp_region_count =3D U540_pmp_region_count,=0D - .pmp_region_info =3D U540_pmp_region_info,=0D - .final_init =3D U540_final_init,=0D - .console_putc =3D sifive_uart_putc,=0D - .console_getc =3D sifive_uart_getc,=0D - .console_init =3D U540_console_init,=0D - .irqchip_init =3D U540_irqchip_init,=0D - .ipi_send =3D clint_ipi_send,=0D - .ipi_clear =3D clint_ipi_clear,=0D - .ipi_init =3D U540_ipi_init,=0D - .get_tlbr_flush_limit =3D U540_get_tlbr_flush_limit,=0D - .timer_value =3D clint_timer_value,=0D - .timer_event_stop =3D clint_timer_event_stop,=0D - .timer_event_start =3D clint_timer_event_start,=0D - .timer_init =3D U540_timer_init,=0D - .system_reset =3D U540_system_reset=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 + .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 -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(0x0001, 0x0000), // SBI P= latform version 1.0=0D - .name =3D "SiFive Freedom U540",=0D - .features =3D SBI_PLATFORM_DEFAULT_FEATURES,=0D - .hart_count =3D U540_BOOTABLE_HART_COUNT,=0D - .hart_index2id =3D U540_hart_index2id,=0D - .hart_stack_size =3D U540_HART_STACK_SIZE,=0D - .platform_ops_addr =3D (unsigned long)&platform_ops=0D +struct sbi_platform platform =3D {=0D + .opensbi_version =3D OPENSBI_VERSION,=0D + .platform_version =3D SBI_PLATFORM_VERSION(0x0, 0x01),=0D + .name =3D "Generic",=0D + .features =3D SBI_PLATFORM_DEFAULT_FEATURES,=0D + .hart_count =3D SBI_HARTMASK_MAX_BITS,=0D + .hart_index2id =3D generic_hart_index2id,=0D + .hart_stack_size =3D SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,=0D + .platform_ops_addr =3D (unsigned long)&platform_ops=0D };=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Li= brary/OpensbiPlatformLib/SifiveFu540.c b/Platform/SiFive/U5SeriesPkg/Freedo= mU540HiFiveUnleashedBoard/Library/OpensbiPlatformLib/SifiveFu540.c new file mode 100644 index 000000000000..748b058840e0 --- /dev/null +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/O= pensbiPlatformLib/SifiveFu540.c @@ -0,0 +1,47 @@ +/*=0D + * SPDX-License-Identifier: BSD-2-Clause=0D + *=0D + * Copyright (c) 2020 Western Digital Corporation or its affiliates.=0D + *=0D + * Authors:=0D + * Anup Patel =0D + */=0D +=0D +#include =0D +#include =0D +#include =0D +=0D +static u64 sifive_fu540_tlbr_flush_limit(const struct fdt_match *match)=0D +{=0D + /*=0D + * The sfence.vma by virtual address does not work on=0D + * SiFive FU540 so we return remote TLB flush limit as zero.=0D + */=0D + return 0;=0D +}=0D +=0D +static int sifive_fu540_fdt_fixup(void *fdt, const struct fdt_match *match= )=0D +{=0D + /*=0D + * SiFive Freedom U540 has an erratum that prevents S-mode software=0D + * to access a PMP protected region using 1GB page table mapping, so=0D + * always add the no-map attribute on this platform.=0D + */=0D + fdt_reserved_memory_nomap_fixup(fdt);=0D +=0D + return 0;=0D +}=0D +=0D +static const struct fdt_match sifive_fu540_match[] =3D {=0D + { .compatible =3D "sifive,fu540" },=0D + { .compatible =3D "sifive,fu540g" },=0D + { .compatible =3D "sifive,fu540-c000" },=0D + { .compatible =3D "sifive,hifive-unleashed-a00" },=0D + { },=0D +};=0D +=0D +const struct platform_override sifive_fu540 =3D {=0D + .match_table =3D sifive_fu540_match,=0D + .tlbr_flush_limit =3D sifive_fu540_tlbr_flush_limit,=0D + .fdt_fixup =3D sifive_fu540_fdt_fixup,=0D +};=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf.inc= b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf.inc index 13c14a4a2c76..e88aee8c0212 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf.inc +++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf.inc @@ -23,10 +23,10 @@ DEFINE CODE_BLOCKS =3D 0x7E0 DEFINE VARS_BLOCKS =3D 0x20=0D =0D DEFINE SECFV_OFFSET =3D 0x00000000=0D -DEFINE SECFV_SIZE =3D 0x00020000=0D -DEFINE PEIFV_OFFSET =3D 0x00020000=0D +DEFINE SECFV_SIZE =3D 0x00030000=0D +DEFINE PEIFV_OFFSET =3D 0x00030000=0D DEFINE PEIFV_SIZE =3D 0x00080000=0D -DEFINE SCRATCH_OFFSET =3D 0x000a0000=0D +DEFINE SCRATCH_OFFSET =3D 0x000b0000=0D DEFINE SCRATCH_SIZE =3D 0x00010000=0D DEFINE FVMAIN_OFFSET =3D 0x00100000 # Must be power of 2 for PMP setti= ng=0D DEFINE FVMAIN_SIZE =3D 0x0018C000=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U5= 40.fdf.inc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U5= 40.fdf.inc index 723632dc792d..8e7afc2d82c4 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf.= inc +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf.= inc @@ -23,10 +23,10 @@ DEFINE CODE_BLOCKS =3D 0x7E0 DEFINE VARS_BLOCKS =3D 0x20=0D =0D DEFINE SECFV_OFFSET =3D 0x00000000=0D -DEFINE SECFV_SIZE =3D 0x00020000=0D -DEFINE PEIFV_OFFSET =3D 0x00020000=0D +DEFINE SECFV_SIZE =3D 0x00030000=0D +DEFINE PEIFV_OFFSET =3D 0x00030000=0D DEFINE PEIFV_SIZE =3D 0x00080000=0D -DEFINE SCRATCH_OFFSET =3D 0x000a0000=0D +DEFINE SCRATCH_OFFSET =3D 0x000b0000=0D DEFINE SCRATCH_SIZE =3D 0x00010000=0D DEFINE FVMAIN_OFFSET =3D 0x00100000 # Must be power of 2 for PMP setti= ng=0D DEFINE FVMAIN_SIZE =3D 0x0018C000=0D --=20 2.31.1