blob: 138a14526d9c5c140fe4c91caee9c528a63d5680 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __LINE_H__
7#define __LINE_H__
8
Al Viro37185b32012-10-08 03:27:32 +01009#include <linux/list.h>
10#include <linux/workqueue.h>
11#include <linux/tty.h>
12#include <linux/interrupt.h>
13#include <linux/spinlock.h>
14#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include "chan_user.h"
16#include "mconsole_kern.h"
17
Al Virocfe6b7c2011-09-09 19:45:42 -040018/* There's only two modifiable fields in this - .mc.list and .driver */
Linus Torvalds1da177e2005-04-16 15:20:36 -070019struct line_driver {
Jeff Diked5c9ffc2007-02-10 01:44:08 -080020 const char *name;
21 const char *device_name;
22 const short major;
23 const short minor_start;
24 const short type;
25 const short subtype;
26 const int read_irq;
27 const char *read_irq_name;
28 const int write_irq;
29 const char *write_irq_name;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 struct mc_device mc;
Al Virocfe6b7c2011-09-09 19:45:42 -040031 struct tty_driver *driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032};
33
34struct line {
Jiri Slaby060ed312012-06-04 13:35:26 +020035 struct tty_port port;
Jeff Diked79a5802007-02-10 01:43:52 -080036 int valid;
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 char *init_str;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 struct list_head chan_list;
Al Viroee485072011-09-08 07:07:26 -040040 struct chan *chan_in, *chan_out;
Jeff Diked79a5802007-02-10 01:43:52 -080041
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070042 /*This lock is actually, mostly, local to*/
43 spinlock_t lock;
Jeff Diked79a5802007-02-10 01:43:52 -080044 int throttled;
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070045 /* Yes, this is a real circular buffer.
46 * XXX: And this should become a struct kfifo!
47 *
48 * buffer points to a buffer allocated on demand, of length
49 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 char *buffer;
51 char *head;
52 char *tail;
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070053
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 int sigio;
Andrew Mortona2ce7742006-12-06 20:31:36 -080055 struct delayed_work task;
Jeff Dike5e7672e2006-09-27 01:50:33 -070056 const struct line_driver *driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057};
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059extern void line_close(struct tty_struct *tty, struct file * filp);
Richard Weinberger79e02732012-06-04 21:57:24 +020060extern int line_open(struct tty_struct *tty, struct file *filp);
61extern int line_install(struct tty_driver *driver, struct tty_struct *tty,
62 struct line *line);
63extern void line_cleanup(struct tty_struct *tty);
64extern void line_hangup(struct tty_struct *tty);
Al Viro43574c12011-09-09 17:25:00 -040065extern int line_setup(char **conf, unsigned nlines, char **def,
66 char *init, char *name);
Jeff Diked50084a2006-01-06 00:18:50 -080067extern int line_write(struct tty_struct *tty, const unsigned char *buf,
68 int len);
WANG Cong3168cb92008-05-06 20:42:33 -070069extern int line_put_char(struct tty_struct *tty, unsigned char ch);
Alan Cox606d0992006-12-08 02:38:45 -080070extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071extern int line_chars_in_buffer(struct tty_struct *tty);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070072extern void line_flush_buffer(struct tty_struct *tty);
73extern void line_flush_chars(struct tty_struct *tty);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern int line_write_room(struct tty_struct *tty);
Jeff Dikee4dcee82006-01-06 00:18:58 -080075extern void line_throttle(struct tty_struct *tty);
76extern void line_unthrottle(struct tty_struct *tty);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070077
Linus Torvalds1da177e2005-04-16 15:20:36 -070078extern char *add_xterm_umid(char *base);
Jeff Dike165dc592006-01-06 00:18:57 -080079extern int line_setup_irq(int fd, int input, int output, struct line *line,
80 void *data);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081extern void line_close_chan(struct line *line);
Al Virocfe6b7c2011-09-09 19:45:42 -040082extern int register_lines(struct line_driver *line_driver,
83 const struct tty_operations *driver,
84 struct line *lines, int nlines);
Al Viro04292b22011-09-09 20:07:05 -040085extern int setup_one_line(struct line *lines, int n, char *init,
86 const struct chan_opts *opts, char **error_out);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087extern void close_lines(struct line *lines, int nlines);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070088
Jeff Diked50084a2006-01-06 00:18:50 -080089extern int line_config(struct line *lines, unsigned int sizeof_lines,
Jeff Dikef28169d2007-02-10 01:43:53 -080090 char *str, const struct chan_opts *opts,
91 char **error_out);
Jeff Dike29d56cf2005-06-25 14:55:25 -070092extern int line_id(char **str, int *start_out, int *end_out);
Jeff Dikef28169d2007-02-10 01:43:53 -080093extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n,
94 char **error_out);
Jeff Diked50084a2006-01-06 00:18:50 -080095extern int line_get_config(char *dev, struct line *lines,
96 unsigned int sizeof_lines, char *str,
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 int size, char **error_out);
98
99#endif