diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/um/drivers/tty.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/um/drivers/tty.c')
-rw-r--r-- | arch/um/drivers/tty.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c new file mode 100644 index 000000000000..6fbb670ee274 --- /dev/null +++ b/arch/um/drivers/tty.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <termios.h> | ||
8 | #include <errno.h> | ||
9 | #include <unistd.h> | ||
10 | #include "chan_user.h" | ||
11 | #include "user_util.h" | ||
12 | #include "user.h" | ||
13 | #include "os.h" | ||
14 | |||
15 | struct tty_chan { | ||
16 | char *dev; | ||
17 | int raw; | ||
18 | struct termios tt; | ||
19 | }; | ||
20 | |||
21 | static void *tty_chan_init(char *str, int device, struct chan_opts *opts) | ||
22 | { | ||
23 | struct tty_chan *data; | ||
24 | |||
25 | if(*str != ':'){ | ||
26 | printk("tty_init : channel type 'tty' must specify " | ||
27 | "a device\n"); | ||
28 | return(NULL); | ||
29 | } | ||
30 | str++; | ||
31 | |||
32 | data = um_kmalloc(sizeof(*data)); | ||
33 | if(data == NULL) | ||
34 | return(NULL); | ||
35 | *data = ((struct tty_chan) { .dev = str, | ||
36 | .raw = opts->raw }); | ||
37 | |||
38 | return(data); | ||
39 | } | ||
40 | |||
41 | static int tty_open(int input, int output, int primary, void *d, | ||
42 | char **dev_out) | ||
43 | { | ||
44 | struct tty_chan *data = d; | ||
45 | int fd, err; | ||
46 | |||
47 | fd = os_open_file(data->dev, of_set_rw(OPENFLAGS(), input, output), 0); | ||
48 | if(fd < 0) return(fd); | ||
49 | if(data->raw){ | ||
50 | CATCH_EINTR(err = tcgetattr(fd, &data->tt)); | ||
51 | if(err) | ||
52 | return(err); | ||
53 | |||
54 | err = raw(fd); | ||
55 | if(err) | ||
56 | return(err); | ||
57 | } | ||
58 | |||
59 | *dev_out = data->dev; | ||
60 | return(fd); | ||
61 | } | ||
62 | |||
63 | static int tty_console_write(int fd, const char *buf, int n, void *d) | ||
64 | { | ||
65 | struct tty_chan *data = d; | ||
66 | |||
67 | return(generic_console_write(fd, buf, n, &data->tt)); | ||
68 | } | ||
69 | |||
70 | struct chan_ops tty_ops = { | ||
71 | .type = "tty", | ||
72 | .init = tty_chan_init, | ||
73 | .open = tty_open, | ||
74 | .close = generic_close, | ||
75 | .read = generic_read, | ||
76 | .write = generic_write, | ||
77 | .console_write = tty_console_write, | ||
78 | .window_size = generic_window_size, | ||
79 | .free = generic_free, | ||
80 | .winch = 0, | ||
81 | }; | ||
82 | |||
83 | /* | ||
84 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
85 | * Emacs will notice this stuff at the end of the file and automatically | ||
86 | * adjust the settings for this buffer only. This must remain at the end | ||
87 | * of the file. | ||
88 | * --------------------------------------------------------------------------- | ||
89 | * Local variables: | ||
90 | * c-file-style: "linux" | ||
91 | * End: | ||
92 | */ | ||