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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mn10300/] [asb/] [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):   dmoseley (based on the original by jskov)
43
// Contributors:nickg, jskov, dmoseley
44
// Date:        2000-08-11
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
#if !defined(CYGSEM_HAL_VIRTUAL_VECTOR_DIAG)
55
 
56
#warning HAL_DIAG has only been verified using CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
57
 
58
#include <cyg/infra/cyg_type.h>         // base types
59
#include <cyg/infra/cyg_trac.h>         // tracing macros
60
#include <cyg/infra/cyg_ass.h>          // assertion macros
61
 
62
#include <cyg/hal/hal_diag.h>
63
#include <cyg/hal/hal_intr.h>
64
 
65
#warning GET HAL_DIAG STUFF WORKING
66
 
67
/*---------------------------------------------------------------------------*/
68
/* Select default diag channel to use                                        */
69
 
70
//#define CYG_KERNEL_DIAG_SERIAL
71
//#define CYG_KERNEL_DIAG_BUFFER
72
//#define CYG_KERNEL_DIAG_GDB
73
 
74
#if !defined(CYG_KERNEL_DIAG_SERIAL) && defined(CYGSEM_HAL_USE_ROM_MONITOR_GDB_stubs)
75
#  define CYG_KERNEL_DIAG_SERIAL
76
#  define CYG_KERNEL_DIAG_GDB
77
#else
78
#  define CYG_KERNEL_DIAG_SERIAL
79
#endif
80
 
81
/*---------------------------------------------------------------------------*/
82
 
83
externC void diag_write_string (const char*);
84
 
85
#if defined(CYG_KERNEL_DIAG_SERIAL)
86
extern void cyg_hal_plf_comms_init(void);
87
extern void cyg_hal_plf_serial_putc(void*, cyg_uint8);
88
extern cyg_uint8 cyg_hal_plf_serial_getc(void*);
89
#endif
90
 
91
#if defined(CYG_KERNEL_DIAG_BUFFER)
92
char hal_diag_buffer[10000];
93
int hal_diag_buffer_pos;
94
#endif
95
 
96
void hal_diag_init(void)
97
{
98
#if defined(CYG_KERNEL_DIAG_SERIAL)
99
  cyg_hal_plf_comms_init();
100
#endif
101
 
102
#if defined(CYG_KERNEL_DIAG_BUFFER)
103
    hal_diag_buffer_pos = 0;
104
#endif
105
}
106
 
107
#ifdef CYG_KERNEL_DIAG_GDB
108
static void gdb_diag_write_char(char c)
109
{
110
    static char line[100];
111
    static int pos = 0;
112
 
113
    // No need to send CRs
114
    if( c == '\r' ) return;
115
 
116
    line[pos++] = c;
117
 
118
    if( c == '\n' || pos == sizeof(line) )
119
    {
120
        while (1)
121
        {
122
            static char hex[] = "0123456789ABCDEF";
123
            cyg_uint8 csum = 0;
124
            int i;
125
 
126
            hal_diag_write_char_serial('$');
127
            hal_diag_write_char_serial('O');
128
            csum += 'O';
129
            for( i = 0; i < pos; i++ )
130
            {
131
                char ch = line[i];
132
                char h = hex[(ch>>4)&0xF];
133
                char l = hex[ch&0xF];
134
                hal_diag_write_char_serial(h);
135
                hal_diag_write_char_serial(l);
136
                csum += h;
137
                csum += l;
138
            }
139
            hal_diag_write_char_serial('#');
140
            hal_diag_write_char_serial(hex[(csum>>4)&0xF]);
141
            hal_diag_write_char_serial(hex[csum&0xF]);
142
 
143
            {
144
                char c1;
145
 
146
                hal_diag_read_char_serial( &c1 );
147
 
148
                if( c1 == '+' ) break;
149
 
150
 
151
                if( cyg_hal_is_break( &c1, 1 ) )
152
                    cyg_hal_user_break( NULL );
153
            }
154
        }
155
 
156
        pos = 0;
157
    }
158
}
159
#endif // CYG_KERNEL_DIAG_GDB
160
 
161
void hal_diag_write_char(char c)
162
{
163
  unsigned long __state;
164
 
165
  HAL_DISABLE_INTERRUPTS(__state);
166
 
167
  if(c == '\n')
168
    {
169
#if defined (CYG_KERNEL_DIAG_SERIAL)
170
      cyg_hal_plf_serial_putc(NULL, '\r');
171
      cyg_hal_plf_serial_putc(NULL, '\n');
172
#endif
173
#if defined(CYG_KERNEL_DIAG_BUFFER)
174
      hal_diag_buffer[hal_diag_buffer_pos++] = c;
175
      if (hal_diag_buffer_pos >= sizeof(hal_diag_buffer) )
176
          hal_diag_buffer_pos = 0;
177
#endif
178
#if defined(CYG_KERNEL_DIAG_GDB)
179
      gdb_diag_write_char(c);
180
#endif
181
    }
182
  else if (c == '\r')
183
    {
184
      // Ignore '\r'
185
    }
186
  else
187
    {
188
#if defined(CYG_KERNEL_DIAG_SERIAL)
189
      cyg_hal_plf_serial_putc(NULL, c);
190
#endif
191
#if defined(CYG_KERNEL_DIAG_BUFFER)
192
      hal_diag_buffer[hal_diag_buffer_pos++] = c;
193
      if (hal_diag_buffer_pos >= sizeof(hal_diag_buffer) )
194
          hal_diag_buffer_pos = 0;
195
#endif
196
#if defined(CYG_KERNEL_DIAG_GDB)
197
      gdb_diag_write_char(c);
198
#endif
199
    }
200
 
201
  HAL_RESTORE_INTERRUPTS(__state);
202
}
203
 
204
void hal_diag_read_char(char *c)
205
{
206
#if defined(CYG_KERNEL_DIAG_SERIAL)
207
    cyg_hal_plf_serial_getc(c);
208
#endif
209
}
210
 
211
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
212
 
213
/*---------------------------------------------------------------------------*/
214
/* 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.