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