source: soft/giet_vm/sys/exc_handler.c @ 189

Last change on this file since 189 was 189, checked in by alain, 12 years ago

Introducing a new release where all initialisation
is done in the boot code.

File size: 3.5 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : exc_handler.c
3// Date     : 01/04/2012
4// Author   : alain greiner and joel porquet
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The exc_handler.c and exc_handler.h files are part of the GIET nano-kernel.
8// They contains the exception handler code.
9///////////////////////////////////////////////////////////////////////////////////
10
11#include <exc_handler.h>
12#include <sys_handler.h>
13#include <drivers.h>
14#include <common.h>
15
16///////////////////////////////////////////////////////////////////////////////////
17// Prototypes of exception handlers.
18///////////////////////////////////////////////////////////////////////////////////
19
20static void _cause_ukn();
21static void _cause_adel();
22static void _cause_ades();
23static void _cause_ibe();
24static void _cause_dbe();
25static void _cause_bp();
26static void _cause_ri();
27static void _cause_cpu();
28static void _cause_ovf();
29
30extern void _int_handler();
31extern void _sys_handler();
32
33///////////////////////////////////////////////////////////////////////////////////
34// Initialize the exception vector indexed by the CR XCODE field
35///////////////////////////////////////////////////////////////////////////////////
36const _exc_func_t _cause_vector[16] = {
37    &_int_handler,  /* 0000 : external interrupt */
38    &_cause_ukn,    /* 0001 : undefined exception */
39    &_cause_ukn,    /* 0010 : undefined exception */
40    &_cause_ukn,    /* 0011 : undefined exception */
41    &_cause_adel,   /* 0100 : illegal address read exception */
42    &_cause_ades,   /* 0101 : illegal address write exception */
43    &_cause_ibe,    /* 0110 : instruction bus error exception */
44    &_cause_dbe,    /* 0111 : data bus error exception */
45    &_sys_handler,  /* 1000 : system call */
46    &_cause_bp,     /* 1001 : breakpoint exception */
47    &_cause_ri,     /* 1010 : illegal codop exception */
48    &_cause_cpu,    /* 1011 : illegal coprocessor access */
49    &_cause_ovf,    /* 1100 : arithmetic overflow exception */
50    &_cause_ukn,    /* 1101 : undefined exception */
51    &_cause_ukn,    /* 1110 : undefined exception */
52    &_cause_ukn,    /* 1111 : undefined exception */
53};
54
55static const char *exc_message_causes[] = {
56    "\n\nException : strange unknown cause\n",
57    "\n\nException : illegal read address \n",
58    "\n\nException : illegal write address\n",
59    "\n\nException : inst bus error       \n",
60    "\n\nException : data bus error       \n",
61    "\n\nException : breakpoint           \n",
62    "\n\nException : reserved instruction \n",
63    "\n\nException : illegal coproc access\n"
64    "\n\nException : arithmetic overflow  \n",
65};
66
67static void _cause(unsigned int msg_cause)
68{
69    _puts( (char*)(exc_message_causes[msg_cause]) );
70    _puts("\n - Cycle     : ");
71    _putd( _proctime() );
72    _puts("\n - Processor : ");
73    _putd( _procid() );
74    _puts("\n - Task      : ");
75    _putd( _get_current_task_id() );
76    _puts("\n - EPC       : ");
77    _putw( _get_epc() );
78    _puts("\n - BVAR      : ");
79    _putw( _get_bvar() );
80    _puts("\n");
81    _exit();
82}
83
84static void _cause_ukn()  { _cause(0); }
85static void _cause_adel() { _cause(1); }
86static void _cause_ades() { _cause(2); }
87static void _cause_ibe()  { _cause(3); }
88static void _cause_dbe()  { _cause(4); }
89static void _cause_bp()   { _cause(5); }
90static void _cause_ri()   { _cause(6); }
91static void _cause_cpu()  { _cause(7); }
92static void _cause_ovf()  { _cause(8); }
93
Note: See TracBrowser for help on using the repository browser.