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