| 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" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include "chan_user.h" | 
|  | 15 | #include "mconsole_kern.h" | 
|  | 16 |  | 
|  | 17 | struct line_driver { | 
|  | 18 | char *name; | 
|  | 19 | char *device_name; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | short major; | 
|  | 21 | short minor_start; | 
|  | 22 | short type; | 
|  | 23 | short subtype; | 
|  | 24 | int read_irq; | 
|  | 25 | char *read_irq_name; | 
|  | 26 | int write_irq; | 
|  | 27 | char *write_irq_name; | 
|  | 28 | char *symlink_from; | 
|  | 29 | char *symlink_to; | 
|  | 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; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | char *init_str; | 
|  | 36 | int init_pri; | 
|  | 37 | struct list_head chan_list; | 
|  | 38 | int valid; | 
|  | 39 | int count; | 
| Jeff Dike | e4dcee8 | 2006-01-06 00:18:58 -0800 | [diff] [blame] | 40 | int throttled; | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 41 | /*This lock is actually, mostly, local to*/ | 
|  | 42 | spinlock_t lock; | 
|  | 43 |  | 
|  | 44 | /* Yes, this is a real circular buffer. | 
|  | 45 | * XXX: And this should become a struct kfifo! | 
|  | 46 | * | 
|  | 47 | * buffer points to a buffer allocated on demand, of length | 
|  | 48 | * 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] | 49 | char *buffer; | 
|  | 50 | char *head; | 
|  | 51 | char *tail; | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 52 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | int sigio; | 
|  | 54 | struct work_struct task; | 
|  | 55 | struct line_driver *driver; | 
|  | 56 | int have_irq; | 
|  | 57 | }; | 
|  | 58 |  | 
|  | 59 | #define LINE_INIT(str, d) \ | 
| Al Viro | 4d338e1 | 2006-03-31 02:30:15 -0800 | [diff] [blame] | 60 | { .init_str =	str, \ | 
|  | 61 | .init_pri =	INIT_STATIC, \ | 
|  | 62 | .valid =	1, \ | 
|  | 63 | .lock =	SPIN_LOCK_UNLOCKED, \ | 
|  | 64 | .driver =	d } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 |  | 
|  | 66 | struct lines { | 
|  | 67 | int num; | 
|  | 68 | }; | 
|  | 69 |  | 
| Al Viro | 4d338e1 | 2006-03-31 02:30:15 -0800 | [diff] [blame] | 70 | #define LINES_INIT(n) {  .num =	n } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 |  | 
|  | 72 | extern void line_close(struct tty_struct *tty, struct file * filp); | 
| Jeff Dike | 1f80171 | 2006-01-06 00:18:55 -0800 | [diff] [blame] | 73 | extern int line_open(struct line *lines, struct tty_struct *tty); | 
| Jeff Dike | d571cd1 | 2006-01-06 00:18:53 -0800 | [diff] [blame] | 74 | extern int line_setup(struct line *lines, unsigned int sizeof_lines, | 
|  | 75 | char *init); | 
| Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 76 | extern int line_write(struct tty_struct *tty, const unsigned char *buf, | 
|  | 77 | int len); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | extern void line_put_char(struct tty_struct *tty, unsigned char ch); | 
|  | 79 | extern void line_set_termios(struct tty_struct *tty, struct termios * old); | 
|  | 80 | extern int line_chars_in_buffer(struct tty_struct *tty); | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 81 | extern void line_flush_buffer(struct tty_struct *tty); | 
|  | 82 | extern void line_flush_chars(struct tty_struct *tty); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | extern int line_write_room(struct tty_struct *tty); | 
|  | 84 | extern int line_ioctl(struct tty_struct *tty, struct file * file, | 
|  | 85 | unsigned int cmd, unsigned long arg); | 
| Jeff Dike | e4dcee8 | 2006-01-06 00:18:58 -0800 | [diff] [blame] | 86 | extern void line_throttle(struct tty_struct *tty); | 
|  | 87 | extern void line_unthrottle(struct tty_struct *tty); | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 88 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | extern char *add_xterm_umid(char *base); | 
| Jeff Dike | 165dc59 | 2006-01-06 00:18:57 -0800 | [diff] [blame] | 90 | extern int line_setup_irq(int fd, int input, int output, struct line *line, | 
|  | 91 | void *data); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | extern void line_close_chan(struct line *line); | 
| Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 93 | extern struct tty_driver * line_register_devfs(struct lines *set, | 
|  | 94 | struct line_driver *line_driver, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | struct tty_operations *driver, | 
|  | 96 | struct line *lines, | 
|  | 97 | int nlines); | 
| Jeff Dike | 1f80171 | 2006-01-06 00:18:55 -0800 | [diff] [blame] | 98 | 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] | 99 | extern void close_lines(struct line *lines, int nlines); | 
| Paolo 'Blaisorblade' Giarrusso | b97b77c | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 100 |  | 
| Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 101 | extern int line_config(struct line *lines, unsigned int sizeof_lines, | 
| Jeff Dike | 1f80171 | 2006-01-06 00:18:55 -0800 | [diff] [blame] | 102 | char *str, struct chan_opts *opts); | 
| Jeff Dike | 29d56cf | 2005-06-25 14:55:25 -0700 | [diff] [blame] | 103 | extern int line_id(char **str, int *start_out, int *end_out); | 
|  | 104 | extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n); | 
| Jeff Dike | d50084a | 2006-01-06 00:18:50 -0800 | [diff] [blame] | 105 | extern int line_get_config(char *dev, struct line *lines, | 
|  | 106 | unsigned int sizeof_lines, char *str, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | int size, char **error_out); | 
|  | 108 |  | 
|  | 109 | #endif |