18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef __LINE_H__ 78c2ecf20Sopenharmony_ci#define __LINE_H__ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/list.h> 108c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 118c2ecf20Sopenharmony_ci#include <linux/tty.h> 128c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 138c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 148c2ecf20Sopenharmony_ci#include <linux/mutex.h> 158c2ecf20Sopenharmony_ci#include "chan_user.h" 168c2ecf20Sopenharmony_ci#include "mconsole_kern.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* There's only two modifiable fields in this - .mc.list and .driver */ 198c2ecf20Sopenharmony_cistruct line_driver { 208c2ecf20Sopenharmony_ci const char *name; 218c2ecf20Sopenharmony_ci const char *device_name; 228c2ecf20Sopenharmony_ci const short major; 238c2ecf20Sopenharmony_ci const short minor_start; 248c2ecf20Sopenharmony_ci const short type; 258c2ecf20Sopenharmony_ci const short subtype; 268c2ecf20Sopenharmony_ci const int read_irq; 278c2ecf20Sopenharmony_ci const char *read_irq_name; 288c2ecf20Sopenharmony_ci const int write_irq; 298c2ecf20Sopenharmony_ci const char *write_irq_name; 308c2ecf20Sopenharmony_ci struct mc_device mc; 318c2ecf20Sopenharmony_ci struct tty_driver *driver; 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct line { 358c2ecf20Sopenharmony_ci struct tty_port port; 368c2ecf20Sopenharmony_ci int valid; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci char *init_str; 398c2ecf20Sopenharmony_ci struct list_head chan_list; 408c2ecf20Sopenharmony_ci struct chan *chan_in, *chan_out; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci /*This lock is actually, mostly, local to*/ 438c2ecf20Sopenharmony_ci spinlock_t lock; 448c2ecf20Sopenharmony_ci int throttled; 458c2ecf20Sopenharmony_ci /* Yes, this is a real circular buffer. 468c2ecf20Sopenharmony_ci * XXX: And this should become a struct kfifo! 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * buffer points to a buffer allocated on demand, of length 498c2ecf20Sopenharmony_ci * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/ 508c2ecf20Sopenharmony_ci char *buffer; 518c2ecf20Sopenharmony_ci char *head; 528c2ecf20Sopenharmony_ci char *tail; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci int sigio; 558c2ecf20Sopenharmony_ci struct delayed_work task; 568c2ecf20Sopenharmony_ci const struct line_driver *driver; 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciextern void line_close(struct tty_struct *tty, struct file * filp); 608c2ecf20Sopenharmony_ciextern int line_open(struct tty_struct *tty, struct file *filp); 618c2ecf20Sopenharmony_ciextern int line_install(struct tty_driver *driver, struct tty_struct *tty, 628c2ecf20Sopenharmony_ci struct line *line); 638c2ecf20Sopenharmony_ciextern void line_cleanup(struct tty_struct *tty); 648c2ecf20Sopenharmony_ciextern void line_hangup(struct tty_struct *tty); 658c2ecf20Sopenharmony_ciextern int line_setup(char **conf, unsigned nlines, char **def, 668c2ecf20Sopenharmony_ci char *init, char *name); 678c2ecf20Sopenharmony_ciextern int line_write(struct tty_struct *tty, const unsigned char *buf, 688c2ecf20Sopenharmony_ci int len); 698c2ecf20Sopenharmony_ciextern void line_set_termios(struct tty_struct *tty, struct ktermios * old); 708c2ecf20Sopenharmony_ciextern int line_chars_in_buffer(struct tty_struct *tty); 718c2ecf20Sopenharmony_ciextern void line_flush_buffer(struct tty_struct *tty); 728c2ecf20Sopenharmony_ciextern void line_flush_chars(struct tty_struct *tty); 738c2ecf20Sopenharmony_ciextern int line_write_room(struct tty_struct *tty); 748c2ecf20Sopenharmony_ciextern void line_throttle(struct tty_struct *tty); 758c2ecf20Sopenharmony_ciextern void line_unthrottle(struct tty_struct *tty); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ciextern char *add_xterm_umid(char *base); 788c2ecf20Sopenharmony_ciextern int line_setup_irq(int fd, int input, int output, struct line *line, 798c2ecf20Sopenharmony_ci void *data); 808c2ecf20Sopenharmony_ciextern void line_close_chan(struct line *line); 818c2ecf20Sopenharmony_ciextern int register_lines(struct line_driver *line_driver, 828c2ecf20Sopenharmony_ci const struct tty_operations *driver, 838c2ecf20Sopenharmony_ci struct line *lines, int nlines); 848c2ecf20Sopenharmony_ciextern int setup_one_line(struct line *lines, int n, char *init, 858c2ecf20Sopenharmony_ci const struct chan_opts *opts, char **error_out); 868c2ecf20Sopenharmony_ciextern void close_lines(struct line *lines, int nlines); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ciextern int line_config(struct line *lines, unsigned int sizeof_lines, 898c2ecf20Sopenharmony_ci char *str, const struct chan_opts *opts, 908c2ecf20Sopenharmony_ci char **error_out); 918c2ecf20Sopenharmony_ciextern int line_id(char **str, int *start_out, int *end_out); 928c2ecf20Sopenharmony_ciextern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, 938c2ecf20Sopenharmony_ci char **error_out); 948c2ecf20Sopenharmony_ciextern int line_get_config(char *dev, struct line *lines, 958c2ecf20Sopenharmony_ci unsigned int sizeof_lines, char *str, 968c2ecf20Sopenharmony_ci int size, char **error_out); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#endif 99