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

4.115
Last change on this file since d08e1320 was d08e1320, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/14 at 13:54:17

m68k/uC5282/console/console.c: Eliminate unused debug methods

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