Example #1
0
File: uart.c Project: Dipupo/rtems
static void irq_handler(void *arg)
{
  int minor = (int)arg;
  console_data *cd = &Console_Port_Data [minor];
  volatile lm3s69xx_uart *uart = get_uart_regs(minor);

  do {
    char buf[LM3S69XX_UART_FIFO_DEPTH];
    int i = 0;
    uint32_t status = uart->fr;

    while (((status & UARTFR_RXFE) == 0) && (i < LM3S69XX_UART_FIFO_DEPTH)) {
      uint32_t d = uart->dr;

      if ((d & UARTDR_ERROR_MSK) == 0) {
        buf[i] = UARTDR_DATA_GET(d);
        i++;
      }

      status = uart->fr;
    }

    if (i > 0)
      rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
  } while (uart->mis != 0);
}
Example #2
0
void
BSP_uart_termios_isr_com2()
{
  unsigned char buf[40];
  int      off, ret, vect;

  off = 0;

  for(;;)
    {
      vect = uread(BSP_UART_COM2, IIR) & 0xf;

      switch(vect)
	{
	case NO_MORE_INTR :
	  /* No more interrupts */
	  if(off != 0)
	    {
	      /* Update rx buffer */
	      rtems_termios_enqueue_raw_characters(termios_ttyp_com2,
						   (char *)buf,
						   off);
	    }
	  return;
	case TRANSMITTER_HODING_REGISTER_EMPTY :
	  /*
	   * TX holding empty: we have to disable these interrupts
	   * if there is nothing more to send.
	   */

	  ret = rtems_termios_dequeue_characters(termios_ttyp_com2, 1);

	  /* If nothing else to send disable interrupts */
	  if(ret == 0)
	    {
	      uwrite(BSP_UART_COM2, IER,
		     (RECEIVE_ENABLE  |
		      RECEIVER_LINE_ST_ENABLE
		     )
		    );
              termios_tx_active_com2 = 0;
	    }
	  break;
	case RECEIVER_DATA_AVAIL :
	case CHARACTER_TIMEOUT_INDICATION:
	  /* RX data ready */
	  assert(off < sizeof(buf));
	  buf[off++] = uread(BSP_UART_COM2, RBR);
	  break;
	case RECEIVER_ERROR:
	  /* RX error: eat character */
	   uartError(BSP_UART_COM2);
	  break;
	default:
	  /* Should not happen */
	  assert(0);
	  return;
	}
    }
}
Example #3
0
/*
 * Interrupt handling.
 */
static void
m5xx_sci_interrupt_handler (rtems_irq_hdl_param unused)
{
  int minor;

  for ( minor = 0; minor < NUM_PORTS; minor++ ) {
    sci_desc *desc = &sci_descs[minor];
    int sccr1 = desc->regs->sccr1;
    int scsr = desc->regs->scsr;

    /*
     * Character received?
     */
    if ((sccr1 & QSMCM_SCI_RIE) && (scsr & QSMCM_SCI_RDRF)) {
      char c = desc->regs->scdr;
      rtems_termios_enqueue_raw_characters(desc->ttyp, &c, 1);
    }
    /*
     * Transmitter empty?
     */
    if ((sccr1 & QSMCM_SCI_TIE) && (scsr & QSMCM_SCI_TDRE)) {
      desc->regs->sccr1 &= ~QSMCM_SCI_TIE;
      rtems_termios_dequeue_characters (desc->ttyp, 1);
    }
  }
}
Example #4
0
/**
 * @brief sci interrupt handler
 *
 * Handler checks which interrupt occured and provides nessesary maintenance
 * dequeue characters in termios driver whether character is send succesfully
 * enqueue characters in termios driver whether character is recieved
 *
 * @param[in] arg rtems_termios_tty
 * @retval Void
 */
static void tms570_sci_interrupt_handler(void * arg)
{
  rtems_termios_tty *tty = arg;
  tms570_sci_context *ctx = rtems_termios_get_device_context(tty);
  char buf[TMS570_SCI_BUFFER_SIZE];
  size_t n;

  /*
   * Check if we have received something.
   */
   if ( (ctx->regs->FLR & TMS570_SCI_FLR_RXRDY ) == TMS570_SCI_FLR_RXRDY ) {
      n = tms570_sci_read_received_chars(ctx, buf, TMS570_SCI_BUFFER_SIZE);
      if ( n > 0 ) {
        /* Hand the data over to the Termios infrastructure */
        rtems_termios_enqueue_raw_characters(tty, buf, n);
      }
    }
  /*
   * Check if we have something transmitted.
   */
  if ( (ctx->regs->FLR & TMS570_SCI_FLR_TXRDY ) == TMS570_SCI_FLR_TXRDY ) {
    n = tms570_sci_transmitted_chars(ctx);
    if ( n > 0 ) {
      /*
       * Notify Termios that we have transmitted some characters.  It
       * will call now the interrupt write function if more characters
       * are ready for transmission.
       */
      rtems_termios_dequeue_characters(tty, n);
    }
  }
}
Example #5
0
/*
 * this task actually processes any receive events
 */
static rtems_task rtems_termios_rxdaemon(rtems_task_argument argument)
{
	struct rtems_termios_tty *tty = (struct rtems_termios_tty *)argument;
	rtems_event_set the_event;
	int c;
	char c_buf;
	while (1) {
		/*
		 * wait for rtems event
		 */
		rtems_event_receive((TERMIOS_RX_PROC_EVENT |
				     TERMIOS_RX_TERMINATE_EVENT),
				    RTEMS_EVENT_ANY | RTEMS_WAIT,
				    RTEMS_NO_TIMEOUT,
				    &the_event);
		if ((the_event & TERMIOS_RX_TERMINATE_EVENT) != 0) {
			tty->rxTaskId = 0;
			rtems_task_delete(RTEMS_SELF);
		}
		else {
			/*
			 * do something
			 */
			c = tty->device.pollRead(tty->minor);
			if (c != EOF) {
				/*
				 * pollRead did call enqueue on its own
				 */
				c_buf = c;
				rtems_termios_enqueue_raw_characters (
				      tty,&c_buf,1);
			}
		}
	}
}
Example #6
0
rtems_isr console_isr_a(
  rtems_vector_number vector
)
{
  char ch;
  int UStat;

  if ( (UStat = LEON_REG.UART_Status_1) & LEON_REG_UART_STATUS_DR ) {
    if (UStat & LEON_REG_UART_STATUS_ERR) {
      LEON_REG.UART_Status_1 = LEON_REG_UART_STATUS_CLR;
    }
    ch = LEON_REG.UART_Channel_1;

    rtems_termios_enqueue_raw_characters( console_termios_data[ 0 ], &ch, 1 );
  }

  if ( LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE ) {
    if ( !Ring_buffer_Is_empty( &TX_Buffer[ 0 ] ) ) {
      Ring_buffer_Remove_character( &TX_Buffer[ 0 ], ch );
      LEON_REG.UART_Channel_1 = (uint32_t) ch;
    } else
     Is_TX_active[ 0 ] = false;
  }

  LEON_Clear_interrupt( LEON_INTERRUPT_UART_1_RX_TX );
}
Example #7
0
static inline void handle_mouse_event(unsigned char scancode)
{
  if (mouse_reply_expected) {
    if (scancode == AUX_ACK) {
      mouse_reply_expected--;
      return;
    }
    mouse_reply_expected = 0;
  }

  if (aux_count) {
    int head = queue->head;
    queue->buf[head] = scancode;
    head = (head + 1) & (AUX_BUF_SIZE-1);
    if (head != queue->tail) {
      queue->head = head;
    }

    /* if the input queue is active, add to it */
    if( driver_input_handler_ps2 ) {
      driver_input_handler_ps2( &scancode, 1 );
    } else {
      /* post this byte to termios */
      rtems_termios_enqueue_raw_characters( termios_ttyp_paux, (char *)&scancode, 1 );
    }
  }
}
Example #8
0
/*
 * Interrupt handler
 */
static rtems_isr
smc1InterruptHandler (rtems_vector_number v)
{
  /*
   * Buffer received?
   */
  if (m360.smc1.smce & 0x1) {
    m360.smc1.smce = 0x1;
    while ((smcRxBd->status & M360_BD_EMPTY) == 0) {
      rtems_termios_enqueue_raw_characters (smc1ttyp,
              (char *)smcRxBd->buffer,
              smcRxBd->length);
      smcRxBd->status = M360_BD_EMPTY | M360_BD_WRAP | M360_BD_INTERRUPT;
    }
  }

  /*
   * Buffer transmitted?
   */
  if (m360.smc1.smce & 0x2) {
    m360.smc1.smce = 0x2;
    if ((smcTxBd->status & M360_BD_READY) == 0)
      rtems_termios_dequeue_characters (smc1ttyp, smcTxBd->length);
  }
  m360.cisr = 1UL << 4;  /* Clear SMC1 interrupt-in-service bit */
}
Example #9
0
/* Handle UART interrupts */
static void apbuart_cons_isr(void *arg)
{
	rtems_termios_tty *tty = arg;
	rtems_termios_device_context *base;
	struct console_dev *condev = rtems_termios_get_device_context(tty);
	struct apbuart_priv *uart = condev_get_priv(condev);
	struct apbuart_regs *regs = uart->regs;
	unsigned int status;
	char buf[33];
	int cnt;

	if (uart->mode == TERMIOS_TASK_DRIVEN) {
		if ((status = regs->status) & APBUART_STATUS_DR) {
			rtems_interrupt_lock_context lock_context;

			/* Turn off RX interrupts */
			base = rtems_termios_get_device_context(tty);
			rtems_termios_device_lock_acquire(base, &lock_context);
			regs->ctrl &=
			    ~(APBUART_CTRL_DI | APBUART_CTRL_RI |
			      APBUART_CTRL_RF);
			rtems_termios_device_lock_release(base, &lock_context);
			/* Activate termios RX daemon task */
			rtems_termios_rxirq_occured(tty);
		}
	} else {
		/*
		 * Get all new characters from APBUART RX (FIFO) and store them
		 * on the stack. Then tell termios about the new characters.
		 * Maximum APBUART RX FIFO size is 32 characters.
		 */
		cnt = 0;
		while (
			((status=regs->status) & APBUART_STATUS_DR) &&
			(cnt < sizeof(buf))
		) {
			buf[cnt] = regs->data;
			cnt++;
		}
		if (0 < cnt) {
			/* Tell termios layer about new characters */
			rtems_termios_enqueue_raw_characters(tty, &buf[0], cnt);
		}
	}

	if (uart->sending && (status & APBUART_STATUS_TE)) {
		/* Tell close that we sent everything */
		cnt = uart->sending;

		/*
		 * Tell termios how much we have sent. dequeue() may call
		 * write_interrupt() to refill the transmitter.
		 * write_interrupt() will eventually be called with 0 len to
		 * disable TX interrupts.
		 */
		rtems_termios_dequeue_characters(tty, cnt);
	}
}
Example #10
0
static void imx_uart_rx_isr(rtems_irq_hdl_param param)
{
    imx_uart_data_t *uart_data = param;
    char buf[32];
    int i=0;

    while (uart_data->regs->sr2 & MC9328MXL_UART_SR2_RDR) {
        buf[i] = uart_data->regs->rxd & 0xff;
        i++;
    }

    rtems_termios_enqueue_raw_characters(uart_data->tty, buf, i);
}
Example #11
0
static rtems_isr mmconsole_interrupt(rtems_vector_number n)
{
  char c;
  while (MM_READ(MM_UART_STAT) & UART_STAT_RX_EVT) {
    c = MM_READ(MM_UART_RXTX);
    MM_WRITE(MM_UART_STAT, UART_STAT_RX_EVT);
    rtems_termios_enqueue_raw_characters(tty, &c, 1);
  }
  if (MM_READ(MM_UART_STAT) & UART_STAT_TX_EVT) {
    MM_WRITE(MM_UART_STAT, UART_STAT_TX_EVT);
    rtems_termios_dequeue_characters(tty, 1);
  }
  lm32_interrupt_ack(1 << MM_IRQ_UART);
}
Example #12
0
/**
 * @brief Process interrupt.
 */
NS16550_STATIC void ns16550_process( int minor)
{
  console_tbl *c = Console_Port_Tbl [minor];
  console_data *d = &Console_Port_Data [minor];
  NS16550Context *ctx = d->pDeviceContext;
  uint32_t port = c->ulCtrlPort1;
  getRegister_f get = c->getRegister;
  int i;
  char buf [SP_FIFO_SIZE];

  /* Iterate until no more interrupts are pending */
  do {
    /* Fetch received characters */
    i = 0;
    while ((get(port, NS16550_LINE_STATUS) & SP_LSR_RDY) != 0) {
      buf[i++] = (char) get(port, NS16550_RECEIVE_BUFFER);
      if (i == SP_FIFO_SIZE) {
        /* Enqueue fetched characters */
        rtems_termios_enqueue_raw_characters( d->termios_data, buf, i);
        i = 0;
      }
    }

    if (i > 0)
      rtems_termios_enqueue_raw_characters( d->termios_data, buf, i);

    /* Check if we can dequeue transmitted characters */
    if (ctx->transmitFifoChars > 0
        && (get( port, NS16550_LINE_STATUS) & SP_LSR_THOLD) != 0) {
      /* Dequeue transmitted characters */
      rtems_termios_dequeue_characters(
        d->termios_data,
        ctx->transmitFifoChars
      );
    }
  } while ((get( port, NS16550_INTERRUPT_ID) & SP_IID_0) == 0);
}
Example #13
0
/* sh4uart2_interrupt_receive --
 *     UART interrupt handler routine -- SCIF
 *     Receiving data
 *
 * PARAMETERS:
 *     vec - interrupt vector number
 *
 * RETURNS:
 *     none
 */
static rtems_isr
sh4uart2_interrupt_receive(rtems_vector_number vec)
{
  register int bp = 0;
  char buf[32];
  volatile uint16_t *ssr2 = (volatile uint16_t *)SH7750_SCSSR2;


  /* Find UART descriptor from vector number */
  sh4uart *uart = &sh4_uarts[1];

  while (1) {
    if ((bp < sizeof(buf) - 1) && ((SCSSR2 & SH7750_SCSSR2_RDF) != 0)) {
      if ((SCSSR2 & (SH7750_SCSSR2_ER | SH7750_SCSSR2_DR |
                      SH7750_SCSSR2_BRK)) != 0 ||
              (SH7750_SCLSR2 & SH7750_SCLSR2_ORER) != 0) {
        if (SCSSR2 & SH7750_SCSSR2_ER) {
          if (!(uart->c_iflag & IGNPAR)) {
            if (uart->c_iflag & PARMRK) {
              buf[bp++] = 0xff;
              buf[bp++] = 0x00;
            } else
              buf[bp++] = 0x00;
          } else
              buf[bp++] = SCRDR1;
        }

        if (SCSSR2 & SH7750_SCSSR2_BRK) {
          if (uart->c_iflag & IGNBRK)
            buf[bp++] = 0x00;
          else
            buf[bp++] = 0x00;   /* XXX -- SIGINT */
        }

        sh4uart_handle_error(uart);
      } else
        buf[bp++] = SCRDR1;
      *ssr2 &= ~SH7750_SCSSR2_RDF;
    } else {
      if (bp != 0)
        rtems_termios_enqueue_raw_characters(uart->tty, buf, bp);
      break;
    }
  }
}
Example #14
0
rtems_timer_service_routine Rx_ISR(
  rtems_id  ignored_id,
  void     *ignored_address
)
{
  uint8_t ch;

  if ( Rx_Index >= Rx_Length )
    return;

  ch = Rx_Buffer[ Rx_Index++ ];
  rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1);
  #if defined(TASK_DRIVEN)
    rtems_termios_rxirq_occured(Ttyp);
  #endif

  (void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL );
}
Example #15
0
/**
 * @brief Process interrupt.
 */
NS16550_STATIC void ns16550_process( int minor)
{
  console_tbl *c = Console_Port_Tbl [minor];
  console_data *d = &Console_Port_Data [minor];
  ns16550_context *ctx = d->pDeviceContext;
  uint32_t port = c->ulCtrlPort1;
  getRegister_f get = c->getRegister;
  int i = 0;
  char buf [SP_FIFO_SIZE];

  /* Iterate until no more interrupts are pending */
  do {
    /* Fetch received characters */
    for (i = 0; i < SP_FIFO_SIZE; ++i) {
      if ((get( port, NS16550_LINE_STATUS) & SP_LSR_RDY) != 0) {
        buf [i] = (char) get(port, NS16550_RECEIVE_BUFFER);
      } else {
        break;
      }
    }

    /* Enqueue fetched characters */
    rtems_termios_enqueue_raw_characters( d->termios_data, buf, i);

    /* Check if we can dequeue transmitted characters */
    if (ctx->transmitFifoChars > 0
        && (get( port, NS16550_LINE_STATUS) & SP_LSR_THOLD) != 0) {
      unsigned chars = ctx->transmitFifoChars;

      /*
       * We finished the transmission, so clear the number of characters in the
       * transmit FIFO.
       */
      ctx->transmitFifoChars = 0;

      /* Dequeue transmitted characters */
      if (rtems_termios_dequeue_characters( d->termios_data, chars) == 0) {
        /* Nothing to do */
        d->bActive = false;
        ns16550_enable_interrupts( c, NS16550_ENABLE_ALL_INTR_EXCEPT_TX);
      }
    }
  } while ((get( port, NS16550_INTERRUPT_ID) & SP_IID_0) == 0);
}
/***************************************************************************
   Function : IntUartTaskRead

   Description : This reads all available characters from the internal uart
   and places them into the termios buffer.  The rx interrupts will be
   re-enabled after all data has been read.
 ***************************************************************************/
static int
IntUartTaskRead(int minor)
{
	char                        buffer[RX_BUFFER_SIZE];
	int                         count;
	int                         rx_in;
	int                         index = 0;
	struct IntUartInfoStruct   *info  = &IntUartInfo[minor];

	/* determine number of values to copy out */
	rx_in = info->rx_in;
	if ( info->rx_out <= rx_in )
	{
		count = rx_in - info->rx_out;
	}
	else
	{
		count = (RX_BUFFER_SIZE - info->rx_out) + rx_in;
	}

	/* copy data into local buffer from rx buffer */
	while ( ( index < count ) && ( index < RX_BUFFER_SIZE ) )
	{
		/* copy data byte */ 
		buffer[index] = info->rx_buffer[info->rx_out];
		index++;

		/* increment rx buffer values */
		info->rx_out++;
		if ( info->rx_out >= RX_BUFFER_SIZE )
		{
			info->rx_out = 0;
		}
	}

	/* check to see if buffer is not empty */
	if ( count > 0 )
	{
		/* set characters into termios buffer  */
		rtems_termios_enqueue_raw_characters(info->ttyp, buffer, count);
	}

	return( EOF );
}
Example #17
0
static void atsam_usart_interrupt(void *arg)
{
  rtems_termios_tty *tty = arg;
  atsam_usart_context *ctx = rtems_termios_get_device_context(tty);
  Usart *regs = ctx->regs;
  uint32_t csr = regs->US_CSR;

  while ((csr & US_CSR_RXRDY) != 0) {
    char c = (char) regs->US_RHR;

    rtems_termios_enqueue_raw_characters(tty, &c, 1);

    csr = regs->US_CSR;
  }

  if (ctx->transmitting && (csr & US_CSR_TXEMPTY) != 0) {
    rtems_termios_dequeue_characters(tty, 1);
  }
}
Example #18
0
static void pl050_interrupt(void *arg)
{
  int minor = (int) arg;
  const console_data *cd = &Console_Port_Data[minor];
  volatile pl050 *regs = pl050_get_regs(minor);
  uint32_t kmiir_rx = PL050_KMIIR_KMIRXINTR;
  uint32_t kmiir_tx = (regs->kmicr & PL050_KMICR_KMITXINTREN) != 0 ?
    PL050_KMIIR_KMITXINTR : 0;
  uint32_t kmiir = regs->kmiir;

  if ((kmiir & kmiir_rx) != 0) {
    char c = (char) PL050_KMIDATA_KMIDATA_GET(regs->kmidata);

    rtems_termios_enqueue_raw_characters(cd->termios_data, &c, 1);
  }

  if ((kmiir & kmiir_tx) != 0) {
    rtems_termios_dequeue_characters(cd->termios_data, 1);
  }
}
Example #19
0
void termios_test_driver_set_rx(
  const void *p,
  size_t      len
)
{
  Rx_Buffer = p;
  Rx_Length = len;
  Rx_Index  = 0;

  if ( Rx_EnqueueNow == false) {
    (void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL );
    return;
  }

  do {
    uint8_t ch;
    ch = Rx_Buffer[ Rx_Index++ ];
    rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1);
  } while (Rx_Index < Rx_Length );
}
Example #20
0
/* This function is called from TERMIOS rxdaemon task without device lock. */
static int read_task(rtems_termios_device_context *base)
{
	rtems_interrupt_lock_context lock_context;
	struct apbuart_priv *uart = base_get_priv(base);
	struct apbuart_regs *regs = uart->regs;
	int cnt;
	char buf[33];
	struct rtems_termios_tty *tty;
	uint32_t ctrl_add;

	ctrl_add = APBUART_CTRL_RI;
	if (uart->cap & CAP_DI) {
		ctrl_add |= (APBUART_CTRL_DI | APBUART_CTRL_RF);
	}
	tty = uart->tty;
	do {
		cnt = 0;
		while (
			(regs->status & APBUART_STATUS_DR) &&
			(cnt < sizeof(buf))
		) {
			buf[cnt] = regs->data;
			cnt++;
		}
		if (0 < cnt) {
			/* Tell termios layer about new characters */
			rtems_termios_enqueue_raw_characters(tty, &buf[0], cnt);
		}

		/*
		 * Turn on RX interrupts. A new character in FIFO now may not
		 * cause interrupt so we must check data ready again
		 * afterwards.
		 */
		rtems_termios_device_lock_acquire(base, &lock_context);
		regs->ctrl |= ctrl_add;
		rtems_termios_device_lock_release(base, &lock_context);
	} while (regs->status & APBUART_STATUS_DR);

	return EOF;
}
Example #21
0
/*
 * Receive-data-full ISR
 *
 * The same routine for all interrupt sources of the same type.
 */
static rtems_isr sh_sci_rx_isr(rtems_vector_number vector)
{
    int minor;

    for (minor = 0; minor < Console_Port_Count; minor++) {
        if (Console_Port_Tbl[minor]->ulIntVector == vector) {
            char   temp8;

            /*
             * FIXME: error handling should be added
             */
            temp8 = read8(Console_Port_Tbl[minor]->ulCtrlPort1 + SCI_RDR);

            rtems_termios_enqueue_raw_characters(
                Console_Port_Data[minor].termios_data, &temp8, 1);

            SH_SCI_REG_MASK(SCI_RDRF, minor, SCI_SSR);
            break;
        }
    }
}
Example #22
0
File: hsu.c Project: Fyleo/rtems
static void lpc32xx_hsu_interrupt_handler(void *arg)
{
  int minor = (int) arg;
  console_tbl *ct = Console_Port_Tbl [minor];
  console_data *cd = &Console_Port_Data [minor];
  volatile lpc32xx_hsu *hsu = (volatile lpc32xx_hsu *) ct->ulCtrlPort1;

  /* Iterate until no more interrupts are pending */
  do {
    int chars_to_dequeue = (int) cd->pDeviceContext;
    int rv = 0;
    int i = 0;
    char buf [HSU_FIFO_SIZE];

    /* Enqueue received characters */
    while (i < HSU_FIFO_SIZE) {
      uint32_t in = hsu->fifo;

      if ((in & HSU_RX_EMPTY) == 0) {
        if ((in & HSU_RX_BREAK) == 0) {
          buf [i] = in & HSU_RX_DATA_MASK;
          ++i;
        }
      } else {
        break;
      }
    }
    rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);

    /* Dequeue transmitted characters */
    cd->pDeviceContext = 0;
    rv = rtems_termios_dequeue_characters(cd->termios_data, chars_to_dequeue);
    if (rv == 0) {
      /* Nothing to transmit */
      cd->bActive = false;
      hsu->ctrl = HSU_CTRL_RX_INTR_ENABLED;
      hsu->iir = HSU_IIR_TX;
    }
  } while ((hsu->iir & HSU_IIR_MASK) != 0);
}
Example #23
0
static void erc32_console_isr_b(
  rtems_vector_number vector
)
{
  console_data *cd = &Console_Port_Data[1];

  /* check for error */
  if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_ERRB) {
      ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
      ERC32_MEC.Control = ERC32_MEC.Control;
  }

  do {
    int chars_to_dequeue = (int)cd->pDeviceContext;
    int rv = 0;
    int i = 0;
    char buf[CONSOLE_BUF_SIZE];
        
    /* enqueue received chars */
    while (i < CONSOLE_BUF_SIZE) {
      if (!(ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_DRB))
        break;
      buf[i] = ERC32_MEC.UART_Channel_B;
      ++i;
    }
    if ( i ) 
      rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);

    /* dequeue transmitted chars */
    if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) {
      rv = rtems_termios_dequeue_characters(
         cd->termios_data, chars_to_dequeue);
      if ( !rv ) {
        cd->pDeviceContext = 0;
        cd->bActive = false;
      }
      ERC32_Clear_interrupt (ERC32_INTERRUPT_UART_B_RX_TX);
    }
  } while (ERC32_Is_interrupt_pending (ERC32_INTERRUPT_UART_B_RX_TX));
}
Example #24
0
File: uart.c Project: RTEMS/rtems
int
BSP_uart_termios_read_com2(int uart)
{
  int     off = (int)0;
  char    buf[40];

  /* read current byte */
  while (( off < sizeof(buf) ) && ( uread(BSP_UART_COM2, LSR) & DR )) {
    buf[off++] = uread(BSP_UART_COM2, RBR);
  }

  /* write out data */
  if ( off > 0 ) {
    rtems_termios_enqueue_raw_characters(termios_ttyp_com2, buf, off);
  }

  /* enable receive interrupts */
  uart_data[BSP_UART_COM2].ier |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
  uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier);

  return ( EOF );
}
static void
m8xx_smc2_interrupt_handler (void *unused)
{
    int nb_overflow;

    /*
     * Buffer received?
     */
    if (m8xx.smc2.smce & M8xx_SMCE_RX) {
        m8xx.smc2.smce = M8xx_SMCE_RX;  /* Clear the event */


        /* Check that the buffer is ours */
        if ((RxBd[SMC2_MINOR]->status & M8xx_BD_EMPTY) == 0) {
            rtems_cache_invalidate_multiple_data_lines(
                (const void *) RxBd[SMC2_MINOR]->buffer,
                RxBd[SMC2_MINOR]->length );
            nb_overflow = rtems_termios_enqueue_raw_characters(
                              (void *)ttyp[SMC2_MINOR],
                              (char *)RxBd[SMC2_MINOR]->buffer,
                              (int)RxBd[SMC2_MINOR]->length );
            RxBd[SMC2_MINOR]->status = M8xx_BD_EMPTY | M8xx_BD_WRAP |
                                       M8xx_BD_INTERRUPT;
        }
    }

    /*
     * Buffer transmitted?
     */
    if (m8xx.smc2.smce & M8xx_SMCE_TX) {
        m8xx.smc2.smce = M8xx_SMCE_TX;    /* Clear the event */

        /* Check that the buffer is ours */
        if ((TxBd[SMC2_MINOR]->status & M8xx_BD_READY) == 0)
            rtems_termios_dequeue_characters (
                (void *)ttyp[SMC2_MINOR],
                (int)TxBd[SMC2_MINOR]->length);
    }
}
Example #26
0
static void mpc55xx_esci_interrupt_handler(void *arg)
{
  mpc55xx_esci_context *self = arg;
  volatile struct ESCI_tag *regs = self->regs;
  union ESCI_SR_tag sr = MPC55XX_ZERO_FLAGS;
  union ESCI_SR_tag active = MPC55XX_ZERO_FLAGS;
  rtems_interrupt_level level;

  /* Status */
  sr.R = regs->SR.R;

  /* Receive data register full? */
  if (sr.B.RDRF != 0) {
    active.B.RDRF = 1;
  }

  /* Transmit data register empty? */
  if (sr.B.TDRE != 0) {
    active.B.TDRE = 1;
  }

  /* Clear flags */
  rtems_interrupt_disable(level);
  regs->SR.R = active.R;
  self->transmit_in_progress = false;
  rtems_interrupt_enable(level);

  /* Enqueue */
  if (active.B.RDRF != 0) {
    char c = regs->DR.B.D;
    rtems_termios_enqueue_raw_characters(self->tty, &c, 1);
  }

  /* Dequeue */
  if (active.B.TDRE != 0) {
    rtems_termios_dequeue_characters(self->tty, 1);
  }
}
Example #27
0
/* Handle UART interrupts */
static void leon3_console_isr(void *arg)
{
  struct apbuart_priv *uart = arg;
  unsigned int status;
  char data;

  /* Get all received characters */
  while ((status=uart->regs->status) & LEON_REG_UART_STATUS_DR) {
    /* Data has arrived, get new data */
    data = uart->regs->data;

    /* Tell termios layer about new character */
    rtems_termios_enqueue_raw_characters(uart->cookie, &data, 1);
  }

  if (
    (status & LEON_REG_UART_STATUS_THE)
      && (uart->regs->ctrl & LEON_REG_UART_CTRL_TI) != 0
  ) {
    /* write_interrupt will get called from this function */
    rtems_termios_dequeue_characters(uart->cookie, 1);
  }
}
Example #28
0
/* sh4uart1_interrupt_receive --
 *     UART interrupt handler routine -- SCI
 *     Receiving data
 *
 * PARAMETERS:
 *     vec - interrupt vector number
 *
 * RETURNS:
 *     none
 */
static rtems_isr
sh4uart1_interrupt_receive(rtems_vector_number vec)
{
  register int bp = 0;
  char buf[32];
  volatile uint8_t *ssr1 = (volatile uint8_t *)SH7750_SCSSR1;


  /* Find UART descriptor from vector number */
  sh4uart *uart = &sh4_uarts[0];

  while (1) {
    if ((bp < sizeof(buf) - 1) && ((SCSSR1 & SH7750_SCSSR1_RDRF) != 0)) {
      /* Receive character and handle frame/parity errors */
      if ((SCSSR1 & (SH7750_SCSSR1_PER | SH7750_SCSSR1_FER |
                      SH7750_SCSSR1_ORER)) != 0) {
        if (SCSSR1 & (SH7750_SCSSR1_PER | SH7750_SCSSR1_FER)) {
            if (!(uart->c_iflag & IGNPAR)) {
              if (uart->c_iflag & PARMRK) {
                buf[bp++] = 0xff;
                buf[bp++] = 0x00;
              } else
                buf[bp++] = 0x00;
            } else
              buf[bp++] = SCRDR1;
          }
          sh4uart_handle_error(uart);
      } else
          buf[bp++] = SCRDR1;
      *ssr1 &= ~SH7750_SCSSR1_RDRF;
    } else {
      if (bp != 0)
        rtems_termios_enqueue_raw_characters(uart->tty, buf, bp);
      break;
    }
  }
}
Example #29
0
static void apbuart_isr(void *arg)
{
  rtems_termios_tty *tty = arg;
  struct apbuart_context *uart = rtems_termios_get_device_context(tty);
  unsigned int status;
  char data;

  /* Get all received characters */
  while ((status=uart->regs->status) & APBUART_STATUS_DR) {
    /* Data has arrived, get new data */
    data = uart->regs->data;

    /* Tell termios layer about new character */
    rtems_termios_enqueue_raw_characters(tty, &data, 1);
  }

  if (
    (status & APBUART_STATUS_TE)
      && (uart->regs->ctrl & APBUART_CTRL_TI) != 0
  ) {
    /* write_interrupt will get called from this function */
    rtems_termios_dequeue_characters(tty, 1);
  }
}
Example #30
0
File: uart.c Project: RTEMS/rtems
void
BSP_uart_termios_isr_com2(void *ignored)
{
  unsigned char buf[40];
  unsigned char val;
  int      off, ret, vect;

  off = 0;

  for(;;)
    {
      vect = uread(BSP_UART_COM2, IIR) & 0xf;

      switch(vect)
	{
	case MODEM_STATUS :
	  val = uread(BSP_UART_COM2, MSR);
	  if(uart_data[BSP_UART_COM2].hwFlow)
	    {
	      if(val & CTS)
		{
		  /* CTS high */
		  termios_stopped_com2 = 0;
		  if(termios_tx_hold_valid_com2)
		    {
		      termios_tx_hold_valid_com2 = 0;
		      BSP_uart_termios_write_com2(0, &termios_tx_hold_com2,
						    1);
		    }
		}
	      else
		{
		  /* CTS low */
		  termios_stopped_com2 = 1;
		}
	    }
	  break;
	case NO_MORE_INTR :
	  /* No more interrupts */
	  if(off != 0)
	    {
	      /* Update rx buffer */
         if( driver_input_handler_com2 )
         {
             driver_input_handler_com2( termios_ttyp_com2, (char *)buf, off );
         }
         else
         {
	        rtems_termios_enqueue_raw_characters(termios_ttyp_com2, (char *)buf, off);
         }
	    }
	  return;
	case TRANSMITTER_HODING_REGISTER_EMPTY :
	  /*
	   * TX holding empty: we have to disable these interrupts
	   * if there is nothing more to send.
	   */

	  /* If nothing else to send disable interrupts */
	  ret = rtems_termios_dequeue_characters(termios_ttyp_com2, 1);
          if ( ret == 0 ) {
            termios_tx_active_com2 = 0;
            uart_data[BSP_UART_COM2].ier &= ~(TRANSMIT_ENABLE);
            uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier);
          }
	  break;
	case RECEIVER_DATA_AVAIL :
	case CHARACTER_TIMEOUT_INDICATION:
          if ( uart_data[BSP_UART_COM2].ioMode == TERMIOS_TASK_DRIVEN ) {
            /* ensure interrupts are enabled */
            if ( uart_data[BSP_UART_COM2].ier & RECEIVE_ENABLE ) {
              /* disable interrupts and notify termios */
              uart_data[BSP_UART_COM2].ier &= ~(RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
              uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier);
              rtems_termios_rxirq_occured(termios_ttyp_com2);
            }
          }
          else {
	    /* RX data ready */
	    assert(off < sizeof(buf));
	    buf[off++] = uread(BSP_UART_COM2, RBR);
          }
	  break;
	case RECEIVER_ERROR:
	  /* RX error: eat character */
	   uartError(BSP_UART_COM2);
	  break;
	default:
	  /* Should not happen */
	  assert(0);
	  return;
	}
    }
}