summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2000-10-18 16:10:50 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2000-10-18 16:10:50 +0000
commit8ad5399ded0178cbb0ba7e7adcb74a04376a253f (patch)
treefc5beecdb8d1dc0351f490936b8ef9cc9ac17c24 /c/src/lib/libbsp
parent2000-10-18 Charles-Antoine Gauthier <charles.gauthier@nrc.ca> (diff)
downloadrtems-8ad5399ded0178cbb0ba7e7adcb74a04376a253f.tar.bz2
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.
Diffstat (limited to 'c/src/lib/libbsp')
-rw-r--r--c/src/lib/libbsp/i386/shared/ChangeLog6
-rw-r--r--c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c2
-rw-r--r--c/src/lib/libbsp/i386/shared/comm/tty_drv.c55
-rw-r--r--c/src/lib/libbsp/i386/shared/comm/uart.c33
-rw-r--r--c/src/lib/libbsp/i386/shared/comm/uart.h4
5 files changed, 86 insertions, 14 deletions
diff --git a/c/src/lib/libbsp/i386/shared/ChangeLog b/c/src/lib/libbsp/i386/shared/ChangeLog
index dad8f658e4..8a3b0bf305 100644
--- a/c/src/lib/libbsp/i386/shared/ChangeLog
+++ b/c/src/lib/libbsp/i386/shared/ChangeLog
@@ -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
i386 RTEMS can be multilib'ed.
diff --git a/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c b/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c
index 60f2204356..aac397f55d 100644
--- a/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c
+++ b/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c
@@ -37,7 +37,7 @@ i386_stub_glue_init(int 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)
diff --git a/c/src/lib/libbsp/i386/shared/comm/tty_drv.c b/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
index b6f3947d4b..98c60ff1c1 100644
--- a/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
+++ b/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
@@ -18,6 +18,19 @@
* MODIFICATION/HISTORY:
*
* $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>
@@ -119,7 +132,7 @@ tty1_initialize(rtems_device_major_number major,
* Do device-specific initialization
*/
/* 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 );
if( !status )
{
@@ -259,7 +272,7 @@ tty1_control(rtems_device_major_number major,
static int
conSetAttr(int port, int minor, const struct termios *t)
{
- int baud;
+ unsigned long baud, databits, parity, stopbits;
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);
return 0;
}
- printk("Setting baud, port=%X, baud=%d\n", port, baud );
- BSP_uart_set_baud( port, baud );
+ if (t->c_cflag & PARENB) {
+ /* 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;
}
@@ -362,7 +407,7 @@ tty2_initialize(rtems_device_major_number major,
* Do device-specific initialization
*/
/* 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 );
if( !status )
{
diff --git a/c/src/lib/libbsp/i386/shared/comm/uart.c b/c/src/lib/libbsp/i386/shared/comm/uart.c
index c794e922a3..50dcd7de6a 100644
--- a/c/src/lib/libbsp/i386/shared/comm/uart.c
+++ b/c/src/lib/libbsp/i386/shared/comm/uart.c
@@ -20,7 +20,10 @@
struct uart_data
{
int hwFlow;
- int baud;
+ unsigned long baud;
+ unsigned long databits;
+ unsigned long parity;
+ unsigned long stopbits;
};
static struct uart_data uart_data[2];
@@ -92,7 +95,15 @@ inline void uartError(int uart)
* and longest rx fifo setting
*/
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;
@@ -128,7 +139,7 @@ BSP_uart_init(int uart, int baud, int hwFlow)
uwrite(uart, DLM, ((BSPBaseBaud/baud) >> 8) & 0xff);
/* 8-bit, no parity , 1 stop */
- uwrite(uart, LCR, CHR_8_BITS);
+ uwrite(uart, LCR, databits | parity | stopbits);
/* Set DTR, RTS and OUT2 high */
@@ -155,7 +166,14 @@ BSP_uart_init(int uart, int baud, int hwFlow)
* Set baud
*/
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;
@@ -168,7 +186,10 @@ BSP_uart_set_baud(int uart, int baud)
* 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;
}
@@ -176,7 +197,7 @@ BSP_uart_set_baud(int uart, int baud)
mcr = uread(uart, MCR);
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, IER, ier);
diff --git a/c/src/lib/libbsp/i386/shared/comm/uart.h b/c/src/lib/libbsp/i386/shared/comm/uart.h
index e43ac9900c..6cdb132b4c 100644
--- a/c/src/lib/libbsp/i386/shared/comm/uart.h
+++ b/c/src/lib/libbsp/i386/shared/comm/uart.h
@@ -10,8 +10,8 @@
#ifndef _BSPUART_H
#define _BSPUART_H
-void BSP_uart_init(int uart, int baud, int hwFlow);
-void BSP_uart_set_baud(int aurt, int baud);
+void BSP_uart_init(int uart, unsigned long baud, unsigned long databits, unsigned long parity, unsigned long stopbits, int hwFlow);
+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_throttle(int uart);
void BSP_uart_unthrottle(int uart);