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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//=============================================================================
2
//
3
//      hal_diag.c
4
//
5
//      Simple polling driver for the 16c550c serial controller(s) in the 
6
//      ORPSoC, to be used for diagnostic I/O and gdb remote debugging.
7
//
8
//=============================================================================
9
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
10
// -------------------------------------------                              
11
// This file is part of eCos, the Embedded Configurable Operating System.   
12
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
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      
17
// version.                                                                 
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT      
20
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
22
// for more details.                                                        
23
//
24
// You should have received a copy of the GNU General Public License        
25
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
26
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
27
//
28
// As a special exception, if other files instantiate templates or use      
29
// macros or inline functions from this file, or you compile this file      
30
// and link it with other works to produce a work based on this file,       
31
// this file does not by itself cause the resulting work to be covered by   
32
// the GNU General Public License. However the source code for this file    
33
// must still be made available in accordance with section (3) of the GNU   
34
// General Public License v2.                                               
35
//
36
// This exception does not invalidate any other reasons why a work based    
37
// on this file might be covered by the GNU General Public License.         
38
// -------------------------------------------                              
39
// ####ECOSGPLCOPYRIGHTEND####                                              
40
//=============================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):   sfurman
44
// Contributors:dmoseley
45
// Date:        2003-02-28
46
// Description: Simple polling driver for the 16c550c serial controller(s) in the ORP,
47
//              to be used for diagnostic I/O and gdb remote debugging.
48
//      
49
//
50
//####DESCRIPTIONEND####
51
//
52
//=============================================================================
53
 
54
#include <pkgconf/hal.h>
55
#include <pkgconf/system.h>
56
#include CYGBLD_HAL_PLATFORM_H
57
 
58
#include <cyg/hal/hal_arch.h>           // SAVE/RESTORE GP macros
59
#include <cyg/hal/hal_io.h>             // IO macros
60
#include <cyg/hal/hal_if.h>             // interface API
61
#include <cyg/hal/hal_intr.h>           // HAL_ENABLE/MASK/UNMASK_INTERRUPTS
62
#include <cyg/hal/hal_misc.h>           // Helper functions
63
#include <cyg/hal/drv_api.h>            // CYG_ISR_HANDLED
64
#include <cyg/infra/cyg_ass.h>          // assertion macros
65
 
66
//-----------------------------------------------------------------------------
67
// Base addresses for each 16550 UART in the system
68
#define SERIAL_16550_CONSOLE_BASE_ADDR    0x90000000
69
#define SERIAL_16550_DEBUGGER_BASE_ADDR   0x90000008
70
 
71
//-----------------------------------------------------------------------------
72
// Define the 16550C serial registers.
73
#define SER_16550_RBR 0x00   // receiver buffer register, read, dlab = 0
74
#define SER_16550_THR 0x00   // transmitter holding register, write, dlab = 0
75
#define SER_16550_DLL 0x00   // divisor latch (LS), read/write, dlab = 1
76
#define SER_16550_IER 0x01   // interrupt enable register, read/write, dlab = 0
77
#define SER_16550_DLM 0x01   // divisor latch (MS), read/write, dlab = 1
78
#define SER_16550_IIR 0x02   // interrupt identification reg, read, dlab = 0
79
#define SER_16550_FCR 0x02   // fifo control register, write, dlab = 0
80
#define SER_16550_AFR 0x02   // alternate function reg, read/write, dlab = 1
81
#define SER_16550_LCR 0x03   // line control register, read/write
82
#define SER_16550_MCR 0x04   // modem control register, read/write
83
#define SER_16550_LSR 0x05   // line status register, read
84
#define SER_16550_MSR 0x06   // modem status register, read
85
#define SER_16550_SCR 0x07   // scratch pad register
86
 
87
// The interrupt enable register bits.
88
#define SIO_IER_ERDAI   0x01            // enable received data available irq
89
#define SIO_IER_ETHREI  0x02            // enable THR empty interrupt
90
#define SIO_IER_ELSI    0x04            // enable receiver line status irq
91
#define SIO_IER_EMSI    0x08            // enable modem status interrupt
92
 
93
// The interrupt identification register bits.
94
#define SIO_IIR_IP      0x01            // 0 if interrupt pending
95
#define SIO_IIR_ID_MASK 0x0e            // mask for interrupt ID bits
96
 
97
// The line status register bits.
98
#define SIO_LSR_DR      0x01            // data ready
99
#define SIO_LSR_OE      0x02            // overrun error
100
#define SIO_LSR_PE      0x04            // parity error
101
#define SIO_LSR_FE      0x08            // framing error
102
#define SIO_LSR_BI      0x10            // break interrupt
103
#define SIO_LSR_THRE    0x20            // transmitter holding register empty
104
#define SIO_LSR_TEMT    0x40            // transmitter register empty
105
#define SIO_LSR_ERR     0x80            // any error condition
106
 
107
// The modem status register bits.
108
#define SIO_MSR_DCTS  0x01              // delta clear to send
109
#define SIO_MSR_DDSR  0x02              // delta data set ready
110
#define SIO_MSR_TERI  0x04              // trailing edge ring indicator
111
#define SIO_MSR_DDCD  0x08              // delta data carrier detect
112
#define SIO_MSR_CTS   0x10              // clear to send
113
#define SIO_MSR_DSR   0x20              // data set ready
114
#define SIO_MSR_RI    0x40              // ring indicator
115
#define SIO_MSR_DCD   0x80              // data carrier detect
116
 
117
// The line control register bits.
118
#define SIO_LCR_WLS0   0x01             // word length select bit 0
119
#define SIO_LCR_WLS1   0x02             // word length select bit 1
120
#define SIO_LCR_STB    0x04             // number of stop bits
121
#define SIO_LCR_PEN    0x08             // parity enable
122
#define SIO_LCR_EPS    0x10             // even parity select
123
#define SIO_LCR_SP     0x20             // stick parity
124
#define SIO_LCR_SB     0x40             // set break
125
#define SIO_LCR_DLAB   0x80             // divisor latch access bit
126
 
127
// The FIFO control register
128
#define SIO_FCR_FCR0   0x01             // enable xmit and rcvr fifos
129
#define SIO_FCR_FCR1   0x02             // clear RCVR FIFO
130
#define SIO_FCR_FCR2   0x04             // clear XMIT FIFO
131
 
132
/////////////////////////////////////////
133
// Interrupt Enable Register
134
#define IER_RCV 0x01
135
#define IER_XMT 0x02
136
#define IER_LS  0x04
137
#define IER_MS  0x08
138
 
139
// Line Control Register
140
#define LCR_WL5 0x00    // Word length
141
#define LCR_WL6 0x01
142
#define LCR_WL7 0x02
143
#define LCR_WL8 0x03
144
#define LCR_SB1 0x00    // Number of stop bits
145
#define LCR_SB1_5 0x04  // 1.5 -> only valid with 5 bit words
146
#define LCR_SB2 0x04
147
#define LCR_PN  0x00    // Parity mode - none
148
#define LCR_PE  0x0C    // Parity mode - even
149
#define LCR_PO  0x08    // Parity mode - odd
150
#define LCR_PM  0x28    // Forced "mark" parity
151
#define LCR_PS  0x38    // Forced "space" parity
152
#define LCR_DL  0x80    // Enable baud rate latch
153
 
154
// Line Status Register
155
#define LSR_RSR 0x01
156
#define LSR_THE 0x20
157
 
158
// Modem Control Register
159
#define MCR_DTR 0x01
160
#define MCR_RTS 0x02
161
#define MCR_INT 0x08   // Enable interrupts
162
 
163
// Interrupt status register
164
#define ISR_None             0x01
165
#define ISR_Rx_Line_Status   0x06
166
#define ISR_Rx_Avail         0x04
167
#define ISR_Rx_Char_Timeout  0x0C
168
#define ISR_Tx_Empty         0x02
169
#define ISR_Modem_Status     0x00
170
 
171
// FIFO control register
172
#define FCR_ENABLE     0x01
173
#define FCR_CLEAR_RCVR 0x02
174
#define FCR_CLEAR_XMIT 0x04
175
 
176
// Assume the UART is driven 1/16 CPU frequency
177
#define UART_CLOCK    ((CYGHWR_HAL_OPENRISC_CPU_FREQ)*1.0e6/16.0)
178
 
179 856 skrzyp
#define DIVISOR(baud) (((((CYGHWR_HAL_OPENRISC_CPU_FREQ)*10000000)/(16*baud))+5)/10)
180 786 skrzyp
 
181
#ifdef CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD
182
#define CYG_DEV_SERIAL_BAUD_DIVISOR   \
183
    DIVISOR(CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD)
184
#else
185
#error Missing/incorrect serial baud rate defined - CDL error?
186
#endif
187
 
188
 
189
//-----------------------------------------------------------------------------
190
typedef struct {
191
    cyg_uint8* base;
192
    cyg_int32 msec_timeout;
193
    int isr_vector;
194
} channel_data_t;
195
 
196
static channel_data_t channels[] = {
197
    { (cyg_uint8*)SERIAL_16550_CONSOLE_BASE_ADDR,
198
      1000,
199
      CYGNUM_HAL_INTERRUPT_SERIAL_CONSOLE
200
    },
201
    { (cyg_uint8*)SERIAL_16550_DEBUGGER_BASE_ADDR,
202
      1000,
203
      CYGNUM_HAL_INTERRUPT_SERIAL_DEBUGGER
204
    }
205
};
206
 
207
//-----------------------------------------------------------------------------
208
// Set the baud rate
209
 
210
static void
211
cyg_hal_plf_serial_set_baud(cyg_uint8* port, cyg_uint16 baud_divisor)
212
{
213
    cyg_uint8 _lcr;
214
 
215
    HAL_READ_UINT8(port+SER_16550_LCR, _lcr);
216
    _lcr |= LCR_DL;
217
    HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
218
 
219
    HAL_WRITE_UINT8(port+SER_16550_DLM, baud_divisor >> 8);
220
    HAL_WRITE_UINT8(port+SER_16550_DLL, baud_divisor & 0xff);
221
 
222
    _lcr &= ~LCR_DL;
223
    HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
224
}
225
 
226
//-----------------------------------------------------------------------------
227
// The minimal init, get and put functions. All by polling.
228
 
229
void
230
cyg_hal_plf_serial_init_channel(void* __ch_data)
231
{
232
    cyg_uint8* port;
233
    cyg_uint8 _lcr;
234
 
235
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
236
    // Go ahead and assume it is channels[0].
237
    if (__ch_data == 0)
238
      __ch_data = (void*)&channels[0];
239
 
240
    port = ((channel_data_t*)__ch_data)->base;
241
 
242
    // Disable port interrupts while changing hardware
243
    HAL_WRITE_UINT8(port+SER_16550_IER, 0);
244
 
245
    // Set databits, stopbits and parity.
246
    _lcr = LCR_WL8 | LCR_SB1 | LCR_PN;
247
    HAL_WRITE_UINT8(port+SER_16550_LCR, _lcr);
248
 
249
    // Set baud rate.
250
    cyg_hal_plf_serial_set_baud(port, CYG_DEV_SERIAL_BAUD_DIVISOR);
251
 
252
    // Enable and clear FIFO
253
    HAL_WRITE_UINT8(port+SER_16550_FCR, (FCR_ENABLE | FCR_CLEAR_RCVR | FCR_CLEAR_XMIT));
254
 
255
    // enable RTS to keep host side happy
256
    HAL_WRITE_UINT8( port+SER_16550_MCR, MCR_RTS );
257
 
258
    // Don't allow interrupts.
259
    HAL_WRITE_UINT8(port+SER_16550_IER, 0);
260
}
261
 
262
void
263
cyg_hal_plf_serial_putc(void* __ch_data, cyg_uint8 __ch)
264
{
265
    cyg_uint8* port;
266
    cyg_uint8 _lsr;
267
 
268
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
269
    // Go ahead and assume it is channels[0].
270
    if (__ch_data == 0)
271
      __ch_data = (void*)&channels[0];
272
 
273
    port = ((channel_data_t*)__ch_data)->base;
274
 
275
    CYGARC_HAL_SAVE_GP();
276
 
277
    do {
278
        HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
279
    } while ((_lsr & SIO_LSR_THRE) == 0);
280
 
281
    // Now, the transmit buffer is empty
282
    HAL_WRITE_UINT8(port+SER_16550_THR, __ch);
283
 
284
    // Hang around until the character has been safely sent.
285
    do {
286
        HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
287
    } while ((_lsr & SIO_LSR_THRE) == 0);
288
 
289
    CYGARC_HAL_RESTORE_GP();
290
}
291
 
292
static int lsr_global;
293
 
294
static cyg_bool
295
cyg_hal_plf_serial_getc_nonblock(void* __ch_data, cyg_uint8* ch)
296
{
297
    cyg_uint8* port;
298
    cyg_uint8 _lsr;
299
 
300
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
301
    // Go ahead and assume it is channels[0].
302
    if (__ch_data == 0)
303
      __ch_data = (void*)&channels[0];
304
 
305
    port = ((channel_data_t*)__ch_data)->base;
306
 
307
    HAL_READ_UINT8(port+SER_16550_LSR, _lsr);
308
    if ((_lsr & SIO_LSR_DR) == 0)
309
        return false;
310
    lsr_global = _lsr;
311
    CYG_ASSERT((_lsr & SIO_LSR_OE) == 0 , "UART receiver overrun error");
312
    HAL_READ_UINT8(port+SER_16550_RBR, *ch);
313
 
314
    return true;
315
}
316
 
317
cyg_uint8
318
cyg_hal_plf_serial_getc(void* __ch_data)
319
{
320
    cyg_uint8 ch;
321
    CYGARC_HAL_SAVE_GP();
322
 
323
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
324
    // Go ahead and assume it is channels[0].
325
    if (__ch_data == 0)
326
      __ch_data = (void*)&channels[0];
327
 
328
    while(!cyg_hal_plf_serial_getc_nonblock(__ch_data, &ch));
329
 
330
    CYGARC_HAL_RESTORE_GP();
331
    return ch;
332
}
333
 
334
static void
335
cyg_hal_plf_serial_write(void* __ch_data, const cyg_uint8* __buf,
336
                         cyg_uint32 __len)
337
{
338
    CYGARC_HAL_SAVE_GP();
339
 
340
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
341
    // Go ahead and assume it is channels[0].
342
    if (__ch_data == 0)
343
      __ch_data = (void*)&channels[0];
344
 
345
    while(__len-- > 0)
346
        cyg_hal_plf_serial_putc(__ch_data, *__buf++);
347
 
348
    CYGARC_HAL_RESTORE_GP();
349
}
350
 
351
static void
352
cyg_hal_plf_serial_read(void* __ch_data, cyg_uint8* __buf, cyg_uint32 __len)
353
{
354
    CYGARC_HAL_SAVE_GP();
355
 
356
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
357
    // Go ahead and assume it is channels[0].
358
    if (__ch_data == 0)
359
      __ch_data = (void*)&channels[0];
360
 
361
    while(__len-- > 0)
362
        *__buf++ = cyg_hal_plf_serial_getc(__ch_data);
363
 
364
    CYGARC_HAL_RESTORE_GP();
365
}
366
 
367
 
368
cyg_bool
369
cyg_hal_plf_serial_getc_timeout(void* __ch_data, cyg_uint8* ch)
370
{
371
    int delay_count;
372
    channel_data_t* chan;
373
    cyg_bool res;
374
    CYGARC_HAL_SAVE_GP();
375
 
376
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
377
    // Go ahead and assume it is channels[0].
378
    if (__ch_data == 0)
379
      __ch_data = (void*)&channels[0];
380
 
381
    chan = (channel_data_t*)__ch_data;
382
 
383
    delay_count = chan->msec_timeout; // delay in 1000 us steps
384
 
385
    for(;;) {
386
        res = cyg_hal_plf_serial_getc_nonblock(__ch_data, ch);
387
        if (res || 0 == delay_count--)
388
            break;
389
        CYGACC_CALL_IF_DELAY_US(1000);
390
    }
391
 
392
    CYGARC_HAL_RESTORE_GP();
393
    return res;
394
}
395
 
396
static int
397
cyg_hal_plf_serial_control(void *__ch_data, __comm_control_cmd_t __func, ...)
398
{
399
    static int irq_state = 0;
400
    channel_data_t* chan;
401
    cyg_uint8 ier;
402
    int ret = 0;
403
    CYGARC_HAL_SAVE_GP();
404
 
405
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
406
    // Go ahead and assume it is channels[0].
407
    if (__ch_data == 0)
408
      __ch_data = (void*)&channels[0];
409
 
410
    chan = (channel_data_t*)__ch_data;
411
 
412
    switch (__func) {
413
    case __COMMCTL_IRQ_ENABLE:
414
        irq_state = 1;
415
 
416
        HAL_READ_UINT8(chan->base + SER_16550_IER, ier);
417
        ier |= SIO_IER_ERDAI;
418
        HAL_WRITE_UINT8(chan->base + SER_16550_IER, ier);
419
 
420
        HAL_INTERRUPT_SET_LEVEL(chan->isr_vector, 1);
421
        HAL_INTERRUPT_UNMASK(chan->isr_vector);
422
        break;
423
    case __COMMCTL_IRQ_DISABLE:
424
        ret = irq_state;
425
        irq_state = 0;
426
 
427
        HAL_READ_UINT8(chan->base + SER_16550_IER, ier);
428
        ier &= ~SIO_IER_ERDAI;
429
        HAL_WRITE_UINT8(chan->base + SER_16550_IER, ier);
430
 
431
        HAL_INTERRUPT_MASK(chan->isr_vector);
432
        break;
433
    case __COMMCTL_DBG_ISR_VECTOR:
434
        ret = chan->isr_vector;
435
        break;
436
    case __COMMCTL_SET_TIMEOUT:
437
    {
438
        va_list ap;
439
 
440
        va_start(ap, __func);
441
 
442
        ret = chan->msec_timeout;
443
        chan->msec_timeout = va_arg(ap, cyg_uint32);
444
 
445
        va_end(ap);
446
    }
447
    break;
448
    case __COMMCTL_SETBAUD:
449
    {
450
        cyg_uint32 baud_rate;
451
        cyg_uint16 baud_divisor;
452
        cyg_uint8* port = chan->base;
453
        va_list ap;
454
 
455
        va_start(ap, __func);
456
        baud_rate = va_arg(ap, cyg_uint32);
457
        va_end(ap);
458
 
459
        switch (baud_rate)
460
        {
461
        case 110:    baud_divisor = DIVISOR(110);    break;
462
        case 150:    baud_divisor = DIVISOR(150);    break;
463
        case 300:    baud_divisor = DIVISOR(300);    break;
464
        case 600:    baud_divisor = DIVISOR(600);    break;
465
        case 1200:   baud_divisor = DIVISOR(1200);   break;
466
        case 2400:   baud_divisor = DIVISOR(2400);   break;
467
        case 4800:   baud_divisor = DIVISOR(4800);   break;
468
        case 7200:   baud_divisor = DIVISOR(7200);   break;
469
        case 9600:   baud_divisor = DIVISOR(9600);   break;
470
        case 14400:  baud_divisor = DIVISOR(14400);  break;
471
        case 19200:  baud_divisor = DIVISOR(19200);  break;
472
        case 38400:  baud_divisor = DIVISOR(38400);  break;
473
        case 57600:  baud_divisor = DIVISOR(57600);  break;
474
        case 115200: baud_divisor = DIVISOR(115200); break;
475
        case 230400: baud_divisor = DIVISOR(230400); break;
476
        default:     return -1;                      break; // Invalid baud rate selected
477
        }
478
 
479
        // Disable port interrupts while changing hardware
480
        HAL_READ_UINT8(port+SER_16550_IER, ier);
481
        HAL_WRITE_UINT8(port+SER_16550_IER, 0);
482
 
483
        // Set baud rate.
484
        cyg_hal_plf_serial_set_baud(port, baud_divisor);
485
 
486
        // Reenable interrupts if necessary
487
        HAL_WRITE_UINT8(port+SER_16550_IER, ier);
488
    }
489
    break;
490
 
491
    case __COMMCTL_GETBAUD:
492
        break;
493
    default:
494
        break;
495
    }
496
    CYGARC_HAL_RESTORE_GP();
497
    return ret;
498
}
499
 
500
static int
501
cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc,
502
                       CYG_ADDRWORD __vector, CYG_ADDRWORD __data)
503
{
504
    int res = 0;
505
    cyg_uint8 _iir, c;
506
    channel_data_t* chan;
507
    CYGARC_HAL_SAVE_GP();
508
 
509
    // Some of the diagnostic print code calls through here with no idea what the ch_data is.
510
    // Go ahead and assume it is channels[0].
511
    if (__ch_data == 0)
512
      __ch_data = (void*)&channels[0];
513
 
514
    chan = (channel_data_t*)__ch_data;
515
 
516
    HAL_INTERRUPT_ACKNOWLEDGE(chan->isr_vector);
517
 
518
    HAL_READ_UINT8(chan->base + SER_16550_IIR, _iir);
519
    _iir &= SIO_IIR_ID_MASK;
520
 
521
    *__ctrlc = 0;
522
    if ((_iir == ISR_Rx_Avail) || (_iir == ISR_Rx_Char_Timeout)) {
523
 
524
        HAL_READ_UINT8(chan->base + SER_16550_RBR, c);
525
 
526
        if( cyg_hal_is_break( &c , 1 ) )
527
            *__ctrlc = 1;
528
 
529
        res = CYG_ISR_HANDLED;
530
    }
531
 
532
    /* sfurman - Hmmm.  Under or1ksim, we sometimes receive interrupts
533
       when no characters are in the FIFO.  I think this is a SW bug
534
       and not a problem w/ or1ksim, but until the problem is solved,
535
       we always consume the interrupt */
536
    res = CYG_ISR_HANDLED;
537
 
538
    CYGARC_HAL_RESTORE_GP();
539
    return res;
540
}
541
 
542
static void
543
cyg_hal_plf_serial_init(void)
544
{
545
    int i;
546
    hal_virtual_comm_table_t* comm;
547
    int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
548
 
549
    //#define NUM_CHANNELS (sizeof(channels)/sizeof(channels[0]))
550
#define NUM_CHANNELS CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS
551
    for (i = 0; i < NUM_CHANNELS; i++) {
552
 
553
        // Disable interrupts.
554
        HAL_INTERRUPT_MASK(channels[i].isr_vector);
555
 
556
        // Init channels
557
        cyg_hal_plf_serial_init_channel((void*)&channels[i]);
558
 
559
        // Setup procs in the vector table
560
 
561
        // Set COMM callbacks for channel
562
        CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
563
        comm = CYGACC_CALL_IF_CONSOLE_PROCS();
564
        CYGACC_COMM_IF_CH_DATA_SET(*comm, &channels[i]);
565
        CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write);
566
        CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read);
567
        CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc);
568
        CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc);
569
        CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control);
570
        CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_serial_isr);
571
        CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
572
    }
573
 
574
    // Restore original console
575
    CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
576
}
577
 
578
void
579
cyg_hal_plf_comms_init(void)
580
{
581
    static int initialized = 0;
582
 
583
    if (initialized)
584
        return;
585
 
586
    initialized = 1;
587
 
588
    cyg_hal_plf_serial_init();
589
}
590
 
591
//-----------------------------------------------------------------------------
592
// 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.