a2486b4cc9fe481d2d3c6f1426bac10aa0638dbd
[safe/jmp/linux-2.6] / arch / um / include / line.h
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 struct line_driver {
19         char *name;
20         char *device_name;
21         short major;
22         short minor_start;
23         short type;
24         short subtype;
25         int read_irq;
26         char *read_irq_name;
27         int write_irq;
28         char *write_irq_name;
29         char *symlink_from;
30         char *symlink_to;
31         struct mc_device mc;
32 };
33
34 struct line {
35         struct tty_struct *tty;
36         spinlock_t count_lock;
37         int valid;
38
39         struct mutex open_mutex;
40         char *init_str;
41         int init_pri;
42         struct list_head chan_list;
43
44         /*This lock is actually, mostly, local to*/
45         spinlock_t lock;
46         int throttled;
47         /* Yes, this is a real circular buffer.
48          * XXX: And this should become a struct kfifo!
49          *
50          * buffer points to a buffer allocated on demand, of length
51          * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
52         char *buffer;
53         char *head;
54         char *tail;
55
56         int sigio;
57         struct delayed_work task;
58         const struct line_driver *driver;
59         int have_irq;
60 };
61
62 #define LINE_INIT(str, d) \
63         { .count_lock = SPIN_LOCK_UNLOCKED, \
64           .init_str =   str,    \
65           .init_pri =   INIT_STATIC, \
66           .valid =      1, \
67           .lock =       SPIN_LOCK_UNLOCKED, \
68           .driver =     d }
69
70 struct lines {
71         int num;
72 };
73
74 #define LINES_INIT(n) {  .num = n }
75
76 extern void line_close(struct tty_struct *tty, struct file * filp);
77 extern int line_open(struct line *lines, struct tty_struct *tty);
78 extern int line_setup(struct line *lines, unsigned int sizeof_lines,
79                       char *init, char **error_out);
80 extern int line_write(struct tty_struct *tty, const unsigned char *buf,
81                       int len);
82 extern void line_put_char(struct tty_struct *tty, unsigned char ch);
83 extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
84 extern int line_chars_in_buffer(struct tty_struct *tty);
85 extern void line_flush_buffer(struct tty_struct *tty);
86 extern void line_flush_chars(struct tty_struct *tty);
87 extern int line_write_room(struct tty_struct *tty);
88 extern int line_ioctl(struct tty_struct *tty, struct file * file,
89                       unsigned int cmd, unsigned long arg);
90 extern void line_throttle(struct tty_struct *tty);
91 extern void line_unthrottle(struct tty_struct *tty);
92
93 extern char *add_xterm_umid(char *base);
94 extern int line_setup_irq(int fd, int input, int output, struct line *line,
95                           void *data);
96 extern void line_close_chan(struct line *line);
97 extern struct tty_driver * line_register_devfs(struct lines *set,
98                                                struct line_driver *line_driver,
99                                                const struct tty_operations *driver,
100                                                struct line *lines, int nlines);
101 extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
102 extern void close_lines(struct line *lines, int nlines);
103
104 extern int line_config(struct line *lines, unsigned int sizeof_lines,
105                        char *str, const struct chan_opts *opts,
106                        char **error_out);
107 extern int line_id(char **str, int *start_out, int *end_out);
108 extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
109                        char **error_out);
110 extern int line_get_config(char *dev, struct line *lines,
111                            unsigned int sizeof_lines, char *str,
112                            int size, char **error_out);
113
114 #endif