From nobody Mon Feb 9 09:22:50 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+82326+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+82326+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1634634517; cv=none; d=zohomail.com; s=zohoarc; b=AOX7+cosL+VRj9ELrx7zqBD57sYehIkz0uHwDq/OUUdqeI6G5yy0pbzqXr/cBfEkrsAOyBR2LnTSZJp5poWFIpJVBLMqmleCUkENZ9yTWlw+tJLg04oYvi23OVZWLtA6JOBhl8S7xXja+F3onDJykkVa9kXmSwsDdnq/95yr640= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634634517; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=5tUerDdxXYA3DFbyxbLY9lGm4/+yZCvRC2gXBZeIBdo=; b=jv0wyzxW8FbpgbeWYCW+J2Vn7M2S/s/7QiP567W/ffyNJczHYIbgZ9gu6SQCXsO4SJ17STsbnNAaS+lzZY77KbnuadIWgIyFMqDk/XjKuuL4T2yXnGNyaavj3tdl387Tkv6XyAQCV06fFkXzw/Bd63LNIZniaak2idAtX83J7Vo= ARC-Authentication-Results: i=1; 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+82326+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634634517258319.12805020456346; Tue, 19 Oct 2021 02:08:37 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 54naYY1788612xzmgy4VBUrI; Tue, 19 Oct 2021 02:08:36 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web08.7307.1634634510127855160 for ; Tue, 19 Oct 2021 02:08:36 -0700 X-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 19J81rT1029136; Tue, 19 Oct 2021 09:08:30 GMT X-Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0b-002e3701.pphosted.com with ESMTP id 3bsd6x5gs5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Oct 2021 09:08:29 +0000 X-Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3427.houston.hpe.com (Postfix) with ESMTP id F217C6A; Tue, 19 Oct 2021 09:08:28 +0000 (UTC) X-Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id E4F4C4E; Tue, 19 Oct 2021 09:08:27 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com, Sunil V L , Daniel Schaefer Subject: [edk2-devel] [edk2-platforms][PATCH 12/30] Platform/RISC-V: Remove platform dependency from this library Date: Tue, 19 Oct 2021 16:09:49 +0800 Message-Id: <20211019081007.31165-13-abner.chang@hpe.com> In-Reply-To: <20211019081007.31165-1-abner.chang@hpe.com> References: <20211019081007.31165-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: EmXl6wY_4M0Ra8ottq0l-xgnv9veBsXo X-Proofpoint-ORIG-GUID: EmXl6wY_4M0Ra8ottq0l-xgnv9veBsXo 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,abner.chang@hpe.com X-Gm-Message-State: 1wIK8LWOcj4bWeCsAdlW25b2x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634634516; bh=GP9srVSiRbYW+BjaHKljJWcH9hF/bspbb5zcK6Gqvyo=; h=Cc:Date:From:Reply-To:Subject:To; b=H1lI68WdQ/g+QtyX7TtP6tUntMWI/4M62onS8SPgXsbjTqvp6pxhc2b2uWJwg2YEd07 cWpFn5v0RNm8S84xh/lCaCbNiFcayCk9scF7582BLyHEHkadcFRC1zAk3yS0z6BC3dvVk nuVjD1YU19l4w7RxcZ+HXng7RI48+HDki2Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634634518386100006 Content-Type: text/plain; charset="utf-8" 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 --- .../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 @@ =20 [Sources] Platform.c - SifiveFu540.c - PlatformOverride.h =20 [Packages] EmbeddedPkg/EmbeddedPkg.dec @@ -45,6 +43,7 @@ PcdLib PrintLib RiscVCpuLib + RiscVSpecialPlatformLib =20 [FixedPcd] gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootHartId 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 467ebbd4b8..0000000000 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/PlatformOverri= de.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platfor= m.c b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c index 4fbb201895..06cd1a299f 100644 --- a/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c +++ b/Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/Platform.c @@ -5,10 +5,16 @@ * * Authors: * Anup Patel + + Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All right= s reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + */ =20 #include -#include +#include + #include #include #include @@ -24,11 +30,12 @@ #include #include =20 -extern const struct platform_override sifive_fu540; - -static const struct platform_override *special_platforms[] =3D { - &sifive_fu540, -}; +// +// SpecialPlatformArray and NumberOfSpecialPlatform are +// provided by RiscVSpecialPlatformLib library. +// +extern const struct platform_override *special_platforms[]; +extern INTN NumberOfPlaformsInArray; =20 static const struct platform_override *generic_plat =3D NULL; static const struct fdt_match *generic_plat_match =3D NULL; @@ -39,7 +46,11 @@ static void fw_platform_lookup_special(void *fdt, int ro= ot_offset) const struct platform_override *plat; const struct fdt_match *match; =20 - for (pos =3D 0; pos < array_size(special_platforms); pos++) { + if (special_platforms =3D=3D NULL || NumberOfPlaformsInArray =3D=3D 0)= { + return; + } + + for (pos =3D 0; pos < (int)NumberOfPlaformsInArray; pos++) { plat =3D special_platforms[pos]; if (!plat->match_table) continue; 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 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2020 Western Digital Corporation or its affiliates. - * - * Authors: - * Anup Patel - */ - -#include -#include -#include - -static u64 sifive_fu540_tlbr_flush_limit(const struct fdt_match *match) -{ - /* - * The sfence.vma by virtual address does not work on - * SiFive FU540 so we return remote TLB flush limit as zero. - */ - return 0; -} - -static int sifive_fu540_fdt_fixup(void *fdt, const struct fdt_match *match) -{ - /* - * SiFive Freedom U540 has an erratum that prevents S-mode software - * to access a PMP protected region using 1GB page table mapping, so - * always add the no-map attribute on this platform. - */ - fdt_reserved_memory_nomap_fixup(fdt); - - return 0; -} - -static const struct fdt_match sifive_fu540_match[] =3D { - { .compatible =3D "sifive,fu540" }, - { .compatible =3D "sifive,fu540g" }, - { .compatible =3D "sifive,fu540-c000" }, - { .compatible =3D "sifive,hifive-unleashed-a00" }, - { }, -}; - -const struct platform_override sifive_fu540 =3D { - .match_table =3D sifive_fu540_match, - .tlbr_flush_limit =3D sifive_fu540_tlbr_flush_limit, - .fdt_fixup =3D sifive_fu540_fdt_fixup, -}; --=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 (#82326): https://edk2.groups.io/g/devel/message/82326 Mute This Topic: https://groups.io/mt/86435678/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-