source: rtems/c/src/libchip/serial/mc68681.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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