source: rtems/c/src/libchip/serial/mc68681.c @ a29909cb

4.115
Last change on this file since a29909cb was a29909cb, checked in by Joel Sherrill <joel.sherrill@…>, on 05/07/12 at 23:26:51

libchip/serial - Only use set_vector() on Simple Vectored Architectures

  • Property mode set to 100644
File size: 19.0 KB
Line 
1/*
2 *  This file contains the termios TTY driver for the Motorola MC68681.
3 *
4 *  This part is available from a number of secondary sources.
5 *  In particular, we know about the following:
6 *
7 *     + Exar 88c681 and 68c681
8 *
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <rtems.h>
20#include <rtems/libio.h>
21#include <stdlib.h>
22
23#include <libchip/serial.h>
24#include <libchip/mc68681.h>
25#include <libchip/sersupp.h>
26#include "mc68681_p.h"
27
28/*
29 * Flow control is only supported when using interrupts
30 */
31
32console_fns mc68681_fns =
33{
34  libchip_serial_default_probe,   /* deviceProbe */
35  mc68681_open,                   /* deviceFirstOpen */
36  NULL,                           /* deviceLastClose */
37  NULL,                           /* deviceRead */
38  mc68681_write_support_int,      /* deviceWrite */
39  mc68681_initialize_interrupts,  /* deviceInitialize */
40  mc68681_write_polled,           /* deviceWritePolled */
41  mc68681_set_attributes,         /* deviceSetAttributes */
42  true                            /* deviceOutputUsesInterrupts */
43};
44
45console_fns mc68681_fns_polled =
46{
47  libchip_serial_default_probe,        /* deviceProbe */
48  mc68681_open,                        /* deviceFirstOpen */
49  mc68681_close,                       /* deviceLastClose */
50  mc68681_inbyte_nonblocking_polled,   /* deviceRead */
51  mc68681_write_support_polled,        /* deviceWrite */
52  mc68681_init,                        /* deviceInitialize */
53  mc68681_write_polled,                /* deviceWritePolled */
54  mc68681_set_attributes,              /* deviceSetAttributes */
55  false,                               /* deviceOutputUsesInterrupts */
56};
57
58
59#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
60  extern void set_vector( rtems_isr_entry, rtems_vector_number, int );
61#endif
62
63/*
64 *  Console Device Driver Entry Points
65 */
66
67/*
68 *  mc68681_baud_rate
69 *
70 *  This routine returns the proper ACR bit and baud rate field values
71 *  based on the requested baud rate.  The baud rate set to be used
72 *  must be configured by the user.
73 */
74
75MC68681_STATIC int mc68681_baud_rate(
76  int           minor,
77  int           baud,
78  unsigned int *baud_mask_p,
79  unsigned int *acr_bit_p,
80  unsigned int *command
81);
82
83/*
84 *  mc68681_set_attributes
85 *
86 *  This function sets the DUART channel to reflect the requested termios
87 *  port settings.
88 */
89
90MC68681_STATIC int mc68681_set_attributes(
91  int minor,
92  const struct termios *t
93)
94{
95  uint32_t               pMC68681_port;
96  uint32_t               pMC68681;
97  unsigned int           mode1;
98  unsigned int           mode2;
99  unsigned int           baud_mask;
100  unsigned int           acr_bit;
101  unsigned int           cmd = 0;
102  setRegister_f          setReg;
103  rtems_interrupt_level  Irql;
104
105  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
106  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
107  setReg        = Console_Port_Tbl[minor]->setRegister;
108
109  /*
110   *  Set the baud rate
111   */
112
113  if (mc68681_baud_rate( minor, t->c_cflag, &baud_mask, &acr_bit, &cmd ) == -1)
114    return -1;
115
116  baud_mask |=  baud_mask << 4;
117  acr_bit   <<= 7;
118
119  /*
120   *  Parity
121   */
122
123  mode1 = 0;
124  mode2 = 0;
125
126  if (t->c_cflag & PARENB) {
127    if (t->c_cflag & PARODD)
128      mode1 |= 0x04;
129    /* else
130                mode1 |= 0x04; */
131  } else {
132   mode1 |= 0x10;
133  }
134
135  /*
136   *  Character Size
137   */
138
139  if (t->c_cflag & CSIZE) {
140    switch (t->c_cflag & CSIZE) {
141      case CS5:  break;
142      case CS6:  mode1 |= 0x01;  break;
143      case CS7:  mode1 |= 0x02;  break;
144      case CS8:  mode1 |= 0x03;  break;
145    }
146  } else {
147    mode1 |= 0x03;       /* default to 9600,8,N,1 */
148  }
149
150  /*
151   *  Stop Bits
152   */
153
154  if (t->c_cflag & CSTOPB) {
155    mode2 |= 0x0F;                      /* 2 stop bits */
156  } else {
157    if ((t->c_cflag & CSIZE) == CS5)    /* CS5 and 1 stop bits not supported */
158      return -1;
159    mode2 |= 0x07;                      /* 1 stop bit */
160  }
161
162 /*
163  *   Hardware Flow Control
164  */
165
166  if(t->c_cflag & CRTSCTS) {
167          mode1 |= 0x80; /* Enable Rx RTS Control */
168          mode2 |= 0x10; /* Enable CTS Enable Tx */
169  }
170
171
172  rtems_interrupt_disable(Irql);
173    (*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit );
174    (*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud_mask );
175    if ( cmd ) {
176      (*setReg)( pMC68681_port, MC68681_COMMAND, cmd );         /* RX */
177      (*setReg)( pMC68681_port, MC68681_COMMAND, cmd | 0x20 );  /* TX */
178    }
179    (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR );
180    (*setReg)( pMC68681_port, MC68681_MODE, mode1 );
181    (*setReg)( pMC68681_port, MC68681_MODE, mode2 );
182  rtems_interrupt_enable(Irql);
183  return 0;
184}
185
186/*
187 *  mc68681_initialize_context
188 *
189 *  This function sets the default values of the per port context structure.
190 */
191
192MC68681_STATIC void mc68681_initialize_context(
193  int               minor,
194  mc68681_context  *pmc68681Context
195)
196{
197  int          port;
198  unsigned int pMC68681;
199  unsigned int pMC68681_port;
200
201  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
202  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
203
204  pmc68681Context->mate = -1;
205
206  for (port=0 ; port<Console_Port_Count ; port++ ) {
207    if ( Console_Port_Tbl[port]->ulCtrlPort1 == pMC68681 &&
208         Console_Port_Tbl[port]->ulCtrlPort2 != pMC68681_port ) {
209      pmc68681Context->mate = port;
210      pmc68681Context->imr  = 0;
211      break;
212    }
213  }
214
215}
216
217/*
218 *  mc68681_init
219 *
220 *  This function initializes the DUART to a quiecsent state.
221 */
222
223MC68681_STATIC void mc68681_init(int minor)
224{
225  uint32_t                pMC68681_port;
226  uint32_t                pMC68681;
227  mc68681_context        *pmc68681Context;
228  setRegister_f           setReg;
229
230  pmc68681Context = (mc68681_context *) malloc(sizeof(mc68681_context));
231
232  Console_Port_Data[minor].pDeviceContext = (void *)pmc68681Context;
233
234  mc68681_initialize_context( minor, pmc68681Context );
235
236  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
237  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
238  setReg        = Console_Port_Tbl[minor]->setRegister;
239
240  /*
241   *  Reset everything and leave this port disabled.
242   */
243
244  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_RX );
245  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_TX );
246  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
247  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_BREAK );
248  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_STOP_BREAK );
249  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
250  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
251
252
253  (*setReg)( pMC68681_port, MC68681_MODE_REG_1A, 0x00 );
254  (*setReg)( pMC68681_port, MC68681_MODE_REG_2A, 0x02 );
255
256  /*
257   *  Disable interrupts on RX and TX for this port
258   */
259
260  mc68681_enable_interrupts( minor, MC68681_IMR_DISABLE_ALL );
261}
262
263/*
264 *  mc68681_open
265 *
266 *  This function opens a port for communication.
267 *
268 *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
269 */
270
271MC68681_STATIC int mc68681_open(
272  int      major,
273  int      minor,
274  void    *arg
275)
276{
277  uint32_t               pMC68681;
278  uint32_t               pMC68681_port;
279  unsigned int           baud;
280  unsigned int           acr_bit;
281  unsigned int           vector;
282  unsigned int           command = 0;
283  rtems_interrupt_level  Irql;
284  setRegister_f          setReg;
285  int                    status;
286
287
288  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
289  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
290  setReg        = Console_Port_Tbl[minor]->setRegister;
291  vector        = Console_Port_Tbl[minor]->ulIntVector;
292
293  /* XXX default baud rate should be from configuration table */
294
295  status = mc68681_baud_rate( minor, B9600, &baud, &acr_bit, &command );
296  if (status < 0) rtems_fatal_error_occurred (RTEMS_NOT_DEFINED);
297
298  /*
299   *  Set the DUART channel to a default useable state
300   */
301
302  rtems_interrupt_disable(Irql);
303    (*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit << 7 );
304    (*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud );
305    if ( command ) {
306      (*setReg)( pMC68681_port, MC68681_COMMAND, command );         /* RX */
307      (*setReg)( pMC68681_port, MC68681_COMMAND, command | 0x20 );  /* TX */
308    }
309    (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR );
310    (*setReg)( pMC68681_port, MC68681_MODE, 0x13 );
311    (*setReg)( pMC68681_port, MC68681_MODE, 0x07 );
312  rtems_interrupt_enable(Irql);
313
314  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_TX );
315  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_RX );
316
317  (*setReg)( pMC68681, MC68681_INTERRUPT_VECTOR_REG, vector );
318
319  return RTEMS_SUCCESSFUL;
320}
321
322/*
323 *  mc68681_close
324 *
325 *  This function shuts down the requested port.
326 */
327
328MC68681_STATIC int mc68681_close(
329  int      major,
330  int      minor,
331  void    *arg
332)
333{
334  uint32_t        pMC68681;
335  uint32_t        pMC68681_port;
336  setRegister_f   setReg;
337
338  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
339  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
340  setReg        = Console_Port_Tbl[minor]->setRegister;
341
342  /*
343   *  Disable interrupts from this channel and then disable it totally.
344   */
345  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
346  (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
347
348  return(RTEMS_SUCCESSFUL);
349}
350
351/*
352 *  mc68681_write_polled
353 *
354 *  This routine polls out the requested character.
355 */
356
357MC68681_STATIC void mc68681_write_polled(
358  int   minor,
359  char  cChar
360)
361{
362  uint32_t                pMC68681_port;
363  unsigned char           ucLineStatus;
364  int                     iTimeout;
365  getRegister_f           getReg;
366  setRegister_f           setReg;
367
368  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
369  getReg        = Console_Port_Tbl[minor]->getRegister;
370  setReg        = Console_Port_Tbl[minor]->setRegister;
371
372  /*
373   * wait for transmitter holding register to be empty
374   */
375  iTimeout = 1000;
376  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
377  while ((ucLineStatus & (MC68681_TX_READY|MC68681_TX_EMPTY)) == 0) {
378
379    if ((ucLineStatus & 0xF0))
380      (*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
381
382    /*
383     * Yield while we wait
384     */
385
386#if 0
387     if(_System_state_Is_up(_System_state_Get())) {
388       rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
389     }
390#endif
391     ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
392     if(!--iTimeout) {
393       break;
394     }
395  }
396
397  /*
398   * transmit character
399   */
400
401  (*setReg)(pMC68681_port, MC68681_TX_BUFFER, cChar);
402}
403
404/*
405 *  mc68681_isr
406 *
407 *  This is the single interrupt entry point which parcels interrupts
408 *  out to the various ports.
409 */
410
411MC68681_STATIC rtems_isr mc68681_isr(
412  rtems_vector_number vector
413)
414{
415  int     minor;
416
417  for(minor=0 ; minor<Console_Port_Count ; minor++) {
418    if(Console_Port_Tbl[minor]->ulIntVector == vector &&
419       Console_Port_Tbl[minor]->deviceType == SERIAL_MC68681 ) {
420      mc68681_process(minor);
421    }
422  }
423}
424
425/*
426 *  mc68681_initialize_interrupts
427 *
428 *  This routine initializes the console's receive and transmit
429 *  ring buffers and loads the appropriate vectors to handle the interrupts.
430 */
431
432MC68681_STATIC void mc68681_initialize_interrupts(int minor)
433{
434  mc68681_init(minor);
435
436  Console_Port_Data[minor].bActive = FALSE;
437
438#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
439  set_vector(mc68681_isr, Console_Port_Tbl[minor]->ulIntVector, 1);
440#endif
441
442  mc68681_enable_interrupts(minor,MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
443}
444
445/*
446 *  mc68681_write_support_int
447 *
448 *  Console Termios output entry point when using interrupt driven output.
449 */
450
451MC68681_STATIC ssize_t mc68681_write_support_int(
452  int         minor,
453  const char *buf,
454  size_t      len
455)
456{
457  uint32_t        Irql;
458  uint32_t        pMC68681_port;
459  setRegister_f   setReg;
460
461  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
462  setReg        = Console_Port_Tbl[minor]->setRegister;
463
464  /*
465   *  We are using interrupt driven output and termios only sends us
466   *  one character at a time.
467   */
468
469  if ( !len )
470    return 0;
471
472  /*
473   *  Put the character out and enable interrupts if necessary.
474   */
475
476  rtems_interrupt_disable(Irql);
477    if ( Console_Port_Data[minor].bActive == FALSE ) {
478      Console_Port_Data[minor].bActive = TRUE;
479      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL);
480    }
481    (*setReg)(pMC68681_port, MC68681_TX_BUFFER, *buf);
482  rtems_interrupt_enable(Irql);
483
484  return 0;
485}
486
487/*
488 *  mc68681_write_support_polled
489 *
490 *  Console Termios output entry point when using polled output.
491 *
492 */
493
494MC68681_STATIC ssize_t mc68681_write_support_polled(
495  int         minor,
496  const char *buf,
497  size_t      len
498)
499{
500  int nwrite = 0;
501
502  /*
503   * poll each byte in the string out of the port.
504   */
505  while (nwrite < len) {
506    /*
507     * transmit character
508     */
509    mc68681_write_polled(minor, *buf++);
510    nwrite++;
511  }
512
513  /*
514   * return the number of bytes written.
515   */
516  return nwrite;
517}
518
519/*
520 *  mc68681_inbyte_nonblocking_polled
521 *
522 *  Console Termios polling input entry point.
523 */
524
525MC68681_STATIC int mc68681_inbyte_nonblocking_polled(
526  int minor
527)
528{
529  uint32_t             pMC68681_port;
530  unsigned char        ucLineStatus;
531  unsigned char        cChar;
532  getRegister_f        getReg;
533
534  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
535  getReg        = Console_Port_Tbl[minor]->getRegister;
536
537  ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
538  if(ucLineStatus & MC68681_RX_READY) {
539    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
540    return (int)cChar;
541  } else {
542    return -1;
543  }
544}
545
546/*
547 *  mc68681_baud_rate
548 */
549
550MC68681_STATIC int mc68681_baud_rate(
551  int           minor,
552  int           baud,
553  unsigned int *baud_mask_p,
554  unsigned int *acr_bit_p,
555  unsigned int *command
556)
557{
558  unsigned int           baud_mask;
559  unsigned int           acr_bit;
560  int                    status;
561  int                    is_extended;
562  int                    baud_requested;
563  mc68681_baud_table_t  *baud_tbl;
564
565  baud_mask = 0;
566  acr_bit = 0;
567  status = 0;
568
569  if (Console_Port_Tbl[minor]->ulDataPort & MC68681_DATA_BAUD_RATE_SET_2)
570  {
571    acr_bit = 1;
572  }
573
574  is_extended = 0;
575
576  switch (Console_Port_Tbl[minor]->ulDataPort & MC68681_XBRG_MASK) {
577    case MC68681_XBRG_IGNORED:
578      *command = 0x00;
579      break;
580    case MC68681_XBRG_ENABLED:
581      *command = 0x80;
582      is_extended = 1;
583      break;
584    case MC68681_XBRG_DISABLED:
585      *command = 0x90;
586      break;
587  }
588
589  baud_requested = baud & CBAUD;
590  if (!baud_requested)
591    baud_requested = B9600;              /* default to 9600 baud */
592
593  baud_requested = rtems_termios_baud_to_index( baud_requested );
594
595  baud_tbl = (mc68681_baud_table_t *)
596     ((uintptr_t)Console_Port_Tbl[minor]->ulClock);
597  if (!baud_tbl)
598    rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS);
599
600  if ( is_extended )
601    baud_mask = (unsigned int)baud_tbl[ acr_bit + 2 ][ baud_requested ];
602  else
603    baud_mask = baud_tbl[ acr_bit ][ baud_requested ];
604
605  if ( baud_mask == MC68681_BAUD_NOT_VALID )
606    status = -1;
607
608  /*
609   *  upper nibble is receiver and lower nibble is transmitter
610   */
611
612  *baud_mask_p = (baud_mask << 4) | baud_mask;
613  *acr_bit_p   = acr_bit;
614  return status;
615}
616
617/*
618 *  mc68681_process
619 *
620 *  This routine is the per port console interrupt handler.
621 */
622
623MC68681_STATIC void mc68681_process(
624  int  minor
625)
626{
627  uint32_t                pMC68681;
628  uint32_t                pMC68681_port;
629  volatile uint8_t        ucLineStatus;
630  volatile uint8_t        ucISRStatus;
631  char                    cChar;
632  getRegister_f           getReg;
633  setRegister_f           setReg;
634
635  pMC68681      = Console_Port_Tbl[minor]->ulCtrlPort1;
636  pMC68681_port = Console_Port_Tbl[minor]->ulCtrlPort2;
637  getReg        = Console_Port_Tbl[minor]->getRegister;
638  setReg        = Console_Port_Tbl[minor]->setRegister;
639
640  /* Get ISR at the beginning of the IT routine */
641  ucISRStatus = (*getReg)(pMC68681, MC68681_INTERRUPT_STATUS_REG);
642
643  /* Get good ISR a or b channel */
644  if (pMC68681 != pMC68681_port){
645    ucISRStatus >>= 4;
646  }
647
648  /* See if is usefull to call rtems_termios_dequeue */
649  if(Console_Port_Data[minor].bActive == FALSE) {
650                ucISRStatus = ucISRStatus & ~MC68681_IR_TX_READY;
651  }
652
653  /*
654   * Deal with any received characters
655   */
656  while(true) {
657    ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
658    if(!(ucLineStatus & MC68681_RX_READY)) {
659      break;
660    }
661    /*
662     *  If there is a RX error, then dump all the data.
663     */
664    if ( ucLineStatus & MC68681_RX_ERRORS ) {
665      do {
666        cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
667        ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
668      } while ( ucLineStatus & MC68681_RX_READY );
669      continue;
670    }
671    cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
672    rtems_termios_enqueue_raw_characters(
673      Console_Port_Data[minor].termios_data,
674      &cChar,
675      1
676    );
677  }
678
679  /*
680   *  Deal with the transmitter
681   */
682
683  if (ucISRStatus & MC68681_IR_TX_READY) {
684    if (!rtems_termios_dequeue_characters(
685          Console_Port_Data[minor].termios_data, 1)) {
686          /* If no more char to send, disable TX interrupt */
687      Console_Port_Data[minor].bActive = FALSE;
688      mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
689    }
690  }
691}
692
693/*
694 *  mc68681_build_imr
695 *
696 *  This function returns the value for the interrupt mask register for this
697 *  DUART.  Since this is a shared register, we must look at the other port
698 *  on this chip to determine whether or not it is using interrupts.
699 */
700
701MC68681_STATIC unsigned int mc68681_build_imr(
702  int  minor,
703  int  enable_flag
704)
705{
706  int              mate;
707  int              is_a;
708  unsigned int     mask;
709  unsigned int     mate_mask;
710  unsigned int     pMC68681;
711  unsigned int     pMC68681_port;
712  mc68681_context *pmc68681Context;
713  mc68681_context *mateContext;
714
715  pMC68681        = Console_Port_Tbl[minor]->ulCtrlPort1;
716  pMC68681_port   = Console_Port_Tbl[minor]->ulCtrlPort2;
717  pmc68681Context = (mc68681_context *) Console_Port_Data[minor].pDeviceContext;
718  mate            = pmc68681Context->mate;
719
720  mask = 0;
721  mate_mask = 0;
722
723  is_a = (pMC68681 == pMC68681_port);
724
725  /*
726   *  If there is a mate for this port, get its IMR mask.
727   */
728
729  if ( mate != -1 ) {
730    mateContext = Console_Port_Data[mate].pDeviceContext;
731
732    if (mateContext)
733      mate_mask = mateContext->imr;
734  }
735
736  /*
737   *  Calculate this port's IMR mask and save it in the context area.
738   */
739
740  if ( Console_Port_Tbl[minor]->pDeviceFns->deviceOutputUsesInterrupts )
741    mask = enable_flag;
742
743  pmc68681Context->imr = mask;
744
745  /*
746   *  Now return the full IMR value
747   */
748
749  if (is_a)
750    return (mate_mask << 4) | mask;
751
752  return (mask << 4) | mate_mask;
753}
754
755/*
756 *  mc68681_enable_interrupts
757 *
758 *  This function enables specific interrupt sources on the DUART.
759 */
760
761MC68681_STATIC void mc68681_enable_interrupts(
762  int minor,
763  int imr_mask
764)
765{
766  uint32_t              pMC68681;
767  setRegister_f         setReg;
768
769  pMC68681 = Console_Port_Tbl[minor]->ulCtrlPort1;
770  setReg   = Console_Port_Tbl[minor]->setRegister;
771
772  /*
773   *  Enable interrupts on RX and TX -- not break
774   */
775
776  (*setReg)(
777     pMC68681,
778     MC68681_INTERRUPT_MASK_REG,
779     mc68681_build_imr(minor, imr_mask)
780  );
781}
Note: See TracBrowser for help on using the repository browser.