Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Paolo Gai <pj@gandalf.sssup.it> |
||
10 | * (see the web pages for full authors list) |
||
11 | * |
||
12 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
13 | * |
||
14 | * http://www.sssup.it |
||
15 | * http://retis.sssup.it |
||
16 | * http://shark.sssup.it |
||
17 | */ |
||
18 | |||
19 | /** |
||
20 | ------------ |
||
21 | CVS : $Id: exchgrx.c,v 1.1.1.1 2002-03-29 14:12:52 pj Exp $ |
||
22 | |||
23 | File: $File$ |
||
24 | Revision: $Revision: 1.1.1.1 $ |
||
25 | Last update: $Date: 2002-03-29 14:12:52 $ |
||
26 | ------------ |
||
27 | **/ |
||
28 | |||
29 | /* |
||
30 | * Copyright (C) 2000 Paolo Gai |
||
31 | * |
||
32 | * This program is free software; you can redistribute it and/or modify |
||
33 | * it under the terms of the GNU General Public License as published by |
||
34 | * the Free Software Foundation; either version 2 of the License, or |
||
35 | * (at your option) any later version. |
||
36 | * |
||
37 | * This program is distributed in the hope that it will be useful, |
||
38 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
39 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
40 | * GNU General Public License for more details. |
||
41 | * |
||
42 | * You should have received a copy of the GNU General Public License |
||
43 | * along with this program; if not, write to the Free Software |
||
44 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
45 | * |
||
46 | */ |
||
47 | |||
48 | #include <kernel/kern.h> |
||
49 | |||
50 | static int myflag; |
||
51 | static siginfo_t myinfo; |
||
52 | static struct timespec mytime; |
||
53 | |||
54 | static void thehandler(int signo, siginfo_t *info, void *extra); |
||
55 | static void theend(void *arg); |
||
56 | |||
57 | /* |
||
58 | This exception handler should be good for text applications that do NOT |
||
59 | use graphics |
||
60 | */ |
||
61 | int set_exchandler_grx(void) |
||
62 | { |
||
63 | struct sigaction action; |
||
64 | |||
65 | myflag = 0; |
||
66 | |||
67 | sys_atrunlevel(theend, NULL, RUNLEVEL_AFTER_EXIT); |
||
68 | |||
69 | /* Init the standard S.Ha.R.K. exception handler */ |
||
70 | action.sa_flags = SA_SIGINFO; /* Set the signal action */ |
||
71 | action.sa_sigaction = thehandler; |
||
72 | action.sa_handler = 0; |
||
73 | sigfillset(&action.sa_mask); /* we block all the other signals... */ |
||
74 | |||
75 | return sigaction(SIGHEXC, &action, NULL); /* set the signal */ |
||
76 | } |
||
77 | |||
78 | void thehandler(int signo, siginfo_t *info, void *extra) |
||
79 | { |
||
80 | if (!myflag) { |
||
81 | myflag = 1; |
||
82 | myinfo = *info; |
||
83 | sys_gettime(&mytime), |
||
84 | |||
85 | sys_abort(AHEXC); |
||
86 | } |
||
87 | } |
||
88 | |||
89 | void theend(void *arg) |
||
90 | { |
||
91 | if (myflag) { |
||
92 | kern_printf("\nS.Ha.R.K. Exception raised!!!" |
||
93 | "\nTime (s:ns) :%d:%d" |
||
94 | "\nException number:%d" |
||
95 | "\nPID :%d\n", |
||
96 | mytime.tv_sec, |
||
97 | mytime.tv_nsec, |
||
98 | myinfo.si_value.sival_int, |
||
99 | myinfo.si_task); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | |||
104 |