aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/rio')
-rw-r--r--drivers/char/rio/Makefile2
-rw-r--r--drivers/char/rio/board.h58
-rw-r--r--drivers/char/rio/bootpkt.h61
-rw-r--r--drivers/char/rio/cirrus.h110
-rw-r--r--drivers/char/rio/cmdblk.h4
-rw-r--r--drivers/char/rio/cmdpkt.h94
-rw-r--r--drivers/char/rio/control.h61
-rw-r--r--drivers/char/rio/daemon.h67
-rw-r--r--drivers/char/rio/defaults.h51
-rw-r--r--drivers/char/rio/error.h82
-rw-r--r--drivers/char/rio/func.h52
-rw-r--r--drivers/char/rio/host.h56
-rw-r--r--drivers/char/rio/link.h124
-rw-r--r--drivers/char/rio/linux_compat.h45
-rw-r--r--drivers/char/rio/list.h56
-rw-r--r--drivers/char/rio/map.h12
-rw-r--r--drivers/char/rio/param.h24
-rw-r--r--drivers/char/rio/parmmap.h68
-rw-r--r--drivers/char/rio/phb.h39
-rw-r--r--drivers/char/rio/pkt.h24
-rw-r--r--drivers/char/rio/port.h250
-rw-r--r--drivers/char/rio/qbuf.h62
-rw-r--r--drivers/char/rio/rio.h173
-rw-r--r--drivers/char/rio/rio_linux.c139
-rw-r--r--drivers/char/rio/rioboot.c1688
-rw-r--r--drivers/char/rio/riocmd.c176
-rw-r--r--drivers/char/rio/rioctrl.c401
-rw-r--r--drivers/char/rio/riodrvr.h48
-rw-r--r--drivers/char/rio/rioinit.c199
-rw-r--r--drivers/char/rio/riointr.c320
-rw-r--r--drivers/char/rio/rioparam.c129
-rw-r--r--drivers/char/rio/riopcicopy.c8
-rw-r--r--drivers/char/rio/rioroute.c166
-rw-r--r--drivers/char/rio/riotable.c123
-rw-r--r--drivers/char/rio/riotty.c198
-rw-r--r--drivers/char/rio/riotypes.h68
-rw-r--r--drivers/char/rio/rom.h62
-rw-r--r--drivers/char/rio/rup.h25
-rw-r--r--drivers/char/rio/sam.h67
-rw-r--r--drivers/char/rio/space.h45
-rw-r--r--drivers/char/rio/top.h48
-rw-r--r--drivers/char/rio/typdef.h82
-rw-r--r--drivers/char/rio/unixrup.h6
43 files changed, 1773 insertions, 3800 deletions
diff --git a/drivers/char/rio/Makefile b/drivers/char/rio/Makefile
index bce2bd1204ed..2d1c5a7cba7d 100644
--- a/drivers/char/rio/Makefile
+++ b/drivers/char/rio/Makefile
@@ -9,4 +9,4 @@
9obj-$(CONFIG_RIO) += rio.o 9obj-$(CONFIG_RIO) += rio.o
10 10
11rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \ 11rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \
12 rioparam.o riopcicopy.o rioroute.o riotable.o riotty.o 12 rioparam.o rioroute.o riotable.o riotty.o
diff --git a/drivers/char/rio/board.h b/drivers/char/rio/board.h
index 29c980204098..bdea633a9076 100644
--- a/drivers/char/rio/board.h
+++ b/drivers/char/rio/board.h
@@ -33,10 +33,6 @@
33#ifndef __rio_board_h__ 33#ifndef __rio_board_h__
34#define __rio_board_h__ 34#define __rio_board_h__
35 35
36#ifdef SCCS_LABELS
37static char *_board_h_sccs_ = "@(#)board.h 1.2";
38#endif
39
40/* 36/*
41** board.h contains the definitions for the *hardware* of the host cards. 37** board.h contains the definitions for the *hardware* of the host cards.
42** It describes the memory overlay for the dual port RAM area. 38** It describes the memory overlay for the dual port RAM area.
@@ -53,29 +49,29 @@ static char *_board_h_sccs_ = "@(#)board.h 1.2";
53** The shape of the Host Control area, at offset 0x7C00, Write Only 49** The shape of the Host Control area, at offset 0x7C00, Write Only
54*/ 50*/
55struct s_Ctrl { 51struct s_Ctrl {
56 BYTE DpCtl; /* 7C00 */ 52 u8 DpCtl; /* 7C00 */
57 BYTE Dp_Unused2_[127]; 53 u8 Dp_Unused2_[127];
58 BYTE DpIntSet; /* 7C80 */ 54 u8 DpIntSet; /* 7C80 */
59 BYTE Dp_Unused3_[127]; 55 u8 Dp_Unused3_[127];
60 BYTE DpTpuReset; /* 7D00 */ 56 u8 DpTpuReset; /* 7D00 */
61 BYTE Dp_Unused4_[127]; 57 u8 Dp_Unused4_[127];
62 BYTE DpIntReset; /* 7D80 */ 58 u8 DpIntReset; /* 7D80 */
63 BYTE Dp_Unused5_[127]; 59 u8 Dp_Unused5_[127];
64}; 60};
65 61
66/* 62/*
67** The PROM data area on the host (0x7C00), Read Only 63** The PROM data area on the host (0x7C00), Read Only
68*/ 64*/
69struct s_Prom { 65struct s_Prom {
70 WORD DpSlxCode[2]; 66 u16 DpSlxCode[2];
71 WORD DpRev; 67 u16 DpRev;
72 WORD Dp_Unused6_; 68 u16 Dp_Unused6_;
73 WORD DpUniq[4]; 69 u16 DpUniq[4];
74 WORD DpJahre; 70 u16 DpJahre;
75 WORD DpWoche; 71 u16 DpWoche;
76 WORD DpHwFeature[5]; 72 u16 DpHwFeature[5];
77 WORD DpOemId; 73 u16 DpOemId;
78 WORD DpSiggy[16]; 74 u16 DpSiggy[16];
79}; 75};
80 76
81/* 77/*
@@ -90,19 +86,19 @@ union u_CtrlProm { /* This is the control/PROM area (0x7C00) */
90** The top end of memory! 86** The top end of memory!
91*/ 87*/
92struct s_ParmMapS { /* Area containing Parm Map Pointer */ 88struct s_ParmMapS { /* Area containing Parm Map Pointer */
93 BYTE Dp_Unused8_[DP_PARMMAP_ADDR]; 89 u8 Dp_Unused8_[DP_PARMMAP_ADDR];
94 WORD DpParmMapAd; 90 u16 DpParmMapAd;
95}; 91};
96 92
97struct s_StartUpS { 93struct s_StartUpS {
98 BYTE Dp_Unused9_[DP_STARTUP_ADDR]; 94 u8 Dp_Unused9_[DP_STARTUP_ADDR];
99 BYTE Dp_LongJump[0x4]; 95 u8 Dp_LongJump[0x4];
100 BYTE Dp_Unused10_[2]; 96 u8 Dp_Unused10_[2];
101 BYTE Dp_ShortJump[0x2]; 97 u8 Dp_ShortJump[0x2];
102}; 98};
103 99
104union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */ 100union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
105 BYTE DpSramMem[DP_SRAM2_SIZE]; 101 u8 DpSramMem[DP_SRAM2_SIZE];
106 struct s_ParmMapS DpParmMapS; 102 struct s_ParmMapS DpParmMapS;
107 struct s_StartUpS DpStartUpS; 103 struct s_StartUpS DpStartUpS;
108}; 104};
@@ -111,11 +107,11 @@ union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
111** This is the DP RAM overlay. 107** This is the DP RAM overlay.
112*/ 108*/
113struct DpRam { 109struct DpRam {
114 BYTE DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */ 110 u8 DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */
115 union u_CtrlProm DpCtrlProm; /* 7C00 - 7DFF */ 111 union u_CtrlProm DpCtrlProm; /* 7C00 - 7DFF */
116 union u_Sram2ParmMap DpSram2ParmMap; /* 7E00 - 7FFF */ 112 union u_Sram2ParmMap DpSram2ParmMap; /* 7E00 - 7FFF */
117 BYTE DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */ 113 u8 DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */
118 BYTE DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */ 114 u8 DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */
119}; 115};
120 116
121#define DpControl DpCtrlProm.DpCtrl.DpCtl 117#define DpControl DpCtrlProm.DpCtrl.DpCtl
diff --git a/drivers/char/rio/bootpkt.h b/drivers/char/rio/bootpkt.h
deleted file mode 100644
index 602266e0c085..000000000000
--- a/drivers/char/rio/bootpkt.h
+++ /dev/null
@@ -1,61 +0,0 @@
1
2
3/****************************************************************************
4 ******* *******
5 ******* B O O T P A C K E T H E A D E R F I L E
6 ******* *******
7 ****************************************************************************
8
9 Author : Ian Nandhra
10 Date :
11
12 *
13 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29 Version : 0.01
30
31
32 Mods
33 ----------------------------------------------------------------------------
34 Date By Description
35 ----------------------------------------------------------------------------
36
37 ***************************************************************************/
38
39#ifndef _pkt_h
40#define _pkt_h 1
41
42#ifndef lint
43#ifdef SCCS
44static char *_rio_bootpkt_h_sccs = "@(#)bootpkt.h 1.1";
45#endif
46#endif
47
48 /*************************************************
49 * Overlayed onto the Data fields of a regular
50 * Packet
51 ************************************************/
52typedef struct BOOT_PKT BOOT_PKT;
53struct BOOT_PKT {
54 short seq_num;
55 char data[10];
56};
57
58
59#endif
60
61/*********** end of file ***********/
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index 89bd94eb45be..f4f837f86829 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -40,73 +40,7 @@
40#endif 40#endif
41#define _cirrus_h 1 41#define _cirrus_h 1
42 42
43 43/* Bit fields for particular registers shared with driver */
44
45/* Bit fields for particular registers */
46
47/* GCR */
48#define GCR_SERIAL 0x00 /* Configure as serial channel */
49#define GCR_PARALLEL 0x80 /* Configure as parallel channel */
50
51/* RDSR - when status read from FIFO */
52#define RDSR_BREAK 0x08 /* Break received */
53#define RDSR_TIMEOUT 0x80 /* No new data timeout */
54#define RDSR_SC1 0x10 /* Special char 1 (tx XON) matched */
55#define RDSR_SC2 0x20 /* Special char 2 (tx XOFF) matched */
56#define RDSR_SC12_MASK 0x30 /* Mask for special chars 1 and 2 */
57
58/* PPR */
59#define PPR_DEFAULT 0x31 /* Default value - for a 25Mhz clock gives
60 a timeout period of 1ms */
61
62/* LIVR */
63#define LIVR_EXCEPTION 0x07 /* Receive exception interrupt */
64
65/* CCR */
66#define CCR_RESET 0x80 /* Reset channel */
67#define CCR_CHANGE 0x4e /* COR's have changed - NB always change all
68 COR's */
69#define CCR_WFLUSH 0x82 /* Flush transmit FIFO and TSR / THR */
70
71#define CCR_SENDSC1 0x21 /* Send special character one */
72#define CCR_SENDSC2 0x22 /* Send special character two */
73#define CCR_SENDSC3 0x23 /* Send special character three */
74#define CCR_SENDSC4 0x24 /* Send special character four */
75
76#define CCR_TENABLE 0x18 /* Enable transmitter */
77#define CCR_TDISABLE 0x14 /* Disable transmitter */
78#define CCR_RENABLE 0x12 /* Enable receiver */
79#define CCR_RDISABLE 0x11 /* Disable receiver */
80
81#define CCR_READY 0x00 /* CCR is ready for another command */
82
83/* CCSR */
84#define CCSR_TXENABLE 0x08 /* Transmitter enable */
85#define CCSR_RXENABLE 0x80 /* Receiver enable */
86#define CCSR_TXFLOWOFF 0x04 /* Transmit flow off */
87#define CCSR_TXFLOWON 0x02 /* Transmit flow on */
88
89/* SVRR */
90#define SVRR_RECEIVE 0x01 /* Receive interrupt pending */
91#define SVRR_TRANSMIT 0x02 /* Transmit interrupt pending */
92#define SVRR_MODEM 0x04 /* Modem interrupt pending */
93
94/* CAR */
95#define CAR_PORTS 0x03 /* Bit fields for ports */
96
97/* IER */
98#define IER_MODEM 0x80 /* Change in modem status */
99#define IER_RECEIVE 0x10 /* Good data / data exception */
100#define IER_TRANSMITR 0x04 /* Transmit ready (FIFO empty) */
101#define IER_TRANSMITE 0x02 /* Transmit empty */
102#define IER_TIMEOUT 0x01 /* Timeout on no data */
103
104#define IER_DEFAULT 0x94 /* Default values */
105#define IER_PARALLEL 0x84 /* Default for Parallel */
106#define IER_EMPTY 0x92 /* Transmitter empty rather than ready */
107
108/* COR1 - Driver only */
109#define COR1_INPCK 0x10 /* Check parity of received characters */
110 44
111/* COR1 - driver and RTA */ 45/* COR1 - driver and RTA */
112#define COR1_ODD 0x80 /* Odd parity */ 46#define COR1_ODD 0x80 /* Odd parity */
@@ -222,35 +156,6 @@
222 156
223#define MSVR1_HOST 0xf3 /* The bits the host wants */ 157#define MSVR1_HOST 0xf3 /* The bits the host wants */
224 158
225/* MSVR2 */
226#define MSVR2_DSR 0x02 /* DSR output pin (DTR on Cirrus) */
227
228/* MCOR */
229#define MCOR_CD 0x80 /* CD (DSR on Cirrus) */
230#define MCOR_RTS 0x40 /* RTS (CTS on Cirrus) */
231#define MCOR_RI 0x20 /* RI */
232#define MCOR_DTR 0x10 /* DTR (CD on Cirrus) */
233
234#define MCOR_DEFAULT (MCOR_CD | MCOR_RTS | MCOR_RI | MCOR_DTR)
235#define MCOR_FULLMODEM MCOR_DEFAULT
236#define MCOR_RJ45 (MCOR_CD | MCOR_RTS | MCOR_DTR)
237#define MCOR_RESTRICTED (MCOR_CD | MCOR_RTS)
238
239/* More MCOR - H/W Handshake (flowcontrol) stuff */
240#define MCOR_THRESH8 0x08 /* eight characters then we stop */
241#define MCOR_THRESH9 0x09 /* nine characters then we stop */
242#define MCOR_THRESH10 0x0A /* ten characters then we stop */
243#define MCOR_THRESH11 0x0B /* eleven characters then we stop */
244
245#define MCOR_THRESHBITS 0x0F /* mask for ANDing out the above */
246
247#define MCOR_THRESHOLD MCOR_THRESH9 /* MUST BE GREATER THAN COR3_THRESHOLD */
248
249
250/* RTPR */
251#define RTPR_DEFAULT 0x02 /* Default */
252
253
254/* Defines for the subscripts of a CONFIG packet */ 159/* Defines for the subscripts of a CONFIG packet */
255#define CONFIG_COR1 1 /* Option register 1 */ 160#define CONFIG_COR1 1 /* Option register 1 */
256#define CONFIG_COR2 2 /* Option register 2 */ 161#define CONFIG_COR2 2 /* Option register 2 */
@@ -264,19 +169,6 @@
264#define CONFIG_TXBAUD 10 /* Tx baud rate */ 169#define CONFIG_TXBAUD 10 /* Tx baud rate */
265#define CONFIG_RXBAUD 11 /* Rx baud rate */ 170#define CONFIG_RXBAUD 11 /* Rx baud rate */
266 171
267/* Port status stuff */
268#define IDLE_CLOSED 0 /* Closed */
269#define IDLE_OPEN 1 /* Idle open */
270#define IDLE_BREAK 2 /* Idle on break */
271
272/* Subscript of MODEM STATUS packet */
273#define MODEM_VALUE 3 /* Current values of handshake pins */
274/* Subscript of SBREAK packet */
275#define BREAK_LENGTH 1 /* Length of a break in slices of 0.01 seconds
276 0 = stay on break until an EBREAK command
277 is sent */
278
279
280#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */ 172#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */
281 173
282/* Packet types going from Host to remote - with the exception of OPEN, MOPEN, 174/* Packet types going from Host to remote - with the exception of OPEN, MOPEN,
diff --git a/drivers/char/rio/cmdblk.h b/drivers/char/rio/cmdblk.h
index a9a8c45631d7..c46b2fdb6626 100644
--- a/drivers/char/rio/cmdblk.h
+++ b/drivers/char/rio/cmdblk.h
@@ -48,10 +48,10 @@ struct CmdBlk {
48 struct CmdBlk *NextP; /* Pointer to next command block */ 48 struct CmdBlk *NextP; /* Pointer to next command block */
49 struct PKT Packet; /* A packet, to copy to the rup */ 49 struct PKT Packet; /* A packet, to copy to the rup */
50 /* The func to call to check if OK */ 50 /* The func to call to check if OK */
51 int (*PreFuncP) (int, struct CmdBlk *); 51 int (*PreFuncP) (unsigned long, struct CmdBlk *);
52 int PreArg; /* The arg for the func */ 52 int PreArg; /* The arg for the func */
53 /* The func to call when completed */ 53 /* The func to call when completed */
54 int (*PostFuncP) (int, struct CmdBlk *); 54 int (*PostFuncP) (unsigned long, struct CmdBlk *);
55 int PostArg; /* The arg for the func */ 55 int PostArg; /* The arg for the func */
56}; 56};
57 57
diff --git a/drivers/char/rio/cmdpkt.h b/drivers/char/rio/cmdpkt.h
index 77cee8df68ef..357ae5722436 100644
--- a/drivers/char/rio/cmdpkt.h
+++ b/drivers/char/rio/cmdpkt.h
@@ -55,24 +55,24 @@ static char *_cmdpkt_h_sccs_ = "@(#)cmdpkt.h 1.2";
55** at Data[2] in the actual pkt! 55** at Data[2] in the actual pkt!
56*/ 56*/
57struct BootSequence { 57struct BootSequence {
58 WORD NumPackets; 58 u16 NumPackets;
59 WORD LoadBase; 59 u16 LoadBase;
60 WORD CodeSize; 60 u16 CodeSize;
61}; 61};
62 62
63#define BOOT_SEQUENCE_LEN 8 63#define BOOT_SEQUENCE_LEN 8
64 64
65struct SamTop { 65struct SamTop {
66 BYTE Unit; 66 u8 Unit;
67 BYTE Link; 67 u8 Link;
68}; 68};
69 69
70struct CmdHdr { 70struct CmdHdr {
71 BYTE PcCommand; 71 u8 PcCommand;
72 union { 72 union {
73 BYTE PcPhbNum; 73 u8 PcPhbNum;
74 BYTE PcLinkNum; 74 u8 PcLinkNum;
75 BYTE PcIDNum; 75 u8 PcIDNum;
76 } U0; 76 } U0;
77}; 77};
78 78
@@ -84,28 +84,28 @@ struct PktCmd {
84 struct BootSequence PcBootSequence; 84 struct BootSequence PcBootSequence;
85 } S1; 85 } S1;
86 struct { 86 struct {
87 WORD PcSequence; 87 u16 PcSequence;
88 BYTE PcBootData[RTA_BOOT_DATA_SIZE]; 88 u8 PcBootData[RTA_BOOT_DATA_SIZE];
89 } S2; 89 } S2;
90 struct { 90 struct {
91 WORD __crud__; 91 u16 __crud__;
92 BYTE PcUniqNum[4]; /* this is really a uint. */ 92 u8 PcUniqNum[4]; /* this is really a uint. */
93 BYTE PcModuleTypes; /* what modules are fitted */ 93 u8 PcModuleTypes; /* what modules are fitted */
94 } S3; 94 } S3;
95 struct { 95 struct {
96 struct CmdHdr CmdHdr; 96 struct CmdHdr CmdHdr;
97 BYTE __undefined__; 97 u8 __undefined__;
98 BYTE PcModemStatus; 98 u8 PcModemStatus;
99 BYTE PcPortStatus; 99 u8 PcPortStatus;
100 BYTE PcSubCommand; /* commands like mem or register dump */ 100 u8 PcSubCommand; /* commands like mem or register dump */
101 WORD PcSubAddr; /* Address for command */ 101 u16 PcSubAddr; /* Address for command */
102 BYTE PcSubData[64]; /* Date area for command */ 102 u8 PcSubData[64]; /* Date area for command */
103 } S4; 103 } S4;
104 struct { 104 struct {
105 struct CmdHdr CmdHdr; 105 struct CmdHdr CmdHdr;
106 BYTE PcCommandText[1]; 106 u8 PcCommandText[1];
107 BYTE __crud__[20]; 107 u8 __crud__[20];
108 BYTE PcIDNum2; /* It had to go somewhere! */ 108 u8 PcIDNum2; /* It had to go somewhere! */
109 } S5; 109 } S5;
110 struct { 110 struct {
111 struct CmdHdr CmdHdr; 111 struct CmdHdr CmdHdr;
@@ -118,45 +118,45 @@ struct PktCmd_M {
118 union { 118 union {
119 struct { 119 struct {
120 struct { 120 struct {
121 uchar PcCommand; 121 u8 PcCommand;
122 union { 122 union {
123 uchar PcPhbNum; 123 u8 PcPhbNum;
124 uchar PcLinkNum; 124 u8 PcLinkNum;
125 uchar PcIDNum; 125 u8 PcIDNum;
126 } U0; 126 } U0;
127 } CmdHdr; 127 } CmdHdr;
128 struct { 128 struct {
129 ushort NumPackets; 129 u16 NumPackets;
130 ushort LoadBase; 130 u16 LoadBase;
131 ushort CodeSize; 131 u16 CodeSize;
132 } PcBootSequence; 132 } PcBootSequence;
133 } S1; 133 } S1;
134 struct { 134 struct {
135 ushort PcSequence; 135 u16 PcSequence;
136 uchar PcBootData[RTA_BOOT_DATA_SIZE]; 136 u8 PcBootData[RTA_BOOT_DATA_SIZE];
137 } S2; 137 } S2;
138 struct { 138 struct {
139 ushort __crud__; 139 u16 __crud__;
140 uchar PcUniqNum[4]; /* this is really a uint. */ 140 u8 PcUniqNum[4]; /* this is really a uint. */
141 uchar PcModuleTypes; /* what modules are fitted */ 141 u8 PcModuleTypes; /* what modules are fitted */
142 } S3; 142 } S3;
143 struct { 143 struct {
144 ushort __cmd_hdr__; 144 u16 __cmd_hdr__;
145 uchar __undefined__; 145 u8 __undefined__;
146 uchar PcModemStatus; 146 u8 PcModemStatus;
147 uchar PcPortStatus; 147 u8 PcPortStatus;
148 uchar PcSubCommand; 148 u8 PcSubCommand;
149 ushort PcSubAddr; 149 u16 PcSubAddr;
150 uchar PcSubData[64]; 150 u8 PcSubData[64];
151 } S4; 151 } S4;
152 struct { 152 struct {
153 ushort __cmd_hdr__; 153 u16 __cmd_hdr__;
154 uchar PcCommandText[1]; 154 u8 PcCommandText[1];
155 uchar __crud__[20]; 155 u8 __crud__[20];
156 uchar PcIDNum2; /* Tacked on end */ 156 u8 PcIDNum2; /* Tacked on end */
157 } S5; 157 } S5;
158 struct { 158 struct {
159 ushort __cmd_hdr__; 159 u16 __cmd_hdr__;
160 struct Top Topology[LINKS_PER_UNIT]; 160 struct Top Topology[LINKS_PER_UNIT];
161 } S6; 161 } S6;
162 } U1; 162 } U1;
diff --git a/drivers/char/rio/control.h b/drivers/char/rio/control.h
deleted file mode 100644
index 6853d03304a3..000000000000
--- a/drivers/char/rio/control.h
+++ /dev/null
@@ -1,61 +0,0 @@
1
2
3/****************************************************************************
4 ******* *******
5 ******* C O N T R O L P A C K E T H E A D E R S
6 ******* *******
7 ****************************************************************************
8
9 Author : Jon Brawn
10 Date :
11
12 *
13 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29 Version : 0.01
30
31
32 Mods
33 ----------------------------------------------------------------------------
34 Date By Description
35 ----------------------------------------------------------------------------
36
37 ***************************************************************************/
38
39
40#ifndef _control_h
41#define _control_h
42
43#ifndef lint
44/* static char *_rio_control_h_sccs = "@(#)control.h 1.4"; */
45#endif
46
47#define CONTROL '^'
48#define IFOAD ( CONTROL + 1 )
49#define IDENTIFY ( CONTROL + 2 )
50#define ZOMBIE ( CONTROL + 3 )
51#define UFOAD ( CONTROL + 4 )
52#define IWAIT ( CONTROL + 5 )
53
54#define IFOAD_MAGIC 0xF0AD /* of course */
55#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
56#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
57#define IWAIT_MAGIC 0xB1DE /* Bide your time */
58
59#endif
60
61/*********** end of file ***********/
diff --git a/drivers/char/rio/daemon.h b/drivers/char/rio/daemon.h
index 28a991bd4fe6..5818a8aa46e0 100644
--- a/drivers/char/rio/daemon.h
+++ b/drivers/char/rio/daemon.h
@@ -45,15 +45,15 @@ static char *_daemon_h_sccs_ = "@(#)daemon.h 1.3";
45*/ 45*/
46 46
47struct Error { 47struct Error {
48 uint Error; 48 unsigned int Error;
49 uint Entry; 49 unsigned int Entry;
50 uint Other; 50 unsigned int Other;
51}; 51};
52 52
53struct DownLoad { 53struct DownLoad {
54 char *DataP; 54 char *DataP;
55 uint Count; 55 unsigned int Count;
56 uint ProductCode; 56 unsigned int ProductCode;
57}; 57};
58 58
59/* 59/*
@@ -68,69 +68,64 @@ struct DownLoad {
68#endif 68#endif
69 69
70struct PortSetup { 70struct PortSetup {
71 uint From; /* Set/Clear XP & IXANY Control from this port.... */ 71 unsigned int From; /* Set/Clear XP & IXANY Control from this port.... */
72 uint To; /* .... to this port */ 72 unsigned int To; /* .... to this port */
73 uint XpCps; /* at this speed */ 73 unsigned int XpCps; /* at this speed */
74 char XpOn[MAX_XP_CTRL_LEN]; /* this is the start string */ 74 char XpOn[MAX_XP_CTRL_LEN]; /* this is the start string */
75 char XpOff[MAX_XP_CTRL_LEN]; /* this is the stop string */ 75 char XpOff[MAX_XP_CTRL_LEN]; /* this is the stop string */
76 uchar IxAny; /* enable/disable IXANY */ 76 u8 IxAny; /* enable/disable IXANY */
77 uchar IxOn; /* enable/disable IXON */ 77 u8 IxOn; /* enable/disable IXON */
78 uchar Lock; /* lock port params */ 78 u8 Lock; /* lock port params */
79 uchar Store; /* store params across closes */ 79 u8 Store; /* store params across closes */
80 uchar Drain; /* close only when drained */ 80 u8 Drain; /* close only when drained */
81}; 81};
82 82
83struct LpbReq { 83struct LpbReq {
84 uint Host; 84 unsigned int Host;
85 uint Link; 85 unsigned int Link;
86 struct LPB *LpbP; 86 struct LPB *LpbP;
87}; 87};
88 88
89struct RupReq { 89struct RupReq {
90 uint HostNum; 90 unsigned int HostNum;
91 uint RupNum; 91 unsigned int RupNum;
92 struct RUP *RupP; 92 struct RUP *RupP;
93}; 93};
94 94
95struct PortReq { 95struct PortReq {
96 uint SysPort; 96 unsigned int SysPort;
97 struct Port *PortP; 97 struct Port *PortP;
98}; 98};
99 99
100struct StreamInfo { 100struct StreamInfo {
101 uint SysPort; 101 unsigned int SysPort;
102#if 0
103 queue_t RQueue;
104 queue_t WQueue;
105#else
106 int RQueue; 102 int RQueue;
107 int WQueue; 103 int WQueue;
108#endif
109}; 104};
110 105
111struct HostReq { 106struct HostReq {
112 uint HostNum; 107 unsigned int HostNum;
113 struct Host *HostP; 108 struct Host *HostP;
114}; 109};
115 110
116struct HostDpRam { 111struct HostDpRam {
117 uint HostNum; 112 unsigned int HostNum;
118 struct DpRam *DpRamP; 113 struct DpRam *DpRamP;
119}; 114};
120 115
121struct DebugCtrl { 116struct DebugCtrl {
122 uint SysPort; 117 unsigned int SysPort;
123 uint Debug; 118 unsigned int Debug;
124 uint Wait; 119 unsigned int Wait;
125}; 120};
126 121
127struct MapInfo { 122struct MapInfo {
128 uint FirstPort; /* 8 ports, starting from this (tty) number */ 123 unsigned int FirstPort; /* 8 ports, starting from this (tty) number */
129 uint RtaUnique; /* reside on this RTA (unique number) */ 124 unsigned int RtaUnique; /* reside on this RTA (unique number) */
130}; 125};
131 126
132struct MapIn { 127struct MapIn {
133 uint NumEntries; /* How many port sets are we mapping? */ 128 unsigned int NumEntries; /* How many port sets are we mapping? */
134 struct MapInfo *MapInfoP; /* Pointer to (user space) info */ 129 struct MapInfo *MapInfoP; /* Pointer to (user space) info */
135}; 130};
136 131
@@ -147,13 +142,13 @@ struct SpecialRupCmd {
147}; 142};
148 143
149struct IdentifyRta { 144struct IdentifyRta {
150 ulong RtaUnique; 145 unsigned long RtaUnique;
151 uchar ID; 146 u8 ID;
152}; 147};
153 148
154struct KillNeighbour { 149struct KillNeighbour {
155 ulong UniqueNum; 150 unsigned long UniqueNum;
156 uchar Link; 151 u8 Link;
157}; 152};
158 153
159struct rioVersion { 154struct rioVersion {
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
deleted file mode 100644
index d55c2f6a9877..000000000000
--- a/drivers/char/rio/defaults.h
+++ /dev/null
@@ -1,51 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* D E F A U L T S
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef lint
39#ifdef SCCS
40static char *_rio_defaults_h_sccs = "@(#)defaults.h 1.1";
41#endif
42#endif
43
44
45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */
46#define SECOND (int) 15625 /* Low priority ticks */
47
48#define LINK_TIMEOUT (int) (POLL_PERIOD / 2)
49
50
51/*********** end of file ***********/
diff --git a/drivers/char/rio/error.h b/drivers/char/rio/error.h
deleted file mode 100644
index f20f0789db8f..000000000000
--- a/drivers/char/rio/error.h
+++ /dev/null
@@ -1,82 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* E R R O R H E A D E R F I L E
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef lint
39/* static char *_rio_error_h_sccs = "@(#)error.h 1.3"; */
40#endif
41
42#define E_NO_ERROR ((ushort) 0)
43#define E_PROCESS_NOT_INIT ((ushort) 1)
44#define E_LINK_TIMEOUT ((ushort) 2)
45#define E_NO_ROUTE ((ushort) 3)
46#define E_CONFUSED ((ushort) 4)
47#define E_HOME ((ushort) 5)
48#define E_CSUM_FAIL ((ushort) 6)
49#define E_DISCONNECTED ((ushort) 7)
50#define E_BAD_RUP ((ushort) 8)
51#define E_NO_VIRGIN ((ushort) 9)
52#define E_BOOT_RUP_BUSY ((ushort) 10)
53
54
55
56 /*************************************************
57 * Parsed to mem_halt()
58 ************************************************/
59#define E_CHANALLOC ((ushort) 0x80)
60#define E_POLL_ALLOC ((ushort) 0x81)
61#define E_LTTWAKE ((ushort) 0x82)
62#define E_LTT_ALLOC ((ushort) 0x83)
63#define E_LRT_ALLOC ((ushort) 0x84)
64#define E_CIRRUS ((ushort) 0x85)
65#define E_MONITOR ((ushort) 0x86)
66#define E_PHB_ALLOC ((ushort) 0x87)
67#define E_ARRAY_ALLOC ((ushort) 0x88)
68#define E_QBUF_ALLOC ((ushort) 0x89)
69#define E_PKT_ALLOC ((ushort) 0x8a)
70#define E_GET_TX_Q_BUF ((ushort) 0x8b)
71#define E_GET_RX_Q_BUF ((ushort) 0x8c)
72#define E_MEM_OUT ((ushort) 0x8d)
73#define E_MMU_INIT ((ushort) 0x8e)
74#define E_LTT_INIT ((ushort) 0x8f)
75#define E_LRT_INIT ((ushort) 0x90)
76#define E_LINK_RUN ((ushort) 0x91)
77#define E_MONITOR_ALLOC ((ushort) 0x92)
78#define E_MONITOR_INIT ((ushort) 0x93)
79#define E_POLL_INIT ((ushort) 0x94)
80
81
82/*********** end of file ***********/
diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h
index b4778410ec6e..e64fe9912394 100644
--- a/drivers/char/rio/func.h
+++ b/drivers/char/rio/func.h
@@ -43,35 +43,33 @@ static char *_func_h_sccs_ = "@(#)func.h 1.3";
43 43
44/* rioboot.c */ 44/* rioboot.c */
45int RIOBootCodeRTA(struct rio_info *, struct DownLoad *); 45int RIOBootCodeRTA(struct rio_info *, struct DownLoad *);
46int RIOBootCodeHOST(struct rio_info *, register struct DownLoad *); 46int RIOBootCodeHOST(struct rio_info *, struct DownLoad *);
47int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *); 47int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *);
48void msec_timeout(struct Host *); 48void msec_timeout(struct Host *);
49int RIOBootRup(struct rio_info *, uint, struct Host *, struct PKT *); 49int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
50int RIOBootOk(struct rio_info *, struct Host *, ulong); 50int RIOBootOk(struct rio_info *, struct Host *, unsigned long);
51int RIORtaBound(struct rio_info *, uint); 51int RIORtaBound(struct rio_info *, unsigned int);
52void FillSlot(int, int, uint, struct Host *); 52void rio_fill_host_slot(int, int, unsigned int, struct Host *);
53 53
54/* riocmd.c */ 54/* riocmd.c */
55int RIOFoadRta(struct Host *, struct Map *); 55int RIOFoadRta(struct Host *, struct Map *);
56int RIOZombieRta(struct Host *, struct Map *); 56int RIOZombieRta(struct Host *, struct Map *);
57int RIOCommandRta(struct rio_info *, uint, int (*func) (struct Host *, struct Map *)); 57int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *));
58int RIOIdentifyRta(struct rio_info *, caddr_t); 58int RIOIdentifyRta(struct rio_info *, void *);
59int RIOKillNeighbour(struct rio_info *, caddr_t); 59int RIOKillNeighbour(struct rio_info *, void *);
60int RIOSuspendBootRta(struct Host *, int, int); 60int RIOSuspendBootRta(struct Host *, int, int);
61int RIOFoadWakeup(struct rio_info *); 61int RIOFoadWakeup(struct rio_info *);
62struct CmdBlk *RIOGetCmdBlk(void); 62struct CmdBlk *RIOGetCmdBlk(void);
63void RIOFreeCmdBlk(struct CmdBlk *); 63void RIOFreeCmdBlk(struct CmdBlk *);
64int RIOQueueCmdBlk(struct Host *, uint, struct CmdBlk *); 64int RIOQueueCmdBlk(struct Host *, unsigned int, struct CmdBlk *);
65void RIOPollHostCommands(struct rio_info *, struct Host *); 65void RIOPollHostCommands(struct rio_info *, struct Host *);
66int RIOWFlushMark(int, struct CmdBlk *); 66int RIOWFlushMark(unsigned long, struct CmdBlk *);
67int RIORFlushEnable(int, struct CmdBlk *); 67int RIORFlushEnable(unsigned long, struct CmdBlk *);
68int RIOUnUse(int, struct CmdBlk *); 68int RIOUnUse(unsigned long, struct CmdBlk *);
69void ShowPacket(uint, struct PKT *);
70 69
71/* rioctrl.c */ 70/* rioctrl.c */
72int copyin(int, caddr_t, int);
73int riocontrol(struct rio_info *, dev_t, int, caddr_t, int); 71int riocontrol(struct rio_info *, dev_t, int, caddr_t, int);
74int RIOPreemptiveCmd(struct rio_info *, struct Port *, uchar); 72int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char);
75 73
76/* rioinit.c */ 74/* rioinit.c */
77void rioinit(struct rio_info *, struct RioHostInfo *); 75void rioinit(struct rio_info *, struct RioHostInfo *);
@@ -80,19 +78,17 @@ void RIOISAinit(struct rio_info *, int);
80int RIODoAT(struct rio_info *, int, int); 78int RIODoAT(struct rio_info *, int, int);
81caddr_t RIOCheckForATCard(int); 79caddr_t RIOCheckForATCard(int);
82int RIOAssignAT(struct rio_info *, int, caddr_t, int); 80int RIOAssignAT(struct rio_info *, int, caddr_t, int);
83int RIOBoardTest(paddr_t, caddr_t, uchar, int); 81int RIOBoardTest(unsigned long, caddr_t, unsigned char, int);
84void RIOAllocDataStructs(struct rio_info *); 82void RIOAllocDataStructs(struct rio_info *);
85void RIOSetupDataStructs(struct rio_info *); 83void RIOSetupDataStructs(struct rio_info *);
86int RIODefaultName(struct rio_info *, struct Host *, uint); 84int RIODefaultName(struct rio_info *, struct Host *, unsigned int);
87struct rioVersion *RIOVersid(void); 85struct rioVersion *RIOVersid(void);
88int RIOMapin(paddr_t, int, caddr_t *); 86void RIOHostReset(unsigned int, struct DpRam *, unsigned int);
89void RIOMapout(paddr_t, long, caddr_t);
90void RIOHostReset(uint, volatile struct DpRam *, uint);
91 87
92/* riointr.c */ 88/* riointr.c */
93void RIOTxEnable(char *); 89void RIOTxEnable(char *);
94void RIOServiceHost(struct rio_info *, struct Host *, int); 90void RIOServiceHost(struct rio_info *, struct Host *, int);
95int riotproc(struct rio_info *, register struct ttystatics *, int, int); 91int riotproc(struct rio_info *, struct ttystatics *, int, int);
96 92
97/* rioparam.c */ 93/* rioparam.c */
98int RIOParam(struct Port *, int, int, int); 94int RIOParam(struct Port *, int, int, int);
@@ -106,18 +102,18 @@ int can_remove_receive(struct PKT **, struct Port *);
106void remove_receive(struct Port *); 102void remove_receive(struct Port *);
107 103
108/* rioroute.c */ 104/* rioroute.c */
109int RIORouteRup(struct rio_info *, uint, struct Host *, struct PKT *); 105int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
110void RIOFixPhbs(struct rio_info *, struct Host *, uint); 106void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int);
111uint GetUnitType(uint); 107unsigned int GetUnitType(unsigned int);
112int RIOSetChange(struct rio_info *); 108int RIOSetChange(struct rio_info *);
113int RIOFindFreeID(struct rio_info *, struct Host *, uint *, uint *); 109int RIOFindFreeID(struct rio_info *, struct Host *, unsigned int *, unsigned int *);
114 110
115 111
116/* riotty.c */ 112/* riotty.c */
117 113
118int riotopen(struct tty_struct *tty, struct file *filp); 114int riotopen(struct tty_struct *tty, struct file *filp);
119int riotclose(void *ptr); 115int riotclose(void *ptr);
120int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t); 116int riotioctl(struct rio_info *, struct tty_struct *, int, caddr_t);
121void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg); 117void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg);
122 118
123/* riotable.c */ 119/* riotable.c */
@@ -131,7 +127,7 @@ int RIOChangeName(struct rio_info *, struct Map *);
131#if 0 127#if 0
132/* riodrvr.c */ 128/* riodrvr.c */
133struct rio_info *rio_install(struct RioHostInfo *); 129struct rio_info *rio_install(struct RioHostInfo *);
134int rio_uninstall(register struct rio_info *); 130int rio_uninstall(struct rio_info *);
135int rio_open(struct rio_info *, int, struct file *); 131int rio_open(struct rio_info *, int, struct file *);
136int rio_close(struct rio_info *, struct file *); 132int rio_close(struct rio_info *, struct file *);
137int rio_read(struct rio_info *, struct file *, char *, int); 133int rio_read(struct rio_info *, struct file *, char *, int);
@@ -143,7 +139,7 @@ int rio_isr_thread(char *);
143struct rio_info *rio_info_store(int cmd, struct rio_info *p); 139struct rio_info *rio_info_store(int cmd, struct rio_info *p);
144#endif 140#endif
145 141
146extern int rio_pcicopy(char *src, char *dst, int n); 142extern void rio_copy_to_card(void *to, void *from, int len);
147extern int rio_minor(struct tty_struct *tty); 143extern int rio_minor(struct tty_struct *tty);
148extern int rio_ismodem(struct tty_struct *tty); 144extern int rio_ismodem(struct tty_struct *tty);
149 145
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index f7dfcedf7d45..3ec73d1a279a 100644
--- a/drivers/char/rio/host.h
+++ b/drivers/char/rio/host.h
@@ -50,22 +50,20 @@ static char *_host_h_sccs_ = "@(#)host.h 1.2";
50** the host. 50** the host.
51*/ 51*/
52struct Host { 52struct Host {
53 uchar Type; /* RIO_EISA, RIO_MCA, ... */ 53 unsigned char Type; /* RIO_EISA, RIO_MCA, ... */
54 uchar Ivec; /* POLLED or ivec number */ 54 unsigned char Ivec; /* POLLED or ivec number */
55 uchar Mode; /* Control stuff */ 55 unsigned char Mode; /* Control stuff */
56 uchar Slot; /* Slot */ 56 unsigned char Slot; /* Slot */
57 volatile caddr_t Caddr; /* KV address of DPRAM */ 57 caddr_t Caddr; /* KV address of DPRAM */
58 volatile struct DpRam *CardP; /* KV address of DPRAM, with overlay */ 58 struct DpRam *CardP; /* KV address of DPRAM, with overlay */
59 paddr_t PaddrP; /* Phys. address of DPRAM */ 59 unsigned long PaddrP; /* Phys. address of DPRAM */
60 char Name[MAX_NAME_LEN]; /* The name of the host */ 60 char Name[MAX_NAME_LEN]; /* The name of the host */
61 uint UniqueNum; /* host unique number */ 61 unsigned int UniqueNum; /* host unique number */
62 spinlock_t HostLock; /* Lock structure for MPX */ 62 spinlock_t HostLock; /* Lock structure for MPX */
63 /*struct pci_devinfo PciDevInfo; *//* PCI Bus/Device/Function stuff */ 63 unsigned int WorkToBeDone; /* set to true each interrupt */
64 /*struct lockb HostLock; *//* Lock structure for MPX */ 64 unsigned int InIntr; /* Being serviced? */
65 uint WorkToBeDone; /* set to true each interrupt */ 65 unsigned int IntSrvDone; /* host's interrupt has been serviced */
66 uint InIntr; /* Being serviced? */ 66 void (*Copy) (void *, void *, int); /* copy func */
67 uint IntSrvDone; /* host's interrupt has been serviced */
68 int (*Copy) (caddr_t, caddr_t, int); /* copy func */
69 struct timer_list timer; 67 struct timer_list timer;
70 /* 68 /*
71 ** I M P O R T A N T ! 69 ** I M P O R T A N T !
@@ -74,7 +72,7 @@ struct Host {
74 ** a RIO_HOST_FOAD command. 72 ** a RIO_HOST_FOAD command.
75 */ 73 */
76 74
77 ulong Flags; /* Whats going down */ 75 unsigned long Flags; /* Whats going down */
78#define RC_WAITING 0 76#define RC_WAITING 0
79#define RC_STARTUP 1 77#define RC_STARTUP 1
80#define RC_RUNNING 2 78#define RC_RUNNING 2
@@ -88,28 +86,28 @@ struct Host {
88** Boot mode applies to the way in which hosts in this system will 86** Boot mode applies to the way in which hosts in this system will
89** boot RTAs 87** boot RTAs
90*/ 88*/
91#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */ 89#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */
92#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */ 90#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */
93#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */ 91#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */
94 92
95 struct Top Topology[LINKS_PER_UNIT]; /* one per link */ 93 struct Top Topology[LINKS_PER_UNIT]; /* one per link */
96 struct Map Mapping[MAX_RUP]; /* Mappings for host */ 94 struct Map Mapping[MAX_RUP]; /* Mappings for host */
97 struct PHB *PhbP; /* Pointer to the PHB array */ 95 struct PHB *PhbP; /* Pointer to the PHB array */
98 ushort *PhbNumP; /* Ptr to Number of PHB's */ 96 unsigned short *PhbNumP; /* Ptr to Number of PHB's */
99 struct LPB *LinkStrP; /* Link Structure Array */ 97 struct LPB *LinkStrP; /* Link Structure Array */
100 struct RUP *RupP; /* Sixteen real rups here */ 98 struct RUP *RupP; /* Sixteen real rups here */
101 struct PARM_MAP *ParmMapP; /* points to the parmmap */ 99 struct PARM_MAP *ParmMapP; /* points to the parmmap */
102 uint ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */ 100 unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
103 uint NumExtraBooted; /* how many of the above */ 101 unsigned int NumExtraBooted; /* how many of the above */
104 /* 102 /*
105 ** Twenty logical rups. 103 ** Twenty logical rups.
106 ** The first sixteen are the real Rup entries (above), the last four 104 ** The first sixteen are the real Rup entries (above), the last four
107 ** are the link RUPs. 105 ** are the link RUPs.
108 */ 106 */
109 struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT]; 107 struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT];
110 int timeout_id; /* For calling 100 ms delays */ 108 int timeout_id; /* For calling 100 ms delays */
111 int timeout_sem; /* For calling 100 ms delays */ 109 int timeout_sem; /* For calling 100 ms delays */
112 long locks; /* long req'd for set_bit --RR */ 110 long locks; /* long req'd for set_bit --RR */
113 char ____end_marker____; 111 char ____end_marker____;
114}; 112};
115#define Control CardP->DpControl 113#define Control CardP->DpControl
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index 48d68ca7f825..f3bf11a04d41 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -37,38 +37,9 @@
37#ifndef _link_h 37#ifndef _link_h
38#define _link_h 1 38#define _link_h 1
39 39
40#ifndef lint
41#ifdef SCCS_LABELS
42/* static char *_rio_link_h_sccs = "@(#)link.h 1.15"; */
43#endif
44#endif
45
46
47
48/************************************************* 40/*************************************************
49 * Define the Link Status stuff 41 * Define the Link Status stuff
50 ************************************************/ 42 ************************************************/
51#define LRT_ACTIVE ((ushort) 0x01)
52#define LRT_SPARE1 ((ushort) 0x02)
53#define INTRO_RCVD ((ushort) 0x04)
54#define FORCED_DISCONNECT ((ushort) 0x08)
55#define LRT_SPARE2 ((ushort) 0x80)
56
57#define TOP_OF_RTA_RAM ((ushort) 0x7000)
58#define HOST_SERIAL_POINTER (unsigned char **) (TOP_OF_RTA_RAM - 2 * sizeof (ushort))
59
60/* Flags for ltt_status */
61#define WAITING_ACK (ushort) 0x0001
62#define DATA_SENT (ushort) 0x0002
63#define WAITING_RUP (ushort) 0x0004
64#define WAITING_RETRY (ushort) 0x0008
65#define WAITING_TOPOLOGY (ushort) 0x0010
66#define SEND_SYNC (ushort) 0x0020
67#define FOAD_THIS_LINK (ushort) 0x0040
68#define REQUEST_SYNC (ushort) 0x0080
69#define REMOTE_DYING (ushort) 0x0100
70#define DIE_NOW (ushort) 0x0200
71
72/* Boot request stuff */ 43/* Boot request stuff */
73#define BOOT_REQUEST ((ushort) 0) /* Request for a boot */ 44#define BOOT_REQUEST ((ushort) 0) /* Request for a boot */
74#define BOOT_ABORT ((ushort) 1) /* Abort a boot */ 45#define BOOT_ABORT ((ushort) 1) /* Abort a boot */
@@ -76,77 +47,48 @@
76 and load address */ 47 and load address */
77#define BOOT_COMPLETED ((ushort) 3) /* Boot completed */ 48#define BOOT_COMPLETED ((ushort) 3) /* Boot completed */
78 49
79/* States that a link can be in */
80#define LINK_DISCONNECTED ((ushort) 0) /* Disconnected */
81#define LINK_BOOT1 ((ushort) 1) /* Trying to send 1st stage boot */
82#define LINK_BOOT2 ((ushort) 2) /* Trying to send 2nd stage boot */
83#define LINK_BOOT2WAIT ((ushort) 3) /* Waiting for selftest results */
84#define LINK_BOOT3 ((ushort) 4) /* Trying to send 3rd stage boots */
85#define LINK_SYNC ((ushort) 5) /* Syncing */
86
87#define LINK_INTRO ((ushort) 10) /* Introductory packet */
88#define LINK_SUPPLYID ((ushort) 11) /* Trying to supply an ID */
89#define LINK_TOPOLOGY ((ushort) 12) /* Send a topology update */
90#define LINK_REQUESTID ((ushort) 13) /* Waiting for an ID */
91#define LINK_CONNECTED ((ushort) 14) /* Connected */
92
93#define LINK_INTERCONNECT ((ushort) 20) /* Subnets interconnected */
94
95#define LINK_SPARE ((ushort) 40)
96
97/*
98** Set the default timeout for link communications.
99*/
100#define LINKTIMEOUT (400 * MILLISECOND)
101
102/*
103** LED stuff
104*/
105#define LED_SET_COLOUR(colour)
106#define LED_OR_COLOUR(colour)
107#define LED_TIMEOUT(time)
108 50
109struct LPB { 51struct LPB {
110 WORD link_number; /* Link Number */ 52 u16 link_number; /* Link Number */
111 Channel_ptr in_ch; /* Link In Channel */ 53 u16 in_ch; /* Link In Channel */
112 Channel_ptr out_ch; /* Link Out Channel */ 54 u16 out_ch; /* Link Out Channel */
113 BYTE attached_serial[4]; /* Attached serial number */ 55 u8 attached_serial[4]; /* Attached serial number */
114 BYTE attached_host_serial[4]; 56 u8 attached_host_serial[4];
115 /* Serial number of Host who 57 /* Serial number of Host who
116 booted the other end */ 58 booted the other end */
117 WORD descheduled; /* Currently Descheduled */ 59 u16 descheduled; /* Currently Descheduled */
118 WORD state; /* Current state */ 60 u16 state; /* Current state */
119 WORD send_poll; /* Send a Poll Packet */ 61 u16 send_poll; /* Send a Poll Packet */
120 Process_ptr ltt_p; /* Process Descriptor */ 62 u16 ltt_p; /* Process Descriptor */
121 Process_ptr lrt_p; /* Process Descriptor */ 63 u16 lrt_p; /* Process Descriptor */
122 WORD lrt_status; /* Current lrt status */ 64 u16 lrt_status; /* Current lrt status */
123 WORD ltt_status; /* Current ltt status */ 65 u16 ltt_status; /* Current ltt status */
124 WORD timeout; /* Timeout value */ 66 u16 timeout; /* Timeout value */
125 WORD topology; /* Topology bits */ 67 u16 topology; /* Topology bits */
126 WORD mon_ltt; 68 u16 mon_ltt;
127 WORD mon_lrt; 69 u16 mon_lrt;
128 WORD WaitNoBoot; /* Secs to hold off booting */ 70 u16 WaitNoBoot; /* Secs to hold off booting */
129 PKT_ptr add_packet_list; /* Add packets to here */ 71 u16 add_packet_list; /* Add packets to here */
130 PKT_ptr remove_packet_list; /* Send packets from here */ 72 u16 remove_packet_list; /* Send packets from here */
131 73
132 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */ 74 u16 lrt_fail_chan; /* Lrt's failure channel */
133 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */ 75 u16 ltt_fail_chan; /* Ltt's failure channel */
134 76
135 /* RUP structure for HOST to driver communications */ 77 /* RUP structure for HOST to driver communications */
136 struct RUP rup; 78 struct RUP rup;
137 struct RUP link_rup; /* RUP for the link (POLL, 79 struct RUP link_rup; /* RUP for the link (POLL,
138 topology etc.) */ 80 topology etc.) */
139 WORD attached_link; /* Number of attached link */ 81 u16 attached_link; /* Number of attached link */
140 WORD csum_errors; /* csum errors */ 82 u16 csum_errors; /* csum errors */
141 WORD num_disconnects; /* number of disconnects */ 83 u16 num_disconnects; /* number of disconnects */
142 WORD num_sync_rcvd; /* # sync's received */ 84 u16 num_sync_rcvd; /* # sync's received */
143 WORD num_sync_rqst; /* # sync requests */ 85 u16 num_sync_rqst; /* # sync requests */
144 WORD num_tx; /* Num pkts sent */ 86 u16 num_tx; /* Num pkts sent */
145 WORD num_rx; /* Num pkts received */ 87 u16 num_rx; /* Num pkts received */
146 WORD module_attached; /* Module tpyes of attached */ 88 u16 module_attached; /* Module tpyes of attached */
147 WORD led_timeout; /* LED timeout */ 89 u16 led_timeout; /* LED timeout */
148 WORD first_port; /* First port to service */ 90 u16 first_port; /* First port to service */
149 WORD last_port; /* Last port to service */ 91 u16 last_port; /* Last port to service */
150}; 92};
151 93
152#endif 94#endif
diff --git a/drivers/char/rio/linux_compat.h b/drivers/char/rio/linux_compat.h
index 17a14c4a3420..34c0d2899ef1 100644
--- a/drivers/char/rio/linux_compat.h
+++ b/drivers/char/rio/linux_compat.h
@@ -19,56 +19,12 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20 20
21 21
22#define disable(oldspl) save_flags (oldspl)
23#define restore(oldspl) restore_flags (oldspl)
24
25#define sysbrk(x) kmalloc ((x),in_interrupt()? GFP_ATOMIC : GFP_KERNEL)
26#define sysfree(p,size) kfree ((p))
27
28#define WBYTE(p,v) writeb(v, &p)
29#define RBYTE(p) readb (&p)
30#define WWORD(p,v) writew(v, &p)
31#define RWORD(p) readw(&p)
32#define WINDW(p,v) writew(v, p)
33#define RINDW(p) readw(p)
34
35#define DEBUG_ALL 22#define DEBUG_ALL
36 23
37#define cprintf printk
38
39#ifdef __KERNEL__
40#define INKERNEL
41#endif
42
43struct ttystatics { 24struct ttystatics {
44 struct termios tm; 25 struct termios tm;
45}; 26};
46 27
47#define bzero(d, n) memset((d), 0, (n))
48#define bcopy(src, dest, n) memcpy ((dest), (src), (n))
49
50#define SEM_SIGIGNORE 0x1234
51
52#ifdef DEBUG_SEM
53#define swait(a,b) printk ("waiting: " __FILE__ " line %d\n", __LINE__)
54#define ssignal(sem) printk ("signalling: " __FILE__ " line %d\n", __LINE__)
55
56#define sreset(sem) printk ("sreset: " __FILE__ "\n")
57#define sem_init(sem,v) printk ("sreset: " __FILE__ "\n")
58#endif
59
60
61#define getpid() (current->pid)
62
63#define QSIZE SERIAL_XMIT_SIZE
64
65#define pseterr(errno) return (- errno)
66
67#define V_CBAUD CBAUD
68
69/* For one reason or another rioboot.c uses delay instead of RIODelay. */
70#define delay(x,y) RIODelay(NULL, y)
71
72extern int rio_debug; 28extern int rio_debug;
73 29
74#define RIO_DEBUG_INIT 0x000001 30#define RIO_DEBUG_INIT 0x000001
@@ -91,6 +47,7 @@ extern int rio_debug;
91#define RIO_DEBUG_DELAY 0x020000 47#define RIO_DEBUG_DELAY 0x020000
92#define RIO_DEBUG_MOD_COUNT 0x040000 48#define RIO_DEBUG_MOD_COUNT 0x040000
93 49
50
94/* Copied over from riowinif.h . This is ugly. The winif file declares 51/* Copied over from riowinif.h . This is ugly. The winif file declares
95also much other stuff which is incompatible with the headers from 52also much other stuff which is incompatible with the headers from
96the older driver. The older driver includes "brates.h" which shadows 53the older driver. The older driver includes "brates.h" which shadows
diff --git a/drivers/char/rio/list.h b/drivers/char/rio/list.h
deleted file mode 100644
index 79b853140ae5..000000000000
--- a/drivers/char/rio/list.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* L I S T *******
4 ******* *******
5 ****************************************************************************
6
7 Author : Jeremy Rolls.
8 Date : 04-Nov-1990
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34 ***************************************************************************/
35
36#ifndef _list_h
37#define _list_h 1
38
39#ifdef SCCS_LABELS
40#ifndef lint
41static char *_rio_list_h_sccs = "@(#)list.h 1.9";
42#endif
43#endif
44
45#define PKT_IN_USE 0x1
46
47#define ZERO_PTR (ushort) 0x8000
48#define CaD PortP->Caddr
49
50/*
51** We can add another packet to a transmit queue if the packet pointer pointed
52** to by the TxAdd pointer has PKT_IN_USE clear in its address.
53*/
54
55#endif /* ifndef _list.h */
56/*********** end of file ***********/
diff --git a/drivers/char/rio/map.h b/drivers/char/rio/map.h
index 97fe287aab2a..bdbcd09c8b81 100644
--- a/drivers/char/rio/map.h
+++ b/drivers/char/rio/map.h
@@ -47,17 +47,17 @@ static char *_map_h_sccs_ = "@(#)map.h 1.2";
47#define MAX_NAME_LEN 32 47#define MAX_NAME_LEN 32
48 48
49struct Map { 49struct Map {
50 uint HostUniqueNum; /* Supporting hosts unique number */ 50 unsigned int HostUniqueNum; /* Supporting hosts unique number */
51 uint RtaUniqueNum; /* Unique number */ 51 unsigned int RtaUniqueNum; /* Unique number */
52 /* 52 /*
53 ** The next two IDs must be swapped on big-endian architectures 53 ** The next two IDs must be swapped on big-endian architectures
54 ** when using a v2.04 /etc/rio/config with a v3.00 driver (when 54 ** when using a v2.04 /etc/rio/config with a v3.00 driver (when
55 ** upgrading for example). 55 ** upgrading for example).
56 */ 56 */
57 ushort ID; /* ID used in the subnet */ 57 unsigned short ID; /* ID used in the subnet */
58 ushort ID2; /* ID of 2nd block of 8 for 16 port */ 58 unsigned short ID2; /* ID of 2nd block of 8 for 16 port */
59 ulong Flags; /* Booted, ID Given, Disconnected */ 59 unsigned long Flags; /* Booted, ID Given, Disconnected */
60 ulong SysPort; /* First tty mapped to this port */ 60 unsigned long SysPort; /* First tty mapped to this port */
61 struct Top Topology[LINKS_PER_UNIT]; /* ID connected to each link */ 61 struct Top Topology[LINKS_PER_UNIT]; /* ID connected to each link */
62 char Name[MAX_NAME_LEN]; /* Cute name by which RTA is known */ 62 char Name[MAX_NAME_LEN]; /* Cute name by which RTA is known */
63}; 63};
diff --git a/drivers/char/rio/param.h b/drivers/char/rio/param.h
index de7e57180c91..675c200b2459 100644
--- a/drivers/char/rio/param.h
+++ b/drivers/char/rio/param.h
@@ -43,18 +43,18 @@ static char *_param_h_sccs_ = "@(#)param.h 1.2";
43*/ 43*/
44 44
45struct phb_param { 45struct phb_param {
46 BYTE Cmd; /* It is very important that these line up */ 46 u8 Cmd; /* It is very important that these line up */
47 BYTE Cor1; /* with what is expected at the other end. */ 47 u8 Cor1; /* with what is expected at the other end. */
48 BYTE Cor2; /* to confirm that you've got it right, */ 48 u8 Cor2; /* to confirm that you've got it right, */
49 BYTE Cor4; /* check with cirrus/cirrus.h */ 49 u8 Cor4; /* check with cirrus/cirrus.h */
50 BYTE Cor5; 50 u8 Cor5;
51 BYTE TxXon; /* Transmit X-On character */ 51 u8 TxXon; /* Transmit X-On character */
52 BYTE TxXoff; /* Transmit X-Off character */ 52 u8 TxXoff; /* Transmit X-Off character */
53 BYTE RxXon; /* Receive X-On character */ 53 u8 RxXon; /* Receive X-On character */
54 BYTE RxXoff; /* Receive X-Off character */ 54 u8 RxXoff; /* Receive X-Off character */
55 BYTE LNext; /* Literal-next character */ 55 u8 LNext; /* Literal-next character */
56 BYTE TxBaud; /* Transmit baudrate */ 56 u8 TxBaud; /* Transmit baudrate */
57 BYTE RxBaud; /* Receive baudrate */ 57 u8 RxBaud; /* Receive baudrate */
58}; 58};
59 59
60#endif 60#endif
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index e24acc1d1844..9764ef85c5a6 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -47,40 +47,40 @@
47typedef struct PARM_MAP PARM_MAP; 47typedef struct PARM_MAP PARM_MAP;
48 48
49struct PARM_MAP { 49struct PARM_MAP {
50 PHB_ptr phb_ptr; /* Pointer to the PHB array */ 50 u16 phb_ptr; /* Pointer to the PHB array */
51 WORD_ptr phb_num_ptr; /* Ptr to Number of PHB's */ 51 u16 phb_num_ptr; /* Ptr to Number of PHB's */
52 FREE_LIST_ptr free_list; /* Free List pointer */ 52 u16 free_list; /* Free List pointer */
53 FREE_LIST_ptr free_list_end; /* Free List End pointer */ 53 u16 free_list_end; /* Free List End pointer */
54 Q_BUF_ptr_ptr q_free_list_ptr; /* Ptr to Q_BUF variable */ 54 u16 q_free_list_ptr; /* Ptr to Q_BUF variable */
55 BYTE_ptr unit_id_ptr; /* Unit Id */ 55 u16 unit_id_ptr; /* Unit Id */
56 LPB_ptr link_str_ptr; /* Link Structure Array */ 56 u16 link_str_ptr; /* Link Structure Array */
57 BYTE_ptr bootloader_1; /* 1st Stage Boot Loader */ 57 u16 bootloader_1; /* 1st Stage Boot Loader */
58 BYTE_ptr bootloader_2; /* 2nd Stage Boot Loader */ 58 u16 bootloader_2; /* 2nd Stage Boot Loader */
59 WORD_ptr port_route_map_ptr; /* Port Route Map */ 59 u16 port_route_map_ptr; /* Port Route Map */
60 ROUTE_STR_ptr route_ptr; /* Unit Route Map */ 60 u16 route_ptr; /* Unit Route Map */
61 NUMBER_ptr map_present; /* Route Map present */ 61 u16 map_present; /* Route Map present */
62 NUMBER pkt_num; /* Total number of packets */ 62 s16 pkt_num; /* Total number of packets */
63 NUMBER q_num; /* Total number of Q packets */ 63 s16 q_num; /* Total number of Q packets */
64 WORD buffers_per_port; /* Number of buffers per port */ 64 u16 buffers_per_port; /* Number of buffers per port */
65 WORD heap_size; /* Initial size of heap */ 65 u16 heap_size; /* Initial size of heap */
66 WORD heap_left; /* Current Heap left */ 66 u16 heap_left; /* Current Heap left */
67 WORD error; /* Error code */ 67 u16 error; /* Error code */
68 WORD tx_max; /* Max number of tx pkts per phb */ 68 u16 tx_max; /* Max number of tx pkts per phb */
69 WORD rx_max; /* Max number of rx pkts per phb */ 69 u16 rx_max; /* Max number of rx pkts per phb */
70 WORD rx_limit; /* For high / low watermarks */ 70 u16 rx_limit; /* For high / low watermarks */
71 NUMBER links; /* Links to use */ 71 s16 links; /* Links to use */
72 NUMBER timer; /* Interrupts per second */ 72 s16 timer; /* Interrupts per second */
73 RUP_ptr rups; /* Pointer to the RUPs */ 73 u16 rups; /* Pointer to the RUPs */
74 WORD max_phb; /* Mostly for debugging */ 74 u16 max_phb; /* Mostly for debugging */
75 WORD living; /* Just increments!! */ 75 u16 living; /* Just increments!! */
76 WORD init_done; /* Initialisation over */ 76 u16 init_done; /* Initialisation over */
77 WORD booting_link; 77 u16 booting_link;
78 WORD idle_count; /* Idle time counter */ 78 u16 idle_count; /* Idle time counter */
79 WORD busy_count; /* Busy counter */ 79 u16 busy_count; /* Busy counter */
80 WORD idle_control; /* Control Idle Process */ 80 u16 idle_control; /* Control Idle Process */
81 WORD tx_intr; /* TX interrupt pending */ 81 u16 tx_intr; /* TX interrupt pending */
82 WORD rx_intr; /* RX interrupt pending */ 82 u16 rx_intr; /* RX interrupt pending */
83 WORD rup_intr; /* RUP interrupt pending */ 83 u16 rup_intr; /* RUP interrupt pending */
84}; 84};
85 85
86#endif 86#endif
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index 2663ca0306e2..a4c48ae4e365 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -37,13 +37,6 @@
37#ifndef _phb_h 37#ifndef _phb_h
38#define _phb_h 1 38#define _phb_h 1
39 39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_phb_h_sccs = "@(#)phb.h 1.12"; */
43#endif
44#endif
45
46
47/************************************************* 40/*************************************************
48 * Handshake asserted. Deasserted by the LTT(s) 41 * Handshake asserted. Deasserted by the LTT(s)
49 ************************************************/ 42 ************************************************/
@@ -124,23 +117,23 @@
124 * the start. The pointer tx_add points to a SPACE to put a Packet. 117 * the start. The pointer tx_add points to a SPACE to put a Packet.
125 * The pointer tx_remove points to the next Packet to remove 118 * The pointer tx_remove points to the next Packet to remove
126 *************************************************************************/ 119 *************************************************************************/
127typedef struct PHB PHB; 120
128struct PHB { 121struct PHB {
129 WORD source; 122 u8 source;
130 WORD handshake; 123 u8 handshake;
131 WORD status; 124 u8 status;
132 NUMBER timeout; /* Maximum of 1.9 seconds */ 125 u16 timeout; /* Maximum of 1.9 seconds */
133 WORD link; /* Send down this link */ 126 u8 link; /* Send down this link */
134 WORD destination; 127 u8 destination;
135 PKT_ptr_ptr tx_start; 128 u16 tx_start;
136 PKT_ptr_ptr tx_end; 129 u16 tx_end;
137 PKT_ptr_ptr tx_add; 130 u16 tx_add;
138 PKT_ptr_ptr tx_remove; 131 u16 tx_remove;
139 132
140 PKT_ptr_ptr rx_start; 133 u16 rx_start;
141 PKT_ptr_ptr rx_end; 134 u16 rx_end;
142 PKT_ptr_ptr rx_add; 135 u16 rx_add;
143 PKT_ptr_ptr rx_remove; 136 u16 rx_remove;
144 137
145}; 138};
146 139
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 7011e52e82db..a9458164f02f 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -37,14 +37,6 @@
37#ifndef _pkt_h 37#ifndef _pkt_h
38#define _pkt_h 1 38#define _pkt_h 1
39 39
40
41#ifdef SCCS_LABELS
42#ifndef lint
43/* static char *_rio_pkt_h_sccs = "@(#)pkt.h 1.8"; */
44#endif
45#endif
46
47#define MAX_TTL 0xf
48#define PKT_CMD_BIT ((ushort) 0x080) 40#define PKT_CMD_BIT ((ushort) 0x080)
49#define PKT_CMD_DATA ((ushort) 0x080) 41#define PKT_CMD_DATA ((ushort) 0x080)
50 42
@@ -70,15 +62,15 @@
70#define CONTROL_DATA_WNDW (DATA_WNDW << 8) 62#define CONTROL_DATA_WNDW (DATA_WNDW << 8)
71 63
72struct PKT { 64struct PKT {
73 BYTE dest_unit; /* Destination Unit Id */ 65 u8 dest_unit; /* Destination Unit Id */
74 BYTE dest_port; /* Destination POrt */ 66 u8 dest_port; /* Destination POrt */
75 BYTE src_unit; /* Source Unit Id */ 67 u8 src_unit; /* Source Unit Id */
76 BYTE src_port; /* Source POrt */ 68 u8 src_port; /* Source POrt */
77 BYTE len; 69 u8 len;
78 BYTE control; 70 u8 control;
79 BYTE data[PKT_MAX_DATA_LEN]; 71 u8 data[PKT_MAX_DATA_LEN];
80 /* Actual data :-) */ 72 /* Actual data :-) */
81 WORD csum; /* C-SUM */ 73 u16 csum; /* C-SUM */
82}; 74};
83#endif 75#endif
84 76
diff --git a/drivers/char/rio/port.h b/drivers/char/rio/port.h
index c99b1e70fdc8..9b5fa3eb0402 100644
--- a/drivers/char/rio/port.h
+++ b/drivers/char/rio/port.h
@@ -33,91 +33,37 @@
33#ifndef __rio_port_h__ 33#ifndef __rio_port_h__
34#define __rio_port_h__ 34#define __rio_port_h__
35 35
36#ifdef SCCS_LABELS
37static char *_port_h_sccs_ = "@(#)port.h 1.3";
38#endif
39
40
41#undef VPIX
42
43
44/*
45** the port data structure - one per port in the system
46*/
47
48#ifdef STATS
49struct RIOStats {
50 /*
51 ** interrupt statistics
52 */
53 uint BreakIntCnt;
54 uint ModemOffCnt;
55 uint ModemOnCnt;
56 uint RxIntCnt;
57 uint TxIntCnt;
58 /*
59 ** throughput statistics
60 */
61 uint RxCharCnt;
62 uint RxPktCnt;
63 uint RxSaveCnt;
64 uint TxCharCnt;
65 uint TxPktCnt;
66 /*
67 ** driver entry statistics
68 */
69 uint CloseCnt;
70 uint IoctlCnt;
71 uint OpenCnt;
72 uint ReadCnt;
73 uint WriteCnt;
74 /*
75 ** proc statistics
76 */
77 uint BlockCnt;
78 uint OutputCnt;
79 uint ResumeCnt;
80 uint RflushCnt;
81 uint SuspendCnt;
82 uint TbreakCnt;
83 uint TimeoutCnt;
84 uint UnblockCnt;
85 uint WflushCnt;
86 uint WFBodgeCnt;
87};
88#endif
89
90/* 36/*
91** Port data structure 37** Port data structure
92*/ 38*/
93struct Port { 39struct Port {
94 struct gs_port gs; 40 struct gs_port gs;
95 int PortNum; /* RIO port no., 0-511 */ 41 int PortNum; /* RIO port no., 0-511 */
96 struct Host *HostP; 42 struct Host *HostP;
97 volatile caddr_t Caddr; 43 caddr_t Caddr;
98 ushort HostPort; /* Port number on host card */ 44 unsigned short HostPort; /* Port number on host card */
99 uchar RupNum; /* Number of RUP for port */ 45 unsigned char RupNum; /* Number of RUP for port */
100 uchar ID2; /* Second ID of RTA for port */ 46 unsigned char ID2; /* Second ID of RTA for port */
101 ulong State; /* FLAGS for open & xopen */ 47 unsigned long State; /* FLAGS for open & xopen */
102#define RIO_LOPEN 0x00001 /* Local open */ 48#define RIO_LOPEN 0x00001 /* Local open */
103#define RIO_MOPEN 0x00002 /* Modem open */ 49#define RIO_MOPEN 0x00002 /* Modem open */
104#define RIO_WOPEN 0x00004 /* Waiting for open */ 50#define RIO_WOPEN 0x00004 /* Waiting for open */
105#define RIO_CLOSING 0x00008 /* The port is being close */ 51#define RIO_CLOSING 0x00008 /* The port is being close */
106#define RIO_XPBUSY 0x00010 /* Transparent printer busy */ 52#define RIO_XPBUSY 0x00010 /* Transparent printer busy */
107#define RIO_BREAKING 0x00020 /* Break in progress */ 53#define RIO_BREAKING 0x00020 /* Break in progress */
108#define RIO_DIRECT 0x00040 /* Doing Direct output */ 54#define RIO_DIRECT 0x00040 /* Doing Direct output */
109#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */ 55#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */
110#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */ 56#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */
111#define RIO_CARR_ON 0x00200 /* Stream has carrier present */ 57#define RIO_CARR_ON 0x00200 /* Stream has carrier present */
112#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */ 58#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */
113#define RIO_RBLK 0x00800 /* Stream is read-blocked */ 59#define RIO_RBLK 0x00800 /* Stream is read-blocked */
114#define RIO_BUSY 0x01000 /* Stream is BUSY for write */ 60#define RIO_BUSY 0x01000 /* Stream is BUSY for write */
115#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */ 61#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */
116#define RIO_TXSTOP 0x04000 /* Stream output is stopped */ 62#define RIO_TXSTOP 0x04000 /* Stream output is stopped */
117#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */ 63#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */
118#define RIO_DYNOROD 0x10000 /* Drain failed */ 64#define RIO_DYNOROD 0x10000 /* Drain failed */
119#define RIO_DELETED 0x20000 /* RTA has been deleted */ 65#define RIO_DELETED 0x20000 /* RTA has been deleted */
120#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */ 66#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */
121#define RIO_USING_EUC 0x100000 /* Using extended Unix chars */ 67#define RIO_USING_EUC 0x100000 /* Using extended Unix chars */
122#define RIO_CAN_COOK 0x200000 /* This line can do cooking */ 68#define RIO_CAN_COOK 0x200000 /* This line can do cooking */
123#define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */ 69#define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */
@@ -125,15 +71,15 @@ struct Port {
125#define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */ 71#define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */
126#define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */ 72#define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */
127 73
128 ulong Config; /* FLAGS for NOREAD.... */ 74 unsigned long Config; /* FLAGS for NOREAD.... */
129#define RIO_NOREAD 0x0001 /* Are not allowed to read port */ 75#define RIO_NOREAD 0x0001 /* Are not allowed to read port */
130#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */ 76#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */
131#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */ 77#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */
132#define RIO_NOMASK 0x0007 /* All not allowed things */ 78#define RIO_NOMASK 0x0007 /* All not allowed things */
133#define RIO_IXANY 0x0008 /* Port is allowed ixany */ 79#define RIO_IXANY 0x0008 /* Port is allowed ixany */
134#define RIO_MODEM 0x0010 /* Stream is a modem device */ 80#define RIO_MODEM 0x0010 /* Stream is a modem device */
135#define RIO_IXON 0x0020 /* Port is allowed ixon */ 81#define RIO_IXON 0x0020 /* Port is allowed ixon */
136#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */ 82#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */
137#define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */ 83#define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */
138#define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */ 84#define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */
139 85
@@ -142,36 +88,36 @@ struct Port {
142** As LynxOS does not appear to support Hardware Flow Control ..... 88** As LynxOS does not appear to support Hardware Flow Control .....
143** Define our own flow control flags in 'Config'. 89** Define our own flow control flags in 'Config'.
144*/ 90*/
145#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */ 91#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */
146#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */ 92#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */
147 93
148 94
149 struct PHB *PhbP; /* pointer to PHB for port */ 95 struct PHB *PhbP; /* pointer to PHB for port */
150 WORD *TxAdd; /* Add packets here */ 96 u16 *TxAdd; /* Add packets here */
151 WORD *TxStart; /* Start of add array */ 97 u16 *TxStart; /* Start of add array */
152 WORD *TxEnd; /* End of add array */ 98 u16 *TxEnd; /* End of add array */
153 WORD *RxRemove; /* Remove packets here */ 99 u16 *RxRemove; /* Remove packets here */
154 WORD *RxStart; /* Start of remove array */ 100 u16 *RxStart; /* Start of remove array */
155 WORD *RxEnd; /* End of remove array */ 101 u16 *RxEnd; /* End of remove array */
156 uint RtaUniqueNum; /* Unique number of RTA */ 102 unsigned int RtaUniqueNum; /* Unique number of RTA */
157 ushort PortState; /* status of port */ 103 unsigned short PortState; /* status of port */
158 ushort ModemState; /* status of modem lines */ 104 unsigned short ModemState; /* status of modem lines */
159 ulong ModemLines; /* Modem bits sent to RTA */ 105 unsigned long ModemLines; /* Modem bits sent to RTA */
160 uchar CookMode; /* who expands CR/LF? */ 106 unsigned char CookMode; /* who expands CR/LF? */
161 uchar ParamSem; /* Prevent write during param */ 107 unsigned char ParamSem; /* Prevent write during param */
162 uchar Mapped; /* if port mapped onto host */ 108 unsigned char Mapped; /* if port mapped onto host */
163 uchar SecondBlock; /* if port belongs to 2nd block 109 unsigned char SecondBlock; /* if port belongs to 2nd block
164 of 16 port RTA */ 110 of 16 port RTA */
165 uchar InUse; /* how many pre-emptive cmds */ 111 unsigned char InUse; /* how many pre-emptive cmds */
166 uchar Lock; /* if params locked */ 112 unsigned char Lock; /* if params locked */
167 uchar Store; /* if params stored across closes */ 113 unsigned char Store; /* if params stored across closes */
168 uchar FirstOpen; /* TRUE if first time port opened */ 114 unsigned char FirstOpen; /* TRUE if first time port opened */
169 uchar FlushCmdBodge; /* if doing a (non)flush */ 115 unsigned char FlushCmdBodge; /* if doing a (non)flush */
170 uchar MagicFlags; /* require intr processing */ 116 unsigned char MagicFlags; /* require intr processing */
171#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */ 117#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */
172#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */ 118#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */
173#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */ 119#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */
174 uchar WflushFlag; /* 1 How many WFLUSHs active */ 120 unsigned char WflushFlag; /* 1 How many WFLUSHs active */
175/* 121/*
176** Transparent print stuff 122** Transparent print stuff
177*/ 123*/
@@ -179,63 +125,55 @@ struct Port {
179#ifndef MAX_XP_CTRL_LEN 125#ifndef MAX_XP_CTRL_LEN
180#define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */ 126#define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */
181#endif 127#endif
182 uint XpCps; 128 unsigned int XpCps;
183 char XpOn[MAX_XP_CTRL_LEN]; 129 char XpOn[MAX_XP_CTRL_LEN];
184 char XpOff[MAX_XP_CTRL_LEN]; 130 char XpOff[MAX_XP_CTRL_LEN];
185 ushort XpLen; /* strlen(XpOn)+strlen(XpOff) */ 131 unsigned short XpLen; /* strlen(XpOn)+strlen(XpOff) */
186 uchar XpActive; 132 unsigned char XpActive;
187 uchar XpLastTickOk; /* TRUE if we can process */ 133 unsigned char XpLastTickOk; /* TRUE if we can process */
188#define XP_OPEN 00001 134#define XP_OPEN 00001
189#define XP_RUNABLE 00002 135#define XP_RUNABLE 00002
190 struct ttystatics *XttyP; 136 struct ttystatics *XttyP;
191 } Xprint; 137 } Xprint;
192#ifdef VPIX 138 unsigned char RxDataStart;
193 v86_t *StashP; 139 unsigned char Cor2Copy; /* copy of COR2 */
194 uint IntMask; 140 char *Name; /* points to the Rta's name */
195 struct termss VpixSs;
196 uchar ModemStatusReg; /* Modem status register */
197#endif
198 uchar RxDataStart;
199 uchar Cor2Copy; /* copy of COR2 */
200 char *Name; /* points to the Rta's name */
201#ifdef STATS
202 struct RIOStats Stat; /* ports statistics */
203#endif
204 char *TxRingBuffer; 141 char *TxRingBuffer;
205 ushort TxBufferIn; /* New data arrives here */ 142 unsigned short TxBufferIn; /* New data arrives here */
206 ushort TxBufferOut; /* Intr removes data here */ 143 unsigned short TxBufferOut; /* Intr removes data here */
207 ushort OldTxBufferOut; /* Indicates if draining */ 144 unsigned short OldTxBufferOut; /* Indicates if draining */
208 int TimeoutId; /* Timeout ID */ 145 int TimeoutId; /* Timeout ID */
209 uint Debug; 146 unsigned int Debug;
210 uchar WaitUntilBooted; /* True if open should block */ 147 unsigned char WaitUntilBooted; /* True if open should block */
211 uint statsGather; /* True if gathering stats */ 148 unsigned int statsGather; /* True if gathering stats */
212 ulong txchars; /* Chars transmitted */ 149 unsigned long txchars; /* Chars transmitted */
213 ulong rxchars; /* Chars received */ 150 unsigned long rxchars; /* Chars received */
214 ulong opens; /* port open count */ 151 unsigned long opens; /* port open count */
215 ulong closes; /* port close count */ 152 unsigned long closes; /* port close count */
216 ulong ioctls; /* ioctl count */ 153 unsigned long ioctls; /* ioctl count */
217 uchar LastRxTgl; /* Last state of rx toggle bit */ 154 unsigned char LastRxTgl; /* Last state of rx toggle bit */
218 spinlock_t portSem; /* Lock using this sem */ 155 spinlock_t portSem; /* Lock using this sem */
219 int MonitorTstate; /* Monitoring ? */ 156 int MonitorTstate; /* Monitoring ? */
220 int timeout_id; /* For calling 100 ms delays */ 157 int timeout_id; /* For calling 100 ms delays */
221 int timeout_sem; /* For calling 100 ms delays */ 158 int timeout_sem; /* For calling 100 ms delays */
222 int firstOpen; /* First time open ? */ 159 int firstOpen; /* First time open ? */
223 char *p; /* save the global struc here .. */ 160 char *p; /* save the global struc here .. */
224}; 161};
225 162
226struct ModuleInfo { 163struct ModuleInfo {
227 char *Name; 164 char *Name;
228 uint Flags[4]; /* one per port on a module */ 165 unsigned int Flags[4]; /* one per port on a module */
229}; 166};
230#endif
231 167
232/* 168/*
233** This struct is required because trying to grab an entire Port structure 169** This struct is required because trying to grab an entire Port structure
234** runs into problems with differing struct sizes between driver and config. 170** runs into problems with differing struct sizes between driver and config.
235*/ 171*/
236struct PortParams { 172struct PortParams {
237 uint Port; 173 unsigned int Port;
238 ulong Config; 174 unsigned long Config;
239 ulong State; 175 unsigned long State;
240 struct ttystatics *TtyP; 176 struct ttystatics *TtyP;
241}; 177};
178
179#endif
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
deleted file mode 100644
index 391ffc335535..000000000000
--- a/drivers/char/rio/qbuf.h
+++ /dev/null
@@ -1,62 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* Q U E U E B U F F E R S T R U C T U R E S
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra / Jeremy Rolls
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef _qbuf_h
39#define _qbuf_h 1
40
41#ifndef lint
42#ifdef SCCS_LABELS
43static char *_rio_qbuf_h_sccs = "@(#)qbuf.h 1.1";
44#endif
45#endif
46
47
48
49#define PKTS_PER_BUFFER (220 / PKT_LENGTH)
50
51typedef struct Q_BUF Q_BUF;
52struct Q_BUF {
53 Q_BUF_ptr next;
54 Q_BUF_ptr prev;
55 PKT_ptr buf[PKTS_PER_BUFFER];
56};
57
58
59#endif
60
61
62/*********** end of file ***********/
diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h
index 7f45e1ab5332..b4c91871ba28 100644
--- a/drivers/char/rio/rio.h
+++ b/drivers/char/rio/rio.h
@@ -33,38 +33,6 @@
33#ifndef __rio_rio_h__ 33#ifndef __rio_rio_h__
34#define __rio_rio_h__ 34#define __rio_rio_h__
35 35
36#ifdef SCCS_LABELS
37static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
38#endif
39
40/*
41** 30.09.1998 ARG -
42** Introduced driver version and host card type strings
43*/
44#define RIO_DRV_STR "Specialix RIO Driver"
45#define RIO_AT_HOST_STR "ISA"
46#define RIO_PCI_HOST_STR "PCI"
47
48
49/*
50** rio_info_store() commands (arbitary values) :
51*/
52#define RIO_INFO_PUT 0xA4B3C2D1
53#define RIO_INFO_GET 0xF1E2D3C4
54
55
56/*
57** anything that I couldn't cram in somewhere else
58*/
59/*
60#ifndef RIODEBUG
61#define debug
62#else
63#define debug rioprint
64#endif
65*/
66
67
68/* 36/*
69** Maximum numbers of things 37** Maximum numbers of things
70*/ 38*/
@@ -101,9 +69,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
101/* 69/*
102** Flag values returned by functions 70** Flag values returned by functions
103*/ 71*/
72
104#define RIO_FAIL -1 73#define RIO_FAIL -1
105#define RIO_SUCCESS 0
106#define COPYFAIL -1 /* copy[in|out] failed */
107 74
108/* 75/*
109** SysPort value for something that hasn't any ports 76** SysPort value for something that hasn't any ports
@@ -142,30 +109,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
142/* 109/*
143** Generally useful constants 110** Generally useful constants
144*/ 111*/
145#define HALF_A_SECOND ((HZ)>>1) 112
146#define A_SECOND (HZ) 113#define HUNDRED_MS ((HZ/10)?(HZ/10):1)
147#define HUNDRED_HZ ((HZ/100)?(HZ/100):1)
148#define FIFTY_HZ ((HZ/50)?(HZ/50):1)
149#define TWENTY_HZ ((HZ/20)?(HZ/20):1)
150#define TEN_HZ ((HZ/10)?(HZ/10):1)
151#define FIVE_HZ ((HZ/5)?(HZ/5):1)
152#define HUNDRED_MS TEN_HZ
153#define FIFTY_MS TWENTY_HZ
154#define TWENTY_MS FIFTY_HZ
155#define TEN_MS HUNDRED_HZ
156#define TWO_SECONDS ((A_SECOND)*2)
157#define FIVE_SECONDS ((A_SECOND)*5)
158#define TEN_SECONDS ((A_SECOND)*10)
159#define FIFTEEN_SECONDS ((A_SECOND)*15)
160#define TWENTY_SECONDS ((A_SECOND)*20)
161#define HALF_A_MINUTE (A_MINUTE>>1)
162#define A_MINUTE (A_SECOND*60)
163#define FIVE_MINUTES (A_MINUTE*5)
164#define QUARTER_HOUR (A_MINUTE*15)
165#define HALF_HOUR (A_MINUTE*30)
166#define HOUR (A_MINUTE*60)
167
168#define SIXTEEN_MEG 0x1000000
169#define ONE_MEG 0x100000 114#define ONE_MEG 0x100000
170#define SIXTY_FOUR_K 0x10000 115#define SIXTY_FOUR_K 0x10000
171 116
@@ -173,8 +118,6 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
173#define RIO_EISA_MEM_SIZE SIXTY_FOUR_K 118#define RIO_EISA_MEM_SIZE SIXTY_FOUR_K
174#define RIO_MCA_MEM_SIZE SIXTY_FOUR_K 119#define RIO_MCA_MEM_SIZE SIXTY_FOUR_K
175 120
176#define POLL_VECTOR 0x100
177
178#define COOK_WELL 0 121#define COOK_WELL 0
179#define COOK_MEDIUM 1 122#define COOK_MEDIUM 1
180#define COOK_RAW 2 123#define COOK_RAW 2
@@ -186,69 +129,26 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
186** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and 129** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and
187** returns the offset into the DP RAM area. 130** returns the offset into the DP RAM area.
188*/ 131*/
189#define RIO_PTR(C,O) (((caddr_t)(C))+(0xFFFF&(O))) 132#define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O)))
190#define RIO_OFF(C,O) ((int)(O)-(int)(C)) 133#define RIO_OFF(C,O) ((long)(O)-(long)(C))
191 134
192/* 135/*
193** How to convert from various different device number formats: 136** How to convert from various different device number formats:
194** DEV is a dev number, as passed to open, close etc - NOT a minor 137** DEV is a dev number, as passed to open, close etc - NOT a minor
195** number! 138** number!
196** 139**/
197** Note: LynxOS only gives us 8 bits for the device minor number, 140
198** so all this crap here to deal with 'modem' bits etc. is
199** just a load of irrelevant old bunkum!
200** This however does not stop us needing to define a value
201** for RIO_MODEMOFFSET which is required by the 'riomkdev'
202** utility in the New Config Utilities suite.
203*/
204/* 0-511: direct 512-1023: modem */
205#define RIO_MODEMOFFSET 0x200 /* doesn't mean anything */
206#define RIO_MODEM_MASK 0x1FF 141#define RIO_MODEM_MASK 0x1FF
207#define RIO_MODEM_BIT 0x200 142#define RIO_MODEM_BIT 0x200
208#define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK) 143#define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK)
209#define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT) 144#define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT)
210#define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \ 145#define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \
211 + MINOR(DEV) 146 + MINOR(DEV)
212 147#define CSUM(pkt_ptr) (((u16 *)(pkt_ptr))[0] + ((u16 *)(pkt_ptr))[1] + \
213#define splrio spltty 148 ((u16 *)(pkt_ptr))[2] + ((u16 *)(pkt_ptr))[3] + \
214 149 ((u16 *)(pkt_ptr))[4] + ((u16 *)(pkt_ptr))[5] + \
215#define RIO_IPL 5 150 ((u16 *)(pkt_ptr))[6] + ((u16 *)(pkt_ptr))[7] + \
216#define RIO_PRI (PZERO+10) 151 ((u16 *)(pkt_ptr))[8] + ((u16 *)(pkt_ptr))[9] )
217#define RIO_CLOSE_PRI PZERO-1 /* uninterruptible sleeps for close */
218
219typedef struct DbInf {
220 uint Flag;
221 char Name[8];
222} DbInf;
223
224#ifndef TRUE
225#define TRUE (1==1)
226#endif
227#ifndef FALSE
228#define FALSE (!TRUE)
229#endif
230
231#define CSUM(pkt_ptr) (((ushort *)(pkt_ptr))[0] + ((ushort *)(pkt_ptr))[1] + \
232 ((ushort *)(pkt_ptr))[2] + ((ushort *)(pkt_ptr))[3] + \
233 ((ushort *)(pkt_ptr))[4] + ((ushort *)(pkt_ptr))[5] + \
234 ((ushort *)(pkt_ptr))[6] + ((ushort *)(pkt_ptr))[7] + \
235 ((ushort *)(pkt_ptr))[8] + ((ushort *)(pkt_ptr))[9] )
236
237/*
238** This happy little macro copies SIZE bytes of data from FROM to TO
239** quite well. SIZE must be a constant.
240*/
241#define CCOPY( FROM, TO, SIZE ) { *(struct s { char data[SIZE]; } *)(TO) = *(struct s *)(FROM); }
242
243/*
244** increment a buffer pointer modulo the size of the buffer...
245*/
246#define BUMP( P, I ) ((P) = (((P)+(I)) & RIOBufferMask))
247
248#define INIT_PACKET( PK, PP ) \
249{ \
250 *((uint *)PK) = PP->PacketInfo; \
251}
252 152
253#define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */ 153#define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */
254 /* prevent a really stupid race condition. */ 154 /* prevent a really stupid race condition. */
@@ -267,27 +167,42 @@ typedef struct DbInf {
267#define DISCONNECT 0 167#define DISCONNECT 0
268#define CONNECT 1 168#define CONNECT 1
269 169
170/* ------ Control Codes ------ */
270 171
271/* 172#define CONTROL '^'
272** Machine types - these must NOT overlap with product codes 0-15 173#define IFOAD ( CONTROL + 1 )
273*/ 174#define IDENTIFY ( CONTROL + 2 )
274#define RIO_MIPS_R3230 31 175#define ZOMBIE ( CONTROL + 3 )
275#define RIO_MIPS_R4030 32 176#define UFOAD ( CONTROL + 4 )
177#define IWAIT ( CONTROL + 5 )
178
179#define IFOAD_MAGIC 0xF0AD /* of course */
180#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
181#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
182#define IWAIT_MAGIC 0xB1DE /* Bide your time */
183
184/* ------ Error Codes ------ */
185
186#define E_NO_ERROR ((ushort) 0)
187
188/* ------ Free Lists ------ */
276 189
277#define RIO_IO_UNKNOWN -2 190struct rio_free_list {
191 u16 next;
192 u16 prev;
193};
278 194
279#undef MODERN 195/* NULL for card side linked lists */
280#define ERROR( E ) do { u.u_error = E; return OPENFAIL } while ( 0 ) 196#define TPNULL ((ushort)(0x8000))
197/* We can add another packet to a transmit queue if the packet pointer pointed
198 * to by the TxAdd pointer has PKT_IN_USE clear in its address. */
199#define PKT_IN_USE 0x1
281 200
282/* Defines for MPX line discipline routines */ 201/* ------ Topology ------ */
283 202
284#define DIST_LINESW_OPEN 0x01 203struct Top {
285#define DIST_LINESW_CLOSE 0x02 204 u8 Unit;
286#define DIST_LINESW_READ 0x04 205 u8 Link;
287#define DIST_LINESW_WRITE 0x08 206};
288#define DIST_LINESW_IOCTL 0x10
289#define DIST_LINESW_INPUT 0x20
290#define DIST_LINESW_OUTPUT 0x40
291#define DIST_LINESW_MDMINT 0x80
292 207
293#endif /* __rio_h__ */ 208#endif /* __rio_h__ */
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index c9af283a811d..78dd856534ce 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -57,15 +57,12 @@
57#include <asm/uaccess.h> 57#include <asm/uaccess.h>
58 58
59#include "linux_compat.h" 59#include "linux_compat.h"
60#include "typdef.h"
61#include "pkt.h" 60#include "pkt.h"
62#include "daemon.h" 61#include "daemon.h"
63#include "rio.h" 62#include "rio.h"
64#include "riospace.h" 63#include "riospace.h"
65#include "top.h"
66#include "cmdpkt.h" 64#include "cmdpkt.h"
67#include "map.h" 65#include "map.h"
68#include "riotypes.h"
69#include "rup.h" 66#include "rup.h"
70#include "port.h" 67#include "port.h"
71#include "riodrvr.h" 68#include "riodrvr.h"
@@ -78,17 +75,13 @@
78#include "unixrup.h" 75#include "unixrup.h"
79#include "board.h" 76#include "board.h"
80#include "host.h" 77#include "host.h"
81#include "error.h"
82#include "phb.h" 78#include "phb.h"
83#include "link.h" 79#include "link.h"
84#include "cmdblk.h" 80#include "cmdblk.h"
85#include "route.h" 81#include "route.h"
86#include "control.h"
87#include "cirrus.h" 82#include "cirrus.h"
88#include "rioioctl.h" 83#include "rioioctl.h"
89#include "param.h" 84#include "param.h"
90#include "list.h"
91#include "sam.h"
92#include "protsts.h" 85#include "protsts.h"
93#include "rioboard.h" 86#include "rioboard.h"
94 87
@@ -297,7 +290,7 @@ static void my_hd(void *ad, int len)
297 unsigned char *addr = ad; 290 unsigned char *addr = ad;
298 291
299 for (i = 0; i < len; i += 16) { 292 for (i = 0; i < len; i += 16) {
300 rio_dprintk(RIO_DEBUG_PARAM, "%08x ", (int) addr + i); 293 rio_dprintk(RIO_DEBUG_PARAM, "%08lx ", (unsigned long) addr + i);
301 for (j = 0; j < 16; j++) { 294 for (j = 0; j < 16; j++) {
302 rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : ""); 295 rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : "");
303 } 296 }
@@ -340,34 +333,19 @@ int RIODelay_ni(struct Port *PortP, int njiffies)
340 return !RIO_FAIL; 333 return !RIO_FAIL;
341} 334}
342 335
343 336void rio_copy_to_card(void *to, void *from, int len)
344int rio_minor(struct tty_struct *tty)
345{ 337{
346 return tty->index + (tty->driver == rio_driver) ? 0 : 256; 338 rio_memcpy_toio(NULL, to, from, len);
347} 339}
348 340
349 341int rio_minor(struct tty_struct *tty)
350int rio_ismodem(struct tty_struct *tty)
351{ 342{
352 return 1; 343 return tty->index + (tty->driver == rio_driver) ? 0 : 256;
353} 344}
354 345
355
356static int rio_set_real_termios(void *ptr) 346static int rio_set_real_termios(void *ptr)
357{ 347{
358 int rv, modem; 348 return RIOParam((struct Port *) ptr, CONFIG, 1, 1);
359 struct tty_struct *tty;
360 func_enter();
361
362 tty = ((struct Port *) ptr)->gs.tty;
363
364 modem = rio_ismodem(tty);
365
366 rv = RIOParam((struct Port *) ptr, CONFIG, modem, 1);
367
368 func_exit();
369
370 return rv;
371} 349}
372 350
373 351
@@ -379,7 +357,7 @@ static void rio_reset_interrupt(struct Host *HostP)
379 case RIO_AT: 357 case RIO_AT:
380 case RIO_MCA: 358 case RIO_MCA:
381 case RIO_PCI: 359 case RIO_PCI:
382 WBYTE(HostP->ResetInt, 0xff); 360 writeb(0xFF, &HostP->ResetInt);
383 } 361 }
384 362
385 func_exit(); 363 func_exit();
@@ -397,9 +375,6 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
397 /* AAargh! The order in which to do these things is essential and 375 /* AAargh! The order in which to do these things is essential and
398 not trivial. 376 not trivial.
399 377
400 - Rate limit goes before "recursive". Otherwise a series of
401 recursive calls will hang the machine in the interrupt routine.
402
403 - hardware twiddling goes before "recursive". Otherwise when we 378 - hardware twiddling goes before "recursive". Otherwise when we
404 poll the card, and a recursive interrupt happens, we won't 379 poll the card, and a recursive interrupt happens, we won't
405 ack the card, so it might keep on interrupting us. (especially 380 ack the card, so it might keep on interrupting us. (especially
@@ -414,26 +389,6 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
414 - The initialized test goes before recursive. 389 - The initialized test goes before recursive.
415 */ 390 */
416 391
417
418
419#ifdef IRQ_RATE_LIMIT
420 /* Aaargh! I'm ashamed. This costs more lines-of-code than the
421 actual interrupt routine!. (Well, used to when I wrote that comment) */
422 {
423 static int lastjif;
424 static int nintr = 0;
425
426 if (lastjif == jiffies) {
427 if (++nintr > IRQ_RATE_LIMIT) {
428 free_irq(HostP->Ivec, ptr);
429 printk(KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", HostP->Ivec);
430 }
431 } else {
432 lastjif = jiffies;
433 nintr = 0;
434 }
435 }
436#endif
437 rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); 392 rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");
438 if (HostP->Ivec == irq) { 393 if (HostP->Ivec == irq) {
439 /* Tell the card we've noticed the interrupt. */ 394 /* Tell the card we've noticed the interrupt. */
@@ -444,13 +399,13 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
444 return IRQ_HANDLED; 399 return IRQ_HANDLED;
445 400
446 if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) { 401 if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) {
447 printk(KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", (int) ptr, HostP->Ivec); 402 printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec);
448 return IRQ_HANDLED; 403 return IRQ_HANDLED;
449 } 404 }
450 405
451 RIOServiceHost(p, HostP, irq); 406 RIOServiceHost(p, HostP, irq);
452 407
453 rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", (int) ptr, HostP->Type); 408 rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type);
454 409
455 clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks); 410 clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks);
456 rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec); 411 rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
@@ -873,7 +828,7 @@ static int rio_init_datastructures(void)
873#define HOST_SZ sizeof(struct Host) 828#define HOST_SZ sizeof(struct Host)
874#define PORT_SZ sizeof(struct Port *) 829#define PORT_SZ sizeof(struct Port *)
875#define TMIO_SZ sizeof(struct termios *) 830#define TMIO_SZ sizeof(struct termios *)
876 rio_dprintk(RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); 831 rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
877 832
878 if (!(p = ckmalloc(RI_SZ))) 833 if (!(p = ckmalloc(RI_SZ)))
879 goto free0; 834 goto free0;
@@ -963,22 +918,21 @@ static void __exit rio_release_drivers(void)
963 918
964static void fix_rio_pci(struct pci_dev *pdev) 919static void fix_rio_pci(struct pci_dev *pdev)
965{ 920{
966 unsigned int hwbase; 921 unsigned long hwbase;
967 unsigned long rebase; 922 unsigned char *rebase;
968 unsigned int t; 923 unsigned int t;
969 924
970#define CNTRL_REG_OFFSET 0x50 925#define CNTRL_REG_OFFSET 0x50
971#define CNTRL_REG_GOODVALUE 0x18260000 926#define CNTRL_REG_GOODVALUE 0x18260000
972 927
973 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); 928 hwbase = pci_resource_start(pdev, 0);
974 hwbase &= PCI_BASE_ADDRESS_MEM_MASK; 929 rebase = ioremap(hwbase, 0x80);
975 rebase = (ulong) ioremap(hwbase, 0x80);
976 t = readl(rebase + CNTRL_REG_OFFSET); 930 t = readl(rebase + CNTRL_REG_OFFSET);
977 if (t != CNTRL_REG_GOODVALUE) { 931 if (t != CNTRL_REG_GOODVALUE) {
978 printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); 932 printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE);
979 writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); 933 writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
980 } 934 }
981 iounmap((char *) rebase); 935 iounmap(rebase);
982} 936}
983#endif 937#endif
984 938
@@ -994,7 +948,6 @@ static int __init rio_init(void)
994 948
995#ifdef CONFIG_PCI 949#ifdef CONFIG_PCI
996 struct pci_dev *pdev = NULL; 950 struct pci_dev *pdev = NULL;
997 unsigned int tint;
998 unsigned short tshort; 951 unsigned short tshort;
999#endif 952#endif
1000 953
@@ -1019,6 +972,8 @@ static int __init rio_init(void)
1019#ifdef CONFIG_PCI 972#ifdef CONFIG_PCI
1020 /* First look for the JET devices: */ 973 /* First look for the JET devices: */
1021 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) { 974 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) {
975 u32 tint;
976
1022 if (pci_enable_device(pdev)) 977 if (pci_enable_device(pdev))
1023 continue; 978 continue;
1024 979
@@ -1029,7 +984,6 @@ static int __init rio_init(void)
1029 Also, reading a non-aligned dword doesn't work. So we read the 984 Also, reading a non-aligned dword doesn't work. So we read the
1030 whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) 985 whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
1031 ourselves */ 986 ourselves */
1032 /* I don't know why the define doesn't work, constant 0x2c does --REW */
1033 pci_read_config_dword(pdev, 0x2c, &tint); 987 pci_read_config_dword(pdev, 0x2c, &tint);
1034 tshort = (tint >> 16) & 0xffff; 988 tshort = (tint >> 16) & 0xffff;
1035 rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); 989 rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
@@ -1039,33 +993,31 @@ static int __init rio_init(void)
1039 } 993 }
1040 rio_dprintk(RIO_DEBUG_PROBE, "cp1\n"); 994 rio_dprintk(RIO_DEBUG_PROBE, "cp1\n");
1041 995
1042 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint);
1043
1044 hp = &p->RIOHosts[p->RIONumHosts]; 996 hp = &p->RIOHosts[p->RIONumHosts];
1045 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; 997 hp->PaddrP = pci_resource_start(pdev, 2);
1046 hp->Ivec = pdev->irq; 998 hp->Ivec = pdev->irq;
1047 if (((1 << hp->Ivec) & rio_irqmask) == 0) 999 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1048 hp->Ivec = 0; 1000 hp->Ivec = 0;
1049 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1001 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1050 hp->CardP = (struct DpRam *) hp->Caddr; 1002 hp->CardP = (struct DpRam *) hp->Caddr;
1051 hp->Type = RIO_PCI; 1003 hp->Type = RIO_PCI;
1052 hp->Copy = rio_pcicopy; 1004 hp->Copy = rio_copy_to_card;
1053 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1005 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1054 spin_lock_init(&hp->HostLock); 1006 spin_lock_init(&hp->HostLock);
1055 rio_reset_interrupt(hp); 1007 rio_reset_interrupt(hp);
1056 rio_start_card_running(hp); 1008 rio_start_card_running(hp);
1057 1009
1058 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); 1010 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1059 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { 1011 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
1060 rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n"); 1012 rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n");
1061 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); 1013 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
1062 p->RIOHosts[p->RIONumHosts].UniqueNum = 1014 p->RIOHosts[p->RIONumHosts].UniqueNum =
1063 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | 1015 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1064 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); 1016 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1065 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1017 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1066 1018
1067 fix_rio_pci(pdev); 1019 fix_rio_pci(pdev);
1068 p->RIOLastPCISearch = RIO_SUCCESS; 1020 p->RIOLastPCISearch = 0;
1069 p->RIONumHosts++; 1021 p->RIONumHosts++;
1070 found++; 1022 found++;
1071 } else { 1023 } else {
@@ -1088,10 +1040,8 @@ static int __init rio_init(void)
1088 continue; 1040 continue;
1089 1041
1090#ifdef CONFIG_RIO_OLDPCI 1042#ifdef CONFIG_RIO_OLDPCI
1091 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint);
1092
1093 hp = &p->RIOHosts[p->RIONumHosts]; 1043 hp = &p->RIOHosts[p->RIONumHosts];
1094 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; 1044 hp->PaddrP = pci_resource_start(pdev, 0);
1095 hp->Ivec = pdev->irq; 1045 hp->Ivec = pdev->irq;
1096 if (((1 << hp->Ivec) & rio_irqmask) == 0) 1046 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1097 hp->Ivec = 0; 1047 hp->Ivec = 0;
@@ -1099,7 +1049,7 @@ static int __init rio_init(void)
1099 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1049 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1100 hp->CardP = (struct DpRam *) hp->Caddr; 1050 hp->CardP = (struct DpRam *) hp->Caddr;
1101 hp->Type = RIO_PCI; 1051 hp->Type = RIO_PCI;
1102 hp->Copy = rio_pcicopy; 1052 hp->Copy = rio_copy_to_card;
1103 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1053 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1104 spin_lock_init(&hp->HostLock); 1054 spin_lock_init(&hp->HostLock);
1105 1055
@@ -1109,14 +1059,14 @@ static int __init rio_init(void)
1109 rio_reset_interrupt(hp); 1059 rio_reset_interrupt(hp);
1110 rio_start_card_running(hp); 1060 rio_start_card_running(hp);
1111 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); 1061 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1112 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { 1062 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
1113 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); 1063 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
1114 p->RIOHosts[p->RIONumHosts].UniqueNum = 1064 p->RIOHosts[p->RIONumHosts].UniqueNum =
1115 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | 1065 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1116 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); 1066 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1117 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1067 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1118 1068
1119 p->RIOLastPCISearch = RIO_SUCCESS; 1069 p->RIOLastPCISearch = 0;
1120 p->RIONumHosts++; 1070 p->RIONumHosts++;
1121 found++; 1071 found++;
1122 } else { 1072 } else {
@@ -1137,8 +1087,8 @@ static int __init rio_init(void)
1137 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1087 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1138 hp->CardP = (struct DpRam *) hp->Caddr; 1088 hp->CardP = (struct DpRam *) hp->Caddr;
1139 hp->Type = RIO_AT; 1089 hp->Type = RIO_AT;
1140 hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL 1090 hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL
1141 * -- YES! this is now a normal copy. Only the 1091 * -- YES! this is now a normal copy. Only the
1142 * old PCI card uses the special PCI copy. 1092 * old PCI card uses the special PCI copy.
1143 * Moreover, the ISA card will work with the 1093 * Moreover, the ISA card will work with the
1144 * special PCI copy anyway. -- REW */ 1094 * special PCI copy anyway. -- REW */
@@ -1150,7 +1100,7 @@ static int __init rio_init(void)
1150 okboard = 0; 1100 okboard = 0;
1151 if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) { 1101 if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) {
1152 /* Board is present... */ 1102 /* Board is present... */
1153 if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) { 1103 if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == 0) {
1154 /* ... and feeling fine!!!! */ 1104 /* ... and feeling fine!!!! */
1155 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1105 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1156 if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) { 1106 if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {
@@ -1252,24 +1202,3 @@ static void __exit rio_exit(void)
1252 1202
1253module_init(rio_init); 1203module_init(rio_init);
1254module_exit(rio_exit); 1204module_exit(rio_exit);
1255
1256/*
1257 * Anybody who knows why this doesn't work for me, please tell me -- REW.
1258 * Snatched from scsi.c (fixed one spelling error):
1259 * Overrides for Emacs so that we follow Linus' tabbing style.
1260 * Emacs will notice this stuff at the end of the file and automatically
1261 * adjust the settings for this buffer only. This must remain at the end
1262 * of the file.
1263 * ---------------------------------------------------------------------------
1264 * Local Variables:
1265 * c-indent-level: 4
1266 * c-brace-imaginary-offset: 0
1267 * c-brace-offset: -4
1268 * c-argdecl-indent: 4
1269 * c-label-offset: -4
1270 * c-continued-statement-offset: 4
1271 * c-continued-brace-offset: 0
1272 * indent-tabs-mode: nil
1273 * tab-width: 8
1274 * End:
1275 */
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
index 92df43552f15..acda9326c2ef 100644
--- a/drivers/char/rio/rioboot.c
+++ b/drivers/char/rio/rioboot.c
@@ -30,38 +30,29 @@
30** ----------------------------------------------------------------------------- 30** -----------------------------------------------------------------------------
31*/ 31*/
32 32
33#ifdef SCCS_LABELS
34static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
35#endif
36
37#include <linux/module.h> 33#include <linux/module.h>
38#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/termios.h>
36#include <linux/serial.h>
37#include <asm/semaphore.h>
38#include <linux/generic_serial.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/delay.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/system.h> 43#include <asm/system.h>
43#include <asm/string.h> 44#include <asm/string.h>
44#include <asm/semaphore.h> 45#include <asm/uaccess.h>
45
46
47#include <linux/termios.h>
48#include <linux/serial.h>
49
50#include <linux/generic_serial.h>
51
52 46
53 47
54#include "linux_compat.h" 48#include "linux_compat.h"
55#include "rio_linux.h" 49#include "rio_linux.h"
56#include "typdef.h"
57#include "pkt.h" 50#include "pkt.h"
58#include "daemon.h" 51#include "daemon.h"
59#include "rio.h" 52#include "rio.h"
60#include "riospace.h" 53#include "riospace.h"
61#include "top.h"
62#include "cmdpkt.h" 54#include "cmdpkt.h"
63#include "map.h" 55#include "map.h"
64#include "riotypes.h"
65#include "rup.h" 56#include "rup.h"
66#include "port.h" 57#include "port.h"
67#include "riodrvr.h" 58#include "riodrvr.h"
@@ -74,161 +65,130 @@ static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
74#include "unixrup.h" 65#include "unixrup.h"
75#include "board.h" 66#include "board.h"
76#include "host.h" 67#include "host.h"
77#include "error.h"
78#include "phb.h" 68#include "phb.h"
79#include "link.h" 69#include "link.h"
80#include "cmdblk.h" 70#include "cmdblk.h"
81#include "route.h" 71#include "route.h"
82 72
83static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP ); 73static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP);
84 74
85static uchar 75static const unsigned char RIOAtVec2Ctrl[] = {
86RIOAtVec2Ctrl[] = 76 /* 0 */ INTERRUPT_DISABLE,
87{ 77 /* 1 */ INTERRUPT_DISABLE,
88 /* 0 */ INTERRUPT_DISABLE, 78 /* 2 */ INTERRUPT_DISABLE,
89 /* 1 */ INTERRUPT_DISABLE, 79 /* 3 */ INTERRUPT_DISABLE,
90 /* 2 */ INTERRUPT_DISABLE, 80 /* 4 */ INTERRUPT_DISABLE,
91 /* 3 */ INTERRUPT_DISABLE, 81 /* 5 */ INTERRUPT_DISABLE,
92 /* 4 */ INTERRUPT_DISABLE, 82 /* 6 */ INTERRUPT_DISABLE,
93 /* 5 */ INTERRUPT_DISABLE, 83 /* 7 */ INTERRUPT_DISABLE,
94 /* 6 */ INTERRUPT_DISABLE, 84 /* 8 */ INTERRUPT_DISABLE,
95 /* 7 */ INTERRUPT_DISABLE, 85 /* 9 */ IRQ_9 | INTERRUPT_ENABLE,
96 /* 8 */ INTERRUPT_DISABLE,
97 /* 9 */ IRQ_9|INTERRUPT_ENABLE,
98 /* 10 */ INTERRUPT_DISABLE, 86 /* 10 */ INTERRUPT_DISABLE,
99 /* 11 */ IRQ_11|INTERRUPT_ENABLE, 87 /* 11 */ IRQ_11 | INTERRUPT_ENABLE,
100 /* 12 */ IRQ_12|INTERRUPT_ENABLE, 88 /* 12 */ IRQ_12 | INTERRUPT_ENABLE,
101 /* 13 */ INTERRUPT_DISABLE, 89 /* 13 */ INTERRUPT_DISABLE,
102 /* 14 */ INTERRUPT_DISABLE, 90 /* 14 */ INTERRUPT_DISABLE,
103 /* 15 */ IRQ_15|INTERRUPT_ENABLE 91 /* 15 */ IRQ_15 | INTERRUPT_ENABLE
104}; 92};
105 93
106/* 94/**
107** Load in the RTA boot code. 95 * RIOBootCodeRTA - Load RTA boot code
108*/ 96 * @p: RIO to load
109int 97 * @rbp: Download descriptor
110RIOBootCodeRTA(p, rbp) 98 *
111struct rio_info * p; 99 * Called when the user process initiates booting of the card firmware.
112struct DownLoad * rbp; 100 * Lads the firmware
101 */
102
103int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp)
113{ 104{
114 int offset; 105 int offset;
115 106
116 func_enter (); 107 func_enter();
117 108
118 /* Linux doesn't allow you to disable interrupts during a 109 rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP);
119 "copyin". (Crash when a pagefault occurs). */
120 /* disable(oldspl); */
121
122 rio_dprintk (RIO_DEBUG_BOOT, "Data at user address 0x%x\n",(int)rbp->DataP);
123 110
124 /* 111 /*
125 ** Check that we have set asside enough memory for this 112 ** Check that we have set asside enough memory for this
126 */ 113 */
127 if ( rbp->Count > SIXTY_FOUR_K ) { 114 if (rbp->Count > SIXTY_FOUR_K) {
128 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n"); 115 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
129 p->RIOError.Error = HOST_FILE_TOO_LARGE; 116 p->RIOError.Error = HOST_FILE_TOO_LARGE;
130 /* restore(oldspl); */ 117 func_exit();
131 func_exit ();
132 return -ENOMEM; 118 return -ENOMEM;
133 } 119 }
134 120
135 if ( p->RIOBooting ) { 121 if (p->RIOBooting) {
136 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n"); 122 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
137 p->RIOError.Error = BOOT_IN_PROGRESS; 123 p->RIOError.Error = BOOT_IN_PROGRESS;
138 /* restore(oldspl); */ 124 func_exit();
139 func_exit ();
140 return -EBUSY; 125 return -EBUSY;
141 } 126 }
142 127
143 /* 128 /*
144 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary, 129 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary,
145 ** so calculate how far we have to move the data up the buffer 130 ** so calculate how far we have to move the data up the buffer
146 ** to achieve this. 131 ** to achieve this.
147 */ 132 */
148 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % 133 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
149 RTA_BOOT_DATA_SIZE;
150 134
151 /* 135 /*
152 ** Be clean, and clear the 'unused' portion of the boot buffer, 136 ** Be clean, and clear the 'unused' portion of the boot buffer,
153 ** because it will (eventually) be part of the Rta run time environment 137 ** because it will (eventually) be part of the Rta run time environment
154 ** and so should be zeroed. 138 ** and so should be zeroed.
155 */ 139 */
156 bzero( (caddr_t)p->RIOBootPackets, offset ); 140 memset(p->RIOBootPackets, 0, offset);
157 141
158 /* 142 /*
159 ** Copy the data from user space. 143 ** Copy the data from user space into the array
160 */ 144 */
161 145
162 if ( copyin((int)rbp->DataP,((caddr_t)(p->RIOBootPackets))+offset, 146 if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) {
163 rbp->Count) ==COPYFAIL ) { 147 rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n");
164 rio_dprintk (RIO_DEBUG_BOOT, "Bad data copy from user space\n");
165 p->RIOError.Error = COPYIN_FAILED; 148 p->RIOError.Error = COPYIN_FAILED;
166 /* restore(oldspl); */ 149 func_exit();
167 func_exit ();
168 return -EFAULT; 150 return -EFAULT;
169 } 151 }
170 152
171 /* 153 /*
172 ** Make sure that our copy of the size includes that offset we discussed 154 ** Make sure that our copy of the size includes that offset we discussed
173 ** earlier. 155 ** earlier.
174 */ 156 */
175 p->RIONumBootPkts = (rbp->Count+offset)/RTA_BOOT_DATA_SIZE; 157 p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE;
176 p->RIOBootCount = rbp->Count; 158 p->RIOBootCount = rbp->Count;
177 159
178 /* restore(oldspl); */
179 func_exit(); 160 func_exit();
180 return 0; 161 return 0;
181} 162}
182 163
183void rio_start_card_running (struct Host * HostP) 164/**
184{ 165 * rio_start_card_running - host card start
185 func_enter (); 166 * @HostP: The RIO to kick off
167 *
168 * Start a RIO processor unit running. Encapsulates the knowledge
169 * of the card type.
170 */
186 171
187 switch ( HostP->Type ) { 172void rio_start_card_running(struct Host *HostP)
173{
174 switch (HostP->Type) {
188 case RIO_AT: 175 case RIO_AT:
189 rio_dprintk (RIO_DEBUG_BOOT, "Start ISA card running\n"); 176 rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n");
190 WBYTE(HostP->Control, 177 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control);
191 BOOT_FROM_RAM | EXTERNAL_BUS_ON
192 | HostP->Mode
193 | RIOAtVec2Ctrl[HostP->Ivec & 0xF] );
194 break;
195
196#ifdef FUTURE_RELEASE
197 case RIO_MCA:
198 /*
199 ** MCA handles IRQ vectors differently, so we don't write
200 ** them to this register.
201 */
202 rio_dprintk (RIO_DEBUG_BOOT, "Start MCA card running\n");
203 WBYTE(HostP->Control, McaTpBootFromRam | McaTpBusEnable | HostP->Mode);
204 break; 178 break;
205
206 case RIO_EISA:
207 /*
208 ** EISA is totally different and expects OUTBZs to turn it on.
209 */
210 rio_dprintk (RIO_DEBUG_BOOT, "Start EISA card running\n");
211 OUTBZ( HostP->Slot, EISA_CONTROL_PORT, HostP->Mode | RIOEisaVec2Ctrl[HostP->Ivec] | EISA_TP_RUN | EISA_TP_BUS_ENABLE | EISA_TP_BOOT_FROM_RAM );
212 break;
213#endif
214
215 case RIO_PCI: 179 case RIO_PCI:
216 /* 180 /*
217 ** PCI is much the same as MCA. Everything is once again memory 181 ** PCI is much the same as MCA. Everything is once again memory
218 ** mapped, so we are writing to memory registers instead of io 182 ** mapped, so we are writing to memory registers instead of io
219 ** ports. 183 ** ports.
220 */ 184 */
221 rio_dprintk (RIO_DEBUG_BOOT, "Start PCI card running\n"); 185 rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n");
222 WBYTE(HostP->Control, PCITpBootFromRam | PCITpBusEnable | HostP->Mode); 186 writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control);
223 break; 187 break;
224 default: 188 default:
225 rio_dprintk (RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type); 189 rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
226 break; 190 break;
227 } 191 }
228/*
229 printk (KERN_INFO "Done with starting the card\n");
230 func_exit ();
231*/
232 return; 192 return;
233} 193}
234 194
@@ -239,370 +199,350 @@ void rio_start_card_running (struct Host * HostP)
239** Put your rubber pants on before messing with this code - even the magic 199** Put your rubber pants on before messing with this code - even the magic
240** numbers have trouble understanding what they are doing here. 200** numbers have trouble understanding what they are doing here.
241*/ 201*/
242int 202
243RIOBootCodeHOST(p, rbp) 203int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
244struct rio_info * p;
245register struct DownLoad *rbp;
246{ 204{
247 register struct Host *HostP; 205 struct Host *HostP;
248 register caddr_t Cad; 206 u8 *Cad;
249 register PARM_MAP *ParmMapP; 207 PARM_MAP *ParmMapP;
250 register int RupN; 208 int RupN;
251 int PortN; 209 int PortN;
252 uint host; 210 unsigned int host;
253 caddr_t StartP; 211 u8 *StartP;
254 BYTE *DestP; 212 u8 *DestP;
255 int wait_count; 213 int wait_count;
256 ushort OldParmMap; 214 u16 OldParmMap;
257 ushort offset; /* It is very important that this is a ushort */ 215 u16 offset; /* It is very important that this is a u16 */
258 /* uint byte; */ 216 u8 *DownCode = NULL;
259 caddr_t DownCode = NULL;
260 unsigned long flags; 217 unsigned long flags;
261 218
262 HostP = NULL; /* Assure the compiler we've initialized it */ 219 HostP = NULL; /* Assure the compiler we've initialized it */
263 for ( host=0; host<p->RIONumHosts; host++ ) { 220
264 rio_dprintk (RIO_DEBUG_BOOT, "Attempt to boot host %d\n",host); 221
222 /* Walk the hosts */
223 for (host = 0; host < p->RIONumHosts; host++) {
224 rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host);
265 HostP = &p->RIOHosts[host]; 225 HostP = &p->RIOHosts[host];
266
267 rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n",
268 HostP->Type, HostP->Mode, HostP->Ivec);
269 226
227 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
270 228
271 if ( (HostP->Flags & RUN_STATE) != RC_WAITING ) { 229 /* Don't boot hosts already running */
272 rio_dprintk (RIO_DEBUG_BOOT, "%s %d already running\n","Host",host); 230 if ((HostP->Flags & RUN_STATE) != RC_WAITING) {
231 rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host);
273 continue; 232 continue;
274 } 233 }
275 234
276 /* 235 /*
277 ** Grab a 32 bit pointer to the card. 236 ** Grab a pointer to the card (ioremapped)
278 */ 237 */
279 Cad = HostP->Caddr; 238 Cad = HostP->Caddr;
280 239
281 /* 240 /*
282 ** We are going to (try) and load in rbp->Count bytes. 241 ** We are going to (try) and load in rbp->Count bytes.
283 ** The last byte will reside at p->RIOConf.HostLoadBase-1; 242 ** The last byte will reside at p->RIOConf.HostLoadBase-1;
284 ** Therefore, we need to start copying at address 243 ** Therefore, we need to start copying at address
285 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count) 244 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count)
286 */ 245 */
287 StartP = (caddr_t)&Cad[p->RIOConf.HostLoadBase-rbp->Count]; 246 StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count];
288 247
289 rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for host is 0x%x\n", (int)Cad ); 248 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad);
290 rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for download is 0x%x\n", (int)StartP); 249 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP);
291 rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase); 250 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
292 rio_dprintk (RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count); 251 rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
293 252
294 if ( p->RIOConf.HostLoadBase < rbp->Count ) { 253 /* Make sure it fits */
295 rio_dprintk (RIO_DEBUG_BOOT, "Bin too large\n"); 254 if (p->RIOConf.HostLoadBase < rbp->Count) {
255 rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n");
296 p->RIOError.Error = HOST_FILE_TOO_LARGE; 256 p->RIOError.Error = HOST_FILE_TOO_LARGE;
297 func_exit (); 257 func_exit();
298 return -EFBIG; 258 return -EFBIG;
299 } 259 }
300 /* 260 /*
301 ** Ensure that the host really is stopped. 261 ** Ensure that the host really is stopped.
302 ** Disable it's external bus & twang its reset line. 262 ** Disable it's external bus & twang its reset line.
303 */ 263 */
304 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); 264 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
305
306 /*
307 ** Copy the data directly from user space to the SRAM.
308 ** This ain't going to be none too clever if the download
309 ** code is bigger than this segment.
310 */
311 rio_dprintk (RIO_DEBUG_BOOT, "Copy in code\n");
312 265
313 /* 266 /*
314 ** PCI hostcard can't cope with 32 bit accesses and so need to copy 267 ** Copy the data directly from user space to the SRAM.
315 ** data to a local buffer, and then dripfeed the card. 268 ** This ain't going to be none too clever if the download
316 */ 269 ** code is bigger than this segment.
317 if ( HostP->Type == RIO_PCI ) { 270 */
318 /* int offset; */ 271 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
319 272
320 DownCode = sysbrk(rbp->Count); 273 /* Buffer to local memory as we want to use I/O space and
321 if ( !DownCode ) { 274 some cards only do 8 or 16 bit I/O */
322 rio_dprintk (RIO_DEBUG_BOOT, "No system memory available\n"); 275
323 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY; 276 DownCode = vmalloc(rbp->Count);
324 func_exit (); 277 if (!DownCode) {
325 return -ENOMEM; 278 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
326 } 279 func_exit();
327 bzero(DownCode, rbp->Count); 280 return -ENOMEM;
328
329 if ( copyin((int)rbp->DataP,DownCode,rbp->Count)==COPYFAIL ) {
330 rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n");
331 sysfree( DownCode, rbp->Count );
332 p->RIOError.Error = COPYIN_FAILED;
333 func_exit ();
334 return -EFAULT;
335 }
336
337 HostP->Copy( DownCode, StartP, rbp->Count );
338
339 sysfree( DownCode, rbp->Count );
340 } 281 }
341 else if ( copyin((int)rbp->DataP,StartP,rbp->Count)==COPYFAIL ) { 282 if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) {
342 rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n"); 283 kfree(DownCode);
343 p->RIOError.Error = COPYIN_FAILED; 284 p->RIOError.Error = COPYIN_FAILED;
344 func_exit (); 285 func_exit();
345 return -EFAULT; 286 return -EFAULT;
346 } 287 }
288 HostP->Copy(DownCode, StartP, rbp->Count);
289 vfree(DownCode);
347 290
348 rio_dprintk (RIO_DEBUG_BOOT, "Copy completed\n"); 291 rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n");
349 292
350 /* 293 /*
351 ** S T O P ! 294 ** S T O P !
352 ** 295 **
353 ** Upto this point the code has been fairly rational, and possibly 296 ** Upto this point the code has been fairly rational, and possibly
354 ** even straight forward. What follows is a pile of crud that will 297 ** even straight forward. What follows is a pile of crud that will
355 ** magically turn into six bytes of transputer assembler. Normally 298 ** magically turn into six bytes of transputer assembler. Normally
356 ** you would expect an array or something, but, being me, I have 299 ** you would expect an array or something, but, being me, I have
357 ** chosen [been told] to use a technique whereby the startup code 300 ** chosen [been told] to use a technique whereby the startup code
358 ** will be correct if we change the loadbase for the code. Which 301 ** will be correct if we change the loadbase for the code. Which
359 ** brings us onto another issue - the loadbase is the *end* of the 302 ** brings us onto another issue - the loadbase is the *end* of the
360 ** code, not the start. 303 ** code, not the start.
361 ** 304 **
362 ** If I were you I wouldn't start from here. 305 ** If I were you I wouldn't start from here.
363 */ 306 */
364 307
365 /* 308 /*
366 ** We now need to insert a short boot section into 309 ** We now need to insert a short boot section into
367 ** the memory at the end of Sram2. This is normally (de)composed 310 ** the memory at the end of Sram2. This is normally (de)composed
368 ** of the last eight bytes of the download code. The 311 ** of the last eight bytes of the download code. The
369 ** download has been assembled/compiled to expect to be 312 ** download has been assembled/compiled to expect to be
370 ** loaded from 0x7FFF downwards. We have loaded it 313 ** loaded from 0x7FFF downwards. We have loaded it
371 ** at some other address. The startup code goes into the small 314 ** at some other address. The startup code goes into the small
372 ** ram window at Sram2, in the last 8 bytes, which are really 315 ** ram window at Sram2, in the last 8 bytes, which are really
373 ** at addresses 0x7FF8-0x7FFF. 316 ** at addresses 0x7FF8-0x7FFF.
374 ** 317 **
375 ** If the loadbase is, say, 0x7C00, then we need to branch to 318 ** If the loadbase is, say, 0x7C00, then we need to branch to
376 ** address 0x7BFE to run the host.bin startup code. We assemble 319 ** address 0x7BFE to run the host.bin startup code. We assemble
377 ** this jump manually. 320 ** this jump manually.
378 ** 321 **
379 ** The two byte sequence 60 08 is loaded into memory at address 322 ** The two byte sequence 60 08 is loaded into memory at address
380 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0, 323 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0,
381 ** which adds '0' to the .O register, complements .O, and then shifts 324 ** which adds '0' to the .O register, complements .O, and then shifts
382 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will 325 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will
383 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new 326 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new
384 ** location. Now, the branch starts from the value of .PC (or .IP or 327 ** location. Now, the branch starts from the value of .PC (or .IP or
385 ** whatever the bloody register is called on this chip), and the .PC 328 ** whatever the bloody register is called on this chip), and the .PC
386 ** will be pointing to the location AFTER the branch, in this case 329 ** will be pointing to the location AFTER the branch, in this case
387 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8. 330 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8.
388 ** 331 **
389 ** A long branch is coded at 0x7FF8. This consists of loading a four 332 ** A long branch is coded at 0x7FF8. This consists of loading a four
390 ** byte offset into .O using nfix (as above) and pfix operators. The 333 ** byte offset into .O using nfix (as above) and pfix operators. The
391 ** pfix operates in exactly the same way as the nfix operator, but 334 ** pfix operates in exactly the same way as the nfix operator, but
392 ** without the complement operation. The offset, of course, must be 335 ** without the complement operation. The offset, of course, must be
393 ** relative to the address of the byte AFTER the branch instruction, 336 ** relative to the address of the byte AFTER the branch instruction,
394 ** which will be (urm) 0x7FFC, so, our final destination of the branch 337 ** which will be (urm) 0x7FFC, so, our final destination of the branch
395 ** (loadbase-2), has to be reached from here. Imagine that the loadbase 338 ** (loadbase-2), has to be reached from here. Imagine that the loadbase
396 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which 339 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which
397 ** is the first byte of the initial two byte short local branch of the 340 ** is the first byte of the initial two byte short local branch of the
398 ** download code). 341 ** download code).
399 ** 342 **
400 ** To code a jump from 0x7FFC (which is where the branch will start 343 ** To code a jump from 0x7FFC (which is where the branch will start
401 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)= 344 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)=
402 ** 0x7BFE. 345 ** 0x7BFE.
403 ** This will be coded as four bytes: 346 ** This will be coded as four bytes:
404 ** 60 2C 20 02 347 ** 60 2C 20 02
405 ** being nfix .O+0 348 ** being nfix .O+0
406 ** pfix .O+C 349 ** pfix .O+C
407 ** pfix .O+0 350 ** pfix .O+0
408 ** jump .O+2 351 ** jump .O+2
409 ** 352 **
410 ** The nfix operator is used, so that the startup code will be 353 ** The nfix operator is used, so that the startup code will be
411 ** compatible with the whole Tp family. (lies, damn lies, it'll never 354 ** compatible with the whole Tp family. (lies, damn lies, it'll never
412 ** work in a month of Sundays). 355 ** work in a month of Sundays).
413 ** 356 **
414 ** The nfix nyble is the 1s complement of the nyble value you 357 ** The nfix nyble is the 1s complement of the nyble value you
415 ** want to load - in this case we wanted 'F' so we nfix loaded '0'. 358 ** want to load - in this case we wanted 'F' so we nfix loaded '0'.
416 */ 359 */
417 360
418 361
419 /* 362 /*
420 ** Dest points to the top 8 bytes of Sram2. The Tp jumps 363 ** Dest points to the top 8 bytes of Sram2. The Tp jumps
421 ** to 0x7FFE at reset time, and starts executing. This is 364 ** to 0x7FFE at reset time, and starts executing. This is
422 ** a short branch to 0x7FF8, where a long branch is coded. 365 ** a short branch to 0x7FF8, where a long branch is coded.
423 */ 366 */
424 367
425 DestP = (BYTE *)&Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ 368 DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
426 369
427#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */ 370#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */
428#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */ 371#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */
429#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */ 372#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */
430 373
431 /* 374 /*
432 ** 0x7FFC is the address of the location following the last byte of 375 ** 0x7FFC is the address of the location following the last byte of
433 ** the four byte jump instruction. 376 ** the four byte jump instruction.
434 ** READ THE ABOVE COMMENTS 377 ** READ THE ABOVE COMMENTS
435 ** 378 **
436 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about. 379 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about.
437 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned, 380 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned,
438 ** cos I don't understand 2's complement). 381 ** cos I don't understand 2's complement).
439 */ 382 */
440 offset = (p->RIOConf.HostLoadBase-2)-0x7FFC; 383 offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC;
441 WBYTE( DestP[0] , NFIX(((ushort)(~offset) >> (ushort)12) & 0xF) ); 384
442 WBYTE( DestP[1] , PFIX(( offset >> 8) & 0xF) ); 385 writeb(NFIX(((unsigned short) (~offset) >> (unsigned short) 12) & 0xF), DestP);
443 WBYTE( DestP[2] , PFIX(( offset >> 4) & 0xF) ); 386 writeb(PFIX((offset >> 8) & 0xF), DestP + 1);
444 WBYTE( DestP[3] , JUMP( offset & 0xF) ); 387 writeb(PFIX((offset >> 4) & 0xF), DestP + 2);
445 388 writeb(JUMP(offset & 0xF), DestP + 3);
446 WBYTE( DestP[6] , NFIX(0) ); 389
447 WBYTE( DestP[7] , JUMP(8) ); 390 writeb(NFIX(0), DestP + 6);
448 391 writeb(JUMP(8), DestP + 7);
449 rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase); 392
450 rio_dprintk (RIO_DEBUG_BOOT, "startup offset is 0x%x\n",offset); 393 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
394 rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset);
451 395
452 /* 396 /*
453 ** Flag what is going on 397 ** Flag what is going on
454 */ 398 */
455 HostP->Flags &= ~RUN_STATE; 399 HostP->Flags &= ~RUN_STATE;
456 HostP->Flags |= RC_STARTUP; 400 HostP->Flags |= RC_STARTUP;
457 401
458 /* 402 /*
459 ** Grab a copy of the current ParmMap pointer, so we 403 ** Grab a copy of the current ParmMap pointer, so we
460 ** can tell when it has changed. 404 ** can tell when it has changed.
461 */ 405 */
462 OldParmMap = RWORD(HostP->__ParmMapR); 406 OldParmMap = readw(&HostP->__ParmMapR);
463 407
464 rio_dprintk (RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n",OldParmMap); 408 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
465 409
466 /* 410 /*
467 ** And start it running (I hope). 411 ** And start it running (I hope).
468 ** As there is nothing dodgy or obscure about the 412 ** As there is nothing dodgy or obscure about the
469 ** above code, this is guaranteed to work every time. 413 ** above code, this is guaranteed to work every time.
470 */ 414 */
471 rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", 415 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
472 HostP->Type, HostP->Mode, HostP->Ivec);
473 416
474 rio_start_card_running(HostP); 417 rio_start_card_running(HostP);
475 418
476 rio_dprintk (RIO_DEBUG_BOOT, "Set control port\n"); 419 rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n");
477 420
478 /* 421 /*
479 ** Now, wait for upto five seconds for the Tp to setup the parmmap 422 ** Now, wait for upto five seconds for the Tp to setup the parmmap
480 ** pointer: 423 ** pointer:
481 */ 424 */
482 for ( wait_count=0; (wait_count<p->RIOConf.StartupTime)&& 425 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) {
483 (RWORD(HostP->__ParmMapR)==OldParmMap); wait_count++ ) { 426 rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR));
484 rio_dprintk (RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n",wait_count,RWORD(HostP->__ParmMapR)); 427 mdelay(100);
485 delay(HostP, HUNDRED_MS);
486 428
487 } 429 }
488 430
489 /* 431 /*
490 ** If the parmmap pointer is unchanged, then the host code 432 ** If the parmmap pointer is unchanged, then the host code
491 ** has crashed & burned in a really spectacular way 433 ** has crashed & burned in a really spectacular way
492 */ 434 */
493 if ( RWORD(HostP->__ParmMapR) == OldParmMap ) { 435 if (readw(&HostP->__ParmMapR) == OldParmMap) {
494 rio_dprintk (RIO_DEBUG_BOOT, "parmmap 0x%x\n", RWORD(HostP->__ParmMapR)); 436 rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR));
495 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n"); 437 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
496 438 HostP->Flags &= ~RUN_STATE;
497#define HOST_DISABLE \ 439 HostP->Flags |= RC_STUFFED;
498 HostP->Flags &= ~RUN_STATE; \ 440 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
499 HostP->Flags |= RC_STUFFED; \ 441 continue;
500 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );\
501 continue
502
503 HOST_DISABLE;
504 } 442 }
505 443
506 rio_dprintk (RIO_DEBUG_BOOT, "Running 0x%x\n", RWORD(HostP->__ParmMapR)); 444 rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR));
507 445
508 /* 446 /*
509 ** Well, the board thought it was OK, and setup its parmmap 447 ** Well, the board thought it was OK, and setup its parmmap
510 ** pointer. For the time being, we will pretend that this 448 ** pointer. For the time being, we will pretend that this
511 ** board is running, and check out what the error flag says. 449 ** board is running, and check out what the error flag says.
512 */ 450 */
513 451
514 /* 452 /*
515 ** Grab a 32 bit pointer to the parmmap structure 453 ** Grab a 32 bit pointer to the parmmap structure
516 */ 454 */
517 ParmMapP = (PARM_MAP *)RIO_PTR(Cad,RWORD(HostP->__ParmMapR)); 455 ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR));
518 rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP); 456 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
519 ParmMapP = (PARM_MAP *)((unsigned long)Cad + 457 ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR));
520 (unsigned long)((RWORD((HostP->__ParmMapR))) & 0xFFFF)); 458 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
521 rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP);
522 459
523 /* 460 /*
524 ** The links entry should be 0xFFFF; we set it up 461 ** The links entry should be 0xFFFF; we set it up
525 ** with a mask to say how many PHBs to use, and 462 ** with a mask to say how many PHBs to use, and
526 ** which links to use. 463 ** which links to use.
527 */ 464 */
528 if ( (RWORD(ParmMapP->links) & 0xFFFF) != 0xFFFF ) { 465 if (readw(&ParmMapP->links) != 0xFFFF) {
529 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 466 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
530 rio_dprintk (RIO_DEBUG_BOOT, "Links = 0x%x\n",RWORD(ParmMapP->links)); 467 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links));
531 HOST_DISABLE; 468 HostP->Flags &= ~RUN_STATE;
469 HostP->Flags |= RC_STUFFED;
470 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
471 continue;
532 } 472 }
533 473
534 WWORD(ParmMapP->links , RIO_LINK_ENABLE); 474 writew(RIO_LINK_ENABLE, &ParmMapP->links);
535 475
536 /* 476 /*
537 ** now wait for the card to set all the parmmap->XXX stuff 477 ** now wait for the card to set all the parmmap->XXX stuff
538 ** this is a wait of upto two seconds.... 478 ** this is a wait of upto two seconds....
539 */ 479 */
540 rio_dprintk (RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n",p->RIOConf.StartupTime); 480 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
541 HostP->timeout_id = 0; 481 HostP->timeout_id = 0;
542 for ( wait_count=0; (wait_count<p->RIOConf.StartupTime) && 482 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) {
543 !RWORD(ParmMapP->init_done); wait_count++ ) { 483 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
544 rio_dprintk (RIO_DEBUG_BOOT, "Waiting for init_done\n"); 484 mdelay(100);
545 delay(HostP, HUNDRED_MS);
546 } 485 }
547 rio_dprintk (RIO_DEBUG_BOOT, "OK! init_done!\n"); 486 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
548 487
549 if (RWORD(ParmMapP->error) != E_NO_ERROR || 488 if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) {
550 !RWORD(ParmMapP->init_done) ) { 489 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
551 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 490 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
552 rio_dprintk (RIO_DEBUG_BOOT, "Timedout waiting for init_done\n"); 491 HostP->Flags &= ~RUN_STATE;
553 HOST_DISABLE; 492 HostP->Flags |= RC_STUFFED;
493 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
494 continue;
554 } 495 }
555 496
556 rio_dprintk (RIO_DEBUG_BOOT, "Got init_done\n"); 497 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
557 498
558 /* 499 /*
559 ** It runs! It runs! 500 ** It runs! It runs!
560 */ 501 */
561 rio_dprintk (RIO_DEBUG_BOOT, "Host ID %x Running\n",HostP->UniqueNum); 502 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
562 503
563 /* 504 /*
564 ** set the time period between interrupts. 505 ** set the time period between interrupts.
565 */ 506 */
566 WWORD(ParmMapP->timer, (short)p->RIOConf.Timer ); 507 writew(p->RIOConf.Timer, &ParmMapP->timer);
567 508
568 /* 509 /*
569 ** Translate all the 16 bit pointers in the __ParmMapR into 510 ** Translate all the 16 bit pointers in the __ParmMapR into
570 ** 32 bit pointers for the driver. 511 ** 32 bit pointers for the driver in ioremap space.
571 */ 512 */
572 HostP->ParmMapP = ParmMapP; 513 HostP->ParmMapP = ParmMapP;
573 HostP->PhbP = (PHB*)RIO_PTR(Cad,RWORD(ParmMapP->phb_ptr)); 514 HostP->PhbP = (struct PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
574 HostP->RupP = (RUP*)RIO_PTR(Cad,RWORD(ParmMapP->rups)); 515 HostP->RupP = (struct RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups));
575 HostP->PhbNumP = (ushort*)RIO_PTR(Cad,RWORD(ParmMapP->phb_num_ptr)); 516 HostP->PhbNumP = (unsigned short *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
576 HostP->LinkStrP = (LPB*)RIO_PTR(Cad,RWORD(ParmMapP->link_str_ptr)); 517 HostP->LinkStrP = (struct LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
577 518
578 /* 519 /*
579 ** point the UnixRups at the real Rups 520 ** point the UnixRups at the real Rups
580 */ 521 */
581 for ( RupN = 0; RupN<MAX_RUP; RupN++ ) { 522 for (RupN = 0; RupN < MAX_RUP; RupN++) {
582 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN]; 523 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
583 HostP->UnixRups[RupN].Id = RupN+1; 524 HostP->UnixRups[RupN].Id = RupN + 1;
584 HostP->UnixRups[RupN].BaseSysPort = NO_PORT; 525 HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
585 spin_lock_init(&HostP->UnixRups[RupN].RupLock); 526 spin_lock_init(&HostP->UnixRups[RupN].RupLock);
586 } 527 }
587 528
588 for ( RupN = 0; RupN<LINKS_PER_UNIT; RupN++ ) { 529 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
589 HostP->UnixRups[RupN+MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup; 530 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
590 HostP->UnixRups[RupN+MAX_RUP].Id = 0; 531 HostP->UnixRups[RupN + MAX_RUP].Id = 0;
591 HostP->UnixRups[RupN+MAX_RUP].BaseSysPort = NO_PORT; 532 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
592 spin_lock_init(&HostP->UnixRups[RupN+MAX_RUP].RupLock); 533 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
593 } 534 }
594 535
595 /* 536 /*
596 ** point the PortP->Phbs at the real Phbs 537 ** point the PortP->Phbs at the real Phbs
597 */ 538 */
598 for ( PortN=p->RIOFirstPortsMapped; 539 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
599 PortN<p->RIOLastPortsMapped+PORTS_PER_RTA; PortN++ ) { 540 if (p->RIOPortp[PortN]->HostP == HostP) {
600 if ( p->RIOPortp[PortN]->HostP == HostP ) {
601 struct Port *PortP = p->RIOPortp[PortN]; 541 struct Port *PortP = p->RIOPortp[PortN];
602 struct PHB *PhbP; 542 struct PHB *PhbP;
603 /* int oldspl; */ 543 /* int oldspl; */
604 544
605 if ( !PortP->Mapped ) 545 if (!PortP->Mapped)
606 continue; 546 continue;
607 547
608 PhbP = &HostP->PhbP[PortP->HostPort]; 548 PhbP = &HostP->PhbP[PortP->HostPort];
@@ -610,641 +550,522 @@ register struct DownLoad *rbp;
610 550
611 PortP->PhbP = PhbP; 551 PortP->PhbP = PhbP;
612 552
613 PortP->TxAdd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_add)); 553 PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add));
614 PortP->TxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_start)); 554 PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start));
615 PortP->TxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_end)); 555 PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end));
616 PortP->RxRemove = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_remove)); 556 PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
617 PortP->RxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_start)); 557 PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start));
618 PortP->RxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_end)); 558 PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end));
619 559
620 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 560 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
621 /* 561 /*
622 ** point the UnixRup at the base SysPort 562 ** point the UnixRup at the base SysPort
623 */ 563 */
624 if ( !(PortN % PORTS_PER_RTA) ) 564 if (!(PortN % PORTS_PER_RTA))
625 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN; 565 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
626 } 566 }
627 } 567 }
628 568
629 rio_dprintk (RIO_DEBUG_BOOT, "Set the card running... \n"); 569 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
630 /* 570 /*
631 ** last thing - show the world that everything is in place 571 ** last thing - show the world that everything is in place
632 */ 572 */
633 HostP->Flags &= ~RUN_STATE; 573 HostP->Flags &= ~RUN_STATE;
634 HostP->Flags |= RC_RUNNING; 574 HostP->Flags |= RC_RUNNING;
635 } 575 }
636 /* 576 /*
637 ** MPX always uses a poller. This is actually patched into the system 577 ** MPX always uses a poller. This is actually patched into the system
638 ** configuration and called directly from each clock tick. 578 ** configuration and called directly from each clock tick.
639 ** 579 **
640 */ 580 */
641 p->RIOPolling = 1; 581 p->RIOPolling = 1;
642 582
643 p->RIOSystemUp++; 583 p->RIOSystemUp++;
644 584
645 rio_dprintk (RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec); 585 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
646 func_exit (); 586 func_exit();
647 return 0; 587 return 0;
648} 588}
649 589
650 590
651 591
652/* 592/**
653** Boot an RTA. If we have successfully processed this boot, then 593 * RIOBootRup - Boot an RTA
654** return 1. If we havent, then return 0. 594 * @p: rio we are working with
655*/ 595 * @Rup: Rup number
656int 596 * @HostP: host object
657RIOBootRup( p, Rup, HostP, PacketP) 597 * @PacketP: packet to use
658struct rio_info * p; 598 *
659uint Rup; 599 * If we have successfully processed this boot, then
660struct Host *HostP; 600 * return 1. If we havent, then return 0.
661struct PKT *PacketP; 601 */
602
603int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP)
662{ 604{
663 struct PktCmd *PktCmdP = (struct PktCmd *)PacketP->data; 605 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
664 struct PktCmd_M *PktReplyP; 606 struct PktCmd_M *PktReplyP;
665 struct CmdBlk *CmdBlkP; 607 struct CmdBlk *CmdBlkP;
666 uint sequence; 608 unsigned int sequence;
667 609
668 /* 610 /*
669 ** If we haven't been told what to boot, we can't boot it. 611 ** If we haven't been told what to boot, we can't boot it.
670 */ 612 */
671 if ( p->RIONumBootPkts == 0 ) { 613 if (p->RIONumBootPkts == 0) {
672 rio_dprintk (RIO_DEBUG_BOOT, "No RTA code to download yet\n"); 614 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
673 return 0; 615 return 0;
674 } 616 }
675 617
676 /* rio_dprint(RIO_DEBUG_BOOT, NULL,DBG_BOOT,"Incoming command packet\n"); */
677 /* ShowPacket( DBG_BOOT, PacketP ); */
678
679 /* 618 /*
680 ** Special case of boot completed - if we get one of these then we 619 ** Special case of boot completed - if we get one of these then we
681 ** don't need a command block. For all other cases we do, so handle 620 ** don't need a command block. For all other cases we do, so handle
682 ** this first and then get a command block, then handle every other 621 ** this first and then get a command block, then handle every other
683 ** case, relinquishing the command block if disaster strikes! 622 ** case, relinquishing the command block if disaster strikes!
684 */ 623 */
685 if ( (RBYTE(PacketP->len) & PKT_CMD_BIT) && 624 if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED))
686 (RBYTE(PktCmdP->Command)==BOOT_COMPLETED) ) 625 return RIOBootComplete(p, HostP, Rup, PktCmdP);
687 return RIOBootComplete(p, HostP, Rup, PktCmdP );
688 626
689 /* 627 /*
690 ** try to unhook a command block from the command free list. 628 ** Try to allocate a command block. This is in kernel space
691 */ 629 */
692 if ( !(CmdBlkP = RIOGetCmdBlk()) ) { 630 if (!(CmdBlkP = RIOGetCmdBlk())) {
693 rio_dprintk (RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n"); 631 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
694 return 0; 632 return 0;
695 } 633 }
696 634
697 /* 635 /*
698 ** Fill in the default info on the command block 636 ** Fill in the default info on the command block
699 */ 637 */
700 CmdBlkP->Packet.dest_unit = Rup < (ushort)MAX_RUP ? Rup : 0; 638 CmdBlkP->Packet.dest_unit = Rup < (unsigned short) MAX_RUP ? Rup : 0;
701 CmdBlkP->Packet.dest_port = BOOT_RUP; 639 CmdBlkP->Packet.dest_port = BOOT_RUP;
702 CmdBlkP->Packet.src_unit = 0; 640 CmdBlkP->Packet.src_unit = 0;
703 CmdBlkP->Packet.src_port = BOOT_RUP; 641 CmdBlkP->Packet.src_port = BOOT_RUP;
704 642
705 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL; 643 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
706 PktReplyP = (struct PktCmd_M *)CmdBlkP->Packet.data; 644 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
707 645
708 /* 646 /*
709 ** process COMMANDS on the boot rup! 647 ** process COMMANDS on the boot rup!
710 */ 648 */
711 if ( RBYTE(PacketP->len) & PKT_CMD_BIT ) { 649 if (readb(&PacketP->len) & PKT_CMD_BIT) {
712 /* 650 /*
713 ** We only expect one type of command - a BOOT_REQUEST! 651 ** We only expect one type of command - a BOOT_REQUEST!
714 */ 652 */
715 if ( RBYTE(PktCmdP->Command) != BOOT_REQUEST ) { 653 if (readb(&PktCmdP->Command) != BOOT_REQUEST) {
716 rio_dprintk (RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %d\n", 654 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts);
717 PktCmdP->Command,Rup,HostP-p->RIOHosts); 655 RIOFreeCmdBlk(CmdBlkP);
718 ShowPacket( DBG_BOOT, PacketP );
719 RIOFreeCmdBlk( CmdBlkP );
720 return 1; 656 return 1;
721 } 657 }
722 658
723 /* 659 /*
724 ** Build a Boot Sequence command block 660 ** Build a Boot Sequence command block
725 ** 661 **
726 ** 02.03.1999 ARG - ESIL 0820 fix 662 ** We no longer need to use "Boot Mode", we'll always allow
727 ** We no longer need to use "Boot Mode", we'll always allow 663 ** boot requests - the boot will not complete if the device
728 ** boot requests - the boot will not complete if the device 664 ** appears in the bindings table.
729 ** appears in the bindings table. 665 **
730 ** So, this conditional is not required ... 666 ** We'll just (always) set the command field in packet reply
731 ** 667 ** to allow an attempted boot sequence :
732 if (p->RIOBootMode == RC_BOOT_NONE) 668 */
733 **
734 ** If the system is in slave mode, and a boot request is
735 ** received, set command to BOOT_ABORT so that the boot
736 ** will not complete.
737 **
738 PktReplyP->Command = BOOT_ABORT;
739 else
740 **
741 ** We'll just (always) set the command field in packet reply
742 ** to allow an attempted boot sequence :
743 */
744 PktReplyP->Command = BOOT_SEQUENCE; 669 PktReplyP->Command = BOOT_SEQUENCE;
745 670
746 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts; 671 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
747 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase; 672 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
748 PktReplyP->BootSequence.CodeSize = p->RIOBootCount; 673 PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
749 674
750 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT; 675 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
751 676
752 bcopy("BOOT",(void *)&CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN],4); 677 memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4);
753 678
754 rio_dprintk (RIO_DEBUG_BOOT, "Boot RTA on Host %d Rup %d - %d (0x%x) packets to 0x%x\n", 679 rio_dprintk(RIO_DEBUG_BOOT, "Boot RTA on Host %Zd Rup %d - %d (0x%x) packets to 0x%x\n", HostP - p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts, p->RIOConf.RtaLoadBase);
755 HostP-p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts,
756 p->RIOConf.RtaLoadBase);
757 680
758 /* 681 /*
759 ** If this host is in slave mode, send the RTA an invalid boot 682 ** If this host is in slave mode, send the RTA an invalid boot
760 ** sequence command block to force it to kill the boot. We wait 683 ** sequence command block to force it to kill the boot. We wait
761 ** for half a second before sending this packet to prevent the RTA 684 ** for half a second before sending this packet to prevent the RTA
762 ** attempting to boot too often. The master host should then grab 685 ** attempting to boot too often. The master host should then grab
763 ** the RTA and make it its own. 686 ** the RTA and make it its own.
764 */ 687 */
765 p->RIOBooting++; 688 p->RIOBooting++;
766 RIOQueueCmdBlk( HostP, Rup, CmdBlkP ); 689 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
767 return 1; 690 return 1;
768 } 691 }
769 692
770 /* 693 /*
771 ** It is a request for boot data. 694 ** It is a request for boot data.
772 */ 695 */
773 sequence = RWORD(PktCmdP->Sequence); 696 sequence = readw(&PktCmdP->Sequence);
774 697
775 rio_dprintk (RIO_DEBUG_BOOT, "Boot block %d on Host %d Rup%d\n",sequence,HostP-p->RIOHosts,Rup); 698 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
776 699
777 if ( sequence >= p->RIONumBootPkts ) { 700 if (sequence >= p->RIONumBootPkts) {
778 rio_dprintk (RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, 701 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
779 p->RIONumBootPkts);
780 ShowPacket( DBG_BOOT, PacketP );
781 } 702 }
782 703
783 PktReplyP->Sequence = sequence; 704 PktReplyP->Sequence = sequence;
784 705 memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE);
785 bcopy( p->RIOBootPackets[ p->RIONumBootPkts - sequence - 1 ],
786 PktReplyP->BootData, RTA_BOOT_DATA_SIZE );
787
788 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN; 706 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
789 ShowPacket( DBG_BOOT, &CmdBlkP->Packet ); 707 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
790 RIOQueueCmdBlk( HostP, Rup, CmdBlkP );
791 return 1; 708 return 1;
792} 709}
793 710
794/* 711/**
795** This function is called when an RTA been booted. 712 * RIOBootComplete - RTA boot is done
796** If booted by a host, HostP->HostUniqueNum is the booting host. 713 * @p: RIO we are working with
797** If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA. 714 * @HostP: Host structure
798** RtaUniq is the booted RTA. 715 * @Rup: RUP being used
799*/ 716 * @PktCmdP: Packet command that was used
800static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP ) 717 *
718 * This function is called when an RTA been booted.
719 * If booted by a host, HostP->HostUniqueNum is the booting host.
720 * If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA.
721 * RtaUniq is the booted RTA.
722 */
723
724static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP)
801{ 725{
802 struct Map *MapP = NULL; 726 struct Map *MapP = NULL;
803 struct Map *MapP2 = NULL; 727 struct Map *MapP2 = NULL;
804 int Flag; 728 int Flag;
805 int found; 729 int found;
806 int host, rta; 730 int host, rta;
807 int EmptySlot = -1; 731 int EmptySlot = -1;
808 int entry, entry2; 732 int entry, entry2;
809 char *MyType, *MyName; 733 char *MyType, *MyName;
810 uint MyLink; 734 unsigned int MyLink;
811 ushort RtaType; 735 unsigned short RtaType;
812 uint RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + 736 u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
813 (RBYTE(PktCmdP->UniqNum[1]) << 8) + 737
814 (RBYTE(PktCmdP->UniqNum[2]) << 16) +
815 (RBYTE(PktCmdP->UniqNum[3]) << 24);
816
817 /* Was RIOBooting-- . That's bad. If an RTA sends two of them, the
818 driver will never think that the RTA has booted... -- REW */
819 p->RIOBooting = 0; 738 p->RIOBooting = 0;
820 739
821 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting); 740 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
822 741
823 /* 742 /*
824 ** Determine type of unit (16/8 port RTA). 743 ** Determine type of unit (16/8 port RTA).
825 */ 744 */
745
826 RtaType = GetUnitType(RtaUniq); 746 RtaType = GetUnitType(RtaUniq);
827 if ( Rup >= (ushort)MAX_RUP ) { 747 if (Rup >= (unsigned short) MAX_RUP)
828 rio_dprintk (RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", 748 rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
829 HostP->Name, 8 * RtaType, RBYTE(PktCmdP->LinkNum)+'A'); 749 else
830 } else { 750 rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
831 rio_dprintk (RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n",
832 HostP->Mapping[Rup].Name, 8 * RtaType,
833 RBYTE(PktCmdP->LinkNum)+'A');
834 }
835 751
836 rio_dprintk (RIO_DEBUG_BOOT, "UniqNum is 0x%x\n",RtaUniq); 752 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
837 753
838 if ( ( RtaUniq == 0x00000000 ) || ( RtaUniq == 0xffffffff ) ) 754 if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) {
839 { 755 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
840 rio_dprintk (RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n"); 756 return 1;
841 return TRUE;
842 } 757 }
843 758
844 /* 759 /*
845 ** If this RTA has just booted an RTA which doesn't belong to this 760 ** If this RTA has just booted an RTA which doesn't belong to this
846 ** system, or the system is in slave mode, do not attempt to create 761 ** system, or the system is in slave mode, do not attempt to create
847 ** a new table entry for it. 762 ** a new table entry for it.
848 */ 763 */
849 if (!RIOBootOk(p, HostP, RtaUniq)) 764
850 { 765 if (!RIOBootOk(p, HostP, RtaUniq)) {
851 MyLink = RBYTE(PktCmdP->LinkNum); 766 MyLink = readb(&PktCmdP->LinkNum);
852 if (Rup < (ushort) MAX_RUP) 767 if (Rup < (unsigned short) MAX_RUP) {
853 { 768 /*
854 /* 769 ** RtaUniq was clone booted (by this RTA). Instruct this RTA
855 ** RtaUniq was clone booted (by this RTA). Instruct this RTA 770 ** to hold off further attempts to boot on this link for 30
856 ** to hold off further attempts to boot on this link for 30 771 ** seconds.
857 ** seconds. 772 */
858 */ 773 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
859 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) 774 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
860 { 775 }
861 rio_dprintk (RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 776 } else
862 'A' + MyLink); 777 /*
863 } 778 ** RtaUniq was booted by this host. Set the booting link
864 } 779 ** to hold off for 30 seconds to give another unit a
865 else 780 ** chance to boot it.
866 { 781 */
867 /* 782 writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot);
868 ** RtaUniq was booted by this host. Set the booting link 783 rio_dprintk(RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n", RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
869 ** to hold off for 30 seconds to give another unit a 784 return 1;
870 ** chance to boot it.
871 */
872 WWORD(HostP->LinkStrP[MyLink].WaitNoBoot, 30);
873 }
874 rio_dprintk (RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n",
875 RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
876 return TRUE;
877 } 785 }
878 786
879 /* 787 /*
880 ** Check for a SLOT_IN_USE entry for this RTA attached to the 788 ** Check for a SLOT_IN_USE entry for this RTA attached to the
881 ** current host card in the driver table. 789 ** current host card in the driver table.
882 ** 790 **
883 ** If it exists, make a note that we have booted it. Other parts of 791 ** If it exists, make a note that we have booted it. Other parts of
884 ** the driver are interested in this information at a later date, 792 ** the driver are interested in this information at a later date,
885 ** in particular when the booting RTA asks for an ID for this unit, 793 ** in particular when the booting RTA asks for an ID for this unit,
886 ** we must have set the BOOTED flag, and the NEWBOOT flag is used 794 ** we must have set the BOOTED flag, and the NEWBOOT flag is used
887 ** to force an open on any ports that where previously open on this 795 ** to force an open on any ports that where previously open on this
888 ** unit. 796 ** unit.
889 */ 797 */
890 for ( entry=0; entry<MAX_RUP; entry++ ) 798 for (entry = 0; entry < MAX_RUP; entry++) {
891 { 799 unsigned int sysport;
892 uint sysport; 800
893 801 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
894 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && 802 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
895 (HostP->Mapping[entry].RtaUniqueNum==RtaUniq)) 803 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
896 { 804 if (sysport < p->RIOFirstPortsBooted)
897 HostP->Mapping[entry].Flags |= RTA_BOOTED|RTA_NEWBOOT; 805 p->RIOFirstPortsBooted = sysport;
898#ifdef NEED_TO_FIX 806 if (sysport > p->RIOLastPortsBooted)
899 RIO_SV_BROADCAST(HostP->svFlags[entry]); 807 p->RIOLastPortsBooted = sysport;
900#endif 808 /*
901 if ( (sysport=HostP->Mapping[entry].SysPort) != NO_PORT ) 809 ** For a 16 port RTA, check the second bank of 8 ports
902 { 810 */
903 if ( sysport < p->RIOFirstPortsBooted ) 811 if (RtaType == TYPE_RTA16) {
904 p->RIOFirstPortsBooted = sysport; 812 entry2 = HostP->Mapping[entry].ID2 - 1;
905 if ( sysport > p->RIOLastPortsBooted ) 813 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
906 p->RIOLastPortsBooted = sysport; 814 sysport = HostP->Mapping[entry2].SysPort;
907 /* 815 if (sysport < p->RIOFirstPortsBooted)
908 ** For a 16 port RTA, check the second bank of 8 ports 816 p->RIOFirstPortsBooted = sysport;
909 */ 817 if (sysport > p->RIOLastPortsBooted)
910 if (RtaType == TYPE_RTA16) 818 p->RIOLastPortsBooted = sysport;
911 { 819 }
912 entry2 = HostP->Mapping[entry].ID2 - 1; 820 }
913 HostP->Mapping[entry2].Flags |= RTA_BOOTED|RTA_NEWBOOT; 821 if (RtaType == TYPE_RTA16)
914#ifdef NEED_TO_FIX 822 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
915 RIO_SV_BROADCAST(HostP->svFlags[entry2]); 823 else
916#endif 824 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
917 sysport = HostP->Mapping[entry2].SysPort; 825 return 1;
918 if ( sysport < p->RIOFirstPortsBooted )
919 p->RIOFirstPortsBooted = sysport;
920 if ( sysport > p->RIOLastPortsBooted )
921 p->RIOLastPortsBooted = sysport;
922 }
923 }
924 if (RtaType == TYPE_RTA16) {
925 rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n",
926 entry+1, entry2+1);
927 } else {
928 rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given ID %d\n",entry+1);
929 } 826 }
930 return TRUE;
931 }
932 } 827 }
933 828
934 rio_dprintk (RIO_DEBUG_BOOT, "RTA not configured for this host\n"); 829 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
935 830
936 if ( Rup >= (ushort)MAX_RUP ) 831 if (Rup >= (unsigned short) MAX_RUP) {
937 { 832 /*
938 /* 833 ** It was a host that did the booting
939 ** It was a host that did the booting 834 */
940 */ 835 MyType = "Host";
941 MyType = "Host"; 836 MyName = HostP->Name;
942 MyName = HostP->Name; 837 } else {
943 } 838 /*
944 else 839 ** It was an RTA that did the booting
945 { 840 */
946 /* 841 MyType = "RTA";
947 ** It was an RTA that did the booting 842 MyName = HostP->Mapping[Rup].Name;
948 */
949 MyType = "RTA";
950 MyName = HostP->Mapping[Rup].Name;
951 } 843 }
952 MyLink = RBYTE(PktCmdP->LinkNum); 844 MyLink = readb(&PktCmdP->LinkNum);
953 845
954 /* 846 /*
955 ** There is no SLOT_IN_USE entry for this RTA attached to the current 847 ** There is no SLOT_IN_USE entry for this RTA attached to the current
956 ** host card in the driver table. 848 ** host card in the driver table.
957 ** 849 **
958 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the 850 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the
959 ** current host card in the driver table. 851 ** current host card in the driver table.
960 ** 852 **
961 ** If we find one, then we re-use that slot. 853 ** If we find one, then we re-use that slot.
962 */ 854 */
963 for ( entry=0; entry<MAX_RUP; entry++ ) 855 for (entry = 0; entry < MAX_RUP; entry++) {
964 { 856 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
965 if ( (HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && 857 if (RtaType == TYPE_RTA16) {
966 (HostP->Mapping[entry].RtaUniqueNum == RtaUniq) ) 858 entry2 = HostP->Mapping[entry].ID2 - 1;
967 { 859 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
968 if (RtaType == TYPE_RTA16) 860 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
969 { 861 else
970 entry2 = HostP->Mapping[entry].ID2 - 1; 862 continue;
971 if ( (HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && 863 } else
972 (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq) ) 864 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
973 rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", 865 if (!p->RIONoMessage)
974 entry, entry2); 866 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
975 else 867 return 1;
976 continue;
977 } 868 }
978 else
979 rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n",entry);
980 if (! p->RIONoMessage)
981 cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
982 return TRUE;
983 }
984 } 869 }
985 870
986 /* 871 /*
987 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 872 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
988 ** attached to the current host card in the driver table. 873 ** attached to the current host card in the driver table.
989 ** 874 **
990 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another 875 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another
991 ** host for this RTA in the driver table. 876 ** host for this RTA in the driver table.
992 ** 877 **
993 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA 878 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA
994 ** entry from the other host and add it to this host (using some of 879 ** entry from the other host and add it to this host (using some of
995 ** the functions from table.c which do this). 880 ** the functions from table.c which do this).
996 ** For a SLOT_TENTATIVE entry on another host, we must cope with the 881 ** For a SLOT_TENTATIVE entry on another host, we must cope with the
997 ** following scenario: 882 ** following scenario:
998 ** 883 **
999 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry 884 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry
1000 ** in table) 885 ** in table)
1001 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE 886 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE
1002 ** entries) 887 ** entries)
1003 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE) 888 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE)
1004 ** + Unplug RTA and plug back into host A. 889 ** + Unplug RTA and plug back into host A.
1005 ** + Configure RTA on host A. We now have the same RTA configured 890 ** + Configure RTA on host A. We now have the same RTA configured
1006 ** with different ports on two different hosts. 891 ** with different ports on two different hosts.
1007 */ 892 */
1008 rio_dprintk (RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq ); 893 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
1009 found = 0; 894 found = 0;
1010 Flag = 0; /* Convince the compiler this variable is initialized */ 895 Flag = 0; /* Convince the compiler this variable is initialized */
1011 for ( host = 0; !found && (host < p->RIONumHosts); host++ ) 896 for (host = 0; !found && (host < p->RIONumHosts); host++) {
1012 { 897 for (rta = 0; rta < MAX_RUP; rta++) {
1013 for ( rta=0; rta<MAX_RUP; rta++ ) 898 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
1014 { 899 Flag = p->RIOHosts[host].Mapping[rta].Flags;
1015 if ((p->RIOHosts[host].Mapping[rta].Flags & 900 MapP = &p->RIOHosts[host].Mapping[rta];
1016 (SLOT_IN_USE | SLOT_TENTATIVE)) && 901 if (RtaType == TYPE_RTA16) {
1017 (p->RIOHosts[host].Mapping[rta].RtaUniqueNum==RtaUniq)) 902 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
1018 { 903 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
1019 Flag = p->RIOHosts[host].Mapping[rta].Flags; 904 } else
1020 MapP = &p->RIOHosts[host].Mapping[rta]; 905 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
1021 if (RtaType == TYPE_RTA16) 906 found = 1;
1022 { 907 break;
1023 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1]; 908 }
1024 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n",
1025 rta+1, MapP->ID2, p->RIOHosts[host].Name);
1026 }
1027 else
1028 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n",
1029 rta+1, p->RIOHosts[host].Name);
1030 found = 1;
1031 break;
1032 } 909 }
1033 }
1034 } 910 }
1035 911
1036 /* 912 /*
1037 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 913 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1038 ** attached to the current host card in the driver table. 914 ** attached to the current host card in the driver table.
1039 ** 915 **
1040 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on 916 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on
1041 ** another host for this RTA in the driver table... 917 ** another host for this RTA in the driver table...
1042 ** 918 **
1043 ** Check for a SLOT_IN_USE entry for this RTA in the config table. 919 ** Check for a SLOT_IN_USE entry for this RTA in the config table.
1044 */ 920 */
1045 if ( !MapP ) 921 if (!MapP) {
1046 { 922 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
1047 rio_dprintk (RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n",RtaUniq); 923 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
1048 for ( rta=0; rta < TOTAL_MAP_ENTRIES; rta++ ) 924 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
1049 { 925
1050 rio_dprintk (RIO_DEBUG_BOOT, "Check table entry %d (%x)", 926 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
1051 rta, 927 MapP = &p->RIOSavedTable[rta];
1052 p->RIOSavedTable[rta].RtaUniqueNum); 928 Flag = p->RIOSavedTable[rta].Flags;
1053 929 if (RtaType == TYPE_RTA16) {
1054 if ( (p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && 930 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
1055 (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq) ) 931 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
1056 { 932 break;
1057 MapP = &p->RIOSavedTable[rta]; 933 }
1058 Flag = p->RIOSavedTable[rta].Flags; 934 MapP2 = &p->RIOSavedTable[entry2];
1059 if (RtaType == TYPE_RTA16) 935 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
1060 { 936 } else
1061 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; 937 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
1062 entry2++) 938 break;
1063 { 939 }
1064 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
1065 break;
1066 }
1067 MapP2 = &p->RIOSavedTable[entry2];
1068 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n",
1069 rta, entry2);
1070 }
1071 else
1072 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
1073 break;
1074 } 940 }
1075 }
1076 } 941 }
1077 942
1078 /* 943 /*
1079 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 944 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1080 ** attached to the current host card in the driver table. 945 ** attached to the current host card in the driver table.
1081 ** 946 **
1082 ** We may have found a SLOT_IN_USE entry on another host for this 947 ** We may have found a SLOT_IN_USE entry on another host for this
1083 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry 948 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry
1084 ** on another host for this RTA in the driver table. 949 ** on another host for this RTA in the driver table.
1085 ** 950 **
1086 ** Check the driver table for room to fit this newly discovered RTA. 951 ** Check the driver table for room to fit this newly discovered RTA.
1087 ** RIOFindFreeID() first looks for free slots and if it does not 952 ** RIOFindFreeID() first looks for free slots and if it does not
1088 ** find any free slots it will then attempt to oust any 953 ** find any free slots it will then attempt to oust any
1089 ** tentative entry in the table. 954 ** tentative entry in the table.
1090 */ 955 */
1091 EmptySlot = 1; 956 EmptySlot = 1;
1092 if (RtaType == TYPE_RTA16) 957 if (RtaType == TYPE_RTA16) {
1093 { 958 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
1094 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) 959 RIODefaultName(p, HostP, entry);
1095 { 960 rio_fill_host_slot(entry, entry2, RtaUniq, HostP);
1096 RIODefaultName(p, HostP, entry); 961 EmptySlot = 0;
1097 FillSlot(entry, entry2, RtaUniq, HostP); 962 }
1098 EmptySlot = 0; 963 } else {
1099 } 964 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
1100 } 965 RIODefaultName(p, HostP, entry);
1101 else 966 rio_fill_host_slot(entry, 0, RtaUniq, HostP);
1102 { 967 EmptySlot = 0;
1103 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) 968 }
1104 {
1105 RIODefaultName(p, HostP, entry);
1106 FillSlot(entry, 0, RtaUniq, HostP);
1107 EmptySlot = 0;
1108 }
1109 } 969 }
1110 970
1111 /* 971 /*
1112 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 972 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1113 ** attached to the current host card in the driver table. 973 ** attached to the current host card in the driver table.
1114 ** 974 **
1115 ** If we found a SLOT_IN_USE entry on another host for this 975 ** If we found a SLOT_IN_USE entry on another host for this
1116 ** RTA in the config or driver table, and there are enough free 976 ** RTA in the config or driver table, and there are enough free
1117 ** slots in the driver table, then we need to move it over and 977 ** slots in the driver table, then we need to move it over and
1118 ** delete it from the other host. 978 ** delete it from the other host.
1119 ** If we found a SLOT_TENTATIVE entry on another host for this 979 ** If we found a SLOT_TENTATIVE entry on another host for this
1120 ** RTA in the driver table, just delete the other host entry. 980 ** RTA in the driver table, just delete the other host entry.
1121 */ 981 */
1122 if (EmptySlot == 0) 982 if (EmptySlot == 0) {
1123 { 983 if (MapP) {
1124 if ( MapP ) 984 if (Flag & SLOT_IN_USE) {
1125 { 985 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
1126 if (Flag & SLOT_IN_USE) 986 HostP->Mapping[entry].SysPort = MapP->SysPort;
1127 { 987 memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN);
1128 rio_dprintk (RIO_DEBUG_BOOT, 988 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
1129 "This RTA configured on another host - move entry to current host (1)\n"); 989 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
1130 HostP->Mapping[entry].SysPort = MapP->SysPort; 990 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
1131 CCOPY( MapP->Name, HostP->Mapping[entry].Name, MAX_NAME_LEN ); 991 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
1132 HostP->Mapping[entry].Flags = 992 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
1133 SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT; 993 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
1134#ifdef NEED_TO_FIX 994 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
1135 RIO_SV_BROADCAST(HostP->svFlags[entry]); 995 } else {
1136#endif 996 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
1137 RIOReMapPorts( p, HostP, &HostP->Mapping[entry] ); 997 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
1138 if ( HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted ) 998 }
1139 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort; 999 if (RtaType == TYPE_RTA16) {
1140 if ( HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted ) 1000 if (Flag & SLOT_IN_USE) {
1141 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort; 1001 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1142 rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",(int)MapP->SysPort,MapP->Name); 1002 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1143 } 1003 /*
1144 else 1004 ** Map second block of ttys for 16 port RTA
1145 { 1005 */
1146 rio_dprintk (RIO_DEBUG_BOOT, 1006 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
1147 "This RTA has a tentative entry on another host - delete that entry (1)\n"); 1007 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1148 HostP->Mapping[entry].Flags = 1008 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1149 SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT; 1009 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1150#ifdef NEED_TO_FIX 1010 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1151 RIO_SV_BROADCAST(HostP->svFlags[entry]); 1011 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
1152#endif 1012 } else
1153 } 1013 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1154 if (RtaType == TYPE_RTA16) 1014 memset(MapP2, 0, sizeof(struct Map));
1155 { 1015 }
1156 if (Flag & SLOT_IN_USE) 1016 memset(MapP, 0, sizeof(struct Map));
1157 { 1017 if (!p->RIONoMessage)
1158 HostP->Mapping[entry2].Flags = SLOT_IN_USE | 1018 printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
1159 RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; 1019 } else if (!p->RIONoMessage)
1160#ifdef NEED_TO_FIX 1020 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
1161 RIO_SV_BROADCAST(HostP->svFlags[entry2]); 1021 RIOSetChange(p);
1162#endif 1022 return 1;
1163 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1164 /*
1165 ** Map second block of ttys for 16 port RTA
1166 */
1167 RIOReMapPorts( p, HostP, &HostP->Mapping[entry2] );
1168 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1169 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1170 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1171 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1172 rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",
1173 (int)HostP->Mapping[entry2].SysPort,
1174 HostP->Mapping[entry].Name);
1175 }
1176 else
1177 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE |
1178 RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1179#ifdef NEED_TO_FIX
1180 RIO_SV_BROADCAST(HostP->svFlags[entry2]);
1181#endif
1182 bzero( (caddr_t)MapP2, sizeof(struct Map) );
1183 }
1184 bzero( (caddr_t)MapP, sizeof(struct Map) );
1185 if (! p->RIONoMessage)
1186 cprintf("An orphaned RTA has been adopted by %s '%s' (%c).\n",MyType,MyName,MyLink+'A');
1187 }
1188 else if (! p->RIONoMessage)
1189 cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
1190 RIOSetChange(p);
1191 return TRUE;
1192 } 1023 }
1193 1024
1194 /* 1025 /*
1195 ** There is no room in the driver table to make an entry for the 1026 ** There is no room in the driver table to make an entry for the
1196 ** booted RTA. Keep a note of its Uniq Num in the overflow table, 1027 ** booted RTA. Keep a note of its Uniq Num in the overflow table,
1197 ** so we can ignore it's ID requests. 1028 ** so we can ignore it's ID requests.
1198 */ 1029 */
1199 if (! p->RIONoMessage) 1030 if (!p->RIONoMessage)
1200 cprintf("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n",MyType,MyName,MyLink+'A'); 1031 printk("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n", MyType, MyName, MyLink + 'A');
1201 for ( entry=0; entry<HostP->NumExtraBooted; entry++ ) 1032 for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
1202 { 1033 if (HostP->ExtraUnits[entry] == RtaUniq) {
1203 if ( HostP->ExtraUnits[entry] == RtaUniq ) 1034 /*
1204 { 1035 ** already got it!
1205 /* 1036 */
1206 ** already got it! 1037 return 1;
1207 */ 1038 }
1208 return TRUE;
1209 }
1210 } 1039 }
1211 /* 1040 /*
1212 ** If there is room, add the unit to the list of extras 1041 ** If there is room, add the unit to the list of extras
1213 */ 1042 */
1214 if ( HostP->NumExtraBooted < MAX_EXTRA_UNITS ) 1043 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
1215 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq; 1044 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
1216 return TRUE; 1045 return 1;
1217} 1046}
1218 1047
1219 1048
1220/* 1049/*
1221** If the RTA or its host appears in the RIOBindTab[] structure then 1050** If the RTA or its host appears in the RIOBindTab[] structure then
1222** we mustn't boot the RTA and should return FALSE. 1051** we mustn't boot the RTA and should return 0.
1223** This operation is slightly different from the other drivers for RIO 1052** This operation is slightly different from the other drivers for RIO
1224** in that this is designed to work with the new utilities 1053** in that this is designed to work with the new utilities
1225** not config.rio and is FAR SIMPLER. 1054** not config.rio and is FAR SIMPLER.
1226** We no longer support the RIOBootMode variable. It is all done from the 1055** We no longer support the RIOBootMode variable. It is all done from the
1227** "boot/noboot" field in the rio.cf file. 1056** "boot/noboot" field in the rio.cf file.
1228*/ 1057*/
1229int 1058int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq)
1230RIOBootOk(p, HostP, RtaUniq)
1231struct rio_info * p;
1232struct Host * HostP;
1233ulong RtaUniq;
1234{ 1059{
1235 int Entry; 1060 int Entry;
1236 uint HostUniq = HostP->UniqueNum; 1061 unsigned int HostUniq = HostP->UniqueNum;
1237 1062
1238 /* 1063 /*
1239 ** Search bindings table for RTA or its parent. 1064 ** Search bindings table for RTA or its parent.
1240 ** If it exists, return 0, else 1. 1065 ** If it exists, return 0, else 1.
1241 */ 1066 */
1242 for (Entry = 0; 1067 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
1243 ( Entry < MAX_RTA_BINDINGS ) && ( p->RIOBindTab[Entry] != 0 ); 1068 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
1244 Entry++)
1245 {
1246 if ( (p->RIOBindTab[Entry] == HostUniq) ||
1247 (p->RIOBindTab[Entry] == RtaUniq) )
1248 return 0; 1069 return 0;
1249 } 1070 }
1250 return 1; 1071 return 1;
@@ -1255,45 +1076,38 @@ ulong RtaUniq;
1255** slots tentative, and the second one RTA_SECOND_SLOT as well. 1076** slots tentative, and the second one RTA_SECOND_SLOT as well.
1256*/ 1077*/
1257 1078
1258void 1079void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host)
1259FillSlot(entry, entry2, RtaUniq, HostP)
1260int entry;
1261int entry2;
1262uint RtaUniq;
1263struct Host *HostP;
1264{ 1080{
1265 int link; 1081 int link;
1266 1082
1267 rio_dprintk (RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq); 1083 rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq);
1268 1084
1269 HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE); 1085 host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
1270 HostP->Mapping[entry].SysPort = NO_PORT; 1086 host->Mapping[entry].SysPort = NO_PORT;
1271 HostP->Mapping[entry].RtaUniqueNum = RtaUniq; 1087 host->Mapping[entry].RtaUniqueNum = rta_uniq;
1272 HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum; 1088 host->Mapping[entry].HostUniqueNum = host->UniqueNum;
1273 HostP->Mapping[entry].ID = entry + 1; 1089 host->Mapping[entry].ID = entry + 1;
1274 HostP->Mapping[entry].ID2 = 0; 1090 host->Mapping[entry].ID2 = 0;
1275 if (entry2) { 1091 if (entry2) {
1276 HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | 1092 host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
1277 SLOT_TENTATIVE | RTA16_SECOND_SLOT); 1093 host->Mapping[entry2].SysPort = NO_PORT;
1278 HostP->Mapping[entry2].SysPort = NO_PORT; 1094 host->Mapping[entry2].RtaUniqueNum = rta_uniq;
1279 HostP->Mapping[entry2].RtaUniqueNum = RtaUniq; 1095 host->Mapping[entry2].HostUniqueNum = host->UniqueNum;
1280 HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum; 1096 host->Mapping[entry2].Name[0] = '\0';
1281 HostP->Mapping[entry2].Name[0] = '\0'; 1097 host->Mapping[entry2].ID = entry2 + 1;
1282 HostP->Mapping[entry2].ID = entry2 + 1; 1098 host->Mapping[entry2].ID2 = entry + 1;
1283 HostP->Mapping[entry2].ID2 = entry + 1; 1099 host->Mapping[entry].ID2 = entry2 + 1;
1284 HostP->Mapping[entry].ID2 = entry2 + 1;
1285 } 1100 }
1286 /* 1101 /*
1287 ** Must set these up, so that utilities show 1102 ** Must set these up, so that utilities show
1288 ** topology of 16 port RTAs correctly 1103 ** topology of 16 port RTAs correctly
1289 */ 1104 */
1290 for ( link=0; link<LINKS_PER_UNIT; link++ ) { 1105 for (link = 0; link < LINKS_PER_UNIT; link++) {
1291 HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT; 1106 host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
1292 HostP->Mapping[entry].Topology[link].Link = NO_LINK; 1107 host->Mapping[entry].Topology[link].Link = NO_LINK;
1293 if (entry2) { 1108 if (entry2) {
1294 HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT; 1109 host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
1295 HostP->Mapping[entry2].Topology[link].Link = NO_LINK; 1110 host->Mapping[entry2].Topology[link].Link = NO_LINK;
1296 } 1111 }
1297 } 1112 }
1298} 1113}
1299
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 694bfb9d9378..e6d2b14b5e65 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -42,6 +42,7 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h> 44#include <asm/semaphore.h>
45#include <asm/uaccess.h>
45 46
46#include <linux/termios.h> 47#include <linux/termios.h>
47#include <linux/serial.h> 48#include <linux/serial.h>
@@ -50,15 +51,12 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
50 51
51#include "linux_compat.h" 52#include "linux_compat.h"
52#include "rio_linux.h" 53#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 54#include "pkt.h"
55#include "daemon.h" 55#include "daemon.h"
56#include "rio.h" 56#include "rio.h"
57#include "riospace.h" 57#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 58#include "cmdpkt.h"
60#include "map.h" 59#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 60#include "rup.h"
63#include "port.h" 61#include "port.h"
64#include "riodrvr.h" 62#include "riodrvr.h"
@@ -71,12 +69,10 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
71#include "unixrup.h" 69#include "unixrup.h"
72#include "board.h" 70#include "board.h"
73#include "host.h" 71#include "host.h"
74#include "error.h"
75#include "phb.h" 72#include "phb.h"
76#include "link.h" 73#include "link.h"
77#include "cmdblk.h" 74#include "cmdblk.h"
78#include "route.h" 75#include "route.h"
79#include "control.h"
80#include "cirrus.h" 76#include "cirrus.h"
81 77
82 78
@@ -143,17 +139,17 @@ int RIOZombieRta(struct Host *HostP, struct Map *MapP)
143 return 0; 139 return 0;
144} 140}
145 141
146int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP)) 142int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
147{ 143{
148 uint Host; 144 unsigned int Host;
149 145
150 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%x func 0x%x\n", RtaUnique, (int) func); 146 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func);
151 147
152 if (!RtaUnique) 148 if (!RtaUnique)
153 return (0); 149 return (0);
154 150
155 for (Host = 0; Host < p->RIONumHosts; Host++) { 151 for (Host = 0; Host < p->RIONumHosts; Host++) {
156 uint Rta; 152 unsigned int Rta;
157 struct Host *HostP = &p->RIOHosts[Host]; 153 struct Host *HostP = &p->RIOHosts[Host];
158 154
159 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 155 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -170,7 +166,7 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
170 ** any connections, we can get to it. 166 ** any connections, we can get to it.
171 */ 167 */
172 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 168 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
173 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 169 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
174 /* 170 /*
175 ** Its worth trying the operation... 171 ** Its worth trying the operation...
176 */ 172 */
@@ -184,18 +180,18 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
184} 180}
185 181
186 182
187int RIOIdentifyRta(struct rio_info *p, caddr_t arg) 183int RIOIdentifyRta(struct rio_info *p, void * arg)
188{ 184{
189 uint Host; 185 unsigned int Host;
190 186
191 if (copyin((int) arg, (caddr_t) & IdRta, sizeof(IdRta)) == COPYFAIL) { 187 if (copy_from_user(&IdRta, arg, sizeof(IdRta))) {
192 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n"); 188 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
193 p->RIOError.Error = COPYIN_FAILED; 189 p->RIOError.Error = COPYIN_FAILED;
194 return -EFAULT; 190 return -EFAULT;
195 } 191 }
196 192
197 for (Host = 0; Host < p->RIONumHosts; Host++) { 193 for (Host = 0; Host < p->RIONumHosts; Host++) {
198 uint Rta; 194 unsigned int Rta;
199 struct Host *HostP = &p->RIOHosts[Host]; 195 struct Host *HostP = &p->RIOHosts[Host];
200 196
201 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 197 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -211,7 +207,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
211 ** any connections, we can get to it. 207 ** any connections, we can get to it.
212 */ 208 */
213 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 209 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
214 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 210 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
215 /* 211 /*
216 ** Its worth trying the operation... 212 ** Its worth trying the operation...
217 */ 213 */
@@ -249,7 +245,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
249} 245}
250 246
251 247
252int RIOKillNeighbour(struct rio_info *p, caddr_t arg) 248int RIOKillNeighbour(struct rio_info *p, void * arg)
253{ 249{
254 uint Host; 250 uint Host;
255 uint ID; 251 uint ID;
@@ -258,7 +254,7 @@ int RIOKillNeighbour(struct rio_info *p, caddr_t arg)
258 254
259 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n"); 255 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
260 256
261 if (copyin((int) arg, (caddr_t) & KillUnit, sizeof(KillUnit)) == COPYFAIL) { 257 if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) {
262 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n"); 258 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
263 p->RIOError.Error = COPYIN_FAILED; 259 p->RIOError.Error = COPYIN_FAILED;
264 return -EFAULT; 260 return -EFAULT;
@@ -344,7 +340,7 @@ int RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
344int RIOFoadWakeup(struct rio_info *p) 340int RIOFoadWakeup(struct rio_info *p)
345{ 341{
346 int port; 342 int port;
347 register struct Port *PortP; 343 struct Port *PortP;
348 unsigned long flags; 344 unsigned long flags;
349 345
350 for (port = 0; port < RIO_PORTS; port++) { 346 for (port = 0; port < RIO_PORTS; port++) {
@@ -374,15 +370,15 @@ int RIOFoadWakeup(struct rio_info *p)
374/* 370/*
375** Incoming command on the COMMAND_RUP to be processed. 371** Incoming command on the COMMAND_RUP to be processed.
376*/ 372*/
377static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 373static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT * PacketP)
378{ 374{
379 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 375 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
380 struct Port *PortP; 376 struct Port *PortP;
381 struct UnixRup *UnixRupP; 377 struct UnixRup *UnixRupP;
382 ushort SysPort; 378 unsigned short SysPort;
383 ushort ReportedModemStatus; 379 unsigned short ReportedModemStatus;
384 ushort rup; 380 unsigned short rup;
385 ushort subCommand; 381 unsigned short subCommand;
386 unsigned long flags; 382 unsigned long flags;
387 383
388 func_enter(); 384 func_enter();
@@ -395,18 +391,18 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
395 ** we can use PhbNum to get the rup number for the appropriate 8 port 391 ** we can use PhbNum to get the rup number for the appropriate 8 port
396 ** block (for the first block, this should be equal to 'Rup'). 392 ** block (for the first block, this should be equal to 'Rup').
397 */ 393 */
398 rup = RBYTE(PktCmdP->PhbNum) / (ushort) PORTS_PER_RTA; 394 rup = readb(&PktCmdP->PhbNum) / (unsigned short) PORTS_PER_RTA;
399 UnixRupP = &HostP->UnixRups[rup]; 395 UnixRupP = &HostP->UnixRups[rup];
400 SysPort = UnixRupP->BaseSysPort + (RBYTE(PktCmdP->PhbNum) % (ushort) PORTS_PER_RTA); 396 SysPort = UnixRupP->BaseSysPort + (readb(&PktCmdP->PhbNum) % (unsigned short) PORTS_PER_RTA);
401 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort); 397 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort);
402 398
403 if (UnixRupP->BaseSysPort == NO_PORT) { 399 if (UnixRupP->BaseSysPort == NO_PORT) {
404 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n"); 400 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n");
405 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n"); 401 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n");
406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %d, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); 402 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
407 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); 403 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup);
408 404
409 if (Rup >= (ushort) MAX_RUP) { 405 if (Rup >= (unsigned short) MAX_RUP) {
410 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); 406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name);
411 } else 407 } else
412 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); 408 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name);
@@ -417,16 +413,16 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
417 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control); 413 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control);
418 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum); 414 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum);
419 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command); 415 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command);
420 return TRUE; 416 return 1;
421 } 417 }
422 PortP = p->RIOPortp[SysPort]; 418 PortP = p->RIOPortp[SysPort];
423 rio_spin_lock_irqsave(&PortP->portSem, flags); 419 rio_spin_lock_irqsave(&PortP->portSem, flags);
424 switch (RBYTE(PktCmdP->Command)) { 420 switch (readb(&PktCmdP->Command)) {
425 case BREAK_RECEIVED: 421 case BREAK_RECEIVED:
426 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n"); 422 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n");
427 /* If the current line disc. is not multi-threading and 423 /* If the current line disc. is not multi-threading and
428 the current processor is not the default, reset rup_intr 424 the current processor is not the default, reset rup_intr
429 and return FALSE to ensure that the command packet is 425 and return 0 to ensure that the command packet is
430 not freed. */ 426 not freed. */
431 /* Call tmgr HANGUP HERE */ 427 /* Call tmgr HANGUP HERE */
432 /* Fix this later when every thing works !!!! RAMRAJ */ 428 /* Fix this later when every thing works !!!! RAMRAJ */
@@ -434,15 +430,15 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
434 break; 430 break;
435 431
436 case COMPLETE: 432 case COMPLETE:
437 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %d\n", RBYTE(PktCmdP->PhbNum), HostP - p->RIOHosts); 433 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts);
438 subCommand = 1; 434 subCommand = 1;
439 switch (RBYTE(PktCmdP->SubCommand)) { 435 switch (readb(&PktCmdP->SubCommand)) {
440 case MEMDUMP: 436 case MEMDUMP:
441 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", RBYTE(PktCmdP->SubCommand), RWORD(PktCmdP->SubAddr)); 437 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr));
442 break; 438 break;
443 case READ_REGISTER: 439 case READ_REGISTER:
444 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", RWORD(PktCmdP->SubAddr)); 440 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr));
445 p->CdRegister = (RBYTE(PktCmdP->ModemStatus) & MSVR1_HOST); 441 p->CdRegister = (readb(&PktCmdP->ModemStatus) & MSVR1_HOST);
446 break; 442 break;
447 default: 443 default:
448 subCommand = 0; 444 subCommand = 0;
@@ -450,10 +446,10 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
450 } 446 }
451 if (subCommand) 447 if (subCommand)
452 break; 448 break;
453 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", RBYTE(PktCmdP->PortStatus), PortP->PortState); 449 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", readb(&PktCmdP->PortStatus), PortP->PortState);
454 if (PortP->PortState != RBYTE(PktCmdP->PortStatus)) { 450 if (PortP->PortState != readb(&PktCmdP->PortStatus)) {
455 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n"); 451 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n");
456 PortP->PortState = RBYTE(PktCmdP->PortStatus); 452 PortP->PortState = readb(&PktCmdP->PortStatus);
457 /* What should we do here ... 453 /* What should we do here ...
458 wakeup( &PortP->PortState ); 454 wakeup( &PortP->PortState );
459 */ 455 */
@@ -467,7 +463,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
467 ** to the check for modem status change (they're just there because 463 ** to the check for modem status change (they're just there because
468 ** it's a convenient place to put them!). 464 ** it's a convenient place to put them!).
469 */ 465 */
470 ReportedModemStatus = RBYTE(PktCmdP->ModemStatus); 466 ReportedModemStatus = readb(&PktCmdP->ModemStatus);
471 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) { 467 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) {
472 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState); 468 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
473 /* 469 /*
@@ -514,9 +510,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
514 */ 510 */
515 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN)) 511 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
516 wake_up_interruptible(&PortP->gs.open_wait); 512 wake_up_interruptible(&PortP->gs.open_wait);
517#ifdef STATS
518 PortP->Stat.ModemOnCnt++;
519#endif
520 } 513 }
521 } else { 514 } else {
522 /* 515 /*
@@ -527,9 +520,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
527 tty_hangup(PortP->gs.tty); 520 tty_hangup(PortP->gs.tty);
528 PortP->State &= ~RIO_CARR_ON; 521 PortP->State &= ~RIO_CARR_ON;
529 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n"); 522 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
530#ifdef STATS
531 PortP->Stat.ModemOffCnt++;
532#endif
533 } 523 }
534 } 524 }
535 } 525 }
@@ -539,14 +529,14 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
539 break; 529 break;
540 530
541 default: 531 default:
542 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %d\n", RBYTE(PktCmdP->Command), HostP - p->RIOHosts); 532 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %Zd\n", readb(&PktCmdP->Command), HostP - p->RIOHosts);
543 break; 533 break;
544 } 534 }
545 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 535 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
546 536
547 func_exit(); 537 func_exit();
548 538
549 return TRUE; 539 return 1;
550} 540}
551 541
552/* 542/*
@@ -566,10 +556,9 @@ struct CmdBlk *RIOGetCmdBlk(void)
566{ 556{
567 struct CmdBlk *CmdBlkP; 557 struct CmdBlk *CmdBlkP;
568 558
569 CmdBlkP = (struct CmdBlk *) sysbrk(sizeof(struct CmdBlk)); 559 CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
570 if (CmdBlkP) 560 if (CmdBlkP)
571 bzero(CmdBlkP, sizeof(struct CmdBlk)); 561 memset(CmdBlkP, 0, sizeof(struct CmdBlk));
572
573 return CmdBlkP; 562 return CmdBlkP;
574} 563}
575 564
@@ -578,7 +567,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
578*/ 567*/
579void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP) 568void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP)
580{ 569{
581 sysfree((void *) CmdBlkP, sizeof(struct CmdBlk)); 570 kfree(CmdBlkP);
582} 571}
583 572
584/* 573/*
@@ -591,7 +580,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
591 struct UnixRup *UnixRupP; 580 struct UnixRup *UnixRupP;
592 unsigned long flags; 581 unsigned long flags;
593 582
594 if (Rup >= (ushort) (MAX_RUP + LINKS_PER_UNIT)) { 583 if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) {
595 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup); 584 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup);
596 RIOFreeCmdBlk(CmdBlkP); 585 RIOFreeCmdBlk(CmdBlkP);
597 return RIO_FAIL; 586 return RIO_FAIL;
@@ -605,14 +594,14 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
605 ** If the RUP is currently inactive, then put the request 594 ** If the RUP is currently inactive, then put the request
606 ** straight on the RUP.... 595 ** straight on the RUP....
607 */ 596 */
608 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) 597 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
609 : TRUE)) { 598 : 1)) {
610 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]); 599 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]);
611 600
612 /* 601 /*
613 ** Whammy! blat that pack! 602 ** Whammy! blat that pack!
614 */ 603 */
615 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 604 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
616 605
617 /* 606 /*
618 ** place command packet on the pending position. 607 ** place command packet on the pending position.
@@ -622,11 +611,11 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
622 /* 611 /*
623 ** set the command register 612 ** set the command register
624 */ 613 */
625 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 614 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
626 615
627 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 616 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
628 617
629 return RIO_SUCCESS; 618 return 0;
630 } 619 }
631 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n"); 620 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n");
632 621
@@ -634,20 +623,20 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
634 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n"); 623 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n");
635 if (UnixRupP->CmdPendingP != NULL) 624 if (UnixRupP->CmdPendingP != NULL)
636 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n"); 625 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n");
637 if (RWORD(UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE) 626 if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
638 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n"); 627 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
639 628
640 Base = &UnixRupP->CmdsWaitingP; 629 Base = &UnixRupP->CmdsWaitingP;
641 630
642 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 631 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base);
643 632
644 while (*Base) { 633 while (*Base) {
645 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk 0x%x here\n", (int) (*Base)); 634 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base);
646 Base = &((*Base)->NextP); 635 Base = &((*Base)->NextP);
647 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 636 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base);
648 } 637 }
649 638
650 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 639 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base);
651 640
652 *Base = CmdBlkP; 641 *Base = CmdBlkP;
653 642
@@ -655,7 +644,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
655 644
656 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 645 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
657 646
658 return RIO_SUCCESS; 647 return 0;
659} 648}
660 649
661/* 650/*
@@ -664,10 +653,10 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
664*/ 653*/
665void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) 654void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
666{ 655{
667 register struct CmdBlk *CmdBlkP; 656 struct CmdBlk *CmdBlkP;
668 register struct UnixRup *UnixRupP; 657 struct UnixRup *UnixRupP;
669 struct PKT *PacketP; 658 struct PKT *PacketP;
670 ushort Rup; 659 unsigned short Rup;
671 unsigned long flags; 660 unsigned long flags;
672 661
673 662
@@ -684,16 +673,14 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
684 /* 673 /*
685 ** First check for incoming commands: 674 ** First check for incoming commands:
686 */ 675 */
687 if (RWORD(UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { 676 if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
688 int FreeMe; 677 int FreeMe;
689 678
690 PacketP = (PKT *) RIO_PTR(HostP->Caddr, RWORD(UnixRupP->RupP->rxpkt)); 679 PacketP = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt));
691 680
692 ShowPacket(DBG_CMD, PacketP); 681 switch (readb(&PacketP->dest_port)) {
693
694 switch (RBYTE(PacketP->dest_port)) {
695 case BOOT_RUP: 682 case BOOT_RUP:
696 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", RBYTE(PacketP->len) & 0x80 ? "Command" : "Data", RBYTE(PacketP->data[0])); 683 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0]));
697 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 684 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
698 FreeMe = RIOBootRup(p, Rup, HostP, PacketP); 685 FreeMe = RIOBootRup(p, Rup, HostP, PacketP);
699 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 686 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -708,7 +695,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
708 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 695 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
709 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); 696 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
710 if (PacketP->data[5] == MEMDUMP) { 697 if (PacketP->data[5] == MEMDUMP) {
711 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(ushort *) & (PacketP->data[6])); 698 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6]));
712 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32); 699 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32);
713 } 700 }
714 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 701 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -721,7 +708,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
721 break; 708 break;
722 709
723 default: 710 default:
724 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", RBYTE(PacketP->dest_port)); 711 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port));
725 FreeMe = 1; 712 FreeMe = 1;
726 break; 713 break;
727 } 714 }
@@ -730,11 +717,11 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
730 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n"); 717 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n");
731 put_free_end(HostP, PacketP); 718 put_free_end(HostP, PacketP);
732 719
733 WWORD(UnixRupP->RupP->rxcontrol, RX_RUP_INACTIVE); 720 writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol);
734 721
735 if (RWORD(UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) { 722 if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
736 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup); 723 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup);
737 WWORD(UnixRupP->RupP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 724 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake);
738 } 725 }
739 } 726 }
740 } 727 }
@@ -744,7 +731,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
744 ** and it has completed, then tidy it up. 731 ** and it has completed, then tidy it up.
745 */ 732 */
746 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */ 733 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */
747 (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 734 (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
748 /* 735 /*
749 ** we are idle. 736 ** we are idle.
750 ** there is a command in pending. 737 ** there is a command in pending.
@@ -755,7 +742,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
755 if (CmdBlkP->Packet.dest_port == BOOT_RUP) 742 if (CmdBlkP->Packet.dest_port == BOOT_RUP)
756 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]); 743 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]);
757 744
758 rio_dprintk(RIO_DEBUG_CMD, "Command 0x%x completed\n", (int) CmdBlkP); 745 rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP);
759 746
760 /* 747 /*
761 ** Clear the Rup lock to prevent mutual exclusion. 748 ** Clear the Rup lock to prevent mutual exclusion.
@@ -782,20 +769,20 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
782 ** is idle, then process the command 769 ** is idle, then process the command
783 */ 770 */
784 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */ 771 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */
785 (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 772 (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
786 /* 773 /*
787 ** if the pre-function is non-zero, call it. 774 ** if the pre-function is non-zero, call it.
788 ** If it returns RIO_FAIL then don't 775 ** If it returns RIO_FAIL then don't
789 ** send this command yet! 776 ** send this command yet!
790 */ 777 */
791 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : TRUE)) { 778 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : 1)) {
792 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command 0x%x\n", (int) CmdBlkP); 779 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command %p\n", CmdBlkP);
793 } else { 780 } else {
794 rio_dprintk(RIO_DEBUG_CMD, "Start new command 0x%x Cmd byte is 0x%x\n", (int) CmdBlkP, CmdBlkP->Packet.data[0]); 781 rio_dprintk(RIO_DEBUG_CMD, "Start new command %p Cmd byte is 0x%x\n", CmdBlkP, CmdBlkP->Packet.data[0]);
795 /* 782 /*
796 ** Whammy! blat that pack! 783 ** Whammy! blat that pack!
797 */ 784 */
798 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 785 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
799 786
800 /* 787 /*
801 ** remove the command from the rup command queue... 788 ** remove the command from the rup command queue...
@@ -810,7 +797,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
810 /* 797 /*
811 ** set the command register 798 ** set the command register
812 */ 799 */
813 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 800 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
814 801
815 /* 802 /*
816 ** the command block will be freed 803 ** the command block will be freed
@@ -822,7 +809,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
822 } while (Rup); 809 } while (Rup);
823} 810}
824 811
825int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP) 812int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP)
826{ 813{
827 struct Port *PortP = (struct Port *) iPortP; 814 struct Port *PortP = (struct Port *) iPortP;
828 unsigned long flags; 815 unsigned long flags;
@@ -834,33 +821,32 @@ int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
834 return RIOUnUse(iPortP, CmdBlkP); 821 return RIOUnUse(iPortP, CmdBlkP);
835} 822}
836 823
837int RIORFlushEnable(int iPortP, struct CmdBlk *CmdBlkP) 824int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP)
838{ 825{
839 struct Port *PortP = (struct Port *) iPortP; 826 struct Port *PortP = (struct Port *) iPortP;
840 PKT *PacketP; 827 struct PKT *PacketP;
841 unsigned long flags; 828 unsigned long flags;
842 829
843 rio_spin_lock_irqsave(&PortP->portSem, flags); 830 rio_spin_lock_irqsave(&PortP->portSem, flags);
844 831
845 while (can_remove_receive(&PacketP, PortP)) { 832 while (can_remove_receive(&PacketP, PortP)) {
846 remove_receive(PortP); 833 remove_receive(PortP);
847 ShowPacket(DBG_PROC, PacketP);
848 put_free_end(PortP->HostP, PacketP); 834 put_free_end(PortP->HostP, PacketP);
849 } 835 }
850 836
851 if (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) { 837 if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
852 /* 838 /*
853 ** MAGIC! (Basically, handshake the RX buffer, so that 839 ** MAGIC! (Basically, handshake the RX buffer, so that
854 ** the RTAs upstream can be re-enabled.) 840 ** the RTAs upstream can be re-enabled.)
855 */ 841 */
856 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n"); 842 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
857 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 843 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
858 } 844 }
859 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 845 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
860 return RIOUnUse(iPortP, CmdBlkP); 846 return RIOUnUse(iPortP, CmdBlkP);
861} 847}
862 848
863int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP) 849int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
864{ 850{
865 struct Port *PortP = (struct Port *) iPortP; 851 struct Port *PortP = (struct Port *) iPortP;
866 unsigned long flags; 852 unsigned long flags;
@@ -890,7 +876,7 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
890 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data 876 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
891 ** hanging around in the transmit buffer is sent immediately. 877 ** hanging around in the transmit buffer is sent immediately.
892 */ 878 */
893 WWORD(PortP->HostP->ParmMapP->tx_intr, 1); 879 writew(1, &PortP->HostP->ParmMapP->tx_intr);
894 /* What to do here .. 880 /* What to do here ..
895 wakeup( (caddr_t)&(PortP->InUse) ); 881 wakeup( (caddr_t)&(PortP->InUse) );
896 */ 882 */
@@ -898,10 +884,6 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
898 return 0; 884 return 0;
899} 885}
900 886
901void ShowPacket(uint Flags, struct PKT *PacketP)
902{
903}
904
905/* 887/*
906** 888**
907** How to use this file: 889** How to use this file:
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index fcf18a061228..d31aba62bb7f 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -51,15 +51,12 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
51 51
52#include "linux_compat.h" 52#include "linux_compat.h"
53#include "rio_linux.h" 53#include "rio_linux.h"
54#include "typdef.h"
55#include "pkt.h" 54#include "pkt.h"
56#include "daemon.h" 55#include "daemon.h"
57#include "rio.h" 56#include "rio.h"
58#include "riospace.h" 57#include "riospace.h"
59#include "top.h"
60#include "cmdpkt.h" 58#include "cmdpkt.h"
61#include "map.h" 59#include "map.h"
62#include "riotypes.h"
63#include "rup.h" 60#include "rup.h"
64#include "port.h" 61#include "port.h"
65#include "riodrvr.h" 62#include "riodrvr.h"
@@ -72,12 +69,10 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
72#include "unixrup.h" 69#include "unixrup.h"
73#include "board.h" 70#include "board.h"
74#include "host.h" 71#include "host.h"
75#include "error.h"
76#include "phb.h" 72#include "phb.h"
77#include "link.h" 73#include "link.h"
78#include "cmdblk.h" 74#include "cmdblk.h"
79#include "route.h" 75#include "route.h"
80#include "control.h"
81#include "cirrus.h" 76#include "cirrus.h"
82#include "rioioctl.h" 77#include "rioioctl.h"
83 78
@@ -131,30 +126,6 @@ static int
131 126
132#define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff)) 127#define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff))
133 128
134int copyin(int arg, caddr_t dp, int siz)
135{
136 int rv;
137
138 rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes from user %p to %p.\n", siz, (void *) arg, dp);
139 rv = copy_from_user(dp, (void *) arg, siz);
140 if (rv)
141 return COPYFAIL;
142 else
143 return rv;
144}
145
146static int copyout(caddr_t dp, int arg, int siz)
147{
148 int rv;
149
150 rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes to user %p from %p.\n", siz, (void *) arg, dp);
151 rv = copy_to_user((void *) arg, dp, siz);
152 if (rv)
153 return COPYFAIL;
154 else
155 return rv;
156}
157
158int riocontrol(p, dev, cmd, arg, su) 129int riocontrol(p, dev, cmd, arg, su)
159struct rio_info *p; 130struct rio_info *p;
160dev_t dev; 131dev_t dev;
@@ -168,7 +139,7 @@ int su;
168 ushort loop; 139 ushort loop;
169 int Entry; 140 int Entry;
170 struct Port *PortP; 141 struct Port *PortP;
171 PKT *PacketP; 142 struct PKT *PacketP;
172 int retval = 0; 143 int retval = 0;
173 unsigned long flags; 144 unsigned long flags;
174 145
@@ -178,7 +149,7 @@ int su;
178 Host = 0; 149 Host = 0;
179 PortP = NULL; 150 PortP = NULL;
180 151
181 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: 0x%x\n", cmd, (int) arg); 152 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, arg);
182 153
183 switch (cmd) { 154 switch (cmd) {
184 /* 155 /*
@@ -189,90 +160,34 @@ int su;
189 ** otherwise just the specified host card will be changed. 160 ** otherwise just the specified host card will be changed.
190 */ 161 */
191 case RIO_SET_TIMER: 162 case RIO_SET_TIMER:
192 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %dms\n", (uint) arg); 163 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", (unsigned long)arg);
193 { 164 {
194 int host, value; 165 int host, value;
195 host = (uint) arg >> 16; 166 host = ((unsigned long) arg >> 16) & 0x0000FFFF;
196 value = (uint) arg & 0x0000ffff; 167 value = (unsigned long) arg & 0x0000ffff;
197 if (host == -1) { 168 if (host == -1) {
198 for (host = 0; host < p->RIONumHosts; host++) { 169 for (host = 0; host < p->RIONumHosts; host++) {
199 if (p->RIOHosts[host].Flags == RC_RUNNING) { 170 if (p->RIOHosts[host].Flags == RC_RUNNING) {
200 WWORD(p->RIOHosts[host].ParmMapP->timer, value); 171 writew(value, &p->RIOHosts[host].ParmMapP->timer);
201 } 172 }
202 } 173 }
203 } else if (host >= p->RIONumHosts) { 174 } else if (host >= p->RIONumHosts) {
204 return -EINVAL; 175 return -EINVAL;
205 } else { 176 } else {
206 if (p->RIOHosts[host].Flags == RC_RUNNING) { 177 if (p->RIOHosts[host].Flags == RC_RUNNING) {
207 WWORD(p->RIOHosts[host].ParmMapP->timer, value); 178 writew(value, &p->RIOHosts[host].ParmMapP->timer);
208 } 179 }
209 } 180 }
210 } 181 }
211 return 0; 182 return 0;
212 183
213 case RIO_IDENTIFY_DRIVER:
214 /*
215 ** 15.10.1998 ARG - ESIL 0760 part fix
216 ** Added driver ident string output.
217 **
218 #ifndef __THIS_RELEASE__
219 #warning Driver Version string not defined !
220 #endif
221 cprintf("%s %s %s %s\n",
222 RIO_DRV_STR,
223 __THIS_RELEASE__,
224 __DATE__, __TIME__ );
225
226 return 0;
227
228 case RIO_DISPLAY_HOST_CFG:
229 **
230 ** 15.10.1998 ARG - ESIL 0760 part fix
231 ** Added driver host card ident string output.
232 **
233 ** Note that the only types currently supported
234 ** are ISA and PCI. Also this driver does not
235 ** (yet) distinguish between the Old PCI card
236 ** and the Jet PCI card. In fact I think this
237 ** driver only supports JET PCI !
238 **
239
240 for (Host = 0; Host < p->RIONumHosts; Host++)
241 {
242 HostP = &(p->RIOHosts[Host]);
243
244 switch ( HostP->Type )
245 {
246 case RIO_AT :
247 strcpy( host_type, RIO_AT_HOST_STR );
248 break;
249
250 case RIO_PCI :
251 strcpy( host_type, RIO_PCI_HOST_STR );
252 break;
253
254 default :
255 strcpy( host_type, "Unknown" );
256 break;
257 }
258
259 cprintf(
260 "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
261 Host, host_type,
262 (uint)HostP->PaddrP,
263 (int)HostP->Ivec - 32 );
264 }
265 return 0;
266 **
267 */
268
269 case RIO_FOAD_RTA: 184 case RIO_FOAD_RTA:
270 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n"); 185 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n");
271 return RIOCommandRta(p, (uint) arg, RIOFoadRta); 186 return RIOCommandRta(p, (unsigned long)arg, RIOFoadRta);
272 187
273 case RIO_ZOMBIE_RTA: 188 case RIO_ZOMBIE_RTA:
274 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n"); 189 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n");
275 return RIOCommandRta(p, (uint) arg, RIOZombieRta); 190 return RIOCommandRta(p, (unsigned long)arg, RIOZombieRta);
276 191
277 case RIO_IDENTIFY_RTA: 192 case RIO_IDENTIFY_RTA:
278 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n"); 193 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n");
@@ -287,7 +202,7 @@ int su;
287 struct CmdBlk *CmdBlkP; 202 struct CmdBlk *CmdBlkP;
288 203
289 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n"); 204 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n");
290 if (copyin((int) arg, (caddr_t) & SpecialRupCmd, sizeof(SpecialRupCmd)) == COPYFAIL) { 205 if (copy_from_user(&SpecialRupCmd, arg, sizeof(SpecialRupCmd))) {
291 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n"); 206 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
292 p->RIOError.Error = COPYIN_FAILED; 207 p->RIOError.Error = COPYIN_FAILED;
293 return -EFAULT; 208 return -EFAULT;
@@ -302,7 +217,7 @@ int su;
302 SpecialRupCmd.Host = 0; 217 SpecialRupCmd.Host = 0;
303 rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum); 218 rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum);
304 if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) { 219 if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) {
305 cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n"); 220 printk(KERN_WARNING "rio: FAILED TO QUEUE SPECIAL RUP COMMAND\n");
306 } 221 }
307 return 0; 222 return 0;
308 } 223 }
@@ -324,7 +239,7 @@ int su;
324 if ((retval = RIOApel(p)) != 0) 239 if ((retval = RIOApel(p)) != 0)
325 return retval; 240 return retval;
326 241
327 if (copyout((caddr_t) p->RIOConnectTable, (int) arg, TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) { 242 if (copy_to_user(arg, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
328 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n"); 243 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
329 p->RIOError.Error = COPYOUT_FAILED; 244 p->RIOError.Error = COPYOUT_FAILED;
330 return -EFAULT; 245 return -EFAULT;
@@ -369,7 +284,7 @@ int su;
369 p->RIOError.Error = NOT_SUPER_USER; 284 p->RIOError.Error = NOT_SUPER_USER;
370 return -EPERM; 285 return -EPERM;
371 } 286 }
372 if (copyin((int) arg, (caddr_t) & p->RIOConnectTable[0], TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) { 287 if (copy_from_user(&p->RIOConnectTable[0], arg, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
373 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n"); 288 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
374 p->RIOError.Error = COPYIN_FAILED; 289 p->RIOError.Error = COPYIN_FAILED;
375 return -EFAULT; 290 return -EFAULT;
@@ -415,7 +330,7 @@ int su;
415 p->RIOError.Error = NOT_SUPER_USER; 330 p->RIOError.Error = NOT_SUPER_USER;
416 return -EPERM; 331 return -EPERM;
417 } 332 }
418 if (copyout((caddr_t) p->RIOBindTab, (int) arg, (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) { 333 if (copy_to_user(arg, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
419 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n"); 334 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
420 p->RIOError.Error = COPYOUT_FAILED; 335 p->RIOError.Error = COPYOUT_FAILED;
421 return -EFAULT; 336 return -EFAULT;
@@ -434,7 +349,7 @@ int su;
434 p->RIOError.Error = NOT_SUPER_USER; 349 p->RIOError.Error = NOT_SUPER_USER;
435 return -EPERM; 350 return -EPERM;
436 } 351 }
437 if (copyin((int) arg, (caddr_t) & p->RIOBindTab[0], (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) { 352 if (copy_from_user(&p->RIOBindTab[0], arg, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
438 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n"); 353 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
439 p->RIOError.Error = COPYIN_FAILED; 354 p->RIOError.Error = COPYIN_FAILED;
440 return -EFAULT; 355 return -EFAULT;
@@ -458,12 +373,12 @@ int su;
458 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) { 373 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
459 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L)) 374 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
460 EmptySlot = Entry; 375 EmptySlot = Entry;
461 else if (p->RIOBindTab[Entry] == (int) arg) { 376 else if (p->RIOBindTab[Entry] == (long)arg) {
462 /* 377 /*
463 ** Already exists - delete 378 ** Already exists - delete
464 */ 379 */
465 p->RIOBindTab[Entry] = 0L; 380 p->RIOBindTab[Entry] = 0L;
466 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %x from p->RIOBindTab\n", (int) arg); 381 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", (unsigned long)arg);
467 return 0; 382 return 0;
468 } 383 }
469 } 384 }
@@ -471,10 +386,10 @@ int su;
471 ** Dosen't exist - add 386 ** Dosen't exist - add
472 */ 387 */
473 if (EmptySlot != -1) { 388 if (EmptySlot != -1) {
474 p->RIOBindTab[EmptySlot] = (int) arg; 389 p->RIOBindTab[EmptySlot] = (unsigned long)arg;
475 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %x to p->RIOBindTab\n", (int) arg); 390 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", (unsigned long) arg);
476 } else { 391 } else {
477 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %x not added\n", (int) arg); 392 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", (unsigned long) arg);
478 return -ENOMEM; 393 return -ENOMEM;
479 } 394 }
480 return 0; 395 return 0;
@@ -482,7 +397,7 @@ int su;
482 397
483 case RIO_RESUME: 398 case RIO_RESUME:
484 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n"); 399 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n");
485 port = (uint) arg; 400 port = (unsigned long) arg;
486 if ((port < 0) || (port > 511)) { 401 if ((port < 0) || (port > 511)) {
487 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port); 402 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
488 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 403 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -518,8 +433,7 @@ int su;
518 p->RIOError.Error = NOT_SUPER_USER; 433 p->RIOError.Error = NOT_SUPER_USER;
519 return -EPERM; 434 return -EPERM;
520 } 435 }
521 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 436 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
522 == COPYFAIL) {
523 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 437 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
524 p->RIOError.Error = COPYIN_FAILED; 438 p->RIOError.Error = COPYIN_FAILED;
525 return -EFAULT; 439 return -EFAULT;
@@ -533,8 +447,7 @@ int su;
533 p->RIOError.Error = NOT_SUPER_USER; 447 p->RIOError.Error = NOT_SUPER_USER;
534 return -EPERM; 448 return -EPERM;
535 } 449 }
536 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 450 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
537 == COPYFAIL) {
538 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 451 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
539 p->RIOError.Error = COPYIN_FAILED; 452 p->RIOError.Error = COPYIN_FAILED;
540 return -EFAULT; 453 return -EFAULT;
@@ -548,8 +461,7 @@ int su;
548 p->RIOError.Error = NOT_SUPER_USER; 461 p->RIOError.Error = NOT_SUPER_USER;
549 return -EPERM; 462 return -EPERM;
550 } 463 }
551 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 464 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
552 == COPYFAIL) {
553 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n"); 465 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n");
554 p->RIOError.Error = COPYIN_FAILED; 466 p->RIOError.Error = COPYIN_FAILED;
555 return -EFAULT; 467 return -EFAULT;
@@ -557,30 +469,14 @@ int su;
557 return RIODeleteRta(p, &MapEnt); 469 return RIODeleteRta(p, &MapEnt);
558 470
559 case RIO_QUICK_CHECK: 471 case RIO_QUICK_CHECK:
560 /* 472 if (copy_to_user(arg, &p->RIORtaDisCons, sizeof(unsigned int))) {
561 ** 09.12.1998 ARG - ESIL 0776 part fix
562 ** A customer was using this to get the RTAs
563 ** connect/disconnect status.
564 ** RIOConCon() had been botched use RIOHalted
565 ** to keep track of RTA connections and
566 ** disconnections. That has been changed and
567 ** RIORtaDisCons in the rio_info struct now
568 ** does the job. So we need to return the value
569 ** of RIORtaCons instead of RIOHalted.
570 **
571 if (copyout((caddr_t)&p->RIOHalted,(int)arg,
572 sizeof(uint))==COPYFAIL) {
573 **
574 */
575
576 if (copyout((caddr_t) & p->RIORtaDisCons, (int) arg, sizeof(uint)) == COPYFAIL) {
577 p->RIOError.Error = COPYOUT_FAILED; 473 p->RIOError.Error = COPYOUT_FAILED;
578 return -EFAULT; 474 return -EFAULT;
579 } 475 }
580 return 0; 476 return 0;
581 477
582 case RIO_LAST_ERROR: 478 case RIO_LAST_ERROR:
583 if (copyout((caddr_t) & p->RIOError, (int) arg, sizeof(struct Error)) == COPYFAIL) 479 if (copy_to_user(arg, &p->RIOError, sizeof(struct Error)))
584 return -EFAULT; 480 return -EFAULT;
585 return 0; 481 return 0;
586 482
@@ -589,7 +485,7 @@ int su;
589 return -EINVAL; 485 return -EINVAL;
590 486
591 case RIO_GET_MODTYPE: 487 case RIO_GET_MODTYPE:
592 if (copyin((int) arg, (caddr_t) & port, sizeof(uint)) == COPYFAIL) { 488 if (copy_from_user(&port, arg, sizeof(unsigned int))) {
593 p->RIOError.Error = COPYIN_FAILED; 489 p->RIOError.Error = COPYIN_FAILED;
594 return -EFAULT; 490 return -EFAULT;
595 } 491 }
@@ -609,36 +505,11 @@ int su;
609 ** Return module type of port 505 ** Return module type of port
610 */ 506 */
611 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes; 507 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes;
612 if (copyout((caddr_t) & port, (int) arg, sizeof(uint)) == COPYFAIL) { 508 if (copy_to_user(arg, &port, sizeof(unsigned int))) {
613 p->RIOError.Error = COPYOUT_FAILED; 509 p->RIOError.Error = COPYOUT_FAILED;
614 return -EFAULT; 510 return -EFAULT;
615 } 511 }
616 return (0); 512 return (0);
617 /*
618 ** 02.03.1999 ARG - ESIL 0820 fix
619 ** We are no longer using "Boot Mode", so these ioctls
620 ** are not required :
621 **
622 case RIO_GET_BOOT_MODE :
623 rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
624 **
625 ** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
626 **
627 if (copyout((caddr_t)&p->RIOBootMode, (int)arg,
628 sizeof(p->RIOBootMode)) == COPYFAIL) {
629 p->RIOError.Error = COPYOUT_FAILED;
630 return -EFAULT;
631 }
632 return(0);
633
634 case RIO_SET_BOOT_MODE :
635 p->RIOBootMode = (uint) arg;
636 rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
637 return(0);
638 **
639 ** End ESIL 0820 fix
640 */
641
642 case RIO_BLOCK_OPENS: 513 case RIO_BLOCK_OPENS:
643 rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n"); 514 rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n");
644 for (Entry = 0; Entry < RIO_PORTS; Entry++) { 515 for (Entry = 0; Entry < RIO_PORTS; Entry++) {
@@ -650,8 +521,7 @@ int su;
650 521
651 case RIO_SETUP_PORTS: 522 case RIO_SETUP_PORTS:
652 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n"); 523 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n");
653 if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup)) 524 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
654 == COPYFAIL) {
655 p->RIOError.Error = COPYIN_FAILED; 525 p->RIOError.Error = COPYIN_FAILED;
656 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT"); 526 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT");
657 return -EFAULT; 527 return -EFAULT;
@@ -667,7 +537,7 @@ int su;
667 return -EINVAL; 537 return -EINVAL;
668 } 538 }
669 if (!p->RIOPortp) { 539 if (!p->RIOPortp) {
670 cprintf("No p->RIOPortp array!\n"); 540 printk(KERN_ERR "rio: No p->RIOPortp array!\n");
671 rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n"); 541 rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n");
672 return -EIO; 542 return -EIO;
673 } 543 }
@@ -681,8 +551,7 @@ int su;
681 551
682 case RIO_GET_PORT_SETUP: 552 case RIO_GET_PORT_SETUP:
683 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n"); 553 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n");
684 if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup)) 554 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
685 == COPYFAIL) {
686 p->RIOError.Error = COPYIN_FAILED; 555 p->RIOError.Error = COPYIN_FAILED;
687 return -EFAULT; 556 return -EFAULT;
688 } 557 }
@@ -698,13 +567,12 @@ int su;
698 PortSetup.Store = p->RIOPortp[port]->Store; 567 PortSetup.Store = p->RIOPortp[port]->Store;
699 PortSetup.Lock = p->RIOPortp[port]->Lock; 568 PortSetup.Lock = p->RIOPortp[port]->Lock;
700 PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps; 569 PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps;
701 bcopy(p->RIOPortp[port]->Xprint.XpOn, PortSetup.XpOn, MAX_XP_CTRL_LEN); 570 memcpy(PortSetup.XpOn, p->RIOPortp[port]->Xprint.XpOn, MAX_XP_CTRL_LEN);
702 bcopy(p->RIOPortp[port]->Xprint.XpOff, PortSetup.XpOff, MAX_XP_CTRL_LEN); 571 memcpy(PortSetup.XpOff, p->RIOPortp[port]->Xprint.XpOff, MAX_XP_CTRL_LEN);
703 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0'; 572 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
704 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0'; 573 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
705 574
706 if (copyout((caddr_t) & PortSetup, (int) arg, sizeof(PortSetup)) 575 if (copy_to_user(arg, &PortSetup, sizeof(PortSetup))) {
707 == COPYFAIL) {
708 p->RIOError.Error = COPYOUT_FAILED; 576 p->RIOError.Error = COPYOUT_FAILED;
709 return -EFAULT; 577 return -EFAULT;
710 } 578 }
@@ -712,7 +580,7 @@ int su;
712 580
713 case RIO_GET_PORT_PARAMS: 581 case RIO_GET_PORT_PARAMS:
714 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n"); 582 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n");
715 if (copyin((int) arg, (caddr_t) & PortParams, sizeof(struct PortParams)) == COPYFAIL) { 583 if (copy_from_user(&PortParams, arg, sizeof(struct PortParams))) {
716 p->RIOError.Error = COPYIN_FAILED; 584 p->RIOError.Error = COPYIN_FAILED;
717 return -EFAULT; 585 return -EFAULT;
718 } 586 }
@@ -725,7 +593,7 @@ int su;
725 PortParams.State = PortP->State; 593 PortParams.State = PortP->State;
726 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port); 594 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port);
727 595
728 if (copyout((caddr_t) & PortParams, (int) arg, sizeof(struct PortParams)) == COPYFAIL) { 596 if (copy_to_user(arg, &PortParams, sizeof(struct PortParams))) {
729 p->RIOError.Error = COPYOUT_FAILED; 597 p->RIOError.Error = COPYOUT_FAILED;
730 return -EFAULT; 598 return -EFAULT;
731 } 599 }
@@ -733,8 +601,7 @@ int su;
733 601
734 case RIO_GET_PORT_TTY: 602 case RIO_GET_PORT_TTY:
735 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n"); 603 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n");
736 if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) 604 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
737 == COPYFAIL) {
738 p->RIOError.Error = COPYIN_FAILED; 605 p->RIOError.Error = COPYIN_FAILED;
739 return -EFAULT; 606 return -EFAULT;
740 } 607 }
@@ -745,14 +612,14 @@ int su;
745 612
746 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port); 613 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
747 PortP = (p->RIOPortp[PortTty.port]); 614 PortP = (p->RIOPortp[PortTty.port]);
748 if (copyout((caddr_t) & PortTty, (int) arg, sizeof(struct PortTty)) == COPYFAIL) { 615 if (copy_to_user(arg, &PortTty, sizeof(struct PortTty))) {
749 p->RIOError.Error = COPYOUT_FAILED; 616 p->RIOError.Error = COPYOUT_FAILED;
750 return -EFAULT; 617 return -EFAULT;
751 } 618 }
752 return retval; 619 return retval;
753 620
754 case RIO_SET_PORT_TTY: 621 case RIO_SET_PORT_TTY:
755 if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) == COPYFAIL) { 622 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
756 p->RIOError.Error = COPYIN_FAILED; 623 p->RIOError.Error = COPYIN_FAILED;
757 return -EFAULT; 624 return -EFAULT;
758 } 625 }
@@ -767,8 +634,7 @@ int su;
767 634
768 case RIO_SET_PORT_PARAMS: 635 case RIO_SET_PORT_PARAMS:
769 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n"); 636 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n");
770 if (copyin((int) arg, (caddr_t) & PortParams, sizeof(PortParams)) 637 if (copy_from_user(&PortParams, arg, sizeof(PortParams))) {
771 == COPYFAIL) {
772 p->RIOError.Error = COPYIN_FAILED; 638 p->RIOError.Error = COPYIN_FAILED;
773 return -EFAULT; 639 return -EFAULT;
774 } 640 }
@@ -784,7 +650,7 @@ int su;
784 650
785 case RIO_GET_PORT_STATS: 651 case RIO_GET_PORT_STATS:
786 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n"); 652 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n");
787 if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) { 653 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
788 p->RIOError.Error = COPYIN_FAILED; 654 p->RIOError.Error = COPYIN_FAILED;
789 return -EFAULT; 655 return -EFAULT;
790 } 656 }
@@ -799,14 +665,14 @@ int su;
799 portStats.opens = PortP->opens; 665 portStats.opens = PortP->opens;
800 portStats.closes = PortP->closes; 666 portStats.closes = PortP->closes;
801 portStats.ioctls = PortP->ioctls; 667 portStats.ioctls = PortP->ioctls;
802 if (copyout((caddr_t) & portStats, (int) arg, sizeof(struct portStats)) == COPYFAIL) { 668 if (copy_to_user(arg, &portStats, sizeof(struct portStats))) {
803 p->RIOError.Error = COPYOUT_FAILED; 669 p->RIOError.Error = COPYOUT_FAILED;
804 return -EFAULT; 670 return -EFAULT;
805 } 671 }
806 return retval; 672 return retval;
807 673
808 case RIO_RESET_PORT_STATS: 674 case RIO_RESET_PORT_STATS:
809 port = (uint) arg; 675 port = (unsigned long) arg;
810 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n"); 676 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
811 if (port >= RIO_PORTS) { 677 if (port >= RIO_PORTS) {
812 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 678 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -824,7 +690,7 @@ int su;
824 690
825 case RIO_GATHER_PORT_STATS: 691 case RIO_GATHER_PORT_STATS:
826 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n"); 692 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n");
827 if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) { 693 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
828 p->RIOError.Error = COPYIN_FAILED; 694 p->RIOError.Error = COPYIN_FAILED;
829 return -EFAULT; 695 return -EFAULT;
830 } 696 }
@@ -840,7 +706,7 @@ int su;
840 706
841 case RIO_READ_CONFIG: 707 case RIO_READ_CONFIG:
842 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n"); 708 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n");
843 if (copyout((caddr_t) & p->RIOConf, (int) arg, sizeof(struct Conf)) == COPYFAIL) { 709 if (copy_to_user(arg, &p->RIOConf, sizeof(struct Conf))) {
844 p->RIOError.Error = COPYOUT_FAILED; 710 p->RIOError.Error = COPYOUT_FAILED;
845 return -EFAULT; 711 return -EFAULT;
846 } 712 }
@@ -852,8 +718,7 @@ int su;
852 p->RIOError.Error = NOT_SUPER_USER; 718 p->RIOError.Error = NOT_SUPER_USER;
853 return -EPERM; 719 return -EPERM;
854 } 720 }
855 if (copyin((int) arg, (caddr_t) & p->RIOConf, sizeof(struct Conf)) 721 if (copy_from_user(&p->RIOConf, arg, sizeof(struct Conf))) {
856 == COPYFAIL) {
857 p->RIOError.Error = COPYIN_FAILED; 722 p->RIOError.Error = COPYIN_FAILED;
858 return -EFAULT; 723 return -EFAULT;
859 } 724 }
@@ -862,7 +727,7 @@ int su;
862 */ 727 */
863 for (Host = 0; Host < p->RIONumHosts; Host++) 728 for (Host = 0; Host < p->RIONumHosts; Host++)
864 if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING) 729 if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING)
865 WWORD(p->RIOHosts[Host].ParmMapP->timer, p->RIOConf.Timer); 730 writew(p->RIOConf.Timer, &p->RIOHosts[Host].ParmMapP->timer);
866 return retval; 731 return retval;
867 732
868 case RIO_START_POLLER: 733 case RIO_START_POLLER:
@@ -881,8 +746,7 @@ int su;
881 case RIO_SETDEBUG: 746 case RIO_SETDEBUG:
882 case RIO_GETDEBUG: 747 case RIO_GETDEBUG:
883 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n"); 748 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n");
884 if (copyin((int) arg, (caddr_t) & DebugCtrl, sizeof(DebugCtrl)) 749 if (copy_from_user(&DebugCtrl, arg, sizeof(DebugCtrl))) {
885 == COPYFAIL) {
886 p->RIOError.Error = COPYIN_FAILED; 750 p->RIOError.Error = COPYIN_FAILED;
887 return -EFAULT; 751 return -EFAULT;
888 } 752 }
@@ -899,7 +763,7 @@ int su;
899 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait); 763 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait);
900 DebugCtrl.Debug = p->rio_debug; 764 DebugCtrl.Debug = p->rio_debug;
901 DebugCtrl.Wait = p->RIODebugWait; 765 DebugCtrl.Wait = p->RIODebugWait;
902 if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) { 766 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
903 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort); 767 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort);
904 p->RIOError.Error = COPYOUT_FAILED; 768 p->RIOError.Error = COPYOUT_FAILED;
905 return -EFAULT; 769 return -EFAULT;
@@ -921,7 +785,7 @@ int su;
921 } else { 785 } else {
922 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug); 786 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug);
923 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug; 787 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug;
924 if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) { 788 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
925 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n"); 789 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
926 p->RIOError.Error = COPYOUT_FAILED; 790 p->RIOError.Error = COPYOUT_FAILED;
927 return -EFAULT; 791 return -EFAULT;
@@ -936,43 +800,20 @@ int su;
936 ** textual null terminated string. 800 ** textual null terminated string.
937 */ 801 */
938 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n"); 802 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n");
939 if (copyout((caddr_t) RIOVersid(), (int) arg, sizeof(struct rioVersion)) == COPYFAIL) { 803 if (copy_to_user(arg, RIOVersid(), sizeof(struct rioVersion))) {
940 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host); 804 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
941 p->RIOError.Error = COPYOUT_FAILED; 805 p->RIOError.Error = COPYOUT_FAILED;
942 return -EFAULT; 806 return -EFAULT;
943 } 807 }
944 return retval; 808 return retval;
945 809
946 /*
947 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
948 ** !! commented out previous 'RIO_VERSID' functionality !!
949 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
950 **
951 case RIO_VERSID:
952 **
953 ** Enquire about the release and version.
954 ** We return MAX_VERSION_LEN bytes, being a textual null
955 ** terminated string.
956 **
957 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
958 if (copyout((caddr_t)RIOVersid(),
959 (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
960 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
961 p->RIOError.Error = COPYOUT_FAILED;
962 return -EFAULT;
963 }
964 return retval;
965 **
966 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
967 */
968
969 case RIO_NUM_HOSTS: 810 case RIO_NUM_HOSTS:
970 /* 811 /*
971 ** Enquire as to the number of hosts located 812 ** Enquire as to the number of hosts located
972 ** at init time. 813 ** at init time.
973 */ 814 */
974 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n"); 815 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n");
975 if (copyout((caddr_t) & p->RIONumHosts, (int) arg, sizeof(p->RIONumHosts)) == COPYFAIL) { 816 if (copy_to_user(arg, &p->RIONumHosts, sizeof(p->RIONumHosts))) {
976 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n"); 817 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
977 p->RIOError.Error = COPYOUT_FAILED; 818 p->RIOError.Error = COPYOUT_FAILED;
978 return -EFAULT; 819 return -EFAULT;
@@ -983,7 +824,7 @@ int su;
983 /* 824 /*
984 ** Kill host. This may not be in the final version... 825 ** Kill host. This may not be in the final version...
985 */ 826 */
986 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %d\n", (int) arg); 827 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", (unsigned long) arg);
987 if (!su) { 828 if (!su) {
988 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n"); 829 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
989 p->RIOError.Error = NOT_SUPER_USER; 830 p->RIOError.Error = NOT_SUPER_USER;
@@ -994,7 +835,7 @@ int su;
994 835
995 for (Host = 0; Host < p->RIONumHosts; Host++) { 836 for (Host = 0; Host < p->RIONumHosts; Host++) {
996 (void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot); 837 (void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot);
997 bzero((caddr_t) & p->RIOHosts[Host].Flags, ((int) &p->RIOHosts[Host].____end_marker____) - ((int) &p->RIOHosts[Host].Flags)); 838 memset(&p->RIOHosts[Host].Flags, 0, ((char *) &p->RIOHosts[Host].____end_marker____) - ((char *) &p->RIOHosts[Host].Flags));
998 p->RIOHosts[Host].Flags = RC_WAITING; 839 p->RIOHosts[Host].Flags = RC_WAITING;
999 } 840 }
1000 RIOFoadWakeup(p); 841 RIOFoadWakeup(p);
@@ -1017,7 +858,7 @@ int su;
1017 p->RIOError.Error = NOT_SUPER_USER; 858 p->RIOError.Error = NOT_SUPER_USER;
1018 return -EPERM; 859 return -EPERM;
1019 } 860 }
1020 if (copyin((int) arg, (caddr_t) & DownLoad, sizeof(DownLoad)) == COPYFAIL) { 861 if (copy_from_user(&DownLoad, arg, sizeof(DownLoad))) {
1021 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n"); 862 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
1022 p->RIOError.Error = COPYIN_FAILED; 863 p->RIOError.Error = COPYIN_FAILED;
1023 return -EFAULT; 864 return -EFAULT;
@@ -1045,9 +886,9 @@ int su;
1045 886
1046 case RIO_PARMS: 887 case RIO_PARMS:
1047 { 888 {
1048 uint host; 889 unsigned int host;
1049 890
1050 if (copyin((int) arg, (caddr_t) & host, sizeof(host)) == COPYFAIL) { 891 if (copy_from_user(&host, arg, sizeof(host))) {
1051 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 892 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
1052 p->RIOError.Error = COPYIN_FAILED; 893 p->RIOError.Error = COPYIN_FAILED;
1053 return -EFAULT; 894 return -EFAULT;
@@ -1056,7 +897,7 @@ int su;
1056 ** Fetch the parmmap 897 ** Fetch the parmmap
1057 */ 898 */
1058 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n"); 899 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n");
1059 if (copyout((caddr_t) p->RIOHosts[host].ParmMapP, (int) arg, sizeof(PARM_MAP)) == COPYFAIL) { 900 if (copy_to_user(arg, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) {
1060 p->RIOError.Error = COPYOUT_FAILED; 901 p->RIOError.Error = COPYOUT_FAILED;
1061 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n"); 902 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
1062 return -EFAULT; 903 return -EFAULT;
@@ -1066,7 +907,7 @@ int su;
1066 907
1067 case RIO_HOST_REQ: 908 case RIO_HOST_REQ:
1068 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n"); 909 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n");
1069 if (copyin((int) arg, (caddr_t) & HostReq, sizeof(HostReq)) == COPYFAIL) { 910 if (copy_from_user(&HostReq, arg, sizeof(HostReq))) {
1070 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 911 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
1071 p->RIOError.Error = COPYIN_FAILED; 912 p->RIOError.Error = COPYIN_FAILED;
1072 return -EFAULT; 913 return -EFAULT;
@@ -1078,7 +919,7 @@ int su;
1078 } 919 }
1079 rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum); 920 rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum);
1080 921
1081 if (copyout((caddr_t) & p->RIOHosts[HostReq.HostNum], (int) HostReq.HostP, sizeof(struct Host)) == COPYFAIL) { 922 if (copy_to_user(HostReq.HostP, &p->RIOHosts[HostReq.HostNum], sizeof(struct Host))) {
1082 p->RIOError.Error = COPYOUT_FAILED; 923 p->RIOError.Error = COPYOUT_FAILED;
1083 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n"); 924 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n");
1084 return -EFAULT; 925 return -EFAULT;
@@ -1087,7 +928,7 @@ int su;
1087 928
1088 case RIO_HOST_DPRAM: 929 case RIO_HOST_DPRAM:
1089 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n"); 930 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n");
1090 if (copyin((int) arg, (caddr_t) & HostDpRam, sizeof(HostDpRam)) == COPYFAIL) { 931 if (copy_from_user(&HostDpRam, arg, sizeof(HostDpRam))) {
1091 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n"); 932 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
1092 p->RIOError.Error = COPYIN_FAILED; 933 p->RIOError.Error = COPYIN_FAILED;
1093 return -EFAULT; 934 return -EFAULT;
@@ -1104,13 +945,13 @@ int su;
1104 /* It's hardware like this that really gets on my tits. */ 945 /* It's hardware like this that really gets on my tits. */
1105 static unsigned char copy[sizeof(struct DpRam)]; 946 static unsigned char copy[sizeof(struct DpRam)];
1106 for (off = 0; off < sizeof(struct DpRam); off++) 947 for (off = 0; off < sizeof(struct DpRam); off++)
1107 copy[off] = p->RIOHosts[HostDpRam.HostNum].Caddr[off]; 948 copy[off] = readb(&p->RIOHosts[HostDpRam.HostNum].Caddr[off]);
1108 if (copyout((caddr_t) copy, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) { 949 if (copy_to_user(HostDpRam.DpRamP, copy, sizeof(struct DpRam))) {
1109 p->RIOError.Error = COPYOUT_FAILED; 950 p->RIOError.Error = COPYOUT_FAILED;
1110 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 951 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
1111 return -EFAULT; 952 return -EFAULT;
1112 } 953 }
1113 } else if (copyout((caddr_t) p->RIOHosts[HostDpRam.HostNum].Caddr, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) { 954 } else if (copy_to_user(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) {
1114 p->RIOError.Error = COPYOUT_FAILED; 955 p->RIOError.Error = COPYOUT_FAILED;
1115 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 956 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
1116 return -EFAULT; 957 return -EFAULT;
@@ -1119,13 +960,13 @@ int su;
1119 960
1120 case RIO_SET_BUSY: 961 case RIO_SET_BUSY:
1121 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n"); 962 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n");
1122 if ((int) arg < 0 || (int) arg > 511) { 963 if ((unsigned long) arg > 511) {
1123 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n", (int) arg); 964 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", (unsigned long) arg);
1124 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 965 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
1125 return -EINVAL; 966 return -EINVAL;
1126 } 967 }
1127 rio_spin_lock_irqsave(&PortP->portSem, flags); 968 rio_spin_lock_irqsave(&PortP->portSem, flags);
1128 p->RIOPortp[(int) arg]->State |= RIO_BUSY; 969 p->RIOPortp[(unsigned long) arg]->State |= RIO_BUSY;
1129 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 970 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1130 return retval; 971 return retval;
1131 972
@@ -1135,7 +976,7 @@ int su;
1135 ** (probably for debug reasons) 976 ** (probably for debug reasons)
1136 */ 977 */
1137 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n"); 978 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n");
1138 if (copyin((int) arg, (caddr_t) & PortReq, sizeof(PortReq)) == COPYFAIL) { 979 if (copy_from_user(&PortReq, arg, sizeof(PortReq))) {
1139 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n"); 980 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
1140 p->RIOError.Error = COPYIN_FAILED; 981 p->RIOError.Error = COPYIN_FAILED;
1141 return -EFAULT; 982 return -EFAULT;
@@ -1147,7 +988,7 @@ int su;
1147 return -ENXIO; 988 return -ENXIO;
1148 } 989 }
1149 rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort); 990 rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort);
1150 if (copyout((caddr_t) p->RIOPortp[PortReq.SysPort], (int) PortReq.PortP, sizeof(struct Port)) == COPYFAIL) { 991 if (copy_to_user(PortReq.PortP, p->RIOPortp[PortReq.SysPort], sizeof(struct Port))) {
1151 p->RIOError.Error = COPYOUT_FAILED; 992 p->RIOError.Error = COPYOUT_FAILED;
1152 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n"); 993 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n");
1153 return -EFAULT; 994 return -EFAULT;
@@ -1160,7 +1001,7 @@ int su;
1160 ** (probably for debug reasons) 1001 ** (probably for debug reasons)
1161 */ 1002 */
1162 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n"); 1003 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n");
1163 if (copyin((int) arg, (caddr_t) & RupReq, sizeof(RupReq)) == COPYFAIL) { 1004 if (copy_from_user(&RupReq, arg, sizeof(RupReq))) {
1164 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n"); 1005 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
1165 p->RIOError.Error = COPYIN_FAILED; 1006 p->RIOError.Error = COPYIN_FAILED;
1166 return -EFAULT; 1007 return -EFAULT;
@@ -1184,7 +1025,7 @@ int su;
1184 } 1025 }
1185 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum); 1026 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum);
1186 1027
1187 if (copyout((caddr_t) HostP->UnixRups[RupReq.RupNum].RupP, (int) RupReq.RupP, sizeof(struct RUP)) == COPYFAIL) { 1028 if (copy_to_user(HostP->UnixRups[RupReq.RupNum].RupP, RupReq.RupP, sizeof(struct RUP))) {
1188 p->RIOError.Error = COPYOUT_FAILED; 1029 p->RIOError.Error = COPYOUT_FAILED;
1189 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n"); 1030 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
1190 return -EFAULT; 1031 return -EFAULT;
@@ -1197,7 +1038,7 @@ int su;
1197 ** (probably for debug reasons) 1038 ** (probably for debug reasons)
1198 */ 1039 */
1199 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n"); 1040 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n");
1200 if (copyin((int) arg, (caddr_t) & LpbReq, sizeof(LpbReq)) == COPYFAIL) { 1041 if (copy_from_user(&LpbReq, arg, sizeof(LpbReq))) {
1201 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n"); 1042 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
1202 p->RIOError.Error = COPYIN_FAILED; 1043 p->RIOError.Error = COPYIN_FAILED;
1203 return -EFAULT; 1044 return -EFAULT;
@@ -1221,7 +1062,7 @@ int su;
1221 } 1062 }
1222 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host); 1063 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host);
1223 1064
1224 if (copyout((caddr_t) & HostP->LinkStrP[LpbReq.Link], (int) LpbReq.LpbP, sizeof(struct LPB)) == COPYFAIL) { 1065 if (copy_to_user(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) {
1225 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n"); 1066 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
1226 p->RIOError.Error = COPYOUT_FAILED; 1067 p->RIOError.Error = COPYOUT_FAILED;
1227 return -EFAULT; 1068 return -EFAULT;
@@ -1252,12 +1093,13 @@ int su;
1252 p->RIOError.Error = SIGNALS_ALREADY_SET; 1093 p->RIOError.Error = SIGNALS_ALREADY_SET;
1253 return -EBUSY; 1094 return -EBUSY;
1254 } 1095 }
1255 p->RIOSignalProcess = getpid(); 1096 /* FIXME: PID tracking */
1097 p->RIOSignalProcess = current->pid;
1256 p->RIOPrintDisabled = DONT_PRINT; 1098 p->RIOPrintDisabled = DONT_PRINT;
1257 return retval; 1099 return retval;
1258 1100
1259 case RIO_SIGNALS_OFF: 1101 case RIO_SIGNALS_OFF:
1260 if (p->RIOSignalProcess != getpid()) { 1102 if (p->RIOSignalProcess != current->pid) {
1261 p->RIOError.Error = NOT_RECEIVING_PROCESS; 1103 p->RIOError.Error = NOT_RECEIVING_PROCESS;
1262 return -EPERM; 1104 return -EPERM;
1263 } 1105 }
@@ -1294,7 +1136,7 @@ int su;
1294 case RIO_MAP_B110_TO_110: 1136 case RIO_MAP_B110_TO_110:
1295 case RIO_MAP_B110_TO_115200: 1137 case RIO_MAP_B110_TO_115200:
1296 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n"); 1138 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n");
1297 port = (uint) arg; 1139 port = (unsigned long) arg;
1298 if (port < 0 || port > 511) { 1140 if (port < 0 || port > 511) {
1299 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port); 1141 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
1300 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 1142 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -1324,7 +1166,7 @@ int su;
1324 1166
1325 case RIO_SEND_PACKET: 1167 case RIO_SEND_PACKET:
1326 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n"); 1168 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
1327 if (copyin((int) arg, (caddr_t) & SendPack, sizeof(SendPack)) == COPYFAIL) { 1169 if (copy_from_user(&SendPack, arg, sizeof(SendPack))) {
1328 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n"); 1170 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
1329 p->RIOError.Error = COPYIN_FAILED; 1171 p->RIOError.Error = COPYIN_FAILED;
1330 return -EFAULT; 1172 return -EFAULT;
@@ -1344,9 +1186,9 @@ int su;
1344 } 1186 }
1345 1187
1346 for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++) 1188 for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++)
1347 WBYTE(PacketP->data[loop], SendPack.Data[loop]); 1189 writeb(SendPack.Data[loop], &PacketP->data[loop]);
1348 1190
1349 WBYTE(PacketP->len, SendPack.Len); 1191 writeb(SendPack.Len, &PacketP->len);
1350 1192
1351 add_transmit(PortP); 1193 add_transmit(PortP);
1352 /* 1194 /*
@@ -1368,7 +1210,7 @@ int su;
1368 return su ? 0 : -EPERM; 1210 return su ? 0 : -EPERM;
1369 1211
1370 case RIO_WHAT_MESG: 1212 case RIO_WHAT_MESG:
1371 if (copyout((caddr_t) & p->RIONoMessage, (int) arg, sizeof(p->RIONoMessage)) == COPYFAIL) { 1213 if (copy_to_user(arg, &p->RIONoMessage, sizeof(p->RIONoMessage))) {
1372 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n"); 1214 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
1373 p->RIOError.Error = COPYOUT_FAILED; 1215 p->RIOError.Error = COPYOUT_FAILED;
1374 return -EFAULT; 1216 return -EFAULT;
@@ -1376,7 +1218,7 @@ int su;
1376 return 0; 1218 return 0;
1377 1219
1378 case RIO_MEM_DUMP: 1220 case RIO_MEM_DUMP:
1379 if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) { 1221 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
1380 p->RIOError.Error = COPYIN_FAILED; 1222 p->RIOError.Error = COPYIN_FAILED;
1381 return -EFAULT; 1223 return -EFAULT;
1382 } 1224 }
@@ -1406,7 +1248,7 @@ int su;
1406 PortP->State |= RIO_BUSY; 1248 PortP->State |= RIO_BUSY;
1407 1249
1408 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1250 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1409 if (copyout((caddr_t) p->RIOMemDump, (int) arg, MEMDUMP_SIZE) == COPYFAIL) { 1251 if (copy_to_user(arg, p->RIOMemDump, MEMDUMP_SIZE)) {
1410 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n"); 1252 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
1411 p->RIOError.Error = COPYOUT_FAILED; 1253 p->RIOError.Error = COPYOUT_FAILED;
1412 return -EFAULT; 1254 return -EFAULT;
@@ -1414,30 +1256,30 @@ int su;
1414 return 0; 1256 return 0;
1415 1257
1416 case RIO_TICK: 1258 case RIO_TICK:
1417 if ((int) arg < 0 || (int) arg >= p->RIONumHosts) 1259 if ((unsigned long) arg >= p->RIONumHosts)
1418 return -EINVAL; 1260 return -EINVAL;
1419 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %d\n", (int) arg); 1261 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", (unsigned long) arg);
1420 WBYTE(p->RIOHosts[(int) arg].SetInt, 0xff); 1262 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].SetInt);
1421 return 0; 1263 return 0;
1422 1264
1423 case RIO_TOCK: 1265 case RIO_TOCK:
1424 if ((int) arg < 0 || (int) arg >= p->RIONumHosts) 1266 if ((unsigned long) arg >= p->RIONumHosts)
1425 return -EINVAL; 1267 return -EINVAL;
1426 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %d\n", (int) arg); 1268 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", (unsigned long) arg);
1427 WBYTE((p->RIOHosts[(int) arg].ResetInt), 0xff); 1269 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].ResetInt);
1428 return 0; 1270 return 0;
1429 1271
1430 case RIO_READ_CHECK: 1272 case RIO_READ_CHECK:
1431 /* Check reads for pkts with data[0] the same */ 1273 /* Check reads for pkts with data[0] the same */
1432 p->RIOReadCheck = !p->RIOReadCheck; 1274 p->RIOReadCheck = !p->RIOReadCheck;
1433 if (copyout((caddr_t) & p->RIOReadCheck, (int) arg, sizeof(uint)) == COPYFAIL) { 1275 if (copy_to_user(arg, &p->RIOReadCheck, sizeof(unsigned int))) {
1434 p->RIOError.Error = COPYOUT_FAILED; 1276 p->RIOError.Error = COPYOUT_FAILED;
1435 return -EFAULT; 1277 return -EFAULT;
1436 } 1278 }
1437 return 0; 1279 return 0;
1438 1280
1439 case RIO_READ_REGISTER: 1281 case RIO_READ_REGISTER:
1440 if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) { 1282 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
1441 p->RIOError.Error = COPYIN_FAILED; 1283 p->RIOError.Error = COPYIN_FAILED;
1442 return -EFAULT; 1284 return -EFAULT;
1443 } 1285 }
@@ -1472,7 +1314,7 @@ int su;
1472 PortP->State |= RIO_BUSY; 1314 PortP->State |= RIO_BUSY;
1473 1315
1474 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1316 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1475 if (copyout((caddr_t) & p->CdRegister, (int) arg, sizeof(uint)) == COPYFAIL) { 1317 if (copy_to_user(arg, &p->CdRegister, sizeof(unsigned int))) {
1476 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n"); 1318 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
1477 p->RIOError.Error = COPYOUT_FAILED; 1319 p->RIOError.Error = COPYOUT_FAILED;
1478 return -EFAULT; 1320 return -EFAULT;
@@ -1485,21 +1327,22 @@ int su;
1485 */ 1327 */
1486 case RIO_MAKE_DEV: 1328 case RIO_MAKE_DEV:
1487 { 1329 {
1488 uint port = (uint) arg & RIO_MODEM_MASK; 1330 unsigned int port = (unsigned long) arg & RIO_MODEM_MASK;
1331 unsigned int ret;
1489 1332
1490 switch ((uint) arg & RIO_DEV_MASK) { 1333 switch ((unsigned long) arg & RIO_DEV_MASK) {
1491 case RIO_DEV_DIRECT: 1334 case RIO_DEV_DIRECT:
1492 arg = (caddr_t) drv_makedev(MAJOR(dev), port); 1335 ret = drv_makedev(MAJOR(dev), port);
1493 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, (int) arg); 1336 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, ret);
1494 return (int) arg; 1337 return ret;
1495 case RIO_DEV_MODEM: 1338 case RIO_DEV_MODEM:
1496 arg = (caddr_t) drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT)); 1339 ret = drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT));
1497 rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, (int) arg); 1340 rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, ret);
1498 return (int) arg; 1341 return ret;
1499 case RIO_DEV_XPRINT: 1342 case RIO_DEV_XPRINT:
1500 arg = (caddr_t) drv_makedev(MAJOR(dev), port); 1343 ret = drv_makedev(MAJOR(dev), port);
1501 rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, (int) arg); 1344 rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, ret);
1502 return (int) arg; 1345 return ret;
1503 } 1346 }
1504 rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n"); 1347 rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n");
1505 return -EINVAL; 1348 return -EINVAL;
@@ -1513,18 +1356,19 @@ int su;
1513 { 1356 {
1514 dev_t dv; 1357 dev_t dv;
1515 int mino; 1358 int mino;
1359 unsigned long ret;
1516 1360
1517 dv = (dev_t) ((int) arg); 1361 dv = (dev_t) ((unsigned long) arg);
1518 mino = RIO_UNMODEM(dv); 1362 mino = RIO_UNMODEM(dv);
1519 1363
1520 if (RIO_ISMODEM(dv)) { 1364 if (RIO_ISMODEM(dv)) {
1521 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino); 1365 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino);
1522 arg = (caddr_t) (mino | RIO_DEV_MODEM); 1366 ret = mino | RIO_DEV_MODEM;
1523 } else { 1367 } else {
1524 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino); 1368 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino);
1525 arg = (caddr_t) (mino | RIO_DEV_DIRECT); 1369 ret = mino | RIO_DEV_DIRECT;
1526 } 1370 }
1527 return (int) arg; 1371 return ret;
1528 } 1372 }
1529 } 1373 }
1530 rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd); 1374 rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd);
@@ -1537,10 +1381,7 @@ int su;
1537/* 1381/*
1538** Pre-emptive commands go on RUPs and are only one byte long. 1382** Pre-emptive commands go on RUPs and are only one byte long.
1539*/ 1383*/
1540int RIOPreemptiveCmd(p, PortP, Cmd) 1384int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
1541struct rio_info *p;
1542struct Port *PortP;
1543uchar Cmd;
1544{ 1385{
1545 struct CmdBlk *CmdBlkP; 1386 struct CmdBlk *CmdBlkP;
1546 struct PktCmd_M *PktCmdP; 1387 struct PktCmd_M *PktCmdP;
@@ -1558,7 +1399,7 @@ uchar Cmd;
1558 return RIO_FAIL; 1399 return RIO_FAIL;
1559 } 1400 }
1560 1401
1561 rio_dprintk(RIO_DEBUG_CTRL, "Command blk 0x%x - InUse now %d\n", (int) CmdBlkP, PortP->InUse); 1402 rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n", CmdBlkP, PortP->InUse);
1562 1403
1563 PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0]; 1404 PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0];
1564 1405
@@ -1572,7 +1413,7 @@ uchar Cmd;
1572 CmdBlkP->Packet.dest_port = COMMAND_RUP; 1413 CmdBlkP->Packet.dest_port = COMMAND_RUP;
1573 CmdBlkP->Packet.len = PKT_CMD_BIT | 2; 1414 CmdBlkP->Packet.len = PKT_CMD_BIT | 2;
1574 CmdBlkP->PostFuncP = RIOUnUse; 1415 CmdBlkP->PostFuncP = RIOUnUse;
1575 CmdBlkP->PostArg = (int) PortP; 1416 CmdBlkP->PostArg = (unsigned long) PortP;
1576 PktCmdP->Command = Cmd; 1417 PktCmdP->Command = Cmd;
1577 port = PortP->HostPort % (ushort) PORTS_PER_RTA; 1418 port = PortP->HostPort % (ushort) PORTS_PER_RTA;
1578 /* 1419 /*
@@ -1584,38 +1425,38 @@ uchar Cmd;
1584 1425
1585 switch (Cmd) { 1426 switch (Cmd) {
1586 case MEMDUMP: 1427 case MEMDUMP:
1587 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk 0x%x (addr 0x%x)\n", (int) CmdBlkP, (int) SubCmd.Addr); 1428 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p (addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr);
1588 PktCmdP->SubCommand = MEMDUMP; 1429 PktCmdP->SubCommand = MEMDUMP;
1589 PktCmdP->SubAddr = SubCmd.Addr; 1430 PktCmdP->SubAddr = SubCmd.Addr;
1590 break; 1431 break;
1591 case FCLOSE: 1432 case FCLOSE:
1592 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk 0x%x\n", (int) CmdBlkP); 1433 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", CmdBlkP);
1593 break; 1434 break;
1594 case READ_REGISTER: 1435 case READ_REGISTER:
1595 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk 0x%x\n", (int) SubCmd.Addr, (int) CmdBlkP); 1436 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk %p\n", (int) SubCmd.Addr, CmdBlkP);
1596 PktCmdP->SubCommand = READ_REGISTER; 1437 PktCmdP->SubCommand = READ_REGISTER;
1597 PktCmdP->SubAddr = SubCmd.Addr; 1438 PktCmdP->SubAddr = SubCmd.Addr;
1598 break; 1439 break;
1599 case RESUME: 1440 case RESUME:
1600 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk 0x%x\n", (int) CmdBlkP); 1441 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", CmdBlkP);
1601 break; 1442 break;
1602 case RFLUSH: 1443 case RFLUSH:
1603 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk 0x%x\n", (int) CmdBlkP); 1444 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", CmdBlkP);
1604 CmdBlkP->PostFuncP = RIORFlushEnable; 1445 CmdBlkP->PostFuncP = RIORFlushEnable;
1605 break; 1446 break;
1606 case SUSPEND: 1447 case SUSPEND:
1607 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk 0x%x\n", (int) CmdBlkP); 1448 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", CmdBlkP);
1608 break; 1449 break;
1609 1450
1610 case MGET: 1451 case MGET:
1611 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk 0x%x\n", (int) CmdBlkP); 1452 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", CmdBlkP);
1612 break; 1453 break;
1613 1454
1614 case MSET: 1455 case MSET:
1615 case MBIC: 1456 case MBIC:
1616 case MBIS: 1457 case MBIS:
1617 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines; 1458 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
1618 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk 0x%x\n", (int) CmdBlkP); 1459 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk %p\n", CmdBlkP);
1619 break; 1460 break;
1620 1461
1621 case WFLUSH: 1462 case WFLUSH:
@@ -1629,7 +1470,7 @@ uchar Cmd;
1629 RIOFreeCmdBlk(CmdBlkP); 1470 RIOFreeCmdBlk(CmdBlkP);
1630 return (RIO_FAIL); 1471 return (RIO_FAIL);
1631 } else { 1472 } else {
1632 rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk 0x%x\n", (int) CmdBlkP); 1473 rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk %p\n", CmdBlkP);
1633 CmdBlkP->PostFuncP = RIOWFlushMark; 1474 CmdBlkP->PostFuncP = RIOWFlushMark;
1634 } 1475 }
1635 break; 1476 break;
diff --git a/drivers/char/rio/riodrvr.h b/drivers/char/rio/riodrvr.h
index 663ee0914ed7..3cffe275f216 100644
--- a/drivers/char/rio/riodrvr.h
+++ b/drivers/char/rio/riodrvr.h
@@ -72,42 +72,42 @@ struct rio_info {
72*/ 72*/
73 int RIOHalted; /* halted ? */ 73 int RIOHalted; /* halted ? */
74 int RIORtaDisCons; /* RTA connections/disconnections */ 74 int RIORtaDisCons; /* RTA connections/disconnections */
75 uint RIOReadCheck; /* Rio read check */ 75 unsigned int RIOReadCheck; /* Rio read check */
76 uint RIONoMessage; /* To display message or not */ 76 unsigned int RIONoMessage; /* To display message or not */
77 uint RIONumBootPkts; /* how many packets for an RTA */ 77 unsigned int RIONumBootPkts; /* how many packets for an RTA */
78 uint RIOBootCount; /* size of RTA code */ 78 unsigned int RIOBootCount; /* size of RTA code */
79 uint RIOBooting; /* count of outstanding boots */ 79 unsigned int RIOBooting; /* count of outstanding boots */
80 uint RIOSystemUp; /* Booted ?? */ 80 unsigned int RIOSystemUp; /* Booted ?? */
81 uint RIOCounting; /* for counting interrupts */ 81 unsigned int RIOCounting; /* for counting interrupts */
82 uint RIOIntCount; /* # of intr since last check */ 82 unsigned int RIOIntCount; /* # of intr since last check */
83 uint RIOTxCount; /* number of xmit intrs */ 83 unsigned int RIOTxCount; /* number of xmit intrs */
84 uint RIORxCount; /* number of rx intrs */ 84 unsigned int RIORxCount; /* number of rx intrs */
85 uint RIORupCount; /* number of rup intrs */ 85 unsigned int RIORupCount; /* number of rup intrs */
86 int RIXTimer; 86 int RIXTimer;
87 int RIOBufferSize; /* Buffersize */ 87 int RIOBufferSize; /* Buffersize */
88 int RIOBufferMask; /* Buffersize */ 88 int RIOBufferMask; /* Buffersize */
89 89
90 int RIOFirstMajor; /* First host card's major no */ 90 int RIOFirstMajor; /* First host card's major no */
91 91
92 uint RIOLastPortsMapped; /* highest port number known */ 92 unsigned int RIOLastPortsMapped; /* highest port number known */
93 uint RIOFirstPortsMapped; /* lowest port number known */ 93 unsigned int RIOFirstPortsMapped; /* lowest port number known */
94 94
95 uint RIOLastPortsBooted; /* highest port number running */ 95 unsigned int RIOLastPortsBooted; /* highest port number running */
96 uint RIOFirstPortsBooted; /* lowest port number running */ 96 unsigned int RIOFirstPortsBooted; /* lowest port number running */
97 97
98 uint RIOLastPortsOpened; /* highest port number running */ 98 unsigned int RIOLastPortsOpened; /* highest port number running */
99 uint RIOFirstPortsOpened; /* lowest port number running */ 99 unsigned int RIOFirstPortsOpened; /* lowest port number running */
100 100
101 /* Flag to say that the topology information has been changed. */ 101 /* Flag to say that the topology information has been changed. */
102 uint RIOQuickCheck; 102 unsigned int RIOQuickCheck;
103 uint CdRegister; /* ??? */ 103 unsigned int CdRegister; /* ??? */
104 int RIOSignalProcess; /* Signalling process */ 104 int RIOSignalProcess; /* Signalling process */
105 int rio_debug; /* To debug ... */ 105 int rio_debug; /* To debug ... */
106 int RIODebugWait; /* For what ??? */ 106 int RIODebugWait; /* For what ??? */
107 int tpri; /* Thread prio */ 107 int tpri; /* Thread prio */
108 int tid; /* Thread id */ 108 int tid; /* Thread id */
109 uint _RIO_Polled; /* Counter for polling */ 109 unsigned int _RIO_Polled; /* Counter for polling */
110 uint _RIO_Interrupted; /* Counter for interrupt */ 110 unsigned int _RIO_Interrupted; /* Counter for interrupt */
111 int intr_tid; /* iointset return value */ 111 int intr_tid; /* iointset return value */
112 int TxEnSem; /* TxEnable Semaphore */ 112 int TxEnSem; /* TxEnable Semaphore */
113 113
@@ -121,9 +121,9 @@ struct rio_info {
121 struct Map RIOSavedTable[TOTAL_MAP_ENTRIES]; 121 struct Map RIOSavedTable[TOTAL_MAP_ENTRIES];
122 122
123 /* RTA to host binding table for master/slave operation */ 123 /* RTA to host binding table for master/slave operation */
124 ulong RIOBindTab[MAX_RTA_BINDINGS]; 124 unsigned long RIOBindTab[MAX_RTA_BINDINGS];
125 /* RTA memory dump variable */ 125 /* RTA memory dump variable */
126 uchar RIOMemDump[MEMDUMP_SIZE]; 126 unsigned char RIOMemDump[MEMDUMP_SIZE];
127 struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES]; 127 struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES];
128 128
129}; 129};
@@ -138,7 +138,5 @@ struct rio_info {
138 138
139 139
140#define RIO_RESET_INT 0x7d80 140#define RIO_RESET_INT 0x7d80
141#define WRBYTE(x,y) *(volatile unsigned char *)((x)) = \
142 (unsigned char)(y)
143 141
144#endif /* __riodrvr.h */ 142#endif /* __riodrvr.h */
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 0d44ef464e6b..24d2992154cc 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -51,15 +51,12 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
51 51
52 52
53#include "linux_compat.h" 53#include "linux_compat.h"
54#include "typdef.h"
55#include "pkt.h" 54#include "pkt.h"
56#include "daemon.h" 55#include "daemon.h"
57#include "rio.h" 56#include "rio.h"
58#include "riospace.h" 57#include "riospace.h"
59#include "top.h"
60#include "cmdpkt.h" 58#include "cmdpkt.h"
61#include "map.h" 59#include "map.h"
62#include "riotypes.h"
63#include "rup.h" 60#include "rup.h"
64#include "port.h" 61#include "port.h"
65#include "riodrvr.h" 62#include "riodrvr.h"
@@ -72,22 +69,17 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
72#include "unixrup.h" 69#include "unixrup.h"
73#include "board.h" 70#include "board.h"
74#include "host.h" 71#include "host.h"
75#include "error.h"
76#include "phb.h" 72#include "phb.h"
77#include "link.h" 73#include "link.h"
78#include "cmdblk.h" 74#include "cmdblk.h"
79#include "route.h" 75#include "route.h"
80#include "control.h"
81#include "cirrus.h" 76#include "cirrus.h"
82#include "rioioctl.h" 77#include "rioioctl.h"
83#include "rio_linux.h" 78#include "rio_linux.h"
84 79
85#undef bcopy
86#define bcopy rio_pcicopy
87
88int RIOPCIinit(struct rio_info *p, int Mode); 80int RIOPCIinit(struct rio_info *p, int Mode);
89 81
90static int RIOScrub(int, BYTE *, int); 82static int RIOScrub(int, u8 *, int);
91 83
92 84
93/** 85/**
@@ -99,12 +91,8 @@ static int RIOScrub(int, BYTE *, int);
99** bits < 0 indicates 8 bit operation requested, 91** bits < 0 indicates 8 bit operation requested,
100** bits > 0 indicates 16 bit operation. 92** bits > 0 indicates 16 bit operation.
101*/ 93*/
102int 94
103RIOAssignAT(p, Base, virtAddr, mode) 95int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode)
104struct rio_info * p;
105int Base;
106caddr_t virtAddr;
107int mode;
108{ 96{
109 int bits; 97 int bits;
110 struct DpRam *cardp = (struct DpRam *)virtAddr; 98 struct DpRam *cardp = (struct DpRam *)virtAddr;
@@ -124,29 +112,25 @@ int mode;
124 /* 112 /*
125 ** Revision 01 AT host cards don't support WORD operations, 113 ** Revision 01 AT host cards don't support WORD operations,
126 */ 114 */
127 if ( RBYTE(cardp->DpRevision) == 01 ) 115 if (readb(&cardp->DpRevision) == 01)
128 bits = BYTE_OPERATION; 116 bits = BYTE_OPERATION;
129 117
130 p->RIOHosts[p->RIONumHosts].Type = RIO_AT; 118 p->RIOHosts[p->RIONumHosts].Type = RIO_AT;
131 p->RIOHosts[p->RIONumHosts].Copy = bcopy; 119 p->RIOHosts[p->RIONumHosts].Copy = rio_copy_to_card;
132 /* set this later */ 120 /* set this later */
133 p->RIOHosts[p->RIONumHosts].Slot = -1; 121 p->RIOHosts[p->RIONumHosts].Slot = -1;
134 p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits; 122 p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits;
135 WBYTE(p->RIOHosts[p->RIONumHosts].Control, 123 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE ,
136 BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 124 &p->RIOHosts[p->RIONumHosts].Control);
137 p->RIOHosts[p->RIONumHosts].Mode | 125 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
138 INTERRUPT_DISABLE ); 126 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE,
139 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff); 127 &p->RIOHosts[p->RIONumHosts].Control);
140 WBYTE(p->RIOHosts[p->RIONumHosts].Control, 128 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
141 BOOT_FROM_RAM | EXTERNAL_BUS_OFF |
142 p->RIOHosts[p->RIONumHosts].Mode |
143 INTERRUPT_DISABLE );
144 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);
145 p->RIOHosts[p->RIONumHosts].UniqueNum = 129 p->RIOHosts[p->RIONumHosts].UniqueNum =
146 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)| 130 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)|
147 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)| 131 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)|
148 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)| 132 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)|
149 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24); 133 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24);
150 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum); 134 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum);
151 135
152 p->RIONumHosts++; 136 p->RIONumHosts++;
@@ -154,7 +138,7 @@ int mode;
154 return(1); 138 return(1);
155} 139}
156 140
157static uchar val[] = { 141static u8 val[] = {
158#ifdef VERY_LONG_TEST 142#ifdef VERY_LONG_TEST
159 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 143 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
160 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36, 144 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36,
@@ -167,12 +151,7 @@ static uchar val[] = {
167** RAM test a board. 151** RAM test a board.
168** Nothing too complicated, just enough to check it out. 152** Nothing too complicated, just enough to check it out.
169*/ 153*/
170int 154int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slot)
171RIOBoardTest(paddr, caddr, type, slot)
172paddr_t paddr;
173caddr_t caddr;
174uchar type;
175int slot;
176{ 155{
177 struct DpRam *DpRam = (struct DpRam *)caddr; 156 struct DpRam *DpRam = (struct DpRam *)caddr;
178 char *ram[4]; 157 char *ram[4];
@@ -180,8 +159,8 @@ int slot;
180 int op, bank; 159 int op, bank;
181 int nbanks; 160 int nbanks;
182 161
183 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=0x%x, slot=%d\n", 162 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=%p, slot=%d\n",
184 type,(int)DpRam, slot); 163 type, DpRam, slot);
185 164
186 RIOHostReset(type, DpRam, slot); 165 RIOHostReset(type, DpRam, slot);
187 166
@@ -209,12 +188,11 @@ int slot;
209 188
210 189
211 if (nbanks == 3) { 190 if (nbanks == 3) {
212 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n", 191 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: %p(0x%x), %p(0x%x), %p(0x%x)\n",
213 (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2]); 192 ram[0], size[0], ram[1], size[1], ram[2], size[2]);
214 } else { 193 } else {
215 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n", 194 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: %p(0x%x), %p(0x%x), %p(0x%x), %p(0x%x)\n",
216 (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2], (int)ram[3], 195 ram[0], size[0], ram[1], size[1], ram[2], size[2], ram[3], size[3]);
217 size[3]);
218 } 196 }
219 197
220 /* 198 /*
@@ -224,7 +202,7 @@ int slot;
224 */ 202 */
225 for (op=0; op<TEST_END; op++) { 203 for (op=0; op<TEST_END; op++) {
226 for (bank=0; bank<nbanks; bank++) { 204 for (bank=0; bank<nbanks; bank++) {
227 if (RIOScrub(op, (BYTE *)ram[bank], size[bank]) == RIO_FAIL) { 205 if (RIOScrub(op, (u8 *)ram[bank], size[bank]) == RIO_FAIL) {
228 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n", 206 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n",
229 bank, op); 207 bank, op);
230 return RIO_FAIL; 208 return RIO_FAIL;
@@ -233,7 +211,7 @@ int slot;
233 } 211 }
234 212
235 rio_dprintk (RIO_DEBUG_INIT, "Test completed\n"); 213 rio_dprintk (RIO_DEBUG_INIT, "Test completed\n");
236 return RIO_SUCCESS; 214 return 0;
237} 215}
238 216
239 217
@@ -248,13 +226,10 @@ int slot;
248** Call with op not zero, and the RAM will be read and compated with val[op-1] 226** Call with op not zero, and the RAM will be read and compated with val[op-1]
249** to check that the data from the previous phase was retained. 227** to check that the data from the previous phase was retained.
250*/ 228*/
251static int 229
252RIOScrub(op, ram, size) 230static int RIOScrub(int op, u8 *ram, int size)
253int op;
254BYTE * ram;
255int size;
256{ 231{
257 int off; 232 int off;
258 unsigned char oldbyte; 233 unsigned char oldbyte;
259 unsigned char newbyte; 234 unsigned char newbyte;
260 unsigned char invbyte; 235 unsigned char invbyte;
@@ -279,15 +254,15 @@ int size;
279 */ 254 */
280 if (op) { 255 if (op) {
281 for (off=0; off<size; off++) { 256 for (off=0; off<size; off++) {
282 if (RBYTE(ram[off]) != oldbyte) { 257 if (readb(ram + off) != oldbyte) {
283 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, RBYTE(ram[off])); 258 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off));
284 return RIO_FAIL; 259 return RIO_FAIL;
285 } 260 }
286 } 261 }
287 for (off=0; off<size; off+=2) { 262 for (off=0; off<size; off+=2) {
288 if (*(ushort *)&ram[off] != oldword) { 263 if (readw(ram + off) != oldword) {
289 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off,oldword,*(ushort *)&ram[off]); 264 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off,oldword, readw(ram + off));
290 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 265 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1));
291 return RIO_FAIL; 266 return RIO_FAIL;
292 } 267 }
293 } 268 }
@@ -301,13 +276,13 @@ int size;
301 ** the BYTE read/write test. 276 ** the BYTE read/write test.
302 */ 277 */
303 for (off=0; off<size; off++) { 278 for (off=0; off<size; off++) {
304 if (op && (RBYTE(ram[off]) != oldbyte)) { 279 if (op && (readb(ram + off) != oldbyte)) {
305 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, RBYTE(ram[off])); 280 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off));
306 return RIO_FAIL; 281 return RIO_FAIL;
307 } 282 }
308 WBYTE(ram[off],invbyte); 283 writeb(invbyte, ram + off);
309 if (RBYTE(ram[off]) != invbyte) { 284 if (readb(ram + off) != invbyte) {
310 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, invbyte, RBYTE(ram[off])); 285 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, invbyte, readb(ram + off));
311 return RIO_FAIL; 286 return RIO_FAIL;
312 } 287 }
313 } 288 }
@@ -320,16 +295,16 @@ int size;
320 ** This is the WORD operation test. 295 ** This is the WORD operation test.
321 */ 296 */
322 for (off=0; off<size; off+=2) { 297 for (off=0; off<size; off+=2) {
323 if (*(ushort *)&ram[off] != invword) { 298 if (readw(ram + off) != invword) {
324 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off, invword, *(ushort *)&ram[off]); 299 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off, invword, readw(ram + off));
325 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 300 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1));
326 return RIO_FAIL; 301 return RIO_FAIL;
327 } 302 }
328 303
329 *(ushort *)&ram[off] = newword; 304 writew(newword, ram + off);
330 if ( *(ushort *)&ram[off] != newword ) { 305 if ( readw(ram + off) != newword ) {
331 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, *(ushort *)&ram[off]); 306 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off));
332 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 307 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
333 return RIO_FAIL; 308 return RIO_FAIL;
334 } 309 }
335 } 310 }
@@ -340,16 +315,16 @@ int size;
340 ** required test data. 315 ** required test data.
341 */ 316 */
342 for (off=0; off<size; off++) { 317 for (off=0; off<size; off++) {
343 if (RBYTE(ram[off]) != newbyte) { 318 if (readb(ram + off) != newbyte) {
344 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, RBYTE(ram[off])); 319 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off));
345 return RIO_FAIL; 320 return RIO_FAIL;
346 } 321 }
347 } 322 }
348 323
349 for (off=0; off<size; off+=2) { 324 for (off=0; off<size; off+=2) {
350 if ( *(ushort *)&ram[off] != newword ) { 325 if (readw(ram + off) != newword ) {
351 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, *(ushort *)&ram[off]); 326 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off));
352 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 327 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
353 return RIO_FAIL; 328 return RIO_FAIL;
354 } 329 }
355 } 330 }
@@ -360,41 +335,37 @@ int size;
360 swapword = invbyte | (newbyte << 8); 335 swapword = invbyte | (newbyte << 8);
361 336
362 for (off=0; off<size; off+=2) { 337 for (off=0; off<size; off+=2) {
363 WBYTE(ram[off],invbyte); 338 writeb(invbyte, &ram[off]);
364 WBYTE(ram[off+1],newbyte); 339 writeb(newbyte, &ram[off+1]);
365 } 340 }
366 341
367 for ( off=0; off<size; off+=2 ) { 342 for ( off=0; off<size; off+=2 ) {
368 if (*(ushort *)&ram[off] != swapword) { 343 if (readw(ram + off) != swapword) {
369 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, swapword, *((ushort *)&ram[off])); 344 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, swapword, readw(ram + off));
370 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 345 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
371 return RIO_FAIL; 346 return RIO_FAIL;
372 } 347 }
373 *((ushort *)&ram[off]) = ~swapword; 348 writew(~swapword, ram + off);
374 } 349 }
375 350
376 for (off=0; off<size; off+=2) { 351 for (off=0; off<size; off+=2) {
377 if (RBYTE(ram[off]) != newbyte) { 352 if (readb(ram + off) != newbyte) {
378 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, RBYTE(ram[off])); 353 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off));
379 return RIO_FAIL; 354 return RIO_FAIL;
380 } 355 }
381 if (RBYTE(ram[off+1]) != invbyte) { 356 if (readb(ram + off + 1) != invbyte) {
382 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off+1, invbyte, RBYTE(ram[off+1])); 357 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off+1, invbyte, readb(ram + off + 1));
383 return RIO_FAIL; 358 return RIO_FAIL;
384 } 359 }
385 *((ushort *)&ram[off]) = newword; 360 writew(newword, ram + off);
386 } 361 }
387 return RIO_SUCCESS; 362 return 0;
388} 363}
389 364
390 365
391int 366int RIODefaultName(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
392RIODefaultName(p, HostP, UnitId)
393struct rio_info * p;
394struct Host * HostP;
395uint UnitId;
396{ 367{
397 bcopy("UNKNOWN RTA X-XX",HostP->Mapping[UnitId].Name,17); 368 memcpy(HostP->Mapping[UnitId].Name, "UNKNOWN RTA X-XX", 17);
398 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts); 369 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts);
399 if ((UnitId+1) > 9) { 370 if ((UnitId+1) > 9) {
400 HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10); 371 HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10);
@@ -412,8 +383,7 @@ uint UnitId;
412 383
413static struct rioVersion stVersion; 384static struct rioVersion stVersion;
414 385
415struct rioVersion * 386struct rioVersion *RIOVersid(void)
416RIOVersid(void)
417{ 387{
418 strlcpy(stVersion.version, "RIO driver for linux V1.0", 388 strlcpy(stVersion.version, "RIO driver for linux V1.0",
419 sizeof(stVersion.version)); 389 sizeof(stVersion.version));
@@ -423,40 +393,31 @@ RIOVersid(void)
423 return &stVersion; 393 return &stVersion;
424} 394}
425 395
426void 396void RIOHostReset(unsigned int Type, struct DpRam *DpRamP, unsigned int Slot)
427RIOHostReset(Type, DpRamP, Slot)
428uint Type;
429volatile struct DpRam *DpRamP;
430uint Slot;
431{ 397{
432 /* 398 /*
433 ** Reset the Tpu 399 ** Reset the Tpu
434 */ 400 */
435 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type); 401 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type);
436 switch ( Type ) { 402 switch ( Type ) {
437 case RIO_AT: 403 case RIO_AT:
438 rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n"); 404 rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n");
439 WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 405 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE | BYTE_OPERATION |
440 INTERRUPT_DISABLE | BYTE_OPERATION | 406 SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
441 SLOW_LINKS | SLOW_AT_BUS); 407 writeb(0xFF, &DpRamP->DpResetTpu);
442 WBYTE(DpRamP->DpResetTpu, 0xFF); 408 udelay(3);
443 udelay(3);
444
445 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n"); 409 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n");
446 WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 410 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE |
447 INTERRUPT_DISABLE | BYTE_OPERATION | 411 BYTE_OPERATION | SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
448 SLOW_LINKS | SLOW_AT_BUS); 412 writeb(0xFF, &DpRamP->DpResetTpu);
449 WBYTE(DpRamP->DpResetTpu, 0xFF); 413 udelay(3);
450 udelay(3); 414 break;
451 break;
452 case RIO_PCI: 415 case RIO_PCI:
453 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n"); 416 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n");
454 DpRamP->DpControl = RIO_PCI_BOOT_FROM_RAM; 417 writeb(RIO_PCI_BOOT_FROM_RAM, &DpRamP->DpControl);
455 DpRamP->DpResetInt = 0xFF; 418 writeb(0xFF, &DpRamP->DpResetInt);
456 DpRamP->DpResetTpu = 0xFF; 419 writeb(0xFF, &DpRamP->DpResetTpu);
457 udelay(100); 420 udelay(100);
458 /* for (i=0; i<6000; i++); */
459 /* suspend( 3 ); */
460 break; 421 break;
461 default: 422 default:
462 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n"); 423 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n");
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 34d8787557a1..97f0fa550652 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -54,15 +54,12 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
54 54
55#include "linux_compat.h" 55#include "linux_compat.h"
56#include "rio_linux.h" 56#include "rio_linux.h"
57#include "typdef.h"
58#include "pkt.h" 57#include "pkt.h"
59#include "daemon.h" 58#include "daemon.h"
60#include "rio.h" 59#include "rio.h"
61#include "riospace.h" 60#include "riospace.h"
62#include "top.h"
63#include "cmdpkt.h" 61#include "cmdpkt.h"
64#include "map.h" 62#include "map.h"
65#include "riotypes.h"
66#include "rup.h" 63#include "rup.h"
67#include "port.h" 64#include "port.h"
68#include "riodrvr.h" 65#include "riodrvr.h"
@@ -75,12 +72,10 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
75#include "unixrup.h" 72#include "unixrup.h"
76#include "board.h" 73#include "board.h"
77#include "host.h" 74#include "host.h"
78#include "error.h"
79#include "phb.h" 75#include "phb.h"
80#include "link.h" 76#include "link.h"
81#include "cmdblk.h" 77#include "cmdblk.h"
82#include "route.h" 78#include "route.h"
83#include "control.h"
84#include "cirrus.h" 79#include "cirrus.h"
85#include "rioioctl.h" 80#include "rioioctl.h"
86 81
@@ -101,8 +96,7 @@ static char *firstchars(char *p, int nch)
101 96
102#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) 97#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask))
103/* Enable and start the transmission of packets */ 98/* Enable and start the transmission of packets */
104void RIOTxEnable(en) 99void RIOTxEnable(char *en)
105char *en;
106{ 100{
107 struct Port *PortP; 101 struct Port *PortP;
108 struct rio_info *p; 102 struct rio_info *p;
@@ -186,10 +180,8 @@ char *en;
186static int RupIntr; 180static int RupIntr;
187static int RxIntr; 181static int RxIntr;
188static int TxIntr; 182static int TxIntr;
189void RIOServiceHost(p, HostP, From) 183
190struct rio_info *p; 184void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
191struct Host *HostP;
192int From;
193{ 185{
194 rio_spin_lock(&HostP->HostLock); 186 rio_spin_lock(&HostP->HostLock);
195 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { 187 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
@@ -201,22 +193,22 @@ int From;
201 } 193 }
202 rio_spin_unlock(&HostP->HostLock); 194 rio_spin_unlock(&HostP->HostLock);
203 195
204 if (RWORD(HostP->ParmMapP->rup_intr)) { 196 if (readw(&HostP->ParmMapP->rup_intr)) {
205 WWORD(HostP->ParmMapP->rup_intr, 0); 197 writew(0, &HostP->ParmMapP->rup_intr);
206 p->RIORupCount++; 198 p->RIORupCount++;
207 RupIntr++; 199 RupIntr++;
208 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP - p->RIOHosts); 200 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts);
209 RIOPollHostCommands(p, HostP); 201 RIOPollHostCommands(p, HostP);
210 } 202 }
211 203
212 if (RWORD(HostP->ParmMapP->rx_intr)) { 204 if (readw(&HostP->ParmMapP->rx_intr)) {
213 int port; 205 int port;
214 206
215 WWORD(HostP->ParmMapP->rx_intr, 0); 207 writew(0, &HostP->ParmMapP->rx_intr);
216 p->RIORxCount++; 208 p->RIORxCount++;
217 RxIntr++; 209 RxIntr++;
218 210
219 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP - p->RIOHosts); 211 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts);
220 /* 212 /*
221 ** Loop through every port. If the port is mapped into 213 ** Loop through every port. If the port is mapped into
222 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is 214 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is
@@ -277,26 +269,26 @@ int From;
277 ** it's handshake bit is set, then we must clear the handshake, 269 ** it's handshake bit is set, then we must clear the handshake,
278 ** so that that downstream RTA is re-enabled. 270 ** so that that downstream RTA is re-enabled.
279 */ 271 */
280 if (!can_remove_receive(&PacketP, PortP) && (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { 272 if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
281 /* 273 /*
282 ** MAGIC! ( Basically, handshake the RX buffer, so that 274 ** MAGIC! ( Basically, handshake the RX buffer, so that
283 ** the RTAs upstream can be re-enabled. ) 275 ** the RTAs upstream can be re-enabled. )
284 */ 276 */
285 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); 277 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n");
286 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 278 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
287 } 279 }
288 rio_spin_unlock(&PortP->portSem); 280 rio_spin_unlock(&PortP->portSem);
289 } 281 }
290 } 282 }
291 283
292 if (RWORD(HostP->ParmMapP->tx_intr)) { 284 if (readw(&HostP->ParmMapP->tx_intr)) {
293 int port; 285 int port;
294 286
295 WWORD(HostP->ParmMapP->tx_intr, 0); 287 writew(0, &HostP->ParmMapP->tx_intr);
296 288
297 p->RIOTxCount++; 289 p->RIOTxCount++;
298 TxIntr++; 290 TxIntr++;
299 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP - p->RIOHosts); 291 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts);
300 292
301 /* 293 /*
302 ** Loop through every port. 294 ** Loop through every port.
@@ -399,7 +391,6 @@ int From;
399 /* For now don't handle RTA reboots. -- REW. 391 /* For now don't handle RTA reboots. -- REW.
400 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */ 392 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
401 if (PortP->MagicFlags) { 393 if (PortP->MagicFlags) {
402#if 1
403 if (PortP->MagicFlags & MAGIC_REBOOT) { 394 if (PortP->MagicFlags & MAGIC_REBOOT) {
404 /* 395 /*
405 ** well, the RTA has been rebooted, and there is room 396 ** well, the RTA has been rebooted, and there is room
@@ -416,13 +407,12 @@ int From;
416 PortP->InUse = NOT_INUSE; 407 PortP->InUse = NOT_INUSE;
417 408
418 rio_spin_unlock(&PortP->portSem); 409 rio_spin_unlock(&PortP->portSem);
419 if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? TRUE : FALSE, DONT_SLEEP) == RIO_FAIL) { 410 if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) {
420 continue; /* with next port */ 411 continue; /* with next port */
421 } 412 }
422 rio_spin_lock(&PortP->portSem); 413 rio_spin_lock(&PortP->portSem);
423 PortP->MagicFlags &= ~MAGIC_REBOOT; 414 PortP->MagicFlags &= ~MAGIC_REBOOT;
424 } 415 }
425#endif
426 416
427 /* 417 /*
428 ** As mentioned above, this is a tacky hack to cope 418 ** As mentioned above, this is a tacky hack to cope
@@ -445,9 +435,9 @@ int From;
445 */ 435 */
446 PktCmdP = (struct PktCmd *) &PacketP->data[0]; 436 PktCmdP = (struct PktCmd *) &PacketP->data[0];
447 437
448 WBYTE(PktCmdP->Command, WFLUSH); 438 writeb(WFLUSH, &PktCmdP->Command);
449 439
450 p = PortP->HostPort % (ushort) PORTS_PER_RTA; 440 p = PortP->HostPort % (u16) PORTS_PER_RTA;
451 441
452 /* 442 /*
453 ** If second block of ports for 16 port RTA, add 8 443 ** If second block of ports for 16 port RTA, add 8
@@ -456,27 +446,27 @@ int From;
456 if (PortP->SecondBlock) 446 if (PortP->SecondBlock)
457 p += PORTS_PER_RTA; 447 p += PORTS_PER_RTA;
458 448
459 WBYTE(PktCmdP->PhbNum, p); 449 writeb(p, &PktCmdP->PhbNum);
460 450
461 /* 451 /*
462 ** to make debuggery easier 452 ** to make debuggery easier
463 */ 453 */
464 WBYTE(PacketP->data[2], 'W'); 454 writeb('W', &PacketP->data[2]);
465 WBYTE(PacketP->data[3], 'F'); 455 writeb('F', &PacketP->data[3]);
466 WBYTE(PacketP->data[4], 'L'); 456 writeb('L', &PacketP->data[4]);
467 WBYTE(PacketP->data[5], 'U'); 457 writeb('U', &PacketP->data[5]);
468 WBYTE(PacketP->data[6], 'S'); 458 writeb('S', &PacketP->data[6]);
469 WBYTE(PacketP->data[7], 'H'); 459 writeb('H', &PacketP->data[7]);
470 WBYTE(PacketP->data[8], ' '); 460 writeb(' ', &PacketP->data[8]);
471 WBYTE(PacketP->data[9], '0' + PortP->WflushFlag); 461 writeb('0' + PortP->WflushFlag, &PacketP->data[9]);
472 WBYTE(PacketP->data[10], ' '); 462 writeb(' ', &PacketP->data[10]);
473 WBYTE(PacketP->data[11], ' '); 463 writeb(' ', &PacketP->data[11]);
474 WBYTE(PacketP->data[12], '\0'); 464 writeb('\0', &PacketP->data[12]);
475 465
476 /* 466 /*
477 ** its two bytes long! 467 ** its two bytes long!
478 */ 468 */
479 WBYTE(PacketP->len, PKT_CMD_BIT | 2); 469 writeb(PKT_CMD_BIT | 2, &PacketP->len);
480 470
481 /* 471 /*
482 ** queue it! 472 ** queue it!
@@ -529,19 +519,15 @@ int From;
529} 519}
530 520
531/* 521/*
532** Routine for handling received data for clist drivers. 522** Routine for handling received data for tty drivers
533** NB: Called with the tty locked. The spl from the lockb( ) is passed.
534** we return the ttySpl level that we re-locked at.
535*/ 523*/
536static void RIOReceive(p, PortP) 524static void RIOReceive(struct rio_info *p, struct Port *PortP)
537struct rio_info *p;
538struct Port *PortP;
539{ 525{
540 struct tty_struct *TtyP; 526 struct tty_struct *TtyP;
541 register ushort transCount; 527 unsigned short transCount;
542 struct PKT *PacketP; 528 struct PKT *PacketP;
543 register uint DataCnt; 529 register unsigned int DataCnt;
544 uchar *ptr; 530 unsigned char *ptr;
545 unsigned char *buf; 531 unsigned char *buf;
546 int copied = 0; 532 int copied = 0;
547 533
@@ -594,9 +580,6 @@ struct Port *PortP;
594 transCount = 1; 580 transCount = 1;
595 while (can_remove_receive(&PacketP, PortP) 581 while (can_remove_receive(&PacketP, PortP)
596 && transCount) { 582 && transCount) {
597#ifdef STATS
598 PortP->Stat.RxIntCnt++;
599#endif /* STATS */
600 RxIntCnt++; 583 RxIntCnt++;
601 584
602 /* 585 /*
@@ -642,28 +625,15 @@ struct Port *PortP;
642 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the 625 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
643 ** driver). 626 ** driver).
644 */ 627 */
645#undef ___DEBUG_IT___ 628 ptr = (unsigned char *) PacketP->data + PortP->RxDataStart;
646#ifdef ___DEBUG_IT___
647 kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ", intCount, RxIntCnt, PortP->PortNum, TtyP->rxqueue.count, transCount, TtyP->flags);
648#endif
649 ptr = (uchar *) PacketP->data + PortP->RxDataStart;
650 629
651 tty_prepare_flip_string(TtyP, &buf, transCount); 630 tty_prepare_flip_string(TtyP, &buf, transCount);
652 rio_memcpy_fromio(buf, ptr, transCount); 631 rio_memcpy_fromio(buf, ptr, transCount);
653#ifdef STATS
654 /*
655 ** keep a count for statistical purposes
656 */
657 PortP->Stat.RxCharCnt += transCount;
658#endif
659 PortP->RxDataStart += transCount; 632 PortP->RxDataStart += transCount;
660 PacketP->len -= transCount; 633 PacketP->len -= transCount;
661 copied += transCount; 634 copied += transCount;
662 635
663 636
664#ifdef ___DEBUG_IT___
665 kkprintf("T:%d L:%d\n", DataCnt, PacketP->len);
666#endif
667 637
668 if (PacketP->len == 0) { 638 if (PacketP->len == 0) {
669 /* 639 /*
@@ -674,12 +644,6 @@ struct Port *PortP;
674 remove_receive(PortP); 644 remove_receive(PortP);
675 put_free_end(PortP->HostP, PacketP); 645 put_free_end(PortP->HostP, PacketP);
676 PortP->RxDataStart = 0; 646 PortP->RxDataStart = 0;
677#ifdef STATS
678 /*
679 ** more lies ( oops, I mean statistics )
680 */
681 PortP->Stat.RxPktCnt++;
682#endif /* STATS */
683 } 647 }
684 } 648 }
685 } 649 }
@@ -691,215 +655,3 @@ struct Port *PortP;
691 return; 655 return;
692} 656}
693 657
694#ifdef FUTURE_RELEASE
695/*
696** The proc routine called by the line discipline to do the work for it.
697** The proc routine works hand in hand with the interrupt routine.
698*/
699int riotproc(p, tp, cmd, port)
700struct rio_info *p;
701register struct ttystatics *tp;
702int cmd;
703int port;
704{
705 register struct Port *PortP;
706 int SysPort;
707 struct PKT *PacketP;
708
709 SysPort = port; /* Believe me, it works. */
710
711 if (SysPort < 0 || SysPort >= RIO_PORTS) {
712 rio_dprintk(RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n", SysPort);
713 return 0;
714 }
715 PortP = p->RIOPortp[SysPort];
716
717 if ((uint) PortP->PhbP < (uint) PortP->Caddr || (uint) PortP->PhbP >= (uint) PortP->Caddr + SIXTY_FOUR_K) {
718 rio_dprintk(RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n", SysPort);
719 rio_dprintk(RIO_DEBUG_INTR, " PortP = 0x%x\n", PortP);
720 rio_dprintk(RIO_DEBUG_INTR, " PortP->PhbP = 0x%x\n", PortP->PhbP);
721 rio_dprintk(RIO_DEBUG_INTR, " PortP->Caddr = 0x%x\n", PortP->PhbP);
722 rio_dprintk(RIO_DEBUG_INTR, " PortP->HostPort = 0x%x\n", PortP->HostPort);
723 return 0;
724 }
725
726 switch (cmd) {
727 case T_WFLUSH:
728 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH\n");
729 /*
730 ** Because of the spooky way the RIO works, we don't need
731 ** to issue a flush command on any of the SET*F commands,
732 ** as that causes trouble with getty and login, which issue
733 ** these commands to incur a READ flush, and rely on the fact
734 ** that the line discipline does a wait for drain for them.
735 ** As the rio doesn't wait for drain, the write flush would
736 ** destroy the Password: prompt. This isn't very friendly, so
737 ** here we only issue a WFLUSH command if we are in the interrupt
738 ** routine, or we aren't executing a SET*F command.
739 */
740 if (PortP->HostP->InIntr || !PortP->FlushCmdBodge) {
741 /*
742 ** form a wflush packet - 1 byte long, no data
743 */
744 if (PortP->State & RIO_DELETED) {
745 rio_dprintk(RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
746 } else {
747 if (RIOPreemptiveCmd(p, PortP, WFLUSH) == RIO_FAIL) {
748 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
749 } else
750 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command\n");
751 }
752 /*
753 ** WFLUSH operation - flush the data!
754 */
755 PortP->TxBufferIn = PortP->TxBufferOut = 0;
756 } else {
757 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
758 }
759 /*
760 ** sort out the line discipline
761 */
762 if (PortP->CookMode == COOK_WELL)
763 goto start;
764 break;
765
766 case T_RESUME:
767 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME\n");
768 /*
769 ** send pre-emptive resume packet
770 */
771 if (PortP->State & RIO_DELETED) {
772 rio_dprintk(RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
773 } else {
774 if (RIOPreemptiveCmd(p, PortP, RESUME) == RIO_FAIL) {
775 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME Command failed\n");
776 }
777 }
778 /*
779 ** and re-start the sender software!
780 */
781 if (PortP->CookMode == COOK_WELL)
782 goto start;
783 break;
784
785 case T_TIME:
786 rio_dprintk(RIO_DEBUG_INTR, "T_TIME\n");
787 /*
788 ** T_TIME is called when xDLY is set in oflags and
789 ** the line discipline timeout has expired. It's
790 ** function in life is to clear the TIMEOUT flag
791 ** and to re-start output to the port.
792 */
793 /*
794 ** Fall through and re-start output
795 */
796 case T_OUTPUT:
797 start:
798 if (PortP->MagicFlags & MAGIC_FLUSH) {
799 PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
800 return 0;
801 }
802 RIOTxEnable((char *) PortP);
803 PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
804 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n"); */
805 break;
806
807 case T_SUSPEND:
808 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND\n");
809 /*
810 ** send a suspend pre-emptive packet.
811 */
812 if (PortP->State & RIO_DELETED) {
813 rio_dprintk(RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
814 } else {
815 if (RIOPreemptiveCmd(p, PortP, SUSPEND) == RIO_FAIL) {
816 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
817 }
818 }
819 /*
820 ** done!
821 */
822 break;
823
824 case T_BLOCK:
825 rio_dprintk(RIO_DEBUG_INTR, "T_BLOCK\n");
826 break;
827
828 case T_RFLUSH:
829 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH\n");
830 if (PortP->State & RIO_DELETED) {
831 rio_dprintk(RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
832 PortP->RxDataStart = 0;
833 } else {
834 if (RIOPreemptiveCmd(p, PortP, RFLUSH) == RIO_FAIL) {
835 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
836 return 0;
837 }
838 PortP->RxDataStart = 0;
839 while (can_remove_receive(&PacketP, PortP)) {
840 remove_receive(PortP);
841 ShowPacket(DBG_PROC, PacketP);
842 put_free_end(PortP->HostP, PacketP);
843 }
844 if (PortP->PhbP->handshake == PHB_HANDSHAKE_SET) {
845 /*
846 ** MAGIC!
847 */
848 rio_dprintk(RIO_DEBUG_INTR, "Set receive handshake bit\n");
849 PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
850 }
851 }
852 break;
853 /* FALLTHROUGH */
854 case T_UNBLOCK:
855 rio_dprintk(RIO_DEBUG_INTR, "T_UNBLOCK\n");
856 /*
857 ** If there is any data to receive set a timeout to service it.
858 */
859 RIOReceive(p, PortP);
860 break;
861
862 case T_BREAK:
863 rio_dprintk(RIO_DEBUG_INTR, "T_BREAK\n");
864 /*
865 ** Send a break command. For Sys V
866 ** this is a timed break, so we
867 ** send a SBREAK[time] packet
868 */
869 /*
870 ** Build a BREAK command
871 */
872 if (PortP->State & RIO_DELETED) {
873 rio_dprintk(RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
874 } else {
875 if (RIOShortCommand(PortP, SBREAK, 2, p->RIOConf.BreakInterval) == RIO_FAIL) {
876 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
877 }
878 }
879
880 /*
881 ** done!
882 */
883 break;
884
885 case T_INPUT:
886 rio_dprintk(RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
887 break;
888 case T_PARM:
889 rio_dprintk(RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
890 break;
891
892 case T_SWTCH:
893 rio_dprintk(RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
894 break;
895
896 default:
897 rio_dprintk(RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n", cmd);
898 }
899 /*
900 ** T_OUTPUT returns without passing through this point!
901 */
902 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n"); */
903 return (0);
904}
905#endif
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index c622f46d6d77..d2e8092cdb29 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -52,15 +52,12 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
52 52
53#include "linux_compat.h" 53#include "linux_compat.h"
54#include "rio_linux.h" 54#include "rio_linux.h"
55#include "typdef.h"
56#include "pkt.h" 55#include "pkt.h"
57#include "daemon.h" 56#include "daemon.h"
58#include "rio.h" 57#include "rio.h"
59#include "riospace.h" 58#include "riospace.h"
60#include "top.h"
61#include "cmdpkt.h" 59#include "cmdpkt.h"
62#include "map.h" 60#include "map.h"
63#include "riotypes.h"
64#include "rup.h" 61#include "rup.h"
65#include "port.h" 62#include "port.h"
66#include "riodrvr.h" 63#include "riodrvr.h"
@@ -73,17 +70,13 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
73#include "unixrup.h" 70#include "unixrup.h"
74#include "board.h" 71#include "board.h"
75#include "host.h" 72#include "host.h"
76#include "error.h"
77#include "phb.h" 73#include "phb.h"
78#include "link.h" 74#include "link.h"
79#include "cmdblk.h" 75#include "cmdblk.h"
80#include "route.h" 76#include "route.h"
81#include "control.h"
82#include "cirrus.h" 77#include "cirrus.h"
83#include "rioioctl.h" 78#include "rioioctl.h"
84#include "param.h" 79#include "param.h"
85#include "list.h"
86#include "sam.h"
87 80
88 81
89 82
@@ -157,20 +150,16 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
157** NB. for MPX 150** NB. for MPX
158** tty lock must NOT have been previously acquired. 151** tty lock must NOT have been previously acquired.
159*/ 152*/
160int RIOParam(PortP, cmd, Modem, SleepFlag) 153int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
161struct Port *PortP;
162int cmd;
163int Modem;
164int SleepFlag;
165{ 154{
166 register struct tty_struct *TtyP; 155 struct tty_struct *TtyP;
167 int retval; 156 int retval;
168 register struct phb_param *phb_param_ptr; 157 struct phb_param *phb_param_ptr;
169 PKT *PacketP; 158 struct PKT *PacketP;
170 int res; 159 int res;
171 uchar Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; 160 u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
172 uchar TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; 161 u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
173 uchar LNext = 0, TxBaud = 0, RxBaud = 0; 162 u8 LNext = 0, TxBaud = 0, RxBaud = 0;
174 int retries = 0xff; 163 int retries = 0xff;
175 unsigned long flags; 164 unsigned long flags;
176 165
@@ -226,16 +215,13 @@ int SleepFlag;
226 if (retval == RIO_FAIL) { 215 if (retval == RIO_FAIL) {
227 rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n"); 216 rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n");
228 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 217 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
229 pseterr(EINTR);
230 func_exit(); 218 func_exit();
231 219 return -EINTR;
232 return RIO_FAIL;
233 } 220 }
234 if (PortP->State & RIO_DELETED) { 221 if (PortP->State & RIO_DELETED) {
235 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 222 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
236 func_exit(); 223 func_exit();
237 224 return 0;
238 return RIO_SUCCESS;
239 } 225 }
240 } 226 }
241 227
@@ -247,7 +233,7 @@ int SleepFlag;
247 } 233 }
248 234
249 rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); 235 rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
250 rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP); 236 rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP);
251 237
252 phb_param_ptr = (struct phb_param *) PacketP->data; 238 phb_param_ptr = (struct phb_param *) PacketP->data;
253 239
@@ -474,9 +460,6 @@ int SleepFlag;
474 e(115200); /* e(230400);e(460800); e(921600); */ 460 e(115200); /* e(230400);e(460800); e(921600); */
475 } 461 }
476 462
477 /* XXX MIssing conversion table. XXX */
478 /* (TtyP->termios->c_cflag & V_CBAUD); */
479
480 rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud); 463 rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);
481 464
482 465
@@ -552,23 +535,23 @@ int SleepFlag;
552 /* 535 /*
553 ** Actually write the info into the packet to be sent 536 ** Actually write the info into the packet to be sent
554 */ 537 */
555 WBYTE(phb_param_ptr->Cmd, cmd); 538 writeb(cmd, &phb_param_ptr->Cmd);
556 WBYTE(phb_param_ptr->Cor1, Cor1); 539 writeb(Cor1, &phb_param_ptr->Cor1);
557 WBYTE(phb_param_ptr->Cor2, Cor2); 540 writeb(Cor2, &phb_param_ptr->Cor2);
558 WBYTE(phb_param_ptr->Cor4, Cor4); 541 writeb(Cor4, &phb_param_ptr->Cor4);
559 WBYTE(phb_param_ptr->Cor5, Cor5); 542 writeb(Cor5, &phb_param_ptr->Cor5);
560 WBYTE(phb_param_ptr->TxXon, TxXon); 543 writeb(TxXon, &phb_param_ptr->TxXon);
561 WBYTE(phb_param_ptr->RxXon, RxXon); 544 writeb(RxXon, &phb_param_ptr->RxXon);
562 WBYTE(phb_param_ptr->TxXoff, TxXoff); 545 writeb(TxXoff, &phb_param_ptr->TxXoff);
563 WBYTE(phb_param_ptr->RxXoff, RxXoff); 546 writeb(RxXoff, &phb_param_ptr->RxXoff);
564 WBYTE(phb_param_ptr->LNext, LNext); 547 writeb(LNext, &phb_param_ptr->LNext);
565 WBYTE(phb_param_ptr->TxBaud, TxBaud); 548 writeb(TxBaud, &phb_param_ptr->TxBaud);
566 WBYTE(phb_param_ptr->RxBaud, RxBaud); 549 writeb(RxBaud, &phb_param_ptr->RxBaud);
567 550
568 /* 551 /*
569 ** Set the length/command field 552 ** Set the length/command field
570 */ 553 */
571 WBYTE(PacketP->len, 12 | PKT_CMD_BIT); 554 writeb(12 | PKT_CMD_BIT, &PacketP->len);
572 555
573 /* 556 /*
574 ** The packet is formed - now, whack it off 557 ** The packet is formed - now, whack it off
@@ -589,7 +572,7 @@ int SleepFlag;
589 */ 572 */
590 func_exit(); 573 func_exit();
591 574
592 return RIO_SUCCESS; 575 return 0;
593} 576}
594 577
595 578
@@ -597,15 +580,13 @@ int SleepFlag;
597** We can add another packet to a transmit queue if the packet pointer pointed 580** We can add another packet to a transmit queue if the packet pointer pointed
598** to by the TxAdd pointer has PKT_IN_USE clear in its address. 581** to by the TxAdd pointer has PKT_IN_USE clear in its address.
599*/ 582*/
600int can_add_transmit(PktP, PortP) 583int can_add_transmit(struct PKT **PktP, struct Port *PortP)
601PKT **PktP;
602struct Port *PortP;
603{ 584{
604 register PKT *tp; 585 struct PKT *tp;
605 586
606 *PktP = tp = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->TxAdd)); 587 *PktP = tp = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd));
607 588
608 return !((uint) tp & PKT_IN_USE); 589 return !((unsigned long) tp & PKT_IN_USE);
609} 590}
610 591
611/* 592/*
@@ -613,27 +594,24 @@ struct Port *PortP;
613** and then move the TxAdd pointer along one position to point to the next 594** and then move the TxAdd pointer along one position to point to the next
614** packet pointer. You must wrap the pointer from the end back to the start. 595** packet pointer. You must wrap the pointer from the end back to the start.
615*/ 596*/
616void add_transmit(PortP) 597void add_transmit(struct Port *PortP)
617struct Port *PortP;
618{ 598{
619 if (RWORD(*PortP->TxAdd) & PKT_IN_USE) { 599 if (readw(PortP->TxAdd) & PKT_IN_USE) {
620 rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!"); 600 rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
621 } 601 }
622 WWORD(*(ushort *) PortP->TxAdd, RWORD(*PortP->TxAdd) | PKT_IN_USE); 602 writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd);
623 PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1; 603 PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;
624 WWORD(PortP->PhbP->tx_add, RIO_OFF(PortP->Caddr, PortP->TxAdd)); 604 writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add);
625} 605}
626 606
627/**************************************** 607/****************************************
628 * Put a packet onto the end of the 608 * Put a packet onto the end of the
629 * free list 609 * free list
630 ****************************************/ 610 ****************************************/
631void put_free_end(HostP, PktP) 611void put_free_end(struct Host *HostP, struct PKT *PktP)
632struct Host *HostP;
633PKT *PktP;
634{ 612{
635 FREE_LIST *tmp_pointer; 613 struct rio_free_list *tmp_pointer;
636 ushort old_end, new_end; 614 unsigned short old_end, new_end;
637 unsigned long flags; 615 unsigned long flags;
638 616
639 rio_spin_lock_irqsave(&HostP->HostLock, flags); 617 rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -643,21 +621,21 @@ PKT *PktP;
643 * 621 *
644 ************************************************/ 622 ************************************************/
645 623
646 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%x)\n", (int) PktP); 624 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP);
647 625
648 if ((old_end = RWORD(HostP->ParmMapP->free_list_end)) != TPNULL) { 626 if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {
649 new_end = RIO_OFF(HostP->Caddr, PktP); 627 new_end = RIO_OFF(HostP->Caddr, PktP);
650 tmp_pointer = (FREE_LIST *) RIO_PTR(HostP->Caddr, old_end); 628 tmp_pointer = (struct rio_free_list *) RIO_PTR(HostP->Caddr, old_end);
651 WWORD(tmp_pointer->next, new_end); 629 writew(new_end, &tmp_pointer->next);
652 WWORD(((FREE_LIST *) PktP)->prev, old_end); 630 writew(old_end, &((struct rio_free_list *) PktP)->prev);
653 WWORD(((FREE_LIST *) PktP)->next, TPNULL); 631 writew(TPNULL, &((struct rio_free_list *) PktP)->next);
654 WWORD(HostP->ParmMapP->free_list_end, new_end); 632 writew(new_end, &HostP->ParmMapP->free_list_end);
655 } else { /* First packet on the free list this should never happen! */ 633 } else { /* First packet on the free list this should never happen! */
656 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n"); 634 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
657 WWORD(HostP->ParmMapP->free_list_end, RIO_OFF(HostP->Caddr, PktP)); 635 writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);
658 tmp_pointer = (FREE_LIST *) PktP; 636 tmp_pointer = (struct rio_free_list *) PktP;
659 WWORD(tmp_pointer->prev, TPNULL); 637 writew(TPNULL, &tmp_pointer->prev);
660 WWORD(tmp_pointer->next, TPNULL); 638 writew(TPNULL, &tmp_pointer->next);
661 } 639 }
662 rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock); 640 rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
663 rio_spin_unlock_irqrestore(&HostP->HostLock, flags); 641 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
@@ -669,12 +647,10 @@ PKT *PktP;
669** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear, 647** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
670** then can_remove_receive() returns 0. 648** then can_remove_receive() returns 0.
671*/ 649*/
672int can_remove_receive(PktP, PortP) 650int can_remove_receive(struct PKT **PktP, struct Port *PortP)
673PKT **PktP;
674struct Port *PortP;
675{ 651{
676 if (RWORD(*PortP->RxRemove) & PKT_IN_USE) { 652 if (readw(PortP->RxRemove) & PKT_IN_USE) {
677 *PktP = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->RxRemove) & ~PKT_IN_USE); 653 *PktP = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE);
678 return 1; 654 return 1;
679 } 655 }
680 return 0; 656 return 0;
@@ -685,10 +661,9 @@ struct Port *PortP;
685** and then bump the pointers. Once the pointers get to the end, they must 661** and then bump the pointers. Once the pointers get to the end, they must
686** be wrapped back to the start. 662** be wrapped back to the start.
687*/ 663*/
688void remove_receive(PortP) 664void remove_receive(struct Port *PortP)
689struct Port *PortP;
690{ 665{
691 WWORD(*PortP->RxRemove, RWORD(*PortP->RxRemove) & ~PKT_IN_USE); 666 writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove);
692 PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1; 667 PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1;
693 WWORD(PortP->PhbP->rx_remove, RIO_OFF(PortP->Caddr, PortP->RxRemove)); 668 writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove);
694} 669}
diff --git a/drivers/char/rio/riopcicopy.c b/drivers/char/rio/riopcicopy.c
deleted file mode 100644
index 535afaa51ca5..000000000000
--- a/drivers/char/rio/riopcicopy.c
+++ /dev/null
@@ -1,8 +0,0 @@
1
2/* Yeah. We have copyright on this one. Sure. */
3
4void rio_pcicopy(char *from, char *to, int amount)
5{
6 while (amount--)
7 *to++ = *from++;
8}
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index f98888f52659..357085337942 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -50,15 +50,12 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
50 50
51#include "linux_compat.h" 51#include "linux_compat.h"
52#include "rio_linux.h" 52#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 53#include "pkt.h"
55#include "daemon.h" 54#include "daemon.h"
56#include "rio.h" 55#include "rio.h"
57#include "riospace.h" 56#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 57#include "cmdpkt.h"
60#include "map.h" 58#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 59#include "rup.h"
63#include "port.h" 60#include "port.h"
64#include "riodrvr.h" 61#include "riodrvr.h"
@@ -71,29 +68,25 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
71#include "unixrup.h" 68#include "unixrup.h"
72#include "board.h" 69#include "board.h"
73#include "host.h" 70#include "host.h"
74#include "error.h"
75#include "phb.h" 71#include "phb.h"
76#include "link.h" 72#include "link.h"
77#include "cmdblk.h" 73#include "cmdblk.h"
78#include "route.h" 74#include "route.h"
79#include "control.h"
80#include "cirrus.h" 75#include "cirrus.h"
81#include "rioioctl.h" 76#include "rioioctl.h"
82#include "param.h" 77#include "param.h"
83#include "list.h"
84#include "sam.h"
85 78
86static int RIOCheckIsolated(struct rio_info *, struct Host *, uint); 79static int RIOCheckIsolated(struct rio_info *, struct Host *, unsigned int);
87static int RIOIsolate(struct rio_info *, struct Host *, uint); 80static int RIOIsolate(struct rio_info *, struct Host *, unsigned int);
88static int RIOCheck(struct Host *, uint); 81static int RIOCheck(struct Host *, unsigned int);
89static void RIOConCon(struct rio_info *, struct Host *, uint, uint, uint, uint, int); 82static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned int, unsigned int, unsigned int, int);
90 83
91 84
92/* 85/*
93** Incoming on the ROUTE_RUP 86** Incoming on the ROUTE_RUP
94** I wrote this while I was tired. Forgive me. 87** I wrote this while I was tired. Forgive me.
95*/ 88*/
96int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 89int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP)
97{ 90{
98 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 91 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
99 struct PktCmd_M *PktReplyP; 92 struct PktCmd_M *PktReplyP;
@@ -104,10 +97,10 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
104 int ThisLink, ThisLinkMin, ThisLinkMax; 97 int ThisLink, ThisLinkMin, ThisLinkMax;
105 int port; 98 int port;
106 int Mod, Mod1, Mod2; 99 int Mod, Mod1, Mod2;
107 ushort RtaType; 100 unsigned short RtaType;
108 uint RtaUniq; 101 unsigned int RtaUniq;
109 uint ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ 102 unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */
110 uint OldUnit, NewUnit, OldLink, NewLink; 103 unsigned int OldUnit, NewUnit, OldLink, NewLink;
111 char *MyType, *MyName; 104 char *MyType, *MyName;
112 int Lies; 105 int Lies;
113 unsigned long flags; 106 unsigned long flags;
@@ -115,7 +108,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
115 /* 108 /*
116 ** Is this unit telling us it's current link topology? 109 ** Is this unit telling us it's current link topology?
117 */ 110 */
118 if (RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY) { 111 if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) {
119 MapP = HostP->Mapping; 112 MapP = HostP->Mapping;
120 113
121 /* 114 /*
@@ -125,7 +118,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
125 ** from an RTA then we need to fill in the Mapping structure's 118 ** from an RTA then we need to fill in the Mapping structure's
126 ** Topology array for the unit. 119 ** Topology array for the unit.
127 */ 120 */
128 if (Rup >= (ushort) MAX_RUP) { 121 if (Rup >= (unsigned short) MAX_RUP) {
129 ThisUnit = HOST_ID; 122 ThisUnit = HOST_ID;
130 TopP = HostP->Topology; 123 TopP = HostP->Topology;
131 MyType = "Host"; 124 MyType = "Host";
@@ -151,11 +144,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
151 ** it won't lie about network interconnect, total disconnects 144 ** it won't lie about network interconnect, total disconnects
152 ** and no-IDs. (or at least, it doesn't *matter* if it does) 145 ** and no-IDs. (or at least, it doesn't *matter* if it does)
153 */ 146 */
154 if (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP) 147 if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP)
155 continue; 148 continue;
156 149
157 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) { 150 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
158 if ((RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) == RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) && (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) == RBYTE(PktCmdP->RouteTopology[NewLink].Link))) { 151 if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) {
159 Lies++; 152 Lies++;
160 } 153 }
161 } 154 }
@@ -164,11 +157,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
164 if (Lies) { 157 if (Lies) {
165 rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies); 158 rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies);
166 rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n", 159 rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
167 RBYTE(PktCmdP->RouteTopology[0].Unit), 160 readb(&PktCmdP->RouteTopology[0].Unit),
168 'A' + RBYTE(PktCmdP->RouteTopology[0].Link), 161 'A' + readb(&PktCmdP->RouteTopology[0].Link),
169 RBYTE(PktCmdP->RouteTopology[1].Unit), 162 readb(&PktCmdP->RouteTopology[1].Unit),
170 'A' + RBYTE(PktCmdP->RouteTopology[1].Link), RBYTE(PktCmdP->RouteTopology[2].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[2].Link), RBYTE(PktCmdP->RouteTopology[3].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[3].Link)); 163 'A' + readb(&PktCmdP->RouteTopology[1].Link), readb(&PktCmdP->RouteTopology[2].Unit), 'A' + readb(&PktCmdP->RouteTopology[2].Link), readb(&PktCmdP->RouteTopology[3].Unit), 'A' + readb(&PktCmdP->RouteTopology[3].Link));
171 return TRUE; 164 return 1;
172 } 165 }
173 166
174 /* 167 /*
@@ -184,8 +177,8 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
184 /* 177 /*
185 ** this is what it is now connected to 178 ** this is what it is now connected to
186 */ 179 */
187 NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit); 180 NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit);
188 NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link); 181 NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link);
189 182
190 if (OldUnit != NewUnit || OldLink != NewLink) { 183 if (OldUnit != NewUnit || OldLink != NewLink) {
191 /* 184 /*
@@ -219,7 +212,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
219 212
220 if (NewUnit == ROUTE_INTERCONNECT) { 213 if (NewUnit == ROUTE_INTERCONNECT) {
221 if (!p->RIONoMessage) 214 if (!p->RIONoMessage)
222 cprintf("%s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink); 215 printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
223 } 216 }
224 217
225 /* 218 /*
@@ -258,18 +251,18 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
258 RIOCheckIsolated(p, HostP, OldUnit); 251 RIOCheckIsolated(p, HostP, OldUnit);
259 } 252 }
260 } 253 }
261 return TRUE; 254 return 1;
262 } 255 }
263 256
264 /* 257 /*
265 ** The only other command we recognise is a route_request command 258 ** The only other command we recognise is a route_request command
266 */ 259 */
267 if (RBYTE(PktCmdP->Command) != ROUTE_REQUEST) { 260 if (readb(&PktCmdP->Command) != ROUTE_REQUEST) {
268 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", RBYTE(PktCmdP->Command), Rup, (int) HostP); 261 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP);
269 return TRUE; 262 return 1;
270 } 263 }
271 264
272 RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24); 265 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
273 266
274 /* 267 /*
275 ** Determine if 8 or 16 port RTA 268 ** Determine if 8 or 16 port RTA
@@ -278,7 +271,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
278 271
279 rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq); 272 rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);
280 273
281 Mod = RBYTE(PktCmdP->ModuleTypes); 274 Mod = readb(&PktCmdP->ModuleTypes);
282 Mod1 = LONYBLE(Mod); 275 Mod1 = LONYBLE(Mod);
283 if (RtaType == TYPE_RTA16) { 276 if (RtaType == TYPE_RTA16) {
284 /* 277 /*
@@ -292,10 +285,6 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
292 rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name); 285 rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
293 } 286 }
294 287
295 if (RtaUniq == 0xffffffff) {
296 ShowPacket(DBG_SPECIAL, PacketP);
297 }
298
299 /* 288 /*
300 ** try to unhook a command block from the command free list. 289 ** try to unhook a command block from the command free list.
301 */ 290 */
@@ -320,7 +309,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
320 PktReplyP->Command = ROUTE_FOAD; 309 PktReplyP->Command = ROUTE_FOAD;
321 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 310 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
322 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 311 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
323 return TRUE; 312 return 1;
324 } 313 }
325 314
326 /* 315 /*
@@ -348,13 +337,13 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
348 if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) { 337 if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) {
349 if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) { 338 if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) {
350 if (!p->RIONoMessage) 339 if (!p->RIONoMessage)
351 cprintf("RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name); 340 printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
352 HostP->Mapping[ThisUnit].Flags |= MSG_DONE; 341 HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
353 } 342 }
354 PktReplyP->Command = ROUTE_FOAD; 343 PktReplyP->Command = ROUTE_FOAD;
355 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 344 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
356 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 345 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
357 return TRUE; 346 return 1;
358 } 347 }
359 348
360 /* 349 /*
@@ -447,7 +436,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
447 /* 436 /*
448 ** Job done, get on with the interrupts! 437 ** Job done, get on with the interrupts!
449 */ 438 */
450 return TRUE; 439 return 1;
451 } 440 }
452 } 441 }
453 /* 442 /*
@@ -475,7 +464,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
475 464
476 if (!UnknownMesgDone) { 465 if (!UnknownMesgDone) {
477 if (!p->RIONoMessage) 466 if (!p->RIONoMessage)
478 cprintf("One or more unknown RTAs are being updated.\n"); 467 printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n");
479 UnknownMesgDone = 1; 468 UnknownMesgDone = 1;
480 } 469 }
481 470
@@ -491,28 +480,25 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
491 if (RtaType == TYPE_RTA16) { 480 if (RtaType == TYPE_RTA16) {
492 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) { 481 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
493 RIODefaultName(p, HostP, ThisUnit); 482 RIODefaultName(p, HostP, ThisUnit);
494 FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP); 483 rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP);
495 } 484 }
496 } else { 485 } else {
497 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) { 486 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
498 RIODefaultName(p, HostP, ThisUnit); 487 RIODefaultName(p, HostP, ThisUnit);
499 FillSlot(ThisUnit, 0, RtaUniq, HostP); 488 rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP);
500 } 489 }
501 } 490 }
502 PktReplyP->Command = ROUTE_USED; 491 PktReplyP->Command = ROUTE_USED;
503 HostP->Copy("RT_USED", PktReplyP->CommandText, 7); 492 HostP->Copy("RT_USED", PktReplyP->CommandText, 7);
504 } 493 }
505 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 494 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
506 return TRUE; 495 return 1;
507} 496}
508 497
509 498
510void RIOFixPhbs(p, HostP, unit) 499void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
511struct rio_info *p;
512struct Host *HostP;
513uint unit;
514{ 500{
515 ushort link, port; 501 unsigned short link, port;
516 struct Port *PortP; 502 struct Port *PortP;
517 unsigned long flags; 503 unsigned long flags;
518 int PortN = HostP->Mapping[unit].SysPort; 504 int PortN = HostP->Mapping[unit].SysPort;
@@ -520,19 +506,19 @@ uint unit;
520 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN); 506 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
521 507
522 if (PortN != -1) { 508 if (PortN != -1) {
523 ushort dest_unit = HostP->Mapping[unit].ID2; 509 unsigned short dest_unit = HostP->Mapping[unit].ID2;
524 510
525 /* 511 /*
526 ** Get the link number used for the 1st 8 phbs on this unit. 512 ** Get the link number used for the 1st 8 phbs on this unit.
527 */ 513 */
528 PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort]; 514 PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort];
529 515
530 link = RWORD(PortP->PhbP->link); 516 link = readw(&PortP->PhbP->link);
531 517
532 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { 518 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
533 ushort dest_port = port + 8; 519 unsigned short dest_port = port + 8;
534 WORD *TxPktP; 520 u16 *TxPktP;
535 PKT *Pkt; 521 struct PKT *Pkt;
536 522
537 PortP = p->RIOPortp[PortN]; 523 PortP = p->RIOPortp[PortN];
538 524
@@ -569,18 +555,18 @@ uint unit;
569 ** card. This needs to be translated into a 32 bit pointer 555 ** card. This needs to be translated into a 32 bit pointer
570 ** so it can be accessed from the driver. 556 ** so it can be accessed from the driver.
571 */ 557 */
572 Pkt = (PKT *) RIO_PTR(HostP->Caddr, RINDW(TxPktP)); 558 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP));
573 559
574 /* 560 /*
575 ** If the packet is used, reset it. 561 ** If the packet is used, reset it.
576 */ 562 */
577 Pkt = (PKT *) ((uint) Pkt & ~PKT_IN_USE); 563 Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE);
578 WBYTE(Pkt->dest_unit, dest_unit); 564 writeb(dest_unit, &Pkt->dest_unit);
579 WBYTE(Pkt->dest_port, dest_port); 565 writeb(dest_port, &Pkt->dest_port);
580 } 566 }
581 rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", RWORD(PortP->PhbP->destination) & 0xff, (RWORD(PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port); 567 rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", readw(&PortP->PhbP->destination) & 0xff, (readw(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
582 WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); 568 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
583 WWORD(PortP->PhbP->link, link); 569 writew(link, &PortP->PhbP->link);
584 570
585 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 571 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
586 } 572 }
@@ -590,9 +576,9 @@ uint unit;
590 */ 576 */
591 if (link > 3) 577 if (link > 3)
592 return; 578 return;
593 if (((unit * 8) + 7) > RWORD(HostP->LinkStrP[link].last_port)) { 579 if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) {
594 rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7); 580 rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
595 WWORD(HostP->LinkStrP[link].last_port, (unit * 8) + 7); 581 writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port);
596 } 582 }
597 } 583 }
598} 584}
@@ -603,10 +589,7 @@ uint unit;
603** the world about it. This is done to ensure that the configurator 589** the world about it. This is done to ensure that the configurator
604** only gets up-to-date information about what is going on. 590** only gets up-to-date information about what is going on.
605*/ 591*/
606static int RIOCheckIsolated(p, HostP, UnitId) 592static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
607struct rio_info *p;
608struct Host *HostP;
609uint UnitId;
610{ 593{
611 unsigned long flags; 594 unsigned long flags;
612 rio_spin_lock_irqsave(&HostP->HostLock, flags); 595 rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -628,12 +611,9 @@ uint UnitId;
628** all the units attached to it. This will mean that the entire 611** all the units attached to it. This will mean that the entire
629** subnet will re-introduce itself. 612** subnet will re-introduce itself.
630*/ 613*/
631static int RIOIsolate(p, HostP, UnitId) 614static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
632struct rio_info *p;
633struct Host *HostP;
634uint UnitId;
635{ 615{
636 uint link, unit; 616 unsigned int link, unit;
637 617
638 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */ 618 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */
639 619
@@ -658,9 +638,7 @@ uint UnitId;
658 return 1; 638 return 1;
659} 639}
660 640
661static int RIOCheck(HostP, UnitId) 641static int RIOCheck(struct Host *HostP, unsigned int UnitId)
662struct Host *HostP;
663uint UnitId;
664{ 642{
665 unsigned char link; 643 unsigned char link;
666 644
@@ -714,8 +692,7 @@ uint UnitId;
714** Returns the type of unit (host, 16/8 port RTA) 692** Returns the type of unit (host, 16/8 port RTA)
715*/ 693*/
716 694
717uint GetUnitType(Uniq) 695unsigned int GetUnitType(unsigned int Uniq)
718uint Uniq;
719{ 696{
720 switch ((Uniq >> 28) & 0xf) { 697 switch ((Uniq >> 28) & 0xf) {
721 case RIO_AT: 698 case RIO_AT:
@@ -736,8 +713,7 @@ uint Uniq;
736 } 713 }
737} 714}
738 715
739int RIOSetChange(p) 716int RIOSetChange(struct rio_info *p)
740struct rio_info *p;
741{ 717{
742 if (p->RIOQuickCheck != NOT_CHANGED) 718 if (p->RIOQuickCheck != NOT_CHANGED)
743 return (0); 719 return (0);
@@ -751,14 +727,13 @@ struct rio_info *p;
751 return (0); 727 return (0);
752} 728}
753 729
754static void RIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change) 730static void RIOConCon(struct rio_info *p,
755struct rio_info *p; 731 struct Host *HostP,
756struct Host *HostP; 732 unsigned int FromId,
757uint FromId; 733 unsigned int FromLink,
758uint FromLink; 734 unsigned int ToId,
759uint ToId; 735 unsigned int ToLink,
760uint ToLink; 736 int Change)
761int Change;
762{ 737{
763 char *FromName; 738 char *FromName;
764 char *FromType; 739 char *FromType;
@@ -818,7 +793,7 @@ int Change;
818 ToType = ToId ? "RTA" : "HOST"; 793 ToType = ToId ? "RTA" : "HOST";
819 794
820 rio_dprintk(RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected"); 795 rio_dprintk(RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
821 cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected"); 796 printk(KERN_DEBUG "rio: Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
822} 797}
823 798
824/* 799/*
@@ -838,7 +813,7 @@ static int RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap)
838 */ 813 */
839 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { 814 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
840 if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) { 815 if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) {
841 bzero((caddr_t) & p->RIOSavedTable[entry], sizeof(struct Map)); 816 memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
842 } 817 }
843 } 818 }
844 return 0; 819 return 0;
@@ -898,7 +873,7 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
898 int nOther = (HostP->Mapping[unit].ID2) - 1; 873 int nOther = (HostP->Mapping[unit].ID2) - 1;
899 874
900 rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther); 875 rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther);
901 bzero((caddr_t) & HostP->Mapping[nOther], sizeof(struct Map)); 876 memset(&HostP->Mapping[nOther], 0, sizeof(struct Map));
902 } 877 }
903 RIORemoveFromSavedTable(p, &HostP->Mapping[unit]); 878 RIORemoveFromSavedTable(p, &HostP->Mapping[unit]);
904 879
@@ -912,7 +887,8 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
912** This function scans the given host table for either one 887** This function scans the given host table for either one
913** or two free unit ID's. 888** or two free unit ID's.
914*/ 889*/
915int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pID2) 890
891int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2)
916{ 892{
917 int unit, tempID; 893 int unit, tempID;
918 894
@@ -997,7 +973,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI
997 /* 973 /*
998 ** Clear out this slot now that we intend to use it. 974 ** Clear out this slot now that we intend to use it.
999 */ 975 */
1000 bzero(&HostP->Mapping[unit], sizeof(struct Map)); 976 memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
1001 977
1002 /* 978 /*
1003 ** If the second ID is not needed then we can return 979 ** If the second ID is not needed then we can return
@@ -1015,7 +991,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI
1015 /* 991 /*
1016 ** Clear out this slot now that we intend to use it. 992 ** Clear out this slot now that we intend to use it.
1017 */ 993 */
1018 bzero(&HostP->Mapping[unit], sizeof(struct Map)); 994 memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
1019 995
1020 /* At this point under the right(wrong?) conditions 996 /* At this point under the right(wrong?) conditions
1021 ** we may have a first unit ID being higher than the 997 ** we may have a first unit ID being higher than the
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index a86b216ab653..d3abe0d37d64 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -53,15 +53,12 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
53 53
54#include "linux_compat.h" 54#include "linux_compat.h"
55#include "rio_linux.h" 55#include "rio_linux.h"
56#include "typdef.h"
57#include "pkt.h" 56#include "pkt.h"
58#include "daemon.h" 57#include "daemon.h"
59#include "rio.h" 58#include "rio.h"
60#include "riospace.h" 59#include "riospace.h"
61#include "top.h"
62#include "cmdpkt.h" 60#include "cmdpkt.h"
63#include "map.h" 61#include "map.h"
64#include "riotypes.h"
65#include "rup.h" 62#include "rup.h"
66#include "port.h" 63#include "port.h"
67#include "riodrvr.h" 64#include "riodrvr.h"
@@ -74,25 +71,20 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
74#include "unixrup.h" 71#include "unixrup.h"
75#include "board.h" 72#include "board.h"
76#include "host.h" 73#include "host.h"
77#include "error.h"
78#include "phb.h" 74#include "phb.h"
79#include "link.h" 75#include "link.h"
80#include "cmdblk.h" 76#include "cmdblk.h"
81#include "route.h" 77#include "route.h"
82#include "control.h"
83#include "cirrus.h" 78#include "cirrus.h"
84#include "rioioctl.h" 79#include "rioioctl.h"
85#include "param.h" 80#include "param.h"
86#include "list.h"
87#include "sam.h"
88#include "protsts.h" 81#include "protsts.h"
89 82
90/* 83/*
91** A configuration table has been loaded. It is now up to us 84** A configuration table has been loaded. It is now up to us
92** to sort it out and use the information contained therein. 85** to sort it out and use the information contained therein.
93*/ 86*/
94int RIONewTable(p) 87int RIONewTable(struct rio_info *p)
95struct rio_info *p;
96{ 88{
97 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt; 89 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
98 struct Map *MapP; 90 struct Map *MapP;
@@ -137,7 +129,7 @@ struct rio_info *p;
137 cptr = MapP->Name; /* (2) */ 129 cptr = MapP->Name; /* (2) */
138 cptr[MAX_NAME_LEN - 1] = '\0'; 130 cptr[MAX_NAME_LEN - 1] = '\0';
139 if (cptr[0] == '\0') { 131 if (cptr[0] == '\0') {
140 bcopy(MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", MapP->Name, 8); 132 memcpy(MapP->Name, MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", 8);
141 MapP->Name[5] = '0' + Entry / 10; 133 MapP->Name[5] = '0' + Entry / 10;
142 MapP->Name[6] = '0' + Entry % 10; 134 MapP->Name[6] = '0' + Entry % 10;
143 } 135 }
@@ -298,9 +290,9 @@ struct rio_info *p;
298 */ 290 */
299 for (Host = 0; Host < RIO_HOSTS; Host++) { 291 for (Host = 0; Host < RIO_HOSTS; Host++) {
300 for (Entry = 0; Entry < MAX_RUP; Entry++) { 292 for (Entry = 0; Entry < MAX_RUP; Entry++) {
301 bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map)); 293 memset(&p->RIOHosts[Host].Mapping[Entry], 0, sizeof(struct Map));
302 } 294 }
303 bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name)); 295 memset(&p->RIOHosts[Host].Name[0], 0, sizeof(p->RIOHosts[Host].Name));
304 } 296 }
305 297
306 /* 298 /*
@@ -326,7 +318,7 @@ struct rio_info *p;
326 */ 318 */
327 if (MapP->ID == 0) { 319 if (MapP->ID == 0) {
328 rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name); 320 rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
329 bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN); 321 memcpy(HostP->Name, MapP->Name, MAX_NAME_LEN);
330 continue; 322 continue;
331 } 323 }
332 324
@@ -370,7 +362,7 @@ struct rio_info *p;
370 } 362 }
371 } 363 }
372 if (!p->RIOHosts[Host].Name[0]) { 364 if (!p->RIOHosts[Host].Name[0]) {
373 bcopy("HOST 1", p->RIOHosts[Host].Name, 7); 365 memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
374 p->RIOHosts[Host].Name[5] += Host; 366 p->RIOHosts[Host].Name[5] += Host;
375 } 367 }
376 /* 368 /*
@@ -398,7 +390,7 @@ struct rio_info *p;
398 */ 390 */
399 if (Host1 != Host) { 391 if (Host1 != Host) {
400 rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name); 392 rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
401 bcopy("HOST 1", p->RIOHosts[Host].Name, 7); 393 memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
402 p->RIOHosts[Host].Name[5] += Host1; 394 p->RIOHosts[Host].Name[5] += Host1;
403 } 395 }
404 rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name); 396 rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
@@ -409,9 +401,10 @@ struct rio_info *p;
409/* 401/*
410** User process needs the config table - build it from first 402** User process needs the config table - build it from first
411** principles. 403** principles.
404**
405* FIXME: SMP locking
412*/ 406*/
413int RIOApel(p) 407int RIOApel(struct rio_info *p)
414struct rio_info *p;
415{ 408{
416 int Host; 409 int Host;
417 int link; 410 int link;
@@ -419,17 +412,17 @@ struct rio_info *p;
419 int Next = 0; 412 int Next = 0;
420 struct Map *MapP; 413 struct Map *MapP;
421 struct Host *HostP; 414 struct Host *HostP;
422 long oldspl; 415 unsigned long flags;
423
424 disable(oldspl); /* strange but true! */
425 416
426 rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n"); 417 rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
427 418
428 bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES); 419 memset(&p->RIOConnectTable[0], 0, sizeof(struct Map) * TOTAL_MAP_ENTRIES);
429 420
430 for (Host = 0; Host < RIO_HOSTS; Host++) { 421 for (Host = 0; Host < RIO_HOSTS; Host++) {
431 rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host); 422 rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host);
432 HostP = &p->RIOHosts[Host]; 423 HostP = &p->RIOHosts[Host];
424 rio_spin_lock_irqsave(&HostP->HostLock, flags);
425
433 MapP = &p->RIOConnectTable[Next++]; 426 MapP = &p->RIOConnectTable[Next++];
434 MapP->HostUniqueNum = HostP->UniqueNum; 427 MapP->HostUniqueNum = HostP->UniqueNum;
435 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) 428 if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
@@ -440,7 +433,7 @@ struct rio_info *p;
440 MapP->SysPort = NO_PORT; 433 MapP->SysPort = NO_PORT;
441 for (link = 0; link < LINKS_PER_UNIT; link++) 434 for (link = 0; link < LINKS_PER_UNIT; link++)
442 MapP->Topology[link] = HostP->Topology[link]; 435 MapP->Topology[link] = HostP->Topology[link];
443 bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN); 436 memcpy(MapP->Name, HostP->Name, MAX_NAME_LEN);
444 for (Rup = 0; Rup < MAX_RUP; Rup++) { 437 for (Rup = 0; Rup < MAX_RUP; Rup++) {
445 if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) { 438 if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) {
446 p->RIOConnectTable[Next] = HostP->Mapping[Rup]; 439 p->RIOConnectTable[Next] = HostP->Mapping[Rup];
@@ -453,8 +446,8 @@ struct rio_info *p;
453 Next++; 446 Next++;
454 } 447 }
455 } 448 }
449 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
456 } 450 }
457 restore(oldspl);
458 return 0; 451 return 0;
459} 452}
460 453
@@ -463,9 +456,7 @@ struct rio_info *p;
463** if the entry is suitably inactive, then we can gob on it and remove 456** if the entry is suitably inactive, then we can gob on it and remove
464** it from the table. 457** it from the table.
465*/ 458*/
466int RIODeleteRta(p, MapP) 459int RIODeleteRta(struct rio_info *p, struct Map *MapP)
467struct rio_info *p;
468struct Map *MapP;
469{ 460{
470 int host, entry, port, link; 461 int host, entry, port, link;
471 int SysPort; 462 int SysPort;
@@ -541,10 +532,10 @@ struct Map *MapP;
541 ** the phb to port mappings in RIORouteRup. 532 ** the phb to port mappings in RIORouteRup.
542 */ 533 */
543 if (PortP->SecondBlock) { 534 if (PortP->SecondBlock) {
544 ushort dest_unit = HostMapP->ID; 535 u16 dest_unit = HostMapP->ID;
545 ushort dest_port = port - SysPort; 536 u16 dest_port = port - SysPort;
546 WORD *TxPktP; 537 u16 *TxPktP;
547 PKT *Pkt; 538 struct PKT *Pkt;
548 539
549 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { 540 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
550 /* 541 /*
@@ -554,19 +545,19 @@ struct Map *MapP;
554 ** a 32 bit pointer so it can be 545 ** a 32 bit pointer so it can be
555 ** accessed from the driver. 546 ** accessed from the driver.
556 */ 547 */
557 Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP)); 548 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&*TxPktP));
558 rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port); 549 rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port);
559 WWORD(Pkt->dest_unit, dest_unit); 550 writew(dest_unit, &Pkt->dest_unit);
560 WWORD(Pkt->dest_port, dest_port); 551 writew(dest_port, &Pkt->dest_port);
561 } 552 }
562 rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port); 553 rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port);
563 WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); 554 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
564 } 555 }
565 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); 556 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
566 } 557 }
567 } 558 }
568 rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n"); 559 rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n");
569 bzero((char *) HostMapP, sizeof(struct Map)); 560 memset(HostMapP, 0, sizeof(struct Map));
570 work_done++; 561 work_done++;
571 } 562 }
572 } 563 }
@@ -576,11 +567,11 @@ struct Map *MapP;
576 /* XXXXX lock me up */ 567 /* XXXXX lock me up */
577 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { 568 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
578 if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { 569 if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
579 bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map)); 570 memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
580 work_done++; 571 work_done++;
581 } 572 }
582 if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { 573 if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
583 bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map)); 574 memset(&p->RIOConnectTable[entry], 0, sizeof(struct Map));
584 work_done++; 575 work_done++;
585 } 576 }
586 } 577 }
@@ -602,7 +593,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
602 593
603 rio_dprintk(RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort); 594 rio_dprintk(RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort);
604 595
605 if ((MapP->ID != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) { 596 if ((MapP->ID != (u16) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
606 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n"); 597 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
607 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE; 598 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
608 return -EINVAL; 599 return -EINVAL;
@@ -648,7 +639,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
648 ** Now we have a host we need to allocate an ID 639 ** Now we have a host we need to allocate an ID
649 ** if the entry does not already have one. 640 ** if the entry does not already have one.
650 */ 641 */
651 if (MapP->ID == (ushort) - 1) { 642 if (MapP->ID == (u16) - 1) {
652 int nNewID; 643 int nNewID;
653 644
654 rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name); 645 rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name);
@@ -667,7 +658,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
667 p->RIOError.Error = COULDNT_FIND_ENTRY; 658 p->RIOError.Error = COULDNT_FIND_ENTRY;
668 return -EBUSY; 659 return -EBUSY;
669 } 660 }
670 MapP->ID = (ushort) nNewID + 1; 661 MapP->ID = (u16) nNewID + 1;
671 rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID); 662 rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
672 HostMapP = &p->RIOHosts[host].Mapping[nNewID]; 663 HostMapP = &p->RIOHosts[host].Mapping[nNewID];
673 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum; 664 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
@@ -708,7 +699,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
708 */ 699 */
709 HostMapP->SysPort = MapP->SysPort; 700 HostMapP->SysPort = MapP->SysPort;
710 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) 701 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
711 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); 702 memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
712 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED; 703 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;
713#ifdef NEED_TO_FIX 704#ifdef NEED_TO_FIX
714 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]); 705 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]);
@@ -742,16 +733,13 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
742} 733}
743 734
744 735
745int RIOReMapPorts(p, HostP, HostMapP) 736int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
746struct rio_info *p;
747struct Host *HostP;
748struct Map *HostMapP;
749{ 737{
750 register struct Port *PortP; 738 struct Port *PortP;
751 uint SubEnt; 739 unsigned int SubEnt;
752 uint HostPort; 740 unsigned int HostPort;
753 uint SysPort; 741 unsigned int SysPort;
754 ushort RtaType; 742 u16 RtaType;
755 unsigned long flags; 743 unsigned long flags;
756 744
757 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID); 745 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID);
@@ -794,12 +782,12 @@ struct Map *HostMapP;
794 */ 782 */
795 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { 783 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
796 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; 784 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
797 PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add)); 785 PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add));
798 PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start)); 786 PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start));
799 PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end)); 787 PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end));
800 PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove)); 788 PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove));
801 PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start)); 789 PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start));
802 PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end)); 790 PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end));
803 } else 791 } else
804 PortP->PhbP = NULL; 792 PortP->PhbP = NULL;
805 793
@@ -813,10 +801,10 @@ struct Map *HostMapP;
813 PortP->RupNum = HostMapP->ID - 1; 801 PortP->RupNum = HostMapP->ID - 1;
814 if (HostMapP->Flags & RTA16_SECOND_SLOT) { 802 if (HostMapP->Flags & RTA16_SECOND_SLOT) {
815 PortP->ID2 = HostMapP->ID2 - 1; 803 PortP->ID2 = HostMapP->ID2 - 1;
816 PortP->SecondBlock = TRUE; 804 PortP->SecondBlock = 1;
817 } else { 805 } else {
818 PortP->ID2 = 0; 806 PortP->ID2 = 0;
819 PortP->SecondBlock = FALSE; 807 PortP->SecondBlock = 0;
820 } 808 }
821 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum; 809 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;
822 810
@@ -866,9 +854,6 @@ struct Map *HostMapP;
866 PortP->RxDataStart = 0; 854 PortP->RxDataStart = 0;
867 PortP->Cor2Copy = 0; 855 PortP->Cor2Copy = 0;
868 PortP->Name = &HostMapP->Name[0]; 856 PortP->Name = &HostMapP->Name[0];
869#ifdef STATS
870 bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats));
871#endif
872 PortP->statsGather = 0; 857 PortP->statsGather = 0;
873 PortP->txchars = 0; 858 PortP->txchars = 0;
874 PortP->rxchars = 0; 859 PortP->rxchars = 0;
@@ -876,10 +861,10 @@ struct Map *HostMapP;
876 PortP->closes = 0; 861 PortP->closes = 0;
877 PortP->ioctls = 0; 862 PortP->ioctls = 0;
878 if (PortP->TxRingBuffer) 863 if (PortP->TxRingBuffer)
879 bzero(PortP->TxRingBuffer, p->RIOBufferSize); 864 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
880 else if (p->RIOBufferSize) { 865 else if (p->RIOBufferSize) {
881 PortP->TxRingBuffer = sysbrk(p->RIOBufferSize); 866 PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL);
882 bzero(PortP->TxRingBuffer, p->RIOBufferSize); 867 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
883 } 868 }
884 PortP->TxBufferOut = 0; 869 PortP->TxBufferOut = 0;
885 PortP->TxBufferIn = 0; 870 PortP->TxBufferIn = 0;
@@ -890,7 +875,7 @@ struct Map *HostMapP;
890 ** If the same, we have received the same rx pkt from the RTA 875 ** If the same, we have received the same rx pkt from the RTA
891 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0. 876 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
892 */ 877 */
893 PortP->LastRxTgl = ~(uchar) PHB_RX_TGL; 878 PortP->LastRxTgl = ~(u8) PHB_RX_TGL;
894 879
895 /* 880 /*
896 ** and mark the port as usable 881 ** and mark the port as usable
@@ -906,9 +891,7 @@ struct Map *HostMapP;
906 return 0; 891 return 0;
907} 892}
908 893
909int RIOChangeName(p, MapP) 894int RIOChangeName(struct rio_info *p, struct Map *MapP)
910struct rio_info *p;
911struct Map *MapP;
912{ 895{
913 int host; 896 int host;
914 struct Map *HostMapP; 897 struct Map *HostMapP;
@@ -941,7 +924,7 @@ struct Map *MapP;
941 return -ENXIO; 924 return -ENXIO;
942 } 925 }
943 if (MapP->ID == 0) { 926 if (MapP->ID == 0) {
944 CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN); 927 memcpy(p->RIOHosts[host].Name, MapP->Name, MAX_NAME_LEN);
945 return 0; 928 return 0;
946 } 929 }
947 930
@@ -951,7 +934,7 @@ struct Map *MapP;
951 p->RIOError.Error = RTA_NUMBER_WRONG; 934 p->RIOError.Error = RTA_NUMBER_WRONG;
952 return -ENXIO; 935 return -ENXIO;
953 } 936 }
954 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); 937 memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
955 return 0; 938 return 0;
956 } 939 }
957 } 940 }
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 6379816ed173..204267613c9c 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -56,15 +56,12 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
56 56
57#include "linux_compat.h" 57#include "linux_compat.h"
58#include "rio_linux.h" 58#include "rio_linux.h"
59#include "typdef.h"
60#include "pkt.h" 59#include "pkt.h"
61#include "daemon.h" 60#include "daemon.h"
62#include "rio.h" 61#include "rio.h"
63#include "riospace.h" 62#include "riospace.h"
64#include "top.h"
65#include "cmdpkt.h" 63#include "cmdpkt.h"
66#include "map.h" 64#include "map.h"
67#include "riotypes.h"
68#include "rup.h" 65#include "rup.h"
69#include "port.h" 66#include "port.h"
70#include "riodrvr.h" 67#include "riodrvr.h"
@@ -77,58 +74,18 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
77#include "unixrup.h" 74#include "unixrup.h"
78#include "board.h" 75#include "board.h"
79#include "host.h" 76#include "host.h"
80#include "error.h"
81#include "phb.h" 77#include "phb.h"
82#include "link.h" 78#include "link.h"
83#include "cmdblk.h" 79#include "cmdblk.h"
84#include "route.h" 80#include "route.h"
85#include "control.h"
86#include "cirrus.h" 81#include "cirrus.h"
87#include "rioioctl.h" 82#include "rioioctl.h"
88#include "param.h" 83#include "param.h"
89#include "list.h"
90#include "sam.h"
91 84
92static void RIOClearUp(struct Port *PortP); 85static void RIOClearUp(struct Port *PortP);
93int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
94
95
96extern int conv_vb[]; /* now defined in ttymgr.c */
97extern int conv_bv[]; /* now defined in ttymgr.c */
98 86
99/* 87/* Below belongs in func.h */
100** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support 88int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
101**
102** ep.def.h is necessary for Modular Kernel Support
103** DO NOT place any kernel 'extern's after this line
104** or this source file will not build riotty.k.o
105*/
106#ifdef uLYNX
107#include <ep.def.h>
108#endif
109
110#ifdef NEED_THIS2
111static struct old_sgttyb default_sg = {
112 B19200, B19200, /* input and output speed */
113 'H' - '@', /* erase char */
114 -1, /* 2nd erase char */
115 'U' - '@', /* kill char */
116 ECHO | CRMOD, /* mode */
117 'C' - '@', /* interrupt character */
118 '\\' - '@', /* quit char */
119 'Q' - '@', /* start char */
120 'S' - '@', /* stop char */
121 'D' - '@', /* EOF */
122 -1, /* brk */
123 (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */
124 'Z' - '@', /* process stop */
125 'Y' - '@', /* delayed stop */
126 'R' - '@', /* reprint line */
127 'O' - '@', /* flush output */
128 'W' - '@', /* word erase */
129 'V' - '@' /* literal next char */
130};
131#endif
132 89
133 90
134extern struct rio_info *p; 91extern struct rio_info *p;
@@ -136,8 +93,7 @@ extern struct rio_info *p;
136 93
137int riotopen(struct tty_struct *tty, struct file *filp) 94int riotopen(struct tty_struct *tty, struct file *filp)
138{ 95{
139 register uint SysPort; 96 unsigned int SysPort;
140 int Modem;
141 int repeat_this = 250; 97 int repeat_this = 250;
142 struct Port *PortP; /* pointer to the port structure */ 98 struct Port *PortP; /* pointer to the port structure */
143 unsigned long flags; 99 unsigned long flags;
@@ -151,16 +107,14 @@ int riotopen(struct tty_struct *tty, struct file *filp)
151 tty->driver_data = NULL; 107 tty->driver_data = NULL;
152 108
153 SysPort = rio_minor(tty); 109 SysPort = rio_minor(tty);
154 Modem = rio_ismodem(tty);
155 110
156 if (p->RIOFailed) { 111 if (p->RIOFailed) {
157 rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n"); 112 rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
158 pseterr(ENXIO);
159 func_exit(); 113 func_exit();
160 return -ENXIO; 114 return -ENXIO;
161 } 115 }
162 116
163 rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", SysPort, Modem ? "Modem" : "tty", p->RIOPortp[SysPort]->Mapped); 117 rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped);
164 118
165 /* 119 /*
166 ** Validate that we have received a legitimate request. 120 ** Validate that we have received a legitimate request.
@@ -170,7 +124,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
170 */ 124 */
171 if (SysPort >= RIO_PORTS) { /* out of range ? */ 125 if (SysPort >= RIO_PORTS) { /* out of range ? */
172 rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort); 126 rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
173 pseterr(ENXIO);
174 func_exit(); 127 func_exit();
175 return -ENXIO; 128 return -ENXIO;
176 } 129 }
@@ -187,7 +140,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
187 */ 140 */
188 rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n"); 141 rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
189 func_exit(); 142 func_exit();
190 pseterr(ENXIO);
191 return -ENXIO; 143 return -ENXIO;
192 } 144 }
193 145
@@ -209,7 +161,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
209 */ 161 */
210 if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) { 162 if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
211 rio_dprintk(RIO_DEBUG_TTY, "Host not running\n"); 163 rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
212 pseterr(ENXIO);
213 func_exit(); 164 func_exit();
214 return -ENXIO; 165 return -ENXIO;
215 } 166 }
@@ -309,15 +260,12 @@ int riotopen(struct tty_struct *tty, struct file *filp)
309 /* PortP->gs.xmit_cnt = 0; */ 260 /* PortP->gs.xmit_cnt = 0; */
310 261
311 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 262 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
312#ifdef NEED_THIS
313 ttyseth(PortP, tp, (struct old_sgttyb *) &default_sg);
314#endif
315 263
316 /* Someone explain to me why this delay/config is 264 /* Someone explain to me why this delay/config is
317 here. If I read the docs correctly the "open" 265 here. If I read the docs correctly the "open"
318 command piggybacks the parameters immediately. 266 command piggybacks the parameters immediately.
319 -- REW */ 267 -- REW */
320 RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP); /* Open the port */ 268 RIOParam(PortP, OPEN, 1, OK_TO_SLEEP); /* Open the port */
321 rio_spin_lock_irqsave(&PortP->portSem, flags); 269 rio_spin_lock_irqsave(&PortP->portSem, flags);
322 270
323 /* 271 /*
@@ -325,20 +273,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
325 */ 273 */
326 while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) { 274 while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) {
327 rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState); 275 rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState);
328/*
329** 15.10.1998 ARG - ESIL 0759
330** (Part) fix for port being trashed when opened whilst RTA "disconnected"
331** Take out the limited wait - now wait for ever or until user
332** bangs us out.
333**
334 if (repeat_this -- <= 0) {
335 rio_dprint(RIO_DEBUG_TTY, ("Waiting for open to finish timed out.\n"));
336 RIOPreemptiveCmd(p, PortP, FCLOSE );
337 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
338 return -EINTR;
339 }
340**
341*/
342 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 276 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
343 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 277 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
344 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); 278 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n");
@@ -358,80 +292,61 @@ int riotopen(struct tty_struct *tty, struct file *filp)
358 } 292 }
359 rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); 293 rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n");
360 } 294 }
361#ifdef MODEM_SUPPORT 295 rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n");
362 if (Modem) { 296 /*
363 rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n"); 297 ** ACTION
298 ** insert test for carrier here. -- ???
299 ** I already see that test here. What's the deal? -- REW
300 */
301 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
302 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
364 /* 303 /*
365 ** ACTION 304 tp->tm.c_state |= CARR_ON;
366 ** insert test for carrier here. -- ??? 305 wakeup((caddr_t) &tp->tm.c_canq);
367 ** I already see that test here. What's the deal? -- REW
368 */ 306 */
369 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { 307 PortP->State |= RIO_CARR_ON;
370 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); 308 wake_up_interruptible(&PortP->gs.open_wait);
309 } else { /* no carrier - wait for DCD */
371 /* 310 /*
372 tp->tm.c_state |= CARR_ON; 311 while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
373 wakeup((caddr_t) &tp->tm.c_canq); 312 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
374 */ 313 */
375 PortP->State |= RIO_CARR_ON; 314 while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
376 wake_up_interruptible(&PortP->gs.open_wait); 315 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
377 } else { /* no carrier - wait for DCD */
378
379 /* 316 /*
380 while (!(PortP->gs.tty->termios->c_state & CARR_ON) && 317 PortP->gs.tty->termios->c_state |= WOPEN;
381 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
382 */ 318 */
383 while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) { 319 PortP->State |= RIO_WOPEN;
384 320 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
385 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort); 321 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
386 /* 322 /*
387 PortP->gs.tty->termios->c_state |= WOPEN; 323 ** ACTION: verify that this is a good thing
324 ** to do here. -- ???
325 ** I think it's OK. -- REW
388 */ 326 */
389 PortP->State |= RIO_WOPEN; 327 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
328 RIOPreemptiveCmd(p, PortP, FCLOSE);
329 /*
330 tp->tm.c_state &= ~WOPEN;
331 */
332 PortP->State &= ~RIO_WOPEN;
390 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 333 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
391 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) 334 func_exit();
392 { 335 return -EINTR;
393 /*
394 ** ACTION: verify that this is a good thing
395 ** to do here. -- ???
396 ** I think it's OK. -- REW
397 */
398 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
399 RIOPreemptiveCmd(p, PortP, FCLOSE);
400 /*
401 tp->tm.c_state &= ~WOPEN;
402 */
403 PortP->State &= ~RIO_WOPEN;
404 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
405 func_exit();
406 return -EINTR;
407 }
408 } 336 }
409 PortP->State &= ~RIO_WOPEN;
410 } 337 }
411 if (p->RIOHalted) 338 PortP->State &= ~RIO_WOPEN;
412 goto bombout;
413 rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
414 PortP->State |= RIO_MOPEN;
415 } else
416#endif
417 {
418 /*
419 ** ACTION
420 ** Direct line open - force carrier (will probably mean
421 ** that sleeping Modem line fubar)
422 */
423 PortP->State |= RIO_LOPEN;
424 } 339 }
340 if (p->RIOHalted)
341 goto bombout;
342 rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
343 PortP->State |= RIO_MOPEN;
425 344
426 if (p->RIOHalted) { 345 if (p->RIOHalted)
427 goto bombout; 346 goto bombout;
428 }
429 347
430 rio_dprintk(RIO_DEBUG_TTY, "high level open done\n"); 348 rio_dprintk(RIO_DEBUG_TTY, "high level open done\n");
431 349
432#ifdef STATS
433 PortP->Stat.OpenCnt++;
434#endif
435 /* 350 /*
436 ** Count opens for port statistics reporting 351 ** Count opens for port statistics reporting
437 */ 352 */
@@ -460,23 +375,21 @@ int riotclose(void *ptr)
460 unsigned long end_time; 375 unsigned long end_time;
461 struct tty_struct *tty; 376 struct tty_struct *tty;
462 unsigned long flags; 377 unsigned long flags;
463 int Modem;
464 int rv = 0; 378 int rv = 0;
465 379
466 rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum); 380 rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
467 381
468 /* PortP = p->RIOPortp[SysPort]; */ 382 /* PortP = p->RIOPortp[SysPort]; */
469 rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP); 383 rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP);
470 /* tp = PortP->TtyP; *//* Get tty */ 384 /* tp = PortP->TtyP; *//* Get tty */
471 tty = PortP->gs.tty; 385 tty = PortP->gs.tty;
472 rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty); 386 rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty);
473 387
474 if (PortP->gs.closing_wait) 388 if (PortP->gs.closing_wait)
475 end_time = jiffies + PortP->gs.closing_wait; 389 end_time = jiffies + PortP->gs.closing_wait;
476 else 390 else
477 end_time = jiffies + MAX_SCHEDULE_TIMEOUT; 391 end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
478 392
479 Modem = rio_ismodem(tty);
480 rio_spin_lock_irqsave(&PortP->portSem, flags); 393 rio_spin_lock_irqsave(&PortP->portSem, flags);
481 394
482 /* 395 /*
@@ -500,7 +413,7 @@ int riotclose(void *ptr)
500 /* 413 /*
501 ** clear the open bits for this device 414 ** clear the open bits for this device
502 */ 415 */
503 PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN); 416 PortP->State &= ~RIO_MOPEN;
504 PortP->State &= ~RIO_CARR_ON; 417 PortP->State &= ~RIO_CARR_ON;
505 PortP->ModemState &= ~MSVR1_CD; 418 PortP->ModemState &= ~MSVR1_CD;
506 /* 419 /*
@@ -536,7 +449,6 @@ int riotclose(void *ptr)
536 449
537 if (!deleted) 450 if (!deleted)
538 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) { 451 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) {
539 cprintf("Need to flush the ttyport\n");
540 if (repeat_this-- <= 0) { 452 if (repeat_this-- <= 0) {
541 rv = -EINTR; 453 rv = -EINTR;
542 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); 454 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
@@ -615,16 +527,13 @@ int riotclose(void *ptr)
615*/ 527*/
616 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); 528 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
617 529
618#ifdef STATS
619 PortP->Stat.CloseCnt++;
620#endif
621 /* 530 /*
622 ** Count opens for port statistics reporting 531 ** Count opens for port statistics reporting
623 */ 532 */
624 if (PortP->statsGather) 533 if (PortP->statsGather)
625 PortP->closes++; 534 PortP->closes++;
626 535
627 close_end: 536close_end:
628 /* XXX: Why would a "DELETED" flag be reset here? I'd have 537 /* XXX: Why would a "DELETED" flag be reset here? I'd have
629 thought that a "deleted" flag means that the port was 538 thought that a "deleted" flag means that the port was
630 permanently gone, but here we can make it reappear by it 539 permanently gone, but here we can make it reappear by it
@@ -640,8 +549,7 @@ int riotclose(void *ptr)
640 549
641 550
642 551
643static void RIOClearUp(PortP) 552static void RIOClearUp(struct Port *PortP)
644struct Port *PortP;
645{ 553{
646 rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n"); 554 rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n");
647 PortP->Config = 0; /* Direct semaphore */ 555 PortP->Config = 0; /* Direct semaphore */
@@ -668,7 +576,7 @@ struct Port *PortP;
668*/ 576*/
669int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg) 577int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg)
670{ 578{
671 PKT *PacketP; 579 struct PKT *PacketP;
672 int retries = 20; /* at 10 per second -> 2 seconds */ 580 int retries = 20; /* at 10 per second -> 2 seconds */
673 unsigned long flags; 581 unsigned long flags;
674 582
@@ -722,15 +630,15 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len
722 /* 630 /*
723 ** set the command byte and the argument byte 631 ** set the command byte and the argument byte
724 */ 632 */
725 WBYTE(PacketP->data[0], command); 633 writeb(command, &PacketP->data[0]);
726 634
727 if (len == 2) 635 if (len == 2)
728 WBYTE(PacketP->data[1], arg); 636 writeb(arg, &PacketP->data[1]);
729 637
730 /* 638 /*
731 ** set the length of the packet and set the command bit. 639 ** set the length of the packet and set the command bit.
732 */ 640 */
733 WBYTE(PacketP->len, PKT_CMD_BIT | len); 641 writeb(PKT_CMD_BIT | len, &PacketP->len);
734 642
735 add_transmit(PortP); 643 add_transmit(PortP);
736 /* 644 /*
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
deleted file mode 100644
index 46084d5c7e98..000000000000
--- a/drivers/char/rio/riotypes.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* R I O T Y P E S
4 ******* *******
5 ****************************************************************************
6
7 Author : Jon Brawn
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36
37#ifndef _riotypes_h
38#define _riotypes_h 1
39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_riotypes_h_sccs = "@(#)riotypes.h 1.10"; */
43#endif
44#endif
45
46typedef unsigned short NUMBER_ptr;
47typedef unsigned short WORD_ptr;
48typedef unsigned short BYTE_ptr;
49typedef unsigned short char_ptr;
50typedef unsigned short Channel_ptr;
51typedef unsigned short FREE_LIST_ptr_ptr;
52typedef unsigned short FREE_LIST_ptr;
53typedef unsigned short LPB_ptr;
54typedef unsigned short Process_ptr;
55typedef unsigned short PHB_ptr;
56typedef unsigned short PKT_ptr;
57typedef unsigned short PKT_ptr_ptr;
58typedef unsigned short Q_BUF_ptr;
59typedef unsigned short Q_BUF_ptr_ptr;
60typedef unsigned short ROUTE_STR_ptr;
61typedef unsigned short RUP_ptr;
62typedef unsigned short short_ptr;
63typedef unsigned short u_short_ptr;
64typedef unsigned short ushort_ptr;
65
66#endif /* __riotypes__ */
67
68/*********** end of file ***********/
diff --git a/drivers/char/rio/rom.h b/drivers/char/rio/rom.h
deleted file mode 100644
index 58a7843625ff..000000000000
--- a/drivers/char/rio/rom.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* R O M
4 ******* *******
5 ****************************************************************************
6
7 Author : Ian Nandhra
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36
37#ifndef _rom_h
38#define _rom_h 1
39
40#ifndef lint
41#ifdef SCCS
42static char *_rio_rom_h_sccs = "@(#)rom.h 1.1";
43#endif
44#endif
45
46typedef struct ROM ROM;
47struct ROM {
48 u_short slx;
49 char pcb_letter_rev;
50 char pcb_number_rev;
51 char serial[4];
52 char year;
53 char week;
54};
55
56#endif
57
58#define HOST_ROM (ROM *) 0x7c00
59#define RTA_ROM (ROM *) 0x7801
60#define ROM_LENGTH 0x20
61
62/*********** end of file ***********/
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index f74f67c6f702..4ae90cb207a9 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -37,14 +37,7 @@
37#ifndef _rup_h 37#ifndef _rup_h
38#define _rup_h 1 38#define _rup_h 1
39 39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_rup_h_sccs = "@(#)rup.h 1.5"; */
43#endif
44#endif
45
46#define MAX_RUP ((short) 16) 40#define MAX_RUP ((short) 16)
47
48#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */ 41#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */
49 42
50/************************************************* 43/*************************************************
@@ -60,15 +53,15 @@
60#define RUP_NO_OWNER 0xff /* RUP not owned by any process */ 53#define RUP_NO_OWNER 0xff /* RUP not owned by any process */
61 54
62struct RUP { 55struct RUP {
63 PKT_ptr txpkt; /* Outgoing packet */ 56 u16 txpkt; /* Outgoing packet */
64 PKT_ptr rxpkt; /* Incoming packet */ 57 u16 rxpkt; /* Incoming packet */
65 WORD link; /* Which link to send down? */ 58 u16 link; /* Which link to send down? */
66 BYTE rup_dest_unit[2]; /* Destination unit */ 59 u8 rup_dest_unit[2]; /* Destination unit */
67 WORD handshake; /* For handshaking */ 60 u16 handshake; /* For handshaking */
68 WORD timeout; /* Timeout */ 61 u16 timeout; /* Timeout */
69 WORD status; /* Status */ 62 u16 status; /* Status */
70 WORD txcontrol; /* Transmit control */ 63 u16 txcontrol; /* Transmit control */
71 WORD rxcontrol; /* Receive control */ 64 u16 rxcontrol; /* Receive control */
72}; 65};
73 66
74#endif 67#endif
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
deleted file mode 100644
index 6f754e19015d..000000000000
--- a/drivers/char/rio/sam.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* S A M . H
4 ******* *******
5 ****************************************************************************
6
7 Author : Ian Nandhra
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36#ifndef _sam_h
37#define _sam_h 1
38
39#ifdef SCCS_LABELS
40#ifndef lint
41/* static char *_rio_sam_h_sccs = "@(#)sam.h 1.3"; */
42#endif
43#endif
44
45
46#define NUM_FREE_LIST_UNITS 500
47
48#ifndef FALSE
49#define FALSE (short) 0x00
50#endif
51#ifndef TRUE
52#define TRUE (short) !FALSE
53#endif
54
55#define TX TRUE
56#define RX FALSE
57
58
59typedef struct FREE_LIST FREE_LIST;
60struct FREE_LIST {
61 FREE_LIST_ptr next;
62 FREE_LIST_ptr prev;
63};
64
65
66#endif
67/*********** end of file ***********/
diff --git a/drivers/char/rio/space.h b/drivers/char/rio/space.h
deleted file mode 100644
index 1f12690f9d1f..000000000000
--- a/drivers/char/rio/space.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : space.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:19
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)space.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_space_h__
34#define __rio_space_h__
35
36#ifdef SCCS_LABELS
37static char *_space_h_sccs_ = "@(#)space.h 1.2";
38#endif
39
40extern int rio_cntls;
41extern int rio_bases[];
42extern int rio_limits[];
43extern int rio_vects[];
44
45#endif /* __rio_space_h__ */
diff --git a/drivers/char/rio/top.h b/drivers/char/rio/top.h
deleted file mode 100644
index d15a11dc4f73..000000000000
--- a/drivers/char/rio/top.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : top.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:19
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)top.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_top_h__
34#define __rio_top_h__
35
36#ifdef SCCS_LABELS
37static char *_top_h_sccs_ = "@(#)top.h 1.2";
38#endif
39
40/*
41** Topology information
42*/
43struct Top {
44 uchar Unit;
45 uchar Link;
46};
47
48#endif /* __rio_top_h__ */
diff --git a/drivers/char/rio/typdef.h b/drivers/char/rio/typdef.h
deleted file mode 100644
index 185b889e1510..000000000000
--- a/drivers/char/rio/typdef.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : typdef.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:20
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)typdef.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_typdef_h__
34#define __rio_typdef_h__
35
36#ifdef SCCS_LABELS
37static char *_typdef_h_sccs_ = "@(#)typdef.h 1.2";
38#endif
39
40#undef VPIX
41
42/*
43** IT IS REALLY, REALLY, IMPORTANT THAT BYTES ARE UNSIGNED!
44**
45** These types are ONLY to be used for refering to data structures
46** on the RIO Host card!
47*/
48typedef volatile unsigned char BYTE;
49typedef volatile unsigned short WORD;
50typedef volatile unsigned int DWORD;
51typedef volatile unsigned short RIOP;
52typedef volatile short NUMBER;
53
54
55/*
56** 27.01.199 ARG - mods to compile 'newutils' on LyxnOS -
57** These #defines are for the benefit of the 'libfuncs' library
58** only. They are not necessarily correct type mappings and
59** are here only to make the source compile.
60*/
61/* typedef unsigned int uint; */
62typedef unsigned long ulong_t;
63typedef unsigned short ushort_t;
64typedef unsigned char uchar_t;
65typedef unsigned char queue_t;
66typedef unsigned char mblk_t;
67typedef unsigned int paddr_t;
68typedef unsigned char uchar;
69
70#define TPNULL ((ushort)(0x8000))
71
72
73/*
74** RIO structures defined in other include files.
75*/
76typedef struct PKT PKT;
77typedef struct LPB LPB;
78typedef struct RUP RUP;
79typedef struct Port Port;
80typedef struct DpRam DpRam;
81
82#endif /* __rio_typdef_h__ */
diff --git a/drivers/char/rio/unixrup.h b/drivers/char/rio/unixrup.h
index a126c7cabac6..4306e01dbf01 100644
--- a/drivers/char/rio/unixrup.h
+++ b/drivers/char/rio/unixrup.h
@@ -45,9 +45,9 @@ struct UnixRup {
45 struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */ 45 struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */
46 struct CmdBlk *CmdPendingP; /* The command currently being sent */ 46 struct CmdBlk *CmdPendingP; /* The command currently being sent */
47 struct RUP *RupP; /* the Rup to send it to */ 47 struct RUP *RupP; /* the Rup to send it to */
48 uint Id; /* Id number */ 48 unsigned int Id; /* Id number */
49 uint BaseSysPort; /* SysPort of first tty on this RTA */ 49 unsigned int BaseSysPort; /* SysPort of first tty on this RTA */
50 uint ModTypes; /* Modules on this RTA */ 50 unsigned int ModTypes; /* Modules on this RTA */
51 spinlock_t RupLock; /* Lock structure for MPX */ 51 spinlock_t RupLock; /* Lock structure for MPX */
52 /* struct lockb RupLock; *//* Lock structure for MPX */ 52 /* struct lockb RupLock; *//* Lock structure for MPX */
53}; 53};