forked from Imagelibrary/rtems
2011-03-03 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1750/bsps * console/erc32_console.c, make/custom/erc32.cfg: The new console driver did not support polled mode. It also had a bug in which it could lose a transmitter interrupt.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2011-03-03 Joel Sherrill <joel.sherrilL@OARcorp.com>
|
||||||
|
|
||||||
|
PR 1750/bsps
|
||||||
|
* console/erc32_console.c, make/custom/erc32.cfg: The new console
|
||||||
|
driver did not support polled mode. It also had a bug in which it
|
||||||
|
could lose a transmitter interrupt.
|
||||||
|
|
||||||
2011-02-28 Joel Sherrill <joel.sherrill@oarcorp.com>
|
2011-02-28 Joel Sherrill <joel.sherrill@oarcorp.com>
|
||||||
|
|
||||||
* console/erc32_console.c: Add polled support. Tinker with interrupt
|
* console/erc32_console.c: Add polled support. Tinker with interrupt
|
||||||
|
|||||||
@@ -36,25 +36,25 @@
|
|||||||
|
|
||||||
static uint8_t erc32_console_get_register(uint32_t addr, uint8_t i)
|
static uint8_t erc32_console_get_register(uint32_t addr, uint8_t i)
|
||||||
{
|
{
|
||||||
volatile uint32_t *reg = (volatile uint32_t *)addr;
|
volatile uint32_t *reg = (volatile uint32_t *)addr;
|
||||||
return (uint8_t) reg [i];
|
return (uint8_t) reg [i];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void erc32_console_set_register(uint32_t addr, uint8_t i, uint8_t val)
|
static void erc32_console_set_register(uint32_t addr, uint8_t i, uint8_t val)
|
||||||
{
|
{
|
||||||
volatile uint32_t *reg = (volatile uint32_t *)addr;
|
volatile uint32_t *reg = (volatile uint32_t *)addr;
|
||||||
reg [i] = val;
|
reg [i] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int erc32_console_first_open(int major, int minor, void *arg);
|
static int erc32_console_first_open(int major, int minor, void *arg);
|
||||||
|
|
||||||
#if (CONSOLE_USE_INTERRUPTS)
|
#if (CONSOLE_USE_INTERRUPTS)
|
||||||
static ssize_t erc32_console_write_support_int(
|
static ssize_t erc32_console_write_support_int(
|
||||||
int minor, const char *buf, size_t len);
|
int minor, const char *buf, size_t len);
|
||||||
#else
|
#else
|
||||||
int console_inbyte_nonblocking( int port );
|
int console_inbyte_nonblocking( int port );
|
||||||
static ssize_t erc32_console_write_support_polled(
|
static ssize_t erc32_console_write_support_polled(
|
||||||
int minor, const char *buf, size_t len);
|
int minor, const char *buf, size_t len);
|
||||||
#endif
|
#endif
|
||||||
static void erc32_console_initialize(int minor);
|
static void erc32_console_initialize(int minor);
|
||||||
|
|
||||||
@@ -87,44 +87,44 @@ rtems_device_minor_number Console_Port_Minor = 0;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
console_tbl Console_Port_Tbl [] = {
|
console_tbl Console_Port_Tbl [] = {
|
||||||
{
|
{
|
||||||
.sDeviceName = "/dev/console_a",
|
.sDeviceName = "/dev/console_a",
|
||||||
.deviceType = SERIAL_CUSTOM,
|
.deviceType = SERIAL_CUSTOM,
|
||||||
.pDeviceFns = &erc32_fns,
|
.pDeviceFns = &erc32_fns,
|
||||||
.deviceProbe = NULL,
|
.deviceProbe = NULL,
|
||||||
.pDeviceFlow = NULL,
|
.pDeviceFlow = NULL,
|
||||||
.ulMargin = 16,
|
.ulMargin = 16,
|
||||||
.ulHysteresis = 8,
|
.ulHysteresis = 8,
|
||||||
.pDeviceParams = (void *) -1, /* could be baud rate */
|
.pDeviceParams = (void *) -1, /* could be baud rate */
|
||||||
.ulCtrlPort1 = 0,
|
.ulCtrlPort1 = 0,
|
||||||
.ulCtrlPort2 = 0,
|
.ulCtrlPort2 = 0,
|
||||||
.ulDataPort = 0,
|
.ulDataPort = 0,
|
||||||
.getRegister = erc32_console_get_register,
|
.getRegister = erc32_console_get_register,
|
||||||
.setRegister = erc32_console_set_register,
|
.setRegister = erc32_console_set_register,
|
||||||
.getData = NULL,
|
.getData = NULL,
|
||||||
.setData = NULL,
|
.setData = NULL,
|
||||||
.ulClock = 16,
|
.ulClock = 16,
|
||||||
.ulIntVector = ERC32_INTERRUPT_UART_A_RX_TX
|
.ulIntVector = ERC32_INTERRUPT_UART_A_RX_TX
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.sDeviceName = "/dev/console_b",
|
.sDeviceName = "/dev/console_b",
|
||||||
.deviceType = SERIAL_CUSTOM,
|
.deviceType = SERIAL_CUSTOM,
|
||||||
.pDeviceFns = &erc32_fns,
|
.pDeviceFns = &erc32_fns,
|
||||||
.deviceProbe = NULL,
|
.deviceProbe = NULL,
|
||||||
.pDeviceFlow = NULL,
|
.pDeviceFlow = NULL,
|
||||||
.ulMargin = 16,
|
.ulMargin = 16,
|
||||||
.ulHysteresis = 8,
|
.ulHysteresis = 8,
|
||||||
.pDeviceParams = (void *) -1, /* could be baud rate */
|
.pDeviceParams = (void *) -1, /* could be baud rate */
|
||||||
.ulCtrlPort1 = 0,
|
.ulCtrlPort1 = 0,
|
||||||
.ulCtrlPort2 = 0,
|
.ulCtrlPort2 = 0,
|
||||||
.ulDataPort = 0,
|
.ulDataPort = 0,
|
||||||
.getRegister = erc32_console_get_register,
|
.getRegister = erc32_console_get_register,
|
||||||
.setRegister = erc32_console_set_register,
|
.setRegister = erc32_console_set_register,
|
||||||
.getData = NULL,
|
.getData = NULL,
|
||||||
.setData = NULL,
|
.setData = NULL,
|
||||||
.ulClock = 16,
|
.ulClock = 16,
|
||||||
.ulIntVector = ERC32_INTERRUPT_UART_B_RX_TX
|
.ulIntVector = ERC32_INTERRUPT_UART_B_RX_TX
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* always exactly two uarts for erc32 */
|
/* always exactly two uarts for erc32 */
|
||||||
@@ -136,130 +136,130 @@ console_data Console_Port_Data [ERC32_UART_COUNT];
|
|||||||
|
|
||||||
static int erc32_console_first_open(int major, int minor, void *arg)
|
static int erc32_console_first_open(int major, int minor, void *arg)
|
||||||
{
|
{
|
||||||
/* Check minor number */
|
/* Check minor number */
|
||||||
if (minor < 0 || minor > 1) {
|
if (minor < 0 || minor > 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtems_libio_open_close_args_t *oca = arg;
|
rtems_libio_open_close_args_t *oca = arg;
|
||||||
struct rtems_termios_tty *tty = oca->iop->data1;
|
struct rtems_termios_tty *tty = oca->iop->data1;
|
||||||
console_tbl *ct = &Console_Port_Tbl [minor];
|
console_tbl *ct = &Console_Port_Tbl [minor];
|
||||||
console_data *cd = &Console_Port_Data [minor];
|
console_data *cd = &Console_Port_Data [minor];
|
||||||
|
|
||||||
cd->termios_data = tty;
|
cd->termios_data = tty;
|
||||||
rtems_termios_set_initial_baud(tty, (int32_t)ct->pDeviceParams);
|
rtems_termios_set_initial_baud(tty, (int32_t)ct->pDeviceParams);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (CONSOLE_USE_INTERRUPTS)
|
#if (CONSOLE_USE_INTERRUPTS)
|
||||||
static ssize_t erc32_console_write_support_int(int minor, const char *buf, size_t len)
|
static ssize_t erc32_console_write_support_int(int minor, const char *buf, size_t len)
|
||||||
{
|
{
|
||||||
console_data *cd = &Console_Port_Data[minor];
|
console_data *cd = &Console_Port_Data[minor];
|
||||||
int k = 0;
|
int k = 0;
|
||||||
|
|
||||||
if (minor == 0) { /* uart a */
|
if (minor == 0) { /* uart a */
|
||||||
for (k = 0; k < len && (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA); k ++) {
|
for (k = 0;
|
||||||
ERC32_MEC.UART_Channel_A = (unsigned char)buf[k];
|
k < len && (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA); k ++) {
|
||||||
}
|
ERC32_MEC.UART_Channel_A = (unsigned char)buf[k];
|
||||||
ERC32_Force_interrupt(ERC32_INTERRUPT_UART_A_RX_TX);
|
|
||||||
} else { /* uart b */
|
|
||||||
for (k = 0; k < len && (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB); k ++) {
|
|
||||||
ERC32_MEC.UART_Channel_B = (unsigned char)buf[k];
|
|
||||||
}
|
|
||||||
ERC32_Force_interrupt(ERC32_INTERRUPT_UART_B_RX_TX);
|
|
||||||
}
|
}
|
||||||
|
ERC32_Force_interrupt(ERC32_INTERRUPT_UART_A_RX_TX);
|
||||||
if (len > 0) {
|
} else { /* uart b */
|
||||||
cd->pDeviceContext = (void *)k;
|
for (k = 0;
|
||||||
cd->bActive = true;
|
k < len && (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB); k ++) {
|
||||||
|
ERC32_MEC.UART_Channel_B = (unsigned char)buf[k];
|
||||||
}
|
}
|
||||||
|
ERC32_Force_interrupt(ERC32_INTERRUPT_UART_B_RX_TX);
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
if (len > 0) {
|
||||||
|
cd->pDeviceContext = (void *)k;
|
||||||
|
cd->bActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void erc32_console_isr_a(
|
static void erc32_console_isr_a(
|
||||||
rtems_vector_number vector
|
rtems_vector_number vector
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
console_data *cd = &Console_Port_Data[0];
|
console_data *cd = &Console_Port_Data[0];
|
||||||
|
|
||||||
/* check for error */
|
/* check for error */
|
||||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_ERRA) {
|
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_ERRA) {
|
||||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
|
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRA;
|
||||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int chars_to_dequeue = (int)cd->pDeviceContext;
|
int chars_to_dequeue = (int)cd->pDeviceContext;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char buf[CONSOLE_BUF_SIZE];
|
char buf[CONSOLE_BUF_SIZE];
|
||||||
|
|
||||||
/* enqueue received chars */
|
/* enqueue received chars */
|
||||||
while (i < CONSOLE_BUF_SIZE) {
|
while (i < CONSOLE_BUF_SIZE) {
|
||||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_DRA) {
|
if (!(ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_DRA))
|
||||||
buf[i] = ERC32_MEC.UART_Channel_A;
|
break;
|
||||||
++i;
|
buf[i] = ERC32_MEC.UART_Channel_A;
|
||||||
} else {
|
++i;
|
||||||
break;
|
}
|
||||||
}
|
if ( i )
|
||||||
}
|
rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
|
||||||
rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
|
|
||||||
|
|
||||||
/* dequeue transmitted chars */
|
/* dequeue transmitted chars */
|
||||||
|
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) {
|
||||||
|
rv = rtems_termios_dequeue_characters(
|
||||||
|
cd->termios_data, chars_to_dequeue);
|
||||||
|
if ( !rv ) {
|
||||||
cd->pDeviceContext = 0;
|
cd->pDeviceContext = 0;
|
||||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEA) {
|
cd->bActive = false;
|
||||||
rv = rtems_termios_dequeue_characters(
|
}
|
||||||
cd->termios_data, chars_to_dequeue);
|
ERC32_Clear_interrupt (ERC32_INTERRUPT_UART_A_RX_TX);
|
||||||
if ( !rv ) {
|
}
|
||||||
cd->bActive = false;
|
} while (ERC32_Is_interrupt_pending (ERC32_INTERRUPT_UART_A_RX_TX));
|
||||||
ERC32_Clear_interrupt (ERC32_INTERRUPT_UART_A_RX_TX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (ERC32_Is_interrupt_pending (ERC32_INTERRUPT_UART_A_RX_TX));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void erc32_console_isr_b(
|
static void erc32_console_isr_b(
|
||||||
rtems_vector_number vector
|
rtems_vector_number vector
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
console_data *cd = &Console_Port_Data[1];
|
console_data *cd = &Console_Port_Data[1];
|
||||||
|
|
||||||
/* check for error */
|
/* check for error */
|
||||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_ERRB) {
|
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_ERRB) {
|
||||||
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
|
ERC32_MEC.UART_Status = ERC32_MEC_UART_STATUS_CLRB;
|
||||||
ERC32_MEC.Control = ERC32_MEC.Control;
|
ERC32_MEC.Control = ERC32_MEC.Control;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int chars_to_dequeue = (int)cd->pDeviceContext;
|
int chars_to_dequeue = (int)cd->pDeviceContext;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char buf[CONSOLE_BUF_SIZE];
|
char buf[CONSOLE_BUF_SIZE];
|
||||||
|
|
||||||
/* enqueue received chars */
|
/* enqueue received chars */
|
||||||
while (i < CONSOLE_BUF_SIZE) {
|
while (i < CONSOLE_BUF_SIZE) {
|
||||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_DRB) {
|
if (!(ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_DRB))
|
||||||
buf[i] = ERC32_MEC.UART_Channel_B;
|
break;
|
||||||
++i;
|
buf[i] = ERC32_MEC.UART_Channel_B;
|
||||||
} else {
|
++i;
|
||||||
break;
|
}
|
||||||
}
|
if ( i )
|
||||||
}
|
rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
|
||||||
rtems_termios_enqueue_raw_characters(cd->termios_data, buf, i);
|
|
||||||
|
|
||||||
/* dequeue transmitted chars */
|
/* 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->pDeviceContext = 0;
|
||||||
if (ERC32_MEC.UART_Status & ERC32_MEC_UART_STATUS_THEB) {
|
cd->bActive = false;
|
||||||
rv = rtems_termios_dequeue_characters(
|
}
|
||||||
cd->termios_data, chars_to_dequeue);
|
ERC32_Clear_interrupt (ERC32_INTERRUPT_UART_B_RX_TX);
|
||||||
if ( !rv ) {
|
}
|
||||||
cd->bActive = false;
|
} while (ERC32_Is_interrupt_pending (ERC32_INTERRUPT_UART_B_RX_TX));
|
||||||
ERC32_Clear_interrupt (ERC32_INTERRUPT_UART_B_RX_TX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (ERC32_Is_interrupt_pending (ERC32_INTERRUPT_UART_B_RX_TX));
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -292,23 +292,23 @@ static void erc32_console_initialize(
|
|||||||
int minor
|
int minor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
console_data *cd = &Console_Port_Data [minor];
|
console_data *cd = &Console_Port_Data [minor];
|
||||||
|
|
||||||
cd->bActive = false;
|
cd->bActive = false;
|
||||||
cd->pDeviceContext = 0;
|
cd->pDeviceContext = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the Termios infrastructure. If Termios has already
|
* Initialize the Termios infrastructure. If Termios has already
|
||||||
* been initialized by another device driver, then this call will
|
* been initialized by another device driver, then this call will
|
||||||
* have no effect.
|
* have no effect.
|
||||||
*/
|
*/
|
||||||
rtems_termios_initialize();
|
rtems_termios_initialize();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize Hardware
|
* Initialize Hardware
|
||||||
*/
|
*/
|
||||||
#if (CONSOLE_USE_INTERRUPTS)
|
#if (CONSOLE_USE_INTERRUPTS)
|
||||||
set_vector(erc32_console_isr_a, CONSOLE_UART_A_TRAP, 1);
|
set_vector(erc32_console_isr_a, CONSOLE_UART_A_TRAP, 1);
|
||||||
set_vector(erc32_console_isr_b, CONSOLE_UART_B_TRAP, 1);
|
set_vector(erc32_console_isr_b, CONSOLE_UART_B_TRAP, 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user