diff options
Diffstat (limited to 'drivers/char/rio/rioparam.c')
-rw-r--r-- | drivers/char/rio/rioparam.c | 663 |
1 files changed, 0 insertions, 663 deletions
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c deleted file mode 100644 index 6415f3f32a72..000000000000 --- a/drivers/char/rio/rioparam.c +++ /dev/null | |||
@@ -1,663 +0,0 @@ | |||
1 | /* | ||
2 | ** ----------------------------------------------------------------------------- | ||
3 | ** | ||
4 | ** Perle Specialix driver for Linux | ||
5 | ** Ported from existing RIO Driver for SCO sources. | ||
6 | * | ||
7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | ** | ||
23 | ** Module : rioparam.c | ||
24 | ** SID : 1.3 | ||
25 | ** Last Modified : 11/6/98 10:33:45 | ||
26 | ** Retrieved : 11/6/98 10:33:50 | ||
27 | ** | ||
28 | ** ident @(#)rioparam.c 1.3 | ||
29 | ** | ||
30 | ** ----------------------------------------------------------------------------- | ||
31 | */ | ||
32 | |||
33 | #include <linux/module.h> | ||
34 | #include <linux/errno.h> | ||
35 | #include <linux/tty.h> | ||
36 | #include <asm/io.h> | ||
37 | #include <asm/system.h> | ||
38 | #include <asm/string.h> | ||
39 | #include <asm/uaccess.h> | ||
40 | |||
41 | #include <linux/termios.h> | ||
42 | #include <linux/serial.h> | ||
43 | |||
44 | #include <linux/generic_serial.h> | ||
45 | |||
46 | |||
47 | #include "linux_compat.h" | ||
48 | #include "rio_linux.h" | ||
49 | #include "pkt.h" | ||
50 | #include "daemon.h" | ||
51 | #include "rio.h" | ||
52 | #include "riospace.h" | ||
53 | #include "cmdpkt.h" | ||
54 | #include "map.h" | ||
55 | #include "rup.h" | ||
56 | #include "port.h" | ||
57 | #include "riodrvr.h" | ||
58 | #include "rioinfo.h" | ||
59 | #include "func.h" | ||
60 | #include "errors.h" | ||
61 | #include "pci.h" | ||
62 | |||
63 | #include "parmmap.h" | ||
64 | #include "unixrup.h" | ||
65 | #include "board.h" | ||
66 | #include "host.h" | ||
67 | #include "phb.h" | ||
68 | #include "link.h" | ||
69 | #include "cmdblk.h" | ||
70 | #include "route.h" | ||
71 | #include "cirrus.h" | ||
72 | #include "rioioctl.h" | ||
73 | #include "param.h" | ||
74 | |||
75 | |||
76 | |||
77 | /* | ||
78 | ** The Scam, based on email from jeremyr@bugs.specialix.co.uk.... | ||
79 | ** | ||
80 | ** To send a command on a particular port, you put a packet with the | ||
81 | ** command bit set onto the port. The command bit is in the len field, | ||
82 | ** and gets ORed in with the actual byte count. | ||
83 | ** | ||
84 | ** When you send a packet with the command bit set the first | ||
85 | ** data byte (data[0]) is interpreted as the command to execute. | ||
86 | ** It also governs what data structure overlay should accompany the packet. | ||
87 | ** Commands are defined in cirrus/cirrus.h | ||
88 | ** | ||
89 | ** If you want the command to pre-emt data already on the queue for the | ||
90 | ** port, set the pre-emptive bit in conjunction with the command bit. | ||
91 | ** It is not defined what will happen if you set the preemptive bit | ||
92 | ** on a packet that is NOT a command. | ||
93 | ** | ||
94 | ** Pre-emptive commands should be queued at the head of the queue using | ||
95 | ** add_start(), whereas normal commands and data are enqueued using | ||
96 | ** add_end(). | ||
97 | ** | ||
98 | ** Most commands do not use the remaining bytes in the data array. The | ||
99 | ** exceptions are OPEN MOPEN and CONFIG. (NB. As with the SI CONFIG and | ||
100 | ** OPEN are currently analogous). With these three commands the following | ||
101 | ** 11 data bytes are all used to pass config information such as baud rate etc. | ||
102 | ** The fields are also defined in cirrus.h. Some contain straightforward | ||
103 | ** information such as the transmit XON character. Two contain the transmit and | ||
104 | ** receive baud rates respectively. For most baud rates there is a direct | ||
105 | ** mapping between the rates defined in <sys/termio.h> and the byte in the | ||
106 | ** packet. There are additional (non UNIX-standard) rates defined in | ||
107 | ** /u/dos/rio/cirrus/h/brates.h. | ||
108 | ** | ||
109 | ** The rest of the data fields contain approximations to the Cirrus registers | ||
110 | ** that are used to program number of bits etc. Each registers bit fields is | ||
111 | ** defined in cirrus.h. | ||
112 | ** | ||
113 | ** NB. Only use those bits that are defined as being driver specific | ||
114 | ** or common to the RTA and the driver. | ||
115 | ** | ||
116 | ** All commands going from RTA->Host will be dealt with by the Host code - you | ||
117 | ** will never see them. As with the SI there will be three fields to look out | ||
118 | ** for in each phb (not yet defined - needs defining a.s.a.p). | ||
119 | ** | ||
120 | ** modem_status - current state of handshake pins. | ||
121 | ** | ||
122 | ** port_status - current port status - equivalent to hi_stat for SI, indicates | ||
123 | ** if port is IDLE_OPEN, IDLE_CLOSED etc. | ||
124 | ** | ||
125 | ** break_status - bit X set if break has been received. | ||
126 | ** | ||
127 | ** Happy hacking. | ||
128 | ** | ||
129 | */ | ||
130 | |||
131 | /* | ||
132 | ** RIOParam is used to open or configure a port. You pass it a PortP, | ||
133 | ** which will have a tty struct attached to it. You also pass a command, | ||
134 | ** either OPEN or CONFIG. The port's setup is taken from the t_ fields | ||
135 | ** of the tty struct inside the PortP, and the port is either opened | ||
136 | ** or re-configured. You must also tell RIOParam if the device is a modem | ||
137 | ** device or not (i.e. top bit of minor number set or clear - take special | ||
138 | ** care when deciding on this!). | ||
139 | ** RIOParam neither flushes nor waits for drain, and is NOT preemptive. | ||
140 | ** | ||
141 | ** RIOParam assumes it will be called at splrio(), and also assumes | ||
142 | ** that CookMode is set correctly in the port structure. | ||
143 | ** | ||
144 | ** NB. for MPX | ||
145 | ** tty lock must NOT have been previously acquired. | ||
146 | */ | ||
147 | int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag) | ||
148 | { | ||
149 | struct tty_struct *TtyP; | ||
150 | int retval; | ||
151 | struct phb_param __iomem *phb_param_ptr; | ||
152 | struct PKT __iomem *PacketP; | ||
153 | int res; | ||
154 | u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; | ||
155 | u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; | ||
156 | u8 LNext = 0, TxBaud = 0, RxBaud = 0; | ||
157 | int retries = 0xff; | ||
158 | unsigned long flags; | ||
159 | |||
160 | func_enter(); | ||
161 | |||
162 | TtyP = PortP->gs.port.tty; | ||
163 | |||
164 | rio_dprintk(RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n", PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP); | ||
165 | |||
166 | if (!TtyP) { | ||
167 | rio_dprintk(RIO_DEBUG_PARAM, "Can't call rioparam with null tty.\n"); | ||
168 | |||
169 | func_exit(); | ||
170 | |||
171 | return RIO_FAIL; | ||
172 | } | ||
173 | rio_spin_lock_irqsave(&PortP->portSem, flags); | ||
174 | |||
175 | if (cmd == RIOC_OPEN) { | ||
176 | /* | ||
177 | ** If the port is set to store or lock the parameters, and it is | ||
178 | ** paramed with OPEN, we want to restore the saved port termio, but | ||
179 | ** only if StoredTermio has been saved, i.e. NOT 1st open after reboot. | ||
180 | */ | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | ** wait for space | ||
185 | */ | ||
186 | while (!(res = can_add_transmit(&PacketP, PortP)) || (PortP->InUse != NOT_INUSE)) { | ||
187 | if (retries-- <= 0) { | ||
188 | break; | ||
189 | } | ||
190 | if (PortP->InUse != NOT_INUSE) { | ||
191 | rio_dprintk(RIO_DEBUG_PARAM, "Port IN_USE for pre-emptive command\n"); | ||
192 | } | ||
193 | |||
194 | if (!res) { | ||
195 | rio_dprintk(RIO_DEBUG_PARAM, "Port has no space on transmit queue\n"); | ||
196 | } | ||
197 | |||
198 | if (SleepFlag != OK_TO_SLEEP) { | ||
199 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | ||
200 | func_exit(); | ||
201 | |||
202 | return RIO_FAIL; | ||
203 | } | ||
204 | |||
205 | rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit\n"); | ||
206 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | ||
207 | retval = RIODelay(PortP, HUNDRED_MS); | ||
208 | rio_spin_lock_irqsave(&PortP->portSem, flags); | ||
209 | if (retval == RIO_FAIL) { | ||
210 | rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n"); | ||
211 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | ||
212 | func_exit(); | ||
213 | return -EINTR; | ||
214 | } | ||
215 | if (PortP->State & RIO_DELETED) { | ||
216 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | ||
217 | func_exit(); | ||
218 | return 0; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | if (!res) { | ||
223 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | ||
224 | func_exit(); | ||
225 | |||
226 | return RIO_FAIL; | ||
227 | } | ||
228 | |||
229 | rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); | ||
230 | rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP); | ||
231 | |||
232 | phb_param_ptr = (struct phb_param __iomem *) PacketP->data; | ||
233 | |||
234 | |||
235 | switch (TtyP->termios->c_cflag & CSIZE) { | ||
236 | case CS5: | ||
237 | { | ||
238 | rio_dprintk(RIO_DEBUG_PARAM, "5 bit data\n"); | ||
239 | Cor1 |= RIOC_COR1_5BITS; | ||
240 | break; | ||
241 | } | ||
242 | case CS6: | ||
243 | { | ||
244 | rio_dprintk(RIO_DEBUG_PARAM, "6 bit data\n"); | ||
245 | Cor1 |= RIOC_COR1_6BITS; | ||
246 | break; | ||
247 | } | ||
248 | case CS7: | ||
249 | { | ||
250 | rio_dprintk(RIO_DEBUG_PARAM, "7 bit data\n"); | ||
251 | Cor1 |= RIOC_COR1_7BITS; | ||
252 | break; | ||
253 | } | ||
254 | case CS8: | ||
255 | { | ||
256 | rio_dprintk(RIO_DEBUG_PARAM, "8 bit data\n"); | ||
257 | Cor1 |= RIOC_COR1_8BITS; | ||
258 | break; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | if (TtyP->termios->c_cflag & CSTOPB) { | ||
263 | rio_dprintk(RIO_DEBUG_PARAM, "2 stop bits\n"); | ||
264 | Cor1 |= RIOC_COR1_2STOP; | ||
265 | } else { | ||
266 | rio_dprintk(RIO_DEBUG_PARAM, "1 stop bit\n"); | ||
267 | Cor1 |= RIOC_COR1_1STOP; | ||
268 | } | ||
269 | |||
270 | if (TtyP->termios->c_cflag & PARENB) { | ||
271 | rio_dprintk(RIO_DEBUG_PARAM, "Enable parity\n"); | ||
272 | Cor1 |= RIOC_COR1_NORMAL; | ||
273 | } else { | ||
274 | rio_dprintk(RIO_DEBUG_PARAM, "Disable parity\n"); | ||
275 | Cor1 |= RIOC_COR1_NOP; | ||
276 | } | ||
277 | if (TtyP->termios->c_cflag & PARODD) { | ||
278 | rio_dprintk(RIO_DEBUG_PARAM, "Odd parity\n"); | ||
279 | Cor1 |= RIOC_COR1_ODD; | ||
280 | } else { | ||
281 | rio_dprintk(RIO_DEBUG_PARAM, "Even parity\n"); | ||
282 | Cor1 |= RIOC_COR1_EVEN; | ||
283 | } | ||
284 | |||
285 | /* | ||
286 | ** COR 2 | ||
287 | */ | ||
288 | if (TtyP->termios->c_iflag & IXON) { | ||
289 | rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop output control\n"); | ||
290 | Cor2 |= RIOC_COR2_IXON; | ||
291 | } else { | ||
292 | if (PortP->Config & RIO_IXON) { | ||
293 | rio_dprintk(RIO_DEBUG_PARAM, "Force enable start/stop output control\n"); | ||
294 | Cor2 |= RIOC_COR2_IXON; | ||
295 | } else | ||
296 | rio_dprintk(RIO_DEBUG_PARAM, "IXON has been disabled.\n"); | ||
297 | } | ||
298 | |||
299 | if (TtyP->termios->c_iflag & IXANY) { | ||
300 | if (PortP->Config & RIO_IXANY) { | ||
301 | rio_dprintk(RIO_DEBUG_PARAM, "Enable any key to restart output\n"); | ||
302 | Cor2 |= RIOC_COR2_IXANY; | ||
303 | } else | ||
304 | rio_dprintk(RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n"); | ||
305 | } | ||
306 | |||
307 | if (TtyP->termios->c_iflag & IXOFF) { | ||
308 | rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop input control 2\n"); | ||
309 | Cor2 |= RIOC_COR2_IXOFF; | ||
310 | } | ||
311 | |||
312 | if (TtyP->termios->c_cflag & HUPCL) { | ||
313 | rio_dprintk(RIO_DEBUG_PARAM, "Hangup on last close\n"); | ||
314 | Cor2 |= RIOC_COR2_HUPCL; | ||
315 | } | ||
316 | |||
317 | if (C_CRTSCTS(TtyP)) { | ||
318 | rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n"); | ||
319 | Cor2 |= RIOC_COR2_CTSFLOW; | ||
320 | Cor2 |= RIOC_COR2_RTSFLOW; | ||
321 | } else { | ||
322 | rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n"); | ||
323 | Cor2 &= ~RIOC_COR2_CTSFLOW; | ||
324 | Cor2 &= ~RIOC_COR2_RTSFLOW; | ||
325 | } | ||
326 | |||
327 | |||
328 | if (TtyP->termios->c_cflag & CLOCAL) { | ||
329 | rio_dprintk(RIO_DEBUG_PARAM, "Local line\n"); | ||
330 | } else { | ||
331 | rio_dprintk(RIO_DEBUG_PARAM, "Possible Modem line\n"); | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | ** COR 4 (there is no COR 3) | ||
336 | */ | ||
337 | if (TtyP->termios->c_iflag & IGNBRK) { | ||
338 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n"); | ||
339 | Cor4 |= RIOC_COR4_IGNBRK; | ||
340 | } | ||
341 | if (!(TtyP->termios->c_iflag & BRKINT)) { | ||
342 | rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n"); | ||
343 | Cor4 |= RIOC_COR4_NBRKINT; | ||
344 | } else { | ||
345 | rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on break condition\n"); | ||
346 | } | ||
347 | |||
348 | if (TtyP->termios->c_iflag & INLCR) { | ||
349 | rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n"); | ||
350 | Cor4 |= RIOC_COR4_INLCR; | ||
351 | } | ||
352 | |||
353 | if (TtyP->termios->c_iflag & IGNCR) { | ||
354 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n"); | ||
355 | Cor4 |= RIOC_COR4_IGNCR; | ||
356 | } | ||
357 | |||
358 | if (TtyP->termios->c_iflag & ICRNL) { | ||
359 | rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n"); | ||
360 | Cor4 |= RIOC_COR4_ICRNL; | ||
361 | } | ||
362 | if (TtyP->termios->c_iflag & IGNPAR) { | ||
363 | rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n"); | ||
364 | Cor4 |= RIOC_COR4_IGNPAR; | ||
365 | } | ||
366 | if (TtyP->termios->c_iflag & PARMRK) { | ||
367 | rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n"); | ||
368 | Cor4 |= RIOC_COR4_PARMRK; | ||
369 | } | ||
370 | |||
371 | /* | ||
372 | ** Set the RAISEMOD flag to ensure that the modem lines are raised | ||
373 | ** on reception of a config packet. | ||
374 | ** The download code handles the zero baud condition. | ||
375 | */ | ||
376 | Cor4 |= RIOC_COR4_RAISEMOD; | ||
377 | |||
378 | /* | ||
379 | ** COR 5 | ||
380 | */ | ||
381 | |||
382 | Cor5 = RIOC_COR5_CMOE; | ||
383 | |||
384 | /* | ||
385 | ** Set to monitor tbusy/tstop (or not). | ||
386 | */ | ||
387 | |||
388 | if (PortP->MonitorTstate) | ||
389 | Cor5 |= RIOC_COR5_TSTATE_ON; | ||
390 | else | ||
391 | Cor5 |= RIOC_COR5_TSTATE_OFF; | ||
392 | |||
393 | /* | ||
394 | ** Could set LNE here if you wanted LNext processing. SVR4 will use it. | ||
395 | */ | ||
396 | if (TtyP->termios->c_iflag & ISTRIP) { | ||
397 | rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n"); | ||
398 | if (!(PortP->State & RIO_TRIAD_MODE)) { | ||
399 | Cor5 |= RIOC_COR5_ISTRIP; | ||
400 | } | ||
401 | } | ||
402 | |||
403 | if (TtyP->termios->c_oflag & ONLCR) { | ||
404 | rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n"); | ||
405 | if (PortP->CookMode == COOK_MEDIUM) | ||
406 | Cor5 |= RIOC_COR5_ONLCR; | ||
407 | } | ||
408 | if (TtyP->termios->c_oflag & OCRNL) { | ||
409 | rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n"); | ||
410 | if (PortP->CookMode == COOK_MEDIUM) | ||
411 | Cor5 |= RIOC_COR5_OCRNL; | ||
412 | } | ||
413 | if ((TtyP->termios->c_oflag & TABDLY) == TAB3) { | ||
414 | rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n"); | ||
415 | if (PortP->CookMode == COOK_MEDIUM) | ||
416 | Cor5 |= RIOC_COR5_TAB3; | ||
417 | } | ||
418 | |||
419 | /* | ||
420 | ** Flow control bytes. | ||
421 | */ | ||
422 | TxXon = TtyP->termios->c_cc[VSTART]; | ||
423 | TxXoff = TtyP->termios->c_cc[VSTOP]; | ||
424 | RxXon = TtyP->termios->c_cc[VSTART]; | ||
425 | RxXoff = TtyP->termios->c_cc[VSTOP]; | ||
426 | /* | ||
427 | ** LNEXT byte | ||
428 | */ | ||
429 | LNext = 0; | ||
430 | |||
431 | /* | ||
432 | ** Baud rate bytes | ||
433 | */ | ||
434 | rio_dprintk(RIO_DEBUG_PARAM, "Mapping of rx/tx baud %x (%x)\n", TtyP->termios->c_cflag, CBAUD); | ||
435 | |||
436 | switch (TtyP->termios->c_cflag & CBAUD) { | ||
437 | #define e(b) case B ## b : RxBaud = TxBaud = RIO_B ## b ;break | ||
438 | e(50); | ||
439 | e(75); | ||
440 | e(110); | ||
441 | e(134); | ||
442 | e(150); | ||
443 | e(200); | ||
444 | e(300); | ||
445 | e(600); | ||
446 | e(1200); | ||
447 | e(1800); | ||
448 | e(2400); | ||
449 | e(4800); | ||
450 | e(9600); | ||
451 | e(19200); | ||
452 | e(38400); | ||
453 | e(57600); | ||
454 | e(115200); /* e(230400);e(460800); e(921600); */ | ||
455 | } | ||
456 | |||
457 | rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud); | ||
458 | |||
459 | |||
460 | /* | ||
461 | ** Leftovers | ||
462 | */ | ||
463 | if (TtyP->termios->c_cflag & CREAD) | ||
464 | rio_dprintk(RIO_DEBUG_PARAM, "Enable receiver\n"); | ||
465 | #ifdef RCV1EN | ||
466 | if (TtyP->termios->c_cflag & RCV1EN) | ||
467 | rio_dprintk(RIO_DEBUG_PARAM, "RCV1EN (?)\n"); | ||
468 | #endif | ||
469 | #ifdef XMT1EN | ||
470 | if (TtyP->termios->c_cflag & XMT1EN) | ||
471 | rio_dprintk(RIO_DEBUG_PARAM, "XMT1EN (?)\n"); | ||
472 | #endif | ||
473 | if (TtyP->termios->c_lflag & ISIG) | ||
474 | rio_dprintk(RIO_DEBUG_PARAM, "Input character signal generating enabled\n"); | ||
475 | if (TtyP->termios->c_lflag & ICANON) | ||
476 | rio_dprintk(RIO_DEBUG_PARAM, "Canonical input: erase and kill enabled\n"); | ||
477 | if (TtyP->termios->c_lflag & XCASE) | ||
478 | rio_dprintk(RIO_DEBUG_PARAM, "Canonical upper/lower presentation\n"); | ||
479 | if (TtyP->termios->c_lflag & ECHO) | ||
480 | rio_dprintk(RIO_DEBUG_PARAM, "Enable input echo\n"); | ||
481 | if (TtyP->termios->c_lflag & ECHOE) | ||
482 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo erase\n"); | ||
483 | if (TtyP->termios->c_lflag & ECHOK) | ||
484 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo kill\n"); | ||
485 | if (TtyP->termios->c_lflag & ECHONL) | ||
486 | rio_dprintk(RIO_DEBUG_PARAM, "Enable echo newline\n"); | ||
487 | if (TtyP->termios->c_lflag & NOFLSH) | ||
488 | rio_dprintk(RIO_DEBUG_PARAM, "Disable flush after interrupt or quit\n"); | ||
489 | #ifdef TOSTOP | ||
490 | if (TtyP->termios->c_lflag & TOSTOP) | ||
491 | rio_dprintk(RIO_DEBUG_PARAM, "Send SIGTTOU for background output\n"); | ||
492 | #endif | ||
493 | #ifdef XCLUDE | ||
494 | if (TtyP->termios->c_lflag & XCLUDE) | ||
495 | rio_dprintk(RIO_DEBUG_PARAM, "Exclusive use of this line\n"); | ||
496 | #endif | ||
497 | if (TtyP->termios->c_iflag & IUCLC) | ||
498 | rio_dprintk(RIO_DEBUG_PARAM, "Map uppercase to lowercase on input\n"); | ||
499 | if (TtyP->termios->c_oflag & OPOST) | ||
500 | rio_dprintk(RIO_DEBUG_PARAM, "Enable output post-processing\n"); | ||
501 | if (TtyP->termios->c_oflag & OLCUC) | ||
502 | rio_dprintk(RIO_DEBUG_PARAM, "Map lowercase to uppercase on output\n"); | ||
503 | if (TtyP->termios->c_oflag & ONOCR) | ||
504 | rio_dprintk(RIO_DEBUG_PARAM, "No carriage return output at column 0\n"); | ||
505 | if (TtyP->termios->c_oflag & ONLRET) | ||
506 | rio_dprintk(RIO_DEBUG_PARAM, "Newline performs carriage return function\n"); | ||
507 | if (TtyP->termios->c_oflag & OFILL) | ||
508 | rio_dprintk(RIO_DEBUG_PARAM, "Use fill characters for delay\n"); | ||
509 | if (TtyP->termios->c_oflag & OFDEL) | ||
510 | rio_dprintk(RIO_DEBUG_PARAM, "Fill character is DEL\n"); | ||
511 | if (TtyP->termios->c_oflag & NLDLY) | ||
512 | rio_dprintk(RIO_DEBUG_PARAM, "Newline delay set\n"); | ||
513 | if (TtyP->termios->c_oflag & CRDLY) | ||
514 | rio_dprintk(RIO_DEBUG_PARAM, "Carriage return delay set\n"); | ||
515 | if (TtyP->termios->c_oflag & TABDLY) | ||
516 | rio_dprintk(RIO_DEBUG_PARAM, "Tab delay set\n"); | ||
517 | /* | ||
518 | ** These things are kind of useful in a later life! | ||
519 | */ | ||
520 | PortP->Cor2Copy = Cor2; | ||
521 | |||
522 | if (PortP->State & RIO_DELETED) { | ||
523 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | ||
524 | func_exit(); | ||
525 | |||
526 | return RIO_FAIL; | ||
527 | } | ||
528 | |||
529 | /* | ||
530 | ** Actually write the info into the packet to be sent | ||
531 | */ | ||
532 | writeb(cmd, &phb_param_ptr->Cmd); | ||
533 | writeb(Cor1, &phb_param_ptr->Cor1); | ||
534 | writeb(Cor2, &phb_param_ptr->Cor2); | ||
535 | writeb(Cor4, &phb_param_ptr->Cor4); | ||
536 | writeb(Cor5, &phb_param_ptr->Cor5); | ||
537 | writeb(TxXon, &phb_param_ptr->TxXon); | ||
538 | writeb(RxXon, &phb_param_ptr->RxXon); | ||
539 | writeb(TxXoff, &phb_param_ptr->TxXoff); | ||
540 | writeb(RxXoff, &phb_param_ptr->RxXoff); | ||
541 | writeb(LNext, &phb_param_ptr->LNext); | ||
542 | writeb(TxBaud, &phb_param_ptr->TxBaud); | ||
543 | writeb(RxBaud, &phb_param_ptr->RxBaud); | ||
544 | |||
545 | /* | ||
546 | ** Set the length/command field | ||
547 | */ | ||
548 | writeb(12 | PKT_CMD_BIT, &PacketP->len); | ||
549 | |||
550 | /* | ||
551 | ** The packet is formed - now, whack it off | ||
552 | ** to its final destination: | ||
553 | */ | ||
554 | add_transmit(PortP); | ||
555 | /* | ||
556 | ** Count characters transmitted for port statistics reporting | ||
557 | */ | ||
558 | if (PortP->statsGather) | ||
559 | PortP->txchars += 12; | ||
560 | |||
561 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); | ||
562 | |||
563 | rio_dprintk(RIO_DEBUG_PARAM, "add_transmit returned.\n"); | ||
564 | /* | ||
565 | ** job done. | ||
566 | */ | ||
567 | func_exit(); | ||
568 | |||
569 | return 0; | ||
570 | } | ||
571 | |||
572 | |||
573 | /* | ||
574 | ** We can add another packet to a transmit queue if the packet pointer pointed | ||
575 | ** to by the TxAdd pointer has PKT_IN_USE clear in its address. | ||
576 | */ | ||
577 | int can_add_transmit(struct PKT __iomem **PktP, struct Port *PortP) | ||
578 | { | ||
579 | struct PKT __iomem *tp; | ||
580 | |||
581 | *PktP = tp = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd)); | ||
582 | |||
583 | return !((unsigned long) tp & PKT_IN_USE); | ||
584 | } | ||
585 | |||
586 | /* | ||
587 | ** To add a packet to the queue, you set the PKT_IN_USE bit in the address, | ||
588 | ** and then move the TxAdd pointer along one position to point to the next | ||
589 | ** packet pointer. You must wrap the pointer from the end back to the start. | ||
590 | */ | ||
591 | void add_transmit(struct Port *PortP) | ||
592 | { | ||
593 | if (readw(PortP->TxAdd) & PKT_IN_USE) { | ||
594 | rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!"); | ||
595 | } | ||
596 | writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd); | ||
597 | PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1; | ||
598 | writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add); | ||
599 | } | ||
600 | |||
601 | /**************************************** | ||
602 | * Put a packet onto the end of the | ||
603 | * free list | ||
604 | ****************************************/ | ||
605 | void put_free_end(struct Host *HostP, struct PKT __iomem *PktP) | ||
606 | { | ||
607 | struct rio_free_list __iomem *tmp_pointer; | ||
608 | unsigned short old_end, new_end; | ||
609 | unsigned long flags; | ||
610 | |||
611 | rio_spin_lock_irqsave(&HostP->HostLock, flags); | ||
612 | |||
613 | /************************************************* | ||
614 | * Put a packet back onto the back of the free list | ||
615 | * | ||
616 | ************************************************/ | ||
617 | |||
618 | rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP); | ||
619 | |||
620 | if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) { | ||
621 | new_end = RIO_OFF(HostP->Caddr, PktP); | ||
622 | tmp_pointer = (struct rio_free_list __iomem *) RIO_PTR(HostP->Caddr, old_end); | ||
623 | writew(new_end, &tmp_pointer->next); | ||
624 | writew(old_end, &((struct rio_free_list __iomem *) PktP)->prev); | ||
625 | writew(TPNULL, &((struct rio_free_list __iomem *) PktP)->next); | ||
626 | writew(new_end, &HostP->ParmMapP->free_list_end); | ||
627 | } else { /* First packet on the free list this should never happen! */ | ||
628 | rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n"); | ||
629 | writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end); | ||
630 | tmp_pointer = (struct rio_free_list __iomem *) PktP; | ||
631 | writew(TPNULL, &tmp_pointer->prev); | ||
632 | writew(TPNULL, &tmp_pointer->next); | ||
633 | } | ||
634 | rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock); | ||
635 | rio_spin_unlock_irqrestore(&HostP->HostLock, flags); | ||
636 | } | ||
637 | |||
638 | /* | ||
639 | ** can_remove_receive(PktP,P) returns non-zero if PKT_IN_USE is set | ||
640 | ** for the next packet on the queue. It will also set PktP to point to the | ||
641 | ** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear, | ||
642 | ** then can_remove_receive() returns 0. | ||
643 | */ | ||
644 | int can_remove_receive(struct PKT __iomem **PktP, struct Port *PortP) | ||
645 | { | ||
646 | if (readw(PortP->RxRemove) & PKT_IN_USE) { | ||
647 | *PktP = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE); | ||
648 | return 1; | ||
649 | } | ||
650 | return 0; | ||
651 | } | ||
652 | |||
653 | /* | ||
654 | ** To remove a packet from the receive queue you clear its PKT_IN_USE bit, | ||
655 | ** and then bump the pointers. Once the pointers get to the end, they must | ||
656 | ** be wrapped back to the start. | ||
657 | */ | ||
658 | void remove_receive(struct Port *PortP) | ||
659 | { | ||
660 | writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove); | ||
661 | PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1; | ||
662 | writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove); | ||
663 | } | ||