aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/rio/riotable.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/rio/riotable.c')
-rw-r--r--drivers/char/rio/riotable.c1019
1 files changed, 472 insertions, 547 deletions
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index e45bc275907a..42c3dffcbbb2 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -91,9 +91,8 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
91** A configuration table has been loaded. It is now up to us 91** A configuration table has been loaded. It is now up to us
92** to sort it out and use the information contained therein. 92** to sort it out and use the information contained therein.
93*/ 93*/
94int 94int RIONewTable(p)
95RIONewTable(p) 95struct rio_info *p;
96struct rio_info * p;
97{ 96{
98 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt; 97 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
99 struct Map *MapP; 98 struct Map *MapP;
@@ -103,26 +102,26 @@ struct rio_info * p;
103 char *cptr; 102 char *cptr;
104 103
105 /* 104 /*
106 ** We have been sent a new table to install. We need to break 105 ** We have been sent a new table to install. We need to break
107 ** it down into little bits and spread it around a bit to see 106 ** it down into little bits and spread it around a bit to see
108 ** what we have got. 107 ** what we have got.
109 */ 108 */
110 /* 109 /*
111 ** Things to check: 110 ** Things to check:
112 ** (things marked 'xx' aren't checked any more!) 111 ** (things marked 'xx' aren't checked any more!)
113 ** (1) That there are no booted Hosts/RTAs out there. 112 ** (1) That there are no booted Hosts/RTAs out there.
114 ** (2) That the names are properly formed 113 ** (2) That the names are properly formed
115 ** (3) That blank entries really are. 114 ** (3) That blank entries really are.
116 ** xx (4) That hosts mentioned in the table actually exist. xx 115 ** xx (4) That hosts mentioned in the table actually exist. xx
117 ** (5) That the IDs are unique (per host). 116 ** (5) That the IDs are unique (per host).
118 ** (6) That host IDs are zero 117 ** (6) That host IDs are zero
119 ** (7) That port numbers are valid 118 ** (7) That port numbers are valid
120 ** (8) That port numbers aren't duplicated 119 ** (8) That port numbers aren't duplicated
121 ** (9) That names aren't duplicated 120 ** (9) That names aren't duplicated
122 ** xx (10) That hosts that actually exist are mentioned in the table. xx 121 ** xx (10) That hosts that actually exist are mentioned in the table. xx
123 */ 122 */
124 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(1)\n"); 123 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(1)\n");
125 if ( p->RIOSystemUp ) { /* (1) */ 124 if (p->RIOSystemUp) { /* (1) */
126 p->RIOError.Error = HOST_HAS_ALREADY_BEEN_BOOTED; 125 p->RIOError.Error = HOST_HAS_ALREADY_BEEN_BOOTED;
127 return -EBUSY; 126 return -EBUSY;
128 } 127 }
@@ -131,19 +130,19 @@ struct rio_info * p;
131 p->RIOError.Entry = -1; 130 p->RIOError.Entry = -1;
132 p->RIOError.Other = -1; 131 p->RIOError.Other = -1;
133 132
134 for ( Entry=0; Entry<TOTAL_MAP_ENTRIES; Entry++ ) { 133 for (Entry = 0; Entry < TOTAL_MAP_ENTRIES; Entry++) {
135 MapP = &p->RIOConnectTable[Entry]; 134 MapP = &p->RIOConnectTable[Entry];
136 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) { 135 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) {
137 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(2)\n"); 136 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(2)\n");
138 cptr = MapP->Name; /* (2) */ 137 cptr = MapP->Name; /* (2) */
139 cptr[MAX_NAME_LEN-1]='\0'; 138 cptr[MAX_NAME_LEN - 1] = '\0';
140 if ( cptr[0]=='\0' ) { 139 if (cptr[0] == '\0') {
141 bcopy(MapP->RtaUniqueNum?"RTA NN":"HOST NN",MapP->Name,8); 140 bcopy(MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", MapP->Name, 8);
142 MapP->Name[5] = '0'+Entry/10; 141 MapP->Name[5] = '0' + Entry / 10;
143 MapP->Name[6] = '0'+Entry%10; 142 MapP->Name[6] = '0' + Entry % 10;
144 } 143 }
145 while ( *cptr ) { 144 while (*cptr) {
146 if ( *cptr<' ' || *cptr>'~' ) { 145 if (*cptr < ' ' || *cptr > '~') {
147 p->RIOError.Error = BAD_CHARACTER_IN_NAME; 146 p->RIOError.Error = BAD_CHARACTER_IN_NAME;
148 p->RIOError.Entry = Entry; 147 p->RIOError.Entry = Entry;
149 return -ENXIO; 148 return -ENXIO;
@@ -153,133 +152,119 @@ struct rio_info * p;
153 } 152 }
154 153
155 /* 154 /*
156 ** If the entry saved was a tentative entry then just forget 155 ** If the entry saved was a tentative entry then just forget
157 ** about it. 156 ** about it.
158 */ 157 */
159 if ( MapP->Flags & SLOT_TENTATIVE ) { 158 if (MapP->Flags & SLOT_TENTATIVE) {
160 MapP->HostUniqueNum = 0; 159 MapP->HostUniqueNum = 0;
161 MapP->RtaUniqueNum = 0; 160 MapP->RtaUniqueNum = 0;
162 continue; 161 continue;
163 } 162 }
164 163
165 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(3)\n"); 164 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(3)\n");
166 if ( !MapP->RtaUniqueNum && !MapP->HostUniqueNum ) { /* (3) */ 165 if (!MapP->RtaUniqueNum && !MapP->HostUniqueNum) { /* (3) */
167 if ( MapP->ID || MapP->SysPort || MapP->Flags ) { 166 if (MapP->ID || MapP->SysPort || MapP->Flags) {
168 rio_dprintk (RIO_DEBUG_TABLE, "%s pretending to be empty but isn't\n",MapP->Name); 167 rio_dprintk(RIO_DEBUG_TABLE, "%s pretending to be empty but isn't\n", MapP->Name);
169 p->RIOError.Error = TABLE_ENTRY_ISNT_PROPERLY_NULL; 168 p->RIOError.Error = TABLE_ENTRY_ISNT_PROPERLY_NULL;
170 p->RIOError.Entry = Entry; 169 p->RIOError.Entry = Entry;
171 return -ENXIO; 170 return -ENXIO;
172 } 171 }
173 rio_dprintk (RIO_DEBUG_TABLE, "!RIO: Daemon: test (3) passes\n"); 172 rio_dprintk(RIO_DEBUG_TABLE, "!RIO: Daemon: test (3) passes\n");
174 continue; 173 continue;
175 } 174 }
176 175
177 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(4)\n"); 176 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(4)\n");
178 for ( Host=0; Host<p->RIONumHosts; Host++ ) { /* (4) */ 177 for (Host = 0; Host < p->RIONumHosts; Host++) { /* (4) */
179 if ( p->RIOHosts[Host].UniqueNum==MapP->HostUniqueNum ) { 178 if (p->RIOHosts[Host].UniqueNum == MapP->HostUniqueNum) {
180 HostP = &p->RIOHosts[Host]; 179 HostP = &p->RIOHosts[Host];
181 /* 180 /*
182 ** having done the lookup, we don't really want to do 181 ** having done the lookup, we don't really want to do
183 ** it again, so hang the host number in a safe place 182 ** it again, so hang the host number in a safe place
184 */ 183 */
185 MapP->Topology[0].Unit = Host; 184 MapP->Topology[0].Unit = Host;
186 break; 185 break;
187 } 186 }
188 } 187 }
189 188
190 if ( Host >= p->RIONumHosts ) { 189 if (Host >= p->RIONumHosts) {
191 rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has unknown host unique number 0x%x\n", 190 rio_dprintk(RIO_DEBUG_TABLE, "RTA %s has unknown host unique number 0x%x\n", MapP->Name, MapP->HostUniqueNum);
192 MapP->Name, MapP->HostUniqueNum);
193 MapP->HostUniqueNum = 0; 191 MapP->HostUniqueNum = 0;
194 /* MapP->RtaUniqueNum = 0; */ 192 /* MapP->RtaUniqueNum = 0; */
195 /* MapP->ID = 0; */ 193 /* MapP->ID = 0; */
196 /* MapP->Flags = 0; */ 194 /* MapP->Flags = 0; */
197 /* MapP->SysPort = 0; */ 195 /* MapP->SysPort = 0; */
198 /* MapP->Name[0] = 0; */ 196 /* MapP->Name[0] = 0; */
199 continue; 197 continue;
200 } 198 }
201 199
202 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(5)\n"); 200 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(5)\n");
203 if ( MapP->RtaUniqueNum ) { /* (5) */ 201 if (MapP->RtaUniqueNum) { /* (5) */
204 if ( !MapP->ID ) { 202 if (!MapP->ID) {
205 rio_dprintk (RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an ID of zero!\n", 203 rio_dprintk(RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an ID of zero!\n", MapP->Name);
206 MapP->Name); 204 p->RIOError.Error = ZERO_RTA_ID;
207 p->RIOError.Error = ZERO_RTA_ID;
208 p->RIOError.Entry = Entry; 205 p->RIOError.Entry = Entry;
209 return -ENXIO; 206 return -ENXIO;
210 } 207 }
211 if ( MapP->ID > MAX_RUP ) { 208 if (MapP->ID > MAX_RUP) {
212 rio_dprintk (RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an invalid ID %d\n", 209 rio_dprintk(RIO_DEBUG_TABLE, "RIO: RTA %s has been allocated an invalid ID %d\n", MapP->Name, MapP->ID);
213 MapP->Name, MapP->ID);
214 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE; 210 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
215 p->RIOError.Entry = Entry; 211 p->RIOError.Entry = Entry;
216 return -ENXIO; 212 return -ENXIO;
217 } 213 }
218 for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) { 214 for (SubEnt = 0; SubEnt < Entry; SubEnt++) {
219 if ( MapP->HostUniqueNum == 215 if (MapP->HostUniqueNum == p->RIOConnectTable[SubEnt].HostUniqueNum && MapP->ID == p->RIOConnectTable[SubEnt].ID) {
220 p->RIOConnectTable[SubEnt].HostUniqueNum && 216 rio_dprintk(RIO_DEBUG_TABLE, "Dupl. ID number allocated to RTA %s and RTA %s\n", MapP->Name, p->RIOConnectTable[SubEnt].Name);
221 MapP->ID == p->RIOConnectTable[SubEnt].ID ) {
222 rio_dprintk (RIO_DEBUG_TABLE, "Dupl. ID number allocated to RTA %s and RTA %s\n",
223 MapP->Name, p->RIOConnectTable[SubEnt].Name);
224 p->RIOError.Error = DUPLICATED_RTA_ID; 217 p->RIOError.Error = DUPLICATED_RTA_ID;
225 p->RIOError.Entry = Entry; 218 p->RIOError.Entry = Entry;
226 p->RIOError.Other = SubEnt; 219 p->RIOError.Other = SubEnt;
227 return -ENXIO; 220 return -ENXIO;
228 } 221 }
229 /* 222 /*
230 ** If the RtaUniqueNum is the same, it may be looking at both 223 ** If the RtaUniqueNum is the same, it may be looking at both
231 ** entries for a 16 port RTA, so check the ids 224 ** entries for a 16 port RTA, so check the ids
232 */ 225 */
233 if ((MapP->RtaUniqueNum == 226 if ((MapP->RtaUniqueNum == p->RIOConnectTable[SubEnt].RtaUniqueNum)
234 p->RIOConnectTable[SubEnt].RtaUniqueNum) 227 && (MapP->ID2 != p->RIOConnectTable[SubEnt].ID)) {
235 && (MapP->ID2 != p->RIOConnectTable[SubEnt].ID)) { 228 rio_dprintk(RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n", MapP->Name);
236 rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n",MapP->Name); 229 rio_dprintk(RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n", p->RIOConnectTable[SubEnt].Name);
237 rio_dprintk (RIO_DEBUG_TABLE, "RTA %s has duplicate unique number\n",
238 p->RIOConnectTable[SubEnt].Name);
239 p->RIOError.Error = DUPLICATE_UNIQUE_NUMBER; 230 p->RIOError.Error = DUPLICATE_UNIQUE_NUMBER;
240 p->RIOError.Entry = Entry; 231 p->RIOError.Entry = Entry;
241 p->RIOError.Other = SubEnt; 232 p->RIOError.Other = SubEnt;
242 return -ENXIO; 233 return -ENXIO;
243 } 234 }
244 } 235 }
245 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7a)\n"); 236 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(7a)\n");
246 /* (7a) */ 237 /* (7a) */
247 if ((MapP->SysPort != NO_PORT)&&(MapP->SysPort % PORTS_PER_RTA)) { 238 if ((MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA)) {
248 rio_dprintk (RIO_DEBUG_TABLE, "TTY Port number %d-RTA %s is not a multiple of %d!\n", 239 rio_dprintk(RIO_DEBUG_TABLE, "TTY Port number %d-RTA %s is not a multiple of %d!\n", (int) MapP->SysPort, MapP->Name, PORTS_PER_RTA);
249 (int)MapP->SysPort,MapP->Name, PORTS_PER_RTA);
250 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE; 240 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
251 p->RIOError.Entry = Entry; 241 p->RIOError.Entry = Entry;
252 return -ENXIO; 242 return -ENXIO;
253 } 243 }
254 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(7b)\n"); 244 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(7b)\n");
255 /* (7b) */ 245 /* (7b) */
256 if ((MapP->SysPort != NO_PORT)&&(MapP->SysPort >= RIO_PORTS)) { 246 if ((MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS)) {
257 rio_dprintk (RIO_DEBUG_TABLE, "TTY Port number %d for RTA %s is too big\n", 247 rio_dprintk(RIO_DEBUG_TABLE, "TTY Port number %d for RTA %s is too big\n", (int) MapP->SysPort, MapP->Name);
258 (int)MapP->SysPort, MapP->Name);
259 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE; 248 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
260 p->RIOError.Entry = Entry; 249 p->RIOError.Entry = Entry;
261 return -ENXIO; 250 return -ENXIO;
262 } 251 }
263 for ( SubEnt=0; SubEnt<Entry; SubEnt++ ) { 252 for (SubEnt = 0; SubEnt < Entry; SubEnt++) {
264 if ( p->RIOConnectTable[SubEnt].Flags & RTA16_SECOND_SLOT ) 253 if (p->RIOConnectTable[SubEnt].Flags & RTA16_SECOND_SLOT)
265 continue; 254 continue;
266 if ( p->RIOConnectTable[SubEnt].RtaUniqueNum ) { 255 if (p->RIOConnectTable[SubEnt].RtaUniqueNum) {
267 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(8)\n"); 256 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(8)\n");
268 /* (8) */ 257 /* (8) */
269 if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort == 258 if ((MapP->SysPort != NO_PORT) && (MapP->SysPort == p->RIOConnectTable[SubEnt].SysPort)) {
270 p->RIOConnectTable[SubEnt].SysPort) ) { 259 rio_dprintk(RIO_DEBUG_TABLE, "RTA %s:same TTY port # as RTA %s (%d)\n", MapP->Name, p->RIOConnectTable[SubEnt].Name, (int) MapP->SysPort);
271 rio_dprintk (RIO_DEBUG_TABLE, "RTA %s:same TTY port # as RTA %s (%d)\n",
272 MapP->Name, p->RIOConnectTable[SubEnt].Name,
273 (int)MapP->SysPort);
274 p->RIOError.Error = TTY_NUMBER_IN_USE; 260 p->RIOError.Error = TTY_NUMBER_IN_USE;
275 p->RIOError.Entry = Entry; 261 p->RIOError.Entry = Entry;
276 p->RIOError.Other = SubEnt; 262 p->RIOError.Other = SubEnt;
277 return -ENXIO; 263 return -ENXIO;
278 } 264 }
279 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(9)\n"); 265 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(9)\n");
280 if (strcmp(MapP->Name, 266 if (strcmp(MapP->Name, p->RIOConnectTable[SubEnt].Name) == 0 && !(MapP->Flags & RTA16_SECOND_SLOT)) { /* (9) */
281 p->RIOConnectTable[SubEnt].Name)==0 && !(MapP->Flags & RTA16_SECOND_SLOT)) { /* (9) */ 267 rio_dprintk(RIO_DEBUG_TABLE, "RTA name %s used twice\n", MapP->Name);
282 rio_dprintk (RIO_DEBUG_TABLE, "RTA name %s used twice\n", MapP->Name);
283 p->RIOError.Error = NAME_USED_TWICE; 268 p->RIOError.Error = NAME_USED_TWICE;
284 p->RIOError.Entry = Entry; 269 p->RIOError.Entry = Entry;
285 p->RIOError.Other = SubEnt; 270 p->RIOError.Other = SubEnt;
@@ -287,19 +272,16 @@ struct rio_info * p;
287 } 272 }
288 } 273 }
289 } 274 }
290 } 275 } else { /* (6) */
291 else { /* (6) */ 276 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: entering(6)\n");
292 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: entering(6)\n"); 277 if (MapP->ID) {
293 if ( MapP->ID ) { 278 rio_dprintk(RIO_DEBUG_TABLE, "RIO:HOST %s has been allocated ID that isn't zero!\n", MapP->Name);
294 rio_dprintk (RIO_DEBUG_TABLE, "RIO:HOST %s has been allocated ID that isn't zero!\n",
295 MapP->Name);
296 p->RIOError.Error = HOST_ID_NOT_ZERO; 279 p->RIOError.Error = HOST_ID_NOT_ZERO;
297 p->RIOError.Entry = Entry; 280 p->RIOError.Entry = Entry;
298 return -ENXIO; 281 return -ENXIO;
299 } 282 }
300 if ( MapP->SysPort != NO_PORT ) { 283 if (MapP->SysPort != NO_PORT) {
301 rio_dprintk (RIO_DEBUG_TABLE, "RIO: HOST %s has been allocated port numbers!\n", 284 rio_dprintk(RIO_DEBUG_TABLE, "RIO: HOST %s has been allocated port numbers!\n", MapP->Name);
302 MapP->Name);
303 p->RIOError.Error = HOST_SYSPORT_BAD; 285 p->RIOError.Error = HOST_SYSPORT_BAD;
304 p->RIOError.Entry = Entry; 286 p->RIOError.Entry = Entry;
305 return -ENXIO; 287 return -ENXIO;
@@ -308,106 +290,101 @@ struct rio_info * p;
308 } 290 }
309 291
310 /* 292 /*
311 ** wow! if we get here then it's a goody! 293 ** wow! if we get here then it's a goody!
312 */ 294 */
313 295
314 /* 296 /*
315 ** Zero the (old) entries for each host... 297 ** Zero the (old) entries for each host...
316 */ 298 */
317 for ( Host=0; Host<RIO_HOSTS; Host++ ) { 299 for (Host = 0; Host < RIO_HOSTS; Host++) {
318 for ( Entry=0; Entry<MAX_RUP; Entry++ ) { 300 for (Entry = 0; Entry < MAX_RUP; Entry++) {
319 bzero((caddr_t)&p->RIOHosts[Host].Mapping[Entry], 301 bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map));
320 sizeof(struct Map));
321 } 302 }
322 bzero((caddr_t)&p->RIOHosts[Host].Name[0], 303 bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name));
323 sizeof(p->RIOHosts[Host].Name) );
324 } 304 }
325 305
326 /* 306 /*
327 ** Copy in the new table entries 307 ** Copy in the new table entries
328 */ 308 */
329 for ( Entry=0; Entry< TOTAL_MAP_ENTRIES; Entry++ ) { 309 for (Entry = 0; Entry < TOTAL_MAP_ENTRIES; Entry++) {
330 rio_dprintk (RIO_DEBUG_TABLE, "RIONewTable: Copy table for Host entry %d\n", Entry); 310 rio_dprintk(RIO_DEBUG_TABLE, "RIONewTable: Copy table for Host entry %d\n", Entry);
331 MapP = &p->RIOConnectTable[Entry]; 311 MapP = &p->RIOConnectTable[Entry];
332 312
333 /* 313 /*
334 ** Now, if it is an empty slot ignore it! 314 ** Now, if it is an empty slot ignore it!
335 */ 315 */
336 if ( MapP->HostUniqueNum==0 ) 316 if (MapP->HostUniqueNum == 0)
337 continue; 317 continue;
338 318
339 /* 319 /*
340 ** we saved the host number earlier, so grab it back 320 ** we saved the host number earlier, so grab it back
341 */ 321 */
342 HostP = &p->RIOHosts[MapP->Topology[0].Unit]; 322 HostP = &p->RIOHosts[MapP->Topology[0].Unit];
343 323
344 /* 324 /*
345 ** If it is a host, then we only need to fill in the name field. 325 ** If it is a host, then we only need to fill in the name field.
346 */ 326 */
347 if ( MapP->ID==0 ) { 327 if (MapP->ID == 0) {
348 rio_dprintk (RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name); 328 rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
349 bcopy(MapP->Name,HostP->Name,MAX_NAME_LEN); 329 bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN);
350 continue; 330 continue;
351 } 331 }
352 332
353 /* 333 /*
354 ** Its an RTA entry, so fill in the host mapping entries for it 334 ** Its an RTA entry, so fill in the host mapping entries for it
355 ** and the port mapping entries. Notice that entry zero is for 335 ** and the port mapping entries. Notice that entry zero is for
356 ** ID one. 336 ** ID one.
357 */ 337 */
358 HostMapP = &HostP->Mapping[MapP->ID-1]; 338 HostMapP = &HostP->Mapping[MapP->ID - 1];
359 339
360 if (MapP->Flags & SLOT_IN_USE) { 340 if (MapP->Flags & SLOT_IN_USE) {
361 rio_dprintk (RIO_DEBUG_TABLE, "Rta entry found. Name %s\n", MapP->Name); 341 rio_dprintk(RIO_DEBUG_TABLE, "Rta entry found. Name %s\n", MapP->Name);
362 /* 342 /*
363 ** structure assign, then sort out the bits we shouldn't have done 343 ** structure assign, then sort out the bits we shouldn't have done
364 */ 344 */
365 *HostMapP = *MapP; 345 *HostMapP = *MapP;
366 346
367 HostMapP->Flags = SLOT_IN_USE; 347 HostMapP->Flags = SLOT_IN_USE;
368 if (MapP->Flags & RTA16_SECOND_SLOT) 348 if (MapP->Flags & RTA16_SECOND_SLOT)
369 HostMapP->Flags |= RTA16_SECOND_SLOT; 349 HostMapP->Flags |= RTA16_SECOND_SLOT;
370 350
371 RIOReMapPorts(p, HostP, HostMapP ); 351 RIOReMapPorts(p, HostP, HostMapP);
372 } 352 } else {
373 else { 353 rio_dprintk(RIO_DEBUG_TABLE, "TENTATIVE Rta entry found. Name %s\n", MapP->Name);
374 rio_dprintk (RIO_DEBUG_TABLE, "TENTATIVE Rta entry found. Name %s\n", MapP->Name);
375 } 354 }
376 } 355 }
377 356
378 for ( Entry=0; Entry< TOTAL_MAP_ENTRIES; Entry++ ) { 357 for (Entry = 0; Entry < TOTAL_MAP_ENTRIES; Entry++) {
379 p->RIOSavedTable[Entry] = p->RIOConnectTable[Entry]; 358 p->RIOSavedTable[Entry] = p->RIOConnectTable[Entry];
380 } 359 }
381 360
382 for ( Host=0; Host<p->RIONumHosts; Host++ ) { 361 for (Host = 0; Host < p->RIONumHosts; Host++) {
383 for ( SubEnt=0; SubEnt<LINKS_PER_UNIT; SubEnt++ ) { 362 for (SubEnt = 0; SubEnt < LINKS_PER_UNIT; SubEnt++) {
384 p->RIOHosts[Host].Topology[SubEnt].Unit = ROUTE_DISCONNECT; 363 p->RIOHosts[Host].Topology[SubEnt].Unit = ROUTE_DISCONNECT;
385 p->RIOHosts[Host].Topology[SubEnt].Link = NO_LINK; 364 p->RIOHosts[Host].Topology[SubEnt].Link = NO_LINK;
386 } 365 }
387 for ( Entry=0; Entry<MAX_RUP; Entry++ ) { 366 for (Entry = 0; Entry < MAX_RUP; Entry++) {
388 for ( SubEnt=0; SubEnt<LINKS_PER_UNIT; SubEnt++ ) { 367 for (SubEnt = 0; SubEnt < LINKS_PER_UNIT; SubEnt++) {
389 p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Unit = 368 p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Unit = ROUTE_DISCONNECT;
390 ROUTE_DISCONNECT; 369 p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Link = NO_LINK;
391 p->RIOHosts[Host].Mapping[Entry].Topology[SubEnt].Link =
392 NO_LINK;
393 } 370 }
394 } 371 }
395 if ( !p->RIOHosts[Host].Name[0] ) { 372 if (!p->RIOHosts[Host].Name[0]) {
396 bcopy("HOST 1",p->RIOHosts[Host].Name,7); 373 bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
397 p->RIOHosts[Host].Name[5] += Host; 374 p->RIOHosts[Host].Name[5] += Host;
398 } 375 }
399 /* 376 /*
400 ** Check that default name assigned is unique. 377 ** Check that default name assigned is unique.
401 */ 378 */
402 Host1 = Host; 379 Host1 = Host;
403 NameIsUnique = 0; 380 NameIsUnique = 0;
404 while (!NameIsUnique) { 381 while (!NameIsUnique) {
405 NameIsUnique = 1; 382 NameIsUnique = 1;
406 for ( Host2=0; Host2<p->RIONumHosts; Host2++ ) { 383 for (Host2 = 0; Host2 < p->RIONumHosts; Host2++) {
407 if (Host2 == Host) 384 if (Host2 == Host)
408 continue; 385 continue;
409 if (strcmp(p->RIOHosts[Host].Name, p->RIOHosts[Host2].Name) 386 if (strcmp(p->RIOHosts[Host].Name, p->RIOHosts[Host2].Name)
410 == 0) { 387 == 0) {
411 NameIsUnique = 0; 388 NameIsUnique = 0;
412 Host1++; 389 Host1++;
413 if (Host1 >= p->RIONumHosts) 390 if (Host1 >= p->RIONumHosts)
@@ -417,15 +394,14 @@ struct rio_info * p;
417 } 394 }
418 } 395 }
419 /* 396 /*
420 ** Rename host if name already used. 397 ** Rename host if name already used.
421 */ 398 */
422 if (Host1 != Host) 399 if (Host1 != Host) {
423 { 400 rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
424 rio_dprintk (RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name); 401 bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
425 bcopy("HOST 1",p->RIOHosts[Host].Name,7);
426 p->RIOHosts[Host].Name[5] += Host1; 402 p->RIOHosts[Host].Name[5] += Host1;
427 } 403 }
428 rio_dprintk (RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name); 404 rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
429 } 405 }
430 return 0; 406 return 0;
431} 407}
@@ -434,9 +410,8 @@ struct rio_info * p;
434** User process needs the config table - build it from first 410** User process needs the config table - build it from first
435** principles. 411** principles.
436*/ 412*/
437int 413int RIOApel(p)
438RIOApel(p) 414struct rio_info *p;
439struct rio_info * p;
440{ 415{
441 int Host; 416 int Host;
442 int link; 417 int link;
@@ -446,35 +421,34 @@ struct rio_info * p;
446 struct Host *HostP; 421 struct Host *HostP;
447 long oldspl; 422 long oldspl;
448 423
449 disable(oldspl); /* strange but true! */ 424 disable(oldspl); /* strange but true! */
450 425
451 rio_dprintk (RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n"); 426 rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
452 427
453 bzero((caddr_t)&p->RIOConnectTable[0], 428 bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES);
454 sizeof(struct Map) * TOTAL_MAP_ENTRIES );
455 429
456 for ( Host=0; Host<RIO_HOSTS; Host++ ) { 430 for (Host = 0; Host < RIO_HOSTS; Host++) {
457 rio_dprintk (RIO_DEBUG_TABLE, "Processing host %d\n", Host); 431 rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host);
458 HostP = &p->RIOHosts[Host]; 432 HostP = &p->RIOHosts[Host];
459 MapP = &p->RIOConnectTable[Next++]; 433 MapP = &p->RIOConnectTable[Next++];
460 MapP->HostUniqueNum = HostP->UniqueNum; 434 MapP->HostUniqueNum = HostP->UniqueNum;
461 if ( (HostP->Flags & RUN_STATE) != RC_RUNNING ) 435 if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
462 continue; 436 continue;
463 MapP->RtaUniqueNum = 0; 437 MapP->RtaUniqueNum = 0;
464 MapP->ID = 0; 438 MapP->ID = 0;
465 MapP->Flags = SLOT_IN_USE; 439 MapP->Flags = SLOT_IN_USE;
466 MapP->SysPort = NO_PORT; 440 MapP->SysPort = NO_PORT;
467 for ( link=0; link<LINKS_PER_UNIT; link++ ) 441 for (link = 0; link < LINKS_PER_UNIT; link++)
468 MapP->Topology[link] = HostP->Topology[link]; 442 MapP->Topology[link] = HostP->Topology[link];
469 bcopy(HostP->Name,MapP->Name,MAX_NAME_LEN); 443 bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN);
470 for ( Rup=0; Rup<MAX_RUP; Rup++ ) { 444 for (Rup = 0; Rup < MAX_RUP; Rup++) {
471 if ( HostP->Mapping[Rup].Flags & (SLOT_IN_USE|SLOT_TENTATIVE) ) { 445 if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) {
472 p->RIOConnectTable[Next] = HostP->Mapping[Rup]; 446 p->RIOConnectTable[Next] = HostP->Mapping[Rup];
473 if ( HostP->Mapping[Rup].Flags & SLOT_IN_USE) 447 if (HostP->Mapping[Rup].Flags & SLOT_IN_USE)
474 p->RIOConnectTable[Next].Flags |= SLOT_IN_USE; 448 p->RIOConnectTable[Next].Flags |= SLOT_IN_USE;
475 if ( HostP->Mapping[Rup].Flags & SLOT_TENTATIVE) 449 if (HostP->Mapping[Rup].Flags & SLOT_TENTATIVE)
476 p->RIOConnectTable[Next].Flags |= SLOT_TENTATIVE; 450 p->RIOConnectTable[Next].Flags |= SLOT_TENTATIVE;
477 if ( HostP->Mapping[Rup].Flags & RTA16_SECOND_SLOT ) 451 if (HostP->Mapping[Rup].Flags & RTA16_SECOND_SLOT)
478 p->RIOConnectTable[Next].Flags |= RTA16_SECOND_SLOT; 452 p->RIOConnectTable[Next].Flags |= RTA16_SECOND_SLOT;
479 Next++; 453 Next++;
480 } 454 }
@@ -489,8 +463,7 @@ struct rio_info * p;
489** if the entry is suitably inactive, then we can gob on it and remove 463** if the entry is suitably inactive, then we can gob on it and remove
490** it from the table. 464** it from the table.
491*/ 465*/
492int 466int RIODeleteRta(p, MapP)
493RIODeleteRta(p, MapP)
494struct rio_info *p; 467struct rio_info *p;
495struct Map *MapP; 468struct Map *MapP;
496{ 469{
@@ -502,110 +475,98 @@ struct Map *MapP;
502 int work_done = 0; 475 int work_done = 0;
503 unsigned long lock_flags, sem_flags; 476 unsigned long lock_flags, sem_flags;
504 477
505 rio_dprintk (RIO_DEBUG_TABLE, "Delete entry on host %x, rta %x\n", 478 rio_dprintk(RIO_DEBUG_TABLE, "Delete entry on host %x, rta %x\n", MapP->HostUniqueNum, MapP->RtaUniqueNum);
506 MapP->HostUniqueNum, MapP->RtaUniqueNum);
507 479
508 for ( host=0; host < p->RIONumHosts; host++ ) { 480 for (host = 0; host < p->RIONumHosts; host++) {
509 HostP = &p->RIOHosts[host]; 481 HostP = &p->RIOHosts[host];
510 482
511 rio_spin_lock_irqsave( &HostP->HostLock, lock_flags ); 483 rio_spin_lock_irqsave(&HostP->HostLock, lock_flags);
512 484
513 if ( (HostP->Flags & RUN_STATE) != RC_RUNNING ) { 485 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
514 rio_spin_unlock_irqrestore(&HostP->HostLock, lock_flags); 486 rio_spin_unlock_irqrestore(&HostP->HostLock, lock_flags);
515 continue; 487 continue;
516 } 488 }
517 489
518 for ( entry=0; entry<MAX_RUP; entry++ ) { 490 for (entry = 0; entry < MAX_RUP; entry++) {
519 if ( MapP->RtaUniqueNum == HostP->Mapping[entry].RtaUniqueNum ) { 491 if (MapP->RtaUniqueNum == HostP->Mapping[entry].RtaUniqueNum) {
520 HostMapP = &HostP->Mapping[entry]; 492 HostMapP = &HostP->Mapping[entry];
521 rio_dprintk (RIO_DEBUG_TABLE, "Found entry offset %d on host %s\n", 493 rio_dprintk(RIO_DEBUG_TABLE, "Found entry offset %d on host %s\n", entry, HostP->Name);
522 entry, HostP->Name);
523 494
524 /* 495 /*
525 ** Check all four links of the unit are disconnected 496 ** Check all four links of the unit are disconnected
526 */ 497 */
527 for ( link=0; link< LINKS_PER_UNIT; link++ ) { 498 for (link = 0; link < LINKS_PER_UNIT; link++) {
528 if ( HostMapP->Topology[link].Unit != ROUTE_DISCONNECT ) { 499 if (HostMapP->Topology[link].Unit != ROUTE_DISCONNECT) {
529 rio_dprintk (RIO_DEBUG_TABLE, "Entry is in use and cannot be deleted!\n"); 500 rio_dprintk(RIO_DEBUG_TABLE, "Entry is in use and cannot be deleted!\n");
530 p->RIOError.Error = UNIT_IS_IN_USE; 501 p->RIOError.Error = UNIT_IS_IN_USE;
531 rio_spin_unlock_irqrestore( &HostP->HostLock, lock_flags); 502 rio_spin_unlock_irqrestore(&HostP->HostLock, lock_flags);
532 return -EBUSY; 503 return -EBUSY;
533 } 504 }
534 } 505 }
535 /* 506 /*
536 ** Slot has been allocated, BUT not booted/routed/ 507 ** Slot has been allocated, BUT not booted/routed/
537 ** connected/selected or anything else-ed 508 ** connected/selected or anything else-ed
538 */ 509 */
539 SysPort = HostMapP->SysPort; 510 SysPort = HostMapP->SysPort;
540 511
541 if ( SysPort != NO_PORT ) { 512 if (SysPort != NO_PORT) {
542 for (port=SysPort; port < SysPort+PORTS_PER_RTA; port++) { 513 for (port = SysPort; port < SysPort + PORTS_PER_RTA; port++) {
543 PortP = p->RIOPortp[port]; 514 PortP = p->RIOPortp[port];
544 rio_dprintk (RIO_DEBUG_TABLE, "Unmap port\n"); 515 rio_dprintk(RIO_DEBUG_TABLE, "Unmap port\n");
545 516
546 rio_spin_lock_irqsave( &PortP->portSem, sem_flags ); 517 rio_spin_lock_irqsave(&PortP->portSem, sem_flags);
547 518
548 PortP->Mapped = 0; 519 PortP->Mapped = 0;
549 520
550 if ( PortP->State & (RIO_MOPEN|RIO_LOPEN) ) { 521 if (PortP->State & (RIO_MOPEN | RIO_LOPEN)) {
551 522
552 rio_dprintk (RIO_DEBUG_TABLE, "Gob on port\n"); 523 rio_dprintk(RIO_DEBUG_TABLE, "Gob on port\n");
553 PortP->TxBufferIn = PortP->TxBufferOut = 0; 524 PortP->TxBufferIn = PortP->TxBufferOut = 0;
554 /* What should I do 525 /* What should I do
555 wakeup( &PortP->TxBufferIn ); 526 wakeup( &PortP->TxBufferIn );
556 wakeup( &PortP->TxBufferOut); 527 wakeup( &PortP->TxBufferOut);
557 */ 528 */
558 PortP->InUse = NOT_INUSE; 529 PortP->InUse = NOT_INUSE;
559 /* What should I do 530 /* What should I do
560 wakeup( &PortP->InUse ); 531 wakeup( &PortP->InUse );
561 signal(PortP->TtyP->t_pgrp,SIGKILL); 532 signal(PortP->TtyP->t_pgrp,SIGKILL);
562 ttyflush(PortP->TtyP,(FREAD|FWRITE)); 533 ttyflush(PortP->TtyP,(FREAD|FWRITE));
563 */ 534 */
564 PortP->State |= RIO_CLOSING | RIO_DELETED; 535 PortP->State |= RIO_CLOSING | RIO_DELETED;
565 } 536 }
566 537
567 /* 538 /*
568 ** For the second slot of a 16 port RTA, the 539 ** For the second slot of a 16 port RTA, the
569 ** driver needs to reset the changes made to 540 ** driver needs to reset the changes made to
570 ** the phb to port mappings in RIORouteRup. 541 ** the phb to port mappings in RIORouteRup.
571 */ 542 */
572 if (PortP->SecondBlock) { 543 if (PortP->SecondBlock) {
573 ushort dest_unit = HostMapP->ID; 544 ushort dest_unit = HostMapP->ID;
574 ushort dest_port = port - SysPort; 545 ushort dest_port = port - SysPort;
575 WORD *TxPktP; 546 WORD *TxPktP;
576 PKT *Pkt; 547 PKT *Pkt;
577 548
578 for (TxPktP = PortP->TxStart; 549 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
579 TxPktP <= PortP->TxEnd; TxPktP++) {
580 /* 550 /*
581 ** *TxPktP is the pointer to the 551 ** *TxPktP is the pointer to the
582 ** transmit packet on the host card. 552 ** transmit packet on the host card.
583 ** This needs to be translated into 553 ** This needs to be translated into
584 ** a 32 bit pointer so it can be 554 ** a 32 bit pointer so it can be
585 ** accessed from the driver. 555 ** accessed from the driver.
586 */ 556 */
587 Pkt = (PKT *) RIO_PTR(HostP->Caddr, 557 Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP));
588 RWORD(*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);
589 rio_dprintk (RIO_DEBUG_TABLE,
590 "Tx packet (%x) destination: Old %x:%x New %x:%x\n",
591 *TxPktP, Pkt->dest_unit,
592 Pkt->dest_port, dest_unit, dest_port);
593 WWORD(Pkt->dest_unit, dest_unit); 559 WWORD(Pkt->dest_unit, dest_unit);
594 WWORD(Pkt->dest_port, dest_port); 560 WWORD(Pkt->dest_port, dest_port);
595 } 561 }
596 rio_dprintk (RIO_DEBUG_TABLE, 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);
597 "Port %d phb destination: Old %x:%x New %x:%x\n", 563 WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8));
598 port, PortP->PhbP->destination & 0xff,
599 (PortP->PhbP->destination >> 8) & 0xff,
600 dest_unit, dest_port);
601 WWORD(PortP->PhbP->destination,
602 dest_unit + (dest_port << 8));
603 } 564 }
604 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); 565 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
605 } 566 }
606 } 567 }
607 rio_dprintk (RIO_DEBUG_TABLE, "Entry nulled.\n"); 568 rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n");
608 bzero((char *)HostMapP,sizeof(struct Map)); 569 bzero((char *) HostMapP, sizeof(struct Map));
609 work_done++; 570 work_done++;
610 } 571 }
611 } 572 }
@@ -613,203 +574,178 @@ struct Map *MapP;
613 } 574 }
614 575
615 /* XXXXX lock me up */ 576 /* XXXXX lock me up */
616 for ( entry=0; entry< TOTAL_MAP_ENTRIES; entry++ ) { 577 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
617 if ( p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum ) { 578 if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
618 bzero((char *)&p->RIOSavedTable[entry],sizeof(struct Map)); 579 bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map));
619 work_done++; 580 work_done++;
620 } 581 }
621 if ( p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum ) { 582 if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
622 bzero((char *)&p->RIOConnectTable[entry],sizeof(struct Map)); 583 bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map));
623 work_done++; 584 work_done++;
624 } 585 }
625 } 586 }
626 if ( work_done ) 587 if (work_done)
627 return 0; 588 return 0;
628 589
629 rio_dprintk (RIO_DEBUG_TABLE, "Couldn't find entry to be deleted\n"); 590 rio_dprintk(RIO_DEBUG_TABLE, "Couldn't find entry to be deleted\n");
630 p->RIOError.Error = COULDNT_FIND_ENTRY; 591 p->RIOError.Error = COULDNT_FIND_ENTRY;
631 return -ENXIO; 592 return -ENXIO;
632} 593}
633 594
634int RIOAssignRta( struct rio_info *p, struct Map *MapP ) 595int RIOAssignRta(struct rio_info *p, struct Map *MapP)
635{ 596{
636 int host; 597 int host;
637 struct Map *HostMapP; 598 struct Map *HostMapP;
638 char *sptr; 599 char *sptr;
639 int link; 600 int link;
640 601
641 602
642 rio_dprintk (RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", 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);
643 MapP->HostUniqueNum,MapP->RtaUniqueNum, 604
644 MapP->ID, (int)MapP->SysPort); 605 if ((MapP->ID != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
645 606 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
646 if ((MapP->ID != (ushort)-1) && 607 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
647 ((int)MapP->ID < (int)1 || (int)MapP->ID > MAX_RUP )) 608 return -EINVAL;
648 { 609 }
649 rio_dprintk (RIO_DEBUG_TABLE, "Bad ID in map entry!\n"); 610 if (MapP->RtaUniqueNum == 0) {
650 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE; 611 rio_dprintk(RIO_DEBUG_TABLE, "Rta Unique number zero!\n");
651 return -EINVAL; 612 p->RIOError.Error = RTA_UNIQUE_NUMBER_ZERO;
652 } 613 return -EINVAL;
653 if (MapP->RtaUniqueNum == 0) 614 }
654 { 615 if ((MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA)) {
655 rio_dprintk (RIO_DEBUG_TABLE, "Rta Unique number zero!\n"); 616 rio_dprintk(RIO_DEBUG_TABLE, "Port %d not multiple of %d!\n", (int) MapP->SysPort, PORTS_PER_RTA);
656 p->RIOError.Error = RTA_UNIQUE_NUMBER_ZERO; 617 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
657 return -EINVAL; 618 return -EINVAL;
658 } 619 }
659 if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort % PORTS_PER_RTA) ) 620 if ((MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS)) {
660 { 621 rio_dprintk(RIO_DEBUG_TABLE, "Port %d not valid!\n", (int) MapP->SysPort);
661 rio_dprintk (RIO_DEBUG_TABLE, "Port %d not multiple of %d!\n",(int)MapP->SysPort,PORTS_PER_RTA); 622 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE;
662 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE; 623 return -EINVAL;
663 return -EINVAL; 624 }
664 } 625
665 if ( (MapP->SysPort != NO_PORT) && (MapP->SysPort >= RIO_PORTS) ) 626 /*
666 { 627 ** Copy the name across to the map entry.
667 rio_dprintk (RIO_DEBUG_TABLE, "Port %d not valid!\n",(int)MapP->SysPort); 628 */
668 p->RIOError.Error = TTY_NUMBER_OUT_OF_RANGE; 629 MapP->Name[MAX_NAME_LEN - 1] = '\0';
669 return -EINVAL; 630 sptr = MapP->Name;
670 } 631 while (*sptr) {
671 632 if (*sptr < ' ' || *sptr > '~') {
672 /* 633 rio_dprintk(RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
673 ** Copy the name across to the map entry. 634 p->RIOError.Error = BAD_CHARACTER_IN_NAME;
674 */ 635 return -EINVAL;
675 MapP->Name[MAX_NAME_LEN-1] = '\0';
676 sptr = MapP->Name;
677 while ( *sptr )
678 {
679 if ( *sptr<' ' || *sptr>'~' )
680 {
681 rio_dprintk (RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
682 p->RIOError.Error = BAD_CHARACTER_IN_NAME;
683 return -EINVAL;
684 }
685 sptr++;
686 }
687
688 for ( host=0; host < p->RIONumHosts; host++ )
689 {
690 if ( MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum )
691 {
692 if ( (p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING )
693 {
694 p->RIOError.Error = HOST_NOT_RUNNING;
695 return -ENXIO;
696 }
697
698 /*
699 ** Now we have a host we need to allocate an ID
700 ** if the entry does not already have one.
701 */
702 if (MapP->ID == (ushort)-1)
703 {
704 int nNewID;
705
706 rio_dprintk (RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n",
707 MapP->Name);
708 /*
709 ** The idea here is to allow RTA's to be assigned
710 ** before they actually appear on the network.
711 ** This allows the addition of RTA's without having
712 ** to plug them in.
713 ** What we do is:
714 ** - Find a free ID and allocate it to the RTA.
715 ** - If this map entry is the second half of a
716 ** 16 port entry then find the other half and
717 ** make sure the 2 cross reference each other.
718 */
719 if (RIOFindFreeID(p, &p->RIOHosts[host], &nNewID, NULL) != 0)
720 {
721 p->RIOError.Error = COULDNT_FIND_ENTRY;
722 return -EBUSY;
723 }
724 MapP->ID = (ushort)nNewID + 1;
725 rio_dprintk (RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
726 HostMapP = &p->RIOHosts[host].Mapping[nNewID];
727 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
728 HostMapP->HostUniqueNum = MapP->HostUniqueNum;
729 HostMapP->ID = MapP->ID;
730 for (link = 0; link < LINKS_PER_UNIT; link++)
731 {
732 HostMapP->Topology[link].Unit = ROUTE_DISCONNECT;
733 HostMapP->Topology[link].Link = NO_LINK;
734 }
735 if (MapP->Flags & RTA16_SECOND_SLOT)
736 {
737 int unit;
738
739 for (unit = 0; unit < MAX_RUP; unit++)
740 if (p->RIOHosts[host].Mapping[unit].RtaUniqueNum ==
741 MapP->RtaUniqueNum)
742 break;
743 if (unit == MAX_RUP)
744 {
745 p->RIOError.Error = COULDNT_FIND_ENTRY;
746 return -EBUSY;
747 }
748 HostMapP->Flags |= RTA16_SECOND_SLOT;
749 HostMapP->ID2 = MapP->ID2 = p->RIOHosts[host].Mapping[unit].ID;
750 p->RIOHosts[host].Mapping[unit].ID2 = MapP->ID;
751 rio_dprintk (RIO_DEBUG_TABLE, "Cross referenced id %d to ID %d.\n",
752 MapP->ID,
753 p->RIOHosts[host].Mapping[unit].ID);
754 } 636 }
755 } 637 sptr++;
638 }
639
640 for (host = 0; host < p->RIONumHosts; host++) {
641 if (MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum) {
642 if ((p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING) {
643 p->RIOError.Error = HOST_NOT_RUNNING;
644 return -ENXIO;
645 }
756 646
757 HostMapP = &p->RIOHosts[host].Mapping[MapP->ID-1]; 647 /*
648 ** Now we have a host we need to allocate an ID
649 ** if the entry does not already have one.
650 */
651 if (MapP->ID == (ushort) - 1) {
652 int nNewID;
758 653
759 if ( HostMapP->Flags & SLOT_IN_USE ) 654 rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name);
760 { 655 /*
761 rio_dprintk (RIO_DEBUG_TABLE, "Map table slot for ID %d is already in use.\n", MapP->ID); 656 ** The idea here is to allow RTA's to be assigned
762 p->RIOError.Error = ID_ALREADY_IN_USE; 657 ** before they actually appear on the network.
763 return -EBUSY; 658 ** This allows the addition of RTA's without having
764 } 659 ** to plug them in.
765 660 ** What we do is:
766 /* 661 ** - Find a free ID and allocate it to the RTA.
767 ** Assign the sys ports and the name, and mark the slot as 662 ** - If this map entry is the second half of a
768 ** being in use. 663 ** 16 port entry then find the other half and
769 */ 664 ** make sure the 2 cross reference each other.
770 HostMapP->SysPort = MapP->SysPort; 665 */
771 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) 666 if (RIOFindFreeID(p, &p->RIOHosts[host], &nNewID, NULL) != 0) {
772 CCOPY( MapP->Name, HostMapP->Name, MAX_NAME_LEN ); 667 p->RIOError.Error = COULDNT_FIND_ENTRY;
773 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED; 668 return -EBUSY;
669 }
670 MapP->ID = (ushort) nNewID + 1;
671 rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
672 HostMapP = &p->RIOHosts[host].Mapping[nNewID];
673 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
674 HostMapP->HostUniqueNum = MapP->HostUniqueNum;
675 HostMapP->ID = MapP->ID;
676 for (link = 0; link < LINKS_PER_UNIT; link++) {
677 HostMapP->Topology[link].Unit = ROUTE_DISCONNECT;
678 HostMapP->Topology[link].Link = NO_LINK;
679 }
680 if (MapP->Flags & RTA16_SECOND_SLOT) {
681 int unit;
682
683 for (unit = 0; unit < MAX_RUP; unit++)
684 if (p->RIOHosts[host].Mapping[unit].RtaUniqueNum == MapP->RtaUniqueNum)
685 break;
686 if (unit == MAX_RUP) {
687 p->RIOError.Error = COULDNT_FIND_ENTRY;
688 return -EBUSY;
689 }
690 HostMapP->Flags |= RTA16_SECOND_SLOT;
691 HostMapP->ID2 = MapP->ID2 = p->RIOHosts[host].Mapping[unit].ID;
692 p->RIOHosts[host].Mapping[unit].ID2 = MapP->ID;
693 rio_dprintk(RIO_DEBUG_TABLE, "Cross referenced id %d to ID %d.\n", MapP->ID, p->RIOHosts[host].Mapping[unit].ID);
694 }
695 }
696
697 HostMapP = &p->RIOHosts[host].Mapping[MapP->ID - 1];
698
699 if (HostMapP->Flags & SLOT_IN_USE) {
700 rio_dprintk(RIO_DEBUG_TABLE, "Map table slot for ID %d is already in use.\n", MapP->ID);
701 p->RIOError.Error = ID_ALREADY_IN_USE;
702 return -EBUSY;
703 }
704
705 /*
706 ** Assign the sys ports and the name, and mark the slot as
707 ** being in use.
708 */
709 HostMapP->SysPort = MapP->SysPort;
710 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
711 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
712 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;
774#ifdef NEED_TO_FIX 713#ifdef NEED_TO_FIX
775 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID-1]); 714 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]);
776#endif 715#endif
777 if (MapP->Flags & RTA16_SECOND_SLOT) 716 if (MapP->Flags & RTA16_SECOND_SLOT)
778 HostMapP->Flags |= RTA16_SECOND_SLOT; 717 HostMapP->Flags |= RTA16_SECOND_SLOT;
779 718
780 RIOReMapPorts( p, &p->RIOHosts[host], HostMapP ); 719 RIOReMapPorts(p, &p->RIOHosts[host], HostMapP);
781 /* 720 /*
782 ** Adjust 2nd block of 8 phbs 721 ** Adjust 2nd block of 8 phbs
783 */ 722 */
784 if (MapP->Flags & RTA16_SECOND_SLOT) 723 if (MapP->Flags & RTA16_SECOND_SLOT)
785 RIOFixPhbs(p, &p->RIOHosts[host], HostMapP->ID - 1); 724 RIOFixPhbs(p, &p->RIOHosts[host], HostMapP->ID - 1);
786 725
787 if ( HostMapP->SysPort != NO_PORT ) 726 if (HostMapP->SysPort != NO_PORT) {
788 { 727 if (HostMapP->SysPort < p->RIOFirstPortsBooted)
789 if ( HostMapP->SysPort < p->RIOFirstPortsBooted ) 728 p->RIOFirstPortsBooted = HostMapP->SysPort;
790 p->RIOFirstPortsBooted = HostMapP->SysPort; 729 if (HostMapP->SysPort > p->RIOLastPortsBooted)
791 if ( HostMapP->SysPort > p->RIOLastPortsBooted ) 730 p->RIOLastPortsBooted = HostMapP->SysPort;
792 p->RIOLastPortsBooted = HostMapP->SysPort; 731 }
793 } 732 if (MapP->Flags & RTA16_SECOND_SLOT)
794 if (MapP->Flags & RTA16_SECOND_SLOT) 733 rio_dprintk(RIO_DEBUG_TABLE, "Second map of RTA %s added to configuration\n", p->RIOHosts[host].Mapping[MapP->ID2 - 1].Name);
795 rio_dprintk (RIO_DEBUG_TABLE, "Second map of RTA %s added to configuration\n", 734 else
796 p->RIOHosts[host].Mapping[MapP->ID2 - 1].Name); 735 rio_dprintk(RIO_DEBUG_TABLE, "RTA %s added to configuration\n", MapP->Name);
797 else 736 return 0;
798 rio_dprintk (RIO_DEBUG_TABLE, "RTA %s added to configuration\n", MapP->Name); 737 }
799 return 0;
800 } 738 }
801 } 739 p->RIOError.Error = UNKNOWN_HOST_NUMBER;
802 p->RIOError.Error = UNKNOWN_HOST_NUMBER; 740 rio_dprintk(RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
803 rio_dprintk (RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum); 741 return -ENXIO;
804 return -ENXIO;
805} 742}
806 743
807 744
808int 745int RIOReMapPorts(p, HostP, HostMapP)
809RIOReMapPorts(p, HostP, HostMapP) 746struct rio_info *p;
810struct rio_info * p;
811struct Host *HostP; 747struct Host *HostP;
812struct Map *HostMapP; 748struct Map *HostMapP;
813{ 749{
814 register struct Port *PortP; 750 register struct Port *PortP;
815 uint SubEnt; 751 uint SubEnt;
@@ -819,135 +755,127 @@ struct Map *HostMapP;
819 unsigned long flags; 755 unsigned long flags;
820 756
821#ifdef CHECK 757#ifdef CHECK
822 CheckHostP( HostP ); 758 CheckHostP(HostP);
823 CheckHostMapP( HostMapP ); 759 CheckHostMapP(HostMapP);
824#endif 760#endif
825 761
826 rio_dprintk (RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int)HostMapP->SysPort, HostMapP->ID); 762 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID);
827 763
828 /* 764 /*
829 ** We need to tell the UnixRups which sysport the rup corresponds to 765 ** We need to tell the UnixRups which sysport the rup corresponds to
830 */ 766 */
831 HostP->UnixRups[HostMapP->ID-1].BaseSysPort = HostMapP->SysPort; 767 HostP->UnixRups[HostMapP->ID - 1].BaseSysPort = HostMapP->SysPort;
832 768
833 if ( HostMapP->SysPort == NO_PORT ) 769 if (HostMapP->SysPort == NO_PORT)
834 return(0); 770 return (0);
835 771
836 RtaType = GetUnitType(HostMapP->RtaUniqueNum); 772 RtaType = GetUnitType(HostMapP->RtaUniqueNum);
837 rio_dprintk (RIO_DEBUG_TABLE, "Mapping sysport %d-%d\n", 773 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d-%d\n", (int) HostMapP->SysPort, (int) HostMapP->SysPort + PORTS_PER_RTA - 1);
838 (int)HostMapP->SysPort, (int)HostMapP->SysPort+PORTS_PER_RTA-1);
839 774
840 /* 775 /*
841 ** now map each of its eight ports 776 ** now map each of its eight ports
842 */ 777 */
843 for ( SubEnt=0; SubEnt<PORTS_PER_RTA; SubEnt++) { 778 for (SubEnt = 0; SubEnt < PORTS_PER_RTA; SubEnt++) {
844 rio_dprintk (RIO_DEBUG_TABLE, "subent = %d, HostMapP->SysPort = %d\n", 779 rio_dprintk(RIO_DEBUG_TABLE, "subent = %d, HostMapP->SysPort = %d\n", SubEnt, (int) HostMapP->SysPort);
845 SubEnt, (int)HostMapP->SysPort); 780 SysPort = HostMapP->SysPort + SubEnt; /* portnumber within system */
846 SysPort = HostMapP->SysPort+SubEnt; /* portnumber within system */ 781 /* portnumber on host */
847 /* portnumber on host */ 782
848 783 HostPort = (HostMapP->ID - 1) * PORTS_PER_RTA + SubEnt;
849 HostPort = (HostMapP->ID-1)*PORTS_PER_RTA+SubEnt; 784
850 785 rio_dprintk(RIO_DEBUG_TABLE, "c1 p = %p, p->rioPortp = %p\n", p, p->RIOPortp);
851 rio_dprintk (RIO_DEBUG_TABLE, "c1 p = %p, p->rioPortp = %p\n", p, p->RIOPortp);
852 PortP = p->RIOPortp[SysPort]; 786 PortP = p->RIOPortp[SysPort];
853#if 0 787#if 0
854 PortP->TtyP = &p->channel[SysPort]; 788 PortP->TtyP = &p->channel[SysPort];
855#endif 789#endif
856 rio_dprintk (RIO_DEBUG_TABLE, "Map port\n"); 790 rio_dprintk(RIO_DEBUG_TABLE, "Map port\n");
857 791
858 /* 792 /*
859 ** Point at all the real neat data structures 793 ** Point at all the real neat data structures
860 */ 794 */
861 rio_spin_lock_irqsave(&PortP->portSem, flags); 795 rio_spin_lock_irqsave(&PortP->portSem, flags);
862 PortP->HostP = HostP; 796 PortP->HostP = HostP;
863 PortP->Caddr = HostP->Caddr; 797 PortP->Caddr = HostP->Caddr;
864 798
865 /* 799 /*
866 ** The PhbP cannot be filled in yet 800 ** The PhbP cannot be filled in yet
867 ** unless the host has been booted 801 ** unless the host has been booted
868 */ 802 */
869 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { 803 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
870 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; 804 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
871 PortP->TxAdd =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->tx_add)); 805 PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add));
872 PortP->TxStart =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->tx_start)); 806 PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start));
873 PortP->TxEnd =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->tx_end)); 807 PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end));
874 PortP->RxRemove=(WORD *)RIO_PTR(HostP->Caddr, 808 PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove));
875 RWORD(PhbP->rx_remove)); 809 PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start));
876 PortP->RxStart =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->rx_start)); 810 PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end));
877 PortP->RxEnd =(WORD *)RIO_PTR(HostP->Caddr,RWORD(PhbP->rx_end)); 811 } else
878 }
879 else
880 PortP->PhbP = NULL; 812 PortP->PhbP = NULL;
881 813
882 /* 814 /*
883 ** port related flags 815 ** port related flags
884 */ 816 */
885 PortP->HostPort = HostPort; 817 PortP->HostPort = HostPort;
886 /* 818 /*
887 ** For each part of a 16 port RTA, RupNum is ID - 1. 819 ** For each part of a 16 port RTA, RupNum is ID - 1.
888 */ 820 */
889 PortP->RupNum = HostMapP->ID - 1; 821 PortP->RupNum = HostMapP->ID - 1;
890 if (HostMapP->Flags & RTA16_SECOND_SLOT) { 822 if (HostMapP->Flags & RTA16_SECOND_SLOT) {
891 PortP->ID2 = HostMapP->ID2 - 1; 823 PortP->ID2 = HostMapP->ID2 - 1;
892 PortP->SecondBlock = TRUE; 824 PortP->SecondBlock = TRUE;
893 } 825 } else {
894 else { 826 PortP->ID2 = 0;
895 PortP->ID2 = 0; 827 PortP->SecondBlock = FALSE;
896 PortP->SecondBlock = FALSE;
897 } 828 }
898 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum; 829 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;
899 830
900 /* 831 /*
901 ** If the port was already mapped then thats all we need to do. 832 ** If the port was already mapped then thats all we need to do.
902 */ 833 */
903 if (PortP->Mapped) { 834 if (PortP->Mapped) {
904 rio_spin_unlock_irqrestore( &PortP->portSem, flags); 835 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
905 continue; 836 continue;
906 } 837 } else
907 else HostMapP->Flags &= ~RTA_NEWBOOT; 838 HostMapP->Flags &= ~RTA_NEWBOOT;
908 839
909 PortP->State = 0; 840 PortP->State = 0;
910 PortP->Config = 0; 841 PortP->Config = 0;
911 /* 842 /*
912 ** Check out the module type - if it is special (read only etc.) 843 ** Check out the module type - if it is special (read only etc.)
913 ** then we need to set flags in the PortP->Config. 844 ** then we need to set flags in the PortP->Config.
914 ** Note: For 16 port RTA, all ports are of the same type. 845 ** Note: For 16 port RTA, all ports are of the same type.
915 */ 846 */
916 if (RtaType == TYPE_RTA16) { 847 if (RtaType == TYPE_RTA16) {
917 PortP->Config |= p->RIOModuleTypes[HostP->UnixRups 848 PortP->Config |= p->RIOModuleTypes[HostP->UnixRups[HostMapP->ID - 1].ModTypes].Flags[SubEnt % PORTS_PER_MODULE];
918 [HostMapP->ID-1].ModTypes].Flags[SubEnt % PORTS_PER_MODULE];
919 } else { 849 } else {
920 if ( SubEnt < PORTS_PER_MODULE ) 850 if (SubEnt < PORTS_PER_MODULE)
921 PortP->Config |= p->RIOModuleTypes[LONYBLE(HostP->UnixRups 851 PortP->Config |= p->RIOModuleTypes[LONYBLE(HostP->UnixRups[HostMapP->ID - 1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
922 [HostMapP->ID-1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
923 else 852 else
924 PortP->Config |= p->RIOModuleTypes[HINYBLE(HostP->UnixRups 853 PortP->Config |= p->RIOModuleTypes[HINYBLE(HostP->UnixRups[HostMapP->ID - 1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
925 [HostMapP->ID-1].ModTypes)].Flags[SubEnt % PORTS_PER_MODULE];
926 } 854 }
927 855
928 /* 856 /*
929 ** more port related flags 857 ** more port related flags
930 */ 858 */
931 PortP->PortState = 0; 859 PortP->PortState = 0;
932 PortP->ModemLines = 0; 860 PortP->ModemLines = 0;
933 PortP->ModemState = 0; 861 PortP->ModemState = 0;
934 PortP->CookMode = COOK_WELL; 862 PortP->CookMode = COOK_WELL;
935 PortP->ParamSem = 0; 863 PortP->ParamSem = 0;
936 PortP->FlushCmdBodge= 0; 864 PortP->FlushCmdBodge = 0;
937 PortP->WflushFlag = 0; 865 PortP->WflushFlag = 0;
938 PortP->MagicFlags = 0; 866 PortP->MagicFlags = 0;
939 PortP->Lock = 0; 867 PortP->Lock = 0;
940 PortP->Store = 0; 868 PortP->Store = 0;
941 PortP->FirstOpen = 1; 869 PortP->FirstOpen = 1;
942 870
943 /* 871 /*
944 ** Buffers 'n things 872 ** Buffers 'n things
945 */ 873 */
946 PortP->RxDataStart = 0; 874 PortP->RxDataStart = 0;
947 PortP->Cor2Copy = 0; 875 PortP->Cor2Copy = 0;
948 PortP->Name = &HostMapP->Name[0]; 876 PortP->Name = &HostMapP->Name[0];
949#ifdef STATS 877#ifdef STATS
950 bzero( (caddr_t)&PortP->Stat, sizeof(struct RIOStats) ); 878 bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats));
951#endif 879#endif
952 PortP->statsGather = 0; 880 PortP->statsGather = 0;
953 PortP->txchars = 0; 881 PortP->txchars = 0;
@@ -955,90 +883,87 @@ struct Map *HostMapP;
955 PortP->opens = 0; 883 PortP->opens = 0;
956 PortP->closes = 0; 884 PortP->closes = 0;
957 PortP->ioctls = 0; 885 PortP->ioctls = 0;
958 if ( PortP->TxRingBuffer ) 886 if (PortP->TxRingBuffer)
959 bzero( PortP->TxRingBuffer, p->RIOBufferSize ); 887 bzero(PortP->TxRingBuffer, p->RIOBufferSize);
960 else if ( p->RIOBufferSize ) { 888 else if (p->RIOBufferSize) {
961 PortP->TxRingBuffer = sysbrk(p->RIOBufferSize); 889 PortP->TxRingBuffer = sysbrk(p->RIOBufferSize);
962 bzero( PortP->TxRingBuffer, p->RIOBufferSize ); 890 bzero(PortP->TxRingBuffer, p->RIOBufferSize);
963 } 891 }
964 PortP->TxBufferOut = 0; 892 PortP->TxBufferOut = 0;
965 PortP->TxBufferIn = 0; 893 PortP->TxBufferIn = 0;
966 PortP->Debug = 0; 894 PortP->Debug = 0;
967 /* 895 /*
968 ** LastRxTgl stores the state of the rx toggle bit for this 896 ** LastRxTgl stores the state of the rx toggle bit for this
969 ** port, to be compared with the state of the next pkt received. 897 ** port, to be compared with the state of the next pkt received.
970 ** If the same, we have received the same rx pkt from the RTA 898 ** If the same, we have received the same rx pkt from the RTA
971 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0. 899 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
972 */ 900 */
973 PortP->LastRxTgl = ~(uchar)PHB_RX_TGL; 901 PortP->LastRxTgl = ~(uchar) PHB_RX_TGL;
974 902
975 /* 903 /*
976 ** and mark the port as usable 904 ** and mark the port as usable
977 */ 905 */
978 PortP->Mapped = 1; 906 PortP->Mapped = 1;
979 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 907 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
980 } 908 }
981 if ( HostMapP->SysPort < p->RIOFirstPortsMapped ) 909 if (HostMapP->SysPort < p->RIOFirstPortsMapped)
982 p->RIOFirstPortsMapped = HostMapP->SysPort; 910 p->RIOFirstPortsMapped = HostMapP->SysPort;
983 if ( HostMapP->SysPort > p->RIOLastPortsMapped ) 911 if (HostMapP->SysPort > p->RIOLastPortsMapped)
984 p->RIOLastPortsMapped = HostMapP->SysPort; 912 p->RIOLastPortsMapped = HostMapP->SysPort;
985 913
986 return 0; 914 return 0;
987} 915}
988 916
989int 917int RIOChangeName(p, MapP)
990RIOChangeName(p, MapP)
991struct rio_info *p; 918struct rio_info *p;
992struct Map* MapP; 919struct Map *MapP;
993{ 920{
994 int host; 921 int host;
995 struct Map *HostMapP; 922 struct Map *HostMapP;
996 char *sptr; 923 char *sptr;
997 924
998 rio_dprintk (RIO_DEBUG_TABLE, "Change name entry on host %x, rta %x, ID %d, Sysport %d\n", 925 rio_dprintk(RIO_DEBUG_TABLE, "Change name entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort);
999 MapP->HostUniqueNum,MapP->RtaUniqueNum,
1000 MapP->ID, (int)MapP->SysPort);
1001 926
1002 if ( MapP->ID > MAX_RUP ) { 927 if (MapP->ID > MAX_RUP) {
1003 rio_dprintk (RIO_DEBUG_TABLE, "Bad ID in map entry!\n"); 928 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
1004 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE; 929 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
1005 return -EINVAL; 930 return -EINVAL;
1006 } 931 }
1007 932
1008 MapP->Name[MAX_NAME_LEN-1] = '\0'; 933 MapP->Name[MAX_NAME_LEN - 1] = '\0';
1009 sptr = MapP->Name; 934 sptr = MapP->Name;
1010 935
1011 while ( *sptr ) { 936 while (*sptr) {
1012 if ( *sptr<' ' || *sptr>'~' ) { 937 if (*sptr < ' ' || *sptr > '~') {
1013 rio_dprintk (RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n"); 938 rio_dprintk(RIO_DEBUG_TABLE, "Name entry contains non-printing characters!\n");
1014 p->RIOError.Error = BAD_CHARACTER_IN_NAME; 939 p->RIOError.Error = BAD_CHARACTER_IN_NAME;
1015 return -EINVAL; 940 return -EINVAL;
1016 } 941 }
1017 sptr++; 942 sptr++;
1018 } 943 }
1019 944
1020 for ( host=0; host < p->RIONumHosts; host++ ) { 945 for (host = 0; host < p->RIONumHosts; host++) {
1021 if ( MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum ) { 946 if (MapP->HostUniqueNum == p->RIOHosts[host].UniqueNum) {
1022 if ( (p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING ) { 947 if ((p->RIOHosts[host].Flags & RUN_STATE) != RC_RUNNING) {
1023 p->RIOError.Error = HOST_NOT_RUNNING; 948 p->RIOError.Error = HOST_NOT_RUNNING;
1024 return -ENXIO; 949 return -ENXIO;
1025 } 950 }
1026 if ( MapP->ID==0 ) { 951 if (MapP->ID == 0) {
1027 CCOPY( MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN ); 952 CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN);
1028 return 0; 953 return 0;
1029 } 954 }
1030 955
1031 HostMapP = &p->RIOHosts[host].Mapping[MapP->ID-1]; 956 HostMapP = &p->RIOHosts[host].Mapping[MapP->ID - 1];
1032 957
1033 if ( HostMapP->RtaUniqueNum != MapP->RtaUniqueNum ) { 958 if (HostMapP->RtaUniqueNum != MapP->RtaUniqueNum) {
1034 p->RIOError.Error = RTA_NUMBER_WRONG; 959 p->RIOError.Error = RTA_NUMBER_WRONG;
1035 return -ENXIO; 960 return -ENXIO;
1036 } 961 }
1037 CCOPY( MapP->Name, HostMapP->Name, MAX_NAME_LEN ); 962 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
1038 return 0; 963 return 0;
1039 } 964 }
1040 } 965 }
1041 p->RIOError.Error = UNKNOWN_HOST_NUMBER; 966 p->RIOError.Error = UNKNOWN_HOST_NUMBER;
1042 rio_dprintk (RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum); 967 rio_dprintk(RIO_DEBUG_TABLE, "Unknown host %x\n", MapP->HostUniqueNum);
1043 return -ENXIO; 968 return -ENXIO;
1044} 969}