blob: b79643eeee08b8de14fff824ba1936652b1c9505 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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' Giarrussob97b77c2005-05-01 08:58:56 -070013#include "linux/spinlock.h"
Jeff Diked79a5802007-02-10 01:43:52 -080014#include "linux/mutex.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include "chan_user.h"
16#include "mconsole_kern.h"
17
18struct line_driver {
19 char *name;
20 char *device_name;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 short major;
22 short minor_start;
23 short type;
24 short subtype;
25 int read_irq;
26 char *read_irq_name;
27 int write_irq;
28 char *write_irq_name;
29 char *symlink_from;
30 char *symlink_to;
31 struct mc_device mc;
32};
33
34struct line {
Jeff Dike165dc592006-01-06 00:18:57 -080035 struct tty_struct *tty;
Jeff Diked79a5802007-02-10 01:43:52 -080036 spinlock_t count_lock;
37 int valid;
38
39 struct mutex open_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 char *init_str;
41 int init_pri;
42 struct list_head chan_list;
Jeff Diked79a5802007-02-10 01:43:52 -080043
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070044 /*This lock is actually, mostly, local to*/
45 spinlock_t lock;
Jeff Diked79a5802007-02-10 01:43:52 -080046 int throttled;
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070047 /* 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 Torvalds1da177e2005-04-16 15:20:36 -070052 char *buffer;
53 char *head;
54 char *tail;
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070055
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 int sigio;
Andrew Mortona2ce7742006-12-06 20:31:36 -080057 struct delayed_work task;
Jeff Dike5e7672e2006-09-27 01:50:33 -070058 const struct line_driver *driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 int have_irq;
60};
61
62#define LINE_INIT(str, d) \
Jeff Diked79a5802007-02-10 01:43:52 -080063 { .count_lock = SPIN_LOCK_UNLOCKED, \
64 .init_str = str, \
Al Viro4d338e12006-03-31 02:30:15 -080065 .init_pri = INIT_STATIC, \
66 .valid = 1, \
67 .lock = SPIN_LOCK_UNLOCKED, \
68 .driver = d }
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70struct lines {
71 int num;
72};
73
Al Viro4d338e12006-03-31 02:30:15 -080074#define LINES_INIT(n) { .num = n }
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76extern void line_close(struct tty_struct *tty, struct file * filp);
Jeff Dike1f801712006-01-06 00:18:55 -080077extern int line_open(struct line *lines, struct tty_struct *tty);
Jeff Diked571cd12006-01-06 00:18:53 -080078extern int line_setup(struct line *lines, unsigned int sizeof_lines,
79 char *init);
Jeff Diked50084a2006-01-06 00:18:50 -080080extern int line_write(struct tty_struct *tty, const unsigned char *buf,
81 int len);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082extern void line_put_char(struct tty_struct *tty, unsigned char ch);
Alan Cox606d0992006-12-08 02:38:45 -080083extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084extern int line_chars_in_buffer(struct tty_struct *tty);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070085extern void line_flush_buffer(struct tty_struct *tty);
86extern void line_flush_chars(struct tty_struct *tty);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087extern int line_write_room(struct tty_struct *tty);
88extern int line_ioctl(struct tty_struct *tty, struct file * file,
89 unsigned int cmd, unsigned long arg);
Jeff Dikee4dcee82006-01-06 00:18:58 -080090extern void line_throttle(struct tty_struct *tty);
91extern void line_unthrottle(struct tty_struct *tty);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070092
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern char *add_xterm_umid(char *base);
Jeff Dike165dc592006-01-06 00:18:57 -080094extern int line_setup_irq(int fd, int input, int output, struct line *line,
95 void *data);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096extern void line_close_chan(struct line *line);
Jeff Diked50084a2006-01-06 00:18:50 -080097extern struct tty_driver * line_register_devfs(struct lines *set,
Jeff Dikeb68e31d2006-10-02 02:17:18 -070098 struct line_driver *line_driver,
99 const struct tty_operations *driver,
100 struct line *lines, int nlines);
Jeff Dike1f801712006-01-06 00:18:55 -0800101extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102extern void close_lines(struct line *lines, int nlines);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -0700103
Jeff Diked50084a2006-01-06 00:18:50 -0800104extern int line_config(struct line *lines, unsigned int sizeof_lines,
Jeff Dike5e7672e2006-09-27 01:50:33 -0700105 char *str, const struct chan_opts *opts);
Jeff Dike29d56cf2005-06-25 14:55:25 -0700106extern int line_id(char **str, int *start_out, int *end_out);
107extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
Jeff Diked50084a2006-01-06 00:18:50 -0800108extern int line_get_config(char *dev, struct line *lines,
109 unsigned int sizeof_lines, char *str,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 int size, char **error_out);
111
112#endif