xref: /linux/arch/um/drivers/line.h (revision 43574c1afea4f798592c03cf4d4ecea4fd0a8416)
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 
18510c72a3SAl Viro /* There's only one modifiable field in this - .mc.list */
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;
31510c72a3SAl Viro };
32510c72a3SAl Viro 
33510c72a3SAl Viro struct line {
34510c72a3SAl Viro 	struct tty_struct *tty;
35510c72a3SAl Viro 	spinlock_t count_lock;
36510c72a3SAl Viro 	unsigned long count;
37510c72a3SAl Viro 	int valid;
38510c72a3SAl Viro 
39510c72a3SAl Viro 	char *init_str;
40510c72a3SAl Viro 	struct list_head chan_list;
41510c72a3SAl Viro 
42510c72a3SAl Viro 	/*This lock is actually, mostly, local to*/
43510c72a3SAl Viro 	spinlock_t lock;
44510c72a3SAl Viro 	int throttled;
45510c72a3SAl Viro 	/* Yes, this is a real circular buffer.
46510c72a3SAl Viro 	 * XXX: And this should become a struct kfifo!
47510c72a3SAl Viro 	 *
48510c72a3SAl Viro 	 * buffer points to a buffer allocated on demand, of length
49510c72a3SAl Viro 	 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
50510c72a3SAl Viro 	char *buffer;
51510c72a3SAl Viro 	char *head;
52510c72a3SAl Viro 	char *tail;
53510c72a3SAl Viro 
54510c72a3SAl Viro 	int sigio;
55510c72a3SAl Viro 	struct delayed_work task;
56510c72a3SAl Viro 	const struct line_driver *driver;
57510c72a3SAl Viro 	int have_irq;
58510c72a3SAl Viro };
59510c72a3SAl Viro 
60510c72a3SAl Viro extern void line_close(struct tty_struct *tty, struct file * filp);
61510c72a3SAl Viro extern int line_open(struct line *lines, struct tty_struct *tty);
62*43574c1aSAl Viro extern int line_setup(char **conf, unsigned nlines, char **def,
63*43574c1aSAl Viro 		      char *init, char *name);
64510c72a3SAl Viro extern int line_write(struct tty_struct *tty, const unsigned char *buf,
65510c72a3SAl Viro 		      int len);
66510c72a3SAl Viro extern int line_put_char(struct tty_struct *tty, unsigned char ch);
67510c72a3SAl Viro extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
68510c72a3SAl Viro extern int line_chars_in_buffer(struct tty_struct *tty);
69510c72a3SAl Viro extern void line_flush_buffer(struct tty_struct *tty);
70510c72a3SAl Viro extern void line_flush_chars(struct tty_struct *tty);
71510c72a3SAl Viro extern int line_write_room(struct tty_struct *tty);
72510c72a3SAl Viro extern int line_ioctl(struct tty_struct *tty, unsigned int cmd,
73510c72a3SAl Viro 				unsigned long arg);
74510c72a3SAl Viro extern void line_throttle(struct tty_struct *tty);
75510c72a3SAl Viro extern void line_unthrottle(struct tty_struct *tty);
76510c72a3SAl Viro 
77510c72a3SAl Viro extern char *add_xterm_umid(char *base);
78510c72a3SAl Viro extern int line_setup_irq(int fd, int input, int output, struct line *line,
79510c72a3SAl Viro 			  void *data);
80510c72a3SAl Viro extern void line_close_chan(struct line *line);
81510c72a3SAl Viro extern struct tty_driver *register_lines(struct line_driver *line_driver,
82510c72a3SAl Viro 					 const struct tty_operations *driver,
83510c72a3SAl Viro 					 struct line *lines, int nlines);
84510c72a3SAl Viro extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
85510c72a3SAl Viro extern void close_lines(struct line *lines, int nlines);
86510c72a3SAl Viro 
87510c72a3SAl Viro extern int line_config(struct line *lines, unsigned int sizeof_lines,
88510c72a3SAl Viro 		       char *str, const struct chan_opts *opts,
89510c72a3SAl Viro 		       char **error_out);
90510c72a3SAl Viro extern int line_id(char **str, int *start_out, int *end_out);
91510c72a3SAl Viro extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
92510c72a3SAl Viro 		       char **error_out);
93510c72a3SAl Viro extern int line_get_config(char *dev, struct line *lines,
94510c72a3SAl Viro 			   unsigned int sizeof_lines, char *str,
95510c72a3SAl Viro 			   int size, char **error_out);
96510c72a3SAl Viro 
97510c72a3SAl Viro #endif
98