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 tx39 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_diag.h> // diag output. FIXME
61 //-----------------------------------------------------------------------------
62 // Serial definitions.
63 #define DIAG_BASE 0xfffff300
64 #define DIAG_SLCR (DIAG_BASE+0x00)
65 #define DIAG_SLSR (DIAG_BASE+0x04)
66 #define DIAG_SLDICR (DIAG_BASE+0x08)
67 #define DIAG_SLDISR (DIAG_BASE+0x0C)
68 #define DIAG_SFCR (DIAG_BASE+0x10)
69 #define DIAG_SBRG (DIAG_BASE+0x14)
70 #define DIAG_TFIFO (DIAG_BASE+0x20)
71 #define DIAG_RFIFO (DIAG_BASE+0x30)
78 //-----------------------------------------------------------------------------
80 // Initialize the current serial port.
81 void hal_jmr_init_serial( void )
84 HAL_WRITE_UINT16( DIAG_SLCR , 0x0020 );
86 HAL_WRITE_UINT16( DIAG_SLDICR , 0x0000 );
88 HAL_WRITE_UINT16( DIAG_SFCR , 0x0000 );
90 // HAL_WRITE_UINT16( DIAG_SBRG , BRG_T2 | 20 );
91 // HAL_WRITE_UINT16( DIAG_SBRG , BRG_T2 | 10 );
92 HAL_WRITE_UINT16( DIAG_SBRG , BRG_T2 | 5 );
97 // Write C to the current serial port.
98 void hal_jmr_put_char( int c )
102 //hal_diag_led(0x20);
106 HAL_READ_UINT16( DIAG_SLDISR , disr );
108 if( disr & 0x0002 ) break;
111 disr = disr & ~0x0002;
113 HAL_WRITE_UINT8( DIAG_TFIFO, c );
115 HAL_WRITE_UINT16( DIAG_SLDISR , disr );
117 //hal_diag_led(0x20);
118 // HAL_DIAG_WRITE_CHAR( c );
121 // Read one character from the current serial port.
122 int hal_jmr_get_char( void )
124 #ifdef CYGPKG_HAL_MIPS_SIM
125 // FIXME: ask nickg if this can go to /dev/null
126 static char input[] = "+$s#73";
134 //hal_diag_led(0x40);
138 HAL_READ_UINT16( DIAG_SLDISR , disr );
140 if( disr & 0x0001 ) break;
143 disr = disr & ~0x0001;
145 HAL_READ_UINT8( DIAG_RFIFO, c );
147 HAL_WRITE_UINT16( DIAG_SLDISR , disr );
149 //hal_diag_led(0x40);
151 // HAL_DIAG_READ_CHAR(c);
152 // diag_printf("<%02x:%c>",c);
159 #endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
160 //-----------------------------------------------------------------------------