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

Subversion Repositories openrisc

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

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 488 julius
extern void cpu_timer_tick();
44 349 julius
 
45 411 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 411 julius
add_handler(unsigned long vector, void (*handler) (void *))
69 349 julius
{
70
  except_handlers[vector] = handler;
71
}
72
 
73
void default_exception_handler_c(unsigned exception_address,unsigned epc)
74
{
75
  int exception_no = (exception_address >> 8) & 0x1f;
76
  if (except_handlers[exception_no])
77
    {
78
      return (*except_handlers[exception_no])();
79
    }
80
 
81
  // Init uart here, incase it hasn't been
82
  uart_init(DEFAULT_UART);
83
 
84
  printf("EPC = 0x%.8x\n", exception_address);
85
 
86
  // Output initial messaging using low-level functions incase
87
  // something really bad happened.
88
  printf("%s%s", exception_strings[exception_no],
89
         STR_EXCEPTION_OCCURED);
90
 
91
  // Icing on the cake using fancy functions
92
  printf("EPC = 0x%.8x\n", epc);
93
  report(exception_address);
94
  report(epc);
95
  __asm__("l.nop 1");
96
  for(;;);
97
}
98
 

powered by: WebSVN 2.1.0

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