🐞 fix(ktime): fix wrong boottime

因为tick从中断到设置中间的时延特别大,因此暂不采用tick做基准时间,直接取gtime的cnt做基准时间
This commit is contained in:
xqyjlj
2023-07-27 11:35:29 +08:00
committed by guo
parent 0eaa757cff
commit d23dd56692
7 changed files with 53 additions and 17 deletions
+7
View File
@@ -13,6 +13,10 @@
#include <gtimer.h>
#include <cpuport.h>
#ifdef RT_USING_KTIME
#include <ktime.h>
#endif
#define EL1_PHY_TIMER_IRQ_NUM 30
static volatile rt_uint64_t timer_step;
@@ -38,6 +42,9 @@ void rt_hw_gtimer_local_enable(void)
rt_hw_gtimer_disable();
rt_hw_set_gtimer_val(timer_step);
rt_hw_interrupt_umask(EL1_PHY_TIMER_IRQ_NUM);
#ifdef RT_USING_KTIME
rt_ktime_cputimer_init();
#endif
rt_hw_gtimer_enable();
}
+7
View File
@@ -14,6 +14,10 @@
#include <encoding.h>
#include "sbi.h"
#ifdef RT_USING_KTIME
#include <ktime.h>
#endif
static volatile uint64_t time_elapsed = 0;
static volatile unsigned long tick_cycles = 0;
@@ -49,6 +53,9 @@ int rt_hw_tick_init(void)
/* Set timer */
sbi_set_timer(get_ticks() + tick_cycles);
#ifdef RT_USING_KTIME
rt_ktime_cputimer_init();
#endif
/* Enable the Supervisor-Timer bit in SIE */
set_csr(sie, SIP_STIP);