summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Kirspel <kevin-kirspel@idexx.com>2017-03-21 15:39:48 -0400
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-03-22 11:55:04 +0100
commit1c6926c11f2e5efcb166c668b097d64a0321d66e (patch)
tree30683dcf11979f51273413aade68a3828d00da10
parentbsp/atsam: Fix DMA support of some drivers (diff)
downloadrtems-1c6926c11f2e5efcb166c668b097d64a0321d66e.tar.bz2
termios: Synchronize with latest FreeBSD headers
Adding modified FreeBSD headers to synchronize RTEMS termios with FreeBSD. Modify termios to support dedicated input and output baud for termios structure. Updated BSPs to use dedicated input and output baud in termios structure. Updated tools to use dedicated input and output baud in termios structure. Updated termios testsuites to use dedicated input and output baud in termios structure. Close #2897.
-rw-r--r--c/src/lib/libbsp/arm/csb336/console/uart.c2
-rw-r--r--c/src/lib/libbsp/arm/lpc32xx/console/hsu.c2
-rw-r--r--c/src/lib/libbsp/i386/shared/comm/tty_drv.c2
-rw-r--r--c/src/lib/libbsp/lm32/shared/milkymist_console/console.c2
-rw-r--r--c/src/lib/libbsp/m68k/av5282/console/console.c6
-rw-r--r--c/src/lib/libbsp/m68k/gen68340/console/console.c18
-rw-r--r--c/src/lib/libbsp/m68k/gen68360/console/console.c2
-rw-r--r--c/src/lib/libbsp/m68k/genmcf548x/console/console.c2
-rw-r--r--c/src/lib/libbsp/m68k/mcf52235/console/console.c8
-rw-r--r--c/src/lib/libbsp/m68k/mcf5225x/console/console.c24
-rw-r--r--c/src/lib/libbsp/m68k/mcf5235/console/console.c8
-rw-r--r--c/src/lib/libbsp/m68k/mcf5329/console/console.c8
-rw-r--r--c/src/lib/libbsp/m68k/mrm332/console/sci.c2
-rw-r--r--c/src/lib/libbsp/m68k/mvme167/console/console.c8
-rw-r--r--c/src/lib/libbsp/m68k/uC5282/console/console.c4
-rw-r--r--c/src/lib/libbsp/powerpc/acinclude.m44
-rw-r--r--c/src/lib/libbsp/powerpc/gen5200/console/console.c2
-rw-r--r--c/src/lib/libbsp/powerpc/shared/console/console.c2
-rw-r--r--c/src/lib/libbsp/powerpc/tqm8xx/console/console.c2
-rw-r--r--c/src/lib/libbsp/shared/console.c4
-rw-r--r--c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c8
-rw-r--r--c/src/lib/libcpu/arm/at91rm9200/usart/usart.c2
-rw-r--r--c/src/lib/libcpu/arm/s3c24xx/include/s3c2400.h2
-rw-r--r--c/src/lib/libcpu/arm/s3c24xx/include/s3c2410.h2
-rw-r--r--c/src/lib/libcpu/bfin/serial/uart.c4
-rw-r--r--c/src/lib/libcpu/powerpc/mpc55xx/esci/esci.c2
-rw-r--r--c/src/lib/libcpu/powerpc/mpc5xx/console-generic/console-generic.c2
-rw-r--r--c/src/lib/libcpu/powerpc/mpc8260/console-generic/console-generic.c4
-rw-r--r--c/src/lib/libcpu/powerpc/mpc8xx/console-generic/console-generic.c4
-rw-r--r--c/src/lib/libcpu/powerpc/ppc403/console/console.c2
-rw-r--r--c/src/lib/libcpu/powerpc/ppc403/console/console405.c2
-rw-r--r--c/src/lib/libcpu/powerpc/ppc403/tty_drv/tty_drv.c2
-rw-r--r--c/src/lib/libcpu/sh/sh7032/sci/sci.c18
-rw-r--r--c/src/lib/libcpu/sh/sh7045/sci/sci.c18
-rw-r--r--c/src/lib/libcpu/sh/sh7045/sci/sci_termios.c7
-rw-r--r--c/src/libchip/serial/mc68681.c2
-rw-r--r--c/src/libchip/serial/mc68681_baud.c28
-rw-r--r--c/src/libchip/serial/z85c30.c2
-rw-r--r--cpukit/libcsupport/Makefile.am2
-rw-r--r--cpukit/libcsupport/include/rtems/termiostypes.h8
-rw-r--r--cpukit/libcsupport/include/sys/_termios.h264
-rw-r--r--cpukit/libcsupport/include/sys/ioccom.h11
-rw-r--r--cpukit/libcsupport/include/sys/termios.h280
-rw-r--r--cpukit/libcsupport/include/sys/ttycom.h6
-rw-r--r--cpukit/libcsupport/include/sys/ttydefaults.h111
-rw-r--r--cpukit/libcsupport/src/cfgetispeed.c2
-rw-r--r--cpukit/libcsupport/src/cfgetospeed.c2
-rw-r--r--cpukit/libcsupport/src/cfmakeraw.c10
-rw-r--r--cpukit/libcsupport/src/cfmakesane.c66
-rw-r--r--cpukit/libcsupport/src/cfsetispeed.c7
-rw-r--r--cpukit/libcsupport/src/cfsetospeed.c7
-rw-r--r--cpukit/libcsupport/src/cfsetspeed.c3
-rw-r--r--cpukit/libcsupport/src/tcdrain.c2
-rw-r--r--cpukit/libcsupport/src/tcflush.c23
-rw-r--r--cpukit/libcsupport/src/tcgetattr.c2
-rw-r--r--cpukit/libcsupport/src/tcsetattr.c35
-rw-r--r--cpukit/libcsupport/src/termios.c44
-rw-r--r--cpukit/libcsupport/src/termios_baud2index.c13
-rw-r--r--cpukit/libcsupport/src/termios_baud2num.c6
-rw-r--r--cpukit/libcsupport/src/termios_baudtable.c5
-rw-r--r--cpukit/libcsupport/src/termios_setbestbaud.c10
-rw-r--r--cpukit/libcsupport/src/termios_setinitialbaud.c9
-rw-r--r--cpukit/libnetworking/net/ppp_tty.c15
-rw-r--r--cpukit/preinstall.am8
-rw-r--r--testsuites/libtests/termios/init.c341
-rw-r--r--testsuites/libtests/termios01/init.c143
-rw-r--r--testsuites/libtests/termios01/termios01.scn270
-rw-r--r--testsuites/libtests/termios01/termios_testdriver.c6
-rw-r--r--testsuites/libtests/termios02/termios02.scn4
-rw-r--r--testsuites/libtests/termios03/termios03.scn6
-rw-r--r--testsuites/libtests/termios04/termios04.scn8
-rw-r--r--testsuites/libtests/termios05/termios05.scn8
-rw-r--r--testsuites/libtests/termios06/init.c2
-rw-r--r--testsuites/libtests/termios06/termios06.scn20
-rw-r--r--testsuites/libtests/termios07/termios07.scn21
-rw-r--r--testsuites/libtests/termios08/termios08.scn19
-rw-r--r--tools/cpu/sh/sci.c29
77 files changed, 1393 insertions, 658 deletions
diff --git a/c/src/lib/libbsp/arm/csb336/console/uart.c b/c/src/lib/libbsp/arm/csb336/console/uart.c
index 1f3a4a1cdb..e2e6bc2ab7 100644
--- a/c/src/lib/libbsp/arm/csb336/console/uart.c
+++ b/c/src/lib/libbsp/arm/csb336/console/uart.c
@@ -322,7 +322,7 @@ static int imx_uart_set_attrs(int minor, const struct termios *t)
{
int baud;
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
imx_uart_set_baud(minor, baud);
return 0;
diff --git a/c/src/lib/libbsp/arm/lpc32xx/console/hsu.c b/c/src/lib/libbsp/arm/lpc32xx/console/hsu.c
index 8beeeef9b0..b2044e0753 100644
--- a/c/src/lib/libbsp/arm/lpc32xx/console/hsu.c
+++ b/c/src/lib/libbsp/arm/lpc32xx/console/hsu.c
@@ -178,7 +178,7 @@ static bool lpc32xx_hsu_set_attributes(
{
lpc32xx_hsu_context *ctx = (lpc32xx_hsu_context *) base;
volatile lpc32xx_hsu *hsu = ctx->hsu;
- int baud_flags = term->c_cflag & CBAUD;
+ int baud_flags = term->c_ospeed;
if (baud_flags != 0) {
int32_t baud = rtems_termios_baud_to_number(baud_flags);
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 2152dec0b4..e15edbd15d 100644
--- a/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
+++ b/c/src/lib/libbsp/i386/shared/comm/tty_drv.c
@@ -227,7 +227,7 @@ conSetAttr(int port, int minor, const struct termios *t)
{
unsigned long baud, databits, parity, stopbits;
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
if ( baud > 115200 )
rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR);
diff --git a/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c b/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c
index 3558e33fc6..de87233299 100644
--- a/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c
+++ b/c/src/lib/libbsp/lm32/shared/milkymist_console/console.c
@@ -41,7 +41,7 @@ static int mmconsole_set_attributes(int minor, const struct termios *t)
{
int baud;
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
case B0:
baud = 0;
break;
diff --git a/c/src/lib/libbsp/m68k/av5282/console/console.c b/c/src/lib/libbsp/m68k/av5282/console/console.c
index 07a1569d58..f56305a970 100644
--- a/c/src/lib/libbsp/m68k/av5282/console/console.c
+++ b/c/src/lib/libbsp/m68k/av5282/console/console.c
@@ -179,7 +179,7 @@ static int IntUartSetAttributes(
/* check to see if input is valid */
if ( t != (const struct termios *)0 ) {
/* determine baud rate index */
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
/* determine data bits */
switch ( t->c_cflag & CSIZE ) {
@@ -240,7 +240,7 @@ static int IntUartSetAttributes(
* Description : This is the interrupt handler for the internal uart. It
* determines which channel caused the interrupt before queueing any received
* chars and dequeueing chars waiting for transmission.
- */
+ */
static rtems_isr IntUartInterruptHandler(rtems_vector_number v)
{
unsigned int chan = v - UART_INTC0_IRQ_VECTOR(0);
@@ -303,7 +303,7 @@ static rtems_isr IntUartInterruptHandler(rtems_vector_number v)
* Description : This initialises the internal uart hardware for all
* internal uarts. If the internal uart is to be interrupt driven then the
* interrupt vectors are hooked.
- */
+ */
static void IntUartInitialize(void)
{
unsigned int chan;
diff --git a/c/src/lib/libbsp/m68k/gen68340/console/console.c b/c/src/lib/libbsp/m68k/gen68340/console/console.c
index dd38559fb1..d6634b1079 100644
--- a/c/src/lib/libbsp/m68k/gen68340/console/console.c
+++ b/c/src/lib/libbsp/m68k/gen68340/console/console.c
@@ -474,20 +474,10 @@ SetAttributes (int minor, const struct termios *t)
{
rtems_interrupt_level level;
float ispeed, ospeed;
- int isp, osp;
-
- /* output speed */
- if (t->c_cflag & CBAUDEX)
- osp = (t->c_cflag & CBAUD) + CBAUD + 1;
- else
- osp = t->c_cflag & CBAUD;
-
- /* input speed */
- isp = (t->c_cflag / (CIBAUD / CBAUD)) & CBAUD;
/* convert it */
- ispeed = rtems_termios_baud_to_number(isp);
- ospeed = rtems_termios_baud_to_number(osp);
+ ispeed = rtems_termios_baud_to_number(t->c_ispeed);
+ ospeed = rtems_termios_baud_to_number(t->c_ospeed);
if (ispeed || ospeed) {
/* update config table */
@@ -515,7 +505,7 @@ SetAttributes (int minor, const struct termios *t)
}
/* if serial module configuration has been changed */
- if (t->c_cflag & (CBAUD | CIBAUD | CSIZE | PARENB)) {
+ if (t->c_cflag & (CSIZE | PARENB)) {
rtems_interrupt_disable(level);
/* reinit the UART */
dbugInitialise();
@@ -693,7 +683,7 @@ rtems_device_driver console_control(
{
rtems_libio_ioctl_args_t *args = arg;
- if (args->command == RTEMS_IO_SET_ATTRIBUTES)
+ if (args->command == TIOCSETA)
SetAttributes (minor, (struct termios *)args->buffer);
return rtems_termios_ioctl (arg);
diff --git a/c/src/lib/libbsp/m68k/gen68360/console/console.c b/c/src/lib/libbsp/m68k/gen68360/console/console.c
index 1a8ed0026f..36d8470168 100644
--- a/c/src/lib/libbsp/m68k/gen68360/console/console.c
+++ b/c/src/lib/libbsp/m68k/gen68360/console/console.c
@@ -86,7 +86,7 @@ smc1SetAttributes (int minor, const struct termios *t)
{
int baud;
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
if (baud > 0)
m360.brgc1 = smc1BRGC (baud);
return 0;
diff --git a/c/src/lib/libbsp/m68k/genmcf548x/console/console.c b/c/src/lib/libbsp/m68k/genmcf548x/console/console.c
index 6891e768e5..23186fcfdf 100644
--- a/c/src/lib/libbsp/m68k/genmcf548x/console/console.c
+++ b/c/src/lib/libbsp/m68k/genmcf548x/console/console.c
@@ -307,7 +307,7 @@ IntUartSetAttributes(int minor, const struct termios *t)
if ( t != (const struct termios *)0 )
{
/* determine baud rate index */
- baud = GetBaud( t->c_cflag & CBAUD );
+ baud = GetBaud( t->c_ospeed );
/* determine data bits */
switch ( t->c_cflag & CSIZE )
diff --git a/c/src/lib/libbsp/m68k/mcf52235/console/console.c b/c/src/lib/libbsp/m68k/mcf52235/console/console.c
index 50c642a021..c2b6e36bfa 100644
--- a/c/src/lib/libbsp/m68k/mcf52235/console/console.c
+++ b/c/src/lib/libbsp/m68k/mcf52235/console/console.c
@@ -152,7 +152,7 @@ static int IntUartSetAttributes(int minor, const struct termios *t)
/* check to see if input is valid */
if (t != (const struct termios *) 0) {
/* determine baud rate index */
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
/* determine data bits */
switch (t->c_cflag & CSIZE) {
@@ -598,8 +598,10 @@ rtems_device_driver console_open(rtems_device_major_number major,
struct termios term;
if (tcgetattr(STDIN_FILENO, &term) >= 0) {
- term.c_cflag &= ~(CBAUD | CSIZE);
- term.c_cflag |= CS8 | B19200;
+ term.c_cflag &= ~(CSIZE);
+ term.c_cflag |= CS8;
+ term.c_ispeed = B19200;
+ term.c_ospeed = B19200;
tcsetattr(STDIN_FILENO, TCSANOW, &term);
}
}
diff --git a/c/src/lib/libbsp/m68k/mcf5225x/console/console.c b/c/src/lib/libbsp/m68k/mcf5225x/console/console.c
index 63bb644682..9e36e3945a 100644
--- a/c/src/lib/libbsp/m68k/mcf5225x/console/console.c
+++ b/c/src/lib/libbsp/m68k/mcf5225x/console/console.c
@@ -150,7 +150,7 @@ IntUartSet(int minor, int baud, int databits, int parity, int stopbits,
Description : This provides the hardware-dependent portion of tcsetattr().
value and sets it. At the moment this just sets the baud rate.
- Note: The highest baudrate is 115200 as this stays within
+ Note: The highest baudrate is 115200 as this stays within
an error of +/- 5% at 25MHz processor clock
***************************************************************************/
static int IntUartSetAttributes(int minor, const struct termios *t)
@@ -166,7 +166,7 @@ static int IntUartSetAttributes(int minor, const struct termios *t)
/* check to see if input is valid */
if (t != (const struct termios *) 0) {
/* determine baud rate index */
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
/* determine data bits */
switch (t->c_cflag & CSIZE) {
@@ -243,7 +243,7 @@ static rtems_isr IntUartInterruptHandler(rtems_vector_number v)
else
MCF_GPIO_PORTTC |= MCF_GPIO_PORTTC_PORTTC0;
#endif
-
+
/* read data and put into the receive buffer */
while (MCF_UART_USR(chan) & MCF_UART_USR_RXRDY) {
@@ -359,9 +359,9 @@ static void IntUartInitialize(void)
/***************************************************************************
Function : IntUartInterruptWrite
- Description : This writes a single character to the appropriate uart
+ Description : This writes a single character to the appropriate uart
channel. This is either called during an interrupt or in the user's task
- to initiate a transmit sequence. Calling this routine enables Tx
+ to initiate a transmit sequence. Calling this routine enables Tx
interrupts.
***************************************************************************/
static ssize_t IntUartInterruptWrite(int minor, const char *buf, size_t len)
@@ -476,7 +476,7 @@ static int IntUartTaskRead(int minor)
/***************************************************************************
Function : IntUartPollRead
- Description : This reads a character from the internal uart. It returns
+ Description : This reads a character from the internal uart. It returns
to the caller without blocking if not character is waiting.
***************************************************************************/
static
@@ -491,8 +491,8 @@ int IntUartPollRead(int minor)
/***************************************************************************
Function : IntUartPollWrite
- Description : This writes out each character in the buffer to the
- appropriate internal uart channel waiting till each one is sucessfully
+ Description : This writes out each character in the buffer to the
+ appropriate internal uart channel waiting till each one is sucessfully
transmitted.
***************************************************************************/
static ssize_t IntUartPollWrite(int minor, const char *buf, size_t len)
@@ -562,7 +562,7 @@ rtems_device_driver console_initialize(rtems_device_major_number major,
/***************************************************************************
Function : console_open
- Description : This actually opens the device depending on the minor
+ Description : This actually opens the device depending on the minor
number set during initialisation. The device specific access routines are
passed to termios when the devices is opened depending on whether it is
polled or not.
@@ -631,8 +631,10 @@ rtems_device_driver console_open(rtems_device_major_number major,
struct termios term;
if (tcgetattr(STDIN_FILENO, &term) >= 0) {
- term.c_cflag &= ~(CBAUD | CSIZE);
- term.c_cflag |= CS8 | B115200;
+ term.c_cflag &= ~(CSIZE);
+ term.c_cflag |= CS8;
+ term.c_ispeed = B115200;
+ term.c_ospeed = B115200;
tcsetattr(STDIN_FILENO, TCSANOW, &term);
}
}
diff --git a/c/src/lib/libbsp/m68k/mcf5235/console/console.c b/c/src/lib/libbsp/m68k/mcf5235/console/console.c
index 3f50b6adac..6fd92aa557 100644
--- a/c/src/lib/libbsp/m68k/mcf5235/console/console.c
+++ b/c/src/lib/libbsp/m68k/mcf5235/console/console.c
@@ -174,7 +174,7 @@ IntUartSetAttributes(int minor, const struct termios *t)
if ( t != (const struct termios *)0 )
{
/* determine baud rate index */
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
/* determine data bits */
switch ( t->c_cflag & CSIZE )
@@ -681,8 +681,10 @@ rtems_device_driver console_open(
struct termios term;
if (tcgetattr (STDIN_FILENO, &term) >= 0)
{
- term.c_cflag &= ~(CBAUD | CSIZE);
- term.c_cflag |= CS8 | B19200;
+ term.c_cflag &= ~(CSIZE);
+ term.c_cflag |= CS8;
+ term.c_ispeed = B19200;
+ term.c_ospeed = B19200;
tcsetattr (STDIN_FILENO, TCSANOW, &term);
}
}
diff --git a/c/src/lib/libbsp/m68k/mcf5329/console/console.c b/c/src/lib/libbsp/m68k/mcf5329/console/console.c
index dfae857533..ba4a7d981a 100644
--- a/c/src/lib/libbsp/m68k/mcf5329/console/console.c
+++ b/c/src/lib/libbsp/m68k/mcf5329/console/console.c
@@ -170,7 +170,7 @@ static int IntUartSetAttributes(int minor, const struct termios *t)
/* check to see if input is valid */
if (t != (const struct termios *) 0) {
/* determine baud rate index */
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
/* determine data bits */
switch (t->c_cflag & CSIZE) {
@@ -613,8 +613,10 @@ rtems_device_driver console_open(rtems_device_major_number major,
struct termios term;
if (tcgetattr(STDIN_FILENO, &term) >= 0) {
- term.c_cflag &= ~(CBAUD | CSIZE);
- term.c_cflag |= CS8 | B19200;
+ term.c_cflag &= ~(CSIZE);
+ term.c_cflag |= CS8;
+ term.c_ispeed = B19200;
+ term.c_ospeed = B19200;
tcsetattr(STDIN_FILENO, TCSANOW, &term);
}
}
diff --git a/c/src/lib/libbsp/m68k/mrm332/console/sci.c b/c/src/lib/libbsp/m68k/mrm332/console/sci.c
index a0f8cc0820..1e92d6d774 100644
--- a/c/src/lib/libbsp/m68k/mrm332/console/sci.c
+++ b/c/src/lib/libbsp/m68k/mrm332/console/sci.c
@@ -675,7 +675,7 @@ int SciSetAttributes(
/* if you look closely you will see this is the only thing we use */
/* set the baud rate */
- baud_requested = t->c_cflag & CBAUD; /* baud rate */
+ baud_requested = t->c_ospeed; /* baud rate */
if (!baud_requested)
{
diff --git a/c/src/lib/libbsp/m68k/mvme167/console/console.c b/c/src/lib/libbsp/m68k/mvme167/console/console.c
index 9ac8f7076f..3b7aecb541 100644
--- a/c/src/lib/libbsp/m68k/mvme167/console/console.c
+++ b/c/src/lib/libbsp/m68k/mvme167/console/console.c
@@ -725,7 +725,7 @@ int cd2401_firstOpen(
* We could have made a tcgetattr() call if we had our fd.
*/
newarg.iop = args->iop;
- newarg.command = RTEMS_IO_GET_ATTRIBUTES;
+ newarg.command = TIOCGETA;
newarg.buffer = &termios;
sc = rtems_termios_ioctl (&newarg);
if (sc != RTEMS_SUCCESSFUL)
@@ -738,7 +738,7 @@ int cd2401_firstOpen(
* on the ttyMutex that it already owns; this is safe in RTEMS.
*/
termios.c_cflag |= CLOCAL; /* Ignore modem status lines */
- newarg.command = RTEMS_IO_SET_ATTRIBUTES;
+ newarg.command = TIOCGETA;
sc = rtems_termios_ioctl (&newarg);
if (sc != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred (sc);
@@ -844,8 +844,8 @@ int cd2401_setAttributes(
/* Determine what the line parameters should be */
/* baud rates */
- out_baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
- in_baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ out_baud = rtems_termios_baud_to_number(t->c_ospeed);
+ in_baud = rtems_termios_baud_to_number(t->c_ispeed);
/* Number of bits per char */
csize = 0x07; /* to avoid a warning */
diff --git a/c/src/lib/libbsp/m68k/uC5282/console/console.c b/c/src/lib/libbsp/m68k/uC5282/console/console.c
index 0f08cea94f..e2c29c0914 100644
--- a/c/src/lib/libbsp/m68k/uC5282/console/console.c
+++ b/c/src/lib/libbsp/m68k/uC5282/console/console.c
@@ -190,7 +190,7 @@ IntUartSetAttributes(int minor, const struct termios *t)
if ( t != (const struct termios *)0 )
{
/* determine baud rate index */
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
/* determine data bits */
switch ( t->c_cflag & CSIZE )
@@ -447,7 +447,7 @@ IntUartInterruptOpen(int major, int minor, void *arg)
MCF5282_GPIO_PUAPAR |= MCF5282_GPIO_PUAPAR_PUAPA3|MCF5282_GPIO_PUAPAR_PUAPA2;
break;
case 2:
- MCF5282_GPIO_PASPAR =
+ MCF5282_GPIO_PASPAR =
(MCF5282_GPIO_PASPAR
& ~(MCF5282_GPIO_PASPAR_PASPA3(3)|MCF5282_GPIO_PASPAR_PASPA2(3)))
| (MCF5282_GPIO_PASPAR_PASPA3(2)|MCF5282_GPIO_PASPAR_PASPA2(2));
diff --git a/c/src/lib/libbsp/powerpc/acinclude.m4 b/c/src/lib/libbsp/powerpc/acinclude.m4
index 4c83475dd8..edc67b5414 100644
--- a/c/src/lib/libbsp/powerpc/acinclude.m4
+++ b/c/src/lib/libbsp/powerpc/acinclude.m4
@@ -32,12 +32,12 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
AC_CONFIG_SUBDIRS([t32mppc]);;
tqm8xx )
AC_CONFIG_SUBDIRS([tqm8xx]);;
- virtex )
- AC_CONFIG_SUBDIRS([virtex]);;
virtex4 )
AC_CONFIG_SUBDIRS([virtex4]);;
virtex5 )
AC_CONFIG_SUBDIRS([virtex5]);;
+ virtex )
+ AC_CONFIG_SUBDIRS([virtex]);;
*)
AC_MSG_ERROR([Invalid BSP]);;
esac
diff --git a/c/src/lib/libbsp/powerpc/gen5200/console/console.c b/c/src/lib/libbsp/powerpc/gen5200/console/console.c
index 26f5558a91..754a52789a 100644
--- a/c/src/lib/libbsp/powerpc/gen5200/console/console.c
+++ b/c/src/lib/libbsp/powerpc/gen5200/console/console.c
@@ -192,7 +192,7 @@ static int mpc5200_psc_setAttributes(
(struct mpc5200_psc *)(&mpc5200.psc[psc_minor_to_regset[minor]]);
/* Baud rate */
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
if (baud > 0) {
/*
* Calculate baud rate
diff --git a/c/src/lib/libbsp/powerpc/shared/console/console.c b/c/src/lib/libbsp/powerpc/shared/console/console.c
index 082cbd9e17..f275683cc2 100644
--- a/c/src/lib/libbsp/powerpc/shared/console/console.c
+++ b/c/src/lib/libbsp/powerpc/shared/console/console.c
@@ -304,7 +304,7 @@ static int conSetAttr(
{
rtems_termios_baud_t baud;
- baud = rtems_termios_baud_to_number(t->c_cflag & CBAUD);
+ baud = rtems_termios_baud_to_number(t->c_ospeed);
if ( baud > 115200 )
rtems_fatal_error_occurred (RTEMS_INTERNAL_ERROR);
diff --git a/c/src/lib/libbsp/powerpc/tqm8xx/console/console.c b/c/src/lib/libbsp/powerpc/tqm8xx/console/console.c
index e0b4c70677..e109303f18 100644
--- a/c/src/lib/libbsp/powerpc/tqm8xx/console/console.c
+++ b/c/src/lib/libbsp/powerpc/tqm8xx/console/console.c
@@ -392,7 +392,7 @@ sccSetAttributes (int minor, const struct termios *t)
{
int baud;
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
diff --git a/c/src/lib/libbsp/shared/console.c b/c/src/lib/libbsp/shared/console.c
index b4af1b389a..b8a078fe52 100644
--- a/c/src/lib/libbsp/shared/console.c
+++ b/c/src/lib/libbsp/shared/console.c
@@ -244,12 +244,12 @@ rtems_device_driver console_open(
* If this is not the console we do not want ECHO and so forth
*/
IoctlArgs.iop = args->iop;
- IoctlArgs.command = RTEMS_IO_GET_ATTRIBUTES;
+ IoctlArgs.command = TIOCGETA;
IoctlArgs.buffer = &Termios;
rtems_termios_ioctl( &IoctlArgs );
Termios.c_lflag = ICANON;
- IoctlArgs.command = RTEMS_IO_SET_ATTRIBUTES;
+ IoctlArgs.command = TIOCSETA;
rtems_termios_ioctl( &IoctlArgs );
}
}
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
index 50805f1ed3..c2beaeae02 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
@@ -39,7 +39,7 @@
#ifdef DEBUG
#define DBG(x...) printk(x)
#else
-#define DBG(x...)
+#define DBG(x...)
#endif
/* LEON3 Low level transmit/receive functions provided by debug-uart code */
@@ -85,7 +85,7 @@ static int apbuart_info(
#define APBUART_INFO_FUNC NULL
#endif
-struct drvmgr_drv_ops apbuart_ops =
+struct drvmgr_drv_ops apbuart_ops =
{
.init = {apbuart_init1, NULL, NULL, NULL},
.remove = NULL,
@@ -567,7 +567,7 @@ int apbuart_set_attributes(int minor, const struct termios *t)
uart->regs->ctrl = ctrl;
/* Baud rate */
- baud = apbuart_baud_num2baud(t->c_cflag & CBAUD);
+ baud = apbuart_baud_num2baud(t->c_ospeed);
if (baud > 0){
/* Get APBUART core frequency */
drvmgr_freq_get(uart->dev, DEV_APB_SLV, &core_clk_hz);
@@ -588,7 +588,7 @@ void apbuart_get_attributes(struct console_dev *condev, struct termios *t)
unsigned int ctrl;
struct apbuart_baud *baud;
- t->c_cflag = t->c_cflag & ~(CSIZE|PARENB|PARODD|CLOCAL|CBAUD);
+ t->c_cflag = t->c_cflag & ~(CSIZE|PARENB|PARODD|CLOCAL);
/* Hardware support only CS8 */
t->c_cflag |= CS8;
diff --git a/c/src/lib/libcpu/arm/at91rm9200/usart/usart.c b/c/src/lib/libcpu/arm/at91rm9200/usart/usart.c
index c552899126..23b877ce64 100644
--- a/c/src/lib/libcpu/arm/at91rm9200/usart/usart.c
+++ b/c/src/lib/libcpu/arm/at91rm9200/usart/usart.c
@@ -240,7 +240,7 @@ static int usart_set_attributes(int minor, const struct termios *t)
} else
mode |= US_MR_PAR_NONE;
- baud_requested = t->c_cflag & CBAUD;
+ baud_requested = t->c_ospeed;
/* If not, set the dbgu console baud as USART baud default */
if (!baud_requested)
diff --git a/c/src/lib/libcpu/arm/s3c24xx/include/s3c2400.h b/c/src/lib/libcpu/arm/s3c24xx/include/s3c2400.h
index 092dcffe5c..89a3cf73d8 100644
--- a/c/src/lib/libcpu/arm/s3c24xx/include/s3c2400.h
+++ b/c/src/lib/libcpu/arm/s3c24xx/include/s3c2400.h
@@ -554,7 +554,7 @@ typedef union {
/* 01 = BACK Porch. */
/* 10 = ACTIVE */
/* 11 = FRONT Porch */
- unsigned VSTATUS:2; /* TFT: Vertical Status (Read only). */
+ unsigned _VSTATUS:2; /* TFT: Vertical Status (Read only). */
/* 00 = VSYNC */
/* 01 = BACK Porch. */
/* 10 = ACTIVE */
diff --git a/c/src/lib/libcpu/arm/s3c24xx/include/s3c2410.h b/c/src/lib/libcpu/arm/s3c24xx/include/s3c2410.h
index d11bcf9d21..c6a0a0b452 100644
--- a/c/src/lib/libcpu/arm/s3c24xx/include/s3c2410.h
+++ b/c/src/lib/libcpu/arm/s3c24xx/include/s3c2410.h
@@ -702,7 +702,7 @@ typedef union {
/* 01 = BACK Porch. */
/* 10 = ACTIVE */
/* 11 = FRONT Porch */
- unsigned VSTATUS:2; /* TFT: Vertical Status (Read only). */
+ unsigned _VSTATUS:2; /* TFT: Vertical Status (Read only). */
/* 00 = VSYNC */
/* 01 = BACK Porch. */
/* 10 = ACTIVE */
diff --git a/c/src/lib/libcpu/bfin/serial/uart.c b/c/src/lib/libcpu/bfin/serial/uart.c
index 79f09415c4..617c59dab3 100644
--- a/c/src/lib/libcpu/bfin/serial/uart.c
+++ b/c/src/lib/libcpu/bfin/serial/uart.c
@@ -9,7 +9,7 @@
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
-
+
#include <rtems.h>
#include <rtems/libio.h>
#include <rtems/termiostypes.h>
@@ -159,7 +159,7 @@ static int setAttributes(int minor, const struct termios *termios)
uint16_t lcr;
base = uartsConfig->channels[minor].uart_baseAddress;
- switch (termios->c_cflag & CBAUD) {
+ switch (termios->c_ospeed) {
case B0: baud = 0; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
diff --git a/c/src/lib/libcpu/powerpc/mpc55xx/esci/esci.c b/c/src/lib/libcpu/powerpc/mpc55xx/esci/esci.c
index f8101d7920..a500743bcd 100644
--- a/c/src/lib/libcpu/powerpc/mpc55xx/esci/esci.c
+++ b/c/src/lib/libcpu/powerpc/mpc55xx/esci/esci.c
@@ -362,7 +362,7 @@ static int mpc55xx_esci_termios_set_attributes( int minor, const struct termios
cr1.B.TE = 1;
/* Baud rate */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
case B50: br = 50; break;
case B75: br = 75; break;
case B110: br = 110; break;
diff --git a/c/src/lib/libcpu/powerpc/mpc5xx/console-generic/console-generic.c b/c/src/lib/libcpu/powerpc/mpc5xx/console-generic/console-generic.c
index 22fee2d719..c1de9c5020 100644
--- a/c/src/lib/libcpu/powerpc/mpc5xx/console-generic/console-generic.c
+++ b/c/src/lib/libcpu/powerpc/mpc5xx/console-generic/console-generic.c
@@ -190,7 +190,7 @@ m5xx_uart_setAttributes(
return RTEMS_INVALID_NUMBER;
/* Baud rate */
- baud = rtems_termios_baud_to_number( t->c_cflag & CBAUD );
+ baud = rtems_termios_baud_to_number( t->c_ospeed );
if (baud > 0) {
sccr0 &= ~QSMCM_SCI_BAUD(-1);
sccr0 |= QSMCM_SCI_BAUD((bsp_clock_speed + (16 * baud)) / (32 * baud));
diff --git a/c/src/lib/libcpu/powerpc/mpc8260/console-generic/console-generic.c b/c/src/lib/libcpu/powerpc/mpc8260/console-generic/console-generic.c
index e325acc3f1..4bfb6407eb 100644
--- a/c/src/lib/libcpu/powerpc/mpc8260/console-generic/console-generic.c
+++ b/c/src/lib/libcpu/powerpc/mpc8260/console-generic/console-generic.c
@@ -108,7 +108,7 @@ m8xx_smc_set_attributes (int minor, const struct termios *t)
uint16_t clen=0, cstopb, parenb, parodd, cread;
/* Baud rate */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
@@ -221,7 +221,7 @@ m8xx_scc_set_attributes (int minor, const struct termios *t)
uint16_t csize=0, cstopb, parenb, parodd;
/* Baud rate */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
diff --git a/c/src/lib/libcpu/powerpc/mpc8xx/console-generic/console-generic.c b/c/src/lib/libcpu/powerpc/mpc8xx/console-generic/console-generic.c
index d7fd8b4dc5..e015a6497b 100644
--- a/c/src/lib/libcpu/powerpc/mpc8xx/console-generic/console-generic.c
+++ b/c/src/lib/libcpu/powerpc/mpc8xx/console-generic/console-generic.c
@@ -175,7 +175,7 @@ m8xx_smc_set_attributes (int minor, const struct termios *t)
uint16_t clen=0, cstopb, parenb, parodd, cread;
/* Baud rate */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
@@ -271,7 +271,7 @@ m8xx_scc_set_attributes (int minor, const struct termios *t)
uint16_t csize=0, cstopb, parenb, parodd;
/* Baud rate */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
diff --git a/c/src/lib/libcpu/powerpc/ppc403/console/console.c b/c/src/lib/libcpu/powerpc/ppc403/console/console.c
index 0e74879947..0e0bbd7fef 100644
--- a/c/src/lib/libcpu/powerpc/ppc403/console/console.c
+++ b/c/src/lib/libcpu/powerpc/ppc403/console/console.c
@@ -224,7 +224,7 @@ spiSetAttributes (int minor, const struct termios *t)
/* FIXME: check c_cflag & CRTSCTS for hardware flowcontrol */
/* FIXME: check and IMPLEMENT XON/XOFF */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
diff --git a/c/src/lib/libcpu/powerpc/ppc403/console/console405.c b/c/src/lib/libcpu/powerpc/ppc403/console/console405.c
index cf936581c2..96c3534a75 100644
--- a/c/src/lib/libcpu/powerpc/ppc403/console/console405.c
+++ b/c/src/lib/libcpu/powerpc/ppc403/console/console405.c
@@ -216,7 +216,7 @@ spiSetAttributes (int minor, const struct termios *t)
/* FIXME: check c_cflag & CRTSCTS for hardware flowcontrol */
/* FIXME: check and IMPLEMENT XON/XOFF */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
diff --git a/c/src/lib/libcpu/powerpc/ppc403/tty_drv/tty_drv.c b/c/src/lib/libcpu/powerpc/ppc403/tty_drv/tty_drv.c
index 1d7b0135bd..3e79bbf9e4 100644
--- a/c/src/lib/libcpu/powerpc/ppc403/tty_drv/tty_drv.c
+++ b/c/src/lib/libcpu/powerpc/ppc403/tty_drv/tty_drv.c
@@ -181,7 +181,7 @@ tty0SetAttributes (int minor, const struct termios *t)
/* FIXME: check c_cflag & CRTSCTS for hardware flow control */
/* FIXME: check and IMPLEMENT XON/XOFF */
- switch (t->c_cflag & CBAUD) {
+ switch (t->c_ospeed) {
default: baud = -1; break;
case B50: baud = 50; break;
case B75: baud = 75; break;
diff --git a/c/src/lib/libcpu/sh/sh7032/sci/sci.c b/c/src/lib/libcpu/sh/sh7032/sci/sci.c
index c9db0fec73..04d9ca5c70 100644
--- a/c/src/lib/libcpu/sh/sh7032/sci/sci.c
+++ b/c/src/lib/libcpu/sh/sh7032/sci/sci.c
@@ -46,29 +46,31 @@ struct scidev_t {
rtems_device_minor_number minor ;
unsigned short opened ;
tcflag_t cflags ;
+ speed_t spd ;
} sci_device[SCI_MINOR_DEVICES] =
{
- { "/dev/sci0", SH_SCI_BASE_0, 0, 0, B9600 | CS8 },
- { "/dev/sci1", SH_SCI_BASE_1, 1, 0, B9600 | CS8 }
+ { "/dev/sci0", SH_SCI_BASE_0, 0, 0, CS8, B9600 },
+ { "/dev/sci1", SH_SCI_BASE_1, 1, 0, CS8, B9600 }
} ;
/* imported from scitab.rel */
extern int _sci_get_brparms(
- tcflag_t cflag,
+ speed_t spd,
unsigned char *smr,
unsigned char *brr );
/* Translate termios' tcflag_t into sci settings */
static int _sci_set_cflags(
struct scidev_t *sci_dev,
- tcflag_t c_cflag )
+ tcflag_t c_cflag,
+ speed_t spd )
{
uint8_t smr ;
uint8_t brr ;
- if ( c_cflag & CBAUD )
+ if ( spd )
{
- if ( _sci_get_brparms( c_cflag, &smr, &brr ) != 0 )
+ if ( _sci_get_brparms( spd, &smr, &brr ) != 0 )
return -1 ;
}
@@ -239,7 +241,7 @@ rtems_device_driver sh_sci_open(
temp8 = read8(sci_device[minor].addr + SCI_SCR);
temp8 &= ~(SCI_TE | SCI_RE) ;
write8(temp8, sci_device[minor].addr + SCI_SCR); /* Clear SCR */
- _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags );
+ _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags, sci_device[minor].spd );
/* FIXME: Should be one bit delay */
CPU_delay(50000); /* microseconds */
@@ -250,7 +252,7 @@ rtems_device_driver sh_sci_open(
temp8 = read8(sci_device[minor].addr + SCI_SCR);
temp8 &= ~(SCI_TE | SCI_RE) ;
write8(temp8, sci_device[minor].addr + SCI_SCR); /* Clear SCR */
- _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags );
+ _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags, sci_device[minor].spd );
/* FIXME: Should be one bit delay */
CPU_delay(50000); /* microseconds */
diff --git a/c/src/lib/libcpu/sh/sh7045/sci/sci.c b/c/src/lib/libcpu/sh/sh7045/sci/sci.c
index 690035a687..143fc1bb94 100644
--- a/c/src/lib/libcpu/sh/sh7045/sci/sci.c
+++ b/c/src/lib/libcpu/sh/sh7045/sci/sci.c
@@ -72,9 +72,9 @@
#define SH_SCI_BASE_0 SCI_SMR0
#define SH_SCI_BASE_1 SCI_SMR1
-#define SH_SCI_DEF_COMM_0 B9600 | CS8
-#define SH_SCI_DEF_COMM_1 B38400 | CS8
-/* #define SH_SCI_DEF_COMM_1 B9600 | CS8 */
+#define SH_SCI_DEF_COMM_0 CS8, B9600
+#define SH_SCI_DEF_COMM_1 CS8, B38400
+/* #define SH_SCI_DEF_COMM_1 CS8, B9600 */
struct scidev_t {
char * name;
@@ -82,6 +82,7 @@ struct scidev_t {
rtems_device_minor_number minor;
unsigned short opened;
tcflag_t cflags;
+ speed_t spd;
} sci_device[SCI_MINOR_DEVICES] =
{
{ "/dev/sci0", SH_SCI_BASE_0, 0, 0, SH_SCI_DEF_COMM_0 },
@@ -96,15 +97,16 @@ static sci_setup_t sio_param[2];
/* Translate termios' tcflag_t into sci settings */
static int _sci_set_cflags(
struct scidev_t *sci_dev,
- tcflag_t c_cflag
+ tcflag_t c_cflag,
+ speed_t spd
)
{
uint8_t smr;
uint8_t brr;
- if ( c_cflag & CBAUD )
+ if ( spd )
{
- if ( _sci_get_brparms( c_cflag, &smr, &brr ) != 0 )
+ if ( _sci_get_brparms( spd, &smr, &brr ) != 0 )
return -1;
}
@@ -351,7 +353,7 @@ rtems_device_driver sh_sci_open(
/* set up SCI registers */
write8(0x00, sci_device[minor].addr + SCI_SCR); /* Clear SCR */
/* set SMR and BRR */
- _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags );
+ _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags, sci_device[minor].spd );
for (a=0; a < 10000L; a++) { /* Delay */
__asm__ volatile ("nop");
@@ -526,7 +528,7 @@ static ssize_t _sh_sci_poll_write(int minor, const char *buf, size_t len)
*/
static int _sh_sci_set_attributes( int minor, const struct termios *t)
{
- return _sci_set_cflags( &sci_device[ minor ], t->c_cflag);
+ return _sci_set_cflags( &sci_device[ minor ], t->c_cflag, t->c_ospeed);
}
diff --git a/c/src/lib/libcpu/sh/sh7045/sci/sci_termios.c b/c/src/lib/libcpu/sh/sh7045/sci/sci_termios.c
index db9040e409..5d588065af 100644
--- a/c/src/lib/libcpu/sh/sh7045/sci/sci_termios.c
+++ b/c/src/lib/libcpu/sh/sh7045/sci/sci_termios.c
@@ -59,7 +59,7 @@
* Automatically generated function imported from scitab.rel
*/
extern int _sci_get_brparms(
- tcflag_t cflag,
+ speed_t spd,
unsigned char *smr,
unsigned char *brr
);
@@ -77,9 +77,10 @@ int sh_sci_set_attributes(
int a;
tcflag_t c_cflag = t->c_cflag;
+ speed_t spd = t->c_ospeed;
- if ( c_cflag & CBAUD ) {
- if ( _sci_get_brparms( c_cflag, &smr, &brr ) != 0 )
+ if ( spd ) {
+ if ( _sci_get_brparms( spd, &smr, &brr ) != 0 )
return -1 ;
}
diff --git a/c/src/libchip/serial/mc68681.c b/c/src/libchip/serial/mc68681.c
index 52e92d5650..f4ddbd6a50 100644
--- a/c/src/libchip/serial/mc68681.c
+++ b/c/src/libchip/serial/mc68681.c
@@ -581,7 +581,7 @@ MC68681_STATIC int mc68681_baud_rate(
break;
}
- baud_requested = baud & CBAUD;
+ baud_requested = baud;
if (!baud_requested)
baud_requested = B9600; /* default to 9600 baud */
diff --git a/c/src/libchip/serial/mc68681_baud.c b/c/src/libchip/serial/mc68681_baud.c
index a27e6c95f6..0f8e87c2c2 100644
--- a/c/src/libchip/serial/mc68681_baud.c
+++ b/c/src/libchip/serial/mc68681_baud.c
@@ -30,10 +30,15 @@ mc68681_baud_t mc68681_baud_rate_table[4][RTEMS_TERMIOS_NUMBER_BAUD_RATES] = {
0x0B, /* B9600 */
MC68681_BAUD_NOT_VALID, /* B19200 */
0x0C, /* B38400 */
+ MC68681_BAUD_NOT_VALID, /* B7200 */
+ MC68681_BAUD_NOT_VALID, /* B14400 */
+ MC68681_BAUD_NOT_VALID, /* B28800 */
MC68681_BAUD_NOT_VALID, /* B57600 */
+ MC68681_BAUD_NOT_VALID, /* B76800 */
MC68681_BAUD_NOT_VALID, /* B115200 */
MC68681_BAUD_NOT_VALID, /* B230400 */
- MC68681_BAUD_NOT_VALID /* B460800 */
+ MC68681_BAUD_NOT_VALID, /* B460800 */
+ MC68681_BAUD_NOT_VALID /* B921600 */
},
{ /* ACR[7] = 1, X = 0 */
MC68681_BAUD_NOT_VALID, /* B0 */
@@ -52,10 +57,15 @@ mc68681_baud_t mc68681_baud_rate_table[4][RTEMS_TERMIOS_NUMBER_BAUD_RATES] = {
0x0B, /* B9600 */
0x0C, /* B19200 */
MC68681_BAUD_NOT_VALID, /* B38400 */
+ MC68681_BAUD_NOT_VALID, /* B7200 */
+ MC68681_BAUD_NOT_VALID, /* B14400 */
+ MC68681_BAUD_NOT_VALID, /* B28800 */
MC68681_BAUD_NOT_VALID, /* B57600 */
+ MC68681_BAUD_NOT_VALID, /* B76800 */
MC68681_BAUD_NOT_VALID, /* B115200 */
MC68681_BAUD_NOT_VALID, /* B230400 */
- MC68681_BAUD_NOT_VALID /* B460800 */
+ MC68681_BAUD_NOT_VALID, /* B460800 */
+ MC68681_BAUD_NOT_VALID /* B921600 */
},
{ /* ACR[7] = 0, X = 1 */
MC68681_BAUD_NOT_VALID, /* B0 */
@@ -74,10 +84,15 @@ mc68681_baud_t mc68681_baud_rate_table[4][RTEMS_TERMIOS_NUMBER_BAUD_RATES] = {
0x0B, /* B9600 */
0x0C, /* B19200 */
MC68681_BAUD_NOT_VALID, /* B38400 */
+ MC68681_BAUD_NOT_VALID, /* B7200 */
+ MC68681_BAUD_NOT_VALID, /* B14400 */
+ MC68681_BAUD_NOT_VALID, /* B28800 */
0x07, /* B57600 */
+ MC68681_BAUD_NOT_VALID, /* B76800 */
0x08, /* B115200 */
MC68681_BAUD_NOT_VALID, /* B230400 */
- MC68681_BAUD_NOT_VALID /* B460800 */
+ MC68681_BAUD_NOT_VALID, /* B460800 */
+ MC68681_BAUD_NOT_VALID /* B921600 */
},
{ /* ACR[7] = 1, X = 1 */
MC68681_BAUD_NOT_VALID, /* B0 */
@@ -96,9 +111,14 @@ mc68681_baud_t mc68681_baud_rate_table[4][RTEMS_TERMIOS_NUMBER_BAUD_RATES] = {
0x0B, /* B9600 */
MC68681_BAUD_NOT_VALID, /* B19200 */
0x0C, /* B38400 */
+ MC68681_BAUD_NOT_VALID, /* B7200 */
+ MC68681_BAUD_NOT_VALID, /* B14400 */
+ MC68681_BAUD_NOT_VALID, /* B28800 */
0x07, /* B57600 */
+ MC68681_BAUD_NOT_VALID, /* B76800 */
0x08, /* B115200 */
MC68681_BAUD_NOT_VALID, /* B230400 */
- MC68681_BAUD_NOT_VALID /* B460800 */
+ MC68681_BAUD_NOT_VALID, /* B460800 */
+ MC68681_BAUD_NOT_VALID /* B921600 */
},
};
diff --git a/c/src/libchip/serial/z85c30.c b/c/src/libchip/serial/z85c30.c
index 7c55a513f7..55df9d3451 100644
--- a/c/src/libchip/serial/z85c30.c
+++ b/c/src/libchip/serial/z85c30.c
@@ -449,7 +449,7 @@ Z85C30_STATIC int z85c30_set_attributes(
* Assert ensures there is no division by 0.
*/
- baud_requested = t->c_cflag & CBAUD;
+ baud_requested = t->c_ospeed;
if (!baud_requested)
baud_requested = B9600; /* default to 9600 baud */
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index 43d34c4a23..14b3b5ad45 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -54,7 +54,7 @@ TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \
src/tcsetpgrp.c src/termios.c src/termiosinitialize.c \
src/termios_baud2index.c src/termios_baud2num.c src/termios_num2baud.c \
src/termios_setinitialbaud.c src/termios_baudtable.c src/cfsetspeed.c \
- src/cfmakeraw.c src/termios_setbestbaud.c
+ src/cfmakeraw.c src/cfmakesane.c src/termios_setbestbaud.c
SYSTEM_CALL_C_FILES = src/open.c src/close.c src/read.c src/write.c \
src/write_r.c \
diff --git a/cpukit/libcsupport/include/rtems/termiostypes.h b/cpukit/libcsupport/include/rtems/termiostypes.h
index 5240b85106..f68de0c12f 100644
--- a/cpukit/libcsupport/include/rtems/termiostypes.h
+++ b/cpukit/libcsupport/include/rtems/termiostypes.h
@@ -527,7 +527,7 @@ extern const rtems_assoc_t rtems_termios_baud_table [];
* @retval B0 Invalid baud value or a baud value of 0.
* @retval other Baud constant according to @a baud.
*/
-tcflag_t rtems_termios_number_to_baud(rtems_termios_baud_t baud);
+speed_t rtems_termios_number_to_baud(rtems_termios_baud_t baud);
/**
* @brief Convert Baud Part of Termios control flags to an integral Baud Value
@@ -537,10 +537,10 @@ tcflag_t rtems_termios_number_to_baud(rtems_termios_baud_t baud);
* @retval 0 Invalid baud value or a baud value of @c B0.
* @retval other Integral baud value.
*/
-rtems_termios_baud_t rtems_termios_baud_to_number(tcflag_t c_cflag);
+rtems_termios_baud_t rtems_termios_baud_to_number(speed_t c_cflag);
-/**
- * @brief Convert Bxxx Constant to Index
+/**
+ * @brief Convert Bxxx Constant to Index
*/
int rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud);
diff --git a/cpukit/libcsupport/include/sys/_termios.h b/cpukit/libcsupport/include/sys/_termios.h
new file mode 100644
index 0000000000..32d9b2481c
--- /dev/null
+++ b/cpukit/libcsupport/include/sys/_termios.h
@@ -0,0 +1,264 @@
+/*-
+ * Copyright (c) 1988, 1989, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)termios.h 8.3 (Berkeley) 3/28/94
+ * $FreeBSD: head/sys/sys/_termios.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _SYS__TERMIOS_H_
+#define _SYS__TERMIOS_H_
+
+/*
+ * Special Control Characters
+ *
+ * Index into c_cc[] character array.
+ *
+ * Name Subscript Enabled by
+ */
+#define VEOF 0 /* ICANON */
+#define VEOL 1 /* ICANON */
+#if !_POSIX_SOURCE || __rtems__
+#define VEOL2 2 /* ICANON together with IEXTEN */
+#endif
+#define VERASE 3 /* ICANON */
+#if !_POSIX_SOURCE || __rtems__
+#define VWERASE 4 /* ICANON together with IEXTEN */
+#endif
+#define VKILL 5 /* ICANON */
+#if !_POSIX_SOURCE || __rtems__
+#define VREPRINT 6 /* ICANON together with IEXTEN */
+#define VERASE2 7 /* ICANON */
+#endif
+/* 7 ex-spare 1 */
+#define VINTR 8 /* ISIG */
+#define VQUIT 9 /* ISIG */
+#define VSUSP 10 /* ISIG */
+#if !_POSIX_SOURCE || __rtems__
+#define VDSUSP 11 /* ISIG together with IEXTEN */
+#endif
+#define VSTART 12 /* IXON, IXOFF */
+#define VSTOP 13 /* IXON, IXOFF */
+#if !_POSIX_SOURCE || __rtems__
+#define VLNEXT 14 /* IEXTEN */
+#define VDISCARD 15 /* IEXTEN */
+#endif
+#define VMIN 16 /* !ICANON */
+#define VTIME 17 /* !ICANON */
+#if !_POSIX_SOURCE || __rtems__
+#define VSTATUS 18 /* ICANON together with IEXTEN */
+/* 19 spare 2 */
+#endif
+#define NCCS 20
+
+#define _POSIX_VDISABLE 0xff
+
+/*
+ * Input flags - software input processing
+ */
+#define IGNBRK 0x00000001 /* ignore BREAK condition */
+#define BRKINT 0x00000002 /* map BREAK to SIGINTR */
+#define IGNPAR 0x00000004 /* ignore (discard) parity errors */
+#define PARMRK 0x00000008 /* mark parity and framing errors */
+#define INPCK 0x00000010 /* enable checking of parity errors */
+#define ISTRIP 0x00000020 /* strip 8th bit off chars */
+#define INLCR 0x00000040 /* map NL into CR */
+#define IGNCR 0x00000080 /* ignore CR */
+#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
+#define IXON 0x00000200 /* enable output flow control */
+#define IXOFF 0x00000400 /* enable input flow control */
+#if !_POSIX_SOURCE || __rtems__
+#define IXANY 0x00000800 /* any char will restart after stop */
+#define IMAXBEL 0x00002000 /* ring bell on input queue full */
+#endif /*_POSIX_SOURCE */
+#ifdef __rtems__
+#define IUCLC 0x00004000 /* map upper case to lower case on input */
+#endif /* __rtems__ */
+/*
+ * Output flags - software output processing
+ */
+#define OPOST 0x00000001 /* enable following output processing */
+#if !_POSIX_SOURCE || __rtems__
+#define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
+#ifndef __rtems__
+#define TABDLY 0x00000004 /* tab delay mask */
+#define TAB0 0x00000000 /* no tab delay and expansion */
+#define TAB3 0x00000004 /* expand tabs to spaces */
+#define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */
+#define OCRNL 0x00000010 /* map CR to NL on output */
+#define ONOCR 0x00000020 /* no CR output at column 0 */
+#define ONLRET 0x00000040 /* NL performs CR function */
+#else /* __rtems__ */
+#define TABDLY 0x0000000C /* tab delay mask */
+#define TAB0 0x00000000 /* no tab delay and expansion */
+#define TAB1 0x00000004
+#define TAB2 0x00000008
+#define TAB3 0x0000000C /* expand tabs to spaces */
+#define XTABS 0x0000000C
+#define ONOEOT 0x00000010 /* discard EOT's (^D) on output) */
+#define OCRNL 0x00000020 /* map CR to NL on output */
+#define ONOCR 0x00000040 /* no CR output at column 0 */
+#define ONLRET 0x00000080 /* NL performs CR function */
+#define OLCUC 0x00000100 /* map lower case to upper case on output */
+#define OFILL 0x00000200 /* send fill characters for a delay, rather than using a timed delay */
+#define OFDEL 0x00000400 /* fill character is ASCII DEL (0177). if unset, fill character is ASCII NUL ('\0') */
+#define NLDLY 0x00000800 /* newline delay mask */
+#define NL0 0x00000000
+#define NL1 0x00000800
+#define CRDLY 0x00003000 /* carriage return delay mask */
+#define CR0 0x00000000
+#define CR1 0x00001000
+#define CR2 0x00002000
+#define CR3 0x00003000
+#define BSDLY 0x00004000 /* Backspace delay mask */
+#define BS0 0x00000000
+#define BS1 0x00004000
+#define VTDLY 0x00008000 /* Vertical tab delay mask */
+#define VT0 0x00000000
+#define VT1 0x00008000
+#define FFDLY 0x00010000 /* Form feed delay mask */
+#define FF0 0x00000000
+#define FF1 0x00010000
+#endif /* __rtems__ */
+#endif /*_POSIX_SOURCE */
+
+/*
+ * Control flags - hardware control of terminal
+ */
+#if !_POSIX_SOURCE || __rtems__
+#define CIGNORE 0x00000001 /* ignore control flags */
+#endif
+#define CSIZE 0x00000300 /* character size mask */
+#define CS5 0x00000000 /* 5 bits (pseudo) */
+#define CS6 0x00000100 /* 6 bits */
+#define CS7 0x00000200 /* 7 bits */
+#define CS8 0x00000300 /* 8 bits */
+#define CSTOPB 0x00000400 /* send 2 stop bits */
+#define CREAD 0x00000800 /* enable receiver */
+#define PARENB 0x00001000 /* parity enable */
+#define PARODD 0x00002000 /* odd parity, else even */
+#define HUPCL 0x00004000 /* hang up on last close */
+#define CLOCAL 0x00008000 /* ignore modem status lines */
+#if !_POSIX_SOURCE || __rtems__
+#define CCTS_OFLOW 0x00010000 /* CTS flow control of output */
+#define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW)
+#define CRTS_IFLOW 0x00020000 /* RTS flow control of input */
+#define CDTR_IFLOW 0x00040000 /* DTR flow control of input */
+#define CDSR_OFLOW 0x00080000 /* DSR flow control of output */
+#define CCAR_OFLOW 0x00100000 /* DCD flow control of output */
+#endif
+
+
+/*
+ * "Local" flags - dumping ground for other state
+ *
+ * Warning: some flags in this structure begin with
+ * the letter "I" and look like they belong in the
+ * input flag.
+ */
+
+#if !_POSIX_SOURCE || __rtems__
+#define ECHOKE 0x00000001 /* visual erase for line kill */
+#endif /*_POSIX_SOURCE */
+#define ECHOE 0x00000002 /* visually erase chars */
+#define ECHOK 0x00000004 /* echo NL after line kill */
+#define ECHO 0x00000008 /* enable echoing */
+#define ECHONL 0x00000010 /* echo NL even if ECHO is off */
+#if !_POSIX_SOURCE || __rtems__
+#define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */
+#define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */
+#endif /*_POSIX_SOURCE */
+#define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */
+#define ICANON 0x00000100 /* canonicalize input lines */
+#if !_POSIX_SOURCE || __rtems__
+#define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
+#endif /*_POSIX_SOURCE */
+#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
+#define EXTPROC 0x00000800 /* external processing */
+#ifdef __rtems__
+#define XCASE 0x00001000 /* visually erase chars */
+#endif /* __rtems__ */
+#define TOSTOP 0x00400000 /* stop background jobs from output */
+#if !_POSIX_SOURCE || __rtems__
+#define FLUSHO 0x00800000 /* output being flushed (state) */
+#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
+#define PENDIN 0x20000000 /* XXX retype pending input (state) */
+#endif /*_POSIX_SOURCE */
+#define NOFLSH 0x80000000 /* don't flush after interrupt */
+
+/*
+ * Standard speeds
+ */
+#define B0 0
+#define B50 50
+#define B75 75
+#define B110 110
+#define B134 134
+#define B150 150
+#define B200 200
+#define B300 300
+#define B600 600
+#define B1200 1200
+#define B1800 1800
+#define B2400 2400
+#define B4800 4800
+#define B9600 9600
+#define B19200 19200
+#define B38400 38400
+#if !_POSIX_SOURCE || __rtems__
+#define B7200 7200
+#define B14400 14400
+#define B28800 28800
+#define B57600 57600
+#define B76800 76800
+#define B115200 115200
+#define B230400 230400
+#define B460800 460800
+#define B921600 921600
+#define EXTA 19200
+#define EXTB 38400
+#endif /* !_POSIX_SOURCE */
+
+#ifdef __rtems__
+#define RTEMS_TERMIOS_NUMBER_BAUD_RATES 25
+#endif /* __rtems__ */
+
+typedef unsigned int tcflag_t;
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+
+struct termios {
+ tcflag_t c_iflag; /* input flags */
+ tcflag_t c_oflag; /* output flags */
+ tcflag_t c_cflag; /* control flags */
+ tcflag_t c_lflag; /* local flags */
+ cc_t c_cc[NCCS]; /* control chars */
+ speed_t c_ispeed; /* input speed */
+ speed_t c_ospeed; /* output speed */
+};
+
+#endif /* !_SYS__TERMIOS_H_ */
diff --git a/cpukit/libcsupport/include/sys/ioccom.h b/cpukit/libcsupport/include/sys/ioccom.h
index 1699fc9eeb..393702d4d6 100644
--- a/cpukit/libcsupport/include/sys/ioccom.h
+++ b/cpukit/libcsupport/include/sys/ioccom.h
@@ -69,17 +69,6 @@ typedef uint32_t ioctl_command_t;
/* this should be _IORW, but stdio got there first */
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
-/*
- * IOCTL values
- */
-
-#define RTEMS_IO_GET_ATTRIBUTES 1
-#define RTEMS_IO_SET_ATTRIBUTES 2
-#define RTEMS_IO_TCDRAIN 3
-#define RTEMS_IO_RCVWAKEUP 4
-#define RTEMS_IO_SNDWAKEUP 5
-#define RTEMS_IO_TCFLUSH 6
-
#ifdef _KERNEL
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
diff --git a/cpukit/libcsupport/include/sys/termios.h b/cpukit/libcsupport/include/sys/termios.h
index 648e3a2822..7568b96be7 100644
--- a/cpukit/libcsupport/include/sys/termios.h
+++ b/cpukit/libcsupport/include/sys/termios.h
@@ -1,221 +1,101 @@
-/**
- * @file
+/*-
+ * Copyright (c) 1988, 1989, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
*
- * @brief POSIX Termios Implementation for RTEMS Console Device Driver
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
- * The Open Group Base Specifications Issue 6
- * IEEE Std 1003.1, 2004 Edition
- * Chapter 11, General Terminal Interface
- */
-
-/*
- * COPYRIGHT (c) 1989-2011.
- * On-Line Applications Research Corporation (OAR).
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * @(#)termios.h 8.3 (Berkeley) 3/28/94
+ * $FreeBSD: head/include/termios.h 265878 2014-05-11 13:48:21Z jilles $
*/
-#ifndef TERMIOS_H
-#define TERMIOS_H
+#ifndef _TERMIOS_H_
+#define _TERMIOS_H_
-#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <sys/_termios.h>
+#include <sys/_types.h>
-#ifdef __cplusplus
-extern "C" {
+#ifndef _PID_T_DECLARED
+typedef __pid_t pid_t;
+#define _PID_T_DECLARED
#endif
-/**
- * @ingroup Termios
- *
- * @brief POSIX Termios Implementation
- *
- */
-/**@{**/
-
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-typedef unsigned int tcflag_t;
+#if !_POSIX_SOURCE || __rtems__
+#define OXTABS TAB3
+#define MDMBUF CCAR_OFLOW
+#endif
-#define NCCS 19
-struct termios {
- tcflag_t c_iflag; /* input mode flags */
- tcflag_t c_oflag; /* output mode flags */
- tcflag_t c_cflag; /* control mode flags */
- tcflag_t c_lflag; /* local mode flags */
- cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
-};
+#if !_POSIX_SOURCE || __rtems__
+#define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE)
+#endif
-/**
- * This value is used to disable processing of a member of c_cc
- * in the struct termios.
+/*
+ * Commands passed to tcsetattr() for setting the termios structure.
*/
-#define _POSIX_VDISABLE 0
-
-/* c_cc characters */
-#define VINTR 0
-#define VQUIT 1
-#define VERASE 2
-#define VKILL 3
-#define VEOF 4
-#define VTIME 5
-#define VMIN 6
-#define VSWTC 7
-#define VSTART 8
-#define VSTOP 9
-#define VSUSP 10
-#define VEOL 11
-#define VREPRINT 12
-#define VDISCARD 13
-#define VWERASE 14
-#define VLNEXT 15
-#define VEOL2 16
-
-/* c_iflag bits */
-#define IGNBRK 0000001
-#define BRKINT 0000002
-#define IGNPAR 0000004
-#define PARMRK 0000010
-#define INPCK 0000020
-#define ISTRIP 0000040
-#define INLCR 0000100
-#define IGNCR 0000200
-#define ICRNL 0000400
-#define IUCLC 0001000
-#define IXON 0002000
-#define IXANY 0004000
-#define IXOFF 0010000
-#define IMAXBEL 0020000
-
-/* c_oflag bits */
-#define OPOST 0000001
-#define OLCUC 0000002
-#define ONLCR 0000004
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-#define OFILL 0000100
-#define OFDEL 0000200
-#define NLDLY 0000400
-#define NL0 0000000
-#define NL1 0000400
-#define CRDLY 0003000
-#define CR0 0000000
-#define CR1 0001000
-#define CR2 0002000
-#define CR3 0003000
-#define TABDLY 0014000
-#define TAB0 0000000
-#define TAB1 0004000
-#define TAB2 0010000
-#define TAB3 0014000
-#define XTABS 0014000
-#define BSDLY 0020000
-#define BS0 0000000
-#define BS1 0020000
-#define VTDLY 0040000
-#define VT0 0000000
-#define VT1 0040000
-#define FFDLY 0100000
-#define FF0 0000000
-#define FF1 0100000
-
-/* c_cflag bit meaning */
-#define CBAUD 0010017
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0000060
-#define CS5 0000000
-#define CS6 0000020
-#define CS7 0000040
-#define CS8 0000060
-#define CSTOPB 0000100
-#define CREAD 0000200
-#define PARENB 0000400
-#define PARODD 0001000
-#define HUPCL 0002000
-#define CLOCAL 0004000
-#define CBAUDEX 0010000
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define CIBAUD 002003600000 /* input baud rate (not used) */
-#define CRTSCTS 020000000000 /* flow control */
-
-#define RTEMS_TERMIOS_NUMBER_BAUD_RATES 20
-
-/* c_lflag bits */
-#define ISIG 0000001
-#define ICANON 0000002
-#define XCASE 0000004
-#define ECHO 0000010
-#define ECHOE 0000020
-#define ECHOK 0000040
-#define ECHONL 0000100
-#define NOFLSH 0000200
-#define TOSTOP 0000400
-#define ECHOCTL 0001000
-#define ECHOPRT 0002000
-#define ECHOKE 0004000
-#define FLUSHO 0010000
-#define PENDIN 0040000
-#define IEXTEN 0100000
-
-/* tcflow() and TCXONC use these */
-#define TCOOFF 0
-#define TCOON 1
-#define TCIOFF 2
-#define TCION 3
-
-/* tcflush() and TCFLSH use these */
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
-
-/* tcsetattr uses these */
-#define TCSANOW 0
-#define TCSADRAIN 1
-#define TCSAFLUSH 2
+#define TCSANOW 0 /* make change immediate */
+#define TCSADRAIN 1 /* drain output, then change */
+#define TCSAFLUSH 2 /* drain output, flush input */
+#if !_POSIX_SOURCE || __rtems__
+#define TCSASOFT 0x10 /* flag - don't alter h.w. state */
+#endif
+#define TCIFLUSH 1
+#define TCOFLUSH 2
+#define TCIOFLUSH 3
+#define TCOOFF 1
+#define TCOON 2
+#define TCIOFF 3
+#define TCION 4
+
+__BEGIN_DECLS
+speed_t cfgetispeed(const struct termios *);
+speed_t cfgetospeed(const struct termios *);
+int cfsetispeed(struct termios *, speed_t);
+int cfsetospeed(struct termios *, speed_t);
+int tcgetattr(int, struct termios *);
+int tcsetattr(int, int, const struct termios *);
int tcdrain(int);
int tcflow(int, int);
int tcflush(int, int);
-int tcgetattr(int, struct termios *);
-int tcsetattr(int, int, struct termios *);
-int tcdrain(int);
-pid_t tcgetprgrp(int);
-int tcsetprgrp(int, pid_t);
int tcsendbreak(int, int);
-speed_t cfgetospeed(const struct termios *tp);
-int cfsetospeed(struct termios *tp, speed_t speed);
-speed_t cfgetispeed(const struct termios *tp);
-int cfsetispeed(struct termios *tp, speed_t speed);
-void cfmakeraw(struct termios *tp);
-int cfsetspeed(struct termios *tp, speed_t speed);
-/** @} */
+#if __POSIX_VISIBLE >= 200112
+pid_t tcgetsid(int);
+#endif
+#if __BSD_VISIBLE
+int tcsetsid(int, pid_t);
-#ifdef __cplusplus
-}
+void cfmakeraw(struct termios *);
+void cfmakesane(struct termios *);
+int cfsetspeed(struct termios *, speed_t);
#endif
+__END_DECLS
+
+#endif /* !_TERMIOS_H_ */
-#endif /* TERMIOS_H */
+#if !_POSIX_SOURCE || __rtems__
+#include <sys/ttycom.h>
+#include <sys/ttydefaults.h>
+#endif
diff --git a/cpukit/libcsupport/include/sys/ttycom.h b/cpukit/libcsupport/include/sys/ttycom.h
index f89a8e08e1..823ce3de5f 100644
--- a/cpukit/libcsupport/include/sys/ttycom.h
+++ b/cpukit/libcsupport/include/sys/ttycom.h
@@ -60,7 +60,11 @@ struct winsize {
/* 3-7 unused */
/* 8-10 compat */
/* 11-12 unused */
-#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
+#ifdef __rtems__
+#define RTEMS_IO_SNDWAKEUP _IOW('t', 11, struct ttywakeup ) /* send tty wakeup */
+#define RTEMS_IO_RCVWAKEUP _IOW('t', 12, struct ttywakeup ) /* recv tty wakeup */
+#endif /* __rtems__ */
+#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
#define TIOCGPTN _IOR('t', 15, int) /* Get pts number. */
#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
diff --git a/cpukit/libcsupport/include/sys/ttydefaults.h b/cpukit/libcsupport/include/sys/ttydefaults.h
new file mode 100644
index 0000000000..29464d03af
--- /dev/null
+++ b/cpukit/libcsupport/include/sys/ttydefaults.h
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
+ * $FreeBSD: head/sys/sys/ttydefaults.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+/*
+ * System wide defaults for terminal state.
+ */
+#ifndef _SYS_TTYDEFAULTS_H_
+#define _SYS_TTYDEFAULTS_H_
+
+/*
+ * Defaults on "first" open.
+ */
+#define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY)
+#define TTYDEF_OFLAG (OPOST | ONLCR)
+#define TTYDEF_LFLAG_NOECHO (ICANON | ISIG | IEXTEN)
+#define TTYDEF_LFLAG_ECHO (TTYDEF_LFLAG_NOECHO \
+ | ECHO | ECHOE | ECHOKE | ECHOCTL)
+#define TTYDEF_LFLAG TTYDEF_LFLAG_ECHO
+#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
+#define TTYDEF_SPEED (B9600)
+
+/*
+ * Control Character Defaults
+ */
+/*
+ * XXX: A lot of code uses lowercase characters, but control-character
+ * conversion is actually only valid when applied to uppercase
+ * characters. We just treat lowercase characters as if they were
+ * inserted as uppercase.
+ */
+#define CTRL(x) ((x) >= 'a' && (x) <= 'z' ? \
+ ((x) - 'a' + 1) : (((x) - 'A' + 1) & 0x7f))
+#define CEOF CTRL('D')
+#define CEOL 0xff /* XXX avoid _POSIX_VDISABLE */
+#define CERASE CTRL('?')
+#define CERASE2 CTRL('H')
+#define CINTR CTRL('C')
+#define CSTATUS CTRL('T')
+#define CKILL CTRL('U')
+#define CMIN 1
+#define CQUIT CTRL('\\')
+#define CSUSP CTRL('Z')
+#define CTIME 0
+#define CDSUSP CTRL('Y')
+#define CSTART CTRL('Q')
+#define CSTOP CTRL('S')
+#define CLNEXT CTRL('V')
+#define CDISCARD CTRL('O')
+#define CWERASE CTRL('W')
+#define CREPRINT CTRL('R')
+#define CEOT CEOF
+/* compat */
+#define CBRK CEOL
+#define CRPRNT CREPRINT
+#define CFLUSH CDISCARD
+
+/* PROTECTED INCLUSION ENDS HERE */
+#endif /* !_SYS_TTYDEFAULTS_H_ */
+
+/*
+ * #define TTYDEFCHARS to include an array of default control characters.
+ */
+#ifdef TTYDEFCHARS
+
+#include <sys/cdefs.h>
+#include <sys/_termios.h>
+
+static const cc_t ttydefchars[] = {
+ CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT, CERASE2, CINTR,
+ CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT, CDISCARD, CMIN, CTIME,
+ CSTATUS, _POSIX_VDISABLE
+};
+_Static_assert(sizeof(ttydefchars) / sizeof(cc_t) == NCCS,
+ "Size of ttydefchars does not match NCCS");
+
+#undef TTYDEFCHARS
+#endif /* TTYDEFCHARS */
diff --git a/cpukit/libcsupport/src/cfgetispeed.c b/cpukit/libcsupport/src/cfgetispeed.c
index 8e9b186c7a..f551e271bf 100644
--- a/cpukit/libcsupport/src/cfgetispeed.c
+++ b/cpukit/libcsupport/src/cfgetispeed.c
@@ -30,6 +30,6 @@ speed_t cfgetispeed(
const struct termios *tp
)
{
- return (tp->c_cflag / (CIBAUD / CBAUD)) & CBAUD;
+ return tp->c_ispeed;
}
#endif
diff --git a/cpukit/libcsupport/src/cfgetospeed.c b/cpukit/libcsupport/src/cfgetospeed.c
index 399d64fc34..96446c7823 100644
--- a/cpukit/libcsupport/src/cfgetospeed.c
+++ b/cpukit/libcsupport/src/cfgetospeed.c
@@ -33,6 +33,6 @@ speed_t cfgetospeed(
const struct termios *tp
)
{
- return tp->c_cflag & CBAUD;
+ return tp->c_ospeed;
}
#endif
diff --git a/cpukit/libcsupport/src/cfmakeraw.c b/cpukit/libcsupport/src/cfmakeraw.c
index 3027df8821..c335b92950 100644
--- a/cpukit/libcsupport/src/cfmakeraw.c
+++ b/cpukit/libcsupport/src/cfmakeraw.c
@@ -54,11 +54,13 @@ cfmakeraw(
struct termios *tp
)
{
- tp->c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+ tp->c_iflag &= ~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR);
+ tp->c_iflag |= IGNBRK;
tp->c_oflag &= ~OPOST;
- tp->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ tp->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|TOSTOP|PENDIN);
tp->c_cflag &= ~(CSIZE|PARENB);
- tp->c_cflag |= CS8;
- /* XXX set MIN/TIME */
+ tp->c_cflag |= CS8|CREAD;
+ tp->c_cc[VMIN] = 1;
+ tp->c_cc[VTIME] = 0;
}
#endif
diff --git a/cpukit/libcsupport/src/cfmakesane.c b/cpukit/libcsupport/src/cfmakesane.c
new file mode 100644
index 0000000000..e44fd6af42
--- /dev/null
+++ b/cpukit/libcsupport/src/cfmakesane.c
@@ -0,0 +1,66 @@
+/* @file
+ *
+ * @brief Baud Rate Functions
+ * @ingroup Termios
+ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#define TTYDEFCHARS
+#include <termios.h>
+
+/*
+ * Obtain a termios structure which is similar to the one provided by
+ * the kernel.
+ */
+void
+cfmakesane(
+ struct termios *tp
+)
+{
+ tp->c_cflag = TTYDEF_CFLAG;
+ tp->c_iflag = TTYDEF_IFLAG;
+ tp->c_lflag = TTYDEF_LFLAG;
+ tp->c_oflag = TTYDEF_OFLAG;
+ tp->c_ispeed = TTYDEF_SPEED;
+ tp->c_ospeed = TTYDEF_SPEED;
+ memcpy(&tp->c_cc, ttydefchars, sizeof ttydefchars);
+}
+#endif
diff --git a/cpukit/libcsupport/src/cfsetispeed.c b/cpukit/libcsupport/src/cfsetispeed.c
index d3a031c049..14e67b9b8b 100644
--- a/cpukit/libcsupport/src/cfsetispeed.c
+++ b/cpukit/libcsupport/src/cfsetispeed.c
@@ -25,8 +25,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
-
-#include <rtems/libio_.h>
+#include <rtems/termiostypes.h>
#include <rtems/seterr.h>
/**
@@ -37,10 +36,10 @@ int cfsetispeed(
speed_t speed
)
{
- if ( speed & ~CBAUD )
+ if ( rtems_termios_baud_to_index( speed ) == -1 )
rtems_set_errno_and_return_minus_one( EINVAL );
- tp->c_cflag = (tp->c_cflag & ~CIBAUD) | (speed * (CIBAUD / CBAUD));
+ tp->c_ispeed = speed;
return 0;
}
#endif
diff --git a/cpukit/libcsupport/src/cfsetospeed.c b/cpukit/libcsupport/src/cfsetospeed.c
index 36e3d997c8..41a232aa0f 100644
--- a/cpukit/libcsupport/src/cfsetospeed.c
+++ b/cpukit/libcsupport/src/cfsetospeed.c
@@ -25,8 +25,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
-
-#include <rtems/libio_.h>
+#include <rtems/termiostypes.h>
#include <rtems/seterr.h>
/**
@@ -37,10 +36,10 @@ int cfsetospeed(
speed_t speed
)
{
- if ( speed & ~CBAUD )
+ if ( rtems_termios_baud_to_index( speed ) == -1 )
rtems_set_errno_and_return_minus_one( EINVAL );
- tp->c_cflag = (tp->c_cflag & ~CBAUD) | speed;
+ tp->c_ospeed = speed;
return 0;
}
#endif
diff --git a/cpukit/libcsupport/src/cfsetspeed.c b/cpukit/libcsupport/src/cfsetspeed.c
index 293ff6e3ef..0d37840319 100644
--- a/cpukit/libcsupport/src/cfsetspeed.c
+++ b/cpukit/libcsupport/src/cfsetspeed.c
@@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <errno.h>
#include <termios.h>
+#include <rtems/termiostypes.h>
#include <rtems/seterr.h>
int cfsetspeed(
@@ -31,7 +32,7 @@ int cfsetspeed(
speed_t speed
)
{
- if ( speed & ~CBAUD )
+ if ( rtems_termios_baud_to_index( speed ) == -1 )
rtems_set_errno_and_return_minus_one( EINVAL );
cfsetispeed( tp, speed );
diff --git a/cpukit/libcsupport/src/tcdrain.c b/cpukit/libcsupport/src/tcdrain.c
index b10d79c69e..7f049aa4cb 100644
--- a/cpukit/libcsupport/src/tcdrain.c
+++ b/cpukit/libcsupport/src/tcdrain.c
@@ -36,7 +36,7 @@ int tcdrain(
int fd
)
{
- return ioctl( fd, RTEMS_IO_TCDRAIN, 0 );
+ return ioctl( fd, TIOCDRAIN, 0 );
}
#endif
diff --git a/cpukit/libcsupport/src/tcflush.c b/cpukit/libcsupport/src/tcflush.c
index eacae1c1f2..cd781cf5a0 100644
--- a/cpukit/libcsupport/src/tcflush.c
+++ b/cpukit/libcsupport/src/tcflush.c
@@ -13,11 +13,30 @@
#include "config.h"
#endif
+#include <sys/fcntl.h>
#include <termios.h>
#include <stdint.h>
#include <sys/ioccom.h>
+#include <rtems/libio.h>
+#include <rtems/libio_.h>
+#include <rtems/seterr.h>
-int tcflush( int fd, int queue )
+int tcflush( int fd, int which )
{
- return ioctl( fd, RTEMS_IO_TCFLUSH, (intptr_t) queue );
+ int com;
+
+ switch (which) {
+ case TCIFLUSH:
+ com = FREAD;
+ break;
+ case TCOFLUSH:
+ com = FWRITE;
+ break;
+ case TCIOFLUSH:
+ com = FREAD | FWRITE;
+ break;
+ default:
+ rtems_set_errno_and_return_minus_one( EINVAL );
+ }
+ return ioctl( fd, TIOCFLUSH, &com );
}
diff --git a/cpukit/libcsupport/src/tcgetattr.c b/cpukit/libcsupport/src/tcgetattr.c
index 11ee593c87..c8c0e84b7f 100644
--- a/cpukit/libcsupport/src/tcgetattr.c
+++ b/cpukit/libcsupport/src/tcgetattr.c
@@ -34,6 +34,6 @@ int tcgetattr(
struct termios *tp
)
{
- return ioctl( fd, RTEMS_IO_GET_ATTRIBUTES, tp );
+ return ioctl( fd, TIOCGETA, tp );
}
#endif
diff --git a/cpukit/libcsupport/src/tcsetattr.c b/cpukit/libcsupport/src/tcsetattr.c
index 556abee4a7..6b6afda718 100644
--- a/cpukit/libcsupport/src/tcsetattr.c
+++ b/cpukit/libcsupport/src/tcsetattr.c
@@ -35,23 +35,32 @@
* POSIX 1003.1b 7.2.1 - Get and Set State
*/
int tcsetattr(
- int fd,
- int opt,
- struct termios *tp
+ int fd,
+ int opt,
+ const struct termios *tp
)
{
- switch (opt) {
- default:
- rtems_set_errno_and_return_minus_one( ENOTSUP );
+ struct termios localterm;
+
+ if (opt & TCSASOFT) {
+ localterm = *tp;
+ localterm.c_cflag |= CIGNORE;
+ tp = &localterm;
+ }
+
+ switch (opt & ~TCSASOFT) {
- case TCSADRAIN:
- if (ioctl( fd, RTEMS_IO_TCDRAIN, NULL ) < 0)
- return -1;
- /*
- * Fall through to....
- */
case TCSANOW:
- return ioctl( fd, RTEMS_IO_SET_ATTRIBUTES, tp );
+ return ioctl( fd, TIOCSETA, tp );
+
+ case TCSADRAIN:
+ return ioctl( fd, TIOCSETAW, tp );
+
+ case TCSAFLUSH:
+ return ioctl( fd, TIOCSETAF, tp );
+
+ default:
+ rtems_set_errno_and_return_minus_one( EINVAL );
}
}
#endif
diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c
index 9eace2eeea..a7944ecc1e 100644
--- a/cpukit/libcsupport/src/termios.c
+++ b/cpukit/libcsupport/src/termios.c
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
+#include <sys/fcntl.h>
#include <sys/ttycom.h>
#include <rtems/termiostypes.h>
@@ -846,6 +847,7 @@ rtems_termios_ioctl (void *arg)
struct rtems_termios_tty *tty = args->iop->data1;
struct ttywakeup *wakeup = (struct ttywakeup *)args->buffer;
rtems_status_code sc;
+ int flags = *((int *)args->buffer);
args->ioctl_return = 0;
sc = rtems_semaphore_obtain (tty->osem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
@@ -865,13 +867,21 @@ rtems_termios_ioctl (void *arg)
}
break;
- case RTEMS_IO_GET_ATTRIBUTES:
+ case TIOCGETA:
*(struct termios *)args->buffer = tty->termios;
break;
- case RTEMS_IO_SET_ATTRIBUTES:
+ case TIOCSETA:
+ case TIOCSETAW:
+ case TIOCSETAF:
tty->termios = *(struct termios *)args->buffer;
+ if (args->command == TIOCSETAW || args->command == TIOCSETAF) {
+ drainOutput (tty);
+ if (args->command == TIOCSETAF) {
+ flushInput (tty);
+ }
+ }
/* check for and process change in flow control options */
termios_set_flowctrl(tty);
@@ -880,7 +890,7 @@ rtems_termios_ioctl (void *arg)
tty->rawInBufSemaphoreTimeout = RTEMS_NO_TIMEOUT;
tty->rawInBufSemaphoreFirstTimeout = RTEMS_NO_TIMEOUT;
} else {
- tty->vtimeTicks = tty->termios.c_cc[VTIME] *
+ tty->vtimeTicks = tty->termios.c_cc[VTIME] *
rtems_clock_get_ticks_per_second() / 10;
if (tty->termios.c_cc[VTIME]) {
tty->rawInBufSemaphoreOptions = RTEMS_WAIT;
@@ -905,25 +915,21 @@ rtems_termios_ioctl (void *arg)
}
break;
- case RTEMS_IO_TCDRAIN:
+ case TIOCDRAIN:
drainOutput (tty);
break;
- case RTEMS_IO_TCFLUSH:
- switch ((intptr_t) args->buffer) {
- case TCIFLUSH:
- flushInput (tty);
- break;
- case TCOFLUSH:
- flushOutput (tty);
- break;
- case TCIOFLUSH:
- flushOutput (tty);
- flushInput (tty);
- break;
- default:
- sc = RTEMS_INVALID_NAME;
- break;
+ case TIOCFLUSH:
+ if (flags == 0) {
+ flags = FREAD | FWRITE;
+ } else {
+ flags &= FREAD | FWRITE;
+ }
+ if (flags & FWRITE) {
+ flushOutput (tty);
+ }
+ if (flags & FREAD) {
+ flushInput (tty);
}
break;
diff --git a/cpukit/libcsupport/src/termios_baud2index.c b/cpukit/libcsupport/src/termios_baud2index.c
index 625a71494d..569ac5c769 100644
--- a/cpukit/libcsupport/src/termios_baud2index.c
+++ b/cpukit/libcsupport/src/termios_baud2index.c
@@ -44,10 +44,15 @@ int rtems_termios_baud_to_index(
case B9600: baud_index = 13; break;
case B19200: baud_index = 14; break;
case B38400: baud_index = 15; break;
- case B57600: baud_index = 16; break;
- case B115200: baud_index = 17; break;
- case B230400: baud_index = 18; break;
- case B460800: baud_index = 19; break;
+ case B7200: baud_index = 16; break;
+ case B14400: baud_index = 17; break;
+ case B28800: baud_index = 18; break;
+ case B57600: baud_index = 19; break;
+ case B76800: baud_index = 20; break;
+ case B115200: baud_index = 21; break;
+ case B230400: baud_index = 22; break;
+ case B460800: baud_index = 23; break;
+ case B921600: baud_index = 24; break;
default: baud_index = -1; break;
}
diff --git a/cpukit/libcsupport/src/termios_baud2num.c b/cpukit/libcsupport/src/termios_baud2num.c
index 07e6446e39..4c80949f17 100644
--- a/cpukit/libcsupport/src/termios_baud2num.c
+++ b/cpukit/libcsupport/src/termios_baud2num.c
@@ -20,9 +20,7 @@
#include <rtems/termiostypes.h>
-rtems_termios_baud_t rtems_termios_baud_to_number(tcflag_t c_cflag)
+rtems_termios_baud_t rtems_termios_baud_to_number(speed_t spd)
{
- uint32_t remote_value = (uint32_t) (c_cflag & CBAUD);
-
- return rtems_assoc_local_by_remote(rtems_termios_baud_table, remote_value);
+ return rtems_assoc_local_by_remote(rtems_termios_baud_table, spd);
}
diff --git a/cpukit/libcsupport/src/termios_baudtable.c b/cpukit/libcsupport/src/termios_baudtable.c
index 74fc492dec..c2a1859154 100644
--- a/cpukit/libcsupport/src/termios_baudtable.c
+++ b/cpukit/libcsupport/src/termios_baudtable.c
@@ -37,9 +37,14 @@ const rtems_assoc_t rtems_termios_baud_table [] = {
{ "B9600", 9600, B9600 },
{ "B19200", 19200, B19200 },
{ "B38400", 38400, B38400 },
+ { "B7200", 7200, B7200 },
+ { "B14400", 14400, B14400 },
+ { "B28800", 28800, B28800 },
{ "B57600", 57600, B57600 },
+ { "B76800", 76800, B76800 },
{ "B115200", 115200, B115200 },
{ "B230400", 230400, B230400 },
{ "B460800", 460800, B460800 },
+ { "B921600", 921600, B921600 },
{ NULL, 0, 0 }
};
diff --git a/cpukit/libcsupport/src/termios_setbestbaud.c b/cpukit/libcsupport/src/termios_setbestbaud.c
index 768011892e..d6dcd7f33d 100644
--- a/cpukit/libcsupport/src/termios_setbestbaud.c
+++ b/cpukit/libcsupport/src/termios_setbestbaud.c
@@ -25,8 +25,7 @@ void rtems_termios_set_best_baud(
{
const rtems_assoc_t *current = &rtems_termios_baud_table[ 0 ];
const rtems_assoc_t *last = current;
- tcflag_t cbaud_mask = CBAUD;
- tcflag_t cbaud;
+ speed_t spd;
while ( current->name != NULL && current->local_value < baud ) {
last = current;
@@ -36,10 +35,11 @@ void rtems_termios_set_best_baud(
if ( current->name != NULL ) {
uint32_t mid = (last->local_value + current->local_value) / UINT32_C( 2 );
- cbaud = baud <= mid ? last->remote_value : current->remote_value;
+ spd = baud <= mid ? last->remote_value : current->remote_value;
} else {
- cbaud = B460800;
+ spd = B460800;
}
- term->c_cflag = (term->c_cflag & ~cbaud_mask) | cbaud;
+ term->c_ispeed = spd;
+ term->c_ospeed = spd;
}
diff --git a/cpukit/libcsupport/src/termios_setinitialbaud.c b/cpukit/libcsupport/src/termios_setinitialbaud.c
index c3e8e579a5..3b8853f6a8 100644
--- a/cpukit/libcsupport/src/termios_setinitialbaud.c
+++ b/cpukit/libcsupport/src/termios_setinitialbaud.c
@@ -26,12 +26,11 @@ int rtems_termios_set_initial_baud(
)
{
int rv = 0;
- tcflag_t c_cflag_baud = rtems_termios_number_to_baud(baud);
+ speed_t spd = rtems_termios_number_to_baud(baud);
- if ( c_cflag_baud != 0 ) {
- tcflag_t cbaud = CBAUD;
-
- tty->termios.c_cflag = (tty->termios.c_cflag & ~cbaud) | c_cflag_baud;
+ if ( spd != 0 ) {
+ tty->termios.c_ispeed = spd;
+ tty->termios.c_ospeed = spd;
} else {
rv = -1;
}
diff --git a/cpukit/libnetworking/net/ppp_tty.c b/cpukit/libnetworking/net/ppp_tty.c
index 45fb499af9..e68124cd7c 100644
--- a/cpukit/libnetworking/net/ppp_tty.c
+++ b/cpukit/libnetworking/net/ppp_tty.c
@@ -224,7 +224,7 @@ pppopen(struct rtems_termios_tty *tty)
sc->sc_relinq = pppasyncrelinq;
sc->sc_outm = NULL;
sc->sc_outmc = NULL;
-
+
/* preallocate mbufs for free queue */
rtems_bsdnet_semaphore_obtain();
for (i=0; i<NUM_MBUFQ; i++) {
@@ -243,8 +243,7 @@ pppopen(struct rtems_termios_tty *tty)
/* initialize values */
sc->sc_if.if_flags |= IFF_RUNNING;
- sc->sc_if.if_baudrate =
- rtems_termios_baud_to_number(tty->termios.c_cflag & CBAUD);
+ sc->sc_if.if_baudrate = tty->termios.c_ispeed;
tty->t_sc = (void *)sc;
@@ -374,7 +373,7 @@ pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
int n;
int len;
int maximum = rw_args->count;
- char *out_buffer = rw_args->buffer;
+ char *out_buffer = rw_args->buffer;
register struct ppp_softc *sc = (struct ppp_softc *)tty->t_sc;
struct mbuf *m;
struct mbuf *m0;
@@ -432,9 +431,11 @@ ppptioctl(struct rtems_termios_tty *tty, rtems_libio_ioctl_args_t *args)
struct ppp_softc *sc = tty->t_sc;
switch (cmd) {
- case RTEMS_IO_GET_ATTRIBUTES:
- case RTEMS_IO_SET_ATTRIBUTES:
- case RTEMS_IO_TCDRAIN:
+ case TIOCGETA:
+ case TIOCSETA:
+ case TIOCSETAW:
+ case TIOCSETAF:
+ case TIOCDRAIN:
case RTEMS_IO_SNDWAKEUP:
case RTEMS_IO_RCVWAKEUP:
case TIOCGETD:
diff --git a/cpukit/preinstall.am b/cpukit/preinstall.am
index a6a5879cc9..53f78f3499 100644
--- a/cpukit/preinstall.am
+++ b/cpukit/preinstall.am
@@ -104,6 +104,14 @@ $(PROJECT_INCLUDE)/sys/ttycom.h: libcsupport/include/sys/ttycom.h $(PROJECT_INCL
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/ttycom.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/ttycom.h
+$(PROJECT_INCLUDE)/sys/ttydefaults.h: libcsupport/include/sys/ttydefaults.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/ttydefaults.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/ttydefaults.h
+
+$(PROJECT_INCLUDE)/sys/_termios.h: libcsupport/include/sys/_termios.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/_termios.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/_termios.h
+
$(PROJECT_INCLUDE)/sys/termios.h: libcsupport/include/sys/termios.h $(PROJECT_INCLUDE)/sys/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/termios.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/termios.h
diff --git a/testsuites/libtests/termios/init.c b/testsuites/libtests/termios/init.c
index fcb586b5ea..d8ac60a8f0 100644
--- a/testsuites/libtests/termios/init.c
+++ b/testsuites/libtests/termios/init.c
@@ -46,6 +46,7 @@ void print_c_oflag(struct termios * tp);
void print_c_lflag(struct termios * tp);
void print_c_cflag(struct termios * tp);
void print_c_cc(struct termios * tp);
+void print_baud(const char* name, speed_t spd);
void print_termios(struct termios *tp);
unsigned long get_baud_rate(void);
unsigned long get_parity(void);
@@ -118,6 +119,9 @@ void print_c_oflag( struct termios * tp )
if( tp->c_oflag & ONLCR )
printf( "ONLCR " );
+ if( tp->c_oflag & ONOEOT )
+ printf( "ONOEOT " );
+
if( tp->c_oflag & OCRNL )
printf( "OCRNL " );
@@ -215,27 +219,38 @@ void print_c_oflag( struct termios * tp )
void print_c_lflag( struct termios * tp )
{
char * c_lflag_bits [] = {
- "ISIG", /* 0000001 */
- "ICANON", /* 0000002 */
- "XCASE", /* 0000004 */
- "ECHO", /* 0000010 */
- "ECHOE", /* 0000020 */
- "ECHOK", /* 0000040 */
- "ECHONL", /* 0000100 */
- "NOFLSH", /* 0000200 */
- "TOSTOP", /* 0000400 */
- "ECHOCTL", /* 0001000 */
- "ECHOPRT", /* 0002000 */
- "ECHOKE", /* 0004000 */
- "FLUSHO", /* 0010000 */
- "unknown", /* 0020000 */
- "PENDIN", /* 0040000 */
- "IEXTEN", /* 0100000 */
- "unknown", /* 0200000 */
- "unknown", /* 0400000 */
- "unknown", /* 1000000 */
- "unknown", /* 2000000 */
- "unknown", /* 4000000 */
+ "ECHOKE", /* 0x00000001 */
+ "ECHOE", /* 0x00000002 */
+ "ECHOK", /* 0x00000004 */
+ "ECHO", /* 0x00000008 */
+ "ECHONL", /* 0x00000010 */
+ "ECHOPRT", /* 0x00000020 */
+ "ECHOCTL", /* 0x00000040 */
+ "ISIG", /* 0x00000080 */
+ "ICANON", /* 0x00000100 */
+ "ALTWERASE", /* 0x00000200 */
+ "IEXTEN", /* 0x00000400 */
+ "EXTPROC", /* 0x00000800 */
+ "XCASE", /* 0x00001000 */
+ "unknown", /* 0x00002000 */
+ "unknown", /* 0x00004000 */
+ "unknown", /* 0x00008000 */
+ "unknown", /* 0x00010000 */
+ "unknown", /* 0x00020000 */
+ "unknown", /* 0x00040000 */
+ "unknown", /* 0x00080000 */
+ "unknown", /* 0x00100000 */
+ "unknown", /* 0x00200000 */
+ "TOSTOP", /* 0x00400000 */
+ "FLUSHO", /* 0x00800000 */
+ "unknown", /* 0x01000000 */
+ "NOKERNINFO", /* 0x02000000 */
+ "unknown", /* 0x04000000 */
+ "unknown", /* 0x08000000 */
+ "unknown", /* 0x10000000 */
+ "PENDIN", /* 0x20000000 */
+ "unknown", /* 0x40000000 */
+ "NOFLSH", /* 0x80000000 */
};
printf( "c_lflag = 0x%08x\n\t", tp->c_lflag );
@@ -246,98 +261,8 @@ void print_c_lflag( struct termios * tp )
void print_c_cflag( struct termios * tp )
{
- unsigned int baud;
-
printf( "c_cflag = 0x%08x\n", tp->c_cflag );
- baud = (tp->c_cflag & CBAUD) ;
- if ( tp->c_cflag & CBAUDEX )
- switch( baud ) {
- case B0:
- printf( "\tCBAUD =\tB0\n" );
- break;
-
- case B50:
- printf( "\tCBAUD =\tB50\n" );
- break;
-
- case B75:
- printf( "\tCBAUD =\tB75\n" );
- break;
-
- case B110:
- printf( "\tCBAUD =\tB110\n" );
- break;
-
- case B134:
- printf( "\tCBAUD =\tB134\n" );
- break;
-
- case B150:
- printf( "\tCBAUD =\tB150\n" );
- break;
-
- case B200:
- printf( "\tCBAUD =\tB200\n" );
- break;
-
- case B300:
- printf( "\tCBAUD =\tB300\n" );
- break;
-
- case B600:
- printf( "\tCBAUD =\tB600\n" );
- break;
-
- case B1200:
- printf( "\tCBAUD =\tB1200\n" );
- break;
-
- case B1800:
- printf( "\tCBAUD =\tB1800\n" );
- break;
-
- case B2400:
- printf( "\tCBAUD =\tB2400\n" );
- break;
-
- case B4800:
- printf( "\tCBAUD =\tB4800\n" );
- break;
-
- case B9600:
- printf( "\tCBAUD =\tB9600\n" );
- break;
-
- case B19200:
- printf( "\tCBAUD =\tB19200\n" );
- break;
-
- case B38400:
- printf( "\tCBAUD =\tB38400\n" );
- break;
-
- case B57600:
- printf( "\tCBAUD =\tB57600\n" );
- break;
-
- case B115200:
- printf( "\tCBAUD =\tB115200\n" );
- break;
-
- case B230400:
- printf( "\tCBAUD =\tB230400\n" );
- break;
-
- case B460800:
- printf( "\tCBAUD =\tB460800\n" );
- break;
-
- default:
- printf( "\tCBAUD =\tunknown (0x%08x)\n", baud );
- break;
- }
-
switch( tp->c_cflag & CSIZE ) {
case CS5:
printf( "\tCSIZE =\tCS5\n" );
@@ -356,6 +281,11 @@ void print_c_cflag( struct termios * tp )
break;
}
+ if( tp->c_cflag & CIGNORE )
+ printf( "\tCIGNORE set: iqnore c_cflags enabled\n" );
+ else
+ printf( "\tCIGNORE clear: iqnore c_cflags disabled\n" );
+
if( tp->c_cflag & CSTOPB )
printf( "\tCSTOPB set: send 2 stop bits\n" );
else
@@ -386,17 +316,35 @@ void print_c_cflag( struct termios * tp )
else
printf( "\tCLOCAL clear: don't ignore modem lines\n" );
-#if defined(CBAUDEX)
- if( tp->c_cflag & CBAUDEX )
- printf( "\tCBAUDEX set: What does this do?\n" );
+ if( tp->c_cflag & CCTS_OFLOW )
+ printf( "\tCCTS_OFLOW: hardware CTS output flow control enabled\n" );
else
- printf( "\tCBAUDEX clear: What does this do?\n" );
-#endif
+ printf( "\tCCTS_OFLOW: hardware CTS output flow control disabled\n" );
+
+ if( tp->c_cflag & CRTS_IFLOW )
+ printf( "\tCRTS_IFLOW: hardware RTS input flow control enabled\n" );
+ else
+ printf( "\tCRTS_IFLOW: hardware RTS input flow control disabled\n" );
if( tp->c_cflag & CRTSCTS )
printf( "\tCRTSCTS: harware flow control enabled?\n" );
else
printf( "\tCRTSCTS: hardware flow control disabled?\n" );
+
+ if( tp->c_cflag & CDSR_OFLOW )
+ printf( "\tCDSR_OFLOW: hardware DSR output flow control enabled\n" );
+ else
+ printf( "\tCDSR_OFLOW: hardware DSR output flow control disabled\n" );
+
+ if( tp->c_cflag & CDTR_IFLOW )
+ printf( "\tCDTR_IFLOW: hardware DTR input flow control enabled\n" );
+ else
+ printf( "\tCDTR_IFLOW: hardware DTR input flow control disabled\n" );
+
+ if( tp->c_cflag & CCAR_OFLOW )
+ printf( "\tCCAR_OFLOW: hardware CD output flow control enabled\n" );
+ else
+ printf( "\tCCAR_OFLOW: hardware CD output flow control disabled\n" );
}
@@ -404,25 +352,26 @@ void print_c_cc( struct termios * tp )
{
size_t i;
char * cc_index_names [ /* NCCS */ ] = {
- "[VINTR] ", /* 0 */
- "[VQUIT] ", /* 1 */
- "[VERASE] ", /* 2 */
- "[VKILL] ", /* 3 */
- "[VEOF] ", /* 4 */
- "[VTIME] ", /* 5 */
- "[VMIN] ", /* 6 */
- "[VSWTC ", /* 7 */
- "[VSTART] ", /* 8 */
- "[VSTOP] ", /* 9 */
+ "[VEOF] ", /* 0 */
+ "[VEOL] ", /* 1 */
+ "[VEOL2] ", /* 2 */
+ "[VERASE] ", /* 3 */
+ "[VWERASE] ", /* 4 */
+ "[VKILL] ", /* 5 */
+ "[VREPRINT]", /* 6 */
+ "[VERASE2] ", /* 7 */
+ "[VINTR] ", /* 8 */
+ "[VQUIT] ", /* 9 */
"[VSUSP] ", /* 10 */
- "[VEOL] ", /* 11 */
- "[VREPRINT]", /* 12 */
- "[VDISCARD]", /* 13 */
- "[VWERASE] ", /* 14 */
- "[VLNEXT ", /* 15 */
- "[VEOL2] ", /* 16 */
- "unknown ", /* 17 */
- "unknown ", /* 18 */
+ "[VDSUSP] ", /* 11 */
+ "[VSTART] ", /* 12 */
+ "[VSTOP] ", /* 13 */
+ "[VLNEXT] ", /* 14 */
+ "[VDISCARD]", /* 15 */
+ "[VMIN] ", /* 16 */
+ "[VTIME] ", /* 17 */
+ "[VSTATUS] ", /* 18 */
+ "unknown ", /* 19 */
};
for( i = 0; i < sizeof(cc_index_names)/sizeof(char*) ; i++ ) {
@@ -431,6 +380,116 @@ void print_c_cc( struct termios * tp )
}
+void print_baud( const char* name, speed_t spd )
+{
+ switch( spd ) {
+ case B0:
+ printf( "%s = B0\n", name );
+ break;
+
+ case B50:
+ printf( "%s = B50\n", name );
+ break;
+
+ case B75:
+ printf( "%s = B75\n", name );
+ break;
+
+ case B110:
+ printf( "%s = B110\n", name );
+ break;
+
+ case B134:
+ printf( "%s = B134\n", name );
+ break;
+
+ case B150:
+ printf( "%s = B150\n", name );
+ break;
+
+ case B200:
+ printf( "%s = B200\n", name );
+ break;
+
+ case B300:
+ printf( "%s = B300\n", name );
+ break;
+
+ case B600:
+ printf( "%s = B600\n", name );
+ break;
+
+ case B1200:
+ printf( "%s = B1200\n", name );
+ break;
+
+ case B1800:
+ printf( "%s = B1800\n", name );
+ break;
+
+ case B2400:
+ printf( "%s = B2400\n", name );
+ break;
+
+ case B4800:
+ printf( "%s = B4800\n", name );
+ break;
+
+ case B9600:
+ printf( "%s = B9600\n", name );
+ break;
+
+ case B19200:
+ printf( "%s = B19200\n", name );
+ break;
+
+ case B38400:
+ printf( "%s = B38400\n", name );
+ break;
+
+ case B7200:
+ printf( "%s = B7200\n", name );
+ break;
+
+ case B14400:
+ printf( "%s = B14400\n", name );
+ break;
+
+ case B28800:
+ printf( "%s = B28800\n", name );
+ break;
+
+ case B57600:
+ printf( "%s = B57600\n", name );
+ break;
+
+ case B76800:
+ printf( "%s = B76800\n", name );
+ break;
+
+ case B115200:
+ printf( "%s = B115200\n", name );
+ break;
+
+ case B230400:
+ printf( "%s = B230400\n", name );
+ break;
+
+ case B460800:
+ printf( "%s = B460800\n", name );
+ break;
+
+ case B921600:
+ printf( "%s = B921600\n", name );
+ break;
+
+ default:
+ printf( "%s = unknown (0x%08x)\n", name, (unsigned int)spd );
+ break;
+ }
+}
+
+
void print_termios( struct termios *tp )
{
printf( "\nLooking at the current termios settings:\n\n" );
@@ -439,6 +498,8 @@ void print_termios( struct termios *tp )
print_c_cflag( tp );
print_c_lflag( tp );
print_c_cc( tp );
+ print_baud( "c_ispeed", tp->c_ispeed );
+ print_baud( "c_ospeed", tp->c_ospeed );
printf( "\n" );
}
@@ -450,7 +511,8 @@ unsigned long get_baud_rate(void)
while( 1 ) {
printf( "Enter the numerical value for the new baud rate.\n" );
printf( "Choices are: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800\n" );
- printf( "2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800\n" );
+ printf( "2400, 4800, 9600, 19200, 38400, 7200, 14400, 28800, 57600, 76800\n" );
+ printf( "115200, 230400, 460800, 921600\n" );
printf( "\nYour choice: " );
scanf( "%lu", &baud_rate );
printf( "\n" );
@@ -470,10 +532,15 @@ unsigned long get_baud_rate(void)
case 9600: return B9600;
case 19200: return B19200;
case 38400: return B38400;
+ case 7200: return B7200;
+ case 14400: return B14400;
+ case 28800: return B28800;
case 57600: return B57600;
+ case 76800: return B76800;
case 115200: return B115200;
case 230400: return B230400;
case 460800: return B460800;
+ case 921600: return B921600;
default:
printf( "%lu is not a valid choice. Try again.\n\n", baud_rate );
@@ -589,7 +656,9 @@ void change_line_settings( struct termios *tp )
sleep( sleep_time );
- tp->c_cflag = CLOCAL | CREAD | parity | stop_bits | data_bits | baud_rate;
+ tp->c_cflag = CLOCAL | CREAD | parity | stop_bits | data_bits;
+ tp->c_ispeed = baud_rate;
+ tp->c_ospeed = baud_rate;
if( tcsetattr( fileno( stdin ), TCSADRAIN, tp ) < 0 ) {
perror( "change_line_settings(): tcsetattr() failed" );
rtems_test_exit( 1 );
diff --git a/testsuites/libtests/termios01/init.c b/testsuites/libtests/termios01/init.c
index 64c3bb286b..562b252745 100644
--- a/testsuites/libtests/termios01/init.c
+++ b/testsuites/libtests/termios01/init.c
@@ -12,6 +12,7 @@
#endif
#include "tmacros.h"
+#define TTYDEFCHARS
#include <termios.h>
#include <rtems/libcsupport.h>
#include <rtems/malloc.h>
@@ -66,10 +67,15 @@ static const termios_baud_test_r baud_table[] = {
{ B9600, 9600 },
{ B19200, 19200 },
{ B38400, 38400 },
+ { B7200, 7200 },
+ { B14400, 14400 },
+ { B28800, 28800 },
{ B57600, 57600 },
+ { B76800, 76800 },
{ B115200, 115200 },
{ B230400, 230400 },
{ B460800, 460800 },
+ { B921600, 921600 },
{ INVALID_CONSTANT, INVALID_BAUD }
};
@@ -233,16 +239,14 @@ static void test_termios_set_baud(
puts( "Test termios setting device baud rate..." );
for (i=0 ; baud_table[i].constant != INVALID_CONSTANT ; i++ ) {
- tcflag_t cbaud = CBAUD;
-
sc = tcgetattr( test, &attr );
if ( sc != 0 ) {
printf( "ERROR - return %d\n", sc );
rtems_test_exit(0);
}
- attr.c_cflag &= ~cbaud;
- attr.c_cflag |= baud_table[i].constant;
+ attr.c_ispeed = baud_table[i].constant;
+ attr.c_ospeed = baud_table[i].constant;
printf(
"tcsetattr(TCSANOW, B%" PRIdrtems_termios_baud_t ") - OK\n",
@@ -258,7 +262,17 @@ static void test_termios_set_baud(
"tcsetattr(TCSADRAIN, B%" PRIdrtems_termios_baud_t ") - OK\n",
baud_table[i].baud
);
- sc = tcsetattr( test, TCSANOW, &attr );
+ sc = tcsetattr( test, TCSADRAIN, &attr );
+ if ( sc != 0 ) {
+ printf( "ERROR - return %d\n", sc );
+ rtems_test_exit(0);
+ }
+
+ printf(
+ "tcsetattr(TCSAFLUSH, B%" PRIdrtems_termios_baud_t ") - OK\n",
+ baud_table[i].baud
+ );
+ sc = tcsetattr( test, TCSAFLUSH, &attr );
if ( sc != 0 ) {
printf( "ERROR - return %d\n", sc );
rtems_test_exit(0);
@@ -301,7 +315,21 @@ static void test_termios_set_charsize(
}
printf( "tcsetattr(TCSADRAIN, CS%d) - OK\n", char_size_table[i].bits );
- sc = tcsetattr( test, TCSANOW, &attr );
+ sc = tcsetattr( test, TCSADRAIN, &attr );
+ if ( sc != 0 ) {
+ printf( "ERROR - return %d\n", sc );
+ rtems_test_exit(0);
+ }
+
+ printf( "tcsetattr(TCSAFLUSH, CS%d) - OK\n", char_size_table[i].bits );
+ sc = tcsetattr( test, TCSAFLUSH, &attr );
+ if ( sc != 0 ) {
+ printf( "ERROR - return %d\n", sc );
+ rtems_test_exit(0);
+ }
+
+ printf( "tcsetattr(TCSASOFT, CS%d) - OK\n", char_size_table[i].bits );
+ sc = tcsetattr( test, TCSASOFT, &attr );
if ( sc != 0 ) {
printf( "ERROR - return %d\n", sc );
rtems_test_exit(0);
@@ -344,7 +372,21 @@ static void test_termios_set_parity(
}
printf( "tcsetattr(TCSADRAIN, %s) - OK\n", parity_table[i].parity );
- sc = tcsetattr( test, TCSANOW, &attr );
+ sc = tcsetattr( test, TCSADRAIN, &attr );
+ if ( sc != 0 ) {
+ printf( "ERROR - return %d\n", sc );
+ rtems_test_exit(0);
+ }
+
+ printf( "tcsetattr(TCSAFLUSH, %s) - OK\n", parity_table[i].parity );
+ sc = tcsetattr( test, TCSAFLUSH, &attr );
+ if ( sc != 0 ) {
+ printf( "ERROR - return %d\n", sc );
+ rtems_test_exit(0);
+ }
+
+ printf( "tcsetattr(TCSASOFT, %s) - OK\n", parity_table[i].parity );
+ sc = tcsetattr( test, TCSASOFT, &attr );
if ( sc != 0 ) {
printf( "ERROR - return %d\n", sc );
rtems_test_exit(0);
@@ -390,7 +432,21 @@ static void test_termios_set_stop_bits(
}
printf( "tcsetattr(TCSADRAIN, %d bits) - OK\n", stop_bits_table[i].stop );
- sc = tcsetattr( test, TCSANOW, &attr );
+ sc = tcsetattr( test, TCSADRAIN, &attr );
+ if ( sc != 0 ) {
+ printf( "ERROR - return %d\n", sc );
+ rtems_test_exit(0);
+ }
+
+ printf( "tcsetattr(TCSAFLUSH, %d bits) - OK\n", stop_bits_table[i].stop );
+ sc = tcsetattr( test, TCSAFLUSH, &attr );
+ if ( sc != 0 ) {
+ printf( "ERROR - return %d\n", sc );
+ rtems_test_exit(0);
+ }
+
+ printf( "tcsetattr(TCSASOFT, %d bits) - OK\n", stop_bits_table[i].stop );
+ sc = tcsetattr( test, TCSASOFT, &attr );
if ( sc != 0 ) {
printf( "ERROR - return %d\n", sc );
rtems_test_exit(0);
@@ -404,9 +460,9 @@ static void test_termios_cfoutspeed(void)
int sc;
speed_t speed;
struct termios term;
- tcflag_t bad;
+ speed_t bad;
- bad = CBAUD << 1;
+ bad = B921600 << 1;
memset( &term, '\0', sizeof(term) );
puts( "cfsetospeed(BAD BAUD) - EINVAL" );
sc = cfsetospeed( &term, bad );
@@ -436,9 +492,9 @@ static void test_termios_cfinspeed(void)
int sc;
speed_t speed;
struct termios term;
- tcflag_t bad;
+ speed_t bad;
- bad = CBAUD << 1;
+ bad = B921600 << 1;
memset( &term, '\0', sizeof(term) );
puts( "cfsetispeed(BAD BAUD) - EINVAL" );
sc = cfsetispeed( &term, bad );
@@ -469,9 +525,9 @@ static void test_termios_cfsetspeed(void)
int status;
speed_t speed;
struct termios term;
- tcflag_t bad;
+ speed_t bad;
- bad = CBAUD << 1;
+ bad = B921600 << 1;
memset( &term, '\0', sizeof(term) );
puts( "cfsetspeed(BAD BAUD) - EINVAL" );
status = cfsetspeed( &term, bad );
@@ -508,15 +564,45 @@ static void test_termios_cfmakeraw(void)
puts( "cfmakeraw - OK" );
/* Check that all of the flags were set correctly */
- rtems_test_assert( ~(term.c_iflag & (IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON)) );
+ rtems_test_assert( ~(term.c_iflag & (IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR)) );
+
+ rtems_test_assert( term.c_iflag & (IGNBRK) );
rtems_test_assert( ~(term.c_oflag & OPOST) );
- rtems_test_assert( ~(term.c_lflag & (ECHO|ECHONL|ICANON|ISIG|IEXTEN)) );
+ rtems_test_assert( ~(term.c_lflag & (ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|TOSTOP|PENDIN)) );
rtems_test_assert( ~(term.c_cflag & (CSIZE|PARENB)) );
- rtems_test_assert( term.c_cflag & CS8 );
+ rtems_test_assert( term.c_cflag & (CS8|CREAD) );
+
+ rtems_test_assert( term.c_cc[VMIN] == 1 );
+
+ rtems_test_assert( term.c_cc[VTIME] == 0 );
+}
+
+static void test_termios_cfmakesane(void)
+{
+ struct termios term;
+
+ memset( &term, '\0', sizeof(term) );
+ cfmakesane( &term );
+ puts( "cfmakesane - OK" );
+
+ /* Check that all of the flags were set correctly */
+ rtems_test_assert( term.c_iflag == TTYDEF_IFLAG );
+
+ rtems_test_assert( term.c_oflag == TTYDEF_OFLAG );
+
+ rtems_test_assert( term.c_lflag == TTYDEF_LFLAG );
+
+ rtems_test_assert( term.c_cflag == TTYDEF_CFLAG );
+
+ rtems_test_assert( term.c_ispeed == TTYDEF_SPEED );
+
+ rtems_test_assert( term.c_ospeed == TTYDEF_SPEED );
+
+ rtems_test_assert( memcmp(&term.c_cc, ttydefchars, sizeof(term.c_cc)) == 0 );
}
typedef struct {
@@ -684,7 +770,7 @@ static void test_set_attributes_error(void)
rtems_test_assert( !ctx.done );
errno = 0;
- rv = ioctl( fd, RTEMS_IO_SET_ATTRIBUTES, &term );
+ rv = ioctl( fd, TIOCSETA, &term );
rtems_test_assert( rv == -1 );
rtems_test_assert( errno == EIO );
rtems_test_assert( ctx.done );
@@ -702,8 +788,8 @@ static void test_set_best_baud(void)
{
static const struct {
uint32_t baud;
- tcflag_t cflag;
- } baud_to_cflag_table[] = {
+ speed_t speed;
+ } baud_to_speed_table[] = {
{ 0, B0 },
{ 25, B0 },
{ 26, B50 },
@@ -731,19 +817,17 @@ static void test_set_best_baud(void)
{ 0xffffffff, B460800 }
};
- size_t n = RTEMS_ARRAY_SIZE(baud_to_cflag_table);
+ size_t n = RTEMS_ARRAY_SIZE(baud_to_speed_table);
size_t i;
for ( i = 0; i < n; ++i ) {
struct termios term;
- tcflag_t cbaud_mask = CBAUD;
memset( &term, 0xff, sizeof( term ) );
- rtems_termios_set_best_baud( &term, baud_to_cflag_table[ i ].baud );
+ rtems_termios_set_best_baud( &term, baud_to_speed_table[ i ].baud );
- rtems_test_assert(
- (term.c_cflag & cbaud_mask) == baud_to_cflag_table[ i ].cflag
- );
+ rtems_test_assert( term.c_ispeed == baud_to_speed_table[ i ].speed );
+ rtems_test_assert( term.c_ospeed == baud_to_speed_table[ i ].speed );
}
}
@@ -791,13 +875,14 @@ static rtems_task Init(
/*
* tcsetattr - ERROR invalid operation
*/
- puts( "tcsetattr - invalid operation - ENOTSUP" );
+ puts( "tcsetattr - invalid operation - EINVAL" );
rc = tcsetattr( test, INT_MAX, &t );
rtems_test_assert( rc == -1 );
- rtems_test_assert( errno == ENOTSUP );
+ rtems_test_assert( errno == EINVAL );
test_termios_cfmakeraw();
-
+ test_termios_cfmakesane();
+
/*
* tcsetattr - TCSADRAIN
*/
diff --git a/testsuites/libtests/termios01/termios01.scn b/testsuites/libtests/termios01/termios01.scn
index c1c54702d8..36f1b8e3a8 100644
--- a/testsuites/libtests/termios01/termios01.scn
+++ b/testsuites/libtests/termios01/termios01.scn
@@ -1,4 +1,4 @@
-*** TEST TERMIOS 01 ***
+*** BEGIN OF TEST TERMIOS 1 ***
Test termios_baud2index...
termios_baud_to_index(-2) - NOT OK
termios_baud_to_index(B0) - OK
@@ -17,10 +17,15 @@ termios_baud_to_index(B4800) - OK
termios_baud_to_index(B9600) - OK
termios_baud_to_index(B19200) - OK
termios_baud_to_index(B38400) - OK
+termios_baud_to_index(B7200) - OK
+termios_baud_to_index(B14400) - OK
+termios_baud_to_index(B28800) - OK
termios_baud_to_index(B57600) - OK
+termios_baud_to_index(B76800) - OK
termios_baud_to_index(B115200) - OK
termios_baud_to_index(B230400) - OK
termios_baud_to_index(B460800) - OK
+termios_baud_to_index(B921600) - OK
Test termios_baud2number...
termios_baud_to_number(-2) - NOT OK
@@ -40,10 +45,15 @@ termios_baud_to_number(B4800) - OK
termios_baud_to_number(B9600) - OK
termios_baud_to_number(B19200) - OK
termios_baud_to_number(B38400) - OK
+termios_baud_to_number(B7200) - OK
+termios_baud_to_number(B14400) - OK
+termios_baud_to_number(B28800) - OK
termios_baud_to_number(B57600) - OK
+termios_baud_to_number(B76800) - OK
termios_baud_to_number(B115200) - OK
termios_baud_to_number(B230400) - OK
termios_baud_to_number(B460800) - OK
+termios_baud_to_number(B921600) - OK
Test termios_number_to_baud...
termios_number_to_baud(-2) - NOT OK
@@ -63,103 +73,179 @@ termios_number_to_baud(B4800) - OK
termios_number_to_baud(B9600) - OK
termios_number_to_baud(B19200) - OK
termios_number_to_baud(B38400) - OK
+termios_number_to_baud(B7200) - OK
+termios_number_to_baud(B14400) - OK
+termios_number_to_baud(B28800) - OK
termios_number_to_baud(B57600) - OK
+termios_number_to_baud(B76800) - OK
termios_number_to_baud(B115200) - OK
termios_number_to_baud(B230400) - OK
termios_number_to_baud(B460800) - OK
+termios_number_to_baud(B921600) - OK
Init - rtems_io_register_driver - Termios Test Driver - OK
Termios_test_driver - rtems_io_register /dev/test - OK
-Init - Major slot returned = 2
+Init - Major slot returned = 3
Init - open - /dev/test - OK
Termios_test_driver - rtems_set_initial_baud - bad baud - OK
Termios_test_driver - rtems_set_initial_baud - 38400 - OK
-tcsetattr - invalid operation - ENOTSUP
+tcsetattr - invalid operation - EINVAL
cfmakeraw - OK
+cfmakesane - OK
tcsetattr - drain - OK
-set_attributes - B0 5-NONE-1
+set_attributes - B0 8-NONE-2
Test termios setting device baud rate...
tcsetattr(TCSANOW, B0) - OK
-set_attributes - B0 5-NONE-1
+set_attributes - B0 8-NONE-2
tcsetattr(TCSADRAIN, B0) - OK
-set_attributes - B0 5-NONE-1
+set_attributes - B0 8-NONE-2
+tcsetattr(TCSAFLUSH, B0) - OK
+set_attributes - B0 8-NONE-2
tcsetattr(TCSANOW, B50) - OK
-set_attributes - B50 5-NONE-1
+set_attributes - B50 8-NONE-2
tcsetattr(TCSADRAIN, B50) - OK
-set_attributes - B50 5-NONE-1
+set_attributes - B50 8-NONE-2
+tcsetattr(TCSAFLUSH, B50) - OK
+set_attributes - B50 8-NONE-2
tcsetattr(TCSANOW, B75) - OK
-set_attributes - B75 5-NONE-1
+set_attributes - B75 8-NONE-2
tcsetattr(TCSADRAIN, B75) - OK
-set_attributes - B75 5-NONE-1
+set_attributes - B75 8-NONE-2
+tcsetattr(TCSAFLUSH, B75) - OK
+set_attributes - B75 8-NONE-2
tcsetattr(TCSANOW, B110) - OK
-set_attributes - B110 5-NONE-1
+set_attributes - B110 8-NONE-2
tcsetattr(TCSADRAIN, B110) - OK
-set_attributes - B110 5-NONE-1
+set_attributes - B110 8-NONE-2
+tcsetattr(TCSAFLUSH, B110) - OK
+set_attributes - B110 8-NONE-2
tcsetattr(TCSANOW, B134) - OK
-set_attributes - B134 5-NONE-1
+set_attributes - B134 8-NONE-2
tcsetattr(TCSADRAIN, B134) - OK
-set_attributes - B134 5-NONE-1
+set_attributes - B134 8-NONE-2
+tcsetattr(TCSAFLUSH, B134) - OK
+set_attributes - B134 8-NONE-2
tcsetattr(TCSANOW, B150) - OK
-set_attributes - B150 5-NONE-1
+set_attributes - B150 8-NONE-2
tcsetattr(TCSADRAIN, B150) - OK
-set_attributes - B150 5-NONE-1
+set_attributes - B150 8-NONE-2
+tcsetattr(TCSAFLUSH, B150) - OK
+set_attributes - B150 8-NONE-2
tcsetattr(TCSANOW, B200) - OK
-set_attributes - B200 5-NONE-1
+set_attributes - B200 8-NONE-2
tcsetattr(TCSADRAIN, B200) - OK
-set_attributes - B200 5-NONE-1
+set_attributes - B200 8-NONE-2
+tcsetattr(TCSAFLUSH, B200) - OK
+set_attributes - B200 8-NONE-2
tcsetattr(TCSANOW, B300) - OK
-set_attributes - B300 5-NONE-1
+set_attributes - B300 8-NONE-2
tcsetattr(TCSADRAIN, B300) - OK
-set_attributes - B300 5-NONE-1
+set_attributes - B300 8-NONE-2
+tcsetattr(TCSAFLUSH, B300) - OK
+set_attributes - B300 8-NONE-2
tcsetattr(TCSANOW, B600) - OK
-set_attributes - B600 5-NONE-1
+set_attributes - B600 8-NONE-2
tcsetattr(TCSADRAIN, B600) - OK
-set_attributes - B600 5-NONE-1
+set_attributes - B600 8-NONE-2
+tcsetattr(TCSAFLUSH, B600) - OK
+set_attributes - B600 8-NONE-2
tcsetattr(TCSANOW, B1200) - OK
-set_attributes - B1200 5-NONE-1
+set_attributes - B1200 8-NONE-2
tcsetattr(TCSADRAIN, B1200) - OK
-set_attributes - B1200 5-NONE-1
+set_attributes - B1200 8-NONE-2
+tcsetattr(TCSAFLUSH, B1200) - OK
+set_attributes - B1200 8-NONE-2
tcsetattr(TCSANOW, B1800) - OK
-set_attributes - B1800 5-NONE-1
+set_attributes - B1800 8-NONE-2
tcsetattr(TCSADRAIN, B1800) - OK
-set_attributes - B1800 5-NONE-1
+set_attributes - B1800 8-NONE-2
+tcsetattr(TCSAFLUSH, B1800) - OK
+set_attributes - B1800 8-NONE-2
tcsetattr(TCSANOW, B2400) - OK
-set_attributes - B2400 5-NONE-1
+set_attributes - B2400 8-NONE-2
tcsetattr(TCSADRAIN, B2400) - OK
-set_attributes - B2400 5-NONE-1
+set_attributes - B2400 8-NONE-2
+tcsetattr(TCSAFLUSH, B2400) - OK
+set_attributes - B2400 8-NONE-2
tcsetattr(TCSANOW, B4800) - OK
-set_attributes - B4800 5-NONE-1
+set_attributes - B4800 8-NONE-2
tcsetattr(TCSADRAIN, B4800) - OK
-set_attributes - B4800 5-NONE-1
+set_attributes - B4800 8-NONE-2
+tcsetattr(TCSAFLUSH, B4800) - OK
+set_attributes - B4800 8-NONE-2
tcsetattr(TCSANOW, B9600) - OK
-set_attributes - B9600 5-NONE-1
+set_attributes - B9600 8-NONE-2
tcsetattr(TCSADRAIN, B9600) - OK
-set_attributes - B9600 5-NONE-1
+set_attributes - B9600 8-NONE-2
+tcsetattr(TCSAFLUSH, B9600) - OK
+set_attributes - B9600 8-NONE-2
tcsetattr(TCSANOW, B19200) - OK
-set_attributes - B19200 5-NONE-1
+set_attributes - B19200 8-NONE-2
tcsetattr(TCSADRAIN, B19200) - OK
-set_attributes - B19200 5-NONE-1
+set_attributes - B19200 8-NONE-2
+tcsetattr(TCSAFLUSH, B19200) - OK
+set_attributes - B19200 8-NONE-2
tcsetattr(TCSANOW, B38400) - OK
-set_attributes - B38400 5-NONE-1
+set_attributes - B38400 8-NONE-2
tcsetattr(TCSADRAIN, B38400) - OK
-set_attributes - B38400 5-NONE-1
+set_attributes - B38400 8-NONE-2
+tcsetattr(TCSAFLUSH, B38400) - OK
+set_attributes - B38400 8-NONE-2
+tcsetattr(TCSANOW, B7200) - OK
+set_attributes - B7200 8-NONE-2
+tcsetattr(TCSADRAIN, B7200) - OK
+set_attributes - B7200 8-NONE-2
+tcsetattr(TCSAFLUSH, B7200) - OK
+set_attributes - B7200 8-NONE-2
+tcsetattr(TCSANOW, B14400) - OK
+set_attributes - B14400 8-NONE-2
+tcsetattr(TCSADRAIN, B14400) - OK
+set_attributes - B14400 8-NONE-2
+tcsetattr(TCSAFLUSH, B14400) - OK
+set_attributes - B14400 8-NONE-2
+tcsetattr(TCSANOW, B28800) - OK
+set_attributes - B28800 8-NONE-2
+tcsetattr(TCSADRAIN, B28800) - OK
+set_attributes - B28800 8-NONE-2
+tcsetattr(TCSAFLUSH, B28800) - OK
+set_attributes - B28800 8-NONE-2
tcsetattr(TCSANOW, B57600) - OK
-set_attributes - B57600 5-NONE-1
+set_attributes - B57600 8-NONE-2
tcsetattr(TCSADRAIN, B57600) - OK
-set_attributes - B57600 5-NONE-1
+set_attributes - B57600 8-NONE-2
+tcsetattr(TCSAFLUSH, B57600) - OK
+set_attributes - B57600 8-NONE-2
+tcsetattr(TCSANOW, B76800) - OK
+set_attributes - B76800 8-NONE-2
+tcsetattr(TCSADRAIN, B76800) - OK
+set_attributes - B76800 8-NONE-2
+tcsetattr(TCSAFLUSH, B76800) - OK
+set_attributes - B76800 8-NONE-2
tcsetattr(TCSANOW, B115200) - OK
-set_attributes - B115200 5-NONE-1
+set_attributes - B115200 8-NONE-2
tcsetattr(TCSADRAIN, B115200) - OK
-set_attributes - B115200 5-NONE-1
+set_attributes - B115200 8-NONE-2
+tcsetattr(TCSAFLUSH, B115200) - OK
+set_attributes - B115200 8-NONE-2
tcsetattr(TCSANOW, B230400) - OK
-set_attributes - B230400 5-NONE-1
+set_attributes - B230400 8-NONE-2
tcsetattr(TCSADRAIN, B230400) - OK
-set_attributes - B230400 5-NONE-1
+set_attributes - B230400 8-NONE-2
+tcsetattr(TCSAFLUSH, B230400) - OK
+set_attributes - B230400 8-NONE-2
tcsetattr(TCSANOW, B460800) - OK
-set_attributes - B460800 5-NONE-1
+set_attributes - B460800 8-NONE-2
tcsetattr(TCSADRAIN, B460800) - OK
-set_attributes - B460800 5-NONE-1
+set_attributes - B460800 8-NONE-2
+tcsetattr(TCSAFLUSH, B460800) - OK
+set_attributes - B460800 8-NONE-2
+tcsetattr(TCSANOW, B921600) - OK
+set_attributes - B921600 8-NONE-2
+tcsetattr(TCSADRAIN, B921600) - OK
+set_attributes - B921600 8-NONE-2
+tcsetattr(TCSAFLUSH, B921600) - OK
+set_attributes - B921600 8-NONE-2
Init - close - /dev/test - OK
Init - open - /dev/test - OK
@@ -168,21 +254,37 @@ Termios_test_driver - rtems_set_initial_baud - 38400 - OK
Test termios setting device character size ...
tcsetattr(TCSANOW, CS5) - OK
-set_attributes - B38400 5-NONE-1
+set_attributes - B38400 5-NONE-2
tcsetattr(TCSADRAIN, CS5) - OK
-set_attributes - B38400 5-NONE-1
+set_attributes - B38400 5-NONE-2
+tcsetattr(TCSAFLUSH, CS5) - OK
+set_attributes - B38400 5-NONE-2
+tcsetattr(TCSASOFT, CS5) - OK
+set_attributes - B38400 5-NONE-2
tcsetattr(TCSANOW, CS6) - OK
-set_attributes - B38400 6-NONE-1
+set_attributes - B38400 6-NONE-2
tcsetattr(TCSADRAIN, CS6) - OK
-set_attributes - B38400 6-NONE-1
+set_attributes - B38400 6-NONE-2
+tcsetattr(TCSAFLUSH, CS6) - OK
+set_attributes - B38400 6-NONE-2
+tcsetattr(TCSASOFT, CS6) - OK
+set_attributes - B38400 6-NONE-2
tcsetattr(TCSANOW, CS7) - OK
-set_attributes - B38400 7-NONE-1
+set_attributes - B38400 7-NONE-2
tcsetattr(TCSADRAIN, CS7) - OK
-set_attributes - B38400 7-NONE-1
+set_attributes - B38400 7-NONE-2
+tcsetattr(TCSAFLUSH, CS7) - OK
+set_attributes - B38400 7-NONE-2
+tcsetattr(TCSASOFT, CS7) - OK
+set_attributes - B38400 7-NONE-2
tcsetattr(TCSANOW, CS8) - OK
-set_attributes - B38400 8-NONE-1
+set_attributes - B38400 8-NONE-2
tcsetattr(TCSADRAIN, CS8) - OK
-set_attributes - B38400 8-NONE-1
+set_attributes - B38400 8-NONE-2
+tcsetattr(TCSAFLUSH, CS8) - OK
+set_attributes - B38400 8-NONE-2
+tcsetattr(TCSASOFT, CS8) - OK
+set_attributes - B38400 8-NONE-2
Init - close - /dev/test - OK
Init - open - /dev/test - OK
@@ -191,17 +293,29 @@ Termios_test_driver - rtems_set_initial_baud - 38400 - OK
Test termios setting device parity ...
tcsetattr(TCSANOW, none) - OK
-set_attributes - B38400 8-NONE-1
+set_attributes - B38400 8-NONE-2
tcsetattr(TCSADRAIN, none) - OK
-set_attributes - B38400 8-NONE-1
+set_attributes - B38400 8-NONE-2
+tcsetattr(TCSAFLUSH, none) - OK
+set_attributes - B38400 8-NONE-2
+tcsetattr(TCSASOFT, none) - OK
+set_attributes - B38400 8-NONE-2
tcsetattr(TCSANOW, even) - OK
-set_attributes - B38400 8-ODD-1
+set_attributes - B38400 8-ODD-2
tcsetattr(TCSADRAIN, even) - OK
-set_attributes - B38400 8-ODD-1
+set_attributes - B38400 8-ODD-2
+tcsetattr(TCSAFLUSH, even) - OK
+set_attributes - B38400 8-ODD-2
+tcsetattr(TCSASOFT, even) - OK
+set_attributes - B38400 8-ODD-2
tcsetattr(TCSANOW, odd) - OK
-set_attributes - B38400 8-EVEN-1
+set_attributes - B38400 8-EVEN-2
tcsetattr(TCSADRAIN, odd) - OK
-set_attributes - B38400 8-EVEN-1
+set_attributes - B38400 8-EVEN-2
+tcsetattr(TCSAFLUSH, odd) - OK
+set_attributes - B38400 8-EVEN-2
+tcsetattr(TCSASOFT, odd) - OK
+set_attributes - B38400 8-EVEN-2
Init - close - /dev/test - OK
Init - open - /dev/test - OK
@@ -213,10 +327,18 @@ tcsetattr(TCSANOW, 1 bit) - OK
set_attributes - B38400 8-NONE-1
tcsetattr(TCSADRAIN, 1 bits) - OK
set_attributes - B38400 8-NONE-1
+tcsetattr(TCSAFLUSH, 1 bits) - OK
+set_attributes - B38400 8-NONE-1
+tcsetattr(TCSASOFT, 1 bits) - OK
+set_attributes - B38400 8-NONE-1
tcsetattr(TCSANOW, 2 bits) - OK
set_attributes - B38400 8-NONE-2
tcsetattr(TCSADRAIN, 2 bits) - OK
set_attributes - B38400 8-NONE-2
+tcsetattr(TCSAFLUSH, 2 bits) - OK
+set_attributes - B38400 8-NONE-2
+tcsetattr(TCSASOFT, 2 bits) - OK
+set_attributes - B38400 8-NONE-2
cfsetospeed(BAD BAUD) - EINVAL
cfsetospeed(B0) - OK
cfgetospeed(B0) - OK
@@ -250,14 +372,24 @@ cfsetospeed(B19200) - OK
cfgetospeed(B19200) - OK
cfsetospeed(B38400) - OK
cfgetospeed(B38400) - OK
+cfsetospeed(B7200) - OK
+cfgetospeed(B7200) - OK
+cfsetospeed(B14400) - OK
+cfgetospeed(B14400) - OK
+cfsetospeed(B28800) - OK
+cfgetospeed(B28800) - OK
cfsetospeed(B57600) - OK
cfgetospeed(B57600) - OK
+cfsetospeed(B76800) - OK
+cfgetospeed(B76800) - OK
cfsetospeed(B115200) - OK
cfgetospeed(B115200) - OK
cfsetospeed(B230400) - OK
cfgetospeed(B230400) - OK
cfsetospeed(B460800) - OK
cfgetospeed(B460800) - OK
+cfsetospeed(B921600) - OK
+cfgetospeed(B921600) - OK
cfsetispeed(BAD BAUD) - EINVAL
cfsetispeed(B0) - OK
cfgetispeed(B0) - OK
@@ -291,14 +423,24 @@ cfsetispeed(B19200) - OK
cfgetispeed(B19200) - OK
cfsetispeed(B38400) - OK
cfgetispeed(B38400) - OK
+cfsetispeed(B7200) - OK
+cfgetispeed(B7200) - OK
+cfsetispeed(B14400) - OK
+cfgetispeed(B14400) - OK
+cfsetispeed(B28800) - OK
+cfgetispeed(B28800) - OK
cfsetispeed(B57600) - OK
cfgetispeed(B57600) - OK
+cfsetispeed(B76800) - OK
+cfgetispeed(B76800) - OK
cfsetispeed(B115200) - OK
cfgetispeed(B115200) - OK
cfsetispeed(B230400) - OK
cfgetispeed(B230400) - OK
cfsetispeed(B460800) - OK
cfgetispeed(B460800) - OK
+cfsetispeed(B921600) - OK
+cfgetispeed(B921600) - OK
cfsetspeed(BAD BAUD) - EINVAL
cfsetspeed(B0) - OK
cfgetspeed(B0) - checking both inspeed and outspeed - OK
@@ -332,14 +474,24 @@ cfsetspeed(B19200) - OK
cfgetspeed(B19200) - checking both inspeed and outspeed - OK
cfsetspeed(B38400) - OK
cfgetspeed(B38400) - checking both inspeed and outspeed - OK
+cfsetspeed(B7200) - OK
+cfgetspeed(B7200) - checking both inspeed and outspeed - OK
+cfsetspeed(B14400) - OK
+cfgetspeed(B14400) - checking both inspeed and outspeed - OK
+cfsetspeed(B28800) - OK
+cfgetspeed(B28800) - checking both inspeed and outspeed - OK
cfsetspeed(B57600) - OK
cfgetspeed(B57600) - checking both inspeed and outspeed - OK
+cfsetspeed(B76800) - OK
+cfgetspeed(B76800) - checking both inspeed and outspeed - OK
cfsetspeed(B115200) - OK
cfgetspeed(B115200) - checking both inspeed and outspeed - OK
cfsetspeed(B230400) - OK
cfgetspeed(B230400) - checking both inspeed and outspeed - OK
cfsetspeed(B460800) - OK
cfgetspeed(B460800) - checking both inspeed and outspeed - OK
+cfsetspeed(B921600) - OK
+cfgetspeed(B921600) - checking both inspeed and outspeed - OK
Init - close - /dev/test - OK
Multiple open of the device
Termios_test_driver - rtems_set_initial_baud - bad baud - OK
@@ -395,4 +547,4 @@ Termios_test_driver - rtems_set_initial_baud - 38400 - OK
Termios_test_driver - rtems_set_initial_baud - bad baud - OK
Termios_test_driver - rtems_set_initial_baud - 38400 - OK
-*** END OF TEST TERMIOS 01 ***
+*** END OF TEST TERMIOS 1 ***
diff --git a/testsuites/libtests/termios01/termios_testdriver.c b/testsuites/libtests/termios01/termios_testdriver.c
index 43aeccd284..bd5c7a12d2 100644
--- a/testsuites/libtests/termios01/termios_testdriver.c
+++ b/testsuites/libtests/termios01/termios_testdriver.c
@@ -85,7 +85,7 @@ int termios_test_driver_set_attributes(
const char *char_size = "5";
const char *stop = "NONE";
- baud_requested = t->c_cflag & CBAUD;
+ baud_requested = t->c_ispeed;
number = rtems_termios_baud_to_number( baud_requested );
@@ -164,7 +164,7 @@ rtems_device_driver termios_test_driver_open(
int rc;
rtems_libio_open_close_args_t *args = arg;
static bool firstCall = true;
-
+
static const rtems_termios_callbacks Callbacks = {
NULL, /* firstOpen */
NULL, /* lastClose */
@@ -192,7 +192,7 @@ rtems_device_driver termios_test_driver_open(
size_t i;
firstCall = false;
-
+
for (i = 0; i < sizeof( allocSizes ) / sizeof( allocSizes [0] ); ++i) {
void *opaque = rtems_heap_greedy_allocate( allocSizes, i );
diff --git a/testsuites/libtests/termios02/termios02.scn b/testsuites/libtests/termios02/termios02.scn
index 9b38d69ba1..be46893122 100644
--- a/testsuites/libtests/termios02/termios02.scn
+++ b/testsuites/libtests/termios02/termios02.scn
@@ -1,4 +1,4 @@
-*** TERMIOS 02 TEST ***
+*** BEGIN OF TEST TERMIOS 2 ***
tcdrain(12) - EBADF
tcdrain(stdin) - OK
tcdrain(stdout) - OK
@@ -24,4 +24,4 @@ ctermid( NULL ) - OK
ctermid ==> /dev/console
ctermid( term_name ) - OK
ctermid ==> /dev/console
-*** END OF TERMIOS 02 TEST ***
+*** END OF TEST TERMIOS 2 ***
diff --git a/testsuites/libtests/termios03/termios03.scn b/testsuites/libtests/termios03/termios03.scn
index 17802fed0e..ed4a7846e5 100644
--- a/testsuites/libtests/termios03/termios03.scn
+++ b/testsuites/libtests/termios03/termios03.scn
@@ -1,4 +1,4 @@
-*** TEST TERMIOS03 ***
+*** BEGIN OF TEST TERMIOS 3 ***
open(/dev/test) - OK
Writing: This is test output.
Transmitted 22 characters
@@ -68,7 +68,7 @@ Echoed 55 characters
54 65 73 74 69 6e 67 20 56 4b 49 4c 4c 08 20 08 |Testing VKILL. .|
08 20 08 08 20 08 08 20 08 08 20 08 08 20 08 08 |. .. .. .. .. ..|
20 08 08 20 08 08 20 08 08 20 08 08 20 08 08 20 | .. .. .. .. .. |
-08 08 20 08 2e 0d 0a
+08 08 20 08 2e 0d 0a |.. .... |
Reading (expected):
7f 54 65 73 74 69 6e 67 20 56 45 52 41 53 45 20 |.Testing VERASE |
@@ -97,4 +97,4 @@ Echoed 140 characters
20 08 08 08 08 08 08 08 08 08 0d 0a | ........... |
close(/dev/test) - OK
-*** END OF TEST TERMIOS03 ***
+*** END OF TEST TERMIOS 3 ***
diff --git a/testsuites/libtests/termios04/termios04.scn b/testsuites/libtests/termios04/termios04.scn
index 99b8eb01f5..812369a4d5 100644
--- a/testsuites/libtests/termios04/termios04.scn
+++ b/testsuites/libtests/termios04/termios04.scn
@@ -1,5 +1,5 @@
-*** TEST TERMIOS04 ***
-open(/dev/test) - OK
+*** BEGIN OF TEST TERMIOS 4 ***
+open(/dev/test) - OK
Writing: This is interrupt driven test output.
Transmitted 39 characters
54 68 69 73 20 69 73 20 69 6e 74 65 72 72 75 70 |This is interrup|
@@ -29,5 +29,5 @@ As Read 37 characters
4e 6f 6e 2d 42 6c 6f 63 6b 69 6e 67 20 69 6e 74 |Non-Blocking int|
65 72 72 75 70 74 20 64 72 69 76 65 6e 20 72 65 |errupt driven re|
61 64 2e 0d 0a |ad... |
-close(/dev/test) - OK
-*** END OF TEST TERMIOS04 ***
+close(/dev/test) - OK
+*** END OF TEST TERMIOS 4 ***
diff --git a/testsuites/libtests/termios05/termios05.scn b/testsuites/libtests/termios05/termios05.scn
index 4d2988f86d..e30a24389c 100644
--- a/testsuites/libtests/termios05/termios05.scn
+++ b/testsuites/libtests/termios05/termios05.scn
@@ -1,5 +1,5 @@
-*** TEST TERMIOS05 ***
-open(/dev/test) - OK
+*** BEGIN OF TEST TERMIOS 5 ***
+open(/dev/test) - OK
Writing: This is test output.
Transmitted 20 characters
54 68 69 73 20 69 73 20 74 65 73 74 20 6f 75 74 |This is test out|
@@ -55,5 +55,5 @@ Read 10 bytes from read(2)
Echoed 12 characters
0a 61 62 63 64 65 66 67 68 2e 0d 0a |.abcdefgh... |
Changing c_iflag to: Disable to lower case mapping on input
-close(/dev/test) - OK
-*** END OF TEST TERMIOS05 ***
+close(/dev/test) - OK
+*** END OF TEST TERMIOS 5 ***
diff --git a/testsuites/libtests/termios06/init.c b/testsuites/libtests/termios06/init.c
index 759b4444c7..9b59ad2fb9 100644
--- a/testsuites/libtests/termios06/init.c
+++ b/testsuites/libtests/termios06/init.c
@@ -198,7 +198,7 @@ rtems_task Init(
ioctl_it();
read_it();
close_it();
-
+
TEST_END();
rtems_test_exit(0);
diff --git a/testsuites/libtests/termios06/termios06.scn b/testsuites/libtests/termios06/termios06.scn
index b558077daa..1039597239 100644
--- a/testsuites/libtests/termios06/termios06.scn
+++ b/testsuites/libtests/termios06/termios06.scn
@@ -1,7 +1,5 @@
-
-
-*** TEST TERMIOS06 ***
-open(/dev/test) - OK
+*** BEGIN OF TEST TERMIOS 6 ***
+open(/dev/test) - OK
ioctl - RTEMS_IO_SNDWAKEUP - OK
ioctl - RTEMS_IO_RCVWAKEUP - OK
ioctl - TIOCGETD - OK
@@ -10,14 +8,13 @@ pppopen called
ioctl - TIOCSETD - OK
pppclose called
pppopen called
-write(PPPD TEST) - OK
+write(PPPD TEST) - OK
pppwrite called - 10 bytes
50 50 50 44 20 54 45 53 54 00 |PPPD TEST. |
-
pppstart called
-ioctl(/dev/test) - OK
+ioctl(/dev/test) - OK
pppioctl called
-tcgetattr(/dev/test) - OK
+tcgetattr(/dev/test) - OK
Turn on flow control on output - OK
Turn off flow control on output - OK
Turn on flow control on input - OK
@@ -25,9 +22,7 @@ Turn off flow control on input - OK
Reading (expected):
54 68 69 73 20 69 73 20 74 65 73 74 20 50 50 50 |This is test PPP|
-
20 69 6e 70 75 74 | input |
-
pppread called
pppinput called - with (T)
pppinput called - with (h)
@@ -53,8 +48,7 @@ pppinput called - with (u)
pppinput called - with (t)
pppinput called - with (.)
Rx_Wake - invoked
-
Read 0 bytes from read(2)
-close(/dev/test) - OK
+Error: length must be greater than zero.close(/dev/test) - OK
pppclose called
-*** END OF TEST TERMIOS06 ***
+*** END OF TEST TERMIOS 6 ***
diff --git a/testsuites/libtests/termios07/termios07.scn b/testsuites/libtests/termios07/termios07.scn
index a63612096b..e5630dbf59 100644
--- a/testsuites/libtests/termios07/termios07.scn
+++ b/testsuites/libtests/termios07/termios07.scn
@@ -1 +1,20 @@
-XXX fill in with test output
+*** BEGIN OF TEST TERMIOS 7 ***
+rtems_termios_bufsize( 64, 64, 64 ) - OK
+open(/dev/test) - OK
+Changing c_iflag to: Set XON/XOFF
+Writing: 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Transmitted 200 characters
+30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 |0123456789012345|
+36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 |6789012345678901|
+32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 |2345678901234567|
+38 39 30 31 32 33 34 35 36 37 38 39 30 31 32 33 |8901234567890123|
+34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 |4567890123456789|
+30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 |0123456789012345|
+36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 |6789012345678901|
+32 33 34 35 36 37 38 39 30 31 32 33 34 35 36 37 |2345678901234567|
+38 39 30 31 32 33 34 35 36 37 38 39 30 31 32 33 |8901234567890123|
+34 35 36 37 38 39 30 31 32 33 34 35 36 37 38 39 |4567890123456789|
+30 31 32 33 34 35 36 37 38 39 30 31 32 33 34 35 |0123456789012345|
+36 37 38 39 30 31 32 33 34 35 36 37 38 39 30 31 |6789012345678901|
+32 33 34 35 36 37 38 39 |23456789 |
+close(/dev/test) - OK
+*** END OF TEST TERMIOS 7 ***
diff --git a/testsuites/libtests/termios08/termios08.scn b/testsuites/libtests/termios08/termios08.scn
index a63612096b..469d537e0f 100644
--- a/testsuites/libtests/termios08/termios08.scn
+++ b/testsuites/libtests/termios08/termios08.scn
@@ -1 +1,18 @@
-XXX fill in with test output
+*** BEGIN OF TEST TERMIOS 8 ***
+open(/dev/test) - OK
+Changing c_lflag to: non-canonical
+Changing to polling - VMIN=0 VTIME=0
+read - 0 expected
+Changing to half-second timeout - VMIN=0 VTIME=5
+read - 0 expected
+Changing to half-second timeout - VMIN=5 VTIME=3
+Enqueue 2 characters
+read - 2 expected
+Changing to half-second timeout - VMIN=5 VTIME=3
+Enqueue 1 character
+read - 1 expected
+Enqueue 7 characters
+read - 5 expected
+read - 2 expected
+close(/dev/test) - OK
+*** END OF TEST TERMIOS 8 ***
diff --git a/tools/cpu/sh/sci.c b/tools/cpu/sh/sci.c
index a092bce9ae..2b68612f2c 100644
--- a/tools/cpu/sh/sci.c
+++ b/tools/cpu/sh/sci.c
@@ -43,10 +43,15 @@ static unsigned int bitrate [] = {
9600,
19200,
38400,
+ 7200,
+ 14400,
+ 28800,
57600,
+ 76800,
115200,
230400,
- 460800
+ 460800,
+ 921600
};
static sci_tab_t test_array[4] ;
@@ -123,8 +128,9 @@ int shgen_gensci(
"static struct sci_bitrate_t {\n"
" unsigned char n ;\n"
" unsigned char N ;\n"
+ " speed_t B ;\n"
"} _sci_bitrates[] = {\n"
- "/* n N error */\n" );
+ "/* n N B error */\n" );
for ( i = 0 ; i < sizeof(bitrate)/sizeof(int) ; i++ )
{
@@ -132,9 +138,10 @@ int shgen_gensci(
if ( i > 0 )
fprintf( file, ",\n" );
- fprintf( file, " { %1d, %3d } /* %+7.2f%% ; B%d ",
+ fprintf( file, " { %1d, %3d, %d } /* %+7.2f%% ; B%d ",
best->n,
best->N,
+ best->B,
best->err,
best->B );
if ( best->n > 3 )
@@ -146,15 +153,19 @@ int shgen_gensci(
fprintf( file,
"int _sci_get_brparms( \n"
- " tcflag_t cflag,\n"
+ " speed_t spd,\n"
" unsigned char *smr,\n"
" unsigned char *brr )\n"
"{\n"
- " unsigned int offset ;\n\n"
- " offset = ( cflag & ( CBAUD & ~CBAUDEX ) )\n"
- " + ( ( cflag & CBAUDEX ) ? B38400 : 0 );\n"
- " if ( offset == 0 ) return -1 ;\n"
- " offset-- ;\n\n"
+ " int offset = -1;\n"
+ " int i;\n\n"
+ " for(i = 0; i < sizeof(_sci_bitrates)/sizeof(_sci_bitrates[0]); i++) {\n"
+ " if( _sci_bitrates[i].B == spd ) {\n"
+ " offset = i;\n"
+ " break;\n"
+ " }\n"
+ " }\n"
+ " if ( offset == -1 ) return -1 ;\n"
" if ( _sci_bitrates[offset].n > 3 ) return -1;\n\n"
" *smr &= ~0x03;\n"
" *smr |= _sci_bitrates[offset].n;\n"