public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms][PATCH 0/5] Platforms cleanup v2
@ 2023-04-06  5:24 Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 1/5] Silicon/RISC-V/ProcessorPkg: remove redundant CpuDxe driver Chai, Evan
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Chai, Evan @ 2023-04-06  5:24 UTC (permalink / raw)
  To: devel

Booting to uefi shell is verfied in Qemu mode, 
The qemu command be refered to '5a> Boot on QEMU' in
https://github.com/riscv-admin/riscv-uefi-edk2-docs

Evan Chai (5):
  Silicon/RISC-V/ProcessorPkg: remove redundant CpuDxe driver
  Platform/Sifive: remove redundant TimerDxe from Platform
  Silicon/RISC-V: remove redundant RiscVTimerLib
  Silicon/RISC-V: remove redundant function code from RiscVCpuLib
  Platform/ Siliocn/: Fix building failure caused by wrong lib.

 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c                          |   4 +++-
 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf                        |   4 +++-
 Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf                                        |   3 ++-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc                                   |  19 ++++++++++---------
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf                                   |   5 +++--
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc                         |  19 ++++++++++---------
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf                         |   5 +++--
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf |   2 ++
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.c                                   | 311 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.h                                   | 174 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.uni                                 |  14 --------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf                              |  54 ------------------------------------------------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerExtra.uni                            |  12 ------------
 Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVCpuLib.h                                    |  20 +-------------------
 Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/Cpu.S                                        |  41 +----------------------------------------
 Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf                      |  35 -----------------------------------
 Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c                            | 199 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc                                            |   6 +-----
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c                                        | 310 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.h                                        | 198 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf                                      |  49 -------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.uni                                      |  13 -------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxeExtra.uni                                 |  14 --------------
 Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf                           |   3 ++-
 24 files changed, 41 insertions(+), 1473 deletions(-)
 delete mode 100644 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.c
 delete mode 100644 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.h
 delete mode 100644 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.uni
 delete mode 100644 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
 delete mode 100644 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerExtra.uni
 delete mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
 delete mode 100644 Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c
 delete mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c
 delete mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.h
 delete mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf
 delete mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.uni
 delete mode 100644 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxeExtra.uni

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [edk2-platforms][PATCH 1/5] Silicon/RISC-V/ProcessorPkg: remove redundant CpuDxe driver
  2023-04-06  5:24 [edk2-platforms][PATCH 0/5] Platforms cleanup v2 Chai, Evan
@ 2023-04-06  5:24 ` Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 2/5] Platform/Sifive: remove redundant TimerDxe from Platform Chai, Evan
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chai, Evan @ 2023-04-06  5:24 UTC (permalink / raw)
  To: devel; +Cc: Daniel Schaefer, Sunil V L, Andrei Warkentin

UefiCpuPkg/CpuDxeRiscV64 will replace it later.

Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Signed-off-by: Evan Chai <evan.chai@intel.com>
---
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc           |   2 +-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf           |   2 +-
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc |   2 +-
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf |   2 +-
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c                | 310 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.h                | 198 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf              |  49 -------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.uni              |  13 -------------
 Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxeExtra.uni         |  14 --------------
 9 files changed, 4 insertions(+), 588 deletions(-)

diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
index fc1ed012..efcfdd35 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
@@ -466,7 +466,7 @@
   #
   # RISC-V Core module
   #
-  Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf
+  UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf
   Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
 
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
index 4ce19279..da4d3379 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
@@ -151,7 +151,7 @@ INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServi
 
 # RISC-V Core Drivers
 INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
-INF  Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf
+INF  UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf
 INF  Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf
 
 INF  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
index e59955d0..d92f8166 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
@@ -465,7 +465,7 @@
   #
   # RISC-V Core module
   #
-  Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf
+  UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf
   Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
 
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
index c58fa635..237ed74a 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
@@ -151,7 +151,7 @@ INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServi
 
 # RISC-V Core Drivers
 INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
-INF  Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf
+INF  UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf
 INF  Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf
 
 INF  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c b/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c
deleted file mode 100644
index 8d4d406e..00000000
--- a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/** @file
-  RISC-V CPU DXE driver.
-
-  Copyright (c) 2016 - 2022, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "CpuDxe.h"
-
-//
-// Global Variables
-//
-STATIC BOOLEAN     mInterruptState = FALSE;
-STATIC EFI_HANDLE  mCpuHandle      = NULL;
-
-EFI_CPU_ARCH_PROTOCOL  gCpu = {
-  CpuFlushCpuDataCache,
-  CpuEnableInterrupt,
-  CpuDisableInterrupt,
-  CpuGetInterruptState,
-  CpuInit,
-  CpuRegisterInterruptHandler,
-  CpuGetTimerValue,
-  CpuSetMemoryAttributes,
-  1,                          // NumberOfTimers
-  4                           // DmaBufferAlignment
-};
-
-//
-// CPU Arch Protocol Functions
-//
-
-/**
-  Flush CPU data cache. If the instruction cache is fully coherent
-  with all DMA operations then function can just return EFI_SUCCESS.
-
-  @param  This              Protocol instance structure
-  @param  Start             Physical address to start flushing from.
-  @param  Length            Number of bytes to flush. Round up to chipset
-                            granularity.
-  @param  FlushType         Specifies the type of flush operation to perform.
-
-  @retval EFI_SUCCESS       If cache was flushed
-  @retval EFI_UNSUPPORTED   If flush type is not supported.
-  @retval EFI_DEVICE_ERROR  If requested range could not be flushed.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuFlushCpuDataCache (
-  IN EFI_CPU_ARCH_PROTOCOL  *This,
-  IN EFI_PHYSICAL_ADDRESS   Start,
-  IN UINT64                 Length,
-  IN EFI_CPU_FLUSH_TYPE     FlushType
-  )
-{
-  return EFI_SUCCESS;
-}
-
-/**
-  Enables CPU interrupts.
-
-  @param  This              Protocol instance structure
-
-  @retval EFI_SUCCESS       If interrupts were enabled in the CPU
-  @retval EFI_DEVICE_ERROR  If interrupts could not be enabled on the CPU.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuEnableInterrupt (
-  IN EFI_CPU_ARCH_PROTOCOL  *This
-  )
-{
-  EnableInterrupts ();
-  mInterruptState = TRUE;
-  return EFI_SUCCESS;
-}
-
-/**
-  Disables CPU interrupts.
-
-  @param  This              Protocol instance structure
-
-  @retval EFI_SUCCESS       If interrupts were disabled in the CPU.
-  @retval EFI_DEVICE_ERROR  If interrupts could not be disabled on the CPU.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuDisableInterrupt (
-  IN EFI_CPU_ARCH_PROTOCOL  *This
-  )
-{
-  DisableInterrupts ();
-  mInterruptState = FALSE;
-  return EFI_SUCCESS;
-}
-
-/**
-  Return the state of interrupts.
-
-  @param  This                   Protocol instance structure
-  @param  State                  Pointer to the CPU's current interrupt state
-
-  @retval EFI_SUCCESS            If interrupts were disabled in the CPU.
-  @retval EFI_INVALID_PARAMETER  State is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuGetInterruptState (
-  IN  EFI_CPU_ARCH_PROTOCOL  *This,
-  OUT BOOLEAN                *State
-  )
-{
-  if (State == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *State = mInterruptState;
-  return EFI_SUCCESS;
-}
-
-/**
-  Generates an INIT to the CPU.
-
-  @param  This              Protocol instance structure
-  @param  InitType          Type of CPU INIT to perform
-
-  @retval EFI_SUCCESS       If CPU INIT occurred. This value should never be
-                            seen.
-  @retval EFI_DEVICE_ERROR  If CPU INIT failed.
-  @retval EFI_UNSUPPORTED   Requested type of CPU INIT not supported.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuInit (
-  IN EFI_CPU_ARCH_PROTOCOL  *This,
-  IN EFI_CPU_INIT_TYPE      InitType
-  )
-{
-  return EFI_UNSUPPORTED;
-}
-
-/**
-  Registers a function to be called from the CPU interrupt handler.
-
-  @param  This                   Protocol instance structure
-  @param  InterruptType          Defines which interrupt to hook. IA-32
-                                 valid range is 0x00 through 0xFF
-  @param  InterruptHandler       A pointer to a function of type
-                                 EFI_CPU_INTERRUPT_HANDLER that is called
-                                 when a processor interrupt occurs.  A null
-                                 pointer is an error condition.
-
-  @retval EFI_SUCCESS            If handler installed or uninstalled.
-  @retval EFI_ALREADY_STARTED    InterruptHandler is not NULL, and a handler
-                                 for InterruptType was previously installed.
-  @retval EFI_INVALID_PARAMETER  InterruptHandler is NULL, and a handler for
-                                 InterruptType was not previously installed.
-  @retval EFI_UNSUPPORTED        The interrupt specified by InterruptType
-                                 is not supported.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuRegisterInterruptHandler (
-  IN EFI_CPU_ARCH_PROTOCOL      *This,
-  IN EFI_EXCEPTION_TYPE         InterruptType,
-  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler
-  )
-{
-  return RegisterCpuInterruptHandler (InterruptType, InterruptHandler);
-}
-
-/**
-  Returns a timer value from one of the CPU's internal timers. There is no
-  inherent time interval between ticks but is a function of the CPU frequency.
-
-  @param  This                - Protocol instance structure.
-  @param  TimerIndex          - Specifies which CPU timer is requested.
-  @param  TimerValue          - Pointer to the returned timer value.
-  @param  TimerPeriod         - A pointer to the amount of time that passes
-                                in femtoseconds (10-15) for each increment
-                                of TimerValue. If TimerValue does not
-                                increment at a predictable rate, then 0 is
-                                returned.  The amount of time that has
-                                passed between two calls to GetTimerValue()
-                                can be calculated with the formula
-                                (TimerValue2 - TimerValue1) * TimerPeriod.
-                                This parameter is optional and may be NULL.
-
-  @retval EFI_SUCCESS           - If the CPU timer count was returned.
-  @retval EFI_UNSUPPORTED       - If the CPU does not have any readable timers.
-  @retval EFI_DEVICE_ERROR      - If an error occurred while reading the timer.
-  @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuGetTimerValue (
-  IN  EFI_CPU_ARCH_PROTOCOL  *This,
-  IN  UINT32                 TimerIndex,
-  OUT UINT64                 *TimerValue,
-  OUT UINT64                 *TimerPeriod OPTIONAL
-  )
-{
-  if (TimerValue == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  if (TimerIndex != 0) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *TimerValue = (UINT64)RiscVReadMachineTimerInterface ();
-  if (TimerPeriod != NULL) {
-    *TimerPeriod = DivU64x32 (
-                     1000000000000000u,
-                     PcdGet64 (PcdRiscVMachineTimerFrequencyInHerz)
-                     );
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Implementation of SetMemoryAttributes() service of CPU Architecture Protocol.
-
-  This function modifies the attributes for the memory region specified by BaseAddress and
-  Length from their current attributes to the attributes specified by Attributes.
-
-  @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
-  @param  BaseAddress      The physical address that is the start address of a memory region.
-  @param  Length           The size in bytes of the memory region.
-  @param  Attributes       The bit mask of attributes to set for the memory region.
-
-  @retval EFI_SUCCESS           The attributes were set for the memory region.
-  @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
-                                BaseAddress and Length cannot be modified.
-  @retval EFI_INVALID_PARAMETER Length is zero.
-                                Attributes specified an illegal combination of attributes that
-                                cannot be set together.
-  @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
-                                the memory resource range.
-  @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory
-                                resource range specified by BaseAddress and Length.
-                                The bit mask of attributes is not support for the memory resource
-                                range specified by BaseAddress and Length.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuSetMemoryAttributes (
-  IN EFI_CPU_ARCH_PROTOCOL  *This,
-  IN EFI_PHYSICAL_ADDRESS   BaseAddress,
-  IN UINT64                 Length,
-  IN UINT64                 Attributes
-  )
-{
-  DEBUG ((DEBUG_INFO, "%a: Set memory attributes not supported yet\n", __FUNCTION__));
-  return EFI_SUCCESS;
-}
-
-/**
-  Initialize the state information for the CPU Architectural Protocol.
-
-  @param ImageHandle     Image handle this driver.
-  @param SystemTable     Pointer to the System Table.
-
-  @retval EFI_SUCCESS           Thread can be successfully created
-  @retval EFI_OUT_OF_RESOURCES  Cannot allocate protocol data structure
-  @retval EFI_DEVICE_ERROR      Cannot create the thread
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeCpu (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  )
-{
-  EFI_STATUS  Status;
-
-  //
-  // Machine mode handler is initiated in CpuExceptionHandlerLibConstructor in
-  // CpuExecptionHandlerLib.
-  //
-
-  //
-  // Make sure interrupts are disabled
-  //
-  DisableInterrupts ();
-
-  //
-  // Install CPU Architectural Protocol
-  //
-  Status = gBS->InstallMultipleProtocolInterfaces (
-                  &mCpuHandle,
-                  &gEfiCpuArchProtocolGuid,
-                  &gCpu,
-                  NULL
-                  );
-  ASSERT_EFI_ERROR (Status);
-  return Status;
-}
diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.h b/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.h
deleted file mode 100644
index 9d70d7b6..00000000
--- a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/** @file
-  RISC-V CPU DXE module header file.
-
-  Copyright (c) 2016 - 2022, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef CPU_DXE_H_
-#define CPU_DXE_H_
-
-#include <PiDxe.h>
-
-#include <Protocol/Cpu.h>
-#include <Library/BaseLib.h>
-#include <Library/CpuExceptionHandlerLib.h>
-#include <Library/DebugLib.h>
-#include <Library/RiscVCpuLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-
-/**
-  Flush CPU data cache. If the instruction cache is fully coherent
-  with all DMA operations then function can just return EFI_SUCCESS.
-
-  @param  This              Protocol instance structure
-  @param  Start             Physical address to start flushing from.
-  @param  Length            Number of bytes to flush. Round up to chipset
-                            granularity.
-  @param  FlushType         Specifies the type of flush operation to perform.
-
-  @retval EFI_SUCCESS       If cache was flushed
-  @retval EFI_UNSUPPORTED   If flush type is not supported.
-  @retval EFI_DEVICE_ERROR  If requested range could not be flushed.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuFlushCpuDataCache (
-  IN EFI_CPU_ARCH_PROTOCOL  *This,
-  IN EFI_PHYSICAL_ADDRESS   Start,
-  IN UINT64                 Length,
-  IN EFI_CPU_FLUSH_TYPE     FlushType
-  );
-
-/**
-  Enables CPU interrupts.
-
-  @param  This              Protocol instance structure
-
-  @retval EFI_SUCCESS       If interrupts were enabled in the CPU
-  @retval EFI_DEVICE_ERROR  If interrupts could not be enabled on the CPU.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuEnableInterrupt (
-  IN EFI_CPU_ARCH_PROTOCOL  *This
-  );
-
-/**
-  Disables CPU interrupts.
-
-  @param  This              Protocol instance structure
-
-  @retval EFI_SUCCESS       If interrupts were disabled in the CPU.
-  @retval EFI_DEVICE_ERROR  If interrupts could not be disabled on the CPU.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuDisableInterrupt (
-  IN EFI_CPU_ARCH_PROTOCOL  *This
-  );
-
-/**
-  Return the state of interrupts.
-
-  @param  This                   Protocol instance structure
-  @param  State                  Pointer to the CPU's current interrupt state
-
-  @retval EFI_SUCCESS            If interrupts were disabled in the CPU.
-  @retval EFI_INVALID_PARAMETER  State is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuGetInterruptState (
-  IN  EFI_CPU_ARCH_PROTOCOL  *This,
-  OUT BOOLEAN                *State
-  );
-
-/**
-  Generates an INIT to the CPU.
-
-  @param  This              Protocol instance structure
-  @param  InitType          Type of CPU INIT to perform
-
-  @retval EFI_SUCCESS       If CPU INIT occurred. This value should never be
-                            seen.
-  @retval EFI_DEVICE_ERROR  If CPU INIT failed.
-  @retval EFI_UNSUPPORTED   Requested type of CPU INIT not supported.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuInit (
-  IN EFI_CPU_ARCH_PROTOCOL  *This,
-  IN EFI_CPU_INIT_TYPE      InitType
-  );
-
-/**
-  Registers a function to be called from the CPU interrupt handler.
-
-  @param  This                   Protocol instance structure
-  @param  InterruptType          Defines which interrupt to hook. IA-32
-                                 valid range is 0x00 through 0xFF
-  @param  InterruptHandler       A pointer to a function of type
-                                 EFI_CPU_INTERRUPT_HANDLER that is called
-                                 when a processor interrupt occurs.  A null
-                                 pointer is an error condition.
-
-  @retval EFI_SUCCESS            If handler installed or uninstalled.
-  @retval EFI_ALREADY_STARTED    InterruptHandler is not NULL, and a handler
-                                 for InterruptType was previously installed.
-  @retval EFI_INVALID_PARAMETER  InterruptHandler is NULL, and a handler for
-                                 InterruptType was not previously installed.
-  @retval EFI_UNSUPPORTED        The interrupt specified by InterruptType
-                                 is not supported.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuRegisterInterruptHandler (
-  IN EFI_CPU_ARCH_PROTOCOL      *This,
-  IN EFI_EXCEPTION_TYPE         InterruptType,
-  IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler
-  );
-
-/**
-  Returns a timer value from one of the CPU's internal timers. There is no
-  inherent time interval between ticks but is a function of the CPU frequency.
-
-  @param  This                - Protocol instance structure.
-  @param  TimerIndex          - Specifies which CPU timer is requested.
-  @param  TimerValue          - Pointer to the returned timer value.
-  @param  TimerPeriod         - A pointer to the amount of time that passes
-                                in femtoseconds (10-15) for each increment
-                                of TimerValue. If TimerValue does not
-                                increment at a predictable rate, then 0 is
-                                returned.  The amount of time that has
-                                passed between two calls to GetTimerValue()
-                                can be calculated with the formula
-                                (TimerValue2 - TimerValue1) * TimerPeriod.
-                                This parameter is optional and may be NULL.
-
-  @retval EFI_SUCCESS           - If the CPU timer count was returned.
-  @retval EFI_UNSUPPORTED       - If the CPU does not have any readable timers.
-  @retval EFI_DEVICE_ERROR      - If an error occurred while reading the timer.
-  @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-CpuGetTimerValue (
-  IN  EFI_CPU_ARCH_PROTOCOL  *This,
-  IN  UINT32                 TimerIndex,
-  OUT UINT64                 *TimerValue,
-  OUT UINT64                 *TimerPeriod OPTIONAL
-  );
-
-/**
-  Set memory cacheability attributes for given range of memeory.
-
-  @param  This                   Protocol instance structure
-  @param  BaseAddress            Specifies the start address of the
-                                 memory range
-  @param  Length                 Specifies the length of the memory range
-  @param  Attributes             The memory cacheability for the memory range
-
-  @retval EFI_SUCCESS            If the cacheability of that memory range is
-                                 set successfully
-  @retval EFI_UNSUPPORTED        If the desired operation cannot be done
-  @retval EFI_INVALID_PARAMETER  The input parameter is not correct,
-                                 such as Length = 0
-
-**/
-EFI_STATUS
-EFIAPI
-CpuSetMemoryAttributes (
-  IN EFI_CPU_ARCH_PROTOCOL  *This,
-  IN EFI_PHYSICAL_ADDRESS   BaseAddress,
-  IN UINT64                 Length,
-  IN UINT64                 Attributes
-  );
-
-#endif
diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf b/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf
deleted file mode 100644
index a422c12e..00000000
--- a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.inf
+++ /dev/null
@@ -1,49 +0,0 @@
-## @file
-#  RISC-V CPU DXE module.
-#
-#  Copyright (c) 2016 - 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x0001001b
-  BASE_NAME                      = CpuDxe
-  MODULE_UNI_FILE                = CpuDxe.uni
-  FILE_GUID                      = 2AEB1f3E-5B6B-441B-92C1-4A9E6FC85E92
-  MODULE_TYPE                    = DXE_DRIVER
-  VERSION_STRING                 = 1.0
-
-  ENTRY_POINT                    = InitializeCpu
-
-[Packages]
-  MdeModulePkg/MdeModulePkg.dec
-  MdePkg/MdePkg.dec
-  Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  CpuLib
-  CpuExceptionHandlerLib
-  DebugLib
-  MachineModeTimerLib
-  RiscVCpuLib
-  TimerLib
-  UefiBootServicesTableLib
-  UefiDriverEntryPoint
-
-[Sources]
-  CpuDxe.c
-  CpuDxe.h
-
-[Protocols]
-  gEfiCpuArchProtocolGuid                       ## PRODUCES
-
-[Pcd]
-  gUefiRiscVPkgTokenSpaceGuid.PcdRiscVMachineTimerFrequencyInHerz
-
-[Depex]
-  TRUE
-
-[UserExtensions.TianoCore."ExtraFiles"]
-  CpuDxeExtra.uni
diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.uni b/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.uni
deleted file mode 100644
index 460141a1..00000000
--- a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxe.uni
+++ /dev/null
@@ -1,13 +0,0 @@
-// /** @file
-//
-// Copyright (c) 2016 - 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT             #language en-US "Installs RISC-V CPU Architecture Protocol"
-
-#string STR_MODULE_DESCRIPTION          #language en-US "RISC-V CPU driver installs CPU Architecture Protocol."
-
diff --git a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxeExtra.uni b/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxeExtra.uni
deleted file mode 100644
index 6f819f06..00000000
--- a/Silicon/RISC-V/ProcessorPkg/Universal/CpuDxe/CpuDxeExtra.uni
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file
-// CpuDxe Localized Strings and Content
-//
-// Copyright (c) 2016 - 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"RISC-V Architectural DXE Driver"
-
-
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [edk2-platforms][PATCH 2/5] Platform/Sifive: remove redundant TimerDxe from Platform
  2023-04-06  5:24 [edk2-platforms][PATCH 0/5] Platforms cleanup v2 Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 1/5] Silicon/RISC-V/ProcessorPkg: remove redundant CpuDxe driver Chai, Evan
@ 2023-04-06  5:24 ` Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 3/5] Silicon/RISC-V: remove redundant RiscVTimerLib Chai, Evan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chai, Evan @ 2023-04-06  5:24 UTC (permalink / raw)
  To: devel; +Cc: Daniel Schaefer, Sunil V L, Andrei Warkentin

It will be replaced by UefiCpuPkg/CpuTimerDxeRiscV64.

Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Signed-off-by: Evan Chai <evan.chai@intel.com>
---
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc           |   2 +-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf           |   2 +-
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc |   2 +-
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf |   2 +-
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.c           | 311 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.h           | 174 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.uni         |  14 --------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf      |  54 ------------------------------------------------------
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerExtra.uni    |  12 ------------
 9 files changed, 4 insertions(+), 569 deletions(-)

diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
index efcfdd35..c26b4608 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
@@ -460,7 +460,7 @@
   #
   # RISC-V Platform module
   #
-  Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
+  UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
   Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
 
   #
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
index da4d3379..b17c960d 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
@@ -150,7 +150,7 @@ INF  EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
 INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
 
 # RISC-V Core Drivers
-INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
+INF  UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
 INF  UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf
 INF  Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf
 
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
index d92f8166..4487913f 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
@@ -459,7 +459,7 @@
   #
   # RISC-V Platform module
   #
-  Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
+  UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
   Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
 
   #
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
index 237ed74a..9ae89647 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
@@ -150,7 +150,7 @@ INF  EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
 INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
 
 # RISC-V Core Drivers
-INF  Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
+INF  UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
 INF  UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf
 INF  Silicon/RISC-V/ProcessorPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf
 
diff --git a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.c b/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.c
deleted file mode 100644
index deb57992..00000000
--- a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/** @file
-  RISC-V Timer Architectural Protocol for U5 series platform.
-
-  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include "Timer.h"
-#include <Library/RiscVEdk2SbiLib.h>
-#include <sbi/riscv_asm.h>
-#include <sbi/riscv_encoding.h>
-#include <sbi/riscv_io.h>
-#include <sbi/riscv_atomic.h>
-#include <U5Clint.h>
-
-BOOLEAN TimerHandlerReentry = FALSE;
-
-//
-// The handle onto which the Timer Architectural Protocol will be installed
-//
-STATIC EFI_HANDLE mTimerHandle = NULL;
-
-//
-// The Timer Architectural Protocol that this driver produces
-//
-EFI_TIMER_ARCH_PROTOCOL   mTimer = {
-  TimerDriverRegisterHandler,
-  TimerDriverSetTimerPeriod,
-  TimerDriverGetTimerPeriod,
-  TimerDriverGenerateSoftInterrupt
-};
-
-//
-// Pointer to the CPU Architectural Protocol instance
-//
-EFI_CPU_ARCH_PROTOCOL *mCpu;
-
-//
-// The notification function to call on every timer interrupt.
-// A bug in the compiler prevents us from initializing this here.
-//
-STATIC EFI_TIMER_NOTIFY mTimerNotifyFunction;
-
-//
-// The current period of the timer interrupt
-//
-STATIC UINT64 mTimerPeriod = 0;
-
-/**
-  U5 Series Timer Interrupt Handler.
-
-  @param InterruptType    The type of interrupt that occured
-  @param SystemContext    A pointer to the system context when the interrupt occured
-**/
-
-VOID
-EFIAPI
-TimerInterruptHandler (
-  IN EFI_EXCEPTION_TYPE   InterruptType,
-  IN EFI_SYSTEM_CONTEXT   SystemContext
-  )
-{
-  EFI_TPL OriginalTPL;
-  UINT64 RiscvTimer;
-
-  if (TimerHandlerReentry) {
-    //
-    // MMode timer occurred when processing
-    // SMode timer handler.
-    //
-    RiscvTimer = RiscVReadMachineTimerInterface();
-    SbiSetTimer (RiscvTimer += mTimerPeriod);
-    csr_clear(CSR_SIP, MIP_STIP);
-    return;
-  }
-  TimerHandlerReentry = TRUE;
-
-  OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
-  csr_clear(CSR_SIE, MIP_STIP); // Disable SMode timer int
-  csr_clear(CSR_SIP, MIP_STIP);
-  if (mTimerPeriod == 0) {
-    gBS->RestoreTPL (OriginalTPL);
-    csr_clear(CSR_SIE, MIP_STIP); // Disable SMode timer int
-    return;
-  }
-  if (mTimerNotifyFunction != NULL) {
-      mTimerNotifyFunction (mTimerPeriod);
-  }
-  RiscvTimer = RiscVReadMachineTimerInterface();
-  SbiSetTimer (RiscvTimer += mTimerPeriod);
-  gBS->RestoreTPL (OriginalTPL);
-  csr_set(CSR_SIE, MIP_STIP); // enable SMode timer int
-  TimerHandlerReentry = FALSE;
-}
-
-/**
-
-  This function registers the handler NotifyFunction so it is called every time
-  the timer interrupt fires.  It also passes the amount of time since the last
-  handler call to the NotifyFunction.  If NotifyFunction is NULL, then the
-  handler is unregistered.  If the handler is registered, then EFI_SUCCESS is
-  returned.  If the CPU does not support registering a timer interrupt handler,
-  then EFI_UNSUPPORTED is returned.  If an attempt is made to register a handler
-  when a handler is already registered, then EFI_ALREADY_STARTED is returned.
-  If an attempt is made to unregister a handler when a handler is not registered,
-  then EFI_INVALID_PARAMETER is returned.  If an error occurs attempting to
-  register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR
-  is returned.
-
-  @param This             The EFI_TIMER_ARCH_PROTOCOL instance.
-  @param NotifyFunction   The function to call when a timer interrupt fires.  This
-                          function executes at TPL_HIGH_LEVEL.  The DXE Core will
-                          register a handler for the timer interrupt, so it can know
-                          how much time has passed.  This information is used to
-                          signal timer based events.  NULL will unregister the handler.
-
-  @retval        EFI_SUCCESS            The timer handler was registered.
-  @retval        EFI_UNSUPPORTED        The platform does not support timer interrupts.
-  @retval        EFI_ALREADY_STARTED    NotifyFunction is not NULL, and a handler is already
-                                        registered.
-  @retval        EFI_INVALID_PARAMETER  NotifyFunction is NULL, and a handler was not
-                                        previously registered.
-  @retval        EFI_DEVICE_ERROR       The timer handler could not be registered.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverRegisterHandler (
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,
-  IN EFI_TIMER_NOTIFY         NotifyFunction
-  )
-{
-  DEBUG ((DEBUG_INFO, "TimerDriverRegisterHandler(0x%lx) called\n", NotifyFunction));
-  mTimerNotifyFunction = NotifyFunction;
-  return EFI_SUCCESS;
-}
-
-/**
-
-  This function adjusts the period of timer interrupts to the value specified
-  by TimerPeriod.  If the timer period is updated, then the selected timer
-  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If
-  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.
-  If an error occurs while attempting to update the timer period, then the
-  timer hardware will be put back in its state prior to this call, and
-  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt
-  is disabled.  This is not the same as disabling the CPU's interrupts.
-  Instead, it must either turn off the timer hardware, or it must adjust the
-  interrupt controller so that a CPU interrupt is not generated when the timer
-  interrupt fires.
-
-
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.
-  @param TimerPeriod     The rate to program the timer interrupt in 100 nS units.  If
-                         the timer hardware is not programmable, then EFI_UNSUPPORTED is
-                         returned.  If the timer is programmable, then the timer period
-                         will be rounded up to the nearest timer period that is supported
-                         by the timer hardware.  If TimerPeriod is set to 0, then the
-                         timer interrupts will be disabled.
-
-  @retval        EFI_SUCCESS       The timer period was changed.
-  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.
-  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverSetTimerPeriod (
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,
-  IN UINT64                   TimerPeriod
-  )
-{
-  UINT64 RiscvTimer;
-
-  DEBUG ((DEBUG_INFO, "TimerDriverSetTimerPeriod(0x%lx)\n", TimerPeriod));
-
-  if (TimerPeriod == 0) {
-    mTimerPeriod = 0;
-    csr_clear(CSR_SIE, MIP_STIP); // disable timer int
-    return EFI_SUCCESS;
-  }
-
-  mTimerPeriod = TimerPeriod; // convert unit from 100ns to 1us
-  RiscvTimer = RiscVReadMachineTimerInterface();
-  SbiSetTimer(RiscvTimer + mTimerPeriod / 10);
-
-  mCpu->EnableInterrupt(mCpu);
-  csr_set(CSR_SIE, MIP_STIP); // enable timer int
-  return EFI_SUCCESS;
-}
-
-/**
-
-  This function retrieves the period of timer interrupts in 100 ns units,
-  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod
-  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is
-  returned, then the timer is currently disabled.
-
-
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.
-  @param TimerPeriod     A pointer to the timer period to retrieve in 100 ns units.  If
-                         0 is returned, then the timer is currently disabled.
-
-  @retval EFI_SUCCESS            The timer period was returned in TimerPeriod.
-  @retval EFI_INVALID_PARAMETER  TimerPeriod is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverGetTimerPeriod (
-  IN EFI_TIMER_ARCH_PROTOCOL   *This,
-  OUT UINT64                   *TimerPeriod
-  )
-{
-  *TimerPeriod = mTimerPeriod;
-  return EFI_SUCCESS;
-}
-
-/**
-
-  This function generates a soft timer interrupt. If the platform does not support soft
-  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.
-  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()
-  service, then a soft timer interrupt will be generated. If the timer interrupt is
-  enabled when this service is called, then the registered handler will be invoked. The
-  registered handler should not be able to distinguish a hardware-generated timer
-  interrupt from a software-generated timer interrupt.
-
-
-  @param This              The EFI_TIMER_ARCH_PROTOCOL instance.
-
-  @retval EFI_SUCCESS       The soft timer interrupt was generated.
-  @retval EFI_UNSUPPORTEDT  The platform does not support the generation of soft timer interrupts.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverGenerateSoftInterrupt (
-  IN EFI_TIMER_ARCH_PROTOCOL  *This
-  )
-{
-  return EFI_SUCCESS;
-}
-
-/**
-  Initialize the Timer Architectural Protocol driver
-
-  @param ImageHandle     ImageHandle of the loaded driver
-  @param SystemTable     Pointer to the System Table
-
-  @retval EFI_SUCCESS            Timer Architectural Protocol created
-  @retval EFI_OUT_OF_RESOURCES   Not enough resources available to initialize driver.
-  @retval EFI_DEVICE_ERROR       A device error occured attempting to initialize the driver.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverInitialize (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  )
-{
-  EFI_STATUS  Status;
-
-  //
-  // Initialize the pointer to our notify function.
-  //
-  mTimerNotifyFunction = NULL;
-
-  //
-  // Make sure the Timer Architectural Protocol is not already installed in the system
-  //
-  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiTimerArchProtocolGuid);
-
-  //
-  // Find the CPU architectural protocol.
-  //
-  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **) &mCpu);
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Force the timer to be disabled
-  //
-  Status = TimerDriverSetTimerPeriod (&mTimer, 0);
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Install interrupt handler for RISC-V Timer.
-  //
-  Status = mCpu->RegisterInterruptHandler (mCpu, EXCEPT_RISCV_TIMER_INT, TimerInterruptHandler);
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Force the timer to be enabled at its default period
-  //
-  Status = TimerDriverSetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION);
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Install the Timer Architectural Protocol onto a new handle
-  //
-  Status = gBS->InstallMultipleProtocolInterfaces (
-                  &mTimerHandle,
-                  &gEfiTimerArchProtocolGuid, &mTimer,
-                  NULL
-                  );
-  ASSERT_EFI_ERROR (Status);
-  return Status;
-}
diff --git a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.h b/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.h
deleted file mode 100644
index 8301685c..00000000
--- a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/** @file
-  RISC-V Timer Architectural Protocol definitions for U5 Series platform,
-
-  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef U5_SERIES_TIMER_H_
-#define U5_SERIES_TIMER_H_
-
-#include <PiDxe.h>
-
-#include <Protocol/Cpu.h>
-#include <Protocol/Timer.h>
-
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/RiscVCpuLib.h>
-
-//
-// RISC-V use 100us timer.
-// The default timer tick duration is set to 10 ms = 10 * 1000 * 10 100 ns units
-//
-#define DEFAULT_TIMER_TICK_DURATION 100000
-
-extern VOID RiscvSetTimerPeriod (UINT32 TimerPeriod);
-
-//
-// Function Prototypes
-//
-/**
-  Initialize the Timer Architectural Protocol driver
-
-  @param ImageHandle     ImageHandle of the loaded driver
-  @param SystemTable     Pointer to the System Table
-
-  @retval EFI_SUCCESS            Timer Architectural Protocol created
-  @retval EFI_OUT_OF_RESOURCES   Not enough resources available to initialize driver.
-  @retval EFI_DEVICE_ERROR       A device error occured attempting to initialize the driver.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverInitialize (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  )
-;
-
-/**
-
-  This function adjusts the period of timer interrupts to the value specified
-  by TimerPeriod.  If the timer period is updated, then the selected timer
-  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If
-  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.
-  If an error occurs while attempting to update the timer period, then the
-  timer hardware will be put back in its state prior to this call, and
-  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt
-  is disabled.  This is not the same as disabling the CPU's interrupts.
-  Instead, it must either turn off the timer hardware, or it must adjust the
-  interrupt controller so that a CPU interrupt is not generated when the timer
-  interrupt fires.
-
-
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.
-  @param NotifyFunction  The rate to program the timer interrupt in 100 nS units.  If
-                         the timer hardware is not programmable, then EFI_UNSUPPORTED is
-                         returned.  If the timer is programmable, then the timer period
-                         will be rounded up to the nearest timer period that is supported
-                         by the timer hardware.  If TimerPeriod is set to 0, then the
-                         timer interrupts will be disabled.
-
-  @retval        EFI_SUCCESS       The timer period was changed.
-  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.
-  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverRegisterHandler (
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,
-  IN EFI_TIMER_NOTIFY         NotifyFunction
-  )
-;
-
-/**
-
-  This function adjusts the period of timer interrupts to the value specified
-  by TimerPeriod.  If the timer period is updated, then the selected timer
-  period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned.  If
-  the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.
-  If an error occurs while attempting to update the timer period, then the
-  timer hardware will be put back in its state prior to this call, and
-  EFI_DEVICE_ERROR is returned.  If TimerPeriod is 0, then the timer interrupt
-  is disabled.  This is not the same as disabling the CPU's interrupts.
-  Instead, it must either turn off the timer hardware, or it must adjust the
-  interrupt controller so that a CPU interrupt is not generated when the timer
-  interrupt fires.
-
-
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.
-  @param TimerPeriod     The rate to program the timer interrupt in 100 nS units.  If
-                         the timer hardware is not programmable, then EFI_UNSUPPORTED is
-                         returned.  If the timer is programmable, then the timer period
-                         will be rounded up to the nearest timer period that is supported
-                         by the timer hardware.  If TimerPeriod is set to 0, then the
-                         timer interrupts will be disabled.
-
-  @retval        EFI_SUCCESS       The timer period was changed.
-  @retval        EFI_UNSUPPORTED   The platform cannot change the period of the timer interrupt.
-  @retval        EFI_DEVICE_ERROR  The timer period could not be changed due to a device error.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverSetTimerPeriod (
-  IN EFI_TIMER_ARCH_PROTOCOL  *This,
-  IN UINT64                   TimerPeriod
-  )
-;
-
-/**
-
-  This function retrieves the period of timer interrupts in 100 ns units,
-  returns that value in TimerPeriod, and returns EFI_SUCCESS.  If TimerPeriod
-  is NULL, then EFI_INVALID_PARAMETER is returned.  If a TimerPeriod of 0 is
-  returned, then the timer is currently disabled.
-
-
-  @param This            The EFI_TIMER_ARCH_PROTOCOL instance.
-  @param TimerPeriod     A pointer to the timer period to retrieve in 100 ns units.  If
-                         0 is returned, then the timer is currently disabled.
-
-  @retval EFI_SUCCESS            The timer period was returned in TimerPeriod.
-  @retval EFI_INVALID_PARAMETER  TimerPeriod is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverGetTimerPeriod (
-  IN EFI_TIMER_ARCH_PROTOCOL   *This,
-  OUT UINT64                   *TimerPeriod
-  )
-;
-
-/**
-
-  This function generates a soft timer interrupt. If the platform does not support soft
-  timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.
-  If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()
-  service, then a soft timer interrupt will be generated. If the timer interrupt is
-  enabled when this service is called, then the registered handler will be invoked. The
-  registered handler should not be able to distinguish a hardware-generated timer
-  interrupt from a software-generated timer interrupt.
-
-
-  @param This              The EFI_TIMER_ARCH_PROTOCOL instance.
-
-  @retval EFI_SUCCESS       The soft timer interrupt was generated.
-  @retval EFI_UNSUPPORTEDT  The platform does not support the generation of soft timer interrupts.
-
-**/
-EFI_STATUS
-EFIAPI
-TimerDriverGenerateSoftInterrupt (
-  IN EFI_TIMER_ARCH_PROTOCOL  *This
-  )
-;
-
-#endif
diff --git a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.uni b/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.uni
deleted file mode 100644
index 38302244..00000000
--- a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/Timer.uni
+++ /dev/null
@@ -1,14 +0,0 @@
-// /** @file
-//
-// RISC-V Timer Arch protocol strings.
-//
-// Copyright (c) 2016, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT             #language en-US "RISC-V timer driver that provides Timer Arch protocol"
-
-#string STR_MODULE_DESCRIPTION          #language en-US "RISC-V timer driver that provides Timer Arch protocol."
diff --git a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf b/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
deleted file mode 100644
index 4571621a..00000000
--- a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerDxe.inf
+++ /dev/null
@@ -1,54 +0,0 @@
-## @file
-# RISC-V Timer Arch protocol module for U5 Series platform
-#
-# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x0001001b
-  BASE_NAME                      = Timer
-  MODULE_UNI_FILE                = Timer.uni
-  FILE_GUID                      = 3F75D495-23FF-46B6-9D19-0DECC8A4EA91
-  MODULE_TYPE                    = DXE_DRIVER
-  VERSION_STRING                 = 1.0
-  ENTRY_POINT                    = TimerDriverInitialize
-#
-# The following information is for reference only and not required by the build
-# tools.
-#
-#  VALID_ARCHITECTURES           = RISCV64
-#
-[Packages]
-  MdePkg/MdePkg.dec
-  Platform/SiFive/U5SeriesPkg/U5SeriesPkg.dec
-  Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  DebugLib
-  IoLib
-  MachineModeTimerLib
-  RiscVCpuLib
-  RiscVEdk2SbiLib
-  UefiBootServicesTableLib
-  UefiDriverEntryPoint
-
-[Sources]
-  Timer.h
-  Timer.c
-
-[Protocols]
-  gEfiCpuArchProtocolGuid       ## CONSUMES
-  gEfiTimerArchProtocolGuid     ## PRODUCES
-
-[Pcd]
-  gUefiRiscVPkgTokenSpaceGuid.PcdRiscVMachineTimerFrequencyInHerz
-
-[Depex]
-  gEfiCpuArchProtocolGuid
-
-[UserExtensions.TianoCore."ExtraFiles"]
-  TimerExtra.uni
diff --git a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerExtra.uni b/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerExtra.uni
deleted file mode 100644
index cf25ff14..00000000
--- a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/TimerDxe/TimerExtra.uni
+++ /dev/null
@@ -1,12 +0,0 @@
-// /** @file
-// Timer Localized Strings and Content
-//
-// Copyright (c) 2016, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"RISC-V Timer DXE Driver"
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [edk2-platforms][PATCH 3/5] Silicon/RISC-V: remove redundant RiscVTimerLib
  2023-04-06  5:24 [edk2-platforms][PATCH 0/5] Platforms cleanup v2 Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 1/5] Silicon/RISC-V/ProcessorPkg: remove redundant CpuDxe driver Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 2/5] Platform/Sifive: remove redundant TimerDxe from Platform Chai, Evan
@ 2023-04-06  5:24 ` Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 4/5] Silicon/RISC-V: remove redundant function code from RiscVCpuLib Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 5/5] Platform/ Siliocn/: Fix building failure caused by wrong lib Chai, Evan
  4 siblings, 0 replies; 6+ messages in thread
From: Chai, Evan @ 2023-04-06  5:24 UTC (permalink / raw)
  To: devel; +Cc: Daniel Schaefer, Sunil V L, Andrei Warkentin

It will be replaced by UefiCpuPkg/Library/BaseRiscV64CpuTimerLib.

Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Signed-off-by: Evan Chai <evan.chai@intel.com>
---
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc              |  11 ++++++-----
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf              |   1 +
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc    |  11 ++++++-----
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf    |   1 +
 Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf |  35 -----------------------------------
 Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c       | 199 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc                       |   6 +-----
 7 files changed, 15 insertions(+), 249 deletions(-)

diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
index c26b4608..95bf5ac4 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
@@ -2,6 +2,7 @@
 #  RISC-V EFI on SiFive VC707 (U500) RISC-V platform
 #
 #  Copyright (c) 2019-2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -228,7 +229,7 @@
   RiscVCoreplexInfoLib|Platform/SiFive/U5SeriesPkg/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf
 
 [LibraryClasses.common.DXE_CORE]
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
@@ -245,7 +246,7 @@
 
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -265,7 +266,7 @@
 
 [LibraryClasses.common.UEFI_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -280,7 +281,7 @@
 
 [LibraryClasses.common.DXE_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -300,7 +301,7 @@
 
 [LibraryClasses.common.UEFI_APPLICATION]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
index b17c960d..684d5cae 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.fdf
@@ -2,6 +2,7 @@
 #  Flash definition file on SiFive VC707 (U500) RISC-V platform
 #
 #  Copyright (c) 2019-2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
index 4487913f..099c4e22 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
@@ -2,6 +2,7 @@
 #  RISC-V EFI on SiFive Freedom U540 HiFive Unleashed RISC-V platform
 #
 #  Copyright (c) 2019-2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -230,7 +231,7 @@
   RiscVCoreplexInfoLib|Platform/SiFive/U5SeriesPkg/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf
 
 [LibraryClasses.common.DXE_CORE]
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
@@ -247,7 +248,7 @@
 
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -267,7 +268,7 @@
 
 [LibraryClasses.common.UEFI_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -282,7 +283,7 @@
 
 [LibraryClasses.common.DXE_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -302,7 +303,7 @@
 
 [LibraryClasses.common.UEFI_APPLICATION]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+  TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
index 9ae89647..c2599ee1 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.fdf
@@ -2,6 +2,7 @@
 #  Flash definition file on SiFive Freedom U540 HiFive Unleashed RISC-V platform
 #
 #  Copyright (c) 2019-2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf b/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
deleted file mode 100644
index 3c61149d..00000000
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
+++ /dev/null
@@ -1,35 +0,0 @@
-## @file
-# RISC-V Timer Library Instance.
-#
-#  Copyright (c) 2016 - 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-#
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION    = 0x0001001b
-  BASE_NAME      = BaseRiscVTimerLib
-  FILE_GUID      = F0450728-3221-488E-8C63-BD3A8DF500E2
-  MODULE_TYPE    = BASE
-  VERSION_STRING = 1.0
-  LIBRARY_CLASS  = TimerLib
-
-[Sources]
-  RiscVTimerLib.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec
-
-[Pcd]
-  gUefiRiscVPkgTokenSpaceGuid.PcdRiscVMachineTimerTickInNanoSecond
-  gUefiRiscVPkgTokenSpaceGuid.PcdRiscVMachineTimerFrequencyInHerz
-
-[LibraryClasses]
-  BaseLib
-  PcdLib
-  RiscVCpuLib
-  MachineModeTimerLib
-
-
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c b/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c
deleted file mode 100644
index 85cd93c5..00000000
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/RiscVTimerLib.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/** @file
-  RISC-V instance of Timer Library.
-
-  Copyright (c) 2016 - 2022, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Uefi.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/RiscVCpuLib.h>
-
-/**
-  Stalls the CPU for at least the given number of ticks.
-
-  Stalls the CPU for at least the given number of ticks. It's invoked by
-  MicroSecondDelay() and NanoSecondDelay().
-
-  @param  Delay     A period of time to delay in ticks.
-
-**/
-VOID
-InternalRiscVTimerDelay (
-  IN UINT32  Delay
-  )
-{
-  UINT32  Ticks;
-  UINT32  Times;
-
-  Times  = Delay >> (RISCV_TIMER_COMPARE_BITS - 2);
-  Delay &= ((1 << (RISCV_TIMER_COMPARE_BITS - 2)) - 1);
-  do {
-    //
-    // The target timer count is calculated here
-    //
-    Ticks = RiscVReadMachineTimerInterface () + Delay;
-    Delay = 1 << (RISCV_TIMER_COMPARE_BITS - 2);
-    while (((Ticks - RiscVReadMachineTimerInterface ()) & (1 << (RISCV_TIMER_COMPARE_BITS - 1))) == 0) {
-      CpuPause ();
-    }
-  } while (Times-- > 0);
-}
-
-/**
-  Stalls the CPU for at least the given number of microseconds.
-
-  Stalls the CPU for the number of microseconds specified by MicroSeconds.
-
-  @param  MicroSeconds  The minimum number of microseconds to delay.
-
-  @return MicroSeconds
-
-**/
-UINTN
-EFIAPI
-MicroSecondDelay (
-  IN UINTN  MicroSeconds
-  )
-{
-  InternalRiscVTimerDelay (
-    (UINT32)DivU64x32 (
-              MultU64x32 (
-                MicroSeconds,
-                PcdGet64 (PcdRiscVMachineTimerFrequencyInHerz)
-                ),
-              1000000u
-              )
-    );
-  return MicroSeconds;
-}
-
-/**
-  Stalls the CPU for at least the given number of nanoseconds.
-
-  Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
-
-  @param  NanoSeconds The minimum number of nanoseconds to delay.
-
-  @return NanoSeconds
-
-**/
-UINTN
-EFIAPI
-NanoSecondDelay (
-  IN UINTN  NanoSeconds
-  )
-{
-  InternalRiscVTimerDelay (
-    (UINT32)DivU64x32 (
-              MultU64x32 (
-                NanoSeconds,
-                PcdGet64 (PcdRiscVMachineTimerFrequencyInHerz)
-                ),
-              1000000000u
-              )
-    );
-  return NanoSeconds;
-}
-
-/**
-  Retrieves the current value of a 64-bit free running performance counter.
-
-  Retrieves the current value of a 64-bit free running performance counter. The
-  counter can either count up by 1 or count down by 1. If the physical
-  performance counter counts by a larger increment, then the counter values
-  must be translated. The properties of the counter can be retrieved from
-  GetPerformanceCounterProperties().
-
-  @return The current value of the free running performance counter.
-
-**/
-UINT64
-EFIAPI
-GetPerformanceCounter (
-  VOID
-  )
-{
-  return (UINT64)RiscVReadMachineTimerInterface ();
-}
-
-/**return
-  Retrieves the 64-bit frequency in Hz and the range of performance counter
-  values.
-
-  If StartValue is not NULL, then the value that the performance counter starts
-  with immediately after is it rolls over is returned in StartValue. If
-  EndValue is not NULL, then the value that the performance counter end with
-  immediately before it rolls over is returned in EndValue. The 64-bit
-  frequency of the performance counter in Hz is always returned. If StartValue
-  is less than EndValue, then the performance counter counts up. If StartValue
-  is greater than EndValue, then the performance counter counts down. For
-  example, a 64-bit free running counter that counts up would have a StartValue
-  of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
-  that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
-
-  @param  StartValue  The value the performance counter starts with when it
-                      rolls over.
-  @param  EndValue    The value that the performance counter ends with before
-                      it rolls over.
-
-  @return The frequency in Hz.
-
-**/
-UINT64
-EFIAPI
-GetPerformanceCounterProperties (
-  OUT      UINT64 *StartValue, OPTIONAL
-  OUT      UINT64                    *EndValue     OPTIONAL
-  )
-{
-  if (StartValue != NULL) {
-    *StartValue = 0;
-  }
-
-  if (EndValue != NULL) {
-    *EndValue = 32 - 1;
-  }
-
-  return PcdGet64 (PcdRiscVMachineTimerFrequencyInHerz);
-}
-
-/**
-  Converts elapsed ticks of performance counter to time in nanoseconds.
-
-  This function converts the elapsed ticks of running performance counter to
-  time value in unit of nanoseconds.
-
-  @param  Ticks     The number of elapsed ticks of running performance counter.
-
-  @return The elapsed time in nanoseconds.
-
-**/
-UINT64
-EFIAPI
-GetTimeInNanoSecond (
-  IN      UINT64  Ticks
-  )
-{
-  UINT64  NanoSeconds;
-  UINT32  Remainder;
-
-  //
-  //          Ticks
-  // Time = --------- x 1,000,000,000
-  //        Frequency
-  //
-  NanoSeconds = MultU64x32 (DivU64x32Remainder (Ticks, PcdGet64 (PcdRiscVMachineTimerFrequencyInHerz), &Remainder), 1000000000u);
-
-  //
-  // Frequency < 0x100000000, so Remainder < 0x100000000, then (Remainder * 1,000,000,000)
-  // will not overflow 64-bit.
-  //
-  NanoSeconds += DivU64x32 (MultU64x32 ((UINT64)Remainder, 1000000000u), PcdGet64 (PcdRiscVMachineTimerFrequencyInHerz));
-
-  return NanoSeconds;
-}
diff --git a/Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc b/Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc
index 0591cd6a..e0b8f30d 100644
--- a/Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc
+++ b/Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dsc
@@ -2,6 +2,7 @@
 # RISC-V processor package.
 #
 # Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -43,7 +44,6 @@
   RiscVCpuLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/RiscVCpuLib.inf
   RiscVEdk2SbiLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.inf
   RiscVOpensbiLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/RiscVOpensbiLib.inf
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
   MachineModeTimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineModeTimer/MachineModeTimerLib/MachineModeTimerLib.inf
   #MachineModeTimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineModeTimer/EmulatedMachineModeTimerLib/EmulatedMachineModeTimerLib.inf
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
@@ -81,20 +81,16 @@
   PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
 
 [LibraryClasses.common.DXE_CORE]
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   PlatformBootManagerLib|Platform/RISC-V/PlatformPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 
 [LibraryClasses.common.DXE_RUNTIME_DRIVER]
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
 
 [LibraryClasses.common.UEFI_DRIVER]
-  TimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
 
 [Components]
-  Silicon/RISC-V/ProcessorPkg/Library/RiscVTimerLib/BaseRiscVTimerLib.inf
   Silicon/RISC-V/ProcessorPkg/Library/RiscVExceptionLib/CpuExceptionHandlerDxeLib.inf
   Silicon/RISC-V/ProcessorPkg/Library/RiscVFirmwareContextSbiLib/RiscVFirmwareContextSbiLib.inf
   Silicon/RISC-V/ProcessorPkg/Library/PeiServicesTablePointerLibOpenSbi/PeiServicesTablePointerLibOpenSbi.inf
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [edk2-platforms][PATCH 4/5] Silicon/RISC-V: remove redundant function code from RiscVCpuLib
  2023-04-06  5:24 [edk2-platforms][PATCH 0/5] Platforms cleanup v2 Chai, Evan
                   ` (2 preceding siblings ...)
  2023-04-06  5:24 ` [edk2-platforms][PATCH 3/5] Silicon/RISC-V: remove redundant RiscVTimerLib Chai, Evan
@ 2023-04-06  5:24 ` Chai, Evan
  2023-04-06  5:24 ` [edk2-platforms][PATCH 5/5] Platform/ Siliocn/: Fix building failure caused by wrong lib Chai, Evan
  4 siblings, 0 replies; 6+ messages in thread
From: Chai, Evan @ 2023-04-06  5:24 UTC (permalink / raw)
  To: devel; +Cc: Daniel Schaefer, Sunil V L, Andrei Warkentin

They had been implemented in MdePkg/Library/BaseLib

Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Signed-off-by: Evan Chai <evan.chai@intel.com>
---
 Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVCpuLib.h | 20 +-------------------
 Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/Cpu.S     | 41 +----------------------------------------
 2 files changed, 2 insertions(+), 59 deletions(-)

diff --git a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVCpuLib.h b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVCpuLib.h
index efe85489..f1555843 100644
--- a/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVCpuLib.h
+++ b/Silicon/RISC-V/ProcessorPkg/Include/Library/RiscVCpuLib.h
@@ -2,6 +2,7 @@
   RISC-V CPU library definitions.
 
   Copyright (c) 2016 - 2022, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -96,23 +97,4 @@ RiscVReadMachineImplementId (
   VOID
   );
 
-VOID
-  RiscVSetSupervisorAddressTranslationRegister (UINT64);
-
-VOID
-  RiscVSetSupervisorScratch (UINT64);
-
-UINT64
-RiscVGetSupervisorScratch (
-  VOID
-  );
-
-VOID
-  RiscVSetSupervisorStvec (UINT64);
-
-UINT64
-RiscVGetSupervisorStvec (
-  VOID
-  );
-
 #endif
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/Cpu.S b/Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/Cpu.S
index e242c9b8..52ef0788 100644
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/Cpu.S
+++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/Cpu.S
@@ -3,6 +3,7 @@
 // RISC-V CPU functions.
 //
 // Copyright (c) 2016 - 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+// Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
@@ -101,43 +102,3 @@ ASM_FUNC (RiscVReadMachineImplementId)
     csrr a0, RISCV_CSR_MACHINE_MIMPID
     ret
 
-//
-// Set Supervisor mode scratch.
-// @param a0 : Value set to Supervisor mode scratch
-//
-ASM_FUNC (RiscVSetSupervisorScratch)
-    csrrw a1, RISCV_CSR_SUPERVISOR_SSCRATCH, a0
-    ret
-
-//
-// Get Supervisor mode scratch.
-// @retval a0 : Value in Supervisor mode scratch
-//
-ASM_FUNC (RiscVGetSupervisorScratch)
-    csrr a0, RISCV_CSR_SUPERVISOR_SSCRATCH
-    ret
-
-//
-// Set Supervisor mode trap vector.
-// @param a0 : Value set to Supervisor mode trap vector
-//
-ASM_FUNC (RiscVSetSupervisorStvec)
-    csrrw a1, RISCV_CSR_SUPERVISOR_STVEC, a0
-    ret
-
-//
-// Get Supervisor mode scratch.
-// @retval a0 : Value in Supervisor mode trap vector
-//
-ASM_FUNC (RiscVGetSupervisorStvec)
-    csrr a0, RISCV_CSR_SUPERVISOR_STVEC
-    ret
-
-//
-// Set Supervisor Address Translation and
-// Protection Register.
-//
-ASM_FUNC (RiscVSetSupervisorAddressTranslationRegister)
-    csrw  RISCV_CSR_SUPERVISOR_SATP, a0
-    ret
-
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [edk2-platforms][PATCH 5/5] Platform/ Siliocn/: Fix building failure caused by wrong lib.
  2023-04-06  5:24 [edk2-platforms][PATCH 0/5] Platforms cleanup v2 Chai, Evan
                   ` (3 preceding siblings ...)
  2023-04-06  5:24 ` [edk2-platforms][PATCH 4/5] Silicon/RISC-V: remove redundant function code from RiscVCpuLib Chai, Evan
@ 2023-04-06  5:24 ` Chai, Evan
  4 siblings, 0 replies; 6+ messages in thread
From: Chai, Evan @ 2023-04-06  5:24 UTC (permalink / raw)
  To: devel; +Cc: Daniel Schaefer, Sunil V L, Andrei Warkentin

RiscVSbiLib was implemented in MdePkg/Library/BaseRiscVSbiLib.

Cc: Daniel Schaefer <git@danielschaefer.me>
Cc: Sunil V L <sunilvl@ventanamicro.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Signed-off-by: Evan Chai <evan.chai@intel.com>
---
 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c                          | 4 +++-
 Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf                        | 4 +++-
 Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf                                        | 3 ++-
 Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc                                   | 4 ++--
 Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc                         | 4 ++--
 Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf | 2 ++
 Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf                           | 3 ++-
 7 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c
index 524b0a63..30ec8a8b 100644
--- a/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -2,13 +2,15 @@
   Reset System Library functions for RISC-V
 
   Copyright (c) 2021, Hewlett Packard Development LP. All rights reserved.<BR>
+  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
 #include <Library/DebugLib.h>
 #include <Library/ResetSystemLib.h>
-#include <Library/RiscVEdk2SbiLib.h>
+#include <Library/BaseRiscVSbiLib.h>
 
 /**
   This function causes a system-wide reset (cold reset), in which
diff --git a/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf
index 8987adb9..605d9efd 100644
--- a/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf
+++ b/Platform/RISC-V/PlatformPkg/Library/ResetSystemLib/ResetSystemLib.inf
@@ -2,6 +2,8 @@
 #  Library instance for ResetSystem library class for RISC-V using SBI ecalls
 #
 #  Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+#
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 
@@ -29,4 +31,4 @@
 
 [LibraryClasses]
   DebugLib
-  RiscVEdk2SbiLib
+  RiscVSbiLib
diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf
index 1e8d53f4..8eef9fbb 100644
--- a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf
+++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf
@@ -2,6 +2,7 @@
 #  RISC-V SEC module.
 #
 #  Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -52,7 +53,7 @@
   RiscVCpuLib
   RiscVOpensbiLib
   RiscVOpensbiPlatformLib
-  RiscVEdk2SbiLib
+  RiscVSbiLib
 
 [FixedPcd]
   gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvBase
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
index 95bf5ac4..4dc24386 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc
@@ -148,10 +148,10 @@
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
 !endif
   RiscVCpuLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/RiscVCpuLib.inf
-  RiscVEdk2SbiLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.inf
+  RiscVSbiLib|MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.inf
   RiscVPlatformTimerLib|Platform/SiFive/U5SeriesPkg/Library/RiscVPlatformTimerLib/RiscVPlatformTimerLib.inf
   MachineModeTimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineModeTimer/EmulatedMachineModeTimerLib/EmulatedMachineModeTimerLib.inf
-  CpuExceptionHandlerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVExceptionLib/CpuExceptionHandlerDxeLib.inf
+  CpuExceptionHandlerLib|UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/BaseRiscV64CpuExceptionHandlerLib.inf
 
   # Flattened Device Tree (FDT) access library
   FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
diff --git a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
index 099c4e22..9dff112d 100644
--- a/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
+++ b/Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc
@@ -149,11 +149,11 @@
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
 !endif
   RiscVCpuLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVCpuLib/RiscVCpuLib.inf
-  RiscVEdk2SbiLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVEdk2SbiLib/RiscVEdk2SbiLib.inf
+  RiscVSbiLib|MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.inf
   RiscVPlatformTimerLib|Platform/SiFive/U5SeriesPkg/Library/RiscVPlatformTimerLib/RiscVPlatformTimerLib.inf
   #MachineModeTimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineModeTimer/MachineModeTimerLib/MachineModeTimerLib.inf
   MachineModeTimerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVReadMachineModeTimer/EmulatedMachineModeTimerLib/EmulatedMachineModeTimerLib.inf
-  CpuExceptionHandlerLib|Silicon/RISC-V/ProcessorPkg/Library/RiscVExceptionLib/CpuExceptionHandlerDxeLib.inf
+  CpuExceptionHandlerLib|UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/BaseRiscV64CpuExceptionHandlerLib.inf
 
 
   # Flattened Device Tree (FDT) access library
diff --git a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf b/Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
index 1158fe62..773b149b 100644
--- a/Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+++ b/Platform/SiFive/U5SeriesPkg/Universal/Dxe/RamFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
@@ -6,6 +6,7 @@
 #  Protocol for a RAM flash device.
 #
 #  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -37,6 +38,7 @@
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec
+  Platform/SiFive/U5SeriesPkg/U5SeriesPkg.dec
 
 [LibraryClasses]
   BaseLib
diff --git a/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf b/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf
index 072024dc..13c25506 100644
--- a/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf
+++ b/Silicon/SiFive/U54/Library/PeiCoreInfoHobLib/PeiCoreInfoHobLib.inf
@@ -2,6 +2,7 @@
 #  Library instance to create core information HOB
 #
 #  Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+#  Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -38,7 +39,7 @@
   MemoryAllocationLib
   PrintLib
   FirmwareContextProcessorSpecificLib
-  RiscVEdk2SbiLib
+  RiscVSbiLib
 
 [FixedPcd]
   gUefiRiscVPkgTokenSpaceGuid.PcdProcessorSpecificDataGuidHobGuid
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-06  5:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06  5:24 [edk2-platforms][PATCH 0/5] Platforms cleanup v2 Chai, Evan
2023-04-06  5:24 ` [edk2-platforms][PATCH 1/5] Silicon/RISC-V/ProcessorPkg: remove redundant CpuDxe driver Chai, Evan
2023-04-06  5:24 ` [edk2-platforms][PATCH 2/5] Platform/Sifive: remove redundant TimerDxe from Platform Chai, Evan
2023-04-06  5:24 ` [edk2-platforms][PATCH 3/5] Silicon/RISC-V: remove redundant RiscVTimerLib Chai, Evan
2023-04-06  5:24 ` [edk2-platforms][PATCH 4/5] Silicon/RISC-V: remove redundant function code from RiscVCpuLib Chai, Evan
2023-04-06  5:24 ` [edk2-platforms][PATCH 5/5] Platform/ Siliocn/: Fix building failure caused by wrong lib Chai, Evan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox