comparison packages/kernel/current/tests/except1.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 1d7f19c9e4d1
comparison
equal deleted inserted replaced
1:72f549f0d891 2:443894e2e912
20 // 20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released 21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998. 22 // September 30, 1998.
23 // 23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created 24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.
26 // ------------------------------------------- 26 // -------------------------------------------
27 // 27 //
28 //####COPYRIGHTEND#### 28 //####COPYRIGHTEND####
29 //================================================================= 29 //=================================================================
30 //#####DESCRIPTIONBEGIN#### 30 //#####DESCRIPTIONBEGIN####
31 // 31 //
32 // Author(s): dsm 32 // Author(s): dsm
33 // Contributors: dsm 33 // Contributors: dsm, jlarmour
34 // Date: 1998-06-15 34 // Date: 1999-02-16
35 // Description: Test basic exception functionality 35 // Description: Test basic exception functionality
36 //####DESCRIPTIONEND#### 36 //####DESCRIPTIONEND####
37 37
38 #include <pkgconf/kernel.h> 38 #include <pkgconf/kernel.h>
39 39
74 CYG_TEST_INFO("handler 1 called"); 74 CYG_TEST_INFO("handler 1 called");
75 75
76 CYG_TEST_CHECK((CYG_ADDRWORD)&d0 == data, "handler given wrong data"); 76 CYG_TEST_CHECK((CYG_ADDRWORD)&d0 == data, "handler given wrong data");
77 77
78 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE 78 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE
79 CYG_TEST_CHECK(number == CYG_EXCEPTION_MAX, "handler given wrong number"); 79 CYG_TEST_CHECK(number == CYGNUM_HAL_EXCEPTION_MAX, "handler given wrong number");
80 #else 80 #else
81 CYG_UNUSED_PARAM(cyg_code, number); 81 CYG_UNUSED_PARAM(cyg_code, number);
82 #endif 82 #endif
83 83
84 CYG_TEST_CHECK((CYG_ADDRWORD)99 == info, "handler given wrong info"); 84 CYG_TEST_CHECK((CYG_ADDRWORD)99 == info, "handler given wrong info");
108 Cyg_Thread *p=Cyg_Thread::self(); 108 Cyg_Thread *p=Cyg_Thread::self();
109 109
110 CYG_UNUSED_PARAM(CYG_ADDRESS, data); 110 CYG_UNUSED_PARAM(CYG_ADDRESS, data);
111 111
112 p->register_exception( 112 p->register_exception(
113 CYG_EXCEPTION_MAX, 113 CYGNUM_HAL_EXCEPTION_MAX,
114 &handler1, 114 &handler1,
115 (CYG_ADDRWORD)&d0, 115 (CYG_ADDRWORD)&d0,
116 &old_handler, 116 &old_handler,
117 &old_data); 117 &old_data);
118 118
119 p->register_exception( 119 p->register_exception(
120 CYG_EXCEPTION_MAX, 120 CYGNUM_HAL_EXCEPTION_MAX,
121 &handler1, 121 &handler1,
122 (CYG_ADDRWORD)&d0, 122 (CYG_ADDRWORD)&d0,
123 &old_handler1, 123 &old_handler1,
124 &old_data1); 124 &old_data1);
125 125
126 CYG_TEST_CHECK(old_handler1 == &handler1, 126 CYG_TEST_CHECK(old_handler1 == &handler1,
127 "register exception: old_handler not the one previously registered"); 127 "register exception: old_handler not the one previously registered");
128 CYG_TEST_CHECK(old_data1 == (CYG_ADDRWORD)&d0, 128 CYG_TEST_CHECK(old_data1 == (CYG_ADDRWORD)&d0,
129 "register exception: old_data not those previously registered"); 129 "register exception: old_data not those previously registered");
130 130
131 p->deliver_exception(CYG_EXCEPTION_MAX, (CYG_ADDRWORD)99); 131 p->deliver_exception(CYGNUM_HAL_EXCEPTION_MAX, (CYG_ADDRWORD)99);
132 132
133 CYG_TEST_INFO("handler 1 returned"); 133 CYG_TEST_INFO("handler 1 returned");
134 134
135 p->deregister_exception(CYG_EXCEPTION_MAX); 135 p->deregister_exception(CYGNUM_HAL_EXCEPTION_MAX);
136 p->deregister_exception(CYG_EXCEPTION_MAX); 136 p->deregister_exception(CYGNUM_HAL_EXCEPTION_MAX);
137 137
138 for(n = CYG_EXCEPTION_MIN; n <= CYG_EXCEPTION_MAX; n++) { 138 #ifdef CYGPKG_HAL_I386_LINUX
139 // We can't catch segmentation violation exceptions on Linux.
140 CYG_TEST_PASS_FINISH("Except 1 OK");
141 #endif
142
143 for(n = CYGNUM_HAL_EXCEPTION_MIN; n <= CYGNUM_HAL_EXCEPTION_MAX; n++) {
139 p->register_exception( 144 p->register_exception(
140 n, 145 n,
141 handler0, 146 handler0,
142 (CYG_ADDRWORD)123, 147 (CYG_ADDRWORD)123,
143 &old_handler1, 148 &old_handler1,
144 &old_data1); 149 &old_data1);
145 } 150 }
146 151
147 CYG_TEST_INFO("Attempting to provoke exception"); 152 CYG_TEST_PASS("Attempting to provoke exception");
148 153
149 cause_exception(); 154 cause_exception();
150 155
151 CYG_TEST_FAIL_FINISH("Couldn't cause exception"); 156 CYG_TEST_FAIL_FINISH("Couldn't cause exception");
152 } 157 }
158 163
159 #endif 164 #endif
160 165
161 void except0_main( void ) 166 void except0_main( void )
162 { 167 {
168 // Use CYG_TEST_GDBCMD _before_ CYG_TEST_INIT()
169 CYG_TEST_GDBCMD("handle SIGBUS nostop");
170 CYG_TEST_GDBCMD("handle SIGSEGV nostop");
171
163 CYG_TEST_INIT(); 172 CYG_TEST_INIT();
164 173
165 #ifdef CYG_HAL_TX39_JMR3904 174 #ifdef HAL_VSR_SET_TO_ECOS_HANDLER
166 175 // Reclaim the VSR off CygMon possibly
167 HAL_VSR_SET( CYG_VECTOR_LOAD_ADDRESS, __default_exception_vsr, &old_vsr ); 176 #ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS
168 177 HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_ACCESS, NULL );
178 #endif
179 #ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS
180 HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS, NULL );
181 #endif
182 #ifdef CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION
183 HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION, NULL );
184 #endif
169 #endif 185 #endif
170 186
171 new_thread(entry0, 0); 187 new_thread(entry0, 0);
172 188
173 Cyg_Scheduler::start(); 189 Cyg_Scheduler::start();
182 #else // def CYGPKG_KERNEL_EXCEPTIONS 198 #else // def CYGPKG_KERNEL_EXCEPTIONS
183 externC void 199 externC void
184 cyg_start( void ) 200 cyg_start( void )
185 { 201 {
186 CYG_TEST_INIT(); 202 CYG_TEST_INIT();
187 CYG_TEST_PASS_FINISH("NA: Exceptions disabled"); 203 CYG_TEST_NA("Exceptions disabled");
188 } 204 }
189 #endif // def CYGPKG_KERNEL_EXCEPTIONS 205 #endif // def CYGPKG_KERNEL_EXCEPTIONS
190 206
191 // EOF except1.cxx 207 // EOF except1.cxx