xref: /linux/arch/um/drivers/line.h (revision 060ed31dd9ede0726f8c88aff36c6cd8ec6d0fe8)
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 {
35*060ed31dSJiri Slaby 	struct tty_port port;
36510c72a3SAl Viro 	struct tty_struct *tty;
37d8c215adSAl Viro 	struct mutex count_lock;
38510c72a3SAl Viro 	int valid;
39510c72a3SAl Viro 
40510c72a3SAl Viro 	char *init_str;
41510c72a3SAl Viro 	struct list_head chan_list;
42ee485070SAl Viro 	struct chan *chan_in, *chan_out;
43510c72a3SAl Viro 
44510c72a3SAl Viro 	/*This lock is actually, mostly, local to*/
45510c72a3SAl Viro 	spinlock_t lock;
46510c72a3SAl Viro 	int throttled;
47510c72a3SAl Viro 	/* Yes, this is a real circular buffer.
48510c72a3SAl Viro 	 * XXX: And this should become a struct kfifo!
49510c72a3SAl Viro 	 *
50510c72a3SAl Viro 	 * buffer points to a buffer allocated on demand, of length
51510c72a3SAl Viro 	 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
52510c72a3SAl Viro 	char *buffer;
53510c72a3SAl Viro 	char *head;
54510c72a3SAl Viro 	char *tail;
55510c72a3SAl Viro 
56510c72a3SAl Viro 	int sigio;
57510c72a3SAl Viro 	struct delayed_work task;
58510c72a3SAl Viro 	const struct line_driver *driver;
59510c72a3SAl Viro };
60510c72a3SAl Viro 
61510c72a3SAl Viro extern void line_close(struct tty_struct *tty, struct file * filp);
62510c72a3SAl Viro extern int line_open(struct line *lines, struct tty_struct *tty);
6343574c1aSAl Viro extern int line_setup(char **conf, unsigned nlines, char **def,
6443574c1aSAl Viro 		      char *init, char *name);
65510c72a3SAl Viro extern int line_write(struct tty_struct *tty, const unsigned char *buf,
66510c72a3SAl Viro 		      int len);
67510c72a3SAl Viro extern int line_put_char(struct tty_struct *tty, unsigned char ch);
68510c72a3SAl Viro extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
69510c72a3SAl Viro extern int line_chars_in_buffer(struct tty_struct *tty);
70510c72a3SAl Viro extern void line_flush_buffer(struct tty_struct *tty);
71510c72a3SAl Viro extern void line_flush_chars(struct tty_struct *tty);
72510c72a3SAl Viro extern int line_write_room(struct tty_struct *tty);
73510c72a3SAl Viro extern int line_ioctl(struct tty_struct *tty, unsigned int cmd,
74510c72a3SAl Viro 				unsigned long arg);
75510c72a3SAl Viro extern void line_throttle(struct tty_struct *tty);
76510c72a3SAl Viro extern void line_unthrottle(struct tty_struct *tty);
77510c72a3SAl Viro 
78510c72a3SAl Viro extern char *add_xterm_umid(char *base);
79510c72a3SAl Viro extern int line_setup_irq(int fd, int input, int output, struct line *line,
80510c72a3SAl Viro 			  void *data);
81510c72a3SAl Viro extern void line_close_chan(struct line *line);
82cfe6b7c7SAl Viro extern int register_lines(struct line_driver *line_driver,
83510c72a3SAl Viro 			  const struct tty_operations *driver,
84510c72a3SAl Viro 			  struct line *lines, int nlines);
8504292b2cSAl Viro extern int setup_one_line(struct line *lines, int n, char *init,
8604292b2cSAl Viro 			  const struct chan_opts *opts, char **error_out);
87510c72a3SAl Viro extern void close_lines(struct line *lines, int nlines);
88510c72a3SAl Viro 
89510c72a3SAl Viro extern int line_config(struct line *lines, unsigned int sizeof_lines,
90510c72a3SAl Viro 		       char *str, const struct chan_opts *opts,
91510c72a3SAl Viro 		       char **error_out);
92510c72a3SAl Viro extern int line_id(char **str, int *start_out, int *end_out);
93510c72a3SAl Viro extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
94510c72a3SAl Viro 		       char **error_out);
95510c72a3SAl Viro extern int line_get_config(char *dev, struct line *lines,
96510c72a3SAl Viro 			   unsigned int sizeof_lines, char *str,
97510c72a3SAl Viro 			   int size, char **error_out);
98510c72a3SAl Viro 
99510c72a3SAl Viro #endif
100