2000-10-18 Charles-Antoine Gauthier <charles.gauthier@nrc.ca>

* comm/i386-stub-glue.c, comm/tty_drv.c, comm/uart.c, comm/uart.h:
	Add the ability to set parity, number of data bits and
	number of stop bits to the existing i386 serial drivers.
This commit is contained in:
Joel Sherrill
2000-10-18 16:10:50 +00:00
parent 664db30bd3
commit 8ad5399ded
5 changed files with 86 additions and 14 deletions

View File

@@ -1,4 +1,10 @@
* comm/i386-stub-glue.c, comm/tty_drv.c, comm/uart.c, comm/uart.h:
Add the ability to set parity, number of data bits and
number of stop bits to the existing i386 serial drivers.
2000-10-17 Joel Sherrill <joel@OARcorp.com>
* irq/idt.c, irq/Makefile.am: Moved idt.c to from libcpu/i386 so * irq/idt.c, irq/Makefile.am: Moved idt.c to from libcpu/i386 so
i386 RTEMS can be multilib'ed. i386 RTEMS can be multilib'ed.

View File

@@ -37,7 +37,7 @@ i386_stub_glue_init(int uart)
uart_current = uart; uart_current = uart;
BSP_uart_init(uart, 38400, 0); BSP_uart_init(uart, 38400, CHR_8_BITS, 0, 0, 0);
} }
void BSP_uart_on(const rtems_raw_irq_connect_data* used) void BSP_uart_on(const rtems_raw_irq_connect_data* used)

View File

@@ -18,6 +18,19 @@
* MODIFICATION/HISTORY: * MODIFICATION/HISTORY:
* *
* $Log$ * $Log$
* Revision 1.1 2000/08/30 08:18:56 joel
* 2000-08-26 Rosimildo da Silva <rdasilva@connecttel.com>
*
* * shared/comm: Added "/dev/ttyS1" & "/dev/ttyS2" support for
* the i386 BSPs.
* * shared/comm/gdb_glue.c: New file.
* * shared/comm/i386_io.c: New file.
* * shared/comm/tty_drv.c: New file.
* * shared/comm/tty_drv.h: New file.
* * shared/comm/Makefile.am: Account for new files.
* * shared/comm/uart.c: Adds support for sending characters to
* another "line discipline."
*
****************************************************************************/ ****************************************************************************/
#include <stdio.h> #include <stdio.h>
@@ -119,7 +132,7 @@ tty1_initialize(rtems_device_major_number major,
* Do device-specific initialization * Do device-specific initialization
*/ */
/* 9600-8-N-1, without hardware flow control */ /* 9600-8-N-1, without hardware flow control */
BSP_uart_init( BSP_UART_COM1, 9600, 0 ); BSP_uart_init( BSP_UART_COM1, 9600, CHR_8_BITS, 0, 0, 0 );
status = BSP_install_rtems_irq_handler( &tty1_isr_data ); status = BSP_install_rtems_irq_handler( &tty1_isr_data );
if( !status ) if( !status )
{ {
@@ -259,7 +272,7 @@ tty1_control(rtems_device_major_number major,
static int static int
conSetAttr(int port, int minor, const struct termios *t) conSetAttr(int port, int minor, const struct termios *t)
{ {
int baud; unsigned long baud, databits, parity, stopbits;
switch (t->c_cflag & CBAUD) switch (t->c_cflag & CBAUD)
{ {
@@ -319,8 +332,40 @@ conSetAttr(int port, int minor, const struct termios *t)
rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR); rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR);
return 0; return 0;
} }
printk("Setting baud, port=%X, baud=%d\n", port, baud ); if (t->c_cflag & PARENB) {
BSP_uart_set_baud( port, baud ); /* Parity is enabled */
if (t->c_cflag & PARODD) {
/* Parity is odd */
parity = PEN;
}
else {
/* Parity is even */
parity = PEN | EPS;
}
}
else {
/* No parity */
parity = 0;
}
switch (t->c_cflag & CSIZE) {
case CS5: databits = CHR_5_BITS; break;
case CS6: databits = CHR_6_BITS; break;
case CS7: databits = CHR_7_BITS; break;
case CS8: databits = CHR_8_BITS; break;
}
if (t->c_cflag & CSTOPB) {
/* 2 stop bits */
stopbits = STB;
}
else {
/* 1 stop bit */
stopbits = 0;
}
printk("Setting attributes, port=%X, baud=%d, linemode = 0x%02x\n", port, baud, databits | parity | stopbits );
BSP_uart_set_attributes(port, baud, databits, parity, stopbits);
return 0; return 0;
} }
@@ -362,7 +407,7 @@ tty2_initialize(rtems_device_major_number major,
* Do device-specific initialization * Do device-specific initialization
*/ */
/* 9600-8-N-1, without hardware flow control */ /* 9600-8-N-1, without hardware flow control */
BSP_uart_init( BSP_UART_COM2, 9600, 0); BSP_uart_init( BSP_UART_COM2, 9600, CHR_8_BITS, 0, 0, 0);
status = BSP_install_rtems_irq_handler( &tty2_isr_data ); status = BSP_install_rtems_irq_handler( &tty2_isr_data );
if( !status ) if( !status )
{ {

View File

@@ -20,7 +20,10 @@
struct uart_data struct uart_data
{ {
int hwFlow; int hwFlow;
int baud; unsigned long baud;
unsigned long databits;
unsigned long parity;
unsigned long stopbits;
}; };
static struct uart_data uart_data[2]; static struct uart_data uart_data[2];
@@ -92,7 +95,15 @@ inline void uartError(int uart)
* and longest rx fifo setting * and longest rx fifo setting
*/ */
void void
BSP_uart_init(int uart, int baud, int hwFlow) BSP_uart_init
(
int uart,
unsigned long baud,
unsigned long databits,
unsigned long parity,
unsigned long stopbits,
int hwFlow
)
{ {
unsigned char tmp; unsigned char tmp;
@@ -128,7 +139,7 @@ BSP_uart_init(int uart, int baud, int hwFlow)
uwrite(uart, DLM, ((BSPBaseBaud/baud) >> 8) & 0xff); uwrite(uart, DLM, ((BSPBaseBaud/baud) >> 8) & 0xff);
/* 8-bit, no parity , 1 stop */ /* 8-bit, no parity , 1 stop */
uwrite(uart, LCR, CHR_8_BITS); uwrite(uart, LCR, databits | parity | stopbits);
/* Set DTR, RTS and OUT2 high */ /* Set DTR, RTS and OUT2 high */
@@ -155,7 +166,14 @@ BSP_uart_init(int uart, int baud, int hwFlow)
* Set baud * Set baud
*/ */
void void
BSP_uart_set_baud(int uart, int baud) BSP_uart_set_attributes
(
int uart,
unsigned long baud,
unsigned long databits,
unsigned long parity,
unsigned long stopbits
)
{ {
unsigned char mcr, ier; unsigned char mcr, ier;
@@ -168,7 +186,10 @@ BSP_uart_set_baud(int uart, int baud)
* indeed required * indeed required
*/ */
if(baud == uart_data[uart].baud) if( (baud == uart_data[uart].baud) &&
(databits == uart_data[uart].databits) &&
(parity == uart_data[uart].parity) &&
(stopbits == uart_data[uart].stopbits) )
{ {
return; return;
} }
@@ -176,7 +197,7 @@ BSP_uart_set_baud(int uart, int baud)
mcr = uread(uart, MCR); mcr = uread(uart, MCR);
ier = uread(uart, IER); ier = uread(uart, IER);
BSP_uart_init(uart, baud, uart_data[uart].hwFlow); BSP_uart_init(uart, baud, databits, parity, stopbits, uart_data[uart].hwFlow);
uwrite(uart, MCR, mcr); uwrite(uart, MCR, mcr);
uwrite(uart, IER, ier); uwrite(uart, IER, ier);

View File

@@ -10,8 +10,8 @@
#ifndef _BSPUART_H #ifndef _BSPUART_H
#define _BSPUART_H #define _BSPUART_H
void BSP_uart_init(int uart, int baud, int hwFlow); void BSP_uart_init(int uart, unsigned long baud, unsigned long databits, unsigned long parity, unsigned long stopbits, int hwFlow);
void BSP_uart_set_baud(int aurt, int baud); void BSP_uart_set_attributes(int uart, unsigned long baud, unsigned long databits, unsigned long parity, unsigned long stopbits);
void BSP_uart_intr_ctrl(int uart, int cmd); void BSP_uart_intr_ctrl(int uart, int cmd);
void BSP_uart_throttle(int uart); void BSP_uart_throttle(int uart);
void BSP_uart_unthrottle(int uart); void BSP_uart_unthrottle(int uart);