source: rtems/c/src/lib/libbsp/m68k/mcf5235/console/console.c @ 8fd9e978

4.104.114.84.95
Last change on this file since 8fd9e978 was 8fd9e978, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/07/05 at 06:26:08

Eliminate unsigned32, unsigned8.

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