Re: [edk2-devel] RFC: UefiCpuPkg for all processor archs

2022-03-03 Thread Abner Chang
Hi Mike,
Do you have any feedback on this? Or we just bring this topic to the design 
meeting? That would be good if any of you can give other thoughts, so I can 
have some POC code before the design meeting.

Thanks
Abner

From: devel@edk2.groups.io  on behalf of Abner Chang 

Sent: Tuesday, March 1, 2022 5:56 PM
To: Ni, Ray ; Kinney, Michael D ; 
Leif Lindholm ; devel@edk2.groups.io ; 
LiChao 
Cc: Andrew Fish ; Sami Mujawar ; 
Schaefer, Daniel (ROM Janitor) ; Sunil V L 

Subject: Re: [edk2-devel] RFC: UefiCpuPkg for all processor archs

Hi Ray,
RISC-V doesn't have the similar functions as those are provided in 
BaseUefiCpuLib.c. In this case, what we can do is just leverage the library 
class but different implementation for archs?
At least we don't need another library class for RISC-V. We can have the common 
source file if all archs provided the same functionality later.

Regards,
Abner

From: Ni, Ray 
Sent: Tuesday, March 1, 2022 3:07 PM
To: Chang, Abner (HPS SW/FW Technologist) ; Kinney, 
Michael D ; Leif Lindholm ; 
devel@edk2.groups.io ; LiChao 
Cc: Andrew Fish ; Sami Mujawar ; LiChao 
; Schaefer, Daniel (ROM Janitor) ; 
Sunil V L 
Subject: RE: RFC: UefiCpuPkg for all processor archs


Abner,

UefiCpuPkg\SecCore\SecCoreNative.inf is a module that might not depend on X86. 
It assumes the UefiCpuPkg/ResetVector inits the CPU well.



UefiCpuPKg/BaseUefiCpuLib

1. Rename BaseUefiCpuLib.c to BaseUefiCpuLibIa32X64.c

   BaseUefiCpuLibRiscV64.c for RISC-V arch and assembly code under /RISCV64

2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way, the directory looks 
clean)



That depends on whether the RISC-V or LoongArch can implement the same API as 
that in X86 version. Maybe some of the APIs are too X86 specific that makes it 
hard for implementing for other ARCHs. That might lead to a more abstraction. 
Without the concrete implementation available, I have no idea what abstraction 
is.



Thanks,

Ray



From: Chang, Abner (HPS SW/FW Technologist) 
Sent: Tuesday, March 1, 2022 9:26 AM
To: Kinney, Michael D ; Leif Lindholm 
; devel@edk2.groups.io; Ni, Ray ; LiChao 

Cc: Andrew Fish ; Sami Mujawar ; LiChao 
; Schaefer, Daniel ; Sunil V L 

Subject: RFC: UefiCpuPkg for all processor archs



Hi Mike and Ray,

I just got a chance to back on this topic and below are few questions regarding 
the UefiCpuPkg for all processor archs.

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.



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.



  *   UefiCpuPKg\SecCore
  *   The implementation of this module is very x86 oriented. There is likely 
nothing to leverage between archs. My thought was
  *   1. Having RISC-V SecCore in its own folder, e.g. 
UefiCpuPkg/RISC-V/SecCore and create the individual INF for archs.
  *   However,
2. We can also consider having the separate section in SecCore/SecCore.inf. 
Move all X86 source files to under UefiCpuPkg/SecCore/X86 and have /RISC-V 
folder under UefiCpuPkg/SecCore  for RISC-V arch. (I prefer this way)
  *
  *   UefiCpuPKg/BaseUefiCpuLib
  *   1. Rename BaseUefiCpuLib.c to BaseUefiCpuLibIa32X64.c
  *  BaseUefiCpuLibRiscV64.c for RISC-V arch and assembly code under 
/RISCV64
  *   2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way, the directory looks 
clean)
  *
  *   UefiCpuPKg/CpuExceptionHandlerLib

Too many X86 source files, move all X86 source files to under 
CpuExecptionHander/X86, CpuExecptionHander/RISC-V for RISC-V arch

  *   Having abstract level under /CpuExecptionHander, e.g. INF, 
PeiException.c, DxeException.c and etc.

  *

  *   UefiCpuPKg\Library\CpuTimerLib
  *   1. Rename BaseCpuTimerLib.c to BaseCpuTimerLibIa32X64.c, 
BaseCpuTimerLibRiscV64.c for RISC-V arch.
  *   2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way)
  *
  *   UefiCpuPKg/CpuDxe
  *   Revise CpuDxe.c and CpuDxe.h to be abstract for the processor archs.
  *   Move all x86 implementations to under /X86, CpuDxe/RISC-V for RISC-V 
CpuDxe implementation

Let me know your thoughts, I can initiate the PoC code after we get on the same 
page.

Thanks

Abner





From: Chang, Abner (HPS SW/FW Technologist)
Sent: Saturday, February 5, 2022 10:56 PM
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com

Re: [edk2-devel] RFC: UefiCpuPkg for all processor archs

2022-03-01 Thread Abner Chang
Hi Ray,
RISC-V doesn't have the similar functions as those are provided in 
BaseUefiCpuLib.c. In this case, what we can do is just leverage the library 
class but different implementation for archs?
At least we don't need another library class for RISC-V. We can have the common 
source file if all archs provided the same functionality later.

Regards,
Abner

From: Ni, Ray 
Sent: Tuesday, March 1, 2022 3:07 PM
To: Chang, Abner (HPS SW/FW Technologist) ; Kinney, 
Michael D ; Leif Lindholm ; 
devel@edk2.groups.io ; LiChao 
Cc: Andrew Fish ; Sami Mujawar ; LiChao 
; Schaefer, Daniel (ROM Janitor) ; 
Sunil V L 
Subject: RE: RFC: UefiCpuPkg for all processor archs


Abner,

UefiCpuPkg\SecCore\SecCoreNative.inf is a module that might not depend on X86. 
It assumes the UefiCpuPkg/ResetVector inits the CPU well.



UefiCpuPKg/BaseUefiCpuLib

1. Rename BaseUefiCpuLib.c to BaseUefiCpuLibIa32X64.c

   BaseUefiCpuLibRiscV64.c for RISC-V arch and assembly code under /RISCV64

2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way, the directory looks 
clean)



That depends on whether the RISC-V or LoongArch can implement the same API as 
that in X86 version. Maybe some of the APIs are too X86 specific that makes it 
hard for implementing for other ARCHs. That might lead to a more abstraction. 
Without the concrete implementation available, I have no idea what abstraction 
is.



Thanks,

Ray



From: Chang, Abner (HPS SW/FW Technologist) 
Sent: Tuesday, March 1, 2022 9:26 AM
To: Kinney, Michael D ; Leif Lindholm 
; devel@edk2.groups.io; Ni, Ray ; LiChao 

Cc: Andrew Fish ; Sami Mujawar ; LiChao 
; Schaefer, Daniel ; Sunil V L 

Subject: RFC: UefiCpuPkg for all processor archs



Hi Mike and Ray,

I just got a chance to back on this topic and below are few questions regarding 
the UefiCpuPkg for all processor archs.

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.



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.



  *   UefiCpuPKg\SecCore
  *   The implementation of this module is very x86 oriented. There is likely 
nothing to leverage between archs. My thought was
  *   1. Having RISC-V SecCore in its own folder, e.g. 
UefiCpuPkg/RISC-V/SecCore and create the individual INF for archs.
  *   However,
2. We can also consider having the separate section in SecCore/SecCore.inf. 
Move all X86 source files to under UefiCpuPkg/SecCore/X86 and have /RISC-V 
folder under UefiCpuPkg/SecCore  for RISC-V arch. (I prefer this way)
  *
  *   UefiCpuPKg/BaseUefiCpuLib
  *   1. Rename BaseUefiCpuLib.c to BaseUefiCpuLibIa32X64.c
  *  BaseUefiCpuLibRiscV64.c for RISC-V arch and assembly code under 
/RISCV64
  *   2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way, the directory looks 
clean)
  *
  *   UefiCpuPKg/CpuExceptionHandlerLib

Too many X86 source files, move all X86 source files to under 
CpuExecptionHander/X86, CpuExecptionHander/RISC-V for RISC-V arch

  *   Having abstract level under /CpuExecptionHander, e.g. INF, 
PeiException.c, DxeException.c and etc.

  *

  *   UefiCpuPKg\Library\CpuTimerLib
  *   1. Rename BaseCpuTimerLib.c to BaseCpuTimerLibIa32X64.c, 
BaseCpuTimerLibRiscV64.c for RISC-V arch.
  *   2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way)
  *
  *   UefiCpuPKg/CpuDxe
  *   Revise CpuDxe.c and CpuDxe.h to be abstract for the processor archs.
  *   Move all x86 implementations to under /X86, CpuDxe/RISC-V for RISC-V 
CpuDxe implementation

Let me know your thoughts, I can initiate the PoC code after we get on the same 
page.

Thanks

Abner





From: Chang, Abner (HPS SW/FW Technologist)
Sent: Saturday, February 5, 2022 10:56 PM
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; Leif Lindholm 
mailto:l...@nuviainc.com>>; 
devel@edk2.groups.io 
mailto:devel@edk2.groups.io>>; Ni, Ray 
mailto:ray...@intel.com>>
Cc: Andrew Fish mailto:af...@apple.com>>; Sami Mujawar 
mailto:sami.muja...@arm.com>>
Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files 
of RISC-V processor package



Thanks Mike.

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 

Re: [edk2-devel] RFC: UefiCpuPkg for all processor archs

2022-02-28 Thread Ni, Ray
Abner,
UefiCpuPkg\SecCore\SecCoreNative.inf is a module that might not depend on X86. 
It assumes the UefiCpuPkg/ResetVector inits the CPU well.

UefiCpuPKg/BaseUefiCpuLib
1. Rename BaseUefiCpuLib.c to BaseUefiCpuLibIa32X64.c
   BaseUefiCpuLibRiscV64.c for RISC-V arch and assembly code under /RISCV64
2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way, the directory looks 
clean)

That depends on whether the RISC-V or LoongArch can implement the same API as 
that in X86 version. Maybe some of the APIs are too X86 specific that makes it 
hard for implementing for other ARCHs. That might lead to a more abstraction. 
Without the concrete implementation available, I have no idea what abstraction 
is.

Thanks,
Ray

From: Chang, Abner (HPS SW/FW Technologist) 
Sent: Tuesday, March 1, 2022 9:26 AM
To: Kinney, Michael D ; Leif Lindholm 
; devel@edk2.groups.io; Ni, Ray ; LiChao 

Cc: Andrew Fish ; Sami Mujawar ; LiChao 
; Schaefer, Daniel ; Sunil V L 

Subject: RFC: UefiCpuPkg for all processor archs

Hi Mike and Ray,
I just got a chance to back on this topic and below are few questions regarding 
the UefiCpuPkg for all processor archs.
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.

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.


  *   UefiCpuPKg\SecCore
  *   The implementation of this module is very x86 oriented. There is likely 
nothing to leverage between archs. My thought was
  *   1. Having RISC-V SecCore in its own folder, e.g. 
UefiCpuPkg/RISC-V/SecCore and create the individual INF for archs.
  *   However,
2. We can also consider having the separate section in SecCore/SecCore.inf. 
Move all X86 source files to under UefiCpuPkg/SecCore/X86 and have /RISC-V 
folder under UefiCpuPkg/SecCore  for RISC-V arch. (I prefer this way)
  *
  *   UefiCpuPKg/BaseUefiCpuLib
  *   1. Rename BaseUefiCpuLib.c to BaseUefiCpuLibIa32X64.c
  *  BaseUefiCpuLibRiscV64.c for RISC-V arch and assembly code under 
/RISCV64
  *   2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way, the directory looks 
clean)
  *
  *   UefiCpuPKg/CpuExceptionHandlerLib
Too many X86 source files, move all X86 source files to under 
CpuExecptionHander/X86, CpuExecptionHander/RISC-V for RISC-V arch

  *   Having abstract level under /CpuExecptionHander, e.g. INF, 
PeiException.c, DxeException.c and etc.

  *

  *   UefiCpuPKg\Library\CpuTimerLib
  *   1. Rename BaseCpuTimerLib.c to BaseCpuTimerLibIa32X64.c, 
BaseCpuTimerLibRiscV64.c for RISC-V arch.
  *   2. Or move all X86 source files to under BaseUefiCpuLib/X86, 
BaseUefiCpuLib/RISC-V for RISC-V arch (I prefer this way)
  *
  *   UefiCpuPKg/CpuDxe
  *   Revise CpuDxe.c and CpuDxe.h to be abstract for the processor archs.
  *   Move all x86 implementations to under /X86, CpuDxe/RISC-V for RISC-V 
CpuDxe implementation
Let me know your thoughts, I can initiate the PoC code after we get on the same 
page.
Thanks
Abner


From: Chang, Abner (HPS SW/FW Technologist)
Sent: Saturday, February 5, 2022 10:56 PM
To: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>; Leif Lindholm 
mailto:l...@nuviainc.com>>; 
devel@edk2.groups.io 
mailto:devel@edk2.groups.io>>; Ni, Ray 
mailto:ray...@intel.com>>
Cc: Andrew Fish mailto:af...@apple.com>>; Sami Mujawar 
mailto:sami.muja...@arm.com>>
Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files 
of RISC-V processor package


Thanks Mike.

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.



Abner



From: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Sent: Saturday, February 5, 2022 4:22 AM
To: Chang, Abner (HPS SW/FW Technologist) 
mailto:abner.ch...@hpe.com>>; Leif Lindholm 
mailto:l...@nuviainc.com>>; 
devel@edk2.groups.io; Ni, Ray 
mailto:ray...@intel.com>>
Cc: Andrew Fish mailto:af...@apple.com>>; Sami Mujawar 
mailto:sami.muja...@arm.com>>
Subject: RE: [edk2-devel] [PATCH 01/79] ProcessorPkg/Include: Add header files