diff options
author | Christian Cunningham <cc@localhost> | 2021-12-04 17:09:22 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2021-12-04 17:09:22 -0700 |
commit | 1c6cd8e1ea53275cc44b2a0ee5a8448cbc4a3f0d (patch) | |
tree | 8ba9eed6acebbd0940898e5c46b35caed7e03792 /src/util | |
parent | 0ee2aaaa26441e37ed27e6c83cf9b65202596a4e (diff) |
Restructured project
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/time.c | 64 | ||||
-rw-r--r-- | src/util/time.h | 14 |
2 files changed, 78 insertions, 0 deletions
diff --git a/src/util/time.c b/src/util/time.c new file mode 100644 index 0000000..72fc52b --- /dev/null +++ b/src/util/time.c @@ -0,0 +1,64 @@ +#include "../sys/core.h" + +void routing_core0cntv_to_core0irq(void) +{ + // IRQ + store32(0x08, CORE0_TIMER_IRQCNTL); + // FIQ + //store32(0x80, CORE0_TIMER_IRQCNTL); +} + +unsigned long read_core0timer_pending(void) +{ + unsigned long tmp; + tmp = load32(CORE0_IRQ_SOURCE); + return tmp; +} + +void enable_cntv(void) +{ + unsigned long cntv_ctl; + cntv_ctl = 1; + asm volatile ("mcr p15, 0, %0, c14, c3, 1" :: "r"(cntv_ctl) ); // write CNTV_CTL +} + +void disable_cntv(void) +{ + unsigned long cntv_ctl; + cntv_ctl = 0; + asm volatile ("mcr p15, 0, %0, c14, c3, 1" :: "r"(cntv_ctl) ); // write CNTV_CTL +} + +unsigned long long read_cntvct(void) +{ + unsigned long long val; + asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (val)); + return (val); +} + +unsigned long long read_cntvoff(void) +{ + unsigned long long val; + asm volatile("mrrc p15, 4, %Q0, %R0, c14" : "=r" (val)); + return (val); +} + +unsigned long read_cntv_tval(void) +{ + unsigned long val; + asm volatile ("mrc p15, 0, %0, c14, c3, 0" : "=r"(val) ); + return val; +} + +void write_cntv_tval(unsigned long val) +{ + asm volatile ("mcr p15, 0, %0, c14, c3, 0" :: "r"(val) ); + return; +} + +unsigned long read_cntfrq(void) +{ + unsigned long val; + asm volatile ("mrc p15, 0, %0, c14, c0, 0" : "=r"(val) ); + return val; +} diff --git a/src/util/time.h b/src/util/time.h new file mode 100644 index 0000000..1fb3906 --- /dev/null +++ b/src/util/time.h @@ -0,0 +1,14 @@ +#ifndef TIME_H +#define TIME_H + +void routing_core0cntv_to_core0irq(void); +unsigned long read_core0timer_pending(void); +void enable_cntv(void); +void disable_cntv(void); +unsigned long long read_cntvct(void); +unsigned long long read_cntvoff(void); +unsigned long read_cntv_tval(void); +void write_cntv_tval(unsigned long val); +unsigned long read_cntfrq(void); + +#endif |