From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.3701.1641630351491776165 for ; Sat, 08 Jan 2022 00:25:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=lNtT18vU; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=000704d8ca=abner.chang@hpe.com) Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2081WPvX003584 for ; Sat, 8 Jan 2022 08:25:50 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 : mime-version : content-transfer-encoding; s=pps0720; bh=WT7IyyJXZ7QW3fbbwyfCnbrXlV6P7hPnsnSlxrj2O6U=; b=lNtT18vUjA6+MRK/IVezCWMDnqLbac//pLvrSWvl7qJ65c4opHDbByWrDD8Qrth6B1K7 qq3J5NlUvHnbjoCBcsoKTR7nZmy+F25aLaztwPOmbpO5SscVbxiC/NpdbcT3OjmE6SOP z42+yQ261Pyt+xlV/ziAf/bOzvjTRskiBXgHG9HcEz+e+6e3Sku83Waes4NetnHyTu39 Tsze9pBBAvh7X3fQG6e5n4PYq+tjGYnvosDPit5oPe8aJ6VcCPsZaMg+uwobUFTce35O KIO26+vEK+ELbupYwtIwfemefoaD1bXGMwEuOPeozAhvnJ5HyircHRISP2Rz6Tqtefi9 Pg== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3df04bhq0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 08 Jan 2022 08:25:50 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id D17F962 for ; Sat, 8 Jan 2022 08:25:49 +0000 (UTC) Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 20B5639; Sat, 8 Jan 2022 08:25:48 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com Subject: [PATCH 46/79] Platform/RISC-V: Remove platform dependency from common platform lib Date: Sat, 8 Jan 2022 15:24:29 +0800 Message-Id: <20220108072444.17879-5-abner.chang@hpe.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220108072444.17879-1-abner.chang@hpe.com> References: <20220108072444.17879-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: k16It34cBNsh41UhobhX27Hztn0f7ofT X-Proofpoint-ORIG-GUID: k16It34cBNsh41UhobhX27Hztn0f7ofT X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-08_03,2022-01-07_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 spamscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201080063 Content-Transfer-Encoding: quoted-printable (This is migrated from edk2-platforms:Platform) This is the generic library for all RISC-V platforms. Remove the dependencies of SiFive U540 platform. Cc: Sunil V L Cc: Daniel Schaefer Signed-off-by: Abner Chang Reviewed-by: Daniel Schaefer Reviewed-by: Sunil V L --- .../OpensbiPlatformLib/OpensbiPlatformLib.inf | 3 +- .../OpensbiPlatformLib/PlatformOverride.h | 30 ------------ .../Library/OpensbiPlatformLib/Platform.c | 25 +++++++--- .../Library/OpensbiPlatformLib/SifiveFu540.c | 47 ------------------- 4 files changed, 19 insertions(+), 86 deletions(-) delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/= PlatformOverride.h delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/= SifiveFu540.c diff --git a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Opensbi= PlatformLib.inf b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Op= ensbiPlatformLib.inf index a408737961..909fbffa8d 100644 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/OpensbiPlatfor= mLib.inf +++ b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/OpensbiPlatfor= mLib.inf @@ -25,8 +25,6 @@ =0D [Sources]=0D Platform.c=0D - SifiveFu540.c=0D - PlatformOverride.h=0D =0D [Packages]=0D EmbeddedPkg/EmbeddedPkg.dec=0D @@ -45,6 +43,7 @@ PcdLib=0D PrintLib=0D RiscVCpuLib=0D + RiscVSpecialPlatformLib=0D =0D [FixedPcd]=0D gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootHartId=0D diff --git a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platfor= mOverride.h b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platfo= rmOverride.h deleted file mode 100644 index 2fbb8ca45d..0000000000 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/PlatformOverri= de.h +++ /dev/null @@ -1,30 +0,0 @@ -/*=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_check)(u32 reset_type, u32 reset_reason,=0D - const struct fdt_match *match);=0D - void (*system_reset)(u32 reset_type, u32 reset_reason,=0D - 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/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platfor= m.c b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c index 9926911297..bdd7a6d3ba 100644 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c +++ b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c @@ -5,10 +5,16 @@ *=0D * Authors:=0D * Anup Patel =0D +=0D + Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All right= s reserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D */=0D =0D #include =0D -#include =0D +#include =0D +=0D #include =0D #include =0D #include =0D @@ -24,11 +30,12 @@ #include =0D #include =0D =0D -extern const struct platform_override sifive_fu540;=0D -=0D -static const struct platform_override *special_platforms[] =3D {=0D - &sifive_fu540,=0D -};=0D +//=0D +// SpecialPlatformArray and NumberOfSpecialPlatform are=0D +// provided by RiscVSpecialPlatformLib library.=0D +//=0D +extern const struct platform_override *special_platforms[];=0D +extern INTN NumberOfPlaformsInArray;=0D =0D static const struct platform_override *generic_plat =3D NULL;=0D static const struct fdt_match *generic_plat_match =3D NULL;=0D @@ -39,7 +46,11 @@ static void fw_platform_lookup_special(void *fdt, int ro= ot_offset) const struct platform_override *plat;=0D const struct fdt_match *match;=0D =0D - for (pos =3D 0; pos < array_size(special_platforms); pos++) {=0D + if (special_platforms =3D=3D NULL || NumberOfPlaformsInArray =3D=3D 0)= {=0D + return;=0D + }=0D +=0D + for (pos =3D 0; pos < (int)NumberOfPlaformsInArray; pos++) {=0D plat =3D special_platforms[pos];=0D if (!plat->match_table)=0D continue;=0D diff --git a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/SifiveF= u540.c b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/SifiveFu540= .c deleted file mode 100644 index 748b058840..0000000000 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/SifiveFu540.c +++ /dev/null @@ -1,47 +0,0 @@ -/*=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 --=20 2.31.1