forked from Imagelibrary/rtems
2008-03-19 Till Straumann <strauman@slac.stanford.edu>
* shared/console/console.c, shared/console/uart.c, shared/console/uart.h: added support for task-driven console.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2008-03-19 Till Straumann <strauman@slac.stanford.edu>
|
||||
|
||||
* shared/console/console.c, shared/console/uart.c,
|
||||
shared/console/uart.h: added support for task-driven
|
||||
console.
|
||||
|
||||
2008-03-19 Till Straumann <strauman@slac.stanford.edu>
|
||||
|
||||
* shared/startup/pretaskinghook.c: install pointer
|
||||
|
||||
@@ -32,6 +32,7 @@ extern int close(int fd);
|
||||
#include <bsp/irq.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/termiostypes.h>
|
||||
#include <termios.h>
|
||||
#include <bsp/uart.h>
|
||||
#include <rtems/bspIo.h> /* printk */
|
||||
@@ -47,6 +48,23 @@ int BSPConsolePort = BSP_CONSOLE_PORT;
|
||||
|
||||
int BSPBaseBaud = BSP_UART_BAUD_BASE;
|
||||
|
||||
/*
|
||||
* TERMIOS_OUTPUT_MODE should be a 'bspopts.h/configure'-able option;
|
||||
* we could even make it a link-time option (but that would require
|
||||
* small changes)...
|
||||
*/
|
||||
#ifndef TERMIOS_OUTPUT_MODE
|
||||
#if 1
|
||||
#define TERMIOS_OUTPUT_MODE TERMIOS_IRQ_DRIVEN
|
||||
#else
|
||||
#define TERMIOS_OUTPUT_MODE TERMIOS_TASK_DRIVEN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ! defined(USE_POLLED_IO) && (TERMIOS_OUTPUT_MODE == TERMIOS_POLLED)
|
||||
#define USE_POLLED_IO
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------+
|
||||
| External Prototypes
|
||||
+--------------------------------------------------------------------------*/
|
||||
@@ -181,18 +199,22 @@ console_open(rtems_device_major_number major,
|
||||
conSetAttr, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
0 /* outputUsesInterrupts */
|
||||
TERMIOS_POLLED /* outputUsesInterrupts */
|
||||
};
|
||||
#else
|
||||
{
|
||||
console_first_open, /* firstOpen */
|
||||
console_last_close, /* lastClose */
|
||||
#if ( TERMIOS_OUTPUT_MODE == TERMIOS_TASK_DRIVEN )
|
||||
BSP_uart_termios_read_com, /* pollRead */
|
||||
#else
|
||||
NULL, /* pollRead */
|
||||
#endif
|
||||
BSP_uart_termios_write_com, /* write */
|
||||
conSetAttr, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
1 /* outputUsesInterrupts */
|
||||
TERMIOS_OUTPUT_MODE /* outputUsesInterrupts */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <bsp.h>
|
||||
#include <bsp/irq.h>
|
||||
#include <bsp/uart.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <rtems/termiostypes.h>
|
||||
#include <termios.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
@@ -25,6 +28,7 @@ struct uart_data
|
||||
int hwFlow;
|
||||
int baud;
|
||||
BSP_UartBreakCbRec breakCallback;
|
||||
int ioMode;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -526,8 +530,9 @@ static volatile char termios_tx_hold_valid_com[2] = {0,0};
|
||||
* Set channel parameters
|
||||
*/
|
||||
void
|
||||
BSP_uart_termios_set(int uart, void *ttyp)
|
||||
BSP_uart_termios_set(int uart, void *p)
|
||||
{
|
||||
struct rtems_termios_tty *ttyp = p;
|
||||
unsigned char val;
|
||||
SANITY_CHECK(uart);
|
||||
|
||||
@@ -546,6 +551,8 @@ BSP_uart_termios_set(int uart, void *ttyp)
|
||||
termios_tx_hold_com[uart] = 0;
|
||||
termios_tx_hold_valid_com[uart] = 0;
|
||||
|
||||
uart_data[uart].ioMode = ttyp->device.outputUsesInterrupts;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -615,11 +622,36 @@ BSP_uart_termios_write_com(int minor, const char *buf, int len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
BSP_uart_termios_read_com(int uart)
|
||||
{
|
||||
int off = (int)0;
|
||||
char buf[40];
|
||||
rtems_interrupt_level l;
|
||||
|
||||
/* read bytes */
|
||||
while (( off < sizeof(buf) ) && ( uread(uart, LSR) & DR )) {
|
||||
buf[off++] = uread(uart, RBR);
|
||||
}
|
||||
|
||||
/* write out data */
|
||||
if ( off > 0 ) {
|
||||
rtems_termios_enqueue_raw_characters(termios_ttyp_com[uart], buf, off);
|
||||
}
|
||||
|
||||
/* enable receive interrupts */
|
||||
rtems_interrupt_disable(l);
|
||||
uwrite(uart, IER, uread(uart, IER) | (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE));
|
||||
rtems_interrupt_enable(l);
|
||||
|
||||
return ( EOF );
|
||||
}
|
||||
|
||||
static void
|
||||
BSP_uart_termios_isr_com(int uart)
|
||||
{
|
||||
unsigned char buf[40];
|
||||
unsigned char val;
|
||||
unsigned char val, ier;
|
||||
int off, ret, vect;
|
||||
|
||||
off = 0;
|
||||
@@ -693,9 +725,24 @@ BSP_uart_termios_isr_com(int uart)
|
||||
break;
|
||||
case RECEIVER_DATA_AVAIL :
|
||||
case CHARACTER_TIMEOUT_INDICATION:
|
||||
/* RX data ready */
|
||||
assert(off < sizeof(buf));
|
||||
buf[off++] = uread(uart, RBR);
|
||||
|
||||
if ( uart_data[uart].ioMode == TERMIOS_TASK_DRIVEN )
|
||||
{
|
||||
/* ensure interrupts are enabled */
|
||||
if ( (ier = uread(uart,IER)) & RECEIVE_ENABLE )
|
||||
{
|
||||
/* disable interrupts and notify termios */
|
||||
ier &= ~(RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE);
|
||||
uwrite(uart, IER, ier);
|
||||
rtems_termios_rxirq_occured(termios_ttyp_com[uart]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* RX data ready */
|
||||
assert(off < sizeof(buf));
|
||||
buf[off++] = uread(uart, RBR);
|
||||
}
|
||||
break;
|
||||
case RECEIVER_ERROR:
|
||||
/* RX error: eat character */
|
||||
|
||||
@@ -25,6 +25,7 @@ void BSP_uart_polled_write(int uart, int val);
|
||||
int BSP_uart_polled_read(int uart);
|
||||
void BSP_uart_termios_set(int uart, void *ttyp);
|
||||
int BSP_uart_termios_write_com(int minor, const char *buf, int len);
|
||||
int BSP_uart_termios_read_com (int minor);
|
||||
void BSP_uart_termios_isr_com1(void *unused);
|
||||
void BSP_uart_termios_isr_com2(void *unused);
|
||||
void BSP_uart_dbgisr_com1(void);
|
||||
|
||||
Reference in New Issue
Block a user