Support armv8.(TODO: fix clock)
This commit is contained in:
@@ -9,13 +9,14 @@
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "actracer.h"
|
||||
#include "core.h"
|
||||
#include "generic_timer.h"
|
||||
|
||||
#include "clock_common_op.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
// armv8 generic timer driver
|
||||
|
||||
#define CNTV_CTL_ENABLE (1 << 0)
|
||||
@@ -24,26 +25,23 @@
|
||||
|
||||
static void enable_timer()
|
||||
{
|
||||
uint64_t c = r_cntv_ctl_el0();
|
||||
c |= CNTV_CTL_ENABLE;
|
||||
c &= ~CNTV_CTL_IMASK;
|
||||
uint32_t c = r_cntv_ctl_el0();
|
||||
c = CNTV_CTL_ENABLE;
|
||||
w_cntv_ctl_el0(c);
|
||||
}
|
||||
|
||||
static void disable_timer()
|
||||
{
|
||||
uint64_t c = r_cntv_ctl_el0();
|
||||
c &= ~CNTV_CTL_ENABLE;
|
||||
c |= CNTV_CTL_IMASK;
|
||||
uint32_t c = r_cntv_ctl_el0();
|
||||
c = CNTV_CTL_IMASK;
|
||||
w_cntv_ctl_el0(c);
|
||||
}
|
||||
|
||||
static void reload_timer()
|
||||
{
|
||||
// interval 100ms
|
||||
uint64_t interval = 100000;
|
||||
uint64_t interval_clk = interval * (r_cntfrq_el0() / 1000000);
|
||||
|
||||
uint32_t interval = 100000;
|
||||
uint32_t interval_clk = interval * (r_cntfrq_el0() / 1000000);
|
||||
w_cntv_tval_el0(interval_clk);
|
||||
}
|
||||
|
||||
@@ -61,7 +59,7 @@ static uint32_t _get_clock_int()
|
||||
|
||||
static uint64_t _get_tick()
|
||||
{
|
||||
return 0;
|
||||
return r_cntvct_el0();
|
||||
}
|
||||
|
||||
static uint64_t _get_second()
|
||||
|
||||
+8
-8
@@ -15,26 +15,26 @@
|
||||
#include <stdint.h>
|
||||
|
||||
// armv8 generic timer
|
||||
static inline uint64_t r_cntv_ctl_el0()
|
||||
static inline uint32_t r_cntv_ctl_el0()
|
||||
{
|
||||
uint64_t x;
|
||||
uint32_t x;
|
||||
__asm__ volatile("mrs %0, cntv_ctl_el0" : "=r"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void w_cntv_ctl_el0(uint64_t x)
|
||||
static inline void w_cntv_ctl_el0(uint32_t x)
|
||||
{
|
||||
__asm__ volatile("msr cntv_ctl_el0, %0" : : "r"(x));
|
||||
}
|
||||
|
||||
static inline uint64_t r_cntv_tval_el0()
|
||||
static inline uint32_t r_cntv_tval_el0()
|
||||
{
|
||||
uint64_t x;
|
||||
uint32_t x;
|
||||
__asm__ volatile("mrs %0, cntv_tval_el0" : "=r"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline void w_cntv_tval_el0(uint64_t x)
|
||||
static inline void w_cntv_tval_el0(uint32_t x)
|
||||
{
|
||||
__asm__ volatile("msr cntv_tval_el0, %0" : : "r"(x));
|
||||
}
|
||||
@@ -46,9 +46,9 @@ static inline uint64_t r_cntvct_el0()
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline uint64_t r_cntfrq_el0()
|
||||
static inline uint32_t r_cntfrq_el0()
|
||||
{
|
||||
uint64_t x;
|
||||
uint32_t x;
|
||||
__asm__ volatile("mrs %0, cntfrq_el0" : "=r"(x));
|
||||
return x;
|
||||
}
|
||||
Reference in New Issue
Block a user