Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Viro | 37185b3 | 2012-10-08 03:27:32 +0100 | [diff] [blame] | 9 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include "chan_user.h" |
| 16 | #include "mconsole_kern.h" |
| 17 | |
Al Viro | cfe6b7c | 2011-09-09 19:45:42 -0400 | [diff] [blame] | 18 | /* There's only two modifiable fields in this - .mc.list and .driver */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | struct line_driver { |
Jeff Dike | d5c9ffc | 2007-02-10 01:44:08 -0800 | [diff] [blame] | 20 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | struct mc_device mc; |
Al Viro | cfe6b7c | 2011-09-09 19:45:42 -0400 | [diff] [blame] | 31 | struct tty_driver *driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | struct line { |
Jiri Slaby | 060ed31 | 2012-06-04 13:35:26 +0200 | [diff] [blame] | 35 | struct tty_port port; |
Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 36 | int valid; |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | char *init_str; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | struct list_head chan_list; |
Al Viro | ee48507 | 2011-09-08 07:07:26 -0400 | [diff] [blame] | 40 | struct chan *chan_in, *chan_out; |
Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 41 | |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 42 | /*This lock is actually, mostly, local to*/ |
| 43 | spinlock_t lock; |
Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 44 | int throttled; |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 45 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | char *buffer; |
| 51 | char *head; |
| 52 | char *tail; |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | int sigio; |
Andrew Morton | a2ce774 | 2006-12-06 20:31:36 -0800 | [diff] [blame] | 55 | struct delayed_work task; |
Jeff Dike | 5e7672e | 2006-09-27 01:50:33 -0700 | [diff] [blame] | 56 | const struct line_driver *driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | extern void line_close(struct tty_struct *tty, struct file * filp); |
Richard Weinberger | 79e0273 | 2012-06-04 21:57:24 +0200 | [diff] [blame] | 60 | extern int line_open(struct tty_struct *tty, struct file *filp); |
| 61 | extern int line_install(struct tty_driver *driver, struct tty_struct *tty, |
| 62 | struct line *line); |
| 63 | extern void line_cleanup(struct tty_struct *tty); |
| 64 | extern void line_hangup(struct tty_struct *tty); |
Al Viro | 43574c1 | 2011-09-09 17:25:00 -0400 | [diff] [blame] | 65 | extern int line_setup(char **conf, unsigned nlines, char **def, |
| 66 | char *init, char *name); |
Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 67 | extern int line_write(struct tty_struct *tty, const unsigned char *buf, |
| 68 | int len); |
WANG Cong | 3168cb9 | 2008-05-06 20:42:33 -0700 | [diff] [blame] | 69 | extern int line_put_char(struct tty_struct *tty, unsigned char ch); |
Alan Cox | 606d099 | 2006-12-08 02:38:45 -0800 | [diff] [blame] | 70 | extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | extern int line_chars_in_buffer(struct tty_struct *tty); |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 72 | extern void line_flush_buffer(struct tty_struct *tty); |
| 73 | extern void line_flush_chars(struct tty_struct *tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | extern int line_write_room(struct tty_struct *tty); |
Jeff Dike | e4dcee8 | 2006-01-06 00:18:58 -0800 | [diff] [blame] | 75 | extern void line_throttle(struct tty_struct *tty); |
| 76 | extern void line_unthrottle(struct tty_struct *tty); |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | extern char *add_xterm_umid(char *base); |
Jeff Dike | 165dc59 | 2006-01-06 00:18:57 -0800 | [diff] [blame] | 79 | extern int line_setup_irq(int fd, int input, int output, struct line *line, |
| 80 | void *data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | extern void line_close_chan(struct line *line); |
Al Viro | cfe6b7c | 2011-09-09 19:45:42 -0400 | [diff] [blame] | 82 | extern int register_lines(struct line_driver *line_driver, |
| 83 | const struct tty_operations *driver, |
| 84 | struct line *lines, int nlines); |
Al Viro | 04292b2 | 2011-09-09 20:07:05 -0400 | [diff] [blame] | 85 | extern int setup_one_line(struct line *lines, int n, char *init, |
| 86 | const struct chan_opts *opts, char **error_out); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | extern void close_lines(struct line *lines, int nlines); |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 88 | |
Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 89 | extern int line_config(struct line *lines, unsigned int sizeof_lines, |
Jeff Dike | f28169d | 2007-02-10 01:43:53 -0800 | [diff] [blame] | 90 | char *str, const struct chan_opts *opts, |
| 91 | char **error_out); |
Jeff Dike | 29d56cf | 2005-06-25 14:55:25 -0700 | [diff] [blame] | 92 | extern int line_id(char **str, int *start_out, int *end_out); |
Jeff Dike | f28169d | 2007-02-10 01:43:53 -0800 | [diff] [blame] | 93 | extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, |
| 94 | char **error_out); |
Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 95 | extern int line_get_config(char *dev, struct line *lines, |
| 96 | unsigned int sizeof_lines, char *str, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | int size, char **error_out); |
| 98 | |
| 99 | #endif |