source: rtems/c/src/lib/libbsp/m68k/uC5282/console/console.c @ 5b6111b

4.104.114.84.95
Last change on this file since 5b6111b was 5b6111b, checked in by Eric Norum <WENorum@…>, on 02/03/05 at 16:01:04

Add support for interrupt controller allocation. This will provides a
mechanism for applications to find a free level/priority.

  • Property mode set to 100644
File size: 22.1 KB
Line 
1 /*
2  *  Multi UART console serial I/O.
3  *
4  * TO DO: Add DMA input/output
5  */
6
7#include <stdio.h>
8#include <fcntl.h>
9#include <rtems/libio.h>
10#include <rtems/termiostypes.h>
11#include <termios.h>
12#include <bsp.h>
13#include <malloc.h>
14#include <rtems/mw_uid.h>
15
16#include <rtems/bspIo.h>
17
18#define UART_INTC0_IRQ_VECTOR(x) (64+13+(x))
19
20#define MCF5282_UART_USR_ERROR ( MCF5282_UART_USR_RB | \
21                                 MCF5282_UART_USR_FE | \
22                                 MCF5282_UART_USR_PE | \
23                                 MCF5282_UART_USR_OE )
24
25static int IntUartPollWrite(int minor, const char *buf, int len);
26static int IntUartInterruptWrite (int minor, const char *buf, int len);
27
28static void
29_BSP_null_char( char c )
30{
31        int level;
32
33    if (c == '\n')
34        _BSP_null_char('\r');
35        rtems_interrupt_disable(level);
36    while ( (MCF5282_UART_USR(CONSOLE_PORT) & MCF5282_UART_USR_TXRDY) == 0 )
37        continue;
38    MCF5282_UART_UTB(CONSOLE_PORT) = c;
39    while ( (MCF5282_UART_USR(CONSOLE_PORT) & MCF5282_UART_USR_TXRDY) == 0 )
40        continue;
41        rtems_interrupt_enable(level);
42}
43BSP_output_char_function_type BSP_output_char = _BSP_null_char;
44
45/*
46 * The MCF5282 has three UARTs but we enable only two here since it's likely
47 * that the I/O pins available to the third will be used for CAN/I2C
48 */
49#define MAX_UART_INFO     2
50#define RX_BUFFER_SIZE    512
51
52struct IntUartInfoStruct
53{
54        int                    iomode;
55        volatile int           uimr;
56        int                    baud;
57        int                    databits;
58        int                    parity;
59        int                    stopbits;
60        int                    hwflow;
61        int                    rx_in;
62        int                    rx_out;
63        char                   rx_buffer[RX_BUFFER_SIZE];
64        void                  *ttyp;
65};
66
67struct IntUartInfoStruct IntUartInfo[MAX_UART_INFO];
68
69static int GetBaud( int baudHandle )
70{
71        int baud = 9600;
72        switch ( baudHandle )
73        {
74                case B0:
75                        baud = (int)0;
76                        break;
77                case B1200:
78                        baud = (int)1200;
79                        break;
80                case B2400:
81                        baud = (int)2400;
82                        break;
83                case B4800:
84                        baud = (int)4800;
85                        break;
86                case B9600:
87                        baud = (int)9600;
88                        break;
89                case B19200:
90                        baud = (int)19200;
91                        break;
92                case B38400:
93                        baud = (int)38400;
94                        break;
95                case B57600:
96                        baud = (int)57600;
97                        break;
98                case B115200:
99                        baud = (int)115200;
100                        break;
101/*              case B576000:
102                        baud = (int)576000; */
103                        break;
104        }
105        return ( baud );
106}
107
108/***************************************************************************
109   Function : IntUartSet
110
111   Description : This updates the hardware UART settings.
112 ***************************************************************************/
113static void
114IntUartSet(int minor, int baud, int databits, int parity, int stopbits, int hwflow)
115{
116        int                         divisor;
117        unsigned32                                      clock_speed;
118        unsigned8                   umr1 = 0;
119        unsigned8                   umr2 = 0;
120        struct IntUartInfoStruct   *info = &IntUartInfo[minor];
121        int                         level;
122
123        rtems_interrupt_disable(level);
124
125
126        /* disable interrupts, clear RTS line, and disable the UARTS */
127        MCF5282_UART_UIMR(minor) = 0;
128        MCF5282_UART_UOP0(minor) = 1;
129        MCF5282_UART_UCR(minor) = (MCF5282_UART_UCR_TX_DISABLED | MCF5282_UART_UCR_RX_DISABLED);
130
131        /* save the current values */
132        info->uimr     = 0;
133        info->baud     = baud;
134        info->databits = databits;
135        info->parity   = parity;
136        info->stopbits = stopbits;
137        info->hwflow   = hwflow;
138
139    clock_speed = bsp_get_CPU_clock_speed();
140    /* determine the baud divisor value */
141    divisor = (clock_speed / ( 32 * baud ));
142    if ( divisor < 2 )
143        divisor = 2;
144
145        /* check to see if doing hardware flow control */
146        if ( hwflow )
147        {
148                /* set hardware flow options */
149                umr1 |= MCF5282_UART_UMR1_RXRTS;
150                umr2 |= MCF5282_UART_UMR2_TXCTS;
151        }
152
153        /* determine the new umr values */
154        umr1 |= (parity | databits);
155        umr2 |= (stopbits);
156
157        /* reset the uart */
158        MCF5282_UART_UCR(minor) = MCF5282_UART_UCR_RESET_ERROR;
159        MCF5282_UART_UCR(minor) = MCF5282_UART_UCR_RESET_RX;
160        MCF5282_UART_UCR(minor) = MCF5282_UART_UCR_RESET_TX;
161
162        /* reset the uart mode register and update values */
163        MCF5282_UART_UCR(minor) = MCF5282_UART_UCR_RESET_MR;
164        MCF5282_UART_UMR(minor) = umr1;
165        MCF5282_UART_UMR(minor) = umr2;
166
167        /* set the baud rate values */
168        MCF5282_UART_UCSR(minor) = (MCF5282_UART_UCSR_RCS_SYS_CLK | MCF5282_UART_UCSR_TCS_SYS_CLK);
169        MCF5282_UART_UBG1(minor) = (divisor & 0xff00) >> 8;
170        MCF5282_UART_UBG2(minor) = (divisor & 0x00ff);
171
172        /* enable the uart */
173    MCF5282_UART_UCR(minor) = (MCF5282_UART_UCR_TX_ENABLED | MCF5282_UART_UCR_RX_ENABLED);
174
175        /* check to see if interrupts need to be enabled */
176        if ( info->iomode != TERMIOS_POLLED )
177        {
178                /* enable rx interrupts */
179                info->uimr |= MCF5282_UART_UIMR_FFULL;
180                MCF5282_UART_UIMR(minor) = info->uimr;
181        }
182
183        /* check to see if doing hardware flow control */
184        if ( hwflow )
185        {
186                /* assert the RTS line */
187                MCF5282_UART_UOP1(minor) = 1;
188        }
189
190        rtems_interrupt_enable(level);
191
192}
193
194
195/***************************************************************************
196   Function : IntUartSetAttributes
197
198   Description : This provides the hardware-dependent portion of tcsetattr().
199   value and sets it. At the moment this just sets the baud rate.
200
201   Note: The highest baudrate is 115200 as this stays within
202   an error of +/- 5% at 25MHz processor clock
203 ***************************************************************************/
204static int
205IntUartSetAttributes(int minor, const struct termios *t)
206{
207        /* set default index values */
208        int                         baud     = (int)9600;
209        int                         databits = (int)MCF5282_UART_UMR1_BC_8;
210        int                         parity   = (int)MCF5282_UART_UMR1_PM_NONE;
211        int                         stopbits = (int)MCF5282_UART_UMR2_STOP_BITS_1;
212        int                         hwflow   = (int)0;
213        struct IntUartInfoStruct   *info     = &IntUartInfo[minor];
214
215        /* check to see if input is valid */
216        if ( t != (const struct termios *)0 )
217        {
218                /* determine baud rate index */
219                baud = GetBaud( t->c_cflag & CBAUD );
220
221                /* determine data bits */
222                switch ( t->c_cflag & CSIZE )
223                {
224                        case CS5:
225                                databits = (int)MCF5282_UART_UMR1_BC_5;
226                                break;
227                        case CS6:
228                                databits = (int)MCF5282_UART_UMR1_BC_6;
229                                break;
230                        case CS7:
231                                databits = (int)MCF5282_UART_UMR1_BC_7;
232                                break;
233                        case CS8:
234                                databits = (int)MCF5282_UART_UMR1_BC_8;
235                                break;
236                }
237
238                /* determine if parity is enabled */
239                if ( t->c_cflag & PARENB )
240                {
241                        if ( t->c_cflag & PARODD )
242                        {
243                                /* odd parity */
244                                parity = (int)MCF5282_UART_UMR1_PM_ODD;
245                        }
246                        else
247                        {
248                                /* even parity */
249                                parity = (int)MCF5282_UART_UMR1_PM_EVEN;
250                        }
251                }
252
253                /* determine stop bits */
254                if ( t->c_cflag & CSTOPB )
255                {
256                        /* two stop bits */
257                        stopbits = (int)MCF5282_UART_UMR2_STOP_BITS_2;
258                }
259
260                /* check to see if hardware flow control */
261                if ( t->c_cflag & CRTSCTS )
262                {
263                        hwflow = 1;
264                }
265        }
266
267        /* check to see if values have changed */
268        if ( ( baud     != info->baud     ) ||
269                 ( databits != info->databits ) ||
270                 ( parity   != info->parity   ) ||
271                 ( stopbits != info->stopbits ) ||
272                 ( hwflow   != info->hwflow   ) )
273        {
274
275                /* call function to set values */
276                IntUartSet(minor, baud, databits, parity, stopbits, hwflow);
277        }
278
279        return( RTEMS_SUCCESSFUL );
280
281}
282
283/***************************************************************************
284   Function : IntUartInterruptHandler
285
286   Description : This is the interrupt handler for the internal uart. It
287   determines which channel caused the interrupt before queueing any received
288   chars and dequeueing chars waiting for transmission.
289 ***************************************************************************/
290static rtems_isr
291IntUartInterruptHandler(rtems_vector_number v)
292{
293        unsigned int                chan = v - UART_INTC0_IRQ_VECTOR(0);
294        struct IntUartInfoStruct   *info = &IntUartInfo[chan];
295
296        /* check to see if received data */
297        if ( MCF5282_UART_UISR(chan) & MCF5282_UART_UISR_RXRDY )
298        {
299                /* read data and put into the receive buffer */
300                while ( MCF5282_UART_USR(chan) & MCF5282_UART_USR_RXRDY )
301                {
302
303                        if ( MCF5282_UART_USR(chan) & MCF5282_UART_USR_ERROR )
304                        {
305                                /* clear the error */
306                                MCF5282_UART_UCR(chan) = MCF5282_UART_UCR_RESET_ERROR;
307                        }
308                        /* put data in rx buffer and check for errors */
309                        info->rx_buffer[info->rx_in] = MCF5282_UART_URB(chan);
310
311                        /* update buffer values */
312                        info->rx_in++;
313
314                        if ( info->rx_in >= RX_BUFFER_SIZE )
315                        {
316                                info->rx_in = 0;
317                        }
318                }
319                /* Make sure the port has been opened */
320                if ( info->ttyp )
321                {
322
323                        /* check to see if task driven */
324                        if ( info->iomode == TERMIOS_TASK_DRIVEN )
325                        {
326                                /* notify rx task that rx buffer has data */
327                                rtems_termios_rxirq_occured(info->ttyp);
328                        }
329                        else
330                        {
331                                /* Push up the received data */
332                                rtems_termios_enqueue_raw_characters(info->ttyp, info->rx_buffer, info->rx_in);
333                                info->rx_in    = 0;
334                        }
335                }
336        }
337
338        /* check to see if data needs to be transmitted */
339        if ( ( info->uimr & MCF5282_UART_UIMR_TXRDY ) &&
340                 ( MCF5282_UART_UISR(chan) & MCF5282_UART_UISR_TXRDY ) )
341        {
342
343                /* disable tx interrupts */
344                info->uimr &= ~MCF5282_UART_UIMR_TXRDY;
345                MCF5282_UART_UIMR(chan) = info->uimr;
346
347                /* tell upper level that character has been sent */
348                if ( info->ttyp )
349                        rtems_termios_dequeue_characters(info->ttyp, 1);
350        }
351}
352
353
354
355/***************************************************************************
356   Function : IntUartInitialize
357
358   Description : This initialises the internal uart hardware for all
359   internal uarts. If the internal uart is to be interrupt driven then the
360   interrupt vectors are hooked.
361 ***************************************************************************/
362static void
363IntUartInitialize(void)
364{
365        unsigned int        chan;
366        struct IntUartInfoStruct   *info;
367        rtems_isr_entry old_handler;
368    int level;
369
370        for ( chan = 0; chan < MAX_UART_INFO; chan++ )
371        {
372                info = &IntUartInfo[chan];
373
374                info->ttyp     = NULL;
375                info->rx_in    = 0;
376                info->rx_out   = 0;
377                info->baud     = -1;
378                info->databits = -1;
379                info->parity   = -1;
380                info->stopbits = -1;
381                info->hwflow   = -1;
382
383                MCF5282_UART_UACR(chan) = 0;
384                MCF5282_UART_UIMR(chan) = 0;
385                if ( info->iomode != TERMIOS_POLLED )
386                {
387                        rtems_interrupt_catch (IntUartInterruptHandler,
388                                                                   UART_INTC0_IRQ_VECTOR(chan),
389                                                                   &old_handler);
390                }
391
392                /* set uart default values */
393                IntUartSetAttributes(chan, NULL);
394
395        /* unmask interrupt */
396                rtems_interrupt_disable(level);
397        switch(chan) {
398        case 0:
399            bsp_allocate_interrupt(UART0_IRQ_LEVEL, UART0_IRQ_PRIORITY);
400            MCF5282_INTC0_ICR13 = MCF5282_INTC_ICR_IL(UART0_IRQ_LEVEL) |
401                                  MCF5282_INTC_ICR_IP(UART0_IRQ_PRIORITY);
402            MCF5282_INTC0_IMRL &= ~(MCF5282_INTC_IMRL_INT13 |
403                                    MCF5282_INTC_IMRL_MASKALL);
404            break;
405
406        case 1:
407            bsp_allocate_interrupt(UART1_IRQ_LEVEL, UART1_IRQ_PRIORITY);
408            MCF5282_INTC0_ICR14 = MCF5282_INTC_ICR_IL(UART1_IRQ_LEVEL) |
409                                  MCF5282_INTC_ICR_IP(UART1_IRQ_PRIORITY);
410            MCF5282_INTC0_IMRL &= ~(MCF5282_INTC_IMRL_INT14 |
411                                    MCF5282_INTC_IMRL_MASKALL);
412            break;
413
414        case 2:
415            bsp_allocate_interrupt(UART2_IRQ_LEVEL, UART2_IRQ_PRIORITY);
416            MCF5282_INTC0_ICR15 = MCF5282_INTC_ICR_IL(UART2_IRQ_LEVEL) |
417                                  MCF5282_INTC_ICR_IP(UART2_IRQ_PRIORITY);
418            MCF5282_INTC0_IMRL &= ~(MCF5282_INTC_IMRL_INT15 |
419                                    MCF5282_INTC_IMRL_MASKALL);
420            break;
421        }
422                rtems_interrupt_enable(level);
423
424        } /* of chan loop */
425
426
427} /* IntUartInitialise */
428
429
430/***************************************************************************
431   Function : IntUartInterruptWrite
432
433   Description : This writes a single character to the appropriate uart
434   channel. This is either called during an interrupt or in the user's task
435   to initiate a transmit sequence. Calling this routine enables Tx
436   interrupts.
437 ***************************************************************************/
438static int
439IntUartInterruptWrite (int minor, const char *buf, int len)
440{
441        int level;
442
443        rtems_interrupt_disable(level);
444
445        /* write out character */
446        MCF5282_UART_UTB(minor) = *buf;
447
448        /* enable tx interrupt */
449        IntUartInfo[minor].uimr |= MCF5282_UART_UIMR_TXRDY;
450        MCF5282_UART_UIMR(minor) = IntUartInfo[minor].uimr;
451
452        rtems_interrupt_enable(level);
453        return( 0 );
454}
455
456/***************************************************************************
457   Function : IntUartInterruptOpen
458
459   Description : This enables interrupts when the tty is opened.
460 ***************************************************************************/
461static int
462IntUartInterruptOpen(int major, int minor, void *arg)
463{
464        struct IntUartInfoStruct   *info = &IntUartInfo[minor];
465
466        /* enable the uart */
467        MCF5282_UART_UCR(minor) = (MCF5282_UART_UCR_TX_ENABLED | MCF5282_UART_UCR_RX_ENABLED);
468
469        /* check to see if interrupts need to be enabled */
470        if ( info->iomode != TERMIOS_POLLED )
471        {
472                /* enable rx interrupts */
473                info->uimr |= MCF5282_UART_UIMR_FFULL;
474                MCF5282_UART_UIMR(minor) = info->uimr;
475        }
476
477        /* check to see if doing hardware flow control */
478        if ( info->hwflow )
479        {
480                /* assert the RTS line */
481                MCF5282_UART_UOP1(minor) = 1;
482        }
483
484        return( 0 );
485}
486
487
488
489/***************************************************************************
490   Function : IntUartInterruptClose
491
492   Description : This disables interrupts when the tty is closed.
493 ***************************************************************************/
494static int
495IntUartInterruptClose(int major, int minor, void *arg)
496{
497        struct IntUartInfoStruct   *info = &IntUartInfo[minor];
498
499        /* disable the interrupts and the uart */
500        MCF5282_UART_UIMR(minor) = 0;
501        MCF5282_UART_UCR(minor) = (MCF5282_UART_UCR_TX_DISABLED | MCF5282_UART_UCR_RX_DISABLED);
502
503        /* reset values */
504        info->ttyp     = NULL;
505        info->uimr       = 0;
506        info->rx_in    = 0;
507        info->rx_out   = 0;
508
509        return( 0 );
510}
511
512/***************************************************************************
513   Function : IntUartTaskRead
514
515   Description : This reads all available characters from the internal uart
516   and places them into the termios buffer.  The rx interrupts will be
517   re-enabled after all data has been read.
518 ***************************************************************************/
519static int
520IntUartTaskRead(int minor)
521{
522        char                        buffer[RX_BUFFER_SIZE];
523        int                         count;
524        int                         rx_in;
525        int                         index = 0;
526        struct IntUartInfoStruct   *info  = &IntUartInfo[minor];
527
528        /* determine number of values to copy out */
529        rx_in = info->rx_in;
530        if ( info->rx_out <= rx_in )
531        {
532                count = rx_in - info->rx_out;
533        }
534        else
535        {
536                count = (RX_BUFFER_SIZE - info->rx_out) + rx_in;
537        }
538
539        /* copy data into local buffer from rx buffer */
540        while ( ( index < count ) && ( index < RX_BUFFER_SIZE ) )
541        {
542                /* copy data byte */
543                buffer[index] = info->rx_buffer[info->rx_out];
544                index++;
545
546                /* increment rx buffer values */
547                info->rx_out++;
548                if ( info->rx_out >= RX_BUFFER_SIZE )
549                {
550                        info->rx_out = 0;
551                }
552        }
553
554        /* check to see if buffer is not empty */
555        if ( count > 0 )
556        {
557                /* set characters into termios buffer  */
558                rtems_termios_enqueue_raw_characters(info->ttyp, buffer, count);
559        }
560
561        return( EOF );
562}
563
564
565
566/***************************************************************************
567   Function : IntUartPollRead
568
569   Description : This reads a character from the internal uart. It returns
570   to the caller without blocking if not character is waiting.
571 ***************************************************************************/
572static int
573IntUartPollRead (int minor)
574{
575        if ( (MCF5282_UART_USR(minor) & MCF5282_UART_USR_RXRDY) == 0 )
576                return(-1);
577
578        return(MCF5282_UART_URB(minor));
579}
580
581
582/***************************************************************************
583   Function : IntUartPollWrite
584
585   Description : This writes out each character in the buffer to the
586   appropriate internal uart channel waiting till each one is sucessfully
587   transmitted.
588 ***************************************************************************/
589static int
590IntUartPollWrite (int minor, const char *buf, int len)
591{
592        /* loop over buffer */
593        while ( len-- )
594        {
595                /* block until we can transmit */
596                while ( (MCF5282_UART_USR(minor) & MCF5282_UART_USR_TXRDY) == 0 )
597                        continue;
598                /* transmit data byte */
599                MCF5282_UART_UTB(minor) = *buf++;
600        }
601        return(0);
602}
603
604/***************************************************************************
605   Function : console_reserve_resources
606
607   Description : This reserves resources consumed by this driver. It passes
608   the request on to the termios subsystem.
609 ***************************************************************************/
610void console_reserve_resources( rtems_configuration_table *configuration )
611{
612        rtems_termios_reserve_resources (configuration, 1);
613}
614
615
616/***************************************************************************
617   Function : console_initialize
618
619   Description : This initialises termios, both sets of uart hardware before
620   registering /dev/tty devices for each channel and the system /dev/console.
621 ***************************************************************************/
622rtems_device_driver console_initialize(
623        rtems_device_major_number  major,
624        rtems_device_minor_number  minor,
625        void  *arg )
626{
627        rtems_status_code status;
628
629
630        /* Set up TERMIOS */
631        rtems_termios_initialize ();
632
633        /* set io modes for the different channels and initialize device */
634    IntUartInfo[minor].iomode = TERMIOS_IRQ_DRIVEN;
635        IntUartInitialize();
636
637        /* Register the console port */
638        status = rtems_io_register_name ("/dev/console", major, CONSOLE_PORT);
639        if ( status != RTEMS_SUCCESSFUL )
640        {
641                rtems_fatal_error_occurred (status);
642        }
643
644        /* Register the other port */
645        if ( CONSOLE_PORT != 0 )
646        {
647                status = rtems_io_register_name ("/dev/tty00", major, 0);
648                if ( status != RTEMS_SUCCESSFUL )
649                {
650                        rtems_fatal_error_occurred (status);
651                }
652        }
653        if ( CONSOLE_PORT != 1 )
654        {
655                status = rtems_io_register_name ("/dev/tty01", major, 1);
656                if ( status != RTEMS_SUCCESSFUL )
657                {
658                        rtems_fatal_error_occurred (status);
659                }
660        }
661
662        return(RTEMS_SUCCESSFUL);
663}
664
665/***************************************************************************
666   Function : console_open
667
668   Description : This actually opens the device depending on the minor
669   number set during initialisation. The device specific access routines are
670   passed to termios when the devices is opened depending on whether it is
671   polled or not.
672 ***************************************************************************/
673rtems_device_driver console_open(
674        rtems_device_major_number major,
675        rtems_device_minor_number minor,
676        void  * arg)
677{
678        rtems_status_code                status = RTEMS_INVALID_NUMBER;
679        rtems_libio_open_close_args_t   *args   = (rtems_libio_open_close_args_t *)arg;
680        struct IntUartInfoStruct        *info;
681
682        static const rtems_termios_callbacks IntUartPollCallbacks = {
683                NULL,                             /* firstOpen */
684                NULL,                             /* lastClose */
685                IntUartPollRead,          /* pollRead */
686                IntUartPollWrite,         /* write */
687                IntUartSetAttributes, /* setAttributes */
688                NULL,                             /* stopRemoteTx */
689                NULL,                             /* startRemoteTx */
690                TERMIOS_POLLED            /* mode */
691        };
692        static const rtems_termios_callbacks IntUartIntrCallbacks = {
693                IntUartInterruptOpen,  /* firstOpen */
694                IntUartInterruptClose, /* lastClose */
695                NULL,                              /* pollRead */
696                IntUartInterruptWrite, /* write */
697                IntUartSetAttributes,  /* setAttributes */
698                NULL,                              /* stopRemoteTx */
699                NULL,                              /* startRemoteTx */
700                TERMIOS_IRQ_DRIVEN         /* mode */
701        };
702
703        static const rtems_termios_callbacks IntUartTaskCallbacks = {
704                IntUartInterruptOpen,  /* firstOpen */
705                IntUartInterruptClose, /* lastClose */
706                IntUartTaskRead,           /* pollRead */
707                IntUartInterruptWrite, /* write */
708                IntUartSetAttributes,  /* setAttributes */
709                NULL,                              /* stopRemoteTx */
710                NULL,                              /* startRemoteTx */
711                TERMIOS_TASK_DRIVEN        /* mode */
712        };
713
714        /* open the port depending on the minor device number */
715        if ( ( minor >= 0 ) && ( minor < MAX_UART_INFO ) )
716        {
717                info = &IntUartInfo[minor];
718                switch ( info->iomode )
719                {
720                        case TERMIOS_POLLED:
721                                status = rtems_termios_open(major, minor, arg, &IntUartPollCallbacks);
722                                break;
723                        case TERMIOS_IRQ_DRIVEN:
724                                status = rtems_termios_open(major, minor, arg, &IntUartIntrCallbacks);
725                                info->ttyp = args->iop->data1;
726                                break;
727                        case TERMIOS_TASK_DRIVEN:
728                                status = rtems_termios_open(major, minor, arg, &IntUartTaskCallbacks);
729                                info->ttyp = args->iop->data1;
730                                break;
731                }
732        }
733
734        return( status );
735}
736
737/***************************************************************************
738   Function : console_close
739
740   Description : This closes the device via termios
741 ***************************************************************************/
742rtems_device_driver console_close(
743        rtems_device_major_number major,
744        rtems_device_minor_number minor,
745        void   * arg)
746{
747    return(rtems_termios_close (arg));
748}
749
750/******************
751*********************************************************
752   Function : console_read
753
754   Description : Read from the device via termios
755 ***************************************************************************/
756rtems_device_driver console_read(
757        rtems_device_major_number major,
758        rtems_device_minor_number minor,
759        void  * arg)
760{
761    return(rtems_termios_read (arg));
762}
763
764/***************************************************************************
765   Function : console_write
766
767   Description : Write to the device via termios
768 ***************************************************************************/
769rtems_device_driver console_write(
770        rtems_device_major_number major,
771        rtems_device_minor_number minor,
772        void  * arg)
773{
774    return(rtems_termios_write (arg));
775}
776
777/***************************************************************************
778   Function : console_ioctl
779
780   Description : Pass the IOCtl call to termios
781 ***************************************************************************/
782rtems_device_driver console_control(
783        rtems_device_major_number major,
784        rtems_device_minor_number minor,
785        void  * arg)
786{
787    return( rtems_termios_ioctl (arg) );
788}
789int DEBUG_OUTCHAR(int c)
790{
791    if(c == '\n')
792        DEBUG_OUTCHAR('\r');
793    _BSP_null_char(c);
794    return c;
795}
796void DEBUG_OUTSTR(const char *msg)
797{
798    while (*msg)
799        DEBUG_OUTCHAR(*msg++);
800}
801void DEBUG_OUTNUM(int i)
802{
803    int n;
804    static const char map[] = "0123456789ABCDEF";
805    DEBUG_OUTCHAR(' ');
806    for (n = 28 ; n >= 0 ; n -= 4)
807        DEBUG_OUTCHAR(map[(i >> n) & 0xF]);
808}
Note: See TracBrowser for help on using the repository browser.