OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [kernel/] [current/] [tests/] [intr0.cxx] - Blame information for rev 819

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//=================================================================
2
//
3
//        intr0.cxx
4
//
5
//        Interrupt test 0
6
//
7
//=================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//=================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):     dsm
43
// Contributors:  dsm, jlarmour
44
// Date:          1999-02-16
45
// Description:   Very basic test of interrupt objects
46
// Options:
47
//     CYGIMP_KERNEL_INTERRUPTS_DSRS_TABLE
48
//     CYGNUM_KERNEL_INTERRUPTS_DSRS_TABLE_SIZE
49
//     CYGIMP_KERNEL_INTERRUPTS_DSRS_LIST
50
//     CYGSEM_KERNEL_INTERRUPTS_DSRS_LIST_FIFO
51
//####DESCRIPTIONEND####
52
 
53
#include <pkgconf/kernel.h>
54
 
55
#include <cyg/kernel/intr.hxx>
56
#include <cyg/hal/hal_intr.h>
57
 
58
#include <cyg/infra/testcase.h>
59
 
60
#include "testaux.hxx"
61
 
62
#ifdef HAL_INTR_TEST_PRIO_A
63
# define PRIO_A HAL_INTR_TEST_PRIO_A
64
#else
65
# define PRIO_A 0
66
#endif
67
 
68
#ifdef HAL_INTR_TEST_PRIO_B
69
# define PRIO_B HAL_INTR_TEST_PRIO_B
70
#else
71
# define PRIO_B 1
72
#endif
73
 
74
#ifdef HAL_INTR_TEST_PRIO_C
75
# define PRIO_C HAL_INTR_TEST_PRIO_C
76
#else
77
# define PRIO_C 1
78
#endif
79
 
80
static cyg_ISR isr0, isr1;
81
static cyg_DSR dsr0, dsr1;
82
 
83
static char intr0_obj[sizeof(Cyg_Interrupt)];
84
static char intr1_obj[sizeof(Cyg_Interrupt)];
85
 
86
static cyg_uint32 isr0(cyg_vector vector, CYG_ADDRWORD data)
87
{
88
    CYG_UNUSED_PARAM(CYG_ADDRWORD, data);
89
 
90
    Cyg_Interrupt::acknowledge_interrupt(vector);
91
    return 0;
92
}
93
 
94
static void dsr0(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data)
95
{
96
    CYG_UNUSED_PARAM(cyg_vector, vector);
97
    CYG_UNUSED_PARAM(cyg_ucount32, count);
98
    CYG_UNUSED_PARAM(CYG_ADDRWORD, data);
99
}
100
 
101
static cyg_uint32 isr1(cyg_vector vector, CYG_ADDRWORD data)
102
{
103
    CYG_UNUSED_PARAM(cyg_vector, vector);
104
    CYG_UNUSED_PARAM(CYG_ADDRWORD, data);
105
    return 0;
106
}
107
 
108
static void dsr1(cyg_vector vector, cyg_ucount32 count, CYG_ADDRWORD data)
109
{
110
    CYG_UNUSED_PARAM(cyg_vector, vector);
111
    CYG_UNUSED_PARAM(cyg_ucount32, count);
112
    CYG_UNUSED_PARAM(CYG_ADDRWORD, data);
113
}
114
 
115
static bool flash( void )
116
{
117
    Cyg_Interrupt intr0 = Cyg_Interrupt(CYGNUM_HAL_ISR_MIN, PRIO_A,
118
                                        (CYG_ADDRWORD)333, isr0, dsr0 );
119
 
120
    return true;
121
}
122
 
123
/* IMPORTANT: The calling convention for VSRs is target dependent.  It is
124
 * unlikely that a plain C or C++ routine would function correctly on any
125
 * particular platform, even if it could correctly access the system
126
 * resources necessary to handle the event that caused it to be called.
127
 * VSRs usually must be written in assembly language.
128
 *
129
 * This is just a test program.  The routine vsr0() below is defined simply
130
 * to define an address that will be in executable memory.  If an event
131
 * causes this VSR to be called, all bets are off.  If it is accidentally
132
 * installed in the vector for the realtime clock, the system will likely
133
 * freeze.
134
 */
135
 
136
static cyg_VSR vsr0;
137
 
138
static void vsr0()
139
{
140
}
141
 
142
void intr0_main( void )
143
{
144
    CYG_TEST_INIT();
145
 
146
    CHECK(flash());
147
    CHECK(flash());
148
 
149
    // Make sure the chosen levels are not already in use.
150
    int in_use;
151
    cyg_vector lvl1 = CYGNUM_HAL_ISR_MIN + (1 % CYGNUM_HAL_ISR_COUNT);
152
    HAL_INTERRUPT_IN_USE( lvl1, in_use );
153
    Cyg_Interrupt* intr0 = NULL;
154
    if (!in_use)
155
        intr0 = new((void *)&intr0_obj[0]) Cyg_Interrupt( lvl1, PRIO_B, (CYG_ADDRWORD)777, isr0, dsr0 );
156
 
157
    cyg_vector lvl2 = CYGNUM_HAL_ISR_MIN + ( 15 % CYGNUM_HAL_ISR_COUNT);
158
    HAL_INTERRUPT_IN_USE( lvl2, in_use );
159
    Cyg_Interrupt* intr1 = NULL;
160
    if (!in_use && lvl1 != lvl2)
161
        intr1 = new((void *)&intr1_obj[0]) Cyg_Interrupt( lvl2, PRIO_C, 888, isr1, dsr1 );
162
 
163
    // Check these functions at least exist
164
    Cyg_Interrupt::disable_interrupts();
165
    Cyg_Interrupt::enable_interrupts();
166
 
167
    if (intr0)
168
        intr0->attach();
169
    if (intr1)
170
        intr1->attach();
171
    if (intr0)
172
        intr0->detach();
173
    if (intr1)
174
        intr1->detach();
175
 
176
    // If this attaching interrupt replaces the previous interrupt
177
    // instead of adding to it we could be in a big mess if the
178
    // vector is being used by something important.
179
 
180
    cyg_vector v = (CYGNUM_HAL_VSR_MIN + 11) % CYGNUM_HAL_VSR_COUNT;
181
    cyg_VSR *old_vsr, *new_vsr;
182
    Cyg_Interrupt::set_vsr( v, vsr0, &old_vsr );
183
    Cyg_Interrupt::get_vsr( v, &new_vsr );
184
    CHECK( vsr0 == new_vsr );
185
 
186
    new_vsr = NULL;
187
    Cyg_Interrupt::set_vsr( v, old_vsr, &new_vsr );
188
    CHECK( new_vsr == vsr0 );
189
 
190
    Cyg_Interrupt::set_vsr( v, new_vsr );
191
    new_vsr = NULL;
192
    Cyg_Interrupt::get_vsr( v, &new_vsr );
193
    CHECK( vsr0 == new_vsr );
194
 
195
    Cyg_Interrupt::set_vsr( v, old_vsr );
196
    CHECK( vsr0 == new_vsr );
197
    new_vsr = NULL;
198
    Cyg_Interrupt::get_vsr( v, &new_vsr );
199
    CHECK( old_vsr == new_vsr );
200
 
201
    CHECK( NULL != new_vsr);
202
 
203
    cyg_vector v1;
204
#ifdef CYGPKG_HAL_MIPS_TX39    
205
    // This can be removed when PR 17831 is fixed
206
    if ( cyg_test_is_simulator )
207
        v1 = 12 % CYGNUM_HAL_ISR_COUNT;
208
    else /* NOTE TRAILING ELSE... */
209
#endif
210
    v1 = CYGNUM_HAL_ISR_MIN + (6 % CYGNUM_HAL_ISR_COUNT);
211
 
212
    Cyg_Interrupt::mask_interrupt(v1);
213
    Cyg_Interrupt::unmask_interrupt(v1);
214
 
215
    Cyg_Interrupt::configure_interrupt(v1, true, true);
216
 
217
    CYG_TEST_PASS_FINISH("Intr 0 OK");
218
}
219
 
220
externC void
221
cyg_start( void )
222
{
223
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
224
    cyg_hal_invoke_constructors();
225
#endif
226
    intr0_main();
227
}
228
// EOF intr0.cxx

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.