annotate packages/kernel/current/src/common/except.cxx @ 208:e0c0827131d1 ecos

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