source: rtems/c/src/lib/libbsp/powerpc/gen5200/console/console.c @ 1af911b8

4.104.114.84.95
Last change on this file since 1af911b8 was 1af911b8, checked in by Ralf Corsepius <ralf.corsepius@…>, on 10/17/06 at 02:40:57

Convert to utf-8.

  • Property mode set to 100644
File size: 22.2 KB
Line 
1/*===============================================================*\
2| Project: RTEMS generic MPC5200 BSP                              |
3+-----------------------------------------------------------------+
4| Partially based on the code references which are named below.   |
5| Adaptions, modifications, enhancements and any recent parts of  |
6| the code are:                                                   |
7|                    Copyright (c) 2005                           |
8|                    Embedded Brains GmbH                         |
9|                    Obere Lagerstr. 30                           |
10|                    D-82178 Puchheim                             |
11|                    Germany                                      |
12|                    rtems@embedded-brains.de                     |
13+-----------------------------------------------------------------+
14| The license and distribution terms for this file may be         |
15| found in the file LICENSE in this distribution or at            |
16|                                                                 |
17| http://www.rtems.com/license/LICENSE.                           |
18|                                                                 |
19+-----------------------------------------------------------------+
20| this file contains the console driver functions                 |
21\*===============================================================*/
22/***********************************************************************/
23/*                                                                     */
24/*   Module:       console.c                                           */
25/*   Date:         07/17/2003                                          */
26/*   Purpose:      RTEMS MPC5x00 console driver                        */
27/*                                                                     */
28/*---------------------------------------------------------------------*/
29/*                                                                     */
30/*   Description:                                                      */
31/*                                                                     */
32/*  The PSCs of mpc5200 are assigned as follows                        */
33/*                                                                     */
34/*              Channel     Device      Minor   Note                   */
35/*                PSC1      /dev/tty0      0                           */
36/*                PSC2      /dev/tty1      1                           */
37/*                PSC3      /dev/tty2      2                           */
38/*                                                                     */
39/*---------------------------------------------------------------------*/
40/*                                                                     */
41/*   Code                                                              */
42/*   References:   Serial driver for MPC8260ads                        */
43/*   Module:       console-generic.c                                   */
44/*   Project:      RTEMS 4.6.0pre1 / MPC8260ads BSP                    */
45/*   Version       1.3                                                 */
46/*   Date:         2002/11/04                                          */
47/*                                                                     */
48/*   Author(s) / Copyright(s):                                         */
49/*                                                                     */
50/*   Author: Jay Monkman (jmonkman@frasca.com)                         */
51/*   Copyright (C) 1998 by Frasca International, Inc.                  */
52/*                                                                     */
53/*   Derived from c/src/lib/libbsp/m68k/gen360/console/console.c       */
54/*   written by:                                                       */
55/*   W. Eric Norum                                                     */
56/*   Saskatchewan Accelerator Laboratory                               */
57/*   University of Saskatchewan                                        */
58/*   Saskatoon, Saskatchewan, CANADA                                   */
59/*   eric@skatter.usask.ca                                             */
60/*                                                                     */
61/*   COPYRIGHT (c) 1989-1998.                                          */
62/*   On-Line Applications Research Corporation (OAR).                  */
63/*                                                                     */
64/*   Modifications by Darlene Stewart <Darlene.Stewart@iit.nrc.ca>     */
65/*   and Charles-Antoine Gauthier <charles.gauthier@iit.nrc.ca>        */
66/*   Copyright (c) 1999, National Research Council of Canada           */
67/*                                                                     */
68/*   Modifications by Andy Dachs <a.dachs@sstl.co.uk> to add MPC8260   */
69/*   support.                                                          */
70/*   Copyright (c) 2001, Surrey Satellite Technology Ltd               */
71/*                                                                     */
72/*   The license and distribution terms for this file may be           */
73/*   found in the file LICENSE in this distribution or at              */
74/*   http://www.OARcorp.com/rtems/license.html.                        */
75/*                                                                     */
76/*---------------------------------------------------------------------*/
77/*                                                                     */
78/*   Partially based on the code references which are named above.     */
79/*   Adaptions, modifications, enhancements and any recent parts of    */
80/*   the code are under the right of                                   */
81/*                                                                     */
82/*         IPR Engineering, Dachauer Straße 38, D-80335 MÃŒnchen        */
83/*                        Copyright(C) 2003                            */
84/*                                                                     */
85/*---------------------------------------------------------------------*/
86/*                                                                     */
87/*   IPR Engineering makes no representation or warranties with        */
88/*   respect to the performance of this computer program, and          */
89/*   specifically disclaims any responsibility for any damages,        */
90/*   special or consequential, connected with the use of this program. */
91/*                                                                     */
92/*---------------------------------------------------------------------*/
93/*                                                                     */
94/*   Version history:  1.0                                             */
95/*                                                                     */
96/***********************************************************************/
97
98#include <rtems.h>
99#include "../include/mpc5200.h"
100#include <bsp.h>
101#include "../irq/irq.h"
102
103#include <rtems/bspIo.h>
104#include <rtems/libio.h>
105#include <string.h>
106
107
108#define NUM_PORTS       MPC5200_PSC_NO
109
110#define PSC1_MINOR      0
111#define PSC2_MINOR      1
112#define PSC3_MINOR      2
113#define PSC4_MINOR      3
114#define PSC5_MINOR      4
115#define PSC6_MINOR      5
116
117uint32_t mpc5200_uart_avail_mask = GEN5200_UART_AVAIL_MASK;
118
119uint8_t psc_minor_to_irqname[NUM_PORTS] =
120  {BSP_SIU_IRQ_PSC1,
121   BSP_SIU_IRQ_PSC2,
122   BSP_SIU_IRQ_PSC3,
123   BSP_SIU_IRQ_PSC4,
124   BSP_SIU_IRQ_PSC5,
125   BSP_SIU_IRQ_PSC6};
126static int mpc5200_psc_irqname_to_minor(int name)
127{
128  int minor;
129  uint8_t *chrptr;
130
131  chrptr = memchr(psc_minor_to_irqname,
132                  name,
133                  sizeof(psc_minor_to_irqname));
134  if (chrptr != NULL) {
135    minor = chrptr - psc_minor_to_irqname;
136  }
137  else {
138    minor = -1;
139  }
140  return minor;
141}
142
143static void A_BSP_output_char(char c);
144BSP_output_char_function_type BSP_output_char = A_BSP_output_char;
145
146/* Used to handle premature outputs of printk */
147uint32_t console_initialized = FALSE;
148
149/* per channel info structure */
150struct per_channel_info
151  {
152  uint16_t shadow_imr;
153  uint8_t shadow_mode1;
154  uint8_t shadow_mode2;
155  int cur_tx_len;
156  int rx_interrupts;
157  int tx_interrupts;
158  int rx_characters;
159  int tx_characters;
160  int breaks_detected;
161  int framing_errors;
162  int parity_errors;
163  int overrun_errors;
164  };
165
166/* Used to handle more than one channel */
167struct per_channel_info channel_info[NUM_PORTS];
168
169  /*
170   * XXX: there are only 6 PSCs, but PSC6 has an extra register gap
171   *      from PSC5, therefore we instantiate seven(!) PSC register sets
172   */
173uint8_t psc_minor_to_regset[MPC5200_PSC_NO] = {0,1,2,3,4,6};
174
175/* Used to track termios private data for callbacks */
176struct rtems_termios_tty *ttyp[NUM_PORTS];
177
178int mpc5200_psc_setAttributes(int minor, const struct termios *t)
179  {
180  int baud;
181  uint8_t csize=0, cstopb, parenb, parodd;
182  struct mpc5200_psc *psc =
183    (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
184
185  /* Baud rate */
186  switch(t->c_cflag & CBAUD)
187    {
188        default:      baud = -1;      break;
189    case B50:     baud = 50;      break;
190    case B75:     baud = 75;      break;
191    case B110:    baud = 110;     break;
192    case B134:    baud = 134;     break;
193    case B150:    baud = 150;     break;
194    case B200:    baud = 200;     break;
195    case B300:    baud = 300;     break;
196    case B600:    baud = 600;     break;
197    case B1200:   baud = 1200;    break;
198    case B1800:   baud = 1800;    break;
199    case B2400:   baud = 2400;    break;
200    case B4800:   baud = 4800;    break;
201    case B9600:   baud = 9600;    break;
202    case B19200:  baud = 19200;   break;
203    case B38400:  baud = 38400;   break;
204    case B57600:  baud = 57600;   break;
205    case B115200: baud = 115200;  break;
206    case B230400: baud = 230400;  break;
207    case B460800: baud = 460800;  break;
208    }
209
210  if(baud > 0)
211    {
212
213   /*
214        * Calculate baud rate
215        * round divider to nearest!
216    */
217    baud = (IPB_CLOCK + baud *16) / (baud * 32);
218
219    }
220
221  /* Number of data bits */
222  switch ( t->c_cflag & CSIZE )
223    {
224    case CS5:     csize = 0x00;  break;
225    case CS6:     csize = 0x01;  break;
226    case CS7:     csize = 0x02;  break;
227    case CS8:     csize = 0x03;  break;
228    }
229
230  /* Stop bits */
231  if(csize == 0)
232    {
233
234    if(t->c_cflag & CSTOPB)
235      cstopb = 0x0F;           /* Two stop bits */
236    else
237      cstopb = 0x00;           /* One stop bit */
238
239    }
240  else
241    {
242
243        if(t->c_cflag & CSTOPB)
244          cstopb = 0x0F;           /* Two stop bits */
245        else
246      cstopb = 0x07;           /* One stop bit */
247
248    }
249
250  /* Parity */
251  if (t->c_cflag & PARENB)
252    parenb = 0x00;             /* Parity enabled on Tx and Rx */
253  else
254    parenb = 0x10;             /* No parity on Tx and Rx */
255
256  if (t->c_cflag & PARODD)
257    parodd = 0x04;             /* Odd parity */
258  else
259    parodd = 0x00;
260
261 /*
262  * Set upper timer counter
263  */
264  psc->ctur = (uint16_t)(baud >> 16);
265
266 /*
267  * Set lower timer counter
268  */
269  psc->ctlr = (uint16_t)(baud & 0x0000FFFF);
270
271 /*
272  * Reset mode pointer
273  */
274  psc->cr = ((1 << 4) << 8);
275
276 /*
277  * Set mode1 register
278  */
279  channel_info[minor].shadow_mode1 &= ~(0x1F);
280  psc->mr = channel_info[minor].shadow_mode1 | (csize | parenb | parodd);
281
282 /*
283  * Set mode2 register
284  */
285  channel_info[minor].shadow_mode2 &= ~(0x0F);
286  psc->mr = channel_info[minor].shadow_mode2 | cstopb;
287
288  return 0;
289
290  }
291
292
293int mpc5200_uart_setAttributes(int minor, const struct termios *t)
294  {
295
296
297  /*
298   * Check that port number is valid
299   */
300  if( (minor < PSC1_MINOR) || (minor > NUM_PORTS-1) )
301    return 0;
302
303  return mpc5200_psc_setAttributes(minor, t);
304
305  }
306
307
308#ifdef UARTS_USE_TERMIOS_INT
309/*
310 * Interrupt handlers
311 */
312static void mpc5200_psc_interrupt_handler(rtems_irq_hdl_param handle)
313  {
314  unsigned char c;
315  uint16_t isr;
316  int nb_overflow;
317  int minor = (int)handle;
318  struct mpc5200_psc *psc =
319    (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
320
321  /*
322   * get content of psc interrupt status
323   */
324  isr = psc->isr_imr;
325
326  /*
327   * Character received?
328   */
329  if(isr & ISR_RX_RDY_FULL)
330    {
331
332    channel_info[minor].rx_interrupts++;
333
334
335#ifndef SINGLE_CHAR_MODE
336    while(psc->rfnum)
337      {
338#endif
339
340     /*
341          * get the character
342      */
343      c = (psc->rb_tb >> 24);
344
345      if (ttyp[minor] != NULL) {
346        nb_overflow = rtems_termios_enqueue_raw_characters((void *)ttyp[minor], (char *)&c, (int)1);
347        channel_info[minor].rx_characters++;
348      }
349
350#ifndef SINGLE_CHAR_MODE
351      }
352#endif
353
354    }
355
356  /*
357   * Character transmitted ?
358   */
359  if(isr & ISR_TX_RDY & channel_info[minor].shadow_imr)
360    {
361
362    channel_info[minor].tx_interrupts++;
363
364    /*
365         * mask interrupt
366         */
367        psc->isr_imr = channel_info[minor].shadow_imr &= ~(IMR_TX_RDY);
368
369        if (ttyp[minor] != NULL) {
370#ifndef SINGLE_CHAR_MODE
371           rtems_termios_dequeue_characters((void *)ttyp[minor], channel_info[minor].cur_tx_len);
372
373           channel_info[minor].tx_characters += channel_info[minor].cur_tx_len;
374#else
375           rtems_termios_dequeue_characters((void *)ttyp[minor], (int)1);
376
377           channel_info[minor].tx_characters++;
378#endif
379        }
380    }
381
382  if(isr & ISR_ERROR)
383    {
384
385    if(isr & ISR_RB)
386          channel_info[minor].breaks_detected++;
387
388        if(isr & ISR_FE)
389          channel_info[minor].framing_errors++;
390
391        if(isr & ISR_PE)
392          channel_info[minor].parity_errors++;
393
394        if(isr & ISR_PE)
395          channel_info[minor].overrun_errors++;
396
397        /*
398        *  Reset error status
399        */
400    psc->cr = ((4 << 4) << 8);
401
402    }
403
404  }
405
406void mpc5200_psc_enable(const rtems_irq_connect_data* ptr) {
407  struct mpc5200_psc *psc;
408  int minor =  mpc5200_psc_irqname_to_minor(ptr->name);
409
410  if (minor >= 0) {
411    psc = (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
412    psc->isr_imr = channel_info[minor].shadow_imr |=
413      (IMR_RX_RDY_FULL | IMR_TX_RDY);
414  }
415}
416
417
418void mpc5200_psc_disable(const rtems_irq_connect_data* ptr) {
419  struct mpc5200_psc *psc;
420  int minor =  mpc5200_psc_irqname_to_minor(ptr->name);
421
422  if (minor >= 0) {
423    psc = (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
424    psc->isr_imr = channel_info[minor].shadow_imr &=
425      ~(IMR_RX_RDY_FULL | IMR_TX_RDY);
426  }
427}
428
429
430int mpc5200_psc_isOn(const rtems_irq_connect_data* ptr) {
431  struct mpc5200_psc *psc;
432  int minor =  mpc5200_psc_irqname_to_minor(ptr->name);
433
434  if (minor >= 0) {
435    psc = (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
436    return ((psc->isr_imr & IMR_RX_RDY_FULL) & (psc->isr_imr & IMR_TX_RDY));
437  }
438  else {
439    return FALSE;
440  }
441}
442
443
444static rtems_irq_connect_data consoleIrqData;
445#endif
446
447void mpc5200_uart_psc_initialize(int minor) {
448  uint32_t baud_divider;
449  struct mpc5200_psc *psc =
450    (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
451
452  /*
453   * Check that minor number is valid
454   */
455  if((minor < PSC1_MINOR) || (minor >= (PSC1_MINOR + NUM_PORTS)))
456    return;
457
458  /*
459   * Clear per channel info
460   */
461  memset((void *)&channel_info[minor], 0, sizeof(struct per_channel_info));
462
463
464  /*
465   * Reset receiver and transmitter
466   */
467  psc->cr = ((2 << 4) << 8);
468  psc->cr = ((3 << 4) << 8);
469
470  /*
471   * Reset mode pointer
472   */
473  psc->cr = ((1 << 4) << 8);
474
475  /*
476   * Set clock select register
477   */
478  psc->sr_csr = 0;
479
480  /*
481   * Set mode1 register
482   */
483  psc->mr = channel_info[minor].shadow_mode1 = 0x33; /* 8Bit / no parity */
484
485  /*
486   * Set mode2 register
487   */
488  psc->mr = channel_info[minor].shadow_mode2 = 7; /* 1 stop bit */
489
490  /*
491   * Set rx FIFO alarm
492   */
493  psc->rfalarm = RX_FIFO_SIZE - 1;
494
495  /*
496   * Set tx FIFO alarm
497   */
498  psc->tfalarm = 1;
499
500  baud_divider = IPB_CLOCK / (9600 * 32);
501  /*
502   * Set upper timer counter
503   */
504  psc->ctur = baud_divider >> 16;
505
506
507  /*
508   * Set lower timer counter
509   */
510
511  psc->ctlr = baud_divider & 0x0000ffff;
512
513  /*
514   * Disable Frame mode / set granularity 0
515   */
516  psc->tfcntl = 0;
517
518#ifdef UARTS_USE_TERMIOS_INT
519  /*
520   * Tie interrupt dependent routines
521   */
522  consoleIrqData.on     = mpc5200_psc_enable;
523  consoleIrqData.off    = mpc5200_psc_disable;
524  consoleIrqData.isOn   = mpc5200_psc_isOn;
525  consoleIrqData.handle = (rtems_irq_hdl_param)minor;
526  consoleIrqData.hdl    = (rtems_irq_hdl)mpc5200_psc_interrupt_handler;
527
528  /*
529   * Tie interrupt handler
530   */
531  consoleIrqData.name = psc_minor_to_irqname[minor];
532
533  /*
534   * Install rtems irq handler
535   */
536  if(!BSP_install_rtems_irq_handler (&consoleIrqData))
537    {
538
539    printk("Unable to connect PSC Irq handler\n");
540    rtems_fatal_error_occurred(1);
541
542    }
543#endif
544
545  /*
546   * Reset rx fifo errors Error/UF/OF
547   */
548  psc->rfstat |= 0x70;
549
550  /*
551   * Reset tx fifo errors Error/UF/OF
552   */
553  psc->tfstat |= 0x70;
554
555#ifdef UARTS_USE_TERMIOS_INT
556  /*
557   * Unmask receive interrupt
558   */
559  psc->isr_imr = channel_info[minor].shadow_imr = IMR_RX_RDY_FULL;
560#endif
561
562  /*
563   * Enable receiver
564   */
565  psc->cr = ((1 << 0) << 8);
566
567  /*
568   * Enable transmitter
569   */
570  psc->cr = ((1 << 2) << 8);
571
572  }
573
574
575int mpc5200_uart_pollRead(int minor)
576  {
577  unsigned char c;
578  struct mpc5200_psc *psc =
579    (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
580
581  if(psc->sr_csr & (1 << 8))
582     c = (psc->rb_tb >> 24);
583      else
584        return -1;
585
586  return c;
587
588  }
589
590
591int mpc5200_uart_pollWrite(int minor, const char *buf, int len)
592  {
593  const char *tmp_buf = buf;
594  struct mpc5200_psc *psc =
595    (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
596
597  while(len--)
598    {
599
600    while(!(psc->sr_csr & (1 << 11)))
601          continue;
602
603        /*rtems_cache_flush_multiple_data_lines( (void *)buf, 1);*/
604
605        psc->rb_tb = (*tmp_buf << 24);
606
607        tmp_buf++;
608
609    }
610
611  return 0;
612
613  }
614
615
616int mpc5200_uart_write(int minor, const char *buf, int len)
617  {
618  int frame_len = len;
619  const char *frame_buf = buf;
620  struct mpc5200_psc *psc =
621    (struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
622
623 /*
624  * Check tx fifo space
625  */
626  if(len > (TX_FIFO_SIZE - psc->tfnum))
627    frame_len = TX_FIFO_SIZE - psc->tfnum;
628
629#ifndef SINGLE_CHAR_MODE
630  channel_info[minor].cur_tx_len = frame_len;
631#else
632  frame_len = 1;
633#endif
634
635 /*rtems_cache_flush_multiple_data_lines( (void *)frame_buf, frame_len);*/
636
637  while(frame_len--)
638    /* perform byte write to avoid extra NUL characters */
639    (* (volatile char *)&(psc->rb_tb)) = *frame_buf++;
640
641 /*
642  * unmask interrupt
643  */
644  psc->isr_imr = channel_info[minor].shadow_imr |= IMR_TX_RDY;
645
646  return 0;
647
648  }
649
650/*
651 *  Print functions prototyped in bspIo.h
652 */
653static void A_BSP_output_char( char c )
654  {
655  char cr = '\r';
656
657
658  if(console_initialized == TRUE)
659    {
660
661#define PRINTK_WRITE mpc5200_uart_pollWrite
662
663    PRINTK_WRITE(PRINTK_MINOR, &c, 1 );
664
665    if( c == '\n' )
666      PRINTK_WRITE( PRINTK_MINOR, &cr, 1 );
667
668    }
669
670  }
671
672/*
673 ***************
674 * BOILERPLATE *
675 ***************
676 *
677 *  All these functions are prototyped in rtems/c/src/lib/include/console.h.
678 */
679
680
681/*
682 * Initialize and register the device
683 */
684rtems_device_driver console_initialize(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
685  {
686
687  rtems_status_code status;
688  rtems_device_minor_number console_minor;
689  char dev_name[] = "/dev/ttyx";
690  uint32_t tty_num = 0;
691
692  /*
693   * Always use and set up TERMIOS
694   */
695  console_minor = PSC1_MINOR;
696  rtems_termios_initialize();
697
698  for (console_minor = PSC1_MINOR;
699      console_minor < PSC1_MINOR + NUM_PORTS;
700      console_minor++) {
701     /*
702      * check, whether UART is available for this board
703      */
704    if (0 != ((1 << console_minor) & (mpc5200_uart_avail_mask))) {
705      /*
706       * Do device-specific initialization and registration for Motorola IceCube
707       */
708      mpc5200_uart_psc_initialize(console_minor); /* /dev/tty0 */
709      dev_name[8] = '0' + tty_num;
710      status = rtems_io_register_name (dev_name, major, console_minor);
711
712      if(status != RTEMS_SUCCESSFUL)
713        {
714            rtems_fatal_error_occurred(status);
715        }
716
717          tty_num++;
718    }
719  }
720
721  /* Now register the RTEMS console */
722  status = rtems_io_register_name ("/dev/console", major, PSC1_MINOR);
723
724  if(status != RTEMS_SUCCESSFUL)
725    rtems_fatal_error_occurred (status);
726
727  console_initialized = TRUE;
728  return RTEMS_SUCCESSFUL;
729
730  }
731
732
733/*
734 * Open the device
735 */
736rtems_device_driver console_open(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
737  {
738#ifdef UARTS_USE_TERMIOS_INT
739  rtems_libio_open_close_args_t *args = arg;
740#endif
741  rtems_status_code sc;
742
743#ifdef UARTS_USE_TERMIOS_INT
744  static const rtems_termios_callbacks intrCallbacks =
745    {
746    NULL,                               /* firstOpen */
747    NULL,                               /* lastClose */
748    NULL,                           /* pollRead */
749    mpc5200_uart_write,             /* write */
750    mpc5200_uart_setAttributes,     /* setAttributes */
751    NULL,
752    NULL,
753    1                                   /* outputUsesInterrupts */
754    };
755#else
756  static const rtems_termios_callbacks pollCallbacks =
757    {
758    NULL,                               /* firstOpen */
759    NULL,                               /* lastClose */
760    mpc5200_uart_pollRead,              /* pollRead */
761    mpc5200_uart_pollWrite,         /* write */
762    mpc5200_uart_setAttributes,     /* setAttributes */
763    NULL,
764    NULL,
765    0                                   /* output don't use Interrupts */
766    };
767#endif
768
769  if(minor > NUM_PORTS - 1)
770    return RTEMS_INVALID_NUMBER;
771
772#ifdef UARTS_USE_TERMIOS_INT
773  sc = rtems_termios_open( major, minor, arg, &intrCallbacks );
774  ttyp[minor] = args->iop->data1;   /* Keep cookie returned by termios_open */
775#else                               /* RTEMS polled I/O with termios */
776  sc = rtems_termios_open( major, minor, arg, &pollCallbacks );
777#endif
778
779  return sc;
780
781  }
782
783
784/*
785 * Close the device
786 */
787rtems_device_driver console_close(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
788  {
789
790  if ( minor > NUM_PORTS-1 )
791    return RTEMS_INVALID_NUMBER;
792
793  ttyp[minor] = NULL; /* mark for int handler: tty no longer open */
794
795  return rtems_termios_close( arg );
796  return 0;
797
798  }
799
800
801/*
802 * Read from the device
803 */
804rtems_device_driver console_read(rtems_device_major_number major, rtems_device_minor_number minor, void *arg)
805  {
806
807  if(minor > NUM_PORTS-1)
808    return RTEMS_INVALID_NUMBER;
809
810  return rtems_termios_read(arg);
811
812  return 0;
813
814  }
815
816
817/*
818 * Write to the device
819 */
820rtems_device_driver console_write(rtems_device_major_number major,rtems_device_minor_number minor,void *arg)
821  {
822
823  if( minor > NUM_PORTS-1 )
824    return RTEMS_INVALID_NUMBER;
825
826  return rtems_termios_write(arg);
827
828  return 0;
829  }
830
831
832/*
833 * Handle ioctl request.
834 */
835rtems_device_driver console_control(rtems_device_major_number major,rtems_device_minor_number minor,void *arg)
836  {
837
838  if ( minor > NUM_PORTS-1 )
839    return RTEMS_INVALID_NUMBER;
840
841  return rtems_termios_ioctl(arg);
842
843  return 0;
844
845  }
Note: See TracBrowser for help on using the repository browser.