annotate packages/kernel/current/src/common/except.cxx @ 2863:7d8c61e6225c default tip

* Added execute permissions to files missed in conversion from CVS
author alexs
date Thu, 26 Mar 2009 20:39:18 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
3 // common/except.cxx
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
5 // Exception handling implementation
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
6 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
16 // version.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
21 // for more details.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
33 // General Public License v2.
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 210
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
39 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
42 // Author(s): nickg
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
43 // Contributors: nickg, jlarmour
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
44 // Date: 1999-02-16
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
45 // Purpose: Exception handling implementation
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
46 // Description: This file contains the code that registers and delivers
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
47 // exceptions.
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
48 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
49 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 #include <pkgconf/kernel.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55 #include <cyg/kernel/ktypes.h> // base kernel types
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56 #include <cyg/infra/cyg_trac.h> // tracing macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57 #include <cyg/infra/cyg_ass.h> // assertion macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58 #include <cyg/kernel/instrmnt.h> // instrumentation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60 #include <cyg/kernel/except.hxx> // our header
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62 #include <cyg/hal/hal_arch.h> // architecture definitions
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63 #include <cyg/hal/hal_intr.h> // vector definitions
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 #include <cyg/kernel/thread.hxx> // thread interface
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67 #include <cyg/kernel/thread.inl> // thread inlines
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69 #ifdef CYGPKG_KERNEL_EXCEPTIONS
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
70
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 // Null exception handler. This is used to capture exceptions that are
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73 // not caught by user supplied handlers.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
75 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
76 cyg_null_exception_handler(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77 CYG_ADDRWORD data, // user supplied data
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78 cyg_code exception_number, // exception being raised
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79 CYG_ADDRWORD exception_info // any exception specific info
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
82 CYG_REPORT_FUNCTION();
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
83 CYG_REPORT_FUNCARG3("data=%08x, exception=%d, info=%08x", data,
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
84 exception_number, exception_info);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85 CYG_TRACE1( 1, "Uncaught exception: %d", exception_number);
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
86 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90 // Exception Controller constructor.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92 Cyg_Exception_Control::Cyg_Exception_Control()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
94 CYG_REPORT_FUNCTION();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
97 for( int i = 0; i < CYGNUM_HAL_EXCEPTION_COUNT ; i++ )
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98 exception_handler[i] = cyg_null_exception_handler,
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99 exception_data[i] = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 exception_handler = cyg_null_exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103 exception_data = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105 #endif
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
106 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110 // Exception registation. Stores the handler function and data to be used
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111 // for handling the given exception number. Where exceptions are not decoded
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112 // only a single handler may be registered for all exceptions. This function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 // also returns the old values of the exception handler and data to allow
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 // chaining to be implemented.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
116 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
117 Cyg_Exception_Control::register_exception(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 cyg_code exception_number, // exception number
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 cyg_exception_handler handler, // handler function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120 CYG_ADDRWORD data, // data argument
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
121 cyg_exception_handler **old_handler, // handler function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 CYG_ADDRWORD *old_data // data argument
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
123 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125 CYG_REPORT_FUNCTION();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
126 CYG_REPORT_FUNCARG5("exception=%d, handler func=%08x, data=%08x, "
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
127 "space for old handler=%08x,space for old data=%08x",
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
128 exception_number, handler, data, old_handler,
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
129 old_data);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
131 CYG_ASSERT( exception_number <= CYGNUM_HAL_EXCEPTION_MAX,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132 "Out of range exception number");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
133 CYG_ASSERT( exception_number >= CYGNUM_HAL_EXCEPTION_MIN,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 "Out of range exception number");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
136
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
137 // Should we complain if there is already a registered
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
138 // handler, or should we just replace is silently?
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
139
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
140 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142 if( old_handler != NULL )
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
143 *old_handler = exception_handler[exception_number -
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
144 CYGNUM_HAL_EXCEPTION_MIN];
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 if( old_data != NULL )
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
146 *old_data = exception_data[exception_number -
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
147 CYGNUM_HAL_EXCEPTION_MIN];
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
148 exception_handler[exception_number - CYGNUM_HAL_EXCEPTION_MIN] = handler;
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
149 exception_data[exception_number - CYGNUM_HAL_EXCEPTION_MIN] = data;
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
151 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
152
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
153 if( old_handler != NULL )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
154 *old_handler = exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
155 if( old_data != NULL )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
156 *old_data = exception_data;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
157 exception_handler = handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
158 exception_data = data;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
159
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
160 #endif
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
161 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
162 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
163
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
164 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
165 // Exception deregistation. Revert the handler for the exception number
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
166 // to the default.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
167
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
168 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
169 Cyg_Exception_Control::deregister_exception(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
170 cyg_code exception_number // exception number
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
171 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
172 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
173 CYG_REPORT_FUNCTION();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
174 CYG_REPORT_FUNCARG1("exception number=%d", exception_number);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
175
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
176 CYG_ASSERT( exception_number <= CYGNUM_HAL_EXCEPTION_MAX,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
177 "Out of range exception number");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
178 CYG_ASSERT( exception_number >= CYGNUM_HAL_EXCEPTION_MIN,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
179 "Out of range exception number");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
180
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
181 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
182
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
183 exception_handler[exception_number - CYGNUM_HAL_EXCEPTION_MIN] =
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
184 cyg_null_exception_handler;
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
185 exception_data[exception_number - CYGNUM_HAL_EXCEPTION_MIN] = 0;
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
186
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
187 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
188
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
189 exception_handler = cyg_null_exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
190 exception_data = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
191
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
192 #endif
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
193
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
194 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
195 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
196
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
197 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
198 // Exception delivery. Call the appropriate exception handler.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
199
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
200 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
201 Cyg_Exception_Control::deliver_exception(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
202 cyg_code exception_number, // exception being raised
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
203 CYG_ADDRWORD exception_info // exception specific info
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
204 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
205 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
206 CYG_REPORT_FUNCTION();
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
207 CYG_REPORT_FUNCARG2("exception number=%d, exception info=%08x",
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
208 exception_number, exception_info);
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
209
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
210 cyg_exception_handler *handler = NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
211 CYG_ADDRWORD data = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
212
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
213 CYG_ASSERT( exception_number <= CYGNUM_HAL_EXCEPTION_MAX,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
214 "Out of range exception number");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
215 CYG_ASSERT( exception_number >= CYGNUM_HAL_EXCEPTION_MIN,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
216 "Out of range exception number");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
217
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
218 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
219
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
220 handler = exception_handler[exception_number - CYGNUM_HAL_EXCEPTION_MIN];
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
221 data = exception_data[exception_number - CYGNUM_HAL_EXCEPTION_MIN];
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
222
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
223 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
224
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
225 handler = exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
226 data = exception_data;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
227
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
228 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
229
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
230 // The handler will always be a callable function: either the user's
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
231 // registered function or the null handler. So it is always safe to
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
232 // just go ahead and call it.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
233
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
234 handler( data, exception_number, exception_info );
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
235
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
236 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
237 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
238
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
239 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
240 // Exception delivery function called from the HAL as a result of a
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
241 // hardware exception being raised.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
242
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
243 externC void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
244 cyg_hal_deliver_exception( CYG_WORD code, CYG_ADDRWORD data )
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
245 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
246 CYG_REPORT_FUNCTION();
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
247 Cyg_Thread::self()->deliver_exception( (cyg_code)code, data );
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
248 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
249 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
250
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
251 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
252 // Where exceptions are global, there is a single static instance of the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
253 // exception control object. Define it here.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
254
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
255 #ifdef CYGSEM_KERNEL_EXCEPTIONS_GLOBAL
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
256
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
257 Cyg_Exception_Control Cyg_Thread::exception_control
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
258 CYG_INIT_PRIORITY(INTERRUPTS);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
259
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
260 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
261
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
262 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
263
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
264 #endif // ifdef CYGPKG_KERNEL_EXCEPTIONS
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
265
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
266 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
267 // EOF common/except.cxx