mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
UefiCpuPkg/BaseRiscV64CpuTimerLib: Add constructor to initialize mTimeBase
mTimeBase is currently initialized only when timer functions are invoked during boot. This requires reading data from a HOB, but accessing HOBs during runtime EFI calls can trigger a kernel panic because the virtual address change event for HOB addresses is not implemented. To address this, a constructor function is added so that mTimeBase is initialized before the kernel boots, avoiding any runtime access to HOB data. Fixes: #11747 Signed-off-by: Chao Liu <chao.liu.riscv@isrc.iscas.ac.cn> Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
This commit is contained in:
parent
e2951626ad
commit
c27b555439
2 changed files with 22 additions and 0 deletions
|
|
@ -16,6 +16,7 @@
|
|||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = TimerLib
|
||||
MODULE_UNI_FILE = BaseRisV64CpuTimerLib.uni
|
||||
CONSTRUCTOR = BaseRiscV64CpuTimerLibConstructor
|
||||
|
||||
[Sources]
|
||||
CpuTimerLib.c
|
||||
|
|
|
|||
|
|
@ -262,3 +262,24 @@ GetTimeInNanoSecond (
|
|||
|
||||
return NanoSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
Constructor function for the Timer Library.
|
||||
|
||||
This constructor function is called early during booting to ensure that
|
||||
GetPerformanceCounterProperties() is invoked and mTimeBase is initialized
|
||||
before any code that depends on it.
|
||||
|
||||
@retval EFI_SUCCESS The constructor always returns success.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
BaseRiscV64CpuTimerLibConstructor (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
GetPerformanceCounterProperties (NULL, NULL);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue