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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [ts6/] [current/] [src/] [hal_diag.c] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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