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 | |
| 9 | #include "linux/list.h" |
| 10 | #include "linux/workqueue.h" |
| 11 | #include "linux/tty.h" |
| 12 | #include "linux/interrupt.h" |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 13 | #include "linux/spinlock.h" |
Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 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; |
Al Viro | d8c215a | 2011-09-09 17:36:37 -0400 | [diff] [blame] | 36 | struct mutex count_lock; |
Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 37 | int valid; |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | char *init_str; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | struct list_head chan_list; |
Al Viro | ee48507 | 2011-09-08 07:07:26 -0400 | [diff] [blame] | 41 | struct chan *chan_in, *chan_out; |
Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 42 | |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 43 | /*This lock is actually, mostly, local to*/ |
| 44 | spinlock_t lock; |
Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 45 | int throttled; |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 46 | /* Yes, this is a real circular buffer. |
| 47 | * XXX: And this should become a struct kfifo! |
| 48 | * |
| 49 | * buffer points to a buffer allocated on demand, of length |
| 50 | * 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] | 51 | char *buffer; |
| 52 | char *head; |
| 53 | char *tail; |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | int sigio; |
Andrew Morton | a2ce774 | 2006-12-06 20:31:36 -0800 | [diff] [blame] | 56 | struct delayed_work task; |
Jeff Dike | 5e7672e | 2006-09-27 01:50:33 -0700 | [diff] [blame] | 57 | const struct line_driver *driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | extern void line_close(struct tty_struct *tty, struct file * filp); |
Jeff Dike | 1f80171 | 2006-01-06 00:18:55 -0800 | [diff] [blame] | 61 | extern int line_open(struct line *lines, struct tty_struct *tty); |
Al Viro | 43574c1 | 2011-09-09 17:25:00 -0400 | [diff] [blame] | 62 | extern int line_setup(char **conf, unsigned nlines, char **def, |
| 63 | char *init, char *name); |
Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 64 | extern int line_write(struct tty_struct *tty, const unsigned char *buf, |
| 65 | int len); |
WANG Cong | 3168cb9 | 2008-05-06 20:42:33 -0700 | [diff] [blame] | 66 | extern int line_put_char(struct tty_struct *tty, unsigned char ch); |
Alan Cox | 606d099 | 2006-12-08 02:38:45 -0800 | [diff] [blame] | 67 | extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | extern int line_chars_in_buffer(struct tty_struct *tty); |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 69 | extern void line_flush_buffer(struct tty_struct *tty); |
| 70 | extern void line_flush_chars(struct tty_struct *tty); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | extern int line_write_room(struct tty_struct *tty); |
Jeff Dike | e4dcee8 | 2006-01-06 00:18:58 -0800 | [diff] [blame] | 72 | extern void line_throttle(struct tty_struct *tty); |
| 73 | extern void line_unthrottle(struct tty_struct *tty); |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | extern char *add_xterm_umid(char *base); |
Jeff Dike | 165dc59 | 2006-01-06 00:18:57 -0800 | [diff] [blame] | 76 | extern int line_setup_irq(int fd, int input, int output, struct line *line, |
| 77 | void *data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | extern void line_close_chan(struct line *line); |
Al Viro | cfe6b7c | 2011-09-09 19:45:42 -0400 | [diff] [blame] | 79 | extern int register_lines(struct line_driver *line_driver, |
| 80 | const struct tty_operations *driver, |
| 81 | struct line *lines, int nlines); |
Al Viro | 04292b2 | 2011-09-09 20:07:05 -0400 | [diff] [blame] | 82 | extern int setup_one_line(struct line *lines, int n, char *init, |
| 83 | const struct chan_opts *opts, char **error_out); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | extern void close_lines(struct line *lines, int nlines); |
Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 85 | |
Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 86 | extern int line_config(struct line *lines, unsigned int sizeof_lines, |
Jeff Dike | f28169d | 2007-02-10 01:43:53 -0800 | [diff] [blame] | 87 | char *str, const struct chan_opts *opts, |
| 88 | char **error_out); |
Jeff Dike | 29d56cf | 2005-06-25 14:55:25 -0700 | [diff] [blame] | 89 | extern int line_id(char **str, int *start_out, int *end_out); |
Jeff Dike | f28169d | 2007-02-10 01:43:53 -0800 | [diff] [blame] | 90 | extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, |
| 91 | char **error_out); |
Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 92 | extern int line_get_config(char *dev, struct line *lines, |
| 93 | unsigned int sizeof_lines, char *str, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | int size, char **error_out); |
| 95 | |
| 96 | #endif |