]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/hal/mips/jmr3904/v2_0/src/plf_stub.c
Initial revision
[karo-tx-redboot.git] / packages / hal / mips / jmr3904 / v2_0 / src / plf_stub.c
1 //=============================================================================
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 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, jskov (based on the old tx39 hal_stub.c)
44 // Contributors:nickg, jskov
45 // Date:        1999-02-12
46 // Purpose:     Platform specific code for GDB stub support.
47 //              
48 //####DESCRIPTIONEND####
49 //
50 //=============================================================================
51
52 #include <pkgconf/hal.h>
53
54 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
55
56 #include <cyg/hal/hal_stub.h>
57
58 #include <cyg/hal/hal_io.h>             // HAL IO macros
59 #include <cyg/hal/hal_diag.h>           // diag output. FIXME
60
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)
72
73 #define BRG_T0          0x0000
74 #define BRG_T2          0x0100
75 #define BRG_T4          0x0200
76 #define BRG_T5          0x0300
77
78 //-----------------------------------------------------------------------------
79
80 // Initialize the current serial port.
81 void hal_jmr_init_serial( void )
82 {
83 //hal_diag_led(0x10);    
84     HAL_WRITE_UINT16( DIAG_SLCR , 0x0020 );
85
86     HAL_WRITE_UINT16( DIAG_SLDICR , 0x0000 );
87     
88     HAL_WRITE_UINT16( DIAG_SFCR , 0x0000 );
89     
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 );    
93
94 //hal_diag_led(0x10);
95 }
96
97 // Write C to the current serial port.
98 void hal_jmr_put_char( int c )
99 {
100     CYG_WORD16 disr;
101     
102 //hal_diag_led(0x20);
103
104     for(;;)
105     {
106         HAL_READ_UINT16( DIAG_SLDISR , disr );
107
108         if( disr & 0x0002 ) break;
109     }
110
111     disr = disr & ~0x0002;
112     
113     HAL_WRITE_UINT8( DIAG_TFIFO, c );
114
115     HAL_WRITE_UINT16( DIAG_SLDISR , disr );    
116
117 //hal_diag_led(0x20);
118 //    HAL_DIAG_WRITE_CHAR( c );
119 }
120
121 // Read one character from the current serial port.
122 int hal_jmr_get_char( void )
123 {
124 #ifdef CYGPKG_HAL_MIPS_SIM
125     // FIXME: ask nickg if this can go to /dev/null
126     static char input[] = "+$s#73";
127     static int i = 0;
128     return input[i++];
129 #else
130     char c;
131
132     CYG_WORD16 disr;
133
134 //hal_diag_led(0x40);        
135     for(;;)
136     {
137         
138         HAL_READ_UINT16( DIAG_SLDISR , disr );
139
140         if( disr & 0x0001 ) break;
141     }
142
143     disr = disr & ~0x0001;
144     
145     HAL_READ_UINT8( DIAG_RFIFO, c );
146     
147     HAL_WRITE_UINT16( DIAG_SLDISR , disr );    
148
149 //hal_diag_led(0x40);
150     
151 //    HAL_DIAG_READ_CHAR(c);
152 //    diag_printf("<%02x:%c>",c);
153
154     return c;
155     
156 #endif    
157 }
158
159 #endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
160 //-----------------------------------------------------------------------------
161 // End of plf_stub.c