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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [cme555/] [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):    Bob Koninckx
43
// Contributors: Bob Koninckx
44
// Date:         2001-12-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
#include <cyg/hal/hal_diag.h>           // our header.
55
 
56
#include <cyg/infra/cyg_type.h>         // base types, externC
57
#include <cyg/hal/drv_api.h>            // CYG_ISR_HANDLED
58
#include <cyg/hal/hal_misc.h>           // Helper functions
59
#include <cyg/hal/hal_io.h>             // IO macros
60
#include <cyg/hal/hal_intr.h>           // Interrupt macros
61
 
62
#include <cyg/hal/hal_arch.h>           // SAVE/RESTORE GP
63
#include <cyg/hal/hal_if.h>             // Calling-if API
64
 
65
 
66
static void cyg_hal_plf_serial_init(void);
67
 
68
void
69
cyg_hal_plf_comms_init(void)
70
{
71
    static int initialized = 0;
72
 
73
    if (initialized)
74
        return;
75
 
76
    initialized = 1;
77
 
78
    cyg_hal_plf_serial_init();
79
}
80
 
81
//=============================================================================
82
// Serial driver
83
//=============================================================================
84
 
85
//-----------------------------------------------------------------------------
86
// There are two serial ports.
87
#define CYG_DEV_SERIAL_BASE_A    0x305008 // SCI1
88
#define CYG_DEV_SERIAL_BASE_B    0x305020 // SCI2
89
 
90
//-----------------------------------------------------------------------------
91
// Define CYG_DEVICE_SERIAL_RS232_SCIBR
92
// Default baudrate is 38400
93
// These values are calculated for a 40Mhz clock frequency
94
// This should be enough, we did not provide clock frequency as a configuration 
95
// option anyway
96
#define CYG_DEV_SERIAL_RS232_SCxBR_300    4167
97
#define CYG_DEV_SERIAL_RS232_SCxBR_600    2083
98
#define CYG_DEV_SERIAL_RS232_SCxBR_1200   1042
99
#define CYG_DEV_SERIAL_RS232_SCxBR_2400    521
100
#define CYG_DEV_SERIAL_RS232_SCxBR_4800    260
101
#define CYG_DEV_SERIAL_RS232_SCxBR_9600    130 
102
#define CYG_DEV_SERIAL_RS232_SCxBR_14400    87
103
#define CYG_DEV_SERIAL_RS232_SCxBR_19200    65
104
#define CYG_DEV_SERIAL_RS232_SCxBR_28800    43
105
#define CYG_DEV_SERIAL_RS232_SCxBR_38400    33
106
#define CYG_DEV_SERIAL_RS232_SCxBR_57600    22
107
#define CYG_DEV_SERIAL_RS232_SCxBR_115200   11
108
 
109
//-----------------------------------------------------------------------------
110
// Define the serial registers.
111
#define CYG_DEV_SERIAL_RS232_SCCR0 0x00
112
#define CYG_DEV_SERIAL_RS232_SCCR1 0x01
113
#define CYG_DEV_SERIAL_RS232_SCSR  0x02
114
#define CYG_DEV_SERIAL_RS232_SCDR  0x03
115
 
116
#define SCCR0_OTHR   0x8000 // Select baud rate other than system clock
117
#define SCCR0_LINKBD 0x4000 // Link baud
118
#define SCCR0_SCxBR  0x1fff // SCI baud rate
119
 
120
#define SCCR1_LOOPS  0x4000 // Loop mode
121
#define SCCR1_WOMS   0x2000 // Wired or for SCI pins
122
#define SCCR1_ILT    0x1000 // Idle line detect type
123
#define SCCR1_PT     0x0800 // Parity type (0 = Odd, 1 = Even)
124
#define SCCR1_PE     0x0400 // Parity enable
125
#define SCCR1_M      0x0200 // Mode select (0 = 10 bit frame, 1 = 11 bit frame)
126
#define SCCR1_WAKE   0x0100 // Wakeup by address mark
127
#define SCCR1_TIE    0x0080 // Transmit interrupt enable
128
#define SCCR1_TCIE   0x0040 // Transmit complete interrupt enable
129
#define SCCR1_RIE    0x0020 // Receiver interrupt enable
130
#define SCCR1_ILIE   0x0010 // Idle line interrupt enable
131
#define SCCR1_TE     0x0008 // Transmiter enable
132
#define SCCR1_RE     0x0004 // Receiver enable
133
#define SCCR1_RWU    0x0002 // Receiver wakeup
134
#define SCCR1_SBK    0x0001 // Send break
135
 
136
#define SCSR_TDRE    0x0100 // Transmit data register empty
137
#define SCSR_TC      0x0080 // Transmit complete
138
#define SCSR_RDRF    0x0040 // Receive data register full
139
#define SCSR_RAF     0x0020 // Receive active flag
140
#define SCSR_IDLE    0x0010 // Idle line detected
141
#define SCSR_OR      0x0008 // Overrun error
142
#define SCSR_NF      0x0004 // Noise error flag
143
#define SCSR_FE      0x0002 // Framing error
144
#define SCSR_PF      0x0001 // Parity error
145
 
146
//-----------------------------------------------------------------------------
147
typedef struct {
148
    cyg_uint16*  base;
149
    cyg_int32    msec_timeout;
150
    int          siu_vector;
151
    int          imb3_vector;
152
    unsigned int level;
153
    int          baud_rate;
154
} channel_data_t;
155
 
156
//-----------------------------------------------------------------------------
157
static void
158
init_serial_channel(const channel_data_t* __ch_data)
159
{
160
    cyg_uint16 * base = __ch_data->base;
161
    cyg_uint16 br;
162
 
163
    switch(__ch_data->baud_rate)
164
    {
165
      case 300:
166
        br = CYG_DEV_SERIAL_RS232_SCxBR_300;
167
        break;
168
      case 600:
169
        br = CYG_DEV_SERIAL_RS232_SCxBR_600;
170
        break;
171
      case 1200:
172
        br = CYG_DEV_SERIAL_RS232_SCxBR_1200;
173
        break;
174
      case 2400:
175
        br = CYG_DEV_SERIAL_RS232_SCxBR_2400;
176
        break;
177
      case 4800:
178
        br = CYG_DEV_SERIAL_RS232_SCxBR_4800;
179
        break;
180
      case 9600:
181
        br = CYG_DEV_SERIAL_RS232_SCxBR_9600;
182
        break;
183
      case 14400:
184
        br = CYG_DEV_SERIAL_RS232_SCxBR_14400;
185
        break;
186
      case 19200:
187
        br = CYG_DEV_SERIAL_RS232_SCxBR_19200;
188
        break;
189
      case 28800:
190
        br = CYG_DEV_SERIAL_RS232_SCxBR_28800;
191
        break;
192
      case 38400:
193
        br = CYG_DEV_SERIAL_RS232_SCxBR_38400;
194
        break;
195
      case 57600:
196
        br = CYG_DEV_SERIAL_RS232_SCxBR_57600;
197
        break;
198
      case 115200:
199
        br = CYG_DEV_SERIAL_RS232_SCxBR_115200;
200
        break;
201
      default:
202
        // Use the default if something unknown is requested
203
        br = CYG_DEV_SERIAL_RS232_SCxBR_38400;
204
        break;
205
    }
206
 
207
    // 8-1-No parity
208
    HAL_WRITE_UINT16(base+CYG_DEV_SERIAL_RS232_SCCR1, (SCCR1_TE | SCCR1_RE));
209
 
210
    // Set baud rate
211
    HAL_WRITE_UINT16(base+CYG_DEV_SERIAL_RS232_SCCR0, br);
212
}
213
 
214
static cyg_bool
215
cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch)
216
{
217
    cyg_uint16 status;
218
    cyg_uint16 result;
219
    cyg_uint16 * base = ((channel_data_t *)__ch_data)->base;
220
 
221
    HAL_READ_UINT16(base+CYG_DEV_SERIAL_RS232_SCSR, status);
222
    if((status & SCSR_RDRF) == 0)
223
        return false;
224
 
225
    HAL_READ_UINT16(base+CYG_DEV_SERIAL_RS232_SCDR, result);
226
    *ch = (cyg_uint8)(result & 0x00ff);
227
 
228
    return true;
229
}
230
 
231
 
232
cyg_uint8
233
cyg_hal_plf_serial_getc(void* __ch_data)
234
{
235
    cyg_uint8 ch;
236
    CYGARC_HAL_SAVE_GP();
237
 
238
    while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch));
239
 
240
    CYGARC_HAL_RESTORE_GP();
241
    return ch;
242
}
243
 
244
void
245
cyg_hal_plf_serial_putc(void* __ch_data, cyg_uint8 c)
246
{
247
    cyg_uint16 status;
248
    cyg_uint16 * base = ((channel_data_t *)__ch_data)->base;
249
 
250
    CYGARC_HAL_SAVE_GP();
251
 
252
    do {
253
       HAL_READ_UINT16(base+CYG_DEV_SERIAL_RS232_SCSR, status);
254
    } while((status & SCSR_TDRE) == 0);
255
 
256
    HAL_WRITE_UINT16(base+CYG_DEV_SERIAL_RS232_SCDR, (short)c);
257
 
258
    // Hang around until the character is safely sent
259
    do {
260
       HAL_READ_UINT16(base+CYG_DEV_SERIAL_RS232_SCSR, status);
261
    } while((status & SCSR_TDRE) == 0);
262
 
263
    CYGARC_HAL_RESTORE_GP();
264
}
265
 
266
// Channel data
267
// Do NOT make them const, will cause problems when trying
268
// to change the timeout parameter ... (Is this a bug in other)
269
// PowerPC platform hals ?? You only see it when you really start from
270
// flash ....
271
static channel_data_t channels[2] = {
272
    { (cyg_uint16*)CYG_DEV_SERIAL_BASE_A,
273
      1000,
274
      CYGNUM_HAL_INTERRUPT_SIU_LVL0,
275
      CYGNUM_HAL_INTERRUPT_IMB3_SCI1_RX,
276
      0,
277
      CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD },
278
    { (cyg_uint16*)CYG_DEV_SERIAL_BASE_B,
279
      1000,
280
      CYGNUM_HAL_INTERRUPT_SIU_LVL0,
281
      CYGNUM_HAL_INTERRUPT_IMB3_SCI2_RX,
282
      0,
283
      CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD }
284
};
285
 
286
static void
287
cyg_hal_plf_serial_write(void* __ch_data, const cyg_uint8* __buf,
288
                         cyg_uint32 __len)
289
{
290
    CYGARC_HAL_SAVE_GP();
291
 
292
    while(__len-- > 0)
293
        cyg_hal_plf_serial_putc(__ch_data, *__buf++);
294
 
295
    CYGARC_HAL_RESTORE_GP();
296
}
297
 
298
static void
299
cyg_hal_plf_serial_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len)
300
{
301
    CYGARC_HAL_SAVE_GP();
302
 
303
    while(__len-- > 0)
304
        *__buf++ = cyg_hal_plf_serial_getc(__ch_data);
305
 
306
    CYGARC_HAL_RESTORE_GP();
307
}
308
 
309
cyg_bool
310
cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch)
311
{
312
    int delay_count;
313
    channel_data_t* chan = (channel_data_t*)__ch_data;
314
    cyg_bool res;
315
    CYGARC_HAL_SAVE_GP();
316
 
317
    delay_count = chan->msec_timeout * 10; // delay in .1 ms steps
318
    for(;;) {
319
        res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch);
320
        if (res || 0 == delay_count--)
321
            break;
322
 
323
        CYGACC_CALL_IF_DELAY_US(100);
324
    }
325
 
326
    CYGARC_HAL_RESTORE_GP();
327
    return res;
328
}
329
 
330
static int
331
cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...)
332
{
333
    static int irq_state = 0;
334
    channel_data_t* chan = (channel_data_t*)__ch_data;
335
 
336
    int ret = 0;
337
    CYGARC_HAL_SAVE_GP();
338
 
339
    switch (__func) {
340
    case __COMMCTL_GETBAUD:
341
        ret = chan->baud_rate;
342
        break;
343
    case __COMMCTL_SETBAUD:
344
        {
345
        va_list ap;
346
        va_start(ap, __func);
347
 
348
        ret = chan->baud_rate;
349
        chan->baud_rate = va_arg(ap, cyg_int32);
350
        init_serial_channel(chan);
351
 
352
        va_end(ap);
353
        }
354
        break;
355
    case __COMMCTL_IRQ_ENABLE:
356
        HAL_INTERRUPT_SET_LEVEL(chan->imb3_vector, chan->level);
357
        HAL_INTERRUPT_UNMASK(chan->imb3_vector);
358
        HAL_INTERRUPT_UNMASK(chan->siu_vector);
359
        irq_state = 1;
360
        break;
361
    case __COMMCTL_IRQ_DISABLE:
362
        ret = irq_state;
363
        irq_state = 0;
364
        HAL_INTERRUPT_MASK(chan->imb3_vector);
365
        HAL_INTERRUPT_MASK(chan->siu_vector);
366
        break;
367
    case __COMMCTL_DBG_ISR_VECTOR:
368
        ret = chan->siu_vector;
369
        break;
370
    case __COMMCTL_SET_TIMEOUT:
371
        {
372
        va_list ap;
373
        va_start(ap, __func);
374
 
375
        ret = chan->msec_timeout;
376
        chan->msec_timeout = va_arg(ap, cyg_uint32);
377
 
378
        va_end(ap);
379
        }
380
        break;
381
    default:
382
        break;
383
    }
384
    CYGARC_HAL_RESTORE_GP();
385
    return ret;
386
}
387
 
388
static int
389
cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc,
390
                       CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
391
{
392
    int res = 0;
393
 
394
    cyg_uint16 status;
395
    cyg_uint16 control;
396
 
397
    cyg_uint16 * base = ((channel_data_t *)__ch_data)->base;
398
 
399
    CYGARC_HAL_SAVE_GP();
400
 
401
    *__ctrlc = 0;
402
 
403
    HAL_READ_UINT16(base+CYG_DEV_SERIAL_RS232_SCSR, status);
404
    HAL_READ_UINT16(base+CYG_DEV_SERIAL_RS232_SCCR1, control);
405
 
406
    if((status & SCSR_RDRF) && (control & SCCR1_RIE))
407
    {   // Only if the interrupt was caused by the channel
408
        cyg_uint8 c;
409
        c = cyg_hal_plf_serial_getc(__ch_data);
410
 
411
        if(cyg_hal_is_break(&c, 1))
412
            *__ctrlc = 1;
413
 
414
        HAL_INTERRUPT_ACKNOWLEDGE(((channel_data_t *)__ch_data)->imb3_vector);
415
        res = CYG_ISR_HANDLED;
416
    }
417
 
418
    CYGARC_HAL_RESTORE_GP();
419
    return res;
420
}
421
 
422
static void
423
cyg_hal_plf_serial_init(void)
424
{
425
    hal_virtual_comm_table_t* comm;
426
    int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
427
 
428
    // Disable interrupts.
429
    HAL_INTERRUPT_MASK(channels[0].imb3_vector);
430
    HAL_INTERRUPT_MASK(channels[1].imb3_vector);
431
 
432
    // Init channels
433
    init_serial_channel(&channels[0]);
434
    init_serial_channel(&channels[1]);
435
 
436
    // Setup procs in the vector table
437
 
438
    // Set channel 0
439
    CYGACC_CALL_IF_SET_CONSOLE_COMM(0);
440
    comm = CYGACC_CALL_IF_CONSOLE_PROCS();
441
    CYGACC_COMM_IF_CH_DATA_SET(*comm, &channels[0]);
442
    CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write);
443
    CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read);
444
    CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc);
445
    CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc);
446
    CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control);
447
    CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr);
448
    CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
449
 
450
    // Set channel 1
451
    CYGACC_CALL_IF_SET_CONSOLE_COMM(1);
452
    comm = CYGACC_CALL_IF_CONSOLE_PROCS();
453
    CYGACC_COMM_IF_CH_DATA_SET(*comm, &channels[1]);
454
    CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write);
455
    CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read);
456
    CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc);
457
    CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc);
458
    CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control);
459
    CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr);
460
    CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
461
 
462
    // Restore original console
463
    CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
464
}
465
 
466
//=============================================================================
467
// Compatibility with older stubs
468
//=============================================================================
469
#ifndef CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
470
 
471
#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS)
472
#include <cyg/hal/hal_stub.h>           // CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION
473
#endif
474
 
475
//-----------------------------------------------------------------------------
476
// Assumption: all diagnostic output must be GDB packetized unless
477
// this is a configuration for a stand-alone ROM system.
478
#if defined(CYG_HAL_STARTUP_ROM) && !defined(CYGSEM_HAL_ROM_MONITOR)
479
# define HAL_DIAG_USES_HARDWARE
480
#endif
481
 
482
#if (CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL == 0)
483
# define __BASE ((cyg_uint16*)CYG_DEV_SERIAL_BASE_A)
484
#elif (CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL == 1)
485
# define __BASE ((cyg_uint16*)CYG_DEV_SERIAL_BASE_B)
486
#else
487
# error "LCD driver not (yet) implemented for cme555"
488
#endif
489
 
490
static channel_data_t channel = { __BASE, 0, 0 };
491
 
492
#ifdef HAL_DIAG_USES_HARDWARE
493
 
494
void hal_diag_init(void)
495
{
496
    init_serial_channel(&channel);
497
}
498
 
499
void hal_diag_write_char(char __c)
500
{
501
    cyg_hal_plf_serial_putc(&channel, __c);
502
}
503
 
504
void hal_diag_read_char(char *c)
505
{
506
    *c = cyg_hal_plf_serial_getc(&channel);
507
}
508
 
509
#else  // ifdef HAL_DIAG_USES_HARDWARE
510
 
511
// Initialize diag port
512
void
513
hal_diag_init(void)
514
{
515
    // Init devices
516
    init_serial_channel(&channel);
517
}
518
 
519
void
520
hal_diag_write_char_serial( char c )
521
{
522
    unsigned long __state;
523
    HAL_DISABLE_INTERRUPTS(__state);
524
    cyg_hal_plf_serial_putc(&channel, c);
525
    HAL_RESTORE_INTERRUPTS(__state);
526
}
527
 
528
void
529
hal_diag_read_char(char *c)
530
{
531
    *c = cyg_hal_plf_serial_getc(&channel);
532
}
533
 
534
void
535
hal_diag_write_char(char c)
536
{
537
    static char line[100];
538
    static int pos = 0;
539
 
540
    // No need to send CRs
541
    if( c == '\r' ) return;
542
 
543
    line[pos++] = c;
544
 
545
    if( c == '\n' || pos == sizeof(line) )
546
    {
547
        CYG_INTERRUPT_STATE old;
548
 
549
        // Disable interrupts. This prevents GDB trying to interrupt us
550
        // while we are in the middle of sending a packet. The serial
551
        // receive interrupt will be seen when we re-enable interrupts
552
        // later.
553
 
554
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
555
        CYG_HAL_GDB_ENTER_CRITICAL_IO_REGION(old);
556
#else
557
        HAL_DISABLE_INTERRUPTS(old);
558
#endif
559
 
560
        while(1)
561
        {
562
            char c1;
563
            static char hex[] = "0123456789ABCDEF";
564
            cyg_uint8 csum = 0;
565
            int i;
566
 
567
            hal_diag_write_char_serial('$');
568
            hal_diag_write_char_serial('O');
569
            csum += 'O';
570
            for( i = 0; i < pos; i++ )
571
            {
572
                char ch = line[i];
573
                char h = hex[(ch>>4)&0xF];
574
                char l = hex[ch&0xF];
575
                hal_diag_write_char_serial(h);
576
                hal_diag_write_char_serial(l);
577
                csum += h;
578
                csum += l;
579
            }
580
            hal_diag_write_char_serial('#');
581
            hal_diag_write_char_serial(hex[(csum>>4)&0xF]);
582
            hal_diag_write_char_serial(hex[csum&0xF]);
583
 
584
            // Wait for the ACK character '+' from GDB here and handle
585
            // receiving a ^C instead.
586
            hal_diag_read_char(&c1);
587
 
588
            if( c1 == '+' )
589
                break;              // a good acknowledge
590
 
591
#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
592
            if( 3 == c1 ) {
593
                // Ctrl-C: breakpoint.
594
                cyg_hal_gdb_interrupt(
595
                    (target_register_t)__builtin_return_address(0));
596
                break;
597
            }
598
#endif
599
            // otherwise, loop round again
600
        }
601
 
602
        pos = 0;
603
 
604
        // And re-enable interrupts
605
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
606
        CYG_HAL_GDB_LEAVE_CRITICAL_IO_REGION(old);
607
#else
608
        HAL_RESTORE_INTERRUPTS(old);
609
#endif
610
 
611
    }
612
}
613
 
614
#endif  // ifdef HAL_DIAG_USES_HARDWARE
615
 
616
#endif // CYGSEM_HAL_VIRTUAL_VECTOR_DIAG
617
 
618
//-----------------------------------------------------------------------------
619
// End of hal_diag.c

powered by: WebSVN 2.1.0

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