[IPV6]: Give sit driver an appropriate module alias.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / um / drivers / ssl.c
blobed9c59082d0df56806248e7928d4a953d524d15e
1 /*
2 * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
6 #include "linux/fs.h"
7 #include "linux/tty.h"
8 #include "linux/tty_driver.h"
9 #include "linux/major.h"
10 #include "linux/mm.h"
11 #include "linux/init.h"
12 #include "linux/console.h"
13 #include "asm/termbits.h"
14 #include "asm/irq.h"
15 #include "line.h"
16 #include "ssl.h"
17 #include "chan_kern.h"
18 #include "user_util.h"
19 #include "kern_util.h"
20 #include "kern.h"
21 #include "init.h"
22 #include "irq_user.h"
23 #include "mconsole_kern.h"
25 static const int ssl_version = 1;
27 /* Referenced only by tty_driver below - presumably it's locked correctly
28 * by the tty driver.
31 static struct tty_driver *ssl_driver;
33 #define NR_PORTS 64
35 static void ssl_announce(char *dev_name, int dev)
37 printk(KERN_INFO "Serial line %d assigned device '%s'\n", dev,
38 dev_name);
41 static struct chan_opts opts = {
42 .announce = ssl_announce,
43 .xterm_title = "Serial Line #%d",
44 .raw = 1,
45 .tramp_stack = 0,
46 .in_kernel = 1,
49 static int ssl_config(char *str);
50 static int ssl_get_config(char *dev, char *str, int size, char **error_out);
51 static int ssl_remove(int n);
53 static struct line_driver driver = {
54 .name = "UML serial line",
55 .device_name = "ttyS",
56 .major = TTY_MAJOR,
57 .minor_start = 64,
58 .type = TTY_DRIVER_TYPE_SERIAL,
59 .subtype = 0,
60 .read_irq = SSL_IRQ,
61 .read_irq_name = "ssl",
62 .write_irq = SSL_WRITE_IRQ,
63 .write_irq_name = "ssl-write",
64 .symlink_from = "serial",
65 .symlink_to = "tts",
66 .mc = {
67 .name = "ssl",
68 .config = ssl_config,
69 .get_config = ssl_get_config,
70 .id = line_id,
71 .remove = ssl_remove,
75 /* The array is initialized by line_init, which is an initcall. The
76 * individual elements are protected by individual semaphores.
78 static struct line serial_lines[NR_PORTS] =
79 { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) };
81 static struct lines lines = LINES_INIT(NR_PORTS);
83 static int ssl_config(char *str)
85 return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts);
88 static int ssl_get_config(char *dev, char *str, int size, char **error_out)
90 return line_get_config(dev, serial_lines, ARRAY_SIZE(serial_lines), str,
91 size, error_out);
94 static int ssl_remove(int n)
96 return line_remove(serial_lines, ARRAY_SIZE(serial_lines), n);
99 static int ssl_open(struct tty_struct *tty, struct file *filp)
101 return line_open(serial_lines, tty);
104 #if 0
105 static void ssl_flush_buffer(struct tty_struct *tty)
107 return;
110 static void ssl_stop(struct tty_struct *tty)
112 printk(KERN_ERR "Someone should implement ssl_stop\n");
115 static void ssl_start(struct tty_struct *tty)
117 printk(KERN_ERR "Someone should implement ssl_start\n");
120 void ssl_hangup(struct tty_struct *tty)
123 #endif
125 static const struct tty_operations ssl_ops = {
126 .open = ssl_open,
127 .close = line_close,
128 .write = line_write,
129 .put_char = line_put_char,
130 .write_room = line_write_room,
131 .chars_in_buffer = line_chars_in_buffer,
132 .flush_buffer = line_flush_buffer,
133 .flush_chars = line_flush_chars,
134 .set_termios = line_set_termios,
135 .ioctl = line_ioctl,
136 .throttle = line_throttle,
137 .unthrottle = line_unthrottle,
138 #if 0
139 .stop = ssl_stop,
140 .start = ssl_start,
141 .hangup = ssl_hangup,
142 #endif
145 /* Changed by ssl_init and referenced by ssl_exit, which are both serialized
146 * by being an initcall and exitcall, respectively.
148 static int ssl_init_done = 0;
150 static void ssl_console_write(struct console *c, const char *string,
151 unsigned len)
153 struct line *line = &serial_lines[c->index];
154 unsigned long flags;
156 spin_lock_irqsave(&line->lock, flags);
157 console_write_chan(&line->chan_list, string, len);
158 spin_unlock_irqrestore(&line->lock, flags);
161 static struct tty_driver *ssl_console_device(struct console *c, int *index)
163 *index = c->index;
164 return ssl_driver;
167 static int ssl_console_setup(struct console *co, char *options)
169 struct line *line = &serial_lines[co->index];
171 return console_open_chan(line, co, &opts);
174 static struct console ssl_cons = {
175 .name = "ttyS",
176 .write = ssl_console_write,
177 .device = ssl_console_device,
178 .setup = ssl_console_setup,
179 .flags = CON_PRINTBUFFER,
180 .index = -1,
183 static int ssl_init(void)
185 char *new_title;
187 printk(KERN_INFO "Initializing software serial port version %d\n",
188 ssl_version);
189 ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops,
190 serial_lines,
191 ARRAY_SIZE(serial_lines));
193 lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts);
195 new_title = add_xterm_umid(opts.xterm_title);
196 if (new_title != NULL)
197 opts.xterm_title = new_title;
199 ssl_init_done = 1;
200 register_console(&ssl_cons);
201 return 0;
203 late_initcall(ssl_init);
205 static void ssl_exit(void)
207 if (!ssl_init_done)
208 return;
209 close_lines(serial_lines, ARRAY_SIZE(serial_lines));
211 __uml_exitcall(ssl_exit);
213 static int ssl_chan_setup(char *str)
215 return line_setup(serial_lines, ARRAY_SIZE(serial_lines), str);
218 __setup("ssl", ssl_chan_setup);
219 __channel_help(ssl_chan_setup, "ssl");