aboutsummaryrefslogtreecommitdiff
path: root/interrupts.c
diff options
context:
space:
mode:
authorvetch <vetch97@gmail.com>2020-01-02 17:54:31 +0100
committervetch <vetch97@gmail.com>2020-01-02 17:54:31 +0100
commitab7b754bb32022336527c1a2d5d710b95a589d0e (patch)
tree19f508f06c72efcbdd2cfad46949ed6f1ae45a3c /interrupts.c
parent5e1e6796109c892c4300c3da17c35e7874a40107 (diff)
parent6bf5a3b8c6e8a5d1cb3fb4880a5d9688ab094c62 (diff)
downloadrpi-MMU-example-ab7b754bb32022336527c1a2d5d710b95a589d0e.tar.gz
rpi-MMU-example-ab7b754bb32022336527c1a2d5d710b95a589d0e.zip
Merge branch 'bob' of https://repo.or.cz/RPi-MMU-example into alice
# Conflicts: # .gitignore # PL0_test.ld # demo_functionality.c # interrupt_vector.S # interrupts.c # kernel.c # memory.h
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")))