OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [mor1kx-5.0/] [sw/] [mor1kx/] [exceptions.c] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
#include "mor1kx-utils.h"
2
#include "int.h" // User interrupt handler header
3
//#include "uart.h"
4
//#include "../mor1ktest.h"
5
 
6
 
7
 
8
 
9
 
10
 
11
 
12
 
13
 
14
/*  sim_uart0   */
15
 #define sim_DATA_REG                                   (*((volatile unsigned int *) (0Xa5000000)))
16
 
17
void sim_putchar(char ch){ //print one char from jtag_uart
18
        sim_DATA_REG=ch;
19
}
20
 
21
 
22
 
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
 
31
 
32
 
33
 
34
 
35
 
36
#define STR_EXCEPTION_OCCURED " exception occured.\n"
37
 
38
char *exception_strings[] = {
39
  "An unknown",             // 0
40
  "A reset (?!)",           // 1 
41
  "A Bus Error",            // 2
42
  "A Data Page Fault",      // 3
43
  "An Instruction Page Fault", // 4
44
  "A Tick-Timer",              // 5
45
  "An Alignment",              // 6
46
  "An Illegal Instruction",    // 7
47
  "An External Interrupt",     // 8
48
  "A D-TLB Miss",              // 9
49
  "An I-TLB Miss",             // a
50
  "A Range",                   // b
51
  "A System Call",             // c
52
  "A Floating-Point",          // d
53
  "A Trap",                    // e
54
  "A \"Reserved\"",            // f
55
  "A \"Reserved\"",            // 10
56
  "A \"Reserved\"",            // 11
57
  "A \"Reserved\"",            // 12
58
  "A \"Reserved\"",            // 13
59
  "A \"Reserved\"",            // 14
60
  "An Implementation Specific \"Reserved\"", // 16
61
  "An Implementation Specific \"Reserved\"", // 17
62
  "An Implementation Specific \"Reserved\"", // 18
63
  "A Custom",                                // 19
64
  "A Custom",                                // 1a
65
  "A Custom",                                // 1b
66
  "A Custom",                                // 1c
67
  "A Custom",                                // 1d
68
  "A Custom",                                // 1e
69
  "A Custom",                                // 1f
70
};
71
 
72
extern void int_main(void);
73
extern void cpu_timer_tick(void);
74
 
75
void (*except_handlers[]) (void)  = {0,    // 0
76
                                    0,    // 1
77
                                    0,    // 2
78
                                    0,    // 3
79
                                    0,    // 4
80
                                    cpu_timer_tick,    // 5
81
                                    0,    // 6
82
                                    0,    // 7
83
                                    int_main,    // 8
84
                                    0,    // 9
85
                                    0,    // a
86
                                    0,    // b
87
                                    0,    // c
88
                                    0,    // d
89
                                    0,    // e
90
                                    0,    // f
91
                                    0,    // 10
92
                                    0,    // 11
93
                                    0,    // 12
94
                                    0};    // 13
95
 
96
 
97
void
98
add_handler(unsigned long vector, void (*handler) (void))
99
{
100
  except_handlers[vector] = handler;
101
}
102
 
103
struct exception_state * current_exception_state_struct;
104
 
105
void
106
default_exception_handler_c(unsigned exception_address, unsigned epc, unsigned esr,
107
                            struct exception_state * exception_state)
108
{
109
  int exception_no = (exception_address >> 8) & 0x1f;
110
  if (except_handlers[exception_no])
111
    {
112
            current_exception_state_struct = exception_state;
113
            (*except_handlers[exception_no])();
114
            return;
115
    }
116
 
117
  // init uart here, incase it hasn't been
118
  //uart_init(DEFAULT_UART);
119
 
120
  //printf("EPC = 0x%.8x\n", exception_address);
121
 
122
  // Output initial messaging using low-level functions incase
123
  // something really bad happened.
124
  //printf("%s%s", exception_strings[exception_no],  STR_EXCEPTION_OCCURED);
125
//sim_putchar(exception_no+'0');          
126
  // Icing on the cake using fancy functions
127
  //printf("EPC = 0x%.8x\n", epc);
128
 
129
  report(exception_address);
130
  report(epc);
131
  __asm__("l.nop 1");
132
  for(;;);
133
}
134
 
135
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.