aboutsummaryrefslogtreecommitdiff
path: root/interrupts.c
diff options
context:
space:
mode:
Diffstat (limited to 'interrupts.c')
-rw-r--r--interrupts.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/interrupts.c b/interrupts.c
index f4192a0..2dd7fbd 100644
--- a/interrupts.c
+++ b/interrupts.c
@@ -1,7 +1,11 @@
+#include "uart.h"
+#include "interrupts.h"
#include "io.h"
#include "svc_interface.h"
#include "armclock.h"
-
+/**
+ @brief The undefined instruction interrupt handler
+ */
void __attribute__((noreturn)) setup(void);
// from what I've heard, reset is never used on the Pi;
@@ -25,7 +29,7 @@ uint32_t supervisor_call_handler(enum svc_type request, uint32_t arg1,
uint32_t arg2, uint32_t arg3)
{
(void) arg2; (void) arg3; // unused for now
-
+
switch(request) {
case UART_PUTCHAR:
putchar(arg1);
@@ -59,6 +63,9 @@ void generic_handler(void)
void irq_handler(void)
{
+ uart_puts("nwm\r\n");
+
+ system_reentry_point();
if (armclk_irq_pending())
{
puts("<<irq from timer>>");
@@ -78,3 +85,30 @@ void fiq_handler(void)
while(1);
}
+
+/* Here is your interrupt function */
+void
+__attribute__((interrupt("IRQ")))
+__attribute__((section(".interrupt_vectors.text")))
+irq_handler(void) {
+ /* You code goes here */
+ uart_puts("GOT INTERRUPT!\r\n");
+
+ local_timer_clr_reload_reg_t temp = { .IntClear = 1, .Reload = 1 };
+ QA7->TimerClearReload = temp; // Clear interrupt & reload
+}
+
+/* here is your main */
+int enable_timer(void) {
+
+ QA7->TimerRouting.Routing = LOCALTIMER_TO_CORE0_IRQ; // Route local timer IRQ to Core0
+ QA7->TimerControlStatus.ReloadValue = 100; // Timer period set
+ QA7->TimerControlStatus.TimerEnable = 1; // Timer enabled
+ QA7->TimerControlStatus.IntEnable = 1; // Timer IRQ enabled
+ QA7->TimerClearReload.IntClear = 1; // Clear interrupt
+ QA7->TimerClearReload.Reload = 1; // Reload now
+ QA7->Core0TimerIntControl.nCNTPNSIRQ_IRQ = 1; // We are in NS EL1 so enable IRQ to core0 that level
+ QA7->Core0TimerIntControl.nCNTPNSIRQ_FIQ = 0; // Make sure FIQ is zero
+ uart_puts("Enabled Timer\r\n");
+ return(0);
+} \ No newline at end of file