blob: 27bf2f6fbc05a60d398cb9b2b8ef0a51605711b2 [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"
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include "chan_user.h"
15#include "mconsole_kern.h"
16
17struct line_driver {
18 char *name;
19 char *device_name;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 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
33struct line {
Jeff Dike165dc592006-01-06 00:18:57 -080034 struct tty_struct *tty;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 char *init_str;
36 int init_pri;
37 struct list_head chan_list;
38 int valid;
39 int count;
Jeff Dikee4dcee82006-01-06 00:18:58 -080040 int throttled;
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070041 /*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 Torvalds1da177e2005-04-16 15:20:36 -070049 char *buffer;
50 char *head;
51 char *tail;
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070052
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 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 Viro4d338e12006-03-31 02:30:15 -080060 { .init_str = str, \
61 .init_pri = INIT_STATIC, \
62 .valid = 1, \
63 .lock = SPIN_LOCK_UNLOCKED, \
64 .driver = d }
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66struct lines {
67 int num;
68};
69
Al Viro4d338e12006-03-31 02:30:15 -080070#define LINES_INIT(n) { .num = n }
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72extern void line_close(struct tty_struct *tty, struct file * filp);
Jeff Dike1f801712006-01-06 00:18:55 -080073extern int line_open(struct line *lines, struct tty_struct *tty);
Jeff Diked571cd12006-01-06 00:18:53 -080074extern int line_setup(struct line *lines, unsigned int sizeof_lines,
75 char *init);
Jeff Diked50084a2006-01-06 00:18:50 -080076extern int line_write(struct tty_struct *tty, const unsigned char *buf,
77 int len);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078extern void line_put_char(struct tty_struct *tty, unsigned char ch);
79extern void line_set_termios(struct tty_struct *tty, struct termios * old);
80extern int line_chars_in_buffer(struct tty_struct *tty);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070081extern void line_flush_buffer(struct tty_struct *tty);
82extern void line_flush_chars(struct tty_struct *tty);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083extern int line_write_room(struct tty_struct *tty);
84extern int line_ioctl(struct tty_struct *tty, struct file * file,
85 unsigned int cmd, unsigned long arg);
Jeff Dikee4dcee82006-01-06 00:18:58 -080086extern void line_throttle(struct tty_struct *tty);
87extern void line_unthrottle(struct tty_struct *tty);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -070088
Linus Torvalds1da177e2005-04-16 15:20:36 -070089extern char *add_xterm_umid(char *base);
Jeff Dike165dc592006-01-06 00:18:57 -080090extern int line_setup_irq(int fd, int input, int output, struct line *line,
91 void *data);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092extern void line_close_chan(struct line *line);
Jeff Diked50084a2006-01-06 00:18:50 -080093extern struct tty_driver * line_register_devfs(struct lines *set,
94 struct line_driver *line_driver,
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 struct tty_operations *driver,
96 struct line *lines,
97 int nlines);
Jeff Dike1f801712006-01-06 00:18:55 -080098extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099extern void close_lines(struct line *lines, int nlines);
Paolo 'Blaisorblade' Giarrussob97b77c2005-05-01 08:58:56 -0700100
Jeff Diked50084a2006-01-06 00:18:50 -0800101extern int line_config(struct line *lines, unsigned int sizeof_lines,
Jeff Dike1f801712006-01-06 00:18:55 -0800102 char *str, struct chan_opts *opts);
Jeff Dike29d56cf2005-06-25 14:55:25 -0700103extern int line_id(char **str, int *start_out, int *end_out);
104extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
Jeff Diked50084a2006-01-06 00:18:50 -0800105extern int line_get_config(char *dev, struct line *lines,
106 unsigned int sizeof_lines, char *str,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 int size, char **error_out);
108
109#endif