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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [vrc437x/] [current/] [src/] [plf_misc.c] - Blame information for rev 825

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      plf_misc.c
4
//
5
//      HAL platform 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 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, jlarmour
44
// Date:         1999-01-21
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/infra/cyg_type.h>         // Base types
56
#include <cyg/infra/cyg_trac.h>         // tracing macros
57
#include <cyg/infra/cyg_ass.h>          // assertion macros
58
 
59
#include <cyg/hal/hal_arch.h>           // architectural definitions
60
 
61
#include <cyg/hal/hal_intr.h>           // Interrupt handling
62
 
63
#include <cyg/hal/hal_cache.h>          // Cache handling
64
 
65
#include <cyg/hal/plf_z8530.h>
66
 
67
/*------------------------------------------------------------------------*/
68
 
69
#ifdef CYGSEM_HAL_MIPS_VR4300_VRC437X_DIAG_ACKS_INT_0
70
 
71
static cyg_uint32 hal_int0_count = 0;
72
 
73
static cyg_uint32 hal_int0_isr( cyg_uint32 vector, cyg_uint32 data )
74
{
75
    hal_int0_count++;
76
    HAL_INTERRUPT_ACKNOWLEDGE( CYGNUM_HAL_INTERRUPT_VRC437X );
77
    return 0;
78
}
79
 
80
#endif
81
 
82
/*------------------------------------------------------------------------*/
83
 
84
 
85
void hal_platform_init(void)
86
{
87
#ifdef CYGSEM_HAL_MIPS_VR4300_VRC437X_DIAG_ACKS_INT_0
88
    HAL_INTERRUPT_ATTACH( CYGNUM_HAL_INTERRUPT_VRC437X, hal_int0_isr, 0, 0 );
89
#endif
90
 
91
#if defined(CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT)
92
    // Set up eCos/ROM interfaces
93
    hal_if_init();
94
#endif    
95
 
96
#if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT)      && \
97
    (defined(CYGSEM_HAL_USE_ROM_MONITOR_CygMon)    || \
98
     defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs))
99
 
100
    {
101
        extern CYG_ADDRESS hal_virtual_vector_table[32];
102
        void patch_dbg_syscalls( void * );
103
        patch_dbg_syscalls( (void *)(&hal_virtual_vector_table[0]) );
104
    }
105
#endif
106
 
107
}
108
/*------------------------------------------------------------------------*/
109
// One-time PCI initialization.
110
 
111
void cyg_hal_plf_pci_init(void)
112
{
113
    cyg_uint8  next_bus;
114
 
115
    // Configure PCI bus.
116
    next_bus = 1;
117
    cyg_pci_configure_bus(0, &next_bus);
118
 
119
}
120
 
121
 
122
/*------------------------------------------------------------------------*/
123
/* Functions to support the detection and execution of a user provoked    */
124
/* program break. These are usually called from interrupt routines.       */
125
 
126
#if !defined(CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT) && \
127
    defined(CYGDBG_HAL_MIPS_DEBUG_GDB_CTRLC_SUPPORT)
128
 
129
cyg_bool cyg_hal_is_break(char *buf, int size)
130
{
131
    while( size )
132
        if( buf[--size] == 0x03 ) return true;
133
 
134
    return false;
135
}
136
 
137
void cyg_hal_user_break( CYG_ADDRWORD *regs )
138
{
139
#if defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs)
140
    // The following code should be at the very start of this function so
141
    // that it can access the RA register before it is saved and reused.
142
    register CYG_WORD32 ra;
143
    asm volatile ( "move %0,$31;" : "=r" (ra) );
144
 
145
        {
146
            extern CYG_ADDRESS hal_virtual_vector_table[64];
147
            typedef void install_bpt_fn(void *epc);
148
            CYG_WORD32 pc;
149
            HAL_SavedRegisters *sreg = (HAL_SavedRegisters *)regs;
150
            install_bpt_fn *ibp = (install_bpt_fn *)hal_virtual_vector_table[35];
151
 
152
            if( regs == NULL ) pc = ra;
153
            else pc = sreg->pc;
154
 
155
            if( ibp != NULL ) ibp((void *)pc);
156
        }
157
 
158
#elif defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
159
 
160
        {
161
            extern void breakpoint(void);
162
            breakpoint();
163
        }
164
 
165
#else
166
 
167
        HAL_BREAKPOINT(breakinst);
168
 
169
#endif
170
 
171
}
172
 
173
#endif
174
 
175
/*------------------------------------------------------------------------*/
176
/* Control C ISR support                                                  */
177
 
178
#if !defined(CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT) && \
179
    defined(CYGDBG_HAL_MIPS_DEBUG_GDB_CTRLC_SUPPORT)
180
 
181
#if CYGHWR_HAL_MIPS_VR4300_VRC437X_GDB_PORT == 0
182
#define DUART_CHAN      DUART_A
183
#else
184
#define DUART_CHAN      DUART_B
185
#endif
186
 
187
struct Hal_SavedRegisters *hal_saved_interrupt_state;
188
 
189
void hal_ctrlc_isr_init(void)
190
{
191
    HAL_DUART_WRITE_CR( DUART_CHAN, 1, 0x10 );
192
    HAL_DUART_WRITE_CR( DUART_CHAN, 9, 0x0a );
193
    HAL_INTERRUPT_SET_LEVEL( CYGHWR_HAL_GDB_PORT_VECTOR, 0 );
194
    HAL_INTERRUPT_UNMASK( CYGHWR_HAL_GDB_PORT_VECTOR );
195
}
196
 
197
cyg_uint32 hal_ctrlc_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
198
{
199
 
200
    char c;
201
    cyg_uint8 rr0;
202
 
203
    HAL_INTERRUPT_ACKNOWLEDGE( CYGHWR_HAL_GDB_PORT_VECTOR );
204
    HAL_DUART_READ_CR(DUART_CHAN, 0, rr0 );
205
 
206
    // The following return value prevents a spurious interrupt report.
207
    // That is what should happen, but for some reason we get the odd extra
208
    // character when running in the test farm. 
209
 
210
    if ( (rr0 & 0x01) == 0 ) return 2;
211
 
212
    HAL_DUART_READ_RR( DUART_CHAN, c );
213
 
214
    if( cyg_hal_is_break( &c , 1 ) )
215
        cyg_hal_user_break( (CYG_ADDRWORD *)hal_saved_interrupt_state );
216
 
217
    return 2;
218
}
219
 
220
#endif
221
 
222
/*------------------------------------------------------------------------*/
223
/* End of plf_misc.c                                                      */

powered by: WebSVN 2.1.0

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