<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hi Mike and Ray,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I just got a chance to back on this topic and below are few questions regarding the UefiCpuPkg for all processor archs.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I change the subject and loop Chao Li from Loongsoon who is contributing Loongarch64 to Uefi/edk2. He may have to handle the similar things for Loongarch64.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I went through RISC-V modules that currently located on edk2-platforms repo (Platform/RISC-V/PlatformPKg and Silicon/RISC-V/ProcessorPkg) and figure out the modules we would move to under UefiCpuPkg and MdeModulePkg.  We could go through the proposal in the
 design meeting later, however I would like to confirm the proposal of revising modules under /UEfiCpuPkg those were implemented in X86 oriented before we get to that point.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style=""><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<ul>
<li><span><span style="">UefiCpuPKg\SecCore</span><br>
</span></li><li style="display: block;"><span><span style=""><span data-pm-slice="1 1 []" data-en-clipboard="true"><span style="color: rgb(0, 0, 0);">The implementation of this module is very x86 oriented. There is likely nothing to leverage between archs. My thought was </span></span></span></span></li><li style="display: block;"><span><span style=""><span data-pm-slice="1 1 []" data-en-clipboard="true"><span style="color: rgb(0, 0, 0);">1. Having RISC-V SecCore in its own folder, e.g. UefiCpuPkg/RISC-V/SecCore and create the individual INF for archs.</span></span></span></span></li><li style="display:block"><span><span style="">However, <br>
<span><span style="color: rgb(0, 0, 0);">2. We can also consider having the separate section in SecCore/SecCore.inf. Move all X86 source files to under UefiCpuPkg/SecCore/X86 <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">and
 have /RISC-V folder under UefiCpuPkg/SecCore</span>  for RISC-V arch. (I prefer this way)</span></span><br>
</span></span></li><li style="display:block"><span><span style=""><span><span style="color: rgb(24, 133, 226);"><br>
</span></span></span></span></li><li style=""><span><span style=""><span><span style="color: rgb(24, 133, 226);"><span data-pm-slice="1 3 []" data-en-clipboard="true"><span style="color: rgb(0, 0, 0);">UefiCpuPKg/BaseUefiCpuLib</span></span></span></span></span></span></li><li style="display:block">1. Rename BaseUefiCpuLib.c to BaseUefiCpuLibIa32X64.c</li><li style="display:block"><span style="">   BaseUefiCpuLibRiscV64.c for RISC-V arch and assembly code under /RISCV64</span></li><li style="display:block"><span style="">2. Or move all X86 source files to under BaseUefiCpuLib/X86, BaseUefiCpuLib/RISC-V for RISC-V arch <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">(I prefer this way,
 the directory looks clean)</span></span></li><li style="display:block"><span style=""><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;"><br>
</span></span></li><li><span data-pm-slice="1 1 []" data-en-clipboard="true"><span style="color: rgb(0, 0, 0);">UefiCpuPKg/CpuExceptionHandlerLib</span></span>
<div><span style="color: rgb(0, 0, 0);">Too many X86 source files, m</span><span style="">ove all X86 source files to under CpuExecptionHander/X86, </span><span style="">CpuExecptionHander/RISC-V for RISC-V arch</span></div>
</li><li style="display:block">Having abstract level under /<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">CpuExecptionHander, e.g. INF, PeiException.c, DxeException.c and etc.</span></li><li style="display:block">
<div><span style=""><br>
</span></div>
</li><li style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span data-pm-slice="1 3 []" data-en-clipboard="true"><span style="color: rgb(0, 0, 0);">UefiCpuPKg\Library\CpuTimerLib</span></span></li><li style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: block;">
1. Rename BaseCpuTimerLib.c to BaseCpuTimerLibIa32X64.c, <span style="">BaseCpuTimerLibRiscV64.c for RISC-V arch.</span></li><li style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: block;">
<span style="">2. Or move all X86 source files to under BaseUefiCpuLib/X86, BaseUefiCpuLib/RISC-V for RISC-V arch <span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;">(I prefer this way)</span></span></li><li style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: block;">
<span style=""><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: inline !important;"><br>
</span></span></li><li style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span data-pm-slice="1 1 []" data-en-clipboard="true"><span style="color: rgb(0, 0, 0);">UefiCpuPKg/CpuDxe</span></span></li><li style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: block;">
<span style="color: rgb(0, 0, 0);">Revise CpuDxe.c and CpuDxe.h to be abstract for the processor archs.</span></li><li style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); display: block;">
<span style="color: rgb(0, 0, 0);">Move all x86 implementations to under /X86, </span><span style="color: rgb(0, 0, 0);">CpuDxe/RISC-V for RISC-V CpuDxe implementation</span></li></ul>
<div><span style="color: rgb(0, 0, 0);">Let me know your thoughts, I can initiate the PoC code after we get on the same page.</span></div>
<div><span style="color: rgb(0, 0, 0);">Thanks</span></div>
<div><span style="color: rgb(0, 0, 0);">Abner</span></div>
<div><span style="color: rgb(0, 0, 0);"><br>
</span></div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size: 11pt;"><b>From:</b> Chang, Abner (HPS SW/FW Technologist)<br>
<b>Sent:</b> Saturday, February 5, 2022 10:56 PM<br>
<b>To:</b> Kinney, Michael D <michael.d.kinney@intel.com>; Leif Lindholm <leif@nuviainc.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Ni, Ray <ray.ni@intel.com><br>
<b>Cc:</b> Andrew Fish <afish@apple.com>; Sami Mujawar <Sami.Mujawar@arm.com><br>
<b>Subject:</b> RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files of RISC-V processor package</font>
<div> </div>
</div>
<div lang="EN-US" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
Thanks Mike.</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
The reason I asked this question is we are working on the OvmfRiscV64 as you suggested. However as you know that both RISC-V processor and platform packages are currently stay in edk2-platforms.  We have to make sure  CI won’t throw errors if we use the edk2
 modules in edk2-platforms. We are in rush to have RISC-V edk2 OVMF for RISC-V community. We will start to move RISC-V edk2 port to UefiCpuPkg or MdePkg once RISC-V OVMF port is upstream.</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
Abner</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b>From:</b> Kinney, Michael D <michael.d.kinney@intel.com> <br>
<b>Sent:</b> Saturday, February 5, 2022 4:22 AM<br>
<b>To:</b> Chang, Abner (HPS SW/FW Technologist) <abner.chang@hpe.com>; Leif Lindholm <leif@nuviainc.com>; devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com><br>
<b>Cc:</b> Andrew Fish <afish@apple.com>; Sami Mujawar <Sami.Mujawar@arm.com><br>
<b>Subject:</b> RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files of RISC-V processor package</p>
</div>
</div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
Abner,</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
I do not know if this patter is being used yet, but there is great value in it for all platforms that are intended to be synced with edk2.</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
The idea of testing an edk2 change against all available open source platforms that use edk2 would increase confidence in the edk2 change.</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
>From a CI agent perspective, there are no issues with pulling more repos and running tests and providing results that can block an edk2 change if it breaks a specific platform.</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
Mike</p>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b>From:</b> Chang, Abner (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>>
<br>
<b>Sent:</b> Friday, February 4, 2022 8:15 AM<br>
<b>To:</b> Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>>; Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>;
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Ni, Ray <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>><br>
<b>Cc:</b> Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
<b>Subject:</b> Re: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files of RISC-V processor package</p>
</div>
</div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;">BTW Mike,</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;">Can Core CI on edk2 repo allow the modules referred in the DSC/FDF (e.g., OvmgRiscV64.dsc) to stay in edk2-platform?</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;">Abner</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size: 12pt; color: black;"> </span></p>
</div>
<div class="x_MsoNormal" align="center" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="color: black;">From:</span></b><span style="color: black;"> Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
<b>Sent:</b> Saturday, January 22, 2022 1:37 AM<br>
<b>To:</b> Chang, Abner (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>>; Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>;
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a> <<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>>; Ni, Ray <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>>; Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
<b>Cc:</b> Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
<b>Subject:</b> RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files of RISC-V processor package</span>
</p>
<div>
<p class="x_MsoNormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
I would recommend adding the Platform DSC required to run RISC-V with QEMU to <span class="x_xspelle">
OvmfPkg</span> so it can be part of CI for edk2 repo so any change to edk2 that is used by RISC-V can be verified by build and boot to shell.</p>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
I would like to see the <span class="x_xspelle">ArmVirtPkg</span> merged into <span class="x_xspelle">
OvmfPkg</span> too so <span class="x_xspelle">OvmfPkg</span> <span class="x_xspelle">
providse</span> FW build for all support CPU <span class="x_xspelle">Archs</span> running through QEMU to support edk2 CI that can build and boot to shell in an Azure Pipelines agent.</p>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
Mike</p>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b>From:</b> Chang, Abner (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>>
<br>
<b>Sent:</b> Friday, January 21, 2022 9:13 AM<br>
<b>To:</b> Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>>; Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>;
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Ni, Ray <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>><br>
<b>Cc:</b> Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
<b>Subject:</b> Re: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files of RISC-V processor package</p>
</div>
</div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;">Ok Mike and Leif,</span></p>
</div>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;">Another question regarding to the location of RISC-V Virtual package for QEMU. What is the location and package you think RISC-V or other processor architectures should stay with?</span></p>
</div>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;"> </span></p>
</div>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;">Thanks</span></p>
</div>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; background: white;">
<span style="font-size: 12pt; color: black;">Abner</span></p>
</div>
<div class="x_MsoNormal" align="center" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<hr size="1" width="98%" align="center">
</div>
<div id="x_x_divRplyFwdMsg">
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="color: black;">From:</span></b><span style="color: black;"> Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
<b>Sent:</b> Saturday, January 15, 2022 12:21 AM<br>
<b>To:</b> Chang, Abner (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>>; Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>;
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a> <<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>>; Ni, Ray <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>>; Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
<b>Cc:</b> Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
<b>Subject:</b> RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files of RISC-V processor package</span>
</p>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:12.0pt">
Hi Abner,<br>
<br>
We already have a package for common platform content in the edk2 repo.<br>
This is the MdeModulePkg.<br>
<br>
However, the number of common platform features added to the MdeModulePkg over<br>
time has made this a very large package, and this can be measured by how complex the<br>
Maintainer.txt rules are for this package.<br>
<br>
The revised approach is to create feature packages that platforms can add<br>
if their platform requires that specific feature category.  Examples are<br>
NetworkPkg, SecurityPkg, FmpDevicePkg, FatPkg, RedfishPkg, SourceLevelDebugPkg.<br>
<br>
Instead of adding another generic package such as CommonPlatformPkg, I<br>
would prefer to see the libs/modules either added to existing packages<br>
that match the feature category, or create new feature packages if <br>
there is a new feature category.<br>
<br>
We also try to limit the edk2 repo to components that are directly related<br>
the UEFI/PI specifications and are not Si/Platform specific.  Si/Platform<br>
specific features go into the edk2-platforms repo.  An example of a generic<br>
feature in the edk2-platforms repo is Features/Ext4.  The UEFI spec only<br>
specifies FAT for UEFI boot from file system.<br>
<br>
There are a number of other feature packages in edk2-platforms in the<br>
Features directory, so you should review those as well to see if there<br>
is natural landing zone for any of your components.<br>
<br>
Mike<br>
<br>
<br>
> -----Original Message-----<br>
> From: Chang, Abner (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>><br>
> Sent: Friday, January 14, 2022 3:15 AM<br>
> To: Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>>; Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>;
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Ni, Ray<br>
> <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>><br>
> Cc: Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
> Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files of RISC-V processor package<br>
> <br>
> <br>
> <br>
> > -----Original Message-----<br>
> > From: Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
> > Sent: Friday, January 14, 2022 12:38 AM<br>
> > To: Chang, Abner (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>>; Leif<br>
> > Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>; <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Ni, Ray<br>
> > <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>>; Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
> > Cc: Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar<br>
> > <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
> > Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header<br>
> > files of RISC-V processor package<br>
> ><br>
> > Hi Abner,<br>
> ><br>
> > General recommendations included below.  Of course each<br>
> > lib/modules/include needs to be reviewed and the<br>
> > best location selected.  I am aware that there are components in edk2 that<br>
> > do not follow these general<br>
> > recommendations.  This is due to content that was added before these<br>
> > recommendations were established<br>
> > and we have work to do to get everything aligned.<br>
> ><br>
> > Mike<br>
> ><br>
> > > -----Original Message-----<br>
> > > From: Chang, Abner (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>><br>
> > > Sent: Wednesday, January 12, 2022 9:34 PM<br>
> > > To: Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>>; Leif Lindholm<br>
> > <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>; <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Ni, Ray<br>
> > > <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>><br>
> > > Cc: Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar<br>
> > <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
> > > Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add<br>
> > header files of RISC-V processor package<br>
> > ><br>
> > > HI Mike,<br>
> > > It is no problem to meet there. However, I am not available to join the<br>
> > design meeting in the next two weeks. Before we can get<br>
> > > together to discuss the best locations, do you have information regarding<br>
> > the rationale of driver/library location?<br>
> > ><br>
> > > What is the best location for,<br>
> > > - Processor ARCH dependent modules<br>
> ><br>
> > MdePkg for libs<br>
> > UefiCpuPkg for modules<br>
> ><br>
> > > - Common modules for all processor ARCHs<br>
> ><br>
> > Feature Packages based on the common feature.  Add to existing if it fits.<br>
> > Create new for completely new feature area.<br>
> ><br>
> > > - Platform module that is specific to processor ARCH?<br>
> ><br>
> > edk2-platform repository<br>
> How about Leif's suggestion? The CommonPlatformPkg on edk2?<br>
> <br>
> Abner<br>
> <br>
> ><br>
> > The only exception so far are platform modules used to support<br>
> > OvmfPkg/QEMU to support CI.<br>
> > In this case the modules are added to OvmfPkg.<br>
> ><br>
> > > - Platform module that is common to processor ARCHs?<br>
> ><br>
> > edk2-platform repository<br>
> ><br>
> > The only exception so far are platform modules used to support<br>
> > OvmfPkg/QEMU to support CI.<br>
> > In this case the modules are added to OvmfPkg.<br>
> ><br>
> > ><br>
> > > Thanks<br>
> > > Abner<br>
> > ><br>
> > > > -----Original Message-----<br>
> > > > From: Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
> > > > Sent: Monday, January 10, 2022 11:58 PM<br>
> > > > To: Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>;
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Chang,<br>
> > Abner<br>
> > > > (HPS SW/FW Technologist) <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>>; Kinney, Michael D<br>
> > > > <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>>; Ni, Ray <<a href="mailto:ray.ni@intel.com">ray.ni@intel.com</a>><br>
> > > > Cc: Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar<br>
> > > > <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
> > > > Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add<br>
> > header<br>
> > > > files of RISC-V processor package<br>
> > > ><br>
> > > > Hi Abner,<br>
> > > ><br>
> > > > I see comments from Leif as well.<br>
> > > ><br>
> > > > Do you think a discussion in the design meeting Ray Ni runs would be<br>
> > > > valuable<br>
> > > > to review all the modules/libs/includes and discuss options for the best<br>
> > > > location for them to reside in the edk2 repos?<br>
> > > ><br>
> > > > Thanks,<br>
> > > ><br>
> > > > Mike<br>
> > > ><br>
> > > > > -----Original Message-----<br>
> > > > > From: Kinney, Michael D <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
> > > > > Sent: Monday, January 10, 2022 7:55 AM<br>
> > > > > To: Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>>;
<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Chang,<br>
> > > > Abner <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>>; Kinney, Michael D<br>
> > > > > <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>><br>
> > > > > Cc: Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Sami Mujawar<br>
> > > > <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
> > > > > Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add<br>
> > > > header files of RISC-V processor package<br>
> > > > ><br>
> > > > > Hi Abner,<br>
> > > > ><br>
> > > > > I would also like to see some proposals on adding the RiscV CPU scoped<br>
> > > > content<br>
> > > > > to the existing MdePkg/UefiCpuPkg instead of adding a new top level<br>
> > CPU<br>
> > > > package.<br>
> > > > ><br>
> > > > > There is already some work started to move some of the ARM specific<br>
> > > > content<br>
> > > > > from ARM CPU packages into MdePkg.<br>
> > > > ><br>
> > > > > Thanks,<br>
> > > > ><br>
> > > > > Mike<br>
> > > > ><br>
> > > > > > -----Original Message-----<br>
> > > > > > From: Leif Lindholm <<a href="mailto:leif@nuviainc.com">leif@nuviainc.com</a>><br>
> > > > > > Sent: Monday, January 10, 2022 5:11 AM<br>
> > > > > > To: <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; Chang, Abner <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>><br>
> > > > > > Cc: Andrew Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>>; Kinney, Michael D<br>
> > > > <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>>; Sami Mujawar<br>
> > <<a href="mailto:Sami.Mujawar@arm.com">Sami.Mujawar@arm.com</a>><br>
> > > > > > Subject: Re: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add<br>
> > > > header files of RISC-V processor package<br>
> > > > > ><br>
> > > > > > On Sat, Jan 08, 2022 at 12:07:53 +0800, Abner Chang wrote:<br>
> > > > > > > (This is migrated from edk2-platforms:Silicon/RISC-V)<br>
> > > > > > ><br>
> > > > > > > RISC-V processor package library definitions.<br>
> > > > > > ><br>
> > > > > > > IndustryStandard/RiscV.h<br>
> > > > > > > -Add RiscV.h which conform with RISC-V Privilege Spec v1.10.<br>
> > > > > > ><br>
> > > > > > > RiscVImpl.h<br>
> > > > > > > -Definition of EDK2 RISC-V implementation.<br>
> > > > > > ><br>
> > > > > > > Signed-off-by: Abner Chang <<a href="mailto:abner.chang@hpe.com">abner.chang@hpe.com</a>><br>
> > > > > > > Co-authored-by: Daniel Schaefer <<a href="mailto:daniel.schaefer@hpe.com">daniel.schaefer@hpe.com</a>><br>
> > > > > > > Co-authored-by: Gilbert Chen <<a href="mailto:gilbert.chen@hpe.com">gilbert.chen@hpe.com</a>><br>
> > > > > > > Reviewed-by: Leif Lindholm <<a href="mailto:leif.lindholm@linaro.org">leif.lindholm@linaro.org</a>><br>
> > > > > ><br>
> > > > > > Hmm, no.<br>
> > > > > > I gave a reviewed-by for that patch to be merged into edk2-platforms<br>
> > > > > > once upon a time. This is not relevant for migration to edk2.<br>
> > > > > ><br>
> > > > > > My proposal for migrating this code would be as follows:<br>
> > > > > > - Announce a hold on merging new code to RiscV portions of<br>
> > > > > >   edk2-platforms.<br>
> > > > > > - Apply any and all bugfixes and CI/uncrustify fixes in place in<br>
> > > > > >   edk2-platforms.<br>
> > > > > > - Get some level of agreement for what to do instead of<br>
> > > > > >   RiscVPlatformPkg - i.e. slot into MdeModulePkg instead.<br>
> > > > > >   -  If that cannot be reached within a few days, create a new<br>
> > > > > >      top-level directory called "CommonPlatformPkg" or something,<br>
> > > > > >      with you, Daniel(/Gilbert?), Sami, me as maintainers.<br>
> > > > > >      - Move all of the RiscVPlatformPkg code under there instead.<br>
> > > > > >      - I'll follow with ArmPlatformPkg.<br>
> > > > > >      - PC/AT code should move across too over time.<br>
> > > > > > - Move the rest of the code across unmodified as massive single<br>
> > > > > >   patches per package (potentially more patches than that for<br>
> > > > > >   RiscVPlatformPkg).<br>
> > > > > >   - Drop all existing Reviewed-by/Acked-by.<br>
> > > > > >   - After each "move" patch, insert a "fixup" patch to address the<br>
> > > > > >     things that need fixing due to path/name changes.<br>
> > > > > ><br>
> > > > > > /<br>
> > > > > >     Leif<br>
> > > > > ><br>
> > > > > > > Cc: Leif Lindholm <<a href="mailto:leif.lindholm@linaro.org">leif.lindholm@linaro.org</a>><br>
> > > > > > > Cc: Gilbert Chen <<a href="mailto:gilbert.chen@hpe.com">gilbert.chen@hpe.com</a>><br>
> > > > > > > ---<br>
> > > > > > >  .../Include/IndustryStandard/RiscV.h          | 156<br>
> > ++++++++++++++++++<br>
> > > > > > >  .../RISC-V/ProcessorPkg/Include/RiscVImpl.h   |  87 ++++++++++<br>
> > > > > > >  2 files changed, 243 insertions(+)<br>
> > > > > > >  create mode 100644 Silicon/RISC-<br>
> > > > V/ProcessorPkg/Include/IndustryStandard/RiscV.h<br>
> > > > > > >  create mode 100644 Silicon/RISC-<br>
> > V/ProcessorPkg/Include/RiscVImpl.h<br>
> > > > > > ><br>
> > > > > > > diff --git a/Silicon/RISC-<br>
> > > > V/ProcessorPkg/Include/IndustryStandard/RiscV.h b/Silicon/RISC-<br>
> > > > > > V/ProcessorPkg/Include/IndustryStandard/RiscV.h<br>
> > > > > > > new file mode 100644<br>
> > > > > > > index 0000000000..2a992394ed<br>
> > > > > > > --- /dev/null<br>
> > > > > > > +++ b/Silicon/RISC-<br>
> > V/ProcessorPkg/Include/IndustryStandard/RiscV.h<br>
> > > > > > > @@ -0,0 +1,156 @@<br>
> > > > > > > +/** @file<br>
> > > > > > > +  RISC-V package definitions.<br>
> > > > > > > +<br>
> > > > > > > +  Copyright (c) 2019, Hewlett Packard Enterprise Development LP.<br>
> > All<br>
> > > > rights reserved.<BR><br>
> > > > > > > +<br>
> > > > > > > +  SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> > > > > > > +<br>
> > > > > > > +**/<br>
> > > > > > > +<br>
> > > > > > > +#ifndef RISCV_INDUSTRY_STANDARD_H_<br>
> > > > > > > +#define RISCV_INDUSTRY_STANDARD_H_<br>
> > > > > > > +<br>
> > > > > > > +#if defined (MDE_CPU_RISCV64)<br>
> > > > > > > +#define RISC_V_XLEN_BITS 64<br>
> > > > > > > +#else<br>
> > > > > > > +#endif<br>
> > > > > > > +<br>
> > > > > > > +#define RISC_V_ISA_ATOMIC_EXTENSION                 (0x00000001 <<<br>
> > 0)<br>
> > > > > > > +#define RISC_V_ISA_BIT_OPERATION_EXTENSION<br>
> > (0x00000001<br>
> > > > << 1)<br>
> > > > > > > +#define RISC_V_ISA_COMPRESSED_EXTENSION             (0x00000001<br>
> > <<<br>
> > > > 2)<br>
> > > > > > > +#define RISC_V_ISA_DOUBLE_PRECISION_FP_EXTENSION<br>
> > > > (0x00000001 << 3)<br>
> > > > > > > +#define RISC_V_ISA_RV32E_ISA                        (0x00000001 << 4)<br>
> > > > > > > +#define RISC_V_ISA_SINGLE_PRECISION_FP_EXTENSION<br>
> > > > (0x00000001 << 5)<br>
> > > > > > > +#define RISC_V_ISA_ADDITIONAL_STANDARD_EXTENSION<br>
> > > > (0x00000001 << 6)<br>
> > > > > > > +#define RISC_V_ISA_RESERVED_1                       (0x00000001 << 7)<br>
> > > > > > > +#define RISC_V_ISA_INTEGER_ISA_EXTENSION            (0x00000001<br>
> > <<<br>
> > > > 8)<br>
> > > > > > > +#define<br>
> > > > RISC_V_ISA_DYNAMICALLY_TRANSLATED_LANGUAGE_EXTENSION<br>
> > > > (0x00000001 << 9)<br>
> > > > > > > +#define RISC_V_ISA_RESERVED_2                       (0x00000001 << 10)<br>
> > > > > > > +#define RISC_V_ISA_DECIMAL_FP_EXTENSION             (0x00000001<br>
> > <<<br>
> > > > 11)<br>
> > > > > > > +#define RISC_V_ISA_INTEGER_MUL_DIV_EXTENSION<br>
> > (0x00000001<br>
> > > > << 12)<br>
> > > > > > > +#define RISC_V_ISA_USER_LEVEL_INTERRUPT_SUPPORTED<br>
> > > > (0x00000001 << 13)<br>
> > > > > > > +#define RISC_V_ISA_RESERVED_3                       (0x00000001 << 14)<br>
> > > > > > > +#define RISC_V_ISA_PACKED_SIMD_EXTENSION<br>
> > (0x00000001 <<<br>
> > > > 15)<br>
> > > > > > > +#define RISC_V_ISA_QUAD_PRECISION_FP_EXTENSION<br>
> > > > (0x00000001 << 16)<br>
> > > > > > > +#define RISC_V_ISA_RESERVED_4                       (0x00000001 << 17)<br>
> > > > > > > +#define RISC_V_ISA_SUPERVISOR_MODE_IMPLEMENTED<br>
> > > > (0x00000001 << 18)<br>
> > > > > > > +#define RISC_V_ISA_TRANSATIONAL_MEMORY_EXTENSION<br>
> > > > (0x00000001 << 19)<br>
> > > > > > > +#define RISC_V_ISA_USER_MODE_IMPLEMENTED<br>
> > (0x00000001<br>
> > > > << 20)<br>
> > > > > > > +#define RISC_V_ISA_VECTOR_EXTENSION                 (0x00000001 <<<br>
> > 21)<br>
> > > > > > > +#define RISC_V_ISA_RESERVED_5                       (0x00000001 << 22)<br>
> > > > > > > +#define RISC_V_ISA_NON_STANDARD_EXTENSION<br>
> > (0x00000001<br>
> > > > << 23)<br>
> > > > > > > +#define RISC_V_ISA_RESERVED_6                       (0x00000001 << 24)<br>
> > > > > > > +#define RISC_V_ISA_RESERVED_7                       (0x00000001 << 25)<br>
> > > > > > > +<br>
> > > > > > > +//<br>
> > > > > > > +// RISC-V CSR definitions.<br>
> > > > > > > +//<br>
> > > > > > > +//<br>
> > > > > > > +// Machine information<br>
> > > > > > > +//<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MVENDORID     0xF11<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MARCHID       0xF12<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MIMPID        0xF13<br>
> > > > > > > +#define RISCV_CSR_MACHINE_HARRID        0xF14<br>
> > > > > > > +//<br>
> > > > > > > +// Machine Trap Setup.<br>
> > > > > > > +//<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MSTATUS       0x300<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MISA          0x301<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MEDELEG       0x302<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MIDELEG       0x303<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MIE           0x304<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MTVEC         0x305<br>
> > > > > > > +<br>
> > > > > > > +#define RISCV_TIMER_COMPARE_BITS      32<br>
> > > > > > > +//<br>
> > > > > > > +// Machine Timer and Counter.<br>
> > > > > > > +//<br>
> > > > > > > +//#define RISCV_CSR_MACHINE_MTIME         0x701<br>
> > > > > > > +//#define RISCV_CSR_MACHINE_MTIMEH        0x741<br>
> > > > > > > +//<br>
> > > > > > > +// Machine Trap Handling.<br>
> > > > > > > +//<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MSCRATCH      0x340<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MEPC          0x341<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MCAUSE        0x342<br>
> > > > > > > +  #define MACHINE_MCAUSE_EXCEPTION_ MASK 0x0f<br>
> > > > > > > +  #define MACHINE_MCAUSE_INTERRUPT      (RISC_V_XLEN_BITS -<br>
> > 1)<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MBADADDR      0x343<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MIP           0x344<br>
> > > > > > > +<br>
> > > > > > > +//<br>
> > > > > > > +// Machine Protection and Translation.<br>
> > > > > > > +//<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MBASE         0x380<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MBOUND        0x381<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MIBASE        0x382<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MIBOUND       0x383<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MDBASE        0x384<br>
> > > > > > > +#define RISCV_CSR_MACHINE_MDBOUND       0x385<br>
> > > > > > > +<br>
> > > > > > > +//<br>
> > > > > > > +// Supervisor mode CSR.<br>
> > > > > > > +//<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_SSTATUS    0x100<br>
> > > > > > > +  #define SSTATUS_SIE_BIT_POSITION      1<br>
> > > > > > > +  #define SSTATUS_SPP_BIT_POSITION      8<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_SIE        0x104<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_SSCRATCH   0x140<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_SEPC       0x141<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_SCAUSE     0x142<br>
> > > > > > > +  #define SCAUSE_USER_SOFTWARE_INT        0<br>
> > > > > > > +  #define SCAUSE_SUPERVISOR_SOFTWARE_INT  1<br>
> > > > > > > +  #define SCAUSE_USER_TIMER_INT           4<br>
> > > > > > > +  #define SCAUSE_SUPERVISOR_TIMER_INT     5<br>
> > > > > > > +  #define SCAUSE_USER_EXTERNAL_INT        8<br>
> > > > > > > +  #define SCAUSE_SUPERVISOR_EXTERNAL_INT  9<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_STVAL      0x143<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_SIP        0x144<br>
> > > > > > > +#define RISCV_CSR_SUPERVISOR_SATP       0x180<br>
> > > > > > > +<br>
> > > > > > > +#if defined (MDE_CPU_RISCV64)<br>
> > > > > > > +  #define RISCV_SATP_MODE_MASK          0xF000000000000000<br>
> > > > > > > +  #define RISCV_SATP_MODE_BIT_POSITION  60<br>
> > > > > > > +#endif<br>
> > > > > > > +    #define RISCV_SATP_MODE_OFF         0<br>
> > > > > > > +    #define RISCV_SATP_MODE_SV32        1<br>
> > > > > > > +    #define RISCV_SATP_MODE_SV39        8<br>
> > > > > > > +    #define RISCV_SATP_MODE_SV48        9<br>
> > > > > > > +    #define RISCV_SATP_MODE_SV57        10<br>
> > > > > > > +    #define RISCV_SATP_MODE_SV64        11<br>
> > > > > > > +<br>
> > > > > > > +  #define SATP64_ASID_MASK              0x0FFFF00000000000<br>
> > > > > > > +  #define SATP64_PPN_MASK               0x00000FFFFFFFFFFF<br>
> > > > > > > +<br>
> > > > > > > +#define RISCV_CAUSE_MISALIGNED_FETCH        0x0<br>
> > > > > > > +#define RISCV_CAUSE_FETCH_ACCESS            0x1<br>
> > > > > > > +#define RISCV_CAUSE_ILLEGAL_INSTRUCTION     0x2<br>
> > > > > > > +#define RISCV_CAUSE_BREAKPOINT              0x3<br>
> > > > > > > +#define RISCV_CAUSE_MISALIGNED_LOAD         0x4<br>
> > > > > > > +#define RISCV_CAUSE_LOAD_ACCESS             0x5<br>
> > > > > > > +#define RISCV_CAUSE_MISALIGNED_STORE        0x6<br>
> > > > > > > +#define RISCV_CAUSE_STORE_ACCESS            0x7<br>
> > > > > > > +#define RISCV_CAUSE_USER_ECALL              0x8<br>
> > > > > > > +#define RISCV_CAUSE_HYPERVISOR_ECALL        0x9<br>
> > > > > > > +#define RISCV_CAUSE_SUPERVISOR_ECALL        0xa<br>
> > > > > > > +#define RISCV_CAUSE_MACHINE_ECALL           0xb<br>
> > > > > > > +#define RISCV_CAUSE_FETCH_PAGE_FAULT        0xc<br>
> > > > > > > +#define RISCV_CAUSE_LOAD_PAGE_FAULT         0xd<br>
> > > > > > > +#define RISCV_CAUSE_STORE_PAGE_FAULT        0xf<br>
> > > > > > > +#define RISCV_CAUSE_FETCH_GUEST_PAGE_FAULT  0x14<br>
> > > > > > > +#define RISCV_CAUSE_LOAD_GUEST_PAGE_FAULT   0x15<br>
> > > > > > > +#define RISCV_CAUSE_STORE_GUEST_PAGE_FAULT  0x17<br>
> > > > > > > +<br>
> > > > > > > +//<br>
> > > > > > > +// Machine Read-Write Shadow of Hypervisor Read-Only Registers<br>
> > > > > > > +//<br>
> > > > > > > +#define RISCV_CSR_HTIMEW                0xB01<br>
> > > > > > > +#define RISCV_CSR_HTIMEHW               0xB81<br>
> > > > > > > +//<br>
> > > > > > > +// Machine Host-Target Interface (Non-Standard Berkeley<br>
> > Extension)<br>
> > > > > > > +//<br>
> > > > > > > +#define RISCV_CSR_MTOHOST               0x780<br>
> > > > > > > +#define RISCV_CSR_MFROMHOST             0x781<br>
> > > > > > > +<br>
> > > > > > > +#endif<br>
> > > > > > > diff --git a/Silicon/RISC-V/ProcessorPkg/Include/RiscVImpl.h<br>
> > > > b/Silicon/RISC-V/ProcessorPkg/Include/RiscVImpl.h<br>
> > > > > > > new file mode 100644<br>
> > > > > > > index 0000000000..14092df174<br>
> > > > > > > --- /dev/null<br>
> > > > > > > +++ b/Silicon/RISC-V/ProcessorPkg/Include/RiscVImpl.h<br>
> > > > > > > @@ -0,0 +1,87 @@<br>
> > > > > > > +/** @file<br>
> > > > > > > +  RISC-V package definitions.<br>
> > > > > > > +<br>
> > > > > > > +  Copyright (c) 2016 - 2019, Hewlett Packard Enterprise<br>
> > Development<br>
> > > > LP. All rights reserved.<BR><br>
> > > > > > > +<br>
> > > > > > > +  SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> > > > > > > +<br>
> > > > > > > +**/<br>
> > > > > > > +<br>
> > > > > > > +#ifndef RISCV_H_<br>
> > > > > > > +#define RISCV_H_<br>
> > > > > > > +<br>
> > > > > > > +#include <Uefi.h><br>
> > > > > > > +#include <IndustryStandard/RiscV.h><br>
> > > > > > > +<br>
> > > > > > > +#define _ASM_FUNC(Name, Section)    \<br>
> > > > > > > +  .global   Name                  ; \<br>
> > > > > > > +  .section  #Section, "ax"        ; \<br>
> > > > > > > +  .type     Name, %function       ; \<br>
> > > > > > > +  .p2align  2                     ; \<br>
> > > > > > > +  Name:<br>
> > > > > > > +<br>
> > > > > > > +#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text.<br>
> > ##<br>
> > > > Name)<br>
> > > > > > > +<br>
> > > > > > > +#if defined (MDE_CPU_RISCV64)<br>
> > > > > > > +typedef UINT64 RISC_V_REGS_PROTOTYPE;<br>
> > > > > > > +#else<br>
> > > > > > > +#endif<br>
> > > > > > > +<br>
> > > > > > > +//<br>
> > > > > > > +// Structure for 128-bit value<br>
> > > > > > > +//<br>
> > > > > > > +typedef struct {<br>
> > > > > > > +  UINT64            Value64_L;<br>
> > > > > > > +  UINT64            Value64_H;<br>
> > > > > > > +} RISCV_UINT128;<br>
> > > > > > > +<br>
> > > > > > > +#define RISCV_MACHINE_CONTEXT_SIZE  0x1000<br>
> > > > > > > +typedef struct _RISCV_MACHINE_MODE_CONTEXT<br>
> > > > RISCV_MACHINE_MODE_CONTEXT;<br>
> > > > > > > +<br>
> > > > > > > +///<br>
> > > > > > > +/// Exception handlers in context.<br>
> > > > > > > +///<br>
> > > > > > > +typedef struct _EXCEPTION_HANDLER_CONTEXT {<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS InstAddressMisalignedHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS InstAccessFaultHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS IllegalInstHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS BreakpointHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS LoadAddrMisalignedHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS LoadAccessFaultHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS StoreAmoAddrMisalignedHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS StoreAmoAccessFaultHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS EnvCallFromUModeHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS EnvCallFromSModeHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS EnvCallFromHModeHander;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS EnvCallFromMModeHander;<br>
> > > > > > > +} EXCEPTION_HANDLER_CONTEXT;<br>
> > > > > > > +<br>
> > > > > > > +///<br>
> > > > > > > +/// Exception handlers in context.<br>
> > > > > > > +///<br>
> > > > > > > +typedef struct _INTERRUPT_HANDLER_CONTEXT {<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS SoftwareIntHandler;<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS TimerIntHandler;<br>
> > > > > > > +} INTERRUPT_HANDLER_CONTEXT;<br>
> > > > > > > +<br>
> > > > > > > +///<br>
> > > > > > > +/// Interrupt handlers in context.<br>
> > > > > > > +///<br>
> > > > > > > +typedef struct _TRAP_HANDLER_CONTEXT {<br>
> > > > > > > +  EXCEPTION_HANDLER_CONTEXT ExceptionHandlerContext;<br>
> > > > > > > +  INTERRUPT_HANDLER_CONTEXT IntHandlerContext;<br>
> > > > > > > +} TRAP_HANDLER_CONTEXT;<br>
> > > > > > > +<br>
> > > > > > > +///<br>
> > > > > > > +/// Machine mode context used for saveing hart-local context.<br>
> > > > > > > +///<br>
> > > > > > > +typedef struct _RISCV_MACHINE_MODE_CONTEXT {<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS PeiService;                /// PEI service.<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS MachineModeTrapHandler;    ///<br>
> > Machine<br>
> > > > mode trap handler.<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS HypervisorModeTrapHandler; ///<br>
> > Hypervisor<br>
> > > > mode trap handler.<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS SupervisorModeTrapHandler; ///<br>
> > Supervisor<br>
> > > > mode trap handler.<br>
> > > > > > > +  EFI_PHYSICAL_ADDRESS UserModeTrapHandler;       /// USer<br>
> > mode<br>
> > > > trap handler.<br>
> > > > > > > +  TRAP_HANDLER_CONTEXT MModeHandler;              /// Handler for<br>
> > > > machine mode.<br>
> > > > > > > +} RISCV_MACHINE_MODE_CONTEXT;<br>
> > > > > > > +<br>
> > > > > > > +#endif<br>
> > > > > > > --<br>
> > > > > > > 2.31.1<br>
> > > > > > ><br>
> > > > > > ><br>
> > > > > > ><br>
> > > > > > > <br>
> > > > > > ><br>
> > > > > > ><br>
> </p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/87111">View/Reply Online (#87111)</a> |    |  <a target="_blank" href="https://groups.io/mt/89466486/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>