OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [drivers/] [or1200/] [exceptions.c] - Blame information for rev 560

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 393 julius
#include "or1200-utils.h"
2 349 julius
#include "int.h" // User interrupt handler header
3
#include "uart.h"
4
#include "printf.h"
5
 
6
#define STR_EXCEPTION_OCCURED " exception occured.\n"
7
 
8
char *exception_strings[] = {
9
  "An unknown",             // 0
10
  "A reset (?!)",           // 1 
11
  "A Bus Error",            // 2
12
  "A Data Page Fault",      // 3
13
  "An Instruction Page Fault", // 4
14
  "A Tick-Timer",              // 5
15
  "An Alignment",              // 6
16
  "An Illegal Instruction",    // 7
17
  "An External Interrupt",     // 8
18
  "A D-TLB Miss",              // 9
19
  "An I-TLB Miss",             // a
20
  "A Range",                   // b
21
  "A System Call",             // c
22
  "A Floating-Point",          // d
23
  "A Trap",                    // e
24
  "A \"Reserved\"",            // f
25
  "A \"Reserved\"",            // 10
26
  "A \"Reserved\"",            // 11
27
  "A \"Reserved\"",            // 12
28
  "A \"Reserved\"",            // 13
29
  "A \"Reserved\"",            // 14
30
  "An Implementation Specific \"Reserved\"", // 16
31
  "An Implementation Specific \"Reserved\"", // 17
32
  "An Implementation Specific \"Reserved\"", // 18
33
  "A Custom",                                // 19
34
  "A Custom",                                // 1a
35
  "A Custom",                                // 1b
36
  "A Custom",                                // 1c
37
  "A Custom",                                // 1d
38
  "A Custom",                                // 1e
39
  "A Custom",                                // 1f
40
};
41
 
42 489 julius
extern void int_main(void);
43
extern void cpu_timer_tick(void);
44 349 julius
 
45 489 julius
void (*except_handlers[]) (void)  = {0,    // 0
46 349 julius
                                    0,    // 1
47
                                    0,    // 2
48
                                    0,    // 3
49
                                    0,    // 4
50 488 julius
                                    cpu_timer_tick,    // 5
51 349 julius
                                    0,    // 6
52
                                    0,    // 7
53
                                    int_main,    // 8
54
                                    0,    // 9
55
                                    0,    // a
56
                                    0,    // b
57
                                    0,    // c
58
                                    0,    // d
59
                                    0,    // e
60
                                    0,    // f
61
                                    0,    // 10
62
                                    0,    // 11
63
                                    0,    // 12
64
                                    0};    // 13
65
 
66
 
67
void
68 489 julius
add_handler(unsigned long vector, void (*handler) (void))
69 349 julius
{
70
  except_handlers[vector] = handler;
71
}
72
 
73 489 julius
void
74
default_exception_handler_c(unsigned exception_address,unsigned epc)
75 349 julius
{
76
  int exception_no = (exception_address >> 8) & 0x1f;
77
  if (except_handlers[exception_no])
78
    {
79 489 julius
            (*except_handlers[exception_no])();
80
            return;
81 349 julius
    }
82
 
83 489 julius
  // init uart here, incase it hasn't been
84 349 julius
  uart_init(DEFAULT_UART);
85
 
86
  printf("EPC = 0x%.8x\n", exception_address);
87
 
88
  // Output initial messaging using low-level functions incase
89
  // something really bad happened.
90
  printf("%s%s", exception_strings[exception_no],
91
         STR_EXCEPTION_OCCURED);
92
 
93
  // Icing on the cake using fancy functions
94
  printf("EPC = 0x%.8x\n", epc);
95
  report(exception_address);
96
  report(epc);
97
  __asm__("l.nop 1");
98
  for(;;);
99
}
100
 

powered by: WebSVN 2.1.0

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