1dbddf429SAlex Dewar /* SPDX-License-Identifier: GPL-2.0 */ 2510c72a3SAl Viro /* 3510c72a3SAl Viro * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) 4510c72a3SAl Viro */ 5510c72a3SAl Viro 6510c72a3SAl Viro #ifndef __LINE_H__ 7510c72a3SAl Viro #define __LINE_H__ 8510c72a3SAl Viro 937185b33SAl Viro #include <linux/list.h> 1037185b33SAl Viro #include <linux/workqueue.h> 1137185b33SAl Viro #include <linux/tty.h> 1237185b33SAl Viro #include <linux/interrupt.h> 1337185b33SAl Viro #include <linux/spinlock.h> 1437185b33SAl 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; 36510c72a3SAl Viro int valid; 37510c72a3SAl Viro 38510c72a3SAl Viro char *init_str; 39510c72a3SAl Viro struct list_head chan_list; 40ee485070SAl Viro struct chan *chan_in, *chan_out; 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 }; 58510c72a3SAl Viro 59510c72a3SAl Viro extern void line_close(struct tty_struct *tty, struct file * filp); 6079e0273dSRichard Weinberger extern int line_open(struct tty_struct *tty, struct file *filp); 6179e0273dSRichard Weinberger extern int line_install(struct tty_driver *driver, struct tty_struct *tty, 6279e0273dSRichard Weinberger struct line *line); 6379e0273dSRichard Weinberger extern void line_cleanup(struct tty_struct *tty); 6479e0273dSRichard Weinberger extern void line_hangup(struct tty_struct *tty); 6543574c1aSAl Viro extern int line_setup(char **conf, unsigned nlines, char **def, 6643574c1aSAl Viro char *init, char *name); 67510c72a3SAl Viro extern int line_write(struct tty_struct *tty, const unsigned char *buf, 68510c72a3SAl Viro int len); 69510c72a3SAl Viro extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); 70*fff4ef17SJiri Slaby extern unsigned int line_chars_in_buffer(struct tty_struct *tty); 71510c72a3SAl Viro extern void line_flush_buffer(struct tty_struct *tty); 72510c72a3SAl Viro extern void line_flush_chars(struct tty_struct *tty); 7303b3b1a2SJiri Slaby extern unsigned int line_write_room(struct tty_struct *tty); 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); 81cfe6b7c7SAl Viro extern int register_lines(struct line_driver *line_driver, 82510c72a3SAl Viro const struct tty_operations *driver, 83510c72a3SAl Viro struct line *lines, int nlines); 8404292b2cSAl Viro extern int setup_one_line(struct line *lines, int n, char *init, 8504292b2cSAl Viro const struct chan_opts *opts, char **error_out); 86510c72a3SAl Viro extern void close_lines(struct line *lines, int nlines); 87510c72a3SAl Viro 88510c72a3SAl Viro extern int line_config(struct line *lines, unsigned int sizeof_lines, 89510c72a3SAl Viro char *str, const struct chan_opts *opts, 90510c72a3SAl Viro char **error_out); 91510c72a3SAl Viro extern int line_id(char **str, int *start_out, int *end_out); 92510c72a3SAl Viro extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, 93510c72a3SAl Viro char **error_out); 94510c72a3SAl Viro extern int line_get_config(char *dev, struct line *lines, 95510c72a3SAl Viro unsigned int sizeof_lines, char *str, 96510c72a3SAl Viro int size, char **error_out); 97510c72a3SAl Viro 98510c72a3SAl Viro #endif 99