]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/l4re_vfs/include/impl/vcon_stream_impl.h
update
[l4.git] / l4 / pkg / l4re_vfs / include / impl / vcon_stream_impl.h
index f4e92dcf1bdefa4ce15d94c94d8ee3e8afec9a36..1c29c5a9f85131391ee835dd2f643380aa2e9821 100644 (file)
 #include "vcon_stream.h"
 #include "vfs_api.h"
 
+#include <termios.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
 namespace L4Re { namespace Core {
 Vcon_stream::Vcon_stream(L4::Cap<L4::Vcon> s) throw()
-: Be_file(), _s(s)
+: Be_file(), _s(s), _irq(cap_alloc()->alloc<L4::Irq>())
 {
 #if 1
-  //printf("VCON: create IRQ\n");
-  _irq = cap_alloc()->alloc<L4::Irq>();
   //printf("VCON: irq cap = %lx\n", _irq.cap());
   int res = l4_error(L4Re::Env::env()->factory()->create_irq(_irq));
   //printf("VCON: irq create res=%d\n", res);
@@ -72,7 +74,7 @@ Vcon_stream::readv(const struct iovec *iovec, int iovcnt) throw()
                return bytes;
 
              _irq->detach();
-             _irq->attach(12, L4_IRQ_F_NONE, L4::Cap<L4::Thread>::Invalid);
+             _irq->attach(12, L4::Cap<L4::Thread>::Invalid);
              ret = _s->read(buf, len);
              if (ret < 0)
                return ret;
@@ -136,4 +138,73 @@ Vcon_stream::fstat64(struct stat64 *buf) const throw()
   return 0;
 }
 
+int
+Vcon_stream::ioctl(unsigned long request, va_list args) throw()
+{
+  switch (request) {
+    case TCGETS:
+       {
+         //vt100_tcgetattr(term, (struct termios *)argp);
+
+         struct termios *t = va_arg(args, struct termios *);
+
+         l4_vcon_attr_t l4a;
+         if (!l4_error(_s->get_attr(&l4a)))
+            {
+              t->c_iflag = l4a.i_flags;
+              t->c_oflag = l4a.o_flags; // output flags
+              t->c_cflag = 0; // control flags
+              t->c_lflag = l4a.l_flags; // local flags
+            }
+          else
+            t->c_iflag = t->c_oflag = t->c_cflag = t->c_lflag = 0;
+#if 0
+         //t->c_lflag |= ECHO; // if term->echo
+         t->c_lflag |= ICANON; // if term->term_mode == VT100MODE_COOKED
+#endif
+
+         t->c_cc[VEOF]   = CEOF;
+         t->c_cc[VEOL]   = _POSIX_VDISABLE;
+         t->c_cc[VEOL2]  = _POSIX_VDISABLE;
+         t->c_cc[VERASE] = CERASE;
+         t->c_cc[VWERASE]= CWERASE;
+         t->c_cc[VKILL]  = CKILL;
+         t->c_cc[VREPRINT]=CREPRINT;
+         t->c_cc[VINTR]  = CINTR;
+         t->c_cc[VQUIT]  = _POSIX_VDISABLE;
+         t->c_cc[VSUSP]  = CSUSP;
+         t->c_cc[VSTART] = CSTART;
+         t->c_cc[VSTOP] = CSTOP;
+         t->c_cc[VLNEXT] = CLNEXT;
+         t->c_cc[VDISCARD]=CDISCARD;
+         t->c_cc[VMIN] = CMIN;
+         t->c_cc[VTIME] = 0;
+
+       }
+
+      return 0;
+
+    case TCSETS:
+    case TCSETSW:
+    case TCSETSF:
+       {
+         //vt100_tcsetattr(term, (struct termios *)argp);
+         struct termios const *t = va_arg(args, struct termios const *);
+
+         // XXX: well, we're cheating, get this from the other side!
+
+         l4_vcon_attr_t l4a;
+         l4a.i_flags = t->c_iflag;
+         l4a.o_flags = t->c_oflag; // output flags
+         l4a.l_flags = t->c_lflag; // local flags
+         _s->set_attr(&l4a);
+       }
+      return 0;
+
+    default:
+      break;
+  };
+  return -EINVAL;
+}
+
 }}