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 char *read_irq_name; 27510c72a3SAl Viro const char *write_irq_name; 28510c72a3SAl Viro struct mc_device mc; 29cfe6b7c7SAl Viro struct tty_driver *driver; 30510c72a3SAl Viro }; 31510c72a3SAl Viro 32510c72a3SAl Viro struct line { 33060ed31dSJiri Slaby struct tty_port port; 34510c72a3SAl Viro int valid; 35510c72a3SAl Viro 36d5a9597dSJohannes Berg int read_irq, write_irq; 37d5a9597dSJohannes Berg 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.*/ 50*b49d1849SJiri Slaby (SUSE) u8 *buffer; 51*b49d1849SJiri Slaby (SUSE) u8 *head; 52*b49d1849SJiri Slaby (SUSE) u8 *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); 6795713967SJiri Slaby (SUSE) extern ssize_t line_write(struct tty_struct *tty, const u8 *buf, size_t len); 68fff4ef17SJiri Slaby extern unsigned 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); 7103b3b1a2SJiri Slaby extern unsigned int line_write_room(struct tty_struct *tty); 72510c72a3SAl Viro extern void line_throttle(struct tty_struct *tty); 73510c72a3SAl Viro extern void line_unthrottle(struct tty_struct *tty); 74510c72a3SAl Viro 75510c72a3SAl Viro extern char *add_xterm_umid(char *base); 76510c72a3SAl Viro extern int line_setup_irq(int fd, int input, int output, struct line *line, 77510c72a3SAl Viro void *data); 78510c72a3SAl Viro extern void line_close_chan(struct line *line); 79cfe6b7c7SAl Viro extern int register_lines(struct line_driver *line_driver, 80510c72a3SAl Viro const struct tty_operations *driver, 81510c72a3SAl Viro struct line *lines, int nlines); 8204292b2cSAl Viro extern int setup_one_line(struct line *lines, int n, char *init, 8304292b2cSAl Viro const struct chan_opts *opts, char **error_out); 84510c72a3SAl Viro extern void close_lines(struct line *lines, int nlines); 85510c72a3SAl Viro 86510c72a3SAl Viro extern int line_config(struct line *lines, unsigned int sizeof_lines, 87510c72a3SAl Viro char *str, const struct chan_opts *opts, 88510c72a3SAl Viro char **error_out); 89510c72a3SAl Viro extern int line_id(char **str, int *start_out, int *end_out); 90510c72a3SAl Viro extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, 91510c72a3SAl Viro char **error_out); 92510c72a3SAl Viro extern int line_get_config(char *dev, struct line *lines, 93510c72a3SAl Viro unsigned int sizeof_lines, char *str, 94510c72a3SAl Viro int size, char **error_out); 95510c72a3SAl Viro 96510c72a3SAl Viro #endif 97