Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode add thunk_tcgetattr and thunk_tcsetattr
details: https://anonhg.NetBSD.org/src/rev/fad7e433e667
branches: trunk
changeset: 768906:fad7e433e667
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Aug 28 21:19:49 2011 +0000
description:
add thunk_tcgetattr and thunk_tcsetattr
diffstat:
sys/arch/usermode/include/thunk.h | 15 +++++++++-
sys/arch/usermode/usermode/thunk.c | 57 ++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 3 deletions(-)
diffs (128 lines):
diff -r 8168a6bed115 -r fad7e433e667 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Sun Aug 28 20:49:30 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Sun Aug 28 21:19:49 2011 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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);
diff -r 8168a6bed115 -r fad7e433e667 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c Sun Aug 28 20:49:30 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c Sun Aug 28 21:19:49 2011 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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();
Home |
Main Index |
Thread Index |
Old Index