2 * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
6 #include "linux/config.h"
9 #include "linux/tty_driver.h"
10 #include "linux/major.h"
12 #include "linux/init.h"
13 #include "asm/termbits.h"
17 #include "chan_kern.h"
18 #include "user_util.h"
19 #include "kern_util.h"
23 #include "mconsole_kern.h"
24 #include "2_5compat.h"
26 static int ssl_version = 1;
28 /* Referenced only by tty_driver below - presumably it's locked correctly
32 static struct tty_driver *ssl_driver;
36 void ssl_announce(char *dev_name, int dev)
38 printk(KERN_INFO "Serial line %d assigned device '%s'\n", dev,
42 static struct chan_opts opts = {
43 .announce = ssl_announce,
44 .xterm_title = "Serial Line #%d",
50 static int ssl_config(char *str);
51 static int ssl_get_config(char *dev, char *str, int size, char **error_out);
52 static int ssl_remove(char *str);
54 static struct line_driver driver = {
55 .name = "UML serial line",
56 .devfs_name = "tts/%d",
57 .major = TTYAUX_MAJOR,
59 .type = TTY_DRIVER_TYPE_SERIAL,
62 .read_irq_name = "ssl",
63 .write_irq = SSL_WRITE_IRQ,
64 .write_irq_name = "ssl-write",
65 .symlink_from = "serial",
70 .get_config = ssl_get_config,
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,
86 sizeof(serial_lines)/sizeof(serial_lines[0]), str));
89 static int ssl_get_config(char *dev, char *str, int size, char **error_out)
91 return(line_get_config(dev, serial_lines,
92 sizeof(serial_lines)/sizeof(serial_lines[0]),
93 str, size, error_out));
96 static int ssl_remove(char *str)
98 return(line_remove(serial_lines,
99 sizeof(serial_lines)/sizeof(serial_lines[0]), str));
102 int ssl_open(struct tty_struct *tty, struct file *filp)
104 return(line_open(serial_lines, tty, &opts));
107 static void ssl_close(struct tty_struct *tty, struct file * filp)
109 line_close(serial_lines, tty);
112 static int ssl_write(struct tty_struct * tty, int from_user,
113 const unsigned char *buf, int count)
115 return(line_write(serial_lines, tty, from_user, buf, count));
118 static void ssl_put_char(struct tty_struct *tty, unsigned char ch)
120 line_write(serial_lines, tty, 0, &ch, sizeof(ch));
123 static void ssl_flush_chars(struct tty_struct *tty)
128 static int ssl_chars_in_buffer(struct tty_struct *tty)
133 static void ssl_flush_buffer(struct tty_struct *tty)
138 static int ssl_ioctl(struct tty_struct *tty, struct file * file,
139 unsigned int cmd, unsigned long arg)
156 "Unimplemented ioctl in ssl_ioctl : 0x%x\n", cmd);
163 static void ssl_throttle(struct tty_struct * tty)
165 printk(KERN_ERR "Someone should implement ssl_throttle\n");
168 static void ssl_unthrottle(struct tty_struct * tty)
170 printk(KERN_ERR "Someone should implement ssl_unthrottle\n");
173 static void ssl_set_termios(struct tty_struct *tty,
174 struct termios *old_termios)
178 static void ssl_stop(struct tty_struct *tty)
180 printk(KERN_ERR "Someone should implement ssl_stop\n");
183 static void ssl_start(struct tty_struct *tty)
185 printk(KERN_ERR "Someone should implement ssl_start\n");
188 void ssl_hangup(struct tty_struct *tty)
192 static struct tty_operations ssl_ops = {
196 .put_char = ssl_put_char,
197 .flush_chars = ssl_flush_chars,
198 .chars_in_buffer = ssl_chars_in_buffer,
199 .flush_buffer = ssl_flush_buffer,
201 .throttle = ssl_throttle,
202 .unthrottle = ssl_unthrottle,
203 .set_termios = ssl_set_termios,
206 .hangup = ssl_hangup,
207 .write_room = line_write_room,
210 /* Changed by ssl_init and referenced by ssl_exit, which are both serialized
211 * by being an initcall and exitcall, respectively.
213 static int ssl_init_done = 0;
219 printk(KERN_INFO "Initializing software serial port version %d\n",
222 ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops,
223 serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]));
225 lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]));
227 new_title = add_xterm_umid(opts.xterm_title);
228 if(new_title != NULL) opts.xterm_title = new_title;
234 __initcall(ssl_init);
236 static int ssl_chan_setup(char *str)
238 line_setup(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]),
243 __setup("ssl", ssl_chan_setup);
244 __channel_help(ssl_chan_setup, "ssl");
246 static void ssl_exit(void)
248 if(!ssl_init_done) return;
249 close_lines(serial_lines,
250 sizeof(serial_lines)/sizeof(serial_lines[0]));
253 __uml_exitcall(ssl_exit);
256 * Overrides for Emacs so that we follow Linus's tabbing style.
257 * Emacs will notice this stuff at the end of the file and automatically
258 * adjust the settings for this buffer only. This must remain at the end
260 * ---------------------------------------------------------------------------
262 * c-file-style: "linux"