aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rio/riotty.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-01-11 15:17:49 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-11 21:42:14 -0500
commit8d8706e2f86d28814c1b40a116ffdeca35e4c949 (patch)
tree146567d7a807feb37a5368fbb4a6ee76d9d7bc7e /drivers/char/rio/riotty.c
parenta9415644583ef344e02f84faf5fe24bfadb2af8e (diff)
[PATCH] lindent rio drivers
Run all rio files through indent -kr -i8 -bri0 -l255, as requested by Alan. rioboot.c and rioinit.c were skipped due to worrisome lindent warnings. Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/rio/riotty.c')
-rw-r--r--drivers/char/rio/riotty.c1224
1 files changed, 590 insertions, 634 deletions
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 78a321afdf4f..5894a25b0113 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -90,21 +90,19 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
90#include "sam.h" 90#include "sam.h"
91 91
92#if 0 92#if 0
93static void ttyseth_pv(struct Port *, struct ttystatics *, 93static void ttyseth_pv(struct Port *, struct ttystatics *, struct termios *sg, int);
94 struct termios *sg, int);
95#endif 94#endif
96 95
97static void RIOClearUp(struct Port *PortP); 96static void RIOClearUp(struct Port *PortP);
98int RIOShortCommand(struct rio_info *p, struct Port *PortP, 97int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
99 int command, int len, int arg);
100 98
101#if 0 99#if 0
102static int RIOCookMode(struct ttystatics *); 100static int RIOCookMode(struct ttystatics *);
103#endif 101#endif
104 102
105extern int conv_vb[]; /* now defined in ttymgr.c */ 103extern int conv_vb[]; /* now defined in ttymgr.c */
106extern int conv_bv[]; /* now defined in ttymgr.c */ 104extern int conv_bv[]; /* now defined in ttymgr.c */
107 105
108/* 106/*
109** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support 107** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support
110** 108**
@@ -117,27 +115,25 @@ extern int conv_bv[]; /* now defined in ttymgr.c */
117#endif 115#endif
118 116
119#ifdef NEED_THIS2 117#ifdef NEED_THIS2
120static struct old_sgttyb 118static struct old_sgttyb default_sg = {
121default_sg = 119 B19200, B19200, /* input and output speed */
122{ 120 'H' - '@', /* erase char */
123 B19200, B19200, /* input and output speed */ 121 -1, /* 2nd erase char */
124 'H' - '@', /* erase char */ 122 'U' - '@', /* kill char */
125 -1, /* 2nd erase char */ 123 ECHO | CRMOD, /* mode */
126 'U' - '@', /* kill char */ 124 'C' - '@', /* interrupt character */
127 ECHO | CRMOD, /* mode */ 125 '\\' - '@', /* quit char */
128 'C' - '@', /* interrupt character */ 126 'Q' - '@', /* start char */
129 '\\' - '@', /* quit char */ 127 'S' - '@', /* stop char */
130 'Q' - '@', /* start char */ 128 'D' - '@', /* EOF */
131 'S' - '@', /* stop char */ 129 -1, /* brk */
132 'D' - '@', /* EOF */ 130 (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */
133 -1, /* brk */ 131 'Z' - '@', /* process stop */
134 (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */ 132 'Y' - '@', /* delayed stop */
135 'Z' - '@', /* process stop */ 133 'R' - '@', /* reprint line */
136 'Y' - '@', /* delayed stop */ 134 'O' - '@', /* flush output */
137 'R' - '@', /* reprint line */ 135 'W' - '@', /* word erase */
138 'O' - '@', /* flush output */ 136 'V' - '@' /* literal next char */
139 'W' - '@', /* word erase */
140 'V' - '@' /* literal next char */
141}; 137};
142#endif 138#endif
143 139
@@ -145,62 +141,59 @@ default_sg =
145extern struct rio_info *p; 141extern struct rio_info *p;
146 142
147 143
148int 144int riotopen(struct tty_struct *tty, struct file *filp)
149riotopen(struct tty_struct * tty, struct file * filp)
150{ 145{
151 register uint SysPort; 146 register uint SysPort;
152 int Modem; 147 int Modem;
153 int repeat_this = 250; 148 int repeat_this = 250;
154 struct Port *PortP; /* pointer to the port structure */ 149 struct Port *PortP; /* pointer to the port structure */
155 unsigned long flags; 150 unsigned long flags;
156 int retval = 0; 151 int retval = 0;
157 152
158 func_enter (); 153 func_enter();
159 154
160 /* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close 155 /* Make sure driver_data is NULL in case the rio isn't booted jet. Else gs_close
161 is going to oops. 156 is going to oops.
162 */ 157 */
163 tty->driver_data = NULL; 158 tty->driver_data = NULL;
164 159
165 SysPort = rio_minor(tty); 160 SysPort = rio_minor(tty);
166 Modem = rio_ismodem(tty); 161 Modem = rio_ismodem(tty);
167 162
168 if ( p->RIOFailed ) { 163 if (p->RIOFailed) {
169 rio_dprintk (RIO_DEBUG_TTY, "System initialisation failed\n"); 164 rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
170 pseterr(ENXIO); 165 pseterr(ENXIO);
171 func_exit (); 166 func_exit();
172 return -ENXIO; 167 return -ENXIO;
173 } 168 }
174 169
175 rio_dprintk (RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", 170 rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", SysPort, Modem ? "Modem" : "tty", p->RIOPortp[SysPort]->Mapped);
176 SysPort, Modem ? "Modem" : "tty",
177 p->RIOPortp[SysPort]->Mapped);
178 171
179 /* 172 /*
180 ** Validate that we have received a legitimate request. 173 ** Validate that we have received a legitimate request.
181 ** Currently, just check that we are opening a port on 174 ** Currently, just check that we are opening a port on
182 ** a host card that actually exists, and that the port 175 ** a host card that actually exists, and that the port
183 ** has been mapped onto a host. 176 ** has been mapped onto a host.
184 */ 177 */
185 if (SysPort >= RIO_PORTS) { /* out of range ? */ 178 if (SysPort >= RIO_PORTS) { /* out of range ? */
186 rio_dprintk (RIO_DEBUG_TTY, "Illegal port number %d\n",SysPort); 179 rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
187 pseterr(ENXIO); 180 pseterr(ENXIO);
188 func_exit(); 181 func_exit();
189 return -ENXIO; 182 return -ENXIO;
190 } 183 }
191 184
192 /* 185 /*
193 ** Grab pointer to the port stucture 186 ** Grab pointer to the port stucture
194 */ 187 */
195 PortP = p->RIOPortp[SysPort]; /* Get control struc */ 188 PortP = p->RIOPortp[SysPort]; /* Get control struc */
196 rio_dprintk (RIO_DEBUG_TTY, "PortP: %p\n", PortP); 189 rio_dprintk(RIO_DEBUG_TTY, "PortP: %p\n", PortP);
197 if ( !PortP->Mapped ) { /* we aren't mapped yet! */ 190 if (!PortP->Mapped) { /* we aren't mapped yet! */
198 /* 191 /*
199 ** The system doesn't know which RTA this port 192 ** The system doesn't know which RTA this port
200 ** corresponds to. 193 ** corresponds to.
201 */ 194 */
202 rio_dprintk (RIO_DEBUG_TTY, "port not mapped into system\n"); 195 rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
203 func_exit (); 196 func_exit();
204 pseterr(ENXIO); 197 pseterr(ENXIO);
205 return -ENXIO; 198 return -ENXIO;
206 } 199 }
@@ -210,132 +203,131 @@ riotopen(struct tty_struct * tty, struct file * filp)
210 PortP->gs.tty = tty; 203 PortP->gs.tty = tty;
211 PortP->gs.count++; 204 PortP->gs.count++;
212 205
213 rio_dprintk (RIO_DEBUG_TTY, "%d bytes in tx buffer\n", 206 rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt);
214 PortP->gs.xmit_cnt);
215 207
216 retval = gs_init_port (&PortP->gs); 208 retval = gs_init_port(&PortP->gs);
217 if (retval) { 209 if (retval) {
218 PortP->gs.count--; 210 PortP->gs.count--;
219 return -ENXIO; 211 return -ENXIO;
220 } 212 }
221 /* 213 /*
222 ** If the host hasn't been booted yet, then 214 ** If the host hasn't been booted yet, then
223 ** fail 215 ** fail
224 */ 216 */
225 if ( (PortP->HostP->Flags & RUN_STATE) != RC_RUNNING ) { 217 if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
226 rio_dprintk (RIO_DEBUG_TTY, "Host not running\n"); 218 rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
227 pseterr(ENXIO); 219 pseterr(ENXIO);
228 func_exit (); 220 func_exit();
229 return -ENXIO; 221 return -ENXIO;
230 } 222 }
231 223
232 /* 224 /*
233 ** If the RTA has not booted yet and the user has choosen to block 225 ** If the RTA has not booted yet and the user has choosen to block
234 ** until the RTA is present then we must spin here waiting for 226 ** until the RTA is present then we must spin here waiting for
235 ** the RTA to boot. 227 ** the RTA to boot.
236 */ 228 */
237#if 0 229#if 0
238 if (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) { 230 if (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) {
239 if (PortP->WaitUntilBooted) { 231 if (PortP->WaitUntilBooted) {
240 rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot\n"); 232 rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot\n");
241 do { 233 do {
242 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 234 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
243 rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n"); 235 rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");
244 func_exit (); 236 func_exit();
245 return -EINTR; 237 return -EINTR;
246 } 238 }
247 if (repeat_this -- <= 0) { 239 if (repeat_this-- <= 0) {
248 rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); 240 rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n");
249 RIOPreemptiveCmd(p, PortP, FCLOSE ); 241 RIOPreemptiveCmd(p, PortP, FCLOSE);
250 pseterr(EINTR); 242 pseterr(EINTR);
251 func_exit (); 243 func_exit();
252 return -EIO; 244 return -EIO;
253 } 245 }
254 } while(!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)); 246 } while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED));
255 rio_dprintk (RIO_DEBUG_TTY, "RTA has been booted\n"); 247 rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n");
256 } else { 248 } else {
257 rio_dprintk (RIO_DEBUG_TTY, "RTA never booted\n"); 249 rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n");
258 pseterr(ENXIO); 250 pseterr(ENXIO);
259 func_exit (); 251 func_exit();
260 return 0; 252 return 0;
261 } 253 }
262 } 254 }
263#else 255#else
264 /* I find the above code a bit hairy. I find the below code 256 /* I find the above code a bit hairy. I find the below code
265 easier to read and shorter. Now, if it works too that would 257 easier to read and shorter. Now, if it works too that would
266 be great... -- REW 258 be great... -- REW
267 */ 259 */
268 rio_dprintk (RIO_DEBUG_TTY, "Checking if RTA has booted... \n"); 260 rio_dprintk(RIO_DEBUG_TTY, "Checking if RTA has booted... \n");
269 while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) { 261 while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) {
270 if (!PortP->WaitUntilBooted) { 262 if (!PortP->WaitUntilBooted) {
271 rio_dprintk (RIO_DEBUG_TTY, "RTA never booted\n"); 263 rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n");
272 func_exit (); 264 func_exit();
273 return -ENXIO; 265 return -ENXIO;
274 } 266 }
275 267
276 /* Under Linux you'd normally use a wait instead of this 268 /* Under Linux you'd normally use a wait instead of this
277 busy-waiting. I'll stick with the old implementation for 269 busy-waiting. I'll stick with the old implementation for
278 now. --REW 270 now. --REW
279 */ 271 */
280 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 272 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
281 rio_dprintk (RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n"); 273 rio_dprintk(RIO_DEBUG_TTY, "RTA_wait_for_boot: EINTR in delay \n");
282 func_exit (); 274 func_exit();
283 return -EINTR; 275 return -EINTR;
284 } 276 }
285 if (repeat_this -- <= 0) { 277 if (repeat_this-- <= 0) {
286 rio_dprintk (RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n"); 278 rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n");
287 func_exit (); 279 func_exit();
288 return -EIO; 280 return -EIO;
289 } 281 }
290 } 282 }
291 rio_dprintk (RIO_DEBUG_TTY, "RTA has been booted\n"); 283 rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n");
292#endif 284#endif
293#if 0 285#if 0
294 tp = PortP->TtyP; /* get tty struct */ 286 tp = PortP->TtyP; /* get tty struct */
295#endif 287#endif
296 rio_spin_lock_irqsave(&PortP->portSem, flags); 288 rio_spin_lock_irqsave(&PortP->portSem, flags);
297 if ( p->RIOHalted ) { 289 if (p->RIOHalted) {
298 goto bombout; 290 goto bombout;
299 } 291 }
300#if 0 292#if 0
301 retval = gs_init_port(&PortP->gs); 293 retval = gs_init_port(&PortP->gs);
302 if (retval){ 294 if (retval) {
303 func_exit (); 295 func_exit();
304 return retval; 296 return retval;
305 } 297 }
306#endif 298#endif
307 299
308 /* 300 /*
309 ** If the port is in the final throws of being closed, 301 ** If the port is in the final throws of being closed,
310 ** we should wait here (politely), waiting 302 ** we should wait here (politely), waiting
311 ** for it to finish, so that it doesn't close us! 303 ** for it to finish, so that it doesn't close us!
312 */ 304 */
313 while ( (PortP->State & RIO_CLOSING) && !p->RIOHalted ) { 305 while ((PortP->State & RIO_CLOSING) && !p->RIOHalted) {
314 rio_dprintk (RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n"); 306 rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n");
315 if (repeat_this -- <= 0) { 307 if (repeat_this-- <= 0) {
316 rio_dprintk (RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); 308 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
317 RIOPreemptiveCmd(p, PortP, FCLOSE ); 309 RIOPreemptiveCmd(p, PortP, FCLOSE);
318 retval = -EINTR; 310 retval = -EINTR;
319 goto bombout; 311 goto bombout;
320 } 312 }
321 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 313 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
322 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 314 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
323 rio_spin_lock_irqsave(&PortP->portSem, flags); 315 rio_spin_lock_irqsave(&PortP->portSem, flags);
324 retval = -EINTR; 316 retval = -EINTR;
325 goto bombout; 317 goto bombout;
326 } 318 }
327 rio_spin_lock_irqsave(&PortP->portSem, flags); 319 rio_spin_lock_irqsave(&PortP->portSem, flags);
328 } 320 }
329 321
330 if ( !PortP->Mapped ) { 322 if (!PortP->Mapped) {
331 rio_dprintk (RIO_DEBUG_TTY, "Port unmapped while closing!\n"); 323 rio_dprintk(RIO_DEBUG_TTY, "Port unmapped while closing!\n");
332 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 324 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
333 retval = -ENXIO; 325 retval = -ENXIO;
334 func_exit (); 326 func_exit();
335 return retval; 327 return retval;
336 } 328 }
337 329
338 if ( p->RIOHalted ) { 330 if (p->RIOHalted) {
339 goto bombout; 331 goto bombout;
340 } 332 }
341 333
@@ -346,16 +338,16 @@ riotopen(struct tty_struct * tty, struct file * filp)
346*/ 338*/
347 /* Uh? Suppose I turn these on and then another process opens 339 /* Uh? Suppose I turn these on and then another process opens
348 the port again? The flags get cleared! Not good. -- REW */ 340 the port again? The flags get cleared! Not good. -- REW */
349 if ( !(PortP->State & (RIO_LOPEN | RIO_MOPEN)) ) { 341 if (!(PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
350 PortP->Config &= ~(RIO_CTSFLOW|RIO_RTSFLOW); 342 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
351 } 343 }
352 344
353 if (!(PortP->firstOpen)) { /* First time ? */ 345 if (!(PortP->firstOpen)) { /* First time ? */
354 rio_dprintk (RIO_DEBUG_TTY, "First open for this port\n"); 346 rio_dprintk(RIO_DEBUG_TTY, "First open for this port\n");
355 347
356 348
357 PortP->firstOpen++; 349 PortP->firstOpen++;
358 PortP->CookMode = 0; /* XXX RIOCookMode(tp); */ 350 PortP->CookMode = 0; /* XXX RIOCookMode(tp); */
359 PortP->InUse = NOT_INUSE; 351 PortP->InUse = NOT_INUSE;
360 352
361 /* Tentative fix for bug PR27. Didn't work. */ 353 /* Tentative fix for bug PR27. Didn't work. */
@@ -363,26 +355,26 @@ riotopen(struct tty_struct * tty, struct file * filp)
363 355
364 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 356 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
365#ifdef NEED_THIS 357#ifdef NEED_THIS
366 ttyseth(PortP, tp, (struct old_sgttyb *)&default_sg); 358 ttyseth(PortP, tp, (struct old_sgttyb *) &default_sg);
367#endif 359#endif
368 360
369 /* Someone explain to me why this delay/config is 361 /* Someone explain to me why this delay/config is
370 here. If I read the docs correctly the "open" 362 here. If I read the docs correctly the "open"
371 command piggybacks the parameters immediately. 363 command piggybacks the parameters immediately.
372 -- REW */ 364 -- REW */
373 RIOParam(PortP,OPEN,Modem,OK_TO_SLEEP); /* Open the port */ 365 RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP); /* Open the port */
374#if 0 366#if 0
375 /* This delay of 1 second was annoying. I removed it. -- REW */ 367 /* This delay of 1 second was annoying. I removed it. -- REW */
376 RIODelay(PortP, HUNDRED_MS*10); 368 RIODelay(PortP, HUNDRED_MS * 10);
377 RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); /* Config the port */ 369 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); /* Config the port */
378#endif 370#endif
379 rio_spin_lock_irqsave(&PortP->portSem, flags); 371 rio_spin_lock_irqsave(&PortP->portSem, flags);
380 372
381 /* 373 /*
382 ** wait for the port to be not closed. 374 ** wait for the port to be not closed.
383 */ 375 */
384 while ( !(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted ) { 376 while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) {
385 rio_dprintk (RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n",PortP->PortState); 377 rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState);
386/* 378/*
387** 15.10.1998 ARG - ESIL 0759 379** 15.10.1998 ARG - ESIL 0759
388** (Part) fix for port being trashed when opened whilst RTA "disconnected" 380** (Part) fix for port being trashed when opened whilst RTA "disconnected"
@@ -399,115 +391,109 @@ riotopen(struct tty_struct * tty, struct file * filp)
399*/ 391*/
400 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 392 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
401 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 393 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
402 rio_dprintk (RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); 394 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n");
403 RIOPreemptiveCmd(p, PortP, FCLOSE ); 395 RIOPreemptiveCmd(p, PortP, FCLOSE);
404 func_exit (); 396 func_exit();
405 return -EINTR; 397 return -EINTR;
406 } 398 }
407 rio_spin_lock_irqsave(&PortP->portSem, flags); 399 rio_spin_lock_irqsave(&PortP->portSem, flags);
408 } 400 }
409 401
410 if ( p->RIOHalted ) { 402 if (p->RIOHalted) {
411 retval = -EIO; 403 retval = -EIO;
412bombout: 404 bombout:
413 /* RIOClearUp( PortP ); */ 405 /* RIOClearUp( PortP ); */
414 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 406 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
415 return retval; 407 return retval;
416 } 408 }
417 rio_dprintk (RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); 409 rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n");
418 } 410 }
419 411#ifdef MODEM_SUPPORT
420#ifdef MODEM_SUPPORT
421 if (Modem) { 412 if (Modem) {
422 rio_dprintk (RIO_DEBUG_TTY, "Modem - test for carrier\n"); 413 rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n");
423 /* 414 /*
424 ** ACTION 415 ** ACTION
425 ** insert test for carrier here. -- ??? 416 ** insert test for carrier here. -- ???
426 ** I already see that test here. What's the deal? -- REW 417 ** I already see that test here. What's the deal? -- REW
427 */ 418 */
428 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) 419 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
429 { 420 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
430 rio_dprintk (RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
431 /* 421 /*
432 tp->tm.c_state |= CARR_ON; 422 tp->tm.c_state |= CARR_ON;
433 wakeup((caddr_t) &tp->tm.c_canq); 423 wakeup((caddr_t) &tp->tm.c_canq);
434 */ 424 */
435 PortP->State |= RIO_CARR_ON; 425 PortP->State |= RIO_CARR_ON;
436 wake_up_interruptible (&PortP->gs.open_wait); 426 wake_up_interruptible(&PortP->gs.open_wait);
437 } 427 } else { /* no carrier - wait for DCD */
438 else /* no carrier - wait for DCD */ 428
439 { 429 /*
440 /* 430 while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
441 while (!(PortP->gs.tty->termios->c_state & CARR_ON) && 431 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
442 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) 432 */
443 */ 433 while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
444 while (!(PortP->State & RIO_CARR_ON) && 434
445 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) { 435 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
446
447 rio_dprintk (RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n",SysPort);
448 /* 436 /*
449 PortP->gs.tty->termios->c_state |= WOPEN; 437 PortP->gs.tty->termios->c_state |= WOPEN;
450 */ 438 */
451 PortP->State |= RIO_WOPEN; 439 PortP->State |= RIO_WOPEN;
452 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 440 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
453 if (RIODelay (PortP, HUNDRED_MS) == RIO_FAIL) 441 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL)
454#if 0 442#if 0
455 if ( sleep((caddr_t)&tp->tm.c_canqo, TTIPRI|PCATCH)) 443 if (sleep((caddr_t) & tp->tm.c_canqo, TTIPRI | PCATCH))
456#endif 444#endif
457 { 445 {
458 /* 446 /*
459 ** ACTION: verify that this is a good thing 447 ** ACTION: verify that this is a good thing
460 ** to do here. -- ??? 448 ** to do here. -- ???
461 ** I think it's OK. -- REW 449 ** I think it's OK. -- REW
462 */ 450 */
463 rio_dprintk (RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", 451 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
464 SysPort); 452 RIOPreemptiveCmd(p, PortP, FCLOSE);
465 RIOPreemptiveCmd( p, PortP, FCLOSE ); 453 /*
466 /* 454 tp->tm.c_state &= ~WOPEN;
467 tp->tm.c_state &= ~WOPEN; 455 */
468 */ 456 PortP->State &= ~RIO_WOPEN;
469 PortP->State &= ~RIO_WOPEN; 457 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
470 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 458 func_exit();
471 func_exit (); 459 return -EINTR;
472 return -EINTR; 460 }
473 }
474 } 461 }
475 PortP->State &= ~RIO_WOPEN; 462 PortP->State &= ~RIO_WOPEN;
476 } 463 }
477 if ( p->RIOHalted ) 464 if (p->RIOHalted)
478 goto bombout; 465 goto bombout;
479 rio_dprintk (RIO_DEBUG_TTY, "Setting RIO_MOPEN\n"); 466 rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
480 PortP->State |= RIO_MOPEN; 467 PortP->State |= RIO_MOPEN;
481 } 468 } else
482 else
483#endif 469#endif
484 { 470 {
485 /* 471 /*
486 ** ACTION 472 ** ACTION
487 ** Direct line open - force carrier (will probably mean 473 ** Direct line open - force carrier (will probably mean
488 ** that sleeping Modem line fubar) 474 ** that sleeping Modem line fubar)
489 */ 475 */
490 PortP->State |= RIO_LOPEN; 476 PortP->State |= RIO_LOPEN;
491 } 477 }
492 478
493 if ( p->RIOHalted ) { 479 if (p->RIOHalted) {
494 goto bombout; 480 goto bombout;
495 } 481 }
496 482
497 rio_dprintk (RIO_DEBUG_TTY, "high level open done\n"); 483 rio_dprintk(RIO_DEBUG_TTY, "high level open done\n");
498 484
499#ifdef STATS 485#ifdef STATS
500 PortP->Stat.OpenCnt++; 486 PortP->Stat.OpenCnt++;
501#endif 487#endif
502 /* 488 /*
503 ** Count opens for port statistics reporting 489 ** Count opens for port statistics reporting
504 */ 490 */
505 if (PortP->statsGather) 491 if (PortP->statsGather)
506 PortP->opens++; 492 PortP->opens++;
507 493
508 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 494 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
509 rio_dprintk (RIO_DEBUG_TTY, "Returning from open\n"); 495 rio_dprintk(RIO_DEBUG_TTY, "Returning from open\n");
510 func_exit (); 496 func_exit();
511 return 0; 497 return 0;
512} 498}
513 499
@@ -516,36 +502,35 @@ bombout:
516** The operating system thinks that this is last close for the device. 502** The operating system thinks that this is last close for the device.
517** As there are two interfaces to the port (Modem and tty), we need to 503** As there are two interfaces to the port (Modem and tty), we need to
518** check that both are closed before we close the device. 504** check that both are closed before we close the device.
519*/ 505*/
520int 506int riotclose(void *ptr)
521riotclose(void *ptr)
522{ 507{
523#if 0 508#if 0
524 register uint SysPort = dev; 509 register uint SysPort = dev;
525 struct ttystatics *tp; /* pointer to our ttystruct */ 510 struct ttystatics *tp; /* pointer to our ttystruct */
526#endif 511#endif
527 struct Port *PortP = ptr; /* pointer to the port structure */ 512 struct Port *PortP = ptr; /* pointer to the port structure */
528 int deleted = 0; 513 int deleted = 0;
529 int try = -1; /* Disable the timeouts by setting them to -1 */ 514 int try = -1; /* Disable the timeouts by setting them to -1 */
530 int repeat_this = -1; /* Congrats to those having 15 years of 515 int repeat_this = -1; /* Congrats to those having 15 years of
531 uptime! (You get to break the driver.) */ 516 uptime! (You get to break the driver.) */
532 unsigned long end_time; 517 unsigned long end_time;
533 struct tty_struct * tty; 518 struct tty_struct *tty;
534 unsigned long flags; 519 unsigned long flags;
535 int Modem; 520 int Modem;
536 int rv = 0; 521 int rv = 0;
537 522
538 rio_dprintk (RIO_DEBUG_TTY, "port close SysPort %d\n",PortP->PortNum); 523 rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
539 524
540 /* PortP = p->RIOPortp[SysPort]; */ 525 /* PortP = p->RIOPortp[SysPort]; */
541 rio_dprintk (RIO_DEBUG_TTY, "Port is at address 0x%x\n",(int)PortP); 526 rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP);
542 /* tp = PortP->TtyP;*/ /* Get tty */ 527 /* tp = PortP->TtyP; *//* Get tty */
543 tty = PortP->gs.tty; 528 tty = PortP->gs.tty;
544 rio_dprintk (RIO_DEBUG_TTY, "TTY is at address 0x%x\n",(int)tty); 529 rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty);
545 530
546 if (PortP->gs.closing_wait) 531 if (PortP->gs.closing_wait)
547 end_time = jiffies + PortP->gs.closing_wait; 532 end_time = jiffies + PortP->gs.closing_wait;
548 else 533 else
549 end_time = jiffies + MAX_SCHEDULE_TIMEOUT; 534 end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
550 535
551 Modem = rio_ismodem(tty); 536 Modem = rio_ismodem(tty);
@@ -553,48 +538,48 @@ riotclose(void *ptr)
553 /* What F.CKING cache? Even then, a higly idle multiprocessor, 538 /* What F.CKING cache? Even then, a higly idle multiprocessor,
554 system with large caches this won't work . Better find out when 539 system with large caches this won't work . Better find out when
555 this doesn't work asap, and fix the cause. -- REW */ 540 this doesn't work asap, and fix the cause. -- REW */
556 541
557 RIODelay(PortP, HUNDRED_MS*10); /* To flush the cache */ 542 RIODelay(PortP, HUNDRED_MS * 10); /* To flush the cache */
558#endif 543#endif
559 rio_spin_lock_irqsave(&PortP->portSem, flags); 544 rio_spin_lock_irqsave(&PortP->portSem, flags);
560 545
561 /* 546 /*
562 ** Setting this flag will make any process trying to open 547 ** Setting this flag will make any process trying to open
563 ** this port block until we are complete closing it. 548 ** this port block until we are complete closing it.
564 */ 549 */
565 PortP->State |= RIO_CLOSING; 550 PortP->State |= RIO_CLOSING;
566 551
567 if ( (PortP->State & RIO_DELETED) ) { 552 if ((PortP->State & RIO_DELETED)) {
568 rio_dprintk (RIO_DEBUG_TTY, "Close on deleted RTA\n"); 553 rio_dprintk(RIO_DEBUG_TTY, "Close on deleted RTA\n");
569 deleted = 1; 554 deleted = 1;
570 } 555 }
571 556
572 if ( p->RIOHalted ) { 557 if (p->RIOHalted) {
573 RIOClearUp( PortP ); 558 RIOClearUp(PortP);
574 rv = -EIO; 559 rv = -EIO;
575 goto close_end; 560 goto close_end;
576 } 561 }
577 562
578 rio_dprintk (RIO_DEBUG_TTY, "Clear bits\n"); 563 rio_dprintk(RIO_DEBUG_TTY, "Clear bits\n");
579 /* 564 /*
580 ** clear the open bits for this device 565 ** clear the open bits for this device
581 */ 566 */
582 PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN); 567 PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN);
583 PortP->State &= ~RIO_CARR_ON; 568 PortP->State &= ~RIO_CARR_ON;
584 PortP->ModemState &= ~MSVR1_CD; 569 PortP->ModemState &= ~MSVR1_CD;
585 /* 570 /*
586 ** If the device was open as both a Modem and a tty line 571 ** If the device was open as both a Modem and a tty line
587 ** then we need to wimp out here, as the port has not really 572 ** then we need to wimp out here, as the port has not really
588 ** been finally closed (gee, whizz!) The test here uses the 573 ** been finally closed (gee, whizz!) The test here uses the
589 ** bit for the OTHER mode of operation, to see if THAT is 574 ** bit for the OTHER mode of operation, to see if THAT is
590 ** still active! 575 ** still active!
591 */ 576 */
592 if ( (PortP->State & (RIO_LOPEN|RIO_MOPEN)) ) { 577 if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
593 /* 578 /*
594 ** The port is still open for the other task - 579 ** The port is still open for the other task -
595 ** return, pretending that we are still active. 580 ** return, pretending that we are still active.
596 */ 581 */
597 rio_dprintk (RIO_DEBUG_TTY, "Channel %d still open !\n",PortP->PortNum); 582 rio_dprintk(RIO_DEBUG_TTY, "Channel %d still open !\n", PortP->PortNum);
598 PortP->State &= ~RIO_CLOSING; 583 PortP->State &= ~RIO_CLOSING;
599 if (PortP->firstOpen) 584 if (PortP->firstOpen)
600 PortP->firstOpen--; 585 PortP->firstOpen--;
@@ -602,48 +587,47 @@ riotclose(void *ptr)
602 return -EIO; 587 return -EIO;
603 } 588 }
604 589
605 rio_dprintk (RIO_DEBUG_TTY, "Closing down - everything must go!\n"); 590 rio_dprintk(RIO_DEBUG_TTY, "Closing down - everything must go!\n");
606 591
607 PortP->State &= ~RIO_DYNOROD; 592 PortP->State &= ~RIO_DYNOROD;
608 593
609 /* 594 /*
610 ** This is where we wait for the port 595 ** This is where we wait for the port
611 ** to drain down before closing. Bye-bye.... 596 ** to drain down before closing. Bye-bye....
612 ** (We never meant to do this) 597 ** (We never meant to do this)
613 */ 598 */
614 rio_dprintk (RIO_DEBUG_TTY, "Timeout 1 starts\n"); 599 rio_dprintk(RIO_DEBUG_TTY, "Timeout 1 starts\n");
615 600
616 if (!deleted) 601 if (!deleted)
617 while ( (PortP->InUse != NOT_INUSE) && !p->RIOHalted && 602 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) {
618 (PortP->TxBufferIn != PortP->TxBufferOut) ) { 603 cprintf("Need to flush the ttyport\n");
619 cprintf("Need to flush the ttyport\n"); 604 if (repeat_this-- <= 0) {
620 if (repeat_this -- <= 0) { 605 rv = -EINTR;
621 rv = -EINTR; 606 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
622 rio_dprintk (RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); 607 RIOPreemptiveCmd(p, PortP, FCLOSE);
623 RIOPreemptiveCmd(p, PortP, FCLOSE); 608 goto close_end;
624 goto close_end; 609 }
625 } 610 rio_dprintk(RIO_DEBUG_TTY, "Calling timeout to flush in closing\n");
626 rio_dprintk (RIO_DEBUG_TTY, "Calling timeout to flush in closing\n"); 611 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
627 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 612 if (RIODelay_ni(PortP, HUNDRED_MS * 10) == RIO_FAIL) {
628 if (RIODelay_ni(PortP, HUNDRED_MS*10) == RIO_FAIL) { 613 rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");
629 rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n"); 614 rv = -EINTR;
630 rv = -EINTR; 615 rio_spin_lock_irqsave(&PortP->portSem, flags);
616 goto close_end;
617 }
631 rio_spin_lock_irqsave(&PortP->portSem, flags); 618 rio_spin_lock_irqsave(&PortP->portSem, flags);
632 goto close_end;
633 } 619 }
634 rio_spin_lock_irqsave(&PortP->portSem, flags);
635 }
636 620
637 PortP->TxBufferIn = PortP->TxBufferOut = 0; 621 PortP->TxBufferIn = PortP->TxBufferOut = 0;
638 repeat_this = 0xff; 622 repeat_this = 0xff;
639 623
640 PortP->InUse = 0; 624 PortP->InUse = 0;
641 if ( (PortP->State & (RIO_LOPEN|RIO_MOPEN)) ) { 625 if ((PortP->State & (RIO_LOPEN | RIO_MOPEN))) {
642 /* 626 /*
643 ** The port has been re-opened for the other task - 627 ** The port has been re-opened for the other task -
644 ** return, pretending that we are still active. 628 ** return, pretending that we are still active.
645 */ 629 */
646 rio_dprintk (RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum); 630 rio_dprintk(RIO_DEBUG_TTY, "Channel %d re-open!\n", PortP->PortNum);
647 PortP->State &= ~RIO_CLOSING; 631 PortP->State &= ~RIO_CLOSING;
648 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 632 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
649 if (PortP->firstOpen) 633 if (PortP->firstOpen)
@@ -651,8 +635,8 @@ riotclose(void *ptr)
651 return -EIO; 635 return -EIO;
652 } 636 }
653 637
654 if ( p->RIOHalted ) { 638 if (p->RIOHalted) {
655 RIOClearUp( PortP ); 639 RIOClearUp(PortP);
656 goto close_end; 640 goto close_end;
657 } 641 }
658 642
@@ -665,57 +649,56 @@ riotclose(void *ptr)
665 } 649 }
666 650
667 if (!deleted) 651 if (!deleted)
668 while (try && (PortP->PortState & PORT_ISOPEN)) { 652 while (try && (PortP->PortState & PORT_ISOPEN)) {
669 try--; 653 try--;
670 if (time_after (jiffies, end_time)) { 654 if (time_after(jiffies, end_time)) {
671 rio_dprintk (RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n" ); 655 rio_dprintk(RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n");
672 RIOPreemptiveCmd(p, PortP,FCLOSE); 656 RIOPreemptiveCmd(p, PortP, FCLOSE);
673 break; 657 break;
674 } 658 }
675 rio_dprintk (RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", 659 rio_dprintk(RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", PortP->PortState & PORT_ISOPEN);
676 PortP->PortState & PORT_ISOPEN);
677 660
678 if ( p->RIOHalted ) { 661 if (p->RIOHalted) {
679 RIOClearUp( PortP ); 662 RIOClearUp(PortP);
680 goto close_end; 663 goto close_end;
681 } 664 }
682 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 665 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
683 rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n"); 666 rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");
684 RIOPreemptiveCmd(p, PortP,FCLOSE); 667 RIOPreemptiveCmd(p, PortP, FCLOSE);
685 break; 668 break;
669 }
686 } 670 }
687 }
688 rio_spin_lock_irqsave(&PortP->portSem, flags); 671 rio_spin_lock_irqsave(&PortP->portSem, flags);
689 rio_dprintk (RIO_DEBUG_TTY, "Close: try was %d on completion\n", try ); 672 rio_dprintk(RIO_DEBUG_TTY, "Close: try was %d on completion\n", try);
690 673
691 /* RIOPreemptiveCmd(p, PortP, FCLOSE); */ 674 /* RIOPreemptiveCmd(p, PortP, FCLOSE); */
692 675
693/* 676/*
694** 15.10.1998 ARG - ESIL 0761 part fix 677** 15.10.1998 ARG - ESIL 0761 part fix
695** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure,** we need to make sure that the flags are clear when the port is opened. 678** RIO has it's own CTSFLOW and RTSFLOW flags in 'Config' in the port structure,** we need to make sure that the flags are clear when the port is opened.
696*/ 679*/
697 PortP->Config &= ~(RIO_CTSFLOW|RIO_RTSFLOW); 680 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
698 681
699#ifdef STATS 682#ifdef STATS
700 PortP->Stat.CloseCnt++; 683 PortP->Stat.CloseCnt++;
701#endif 684#endif
702 /* 685 /*
703 ** Count opens for port statistics reporting 686 ** Count opens for port statistics reporting
704 */ 687 */
705 if (PortP->statsGather) 688 if (PortP->statsGather)
706 PortP->closes++; 689 PortP->closes++;
707 690
708close_end: 691 close_end:
709 /* XXX: Why would a "DELETED" flag be reset here? I'd have 692 /* XXX: Why would a "DELETED" flag be reset here? I'd have
710 thought that a "deleted" flag means that the port was 693 thought that a "deleted" flag means that the port was
711 permanently gone, but here we can make it reappear by it 694 permanently gone, but here we can make it reappear by it
712 being in close during the "deletion". 695 being in close during the "deletion".
713 */ 696 */
714 PortP->State &= ~(RIO_CLOSING|RIO_DELETED); 697 PortP->State &= ~(RIO_CLOSING | RIO_DELETED);
715 if (PortP->firstOpen) 698 if (PortP->firstOpen)
716 PortP->firstOpen--; 699 PortP->firstOpen--;
717 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 700 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
718 rio_dprintk (RIO_DEBUG_TTY, "Return from close\n"); 701 rio_dprintk(RIO_DEBUG_TTY, "Return from close\n");
719 return rv; 702 return rv;
720} 703}
721 704
@@ -728,52 +711,50 @@ close_end:
728** COOK_MEDIUM if the card can do all the processing necessary. 711** COOK_MEDIUM if the card can do all the processing necessary.
729*/ 712*/
730#if 0 713#if 0
731static int 714static int RIOCookMode(struct ttystatics *tp)
732RIOCookMode(struct ttystatics *tp)
733{ 715{
734 /* 716 /*
735 ** We can't handle tm.c_mstate != 0 on SCO 717 ** We can't handle tm.c_mstate != 0 on SCO
736 ** We can't handle mapping 718 ** We can't handle mapping
737 ** We can't handle non-ttwrite line disc. 719 ** We can't handle non-ttwrite line disc.
738 ** We can't handle lflag XCASE 720 ** We can't handle lflag XCASE
739 ** We can handle oflag OPOST & (OCRNL, ONLCR, TAB3) 721 ** We can handle oflag OPOST & (OCRNL, ONLCR, TAB3)
740 */ 722 */
741 723
742#ifdef CHECK 724#ifdef CHECK
743 CheckTtyP( tp ); 725 CheckTtyP(tp);
744#endif 726#endif
745 if (!(tp->tm.c_oflag & OPOST)) /* No post processing */ 727 if (!(tp->tm.c_oflag & OPOST)) /* No post processing */
746 return COOK_RAW; /* Raw mode o/p */ 728 return COOK_RAW; /* Raw mode o/p */
747 729
748 if ( tp->tm.c_lflag & XCASE ) 730 if (tp->tm.c_lflag & XCASE)
749 return COOK_WELL; /* Use line disc */ 731 return COOK_WELL; /* Use line disc */
750 732
751 if (tp->tm.c_oflag & ~(OPOST | ONLCR | OCRNL | TAB3 ) ) 733 if (tp->tm.c_oflag & ~(OPOST | ONLCR | OCRNL | TAB3))
752 return COOK_WELL; /* Use line disc for strange modes */ 734 return COOK_WELL; /* Use line disc for strange modes */
753 735
754 if ( tp->tm.c_oflag == OPOST ) /* If only OPOST is set, do RAW */ 736 if (tp->tm.c_oflag == OPOST) /* If only OPOST is set, do RAW */
755 return COOK_RAW; 737 return COOK_RAW;
756 738
757 /* 739 /*
758 ** So, we need to output process! 740 ** So, we need to output process!
759 */ 741 */
760 return COOK_MEDIUM; 742 return COOK_MEDIUM;
761} 743}
762#endif 744#endif
763 745
764static void 746static void RIOClearUp(PortP)
765RIOClearUp(PortP)
766struct Port *PortP; 747struct Port *PortP;
767{ 748{
768 rio_dprintk (RIO_DEBUG_TTY, "RIOHalted set\n"); 749 rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n");
769 PortP->Config = 0; /* Direct semaphore */ 750 PortP->Config = 0; /* Direct semaphore */
770 PortP->PortState = 0; 751 PortP->PortState = 0;
771 PortP->firstOpen = 0; 752 PortP->firstOpen = 0;
772 PortP->FlushCmdBodge = 0; 753 PortP->FlushCmdBodge = 0;
773 PortP->ModemState = PortP->CookMode = 0; 754 PortP->ModemState = PortP->CookMode = 0;
774 PortP->Mapped = 0; 755 PortP->Mapped = 0;
775 PortP->WflushFlag = 0; 756 PortP->WflushFlag = 0;
776 PortP->MagicFlags = 0; 757 PortP->MagicFlags = 0;
777 PortP->RxDataStart = 0; 758 PortP->RxDataStart = 0;
778 PortP->TxBufferIn = 0; 759 PortP->TxBufferIn = 0;
779 PortP->TxBufferOut = 0; 760 PortP->TxBufferOut = 0;
@@ -788,33 +769,31 @@ struct Port *PortP;
788** Other values of len aren't allowed, and will cause 769** Other values of len aren't allowed, and will cause
789** a panic. 770** a panic.
790*/ 771*/
791int RIOShortCommand(struct rio_info *p, struct Port *PortP, 772int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg)
792 int command, int len, int arg)
793{ 773{
794 PKT *PacketP; 774 PKT *PacketP;
795 int retries = 20; /* at 10 per second -> 2 seconds */ 775 int retries = 20; /* at 10 per second -> 2 seconds */
796 unsigned long flags; 776 unsigned long flags;
797 777
798 rio_dprintk (RIO_DEBUG_TTY, "entering shortcommand.\n"); 778 rio_dprintk(RIO_DEBUG_TTY, "entering shortcommand.\n");
799#ifdef CHECK 779#ifdef CHECK
800 CheckPortP( PortP ); 780 CheckPortP(PortP);
801 if ( len < 1 || len > 2 ) 781 if (len < 1 || len > 2)
802 cprintf(("STUPID LENGTH %d\n",len)); 782 cprintf(("STUPID LENGTH %d\n", len));
803#endif 783#endif
804 784
805 if ( PortP->State & RIO_DELETED ) { 785 if (PortP->State & RIO_DELETED) {
806 rio_dprintk (RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); 786 rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n");
807 return RIO_FAIL; 787 return RIO_FAIL;
808 } 788 }
809 rio_spin_lock_irqsave(&PortP->portSem, flags); 789 rio_spin_lock_irqsave(&PortP->portSem, flags);
810 790
811 /* 791 /*
812 ** If the port is in use for pre-emptive command, then wait for it to 792 ** If the port is in use for pre-emptive command, then wait for it to
813 ** be free again. 793 ** be free again.
814 */ 794 */
815 while ( (PortP->InUse != NOT_INUSE) && !p->RIOHalted ) { 795 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted) {
816 rio_dprintk (RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", 796 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not in use (%d)\n", retries);
817 retries);
818 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 797 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
819 if (retries-- <= 0) { 798 if (retries-- <= 0) {
820 return RIO_FAIL; 799 return RIO_FAIL;
@@ -824,47 +803,47 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP,
824 } 803 }
825 rio_spin_lock_irqsave(&PortP->portSem, flags); 804 rio_spin_lock_irqsave(&PortP->portSem, flags);
826 } 805 }
827 if ( PortP->State & RIO_DELETED ) { 806 if (PortP->State & RIO_DELETED) {
828 rio_dprintk (RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n"); 807 rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n");
829 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 808 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
830 return RIO_FAIL; 809 return RIO_FAIL;
831 } 810 }
832 811
833 while ( !can_add_transmit(&PacketP,PortP) && !p->RIOHalted ) { 812 while (!can_add_transmit(&PacketP, PortP) && !p->RIOHalted) {
834 rio_dprintk (RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries); 813 rio_dprintk(RIO_DEBUG_TTY, "Waiting to add short command to queue (%d)\n", retries);
835 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 814 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
836 if (retries-- <= 0) { 815 if (retries-- <= 0) {
837 rio_dprintk (RIO_DEBUG_TTY, "out of tries. Failing\n"); 816 rio_dprintk(RIO_DEBUG_TTY, "out of tries. Failing\n");
838 return RIO_FAIL; 817 return RIO_FAIL;
839 } 818 }
840 if ( RIODelay_ni(PortP, HUNDRED_MS)==RIO_FAIL ) { 819 if (RIODelay_ni(PortP, HUNDRED_MS) == RIO_FAIL) {
841 return RIO_FAIL; 820 return RIO_FAIL;
842 } 821 }
843 rio_spin_lock_irqsave(&PortP->portSem, flags); 822 rio_spin_lock_irqsave(&PortP->portSem, flags);
844 } 823 }
845 824
846 if ( p->RIOHalted ) { 825 if (p->RIOHalted) {
847 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 826 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
848 return RIO_FAIL; 827 return RIO_FAIL;
849 } 828 }
850 829
851 /* 830 /*
852 ** set the command byte and the argument byte 831 ** set the command byte and the argument byte
853 */ 832 */
854 WBYTE(PacketP->data[0] , command); 833 WBYTE(PacketP->data[0], command);
855 834
856 if ( len==2 ) 835 if (len == 2)
857 WBYTE(PacketP->data[1] , arg); 836 WBYTE(PacketP->data[1], arg);
858 837
859 /* 838 /*
860 ** set the length of the packet and set the command bit. 839 ** set the length of the packet and set the command bit.
861 */ 840 */
862 WBYTE(PacketP->len , PKT_CMD_BIT | len); 841 WBYTE(PacketP->len, PKT_CMD_BIT | len);
863 842
864 add_transmit(PortP); 843 add_transmit(PortP);
865 /* 844 /*
866 ** Count characters transmitted for port statistics reporting 845 ** Count characters transmitted for port statistics reporting
867 */ 846 */
868 if (PortP->statsGather) 847 if (PortP->statsGather)
869 PortP->txchars += len; 848 PortP->txchars += len;
870 849
@@ -878,28 +857,26 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP,
878** This is an ioctl interface. This is the twentieth century. You know what 857** This is an ioctl interface. This is the twentieth century. You know what
879** its all about. 858** its all about.
880*/ 859*/
881int 860int riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
882riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
883{ 861{
884 register struct Port *PortP; 862 register struct Port *PortP;
885 register struct ttystatics *tp; 863 register struct ttystatics *tp;
886 int current; 864 int current;
887 int ParamSemIncremented = 0; 865 int ParamSemIncremented = 0;
888 int old_oflag, old_cflag, old_iflag, changed, oldcook; 866 int old_oflag, old_cflag, old_iflag, changed, oldcook;
889 int i; 867 int i;
890 unsigned char sio_regs[5]; /* Here be magic */ 868 unsigned char sio_regs[5]; /* Here be magic */
891 short vpix_cflag; 869 short vpix_cflag;
892 short divisor; 870 short divisor;
893 int baud; 871 int baud;
894 uint SysPort = rio_minor(tty); 872 uint SysPort = rio_minor(tty);
895 int Modem = rio_ismodem(tty); 873 int Modem = rio_ismodem(tty);
896 int ioctl_processed; 874 int ioctl_processed;
897 875
898 rio_dprintk (RIO_DEBUG_TTY, "port ioctl SysPort %d command 0x%x argument 0x%x %s\n", 876 rio_dprintk(RIO_DEBUG_TTY, "port ioctl SysPort %d command 0x%x argument 0x%x %s\n", SysPort, cmd, arg, Modem ? "Modem" : "tty");
899 SysPort, cmd, arg, Modem?"Modem":"tty") ; 877
900 878 if (SysPort >= RIO_PORTS) {
901 if ( SysPort >= RIO_PORTS ) { 879 rio_dprintk(RIO_DEBUG_TTY, "Bad port number %d\n", SysPort);
902 rio_dprintk (RIO_DEBUG_TTY, "Bad port number %d\n", SysPort);
903 return -ENXIO; 880 return -ENXIO;
904 } 881 }
905 882
@@ -912,205 +889,195 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
912 PortP->Stat.IoctlCnt++; 889 PortP->Stat.IoctlCnt++;
913#endif 890#endif
914 891
915 if ( PortP->State & RIO_DELETED ) { 892 if (PortP->State & RIO_DELETED) {
916 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 893 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
917 return -EIO; 894 return -EIO;
918 } 895 }
919 896
920 897
921 if ( p->RIOHalted ) { 898 if (p->RIOHalted) {
922 RIOClearUp( PortP ); 899 RIOClearUp(PortP);
923 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 900 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
924 return -EIO; 901 return -EIO;
925 } 902 }
926 903
927 /* 904 /*
928 ** Count ioctls for port statistics reporting 905 ** Count ioctls for port statistics reporting
929 */ 906 */
930 if (PortP->statsGather) 907 if (PortP->statsGather)
931 PortP->ioctls++; 908 PortP->ioctls++;
932 909
933 /* 910 /*
934 ** Specialix RIO Ioctl calls 911 ** Specialix RIO Ioctl calls
935 */ 912 */
936 switch (cmd) { 913 switch (cmd) {
937 914
938 case TCRIOTRIAD: 915 case TCRIOTRIAD:
939 if ( arg ) 916 if (arg)
940 PortP->State |= RIO_TRIAD_MODE; 917 PortP->State |= RIO_TRIAD_MODE;
941 else 918 else
942 PortP->State &= ~RIO_TRIAD_MODE; 919 PortP->State &= ~RIO_TRIAD_MODE;
943 /* 920 /*
944 ** Normally, when istrip is set on a port, a config is 921 ** Normally, when istrip is set on a port, a config is
945 ** sent to the RTA instructing the CD1400 to do the 922 ** sent to the RTA instructing the CD1400 to do the
946 ** stripping. In TRIAD mode, the interrupt receive routine 923 ** stripping. In TRIAD mode, the interrupt receive routine
947 ** must do the stripping instead, since it has to detect 924 ** must do the stripping instead, since it has to detect
948 ** an 8 bit function key sequence. If istrip is set with 925 ** an 8 bit function key sequence. If istrip is set with
949 ** TRIAD mode on(off), and 8 bit data is being read by 926 ** TRIAD mode on(off), and 8 bit data is being read by
950 ** the port, the user then turns TRIAD mode off(on), the RTA 927 ** the port, the user then turns TRIAD mode off(on), the RTA
951 ** must be reconfigured (not) to do the stripping. 928 ** must be reconfigured (not) to do the stripping.
952 ** Hence we call RIOParam here. 929 ** Hence we call RIOParam here.
953 */ 930 */
954 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 931 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
955 RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); 932 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
956 return 0; 933 return 0;
957 934
958 case TCRIOTSTATE: 935 case TCRIOTSTATE:
959 rio_dprintk (RIO_DEBUG_TTY, "tbusy/tstop monitoring %sabled\n", 936 rio_dprintk(RIO_DEBUG_TTY, "tbusy/tstop monitoring %sabled\n", arg ? "en" : "dis");
960 arg ? "en" : "dis"); 937 /* MonitorTstate = 0 ; */
961 /* MonitorTstate = 0 ;*/ 938 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
962 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 939 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
963 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); 940 return 0;
964 return 0;
965 941
966 case TCRIOSTATE: /* current state of Modem input pins */ 942 case TCRIOSTATE: /* current state of Modem input pins */
967 rio_dprintk (RIO_DEBUG_TTY, "TCRIOSTATE\n"); 943 rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE\n");
968 if (RIOPreemptiveCmd(p, PortP, MGET) == RIO_FAIL) 944 if (RIOPreemptiveCmd(p, PortP, MGET) == RIO_FAIL)
969 rio_dprintk (RIO_DEBUG_TTY, "TCRIOSTATE command failed\n"); 945 rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE command failed\n");
970 PortP->State |= RIO_BUSY; 946 PortP->State |= RIO_BUSY;
971 current = PortP->ModemState; 947 current = PortP->ModemState;
972 if ( copyout((caddr_t)&current, (int)arg, 948 if (copyout((caddr_t) & current, (int) arg, sizeof(current)) == COPYFAIL) {
973 sizeof(current))==COPYFAIL ) { 949 rio_dprintk(RIO_DEBUG_TTY, "Copyout failed\n");
974 rio_dprintk (RIO_DEBUG_TTY, "Copyout failed\n");
975 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
976 pseterr(EFAULT);
977 }
978 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 950 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
979 return 0; 951 pseterr(EFAULT);
952 }
953 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
954 return 0;
980 955
981 case TCRIOMBIS: /* Set modem lines */ 956 case TCRIOMBIS: /* Set modem lines */
982 case TCRIOMBIC: /* Clear modem lines */ 957 case TCRIOMBIC: /* Clear modem lines */
983 rio_dprintk (RIO_DEBUG_TTY, "TCRIOMBIS/TCRIOMBIC\n"); 958 rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS/TCRIOMBIC\n");
984 if (cmd == TCRIOMBIS) { 959 if (cmd == TCRIOMBIS) {
985 uint state; 960 uint state;
986 state = (uint)arg; 961 state = (uint) arg;
987 PortP->ModemState |= (ushort)state; 962 PortP->ModemState |= (ushort) state;
988 PortP->ModemLines = (ulong) arg; 963 PortP->ModemLines = (ulong) arg;
989 if (RIOPreemptiveCmd(p, PortP, MBIS) == RIO_FAIL) 964 if (RIOPreemptiveCmd(p, PortP, MBIS) == RIO_FAIL)
990 rio_dprintk (RIO_DEBUG_TTY, 965 rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS command failed\n");
991 "TCRIOMBIS command failed\n"); 966 } else {
992 } 967 uint state;
993 else {
994 uint state;
995
996 state = (uint)arg;
997 PortP->ModemState &= ~(ushort)state;
998 PortP->ModemLines = (ulong) arg;
999 if (RIOPreemptiveCmd(p, PortP, MBIC) == RIO_FAIL)
1000 rio_dprintk (RIO_DEBUG_TTY, "TCRIOMBIC command failed\n");
1001 }
1002 PortP->State |= RIO_BUSY;
1003 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1004 return 0;
1005 968
1006 case TCRIOXPON: /* set Xprint ON string */ 969 state = (uint) arg;
1007 rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPON\n"); 970 PortP->ModemState &= ~(ushort) state;
1008 if ( copyin((int)arg, (caddr_t)PortP->Xprint.XpOn, 971 PortP->ModemLines = (ulong) arg;
1009 MAX_XP_CTRL_LEN)==COPYFAIL ) { 972 if (RIOPreemptiveCmd(p, PortP, MBIC) == RIO_FAIL)
1010 rio_dprintk (RIO_DEBUG_TTY, "Copyin failed\n"); 973 rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIC command failed\n");
1011 PortP->Xprint.XpOn[0] = '\0'; 974 }
1012 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 975 PortP->State |= RIO_BUSY;
1013 pseterr(EFAULT); 976 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1014 } 977 return 0;
1015 PortP->Xprint.XpOn[MAX_XP_CTRL_LEN-1] = '\0';
1016 PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn)+
1017 strlen(PortP->Xprint.XpOff);
1018 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1019 return 0;
1020 978
1021 case TCRIOXPOFF: /* set Xprint OFF string */ 979 case TCRIOXPON: /* set Xprint ON string */
1022 rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPOFF\n"); 980 rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPON\n");
1023 if ( copyin( (int)arg, (caddr_t)PortP->Xprint.XpOff, 981 if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOn, MAX_XP_CTRL_LEN) == COPYFAIL) {
1024 MAX_XP_CTRL_LEN)==COPYFAIL ) { 982 rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n");
1025 rio_dprintk (RIO_DEBUG_TTY, "Copyin failed\n"); 983 PortP->Xprint.XpOn[0] = '\0';
1026 PortP->Xprint.XpOff[0] = '\0';
1027 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1028 pseterr(EFAULT);
1029 }
1030 PortP->Xprint.XpOff[MAX_XP_CTRL_LEN-1] = '\0';
1031 PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn)+
1032 strlen(PortP->Xprint.XpOff);
1033 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 984 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1034 return 0; 985 pseterr(EFAULT);
986 }
987 PortP->Xprint.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
988 PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff);
989 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
990 return 0;
1035 991
1036 case TCRIOXPCPS: /* set Xprint CPS string */ 992 case TCRIOXPOFF: /* set Xprint OFF string */
1037 rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPCPS\n"); 993 rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPOFF\n");
1038 if ( (uint)arg > p->RIOConf.MaxXpCps || 994 if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOff, MAX_XP_CTRL_LEN) == COPYFAIL) {
1039 (uint)arg < p->RIOConf.MinXpCps ) { 995 rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n");
1040 rio_dprintk (RIO_DEBUG_TTY, "%d CPS out of range\n",arg); 996 PortP->Xprint.XpOff[0] = '\0';
1041 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1042 pseterr(EINVAL);
1043 return 0;
1044 }
1045 PortP->Xprint.XpCps = (uint)arg;
1046 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 997 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1047 return 0; 998 pseterr(EFAULT);
999 }
1000 PortP->Xprint.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
1001 PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff);
1002 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1003 return 0;
1048 1004
1049 case TCRIOXPRINT: 1005 case TCRIOXPCPS: /* set Xprint CPS string */
1050 rio_dprintk (RIO_DEBUG_TTY, "TCRIOXPRINT\n"); 1006 rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPCPS\n");
1051 if ( copyout((caddr_t)&PortP->Xprint, (int)arg, 1007 if ((uint) arg > p->RIOConf.MaxXpCps || (uint) arg < p->RIOConf.MinXpCps) {
1052 sizeof(struct Xprint))==COPYFAIL ) { 1008 rio_dprintk(RIO_DEBUG_TTY, "%d CPS out of range\n", arg);
1053 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1054 pseterr(EFAULT);
1055 }
1056 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1009 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1010 pseterr(EINVAL);
1057 return 0; 1011 return 0;
1012 }
1013 PortP->Xprint.XpCps = (uint) arg;
1014 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1015 return 0;
1058 1016
1059 case TCRIOIXANYON: 1017 case TCRIOXPRINT:
1060 rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXANYON\n"); 1018 rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPRINT\n");
1061 PortP->Config |= RIO_IXANY; 1019 if (copyout((caddr_t) & PortP->Xprint, (int) arg, sizeof(struct Xprint)) == COPYFAIL) {
1062 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1020 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1063 return 0; 1021 pseterr(EFAULT);
1022 }
1023 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1024 return 0;
1064 1025
1065 case TCRIOIXANYOFF: 1026 case TCRIOIXANYON:
1066 rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXANYOFF\n"); 1027 rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYON\n");
1067 PortP->Config &= ~RIO_IXANY; 1028 PortP->Config |= RIO_IXANY;
1068 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1029 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1069 return 0; 1030 return 0;
1070 1031
1071 case TCRIOIXONON: 1032 case TCRIOIXANYOFF:
1072 rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXONON\n"); 1033 rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYOFF\n");
1073 PortP->Config |= RIO_IXON; 1034 PortP->Config &= ~RIO_IXANY;
1074 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1035 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1075 return 0; 1036 return 0;
1076 1037
1077 case TCRIOIXONOFF: 1038 case TCRIOIXONON:
1078 rio_dprintk (RIO_DEBUG_TTY, "TCRIOIXONOFF\n"); 1039 rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONON\n");
1079 PortP->Config &= ~RIO_IXON; 1040 PortP->Config |= RIO_IXON;
1080 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1041 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1081 return 0; 1042 return 0;
1043
1044 case TCRIOIXONOFF:
1045 rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONOFF\n");
1046 PortP->Config &= ~RIO_IXON;
1047 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1048 return 0;
1082 1049
1083/* 1050/*
1084** 15.10.1998 ARG - ESIL 0761 part fix 1051** 15.10.1998 ARG - ESIL 0761 part fix
1085** Added support for CTS and RTS flow control ioctls : 1052** Added support for CTS and RTS flow control ioctls :
1086*/ 1053*/
1087 case TCRIOCTSFLOWEN: 1054 case TCRIOCTSFLOWEN:
1088 rio_dprintk (RIO_DEBUG_TTY, "TCRIOCTSFLOWEN\n"); 1055 rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWEN\n");
1089 PortP->Config |= RIO_CTSFLOW; 1056 PortP->Config |= RIO_CTSFLOW;
1090 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1057 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1091 RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); 1058 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
1092 return 0; 1059 return 0;
1093 1060
1094 case TCRIOCTSFLOWDIS: 1061 case TCRIOCTSFLOWDIS:
1095 rio_dprintk (RIO_DEBUG_TTY, "TCRIOCTSFLOWDIS\n"); 1062 rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWDIS\n");
1096 PortP->Config &= ~RIO_CTSFLOW; 1063 PortP->Config &= ~RIO_CTSFLOW;
1097 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1064 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1098 RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); 1065 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
1099 return 0; 1066 return 0;
1100 1067
1101 case TCRIORTSFLOWEN: 1068 case TCRIORTSFLOWEN:
1102 rio_dprintk (RIO_DEBUG_TTY, "TCRIORTSFLOWEN\n"); 1069 rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWEN\n");
1103 PortP->Config |= RIO_RTSFLOW; 1070 PortP->Config |= RIO_RTSFLOW;
1104 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1071 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1105 RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); 1072 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
1106 return 0; 1073 return 0;
1107 1074
1108 case TCRIORTSFLOWDIS: 1075 case TCRIORTSFLOWDIS:
1109 rio_dprintk (RIO_DEBUG_TTY, "TCRIORTSFLOWDIS\n"); 1076 rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWDIS\n");
1110 PortP->Config &= ~RIO_RTSFLOW; 1077 PortP->Config &= ~RIO_RTSFLOW;
1111 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1078 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1112 RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); 1079 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
1113 return 0; 1080 return 0;
1114 1081
1115/* end ESIL 0761 part fix */ 1082/* end ESIL 0761 part fix */
1116 1083
@@ -1119,35 +1086,35 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
1119 1086
1120 /* Lynx IOCTLS */ 1087 /* Lynx IOCTLS */
1121 switch (cmd) { 1088 switch (cmd) {
1122 case TIOCSETP: 1089 case TIOCSETP:
1123 case TIOCSETN: 1090 case TIOCSETN:
1124 case OTIOCSETP: 1091 case OTIOCSETP:
1125 case OTIOCSETN: 1092 case OTIOCSETN:
1126 ioctl_processed++; 1093 ioctl_processed++;
1127 ttyseth(PortP, tp, (struct old_sgttyb *)arg); 1094 ttyseth(PortP, tp, (struct old_sgttyb *) arg);
1128 break; 1095 break;
1129 case TCSETA: 1096 case TCSETA:
1130 case TCSETAW: 1097 case TCSETAW:
1131 case TCSETAF: 1098 case TCSETAF:
1132 ioctl_processed++; 1099 ioctl_processed++;
1133 rio_dprintk (RIO_DEBUG_TTY, "NON POSIX ioctl\n"); 1100 rio_dprintk(RIO_DEBUG_TTY, "NON POSIX ioctl\n");
1134 ttyseth_pv(PortP, tp, (struct termios *)arg, 0); 1101 ttyseth_pv(PortP, tp, (struct termios *) arg, 0);
1135 break; 1102 break;
1136 case TCSETAP: /* posix tcsetattr() */ 1103 case TCSETAP: /* posix tcsetattr() */
1137 case TCSETAWP: /* posix tcsetattr() */ 1104 case TCSETAWP: /* posix tcsetattr() */
1138 case TCSETAFP: /* posix tcsetattr() */ 1105 case TCSETAFP: /* posix tcsetattr() */
1139 rio_dprintk (RIO_DEBUG_TTY, "NON POSIX SYSV ioctl\n"); 1106 rio_dprintk(RIO_DEBUG_TTY, "NON POSIX SYSV ioctl\n");
1140 ttyseth_pv(PortP, tp, (struct termios *)arg, 1); 1107 ttyseth_pv(PortP, tp, (struct termios *) arg, 1);
1141 ioctl_processed++; 1108 ioctl_processed++;
1142 break; 1109 break;
1143 } 1110 }
1144 1111
1145 /* 1112 /*
1146 ** If its any of the commands that require the port to be in the 1113 ** If its any of the commands that require the port to be in the
1147 ** non-busy state wait until all output has drained 1114 ** non-busy state wait until all output has drained
1148 */ 1115 */
1149 if (!ioctl_processed) 1116 if (!ioctl_processed)
1150 switch(cmd) { 1117 switch (cmd) {
1151 case TCSETAW: 1118 case TCSETAW:
1152 case TCSETAF: 1119 case TCSETAF:
1153 case TCSETA: 1120 case TCSETA:
@@ -1171,29 +1138,29 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
1171#endif 1138#endif
1172 case TIOCSETD: 1139 case TIOCSETD:
1173 case TIOCSETN: 1140 case TIOCSETN:
1174 rio_dprintk (RIO_DEBUG_TTY, "wait for non-BUSY, semaphore set\n"); 1141 rio_dprintk(RIO_DEBUG_TTY, "wait for non-BUSY, semaphore set\n");
1175 /* 1142 /*
1176 ** Wait for drain here, at least as far as the double buffer 1143 ** Wait for drain here, at least as far as the double buffer
1177 ** being empty. 1144 ** being empty.
1178 */ 1145 */
1179 /* XXX Does the above comment mean that this has 1146 /* XXX Does the above comment mean that this has
1180 still to be implemented? -- REW */ 1147 still to be implemented? -- REW */
1181 /* XXX Is the locking OK together with locking 1148 /* XXX Is the locking OK together with locking
1182 in txenable? (Deadlock?) -- REW */ 1149 in txenable? (Deadlock?) -- REW */
1183 1150
1184 RIOTxEnable((char *)PortP); 1151 RIOTxEnable((char *) PortP);
1185 break; 1152 break;
1186 default: 1153 default:
1187 break; 1154 break;
1188 } 1155 }
1189 1156
1190 old_cflag = tp->tm.c_cflag; 1157 old_cflag = tp->tm.c_cflag;
1191 old_iflag = tp->tm.c_iflag; 1158 old_iflag = tp->tm.c_iflag;
1192 old_oflag = tp->tm.c_oflag; 1159 old_oflag = tp->tm.c_oflag;
1193 oldcook = PortP->CookMode; 1160 oldcook = PortP->CookMode;
1194 1161
1195 if ( p->RIOHalted ) { 1162 if (p->RIOHalted) {
1196 RIOClearUp( PortP ); 1163 RIOClearUp(PortP);
1197 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1164 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1198 pseterr(EIO); 1165 pseterr(EIO);
1199 return 0; 1166 return 0;
@@ -1202,10 +1169,10 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
1202 PortP->FlushCmdBodge = 0; 1169 PortP->FlushCmdBodge = 0;
1203 1170
1204 /* 1171 /*
1205 ** If the port is locked, and it is reconfigured, we want 1172 ** If the port is locked, and it is reconfigured, we want
1206 ** to restore the state of the tty structure so the change is NOT 1173 ** to restore the state of the tty structure so the change is NOT
1207 ** made. 1174 ** made.
1208 */ 1175 */
1209 if (PortP->Lock) { 1176 if (PortP->Lock) {
1210 tp->tm.c_iflag = PortP->StoredTty.iflag; 1177 tp->tm.c_iflag = PortP->StoredTty.iflag;
1211 tp->tm.c_oflag = PortP->StoredTty.oflag; 1178 tp->tm.c_oflag = PortP->StoredTty.oflag;
@@ -1214,13 +1181,12 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
1214 tp->tm.c_line = PortP->StoredTty.line; 1181 tp->tm.c_line = PortP->StoredTty.line;
1215 for (i = 0; i < NCC + 1; i++) 1182 for (i = 0; i < NCC + 1; i++)
1216 tp->tm.c_cc[i] = PortP->StoredTty.cc[i]; 1183 tp->tm.c_cc[i] = PortP->StoredTty.cc[i];
1217 } 1184 } else {
1218 else {
1219 /* 1185 /*
1220 ** If the port is set to store the parameters, and it is 1186 ** If the port is set to store the parameters, and it is
1221 ** reconfigured, we want to save the current tty struct so it 1187 ** reconfigured, we want to save the current tty struct so it
1222 ** may be restored on the next open. 1188 ** may be restored on the next open.
1223 */ 1189 */
1224 if (PortP->Store) { 1190 if (PortP->Store) {
1225 PortP->StoredTty.iflag = tp->tm.c_iflag; 1191 PortP->StoredTty.iflag = tp->tm.c_iflag;
1226 PortP->StoredTty.oflag = tp->tm.c_oflag; 1192 PortP->StoredTty.oflag = tp->tm.c_oflag;
@@ -1232,44 +1198,41 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
1232 } 1198 }
1233 } 1199 }
1234 1200
1235 changed = (tp->tm.c_cflag != old_cflag) || 1201 changed = (tp->tm.c_cflag != old_cflag) || (tp->tm.c_iflag != old_iflag) || (tp->tm.c_oflag != old_oflag);
1236 (tp->tm.c_iflag != old_iflag) ||
1237 (tp->tm.c_oflag != old_oflag);
1238 1202
1239 PortP->CookMode = RIOCookMode(tp); /* Set new cooking mode */ 1203 PortP->CookMode = RIOCookMode(tp); /* Set new cooking mode */
1240 1204
1241 rio_dprintk (RIO_DEBUG_TTY, "RIOIoctl changed %d newcook %d oldcook %d\n", 1205 rio_dprintk(RIO_DEBUG_TTY, "RIOIoctl changed %d newcook %d oldcook %d\n", changed, PortP->CookMode, oldcook);
1242 changed,PortP->CookMode,oldcook);
1243 1206
1244#ifdef MODEM_SUPPORT 1207#ifdef MODEM_SUPPORT
1245 /* 1208 /*
1246 ** kludge to force CARR_ON if CLOCAL set 1209 ** kludge to force CARR_ON if CLOCAL set
1247 */ 1210 */
1248 if ((tp->tm.c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { 1211 if ((tp->tm.c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
1249 tp->tm.c_state |= CARR_ON; 1212 tp->tm.c_state |= CARR_ON;
1250 wakeup ((caddr_t)&tp->tm.c_canq); 1213 wakeup((caddr_t) & tp->tm.c_canq);
1251 } 1214 }
1252#endif 1215#endif
1253 1216
1254 if ( p->RIOHalted ) { 1217 if (p->RIOHalted) {
1255 RIOClearUp( PortP ); 1218 RIOClearUp(PortP);
1256 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1219 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1257 pseterr(EIO); 1220 pseterr(EIO);
1258 return 0; 1221 return 0;
1259 } 1222 }
1260 /* 1223 /*
1261 ** Re-configure if modes or cooking have changed 1224 ** Re-configure if modes or cooking have changed
1262 */ 1225 */
1263 if (changed || oldcook != PortP->CookMode || (ioctl_processed)) { 1226 if (changed || oldcook != PortP->CookMode || (ioctl_processed)) {
1264 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1227 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1265 rio_dprintk (RIO_DEBUG_TTY, "Ioctl changing the PORT settings\n"); 1228 rio_dprintk(RIO_DEBUG_TTY, "Ioctl changing the PORT settings\n");
1266 RIOParam(PortP,CONFIG,Modem,OK_TO_SLEEP); 1229 RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);
1267 rio_spin_lock_irqsave(&PortP->portSem, flags); 1230 rio_spin_lock_irqsave(&PortP->portSem, flags);
1268 } 1231 }
1269 1232
1270 if (p->RIOHalted) { 1233 if (p->RIOHalted) {
1271 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1234 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1272 RIOClearUp( PortP ); 1235 RIOClearUp(PortP);
1273 pseterr(EIO); 1236 pseterr(EIO);
1274 return 0; 1237 return 0;
1275 } 1238 }
@@ -1280,36 +1243,32 @@ riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)
1280/* 1243/*
1281 ttyseth -- set hardware dependent tty settings 1244 ttyseth -- set hardware dependent tty settings
1282*/ 1245*/
1283void 1246void ttyseth(PortP, s, sg)
1284ttyseth(PortP, s, sg) 1247struct Port *PortP;
1285struct Port * PortP; 1248struct ttystatics *s;
1286struct ttystatics * s;
1287struct old_sgttyb *sg; 1249struct old_sgttyb *sg;
1288{ 1250{
1289 struct old_sgttyb * tsg; 1251 struct old_sgttyb *tsg;
1290 struct termios *tp = &s->tm; 1252 struct termios *tp = &s->tm;
1291 1253
1292 tsg = &s->sg; 1254 tsg = &s->sg;
1293 1255
1294 if (sg->sg_flags & (EVENP|ODDP)) { 1256 if (sg->sg_flags & (EVENP | ODDP)) {
1295 tp->c_cflag &= PARENB; 1257 tp->c_cflag &= PARENB;
1296 if (sg->sg_flags & EVENP) { 1258 if (sg->sg_flags & EVENP) {
1297 if (sg->sg_flags & ODDP) { 1259 if (sg->sg_flags & ODDP) {
1298 tp->c_cflag &= V_CS7; 1260 tp->c_cflag &= V_CS7;
1299 tp->c_cflag &= ~PARENB; 1261 tp->c_cflag &= ~PARENB;
1300 } 1262 } else {
1301 else {
1302 tp->c_cflag &= V_CS7; 1263 tp->c_cflag &= V_CS7;
1303 tp->c_cflag &= PARENB; 1264 tp->c_cflag &= PARENB;
1304 tp->c_cflag &= PARODD; 1265 tp->c_cflag &= PARODD;
1305 } 1266 }
1306 } 1267 } else if (sg->sg_flags & ODDP) {
1307 else if (sg->sg_flags & ODDP) {
1308 tp->c_cflag &= V_CS7; 1268 tp->c_cflag &= V_CS7;
1309 tp->c_cflag &= PARENB; 1269 tp->c_cflag &= PARENB;
1310 tp->c_cflag &= PARODD; 1270 tp->c_cflag &= PARODD;
1311 } 1271 } else {
1312 else {
1313 tp->c_cflag &= V_CS7; 1272 tp->c_cflag &= V_CS7;
1314 tp->c_cflag &= PARENB; 1273 tp->c_cflag &= PARENB;
1315 } 1274 }
@@ -1320,16 +1279,16 @@ struct old_sgttyb *sg;
1320 * I will have to use separate sets of flags to store them in the 1279 * I will have to use separate sets of flags to store them in the
1321 * Port structure. 1280 * Port structure.
1322 */ 1281 */
1323 if ( !sg->sg_ospeed ) 1282 if (!sg->sg_ospeed)
1324 sg->sg_ospeed = sg->sg_ispeed; 1283 sg->sg_ospeed = sg->sg_ispeed;
1325 else 1284 else
1326 sg->sg_ispeed = sg->sg_ospeed; 1285 sg->sg_ispeed = sg->sg_ospeed;
1327 if (sg->sg_ispeed > V_EXTB ) 1286 if (sg->sg_ispeed > V_EXTB)
1328 sg->sg_ispeed = V_EXTB; 1287 sg->sg_ispeed = V_EXTB;
1329 if (sg->sg_ispeed < V_B0) 1288 if (sg->sg_ispeed < V_B0)
1330 sg->sg_ispeed = V_B0; 1289 sg->sg_ispeed = V_B0;
1331 *tsg = *sg; 1290 *tsg = *sg;
1332 tp->c_cflag = (tp->c_cflag & ~V_CBAUD) | conv_bv[(int)sg->sg_ispeed]; 1291 tp->c_cflag = (tp->c_cflag & ~V_CBAUD) | conv_bv[(int) sg->sg_ispeed];
1333} 1292}
1334 1293
1335/* 1294/*
@@ -1338,36 +1297,33 @@ struct old_sgttyb *sg;
1338 sysv = 0 => (POSIX): struct termios *sg 1297 sysv = 0 => (POSIX): struct termios *sg
1339 sysv != 0 => (System V): struct termio *sg 1298 sysv != 0 => (System V): struct termio *sg
1340*/ 1299*/
1341static void 1300static void ttyseth_pv(PortP, s, sg, sysv)
1342ttyseth_pv(PortP, s, sg, sysv)
1343struct Port *PortP; 1301struct Port *PortP;
1344struct ttystatics *s; 1302struct ttystatics *s;
1345struct termios *sg; 1303struct termios *sg;
1346int sysv; 1304int sysv;
1347{ 1305{
1348 int speed; 1306 int speed;
1349 unsigned char csize; 1307 unsigned char csize;
1350 unsigned char cread; 1308 unsigned char cread;
1351 unsigned int lcr_flags; 1309 unsigned int lcr_flags;
1352 int ps; 1310 int ps;
1353 1311
1354 if (sysv) { 1312 if (sysv) {
1355 /* sg points to a System V termio structure */ 1313 /* sg points to a System V termio structure */
1356 csize = ((struct termio *)sg)->c_cflag & CSIZE; 1314 csize = ((struct termio *) sg)->c_cflag & CSIZE;
1357 cread = ((struct termio *)sg)->c_cflag & CREAD; 1315 cread = ((struct termio *) sg)->c_cflag & CREAD;
1358 speed = conv_vb[((struct termio *)sg)->c_cflag & V_CBAUD]; 1316 speed = conv_vb[((struct termio *) sg)->c_cflag & V_CBAUD];
1359 } 1317 } else {
1360 else { 1318 /* sg points to a POSIX termios structure */
1361 /* sg points to a POSIX termios structure */ 1319 csize = sg->c_cflag & CSIZE;
1362 csize = sg->c_cflag & CSIZE; 1320 cread = sg->c_cflag & CREAD;
1363 cread = sg->c_cflag & CREAD; 1321 speed = conv_vb[sg->c_cflag & V_CBAUD];
1364 speed = conv_vb[sg->c_cflag & V_CBAUD]; 1322 }
1365 } 1323 if (s->sg.sg_ispeed != speed || s->sg.sg_ospeed != speed) {
1366 if (s->sg.sg_ispeed != speed || s->sg.sg_ospeed != speed) { 1324 s->sg.sg_ispeed = speed;
1367 s->sg.sg_ispeed = speed; 1325 s->sg.sg_ospeed = speed;
1368 s->sg.sg_ospeed = speed; 1326 s->tm.c_cflag = (s->tm.c_cflag & ~V_CBAUD) | conv_bv[(int) s->sg.sg_ispeed];
1369 s->tm.c_cflag = (s->tm.c_cflag & ~V_CBAUD) | 1327 }
1370 conv_bv[(int)s->sg.sg_ispeed];
1371 }
1372} 1328}
1373#endif 1329#endif