From 119bced0fd63d7651a27cdf2f738b7cb4b0d9c10 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 22 May 1998 14:51:11 +0000 Subject: Added tcdrain(), cfgetospeed(0, cfsetospeed(), cfgetispeed(), and cfsetispeed(). --- cpukit/libcsupport/src/tcdrain.c | 26 ++++++++++++++++++++++++++ cpukit/libcsupport/src/termios.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 cpukit/libcsupport/src/tcdrain.c (limited to 'cpukit') diff --git a/cpukit/libcsupport/src/tcdrain.c b/cpukit/libcsupport/src/tcdrain.c new file mode 100644 index 0000000000..585871cc90 --- /dev/null +++ b/cpukit/libcsupport/src/tcdrain.c @@ -0,0 +1,26 @@ +/* + * This file contains the RTEMS implementation of the POSIX API + * routines tcdrain. + * + * $Id$ + * + */ + +#include +#if defined(RTEMS_NEWLIB) + +#include +#include +#include +#include + +#include "internal.h" +#include "libio.h" + +int +tcdrain(int fd) +{ + return __rtems_ioctl(fd,RTEMS_IO_TCDRAIN,0); +} + +#endif diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c index b2d1bb1499..648e2c0c3e 100644 --- a/cpukit/libcsupport/src/termios.c +++ b/cpukit/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; -- cgit v1.2.3