source: soft/giet_vm/giet_kernel/exc_handler.c @ 264

Last change on this file since 264 was 258, checked in by alain, 11 years ago

This is a major release, including a deep restructuration of code.
The main evolutions are

  • use of the Tsar preloader to load the GIET boot-loader from disk
  • introduction of a FAT32 file system library,
  • use of this fat32 library by the boot-loader to load the map.bin data structure, and the various .elf files
  • reorganisation of drivers (one file per peripheral).
  • introduction of drivers for new peripherals: vci_chbuf_dma and vci_multi_ahci.
  • introduction of a new physical memory allocator in the boot code.

This release has been tested on the tsar_generic_iob architecture,
for the two following mappings: 4c_1p_iob_four.xml and 4c_1p_iob_sort.xml

  • Property svn:executable set to *
File size: 3.8 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 <ctx_handler.h>
13#include <sys_handler.h>
14#include <tty_driver.h>
15#include <utils.h>
16
17///////////////////////////////////////////////////////////////////////////////////
18// Prototypes of exception handlers.
19///////////////////////////////////////////////////////////////////////////////////
20
21static void _cause_ukn();
22static void _cause_adel();
23static void _cause_ades();
24static void _cause_ibe();
25static void _cause_dbe();
26static void _cause_bp();
27static void _cause_ri();
28static void _cause_cpu();
29static void _cause_ovf();
30
31extern void _int_handler();
32extern void _sys_handler();
33
34///////////////////////////////////////////////////////////////////////////////////
35// Initialize the exception vector indexed by the CR XCODE field
36///////////////////////////////////////////////////////////////////////////////////
37const _exc_func_t _cause_vector[16] = 
38{
39    &_int_handler,  /* 0000 : external interrupt */
40    &_cause_ukn,    /* 0001 : undefined exception */
41    &_cause_ukn,    /* 0010 : undefined exception */
42    &_cause_ukn,    /* 0011 : undefined exception */
43    &_cause_adel,   /* 0100 : illegal address read exception */
44    &_cause_ades,   /* 0101 : illegal address write exception */
45    &_cause_ibe,    /* 0110 : instruction bus error exception */
46    &_cause_dbe,    /* 0111 : data bus error exception */
47    &_sys_handler,  /* 1000 : system call */
48    &_cause_bp,     /* 1001 : breakpoint exception */
49    &_cause_ri,     /* 1010 : illegal codop exception */
50    &_cause_cpu,    /* 1011 : illegal coprocessor access */
51    &_cause_ovf,    /* 1100 : arithmetic overflow exception */
52    &_cause_ukn,    /* 1101 : undefined exception */
53    &_cause_ukn,    /* 1110 : undefined exception */
54    &_cause_ukn,    /* 1111 : undefined exception */
55};
56
57static const char * exc_type[] = 
58{
59    "strange unknown cause",
60    "illegal read address",
61    "illegal write address",
62    "inst bus error",
63    "data bus error",
64    "breakpoint",
65    "reserved instruction",
66    "illegal coproc access",
67    "arithmetic overflow",
68};
69
70
71static void _display_cause(unsigned int type) 
72{
73    _tty_get_lock( 0 );
74    _puts("\n[GIET] Exception for task ");
75    _putd(_get_context_slot(CTX_LTID_ID));
76    _puts(" on processor ");
77    _putd(_get_procid());
78    _puts(" at cycle ");
79    _putd(_get_proctime());
80    _puts("\n - type      : ");
81    _puts((char *) exc_type[type]);
82    _puts("\n - EPC       : ");
83    _putx(_get_epc());
84    _puts("\n - BVAR      : ");
85    _putx(_get_bvar());
86    _puts("\n");
87    _puts("...Task desactivated\n");
88    _tty_release_lock( 0 );
89
90    // goes to sleeping state
91    _set_context_slot(CTX_RUN_ID, 0);
92
93    // deschedule
94    _ctx_switch();
95}
96
97static void _cause_ukn()  { _display_cause(0); }
98static void _cause_adel() { _display_cause(1); }
99static void _cause_ades() { _display_cause(2); }
100static void _cause_ibe()  { _display_cause(3); }
101static void _cause_dbe()  { _display_cause(4); }
102static void _cause_bp()   { _display_cause(5); }
103static void _cause_ri()   { _display_cause(6); }
104static void _cause_cpu()  { _display_cause(7); }
105static void _cause_ovf()  { _display_cause(8); }
106
107// Local Variables:
108// tab-width: 4
109// c-basic-offset: 4
110// c-file-offsets:((innamespace . 0)(inline-open . 0))
111// indent-tabs-mode: nil
112// End:
113// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
114
Note: See TracBrowser for help on using the repository browser.