aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-02-01 19:39:36 -0700
committerChristian Cunningham <cc@localhost>2022-02-01 19:39:36 -0700
commit98793badc1c1d3e4bfd735fdecd3d2d731701ab3 (patch)
tree3406220e55b0e7cce3895817796f75bf754da6d9 /include
parent33e35caf1104cdf5b8e1470112677f78b5e8dc59 (diff)
Syscall to get timer value
Diffstat (limited to 'include')
-rw-r--r--include/cpu.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/cpu.h b/include/cpu.h
index cccc12b..c15c086 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -82,6 +82,20 @@ static inline void* getirqstack(void)
#define sys0(sys_n) asm volatile("svc #" syscall_h_expand_and_quote(sys_n) ::: "r0", "r1", "r2", "r3");
#define sys1(sys_n,arg0) asm volatile("svc #" syscall_h_expand_and_quote(sys_n) ::[r0]"r"(arg0): "r0", "r1", "r2", "r3");
+__attribute__((always_inline)) static inline unsigned long long get_sys_time(void)
+{
+ union {
+ struct {
+ unsigned long lo;
+ unsigned long hi;
+ }s;
+ unsigned long long llv;
+ }t;
+ asm volatile("svc #1\nmov %0, r0\nmov %0, r1" : "=r"(t.s.lo), "=r"(t.s.hi));
+ return t.llv;
+}
+
#define SYS_SCHED 2
+#define SYS_TIME 1
#endif