aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-20 16:28:18 -0700
committerChristian Cunningham <cc@localhost>2022-01-20 16:28:18 -0700
commit022dfd0f42962da6c60fbeb5604e1455a07eaaa6 (patch)
tree9798813d345b18a00337c26ec6384b42fe41e208
parenta9171b3f7499dfff1f40bf3503fdf13a20487b68 (diff)
Added System Timer Hook
-rw-r--r--include/symbols.h25
-rw-r--r--include/util/time.h1
-rw-r--r--src/cpu/irq.c4
-rw-r--r--src/sys/core.c1
-rw-r--r--src/util/status.c9
-rw-r--r--src/util/time.c14
6 files changed, 54 insertions, 0 deletions
diff --git a/include/symbols.h b/include/symbols.h
index 4f4bb28..8c41c86 100644
--- a/include/symbols.h
+++ b/include/symbols.h
@@ -81,8 +81,33 @@ enum
GPU_INTERRUPTS_ROUTING = 0x4000000C,
CORE0_TIMER_IRQCNTL = 0x40000040,
+ CORE1_TIMER_IRQCNTL = 0x40000044,
+ CORE2_TIMER_IRQCNTL = 0x40000048,
+ CORE3_TIMER_IRQCNTL = 0x4000004c,
+ CORE0_MBOX_IRQCNTL = 0x40000050,
+ CORE1_MBOX_IRQCNTL = 0x40000054,
+ CORE2_MBOX_IRQCNTL = 0x40000058,
+ CORE3_MBOX_IRQCNTL = 0x4000005c,
CORE0_IRQ_SOURCE = 0x40000060,
+ CORE1_IRQ_SOURCE = 0x40000064,
+ CORE2_IRQ_SOURCE = 0x40000068,
+ CORE3_IRQ_SOURCE = 0x4000006c,
CORE0_FIQ_SOURCE = 0x40000070,
+ CORE1_FIQ_SOURCE = 0x40000074,
+ CORE2_FIQ_SOURCE = 0x40000078,
+ CORE3_FIQ_SOURCE = 0x4000007c,
+
+ SYS_TIMER_CS = (MMIO_BASE + 0x3000),
+ SYS_TIMER_CHI = (MMIO_BASE + 0x3004),
+ SYS_TIMER_CLO = (MMIO_BASE + 0x3008),
+ SYS_TIMER_C0 = (MMIO_BASE + 0x300c),
+ SYS_TIMER_C1 = (MMIO_BASE + 0x3010),
+ SYS_TIMER_C2 = (MMIO_BASE + 0x3014),
+ SYS_TIMER_C3 = (MMIO_BASE + 0x3018),
+ SYS_TIMER_SC_M0 = (1 << 0),
+ SYS_TIMER_SC_M1 = (1 << 1),
+ SYS_TIMER_SC_M2 = (1 << 2),
+ SYS_TIMER_SC_M3 = (1 << 3),
/* Power Management, Reset controller and Watchdog registers */
//BCM2835_PERI_BASE = 0x3F000000,
diff --git a/include/util/time.h b/include/util/time.h
index f73314f..dc51e00 100644
--- a/include/util/time.h
+++ b/include/util/time.h
@@ -9,6 +9,7 @@ unsigned long long read_cntvoff(void);
unsigned long read_cntv_tval(void);
void write_cntv_tval(unsigned long val);
unsigned long read_cntfrq(void);
+unsigned long long get_time(void);
static inline void enablecntv(void)
{
diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index f1d8fb6..fb73b8a 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -102,6 +102,8 @@ void c_irq_handler(void)
} else if (source & (1 << 3)) {
c_timer();
return;
+ } else {
+ uart_string("Unknown Interrupt Detected!");
}
return;
}
@@ -196,6 +198,8 @@ void c_fiq_handler(void)
} else if (source & (1 << 3)) {
c_timer();
return;
+ } else {
+ uart_string("Unknown Interrupt Detected!");
}
return;
}
diff --git a/src/sys/core.c b/src/sys/core.c
index 0b4b91a..d658d90 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -33,6 +33,7 @@ void sysinit(void)
cmdidx = 0;
for(int i = 0; i < 2048; i++)
cmd[i] = 0;
+ *(unsigned long*) SYS_TIMER_C0 = 60000000; // 60 second trigger
///...
// Route GPU interrupts to Core 0
diff --git a/src/util/status.c b/src/util/status.c
index dd2b899..7abf931 100644
--- a/src/util/status.c
+++ b/src/util/status.c
@@ -162,6 +162,15 @@ void status(void)
"and %0, %0, #3" : "=r"(coren) :: "cc");
write_string(&g_Drawer, "Status Updated by Core #");
write_10(&g_Drawer, coren);
+ write_string(&g_Drawer, "\nSys Timer Status: ");
+ coren = *(unsigned long*)SYS_TIMER_CS;
+ write_10(&g_Drawer, coren);
+ write_string(&g_Drawer, " : ");
+ unsigned long long tval = get_time();
+ write_hex32(&g_Drawer, (tval >> 32));
+ write_hex32(&g_Drawer, tval);
+ write_char(&g_Drawer, '\n');
+ write_10(&g_Drawer, ((unsigned long)tval)/1000000);
g_Drawer.x = x;
g_Drawer.y = y;
diff --git a/src/util/time.c b/src/util/time.c
index a0c539b..e9e5716 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -51,3 +51,17 @@ unsigned long read_cntfrq(void)
asm volatile ("mrc p15, 0, %0, c14, c0, 0" : "=r"(val) );
return val;
}
+
+unsigned long long get_time(void)
+{
+ union {
+ unsigned long long tval;
+ struct {
+ unsigned long high;
+ unsigned long low;
+ } tvalb;
+ } t;
+ t.tvalb.low = *(unsigned long*)SYS_TIMER_CLO;
+ t.tvalb.high = *(unsigned long*)SYS_TIMER_CHI;
+ return t.tval;
+}