Mercurial > flash_v2
comparison packages/kernel/current/tests/except1.cxx @ 78:59d97b6ba612 ecos-sw-2000-03-28
Merge from eCos master repository on 2000-03-28-19:50:47-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 20:13:29 +0000 |
| parents | c5536bad4c24 |
| children | 518f42066aba |
comparison
equal
deleted
inserted
replaced
| 77:abb6bd809e81 | 78:59d97b6ba612 |
|---|---|
| 53 #include <cyg/kernel/thread.inl> | 53 #include <cyg/kernel/thread.inl> |
| 54 | 54 |
| 55 #define NTHREADS 1 | 55 #define NTHREADS 1 |
| 56 #include "testaux.hxx" | 56 #include "testaux.hxx" |
| 57 | 57 |
| 58 static int d0; | |
| 59 #ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS | |
| 58 static cyg_exception_handler handler0; | 60 static cyg_exception_handler handler0; |
| 59 static int d0; | |
| 60 | 61 |
| 61 static void handler0(CYG_ADDRWORD data, cyg_code number, CYG_ADDRWORD info) | 62 static void handler0(CYG_ADDRWORD data, cyg_code number, CYG_ADDRWORD info) |
| 62 { | 63 { |
| 63 CYG_TEST_INFO("handler 0 called"); | 64 CYG_TEST_INFO("handler 0 called"); |
| 64 | 65 |
| 68 CYG_UNUSED_PARAM(cyg_code, number); | 69 CYG_UNUSED_PARAM(cyg_code, number); |
| 69 CYG_UNUSED_PARAM(CYG_ADDRWORD, info); | 70 CYG_UNUSED_PARAM(CYG_ADDRWORD, info); |
| 70 | 71 |
| 71 CYG_TEST_PASS_FINISH("Except 1 OK"); | 72 CYG_TEST_PASS_FINISH("Except 1 OK"); |
| 72 } | 73 } |
| 74 #endif | |
| 73 | 75 |
| 74 static void handler1(CYG_ADDRWORD data, cyg_code number, CYG_ADDRWORD info) | 76 static void handler1(CYG_ADDRWORD data, cyg_code number, CYG_ADDRWORD info) |
| 75 { | 77 { |
| 76 CYG_TEST_INFO("handler 1 called"); | 78 CYG_TEST_INFO("handler 1 called"); |
| 77 | 79 |
| 84 #endif | 86 #endif |
| 85 | 87 |
| 86 CYG_TEST_CHECK((CYG_ADDRWORD)99 == info, "handler given wrong info"); | 88 CYG_TEST_CHECK((CYG_ADDRWORD)99 == info, "handler given wrong info"); |
| 87 } | 89 } |
| 88 | 90 |
| 89 | 91 #ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS |
| 90 // The following function attempts to cause an exception in various | 92 // The following function attempts to cause an exception in various |
| 91 // hacky ways. It is machine dependent what exception is generated. | 93 // hacky ways. It is machine dependent what exception is generated. |
| 92 // It does reads rather than writes hoping not to corrupt anything | 94 // It does reads rather than writes hoping not to corrupt anything |
| 93 // important. | 95 // important. |
| 94 void cause_exception(void) | 96 void cause_exception(void) |
| 99 do { | 101 do { |
| 100 x=*(volatile int *)(p-1)/p; | 102 x=*(volatile int *)(p-1)/p; |
| 101 p+=0x100000; | 103 p+=0x100000; |
| 102 } while(p != 0); | 104 } while(p != 0); |
| 103 } | 105 } |
| 106 #endif | |
| 104 | 107 |
| 105 static void entry0( CYG_ADDRWORD data ) | 108 static void entry0( CYG_ADDRWORD data ) |
| 106 { | 109 { |
| 110 #ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS | |
| 107 cyg_code n; | 111 cyg_code n; |
| 112 #endif | |
| 108 cyg_exception_handler *old_handler, *old_handler1; | 113 cyg_exception_handler *old_handler, *old_handler1; |
| 109 CYG_ADDRWORD old_data, old_data1; | 114 CYG_ADDRWORD old_data, old_data1; |
| 110 Cyg_Thread *p=Cyg_Thread::self(); | 115 Cyg_Thread *p=Cyg_Thread::self(); |
| 111 | 116 |
| 112 CYG_UNUSED_PARAM(CYG_ADDRESS, data); | 117 CYG_UNUSED_PARAM(CYG_ADDRESS, data); |
| 135 CYG_TEST_INFO("handler 1 returned"); | 140 CYG_TEST_INFO("handler 1 returned"); |
| 136 | 141 |
| 137 p->deregister_exception(CYGNUM_HAL_EXCEPTION_MAX); | 142 p->deregister_exception(CYGNUM_HAL_EXCEPTION_MAX); |
| 138 p->deregister_exception(CYGNUM_HAL_EXCEPTION_MAX); | 143 p->deregister_exception(CYGNUM_HAL_EXCEPTION_MAX); |
| 139 | 144 |
| 145 #ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS | |
| 146 | |
| 140 #if 0 | 147 #if 0 |
| 141 #elif defined(CYGPKG_HAL_POWERPC_SIM) | 148 #elif defined(CYGPKG_HAL_POWERPC_SIM) |
| 142 // The exception generated by the SIM is not recognized by GDB. | 149 // The exception generated by the SIM is not recognized by GDB. |
| 143 // PR 19945 workaround. | 150 // PR 19945 workaround. |
| 144 CYG_TEST_NA("Not applicable to PowerPC SIM"); | 151 CYG_TEST_NA("Not applicable to PowerPC SIM"); |
| 159 CYG_TEST_PASS("Attempting to provoke exception"); | 166 CYG_TEST_PASS("Attempting to provoke exception"); |
| 160 | 167 |
| 161 cause_exception(); | 168 cause_exception(); |
| 162 | 169 |
| 163 CYG_TEST_FAIL_FINISH("Couldn't cause exception"); | 170 CYG_TEST_FAIL_FINISH("Couldn't cause exception"); |
| 171 #else // CYGNUM_HAL_EXCEPTION_DATA_ACCESS | |
| 172 CYG_TEST_NA("Platform does not support data exceptions"); | |
| 173 #endif | |
| 174 | |
| 164 } | 175 } |
| 165 | 176 |
| 166 #ifdef CYG_HAL_MIPS_TX39_JMR3904 | 177 #ifdef CYG_HAL_MIPS_TX39_JMR3904 |
| 167 | 178 |
| 168 externC cyg_VSR __default_exception_vsr; | 179 externC cyg_VSR __default_exception_vsr; |
