comparison packages/kernel/current/tests/kintr0.c @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children 443894e2e912
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 /*=================================================================
2 //
3 // kintr0.c
4 //
5 // Kernel C API Intr 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
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved.
26 // -------------------------------------------
27 //
28 //####COPYRIGHTEND####
29 //==========================================================================
30 //#####DESCRIPTIONBEGIN####
31 //
32 // Author(s): dsm
33 // Contributors: dsm
34 // Date: 1998-06-15
35 // Description: Very basic test of interrupt objects
36 // Options:
37 // CYGIMP_KERNEL_INTERRUPTS_DSRS_TABLE
38 // CYGIMP_KERNEL_INTERRUPTS_DSRS_TABLE_MAX
39 // CYGIMP_KERNEL_INTERRUPTS_DSRS_LIST
40 //####DESCRIPTIONEND####
41 */
42
43 #include <cyg/kernel/kapi.h>
44 #include <cyg/hal/hal_intr.h>
45
46 #include <cyg/infra/testcase.h>
47
48 #ifdef CYGFUN_KERNEL_API_C
49
50 #include "testaux.h"
51
52 static cyg_interrupt intr_obj[2];
53
54 static cyg_handle_t intr0, intr1;
55
56
57 static cyg_ISR_t isr0, isr1;
58 static cyg_DSR_t dsr0, dsr1;
59
60 static cyg_uint32 isr0(cyg_vector_t vector, cyg_addrword_t data)
61 {
62 CYG_UNUSED_PARAM(cyg_addrword_t, data);
63
64 cyg_interrupt_acknowledge(vector);
65 return 0;
66 }
67
68 static void dsr0(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
69 {
70 CYG_UNUSED_PARAM(cyg_vector_t, vector);
71 CYG_UNUSED_PARAM(cyg_ucount32, count);
72 CYG_UNUSED_PARAM(cyg_addrword_t, data);
73 }
74
75 static cyg_uint32 isr1(cyg_vector_t vector, cyg_addrword_t data)
76 {
77 CYG_UNUSED_PARAM(cyg_vector_t, vector);
78 CYG_UNUSED_PARAM(cyg_addrword_t, data);
79 return 0;
80 }
81
82 static void dsr1(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
83 {
84 CYG_UNUSED_PARAM(cyg_vector_t, vector);
85 CYG_UNUSED_PARAM(cyg_ucount32, count);
86 CYG_UNUSED_PARAM(cyg_addrword_t, data);
87 }
88
89 static bool flash( void )
90 {
91 cyg_handle_t handle;
92 cyg_interrupt intr;
93
94 cyg_interrupt_create(0, 0, (cyg_addrword_t)333, isr0, dsr0, &handle, &intr );
95 cyg_interrupt_delete(handle);
96
97 return true;
98 }
99
100 static cyg_VSR_t vsr0;
101
102 static void vsr0()
103 {
104 }
105
106 void kintr0_main( void )
107 {
108 cyg_vector_t v = 11 % CYG_VSR_COUNT;
109 cyg_vector_t v1 = 6 % CYG_ISR_COUNT;
110 cyg_VSR_t *old_vsr, *new_vsr;
111
112 CYG_TEST_INIT();
113
114 CHECK(flash());
115 CHECK(flash());
116
117 cyg_interrupt_create(1 % (CYG_ISR_COUNT), 1, (cyg_addrword_t)777,
118 isr0, dsr0, &intr0, &intr_obj[0]);
119
120 cyg_interrupt_create(15 % (CYG_ISR_COUNT), 1, 888,
121 isr1, dsr1, &intr1, &intr_obj[1]);
122
123
124 // Check these functions at least exist
125
126 cyg_interrupt_enable();
127 cyg_interrupt_disable();
128
129 cyg_interrupt_attach(intr0);
130 cyg_interrupt_attach(intr1);
131 cyg_interrupt_detach(intr0);
132 cyg_interrupt_detach(intr1);
133
134 // If this attaching interrupt replaces the previous interrupt
135 // instead of adding to it we could be in a big mess if the
136 // vector is being used by something important.
137
138 cyg_interrupt_get_vsr( v, &old_vsr );
139 cyg_interrupt_set_vsr( v, vsr0 );
140 cyg_interrupt_get_vsr( v, &new_vsr );
141 CHECK( vsr0 == new_vsr );
142
143 new_vsr = NULL;
144 cyg_interrupt_get_vsr( v, &new_vsr );
145 cyg_interrupt_set_vsr( v, old_vsr );
146 CHECK( new_vsr == vsr0 );
147
148 cyg_interrupt_set_vsr( v, new_vsr );
149 new_vsr = NULL;
150 cyg_interrupt_get_vsr( v, &new_vsr );
151 CHECK( vsr0 == new_vsr );
152
153 cyg_interrupt_set_vsr( v, old_vsr );
154 CHECK( vsr0 == new_vsr );
155 new_vsr = NULL;
156 cyg_interrupt_get_vsr( v, &new_vsr );
157 CHECK( old_vsr == new_vsr );
158
159 CHECK( NULL != vsr0 );
160
161 cyg_interrupt_mask(v1);
162 cyg_interrupt_unmask(v1);
163
164 cyg_interrupt_configure(v1, true, true);
165
166 CYG_TEST_PASS_FINISH("Kernel C API Intr 0 OK");
167 }
168
169 externC void
170 cyg_start( void )
171 {
172 kintr0_main();
173 }
174
175 #else /* def CYGFUN_KERNEL_API_C */
176 externC void
177 cyg_start( void )
178 {
179 CYG_TEST_INIT();
180 CYG_TEST_PASS_FINISH("Kernel C API layer disabled");
181 }
182 #endif /* def CYGFUN_KERNEL_API_C */
183
184 /* EOF kintr0.c */