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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [common/] [current/] [src/] [hal_misc.c] - Blame information for rev 794

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      hal_misc.c
4
//
5
//      Common HAL miscellaneous functions
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, 2003 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):    nickg
43
// Contributors: nickg, jskov
44
// Date:         2000-06-08
45
// Purpose:      HAL miscellaneous functions
46
// Description:  This file contains miscellaneous functions provided by the
47
//               HAL.
48
//
49
//####DESCRIPTIONEND####
50
//
51
//========================================================================*/
52
 
53
#include <pkgconf/hal.h>
54
 
55
#include <cyg/hal/hal_arch.h>
56
#include <cyg/hal/hal_if.h>
57
 
58
#include <cyg/hal/hal_intr.h>
59
#include <cyg/hal/hal_misc.h>           // our header
60
 
61
#include <cyg/infra/cyg_type.h>         // Base types
62
#include <cyg/infra/cyg_trac.h>         // tracing macros
63
#include <cyg/infra/cyg_ass.h>          // assertion macros
64
 
65
//--------------------------------------------------------------------------
66
 
67
//--------------------------------------------------------------------------
68
// Macro for finding return address. 
69
#ifndef CYGARC_HAL_GET_RETURN_ADDRESS
70
 
71
#define CYGARC_HAL_GET_RETURN_ADDRESS(_x_, _dummy_)     \
72
    CYG_MACRO_START                                     \
73
    (_dummy_) = 1;                                      \
74
    (_x_) = (CYG_ADDRWORD)&&__backup_return_address;    \
75
    CYG_MACRO_END
76
 
77
#define CYGARC_HAL_GET_RETURN_ADDRESS_BACKUP(_dummy_)   \
78
    CYG_MACRO_START                                     \
79
__backup_return_address:                                \
80
    if ((_dummy_)-- > 0)                                \
81
        goto __backup_return_address;                   \
82
    CYG_MACRO_END
83
#endif
84
 
85
//--------------------------------------------------------------------------
86
// Macro for finding PC in saved regs
87
#ifndef CYGARC_HAL_GET_PC_REG
88
#define CYGARC_HAL_GET_PC_REG(_regs_,_val_) ((_val_) = (_regs_)->pc)
89
#endif
90
 
91
//--------------------------------------------------------------------------
92
// Macro for matching interrupt vector to GDB comm channel.
93
#ifndef CYGHWR_HAL_GDB_PORT_VECTORS_MATCH
94
#define CYGHWR_HAL_GDB_PORT_VECTORS_MATCH(_v_,_gv_) ((_v_)==(_gv_))
95
#endif
96
 
97
#if defined(CYGPKG_CYGMON)
98
unsigned long cygmon_memsize = 0;
99
#endif
100
 
101
//--------------------------------------------------------------------------
102
// Functions to support the detection and execution of a user provoked
103
// program break. These are usually called from interrupt routines.
104
 
105
cyg_bool
106
cyg_hal_is_break(char *buf, int size)
107
{
108
    while( size )
109
        if( buf[--size] == 0x03 ) return true;
110
 
111
    return false;
112
}
113
 
114
// Keep this variable global, to prevent the compiler removing it (and
115
// the goto-reference) due to being local to the function where it is
116
// used. Yes, it's ugly.
117
int _cyg_hal_compiler_dummy;
118
 
119
void
120
cyg_hal_user_break( CYG_ADDRWORD *regs )
121
{
122
#if defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs) \
123
    || defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon) \
124
    || defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
125
 
126
    CYG_ADDRWORD __ra;
127
    CYG_WORD32 __pc;
128
    HAL_SavedRegisters *sreg = (HAL_SavedRegisters *)regs;
129
 
130
    CYGARC_HAL_GET_RETURN_ADDRESS(__ra, _cyg_hal_compiler_dummy);
131
 
132
    if( regs == NULL ) __pc = __ra;
133
    else  CYGARC_HAL_GET_PC_REG(sreg, __pc);
134
 
135
    CYGACC_CALL_IF_INSTALL_BPT_FN((void *)__pc);
136
 
137
    CYGARC_HAL_GET_RETURN_ADDRESS_BACKUP(_cyg_hal_compiler_dummy);
138
 
139
#else
140
 
141
    HAL_BREAKPOINT(breakinst);
142
 
143
#endif
144
}
145
 
146
 
147
//--------------------------------------------------------------------------
148
// The system default interrupt ISR. It calls the architecture default
149
// ISR as well if necessary.
150
externC cyg_uint32 hal_arch_default_isr(CYG_ADDRWORD vector,
151
                                        CYG_ADDRWORD data);
152
 
153
cyg_uint32
154
hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
155
{
156
    cyg_uint32 result;
157
 
158
#if (defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)           \
159
     || defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT)) &&    \
160
        (defined(CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT) ||     \
161
          defined(CYGHWR_HAL_GDB_PORT_VECTOR) &&           \
162
          defined(HAL_CTRLC_ISR))
163
 
164
#ifndef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN    
165
#if CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
166
    int gdb_vector = -1;
167
    // This check only to avoid crash on older stubs in case of unhandled
168
    // interrupts. It is a bit messy, but required in a transition period.
169
#ifndef CYGSEM_HAL_ROM_MONITOR
170
    if (CYGNUM_CALL_IF_TABLE_VERSION_CALL_HACK ==
171
        (CYGACC_CALL_IF_VERSION() & CYGNUM_CALL_IF_TABLE_VERSION_CALL_MASK))
172
#endif
173
    {
174
        hal_virtual_comm_table_t* __chan = CYGACC_CALL_IF_DEBUG_PROCS();
175
        if (__chan)
176
            gdb_vector = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_DBG_ISR_VECTOR);
177
    }
178
    if( CYGHWR_HAL_GDB_PORT_VECTORS_MATCH(vector, gdb_vector) )
179
#else
180
    // Old code using hardwired channels. This should go away eventually.
181
    if( vector == CYGHWR_HAL_GDB_PORT_VECTOR )
182
#endif
183
#endif
184
    {
185
        result = HAL_CTRLC_ISR( vector, data );
186
        if( 0 != result ) return result;
187
    }
188
#endif
189
 
190
    result = hal_arch_default_isr (vector, data);
191
    if( 0 != result) return result;
192
 
193
    CYG_TRACE2(true, "Interrupt: %d, Data: 0x%08x", vector, data);
194
    CYG_FAIL("Spurious Interrupt!!!");
195
    return 0;
196
}
197
 
198
 
199
//--------------------------------------------------------------------------
200
// End of hal_misc.c

powered by: WebSVN 2.1.0

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