OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [drivers/] [or1200/] [exceptions.c] - Diff between revs 488 and 489

Only display areas with differences | Details | Blame | View Log

Rev 488 Rev 489
#include "or1200-utils.h"
#include "or1200-utils.h"
#include "int.h" // User interrupt handler header
#include "int.h" // User interrupt handler header
#include "uart.h"
#include "uart.h"
#include "printf.h"
#include "printf.h"
 
 
#define STR_EXCEPTION_OCCURED " exception occured.\n"
#define STR_EXCEPTION_OCCURED " exception occured.\n"
 
 
char *exception_strings[] = {
char *exception_strings[] = {
  "An unknown",             // 0
  "An unknown",             // 0
  "A reset (?!)",           // 1 
  "A reset (?!)",           // 1 
  "A Bus Error",            // 2
  "A Bus Error",            // 2
  "A Data Page Fault",      // 3
  "A Data Page Fault",      // 3
  "An Instruction Page Fault", // 4
  "An Instruction Page Fault", // 4
  "A Tick-Timer",              // 5
  "A Tick-Timer",              // 5
  "An Alignment",              // 6
  "An Alignment",              // 6
  "An Illegal Instruction",    // 7
  "An Illegal Instruction",    // 7
  "An External Interrupt",     // 8
  "An External Interrupt",     // 8
  "A D-TLB Miss",              // 9
  "A D-TLB Miss",              // 9
  "An I-TLB Miss",             // a
  "An I-TLB Miss",             // a
  "A Range",                   // b
  "A Range",                   // b
  "A System Call",             // c
  "A System Call",             // c
  "A Floating-Point",          // d
  "A Floating-Point",          // d
  "A Trap",                    // e
  "A Trap",                    // e
  "A \"Reserved\"",            // f
  "A \"Reserved\"",            // f
  "A \"Reserved\"",            // 10
  "A \"Reserved\"",            // 10
  "A \"Reserved\"",            // 11
  "A \"Reserved\"",            // 11
  "A \"Reserved\"",            // 12
  "A \"Reserved\"",            // 12
  "A \"Reserved\"",            // 13
  "A \"Reserved\"",            // 13
  "A \"Reserved\"",            // 14
  "A \"Reserved\"",            // 14
  "An Implementation Specific \"Reserved\"", // 16
  "An Implementation Specific \"Reserved\"", // 16
  "An Implementation Specific \"Reserved\"", // 17
  "An Implementation Specific \"Reserved\"", // 17
  "An Implementation Specific \"Reserved\"", // 18
  "An Implementation Specific \"Reserved\"", // 18
  "A Custom",                                // 19
  "A Custom",                                // 19
  "A Custom",                                // 1a
  "A Custom",                                // 1a
  "A Custom",                                // 1b
  "A Custom",                                // 1b
  "A Custom",                                // 1c
  "A Custom",                                // 1c
  "A Custom",                                // 1d
  "A Custom",                                // 1d
  "A Custom",                                // 1e
  "A Custom",                                // 1e
  "A Custom",                                // 1f
  "A Custom",                                // 1f
};
};
 
 
extern void int_main();
extern void int_main(void);
extern void cpu_timer_tick();
extern void cpu_timer_tick(void);
 
 
void (*except_handlers[]) (void ) = {0,    // 0
void (*except_handlers[]) (void)  = {0,    // 0
                                    0,    // 1
                                    0,    // 1
                                    0,    // 2
                                    0,    // 2
                                    0,    // 3
                                    0,    // 3
                                    0,    // 4
                                    0,    // 4
                                    cpu_timer_tick,    // 5
                                    cpu_timer_tick,    // 5
                                    0,    // 6
                                    0,    // 6
                                    0,    // 7
                                    0,    // 7
                                    int_main,    // 8
                                    int_main,    // 8
                                    0,    // 9
                                    0,    // 9
                                    0,    // a
                                    0,    // a
                                    0,    // b
                                    0,    // b
                                    0,    // c
                                    0,    // c
                                    0,    // d
                                    0,    // d
                                    0,    // e
                                    0,    // e
                                    0,    // f
                                    0,    // f
                                    0,    // 10
                                    0,    // 10
                                    0,    // 11
                                    0,    // 11
                                    0,    // 12
                                    0,    // 12
                                    0};    // 13
                                    0};    // 13
 
 
 
 
void
void
add_handler(unsigned long vector, void (*handler) (void *))
add_handler(unsigned long vector, void (*handler) (void))
{
{
  except_handlers[vector] = handler;
  except_handlers[vector] = handler;
}
}
 
 
void default_exception_handler_c(unsigned exception_address,unsigned epc)
void
 
default_exception_handler_c(unsigned exception_address,unsigned epc)
{
{
  int exception_no = (exception_address >> 8) & 0x1f;
  int exception_no = (exception_address >> 8) & 0x1f;
  if (except_handlers[exception_no])
  if (except_handlers[exception_no])
    {
    {
      return (*except_handlers[exception_no])();
            (*except_handlers[exception_no])();
 
            return;
    }
    }
 
 
  // Init uart here, incase it hasn't been
  // init uart here, incase it hasn't been
  uart_init(DEFAULT_UART);
  uart_init(DEFAULT_UART);
 
 
  printf("EPC = 0x%.8x\n", exception_address);
  printf("EPC = 0x%.8x\n", exception_address);
 
 
  // Output initial messaging using low-level functions incase
  // Output initial messaging using low-level functions incase
  // something really bad happened.
  // something really bad happened.
  printf("%s%s", exception_strings[exception_no],
  printf("%s%s", exception_strings[exception_no],
         STR_EXCEPTION_OCCURED);
         STR_EXCEPTION_OCCURED);
 
 
  // Icing on the cake using fancy functions
  // Icing on the cake using fancy functions
  printf("EPC = 0x%.8x\n", epc);
  printf("EPC = 0x%.8x\n", epc);
  report(exception_address);
  report(exception_address);
  report(epc);
  report(epc);
  __asm__("l.nop 1");
  __asm__("l.nop 1");
  for(;;);
  for(;;);
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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