UefiCpuPkg: CpuTimerDxeRiscV64: Fix incorrect value sent to SbiSetTimer
SbiSetTimer expects core tick value. Cc: Andrei Warkentin <andrei.warkentin@intel.com> Signed-off-by: Tuan Phan <tphan@ventanamicro.com> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
This commit is contained in:
@ -40,6 +40,9 @@
|
|||||||
Timer.h
|
Timer.h
|
||||||
Timer.c
|
Timer.c
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency ## CONSUMES
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiCpuArchProtocolGuid ## CONSUMES
|
gEfiCpuArchProtocolGuid ## CONSUMES
|
||||||
gEfiTimerArchProtocolGuid ## PRODUCES
|
gEfiTimerArchProtocolGuid ## PRODUCES
|
||||||
|
@ -81,7 +81,14 @@ TimerInterruptHandler (
|
|||||||
}
|
}
|
||||||
|
|
||||||
mLastPeriodStart = PeriodStart;
|
mLastPeriodStart = PeriodStart;
|
||||||
SbiSetTimer (PeriodStart += mTimerPeriod);
|
PeriodStart += DivU64x32 (
|
||||||
|
MultU64x32 (
|
||||||
|
mTimerPeriod,
|
||||||
|
PcdGet64 (PcdCpuCoreCrystalClockFrequency)
|
||||||
|
),
|
||||||
|
1000000u
|
||||||
|
); // convert to tick
|
||||||
|
SbiSetTimer (PeriodStart);
|
||||||
RiscVEnableTimerInterrupt (); // enable SMode timer int
|
RiscVEnableTimerInterrupt (); // enable SMode timer int
|
||||||
gBS->RestoreTPL (OriginalTPL);
|
gBS->RestoreTPL (OriginalTPL);
|
||||||
}
|
}
|
||||||
@ -163,6 +170,8 @@ TimerDriverSetTimerPeriod (
|
|||||||
IN UINT64 TimerPeriod
|
IN UINT64 TimerPeriod
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UINT64 PeriodStart;
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "TimerDriverSetTimerPeriod(0x%lx)\n", TimerPeriod));
|
DEBUG ((DEBUG_INFO, "TimerDriverSetTimerPeriod(0x%lx)\n", TimerPeriod));
|
||||||
|
|
||||||
if (TimerPeriod == 0) {
|
if (TimerPeriod == 0) {
|
||||||
@ -172,8 +181,17 @@ TimerDriverSetTimerPeriod (
|
|||||||
}
|
}
|
||||||
|
|
||||||
mTimerPeriod = TimerPeriod / 10; // convert unit from 100ns to 1us
|
mTimerPeriod = TimerPeriod / 10; // convert unit from 100ns to 1us
|
||||||
|
|
||||||
mLastPeriodStart = RiscVReadTimer ();
|
mLastPeriodStart = RiscVReadTimer ();
|
||||||
SbiSetTimer (mLastPeriodStart + mTimerPeriod);
|
PeriodStart = mLastPeriodStart;
|
||||||
|
PeriodStart += DivU64x32 (
|
||||||
|
MultU64x32 (
|
||||||
|
mTimerPeriod,
|
||||||
|
PcdGet64 (PcdCpuCoreCrystalClockFrequency)
|
||||||
|
),
|
||||||
|
1000000u
|
||||||
|
); // convert to tick
|
||||||
|
SbiSetTimer (PeriodStart);
|
||||||
|
|
||||||
mCpu->EnableInterrupt (mCpu);
|
mCpu->EnableInterrupt (mCpu);
|
||||||
RiscVEnableTimerInterrupt (); // enable SMode timer int
|
RiscVEnableTimerInterrupt (); // enable SMode timer int
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <Library/IoLib.h>
|
#include <Library/IoLib.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// RISC-V use 100us timer.
|
// RISC-V use 100ns timer.
|
||||||
// The default timer tick duration is set to 10 ms = 10 * 1000 * 10 100 ns units
|
// The default timer tick duration is set to 10 ms = 10 * 1000 * 10 100 ns units
|
||||||
//
|
//
|
||||||
#define DEFAULT_TIMER_TICK_DURATION 100000
|
#define DEFAULT_TIMER_TICK_DURATION 100000
|
||||||
|
Reference in New Issue
Block a user