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

4.104.114.84.95
Last change on this file since ca680bc5 was ca680bc5, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/31/05 at 05:09:26

New (CVS import Thomas Doerfler <Thomas.Doerfler@…>'s
submission).

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