xref: /linux/arch/um/drivers/line.h (revision 79e0273d187c807dfec8d0cf450b8187cab5d3af)
1510c72a3SAl Viro /*
2510c72a3SAl Viro  * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3510c72a3SAl Viro  * Licensed under the GPL
4510c72a3SAl Viro  */
5510c72a3SAl Viro 
6510c72a3SAl Viro #ifndef __LINE_H__
7510c72a3SAl Viro #define __LINE_H__
8510c72a3SAl Viro 
9510c72a3SAl Viro #include "linux/list.h"
10510c72a3SAl Viro #include "linux/workqueue.h"
11510c72a3SAl Viro #include "linux/tty.h"
12510c72a3SAl Viro #include "linux/interrupt.h"
13510c72a3SAl Viro #include "linux/spinlock.h"
14510c72a3SAl Viro #include "linux/mutex.h"
15510c72a3SAl Viro #include "chan_user.h"
16510c72a3SAl Viro #include "mconsole_kern.h"
17510c72a3SAl Viro 
18cfe6b7c7SAl Viro /* There's only two modifiable fields in this - .mc.list and .driver */
19510c72a3SAl Viro struct line_driver {
20510c72a3SAl Viro 	const char *name;
21510c72a3SAl Viro 	const char *device_name;
22510c72a3SAl Viro 	const short major;
23510c72a3SAl Viro 	const short minor_start;
24510c72a3SAl Viro 	const short type;
25510c72a3SAl Viro 	const short subtype;
26510c72a3SAl Viro 	const int read_irq;
27510c72a3SAl Viro 	const char *read_irq_name;
28510c72a3SAl Viro 	const int write_irq;
29510c72a3SAl Viro 	const char *write_irq_name;
30510c72a3SAl Viro 	struct mc_device mc;
31cfe6b7c7SAl Viro 	struct tty_driver *driver;
32510c72a3SAl Viro };
33510c72a3SAl Viro 
34510c72a3SAl Viro struct line {
35060ed31dSJiri Slaby 	struct tty_port port;
36d8c215adSAl Viro 	struct mutex count_lock;
37510c72a3SAl Viro 	int valid;
38510c72a3SAl Viro 
39510c72a3SAl Viro 	char *init_str;
40510c72a3SAl Viro 	struct list_head chan_list;
41ee485070SAl Viro 	struct chan *chan_in, *chan_out;
42510c72a3SAl Viro 
43510c72a3SAl Viro 	/*This lock is actually, mostly, local to*/
44510c72a3SAl Viro 	spinlock_t lock;
45510c72a3SAl Viro 	int throttled;
46510c72a3SAl Viro 	/* Yes, this is a real circular buffer.
47510c72a3SAl Viro 	 * XXX: And this should become a struct kfifo!
48510c72a3SAl Viro 	 *
49510c72a3SAl Viro 	 * buffer points to a buffer allocated on demand, of length
50510c72a3SAl Viro 	 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
51510c72a3SAl Viro 	char *buffer;
52510c72a3SAl Viro 	char *head;
53510c72a3SAl Viro 	char *tail;
54510c72a3SAl Viro 
55510c72a3SAl Viro 	int sigio;
56510c72a3SAl Viro 	struct delayed_work task;
57510c72a3SAl Viro 	const struct line_driver *driver;
58510c72a3SAl Viro };
59510c72a3SAl Viro 
60510c72a3SAl Viro extern void line_close(struct tty_struct *tty, struct file * filp);
61*79e0273dSRichard Weinberger extern int line_open(struct tty_struct *tty, struct file *filp);
62*79e0273dSRichard Weinberger extern int line_install(struct tty_driver *driver, struct tty_struct *tty,
63*79e0273dSRichard Weinberger 	struct line *line);
64*79e0273dSRichard Weinberger extern void line_cleanup(struct tty_struct *tty);
65*79e0273dSRichard Weinberger extern void line_hangup(struct tty_struct *tty);
6643574c1aSAl Viro extern int line_setup(char **conf, unsigned nlines, char **def,
6743574c1aSAl Viro 		      char *init, char *name);
68510c72a3SAl Viro extern int line_write(struct tty_struct *tty, const unsigned char *buf,
69510c72a3SAl Viro 		      int len);
70510c72a3SAl Viro extern int line_put_char(struct tty_struct *tty, unsigned char ch);
71510c72a3SAl Viro extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
72510c72a3SAl Viro extern int line_chars_in_buffer(struct tty_struct *tty);
73510c72a3SAl Viro extern void line_flush_buffer(struct tty_struct *tty);
74510c72a3SAl Viro extern void line_flush_chars(struct tty_struct *tty);
75510c72a3SAl Viro extern int line_write_room(struct tty_struct *tty);
76510c72a3SAl Viro extern void line_throttle(struct tty_struct *tty);
77510c72a3SAl Viro extern void line_unthrottle(struct tty_struct *tty);
78510c72a3SAl Viro 
79510c72a3SAl Viro extern char *add_xterm_umid(char *base);
80510c72a3SAl Viro extern int line_setup_irq(int fd, int input, int output, struct line *line,
81510c72a3SAl Viro 			  void *data);
82510c72a3SAl Viro extern void line_close_chan(struct line *line);
83cfe6b7c7SAl Viro extern int register_lines(struct line_driver *line_driver,
84510c72a3SAl Viro 			  const struct tty_operations *driver,
85510c72a3SAl Viro 			  struct line *lines, int nlines);
8604292b2cSAl Viro extern int setup_one_line(struct line *lines, int n, char *init,
8704292b2cSAl Viro 			  const struct chan_opts *opts, char **error_out);
88510c72a3SAl Viro extern void close_lines(struct line *lines, int nlines);
89510c72a3SAl Viro 
90510c72a3SAl Viro extern int line_config(struct line *lines, unsigned int sizeof_lines,
91510c72a3SAl Viro 		       char *str, const struct chan_opts *opts,
92510c72a3SAl Viro 		       char **error_out);
93510c72a3SAl Viro extern int line_id(char **str, int *start_out, int *end_out);
94510c72a3SAl Viro extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
95510c72a3SAl Viro 		       char **error_out);
96510c72a3SAl Viro extern int line_get_config(char *dev, struct line *lines,
97510c72a3SAl Viro 			   unsigned int sizeof_lines, char *str,
98510c72a3SAl Viro 			   int size, char **error_out);
99510c72a3SAl Viro 
100510c72a3SAl Viro #endif
101