summaryrefslogtreecommitdiffstats
path: root/c/src/exec/libcsupport
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-05-22 14:51:11 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-05-22 14:51:11 +0000
commit119bced0fd63d7651a27cdf2f738b7cb4b0d9c10 (patch)
tree576d37ede74625e54a227c09e67ae4d6db7b3f0a /c/src/exec/libcsupport
parentAdded tcdrain(), cfgetospeed(), cfsetospeed(), cfgetispeed(), and cfsetispeed(). (diff)
downloadrtems-119bced0fd63d7651a27cdf2f738b7cb4b0d9c10.tar.bz2
Added tcdrain(), cfgetospeed(0, cfsetospeed(), cfgetispeed(), and
cfsetispeed().
Diffstat (limited to 'c/src/exec/libcsupport')
-rw-r--r--c/src/exec/libcsupport/src/tcdrain.c26
-rw-r--r--c/src/exec/libcsupport/src/termios.c30
2 files changed, 56 insertions, 0 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;