| 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 |  | 
| Jeff Dike | d5c9ffc | 2007-02-10 01:44:08 -0800 | [diff] [blame] | 18 | /* There's only one modifiable field in this - .mc.list */ | 
| 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; | 
|  | 31 | }; | 
|  | 32 |  | 
|  | 33 | struct line { | 
| Jeff Dike | 165dc59 | 2006-01-06 00:18:57 -0800 | [diff] [blame] | 34 | struct tty_struct *tty; | 
| Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 35 | spinlock_t count_lock; | 
|  | 36 | int valid; | 
|  | 37 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | char *init_str; | 
|  | 39 | int init_pri; | 
|  | 40 | struct list_head chan_list; | 
| 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 | int have_irq; | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | #define LINE_INIT(str, d) \ | 
| Jeff Dike | 5563d72 | 2008-05-12 14:01:54 -0700 | [diff] [blame] | 61 | { .count_lock =	__SPIN_LOCK_UNLOCKED((str).count_lock), \ | 
| Jeff Dike | d79a580 | 2007-02-10 01:43:52 -0800 | [diff] [blame] | 62 | .init_str =	str,	\ | 
| Al Viro | 4d338e1 | 2006-03-31 02:30:15 -0800 | [diff] [blame] | 63 | .init_pri =	INIT_STATIC, \ | 
|  | 64 | .valid =	1, \ | 
| Jeff Dike | 5563d72 | 2008-05-12 14:01:54 -0700 | [diff] [blame] | 65 | .lock =	__SPIN_LOCK_UNLOCKED((str).lock), \ | 
| Al Viro | 4d338e1 | 2006-03-31 02:30:15 -0800 | [diff] [blame] | 66 | .driver =	d } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | extern void line_close(struct tty_struct *tty, struct file * filp); | 
| Jeff Dike | 1f80171 | 2006-01-06 00:18:55 -0800 | [diff] [blame] | 69 | extern int line_open(struct line *lines, struct tty_struct *tty); | 
| Jeff Dike | d571cd1 | 2006-01-06 00:18:53 -0800 | [diff] [blame] | 70 | extern int line_setup(struct line *lines, unsigned int sizeof_lines, | 
| Jeff Dike | f28169d | 2007-02-10 01:43:53 -0800 | [diff] [blame] | 71 | char *init, char **error_out); | 
| Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 72 | extern int line_write(struct tty_struct *tty, const unsigned char *buf, | 
|  | 73 | int len); | 
| WANG Cong | 3168cb9 | 2008-05-06 20:42:33 -0700 | [diff] [blame] | 74 | extern int line_put_char(struct tty_struct *tty, unsigned char ch); | 
| Alan Cox | 606d099 | 2006-12-08 02:38:45 -0800 | [diff] [blame] | 75 | extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | extern int line_chars_in_buffer(struct tty_struct *tty); | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 77 | extern void line_flush_buffer(struct tty_struct *tty); | 
|  | 78 | extern void line_flush_chars(struct tty_struct *tty); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | extern int line_write_room(struct tty_struct *tty); | 
| Richard Weinberger | 8a06dc4d | 2011-03-22 16:33:48 -0700 | [diff] [blame] | 80 | extern int line_ioctl(struct tty_struct *tty, unsigned int cmd, | 
|  | 81 | unsigned long arg); | 
| Jeff Dike | e4dcee8 | 2006-01-06 00:18:58 -0800 | [diff] [blame] | 82 | extern void line_throttle(struct tty_struct *tty); | 
|  | 83 | extern void line_unthrottle(struct tty_struct *tty); | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 84 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | extern char *add_xterm_umid(char *base); | 
| Jeff Dike | 165dc59 | 2006-01-06 00:18:57 -0800 | [diff] [blame] | 86 | extern int line_setup_irq(int fd, int input, int output, struct line *line, | 
|  | 87 | void *data); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | extern void line_close_chan(struct line *line); | 
| Jeff Dike | d5c9ffc | 2007-02-10 01:44:08 -0800 | [diff] [blame] | 89 | extern struct tty_driver *register_lines(struct line_driver *line_driver, | 
|  | 90 | const struct tty_operations *driver, | 
|  | 91 | struct line *lines, int nlines); | 
| Jeff Dike | 1f80171 | 2006-01-06 00:18:55 -0800 | [diff] [blame] | 92 | extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | extern void close_lines(struct line *lines, int nlines); | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 94 |  | 
| Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 95 | extern int line_config(struct line *lines, unsigned int sizeof_lines, | 
| Jeff Dike | f28169d | 2007-02-10 01:43:53 -0800 | [diff] [blame] | 96 | char *str, const struct chan_opts *opts, | 
|  | 97 | char **error_out); | 
| Jeff Dike | 29d56cf | 2005-06-25 14:55:25 -0700 | [diff] [blame] | 98 | extern int line_id(char **str, int *start_out, int *end_out); | 
| Jeff Dike | f28169d | 2007-02-10 01:43:53 -0800 | [diff] [blame] | 99 | extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n, | 
|  | 100 | char **error_out); | 
| Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 101 | extern int line_get_config(char *dev, struct line *lines, | 
|  | 102 | unsigned int sizeof_lines, char *str, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | int size, char **error_out); | 
|  | 104 |  | 
|  | 105 | #endif |