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 #define __NO_VERSION__
38 #include <linux/module.h>
39 #include <linux/malloc.h>
40 #include <linux/errno.h>
42 #include <asm/system.h>
43 #include <asm/string.h>
44 #include <asm/semaphore.h>
45 #include <asm/uaccess.h>
47 #include <linux/termios.h>
48 #include <linux/serial.h>
50 #include <linux/compatmac.h>
51 #include <linux/generic_serial.h>
54 #include "linux_compat.h"
55 #include "rio_linux.h"
87 static struct LpbReq LpbReq
;
88 static struct RupReq RupReq
;
89 static struct PortReq PortReq
;
90 static struct HostReq HostReq
;
91 static struct HostDpRam HostDpRam
;
92 static struct DebugCtrl DebugCtrl
;
93 static struct Map MapEnt
;
94 static struct PortSetup PortSetup
;
95 static struct DownLoad DownLoad
;
96 static struct SendPack SendPack
;
97 /* static struct StreamInfo StreamInfo; */
98 /* static char modemtable[RIO_PORTS]; */
99 static struct SpecialRupCmd SpecialRupCmd
;
100 static struct PortParams PortParams
;
101 static struct portStats portStats
;
103 static struct SubCmdStruct
{
112 struct ttystatics Tty
;
115 static struct PortTty PortTty
;
116 typedef struct ttystatics TERMIO
;
119 ** This table is used when the config.rio downloads bin code to the
120 ** driver. We index the table using the product code, 0-F, and call
121 ** the function pointed to by the entry, passing the information
123 ** The RIOBootCodeUNKNOWN entry is there to politely tell the calling
124 ** process to bog off.
127 (*RIOBootTable
[MAX_PRODUCT
])(struct rio_info
*, struct DownLoad
*) =
129 /* 0 */ RIOBootCodeHOST
, /* Host Card */
130 /* 1 */ RIOBootCodeRTA
, /* RTA */
133 #define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff))
136 int copyin (int arg
, caddr_t dp
, int siz
)
140 rio_dprint (RIO_DEBUG_CTRL
, ("Copying %d bytes from user %p to %p.\n", siz
, (void *) arg
, dp
));
141 rv
= copy_from_user (dp
, (void *)arg
, siz
);
142 if (rv
< 0) return COPYFAIL
;
147 int copyout (caddr_t dp
, int arg
, int siz
)
151 rio_dprint (RIO_DEBUG_CTRL
, ("Copying %d bytes to user %p from %p.\n", siz
, (void *) arg
, dp
));
152 rv
= copy_to_user ((void *)arg
, dp
, siz
);
153 if (rv
< 0) return COPYFAIL
;
165 if (rbounds ((unsigned long) arg
) >= siz
) {
166 bcopy ( arg
, dp
, siz
);
173 copyout (dp
, arg
, siz
)
178 if (wbounds ((unsigned long) arg
) >= siz
) {
179 bcopy ( dp
, arg
, siz
);
187 riocontrol(p
, dev
, cmd
, arg
, su
)
194 uint Host
; /* leave me unsigned! */
195 uint port
; /* and me! */
204 /* Confuse teh compiler to think that we've initialized these */
208 rio_dprint(RIO_DEBUG_CTRL
, ("control ioctl cmd: 0x%x arg: 0x%x\n", cmd
, (int)arg
));
214 ** Change the value of the host card interrupt timer.
215 ** If the host card number is -1 then all host cards are changed
216 ** otherwise just the specified host card will be changed.
219 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SET_TIMER to %dms\n", (uint
)arg
));
222 host
= (uint
)arg
>> 16;
223 value
= (uint
)arg
& 0x0000ffff;
225 for (host
= 0; host
< p
->RIONumHosts
; host
++) {
226 if (p
->RIOHosts
[host
].Flags
== RC_RUNNING
) {
227 WWORD(p
->RIOHosts
[host
].ParmMapP
->timer
, value
);
230 } else if (host
>= p
->RIONumHosts
) {
233 if ( p
->RIOHosts
[host
].Flags
== RC_RUNNING
) {
234 WWORD(p
->RIOHosts
[host
].ParmMapP
->timer
, value
);
240 case RIO_IDENTIFY_DRIVER
:
242 ** 15.10.1998 ARG - ESIL 0760 part fix
243 ** Added driver ident string output.
245 #ifndef __THIS_RELEASE__
246 #warning Driver Version string not defined !
248 cprintf("%s %s %s %s\n",
251 __DATE__, __TIME__ );
255 case RIO_DISPLAY_HOST_CFG:
257 ** 15.10.1998 ARG - ESIL 0760 part fix
258 ** Added driver host card ident string output.
260 ** Note that the only types currently supported
261 ** are ISA and PCI. Also this driver does not
262 ** (yet) distinguish between the Old PCI card
263 ** and the Jet PCI card. In fact I think this
264 ** driver only supports JET PCI !
267 for (Host = 0; Host < p->RIONumHosts; Host++)
269 HostP = &(p->RIOHosts[Host]);
271 switch ( HostP->Type )
274 strcpy( host_type, RIO_AT_HOST_STR );
278 strcpy( host_type, RIO_PCI_HOST_STR );
282 strcpy( host_type, "Unknown" );
287 "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
290 (int)HostP->Ivec - 32 );
297 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_FOAD_RTA\n"));
298 return RIOCommandRta(p
, (uint
)arg
, RIOFoadRta
);
301 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_ZOMBIE_RTA\n"));
302 return RIOCommandRta(p
, (uint
)arg
, RIOZombieRta
);
304 case RIO_IDENTIFY_RTA
:
305 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_IDENTIFY_RTA\n"));
306 return RIOIdentifyRta(p
, arg
);
308 case RIO_KILL_NEIGHBOUR
:
309 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_KILL_NEIGHBOUR\n"));
310 return RIOKillNeighbour(p
, arg
);
312 case SPECIAL_RUP_CMD
:
314 struct CmdBlk
*CmdBlkP
;
316 rio_dprint(RIO_DEBUG_CTRL
, ("SPECIAL_RUP_CMD\n"));
317 if (copyin((int)arg
, (caddr_t
)&SpecialRupCmd
,
318 sizeof(SpecialRupCmd
)) == COPYFAIL
) {
319 rio_dprint(RIO_DEBUG_CTRL
, ("SPECIAL_RUP_CMD copy failed\n"));
320 p
->RIOError
.Error
= COPYIN_FAILED
;
323 CmdBlkP
= RIOGetCmdBlk();
325 rio_dprint(RIO_DEBUG_CTRL
, ("SPECIAL_RUP_CMD GetCmdBlk failed\n"));
328 CmdBlkP
->Packet
= SpecialRupCmd
.Packet
;
329 if ( SpecialRupCmd
.Host
>= p
->RIONumHosts
)
330 SpecialRupCmd
.Host
= 0;
331 rio_dprint(RIO_DEBUG_CTRL
, ("Queue special rup command for host %d rup %d\n",
332 SpecialRupCmd
.Host
, SpecialRupCmd
.RupNum
));
333 if (RIOQueueCmdBlk(&p
->RIOHosts
[SpecialRupCmd
.Host
],
334 SpecialRupCmd
.RupNum
, CmdBlkP
) == RIO_FAIL
) {
335 cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n");
341 #ifdef DEBUG_MEM_SUPPORT
342 RIO_DEBUG_CTRL
, if (su
)
343 return rio_RIODebugMemory(RIO_DEBUG_CTRL
, arg
);
349 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_ALL_MODEM\n"));
350 p
->RIOError
.Error
= IOCTL_COMMAND_UNKNOWN
;
355 ** Read the routing table from the device driver to user space
357 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_TABLE\n"));
359 if ((retval
= RIOApel(p
)) != 0)
362 if (copyout((caddr_t
)p
->RIOConnectTable
, (int)arg
,
363 TOTAL_MAP_ENTRIES
*sizeof(struct Map
)) == COPYFAIL
) {
364 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_TABLE copy failed\n"));
365 p
->RIOError
.Error
= COPYOUT_FAILED
;
371 rio_dprint(RIO_DEBUG_CTRL
, ("*****\nMAP ENTRIES\n") );
372 for ( entry
=0; entry
<TOTAL_MAP_ENTRIES
; entry
++ )
374 if ((p
->RIOConnectTable
[entry
].ID
== 0) &&
375 (p
->RIOConnectTable
[entry
].HostUniqueNum
== 0) &&
376 (p
->RIOConnectTable
[entry
].RtaUniqueNum
== 0)) continue;
378 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.HostUniqueNum = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].HostUniqueNum
) );
379 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.RtaUniqueNum = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].RtaUniqueNum
) );
380 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.ID = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].ID
) );
381 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.ID2 = 0x%x\n", entry
, p
->RIOConnectTable
[entry
].ID2
) );
382 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Flags = 0x%x\n", entry
, (int)p
->RIOConnectTable
[entry
].Flags
) );
383 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.SysPort = 0x%x\n", entry
, (int)p
->RIOConnectTable
[entry
].SysPort
) );
384 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[0].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[0].Unit
) );
385 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[0].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[0].Link
) );
386 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[1].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[1].Unit
) );
387 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[1].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[1].Link
) );
388 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[2].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[2].Unit
) );
389 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[2].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[2].Link
) );
390 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[3].Unit = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[3].Unit
) );
391 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Top[4].Link = %x\n", entry
, p
->RIOConnectTable
[entry
].Topology
[3].Link
) );
392 rio_dprint(RIO_DEBUG_CTRL
, ("Map entry %d.Name = %s\n", entry
, p
->RIOConnectTable
[entry
].Name
) );
394 rio_dprint(RIO_DEBUG_CTRL
, ("*****\nEND MAP ENTRIES\n") );
396 p
->RIOQuickCheck
= NOT_CHANGED
; /* a table has been gotten */
401 ** Write the routing table to the device driver from user space
403 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PUT_TABLE\n"));
406 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PUT_TABLE !Root\n"));
407 p
->RIOError
.Error
= NOT_SUPER_USER
;
410 if ( copyin((int)arg
, (caddr_t
)&p
->RIOConnectTable
[0],
411 TOTAL_MAP_ENTRIES
*sizeof(struct Map
) ) == COPYFAIL
) {
412 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PUT_TABLE copy failed\n"));
413 p
->RIOError
.Error
= COPYIN_FAILED
;
417 ***********************************
420 rio_dprint(RIO_DEBUG_CTRL, ("*****\nMAP ENTRIES\n") );
421 for ( entry=0; entry<TOTAL_MAP_ENTRIES; entry++ )
423 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.HostUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].HostUniqueNum ) );
424 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.RtaUniqueNum = 0x%x\n", entry, p->RIOConnectTable[entry].RtaUniqueNum ) );
425 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.ID = 0x%x\n", entry, p->RIOConnectTable[entry].ID ) );
426 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.ID2 = 0x%x\n", entry, p->RIOConnectTable[entry].ID2 ) );
427 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Flags = 0x%x\n", entry, p->RIOConnectTable[entry].Flags ) );
428 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.SysPort = 0x%x\n", entry, p->RIOConnectTable[entry].SysPort ) );
429 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[0].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[0].Unit ) );
430 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[0].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[0].Link ) );
431 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[1].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[1].Unit ) );
432 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[1].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[1].Link ) );
433 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[2].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[2].Unit ) );
434 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[2].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[2].Link ) );
435 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[3].Unit = %b\n", entry, p->RIOConnectTable[entry].Topology[3].Unit ) );
436 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Top[4].Link = %b\n", entry, p->RIOConnectTable[entry].Topology[3].Link ) );
437 rio_dprint(RIO_DEBUG_CTRL, ("Map entry %d.Name = %s\n", entry, p->RIOConnectTable[entry].Name ) );
439 rio_dprint(RIO_DEBUG_CTRL, ("*****\nEND MAP ENTRIES\n") );
441 ***********************************
443 return RIONewTable(p
);
445 case RIO_GET_BINDINGS
:
447 ** Send bindings table, containing unique numbers of RTAs owned
448 ** by this system to user space
450 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_BINDINGS\n"));
454 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_BINDINGS !Root\n"));
455 p
->RIOError
.Error
= NOT_SUPER_USER
;
458 if (copyout((caddr_t
) p
->RIOBindTab
, (int)arg
,
459 (sizeof(ulong
) * MAX_RTA_BINDINGS
)) == COPYFAIL
) {
460 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_BINDINGS copy failed\n"));
461 p
->RIOError
.Error
= COPYOUT_FAILED
;
466 case RIO_PUT_BINDINGS
:
468 ** Receive a bindings table, containing unique numbers of RTAs owned
471 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PUT_BINDINGS\n"));
475 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PUT_BINDINGS !Root\n"));
476 p
->RIOError
.Error
= NOT_SUPER_USER
;
479 if (copyin((int)arg
, (caddr_t
)&p
->RIOBindTab
[0],
480 (sizeof(ulong
) * MAX_RTA_BINDINGS
))==COPYFAIL
) {
481 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PUT_BINDINGS copy failed\n"));
482 p
->RIOError
.Error
= COPYIN_FAILED
;
491 ** Bind this RTA to host, so that it will be booted by
492 ** host in 'boot owned RTAs' mode.
494 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_BIND_RTA\n"));
497 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_BIND_RTA !Root\n"));
498 p
->RIOError
.Error
= NOT_SUPER_USER
;
501 for (Entry
= 0; Entry
< MAX_RTA_BINDINGS
; Entry
++) {
502 if ((EmptySlot
== -1) && (p
->RIOBindTab
[Entry
] == 0L))
504 else if (p
->RIOBindTab
[Entry
] == (int) arg
) {
506 ** Already exists - delete
508 p
->RIOBindTab
[Entry
] = 0L;
509 rio_dprint(RIO_DEBUG_CTRL
, ("Removing Rta %x from p->RIOBindTab\n",
515 ** Dosen't exist - add
517 if (EmptySlot
!= -1) {
518 p
->RIOBindTab
[EmptySlot
] = (int) arg
;
519 rio_dprint(RIO_DEBUG_CTRL
, ("Adding Rta %x to p->RIOBindTab\n",
523 rio_dprint(RIO_DEBUG_CTRL
, ("p->RIOBindTab full! - Rta %x not added\n",
531 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_RESUME\n"));
533 if ((port
< 0) || (port
> 511)) {
534 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_RESUME: Bad port number %d\n", port
));
535 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
538 PortP
= p
->RIOPortp
[port
];
539 if (!PortP
->Mapped
) {
540 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_RESUME: Port %d not mapped\n", port
));
541 p
->RIOError
.Error
= PORT_NOT_MAPPED_INTO_SYSTEM
;
544 if (!(PortP
->State
& (RIO_LOPEN
| RIO_MOPEN
))) {
545 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_RESUME: Port %d not open\n", port
));
549 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
550 if (RIOPreemptiveCmd(p
, (p
->RIOPortp
[port
]), RESUME
) ==
552 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_RESUME failed\n"));
553 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
557 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_RESUME: Port %d resumed\n", port
));
558 PortP
->State
|= RIO_BUSY
;
560 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
564 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_ASSIGN_RTA\n"));
566 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_ASSIGN_RTA !Root\n"));
567 p
->RIOError
.Error
= NOT_SUPER_USER
;
570 if (copyin((int)arg
, (caddr_t
)&MapEnt
, sizeof(MapEnt
))
572 rio_dprint(RIO_DEBUG_CTRL
, ("Copy from user space failed\n"));
573 p
->RIOError
.Error
= COPYIN_FAILED
;
576 return RIOAssignRta(p
, &MapEnt
);
578 case RIO_CHANGE_NAME
:
579 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_CHANGE_NAME\n"));
581 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_CHANGE_NAME !Root\n"));
582 p
->RIOError
.Error
= NOT_SUPER_USER
;
585 if (copyin((int)arg
, (caddr_t
)&MapEnt
, sizeof(MapEnt
))
587 rio_dprint(RIO_DEBUG_CTRL
, ("Copy from user space failed\n"));
588 p
->RIOError
.Error
= COPYIN_FAILED
;
591 return RIOChangeName(p
, &MapEnt
);
594 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_DELETE_RTA\n"));
596 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_DELETE_RTA !Root\n"));
597 p
->RIOError
.Error
= NOT_SUPER_USER
;
600 if (copyin((int)arg
, (caddr_t
)&MapEnt
, sizeof(MapEnt
))
602 rio_dprint(RIO_DEBUG_CTRL
, ("Copy from data space failed\n"));
603 p
->RIOError
.Error
= COPYIN_FAILED
;
606 return RIODeleteRta(p
, &MapEnt
);
608 case RIO_QUICK_CHECK
:
610 ** 09.12.1998 ARG - ESIL 0776 part fix
611 ** A customer was using this to get the RTAs
612 ** connect/disconnect status.
613 ** RIOConCon() had been botched use RIOHalted
614 ** to keep track of RTA connections and
615 ** disconnections. That has been changed and
616 ** RIORtaDisCons in the rio_info struct now
617 ** does the job. So we need to return the value
618 ** of RIORtaCons instead of RIOHalted.
620 if (copyout((caddr_t)&p->RIOHalted,(int)arg,
621 sizeof(uint))==COPYFAIL) {
625 if (copyout((caddr_t
)&p
->RIORtaDisCons
,(int)arg
,
626 sizeof(uint
))==COPYFAIL
) {
627 p
->RIOError
.Error
= COPYOUT_FAILED
;
633 if (copyout((caddr_t
)&p
->RIOError
, (int)arg
,
634 sizeof(struct Error
)) ==COPYFAIL
)
639 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_LOG\n"));
647 case RIO_GET_MODTYPE
:
648 if ( copyin( (int)arg
, (caddr_t
)&port
,
649 sizeof(uint
)) == COPYFAIL
)
651 p
->RIOError
.Error
= COPYIN_FAILED
;
654 rio_dprint(RIO_DEBUG_CTRL
, ("Get module type for port %d\n", port
));
655 if ( port
< 0 || port
> 511 )
657 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_MODTYPE: Bad port number %d\n", port
));
658 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
661 PortP
= (p
->RIOPortp
[port
]);
664 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_MODTYPE: Port %d not mapped\n", port
));
665 p
->RIOError
.Error
= PORT_NOT_MAPPED_INTO_SYSTEM
;
669 ** Return module type of port
671 port
= PortP
->HostP
->UnixRups
[PortP
->RupNum
].ModTypes
;
672 if (copyout((caddr_t
)&port
, (int)arg
,
673 sizeof(uint
)) == COPYFAIL
) {
674 p
->RIOError
.Error
= COPYOUT_FAILED
;
679 ** 02.03.1999 ARG - ESIL 0820 fix
680 ** We are no longer using "Boot Mode", so these ioctls
681 ** are not required :
683 case RIO_GET_BOOT_MODE :
684 rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
686 ** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
688 if (copyout((caddr_t)&p->RIOBootMode, (int)arg,
689 sizeof(p->RIOBootMode)) == COPYFAIL) {
690 p->RIOError.Error = COPYOUT_FAILED;
695 case RIO_SET_BOOT_MODE :
696 p->RIOBootMode = (uint) arg;
697 rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
703 case RIO_BLOCK_OPENS
:
704 rio_dprint(RIO_DEBUG_CTRL
, ("Opens block until booted\n"));
705 for ( Entry
=0; Entry
< RIO_PORTS
; Entry
++ ) {
706 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
707 p
->RIOPortp
[Entry
]->WaitUntilBooted
= 1;
708 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
712 case RIO_SETUP_PORTS
:
713 rio_dprint(RIO_DEBUG_CTRL
, ("Setup ports\n"));
714 if (copyin((int)arg
, (caddr_t
)&PortSetup
, sizeof(PortSetup
))
716 p
->RIOError
.Error
= COPYIN_FAILED
;
717 rio_dprint(RIO_DEBUG_CTRL
, ("EFAULT"));
720 if ( PortSetup
.From
> PortSetup
.To
||
721 PortSetup
.To
>= RIO_PORTS
) {
722 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
723 rio_dprint(RIO_DEBUG_CTRL
, ("ENXIO"));
726 if ( PortSetup
.XpCps
> p
->RIOConf
.MaxXpCps
||
727 PortSetup
.XpCps
< p
->RIOConf
.MinXpCps
) {
728 p
->RIOError
.Error
= XPRINT_CPS_OUT_OF_RANGE
;
729 rio_dprint(RIO_DEBUG_CTRL
, ("EINVAL"));
732 if ( !p
->RIOPortp
) {
733 cprintf("No p->RIOPortp array!\n");
734 rio_dprint(RIO_DEBUG_CTRL
, ("No p->RIOPortp array!\n"));
737 rio_dprint(RIO_DEBUG_CTRL
, ("entering loop (%d %d)!\n", PortSetup
.From
, PortSetup
.To
));
738 for (loop
=PortSetup
.From
; loop
<=PortSetup
.To
; loop
++) {
739 rio_dprint(RIO_DEBUG_CTRL
, ("in loop (%d)!\n", loop
));
741 PortP
= p
->RIOPortp
[loop
];
743 PortP
->TtyP
= &p
->channel
[loop
];
745 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
746 if ( PortSetup
.IxAny
)
747 PortP
->Config
|= RIO_IXANY
;
749 PortP
->Config
&= ~RIO_IXANY
;
750 if ( PortSetup
.IxOn
)
751 PortP
->Config
|= RIO_IXON
;
753 PortP
->Config
&= ~RIO_IXON
;
756 ** If the port needs to wait for all a processes output
757 ** to drain before closing then this flag will be set.
759 if (PortSetup
.Drain
) {
760 PortP
->Config
|= RIO_WAITDRAIN
;
762 PortP
->Config
&= ~RIO_WAITDRAIN
;
765 ** Store setings if locking or unlocking port or if the
766 ** port is not locked, when setting the store option.
769 ((PortSetup
.Lock
&& !PortP
->Lock
) ||
771 (PortSetup
.Store
&& !PortP
->Store
)))) {
772 PortP
->StoredTty
.iflag
= PortP
->TtyP
->tm
.c_iflag
;
773 PortP
->StoredTty
.oflag
= PortP
->TtyP
->tm
.c_oflag
;
774 PortP
->StoredTty
.cflag
= PortP
->TtyP
->tm
.c_cflag
;
775 PortP
->StoredTty
.lflag
= PortP
->TtyP
->tm
.c_lflag
;
776 PortP
->StoredTty
.line
= PortP
->TtyP
->tm
.c_line
;
777 bcopy(PortP
->TtyP
->tm
.c_cc
, PortP
->StoredTty
.cc
,
780 PortP
->Lock
= PortSetup
.Lock
;
781 PortP
->Store
= PortSetup
.Store
;
782 PortP
->Xprint
.XpCps
= PortSetup
.XpCps
;
783 bcopy(PortSetup
.XpOn
,PortP
->Xprint
.XpOn
,MAX_XP_CTRL_LEN
);
784 bcopy(PortSetup
.XpOff
,PortP
->Xprint
.XpOff
,MAX_XP_CTRL_LEN
);
785 PortP
->Xprint
.XpOn
[MAX_XP_CTRL_LEN
-1] = '\0';
786 PortP
->Xprint
.XpOff
[MAX_XP_CTRL_LEN
-1] = '\0';
787 PortP
->Xprint
.XpLen
= RIOStrlen(PortP
->Xprint
.XpOn
)+
788 RIOStrlen(PortP
->Xprint
.XpOff
);
789 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
792 rio_dprint(RIO_DEBUG_CTRL
, ("after loop (%d)!\n", loop
));
793 rio_dprint(RIO_DEBUG_CTRL
, ("Retval:%x\n", retval
) );
796 case RIO_GET_PORT_SETUP
:
797 rio_dprint(RIO_DEBUG_CTRL
, ("Get port setup\n"));
798 if (copyin((int)arg
, (caddr_t
)&PortSetup
, sizeof(PortSetup
))
800 p
->RIOError
.Error
= COPYIN_FAILED
;
803 if ( PortSetup
.From
>= RIO_PORTS
) {
804 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
808 port
= PortSetup
.To
= PortSetup
.From
;
809 PortSetup
.IxAny
= (p
->RIOPortp
[port
]->Config
& RIO_IXANY
) ?
811 PortSetup
.IxOn
= (p
->RIOPortp
[port
]->Config
& RIO_IXON
) ?
813 PortSetup
.Drain
= (p
->RIOPortp
[port
]->Config
& RIO_WAITDRAIN
) ?
815 PortSetup
.Store
= p
->RIOPortp
[port
]->Store
;
816 PortSetup
.Lock
= p
->RIOPortp
[port
]->Lock
;
817 PortSetup
.XpCps
= p
->RIOPortp
[port
]->Xprint
.XpCps
;
818 bcopy(p
->RIOPortp
[port
]->Xprint
.XpOn
, PortSetup
.XpOn
,
820 bcopy(p
->RIOPortp
[port
]->Xprint
.XpOff
, PortSetup
.XpOff
,
822 PortSetup
.XpOn
[MAX_XP_CTRL_LEN
-1] = '\0';
823 PortSetup
.XpOff
[MAX_XP_CTRL_LEN
-1] = '\0';
825 if ( copyout((caddr_t
)&PortSetup
,(int)arg
,sizeof(PortSetup
))
827 p
->RIOError
.Error
= COPYOUT_FAILED
;
832 case RIO_GET_PORT_PARAMS
:
833 rio_dprint(RIO_DEBUG_CTRL
, ("Get port params\n"));
834 if (copyin( (int)arg
, (caddr_t
)&PortParams
,
835 sizeof(struct PortParams
)) == COPYFAIL
) {
836 p
->RIOError
.Error
= COPYIN_FAILED
;
839 if (PortParams
.Port
>= RIO_PORTS
) {
840 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
843 PortP
= (p
->RIOPortp
[PortParams
.Port
]);
844 PortParams
.Config
= PortP
->Config
;
845 PortParams
.State
= PortP
->State
;
846 rio_dprint(RIO_DEBUG_CTRL
, ("Port %d\n", PortParams
.Port
));
848 if (copyout((caddr_t
)&PortParams
, (int)arg
,
849 sizeof(struct PortParams
)) == COPYFAIL
) {
850 p
->RIOError
.Error
= COPYOUT_FAILED
;
855 case RIO_GET_PORT_TTY
:
856 rio_dprint(RIO_DEBUG_CTRL
, ("Get port tty\n"));
857 if (copyin((int)arg
, (caddr_t
)&PortTty
, sizeof(struct PortTty
))
859 p
->RIOError
.Error
= COPYIN_FAILED
;
862 if ( PortTty
.port
>= RIO_PORTS
) {
863 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
867 rio_dprint(RIO_DEBUG_CTRL
, ("Port %d\n", PortTty
.port
));
868 PortP
= (p
->RIOPortp
[PortTty
.port
]);
870 PortTty
.Tty
.tm
.c_iflag
= PortP
->TtyP
->tm
.c_iflag
;
871 PortTty
.Tty
.tm
.c_oflag
= PortP
->TtyP
->tm
.c_oflag
;
872 PortTty
.Tty
.tm
.c_cflag
= PortP
->TtyP
->tm
.c_cflag
;
873 PortTty
.Tty
.tm
.c_lflag
= PortP
->TtyP
->tm
.c_lflag
;
875 if (copyout((caddr_t
)&PortTty
, (int)arg
,
876 sizeof(struct PortTty
)) == COPYFAIL
) {
877 p
->RIOError
.Error
= COPYOUT_FAILED
;
882 case RIO_SET_PORT_TTY
:
883 if (copyin((int)arg
, (caddr_t
)&PortTty
,
884 sizeof(struct PortTty
)) == COPYFAIL
) {
885 p
->RIOError
.Error
= COPYIN_FAILED
;
888 rio_dprint(RIO_DEBUG_CTRL
, ("Set port %d tty\n", PortTty
.port
));
889 if (PortTty
.port
>= (ushort
) RIO_PORTS
) {
890 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
893 PortP
= (p
->RIOPortp
[PortTty
.port
]);
895 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
896 PortP
->TtyP
->tm
.c_iflag
= PortTty
.Tty
.tm
.c_iflag
;
897 PortP
->TtyP
->tm
.c_oflag
= PortTty
.Tty
.tm
.c_oflag
;
898 PortP
->TtyP
->tm
.c_cflag
= PortTty
.Tty
.tm
.c_cflag
;
899 PortP
->TtyP
->tm
.c_lflag
= PortTty
.Tty
.tm
.c_lflag
;
900 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
903 RIOParam(PortP
, CONFIG
, PortP
->State
& RIO_MODEM
, OK_TO_SLEEP
);
906 case RIO_SET_PORT_PARAMS
:
907 rio_dprint(RIO_DEBUG_CTRL
, ("Set port params\n"));
908 if ( copyin((int)arg
, (caddr_t
)&PortParams
, sizeof(PortParams
))
910 p
->RIOError
.Error
= COPYIN_FAILED
;
913 if (PortParams
.Port
>= (ushort
) RIO_PORTS
) {
914 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
917 PortP
= (p
->RIOPortp
[PortParams
.Port
]);
918 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
919 PortP
->Config
= PortParams
.Config
;
920 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
923 case RIO_GET_PORT_STATS
:
924 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GET_PORT_STATS\n"));
925 if ( copyin((int)arg
, (caddr_t
)&portStats
,
926 sizeof(struct portStats
)) == COPYFAIL
) {
927 p
->RIOError
.Error
= COPYIN_FAILED
;
930 if ( portStats
.port
>= RIO_PORTS
) {
931 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
934 PortP
= (p
->RIOPortp
[portStats
.port
]);
935 portStats
.gather
= PortP
->statsGather
;
936 portStats
.txchars
= PortP
->txchars
;
937 portStats
.rxchars
= PortP
->rxchars
;
938 portStats
.opens
= PortP
->opens
;
939 portStats
.closes
= PortP
->closes
;
940 portStats
.ioctls
= PortP
->ioctls
;
941 if ( copyout((caddr_t
)&portStats
, (int)arg
,
942 sizeof(struct portStats
)) == COPYFAIL
) {
943 p
->RIOError
.Error
= COPYOUT_FAILED
;
948 case RIO_RESET_PORT_STATS
:
950 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_RESET_PORT_STATS\n"));
951 if ( port
>= RIO_PORTS
) {
952 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
955 PortP
= (p
->RIOPortp
[port
]);
956 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
962 rio_spin_unlock_irqrestore(&PortP
->portSem
, flags
);
965 case RIO_GATHER_PORT_STATS
:
966 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GATHER_PORT_STATS\n"));
967 if ( copyin( (int)arg
, (caddr_t
)&portStats
,
968 sizeof(struct portStats
)) == COPYFAIL
) {
969 p
->RIOError
.Error
= COPYIN_FAILED
;
972 if ( portStats
.port
>= RIO_PORTS
) {
973 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
976 PortP
= (p
->RIOPortp
[portStats
.port
]);
977 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
978 PortP
->statsGather
= portStats
.gather
;
979 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
982 #ifdef DEBUG_SUPPORTED
983 case RIO_READ_LEVELS
:
986 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_READ_LEVELS\n"));
987 for ( num
=0; RIODbInf
[num
].Flag
; num
++ ) ;
988 rio_dprint(RIO_DEBUG_CTRL
, ("%d levels to copy\n",num
));
989 if (copyout((caddr_t
)RIODbInf
,(int)arg
,
990 sizeof(struct DbInf
)*(num
+1))==COPYFAIL
) {
991 rio_dprint(RIO_DEBUG_CTRL
, ("ReadLevels Copy failed\n"));
992 p
->RIOError
.Error
= COPYOUT_FAILED
;
995 rio_dprint(RIO_DEBUG_CTRL
, ("%d levels to copied\n",num
));
1000 case RIO_READ_CONFIG
:
1001 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_READ_CONFIG\n"));
1002 if (copyout((caddr_t
)&p
->RIOConf
, (int)arg
,
1003 sizeof(struct Conf
)) ==COPYFAIL
) {
1004 p
->RIOError
.Error
= COPYOUT_FAILED
;
1009 case RIO_SET_CONFIG
:
1010 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SET_CONFIG\n"));
1012 p
->RIOError
.Error
= NOT_SUPER_USER
;
1015 if ( copyin((int)arg
, (caddr_t
)&p
->RIOConf
, sizeof(struct Conf
) )
1017 p
->RIOError
.Error
= COPYIN_FAILED
;
1021 ** move a few value around
1023 for (Host
=0; Host
< p
->RIONumHosts
; Host
++)
1024 if ( (p
->RIOHosts
[Host
].Flags
& RUN_STATE
) == RC_RUNNING
)
1025 WWORD(p
->RIOHosts
[Host
].ParmMapP
->timer
,
1029 case RIO_START_POLLER
:
1030 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_START_POLLER\n"));
1033 case RIO_STOP_POLLER
:
1034 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_STOP_POLLER\n"));
1036 p
->RIOError
.Error
= NOT_SUPER_USER
;
1039 p
->RIOPolling
= NOT_POLLING
;
1044 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SETDEBUG/RIO_GETDEBUG\n"));
1045 if ( copyin( (int)arg
, (caddr_t
)&DebugCtrl
, sizeof(DebugCtrl
) )
1047 p
->RIOError
.Error
= COPYIN_FAILED
;
1050 if ( DebugCtrl
.SysPort
== NO_PORT
) {
1051 if ( cmd
== RIO_SETDEBUG
) {
1053 p
->RIOError
.Error
= NOT_SUPER_USER
;
1056 p
->rio_debug
= DebugCtrl
.Debug
;
1057 p
->RIODebugWait
= DebugCtrl
.Wait
;
1058 rio_dprint(RIO_DEBUG_CTRL
, ("Set global debug to 0x%x set wait to 0x%x\n",
1059 p
->rio_debug
,p
->RIODebugWait
));
1062 rio_dprint(RIO_DEBUG_CTRL
, ("Get global debug 0x%x wait 0x%x\n",
1063 p
->rio_debug
,p
->RIODebugWait
));
1064 DebugCtrl
.Debug
= p
->rio_debug
;
1065 DebugCtrl
.Wait
= p
->RIODebugWait
;
1066 if ( copyout((caddr_t
)&DebugCtrl
,(int)arg
,
1067 sizeof(DebugCtrl
)) == COPYFAIL
) {
1068 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SET/GET DEBUG: bad port number %d\n",
1069 DebugCtrl
.SysPort
));
1070 p
->RIOError
.Error
= COPYOUT_FAILED
;
1075 else if ( DebugCtrl
.SysPort
>= RIO_PORTS
&&
1076 DebugCtrl
.SysPort
!= NO_PORT
) {
1077 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SET/GET DEBUG: bad port number %d\n",
1078 DebugCtrl
.SysPort
));
1079 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1082 else if ( cmd
== RIO_SETDEBUG
) {
1084 p
->RIOError
.Error
= NOT_SUPER_USER
;
1087 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1088 p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
= DebugCtrl
.Debug
;
1089 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1090 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SETDEBUG 0x%x\n",
1091 p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
));
1094 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GETDEBUG 0x%x\n",
1095 p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
));
1096 DebugCtrl
.Debug
= p
->RIOPortp
[DebugCtrl
.SysPort
]->Debug
;
1097 if ( copyout((caddr_t
)&DebugCtrl
,(int)arg
,
1098 sizeof(DebugCtrl
))==COPYFAIL
) {
1099 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_GETDEBUG: Bad copy to user space\n"));
1100 p
->RIOError
.Error
= COPYOUT_FAILED
;
1108 ** Enquire about the release and version.
1109 ** We return MAX_VERSION_LEN bytes, being a
1110 ** textual null terminated string.
1112 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_VERSID\n") );
1113 if ( copyout( (caddr_t
)RIOVersid(),
1115 sizeof(struct rioVersion
) ) == COPYFAIL
)
1117 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_VERSID: Bad copy to user space (host=%d)\n",Host
) );
1118 p
->RIOError
.Error
= COPYOUT_FAILED
;
1124 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1125 ** !! commented out previous 'RIO_VERSID' functionality !!
1126 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1130 ** Enquire about the release and version.
1131 ** We return MAX_VERSION_LEN bytes, being a textual null
1132 ** terminated string.
1134 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
1135 if (copyout((caddr_t)RIOVersid(),
1136 (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
1137 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
1138 p->RIOError.Error = COPYOUT_FAILED;
1143 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1148 ** Enquire as to the number of hosts located
1151 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_NUM_HOSTS\n"));
1152 if (copyout((caddr_t
)&p
->RIONumHosts
, (int)arg
,
1153 sizeof(p
->RIONumHosts
) )==COPYFAIL
) {
1154 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_NUM_HOSTS: Bad copy to user space\n"));
1155 p
->RIOError
.Error
= COPYOUT_FAILED
;
1162 ** Kill host. This may not be in the final version...
1164 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_FOAD %d\n", (int)arg
));
1166 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_FOAD: Not super user\n"));
1167 p
->RIOError
.Error
= NOT_SUPER_USER
;
1173 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ ) {
1174 (void)RIOBoardTest( p
->RIOHosts
[Host
].PaddrP
,
1175 p
->RIOHosts
[Host
].Caddr
, p
->RIOHosts
[Host
].Type
,
1176 p
->RIOHosts
[Host
].Slot
);
1177 bzero( (caddr_t
)&p
->RIOHosts
[Host
].Flags
,
1178 ((int)&p
->RIOHosts
[Host
].____end_marker____
) -
1179 ((int)&p
->RIOHosts
[Host
].Flags
) );
1180 p
->RIOHosts
[Host
].Flags
= RC_WAITING
;
1182 RIOSetupDataStructs(p
);
1186 p
->RIONumBootPkts
= 0;
1189 #ifdef RINGBUFFER_SUPPORT
1190 for( loop
=0; loop
<RIO_PORTS
; loop
++ )
1191 if ( p
->RIOPortp
[loop
]->TxRingBuffer
)
1192 sysfree((void *)p
->RIOPortp
[loop
]->TxRingBuffer
,
1196 bzero((caddr_t
)&p
->RIOPortp
[0],RIO_PORTS
*sizeof(struct Port
));
1198 printk ("HEEEEELP!\n");
1201 for( loop
=0; loop
<RIO_PORTS
; loop
++ ) {
1203 p
->RIOPortp
[loop
]->TtyP
= &p
->channel
[loop
];
1206 p
->RIOPortp
[loop
]->portSem
= SPIN_LOCK_UNLOCKED
;
1207 p
->RIOPortp
[loop
]->InUse
= NOT_INUSE
;
1214 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_DOWNLOAD\n"));
1216 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_DOWNLOAD: Not super user\n"));
1217 p
->RIOError
.Error
= NOT_SUPER_USER
;
1220 if ( copyin((int)arg
, (caddr_t
)&DownLoad
,
1221 sizeof(DownLoad
) )==COPYFAIL
) {
1222 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_DOWNLOAD: Copy in from user space failed\n"));
1223 p
->RIOError
.Error
= COPYIN_FAILED
;
1226 rio_dprint(RIO_DEBUG_CTRL
, ("Copied in download code for product code 0x%x\n",
1227 DownLoad
.ProductCode
) );
1230 ** It is important that the product code is an unsigned object!
1232 if ( DownLoad
.ProductCode
> MAX_PRODUCT
) {
1233 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_DOWNLOAD: Bad product code %d passed\n",
1234 DownLoad
.ProductCode
));
1235 p
->RIOError
.Error
= NO_SUCH_PRODUCT
;
1241 retval
= (*(RIOBootTable
[DownLoad
.ProductCode
]))(p
, &DownLoad
);
1245 ** and go back, content with a job well completed.
1253 if (copyin((int)arg
, (caddr_t
)&host
,
1254 sizeof(host
) ) == COPYFAIL
) {
1255 rio_dprint(RIO_DEBUG_CTRL
, (
1256 "RIO_HOST_REQ: Copy in from user space failed\n"));
1257 p
->RIOError
.Error
= COPYIN_FAILED
;
1261 ** Fetch the parmmap
1263 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PARMS\n"));
1264 if ( copyout( (caddr_t
)p
->RIOHosts
[host
].ParmMapP
,
1265 (int)arg
, sizeof(PARM_MAP
) )==COPYFAIL
) {
1266 p
->RIOError
.Error
= COPYOUT_FAILED
;
1267 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_PARMS: Copy out to user space failed\n"));
1274 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_REQ\n"));
1275 if (copyin((int)arg
, (caddr_t
)&HostReq
,
1276 sizeof(HostReq
) )==COPYFAIL
) {
1277 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_REQ: Copy in from user space failed\n"));
1278 p
->RIOError
.Error
= COPYIN_FAILED
;
1281 if ( HostReq
.HostNum
>= p
->RIONumHosts
) {
1282 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1283 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_REQ: Illegal host number %d\n",
1287 rio_dprint(RIO_DEBUG_CTRL
, ("Request for host %d\n", HostReq
.HostNum
));
1289 if (copyout((caddr_t
)&p
->RIOHosts
[HostReq
.HostNum
],
1290 (int)HostReq
.HostP
,sizeof(struct Host
) ) == COPYFAIL
) {
1291 p
->RIOError
.Error
= COPYOUT_FAILED
;
1292 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_REQ: Bad copy to user space\n"));
1297 case RIO_HOST_DPRAM
:
1298 rio_dprint(RIO_DEBUG_CTRL
, ("Request for DPRAM\n"));
1299 if ( copyin( (int)arg
, (caddr_t
)&HostDpRam
,
1300 sizeof(HostDpRam
) )==COPYFAIL
) {
1301 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_DPRAM: Copy in from user space failed\n"));
1302 p
->RIOError
.Error
= COPYIN_FAILED
;
1305 if ( HostDpRam
.HostNum
>= p
->RIONumHosts
) {
1306 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1307 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_DPRAM: Illegal host number %d\n",
1308 HostDpRam
.HostNum
));
1311 rio_dprint(RIO_DEBUG_CTRL
, ("Request for host %d\n", HostDpRam
.HostNum
));
1313 if (p
->RIOHosts
[HostDpRam
.HostNum
].Type
== RIO_PCI
) {
1315 /* It's hardware like this that really gets on my tits. */
1316 static unsigned char copy
[sizeof(struct DpRam
)];
1317 for ( off
=0; off
<sizeof(struct DpRam
); off
++ )
1318 copy
[off
] = p
->RIOHosts
[HostDpRam
.HostNum
].Caddr
[off
];
1319 if ( copyout( (caddr_t
)copy
, (int)HostDpRam
.DpRamP
,
1320 sizeof(struct DpRam
) ) == COPYFAIL
) {
1321 p
->RIOError
.Error
= COPYOUT_FAILED
;
1322 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_DPRAM: Bad copy to user space\n"));
1326 else if (copyout((caddr_t
)p
->RIOHosts
[HostDpRam
.HostNum
].Caddr
,
1327 (int)HostDpRam
.DpRamP
,
1328 sizeof(struct DpRam
) ) == COPYFAIL
) {
1329 p
->RIOError
.Error
= COPYOUT_FAILED
;
1330 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_DPRAM: Bad copy to user space\n"));
1336 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SET_BUSY\n"));
1337 if ( (int)arg
< 0 || (int)arg
> 511 ) {
1338 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SET_BUSY: Bad port number %d\n",(int)arg
));
1339 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1342 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1343 p
->RIOPortp
[(int)arg
]->State
|= RIO_BUSY
;
1344 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1349 ** The daemon want port information
1350 ** (probably for debug reasons)
1352 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_PORT\n"));
1353 if ( copyin((int)arg
, (caddr_t
)&PortReq
,
1354 sizeof(PortReq
) )==COPYFAIL
) {
1355 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_PORT: Copy in from user space failed\n"));
1356 p
->RIOError
.Error
= COPYIN_FAILED
;
1360 if (PortReq
.SysPort
>= RIO_PORTS
) { /* SysPort is unsigned */
1361 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_PORT: Illegal port number %d\n",
1363 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1366 rio_dprint(RIO_DEBUG_CTRL
, ("Request for port %d\n", PortReq
.SysPort
));
1367 if (copyout((caddr_t
)p
->RIOPortp
[PortReq
.SysPort
],
1369 sizeof(struct Port
) ) == COPYFAIL
) {
1370 p
->RIOError
.Error
= COPYOUT_FAILED
;
1371 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_PORT: Bad copy to user space\n"));
1378 ** The daemon want rup information
1379 ** (probably for debug reasons)
1381 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_RUP\n"));
1382 if (copyin((int)arg
, (caddr_t
)&RupReq
,
1383 sizeof(RupReq
) )==COPYFAIL
) {
1384 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_RUP: Copy in from user space failed\n"));
1385 p
->RIOError
.Error
= COPYIN_FAILED
;
1388 if (RupReq
.HostNum
>= p
->RIONumHosts
) { /* host is unsigned */
1389 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_RUP: Illegal host number %d\n",
1391 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1394 if ( RupReq
.RupNum
>= MAX_RUP
+LINKS_PER_UNIT
) { /* eek! */
1395 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_RUP: Illegal rup number %d\n",
1397 p
->RIOError
.Error
= RUP_NUMBER_OUT_OF_RANGE
;
1400 HostP
= &p
->RIOHosts
[RupReq
.HostNum
];
1402 if ((HostP
->Flags
& RUN_STATE
) != RC_RUNNING
) {
1403 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_RUP: Host %d not running\n",
1405 p
->RIOError
.Error
= HOST_NOT_RUNNING
;
1408 rio_dprint(RIO_DEBUG_CTRL
, ("Request for rup %d from host %d\n",
1409 RupReq
.RupNum
,RupReq
.HostNum
));
1411 if (copyout((caddr_t
)HostP
->UnixRups
[RupReq
.RupNum
].RupP
,
1412 (int)RupReq
.RupP
,sizeof(struct RUP
) ) == COPYFAIL
) {
1413 p
->RIOError
.Error
= COPYOUT_FAILED
;
1414 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_RUP: Bad copy to user space\n"));
1421 ** The daemon want lpb information
1422 ** (probably for debug reasons)
1424 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_LPB\n"));
1425 if (copyin((int)arg
, (caddr_t
)&LpbReq
,
1426 sizeof(LpbReq
) )==COPYFAIL
) {
1427 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_LPB: Bad copy from user space\n"));
1428 p
->RIOError
.Error
= COPYIN_FAILED
;
1431 if (LpbReq
.Host
>= p
->RIONumHosts
) { /* host is unsigned */
1432 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_LPB: Illegal host number %d\n",
1434 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1437 if ( LpbReq
.Link
>= LINKS_PER_UNIT
) { /* eek! */
1438 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_LPB: Illegal link number %d\n",
1440 p
->RIOError
.Error
= LINK_NUMBER_OUT_OF_RANGE
;
1443 HostP
= &p
->RIOHosts
[LpbReq
.Host
];
1445 if ( (HostP
->Flags
& RUN_STATE
) != RC_RUNNING
) {
1446 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_LPB: Host %d not running\n",
1448 p
->RIOError
.Error
= HOST_NOT_RUNNING
;
1451 rio_dprint(RIO_DEBUG_CTRL
, ("Request for lpb %d from host %d\n",
1452 LpbReq
.Link
, LpbReq
.Host
));
1454 if (copyout((caddr_t
)&HostP
->LinkStrP
[LpbReq
.Link
],
1455 (int)LpbReq
.LpbP
,sizeof(struct LPB
) ) == COPYFAIL
) {
1456 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_HOST_LPB: Bad copy to user space\n"));
1457 p
->RIOError
.Error
= COPYOUT_FAILED
;
1463 ** Here 3 IOCTL's that allow us to change the way in which
1464 ** rio logs errors. send them just to syslog or send them
1465 ** to both syslog and console or send them to just the console.
1467 ** See RioStrBuf() in util.c for the other half.
1469 case RIO_SYSLOG_ONLY
:
1470 p
->RIOPrintLogState
= PRINT_TO_LOG
; /* Just syslog */
1473 case RIO_SYSLOG_CONS
:
1474 p
->RIOPrintLogState
= PRINT_TO_LOG_CONS
;/* syslog and console */
1478 p
->RIOPrintLogState
= PRINT_TO_CONS
; /* Just console */
1481 case RIO_SIGNALS_ON
:
1482 if ( p
->RIOSignalProcess
) {
1483 p
->RIOError
.Error
= SIGNALS_ALREADY_SET
;
1486 p
->RIOSignalProcess
= getpid();
1487 p
->RIOPrintDisabled
= DONT_PRINT
;
1490 case RIO_SIGNALS_OFF
:
1491 if ( p
->RIOSignalProcess
!= getpid() ) {
1492 p
->RIOError
.Error
= NOT_RECEIVING_PROCESS
;
1495 rio_dprint(RIO_DEBUG_CTRL
, ("Clear signal process to zero\n"));
1496 p
->RIOSignalProcess
= 0;
1499 case RIO_SET_BYTE_MODE
:
1500 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1501 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1502 p
->RIOHosts
[Host
].Mode
&= ~WORD_OPERATION
;
1505 case RIO_SET_WORD_MODE
:
1506 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1507 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1508 p
->RIOHosts
[Host
].Mode
|= WORD_OPERATION
;
1511 case RIO_SET_FAST_BUS
:
1512 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1513 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1514 p
->RIOHosts
[Host
].Mode
|= FAST_AT_BUS
;
1517 case RIO_SET_SLOW_BUS
:
1518 for ( Host
=0; Host
<p
->RIONumHosts
; Host
++ )
1519 if ( p
->RIOHosts
[Host
].Type
== RIO_AT
)
1520 p
->RIOHosts
[Host
].Mode
&= ~FAST_AT_BUS
;
1523 case RIO_MAP_B50_TO_50
:
1524 case RIO_MAP_B50_TO_57600
:
1525 case RIO_MAP_B110_TO_110
:
1526 case RIO_MAP_B110_TO_115200
:
1527 rio_dprint(RIO_DEBUG_CTRL
, ("Baud rate mapping\n"));
1529 if ( port
< 0 || port
> 511 ) {
1530 rio_dprint(RIO_DEBUG_CTRL
, ("Baud rate mapping: Bad port number %d\n", port
));
1531 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1534 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1537 case RIO_MAP_B50_TO_50
:
1538 p
->RIOPortp
[port
]->Config
|= RIO_MAP_50_TO_50
;
1540 case RIO_MAP_B50_TO_57600
:
1541 p
->RIOPortp
[port
]->Config
&= ~RIO_MAP_50_TO_50
;
1543 case RIO_MAP_B110_TO_110
:
1544 p
->RIOPortp
[port
]->Config
|= RIO_MAP_110_TO_110
;
1546 case RIO_MAP_B110_TO_115200
:
1547 p
->RIOPortp
[port
]->Config
&= ~RIO_MAP_110_TO_110
;
1550 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1553 case RIO_STREAM_INFO
:
1554 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_STREAM_INFO\n"));
1557 case RIO_SEND_PACKET
:
1558 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SEND_PACKET\n"));
1559 if ( copyin( (int)arg
, (caddr_t
)&SendPack
,
1560 sizeof(SendPack
) )==COPYFAIL
) {
1561 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_SEND_PACKET: Bad copy from user space\n"));
1562 p
->RIOError
.Error
= COPYIN_FAILED
;
1565 if ( SendPack
.PortNum
>= 128 ) {
1566 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1570 PortP
= p
->RIOPortp
[SendPack
.PortNum
];
1571 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1573 if ( !can_add_transmit(&PacketP
,PortP
) ) {
1574 p
->RIOError
.Error
= UNIT_IS_IN_USE
;
1575 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1579 for ( loop
=0; loop
<(ushort
)(SendPack
.Len
& 127); loop
++ )
1580 WBYTE(PacketP
->data
[loop
], SendPack
.Data
[loop
] );
1582 WBYTE(PacketP
->len
, SendPack
.Len
);
1584 add_transmit( PortP
);
1586 ** Count characters transmitted for port statistics reporting
1588 if (PortP
->statsGather
)
1589 PortP
->txchars
+= (SendPack
.Len
& 127);
1590 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1595 p
->RIONoMessage
= 1;
1596 return su
? 0 : EPERM
;
1600 p
->RIONoMessage
= 0;
1601 return su
? 0 : EPERM
;
1604 if ( copyout( (caddr_t
)&p
->RIONoMessage
, (int)arg
,
1605 sizeof(p
->RIONoMessage
) )==COPYFAIL
) {
1606 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_WHAT_MESG: Bad copy to user space\n"));
1607 p
->RIOError
.Error
= COPYOUT_FAILED
;
1613 if (copyin((int)arg
, (caddr_t
)&SubCmd
,
1614 sizeof(struct SubCmdStruct
)) == COPYFAIL
) {
1615 p
->RIOError
.Error
= COPYIN_FAILED
;
1618 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_MEM_DUMP host %d rup %d addr %x\n",
1619 SubCmd
.Host
, SubCmd
.Rup
, SubCmd
.Addr
));
1621 if (SubCmd
.Rup
>= MAX_RUP
+LINKS_PER_UNIT
) {
1622 p
->RIOError
.Error
= RUP_NUMBER_OUT_OF_RANGE
;
1626 if (SubCmd
.Host
>= p
->RIONumHosts
) {
1627 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1631 port
= p
->RIOHosts
[SubCmd
.Host
].
1632 UnixRups
[SubCmd
.Rup
].BaseSysPort
;
1634 PortP
= p
->RIOPortp
[port
];
1636 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1638 if ( RIOPreemptiveCmd(p
, PortP
, MEMDUMP
) == RIO_FAIL
) {
1639 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_MEM_DUMP failed\n"));
1640 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1644 PortP
->State
|= RIO_BUSY
;
1646 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1647 if ( copyout( (caddr_t
)p
->RIOMemDump
, (int)arg
,
1648 MEMDUMP_SIZE
) == COPYFAIL
) {
1649 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_MEM_DUMP copy failed\n"));
1650 p
->RIOError
.Error
= COPYOUT_FAILED
;
1656 if ((int)arg
< 0 || (int)arg
>= p
->RIONumHosts
)
1658 rio_dprint(RIO_DEBUG_CTRL
, ("Set interrupt for host %d\n", (int)arg
));
1659 WBYTE(p
->RIOHosts
[(int)arg
].SetInt
, 0xff);
1663 if ((int)arg
< 0 || (int)arg
>= p
->RIONumHosts
)
1665 rio_dprint(RIO_DEBUG_CTRL
, ("Clear interrupt for host %d\n", (int)arg
));
1666 WBYTE((p
->RIOHosts
[(int)arg
].ResetInt
) , 0xff);
1669 case RIO_READ_CHECK
:
1670 /* Check reads for pkts with data[0] the same */
1671 p
->RIOReadCheck
= !p
->RIOReadCheck
;
1672 if (copyout((caddr_t
)&p
->RIOReadCheck
,(int)arg
,
1673 sizeof(uint
))== COPYFAIL
) {
1674 p
->RIOError
.Error
= COPYOUT_FAILED
;
1679 case RIO_READ_REGISTER
:
1680 if (copyin((int)arg
, (caddr_t
)&SubCmd
,
1681 sizeof(struct SubCmdStruct
)) == COPYFAIL
) {
1682 p
->RIOError
.Error
= COPYIN_FAILED
;
1685 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_READ_REGISTER host %d rup %d port %d reg %x\n",
1686 SubCmd
.Host
, SubCmd
.Rup
, SubCmd
.Port
, SubCmd
.Addr
));
1688 if (SubCmd
.Port
> 511) {
1689 rio_dprint(RIO_DEBUG_CTRL
, ("Baud rate mapping: Bad port number %d\n",
1691 p
->RIOError
.Error
= PORT_NUMBER_OUT_OF_RANGE
;
1695 if (SubCmd
.Rup
>= MAX_RUP
+LINKS_PER_UNIT
) {
1696 p
->RIOError
.Error
= RUP_NUMBER_OUT_OF_RANGE
;
1700 if (SubCmd
.Host
>= p
->RIONumHosts
) {
1701 p
->RIOError
.Error
= HOST_NUMBER_OUT_OF_RANGE
;
1705 port
= p
->RIOHosts
[SubCmd
.Host
].
1706 UnixRups
[SubCmd
.Rup
].BaseSysPort
+ SubCmd
.Port
;
1707 PortP
= p
->RIOPortp
[port
];
1709 rio_spin_lock_irqsave(&PortP
->portSem
, flags
);
1711 if (RIOPreemptiveCmd(p
, PortP
, READ_REGISTER
) == RIO_FAIL
) {
1712 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_READ_REGISTER failed\n"));
1713 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1717 PortP
->State
|= RIO_BUSY
;
1719 rio_spin_unlock_irqrestore( &PortP
->portSem
, flags
);
1720 if (copyout((caddr_t
)&p
->CdRegister
, (int)arg
,
1721 sizeof(uint
)) == COPYFAIL
) {
1722 rio_dprint(RIO_DEBUG_CTRL
, ("RIO_READ_REGISTER copy failed\n"));
1723 p
->RIOError
.Error
= COPYOUT_FAILED
;
1728 ** rio_make_dev: given port number (0-511) ORed with port type
1729 ** (RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT) return dev_t
1730 ** value to pass to mknod to create the correct device node.
1734 uint port
= (uint
)arg
& RIO_MODEM_MASK
;
1736 switch ( (uint
)arg
& RIO_DEV_MASK
) {
1737 case RIO_DEV_DIRECT
:
1738 arg
= (caddr_t
)drv_makedev(major(dev
), port
);
1739 rio_dprint(RIO_DEBUG_CTRL
, ("Makedev direct 0x%x is 0x%x\n",port
, (int)arg
));
1742 arg
= (caddr_t
)drv_makedev(major(dev
), (port
|RIO_MODEM_BIT
) );
1743 rio_dprint(RIO_DEBUG_CTRL
, ("Makedev modem 0x%x is 0x%x\n",port
, (int)arg
));
1745 case RIO_DEV_XPRINT
:
1746 arg
= (caddr_t
)drv_makedev(major(dev
), port
);
1747 rio_dprint(RIO_DEBUG_CTRL
, ("Makedev printer 0x%x is 0x%x\n",port
, (int)arg
));
1750 rio_dprint(RIO_DEBUG_CTRL
, ("MAKE Device is called\n"));
1754 ** rio_minor: given a dev_t from a stat() call, return
1755 ** the port number (0-511) ORed with the port type
1756 ** ( RIO_DEV_DIRECT, RIO_DEV_MODEM, RIO_DEV_XPRINT )
1763 dv
= (dev_t
)((int)arg
);
1764 mino
= RIO_UNMODEM(dv
);
1766 if ( RIO_ISMODEM(dv
) ) {
1767 rio_dprint(RIO_DEBUG_CTRL
, ("Minor for device 0x%x: modem %d\n", dv
, mino
));
1768 arg
= (caddr_t
)(mino
| RIO_DEV_MODEM
);
1771 rio_dprint(RIO_DEBUG_CTRL
, ("Minor for device 0x%x: direct %d\n", dv
, mino
));
1772 arg
= (caddr_t
)(mino
| RIO_DEV_DIRECT
);
1777 rio_dprint(RIO_DEBUG_CTRL
, ("INVALID DAEMON IOCTL 0x%x\n",cmd
));
1778 p
->RIOError
.Error
= IOCTL_COMMAND_UNKNOWN
;
1783 ** Pre-emptive commands go on RUPs and are only one byte long.
1786 RIOPreemptiveCmd(p
, PortP
, Cmd
)
1787 struct rio_info
* p
;
1791 struct CmdBlk
*CmdBlkP
;
1792 struct PktCmd_M
*PktCmdP
;
1798 CheckPortP( PortP
);
1801 if ( PortP
->State
& RIO_DELETED
) {
1802 rio_dprint(RIO_DEBUG_CTRL
, ("Preemptive command to deleted RTA ignored\n"));
1806 if (((int)((char)PortP
->InUse
) == -1) || ! (CmdBlkP
= RIOGetCmdBlk()) ) {
1807 rio_dprint(RIO_DEBUG_CTRL
, ("Cannot allocate command block for command %d on port %d\n",
1808 Cmd
, PortP
->PortNum
));
1812 rio_dprint(RIO_DEBUG_CTRL
, ("Command blk 0x%x - InUse now %d\n",
1813 (int)CmdBlkP
,PortP
->InUse
));
1815 PktCmdP
= (struct PktCmd_M
*)&CmdBlkP
->Packet
.data
[0];
1817 CmdBlkP
->Packet
.src_unit
= 0;
1818 if (PortP
->SecondBlock
)
1821 rup
= PortP
->RupNum
;
1822 CmdBlkP
->Packet
.dest_unit
= rup
;
1823 CmdBlkP
->Packet
.src_port
= COMMAND_RUP
;
1824 CmdBlkP
->Packet
.dest_port
= COMMAND_RUP
;
1825 CmdBlkP
->Packet
.len
= PKT_CMD_BIT
| 2;
1826 CmdBlkP
->PostFuncP
= RIOUnUse
;
1827 CmdBlkP
->PostArg
= (int)PortP
;
1828 PktCmdP
->Command
= Cmd
;
1829 port
= PortP
->HostPort
% (ushort
)PORTS_PER_RTA
;
1831 ** Index ports 8-15 for 2nd block of 16 port RTA.
1833 if (PortP
->SecondBlock
)
1834 port
+= (ushort
) PORTS_PER_RTA
;
1835 PktCmdP
->PhbNum
= port
;
1839 rio_dprint(RIO_DEBUG_CTRL
, ("Queue MEMDUMP command blk 0x%x (addr 0x%x)\n",
1840 (int)CmdBlkP
, (int)SubCmd
.Addr
));
1841 PktCmdP
->SubCommand
= MEMDUMP
;
1842 PktCmdP
->SubAddr
= SubCmd
.Addr
;
1845 rio_dprint(RIO_DEBUG_CTRL
, ("Queue FCLOSE command blk 0x%x\n",(int)CmdBlkP
));
1848 rio_dprint(RIO_DEBUG_CTRL
, ("Queue READ_REGISTER (0x%x) command blk 0x%x\n",
1849 (int)SubCmd
.Addr
, (int)CmdBlkP
));
1850 PktCmdP
->SubCommand
= READ_REGISTER
;
1851 PktCmdP
->SubAddr
= SubCmd
.Addr
;
1854 rio_dprint(RIO_DEBUG_CTRL
, ("Queue RESUME command blk 0x%x\n",(int)CmdBlkP
));
1857 rio_dprint(RIO_DEBUG_CTRL
, ("Queue RFLUSH command blk 0x%x\n",(int)CmdBlkP
));
1858 CmdBlkP
->PostFuncP
= RIORFlushEnable
;
1861 rio_dprint(RIO_DEBUG_CTRL
, ("Queue SUSPEND command blk 0x%x\n",(int)CmdBlkP
));
1865 rio_dprint(RIO_DEBUG_CTRL
, ("Queue MGET command blk 0x%x\n", (int)CmdBlkP
));
1871 CmdBlkP
->Packet
.data
[4] = (char) PortP
->ModemLines
;
1872 rio_dprint(RIO_DEBUG_CTRL
, ("Queue MSET/MBIC/MBIS command blk 0x%x\n", (int)CmdBlkP
));
1877 ** If we have queued up the maximum number of Write flushes
1878 ** allowed then we should not bother sending any more to the
1881 if ((int)((char)PortP
->WflushFlag
) == (int)-1) {
1882 rio_dprint(RIO_DEBUG_CTRL
, ("Trashed WFLUSH, WflushFlag about to wrap!"));
1883 RIOFreeCmdBlk(CmdBlkP
);
1886 rio_dprint(RIO_DEBUG_CTRL
, ("Queue WFLUSH command blk 0x%x\n",
1888 CmdBlkP
->PostFuncP
= RIOWFlushMark
;
1895 Ret
= RIOQueueCmdBlk( PortP
->HostP
, rup
, CmdBlkP
);