2 ** -----------------------------------------------------------------------------
4 ** Perle Specialix driver for Linux
5 ** Ported from existing RIO Driver for SCO sources.
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 ** Last Modified : 11/6/98 10:33:42
26 ** Retrieved : 11/6/98 10:33:49
28 ** ident @(#)rioctrl.c 1.3
30 ** -----------------------------------------------------------------------------
33 static char *_rioctrl_c_sccs_
= "@(#)rioctrl.c 1.3";
37 #include <linux/module.h>
38 #include <linux/slab.h>
39 #include <linux/errno.h>
41 #include <asm/system.h>
42 #include <asm/string.h>
43 #include <asm/semaphore.h>
44 #include <asm/uaccess.h>
46 #include <linux/termios.h>
47 #include <linux/serial.h>
49 #include <linux/generic_serial.h>
52 #include "linux_compat.h"
53 #include "rio_linux.h"
85 static struct LpbReq LpbReq
;
86 static struct RupReq RupReq
;
87 static struct PortReq PortReq
;
88 static struct HostReq HostReq
;
89 static struct HostDpRam HostDpRam
;
90 static struct DebugCtrl DebugCtrl
;
91 static struct Map MapEnt
;
92 static struct PortSetup PortSetup
;
93 static struct DownLoad DownLoad
;
94 static struct SendPack SendPack
;
95 /* static struct StreamInfo StreamInfo; */
96 /* static char modemtable[RIO_PORTS]; */
97 static struct SpecialRupCmd SpecialRupCmd
;
98 static struct PortParams PortParams
;
99 static struct portStats portStats
;
101 static struct SubCmdStruct
{
110 struct ttystatics Tty
;
113 static struct PortTty PortTty
;
114 typedef struct ttystatics TERMIO
;
117 ** This table is used when the config.rio downloads bin code to the
118 ** driver. We index the table using the product code, 0-F, and call
119 ** the function pointed to by the entry, passing the information
121 ** The RIOBootCodeUNKNOWN entry is there to politely tell the calling
122 ** process to bog off.
125 (*RIOBootTable
[MAX_PRODUCT
])(struct rio_info
*, struct DownLoad
*) =
127 /* 0 */ RIOBootCodeHOST
, /* Host Card */
128 /* 1 */ RIOBootCodeRTA
, /* RTA */
131 #define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff))
133 int copyin (int arg
, caddr_t dp
, int siz
)
137 rio_dprintk (RIO_DEBUG_CTRL
, "Copying %d bytes from user %p to %p.\n", siz
, (void *)arg
, dp
);
138 rv
= copy_from_user (dp
, (void *)arg
, siz
);
139 if (rv
) return COPYFAIL
;
143 static int copyout (caddr_t dp
, int arg
, int siz
)
147 rio_dprintk (RIO_DEBUG_CTRL
, "Copying %d bytes to user %p from %p.\n", siz
, (void *)arg
, dp
);
148 rv
= copy_to_user ((void *)arg
, dp
, siz
);
149 if (rv
) return COPYFAIL
;
154 riocontrol(p
, dev
, cmd
, arg
, su
)
161 uint Host
; /* leave me unsigned! */
162 uint port
; /* and me! */
173 /* Confuse the compiler to think that we've initialized these */
177 rio_dprintk (RIO_DEBUG_CTRL
, "control ioctl cmd: 0x%x arg: 0x%x\n", cmd
, (int)arg
);
183 ** Change the value of the host card interrupt timer.
184 ** If the host card number is -1 then all host cards are changed
185 ** otherwise just the specified host card will be changed.
188 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SET_TIMER to %dms\n", (uint
)arg
);
191 host
= (uint
)arg
>> 16;
192 value
= (uint
)arg
& 0x0000ffff;
194 for (host
= 0; host
< p
->RIONumHosts
; host
++) {
195 if (p
->RIOHosts
[host
].Flags
== RC_RUNNING
) {
196 WWORD(p
->RIOHosts
[host
].ParmMapP
->timer
, value
);
199 } else if (host
>= p
->RIONumHosts
) {
202 if ( p
->RIOHosts
[host
].Flags
== RC_RUNNING
) {
203 WWORD(p
->RIOHosts
[host
].ParmMapP
->timer
, value
);
209 case RIO_IDENTIFY_DRIVER
:
211 ** 15.10.1998 ARG - ESIL 0760 part fix
212 ** Added driver ident string output.
214 #ifndef __THIS_RELEASE__
215 #warning Driver Version string not defined !
217 cprintf("%s %s %s %s\n",
220 __DATE__, __TIME__ );
224 case RIO_DISPLAY_HOST_CFG:
226 ** 15.10.1998 ARG - ESIL 0760 part fix
227 ** Added driver host card ident string output.
229 ** Note that the only types currently supported
230 ** are ISA and PCI. Also this driver does not
231 ** (yet) distinguish between the Old PCI card
232 ** and the Jet PCI card. In fact I think this
233 ** driver only supports JET PCI !
236 for (Host = 0; Host < p->RIONumHosts; Host++)
238 HostP = &(p->RIOHosts[Host]);
240 switch ( HostP->Type )
243 strcpy( host_type, RIO_AT_HOST_STR );
247 strcpy( host_type, RIO_PCI_HOST_STR );
251 strcpy( host_type, "Unknown" );
256 "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
259 (int)HostP->Ivec - 32 );
266 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_FOAD_RTA\n");
267 return RIOCommandRta(p
, (uint
)arg
, RIOFoadRta
);
270 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_ZOMBIE_RTA\n");
271 return RIOCommandRta(p
, (uint
)arg
, RIOZombieRta
);
273 case RIO_IDENTIFY_RTA
:
274 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_IDENTIFY_RTA\n");
275 return RIOIdentifyRta(p
, arg
);
277 case RIO_KILL_NEIGHBOUR
:
278 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_KILL_NEIGHBOUR\n");
279 return RIOKillNeighbour(p
, arg
);
281 case SPECIAL_RUP_CMD
:
283 struct CmdBlk
*CmdBlkP
;
285 rio_dprintk (RIO_DEBUG_CTRL
, "SPECIAL_RUP_CMD\n");
286 if (copyin((int)arg
, (caddr_t
)&SpecialRupCmd
,
287 sizeof(SpecialRupCmd
)) == COPYFAIL
) {
288 rio_dprintk (RIO_DEBUG_CTRL
, "SPECIAL_RUP_CMD copy failed\n");
289 p
->RIOError
.Error
= COPYIN_FAILED
;
292 CmdBlkP
= RIOGetCmdBlk();
294 rio_dprintk (RIO_DEBUG_CTRL
, "SPECIAL_RUP_CMD GetCmdBlk failed\n");
297 CmdBlkP
->Packet
= SpecialRupCmd
.Packet
;
298 if ( SpecialRupCmd
.Host
>= p
->RIONumHosts
)
299 SpecialRupCmd
.Host
= 0;
300 rio_dprintk (RIO_DEBUG_CTRL
, "Queue special rup command for host %d rup %d\n",
301 SpecialRupCmd
.Host
, SpecialRupCmd
.RupNum
);
302 if (RIOQueueCmdBlk(&p
->RIOHosts
[SpecialRupCmd
.Host
],
303 SpecialRupCmd
.RupNum
, CmdBlkP
) == RIO_FAIL
) {
304 cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n");
310 #ifdef DEBUG_MEM_SUPPORT
311 RIO_DEBUG_CTRL
, if (su
)
312 return rio_RIODebugMemory(RIO_DEBUG_CTRL
, arg
);
318 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_ALL_MODEM\n");
319 p
->RIOError
.Error
= IOCTL_COMMAND_UNKNOWN
;
324 ** Read the routing table from the device driver to user space
326 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_TABLE\n");
328 if ((retval
= RIOApel(p
)) != 0)
331 if (copyout((caddr_t
)p
->RIOConnectTable
, (int)arg
,
332 TOTAL_MAP_ENTRIES
*sizeof(struct Map
)) == COPYFAIL
) {
333 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_TABLE copy failed\n");
334 p
->RIOError
.Error
= COPYOUT_FAILED
;
340 rio_dprintk (RIO_DEBUG_CTRL
, "*****\nMAP ENTRIES\n");
341 for ( entry
=0; entry
<TOTAL_MAP_ENTRIES
; entry
++ )
343 if ((p
->RIOConnectTable
[entry
].ID
== 0) &&
344 (p
->RIOConnectTable
[entry
].HostUniqueNum
== 0) &&
345 (p
->RIOConnectTable
[entry
].RtaUniqueNum
== 0)) continue;
347 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.HostUniqueNum = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].HostUniqueNum
);
348 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.RtaUniqueNum = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].RtaUniqueNum
);
349 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.ID = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].ID
);
350 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.ID2 = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].ID2
);
351 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Flags = 0x%x\n", entry
, (int)p
->RIOConnectTable
[entry
].Flags
);
352 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.SysPort = 0x%x\n", entry
, (int)p
->RIOConnectTable
[entry
].SysPort
);
353 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[0].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[0].Unit
);
354 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[0].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[0].Link
);
355 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[1].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[1].Unit
);
356 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[1].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[1].Link
);
357 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[2].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[2].Unit
);
358 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[2].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[2].Link
);
359 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[3].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[3].Unit
);
360 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Top[4].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[3].Link
);
361 rio_dprintk (RIO_DEBUG_CTRL
, "Map entry %d.Name = %s\n", entry
, p
->RIOConnectTable
[entry
].Name
);
363 rio_dprintk (RIO_DEBUG_CTRL
, "*****\nEND MAP ENTRIES\n");
365 p
->RIOQuickCheck
= NOT_CHANGED
; /* a table has been gotten */
370 ** Write the routing table to the device driver from user space
372 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PUT_TABLE\n");
375 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PUT_TABLE !Root\n");
376 p
->RIOError
.Error
= NOT_SUPER_USER
;
379 if ( copyin((int)arg
, (caddr_t
)&p
->RIOConnectTable
[0],
380 TOTAL_MAP_ENTRIES
*sizeof(struct Map
) ) == COPYFAIL
) {
381 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PUT_TABLE copy failed\n");
382 p
->RIOError
.Error
= COPYIN_FAILED
;
386 ***********************************
389 rio_dprint(RIO_DEBUG_CTRL, ("*****\nMAP ENTRIES\n") );
390 for ( entry=0; entry<TOTAL_MAP_ENTRIES; entry++ )
392 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.HostUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].HostUniqueNum ) );
393 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.RtaUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].RtaUniqueNum ) );
394 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.ID = 0x%x\n", entry, p->RIOConnectTable[entry].ID ) );
395 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.ID2 = 0x%x\n", entry, p->RIOConnectTable[entry].ID2 ) );
396 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Flags = 0x%x\n", entry, p->RIOConnectTable[entry].Flags ) );
397 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.SysPort = 0x%x\n", entry, p->RIOConnectTable[entry].SysPort ) );
398 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[0].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[0].Unit ) );
399 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[0].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[0].Link ) );
400 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[1].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[1].Unit ) );
401 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[1].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[1].Link ) );
402 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[2].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[2].Unit ) );
403 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[2].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[2].Link ) );
404 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[3].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[3].Unit ) );
405 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[4].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[3].Link ) );
406 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Name = %s\n", entry, p->RIOConnectTable[entry].Name ) );
408 rio_dprint(RIO_DEBUG_CTRL, ("*****\nEND MAP ENTRIES\n") );
410 ***********************************
412 return RIONewTable(p
);
414 case RIO_GET_BINDINGS
:
416 ** Send bindings table, containing unique numbers of RTAs owned
417 ** by this system to user space
419 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_BINDINGS\n");
423 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_BINDINGS !Root\n");
424 p
->RIOError
.Error
= NOT_SUPER_USER
;
427 if (copyout((caddr_t
) p
->RIOBindTab
, (int)arg
,
428 (sizeof(ulong
) * MAX_RTA_BINDINGS
)) == COPYFAIL
) {
429 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_BINDINGS copy failed\n");
430 p
->RIOError
.Error
= COPYOUT_FAILED
;
435 case RIO_PUT_BINDINGS
:
437 ** Receive a bindings table, containing unique numbers of RTAs owned
440 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PUT_BINDINGS\n");
444 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PUT_BINDINGS !Root\n");
445 p
->RIOError
.Error
= NOT_SUPER_USER
;
448 if (copyin((int)arg
, (caddr_t
)&p
->RIOBindTab
[0],
449 (sizeof(ulong
) * MAX_RTA_BINDINGS
))==COPYFAIL
) {
450 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PUT_BINDINGS copy failed\n");
451 p
->RIOError
.Error
= COPYIN_FAILED
;
460 ** Bind this RTA to host, so that it will be booted by
461 ** host in 'boot owned RTAs' mode.
463 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_BIND_RTA\n");
466 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_BIND_RTA !Root\n");
467 p
->RIOError
.Error
= NOT_SUPER_USER
;
470 for (Entry
= 0; Entry
< MAX_RTA_BINDINGS
; Entry
++) {
471 if ((EmptySlot
== -1) && (p
->RIOBindTab
[Entry
] == 0L))
473 else if (p
->RIOBindTab
[Entry
] == (int) arg
) {
475 ** Already exists - delete
477 p
->RIOBindTab
[Entry
] = 0L;
478 rio_dprintk (RIO_DEBUG_CTRL
, "Removing Rta %x from p->RIOBindTab\n",
484 ** Dosen't exist - add
486 if (EmptySlot
!= -1) {
487 p
->RIOBindTab
[EmptySlot
] = (int) arg
;
488 rio_dprintk (RIO_DEBUG_CTRL
, "Adding Rta %x to p->RIOBindTab\n",
492 rio_dprintk (RIO_DEBUG_CTRL
, "p->RIOBindTab full! - Rta %x not added\n",
500 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_RESUME\n");
502 if ((port
< 0) || (port
> 511)) {
503 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_RESUME: Bad port number %d\n", port
);
504 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
507 PortP
= p
->RIOPortp
[port
];
508 if (!PortP
->Mapped
) {
509 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_RESUME: Port %d not mapped\n", port
);
510 p
->RIOError
.Error
= PORT_NOT_MAPPED_INTO_SYSTEM
;
513 if (!(PortP
->State
& (RIO_LOPEN
| RIO_MOPEN
))) {
514 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_RESUME: Port %d not open\n", port
);
518 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
519 if (RIOPreemptiveCmd(p
, (p
->RIOPortp
[port
]), RESUME
) ==
521 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_RESUME failed\n");
522 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
526 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_RESUME: Port %d resumed\n", port
);
527 PortP
->State
|= RIO_BUSY
;
529 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
533 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_ASSIGN_RTA\n");
535 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_ASSIGN_RTA !Root\n");
536 p
->RIOError
.Error
= NOT_SUPER_USER
;
539 if (copyin((int)arg
, (caddr_t
)&MapEnt
, sizeof(MapEnt
))
541 rio_dprintk (RIO_DEBUG_CTRL
, "Copy from user space failed\n");
542 p
->RIOError
.Error
= COPYIN_FAILED
;
545 return RIOAssignRta(p
, &MapEnt
);
547 case RIO_CHANGE_NAME
:
548 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_CHANGE_NAME\n");
550 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_CHANGE_NAME !Root\n");
551 p
->RIOError
.Error
= NOT_SUPER_USER
;
554 if (copyin((int)arg
, (caddr_t
)&MapEnt
, sizeof(MapEnt
))
556 rio_dprintk (RIO_DEBUG_CTRL
, "Copy from user space failed\n");
557 p
->RIOError
.Error
= COPYIN_FAILED
;
560 return RIOChangeName(p
, &MapEnt
);
563 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_DELETE_RTA\n");
565 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_DELETE_RTA !Root\n");
566 p
->RIOError
.Error
= NOT_SUPER_USER
;
569 if (copyin((int)arg
, (caddr_t
)&MapEnt
, sizeof(MapEnt
))
571 rio_dprintk (RIO_DEBUG_CTRL
, "Copy from data space failed\n");
572 p
->RIOError
.Error
= COPYIN_FAILED
;
575 return RIODeleteRta(p
, &MapEnt
);
577 case RIO_QUICK_CHECK
:
579 ** 09.12.1998 ARG - ESIL 0776 part fix
580 ** A customer was using this to get the RTAs
581 ** connect/disconnect status.
582 ** RIOConCon() had been botched use RIOHalted
583 ** to keep track of RTA connections and
584 ** disconnections. That has been changed and
585 ** RIORtaDisCons in the rio_info struct now
586 ** does the job. So we need to return the value
587 ** of RIORtaCons instead of RIOHalted.
589 if (copyout((caddr_t)&p->RIOHalted,(int)arg,
590 sizeof(uint))==COPYFAIL) {
594 if (copyout((caddr_t
)&p
->RIORtaDisCons
,(int)arg
,
595 sizeof(uint
))==COPYFAIL
) {
596 p
->RIOError
.Error
= COPYOUT_FAILED
;
602 if (copyout((caddr_t
)&p
->RIOError
, (int)arg
,
603 sizeof(struct Error
)) ==COPYFAIL
)
608 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_LOG\n");
616 case RIO_GET_MODTYPE
:
617 if ( copyin( (int)arg
, (caddr_t
)&port
,
618 sizeof(uint
)) == COPYFAIL
)
620 p
->RIOError
.Error
= COPYIN_FAILED
;
623 rio_dprintk (RIO_DEBUG_CTRL
, "Get module type for port %d\n", port
);
624 if ( port
< 0 || port
> 511 )
626 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_MODTYPE: Bad port number %d\n", port
);
627 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
630 PortP
= (p
->RIOPortp
[port
]);
633 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_MODTYPE: Port %d not mapped\n", port
);
634 p
->RIOError
.Error
= PORT_NOT_MAPPED_INTO_SYSTEM
;
638 ** Return module type of port
640 port
= PortP
->HostP
->UnixRups
[PortP
->RupNum
].ModTypes
;
641 if (copyout((caddr_t
)&port
, (int)arg
,
642 sizeof(uint
)) == COPYFAIL
) {
643 p
->RIOError
.Error
= COPYOUT_FAILED
;
648 ** 02.03.1999 ARG - ESIL 0820 fix
649 ** We are no longer using "Boot Mode", so these ioctls
650 ** are not required :
652 case RIO_GET_BOOT_MODE :
653 rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
655 ** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
657 if (copyout((caddr_t)&p->RIOBootMode, (int)arg,
658 sizeof(p->RIOBootMode)) == COPYFAIL) {
659 p->RIOError.Error = COPYOUT_FAILED;
664 case RIO_SET_BOOT_MODE :
665 p->RIOBootMode = (uint) arg;
666 rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
672 case RIO_BLOCK_OPENS
:
673 rio_dprintk (RIO_DEBUG_CTRL
, "Opens block until booted\n");
674 for ( Entry
=0; Entry
< RIO_PORTS
; Entry
++ ) {
675 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
676 p
->RIOPortp
[Entry
]->WaitUntilBooted
= 1;
677 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
681 case RIO_SETUP_PORTS
:
682 rio_dprintk (RIO_DEBUG_CTRL
, "Setup ports\n");
683 if (copyin((int)arg
, (caddr_t
)&PortSetup
, sizeof(PortSetup
))
685 p
->RIOError
.Error
= COPYIN_FAILED
;
686 rio_dprintk (RIO_DEBUG_CTRL
, "EFAULT");
689 if ( PortSetup
.From
> PortSetup
.To
||
690 PortSetup
.To
>= RIO_PORTS
) {
691 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
692 rio_dprintk (RIO_DEBUG_CTRL
, "ENXIO");
695 if ( PortSetup
.XpCps
> p
->RIOConf
.MaxXpCps
||
696 PortSetup
.XpCps
< p
->RIOConf
.MinXpCps
) {
697 p
->RIOError
.Error
= XPRINT_CPS_OUT_OF_RANGE
;
698 rio_dprintk (RIO_DEBUG_CTRL
, "EINVAL");
701 if ( !p
->RIOPortp
) {
702 cprintf("No p->RIOPortp array!\n");
703 rio_dprintk (RIO_DEBUG_CTRL
, "No p->RIOPortp array!\n");
706 rio_dprintk (RIO_DEBUG_CTRL
, "entering loop (%d %d)!\n", PortSetup
.From
, PortSetup
.To
);
707 for (loop
=PortSetup
.From
; loop
<=PortSetup
.To
; loop
++) {
708 rio_dprintk (RIO_DEBUG_CTRL
, "in loop (%d)!\n", loop
);
710 PortP
= p
->RIOPortp
[loop
];
712 PortP
->TtyP
= &p
->channel
[loop
];
714 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
715 if ( PortSetup
.IxAny
)
716 PortP
->Config
|= RIO_IXANY
;
718 PortP
->Config
&= ~RIO_IXANY
;
719 if ( PortSetup
.IxOn
)
720 PortP
->Config
|= RIO_IXON
;
722 PortP
->Config
&= ~RIO_IXON
;
725 ** If the port needs to wait for all a processes output
726 ** to drain before closing then this flag will be set.
728 if (PortSetup
.Drain
) {
729 PortP
->Config
|= RIO_WAITDRAIN
;
731 PortP
->Config
&= ~RIO_WAITDRAIN
;
734 ** Store settings if locking or unlocking port or if the
735 ** port is not locked, when setting the store option.
738 ((PortSetup
.Lock
&& !PortP
->Lock
) ||
740 (PortSetup
.Store
&& !PortP
->Store
)))) {
741 PortP
->StoredTty
.iflag
= PortP
->TtyP
->tm
.c_iflag
;
742 PortP
->StoredTty
.oflag
= PortP
->TtyP
->tm
.c_oflag
;
743 PortP
->StoredTty
.cflag
= PortP
->TtyP
->tm
.c_cflag
;
744 PortP
->StoredTty
.lflag
= PortP
->TtyP
->tm
.c_lflag
;
745 PortP
->StoredTty
.line
= PortP
->TtyP
->tm
.c_line
;
746 bcopy(PortP
->TtyP
->tm
.c_cc
, PortP
->StoredTty
.cc
,
749 PortP
->Lock
= PortSetup
.Lock
;
750 PortP
->Store
= PortSetup
.Store
;
751 PortP
->Xprint
.XpCps
= PortSetup
.XpCps
;
752 bcopy(PortSetup
.XpOn
,PortP
->Xprint
.XpOn
,MAX_XP_CTRL_LEN
);
753 bcopy(PortSetup
.XpOff
,PortP
->Xprint
.XpOff
,MAX_XP_CTRL_LEN
);
754 PortP
->Xprint
.XpOn
[MAX_XP_CTRL_LEN
-1] = '\0';
755 PortP
->Xprint
.XpOff
[MAX_XP_CTRL_LEN
-1] = '\0';
756 PortP
->Xprint
.XpLen
= RIOStrlen(PortP
->Xprint
.XpOn
)+
757 RIOStrlen(PortP
->Xprint
.XpOff
);
758 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
761 rio_dprintk (RIO_DEBUG_CTRL
, "after loop (%d)!\n", loop
);
762 rio_dprintk (RIO_DEBUG_CTRL
, "Retval:%x\n", retval
);
765 case RIO_GET_PORT_SETUP
:
766 rio_dprintk (RIO_DEBUG_CTRL
, "Get port setup\n");
767 if (copyin((int)arg
, (caddr_t
)&PortSetup
, sizeof(PortSetup
))
769 p
->RIOError
.Error
= COPYIN_FAILED
;
772 if ( PortSetup
.From
>= RIO_PORTS
) {
773 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
777 port
= PortSetup
.To
= PortSetup
.From
;
778 PortSetup
.IxAny
= (p
->RIOPortp
[port
]->Config
& RIO_IXANY
) ?
780 PortSetup
.IxOn
= (p
->RIOPortp
[port
]->Config
& RIO_IXON
) ?
782 PortSetup
.Drain
= (p
->RIOPortp
[port
]->Config
& RIO_WAITDRAIN
) ?
784 PortSetup
.Store
= p
->RIOPortp
[port
]->Store
;
785 PortSetup
.Lock
= p
->RIOPortp
[port
]->Lock
;
786 PortSetup
.XpCps
= p
->RIOPortp
[port
]->Xprint
.XpCps
;
787 bcopy(p
->RIOPortp
[port
]->Xprint
.XpOn
, PortSetup
.XpOn
,
789 bcopy(p
->RIOPortp
[port
]->Xprint
.XpOff
, PortSetup
.XpOff
,
791 PortSetup
.XpOn
[MAX_XP_CTRL_LEN
-1] = '\0';
792 PortSetup
.XpOff
[MAX_XP_CTRL_LEN
-1] = '\0';
794 if ( copyout((caddr_t
)&PortSetup
,(int)arg
,sizeof(PortSetup
))
796 p
->RIOError
.Error
= COPYOUT_FAILED
;
801 case RIO_GET_PORT_PARAMS
:
802 rio_dprintk (RIO_DEBUG_CTRL
, "Get port params\n");
803 if (copyin( (int)arg
, (caddr_t
)&PortParams
,
804 sizeof(struct PortParams
)) == COPYFAIL
) {
805 p
->RIOError
.Error
= COPYIN_FAILED
;
808 if (PortParams
.Port
>= RIO_PORTS
) {
809 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
812 PortP
= (p
->RIOPortp
[PortParams
.Port
]);
813 PortParams
.Config
= PortP
->Config
;
814 PortParams
.State
= PortP
->State
;
815 rio_dprintk (RIO_DEBUG_CTRL
, "Port %d\n", PortParams
.Port
);
817 if (copyout((caddr_t
)&PortParams
, (int)arg
,
818 sizeof(struct PortParams
)) == COPYFAIL
) {
819 p
->RIOError
.Error
= COPYOUT_FAILED
;
824 case RIO_GET_PORT_TTY
:
825 rio_dprintk (RIO_DEBUG_CTRL
, "Get port tty\n");
826 if (copyin((int)arg
, (caddr_t
)&PortTty
, sizeof(struct PortTty
))
828 p
->RIOError
.Error
= COPYIN_FAILED
;
831 if ( PortTty
.port
>= RIO_PORTS
) {
832 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
836 rio_dprintk (RIO_DEBUG_CTRL
, "Port %d\n", PortTty
.port
);
837 PortP
= (p
->RIOPortp
[PortTty
.port
]);
839 PortTty
.Tty
.tm
.c_iflag
= PortP
->TtyP
->tm
.c_iflag
;
840 PortTty
.Tty
.tm
.c_oflag
= PortP
->TtyP
->tm
.c_oflag
;
841 PortTty
.Tty
.tm
.c_cflag
= PortP
->TtyP
->tm
.c_cflag
;
842 PortTty
.Tty
.tm
.c_lflag
= PortP
->TtyP
->tm
.c_lflag
;
844 if (copyout((caddr_t
)&PortTty
, (int)arg
,
845 sizeof(struct PortTty
)) == COPYFAIL
) {
846 p
->RIOError
.Error
= COPYOUT_FAILED
;
851 case RIO_SET_PORT_TTY
:
852 if (copyin((int)arg
, (caddr_t
)&PortTty
,
853 sizeof(struct PortTty
)) == COPYFAIL
) {
854 p
->RIOError
.Error
= COPYIN_FAILED
;
857 rio_dprintk (RIO_DEBUG_CTRL
, "Set port %d tty\n", PortTty
.port
);
858 if (PortTty
.port
>= (ushort
) RIO_PORTS
) {
859 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
862 PortP
= (p
->RIOPortp
[PortTty
.port
]);
864 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
865 PortP
->TtyP
->tm
.c_iflag
= PortTty
.Tty
.tm
.c_iflag
;
866 PortP
->TtyP
->tm
.c_oflag
= PortTty
.Tty
.tm
.c_oflag
;
867 PortP
->TtyP
->tm
.c_cflag
= PortTty
.Tty
.tm
.c_cflag
;
868 PortP
->TtyP
->tm
.c_lflag
= PortTty
.Tty
.tm
.c_lflag
;
869 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
872 RIOParam(PortP
, CONFIG
, PortP
->State
& RIO_MODEM
, OK_TO_SLEEP
);
875 case RIO_SET_PORT_PARAMS
:
876 rio_dprintk (RIO_DEBUG_CTRL
, "Set port params\n");
877 if ( copyin((int)arg
, (caddr_t
)&PortParams
, sizeof(PortParams
))
879 p
->RIOError
.Error
= COPYIN_FAILED
;
882 if (PortParams
.Port
>= (ushort
) RIO_PORTS
) {
883 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
886 PortP
= (p
->RIOPortp
[PortParams
.Port
]);
887 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
888 PortP
->Config
= PortParams
.Config
;
889 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
892 case RIO_GET_PORT_STATS
:
893 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GET_PORT_STATS\n");
894 if ( copyin((int)arg
, (caddr_t
)&portStats
,
895 sizeof(struct portStats
)) == COPYFAIL
) {
896 p
->RIOError
.Error
= COPYIN_FAILED
;
899 if ( portStats
.port
>= RIO_PORTS
) {
900 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
903 PortP
= (p
->RIOPortp
[portStats
.port
]);
904 portStats
.gather
= PortP
->statsGather
;
905 portStats
.txchars
= PortP
->txchars
;
906 portStats
.rxchars
= PortP
->rxchars
;
907 portStats
.opens
= PortP
->opens
;
908 portStats
.closes
= PortP
->closes
;
909 portStats
.ioctls
= PortP
->ioctls
;
910 if ( copyout((caddr_t
)&portStats
, (int)arg
,
911 sizeof(struct portStats
)) == COPYFAIL
) {
912 p
->RIOError
.Error
= COPYOUT_FAILED
;
917 case RIO_RESET_PORT_STATS
:
919 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_RESET_PORT_STATS\n");
920 if ( port
>= RIO_PORTS
) {
921 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
924 PortP
= (p
->RIOPortp
[port
]);
925 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
931 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
934 case RIO_GATHER_PORT_STATS
:
935 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GATHER_PORT_STATS\n");
936 if ( copyin( (int)arg
, (caddr_t
)&portStats
,
937 sizeof(struct portStats
)) == COPYFAIL
) {
938 p
->RIOError
.Error
= COPYIN_FAILED
;
941 if ( portStats
.port
>= RIO_PORTS
) {
942 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
945 PortP
= (p
->RIOPortp
[portStats
.port
]);
946 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
947 PortP
->statsGather
= portStats
.gather
;
948 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
951 #ifdef DEBUG_SUPPORTED
952 case RIO_READ_LEVELS
:
955 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_READ_LEVELS\n");
956 for ( num
=0; RIODbInf
[num
].Flag
; num
++ ) ;
957 rio_dprintk (RIO_DEBUG_CTRL
, "%d levels to copy\n",num
);
958 if (copyout((caddr_t
)RIODbInf
,(int)arg
,
959 sizeof(struct DbInf
)*(num
+1))==COPYFAIL
) {
960 rio_dprintk (RIO_DEBUG_CTRL
, "ReadLevels Copy failed\n");
961 p
->RIOError
.Error
= COPYOUT_FAILED
;
964 rio_dprintk (RIO_DEBUG_CTRL
, "%d levels to copied\n",num
);
969 case RIO_READ_CONFIG
:
970 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_READ_CONFIG\n");
971 if (copyout((caddr_t
)&p
->RIOConf
, (int)arg
,
972 sizeof(struct Conf
)) ==COPYFAIL
) {
973 p
->RIOError
.Error
= COPYOUT_FAILED
;
979 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SET_CONFIG\n");
981 p
->RIOError
.Error
= NOT_SUPER_USER
;
984 if ( copyin((int)arg
, (caddr_t
)&p
->RIOConf
, sizeof(struct Conf
) )
986 p
->RIOError
.Error
= COPYIN_FAILED
;
990 ** move a few value around
992 for (Host
=0; Host
< p
->RIONumHosts
; Host
++)
993 if ( (p
->RIOHosts
[Host
].Flags
& RUN_STATE
) == RC_RUNNING
)
994 WWORD(p
->RIOHosts
[Host
].ParmMapP
->timer
,
998 case RIO_START_POLLER
:
999 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_START_POLLER\n");
1002 case RIO_STOP_POLLER
:
1003 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_STOP_POLLER\n");
1005 p
->RIOError
.Error
= NOT_SUPER_USER
;
1008 p
->RIOPolling
= NOT_POLLING
;
1013 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SETDEBUG/RIO_GETDEBUG\n");
1014 if ( copyin( (int)arg
, (caddr_t
)&DebugCtrl
, sizeof(DebugCtrl
) )
1016 p
->RIOError
.Error
= COPYIN_FAILED
;
1019 if ( DebugCtrl
.SysPort
== NO_PORT
) {
1020 if ( cmd
== RIO_SETDEBUG
) {
1022 p
->RIOError
.Error
= NOT_SUPER_USER
;
1025 p
->rio_debug
= DebugCtrl
.Debug
;
1026 p
->RIODebugWait
= DebugCtrl
.Wait
;
1027 rio_dprintk (RIO_DEBUG_CTRL
, "Set global debug to 0x%x set wait to 0x%x\n",
1028 p
->rio_debug
,p
->RIODebugWait
);
1031 rio_dprintk (RIO_DEBUG_CTRL
, "Get global debug 0x%x wait 0x%x\n",
1032 p
->rio_debug
,p
->RIODebugWait
);
1033 DebugCtrl
.Debug
= p
->rio_debug
;
1034 DebugCtrl
.Wait
= p
->RIODebugWait
;
1035 if ( copyout((caddr_t
)&DebugCtrl
,(int)arg
,
1036 sizeof(DebugCtrl
)) == COPYFAIL
) {
1037 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SET/GET DEBUG: bad port number %d\n",
1039 p
->RIOError
.Error
= COPYOUT_FAILED
;
1044 else if ( DebugCtrl
.SysPort
>= RIO_PORTS
&&
1045 DebugCtrl
.SysPort
!= NO_PORT
) {
1046 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SET/GET DEBUG: bad port number %d\n",
1048 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1051 else if ( cmd
== RIO_SETDEBUG
) {
1053 p
->RIOError
.Error
= NOT_SUPER_USER
;
1056 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1057 p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
= DebugCtrl
.Debug
;
1058 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1059 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SETDEBUG 0x%x\n",
1060 p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
);
1063 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GETDEBUG 0x%x\n",
1064 p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
);
1065 DebugCtrl
.Debug
= p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
;
1066 if ( copyout((caddr_t
)&DebugCtrl
,(int)arg
,
1067 sizeof(DebugCtrl
))==COPYFAIL
) {
1068 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_GETDEBUG: Bad copy to user space\n");
1069 p
->RIOError
.Error
= COPYOUT_FAILED
;
1077 ** Enquire about the release and version.
1078 ** We return MAX_VERSION_LEN bytes, being a
1079 ** textual null terminated string.
1081 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_VERSID\n");
1082 if ( copyout( (caddr_t
)RIOVersid(),
1084 sizeof(struct rioVersion
) ) == COPYFAIL
)
1086 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host
);
1087 p
->RIOError
.Error
= COPYOUT_FAILED
;
1093 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1094 ** !! commented out previous 'RIO_VERSID' functionality !!
1095 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1099 ** Enquire about the release and version.
1100 ** We return MAX_VERSION_LEN bytes, being a textual null
1101 ** terminated string.
1103 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
1104 if (copyout((caddr_t)RIOVersid(),
1105 (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
1106 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
1107 p->RIOError.Error = COPYOUT_FAILED;
1112 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1117 ** Enquire as to the number of hosts located
1120 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_NUM_HOSTS\n");
1121 if (copyout((caddr_t
)&p
->RIONumHosts
, (int)arg
,
1122 sizeof(p
->RIONumHosts
) )==COPYFAIL
) {
1123 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_NUM_HOSTS: Bad copy to user space\n");
1124 p
->RIOError
.Error
= COPYOUT_FAILED
;
1131 ** Kill host. This may not be in the final version...
1133 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_FOAD %d\n", (int)arg
);
1135 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_FOAD: Not super user\n");
1136 p
->RIOError
.Error
= NOT_SUPER_USER
;
1142 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ ) {
1143 (void)RIOBoardTest( p
->RIOHosts
[Host
].PaddrP
,
1144 p
->RIOHosts
[Host
].Caddr
, p
->RIOHosts
[Host
].Type
,
1145 p
->RIOHosts
[Host
].Slot
);
1146 bzero( (caddr_t
)&p
->RIOHosts
[Host
].Flags
,
1147 ((int)&p
->RIOHosts
[Host
].____end_marker____
) -
1148 ((int)&p
->RIOHosts
[Host
].Flags
) );
1149 p
->RIOHosts
[Host
].Flags
= RC_WAITING
;
1151 RIOSetupDataStructs(p
);
1155 p
->RIONumBootPkts
= 0;
1158 #ifdef RINGBUFFER_SUPPORT
1159 for( loop
=0; loop
<RIO_PORTS
; loop
++ )
1160 if ( p
->RIOPortp
[loop
]->TxRingBuffer
)
1161 sysfree((void *)p
->RIOPortp
[loop
]->TxRingBuffer
,
1165 bzero((caddr_t
)&p
->RIOPortp
[0],RIO_PORTS
*sizeof(struct Port
));
1167 printk ("HEEEEELP!\n");
1170 for( loop
=0; loop
<RIO_PORTS
; loop
++ ) {
1172 p
->RIOPortp
[loop
]->TtyP
= &p
->channel
[loop
];
1175 spin_lock_init(&p
->RIOPortp
[loop
]->portSem
);
1176 p
->RIOPortp
[loop
]->InUse
= NOT_INUSE
;
1183 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_DOWNLOAD\n");
1185 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_DOWNLOAD: Not super user\n");
1186 p
->RIOError
.Error
= NOT_SUPER_USER
;
1189 if ( copyin((int)arg
, (caddr_t
)&DownLoad
,
1190 sizeof(DownLoad
) )==COPYFAIL
) {
1191 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_DOWNLOAD: Copy in from user space failed\n");
1192 p
->RIOError
.Error
= COPYIN_FAILED
;
1195 rio_dprintk (RIO_DEBUG_CTRL
, "Copied in download code for product code 0x%x\n",
1196 DownLoad
.ProductCode
);
1199 ** It is important that the product code is an unsigned object!
1201 if ( DownLoad
.ProductCode
> MAX_PRODUCT
) {
1202 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_DOWNLOAD: Bad product code %d passed\n",
1203 DownLoad
.ProductCode
);
1204 p
->RIOError
.Error
= NO_SUCH_PRODUCT
;
1210 retval
= (*(RIOBootTable
[DownLoad
.ProductCode
]))(p
, &DownLoad
);
1214 ** and go back, content with a job well completed.
1222 if (copyin((int)arg
, (caddr_t
)&host
,
1223 sizeof(host
) ) == COPYFAIL
) {
1224 rio_dprintk (RIO_DEBUG_CTRL
,
1225 "RIO_HOST_REQ: Copy in from user space failed\n");
1226 p
->RIOError
.Error
= COPYIN_FAILED
;
1230 ** Fetch the parmmap
1232 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PARMS\n");
1233 if ( copyout( (caddr_t
)p
->RIOHosts
[host
].ParmMapP
,
1234 (int)arg
, sizeof(PARM_MAP
) )==COPYFAIL
) {
1235 p
->RIOError
.Error
= COPYOUT_FAILED
;
1236 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_PARMS: Copy out to user space failed\n");
1243 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_REQ\n");
1244 if (copyin((int)arg
, (caddr_t
)&HostReq
,
1245 sizeof(HostReq
) )==COPYFAIL
) {
1246 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_REQ: Copy in from user space failed\n");
1247 p
->RIOError
.Error
= COPYIN_FAILED
;
1250 if ( HostReq
.HostNum
>= p
->RIONumHosts
) {
1251 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1252 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_REQ: Illegal host number %d\n",
1256 rio_dprintk (RIO_DEBUG_CTRL
, "Request for host %d\n", HostReq
.HostNum
);
1258 if (copyout((caddr_t
)&p
->RIOHosts
[HostReq
.HostNum
],
1259 (int)HostReq
.HostP
,sizeof(struct Host
) ) == COPYFAIL
) {
1260 p
->RIOError
.Error
= COPYOUT_FAILED
;
1261 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_REQ: Bad copy to user space\n");
1266 case RIO_HOST_DPRAM
:
1267 rio_dprintk (RIO_DEBUG_CTRL
, "Request for DPRAM\n");
1268 if ( copyin( (int)arg
, (caddr_t
)&HostDpRam
,
1269 sizeof(HostDpRam
) )==COPYFAIL
) {
1270 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_DPRAM: Copy in from user space failed\n");
1271 p
->RIOError
.Error
= COPYIN_FAILED
;
1274 if ( HostDpRam
.HostNum
>= p
->RIONumHosts
) {
1275 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1276 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_DPRAM: Illegal host number %d\n",
1280 rio_dprintk (RIO_DEBUG_CTRL
, "Request for host %d\n", HostDpRam
.HostNum
);
1282 if (p
->RIOHosts
[HostDpRam
.HostNum
].Type
== RIO_PCI
) {
1284 /* It's hardware like this that really gets on my tits. */
1285 static unsigned char copy
[sizeof(struct DpRam
)];
1286 for ( off
=0; off
<sizeof(struct DpRam
); off
++ )
1287 copy
[off
] = p
->RIOHosts
[HostDpRam
.HostNum
].Caddr
[off
];
1288 if ( copyout( (caddr_t
)copy
, (int)HostDpRam
.DpRamP
,
1289 sizeof(struct DpRam
) ) == COPYFAIL
) {
1290 p
->RIOError
.Error
= COPYOUT_FAILED
;
1291 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_DPRAM: Bad copy to user space\n");
1295 else if (copyout((caddr_t
)p
->RIOHosts
[HostDpRam
.HostNum
].Caddr
,
1296 (int)HostDpRam
.DpRamP
,
1297 sizeof(struct DpRam
) ) == COPYFAIL
) {
1298 p
->RIOError
.Error
= COPYOUT_FAILED
;
1299 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_DPRAM: Bad copy to user space\n");
1305 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SET_BUSY\n");
1306 if ( (int)arg
< 0 || (int)arg
> 511 ) {
1307 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SET_BUSY: Bad port number %d\n",(int)arg
);
1308 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1311 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1312 p
->RIOPortp
[(int)arg
]->State
|= RIO_BUSY
;
1313 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1318 ** The daemon want port information
1319 ** (probably for debug reasons)
1321 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_PORT\n");
1322 if ( copyin((int)arg
, (caddr_t
)&PortReq
,
1323 sizeof(PortReq
) )==COPYFAIL
) {
1324 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_PORT: Copy in from user space failed\n");
1325 p
->RIOError
.Error
= COPYIN_FAILED
;
1329 if (PortReq
.SysPort
>= RIO_PORTS
) { /* SysPort is unsigned */
1330 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_PORT: Illegal port number %d\n",
1332 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1335 rio_dprintk (RIO_DEBUG_CTRL
, "Request for port %d\n", PortReq
.SysPort
);
1336 if (copyout((caddr_t
)p
->RIOPortp
[PortReq
.SysPort
],
1338 sizeof(struct Port
) ) == COPYFAIL
) {
1339 p
->RIOError
.Error
= COPYOUT_FAILED
;
1340 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_PORT: Bad copy to user space\n");
1347 ** The daemon want rup information
1348 ** (probably for debug reasons)
1350 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_RUP\n");
1351 if (copyin((int)arg
, (caddr_t
)&RupReq
,
1352 sizeof(RupReq
) )==COPYFAIL
) {
1353 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_RUP: Copy in from user space failed\n");
1354 p
->RIOError
.Error
= COPYIN_FAILED
;
1357 if (RupReq
.HostNum
>= p
->RIONumHosts
) { /* host is unsigned */
1358 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_RUP: Illegal host number %d\n",
1360 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1363 if ( RupReq
.RupNum
>= MAX_RUP
+LINKS_PER_UNIT
) { /* eek! */
1364 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_RUP: Illegal rup number %d\n",
1366 p
->RIOError
.Error
= RUP_NUMBER_OUT_OF_RANGE
;
1369 HostP
= &p
->RIOHosts
[RupReq
.HostNum
];
1371 if ((HostP
->Flags
& RUN_STATE
) != RC_RUNNING
) {
1372 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_RUP: Host %d not running\n",
1374 p
->RIOError
.Error
= HOST_NOT_RUNNING
;
1377 rio_dprintk (RIO_DEBUG_CTRL
, "Request for rup %d from host %d\n",
1378 RupReq
.RupNum
,RupReq
.HostNum
);
1380 if (copyout((caddr_t
)HostP
->UnixRups
[RupReq
.RupNum
].RupP
,
1381 (int)RupReq
.RupP
,sizeof(struct RUP
) ) == COPYFAIL
) {
1382 p
->RIOError
.Error
= COPYOUT_FAILED
;
1383 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_RUP: Bad copy to user space\n");
1390 ** The daemon want lpb information
1391 ** (probably for debug reasons)
1393 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_LPB\n");
1394 if (copyin((int)arg
, (caddr_t
)&LpbReq
,
1395 sizeof(LpbReq
) )==COPYFAIL
) {
1396 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_LPB: Bad copy from user space\n");
1397 p
->RIOError
.Error
= COPYIN_FAILED
;
1400 if (LpbReq
.Host
>= p
->RIONumHosts
) { /* host is unsigned */
1401 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_LPB: Illegal host number %d\n",
1403 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1406 if ( LpbReq
.Link
>= LINKS_PER_UNIT
) { /* eek! */
1407 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_LPB: Illegal link number %d\n",
1409 p
->RIOError
.Error
= LINK_NUMBER_OUT_OF_RANGE
;
1412 HostP
= &p
->RIOHosts
[LpbReq
.Host
];
1414 if ( (HostP
->Flags
& RUN_STATE
) != RC_RUNNING
) {
1415 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_LPB: Host %d not running\n",
1417 p
->RIOError
.Error
= HOST_NOT_RUNNING
;
1420 rio_dprintk (RIO_DEBUG_CTRL
, "Request for lpb %d from host %d\n",
1421 LpbReq
.Link
, LpbReq
.Host
);
1423 if (copyout((caddr_t
)&HostP
->LinkStrP
[LpbReq
.Link
],
1424 (int)LpbReq
.LpbP
,sizeof(struct LPB
) ) == COPYFAIL
) {
1425 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_HOST_LPB: Bad copy to user space\n");
1426 p
->RIOError
.Error
= COPYOUT_FAILED
;
1432 ** Here 3 IOCTL's that allow us to change the way in which
1433 ** rio logs errors. send them just to syslog or send them
1434 ** to both syslog and console or send them to just the console.
1436 ** See RioStrBuf() in util.c for the other half.
1438 case RIO_SYSLOG_ONLY
:
1439 p
->RIOPrintLogState
= PRINT_TO_LOG
; /* Just syslog */
1442 case RIO_SYSLOG_CONS
:
1443 p
->RIOPrintLogState
= PRINT_TO_LOG_CONS
;/* syslog and console */
1447 p
->RIOPrintLogState
= PRINT_TO_CONS
; /* Just console */
1450 case RIO_SIGNALS_ON
:
1451 if ( p
->RIOSignalProcess
) {
1452 p
->RIOError
.Error
= SIGNALS_ALREADY_SET
;
1455 p
->RIOSignalProcess
= getpid();
1456 p
->RIOPrintDisabled
= DONT_PRINT
;
1459 case RIO_SIGNALS_OFF
:
1460 if ( p
->RIOSignalProcess
!= getpid() ) {
1461 p
->RIOError
.Error
= NOT_RECEIVING_PROCESS
;
1464 rio_dprintk (RIO_DEBUG_CTRL
, "Clear signal process to zero\n");
1465 p
->RIOSignalProcess
= 0;
1468 case RIO_SET_BYTE_MODE
:
1469 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1470 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1471 p
->RIOHosts
[Host
].Mode
&= ~WORD_OPERATION
;
1474 case RIO_SET_WORD_MODE
:
1475 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1476 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1477 p
->RIOHosts
[Host
].Mode
|= WORD_OPERATION
;
1480 case RIO_SET_FAST_BUS
:
1481 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1482 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1483 p
->RIOHosts
[Host
].Mode
|= FAST_AT_BUS
;
1486 case RIO_SET_SLOW_BUS
:
1487 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1488 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1489 p
->RIOHosts
[Host
].Mode
&= ~FAST_AT_BUS
;
1492 case RIO_MAP_B50_TO_50
:
1493 case RIO_MAP_B50_TO_57600
:
1494 case RIO_MAP_B110_TO_110
:
1495 case RIO_MAP_B110_TO_115200
:
1496 rio_dprintk (RIO_DEBUG_CTRL
, "Baud rate mapping\n");
1498 if ( port
< 0 || port
> 511 ) {
1499 rio_dprintk (RIO_DEBUG_CTRL
, "Baud rate mapping: Bad port number %d\n", port
);
1500 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1503 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1506 case RIO_MAP_B50_TO_50
:
1507 p
->RIOPortp
[port
]->Config
|= RIO_MAP_50_TO_50
;
1509 case RIO_MAP_B50_TO_57600
:
1510 p
->RIOPortp
[port
]->Config
&= ~RIO_MAP_50_TO_50
;
1512 case RIO_MAP_B110_TO_110
:
1513 p
->RIOPortp
[port
]->Config
|= RIO_MAP_110_TO_110
;
1515 case RIO_MAP_B110_TO_115200
:
1516 p
->RIOPortp
[port
]->Config
&= ~RIO_MAP_110_TO_110
;
1519 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1522 case RIO_STREAM_INFO
:
1523 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_STREAM_INFO\n");
1526 case RIO_SEND_PACKET
:
1527 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SEND_PACKET\n");
1528 if ( copyin( (int)arg
, (caddr_t
)&SendPack
,
1529 sizeof(SendPack
) )==COPYFAIL
) {
1530 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_SEND_PACKET: Bad copy from user space\n");
1531 p
->RIOError
.Error
= COPYIN_FAILED
;
1534 if ( SendPack
.PortNum
>= 128 ) {
1535 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1539 PortP
= p
->RIOPortp
[SendPack
.PortNum
];
1540 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1542 if ( !can_add_transmit(&PacketP
,PortP
) ) {
1543 p
->RIOError
.Error
= UNIT_IS_IN_USE
;
1544 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1548 for ( loop
=0; loop
<(ushort
)(SendPack
.Len
& 127); loop
++ )
1549 WBYTE(PacketP
->data
[loop
], SendPack
.Data
[loop
] );
1551 WBYTE(PacketP
->len
, SendPack
.Len
);
1553 add_transmit( PortP
);
1555 ** Count characters transmitted for port statistics reporting
1557 if (PortP
->statsGather
)
1558 PortP
->txchars
+= (SendPack
.Len
& 127);
1559 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1564 p
->RIONoMessage
= 1;
1565 return su
? 0 : -EPERM
;
1569 p
->RIONoMessage
= 0;
1570 return su
? 0 : -EPERM
;
1573 if ( copyout( (caddr_t
)&p
->RIONoMessage
, (int)arg
,
1574 sizeof(p
->RIONoMessage
) )==COPYFAIL
) {
1575 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_WHAT_MESG: Bad copy to user space\n");
1576 p
->RIOError
.Error
= COPYOUT_FAILED
;
1582 if (copyin((int)arg
, (caddr_t
)&SubCmd
,
1583 sizeof(struct SubCmdStruct
)) == COPYFAIL
) {
1584 p
->RIOError
.Error
= COPYIN_FAILED
;
1587 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_MEM_DUMP host %d rup %d addr %x\n",
1588 SubCmd
.Host
, SubCmd
.Rup
, SubCmd
.Addr
);
1590 if (SubCmd
.Rup
>= MAX_RUP
+LINKS_PER_UNIT
) {
1591 p
->RIOError
.Error
= RUP_NUMBER_OUT_OF_RANGE
;
1595 if (SubCmd
.Host
>= p
->RIONumHosts
) {
1596 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1600 port
= p
->RIOHosts
[SubCmd
.Host
].
1601 UnixRups
[SubCmd
.Rup
].BaseSysPort
;
1603 PortP
= p
->RIOPortp
[port
];
1605 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1607 if ( RIOPreemptiveCmd(p
, PortP
, MEMDUMP
) == RIO_FAIL
) {
1608 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_MEM_DUMP failed\n");
1609 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1613 PortP
->State
|= RIO_BUSY
;
1615 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1616 if ( copyout( (caddr_t
)p
->RIOMemDump
, (int)arg
,
1617 MEMDUMP_SIZE
) == COPYFAIL
) {
1618 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_MEM_DUMP copy failed\n");
1619 p
->RIOError
.Error
= COPYOUT_FAILED
;
1625 if ((int)arg
< 0 || (int)arg
>= p
->RIONumHosts
)
1627 rio_dprintk (RIO_DEBUG_CTRL
, "Set interrupt for host %d\n", (int)arg
);
1628 WBYTE(p
->RIOHosts
[(int)arg
].SetInt
, 0xff);
1632 if ((int)arg
< 0 || (int)arg
>= p
->RIONumHosts
)
1634 rio_dprintk (RIO_DEBUG_CTRL
, "Clear interrupt for host %d\n", (int)arg
);
1635 WBYTE((p
->RIOHosts
[(int)arg
].ResetInt
) , 0xff);
1638 case RIO_READ_CHECK
:
1639 /* Check reads for pkts with data[0] the same */
1640 p
->RIOReadCheck
= !p
->RIOReadCheck
;
1641 if (copyout((caddr_t
)&p
->RIOReadCheck
,(int)arg
,
1642 sizeof(uint
))== COPYFAIL
) {
1643 p
->RIOError
.Error
= COPYOUT_FAILED
;
1648 case RIO_READ_REGISTER
:
1649 if (copyin((int)arg
, (caddr_t
)&SubCmd
,
1650 sizeof(struct SubCmdStruct
)) == COPYFAIL
) {
1651 p
->RIOError
.Error
= COPYIN_FAILED
;
1654 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_READ_REGISTER host %d rup %d port %d reg %x\n",
1655 SubCmd
.Host
, SubCmd
.Rup
, SubCmd
.Port
, SubCmd
.Addr
);
1657 if (SubCmd
.Port
> 511) {
1658 rio_dprintk (RIO_DEBUG_CTRL
, "Baud rate mapping: Bad port number %d\n",
1660 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1664 if (SubCmd
.Rup
>= MAX_RUP
+LINKS_PER_UNIT
) {
1665 p
->RIOError
.Error
= RUP_NUMBER_OUT_OF_RANGE
;
1669 if (SubCmd
.Host
>= p
->RIONumHosts
) {
1670 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1674 port
= p
->RIOHosts
[SubCmd
.Host
].
1675 UnixRups
[SubCmd
.Rup
].BaseSysPort
+ SubCmd
.Port
;
1676 PortP
= p
->RIOPortp
[port
];
1678 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1680 if (RIOPreemptiveCmd(p
, PortP
, READ_REGISTER
) == RIO_FAIL
) {
1681 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_READ_REGISTER failed\n");
1682 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1686 PortP
->State
|= RIO_BUSY
;
1688 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1689 if (copyout((caddr_t
)&p
->CdRegister
, (int)arg
,
1690 sizeof(uint
)) == COPYFAIL
) {
1691 rio_dprintk (RIO_DEBUG_CTRL
, "RIO_READ_REGISTER copy failed\n");
1692 p
->RIOError
.Error
= COPYOUT_FAILED
;
1697 ** rio_make_dev: given port number (0-511) ORed with port type
1698 ** (RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT) return dev_t
1699 ** value to pass to mknod to create the correct device node.
1703 uint port
= (uint
)arg
& RIO_MODEM_MASK
;
1705 switch ( (uint
)arg
& RIO_DEV_MASK
) {
1706 case RIO_DEV_DIRECT
:
1707 arg
= (caddr_t
)drv_makedev(MAJOR(dev
), port
);
1708 rio_dprintk (RIO_DEBUG_CTRL
, "Makedev direct 0x%x is 0x%x\n",port
, (int)arg
);
1711 arg
= (caddr_t
)drv_makedev(MAJOR(dev
), (port
|RIO_MODEM_BIT
) );
1712 rio_dprintk (RIO_DEBUG_CTRL
, "Makedev modem 0x%x is 0x%x\n",port
, (int)arg
);
1714 case RIO_DEV_XPRINT
:
1715 arg
= (caddr_t
)drv_makedev(MAJOR(dev
), port
);
1716 rio_dprintk (RIO_DEBUG_CTRL
, "Makedev printer 0x%x is 0x%x\n",port
, (int)arg
);
1719 rio_dprintk (RIO_DEBUG_CTRL
, "MAKE Device is called\n");
1723 ** rio_minor: given a dev_t from a stat() call, return
1724 ** the port number (0-511) ORed with the port type
1725 ** ( RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT )
1732 dv
= (dev_t
)((int)arg
);
1733 mino
= RIO_UNMODEM(dv
);
1735 if ( RIO_ISMODEM(dv
) ) {
1736 rio_dprintk (RIO_DEBUG_CTRL
, "Minor for device 0x%x: modem %d\n", dv
, mino
);
1737 arg
= (caddr_t
)(mino
| RIO_DEV_MODEM
);
1740 rio_dprintk (RIO_DEBUG_CTRL
, "Minor for device 0x%x: direct %d\n", dv
, mino
);
1741 arg
= (caddr_t
)(mino
| RIO_DEV_DIRECT
);
1746 rio_dprintk (RIO_DEBUG_CTRL
, "INVALID DAEMON IOCTL 0x%x\n",cmd
);
1747 p
->RIOError
.Error
= IOCTL_COMMAND_UNKNOWN
;
1754 ** Pre-emptive commands go on RUPs and are only one byte long.
1757 RIOPreemptiveCmd(p
, PortP
, Cmd
)
1758 struct rio_info
* p
;
1762 struct CmdBlk
*CmdBlkP
;
1763 struct PktCmd_M
*PktCmdP
;
1769 CheckPortP( PortP
);
1772 if ( PortP
->State
& RIO_DELETED
) {
1773 rio_dprintk (RIO_DEBUG_CTRL
, "Preemptive command to deleted RTA ignored\n");
1777 if (((int)((char)PortP
->InUse
) == -1) || ! (CmdBlkP
= RIOGetCmdBlk()) ) {
1778 rio_dprintk (RIO_DEBUG_CTRL
, "Cannot allocate command block for command %d on port %d\n",
1779 Cmd
, PortP
->PortNum
);
1783 rio_dprintk (RIO_DEBUG_CTRL
, "Command blk 0x%x - InUse now %d\n",
1784 (int)CmdBlkP
,PortP
->InUse
);
1786 PktCmdP
= (struct PktCmd_M
*)&CmdBlkP
->Packet
.data
[0];
1788 CmdBlkP
->Packet
.src_unit
= 0;
1789 if (PortP
->SecondBlock
)
1792 rup
= PortP
->RupNum
;
1793 CmdBlkP
->Packet
.dest_unit
= rup
;
1794 CmdBlkP
->Packet
.src_port
= COMMAND_RUP
;
1795 CmdBlkP
->Packet
.dest_port
= COMMAND_RUP
;
1796 CmdBlkP
->Packet
.len
= PKT_CMD_BIT
| 2;
1797 CmdBlkP
->PostFuncP
= RIOUnUse
;
1798 CmdBlkP
->PostArg
= (int)PortP
;
1799 PktCmdP
->Command
= Cmd
;
1800 port
= PortP
->HostPort
% (ushort
)PORTS_PER_RTA
;
1802 ** Index ports 8-15 for 2nd block of 16 port RTA.
1804 if (PortP
->SecondBlock
)
1805 port
+= (ushort
) PORTS_PER_RTA
;
1806 PktCmdP
->PhbNum
= port
;
1810 rio_dprintk (RIO_DEBUG_CTRL
, "Queue MEMDUMP command blk 0x%x (addr 0x%x)\n",
1811 (int)CmdBlkP
, (int)SubCmd
.Addr
);
1812 PktCmdP
->SubCommand
= MEMDUMP
;
1813 PktCmdP
->SubAddr
= SubCmd
.Addr
;
1816 rio_dprintk (RIO_DEBUG_CTRL
, "Queue FCLOSE command blk 0x%x\n",(int)CmdBlkP
);
1819 rio_dprintk (RIO_DEBUG_CTRL
, "Queue READ_REGISTER (0x%x) command blk 0x%x\n",
1820 (int)SubCmd
.Addr
, (int)CmdBlkP
);
1821 PktCmdP
->SubCommand
= READ_REGISTER
;
1822 PktCmdP
->SubAddr
= SubCmd
.Addr
;
1825 rio_dprintk (RIO_DEBUG_CTRL
, "Queue RESUME command blk 0x%x\n",(int)CmdBlkP
);
1828 rio_dprintk (RIO_DEBUG_CTRL
, "Queue RFLUSH command blk 0x%x\n",(int)CmdBlkP
);
1829 CmdBlkP
->PostFuncP
= RIORFlushEnable
;
1832 rio_dprintk (RIO_DEBUG_CTRL
, "Queue SUSPEND command blk 0x%x\n",(int)CmdBlkP
);
1836 rio_dprintk (RIO_DEBUG_CTRL
, "Queue MGET command blk 0x%x\n", (int)CmdBlkP
);
1842 CmdBlkP
->Packet
.data
[4] = (char) PortP
->ModemLines
;
1843 rio_dprintk (RIO_DEBUG_CTRL
, "Queue MSET/MBIC/MBIS command blk 0x%x\n", (int)CmdBlkP
);
1848 ** If we have queued up the maximum number of Write flushes
1849 ** allowed then we should not bother sending any more to the
1852 if ((int)((char)PortP
->WflushFlag
) == (int)-1) {
1853 rio_dprintk (RIO_DEBUG_CTRL
, "Trashed WFLUSH, WflushFlag about to wrap!");
1854 RIOFreeCmdBlk(CmdBlkP
);
1857 rio_dprintk (RIO_DEBUG_CTRL
, "Queue WFLUSH command blk 0x%x\n",
1859 CmdBlkP
->PostFuncP
= RIOWFlushMark
;
1866 Ret
= RIOQueueCmdBlk( PortP
->HostP
, rup
, CmdBlkP
);