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.web11.7688.1636432020799450548 for ; Mon, 08 Nov 2021 20:27:08 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=U+JA2ycV; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=094764bedf=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 1A93HA8l007157; Tue, 9 Nov 2021 04:27:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : mime-version; s=pps0720; bh=uFQ2uifjCuM97hpDZ8v2CYUn89FgB569A5Qc/h/fxlI=; b=U+JA2ycVMR4CUIi4nAdoL5HLKcoKOEkUrfFOC3RzHBrdOk45+mVUSDa8CVpRUUxQBmG0 GWQn/v3glq4ew7OKSLJ8HDfm3XFTiYw9TIwIp/p6w1h3m358vzU26xZTy0KDqwxo/EqT n5JOaoJgCNQfq/avh5wkaSXU2yhnutUjSuH44ejjT+xYzYcUUaEVwy0nvOxy0RZiu4Wa npYcK+cnRTMlhhiDRelmyHnyQfAZ2sHaLTc79iTwcKtqPqBhJqDGu6LmqPyWcNCWMO/A GnWP+OumD/hoPF7BwLNu4i8cr7/VeJMQxfGJsoULIts+l7r3HUlJpO1rbdYxlCP44FrW +g== Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0b-002e3701.pphosted.com with ESMTP id 3c75c3xntq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Nov 2021 04:26:59 +0000 Received: from G2W6310.americas.hpqcorp.net (g2w6310.austin.hp.com [16.197.64.52]) (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 17E5E61; Tue, 9 Nov 2021 04:26:59 +0000 (UTC) Received: from G9W8453.americas.hpqcorp.net (2002:10d8:a0d3::10d8:a0d3) by G2W6310.americas.hpqcorp.net (2002:10c5:4034::10c5:4034) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 9 Nov 2021 04:26:58 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (15.241.52.11) by G9W8453.americas.hpqcorp.net (16.216.160.211) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Tue, 9 Nov 2021 04:26:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SI0Ad5maUf/kO1uivFZXYH4h/ToEGs/U7yVF+gQ1UPo4bC8PYZtE7AFQpw0VXNjeKiYolevuedqxjNux/ofNc5i/5aY93LgNIZvm8HWFxxbJcwnJExtVT5HQuh3KLmt4/lusS4VwQsRXtwe56V5YppFtxJxjGEJUDcqTndbAtRJt9hxGOfbIEOyrQGRue5gtyzuz36XeK4Bnj7E+7AYZZhAy951rj7lLEEhZXm063R8agKtuR7EBtgOE++K11lMLfZFX8SOXnzK2Y59c2KengRroqsrl5ab8AycKMuC4gaH7+cHU+FPXJxMlMowKctSrqF7B+INiHyYN2s9qnTYlTg== 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=uFQ2uifjCuM97hpDZ8v2CYUn89FgB569A5Qc/h/fxlI=; b=FSzivHQGXR/2Zk4mCp8ej6JqCZL2Ghf2cQUBqCDqSGB2XheKvE8M5vvN2KGuqVfB8kxtUzdgV1x9Gf4+IKYpyM7UxoJST02aPxNCCOgTJoqRjC53LlE5paU/wO6enT+IT9KNAD+4hbqYNUe8jQ5ZcTRngjBOP2YgTjhNb5VYIWIyHF+oombskLwnNKzrLGbZhI4lBX5MIpcCh21KJAViix6o9hyKsrqTLhxy9ofenjp/sviY/7IY4pF6/R7VIq7bFX17K+IF5nQCqzDMPcxuZk0LQgQEWd98BfwM3Joq3A52+peJO2z4q5HQLF0fAXy7d2+hI8tHzcaCpSKNqM6Ryw== 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 Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760f::13) by DF4PR8401MB0683.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7608::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Tue, 9 Nov 2021 04:26:57 +0000 Received: from DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::f16b:a443:db34:2774]) by DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM ([fe80::f16b:a443:db34:2774%11]) with mapi id 15.20.4669.016; Tue, 9 Nov 2021 04:26:57 +0000 From: "Daniel Schaefer" To: "Chang, Abner (HPS SW/FW Technologist)" , "devel@edk2.groups.io" CC: Sunil V L Subject: Re: [edk2-platforms][PATCH 00/30] EDK2 RISC-V port with opensbi v0.9 Thread-Topic: [edk2-platforms][PATCH 00/30] EDK2 RISC-V port with opensbi v0.9 Thread-Index: AQHXxMjleOBGST5g8EK7Kjsb5rQ6s6v6ul+8 Date: Tue, 9 Nov 2021 04:26:57 +0000 Message-ID: References: <20211019081007.31165-1-abner.chang@hpe.com> In-Reply-To: <20211019081007.31165-1-abner.chang@hpe.com> Accept-Language: en-US, de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: hpe.com; dkim=none (message not signed) header.d=none;hpe.com; dmarc=none action=none header.from=hpe.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7ab15218-21b1-4657-b5ac-08d9a3392aae x-ms-traffictypediagnostic: DF4PR8401MB0683: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jYh1BCo3pOInsG68e4O+xDDefe6Qh4a/Uz+vi/nwMlnsZxvmKcErPnRLw/+1BghSGzvLkx2ZsxtqlPo6OjmS/CUwReV9wPeSSIIcsUSkGNGTksPe3U1eyjU/Yc6nFKzlf1wXGVVxen76GAcAuyWmUfUkjElndwIRBCKxNSKvSFJLH0VdNaY2Eb0xnUIFy+6vpH+YWMOqzkSC97mUbCL33HwNk0j55BWOjlH7w7SvqUMU9tTlicc1xFu6qnQFAECoTPS+mZHmQZXOVew6ssddZc0QnK5OF97oeLvSCd7m7rlhF12tV8AsYU0e5EtZqfhniLCXPUcaWpuOshfhbnLNP73ZtnWvR6EDya2db8zqFtq69h+Iq2CkB91E0AR1Z/OR+DrvgabVu1xkENDdP1M2uH4Pjk9EgHnZBSlvcFXgQp/y0FJ53uiFLq7cJm9S0brNM9nSxgkRRWPdq2Al9qSVUlYHSKzrKN0K0OT5SJc4DRzmF+IPoUvb6D85FQGZ3g267bDab8RY6LkQ0Pa00Mjyps9NNU+sNGNbePfksqb8rkQ06VxoHtwMFNnaZOUe9u/JmeDjeTvo7psOLrpPRg7W4qSghMhOr9ZzGWeAPtgLZyO7ejuV/uuEiu8Yd6L4zlLcYTE8w7OwNy5F2vxydJDZ1w6ZFpmiUe9G5nQzuKJIeVuScQkDr2CG5SmG+JSRVqFKEMz8zyzwkEJqVzruOdnN0w== 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)(316002)(110136005)(5660300002)(83380400001)(86362001)(33656002)(71200400001)(38100700002)(8936002)(122000001)(26005)(52536014)(66556008)(64756008)(66446008)(82960400001)(76116006)(66946007)(66476007)(91956017)(8676002)(4326008)(7696005)(2906002)(508600001)(6506007)(53546011)(38070700005)(186003)(9686003)(55016002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?1phF5dE7aZvmQ4fTuEt/dYxLXhKJglsqNmY7bUZkr30HpGbbC1bzpDYY9CrH?= =?us-ascii?Q?NiuccuaNiZloDLDYhr/J3twFXi0CQg5Qhn3ZN67SKTclnLBOSnH68jNIijqW?= =?us-ascii?Q?hOvxzujn3xCh4RDBD2wIbE2kfCmjc3KbVTJY7G0dWCilZ/Oc0o11eBTIovWe?= =?us-ascii?Q?PDSetPO60znIO9thzPQbuNBWhWWjZu/KEmrALuEnjTP35hsudL/6hjuTHfyB?= =?us-ascii?Q?+SjIQkdV9aJUb1V2xgR/VzirBQycBgZM/WNMC5f0cKYBtTty5mHnbvpZGBZg?= =?us-ascii?Q?xThTT84Sk8BSi1vlMukkxTGy4QQN/Bi55QOs9sPyZ4K5GL1ElMT1OSJUEpcV?= =?us-ascii?Q?WORtD+qSbD7HDCXJ+isOLx8vBd2K5V4WtiubxeORYtYSfwUgX6dMwd3Fm8u0?= =?us-ascii?Q?xZ7fTnccoIT3MdVzvRKR5rIukbPesI2lCC2fFag9ycmQn5OlWUUW/bJEK1Xt?= =?us-ascii?Q?EaPNdL/15EPo3+4AQ2vDcvGSXw3tEY2HJoFUqYou9/3d82qAg1+JlgzcmqjC?= =?us-ascii?Q?Usaf5zSzEpbJD9Kc9nDPMdsoxdF3gSR9JYtF7jlxDxvZ+v88GVwJrO/vhW3B?= =?us-ascii?Q?K5uvfYgSrislgoGu2cfoaGudGafEgjSy96h317Jw8WOwD3hoWXNqj/meryN1?= =?us-ascii?Q?hmB8HxPbY9ukKiL0Z34jvCRBoJHRdtfLvGcH2fRYRxv1ZcpRa5aVbDFrcIe3?= =?us-ascii?Q?WjddccPcqUyyjZrD1e+UM0eWaeDFei2TsnA7pXt5poMR85KZseDCN4sL0lS3?= =?us-ascii?Q?2LGFao9E/b6XkBGOx45OphMkiYFjUCMPpfww2hUBbOyCUjTji3AAE0vnh7xD?= =?us-ascii?Q?W5H1qXMktYRijCoZXDpz/S0cKZF1qa3hFxkGUb/CU3U1Cu1ydLS7Tar+I+Jd?= =?us-ascii?Q?REbY/cvCJ4bmfaoCO+/+HzbAYAI6ntewfkLcgV0V+ZHGRnHVhtQl48n1wIXy?= =?us-ascii?Q?qQ2j5lY+NXNBxRmJb+mF0pDAnts8cf6xXPmktGLY/mhKdJjpMNh5aLV8yJVT?= =?us-ascii?Q?T/fgccBlL7nkkTQM3jBETyfPfdcUoCiNFMHtwPBcZ03ZgWNwxc/8aOXhnUo5?= =?us-ascii?Q?oLvzeO7EDE6oiRKK0q1VPi4e4nKn0KPwBvWL+23xRM5flIBVZBm46uyBOOMV?= =?us-ascii?Q?liw/iHydApsrhSfGNilYMWLBWyjUEb1QtyI/RbIHtnoXIexy4QzmT2hAVsZZ?= =?us-ascii?Q?yXvYJliVNRLonXZehi99XKUQol+A/OnJUm+OGDW2H/HO6+dQeb4jSQR10kB/?= =?us-ascii?Q?irK2xr2UPrObQbNam7iT1lq0z+9ymN4wcdkgjgZu9xp4Puz7ySh1lCyt+wIy?= =?us-ascii?Q?e8iqd9Cyoz39WMFpSm821nW6I0GQWYTu6oqXeVlZ4c9j72pq+t1AiZWoEH0L?= =?us-ascii?Q?Jrl1zc076pkqi48UEOS3vStqRPkjKAnapFEGyxMC1lRaJZ7SnaO6Pfk7VMB9?= =?us-ascii?Q?4Ta+EZ6Wanc3FSAhGdACY/Iu/xL04cSooh09R3vHbIHFqZ1BRj1pDvEon9to?= =?us-ascii?Q?42izC7XjDqEDlCnv2VfZUK7ndyRjB9k74jNTN9we9L7YUN7eHswE5Bfsjk3N?= =?us-ascii?Q?QSeihny9EVjN1muRXY5Fadfty0llDeTfVM3SsK/YxaPx2DNFToyxY0hD1R8p?= =?us-ascii?Q?EQ=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0923.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 7ab15218-21b1-4657-b5ac-08d9a3392aae X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2021 04:26:57.2402 (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: GpMIjnNhE+5vU4ntGsAIDPudum5sbqVn6LnZYUFAGYBbpEcjo126Hn+4VCmniuf1ziS41S5C56FH+rwzV9XdQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB0683 X-OriginatorOrg: hpe.com X-Proofpoint-GUID: 9wxU8G-eVd-iJD8YQ5nKPWtOt5HIRmUg X-Proofpoint-ORIG-GUID: 9wxU8G-eVd-iJD8YQ5nKPWtOt5HIRmUg 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.0.607.475 definitions=2021-11-08_07,2021-11-08_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 clxscore=1011 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111090023 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_DF4PR8401MB0923CBAEC8E60C402EC5E942E0929DF4PR8401MB0923_" --_000_DF4PR8401MB0923CBAEC8E60C402EC5E942E0929DF4PR8401MB0923_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Daniel Schaefer ________________________________ From: Chang, Abner (HPS SW/FW Technologist) Sent: Tuesday, October 19, 2021 16:09 To: devel@edk2.groups.io Cc: Chang, Abner (HPS SW/FW Technologist) ; Sunil V L = ; Schaefer, Daniel Subject: [edk2-platforms][PATCH 00/30] EDK2 RISC-V port with opensbi v0.9 This is the patch set to incorporate opensbi v0.9 with edk2 RISC-V port. There are many architecture changes to compliant with the RISC-V SBI implementation (opensbi) and also provide the flexibility to OEM platform. Below is the summary of major changes. You can also refer to patch (1/31) to understand the architecture design. - Flexibly support privilege modes for edk2 execution phases using PCD. - M-mode SEC then S-mode all the way to boot OS. - M-mode SEC and PEI, then S-mode for DXE to boot OS. - M-mode firmware all the way to S-mode OS. Default is M-mode SEC then S-mode all the way to boot OS. Still have to implemente priviledge mode switching for PEI to DXE and BDSto Boot OS. - Apply opensbi firmware domain solution to protect firmware regions using FDF/PCD. - Provide Platform SEC PPI library that can be executed in either M-mode or S-mode PEI phases according to OEM platform definition. - Determine boot hart using Device Tree or PCD. This allows OEM to flexibly select the desired HARTs for booting system. Non-boot HARTs can be used for other applications/purposes. - Provide an edk2 library wrapper of opensbi platform functions. This allows OEM to have procedures that hooks before or after the certain opensbi platform functions. - Other patches to adopt opensbi v0.9. Cc: Sunil V L Cc: Daniel Schaefer Signed-off-by: Abner Chang Abner Chang (30): RISC-V/PlatformPkg: Update document RISC-V: Add RISC-V PeiCoreEntryPoint library RISC-V: Create opensbi firmware domains RISC-V: Use RISC-V PeiCoreEntryPoint library Platform/RISC-V: Add library to get PPI descriptor Platform/U540: Provide PlatormSecPpiLib Platform/RISC-V: Use PlatformSecPpiLib Platform/SiFive: CoreInfoHob uses RiscVFirmwareContextLib SiFive/U5SeriesPkg: Add CLINT to Device Tree Platform/RISC-V: Add NULL library instance of RiscVSpecialPlatformLib SiFive/U540: RiscVSpecialPlatformLib instance of U540 Platform/RISC-V: Remove platform dependency from this library Platform/RISC-V: Remove Null instance of OpensbilatformLibNull RiscVPlatformPkg/Sec: Initial hart_index2Id array RiscVPlatformPkg/OpensbiPlatformLib: Remove platform code RiscVPlatformPkg/U540: Only use four harts on U540 U5SeriesPkg/PeiCoreInfoHob: Remove hart count check RiscVPlatformPkg/RiscVSpecialPlatformLib: Rename module name RiscVPlatformPkg/U540: Add SortLib ProcessorPkg/opensbi: Update opensbi library RiscVPlatformPkg/Sec: Check Cold/Warm hart RiscVPlatformPkg/Sec: Add more comments to Secmain.c RiscV/ProcessorPkg: Create read mtime CSR library instances RiscV/ProcessorPkg: Use mtime CSR library Silicon/SiFive: Use mtime CSR library SiFive/SerialPortLib: Remove global variable RISC-V/PlatformPkg: Updates for the latest OpenSBI RiscVPlatformPkg/Sec: Separate EDK2 Opensbi platform hook. RISC-V/PlatformPkg: Determine hart number from DTB Silicon/RISC-V: Add PciCpuIoDxe driver .../RISC-V/PlatformPkg/RiscVPlatformPkg.dec | 52 +- .../RISC-V/ProcessorPkg/RiscVProcessorPkg.dec | 1 + .../RISC-V/PlatformPkg/RiscVPlatformPkg.dsc | 20 +- .../FreedomU500VC707Board/U500.dsc | 1 + .../FreedomU540HiFiveUnleashedBoard/U540.dsc | 11 +- .../RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc | 3 + .../U540.fdf.inc | 94 +- .../VarStore.fdf.inc | 8 +- .../Edk2OpensbiPlatformWrapperLib.inf | 44 + .../OpensbiPlatformLib/OpensbiPlatformLib.inf | 11 +- .../OpensbiPlatformLibNull.inf | 38 - .../PeiCoreEntryPoint/PeiCoreEntryPoint.inf | 37 + .../PlatformSecPpiLibNull.inf | 36 + .../RiscVSpecialPlatformLibNull.inf | 36 + .../PlatformPkg/Universal/Sec/SecMain.inf | 15 +- .../RiscVSpecialPlatformLib.inf | 36 + .../PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf | 3 +- .../PlatformSecPpiLib/PlatformSecPpiLib.inf | 43 + .../Universal/Dxe/TimerDxe/TimerDxe.inf | 1 + .../EmulatedMachineModeTimerLib.inf | 34 + .../MachineModeTimerLib.inf | 38 + .../RiscVTimerLib/BaseRiscVTimerLib.inf | 3 +- .../ProcessorPkg/Universal/CpuDxe/CpuDxe.inf | 1 + .../Universal/PciCpuIo2Dxe/PciCpuIo2Dxe.inf | 47 + .../Library/Edk2OpensbiPlatformWrapperLib.h | 16 + .../Include/Library/PlatformSecPpiLib.h | 24 + .../Include/Library/RiscVSpecialPlatformLib.h | 20 + .../OpensbiPlatformLib/PlatformOverride.h | 30 - .../PlatformPkg/Universal/Sec/SecMain.h | 28 +- .../SiFive/U5SeriesPkg/Include/SifiveU5Uart.h | 1 + .../Include/IndustryStandard/RiscV.h | 5 + .../Include/IndustryStandard/RiscVOpensbi.h | 8 +- .../Include/Library/RiscVCpuLib.h | 3 + .../Edk2OpensbiPlatformWrapperLib.c | 530 +++++ .../Library/OpensbiPlatformLib/Platform.c | 77 +- .../Library/OpensbiPlatformLibNull/Platform.c | 51 - .../PeiCoreEntryPoint/PeiCoreEntryPoint.c | 108 + .../PlatformSecPpiLibNull/PlatformSecPpiLib.c | 28 + .../RiscVSpecialPlatformLib.c | 20 + .../PlatformPkg/Universal/Sec/SecMain.c | 268 +-- .../RiscVSpecialPlatformLib}/SifiveFu540.c | 11 +- .../Library/PeiCoreInfoHobLib/CoreInfoHob.c | 9 +- .../PlatformSecPpiLib/PlatformSecPpiLib.c | 148 ++ .../Library/SerialIoLib/SerialPortLib.c | 58 +- .../Universal/Dxe/TimerDxe/Timer.c | 14 +- .../Library/RiscVTimerLib/RiscVTimerLib.c | 6 +- .../ProcessorPkg/Universal/CpuDxe/CpuDxe.c | 2 +- .../Universal/PciCpuIo2Dxe/PciCpuIo2Dxe.c | 554 +++++ .../Library/PeiCoreInfoHobLib/CoreInfoHob.c | 6 +- Platform/RISC-V/PlatformPkg/Readme.md | 132 +- .../Documents/Media/RiscVEdk2BootProcess.svg | 1928 +++++++++++++++++ .../Documents/Media/RiscVEdk2FwDomain.svg | 1290 +++++++++++ .../PeiCoreEntryPoint/PeiCoreEntryPoint.uni | 14 + .../Universal/Sec/Riscv64/SecEntry.S | 372 ++-- .../DeviceTree/fu540-c000.dtsi | 591 ++--- .../Library/RiscVOpensbiLib/opensbi | 2 +- .../EmulatedMachineModeTimerLib.S | 24 + .../MachineModeTimerLib/MachineModeTimerLib.S | 25 + 58 files changed, 6105 insertions(+), 911 deletions(-) create mode 100644 Platform/RISC-V/PlatformPkg/Library/Edk2OpensbiPlatform= WrapperLib/Edk2OpensbiPlatformWrapperLib.inf delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibN= ull/OpensbiPlatformLibNull.inf create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/P= eiCoreEntryPoint.inf create mode 100644 Platform/RISC-V/PlatformPkg/Library/PlatformSecPpiLibNu= ll/PlatformSecPpiLibNull.inf create mode 100644 Platform/RISC-V/PlatformPkg/Library/RiscVSpecialPlatfor= mLibNull/RiscVSpecialPlatformLibNull.inf create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedB= oard/Library/RiscVSpecialPlatformLib/RiscVSpecialPlatformLib.inf create mode 100644 Platform/SiFive/U5SeriesPkg/Library/PlatformSecPpiLib/P= latformSecPpiLib.inf create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineMod= eTimer/EmulatedMachineModeTimerLib/EmulatedMachineModeTimerLib.inf create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineMod= eTimer/MachineModeTimerLib/MachineModeTimerLib.inf create mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/PciCpuIo2Dxe/PciC= puIo2Dxe.inf create mode 100644 Platform/RISC-V/PlatformPkg/Include/Library/Edk2Opensbi= PlatformWrapperLib.h create mode 100644 Platform/RISC-V/PlatformPkg/Include/Library/PlatformSec= PpiLib.h create mode 100644 Platform/RISC-V/PlatformPkg/Include/Library/RiscVSpecia= lPlatformLib.h delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLib/= PlatformOverride.h create mode 100644 Platform/RISC-V/PlatformPkg/Library/Edk2OpensbiPlatform= WrapperLib/Edk2OpensbiPlatformWrapperLib.c delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatformLibN= ull/Platform.c create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/P= eiCoreEntryPoint.c create mode 100644 Platform/RISC-V/PlatformPkg/Library/PlatformSecPpiLibNu= ll/PlatformSecPpiLib.c create mode 100644 Platform/RISC-V/PlatformPkg/Library/RiscVSpecialPlatfor= mLibNull/RiscVSpecialPlatformLib.c rename Platform/{RISC-V/PlatformPkg/Library/OpensbiPlatformLib =3D> SiFive= /U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPlatformLi= b}/SifiveFu540.c (76%) create mode 100644 Platform/SiFive/U5SeriesPkg/Library/PlatformSecPpiLib/P= latformSecPpiLib.c create mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/PciCpuIo2Dxe/PciC= puIo2Dxe.c create mode 100644 Platform/RISC-V/PlatformPkg/Documents/Media/RiscVEdk2Bo= otProcess.svg create mode 100644 Platform/RISC-V/PlatformPkg/Documents/Media/RiscVEdk2Fw= Domain.svg create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/P= eiCoreEntryPoint.uni create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineMod= eTimer/EmulatedMachineModeTimerLib/EmulatedMachineModeTimerLib.S create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineMod= eTimer/MachineModeTimerLib/MachineModeTimerLib.S -- 2.31.1 --_000_DF4PR8401MB0923CBAEC8E60C402EC5E942E0929DF4PR8401MB0923_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Daniel Schaefer <daniel.schaefer@hpe.com>

From: Chang, Abner (HPS SW/= FW Technologist) <abner.chang@hpe.com>
Sent: Tuesday, October 19, 2021 16:09
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Chang, Abner (HPS SW/FW Technologist) <abner.chang@hpe.com>= ;; Sunil V L <sunilvl@ventanamicro.com>; Schaefer, Daniel <daniel.= schaefer@hpe.com>
Subject: [edk2-platforms][PATCH 00/30] EDK2 RISC-V port with opensbi= v0.9
 
This is the patch set to incorporate opensbi v0.9 = with edk2
RISC-V port. There are many architecture changes to compliant
with the RISC-V SBI implementation (opensbi) and also provide the
flexibility to OEM platform.

Below is the summary of major changes. You can also refer to patch (1/31) to understand the architecture design.

- Flexibly support privilege modes for edk2 execution phases using PCD.
  - M-mode SEC then S-mode all the way to boot OS.
  - M-mode SEC and PEI, then S-mode for DXE to boot OS.
  - M-mode firmware all the way to S-mode OS.
  Default is M-mode SEC then S-mode all the way to boot OS.
  Still have to implemente priviledge mode switching for PEI to DXE an= d
  BDSto Boot OS.

- Apply opensbi firmware domain solution to protect firmware regions using<= br>   FDF/PCD.

- Provide Platform SEC PPI library that can be executed in either M-mode or=
  S-mode PEI phases according to OEM platform definition.

- Determine boot hart using Device Tree or PCD. This allows OEM to
  flexibly select the desired HARTs for booting system. Non-boot HARTs=
  can be used for other applications/purposes.

- Provide an edk2 library wrapper of opensbi platform functions. This
  allows OEM to have procedures that hooks before or after the certain=
  opensbi platform functions.

- Other patches to adopt opensbi v0.9.

Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
Signed-off-by: Abner Chang <abner.chang@hpe.com>

Abner Chang (30):
  RISC-V/PlatformPkg: Update document
  RISC-V: Add RISC-V PeiCoreEntryPoint library
  RISC-V: Create opensbi firmware domains
  RISC-V: Use RISC-V PeiCoreEntryPoint library
  Platform/RISC-V: Add library to get PPI descriptor
  Platform/U540: Provide PlatormSecPpiLib
  Platform/RISC-V: Use PlatformSecPpiLib
  Platform/SiFive: CoreInfoHob uses RiscVFirmwareContextLib
  SiFive/U5SeriesPkg: Add CLINT to Device Tree
  Platform/RISC-V: Add NULL library instance of RiscVSpecialPlatformLi= b
  SiFive/U540: RiscVSpecialPlatformLib instance of U540
  Platform/RISC-V: Remove platform dependency from this library
  Platform/RISC-V: Remove Null instance of OpensbilatformLibNull
  RiscVPlatformPkg/Sec: Initial hart_index2Id array
  RiscVPlatformPkg/OpensbiPlatformLib: Remove platform code
  RiscVPlatformPkg/U540: Only use four harts on U540
  U5SeriesPkg/PeiCoreInfoHob: Remove hart count check
  RiscVPlatformPkg/RiscVSpecialPlatformLib: Rename module name
  RiscVPlatformPkg/U540: Add SortLib
  ProcessorPkg/opensbi: Update opensbi library
  RiscVPlatformPkg/Sec: Check Cold/Warm hart
  RiscVPlatformPkg/Sec: Add more comments to Secmain.c
  RiscV/ProcessorPkg: Create read mtime CSR library instances
  RiscV/ProcessorPkg: Use mtime CSR library
  Silicon/SiFive: Use mtime CSR library
  SiFive/SerialPortLib: Remove global variable
  RISC-V/PlatformPkg: Updates for the latest OpenSBI
  RiscVPlatformPkg/Sec: Separate EDK2 Opensbi platform hook.
  RISC-V/PlatformPkg: Determine hart number from DTB
  Silicon/RISC-V: Add PciCpuIoDxe driver

 .../RISC-V/PlatformPkg/RiscVPlatformPkg.dec   |  = 52 +-
 .../RISC-V/ProcessorPkg/RiscVProcessorPkg.dec |    1 +=
 .../RISC-V/PlatformPkg/RiscVPlatformPkg.dsc   |  = 20 +-
 .../FreedomU500VC707Board/U500.dsc      = ;      |    1 +
 .../FreedomU540HiFiveUnleashedBoard/U540.dsc  |   11 += -
 .../RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc |    3 +=
 .../U540.fdf.inc         = ;            &n= bsp;        |   94 +-
 .../VarStore.fdf.inc        &= nbsp;           &nbs= p;     |    8 +-
 .../Edk2OpensbiPlatformWrapperLib.inf     &n= bsp;   |   44 +
 .../OpensbiPlatformLib/OpensbiPlatformLib.inf |   11 +-
 .../OpensbiPlatformLibNull.inf      &nb= sp;         |   38 -
 .../PeiCoreEntryPoint/PeiCoreEntryPoint.inf   |  = 37 +
 .../PlatformSecPpiLibNull.inf      &nbs= p;          |   36 +=
 .../RiscVSpecialPlatformLibNull.inf     &nbs= p;     |   36 +
 .../PlatformPkg/Universal/Sec/SecMain.inf     |&n= bsp;  15 +-
 .../RiscVSpecialPlatformLib.inf      &n= bsp;        |   36 +
 .../PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf   |  =   3 +-
 .../PlatformSecPpiLib/PlatformSecPpiLib.inf   |  = 43 +
 .../Universal/Dxe/TimerDxe/TimerDxe.inf     =   |    1 +
 .../EmulatedMachineModeTimerLib.inf     &nbs= p;     |   34 +
 .../MachineModeTimerLib.inf       =             | &= nbsp; 38 +
 .../RiscVTimerLib/BaseRiscVTimerLib.inf     =   |    3 +-
 .../ProcessorPkg/Universal/CpuDxe/CpuDxe.inf  |   = ; 1 +
 .../Universal/PciCpuIo2Dxe/PciCpuIo2Dxe.inf   |  = 47 +
 .../Library/Edk2OpensbiPlatformWrapperLib.h   |  = 16 +
 .../Include/Library/PlatformSecPpiLib.h     =   |   24 +
 .../Include/Library/RiscVSpecialPlatformLib.h |   20 +
 .../OpensbiPlatformLib/PlatformOverride.h     |&n= bsp;  30 -
 .../PlatformPkg/Universal/Sec/SecMain.h     =   |   28 +-
 .../SiFive/U5SeriesPkg/Include/SifiveU5Uart.h |    1 +=
 .../Include/IndustryStandard/RiscV.h     &nb= sp;    |    5 +
 .../Include/IndustryStandard/RiscVOpensbi.h   |  =   8 +-
 .../Include/Library/RiscVCpuLib.h      =        |    3 +
 .../Edk2OpensbiPlatformWrapperLib.c     &nbs= p;     |  530 +++++
 .../Library/OpensbiPlatformLib/Platform.c     |&n= bsp;  77 +-
 .../Library/OpensbiPlatformLibNull/Platform.c |   51 -
 .../PeiCoreEntryPoint/PeiCoreEntryPoint.c     |&n= bsp; 108 +
 .../PlatformSecPpiLibNull/PlatformSecPpiLib.c |   28 +
 .../RiscVSpecialPlatformLib.c      &nbs= p;          |   20 +=
 .../PlatformPkg/Universal/Sec/SecMain.c     =   |  268 +--
 .../RiscVSpecialPlatformLib}/SifiveFu540.c    | &= nbsp; 11 +-
 .../Library/PeiCoreInfoHobLib/CoreInfoHob.c   |  =   9 +-
 .../PlatformSecPpiLib/PlatformSecPpiLib.c     |&n= bsp; 148 ++
 .../Library/SerialIoLib/SerialPortLib.c     =   |   58 +-
 .../Universal/Dxe/TimerDxe/Timer.c      = ;      |   14 +-
 .../Library/RiscVTimerLib/RiscVTimerLib.c     |&n= bsp;   6 +-
 .../ProcessorPkg/Universal/CpuDxe/CpuDxe.c    | &= nbsp;  2 +-
 .../Universal/PciCpuIo2Dxe/PciCpuIo2Dxe.c     |&n= bsp; 554 +++++
 .../Library/PeiCoreInfoHobLib/CoreInfoHob.c   |  =   6 +-
 Platform/RISC-V/PlatformPkg/Readme.md     &n= bsp;   |  132 +-
 .../Documents/Media/RiscVEdk2BootProcess.svg  | 1928 +++++++++++= ++++++
 .../Documents/Media/RiscVEdk2FwDomain.svg     | 1= 290 +++++++++++
 .../PeiCoreEntryPoint/PeiCoreEntryPoint.uni   |  = 14 +
 .../Universal/Sec/Riscv64/SecEntry.S     &nb= sp;    |  372 ++--
 .../DeviceTree/fu540-c000.dtsi      &nb= sp;         |  591 ++---
 .../Library/RiscVOpensbiLib/opensbi     &nbs= p;     |    2 +-
 .../EmulatedMachineModeTimerLib.S      =        |   24 +
 .../MachineModeTimerLib/MachineModeTimerLib.S |   25 +
 58 files changed, 6105 insertions(+), 911 deletions(-)
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/Edk2OpensbiPla= tformWrapperLib/Edk2OpensbiPlatformWrapperLib.inf
 delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatfor= mLibNull/OpensbiPlatformLibNull.inf
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPo= int/PeiCoreEntryPoint.inf
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/PlatformSecPpi= LibNull/PlatformSecPpiLibNull.inf
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/RiscVSpecialPl= atformLibNull/RiscVSpecialPlatformLibNull.inf
 create mode 100644 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnlea= shedBoard/Library/RiscVSpecialPlatformLib/RiscVSpecialPlatformLib.inf
 create mode 100644 Platform/SiFive/U5SeriesPkg/Library/PlatformSecPpi= Lib/PlatformSecPpiLib.inf
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachi= neModeTimer/EmulatedMachineModeTimerLib/EmulatedMachineModeTimerLib.inf
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachi= neModeTimer/MachineModeTimerLib/MachineModeTimerLib.inf
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/PciCpuIo2Dxe= /PciCpuIo2Dxe.inf
 create mode 100644 Platform/RISC-V/PlatformPkg/Include/Library/Edk2Op= ensbiPlatformWrapperLib.h
 create mode 100644 Platform/RISC-V/PlatformPkg/Include/Library/Platfo= rmSecPpiLib.h
 create mode 100644 Platform/RISC-V/PlatformPkg/Include/Library/RiscVS= pecialPlatformLib.h
 delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatfor= mLib/PlatformOverride.h
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/Edk2OpensbiPla= tformWrapperLib/Edk2OpensbiPlatformWrapperLib.c
 delete mode 100644 Platform/RISC-V/PlatformPkg/Library/OpensbiPlatfor= mLibNull/Platform.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPo= int/PeiCoreEntryPoint.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/PlatformSecPpi= LibNull/PlatformSecPpiLib.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/RiscVSpecialPl= atformLibNull/RiscVSpecialPlatformLib.c
 rename Platform/{RISC-V/PlatformPkg/Library/OpensbiPlatformLib =3D>= ; SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/Library/RiscVSpecialPl= atformLib}/SifiveFu540.c (76%)
 create mode 100644 Platform/SiFive/U5SeriesPkg/Library/PlatformSecPpi= Lib/PlatformSecPpiLib.c
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/PciCpuIo2Dxe= /PciCpuIo2Dxe.c
 create mode 100644 Platform/RISC-V/PlatformPkg/Documents/Media/RiscVE= dk2BootProcess.svg
 create mode 100644 Platform/RISC-V/PlatformPkg/Documents/Media/RiscVE= dk2FwDomain.svg
 create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPo= int/PeiCoreEntryPoint.uni
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachi= neModeTimer/EmulatedMachineModeTimerLib/EmulatedMachineModeTimerLib.S
 create mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachi= neModeTimer/MachineModeTimerLib/MachineModeTimerLib.S

--
2.31.1

--_000_DF4PR8401MB0923CBAEC8E60C402EC5E942E0929DF4PR8401MB0923_--