source: rtems/c/src/lib/libbsp/m68k/uC5282/console/console.c @ 1d386ff

4.104.114.84.95
Last change on this file since 1d386ff was 1d386ff, checked in by Eric Norum <WENorum@…>, on 02/01/05 at 22:36:53

Want only two serial ports for now.

  • Property mode set to 100644
File size: 21.9 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 = 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            MCF5282_INTC0_ICR13 = MCF5282_INTC_ICR_IL(UART0_IRQ_LEVEL) |
400                                  MCF5282_INTC_ICR_IP(UART0_IRQ_PRIORITY);
401            MCF5282_INTC0_IMRL &= ~(MCF5282_INTC_IMRL_INT13 |
402                                    MCF5282_INTC_IMRL_MASKALL);
403            break;
404
405        case 1:
406            MCF5282_INTC0_ICR14 = MCF5282_INTC_ICR_IL(UART1_IRQ_LEVEL) |
407                                  MCF5282_INTC_ICR_IP(UART1_IRQ_PRIORITY);
408            MCF5282_INTC0_IMRL &= ~(MCF5282_INTC_IMRL_INT14 |
409                                    MCF5282_INTC_IMRL_MASKALL);
410            break;
411
412        case 2:
413            MCF5282_INTC0_ICR15 = MCF5282_INTC_ICR_IL(UART2_IRQ_LEVEL) |
414                                  MCF5282_INTC_ICR_IP(UART2_IRQ_PRIORITY);
415            MCF5282_INTC0_IMRL &= ~(MCF5282_INTC_IMRL_INT15 |
416                                    MCF5282_INTC_IMRL_MASKALL);
417            break;
418        }
419                rtems_interrupt_enable(level);
420
421        } /* of chan loop */
422
423
424} /* IntUartInitialise */
425
426
427/***************************************************************************
428   Function : IntUartInterruptWrite
429
430   Description : This writes a single character to the appropriate uart
431   channel. This is either called during an interrupt or in the user's task
432   to initiate a transmit sequence. Calling this routine enables Tx
433   interrupts.
434 ***************************************************************************/
435static int
436IntUartInterruptWrite (int minor, const char *buf, int len)
437{
438        int level;
439
440        rtems_interrupt_disable(level);
441
442        /* write out character */
443        MCF5282_UART_UTB(minor) = *buf;
444
445        /* enable tx interrupt */
446        IntUartInfo[minor].uimr |= MCF5282_UART_UIMR_TXRDY;
447        MCF5282_UART_UIMR(minor) = IntUartInfo[minor].uimr;
448
449        rtems_interrupt_enable(level);
450        return( 0 );
451}
452
453/***************************************************************************
454   Function : IntUartInterruptOpen
455
456   Description : This enables interrupts when the tty is opened.
457 ***************************************************************************/
458static int
459IntUartInterruptOpen(int major, int minor, void *arg)
460{
461        struct IntUartInfoStruct   *info = &IntUartInfo[minor];
462
463        /* enable the uart */
464        MCF5282_UART_UCR(minor) = (MCF5282_UART_UCR_TX_ENABLED | MCF5282_UART_UCR_RX_ENABLED);
465
466        /* check to see if interrupts need to be enabled */
467        if ( info->iomode != TERMIOS_POLLED )
468        {
469                /* enable rx interrupts */
470                info->uimr |= MCF5282_UART_UIMR_FFULL;
471                MCF5282_UART_UIMR(minor) = info->uimr;
472        }
473
474        /* check to see if doing hardware flow control */
475        if ( info->hwflow )
476        {
477                /* assert the RTS line */
478                MCF5282_UART_UOP1(minor) = 1;
479        }
480
481        return( 0 );
482}
483
484
485
486/***************************************************************************
487   Function : IntUartInterruptClose
488
489   Description : This disables interrupts when the tty is closed.
490 ***************************************************************************/
491static int
492IntUartInterruptClose(int major, int minor, void *arg)
493{
494        struct IntUartInfoStruct   *info = &IntUartInfo[minor];
495
496        /* disable the interrupts and the uart */
497        MCF5282_UART_UIMR(minor) = 0;
498        MCF5282_UART_UCR(minor) = (MCF5282_UART_UCR_TX_DISABLED | MCF5282_UART_UCR_RX_DISABLED);
499
500        /* reset values */
501        info->ttyp     = NULL;
502        info->uimr       = 0;
503        info->rx_in    = 0;
504        info->rx_out   = 0;
505
506        return( 0 );
507}
508
509/***************************************************************************
510   Function : IntUartTaskRead
511
512   Description : This reads all available characters from the internal uart
513   and places them into the termios buffer.  The rx interrupts will be
514   re-enabled after all data has been read.
515 ***************************************************************************/
516static int
517IntUartTaskRead(int minor)
518{
519        char                        buffer[RX_BUFFER_SIZE];
520        int                         count;
521        int                         rx_in;
522        int                         index = 0;
523        struct IntUartInfoStruct   *info  = &IntUartInfo[minor];
524
525        /* determine number of values to copy out */
526        rx_in = info->rx_in;
527        if ( info->rx_out <= rx_in )
528        {
529                count = rx_in - info->rx_out;
530        }
531        else
532        {
533                count = (RX_BUFFER_SIZE - info->rx_out) + rx_in;
534        }
535
536        /* copy data into local buffer from rx buffer */
537        while ( ( index < count ) && ( index < RX_BUFFER_SIZE ) )
538        {
539                /* copy data byte */
540                buffer[index] = info->rx_buffer[info->rx_out];
541                index++;
542
543                /* increment rx buffer values */
544                info->rx_out++;
545                if ( info->rx_out >= RX_BUFFER_SIZE )
546                {
547                        info->rx_out = 0;
548                }
549        }
550
551        /* check to see if buffer is not empty */
552        if ( count > 0 )
553        {
554                /* set characters into termios buffer  */
555                rtems_termios_enqueue_raw_characters(info->ttyp, buffer, count);
556        }
557
558        return( EOF );
559}
560
561
562
563/***************************************************************************
564   Function : IntUartPollRead
565
566   Description : This reads a character from the internal uart. It returns
567   to the caller without blocking if not character is waiting.
568 ***************************************************************************/
569static int
570IntUartPollRead (int minor)
571{
572        if ( (MCF5282_UART_USR(minor) & MCF5282_UART_USR_RXRDY) == 0 )
573                return(-1);
574
575        return(MCF5282_UART_URB(minor));
576}
577
578
579/***************************************************************************
580   Function : IntUartPollWrite
581
582   Description : This writes out each character in the buffer to the
583   appropriate internal uart channel waiting till each one is sucessfully
584   transmitted.
585 ***************************************************************************/
586static int
587IntUartPollWrite (int minor, const char *buf, int len)
588{
589        /* loop over buffer */
590        while ( len-- )
591        {
592                /* block until we can transmit */
593                while ( (MCF5282_UART_USR(minor) & MCF5282_UART_USR_TXRDY) == 0 )
594                        continue;
595                /* transmit data byte */
596                MCF5282_UART_UTB(minor) = *buf++;
597        }
598        return(0);
599}
600
601/***************************************************************************
602   Function : console_reserve_resources
603
604   Description : This reserves resources consumed by this driver. It passes
605   the request on to the termios subsystem.
606 ***************************************************************************/
607void console_reserve_resources( rtems_configuration_table *configuration )
608{
609        rtems_termios_reserve_resources (configuration, 1);
610}
611
612
613/***************************************************************************
614   Function : console_initialize
615
616   Description : This initialises termios, both sets of uart hardware before
617   registering /dev/tty devices for each channel and the system /dev/console.
618 ***************************************************************************/
619rtems_device_driver console_initialize(
620        rtems_device_major_number  major,
621        rtems_device_minor_number  minor,
622        void  *arg )
623{
624        rtems_status_code status;
625
626
627        /* Set up TERMIOS */
628        rtems_termios_initialize ();
629
630        /* set io modes for the different channels and initialize device */
631    IntUartInfo[minor].iomode = TERMIOS_IRQ_DRIVEN;
632        IntUartInitialize();
633
634        /* Register the console port */
635        status = rtems_io_register_name ("/dev/console", major, CONSOLE_PORT);
636        if ( status != RTEMS_SUCCESSFUL )
637        {
638                rtems_fatal_error_occurred (status);
639        }
640
641        /* Register the other port */
642        if ( CONSOLE_PORT != 0 )
643        {
644                status = rtems_io_register_name ("/dev/tty00", major, 0);
645                if ( status != RTEMS_SUCCESSFUL )
646                {
647                        rtems_fatal_error_occurred (status);
648                }
649        }
650        if ( CONSOLE_PORT != 1 )
651        {
652                status = rtems_io_register_name ("/dev/tty01", major, 1);
653                if ( status != RTEMS_SUCCESSFUL )
654                {
655                        rtems_fatal_error_occurred (status);
656                }
657        }
658
659        return(RTEMS_SUCCESSFUL);
660}
661
662/***************************************************************************
663   Function : console_open
664
665   Description : This actually opens the device depending on the minor
666   number set during initialisation. The device specific access routines are
667   passed to termios when the devices is opened depending on whether it is
668   polled or not.
669 ***************************************************************************/
670rtems_device_driver console_open(
671        rtems_device_major_number major,
672        rtems_device_minor_number minor,
673        void  * arg)
674{
675        rtems_status_code                status = RTEMS_INVALID_NUMBER;
676        rtems_libio_open_close_args_t   *args   = (rtems_libio_open_close_args_t *)arg;
677        struct IntUartInfoStruct        *info;
678
679        static const rtems_termios_callbacks IntUartPollCallbacks = {
680                NULL,                             /* firstOpen */
681                NULL,                             /* lastClose */
682                IntUartPollRead,          /* pollRead */
683                IntUartPollWrite,         /* write */
684                IntUartSetAttributes, /* setAttributes */
685                NULL,                             /* stopRemoteTx */
686                NULL,                             /* startRemoteTx */
687                TERMIOS_POLLED            /* mode */
688        };
689        static const rtems_termios_callbacks IntUartIntrCallbacks = {
690                IntUartInterruptOpen,  /* firstOpen */
691                IntUartInterruptClose, /* lastClose */
692                NULL,                              /* pollRead */
693                IntUartInterruptWrite, /* write */
694                IntUartSetAttributes,  /* setAttributes */
695                NULL,                              /* stopRemoteTx */
696                NULL,                              /* startRemoteTx */
697                TERMIOS_IRQ_DRIVEN         /* mode */
698        };
699
700        static const rtems_termios_callbacks IntUartTaskCallbacks = {
701                IntUartInterruptOpen,  /* firstOpen */
702                IntUartInterruptClose, /* lastClose */
703                IntUartTaskRead,           /* pollRead */
704                IntUartInterruptWrite, /* write */
705                IntUartSetAttributes,  /* setAttributes */
706                NULL,                              /* stopRemoteTx */
707                NULL,                              /* startRemoteTx */
708                TERMIOS_TASK_DRIVEN        /* mode */
709        };
710
711        /* open the port depending on the minor device number */
712        if ( ( minor >= 0 ) && ( minor < MAX_UART_INFO ) )
713        {
714                info = &IntUartInfo[minor];
715                switch ( info->iomode )
716                {
717                        case TERMIOS_POLLED:
718                                status = rtems_termios_open(major, minor, arg, &IntUartPollCallbacks);
719                                break;
720                        case TERMIOS_IRQ_DRIVEN:
721                                status = rtems_termios_open(major, minor, arg, &IntUartIntrCallbacks);
722                                info->ttyp = args->iop->data1;
723                                break;
724                        case TERMIOS_TASK_DRIVEN:
725                                status = rtems_termios_open(major, minor, arg, &IntUartTaskCallbacks);
726                                info->ttyp = args->iop->data1;
727                                break;
728                }
729        }
730
731        return( status );
732}
733
734/***************************************************************************
735   Function : console_close
736
737   Description : This closes the device via termios
738 ***************************************************************************/
739rtems_device_driver console_close(
740        rtems_device_major_number major,
741        rtems_device_minor_number minor,
742        void   * arg)
743{
744    return(rtems_termios_close (arg));
745}
746
747/******************
748*********************************************************
749   Function : console_read
750
751   Description : Read from the device via termios
752 ***************************************************************************/
753rtems_device_driver console_read(
754        rtems_device_major_number major,
755        rtems_device_minor_number minor,
756        void  * arg)
757{
758    return(rtems_termios_read (arg));
759}
760
761/***************************************************************************
762   Function : console_write
763
764   Description : Write to the device via termios
765 ***************************************************************************/
766rtems_device_driver console_write(
767        rtems_device_major_number major,
768        rtems_device_minor_number minor,
769        void  * arg)
770{
771    return(rtems_termios_write (arg));
772}
773
774/***************************************************************************
775   Function : console_ioctl
776
777   Description : Pass the IOCtl call to termios
778 ***************************************************************************/
779rtems_device_driver console_control(
780        rtems_device_major_number major,
781        rtems_device_minor_number minor,
782        void  * arg)
783{
784    return( rtems_termios_ioctl (arg) );
785}
786int DEBUG_OUTCHAR(int c)
787{
788    if(c == '\n')
789        DEBUG_OUTCHAR('\r');
790    _BSP_null_char(c);
791    return c;
792}
793void DEBUG_OUTSTR(const char *msg)
794{
795    while (*msg)
796        DEBUG_OUTCHAR(*msg++);
797}
798void DEBUG_OUTNUM(int i)
799{
800    int n;
801    static const char map[] = "0123456789ABCDEF";
802    DEBUG_OUTCHAR(' ');
803    for (n = 28 ; n >= 0 ; n -= 4)
804        DEBUG_OUTCHAR(map[(i >> n) & 0xF]);
805}
Note: See TracBrowser for help on using the repository browser.