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>
|
2008-03-19 Till Straumann <strauman@slac.stanford.edu>
|
||||||
|
|
||||||
* shared/startup/pretaskinghook.c: install pointer
|
* shared/startup/pretaskinghook.c: install pointer
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ extern int close(int fd);
|
|||||||
#include <bsp/irq.h>
|
#include <bsp/irq.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/bspIo.h>
|
||||||
#include <rtems/libio.h>
|
#include <rtems/libio.h>
|
||||||
|
#include <rtems/termiostypes.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <bsp/uart.h>
|
#include <bsp/uart.h>
|
||||||
#include <rtems/bspIo.h> /* printk */
|
#include <rtems/bspIo.h> /* printk */
|
||||||
@@ -47,6 +48,23 @@ int BSPConsolePort = BSP_CONSOLE_PORT;
|
|||||||
|
|
||||||
int BSPBaseBaud = BSP_UART_BAUD_BASE;
|
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
|
| External Prototypes
|
||||||
+--------------------------------------------------------------------------*/
|
+--------------------------------------------------------------------------*/
|
||||||
@@ -181,18 +199,22 @@ console_open(rtems_device_major_number major,
|
|||||||
conSetAttr, /* setAttributes */
|
conSetAttr, /* setAttributes */
|
||||||
NULL, /* stopRemoteTx */
|
NULL, /* stopRemoteTx */
|
||||||
NULL, /* startRemoteTx */
|
NULL, /* startRemoteTx */
|
||||||
0 /* outputUsesInterrupts */
|
TERMIOS_POLLED /* outputUsesInterrupts */
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
console_first_open, /* firstOpen */
|
console_first_open, /* firstOpen */
|
||||||
console_last_close, /* lastClose */
|
console_last_close, /* lastClose */
|
||||||
|
#if ( TERMIOS_OUTPUT_MODE == TERMIOS_TASK_DRIVEN )
|
||||||
|
BSP_uart_termios_read_com, /* pollRead */
|
||||||
|
#else
|
||||||
NULL, /* pollRead */
|
NULL, /* pollRead */
|
||||||
|
#endif
|
||||||
BSP_uart_termios_write_com, /* write */
|
BSP_uart_termios_write_com, /* write */
|
||||||
conSetAttr, /* setAttributes */
|
conSetAttr, /* setAttributes */
|
||||||
NULL, /* stopRemoteTx */
|
NULL, /* stopRemoteTx */
|
||||||
NULL, /* startRemoteTx */
|
NULL, /* startRemoteTx */
|
||||||
1 /* outputUsesInterrupts */
|
TERMIOS_OUTPUT_MODE /* outputUsesInterrupts */
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,14 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <bsp.h>
|
#include <bsp.h>
|
||||||
#include <bsp/irq.h>
|
#include <bsp/irq.h>
|
||||||
#include <bsp/uart.h>
|
#include <bsp/uart.h>
|
||||||
#include <rtems/libio.h>
|
#include <rtems/libio.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/bspIo.h>
|
||||||
|
#include <rtems/termiostypes.h>
|
||||||
|
#include <termios.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -25,6 +28,7 @@ struct uart_data
|
|||||||
int hwFlow;
|
int hwFlow;
|
||||||
int baud;
|
int baud;
|
||||||
BSP_UartBreakCbRec breakCallback;
|
BSP_UartBreakCbRec breakCallback;
|
||||||
|
int ioMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -526,8 +530,9 @@ static volatile char termios_tx_hold_valid_com[2] = {0,0};
|
|||||||
* Set channel parameters
|
* Set channel parameters
|
||||||
*/
|
*/
|
||||||
void
|
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;
|
unsigned char val;
|
||||||
SANITY_CHECK(uart);
|
SANITY_CHECK(uart);
|
||||||
|
|
||||||
@@ -546,6 +551,8 @@ BSP_uart_termios_set(int uart, void *ttyp)
|
|||||||
termios_tx_hold_com[uart] = 0;
|
termios_tx_hold_com[uart] = 0;
|
||||||
termios_tx_hold_valid_com[uart] = 0;
|
termios_tx_hold_valid_com[uart] = 0;
|
||||||
|
|
||||||
|
uart_data[uart].ioMode = ttyp->device.outputUsesInterrupts;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,11 +622,36 @@ BSP_uart_termios_write_com(int minor, const char *buf, int len)
|
|||||||
return 0;
|
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
|
static void
|
||||||
BSP_uart_termios_isr_com(int uart)
|
BSP_uart_termios_isr_com(int uart)
|
||||||
{
|
{
|
||||||
unsigned char buf[40];
|
unsigned char buf[40];
|
||||||
unsigned char val;
|
unsigned char val, ier;
|
||||||
int off, ret, vect;
|
int off, ret, vect;
|
||||||
|
|
||||||
off = 0;
|
off = 0;
|
||||||
@@ -693,9 +725,24 @@ BSP_uart_termios_isr_com(int uart)
|
|||||||
break;
|
break;
|
||||||
case RECEIVER_DATA_AVAIL :
|
case RECEIVER_DATA_AVAIL :
|
||||||
case CHARACTER_TIMEOUT_INDICATION:
|
case CHARACTER_TIMEOUT_INDICATION:
|
||||||
/* RX data ready */
|
|
||||||
assert(off < sizeof(buf));
|
if ( uart_data[uart].ioMode == TERMIOS_TASK_DRIVEN )
|
||||||
buf[off++] = uread(uart, RBR);
|
{
|
||||||
|
/* 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;
|
break;
|
||||||
case RECEIVER_ERROR:
|
case RECEIVER_ERROR:
|
||||||
/* RX error: eat character */
|
/* RX error: eat character */
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ void BSP_uart_polled_write(int uart, int val);
|
|||||||
int BSP_uart_polled_read(int uart);
|
int BSP_uart_polled_read(int uart);
|
||||||
void BSP_uart_termios_set(int uart, void *ttyp);
|
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_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_com1(void *unused);
|
||||||
void BSP_uart_termios_isr_com2(void *unused);
|
void BSP_uart_termios_isr_com2(void *unused);
|
||||||
void BSP_uart_dbgisr_com1(void);
|
void BSP_uart_dbgisr_com1(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user