aboutsummaryrefslogtreecommitdiff
path: root/interrupts.c
diff options
context:
space:
mode:
Diffstat (limited to 'interrupts.c')
-rw-r--r--interrupts.c80
1 files changed, 69 insertions, 11 deletions
diff --git a/interrupts.c b/interrupts.c
index 712cfb9..2dd7fbd 100644
--- a/interrupts.c
+++ b/interrupts.c
@@ -1,33 +1,91 @@
#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);
- If an undefined instruction is encountered, the CPU will start
- executing this function. Just trap here as a debug solution.
-*/
-void __attribute__((interrupt("UNDEF"))) undefined_instruction_vector(void)
+// from what I've heard, reset is never used on the Pi;
+// in our case it should run once - when stage1 of the kernel
+// jumps to stage2
+void reset_handler(void)
{
- uart_puts("Undefined instruction occured");
+ setup();
+}
+
+void undefined_instruction_vector(void)
+{
+ puts("Undefined instruction occured");
while( 1 )
{
/* Do Nothing! */
}
}
-void __attribute__((section(".interrupt_vectors.data")))
-(*system_reentry_point) (void);
+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
-void
-__attribute__((interrupt("ABORT")))
-__attribute__((section(".interrupt_vectors.text")))
-abort_handler(void)
+ switch(request) {
+ case UART_PUTCHAR:
+ putchar(arg1);
+ break;
+ case UART_GETCHAR:
+ return getchar();
+ case UART_WRITE:
+ puts("UART_WRITE not implemented!!!!!");
+ break;
+ default:
+ // perhaps we should kill the process now?
+ puts("unknown supervisor call type!!!!!");
+ }
+
+ return 0; // a dummy value
+}
+
+void abort_handler(void)
+{
+ puts("re-entered system");
+
+ while(1);
+}
+
+void generic_handler(void)
+{
+ puts("something weird happened");
+
+ while(1);
+}
+
+void irq_handler(void)
{
uart_puts("nwm\r\n");
system_reentry_point();
+ if (armclk_irq_pending())
+ {
+ puts("<<irq from timer>>");
+ armclk_irq_settimeout(0x00100000);
+ }
+ else
+ {
+ puts("unknown irq");
+ while(1);
+ }
+}
+
+void fiq_handler(void)
+{
+ puts("fiq happened");
+
+ while(1);
}
+
/* Here is your interrupt function */
void
__attribute__((interrupt("IRQ")))