1 |
27 |
unneback |
//=============================================================================
|
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:tmichals
|
45 |
|
|
// Date: 1999-02-12
|
46 |
|
|
// Purpose: Platform specific code for GDB stub support.
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//=============================================================================
|
51 |
|
|
#include <pkgconf/hal.h>
|
52 |
|
|
#include <pkgconf/system.h>
|
53 |
|
|
|
54 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
55 |
|
|
#include <cyg/hal/drv_api.h> // Cache handling
|
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 |
|
|
#include <cyg/hal/hal_arch.h> // architectural definitions
|
60 |
|
|
#include <cyg/hal/hal_intr.h> // Interrupt handling
|
61 |
|
|
#include <cyg/hal/hal_cache.h> // Cache handling
|
62 |
|
|
|
63 |
|
|
#include <cyg/hal/hal_io.h> // HAL IO macros
|
64 |
|
|
#include <cyg/hal/hal_diag.h> // diag output. FIXME
|
65 |
|
|
#include <cyg/hal/idt32334sio.h>
|
66 |
|
|
#include <pkgconf/hal.h>
|
67 |
|
|
#include <cyg/hal/hal_intr.h>
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
#define PIO_DIRCNTL_REG 0xb8000604
|
72 |
|
|
|
73 |
|
|
void hal_IDT32334_init_serial_baud( int baud )
|
74 |
|
|
{
|
75 |
|
|
cyg_uint16 baud_divisor;
|
76 |
|
|
cyg_uint8 _lcr, _ier;
|
77 |
|
|
cyg_addrword_t port = CMA_SER_16550_BASE_A;
|
78 |
|
|
cyg_uint32 status;
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
HAL_READ_UINT32 ( PIO_DIRCNTL_REG+4, status);
|
82 |
|
|
status |= 0xf0;
|
83 |
|
|
HAL_WRITE_UINT32 ( PIO_DIRCNTL_REG+4, status);
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
HAL_READ_UINT32 (PIO_DIRCNTL_REG, status);
|
87 |
|
|
status &= 0xffffff0f;
|
88 |
|
|
status |= 0x50;
|
89 |
|
|
HAL_WRITE_UINT32(PIO_DIRCNTL_REG, status);
|
90 |
|
|
|
91 |
|
|
baud_divisor = (CYGHWR_HAL_MIPS_CPU_FREQ_ACTUAL) / (16 * baud);
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
// Set databits, stopbits and parity.
|
95 |
|
|
_lcr = LCR_WL8 | LCR_SB1 | LCR_PN;
|
96 |
|
|
|
97 |
|
|
HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
|
98 |
|
|
|
99 |
|
|
// Set baud rate.
|
100 |
|
|
_lcr |= LCR_DL;
|
101 |
|
|
HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
|
102 |
|
|
HAL_WRITE_UINT8(port+SER_16550_DLM, baud_divisor >> 8);
|
103 |
|
|
HAL_WRITE_UINT8(port+SER_16550_DLL, baud_divisor & 0xff);
|
104 |
|
|
_lcr &= ~LCR_DL;
|
105 |
|
|
HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
|
106 |
|
|
|
107 |
|
|
HAL_WRITE_UINT8(port+SER_16550_FCR, 0x1);
|
108 |
|
|
|
109 |
|
|
HAL_WRITE_UINT8(port+SER_16550_MSR, 0x30);
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
#ifndef CYGNUM_IO_SERIAL_IDT32334_SERIAL0_BAUD
|
117 |
|
|
# define CYGNUM_IO_SERIAL_IDT32334_SERIAL0_BAUD 115200
|
118 |
|
|
#endif
|
119 |
|
|
|
120 |
|
|
// Initialize the current serial port.
|
121 |
|
|
void hal_IDT32334_init_serial( void )
|
122 |
|
|
{
|
123 |
|
|
hal_IDT32334_init_serial_baud( CYGNUM_IO_SERIAL_IDT32334_SERIAL0_BAUD);
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
// Write C to the current serial port.
|
127 |
|
|
void hal_IDT32334_put_char( int c )
|
128 |
|
|
{
|
129 |
|
|
cyg_uint8 _lsr;
|
130 |
|
|
cyg_addrword_t port =CMA_SER_16550_BASE_A;
|
131 |
|
|
|
132 |
|
|
do
|
133 |
|
|
{
|
134 |
|
|
HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
|
135 |
|
|
}while ( !(_lsr & SIO_LSR_THRE) && (_lsr));
|
136 |
|
|
|
137 |
|
|
if ((_lsr & SIO_LSR_THRE) || (!_lsr))
|
138 |
|
|
HAL_WRITE_UINT8(port+SER_16550_THR, c);
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
// Read one character from the current serial port.
|
142 |
|
|
int hal_IDT32334_get_char( void )
|
143 |
|
|
{
|
144 |
|
|
unsigned char c;
|
145 |
|
|
cyg_uint8 _lsr;
|
146 |
|
|
cyg_addrword_t port = CMA_SER_16550_BASE_A;
|
147 |
|
|
|
148 |
|
|
do {
|
149 |
|
|
HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
|
150 |
|
|
} while ((_lsr & SIO_LSR_DR) == 0);
|
151 |
|
|
|
152 |
|
|
HAL_READ_UINT8(port+SER_16550_RBR, c);
|
153 |
|
|
return c;
|
154 |
|
|
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
int hal_IDT32334_chk_char()
|
159 |
|
|
{
|
160 |
|
|
unsigned char c;
|
161 |
|
|
cyg_uint8 _lsr;
|
162 |
|
|
cyg_addrword_t port = CMA_SER_16550_BASE_A;
|
163 |
|
|
|
164 |
|
|
HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
|
165 |
|
|
return (_lsr & SIO_LSR_DR)?1:0;
|
166 |
|
|
|
167 |
|
|
}
|
168 |
|
|
//#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
|
169 |
|
|
//-----------------------------------------------------------------------------
|
170 |
|
|
// End of plf_stub.c
|