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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [infra/] [v2_0/] [src/] [tcdiag.cxx] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//        tcdiag.cxx
4
//
5
//        Infrastructure diag test harness.
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 Red Hat, 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 version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//==========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):     dsm
44
// Contributors:  dsm, jlarmour
45
// Date:          1999-02-16
46
// Description:   Test harness implementation that uses the infrastructure
47
//                diag channel.  This is intended for manual testing.
48
// 
49
//####DESCRIPTIONEND####
50
 
51
#include <pkgconf/infra.h>
52
#include <pkgconf/system.h>
53
#include CYGBLD_HAL_TARGET_H           // get initialization for
54
#include CYGBLD_HAL_PLATFORM_H         //   cyg_test_is_simulator
55
 
56
#include <cyg/infra/cyg_type.h>        // base types
57
#include <cyg/hal/hal_arch.h>          // any architecture specific stuff
58
#include <cyg/infra/diag.h>            // HAL polled output
59
#include <cyg/infra/testcase.h>        // what we implement
60
 
61
#include <cyg/hal/hal_intr.h>          // exit macro, if defined
62
 
63
#ifdef CYGHWR_TARGET_SIMULATOR_NO_GDB_WORKING
64
int cyg_test_is_simulator = 1;         // set this anyway
65
#else
66
int cyg_test_is_simulator = 0;         // infrastructure changes as necessary
67
#endif
68
 
69
//----------------------------------------------------------------------------
70
// Functions ensuring we get pretty printed assertion messages in the
71
// farm - regardless of configuration and GDB capabilities.
72
 
73
#ifdef CYGPKG_KERNEL
74
# include <pkgconf/kernel.h>
75
# include <cyg/kernel/thread.hxx>        // thread id to print
76
# include <cyg/kernel/thread.inl>        // ancillaries for above
77
#endif
78
 
79
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
80
#include <cyg/hal/hal_if.h>
81
#endif
82
 
83
static inline const char *trim_file(const char *file)
84
{
85
    if ( NULL == file )
86
        file = "<nofile>";
87
 
88
    const char *f = file;
89
 
90
    while( *f ) f++;
91
 
92
    while( *f != '/' && f != file ) f--;
93
 
94
    return f==file?f:(f+1);
95
}
96
 
97
static inline const char *trim_func(const char *func)
98
{
99
    static char fbuf[100];
100
    int i;
101
 
102
    if ( NULL == func )
103
        func = "<nofunc>";
104
 
105
    for( i = 0; func[i] && func[i] != '(' ; i++ )
106
        fbuf[i] = func[i];
107
 
108
    fbuf[i++] = '(';
109
    fbuf[i++] = ')';
110
    fbuf[i  ] = 0;
111
 
112
    return &fbuf[0];
113
}
114
 
115
static inline
116
void write_lnum( cyg_uint32 lnum)
117
{
118
    diag_write_char('[');
119
    diag_write_dec(lnum);
120
    diag_write_char(']');
121
}
122
 
123
static inline
124
void write_thread_id()
125
{
126
#ifdef CYGPKG_KERNEL
127
    Cyg_Thread *t = Cyg_Thread::self();
128
    cyg_uint16 tid = 0xFFFF;
129
 
130
    if( t != NULL ) tid = t->get_unique_id();
131
 
132
    diag_write_char('<');
133
    diag_write_hex(tid);
134
    diag_write_char('>');
135
#endif
136
}
137
 
138
// Called from the CYG_ASSERT_DOCALL macro
139
externC void
140
cyg_assert_msg( const char *psz_func, const char *psz_file,
141
                cyg_uint32 linenum, const char *psz_msg ) __THROW
142
{
143
    cyg_uint32 old_ints;
144
 
145
    HAL_DISABLE_INTERRUPTS(old_ints);
146
    DIAG_DEVICE_START_SYNC();
147
 
148
#ifdef CYG_HAL_DIAG_LOCK
149
    CYG_HAL_DIAG_LOCK();
150
#endif    
151
 
152
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
153
    {
154
        int cur_console;
155
        int i;
156
        cur_console = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
157
        if ( CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,
158
                                          "info_console_force", &i,
159
                                          CYGNUM_FLASH_CFG_OP_CONFIG_BOOL ) )
160
            if ( i )
161
                if ( CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,
162
                                                  "info_console_number", &i,
163
                                                  CYGNUM_FLASH_CFG_OP_CONFIG_INT ) )
164
                    // Then i is the console to force it to:
165
                    CYGACC_CALL_IF_SET_CONSOLE_COMM( i );
166
#endif
167
    diag_write_string("ASSERT FAIL: ");
168
    write_thread_id();
169
    diag_write_string(trim_file(psz_file));
170
    write_lnum(linenum);
171
    diag_write_string(trim_func(psz_func));
172
    diag_write_char(' ');
173
    diag_write_string(psz_msg);
174
    diag_write_char('\n');
175
 
176
#ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
177
        CYGACC_CALL_IF_SET_CONSOLE_COMM(cur_console);
178
    }
179
#endif
180
#ifdef CYG_HAL_DIAG_UNLOCK
181
    CYG_HAL_DIAG_UNLOCK();
182
#endif    
183
 
184
    DIAG_DEVICE_END_SYNC();
185
    HAL_RESTORE_INTERRUPTS(old_ints);
186
}
187
 
188
externC void
189
cyg_test_init(void)
190
{
191
    // currently nothing
192
}
193
 
194
externC void
195
cyg_test_output(Cyg_test_code status, const char *msg, int line,
196
                const char *file)
197
{
198
    char *st;
199
 
200
    switch (status) {
201
    case CYGNUM_TEST_FAIL:
202
        st = "FAIL:";
203
        break;
204
    case CYGNUM_TEST_PASS:
205
        st = "PASS:";
206
        break;
207
    case CYGNUM_TEST_EXIT:
208
        st = "EXIT:";
209
        break;
210
    case CYGNUM_TEST_INFO:
211
        st = "INFO:";
212
        break;
213
    case CYGNUM_TEST_GDBCMD:
214
        st = "GDB:";
215
        break;
216
    case CYGNUM_TEST_NA:
217
        st = "NOTAPPLICABLE:";
218
        break;
219
    default:
220
        st = "UNKNOWN STATUS:";
221
        break;
222
    }
223
 
224
#ifdef CYG_HAL_DIAG_LOCK
225
    CYG_HAL_DIAG_LOCK();
226
#endif    
227
 
228
    diag_write_string(st);
229
    diag_write_char('<');
230
    diag_write_string(msg);
231
    diag_write_char('>');
232
    if( CYGNUM_TEST_FAIL == status ) {
233
        diag_write_string(" Line: ");
234
        diag_write_dec(line);
235
        diag_write_string(", File: ");
236
        diag_write_string(file);
237
    }
238
    diag_write_char('\n');
239
 
240
#ifdef CYG_HAL_DIAG_UNLOCK
241
    CYG_HAL_DIAG_UNLOCK();
242
#endif    
243
 
244
 
245
}
246
 
247
// This is an appropriate function to set a breakpoint on
248
externC void
249
cyg_test_exit(void)
250
{
251
// workaround SH dwarf2 gen problem    
252
#if defined(CYGPKG_HAL_SH) && (__GNUC__ >= 3)
253
    static volatile int i;
254
    i++;
255
#endif
256
#ifdef CYGHWR_TEST_PROGRAM_EXIT
257
    CYGHWR_TEST_PROGRAM_EXIT();
258
#endif
259
 
260
    for(;;)
261
        ;
262
}
263
// EOF tcdiag.cxx

powered by: WebSVN 2.1.0

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