Mercurial > ecos
annotate packages/kernel/current/tests/intr0.cxx @ 10:d3fbcdfa1b2f ecos-sw-1999-05-29
Merge from eCos master repository on 1999-05-29-00:13:11-BST
| author | jlarmour |
|---|---|
| date | Fri, 28 May 1999 16:43:09 +0000 |
| parents | 443894e2e912 |
| children | 29bc183297e1 |
| rev | line source |
|---|---|
| 0 | 1 //================================================================= |
| 2 // | |
| 3 // intr0.cxx | |
| 4 // | |
| 5 // Interrupt test 0 | |
| 6 // | |
| 7 //================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 2 | 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
| 0 | 26 // ------------------------------------------- |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //================================================================= | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): dsm | |
| 2 | 33 // Contributors: dsm, jlarmour |
| 34 // Date: 1999-02-16 | |
| 0 | 35 // Description: Very basic test of interrupt objects |
| 36 // Options: | |
| 37 // CYGIMP_KERNEL_INTERRUPTS_DSRS_TABLE | |
| 38 // CYGIMP_KERNEL_INTERRUPTS_DSRS_TABLE_SIZE | |
| 39 // CYGIMP_KERNEL_INTERRUPTS_DSRS_LIST | |
| 40 //####DESCRIPTIONEND#### | |
| 41 | |
| 42 #include <pkgconf/kernel.h> | |
| 43 | |
| 44 #include <cyg/kernel/intr.hxx> | |
| 45 #include <cyg/hal/hal_intr.h> | |
| 46 | |
| 47 #include <cyg/infra/testcase.h> | |
| 48 | |
| 49 #include "testaux.hxx" | |
| 50 | |
| 51 static cyg_ISR isr0, isr1; | |
| 52 static cyg_DSR dsr0, dsr1; | |
| 53 | |
| 2 | 54 static char intr0_obj[sizeof(Cyg_Interrupt)]; |
| 55 static char intr1_obj[sizeof(Cyg_Interrupt)]; | |
| 56 | |
| 0 | 57 static cyg_uint32 isr0(cyg_vector vector, CYG_ADDRWORD data) |
| 58 { | |
| 59 CYG_UNUSED_PARAM(CYG_ADDRWORD, data); | |
| 60 | |
| 61 Cyg_Interrupt::acknowledge_interrupt(vector); | |
| 62 return 0; | |
| 63 } | |
| 64 | |
| 65 static void dsr0(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data) | |
| 66 { | |
| 67 CYG_UNUSED_PARAM(cyg_vector, vector); | |
| 68 CYG_UNUSED_PARAM(cyg_ucount32, count); | |
| 69 CYG_UNUSED_PARAM(CYG_ADDRWORD, data); | |
| 70 } | |
| 71 | |
| 72 static cyg_uint32 isr1(cyg_vector vector, CYG_ADDRWORD data) | |
| 73 { | |
| 74 CYG_UNUSED_PARAM(cyg_vector, vector); | |
| 75 CYG_UNUSED_PARAM(CYG_ADDRWORD, data); | |
| 76 return 0; | |
| 77 } | |
| 78 | |
| 79 static void dsr1(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data) | |
| 80 { | |
| 81 CYG_UNUSED_PARAM(cyg_vector, vector); | |
| 82 CYG_UNUSED_PARAM(cyg_ucount32, count); | |
| 83 CYG_UNUSED_PARAM(CYG_ADDRWORD, data); | |
| 84 } | |
| 85 | |
| 86 static bool flash( void ) | |
| 87 { | |
| 88 Cyg_Interrupt intr0 = Cyg_Interrupt( 0, 0, (CYG_ADDRWORD)333, isr0, dsr0 ); | |
| 89 | |
| 90 return true; | |
| 91 } | |
| 92 | |
| 93 static cyg_VSR vsr0; | |
| 94 | |
| 95 static void vsr0() | |
| 96 { | |
| 97 } | |
| 98 | |
| 99 void intr0_main( void ) | |
| 100 { | |
| 101 CYG_TEST_INIT(); | |
| 102 | |
| 103 CHECK(flash()); | |
| 104 CHECK(flash()); | |
| 105 | |
| 2 | 106 // Make sure the chosen levels are not already in use. |
| 107 int in_use; | |
| 108 cyg_vector lvl1 = 1 % (CYGNUM_HAL_ISR_COUNT); | |
| 109 HAL_INTERRUPT_IN_USE( lvl1, in_use ); | |
| 110 Cyg_Interrupt* intr0 = NULL; | |
| 111 if (!in_use) | |
| 112 intr0 = new((void *)&intr0_obj[0]) Cyg_Interrupt( lvl1, 1, (CYG_ADDRWORD)777, isr0, dsr0 ); | |
| 113 | |
| 114 cyg_vector lvl2 = 15 % (CYGNUM_HAL_ISR_COUNT); | |
| 115 HAL_INTERRUPT_IN_USE( lvl2, in_use ); | |
| 116 Cyg_Interrupt* intr1 = NULL; | |
| 117 if (!in_use && lvl1 != lvl2) | |
| 118 intr1 = new((void *)&intr1_obj[0]) Cyg_Interrupt( lvl2, 1, 888, isr1, dsr1 ); | |
| 0 | 119 |
| 120 // Check these functions at least exist | |
| 121 Cyg_Interrupt::enable_interrupts(); | |
| 122 Cyg_Interrupt::disable_interrupts(); | |
| 123 | |
| 2 | 124 if (intr0) |
| 125 intr0->attach(); | |
| 126 if (intr1) | |
| 127 intr1->attach(); | |
| 128 if (intr0) | |
| 129 intr0->detach(); | |
| 130 if (intr1) | |
| 131 intr1->detach(); | |
| 0 | 132 |
| 133 // If this attaching interrupt replaces the previous interrupt | |
| 134 // instead of adding to it we could be in a big mess if the | |
| 135 // vector is being used by something important. | |
| 2 | 136 |
| 137 cyg_vector v = 11 % CYGNUM_HAL_VSR_COUNT; | |
| 0 | 138 cyg_VSR *old_vsr, *new_vsr; |
| 139 Cyg_Interrupt::set_vsr( v, vsr0, &old_vsr ); | |
| 140 Cyg_Interrupt::get_vsr( v, &new_vsr ); | |
| 141 CHECK( vsr0 == new_vsr ); | |
| 142 | |
| 143 new_vsr = NULL; | |
| 144 Cyg_Interrupt::set_vsr( v, old_vsr, &new_vsr ); | |
| 145 CHECK( new_vsr == vsr0 ); | |
| 146 | |
| 147 Cyg_Interrupt::set_vsr( v, new_vsr ); | |
| 148 new_vsr = NULL; | |
| 2 | 149 Cyg_Interrupt::get_vsr( v, &new_vsr ); |
| 0 | 150 CHECK( vsr0 == new_vsr ); |
| 151 | |
| 152 Cyg_Interrupt::set_vsr( v, old_vsr ); | |
| 153 CHECK( vsr0 == new_vsr ); | |
| 154 new_vsr = NULL; | |
| 155 Cyg_Interrupt::get_vsr( v, &new_vsr ); | |
| 156 CHECK( old_vsr == new_vsr ); | |
| 2 | 157 |
| 0 | 158 CHECK( NULL != vsr0 ); |
| 159 | |
| 2 | 160 cyg_vector v1; |
|
10
d3fbcdfa1b2f
Merge from eCos master repository on 1999-05-29-00:13:11-BST
jlarmour
parents:
2
diff
changeset
|
161 #ifdef CYGPKG_HAL_MIPS_TX39 |
| 2 | 162 // This can be removed when PR 17831 is fixed |
| 163 if ( cyg_test_is_simulator ) | |
| 164 v1 = 12 % CYGNUM_HAL_ISR_COUNT; | |
| 165 else /* NOTE TRAILING ELSE... */ | |
| 166 #endif | |
| 167 v1 = 6 % CYGNUM_HAL_ISR_COUNT; | |
| 168 | |
| 0 | 169 Cyg_Interrupt::mask_interrupt(v1); |
| 170 Cyg_Interrupt::unmask_interrupt(v1); | |
| 171 | |
| 172 Cyg_Interrupt::configure_interrupt(v1, true, true); | |
| 173 | |
| 174 CYG_TEST_PASS_FINISH("Intr 0 OK"); | |
| 175 } | |
| 176 | |
| 177 externC void | |
| 178 cyg_start( void ) | |
| 179 { | |
| 180 intr0_main(); | |
| 181 } | |
| 182 // EOF intr0.cxx |
