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.web10.5138.1634615443378764322 for ; Mon, 18 Oct 2021 20:50:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=XLbfr4u0; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=092675a635=daniel.schaefer@hpe.com) Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19J3VwAR009195; Tue, 19 Oct 2021 03:50:42 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=Ei3ZA82hS9g1PRvVk5WpopvcRogm8TzvwjSTTfSR6+0=; b=XLbfr4u0hu4fXQ4yMB614Kr6LJMJsA1Prb6a7OUy2H9Vp347U/ktaIh9iK27D6VwUggZ D7gR5qHT4X4yW1zisFTFjK7ZKAtmA0MzOICNI0Abu5aXLxD3h5ReyTAlD8OEp69xHiTh RAr9Hpx4peoO70K/L7LyIEZe27LsoJtYY2hClgBE0d8gbDJGkcfRS/MNGyUe/ES5Ywwr 40bTusmsz4aBAd7NEsI7EqJtuBEA+1XCHjG6BCzpjRisSyyLfth4uK8WQdFrHeDqU/3Z fNWJIOjCPyy9abB8junVNjiVfEq7UUP9RxvZAY5kDPR3qLnXO+o6tWKuWVCwLTa/Bq67 Gg== Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0b-002e3701.pphosted.com with ESMTP id 3bsb1x4qt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Oct 2021 03:50:42 +0000 Received: from G4W9119.americas.hpqcorp.net (g4w9119.houston.hp.com [16.210.20.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3425.houston.hpe.com (Postfix) with ESMTPS id C3AD892; Tue, 19 Oct 2021 03:50:41 +0000 (UTC) Received: from G1W8108.americas.hpqcorp.net (2002:10c1:483c::10c1:483c) by G4W9119.americas.hpqcorp.net (2002:10d2:14d6::10d2:14d6) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 19 Oct 2021 03:50:41 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (15.241.52.11) by G1W8108.americas.hpqcorp.net (16.193.72.60) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Tue, 19 Oct 2021 03:50:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lfx2AWE9rviHxR9oOFtVWfIXQ+XXLgpI97JZzJHgUBgQXL4fnF9npE1TWB/60Xq/S10AYTFU2k3qR15ovBp/wCjNRQOrd++n3pL1lXl78ina4UbEEXqgQr333j3UYhne1hrhUWwGUWY5sF9tMpq+lvIlsQnN5PKSlLWKgi1yELy/qTdjv8kj7St7HMSG3k6fAuElPZi3ZePbg0eZ2wiD/lYAJBYIMmwfi1FN6KeYaEso7HDaIqXUzlR919fnVhn8oJCiXsX6kRvScZHNqVTtbLs+XQ182+XdUPA4U4qOMrC8ZRWByrNrghovJdpKtaDsEegadMRMvLogF4hyBDni4w== 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=Ei3ZA82hS9g1PRvVk5WpopvcRogm8TzvwjSTTfSR6+0=; b=Ju54c4H2+ZYtvj7Q9REj4wTHpyYI9hMHOLNidCt8VCHdOi//krQra5SOosFdEfbkmk5Ss4iIYwdVNac+2DgQ9kuRG4q9JmlOC98aD3X2kdTr5NACYFsKOaTms3+joQkq0WwWiOEUxN3kalSw7TxtjYVa0DDLWClwSop2XpUwwQM66hq79Ez4SxHP91Nbc+NWnhaHAVKWUzRCcCYRKHO0Qa2S800+uwO8yjAlfFfgt3ojEI0sjmzaJOYFTuEBwG/i5ZWYEV5nA5bqooqEqpHKS1RcrnM6oxWWynxGSOe7hUrCF9N3OrrBZfVI2Vbv0u4aPWrwuOXbYjSRIxwf1/MCCg== 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:40 +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:40 +0000 From: "Daniel Schaefer" To: CC: Daniel Schaefer , Abner Chang , Sunil V L Subject: [edk2-platforms] [PATCH v3 10/14] RISC-V/PlatformPkg: Fixup FDT from HOB and install into config table Date: Tue, 19 Oct 2021 11:48:45 +0800 Message-ID: <20211019034849.16847-11-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:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ffe1273d-a2e5-4293-70f9-08d992b39de7 X-MS-TrafficTypeDiagnostic: DF4PR8401MB0921: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:422; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JbzWCJB1+baSdWdsoX42rFcNFJ3faRkpbnRZObSfnnI2wefPhRsAkCHvGsE7d5KxYTE6/27ObJNv/oJSgg/fCYyznCoWK7OD7SnMpTL5zAnqYrt/MjZc87f8WKwCkZoihABDcHdkg5RixJfY0ZwcWWGBCOHOG9PsFlwve6chbTMtAm2+q0iWynZVvycsl1rdxzIIPjO/9YCYhlcLZEkB7x2bL+TknI1iqqCXUu5X0RwMkZgU0EcxNu+y174KTQHxZqAuyWXpEtxWz3GEzQM0W4ymLULyIrtAwsQGjunC1YlgMN9SwrYeM40ji+3BYx2HTPi6Cx/csLwjBCYWt5+J+pd51Kmv+uZ57c1sTi8ap0+kueAi4+ZPcqEwNWiDPq6Dt90eG2Np+DH0uMviTHC/3Q7KodyndMIp+bHxmHA+lwUK3Bvr1BvfmHnc5cIteNI589OaEUy9Fw/spJjbXdI9Hazd5loEIMKfOMPvgLR2jJWgN8Nd45vwhAiyJ3eMeapI8uC21TR+t1Ree+lzB62iYuUmBTUxXE99vtLY7220DY31C7+AquODSqjEsD0NNpkYp5kE17YE95BioTq1VbEb0q/KIXgox7TBV1Uwq6Vvtb3f226NRQzmiA6Mjq1+tfl0AxvMWoSFvqj2VnyRMEhJ9CIrjEp9w98eWZtxVvnD4M2CfWK7WOAXCfe6LeWr7G2Gj7tQmLeeP9rtTjfHsGkjBA== 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)(5660300002)(7696005)(316002)(83380400001)(36756003)(6666004)(8936002)(6486002)(508600001)(66476007)(86362001)(52116002)(44832011)(82960400001)(2906002)(1076003)(38350700002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7NEcqUirvfdcs7uaw7hhGHFzmYK0byybsPq12bJQIGvsKpiDMXdvfAL/slkC?= =?us-ascii?Q?IccXu/lO08PPNXEetQFKw6acUeMQhlWbfNvh9yBKovASxeC6izIagibbs8Fx?= =?us-ascii?Q?LP6cj5KbtOvdfgp0ptncYvJANnuJybcwf2ESZGbw1ncneY+EVLxf0acW0OmJ?= =?us-ascii?Q?LuAbK6U+tDE14HHjnqtEBlo2bX1zvtWCqKosTg4AZqI/AJFZy4hvOCgK85Lc?= =?us-ascii?Q?q5KpxSzFiPMIi7FzhJCcGEqRGyWVyYZYRDTZC8t7CJraCAixorKq5zyWFutD?= =?us-ascii?Q?BVc3az9r/Y1+RwnVoS6sDx8WDbgx96fKCKZelKra9yQ/j30VhSYnpjVHT/Fd?= =?us-ascii?Q?kMoP3hWDsYM8hR7s8vxGfjboyp6awACkJRFqRG1HEjjM8M3JxUDRBp6kNilD?= =?us-ascii?Q?nnMpvpQZFdT9f/oDc25eG0eHh5WSBqIXj0mFFiEoYiEWCs1UzbDBvTCTUdp2?= =?us-ascii?Q?Mvo7GCVvrkU9JBypQOYQdp0yqugis6xLT24KuuJHJ4vyUDYLL0ljxbHr/DSZ?= =?us-ascii?Q?wQou2gJfc0KaZ4fyEHGsU9KkEc+Uy0KPFiGzgTFesRfA9CGdEPN9/HPe1OVw?= =?us-ascii?Q?mpJKzS6IOVCuj7deF4Vu10UjMaaSYxba0YL3QvCDQe946/258fs7VhRiAc4T?= =?us-ascii?Q?mtG9hFiotIPdAiBVrdesg0wbPLCDV0AyWdbDIVzaZCIFH7bodehVJdoJ179H?= =?us-ascii?Q?oXLyaOfvswSjowfnBecS2V2MV7mkp4sSDK8Ymj+KXvHALTEeCmYrpjR3H3ea?= =?us-ascii?Q?vu28uob8f0YC0SkEPN3aTCbzASi+8T2e37UOKxt+ANhqqQ8yi/omJFCCLYtC?= =?us-ascii?Q?qexinfdJ8s4+Q4JD7DZiKtmsFiXO9h29ATuSa5VRww3eFjDHC4amrIalEKUd?= =?us-ascii?Q?WhZ1DUQ5l/R12N7JErC27zXVsU+wfL9sywe5Vj1xnuOoCsHzlcLio/331EGE?= =?us-ascii?Q?AcsSzth+nPMog61RQOrfZOkz5Kei0Q8Gm5BTNp6fTSWuZjH7DRx3Om5ec0U7?= =?us-ascii?Q?QaSVTyxjZ5TTHiEdxQQ5TQnjrkCDE3jCrrDkITHux66hCMDBRYOWYai3xZrz?= =?us-ascii?Q?efgdo534VQy/pqXzqWNxJ20Ljz0Cfb8r2A82XxD3GVxbE6igotLeAqBOOPdr?= =?us-ascii?Q?GeLWxohOE3CwRVBAi1zPXuzmneb4wlU5C4G/GbNKmFXwI00PU9lVghn7PWZc?= =?us-ascii?Q?m6ILHJewSZYAx8/Sjpa/lEOTw3ng9oWPprFOFfmwHPdeqf75a/YqZVitk+kJ?= =?us-ascii?Q?hB6JtSx4TvlUdpl0sWfxu5OxwM1UZdLS6zu+36r7iLi8/ou5IUpSJ4nE141O?= =?us-ascii?Q?4POzMyLSwTuQ/ehx0J9VmtuO?= X-MS-Exchange-CrossTenant-Network-Message-Id: ffe1273d-a2e5-4293-70f9-08d992b39de7 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:39.9356 (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: YtJ86UdqOFtGIbE+CdKCrOsRP0qi33fTlUCRHBbRned3SAV61fNPyOv6Q6RukZ0XH4auDTQXLbxt60BrvYuuJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0921 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: OYjmu7s3DqNfjQPnwPBs9FpHX9K3DI-u X-Proofpoint-ORIG-GUID: OYjmu7s3DqNfjQPnwPBs9FpHX9K3DI-u 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 impostorscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 bulkscore=0 spamscore=0 phishscore=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 The Linux EFISTUB reads the FDT from the EFI system configuration table. Before installing the FDT needs to be patched with the booting hartid, because the kernel in S-Mode cannot determine it. Cc: Daniel Schaefer Cc: Abner Chang Cc: Sunil V L Reviewed-by: Abner Chang Signed-off-by: Daniel Schaefer --- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc | 2= + Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc | 3= +- Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf | 1= + Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf | 53= +++++++++ Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.c | 116= ++++++++++++++++++++ 5 files changed, 174 insertions(+), 1 deletion(-) diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U5= 40.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.d= sc index 4fab3c4bdcbb..cc62ad05212a 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc @@ -516,6 +516,8 @@ MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf=0D MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf=0D =0D + Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf=0D +=0D #=0D # FAT filesystem + GPT/MBR partitioning + UDF filesystem=0D #=0D diff --git a/Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc b/Silicon/RI= SC-V/ProcessorPkg/RiscVProcessorPkg.dsc index 1292ba1beab7..531319322c62 100644 --- a/Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc +++ b/Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc @@ -1,7 +1,7 @@ #/** @file=0D # RISC-V processor package.=0D #=0D -# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All right= s reserved.
=0D +# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All right= s reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -102,3 +102,4 @@ =0D Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf=0D Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf=0D + Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf=0D diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U5= 40.fdf b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.f= df index f0bd65fad648..c58fa6357451 100644 --- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf +++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf @@ -182,6 +182,7 @@ INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEng= ineDxe.inf INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe= .inf=0D INF FatPkg/EnhancedFatDxe/Fat.inf=0D INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf=0D +INF Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf=0D =0D !ifndef $(SOURCE_DEBUG_ENABLE)=0D INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf b/Sili= con/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf new file mode 100644 index 000000000000..ae6468f9f55f --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.inf @@ -0,0 +1,53 @@ +## @file=0D +# RISC-V Flattened Device Tree DXE module.=0D +#=0D +# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x0001001b=0D + BASE_NAME =3D FdtDxe=0D + FILE_GUID =3D a7d8f3f7-d8a7-47df-b3ec-9E5A693C380C=0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + ENTRY_POINT =3D InstallFdt=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D RISCV64=0D +#=0D +=0D +=0D +[Packages]=0D + EmbeddedPkg/EmbeddedPkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + MdePkg/MdePkg.dec=0D + Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec=0D + EmbeddedPkg/EmbeddedPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + BaseMemoryLib=0D + DebugLib=0D + FdtLib=0D + HobLib=0D + MemoryAllocationLib=0D + RiscVCpuLib=0D + UefiBootServicesTableLib=0D + UefiDriverEntryPoint=0D +=0D +[Sources]=0D + FdtDxe.c=0D +=0D +[Guids]=0D + gFdtHobGuid=0D + gFdtTableGuid=0D +=0D +[Pcd]=0D + gUefiRiscVPlatformPkgTokenSpaceGuid.PcdBootHartId ## CONSUMES=0D +=0D +[Depex]=0D + TRUE=0D diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.c b/Silico= n/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.c new file mode 100644 index 000000000000..22b12027d334 --- /dev/null +++ b/Silicon/RISC-V/ProcessorPkg/Universal/FdtDxe/FdtDxe.c @@ -0,0 +1,116 @@ +/** @file=0D + RISC-V Flattened Device Tree DXE module=0D +=0D + The Linux booting protocol on RISC-V requires the id of the booting hart= to=0D + be passed as a0. Therefore the EFISTUB needs to get this information. Be= cause=0D + it runs in S-Mode, it cannot get this information from mhartid. Instead = we=0D + insert the id into the device tree, that the EFIFSTUB can read from the = config table.=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 +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Fix up the device tree with booting hartid for the kernel=0D +=0D + @param DtbBlob The device tree. Is extended to fit the hart id.=0D +=0D + @retval EFI_SUCCESS The device tree was success fixed up with = the hart id.=0D + @retval EFI_OUT_OF_RESOURCES There is not enough memory available to co= mplete the operation.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +FixDtb (=0D + IN OUT VOID *DtbBlob,=0D + IN UINTN BootingHartId=0D + )=0D +{=0D + fdt32_t Size;=0D + UINT32 ChosenOffset, Err;=0D +=0D + DEBUG ((DEBUG_INFO, "Fixing up device tree with boot hart id: %d\n",=0D + BootingHartId));=0D +=0D + Size =3D fdt_totalsize(DtbBlob);=0D + Err =3D fdt_open_into(DtbBlob, DtbBlob, Size + 32);=0D + if (Err < 0) {=0D + DEBUG ((DEBUG_ERROR,=0D + "Device Tree can't be expanded to accommodate new node\n", __FUNCTIO= N__));=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + ChosenOffset =3D fdt_path_offset(DtbBlob, "/chosen");=0D + fdt_setprop_u32(DtbBlob, ChosenOffset, "boot-hartid", BootingHartId);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Install the FDT passed in HOB into EFI system configuration table.=0D +=0D + @retval EFI_SUCCESS Successfully installed fixed up FDT in conf= ig table.=0D + @retval EFI_NOT_FOUND Did not find FDT HOB.=0D + @retval EFI_OUT_OF_RESOURCES There is not enough memory available to com= plete the operation.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +InstallFdtFromHob (VOID)=0D +{=0D + EFI_STATUS Status;=0D + EFI_HOB_GUID_TYPE *GuidHob;=0D + VOID *DataInHob;=0D + UINTN DataSize;=0D +=0D + GuidHob =3D GetFirstGuidHob (&gFdtHobGuid);=0D + if (GuidHob =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "Failed to find RISC-V DTB Hob\n",=0D + __FUNCTION__));=0D + return EFI_NOT_FOUND;=0D + }=0D + DataInHob =3D (VOID *) *((UINTN *) GET_GUID_HOB_DATA (GuidHob));=0D + DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D +=0D + Status =3D FixDtb (DataInHob, PcdGet32(PcdBootHartId));=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + Status =3D gBS->InstallConfigurationTable (&gFdtTableGuid, DataInHob);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a: failed to install FDT configuration table\n"= ,=0D + __FUNCTION__));=0D + }=0D + return Status;=0D +}=0D +=0D +/**=0D + Install the FDT from the HOB into the EFI system configuration table.=0D +=0D + @param ImageHandle Image handle of this driver.=0D + @param SystemTable Pointer to the System Table.=0D +=0D + @retval EFI_SUCCESS FDT successfully installed into config table.=0D + @retval EFI_NOT_FOUND Did not find FDT HOB.=0D + @retval EFI_OUT_OF_RESOURCES There is not enough memory available to com= plete the operation.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +InstallFdt (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + Status =3D InstallFdtFromHob ();=0D +=0D + return Status;=0D +}=0D --=20 2.31.1