Module Name: src
Committed By: jmcneill
Date: Sun Aug 28 21:19:49 UTC 2011
Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: thunk.c
Log Message:
add thunk_tcgetattr and thunk_tcsetattr
To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/usermode/usermode/thunk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.19 src/sys/arch/usermode/include/thunk.h:1.20
--- src/sys/arch/usermode/include/thunk.h:1.19 Sun Aug 28 19:37:15 2011
+++ src/sys/arch/usermode/include/thunk.h Sun Aug 28 21:19:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.19 2011/08/28 19:37:15 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.20 2011/08/28 21:19:49 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -48,6 +48,16 @@
struct thunk_timeval it_value;
};
+struct thunk_termios {
+ uint32_t c_iflag;
+ uint32_t c_oflag;
+ uint32_t c_cflag;
+ uint32_t c_lflag;
+ uint8_t c_cc[20];
+ int32_t c_ispeed;
+ int32_t c_ospeed;
+};
+
int thunk_setitimer(int, const struct thunk_itimerval *, struct thunk_itimerval *);
int thunk_gettimeofday(struct thunk_timeval *, void *);
unsigned int thunk_getcounter(void);
@@ -63,6 +73,9 @@
void thunk_makecontext_trapframe2go(ucontext_t *, void *func, void *trapframe);
int thunk_swapcontext(ucontext_t *, ucontext_t *);
+int thunk_tcgetattr(int, struct thunk_termios *);
+int thunk_tcsetattr(int, int, const struct thunk_termios *);
+
int thunk_getchar(void);
void thunk_putchar(int);
Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.21 src/sys/arch/usermode/usermode/thunk.c:1.22
--- src/sys/arch/usermode/usermode/thunk.c:1.21 Sun Aug 28 19:37:16 2011
+++ src/sys/arch/usermode/usermode/thunk.c Sun Aug 28 21:19:49 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.21 2011/08/28 19:37:16 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.22 2011/08/28 21:19:49 jmcneill Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: thunk.c,v 1.21 2011/08/28 19:37:16 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.22 2011/08/28 21:19:49 jmcneill Exp $");
#include <sys/types.h>
#include <sys/ansi.h>
@@ -40,6 +40,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
+#include <termios.h>
#include <time.h>
#include <ucontext.h>
#include <unistd.h>
@@ -74,6 +75,36 @@
thunk_from_timeval(&it->it_value, &tit->it_value);
}
+static void
+thunk_to_termios(const struct thunk_termios *tt, struct termios *t)
+{
+ int i;
+
+ t->c_iflag = tt->c_iflag;
+ t->c_oflag = tt->c_oflag;
+ t->c_cflag = tt->c_cflag;
+ t->c_lflag = tt->c_lflag;
+ for (i = 0; i < __arraycount(t->c_cc); i++)
+ t->c_cc[i] = tt->c_cc[i];
+ t->c_ispeed = tt->c_ispeed;
+ t->c_ospeed= tt->c_ospeed;
+}
+
+static void
+thunk_from_termios(const struct termios *t, struct thunk_termios *tt)
+{
+ int i;
+
+ tt->c_iflag = t->c_iflag;
+ tt->c_oflag = t->c_oflag;
+ tt->c_cflag = t->c_cflag;
+ tt->c_lflag = t->c_lflag;
+ for (i = 0; i < __arraycount(tt->c_cc); i++)
+ tt->c_cc[i] = t->c_cc[i];
+ tt->c_ispeed = t->c_ispeed;
+ tt->c_ospeed= t->c_ospeed;
+}
+
int
thunk_setitimer(int which, const struct thunk_itimerval *value,
struct thunk_itimerval *ovalue)
@@ -186,6 +217,28 @@
}
int
+thunk_tcgetattr(int fd, struct thunk_termios *tt)
+{
+ struct termios t;
+ int error;
+
+ error = tcgetattr(fd, &t);
+ if (error)
+ return error;
+ thunk_from_termios(&t, tt);
+ return 0;
+}
+
+int
+thunk_tcsetattr(int fd, int action, const struct thunk_termios *tt)
+{
+ struct termios t;
+
+ thunk_to_termios(tt, &t);
+ return tcsetattr(fd, action, &t);
+}
+
+int
thunk_getchar(void)
{
return getchar();