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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [vrc437x/] [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):   nickg
43
// Contributors:        nickg
44
// Date:        1998-03-02
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_arch.h>
59
#include <cyg/hal/hal_diag.h>
60
 
61
#include <cyg/hal/hal_intr.h>
62
 
63
#include <cyg/hal/hal_io.h>
64
 
65
#include <cyg/hal/plf_stub.h>
66
 
67
 
68
#if defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs)
69
 
70
#define CYG_KERNEL_DIAG_GDB
71
 
72
#endif
73
 
74
/*---------------------------------------------------------------------------*/
75
 
76
void hal_diag_init()
77
{
78
    cyg_hal_plf_comms_init();
79
}
80
 
81
/*---------------------------------------------------------------------------*/
82
 
83
void hal_diag_write_char(char c)
84
{
85
#ifdef CYG_KERNEL_DIAG_GDB    
86
    static char line[100];
87
    static int pos = 0;
88
 
89
    // No need to send CRs
90
    if( c == '\r' ) return;
91
 
92
    line[pos++] = c;
93
 
94
    if( c == '\n' || pos == sizeof(line) )
95
    {
96
 
97
        // Disable interrupts. This prevents GDB trying to interrupt us
98
        // while we are in the middle of sending a packet. The serial
99
        // receive interrupt will be seen when we re-enable interrupts
100
        // later.
101
        CYG_INTERRUPT_STATE oldstate;
102
        HAL_DISABLE_INTERRUPTS(oldstate);
103
 
104
        while(1)
105
        {
106
            static char hex[] = "0123456789ABCDEF";
107
            cyg_uint8 csum = 0;
108
            int i;
109
            char c1;
110
 
111
            cyg_hal_plf_serial_putc(NULL, '$');
112
            cyg_hal_plf_serial_putc(NULL, 'O');
113
            csum += 'O';
114
            for( i = 0; i < pos; i++ )
115
            {
116
                char ch = line[i];
117
                char h = hex[(ch>>4)&0xF];
118
                char l = hex[ch&0xF];
119
                cyg_hal_plf_serial_putc(NULL, h);
120
                cyg_hal_plf_serial_putc(NULL, l);
121
                csum += h;
122
                csum += l;
123
            }
124
            cyg_hal_plf_serial_putc(NULL, '#');
125
            cyg_hal_plf_serial_putc(NULL, hex[(csum>>4)&0xF]);
126
            cyg_hal_plf_serial_putc(NULL, hex[csum&0xF]);
127
 
128
            c1 = cyg_hal_plf_serial_getc( NULL );
129
 
130
            if( c1 == '+' ) break;
131
 
132
            if( cyg_hal_is_break( &c1 , 1 ) )
133
                cyg_hal_user_break( NULL );
134
 
135
        }
136
 
137
        pos = 0;
138
 
139
        // Wait for all data from serial line to drain
140
        // and clear ready-to-send indication.
141
//        hal_diag_drain_serial0();
142
 
143
        // Disabling the interrupts for an extended period of time
144
        // can provoke a spurious interrupt 0. FIXME - why?
145
#ifdef CYGSEM_HAL_MIPS_VR4300_VRC437X_DIAG_ACKS_INT_0
146
        HAL_INTERRUPT_ACKNOWLEDGE( CYGNUM_HAL_INTERRUPT_VRC437X );
147
#endif
148
 
149
        // And re-enable interrupts
150
        HAL_RESTORE_INTERRUPTS( oldstate );
151
 
152
    }
153
#else
154
    cyg_hal_plf_serial_putc(NULL, c);
155
#endif    
156
}
157
 
158
/*---------------------------------------------------------------------------*/
159
 
160
void hal_diag_read_char(char *c)
161
{
162
    *c = cyg_hal_plf_serial_getc(NULL);
163
}
164
 
165
/*---------------------------------------------------------------------------*/
166
/* End of hal_diag.c */

powered by: WebSVN 2.1.0

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