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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [powerpc/] [ts6/] [v2_0/] [src/] [hal_diag.c] - Blame information for rev 249

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

Line No. Rev Author Line
1 27 unneback
//=============================================================================
2
//
3
//      hal_diag.c
4
//
5
//      HAL diagnostic output code
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
// Copyright (C) 2002 Gary Thomas
13
//
14
// eCos is free software; you can redistribute it and/or modify it under
15
// the terms of the GNU General Public License as published by the Free
16
// Software Foundation; either version 2 or (at your option) any later version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License along
24
// with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26
//
27
// As a special exception, if other files instantiate templates or use macros
28
// or inline functions from this file, or you compile this file and link it
29
// with other works to produce a work based on this file, this file does not
30
// by itself cause the resulting work to be covered by the GNU General Public
31
// License. However the source code for this file must still be made available
32
// in accordance with section (3) of the GNU General Public License.
33
//
34
// This exception does not invalidate any other reasons why a work based on
35
// this file might be covered by the GNU General Public License.
36
//
37
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38
// at http://sources.redhat.com/ecos/ecos-license/
39
// -------------------------------------------
40
//####ECOSGPLCOPYRIGHTEND####
41
//=============================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):   pfine
45
// Contributors:hmt, jskov
46
// Date:        2002-02-27
47
// Purpose:     HAL diagnostic output
48
// Description: Implementations of HAL diagnostic output support.
49
//
50
//####DESCRIPTIONEND####
51
//
52
//=============================================================================
53
 
54
#include <pkgconf/hal.h>
55
 
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
 
60
#include <cyg/hal/hal_io.h>             // IO macros
61
#include <cyg/hal/hal_diag.h>
62
#include <cyg/hal/hal_intr.h>           // Interrupt macros
63
 
64
#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
65
#include <cyg/hal/hal_stub.h>           // hal_output_gdb_string
66
#endif
67
 
68
#include <cyg/hal/ppc_regs.h>
69
#include <cyg/hal/mpc8260.h>
70
 
71
// This prototype probably needs to be in an include file
72
void
73
cyg_hal_plf_serial_init(void);
74
 
75
 
76
void
77
cyg_hal_plf_comms_init(void)
78
{
79
    static int initialized = 0;
80
 
81
    if (initialized)
82
        return;
83
    initialized = 1;
84
 
85
/* This is where I will put the SCC1 initialization code */
86
    cyg_hal_plf_serial_init();
87
}
88
 
89
 
90
#ifdef LATER
91
#if !defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG)
92
 
93
//-----------------------------------------------------------------------------
94
// Select default diag channel to use
95
 
96
//#define CYG_KERNEL_DIAG_ROMART
97
//#define CYG_KERNEL_DIAG_SERIAL
98
 
99
#if !defined(CYG_KERNEL_DIAG_SERIAL)
100
#define CYG_KERNEL_DIAG_SERIAL
101
#endif
102
 
103
#ifdef CYGDBG_DIAG_BUF
104
// Keep diag messages in a buffer for later [re]display
105
 
106
int enable_diag_uart = 1;
107
int enable_diag_buf = 1;
108
static char diag_buf[40960*4];
109
static int  diag_buf_ptr = 0;
110
 
111
static void
112
diag_putc(char c)
113
{
114
    if (enable_diag_buf) {
115
        diag_buf[diag_buf_ptr++] = c;
116
        if (diag_buf_ptr == sizeof(diag_buf)) diag_buf_ptr--;
117
    }
118
}
119
 
120
void
121
dump_diag_buf(int start, int len)
122
{
123
    int i;
124
    enable_diag_uart = 1;
125
    enable_diag_buf = 0;
126
    if (len == 0) len = diag_buf_ptr;
127
    diag_printf("\nDiag buf\n");
128
    for (i = start;  i < len;  i++) {
129
        hal_diag_write_char(diag_buf[i]);
130
    }
131
}
132
#endif // CYGDBG_DIAG_BUF
133
 
134
 
135
//-----------------------------------------------------------------------------
136
// MBX board specific serial output; using GDB protocol by default:
137
 
138
 
139
#if defined(CYG_KERNEL_DIAG_SERIAL)
140
 
141
t_PQ2IMM *IMM;
142
 
143
void hal_diag_init(void)
144
{
145
    static int init = 0;
146
    if (init) return;
147
    init++;
148
 
149
    // hardwired base
150
    //eppc = eppc_base();
151
    IMM = (t_PQ2IMM *) 0x04700000;
152
 
153
    // init the actual serial port
154
    cyg_hal_plf_serial_init_channel();
155
#ifdef CYGSEM_HAL_DIAG_MANGLER_GDB
156
#ifndef CYG_HAL_STARTUP_ROM
157
    // We are talking to GDB; ack the "go" packet!
158
    cyg_hal_plf_serial_putc('+');
159
#endif
160
#endif
161
}
162
 
163
void hal_diag_write_char_serial( char c )
164
{
165
    unsigned long __state;
166
    HAL_DISABLE_INTERRUPTS(__state);
167
    cyg_hal_plf_serial_putc(c);
168
    HAL_RESTORE_INTERRUPTS(__state);
169
}
170
 
171
#if defined(CYG_HAL_STARTUP_ROM) || !defined(CYGDBG_HAL_DIAG_TO_DEBUG_CHAN)
172
void hal_diag_write_char(char c)
173
{
174
#ifdef CYGDBG_DIAG_BUF
175
    diag_putc(c);
176
    if (!enable_diag_uart) return;
177
#endif // CYGDBG_DIAG_BUF
178
    hal_diag_write_char_serial(c);
179
}
180
 
181
#else // RAM start so encode for GDB
182
 
183
void hal_diag_write_char(char c)
184
{
185
    static char line[100];
186
    static int pos = 0;
187
 
188
#ifdef CYGDBG_DIAG_BUF
189
    diag_putc(c);
190
    if (!enable_diag_uart) return;
191
#endif // CYGDBG_DIAG_BUF
192
 
193
    // No need to send CRs
194
    if( c == '\r' ) return;
195
 
196
    line[pos++] = c;
197
 
198
    if( c == '\n' || pos == sizeof(line) )
199
    {
200
        CYG_INTERRUPT_STATE old;
201
 
202
        // Disable interrupts. This prevents GDB trying to interrupt us
203
        // while we are in the middle of sending a packet. The serial
204
        // receive interrupt will be seen when we re-enable interrupts
205
        // later.
206
 
207
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
208
        CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old);
209
#else
210
        HAL_DISABLE_INTERRUPTS(old);
211
#endif
212
 
213
        while(1)
214
        {
215
            static char hex[] = "0123456789ABCDEF";
216
            cyg_uint8 csum = 0;
217
            int i;
218
 
219
            hal_diag_write_char_serial('$');
220
            hal_diag_write_char_serial('O');
221
            csum += 'O';
222
            for( i = 0; i < pos; i++ )
223
            {
224
                char ch = line[i];
225
                char h = hex[(ch>>4)&0xF];
226
                char l = hex[ch&0xF];
227
                hal_diag_write_char_serial(h);
228
                hal_diag_write_char_serial(l);
229
                csum += h;
230
                csum += l;
231
            }
232
            hal_diag_write_char_serial('#');
233
            hal_diag_write_char_serial(hex[(csum>>4)&0xF]);
234
            hal_diag_write_char_serial(hex[csum&0xF]);
235
 
236
#ifndef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
237
            // only gobble characters if no interrupt handler to grab ^Cs
238
            // is installed (which is exclusive with device driver use)
239
 
240
            // Wait for the ACK character '+' from GDB here and handle
241
            // receiving a ^C instead.  This is the reason for this clause
242
            // being a loop.
243
            c = cyg_hal_plf_serial_getc(eppc);
244
 
245
            if( c == '+' )
246
                break;              // a good acknowledge
247
#if 0
248
            if( c1 == 3 ) {
249
                // Ctrl-C: breakpoint.
250
                breakpoint();
251
                break;
252
            }
253
#endif
254
            // otherwise, loop round again
255
#else
256
            break;
257
#endif
258
        }
259
 
260
        pos = 0;
261
 
262
        // And re-enable interrupts
263
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
264
        CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old);
265
#else
266
        HAL_RESTORE_INTERRUPTS(old);
267
#endif
268
 
269
    }
270
}
271
#endif // NOT def CYG_HAL_STARTUP_ROM
272
 
273
#if 0
274
// These should not need to be prototyped here, but where????
275
cyg_uint8
276
cyg_hal_plf_serial_getc(void* __ch_data);
277
 
278
void
279
cyg_hal_plf_serial_putc(void* __ch_data, cyg_uint8 ch);
280
#endif
281
 
282
void hal_diag_read_char(char *c)
283
{
284
    *c = cyg_hal_plf_serial_getc();
285
}
286
 
287
#endif // CYG_KERNEL_DIAG_SERIAL
288
 
289
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
290
#endif
291
 
292
// EOF hal_diag.c

powered by: WebSVN 2.1.0

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