forked from Imagelibrary/rtems
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:
committed by
Sebastian Huber
parent
c4b058ca48
commit
1c6926c11f
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 ;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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 */
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user