diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-05-22 14:51:11 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-05-22 14:51:11 +0000 |
commit | 119bced0fd63d7651a27cdf2f738b7cb4b0d9c10 (patch) | |
tree | 576d37ede74625e54a227c09e67ae4d6db7b3f0a /c/src | |
parent | Added tcdrain(), cfgetospeed(), cfsetospeed(), cfgetispeed(), and cfsetispeed(). (diff) | |
download | rtems-119bced0fd63d7651a27cdf2f738b7cb4b0d9c10.tar.bz2 |
Added tcdrain(), cfgetospeed(0, cfsetospeed(), cfgetispeed(), and
cfsetispeed().
Diffstat (limited to '')
-rw-r--r-- | c/src/exec/libcsupport/src/tcdrain.c | 26 | ||||
-rw-r--r-- | c/src/exec/libcsupport/src/termios.c | 30 | ||||
-rw-r--r-- | c/src/lib/libc/cfiospeed.c | 54 | ||||
-rw-r--r-- | c/src/lib/libc/tcattr.c | 6 | ||||
-rw-r--r-- | c/src/lib/libc/tcdrain.c | 26 | ||||
-rw-r--r-- | c/src/lib/libc/termios.c | 30 |
6 files changed, 166 insertions, 6 deletions
diff --git a/c/src/exec/libcsupport/src/tcdrain.c b/c/src/exec/libcsupport/src/tcdrain.c new file mode 100644 index 0000000000..585871cc90 --- /dev/null +++ b/c/src/exec/libcsupport/src/tcdrain.c @@ -0,0 +1,26 @@ +/* + * This file contains the RTEMS implementation of the POSIX API + * routines tcdrain. + * + * $Id$ + * + */ + +#include <rtems.h> +#if defined(RTEMS_NEWLIB) + +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <termios.h> + +#include "internal.h" +#include "libio.h" + +int +tcdrain(int fd) +{ + return __rtems_ioctl(fd,RTEMS_IO_TCDRAIN,0); +} + +#endif diff --git a/c/src/exec/libcsupport/src/termios.c b/c/src/exec/libcsupport/src/termios.c index b2d1bb1499..648e2c0c3e 100644 --- a/c/src/exec/libcsupport/src/termios.c +++ b/c/src/exec/libcsupport/src/termios.c @@ -297,6 +297,31 @@ rtems_termios_open ( return RTEMS_SUCCESSFUL; } +/* + * Drain output queue + */ +static void +drainOutput (struct rtems_termios_tty *tty) +{ + rtems_interrupt_level level; + rtems_status_code sc; + + if (tty->device.outputUsesInterrupts) { + rtems_interrupt_disable (level); + while (tty->rawOutBufTail != tty->rawOutBufHead) { + tty->rawOutBufState = rob_wait; + rtems_interrupt_enable (level); + sc = rtems_semaphore_obtain (tty->rawOutBufSemaphore, + RTEMS_WAIT, + RTEMS_NO_TIMEOUT); + if (sc != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred (sc); + rtems_interrupt_disable (level); + } + rtems_interrupt_enable (level); + } +} + rtems_status_code rtems_termios_close (void *arg) { @@ -308,6 +333,7 @@ rtems_termios_close (void *arg) if (sc != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred (sc); if (--tty->refcount == 0) { + drainOutput (tty); if (tty->device.lastClose) (*tty->device.lastClose)(tty->major, tty->minor, arg); if (tty->forw == NULL) @@ -384,6 +410,10 @@ rtems_termios_ioctl (void *arg) if (tty->device.setAttributes) (*tty->device.setAttributes)(tty->minor, &tty->termios); break; + + case RTEMS_IO_TCDRAIN: + drainOutput (tty); + break; } rtems_semaphore_release (tty->osem); args->ioctl_return = sc; diff --git a/c/src/lib/libc/cfiospeed.c b/c/src/lib/libc/cfiospeed.c new file mode 100644 index 0000000000..772d6083c9 --- /dev/null +++ b/c/src/lib/libc/cfiospeed.c @@ -0,0 +1,54 @@ +/* + * This file contains the RTEMS implementation of the POSIX API + * routines cfgetispeed, cfgetospeed, cfsetispeed and cfsetospeed. + * + * $Id$ + * + */ + +#include <rtems.h> +#if defined(RTEMS_NEWLIB) + +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <termios.h> + +#include "internal.h" +#include "libio.h" + +speed_t +cfgetospeed(const struct termios *tp) +{ + return tp->c_cflag & CBAUD; +} + +int +cfsetospeed(struct termios *tp, speed_t speed) +{ + if (speed & ~CBAUD) { + errno = EINVAL; + return -1; + } + tp->c_cflag = (tp->c_cflag & ~CBAUD) | speed; + return 0; +} + +speed_t +cfgetispeed(const struct termios *tp) +{ + return (tp->c_cflag / (CIBAUD / CBAUD)) & CBAUD; +} + +int +cfsetispeed(struct termios *tp, speed_t speed) +{ + if (speed & ~CBAUD) { + errno = EINVAL; + return -1; + } + tp->c_cflag = (tp->c_cflag & ~CBAUD) | (speed * (CIBAUD / CBAUD)); + return 0; +} + +#endif diff --git a/c/src/lib/libc/tcattr.c b/c/src/lib/libc/tcattr.c index 86c2569a94..aaa5ff6e6e 100644 --- a/c/src/lib/libc/tcattr.c +++ b/c/src/lib/libc/tcattr.c @@ -37,10 +37,4 @@ tcsetattr(int fd, int opt, struct termios *tp) return __rtems_ioctl(fd,RTEMS_IO_SET_ATTRIBUTES,tp); } -int -tcdrain(int fd) -{ - return __rtems_ioctl(fd,RTEMS_IO_TCDRAIN,0); -} - #endif diff --git a/c/src/lib/libc/tcdrain.c b/c/src/lib/libc/tcdrain.c new file mode 100644 index 0000000000..585871cc90 --- /dev/null +++ b/c/src/lib/libc/tcdrain.c @@ -0,0 +1,26 @@ +/* + * This file contains the RTEMS implementation of the POSIX API + * routines tcdrain. + * + * $Id$ + * + */ + +#include <rtems.h> +#if defined(RTEMS_NEWLIB) + +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <termios.h> + +#include "internal.h" +#include "libio.h" + +int +tcdrain(int fd) +{ + return __rtems_ioctl(fd,RTEMS_IO_TCDRAIN,0); +} + +#endif diff --git a/c/src/lib/libc/termios.c b/c/src/lib/libc/termios.c index b2d1bb1499..648e2c0c3e 100644 --- a/c/src/lib/libc/termios.c +++ b/c/src/lib/libc/termios.c @@ -297,6 +297,31 @@ rtems_termios_open ( return RTEMS_SUCCESSFUL; } +/* + * Drain output queue + */ +static void +drainOutput (struct rtems_termios_tty *tty) +{ + rtems_interrupt_level level; + rtems_status_code sc; + + if (tty->device.outputUsesInterrupts) { + rtems_interrupt_disable (level); + while (tty->rawOutBufTail != tty->rawOutBufHead) { + tty->rawOutBufState = rob_wait; + rtems_interrupt_enable (level); + sc = rtems_semaphore_obtain (tty->rawOutBufSemaphore, + RTEMS_WAIT, + RTEMS_NO_TIMEOUT); + if (sc != RTEMS_SUCCESSFUL) + rtems_fatal_error_occurred (sc); + rtems_interrupt_disable (level); + } + rtems_interrupt_enable (level); + } +} + rtems_status_code rtems_termios_close (void *arg) { @@ -308,6 +333,7 @@ rtems_termios_close (void *arg) if (sc != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred (sc); if (--tty->refcount == 0) { + drainOutput (tty); if (tty->device.lastClose) (*tty->device.lastClose)(tty->major, tty->minor, arg); if (tty->forw == NULL) @@ -384,6 +410,10 @@ rtems_termios_ioctl (void *arg) if (tty->device.setAttributes) (*tty->device.setAttributes)(tty->minor, &tty->termios); break; + + case RTEMS_IO_TCDRAIN: + drainOutput (tty); + break; } rtems_semaphore_release (tty->osem); args->ioctl_return = sc; |