xref: /OK3568_Linux_fs/kernel/arch/um/drivers/line.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #ifndef __LINE_H__
7*4882a593Smuzhiyun #define __LINE_H__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/list.h>
10*4882a593Smuzhiyun #include <linux/workqueue.h>
11*4882a593Smuzhiyun #include <linux/tty.h>
12*4882a593Smuzhiyun #include <linux/interrupt.h>
13*4882a593Smuzhiyun #include <linux/spinlock.h>
14*4882a593Smuzhiyun #include <linux/mutex.h>
15*4882a593Smuzhiyun #include "chan_user.h"
16*4882a593Smuzhiyun #include "mconsole_kern.h"
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /* There's only two modifiable fields in this - .mc.list and .driver */
19*4882a593Smuzhiyun struct line_driver {
20*4882a593Smuzhiyun 	const char *name;
21*4882a593Smuzhiyun 	const char *device_name;
22*4882a593Smuzhiyun 	const short major;
23*4882a593Smuzhiyun 	const short minor_start;
24*4882a593Smuzhiyun 	const short type;
25*4882a593Smuzhiyun 	const short subtype;
26*4882a593Smuzhiyun 	const int read_irq;
27*4882a593Smuzhiyun 	const char *read_irq_name;
28*4882a593Smuzhiyun 	const int write_irq;
29*4882a593Smuzhiyun 	const char *write_irq_name;
30*4882a593Smuzhiyun 	struct mc_device mc;
31*4882a593Smuzhiyun 	struct tty_driver *driver;
32*4882a593Smuzhiyun };
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun struct line {
35*4882a593Smuzhiyun 	struct tty_port port;
36*4882a593Smuzhiyun 	int valid;
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun 	char *init_str;
39*4882a593Smuzhiyun 	struct list_head chan_list;
40*4882a593Smuzhiyun 	struct chan *chan_in, *chan_out;
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun 	/*This lock is actually, mostly, local to*/
43*4882a593Smuzhiyun 	spinlock_t lock;
44*4882a593Smuzhiyun 	int throttled;
45*4882a593Smuzhiyun 	/* Yes, this is a real circular buffer.
46*4882a593Smuzhiyun 	 * XXX: And this should become a struct kfifo!
47*4882a593Smuzhiyun 	 *
48*4882a593Smuzhiyun 	 * buffer points to a buffer allocated on demand, of length
49*4882a593Smuzhiyun 	 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
50*4882a593Smuzhiyun 	char *buffer;
51*4882a593Smuzhiyun 	char *head;
52*4882a593Smuzhiyun 	char *tail;
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun 	int sigio;
55*4882a593Smuzhiyun 	struct delayed_work task;
56*4882a593Smuzhiyun 	const struct line_driver *driver;
57*4882a593Smuzhiyun };
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun extern void line_close(struct tty_struct *tty, struct file * filp);
60*4882a593Smuzhiyun extern int line_open(struct tty_struct *tty, struct file *filp);
61*4882a593Smuzhiyun extern int line_install(struct tty_driver *driver, struct tty_struct *tty,
62*4882a593Smuzhiyun 	struct line *line);
63*4882a593Smuzhiyun extern void line_cleanup(struct tty_struct *tty);
64*4882a593Smuzhiyun extern void line_hangup(struct tty_struct *tty);
65*4882a593Smuzhiyun extern int line_setup(char **conf, unsigned nlines, char **def,
66*4882a593Smuzhiyun 		      char *init, char *name);
67*4882a593Smuzhiyun extern int line_write(struct tty_struct *tty, const unsigned char *buf,
68*4882a593Smuzhiyun 		      int len);
69*4882a593Smuzhiyun extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
70*4882a593Smuzhiyun extern int line_chars_in_buffer(struct tty_struct *tty);
71*4882a593Smuzhiyun extern void line_flush_buffer(struct tty_struct *tty);
72*4882a593Smuzhiyun extern void line_flush_chars(struct tty_struct *tty);
73*4882a593Smuzhiyun extern int line_write_room(struct tty_struct *tty);
74*4882a593Smuzhiyun extern void line_throttle(struct tty_struct *tty);
75*4882a593Smuzhiyun extern void line_unthrottle(struct tty_struct *tty);
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun extern char *add_xterm_umid(char *base);
78*4882a593Smuzhiyun extern int line_setup_irq(int fd, int input, int output, struct line *line,
79*4882a593Smuzhiyun 			  void *data);
80*4882a593Smuzhiyun extern void line_close_chan(struct line *line);
81*4882a593Smuzhiyun extern int register_lines(struct line_driver *line_driver,
82*4882a593Smuzhiyun 			  const struct tty_operations *driver,
83*4882a593Smuzhiyun 			  struct line *lines, int nlines);
84*4882a593Smuzhiyun extern int setup_one_line(struct line *lines, int n, char *init,
85*4882a593Smuzhiyun 			  const struct chan_opts *opts, char **error_out);
86*4882a593Smuzhiyun extern void close_lines(struct line *lines, int nlines);
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun extern int line_config(struct line *lines, unsigned int sizeof_lines,
89*4882a593Smuzhiyun 		       char *str, const struct chan_opts *opts,
90*4882a593Smuzhiyun 		       char **error_out);
91*4882a593Smuzhiyun extern int line_id(char **str, int *start_out, int *end_out);
92*4882a593Smuzhiyun extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
93*4882a593Smuzhiyun 		       char **error_out);
94*4882a593Smuzhiyun extern int line_get_config(char *dev, struct line *lines,
95*4882a593Smuzhiyun 			   unsigned int sizeof_lines, char *str,
96*4882a593Smuzhiyun 			   int size, char **error_out);
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun #endif
99