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