OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mn10300/] [stdeval1/] [v2_0/] [src/] [plf_stub.c] - Blame information for rev 454

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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 mn10300 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_intr.h>           // HAL interrupt macros
60
 
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)
69
 
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)
74
 
75
#define PORT3_MD        ((volatile cyg_uint8 *)0x36008025)
76
 
77
// Mystery register
78
#define TMPSCNT         ((volatile cyg_uint8 *)0x34001071)
79
 
80
#define SIO1_LSTAT_TRDY  0x20
81
#define SIO1_LSTAT_RRDY  0x10
82
 
83
 
84
//---------------------------------------------------------------------------
85
 
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
89
// anything up.
90
int cyg_hal_gdb_isr(cyg_uint32 vector, target_register_t pc)
91
{
92
    if ( CYGNUM_HAL_INTERRUPT_SERIAL_1_RX == vector ) {
93
        cyg_uint8 c;
94
 
95
        HAL_READ_UINT8 (SERIAL1_RXR, c);
96
        HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX);
97
        if( 3 == c )
98
        {
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);
103
 
104
            // Interrupt handled. Don't call ISR proper. At return
105
            // from the VSR, execution will stop at the breakpoint
106
            // just set.
107
            return 0;
108
        }
109
    }
110
 
111
    // Not caused by GDB. Call ISR proper.
112
    return 1;
113
}
114
 
115
int hal_stdeval1_interruptible(int state)
116
{
117
    if (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)
121
    } else {
122
        HAL_INTERRUPT_MASK (CYGNUM_HAL_INTERRUPT_SERIAL_1_RX)
123
    }
124
    return 0;
125
}
126
 
127
void hal_stdeval1_init_break_irq( void )
128
{
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();
134
}
135
#endif
136
 
137
// Initialize the current serial port.
138
void hal_stdeval1_init_serial( void )
139
{
140
    // 48 translates to 38400 baud.
141
    HAL_WRITE_UINT8 (TIMER1_BR, 48);
142
 
143
    // Timer1 sourced from IOCLK
144
    HAL_WRITE_UINT8 (TIMER1_MD, 0x80);
145
 
146
    // Mode on PORT3, used for serial line controls.
147
    HAL_WRITE_UINT8 (PORT3_MD, 0x01);
148
 
149
    // No interrupts for now.
150
    HAL_WRITE_UINT8 (SERIAL1_ICR, 0x00);
151
 
152
    // Source from timer 1, 8bit chars, enable tx and rx
153
    HAL_WRITE_UINT16 (SERIAL1_CR, 0xc084);
154
}
155
 
156
// Write C to the current serial port.
157
void hal_stdeval1_put_char( int c )
158
{
159
    cyg_uint16 sr;
160
 
161
    do {
162
        HAL_READ_UINT16 (SERIAL1_SR, sr);
163
    } while ((sr & SIO1_LSTAT_TRDY) != 0);
164
 
165
    HAL_WRITE_UINT8 (SERIAL1_TXR, c);
166
}
167
 
168
// Read one character from the current serial port.
169
int hal_stdeval1_get_char( void )
170
{
171
    char c;
172
    cyg_uint16 sr;
173
 
174
    do {
175
        HAL_READ_UINT16 (SERIAL1_SR, sr);
176
    } while ((sr & SIO1_LSTAT_RRDY) == 0);
177
 
178
    HAL_READ_UINT8 (SERIAL1_RXR, c);
179
 
180
    return c;
181
}
182
 
183
#endif // ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
184
//-----------------------------------------------------------------------------
185
// End of plf_stub.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.