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

Subversion Repositories openrisc

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

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
extern void int_main();
43
 
44 411 julius
void (*except_handlers[]) (void ) = {0,    // 0
45 349 julius
                                    0,    // 1
46
                                    0,    // 2
47
                                    0,    // 3
48
                                    0,    // 4
49
                                    0,    // 5
50
                                    0,    // 6
51
                                    0,    // 7
52
                                    int_main,    // 8
53
                                    0,    // 9
54
                                    0,    // a
55
                                    0,    // b
56
                                    0,    // c
57
                                    0,    // d
58
                                    0,    // e
59
                                    0,    // f
60
                                    0,    // 10
61
                                    0,    // 11
62
                                    0,    // 12
63
                                    0};    // 13
64
 
65
 
66
void
67 411 julius
add_handler(unsigned long vector, void (*handler) (void *))
68 349 julius
{
69
  except_handlers[vector] = handler;
70
}
71
 
72
void default_exception_handler_c(unsigned exception_address,unsigned epc)
73
{
74
  int exception_no = (exception_address >> 8) & 0x1f;
75
  if (except_handlers[exception_no])
76
    {
77
      return (*except_handlers[exception_no])();
78
    }
79
 
80
  // Init uart here, incase it hasn't been
81
  uart_init(DEFAULT_UART);
82
 
83
  printf("EPC = 0x%.8x\n", exception_address);
84
 
85
  // Output initial messaging using low-level functions incase
86
  // something really bad happened.
87
  printf("%s%s", exception_strings[exception_no],
88
         STR_EXCEPTION_OCCURED);
89
 
90
  // Icing on the cake using fancy functions
91
  printf("EPC = 0x%.8x\n", epc);
92
  report(exception_address);
93
  report(epc);
94
  __asm__("l.nop 1");
95
  for(;;);
96
}
97
 

powered by: WebSVN 2.1.0

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