aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2011-08-18 15:08:29 -0400
committerRichard Weinberger <richard@nod.at>2011-11-02 09:15:12 -0400
commit510c72a3cf51c9463db64eb6c21347f4940a202f (patch)
tree948235a6eb749b9ec7a195eda7dfedbaff2834cb /arch/um/drivers
parent17e052093bcd21eaf9eb6e792cd76fdc4f0e3505 (diff)
um: take chan_*.h and line.h to arch/um/drivers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/chan.h50
-rw-r--r--arch/um/drivers/chan_kern.c2
-rw-r--r--arch/um/drivers/chan_user.h55
-rw-r--r--arch/um/drivers/line.c2
-rw-r--r--arch/um/drivers/line.h106
-rw-r--r--arch/um/drivers/ssl.c3
-rw-r--r--arch/um/drivers/stdio_console.c3
7 files changed, 215 insertions, 6 deletions
diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h
new file mode 100644
index 000000000000..8df0fd9024dc
--- /dev/null
+++ b/arch/um/drivers/chan.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __CHAN_KERN_H__
7#define __CHAN_KERN_H__
8
9#include <linux/tty.h>
10#include <linux/list.h>
11#include <linux/console.h>
12#include "chan_user.h"
13#include "line.h"
14
15struct chan {
16 struct list_head list;
17 struct list_head free_list;
18 struct line *line;
19 char *dev;
20 unsigned int primary:1;
21 unsigned int input:1;
22 unsigned int output:1;
23 unsigned int opened:1;
24 unsigned int enabled:1;
25 int fd;
26 const struct chan_ops *ops;
27 void *data;
28};
29
30extern void chan_interrupt(struct list_head *chans, struct delayed_work *task,
31 struct tty_struct *tty, int irq);
32extern int parse_chan_pair(char *str, struct line *line, int device,
33 const struct chan_opts *opts, char **error_out);
34extern int write_chan(struct list_head *chans, const char *buf, int len,
35 int write_irq);
36extern int console_write_chan(struct list_head *chans, const char *buf,
37 int len);
38extern int console_open_chan(struct line *line, struct console *co);
39extern void deactivate_chan(struct list_head *chans, int irq);
40extern void reactivate_chan(struct list_head *chans, int irq);
41extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty);
42extern int enable_chan(struct line *line);
43extern void close_chan(struct list_head *chans, int delay_free_irq);
44extern int chan_window_size(struct list_head *chans,
45 unsigned short *rows_out,
46 unsigned short *cols_out);
47extern int chan_config_string(struct list_head *chans, char *str, int size,
48 char **error_out);
49
50#endif
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index d4191fe1cede..e0406832df89 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -6,7 +6,7 @@
6#include <linux/slab.h> 6#include <linux/slab.h>
7#include <linux/tty.h> 7#include <linux/tty.h>
8#include <linux/tty_flip.h> 8#include <linux/tty_flip.h>
9#include "chan_kern.h" 9#include "chan.h"
10#include "os.h" 10#include "os.h"
11 11
12#ifdef CONFIG_NOCONFIG_CHAN 12#ifdef CONFIG_NOCONFIG_CHAN
diff --git a/arch/um/drivers/chan_user.h b/arch/um/drivers/chan_user.h
new file mode 100644
index 000000000000..9b9ced85b703
--- /dev/null
+++ b/arch/um/drivers/chan_user.h
@@ -0,0 +1,55 @@
1/*
2 * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __CHAN_USER_H__
7#define __CHAN_USER_H__
8
9#include "init.h"
10
11struct chan_opts {
12 void (*const announce)(char *dev_name, int dev);
13 char *xterm_title;
14 const int raw;
15};
16
17enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE };
18
19struct chan_ops {
20 char *type;
21 void *(*init)(char *, int, const struct chan_opts *);
22 int (*open)(int, int, int, void *, char **);
23 void (*close)(int, void *);
24 int (*read)(int, char *, void *);
25 int (*write)(int, const char *, int, void *);
26 int (*console_write)(int, const char *, int);
27 int (*window_size)(int, void *, unsigned short *, unsigned short *);
28 void (*free)(void *);
29 int winch;
30};
31
32extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops,
33 tty_ops, xterm_ops;
34
35extern void generic_close(int fd, void *unused);
36extern int generic_read(int fd, char *c_out, void *unused);
37extern int generic_write(int fd, const char *buf, int n, void *unused);
38extern int generic_console_write(int fd, const char *buf, int n);
39extern int generic_window_size(int fd, void *unused, unsigned short *rows_out,
40 unsigned short *cols_out);
41extern void generic_free(void *data);
42
43struct tty_struct;
44extern void register_winch(int fd, struct tty_struct *tty);
45extern void register_winch_irq(int fd, int tty_fd, int pid,
46 struct tty_struct *tty, unsigned long stack);
47
48#define __channel_help(fn, prefix) \
49__uml_help(fn, prefix "[0-9]*=<channel description>\n" \
50" Attach a console or serial line to a host channel. See\n" \
51" http://user-mode-linux.sourceforge.net/old/input.html for a complete\n" \
52" description of this switch.\n\n" \
53);
54
55#endif
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 364c8a15c4c3..c1cf2206b84b 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -7,7 +7,7 @@
7#include "linux/kd.h" 7#include "linux/kd.h"
8#include "linux/sched.h" 8#include "linux/sched.h"
9#include "linux/slab.h" 9#include "linux/slab.h"
10#include "chan_kern.h" 10#include "chan.h"
11#include "irq_kern.h" 11#include "irq_kern.h"
12#include "irq_user.h" 12#include "irq_user.h"
13#include "kern_util.h" 13#include "kern_util.h"
diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
new file mode 100644
index 000000000000..63df3ca02ac2
--- /dev/null
+++ b/arch/um/drivers/line.h
@@ -0,0 +1,106 @@
1/*
2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __LINE_H__
7#define __LINE_H__
8
9#include "linux/list.h"
10#include "linux/workqueue.h"
11#include "linux/tty.h"
12#include "linux/interrupt.h"
13#include "linux/spinlock.h"
14#include "linux/mutex.h"
15#include "chan_user.h"
16#include "mconsole_kern.h"
17
18/* There's only one modifiable field in this - .mc.list */
19struct line_driver {
20 const char *name;
21 const char *device_name;
22 const short major;
23 const short minor_start;
24 const short type;
25 const short subtype;
26 const int read_irq;
27 const char *read_irq_name;
28 const int write_irq;
29 const char *write_irq_name;
30 struct mc_device mc;
31};
32
33struct line {
34 struct tty_struct *tty;
35 spinlock_t count_lock;
36 unsigned long count;
37 int valid;
38
39 char *init_str;
40 int init_pri;
41 struct list_head chan_list;
42
43 /*This lock is actually, mostly, local to*/
44 spinlock_t lock;
45 int throttled;
46 /* Yes, this is a real circular buffer.
47 * XXX: And this should become a struct kfifo!
48 *
49 * buffer points to a buffer allocated on demand, of length
50 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
51 char *buffer;
52 char *head;
53 char *tail;
54
55 int sigio;
56 struct delayed_work task;
57 const struct line_driver *driver;
58 int have_irq;
59};
60
61#define LINE_INIT(str, d) \
62 { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \
63 .init_str = str, \
64 .init_pri = INIT_STATIC, \
65 .valid = 1, \
66 .lock = __SPIN_LOCK_UNLOCKED((str).lock), \
67 .driver = d }
68
69extern void line_close(struct tty_struct *tty, struct file * filp);
70extern int line_open(struct line *lines, struct tty_struct *tty);
71extern int line_setup(struct line *lines, unsigned int sizeof_lines,
72 char *init, char **error_out);
73extern int line_write(struct tty_struct *tty, const unsigned char *buf,
74 int len);
75extern int line_put_char(struct tty_struct *tty, unsigned char ch);
76extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
77extern int line_chars_in_buffer(struct tty_struct *tty);
78extern void line_flush_buffer(struct tty_struct *tty);
79extern void line_flush_chars(struct tty_struct *tty);
80extern int line_write_room(struct tty_struct *tty);
81extern int line_ioctl(struct tty_struct *tty, unsigned int cmd,
82 unsigned long arg);
83extern void line_throttle(struct tty_struct *tty);
84extern void line_unthrottle(struct tty_struct *tty);
85
86extern char *add_xterm_umid(char *base);
87extern int line_setup_irq(int fd, int input, int output, struct line *line,
88 void *data);
89extern void line_close_chan(struct line *line);
90extern struct tty_driver *register_lines(struct line_driver *line_driver,
91 const struct tty_operations *driver,
92 struct line *lines, int nlines);
93extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
94extern void close_lines(struct line *lines, int nlines);
95
96extern int line_config(struct line *lines, unsigned int sizeof_lines,
97 char *str, const struct chan_opts *opts,
98 char **error_out);
99extern int line_id(char **str, int *start_out, int *end_out);
100extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
101 char **error_out);
102extern int line_get_config(char *dev, struct line *lines,
103 unsigned int sizeof_lines, char *str,
104 int size, char **error_out);
105
106#endif
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index 678e205adf29..9d8c20af6f80 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -12,9 +12,8 @@
12#include "linux/console.h" 12#include "linux/console.h"
13#include "asm/termbits.h" 13#include "asm/termbits.h"
14#include "asm/irq.h" 14#include "asm/irq.h"
15#include "line.h"
16#include "ssl.h" 15#include "ssl.h"
17#include "chan_kern.h" 16#include "chan.h"
18#include "init.h" 17#include "init.h"
19#include "irq_user.h" 18#include "irq_user.h"
20#include "mconsole_kern.h" 19#include "mconsole_kern.h"
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 49266f6108c4..088776f01908 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -20,8 +20,7 @@
20#include "asm/current.h" 20#include "asm/current.h"
21#include "asm/irq.h" 21#include "asm/irq.h"
22#include "stdio_console.h" 22#include "stdio_console.h"
23#include "line.h" 23#include "chan.h"
24#include "chan_kern.h"
25#include "irq_user.h" 24#include "irq_user.h"
26#include "mconsole_kern.h" 25#include "mconsole_kern.h"
27#include "init.h" 26#include "init.h"