1 |
786 |
skrzyp |
//=============================================================================
|
2 |
|
|
//
|
3 |
|
|
// plf_stub.c
|
4 |
|
|
//
|
5 |
|
|
// Platform specific code for GDB stub support.
|
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, jskov (based on the old mn10300 hal_stub.c)
|
43 |
|
|
// Contributors:nickg, jskov
|
44 |
|
|
// Date: 1999-02-12
|
45 |
|
|
// Purpose: Platform specific code for GDB stub support.
|
46 |
|
|
//
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
//
|
49 |
|
|
//=============================================================================
|
50 |
|
|
|
51 |
|
|
#include <pkgconf/hal.h>
|
52 |
|
|
|
53 |
|
|
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
|
54 |
|
|
|
55 |
|
|
#include <cyg/hal/hal_stub.h>
|
56 |
|
|
|
57 |
|
|
#include <cyg/hal/hal_io.h> // HAL IO macros
|
58 |
|
|
#include <cyg/hal/hal_intr.h> // HAL interrupt macros
|
59 |
|
|
|
60 |
|
|
//---------------------------------------------------------------------------
|
61 |
|
|
// MN10300 Serial line
|
62 |
|
|
// We use serial1 on MN103002
|
63 |
|
|
#define SERIAL1_CR ((volatile cyg_uint16 *)0x34000810)
|
64 |
|
|
#define SERIAL1_ICR ((volatile cyg_uint8 *) 0x34000814)
|
65 |
|
|
#define SERIAL1_TXR ((volatile cyg_uint8 *) 0x34000818)
|
66 |
|
|
#define SERIAL1_RXR ((volatile cyg_uint8 *) 0x34000819)
|
67 |
|
|
#define SERIAL1_SR ((volatile cyg_uint16 *)0x3400081c)
|
68 |
|
|
|
69 |
|
|
// Timer 1 provided baud rate divisor
|
70 |
|
|
#define TIMER1_MD ((volatile cyg_uint8 *)0x34001001)
|
71 |
|
|
#define TIMER1_BR ((volatile cyg_uint8 *)0x34001011)
|
72 |
|
|
#define TIMER1_CR ((volatile cyg_uint8 *)0x34001021)
|
73 |
|
|
|
74 |
|
|
#define PORT3_MD ((volatile cyg_uint8 *)0x36008025)
|
75 |
|
|
|
76 |
|
|
// Mystery register
|
77 |
|
|
#define TMPSCNT ((volatile cyg_uint8 *)0x34001071)
|
78 |
|
|
|
79 |
|
|
#define SIO1_LSTAT_TRDY 0x20
|
80 |
|
|
#define SIO1_LSTAT_RRDY 0x10
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
//---------------------------------------------------------------------------
|
84 |
|
|
|
85 |
|
|
#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
|
86 |
|
|
// This ISR is called from the interrupt handler. This should only
|
87 |
|
|
// happen when there is no serial driver, so the code shouldn't mess
|
88 |
|
|
// anything up.
|
89 |
|
|
int cyg_hal_gdb_isr(cyg_uint32 vector, target_register_t pc)
|
90 |
|
|
{
|
91 |
|
|
if ( CYGNUM_HAL_INTERRUPT_SERIAL_1_RX == vector ) {
|
92 |
|
|
cyg_uint8 c;
|
93 |
|
|
|
94 |
|
|
HAL_READ_UINT8 (SERIAL1_RXR, c);
|
95 |
|
|
HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX);
|
96 |
|
|
if( 3 == c )
|
97 |
|
|
{
|
98 |
|
|
// Ctrl-C: set a breakpoint at PC so GDB will display the
|
99 |
|
|
// correct program context when stopping rather than the
|
100 |
|
|
// interrupt handler.
|
101 |
|
|
cyg_hal_gdb_interrupt (pc);
|
102 |
|
|
|
103 |
|
|
// Interrupt handled. Don't call ISR proper. At return
|
104 |
|
|
// from the VSR, execution will stop at the breakpoint
|
105 |
|
|
// just set.
|
106 |
|
|
return 0;
|
107 |
|
|
}
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
// Not caused by GDB. Call ISR proper.
|
111 |
|
|
return 1;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
int hal_stdeval1_interruptible(int state)
|
115 |
|
|
{
|
116 |
|
|
if (state) {
|
117 |
|
|
HAL_WRITE_UINT8 (SERIAL1_ICR, 0);
|
118 |
|
|
HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
|
119 |
|
|
HAL_INTERRUPT_UNMASK (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
|
120 |
|
|
} else {
|
121 |
|
|
HAL_INTERRUPT_MASK (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
|
122 |
|
|
}
|
123 |
|
|
return 0;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
void hal_stdeval1_init_break_irq( void )
|
127 |
|
|
{
|
128 |
|
|
// Enable serial receive interrupts.
|
129 |
|
|
HAL_WRITE_UINT8 (SERIAL1_ICR, 0);
|
130 |
|
|
HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
|
131 |
|
|
HAL_INTERRUPT_UNMASK (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
|
132 |
|
|
HAL_ENABLE_INTERRUPTS();
|
133 |
|
|
}
|
134 |
|
|
#endif
|
135 |
|
|
|
136 |
|
|
// Initialize the current serial port.
|
137 |
|
|
void hal_stdeval1_init_serial( void )
|
138 |
|
|
{
|
139 |
|
|
// 48 translates to 38400 baud.
|
140 |
|
|
HAL_WRITE_UINT8 (TIMER1_BR, 48);
|
141 |
|
|
|
142 |
|
|
// Timer1 sourced from IOCLK
|
143 |
|
|
HAL_WRITE_UINT8 (TIMER1_MD, 0x80);
|
144 |
|
|
|
145 |
|
|
// Mode on PORT3, used for serial line controls.
|
146 |
|
|
HAL_WRITE_UINT8 (PORT3_MD, 0x01);
|
147 |
|
|
|
148 |
|
|
// No interrupts for now.
|
149 |
|
|
HAL_WRITE_UINT8 (SERIAL1_ICR, 0x00);
|
150 |
|
|
|
151 |
|
|
// Source from timer 1, 8bit chars, enable tx and rx
|
152 |
|
|
HAL_WRITE_UINT16 (SERIAL1_CR, 0xc084);
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
// Write C to the current serial port.
|
156 |
|
|
void hal_stdeval1_put_char( int c )
|
157 |
|
|
{
|
158 |
|
|
cyg_uint16 sr;
|
159 |
|
|
|
160 |
|
|
do {
|
161 |
|
|
HAL_READ_UINT16 (SERIAL1_SR, sr);
|
162 |
|
|
} while ((sr & SIO1_LSTAT_TRDY) != 0);
|
163 |
|
|
|
164 |
|
|
HAL_WRITE_UINT8 (SERIAL1_TXR, c);
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
// Read one character from the current serial port.
|
168 |
|
|
int hal_stdeval1_get_char( void )
|
169 |
|
|
{
|
170 |
|
|
char c;
|
171 |
|
|
cyg_uint16 sr;
|
172 |
|
|
|
173 |
|
|
do {
|
174 |
|
|
HAL_READ_UINT16 (SERIAL1_SR, sr);
|
175 |
|
|
} while ((sr & SIO1_LSTAT_RRDY) == 0);
|
176 |
|
|
|
177 |
|
|
HAL_READ_UINT8 (SERIAL1_RXR, c);
|
178 |
|
|
|
179 |
|
|
return c;
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
|
183 |
|
|
//-----------------------------------------------------------------------------
|
184 |
|
|
// End of plf_stub.c
|