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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [common/] [v2_0/] [src/] [hal_misc.c] - Blame information for rev 802

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

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