162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __LINE_H__ 762306a36Sopenharmony_ci#define __LINE_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/list.h> 1062306a36Sopenharmony_ci#include <linux/workqueue.h> 1162306a36Sopenharmony_ci#include <linux/tty.h> 1262306a36Sopenharmony_ci#include <linux/interrupt.h> 1362306a36Sopenharmony_ci#include <linux/spinlock.h> 1462306a36Sopenharmony_ci#include <linux/mutex.h> 1562306a36Sopenharmony_ci#include "chan_user.h" 1662306a36Sopenharmony_ci#include "mconsole_kern.h" 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* There's only two modifiable fields in this - .mc.list and .driver */ 1962306a36Sopenharmony_cistruct line_driver { 2062306a36Sopenharmony_ci const char *name; 2162306a36Sopenharmony_ci const char *device_name; 2262306a36Sopenharmony_ci const short major; 2362306a36Sopenharmony_ci const short minor_start; 2462306a36Sopenharmony_ci const short type; 2562306a36Sopenharmony_ci const short subtype; 2662306a36Sopenharmony_ci const char *read_irq_name; 2762306a36Sopenharmony_ci const char *write_irq_name; 2862306a36Sopenharmony_ci struct mc_device mc; 2962306a36Sopenharmony_ci struct tty_driver *driver; 3062306a36Sopenharmony_ci}; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cistruct line { 3362306a36Sopenharmony_ci struct tty_port port; 3462306a36Sopenharmony_ci int valid; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci int read_irq, write_irq; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci char *init_str; 3962306a36Sopenharmony_ci struct list_head chan_list; 4062306a36Sopenharmony_ci struct chan *chan_in, *chan_out; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci /*This lock is actually, mostly, local to*/ 4362306a36Sopenharmony_ci spinlock_t lock; 4462306a36Sopenharmony_ci int throttled; 4562306a36Sopenharmony_ci /* Yes, this is a real circular buffer. 4662306a36Sopenharmony_ci * XXX: And this should become a struct kfifo! 4762306a36Sopenharmony_ci * 4862306a36Sopenharmony_ci * buffer points to a buffer allocated on demand, of length 4962306a36Sopenharmony_ci * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/ 5062306a36Sopenharmony_ci char *buffer; 5162306a36Sopenharmony_ci char *head; 5262306a36Sopenharmony_ci char *tail; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci int sigio; 5562306a36Sopenharmony_ci struct delayed_work task; 5662306a36Sopenharmony_ci const struct line_driver *driver; 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ciextern void line_close(struct tty_struct *tty, struct file * filp); 6062306a36Sopenharmony_ciextern int line_open(struct tty_struct *tty, struct file *filp); 6162306a36Sopenharmony_ciextern int line_install(struct tty_driver *driver, struct tty_struct *tty, 6262306a36Sopenharmony_ci struct line *line); 6362306a36Sopenharmony_ciextern void line_cleanup(struct tty_struct *tty); 6462306a36Sopenharmony_ciextern void line_hangup(struct tty_struct *tty); 6562306a36Sopenharmony_ciextern int line_setup(char **conf, unsigned nlines, char **def, 6662306a36Sopenharmony_ci char *init, char *name); 6762306a36Sopenharmony_ciextern ssize_t line_write(struct tty_struct *tty, const u8 *buf, size_t len); 6862306a36Sopenharmony_ciextern unsigned int line_chars_in_buffer(struct tty_struct *tty); 6962306a36Sopenharmony_ciextern void line_flush_buffer(struct tty_struct *tty); 7062306a36Sopenharmony_ciextern void line_flush_chars(struct tty_struct *tty); 7162306a36Sopenharmony_ciextern unsigned int line_write_room(struct tty_struct *tty); 7262306a36Sopenharmony_ciextern void line_throttle(struct tty_struct *tty); 7362306a36Sopenharmony_ciextern void line_unthrottle(struct tty_struct *tty); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciextern char *add_xterm_umid(char *base); 7662306a36Sopenharmony_ciextern int line_setup_irq(int fd, int input, int output, struct line *line, 7762306a36Sopenharmony_ci void *data); 7862306a36Sopenharmony_ciextern void line_close_chan(struct line *line); 7962306a36Sopenharmony_ciextern int register_lines(struct line_driver *line_driver, 8062306a36Sopenharmony_ci const struct tty_operations *driver, 8162306a36Sopenharmony_ci struct line *lines, int nlines); 8262306a36Sopenharmony_ciextern int setup_one_line(struct line *lines, int n, char *init, 8362306a36Sopenharmony_ci const struct chan_opts *opts, char **error_out); 8462306a36Sopenharmony_ciextern void close_lines(struct line *lines, int nlines); 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ciextern int line_config(struct line *lines, unsigned int sizeof_lines, 8762306a36Sopenharmony_ci char *str, const struct chan_opts *opts, 8862306a36Sopenharmony_ci char **error_out); 8962306a36Sopenharmony_ciextern int line_id(char **str, int *start_out, int *end_out); 9062306a36Sopenharmony_ciextern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, 9162306a36Sopenharmony_ci char **error_out); 9262306a36Sopenharmony_ciextern int line_get_config(char *dev, struct line *lines, 9362306a36Sopenharmony_ci unsigned int sizeof_lines, char *str, 9462306a36Sopenharmony_ci int size, char **error_out); 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#endif 97