aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rio/riocmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/rio/riocmd.c')
-rw-r--r--drivers/char/rio/riocmd.c176
1 files changed, 79 insertions, 97 deletions
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 694bfb9d9378..e6d2b14b5e65 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -42,6 +42,7 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h> 44#include <asm/semaphore.h>
45#include <asm/uaccess.h>
45 46
46#include <linux/termios.h> 47#include <linux/termios.h>
47#include <linux/serial.h> 48#include <linux/serial.h>
@@ -50,15 +51,12 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
50 51
51#include "linux_compat.h" 52#include "linux_compat.h"
52#include "rio_linux.h" 53#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 54#include "pkt.h"
55#include "daemon.h" 55#include "daemon.h"
56#include "rio.h" 56#include "rio.h"
57#include "riospace.h" 57#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 58#include "cmdpkt.h"
60#include "map.h" 59#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 60#include "rup.h"
63#include "port.h" 61#include "port.h"
64#include "riodrvr.h" 62#include "riodrvr.h"
@@ -71,12 +69,10 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
71#include "unixrup.h" 69#include "unixrup.h"
72#include "board.h" 70#include "board.h"
73#include "host.h" 71#include "host.h"
74#include "error.h"
75#include "phb.h" 72#include "phb.h"
76#include "link.h" 73#include "link.h"
77#include "cmdblk.h" 74#include "cmdblk.h"
78#include "route.h" 75#include "route.h"
79#include "control.h"
80#include "cirrus.h" 76#include "cirrus.h"
81 77
82 78
@@ -143,17 +139,17 @@ int RIOZombieRta(struct Host *HostP, struct Map *MapP)
143 return 0; 139 return 0;
144} 140}
145 141
146int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP)) 142int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
147{ 143{
148 uint Host; 144 unsigned int Host;
149 145
150 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%x func 0x%x\n", RtaUnique, (int) func); 146 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func);
151 147
152 if (!RtaUnique) 148 if (!RtaUnique)
153 return (0); 149 return (0);
154 150
155 for (Host = 0; Host < p->RIONumHosts; Host++) { 151 for (Host = 0; Host < p->RIONumHosts; Host++) {
156 uint Rta; 152 unsigned int Rta;
157 struct Host *HostP = &p->RIOHosts[Host]; 153 struct Host *HostP = &p->RIOHosts[Host];
158 154
159 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 155 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -170,7 +166,7 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
170 ** any connections, we can get to it. 166 ** any connections, we can get to it.
171 */ 167 */
172 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 168 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
173 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 169 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
174 /* 170 /*
175 ** Its worth trying the operation... 171 ** Its worth trying the operation...
176 */ 172 */
@@ -184,18 +180,18 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
184} 180}
185 181
186 182
187int RIOIdentifyRta(struct rio_info *p, caddr_t arg) 183int RIOIdentifyRta(struct rio_info *p, void * arg)
188{ 184{
189 uint Host; 185 unsigned int Host;
190 186
191 if (copyin((int) arg, (caddr_t) & IdRta, sizeof(IdRta)) == COPYFAIL) { 187 if (copy_from_user(&IdRta, arg, sizeof(IdRta))) {
192 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n"); 188 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
193 p->RIOError.Error = COPYIN_FAILED; 189 p->RIOError.Error = COPYIN_FAILED;
194 return -EFAULT; 190 return -EFAULT;
195 } 191 }
196 192
197 for (Host = 0; Host < p->RIONumHosts; Host++) { 193 for (Host = 0; Host < p->RIONumHosts; Host++) {
198 uint Rta; 194 unsigned int Rta;
199 struct Host *HostP = &p->RIOHosts[Host]; 195 struct Host *HostP = &p->RIOHosts[Host];
200 196
201 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 197 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -211,7 +207,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
211 ** any connections, we can get to it. 207 ** any connections, we can get to it.
212 */ 208 */
213 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 209 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
214 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 210 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
215 /* 211 /*
216 ** Its worth trying the operation... 212 ** Its worth trying the operation...
217 */ 213 */
@@ -249,7 +245,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
249} 245}
250 246
251 247
252int RIOKillNeighbour(struct rio_info *p, caddr_t arg) 248int RIOKillNeighbour(struct rio_info *p, void * arg)
253{ 249{
254 uint Host; 250 uint Host;
255 uint ID; 251 uint ID;
@@ -258,7 +254,7 @@ int RIOKillNeighbour(struct rio_info *p, caddr_t arg)
258 254
259 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n"); 255 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
260 256
261 if (copyin((int) arg, (caddr_t) & KillUnit, sizeof(KillUnit)) == COPYFAIL) { 257 if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) {
262 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n"); 258 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
263 p->RIOError.Error = COPYIN_FAILED; 259 p->RIOError.Error = COPYIN_FAILED;
264 return -EFAULT; 260 return -EFAULT;
@@ -344,7 +340,7 @@ int RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
344int RIOFoadWakeup(struct rio_info *p) 340int RIOFoadWakeup(struct rio_info *p)
345{ 341{
346 int port; 342 int port;
347 register struct Port *PortP; 343 struct Port *PortP;
348 unsigned long flags; 344 unsigned long flags;
349 345
350 for (port = 0; port < RIO_PORTS; port++) { 346 for (port = 0; port < RIO_PORTS; port++) {
@@ -374,15 +370,15 @@ int RIOFoadWakeup(struct rio_info *p)
374/* 370/*
375** Incoming command on the COMMAND_RUP to be processed. 371** Incoming command on the COMMAND_RUP to be processed.
376*/ 372*/
377static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 373static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT * PacketP)
378{ 374{
379 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 375 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
380 struct Port *PortP; 376 struct Port *PortP;
381 struct UnixRup *UnixRupP; 377 struct UnixRup *UnixRupP;
382 ushort SysPort; 378 unsigned short SysPort;
383 ushort ReportedModemStatus; 379 unsigned short ReportedModemStatus;
384 ushort rup; 380 unsigned short rup;
385 ushort subCommand; 381 unsigned short subCommand;
386 unsigned long flags; 382 unsigned long flags;
387 383
388 func_enter(); 384 func_enter();
@@ -395,18 +391,18 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
395 ** we can use PhbNum to get the rup number for the appropriate 8 port 391 ** we can use PhbNum to get the rup number for the appropriate 8 port
396 ** block (for the first block, this should be equal to 'Rup'). 392 ** block (for the first block, this should be equal to 'Rup').
397 */ 393 */
398 rup = RBYTE(PktCmdP->PhbNum) / (ushort) PORTS_PER_RTA; 394 rup = readb(&PktCmdP->PhbNum) / (unsigned short) PORTS_PER_RTA;
399 UnixRupP = &HostP->UnixRups[rup]; 395 UnixRupP = &HostP->UnixRups[rup];
400 SysPort = UnixRupP->BaseSysPort + (RBYTE(PktCmdP->PhbNum) % (ushort) PORTS_PER_RTA); 396 SysPort = UnixRupP->BaseSysPort + (readb(&PktCmdP->PhbNum) % (unsigned short) PORTS_PER_RTA);
401 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort); 397 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort);
402 398
403 if (UnixRupP->BaseSysPort == NO_PORT) { 399 if (UnixRupP->BaseSysPort == NO_PORT) {
404 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n"); 400 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n");
405 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n"); 401 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n");
406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %d, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); 402 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
407 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); 403 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup);
408 404
409 if (Rup >= (ushort) MAX_RUP) { 405 if (Rup >= (unsigned short) MAX_RUP) {
410 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); 406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name);
411 } else 407 } else
412 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); 408 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name);
@@ -417,16 +413,16 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
417 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control); 413 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control);
418 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum); 414 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum);
419 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command); 415 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command);
420 return TRUE; 416 return 1;
421 } 417 }
422 PortP = p->RIOPortp[SysPort]; 418 PortP = p->RIOPortp[SysPort];
423 rio_spin_lock_irqsave(&PortP->portSem, flags); 419 rio_spin_lock_irqsave(&PortP->portSem, flags);
424 switch (RBYTE(PktCmdP->Command)) { 420 switch (readb(&PktCmdP->Command)) {
425 case BREAK_RECEIVED: 421 case BREAK_RECEIVED:
426 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n"); 422 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n");
427 /* If the current line disc. is not multi-threading and 423 /* If the current line disc. is not multi-threading and
428 the current processor is not the default, reset rup_intr 424 the current processor is not the default, reset rup_intr
429 and return FALSE to ensure that the command packet is 425 and return 0 to ensure that the command packet is
430 not freed. */ 426 not freed. */
431 /* Call tmgr HANGUP HERE */ 427 /* Call tmgr HANGUP HERE */
432 /* Fix this later when every thing works !!!! RAMRAJ */ 428 /* Fix this later when every thing works !!!! RAMRAJ */
@@ -434,15 +430,15 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
434 break; 430 break;
435 431
436 case COMPLETE: 432 case COMPLETE:
437 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %d\n", RBYTE(PktCmdP->PhbNum), HostP - p->RIOHosts); 433 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts);
438 subCommand = 1; 434 subCommand = 1;
439 switch (RBYTE(PktCmdP->SubCommand)) { 435 switch (readb(&PktCmdP->SubCommand)) {
440 case MEMDUMP: 436 case MEMDUMP:
441 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", RBYTE(PktCmdP->SubCommand), RWORD(PktCmdP->SubAddr)); 437 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr));
442 break; 438 break;
443 case READ_REGISTER: 439 case READ_REGISTER:
444 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", RWORD(PktCmdP->SubAddr)); 440 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr));
445 p->CdRegister = (RBYTE(PktCmdP->ModemStatus) & MSVR1_HOST); 441 p->CdRegister = (readb(&PktCmdP->ModemStatus) & MSVR1_HOST);
446 break; 442 break;
447 default: 443 default:
448 subCommand = 0; 444 subCommand = 0;
@@ -450,10 +446,10 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
450 } 446 }
451 if (subCommand) 447 if (subCommand)
452 break; 448 break;
453 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", RBYTE(PktCmdP->PortStatus), PortP->PortState); 449 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", readb(&PktCmdP->PortStatus), PortP->PortState);
454 if (PortP->PortState != RBYTE(PktCmdP->PortStatus)) { 450 if (PortP->PortState != readb(&PktCmdP->PortStatus)) {
455 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n"); 451 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n");
456 PortP->PortState = RBYTE(PktCmdP->PortStatus); 452 PortP->PortState = readb(&PktCmdP->PortStatus);
457 /* What should we do here ... 453 /* What should we do here ...
458 wakeup( &PortP->PortState ); 454 wakeup( &PortP->PortState );
459 */ 455 */
@@ -467,7 +463,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
467 ** to the check for modem status change (they're just there because 463 ** to the check for modem status change (they're just there because
468 ** it's a convenient place to put them!). 464 ** it's a convenient place to put them!).
469 */ 465 */
470 ReportedModemStatus = RBYTE(PktCmdP->ModemStatus); 466 ReportedModemStatus = readb(&PktCmdP->ModemStatus);
471 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) { 467 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) {
472 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState); 468 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
473 /* 469 /*
@@ -514,9 +510,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
514 */ 510 */
515 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN)) 511 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
516 wake_up_interruptible(&PortP->gs.open_wait); 512 wake_up_interruptible(&PortP->gs.open_wait);
517#ifdef STATS
518 PortP->Stat.ModemOnCnt++;
519#endif
520 } 513 }
521 } else { 514 } else {
522 /* 515 /*
@@ -527,9 +520,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
527 tty_hangup(PortP->gs.tty); 520 tty_hangup(PortP->gs.tty);
528 PortP->State &= ~RIO_CARR_ON; 521 PortP->State &= ~RIO_CARR_ON;
529 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n"); 522 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
530#ifdef STATS
531 PortP->Stat.ModemOffCnt++;
532#endif
533 } 523 }
534 } 524 }
535 } 525 }
@@ -539,14 +529,14 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
539 break; 529 break;
540 530
541 default: 531 default:
542 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %d\n", RBYTE(PktCmdP->Command), HostP - p->RIOHosts); 532 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %Zd\n", readb(&PktCmdP->Command), HostP - p->RIOHosts);
543 break; 533 break;
544 } 534 }
545 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 535 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
546 536
547 func_exit(); 537 func_exit();
548 538
549 return TRUE; 539 return 1;
550} 540}
551 541
552/* 542/*
@@ -566,10 +556,9 @@ struct CmdBlk *RIOGetCmdBlk(void)
566{ 556{
567 struct CmdBlk *CmdBlkP; 557 struct CmdBlk *CmdBlkP;
568 558
569 CmdBlkP = (struct CmdBlk *) sysbrk(sizeof(struct CmdBlk)); 559 CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
570 if (CmdBlkP) 560 if (CmdBlkP)
571 bzero(CmdBlkP, sizeof(struct CmdBlk)); 561 memset(CmdBlkP, 0, sizeof(struct CmdBlk));
572
573 return CmdBlkP; 562 return CmdBlkP;
574} 563}
575 564
@@ -578,7 +567,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
578*/ 567*/
579void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP) 568void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP)
580{ 569{
581 sysfree((void *) CmdBlkP, sizeof(struct CmdBlk)); 570 kfree(CmdBlkP);
582} 571}
583 572
584/* 573/*
@@ -591,7 +580,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
591 struct UnixRup *UnixRupP; 580 struct UnixRup *UnixRupP;
592 unsigned long flags; 581 unsigned long flags;
593 582
594 if (Rup >= (ushort) (MAX_RUP + LINKS_PER_UNIT)) { 583 if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) {
595 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup); 584 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup);
596 RIOFreeCmdBlk(CmdBlkP); 585 RIOFreeCmdBlk(CmdBlkP);
597 return RIO_FAIL; 586 return RIO_FAIL;
@@ -605,14 +594,14 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
605 ** If the RUP is currently inactive, then put the request 594 ** If the RUP is currently inactive, then put the request
606 ** straight on the RUP.... 595 ** straight on the RUP....
607 */ 596 */
608 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) 597 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
609 : TRUE)) { 598 : 1)) {
610 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]); 599 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]);
611 600
612 /* 601 /*
613 ** Whammy! blat that pack! 602 ** Whammy! blat that pack!
614 */ 603 */
615 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 604 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
616 605
617 /* 606 /*
618 ** place command packet on the pending position. 607 ** place command packet on the pending position.
@@ -622,11 +611,11 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
622 /* 611 /*
623 ** set the command register 612 ** set the command register
624 */ 613 */
625 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 614 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
626 615
627 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 616 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
628 617
629 return RIO_SUCCESS; 618 return 0;
630 } 619 }
631 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n"); 620 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n");
632 621
@@ -634,20 +623,20 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
634 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n"); 623 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n");
635 if (UnixRupP->CmdPendingP != NULL) 624 if (UnixRupP->CmdPendingP != NULL)
636 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n"); 625 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n");
637 if (RWORD(UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE) 626 if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
638 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n"); 627 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
639 628
640 Base = &UnixRupP->CmdsWaitingP; 629 Base = &UnixRupP->CmdsWaitingP;
641 630
642 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 631 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base);
643 632
644 while (*Base) { 633 while (*Base) {
645 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk 0x%x here\n", (int) (*Base)); 634 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base);
646 Base = &((*Base)->NextP); 635 Base = &((*Base)->NextP);
647 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 636 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base);
648 } 637 }
649 638
650 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 639 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base);
651 640
652 *Base = CmdBlkP; 641 *Base = CmdBlkP;
653 642
@@ -655,7 +644,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
655 644
656 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 645 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
657 646
658 return RIO_SUCCESS; 647 return 0;
659} 648}
660 649
661/* 650/*
@@ -664,10 +653,10 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
664*/ 653*/
665void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) 654void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
666{ 655{
667 register struct CmdBlk *CmdBlkP; 656 struct CmdBlk *CmdBlkP;
668 register struct UnixRup *UnixRupP; 657 struct UnixRup *UnixRupP;
669 struct PKT *PacketP; 658 struct PKT *PacketP;
670 ushort Rup; 659 unsigned short Rup;
671 unsigned long flags; 660 unsigned long flags;
672 661
673 662
@@ -684,16 +673,14 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
684 /* 673 /*
685 ** First check for incoming commands: 674 ** First check for incoming commands:
686 */ 675 */
687 if (RWORD(UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { 676 if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
688 int FreeMe; 677 int FreeMe;
689 678
690 PacketP = (PKT *) RIO_PTR(HostP->Caddr, RWORD(UnixRupP->RupP->rxpkt)); 679 PacketP = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt));
691 680
692 ShowPacket(DBG_CMD, PacketP); 681 switch (readb(&PacketP->dest_port)) {
693
694 switch (RBYTE(PacketP->dest_port)) {
695 case BOOT_RUP: 682 case BOOT_RUP:
696 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", RBYTE(PacketP->len) & 0x80 ? "Command" : "Data", RBYTE(PacketP->data[0])); 683 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0]));
697 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 684 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
698 FreeMe = RIOBootRup(p, Rup, HostP, PacketP); 685 FreeMe = RIOBootRup(p, Rup, HostP, PacketP);
699 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 686 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -708,7 +695,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
708 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 695 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
709 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); 696 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
710 if (PacketP->data[5] == MEMDUMP) { 697 if (PacketP->data[5] == MEMDUMP) {
711 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(ushort *) & (PacketP->data[6])); 698 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6]));
712 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32); 699 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32);
713 } 700 }
714 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 701 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -721,7 +708,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
721 break; 708 break;
722 709
723 default: 710 default:
724 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", RBYTE(PacketP->dest_port)); 711 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port));
725 FreeMe = 1; 712 FreeMe = 1;
726 break; 713 break;
727 } 714 }
@@ -730,11 +717,11 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
730 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n"); 717 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n");
731 put_free_end(HostP, PacketP); 718 put_free_end(HostP, PacketP);
732 719
733 WWORD(UnixRupP->RupP->rxcontrol, RX_RUP_INACTIVE); 720 writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol);
734 721
735 if (RWORD(UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) { 722 if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
736 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup); 723 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup);
737 WWORD(UnixRupP->RupP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 724 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake);
738 } 725 }
739 } 726 }
740 } 727 }
@@ -744,7 +731,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
744 ** and it has completed, then tidy it up. 731 ** and it has completed, then tidy it up.
745 */ 732 */
746 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */ 733 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */
747 (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 734 (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
748 /* 735 /*
749 ** we are idle. 736 ** we are idle.
750 ** there is a command in pending. 737 ** there is a command in pending.
@@ -755,7 +742,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
755 if (CmdBlkP->Packet.dest_port == BOOT_RUP) 742 if (CmdBlkP->Packet.dest_port == BOOT_RUP)
756 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]); 743 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]);
757 744
758 rio_dprintk(RIO_DEBUG_CMD, "Command 0x%x completed\n", (int) CmdBlkP); 745 rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP);
759 746
760 /* 747 /*
761 ** Clear the Rup lock to prevent mutual exclusion. 748 ** Clear the Rup lock to prevent mutual exclusion.
@@ -782,20 +769,20 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
782 ** is idle, then process the command 769 ** is idle, then process the command
783 */ 770 */
784 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */ 771 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */
785 (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 772 (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
786 /* 773 /*
787 ** if the pre-function is non-zero, call it. 774 ** if the pre-function is non-zero, call it.
788 ** If it returns RIO_FAIL then don't 775 ** If it returns RIO_FAIL then don't
789 ** send this command yet! 776 ** send this command yet!
790 */ 777 */
791 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : TRUE)) { 778 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : 1)) {
792 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command 0x%x\n", (int) CmdBlkP); 779 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command %p\n", CmdBlkP);
793 } else { 780 } else {
794 rio_dprintk(RIO_DEBUG_CMD, "Start new command 0x%x Cmd byte is 0x%x\n", (int) CmdBlkP, CmdBlkP->Packet.data[0]); 781 rio_dprintk(RIO_DEBUG_CMD, "Start new command %p Cmd byte is 0x%x\n", CmdBlkP, CmdBlkP->Packet.data[0]);
795 /* 782 /*
796 ** Whammy! blat that pack! 783 ** Whammy! blat that pack!
797 */ 784 */
798 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 785 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
799 786
800 /* 787 /*
801 ** remove the command from the rup command queue... 788 ** remove the command from the rup command queue...
@@ -810,7 +797,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
810 /* 797 /*
811 ** set the command register 798 ** set the command register
812 */ 799 */
813 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 800 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
814 801
815 /* 802 /*
816 ** the command block will be freed 803 ** the command block will be freed
@@ -822,7 +809,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
822 } while (Rup); 809 } while (Rup);
823} 810}
824 811
825int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP) 812int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP)
826{ 813{
827 struct Port *PortP = (struct Port *) iPortP; 814 struct Port *PortP = (struct Port *) iPortP;
828 unsigned long flags; 815 unsigned long flags;
@@ -834,33 +821,32 @@ int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
834 return RIOUnUse(iPortP, CmdBlkP); 821 return RIOUnUse(iPortP, CmdBlkP);
835} 822}
836 823
837int RIORFlushEnable(int iPortP, struct CmdBlk *CmdBlkP) 824int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP)
838{ 825{
839 struct Port *PortP = (struct Port *) iPortP; 826 struct Port *PortP = (struct Port *) iPortP;
840 PKT *PacketP; 827 struct PKT *PacketP;
841 unsigned long flags; 828 unsigned long flags;
842 829
843 rio_spin_lock_irqsave(&PortP->portSem, flags); 830 rio_spin_lock_irqsave(&PortP->portSem, flags);
844 831
845 while (can_remove_receive(&PacketP, PortP)) { 832 while (can_remove_receive(&PacketP, PortP)) {
846 remove_receive(PortP); 833 remove_receive(PortP);
847 ShowPacket(DBG_PROC, PacketP);
848 put_free_end(PortP->HostP, PacketP); 834 put_free_end(PortP->HostP, PacketP);
849 } 835 }
850 836
851 if (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) { 837 if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
852 /* 838 /*
853 ** MAGIC! (Basically, handshake the RX buffer, so that 839 ** MAGIC! (Basically, handshake the RX buffer, so that
854 ** the RTAs upstream can be re-enabled.) 840 ** the RTAs upstream can be re-enabled.)
855 */ 841 */
856 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n"); 842 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
857 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 843 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
858 } 844 }
859 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 845 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
860 return RIOUnUse(iPortP, CmdBlkP); 846 return RIOUnUse(iPortP, CmdBlkP);
861} 847}
862 848
863int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP) 849int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
864{ 850{
865 struct Port *PortP = (struct Port *) iPortP; 851 struct Port *PortP = (struct Port *) iPortP;
866 unsigned long flags; 852 unsigned long flags;
@@ -890,7 +876,7 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
890 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data 876 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
891 ** hanging around in the transmit buffer is sent immediately. 877 ** hanging around in the transmit buffer is sent immediately.
892 */ 878 */
893 WWORD(PortP->HostP->ParmMapP->tx_intr, 1); 879 writew(1, &PortP->HostP->ParmMapP->tx_intr);
894 /* What to do here .. 880 /* What to do here ..
895 wakeup( (caddr_t)&(PortP->InUse) ); 881 wakeup( (caddr_t)&(PortP->InUse) );
896 */ 882 */
@@ -898,10 +884,6 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
898 return 0; 884 return 0;
899} 885}
900 886
901void ShowPacket(uint Flags, struct PKT *PacketP)
902{
903}
904
905/* 887/*
906** 888**
907** How to use this file: 889** How to use this file: