~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/arch/um/drivers/ssl.c

Version: ~ [ 0.6-2.3.46 ] ~
Architecture: ~ [ um ] ~

** Warning: Cannot open xref database.

1 #include "linux/fs.h" 2 #include "linux/tty.h" 3 #include "linux/tty_driver.h" 4 #include "linux/major.h" 5 #include "linux/mm.h" 6 #include "linux/init.h" 7 #include "asm/termbits.h" 8 #include "ssl.h" 9 #include "user_util.h" 10 #include "kern_util.h" 11 12 static int ssl_version = 0; 13 14 static struct tty_driver ssl_driver; 15 16 static int ssl_refcount = 0; 17 18 #define NR_PORTS 64 19 20 static struct tty_struct *ssl_table[NR_PORTS]; 21 static struct termios *ssl_termios[NR_PORTS]; 22 static struct termios *ssl_termios_locked[NR_PORTS]; 23 24 static struct { 25 int master_fd; 26 struct tty_struct *tty; 27 } private[NR_PORTS]; 28 29 void ssl_receive_char(int fd, char ch) 30 { 31 struct tty_struct *tty; 32 int i; 33 34 for(i=0;i<NR_PORTS;i++){ 35 if(private[i].master_fd == fd) 36 break; 37 } 38 if(i == NR_PORTS) 39 panic("ssl_receive_chars couldn't find fd %d\n", fd); 40 tty = private[i].tty; 41 if(tty == NULL) return; 42 if (tty->flip.count >= TTY_FLIPBUF_SIZE) 43 return; 44 if((tty->flip.flag_buf_ptr == NULL) || (tty->flip.char_buf_ptr == NULL)) 45 return; 46 tty->flip.count++; 47 *tty->flip.flag_buf_ptr++ = 0; 48 *tty->flip.char_buf_ptr++ = ch; 49 tty_flip_buffer_push(tty); 50 } 51 52 int ssl_open(struct tty_struct *tty, struct file * filp) 53 { 54 int line; 55 56 line = MINOR(tty->device) - tty->driver.minor_start; 57 if ((line < 0) || (line >= NR_PORTS)) 58 return -ENODEV; 59 if(private[line].master_fd == -1){ 60 panic("serial line %d hasn't been assigned a pty", line); 61 } 62 if(tty == NULL) panic("NULL tty in ssl_open"); 63 private[line].tty = tty; 64 return(0); 65 } 66 67 static void ssl_close(struct tty_struct *tty, struct file * filp) 68 { 69 int line; 70 71 line = MINOR(tty->device) - tty->driver.minor_start; 72 return; 73 } 74 75 static int ssl_write(struct tty_struct * tty, int from_user, 76 const unsigned char *buf, int count) 77 { 78 int line; 79 80 line = MINOR(tty->device) - tty->driver.minor_start; 81 if ((line < 0) || (line >= NR_PORTS)) 82 panic("Bad tty in ssl_put_char"); 83 if(private[line].master_fd == -1) 84 panic("tty not opened in ssl_put_char"); 85 return(write(private[line].master_fd, buf, count)); 86 } 87 88 static void ssl_put_char(struct tty_struct *tty, unsigned char ch) 89 { 90 int line; 91 92 line = MINOR(tty->device) - tty->driver.minor_start; 93 if ((line < 0) || (line >= NR_PORTS)) 94 panic("Bad tty in ssl_put_char"); 95 if(private[line].master_fd == -1) 96 panic("tty not opened in ssl_put_char"); 97 write(private[line].master_fd, &ch, sizeof(ch)); 98 } 99 100 static void ssl_flush_chars(struct tty_struct *tty) 101 { 102 return; 103 } 104 105 static int ssl_write_room(struct tty_struct *tty) 106 { 107 return(16384); 108 } 109 110 static int ssl_chars_in_buffer(struct tty_struct *tty) 111 { 112 return(0); 113 } 114 115 static void ssl_flush_buffer(struct tty_struct *tty) 116 { 117 return; 118 } 119 120 static int ssl_ioctl(struct tty_struct *tty, struct file * file, 121 unsigned int cmd, unsigned long arg) 122 { 123 int ret; 124 125 ret = 0; 126 switch(cmd){ 127 case TCGETS: 128 case TCSETS: 129 case TCFLSH: 130 case TCSETSF: 131 case TCSETSW: 132 case TCGETA: 133 ret = -ENOIOCTLCMD; 134 break; 135 default: 136 printk("Unimplemented ioctl in ssl_ioctl : 0x%x\n", cmd); 137 ret = -ENOIOCTLCMD; 138 break; 139 } 140 return(ret); 141 } 142 143 static void ssl_throttle(struct tty_struct * tty) 144 { 145 KERN_UNTESTED(); 146 } 147 148 static void ssl_unthrottle(struct tty_struct * tty) 149 { 150 KERN_UNTESTED(); 151 } 152 153 static void ssl_set_termios(struct tty_struct *tty, 154 struct termios *old_termios) 155 { 156 } 157 158 static void ssl_stop(struct tty_struct *tty) 159 { 160 KERN_UNTESTED(); 161 } 162 163 static void ssl_start(struct tty_struct *tty) 164 { 165 KERN_UNTESTED(); 166 } 167 168 void ssl_hangup(struct tty_struct *tty) 169 { 170 return; 171 } 172 173 int ssl_init(void) 174 { 175 char dev[] = "/dev/ptyXX"; 176 unsigned long stack, sp; 177 int i, pid; 178 179 printk(KERN_INFO "Initializing software serial port version %d\n", 180 ssl_version); 181 182 /* Initialize the tty_driver structure */ 183 184 memset(&ssl_driver, 0, sizeof(struct tty_driver)); 185 ssl_driver.magic = TTY_DRIVER_MAGIC; 186 ssl_driver.name = "cua"; 187 ssl_driver.major = TTYAUX_MAJOR; 188 ssl_driver.minor_start = 64; 189 ssl_driver.num = NR_PORTS; 190 ssl_driver.type = TTY_DRIVER_TYPE_SERIAL; 191 ssl_driver.subtype = 0; 192 ssl_driver.init_termios = tty_std_termios; 193 ssl_driver.init_termios.c_cflag = 194 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 195 ssl_driver.flags = TTY_DRIVER_REAL_RAW; 196 ssl_driver.refcount = &ssl_refcount; 197 ssl_driver.table = ssl_table; 198 ssl_driver.termios = ssl_termios; 199 ssl_driver.termios_locked = ssl_termios_locked; 200 201 ssl_driver.open = ssl_open; 202 ssl_driver.close = ssl_close; 203 ssl_driver.write = ssl_write; 204 ssl_driver.put_char = ssl_put_char; 205 ssl_driver.flush_chars = ssl_flush_chars; 206 ssl_driver.write_room = ssl_write_room; 207 ssl_driver.chars_in_buffer = ssl_chars_in_buffer; 208 ssl_driver.flush_buffer = ssl_flush_buffer; 209 ssl_driver.ioctl = ssl_ioctl; 210 ssl_driver.throttle = ssl_throttle; 211 ssl_driver.unthrottle = ssl_unthrottle; 212 ssl_driver.set_termios = ssl_set_termios; 213 ssl_driver.stop = ssl_stop; 214 ssl_driver.start = ssl_start; 215 ssl_driver.hangup = ssl_hangup; 216 if (tty_register_driver(&ssl_driver)) 217 panic("Couldn't register ssl driver\n"); 218 for(i=0;i<NR_PORTS;i++){ 219 private[i].master_fd = -1; 220 } 221 private[0].master_fd = getmaster(dev); 222 printk("serial line %d assigned pty %s\n", 0, dev); 223 ssl_add_fd(private[0].master_fd); 224 stack = __get_free_page(GFP_KERNEL); 225 if(stack == 0) 226 panic("Out of memory in ssl_init"); 227 sp = stack + PAGE_SIZE - sizeof(void *); 228 pid = ssl_thread(sp); 229 printk("ssl receive thread is pid %d\n", pid); 230 return(0); 231 } 232 233 __initcall(ssl_init); 234

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.