annotate packages/kernel/current/src/common/except.cxx @ 2:443894e2e912 ecos-v1_2_1-release

Block commit of eCos version 1.2.1
author jlarmour
date Tue, 11 May 1999 12:24:34 +0000
parents 3111d98ba7b3
children c38311975d4f
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 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
8 //####COPYRIGHTBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
9 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
10 // -------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
11 // The contents of this file are subject to the Cygnus eCos Public License
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
12 // Version 1.0 (the "License"); you may not use this file except in
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
13 // compliance with the License. You may obtain a copy of the License at
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
14 // http://sourceware.cygnus.com/ecos
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
15 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
16 // Software distributed under the License is distributed on an "AS IS"
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
18 // License for the specific language governing rights and limitations under
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
19 // the License.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
20 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
21 // The Original Code is eCos - Embedded Cygnus Operating System, released
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
22 // September 30, 1998.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
23 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
24 // The Initial Developer of the Original Code is Cygnus. Portions created
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
26 // -------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
27 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
28 //####COPYRIGHTEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
29 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
30 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
31 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
32 // Author(s): nickg
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
33 // Contributors: nickg, jlarmour
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
34 // Date: 1999-02-16
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
35 // Purpose: Exception handling implementation
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
36 // Description: This file contains the code that registers and delivers
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
37 // exceptions.
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
38 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
39 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
43 #include <pkgconf/kernel.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
44
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
45 #include <cyg/kernel/ktypes.h> // base kernel types
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
46 #include <cyg/infra/cyg_trac.h> // tracing macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
47 #include <cyg/infra/cyg_ass.h> // assertion macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
48 #include <cyg/kernel/instrmnt.h> // instrumentation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
49
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 #include <cyg/kernel/except.hxx> // our header
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 #include <cyg/hal/hal_arch.h> // architecture definitions
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 #include <cyg/hal/hal_intr.h> // vector definitions
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/thread.hxx> // thread interface
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57 #include <cyg/kernel/thread.inl> // thread inlines
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59 #ifdef CYGPKG_KERNEL_EXCEPTIONS
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60
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 // Null exception handler. This is used to capture exceptions that are
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63 // not caught by user supplied handlers.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
65 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
66 cyg_null_exception_handler(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67 CYG_ADDRWORD data, // user supplied data
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 cyg_code exception_number, // exception being raised
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69 CYG_ADDRWORD exception_info // any exception specific info
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 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
72 CYG_REPORT_FUNCTION();
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
73 CYG_REPORT_FUNCARG3("data=%08x, exception=%d, info=%08x", data,
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
74 exception_number, exception_info);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75 CYG_TRACE1( 1, "Uncaught exception: %d", exception_number);
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
76 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80 // Exception Controller constructor.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 Cyg_Exception_Control::Cyg_Exception_Control()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
84 CYG_REPORT_FUNCTION();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
87 for( int i = 0; i < CYGNUM_HAL_EXCEPTION_COUNT ; i++ )
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88 exception_handler[i] = cyg_null_exception_handler,
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 exception_data[i] = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90 #else
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 exception_handler = cyg_null_exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93 exception_data = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
94
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95 #endif
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
96 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
100 // Exception registation. Stores the handler function and data to be used
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101 // for handling the given exception number. Where exceptions are not decoded
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 // only a single handler may be registered for all exceptions. This function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103 // 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
104 // chaining to be implemented.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
106 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
107 Cyg_Exception_Control::register_exception(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108 cyg_code exception_number, // exception number
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109 cyg_exception_handler handler, // handler function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110 CYG_ADDRWORD data, // data argument
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111 cyg_exception_handler **old_handler, // handler function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112 CYG_ADDRWORD *old_data // data argument
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 CYG_REPORT_FUNCTION();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
116 CYG_REPORT_FUNCARG5("exception=%d, handler func=%08x, data=%08x, "
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
117 "space for old handler=%08x,space for old data=%08x",
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
118 exception_number, handler, data, old_handler,
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
119 old_data);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
121 CYG_ASSERT( exception_number <= CYGNUM_HAL_EXCEPTION_MAX,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 "Out of range exception number");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
123 CYG_ASSERT( exception_number >= CYGNUM_HAL_EXCEPTION_MIN,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 "Out of range exception number");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
126
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127 // Should we complain if there is already a registered
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
128 // handler, or should we just replace is silently?
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132 if( old_handler != NULL )
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
133 *old_handler = exception_handler[exception_number -
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
134 CYGNUM_HAL_EXCEPTION_MIN];
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135 if( old_data != NULL )
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
136 *old_data = exception_data[exception_number -
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
137 CYGNUM_HAL_EXCEPTION_MIN];
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
138 exception_handler[exception_number - CYGNUM_HAL_EXCEPTION_MIN] = handler;
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
139 exception_data[exception_number - CYGNUM_HAL_EXCEPTION_MIN] = data;
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
140
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
143 if( old_handler != NULL )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144 *old_handler = exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 if( old_data != NULL )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146 *old_data = exception_data;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147 exception_handler = handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148 exception_data = data;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150 #endif
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
151 CYG_REPORT_RETURN();
0
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
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
154 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
155 // Exception deregistation. Revert the handler for the exception number
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
156 // to the default.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
157
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
158 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
159 Cyg_Exception_Control::deregister_exception(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
160 cyg_code exception_number // exception number
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
161 )
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 CYG_REPORT_FUNCTION();
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
164 CYG_REPORT_FUNCARG1("exception number=%d", exception_number);
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
165
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
166 CYG_ASSERT( exception_number <= CYGNUM_HAL_EXCEPTION_MAX,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
167 "Out of range exception number");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
168 CYG_ASSERT( exception_number >= CYGNUM_HAL_EXCEPTION_MIN,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
169 "Out of range exception number");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
170
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
171 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
172
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
173 exception_handler[exception_number - CYGNUM_HAL_EXCEPTION_MIN] =
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
174 cyg_null_exception_handler;
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
175 exception_data[exception_number - CYGNUM_HAL_EXCEPTION_MIN] = 0;
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
176
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
177 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
178
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
179 exception_handler = cyg_null_exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
180 exception_data = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
181
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
182 #endif
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
183
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
184 CYG_REPORT_RETURN();
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
185 }
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 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
188 // Exception delivery. Call the appropriate exception handler.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
189
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
190 void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
191 Cyg_Exception_Control::deliver_exception(
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
192 cyg_code exception_number, // exception being raised
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
193 CYG_ADDRWORD exception_info // exception specific info
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
194 )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
195 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
196 CYG_REPORT_FUNCTION();
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
197 CYG_REPORT_FUNCARG2("exception number=%d, exception info=%08x",
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
198 exception_number, exception_info);
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
199
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
200 cyg_exception_handler *handler = NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
201 CYG_ADDRWORD data = 0;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
202
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
203 CYG_ASSERT( exception_number <= CYGNUM_HAL_EXCEPTION_MAX,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
204 "Out of range exception number");
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
205 CYG_ASSERT( exception_number >= CYGNUM_HAL_EXCEPTION_MIN,
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
206 "Out of range exception number");
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
207
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
208 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
209
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
210 handler = exception_handler[exception_number - CYGNUM_HAL_EXCEPTION_MIN];
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
211 data = exception_data[exception_number - CYGNUM_HAL_EXCEPTION_MIN];
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
212
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
213 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
214
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
215 handler = exception_handler;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
216 data = exception_data;
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 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
219
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
220 // The handler will always be a callable function: either the user's
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
221 // registered function or the null handler. So it is always safe to
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
222 // just go ahead and call it.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
223
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
224 handler( data, exception_number, exception_info );
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
225
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
226 CYG_REPORT_RETURN();
0
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
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 // Exception delivery function called from the HAL as a result of a
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
231 // hardware exception being raised.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
232
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
233 externC void
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
234 cyg_hal_deliver_exception( CYG_WORD code, CYG_ADDRWORD data )
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
235 {
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
236 CYG_REPORT_FUNCTION();
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
237 Cyg_Thread::self()->deliver_exception( (cyg_code)code, data );
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
238 CYG_REPORT_RETURN();
0
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
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
241 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
242 // Where exceptions are global, there is a single static instance of the
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
243 // exception control object. Define it here.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
244
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
245 #ifdef CYGSEM_KERNEL_EXCEPTIONS_GLOBAL
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
246
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
247 Cyg_Exception_Control Cyg_Thread::exception_control
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
248 CYG_INIT_PRIORITY(INTERRUPTS);
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 #endif
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 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
253
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
254 #endif // ifdef CYGPKG_KERNEL_EXCEPTIONS
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
255
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
256 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
257 // EOF common/except.cxx