From d78d5bb36a6bd3e10ef10570eaa2aba47b65b57f Mon Sep 17 00:00:00 2001 From: lr <1234@qq.com> Date: Tue, 23 Jul 2024 17:30:42 +0800 Subject: [PATCH] add get_second/tick for 3568 --- .../clock/arm/armv8-a/cortex-a55/3568/clock.c | 2 +- .../XiZi_AIoT/services/lib/usyscall/usyscall.c | 14 ++++++++++++++ .../XiZi_AIoT/services/lib/usyscall/usyscall.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a55/3568/clock.c b/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a55/3568/clock.c index 4c8557aaa..39d2995d6 100644 --- a/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a55/3568/clock.c +++ b/Ubiquitous/XiZi_AIoT/hardkernel/clock/arm/armv8-a/cortex-a55/3568/clock.c @@ -64,7 +64,7 @@ static uint64_t _get_tick() static uint64_t _get_second() { - return 0; + return _get_tick() / r_cntfrq_el0(); } static bool _is_timer_expired() diff --git a/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.c b/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.c index a6fd43a4a..debd8af62 100644 --- a/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.c +++ b/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.c @@ -101,6 +101,20 @@ int show_cpu() return syscall(SYSCALL_SYS_STATE, SYS_STATE_SHOW_CPU_INFO, 0, 0, 0); } +uintptr_t get_second() +{ + sys_state_info info; + syscall(SYSCALL_SYS_STATE, SYS_STATE_GET_CURRENT_SECOND, (intptr_t)&info, 0, 0); + return info.current_second; +} + +uintptr_t get_tick() +{ + sys_state_info info; + syscall(SYSCALL_SYS_STATE, SYS_STATE_GET_CURRENT_TICK, (intptr_t)&info, 0, 0); + return info.current_tick; +} + uintptr_t mmap(uintptr_t vaddr, uintptr_t paddr, int len, bool is_dev) { uintptr_t vaddr_inner = vaddr, paddr_inner = paddr; diff --git a/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.h b/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.h index 2ff0a2446..e76f684a1 100644 --- a/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.h +++ b/Ubiquitous/XiZi_AIoT/services/lib/usyscall/usyscall.h @@ -99,6 +99,9 @@ int show_task(); int show_mem(); int show_cpu(); +uintptr_t get_second(); +uintptr_t get_tick(); + int semaphore_new(int val); bool semaphore_free(int sem_id); bool semaphore_wait(int sem_id);