1 //=============================================================================
5 // Platform specific code for GDB stub support.
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.
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.
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
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.
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.
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.
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####
43 // Author(s): nickg, jskov (based on the old mn10300 hal_stub.c)
44 // Contributors:nickg, jskov
46 // Purpose: Platform specific code for GDB stub support.
48 //####DESCRIPTIONEND####
50 //=============================================================================
52 #include <pkgconf/hal.h>
54 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
56 #include <cyg/hal/hal_stub.h>
58 #include <cyg/hal/hal_io.h> // HAL IO macros
59 #include <cyg/hal/hal_intr.h> // HAL interrupt macros
61 //---------------------------------------------------------------------------
62 // MN10300 Serial line
63 // We use serial1 on MN103002
64 #define SERIAL1_CR ((volatile cyg_uint16 *)0x34000810)
65 #define SERIAL1_ICR ((volatile cyg_uint8 *) 0x34000814)
66 #define SERIAL1_TXR ((volatile cyg_uint8 *) 0x34000818)
67 #define SERIAL1_RXR ((volatile cyg_uint8 *) 0x34000819)
68 #define SERIAL1_SR ((volatile cyg_uint16 *)0x3400081c)
70 // Timer 1 provided baud rate divisor
71 #define TIMER1_MD ((volatile cyg_uint8 *)0x34001001)
72 #define TIMER1_BR ((volatile cyg_uint8 *)0x34001011)
73 #define TIMER1_CR ((volatile cyg_uint8 *)0x34001021)
75 #define PORT3_MD ((volatile cyg_uint8 *)0x36008025)
78 #define TMPSCNT ((volatile cyg_uint8 *)0x34001071)
80 #define SIO1_LSTAT_TRDY 0x20
81 #define SIO1_LSTAT_RRDY 0x10
84 //---------------------------------------------------------------------------
86 #ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
87 // This ISR is called from the interrupt handler. This should only
88 // happen when there is no serial driver, so the code shouldn't mess
90 int cyg_hal_gdb_isr(cyg_uint32 vector, target_register_t pc)
92 if ( CYGNUM_HAL_INTERRUPT_SERIAL_1_RX == vector ) {
95 HAL_READ_UINT8 (SERIAL1_RXR, c);
96 HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX);
99 // Ctrl-C: set a breakpoint at PC so GDB will display the
100 // correct program context when stopping rather than the
101 // interrupt handler.
102 cyg_hal_gdb_interrupt (pc);
104 // Interrupt handled. Don't call ISR proper. At return
105 // from the VSR, execution will stop at the breakpoint
111 // Not caused by GDB. Call ISR proper.
115 int hal_stdeval1_interruptible(int state)
118 HAL_WRITE_UINT8 (SERIAL1_ICR, 0);
119 HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
120 HAL_INTERRUPT_UNMASK (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
122 HAL_INTERRUPT_MASK (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
127 void hal_stdeval1_init_break_irq( void )
129 // Enable serial receive interrupts.
130 HAL_WRITE_UINT8 (SERIAL1_ICR, 0);
131 HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
132 HAL_INTERRUPT_UNMASK (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
133 HAL_ENABLE_INTERRUPTS();
137 // Initialize the current serial port.
138 void hal_stdeval1_init_serial( void )
140 // 48 translates to 38400 baud.
141 HAL_WRITE_UINT8 (TIMER1_BR, 48);
143 // Timer1 sourced from IOCLK
144 HAL_WRITE_UINT8 (TIMER1_MD, 0x80);
146 // Mode on PORT3, used for serial line controls.
147 HAL_WRITE_UINT8 (PORT3_MD, 0x01);
149 // No interrupts for now.
150 HAL_WRITE_UINT8 (SERIAL1_ICR, 0x00);
152 // Source from timer 1, 8bit chars, enable tx and rx
153 HAL_WRITE_UINT16 (SERIAL1_CR, 0xc084);
156 // Write C to the current serial port.
157 void hal_stdeval1_put_char( int c )
162 HAL_READ_UINT16 (SERIAL1_SR, sr);
163 } while ((sr & SIO1_LSTAT_TRDY) != 0);
165 HAL_WRITE_UINT8 (SERIAL1_TXR, c);
168 // Read one character from the current serial port.
169 int hal_stdeval1_get_char( void )
175 HAL_READ_UINT16 (SERIAL1_SR, sr);
176 } while ((sr & SIO1_LSTAT_RRDY) == 0);
178 HAL_READ_UINT8 (SERIAL1_RXR, c);
183 #endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
184 //-----------------------------------------------------------------------------