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.
This commit is contained in:
Kevin Kirspel
2017-03-21 15:39:48 -04:00
committed by Sebastian Huber
parent c4b058ca48
commit 1c6926c11f
77 changed files with 1396 additions and 661 deletions

View File

@@ -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)

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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));

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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 ;
}