basic terminal
[cortex-from-scratch] / ivt.c
diff --git a/ivt.c b/ivt.c
index 183713f..b3854f1 100644 (file)
--- a/ivt.c
+++ b/ivt.c
@@ -1,3 +1,13 @@
+/* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
+ * 
+ * $LOG$
+ * 2019/7/20 - ROBIN KRENS     
+ * Initial version 
+ * 
+ * $DESCRIPTION$
+ * 
+ * */
+
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -35,7 +45,7 @@ struct interrupt_frame {
  * interrupt vector 16-92: irq0 - irq ..
  * */
 
-uint32_t ivt[92];
+uint32_t __attribute__((aligned(0x100))) ivt[92];
 
 /* each message corresponds to each and every exception. 
  * We get the correct message by accessing
@@ -83,8 +93,8 @@ void ivt_set_gate(unsigned char num, void * isr(), short pri) {
 
 
 /* Dummy interrupt */
-__attribute__ ((interrupt)) 
-void * dummy_isr(struct interrupt_frame * frame) {
+// __attribute__ ((interrupt)) 
+void * dummy_isr(/* struct interrupt_frame * frame */) {
 
        uint8_t nr = *SCB_VTOR_ST & 0xFF;
        
@@ -105,16 +115,17 @@ void ivt_init() {
        // don't need to relocate or init this here
        extern void * reset,  * nmi, * hardfault;
 
-       for (int i = 1; i <= 6 ; i++) {
+       for (int i = 1; i <= 64 ; i++) {
                ivt_set_gate(i, dummy_isr, 0);
        }
 
+
        /* the vector table starts at 0x0. Since the address 0x0 point to 
         * bootcode, it is on ROM or FLASH. The vector table can be
         * relocated to other memory locations. We can do this by setting 
         * a register in the NVIC called the vector table offset register */
 
        //*SCB_VTOR = (volatile uint32_t) &ivt; 
-       regw_u32(SCB_VTOR, (uint32_t) &ivt, 0, 0x01);
+       regw_u32(SCB_VTOR, (uint32_t) &ivt, 0, OWRITE);
 
 }