blob: 9a96fc644e52c176351e2008f7767316748a6a17 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 : rioboot.c
24** SID : 1.3
25** Last Modified : 11/6/98 10:33:36
26** Retrieved : 11/6/98 10:33:48
27**
28** ident @(#)rioboot.c 1.3
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifdef SCCS_LABELS
34static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
35#endif
36
37#include <linux/module.h>
38#include <linux/slab.h>
39#include <linux/errno.h>
40#include <linux/interrupt.h>
41#include <asm/io.h>
42#include <asm/system.h>
43#include <asm/string.h>
44#include <asm/semaphore.h>
45
46
47#include <linux/termios.h>
48#include <linux/serial.h>
49
50#include <linux/generic_serial.h>
51
52
53
54#include "linux_compat.h"
55#include "rio_linux.h"
56#include "typdef.h"
57#include "pkt.h"
58#include "daemon.h"
59#include "rio.h"
60#include "riospace.h"
61#include "top.h"
62#include "cmdpkt.h"
63#include "map.h"
64#include "riotypes.h"
65#include "rup.h"
66#include "port.h"
67#include "riodrvr.h"
68#include "rioinfo.h"
69#include "func.h"
70#include "errors.h"
71#include "pci.h"
72
73#include "parmmap.h"
74#include "unixrup.h"
75#include "board.h"
76#include "host.h"
77#include "error.h"
78#include "phb.h"
79#include "link.h"
80#include "cmdblk.h"
81#include "route.h"
82
Alan Cox3b8e3f12006-03-24 03:18:24 -080083static int RIOBootComplete(struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Alan Cox3b8e3f12006-03-24 03:18:24 -080085static uchar RIOAtVec2Ctrl[] = {
86 /* 0 */ INTERRUPT_DISABLE,
87 /* 1 */ INTERRUPT_DISABLE,
88 /* 2 */ INTERRUPT_DISABLE,
89 /* 3 */ INTERRUPT_DISABLE,
90 /* 4 */ INTERRUPT_DISABLE,
91 /* 5 */ INTERRUPT_DISABLE,
92 /* 6 */ INTERRUPT_DISABLE,
93 /* 7 */ INTERRUPT_DISABLE,
94 /* 8 */ INTERRUPT_DISABLE,
95 /* 9 */ IRQ_9 | INTERRUPT_ENABLE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 /* 10 */ INTERRUPT_DISABLE,
Alan Cox3b8e3f12006-03-24 03:18:24 -080097 /* 11 */ IRQ_11 | INTERRUPT_ENABLE,
98 /* 12 */ IRQ_12 | INTERRUPT_ENABLE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 /* 13 */ INTERRUPT_DISABLE,
100 /* 14 */ INTERRUPT_DISABLE,
Alan Cox3b8e3f12006-03-24 03:18:24 -0800101 /* 15 */ IRQ_15 | INTERRUPT_ENABLE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102};
103
104/*
105** Load in the RTA boot code.
106*/
Alan Cox3b8e3f12006-03-24 03:18:24 -0800107int RIOBootCodeRTA(p, rbp)
108struct rio_info *p;
109struct DownLoad *rbp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
111 int offset;
112
Alan Cox3b8e3f12006-03-24 03:18:24 -0800113 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115 /* Linux doesn't allow you to disable interrupts during a
116 "copyin". (Crash when a pagefault occurs). */
117 /* disable(oldspl); */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800118
119 rio_dprintk(RIO_DEBUG_BOOT, "Data at user address 0x%x\n", (int) rbp->DataP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800122 ** Check that we have set asside enough memory for this
123 */
124 if (rbp->Count > SIXTY_FOUR_K) {
125 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 p->RIOError.Error = HOST_FILE_TOO_LARGE;
127 /* restore(oldspl); */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800128 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 return -ENOMEM;
130 }
131
Alan Cox3b8e3f12006-03-24 03:18:24 -0800132 if (p->RIOBooting) {
133 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 p->RIOError.Error = BOOT_IN_PROGRESS;
135 /* restore(oldspl); */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800136 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 return -EBUSY;
138 }
139
140 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800141 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary,
142 ** so calculate how far we have to move the data up the buffer
143 ** to achieve this.
144 */
145 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800148 ** Be clean, and clear the 'unused' portion of the boot buffer,
149 ** because it will (eventually) be part of the Rta run time environment
150 ** and so should be zeroed.
151 */
152 bzero((caddr_t) p->RIOBootPackets, offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800155 ** Copy the data from user space.
156 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
Alan Cox3b8e3f12006-03-24 03:18:24 -0800158 if (copyin((int) rbp->DataP, ((caddr_t) (p->RIOBootPackets)) + offset, rbp->Count) == COPYFAIL) {
159 rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 p->RIOError.Error = COPYIN_FAILED;
161 /* restore(oldspl); */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800162 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 return -EFAULT;
164 }
165
166 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800167 ** Make sure that our copy of the size includes that offset we discussed
168 ** earlier.
169 */
170 p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE;
171 p->RIOBootCount = rbp->Count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173 /* restore(oldspl); */
174 func_exit();
175 return 0;
176}
177
Alan Cox3b8e3f12006-03-24 03:18:24 -0800178void rio_start_card_running(struct Host *HostP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179{
Alan Cox3b8e3f12006-03-24 03:18:24 -0800180 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Alan Cox3b8e3f12006-03-24 03:18:24 -0800182 switch (HostP->Type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 case RIO_AT:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800184 rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n");
185 WBYTE(HostP->Control, BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 break;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800187
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188#ifdef FUTURE_RELEASE
189 case RIO_MCA:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800190 /*
191 ** MCA handles IRQ vectors differently, so we don't write
192 ** them to this register.
193 */
194 rio_dprintk(RIO_DEBUG_BOOT, "Start MCA card running\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 WBYTE(HostP->Control, McaTpBootFromRam | McaTpBusEnable | HostP->Mode);
196 break;
197
198 case RIO_EISA:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800199 /*
200 ** EISA is totally different and expects OUTBZs to turn it on.
201 */
202 rio_dprintk(RIO_DEBUG_BOOT, "Start EISA card running\n");
203 OUTBZ(HostP->Slot, EISA_CONTROL_PORT, HostP->Mode | RIOEisaVec2Ctrl[HostP->Ivec] | EISA_TP_RUN | EISA_TP_BUS_ENABLE | EISA_TP_BOOT_FROM_RAM);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 break;
205#endif
206
207 case RIO_PCI:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800208 /*
209 ** PCI is much the same as MCA. Everything is once again memory
210 ** mapped, so we are writing to memory registers instead of io
211 ** ports.
212 */
213 rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 WBYTE(HostP->Control, PCITpBootFromRam | PCITpBusEnable | HostP->Mode);
215 break;
216 default:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800217 rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 break;
219 }
220/*
221 printk (KERN_INFO "Done with starting the card\n");
222 func_exit ();
223*/
224 return;
225}
226
227/*
228** Load in the host boot code - load it directly onto all halted hosts
229** of the correct type.
230**
231** Put your rubber pants on before messing with this code - even the magic
232** numbers have trouble understanding what they are doing here.
233*/
Alan Cox3b8e3f12006-03-24 03:18:24 -0800234int RIOBootCodeHOST(p, rbp)
235struct rio_info *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236register struct DownLoad *rbp;
237{
238 register struct Host *HostP;
239 register caddr_t Cad;
240 register PARM_MAP *ParmMapP;
241 register int RupN;
242 int PortN;
243 uint host;
244 caddr_t StartP;
245 BYTE *DestP;
246 int wait_count;
247 ushort OldParmMap;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800248 ushort offset; /* It is very important that this is a ushort */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 /* uint byte; */
250 caddr_t DownCode = NULL;
251 unsigned long flags;
252
Alan Cox3b8e3f12006-03-24 03:18:24 -0800253 HostP = NULL; /* Assure the compiler we've initialized it */
254 for (host = 0; host < p->RIONumHosts; host++) {
255 rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 HostP = &p->RIOHosts[host];
Alan Cox3b8e3f12006-03-24 03:18:24 -0800257
258 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260
Alan Cox3b8e3f12006-03-24 03:18:24 -0800261 if ((HostP->Flags & RUN_STATE) != RC_WAITING) {
262 rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 continue;
264 }
265
266 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800267 ** Grab a 32 bit pointer to the card.
268 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 Cad = HostP->Caddr;
270
271 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800272 ** We are going to (try) and load in rbp->Count bytes.
273 ** The last byte will reside at p->RIOConf.HostLoadBase-1;
274 ** Therefore, we need to start copying at address
275 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count)
276 */
277 StartP = (caddr_t) & Cad[p->RIOConf.HostLoadBase - rbp->Count];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Alan Cox3b8e3f12006-03-24 03:18:24 -0800279 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is 0x%x\n", (int) Cad);
280 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is 0x%x\n", (int) StartP);
281 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
282 rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Alan Cox3b8e3f12006-03-24 03:18:24 -0800284 if (p->RIOConf.HostLoadBase < rbp->Count) {
285 rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 p->RIOError.Error = HOST_FILE_TOO_LARGE;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800287 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 return -EFBIG;
289 }
290 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800291 ** Ensure that the host really is stopped.
292 ** Disable it's external bus & twang its reset line.
293 */
294 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800297 ** Copy the data directly from user space to the SRAM.
298 ** This ain't going to be none too clever if the download
299 ** code is bigger than this segment.
300 */
301 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800304 ** PCI hostcard can't cope with 32 bit accesses and so need to copy
305 ** data to a local buffer, and then dripfeed the card.
306 */
307 if (HostP->Type == RIO_PCI) {
308 /* int offset; */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 DownCode = sysbrk(rbp->Count);
Alan Cox3b8e3f12006-03-24 03:18:24 -0800311 if (!DownCode) {
312 rio_dprintk(RIO_DEBUG_BOOT, "No system memory available\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800314 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 return -ENOMEM;
316 }
317 bzero(DownCode, rbp->Count);
318
Alan Cox3b8e3f12006-03-24 03:18:24 -0800319 if (copyin((int) rbp->DataP, DownCode, rbp->Count) == COPYFAIL) {
320 rio_dprintk(RIO_DEBUG_BOOT, "Bad copyin of host data\n");
321 sysfree(DownCode, rbp->Count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 p->RIOError.Error = COPYIN_FAILED;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800323 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 return -EFAULT;
325 }
326
Alan Cox3b8e3f12006-03-24 03:18:24 -0800327 HostP->Copy(DownCode, StartP, rbp->Count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Alan Cox3b8e3f12006-03-24 03:18:24 -0800329 sysfree(DownCode, rbp->Count);
330 } else if (copyin((int) rbp->DataP, StartP, rbp->Count) == COPYFAIL) {
331 rio_dprintk(RIO_DEBUG_BOOT, "Bad copyin of host data\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 p->RIOError.Error = COPYIN_FAILED;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800333 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 return -EFAULT;
335 }
336
Alan Cox3b8e3f12006-03-24 03:18:24 -0800337 rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800340 ** S T O P !
341 **
342 ** Upto this point the code has been fairly rational, and possibly
343 ** even straight forward. What follows is a pile of crud that will
344 ** magically turn into six bytes of transputer assembler. Normally
345 ** you would expect an array or something, but, being me, I have
346 ** chosen [been told] to use a technique whereby the startup code
347 ** will be correct if we change the loadbase for the code. Which
348 ** brings us onto another issue - the loadbase is the *end* of the
349 ** code, not the start.
350 **
351 ** If I were you I wouldn't start from here.
352 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800355 ** We now need to insert a short boot section into
356 ** the memory at the end of Sram2. This is normally (de)composed
357 ** of the last eight bytes of the download code. The
358 ** download has been assembled/compiled to expect to be
359 ** loaded from 0x7FFF downwards. We have loaded it
360 ** at some other address. The startup code goes into the small
361 ** ram window at Sram2, in the last 8 bytes, which are really
362 ** at addresses 0x7FF8-0x7FFF.
363 **
364 ** If the loadbase is, say, 0x7C00, then we need to branch to
365 ** address 0x7BFE to run the host.bin startup code. We assemble
366 ** this jump manually.
367 **
368 ** The two byte sequence 60 08 is loaded into memory at address
369 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0,
370 ** which adds '0' to the .O register, complements .O, and then shifts
371 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will
372 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new
373 ** location. Now, the branch starts from the value of .PC (or .IP or
374 ** whatever the bloody register is called on this chip), and the .PC
375 ** will be pointing to the location AFTER the branch, in this case
376 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8.
377 **
378 ** A long branch is coded at 0x7FF8. This consists of loading a four
379 ** byte offset into .O using nfix (as above) and pfix operators. The
380 ** pfix operates in exactly the same way as the nfix operator, but
381 ** without the complement operation. The offset, of course, must be
382 ** relative to the address of the byte AFTER the branch instruction,
383 ** which will be (urm) 0x7FFC, so, our final destination of the branch
384 ** (loadbase-2), has to be reached from here. Imagine that the loadbase
385 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which
386 ** is the first byte of the initial two byte short local branch of the
387 ** download code).
388 **
389 ** To code a jump from 0x7FFC (which is where the branch will start
390 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)=
391 ** 0x7BFE.
392 ** This will be coded as four bytes:
393 ** 60 2C 20 02
394 ** being nfix .O+0
395 ** pfix .O+C
396 ** pfix .O+0
397 ** jump .O+2
398 **
399 ** The nfix operator is used, so that the startup code will be
400 ** compatible with the whole Tp family. (lies, damn lies, it'll never
401 ** work in a month of Sundays).
402 **
403 ** The nfix nyble is the 1s complement of the nyble value you
404 ** want to load - in this case we wanted 'F' so we nfix loaded '0'.
405 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
407
408 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800409 ** Dest points to the top 8 bytes of Sram2. The Tp jumps
410 ** to 0x7FFE at reset time, and starts executing. This is
411 ** a short branch to 0x7FF8, where a long branch is coded.
412 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
Alan Cox3b8e3f12006-03-24 03:18:24 -0800414 DestP = (BYTE *) & Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415
416#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */
417#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800418#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
420 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800421 ** 0x7FFC is the address of the location following the last byte of
422 ** the four byte jump instruction.
423 ** READ THE ABOVE COMMENTS
424 **
425 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about.
426 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned,
427 ** cos I don't understand 2's complement).
428 */
429 offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC;
430 WBYTE(DestP[0], NFIX(((ushort) (~offset) >> (ushort) 12) & 0xF));
431 WBYTE(DestP[1], PFIX((offset >> 8) & 0xF));
432 WBYTE(DestP[2], PFIX((offset >> 4) & 0xF));
433 WBYTE(DestP[3], JUMP(offset & 0xF));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
Alan Cox3b8e3f12006-03-24 03:18:24 -0800435 WBYTE(DestP[6], NFIX(0));
436 WBYTE(DestP[7], JUMP(8));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Alan Cox3b8e3f12006-03-24 03:18:24 -0800438 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
439 rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
441 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800442 ** Flag what is going on
443 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 HostP->Flags &= ~RUN_STATE;
445 HostP->Flags |= RC_STARTUP;
446
447 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800448 ** Grab a copy of the current ParmMap pointer, so we
449 ** can tell when it has changed.
450 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 OldParmMap = RWORD(HostP->__ParmMapR);
452
Alan Cox3b8e3f12006-03-24 03:18:24 -0800453 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
455 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800456 ** And start it running (I hope).
457 ** As there is nothing dodgy or obscure about the
458 ** above code, this is guaranteed to work every time.
459 */
460 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
462 rio_start_card_running(HostP);
463
Alan Cox3b8e3f12006-03-24 03:18:24 -0800464 rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465
466 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800467 ** Now, wait for upto five seconds for the Tp to setup the parmmap
468 ** pointer:
469 */
470 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (RWORD(HostP->__ParmMapR) == OldParmMap); wait_count++) {
471 rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, RWORD(HostP->__ParmMapR));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 delay(HostP, HUNDRED_MS);
473
474 }
475
476 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800477 ** If the parmmap pointer is unchanged, then the host code
478 ** has crashed & burned in a really spectacular way
479 */
480 if (RWORD(HostP->__ParmMapR) == OldParmMap) {
481 rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", RWORD(HostP->__ParmMapR));
482 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
483 HostP->Flags &= ~RUN_STATE;
484 HostP->Flags |= RC_STUFFED;
485 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
486 continue}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
Alan Cox3b8e3f12006-03-24 03:18:24 -0800488 rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", RWORD(HostP->__ParmMapR));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
490 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800491 ** Well, the board thought it was OK, and setup its parmmap
492 ** pointer. For the time being, we will pretend that this
493 ** board is running, and check out what the error flag says.
494 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
496 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800497 ** Grab a 32 bit pointer to the parmmap structure
498 */
499 ParmMapP = (PARM_MAP *) RIO_PTR(Cad, RWORD(HostP->__ParmMapR));
500 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int) ParmMapP);
501 ParmMapP = (PARM_MAP *) ((unsigned long) Cad + (unsigned long) ((RWORD((HostP->__ParmMapR))) & 0xFFFF));
502 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int) ParmMapP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800505 ** The links entry should be 0xFFFF; we set it up
506 ** with a mask to say how many PHBs to use, and
507 ** which links to use.
508 */
509 if ((RWORD(ParmMapP->links) & 0xFFFF) != 0xFFFF) {
510 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
511 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", RWORD(ParmMapP->links));
512 HostP->Flags &= ~RUN_STATE;
513 HostP->Flags |= RC_STUFFED;
514 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
515 continue}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516
Alan Cox3b8e3f12006-03-24 03:18:24 -0800517 WWORD(ParmMapP->links, RIO_LINK_ENABLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
519 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800520 ** now wait for the card to set all the parmmap->XXX stuff
521 ** this is a wait of upto two seconds....
522 */
523 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 HostP->timeout_id = 0;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800525 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !RWORD(ParmMapP->init_done); wait_count++) {
526 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 delay(HostP, HUNDRED_MS);
528 }
Alan Cox3b8e3f12006-03-24 03:18:24 -0800529 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
Alan Cox3b8e3f12006-03-24 03:18:24 -0800531 if (RWORD(ParmMapP->error) != E_NO_ERROR || !RWORD(ParmMapP->init_done)) {
532 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
533 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
534 HostP->Flags &= ~RUN_STATE;
535 HostP->Flags |= RC_STUFFED;
536 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
537 continue}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538
Alan Cox3b8e3f12006-03-24 03:18:24 -0800539 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540
541 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800542 ** It runs! It runs!
543 */
544 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
546 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800547 ** set the time period between interrupts.
548 */
549 WWORD(ParmMapP->timer, (short) p->RIOConf.Timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550
551 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800552 ** Translate all the 16 bit pointers in the __ParmMapR into
553 ** 32 bit pointers for the driver.
554 */
555 HostP->ParmMapP = ParmMapP;
556 HostP->PhbP = (PHB *) RIO_PTR(Cad, RWORD(ParmMapP->phb_ptr));
557 HostP->RupP = (RUP *) RIO_PTR(Cad, RWORD(ParmMapP->rups));
558 HostP->PhbNumP = (ushort *) RIO_PTR(Cad, RWORD(ParmMapP->phb_num_ptr));
559 HostP->LinkStrP = (LPB *) RIO_PTR(Cad, RWORD(ParmMapP->link_str_ptr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560
561 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800562 ** point the UnixRups at the real Rups
563 */
564 for (RupN = 0; RupN < MAX_RUP; RupN++) {
565 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
566 HostP->UnixRups[RupN].Id = RupN + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
568 spin_lock_init(&HostP->UnixRups[RupN].RupLock);
569 }
570
Alan Cox3b8e3f12006-03-24 03:18:24 -0800571 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
572 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
573 HostP->UnixRups[RupN + MAX_RUP].Id = 0;
574 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
575 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 }
577
578 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800579 ** point the PortP->Phbs at the real Phbs
580 */
581 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
582 if (p->RIOPortp[PortN]->HostP == HostP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 struct Port *PortP = p->RIOPortp[PortN];
584 struct PHB *PhbP;
585 /* int oldspl; */
586
Alan Cox3b8e3f12006-03-24 03:18:24 -0800587 if (!PortP->Mapped)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 continue;
589
590 PhbP = &HostP->PhbP[PortP->HostPort];
591 rio_spin_lock_irqsave(&PortP->portSem, flags);
592
593 PortP->PhbP = PhbP;
594
Alan Cox3b8e3f12006-03-24 03:18:24 -0800595 PortP->TxAdd = (WORD *) RIO_PTR(Cad, RWORD(PhbP->tx_add));
596 PortP->TxStart = (WORD *) RIO_PTR(Cad, RWORD(PhbP->tx_start));
597 PortP->TxEnd = (WORD *) RIO_PTR(Cad, RWORD(PhbP->tx_end));
598 PortP->RxRemove = (WORD *) RIO_PTR(Cad, RWORD(PhbP->rx_remove));
599 PortP->RxStart = (WORD *) RIO_PTR(Cad, RWORD(PhbP->rx_start));
600 PortP->RxEnd = (WORD *) RIO_PTR(Cad, RWORD(PhbP->rx_end));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
602 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
603 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800604 ** point the UnixRup at the base SysPort
605 */
606 if (!(PortN % PORTS_PER_RTA))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
608 }
609 }
610
Alan Cox3b8e3f12006-03-24 03:18:24 -0800611 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800613 ** last thing - show the world that everything is in place
614 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 HostP->Flags &= ~RUN_STATE;
616 HostP->Flags |= RC_RUNNING;
617 }
618 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800619 ** MPX always uses a poller. This is actually patched into the system
620 ** configuration and called directly from each clock tick.
621 **
622 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 p->RIOPolling = 1;
624
625 p->RIOSystemUp++;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800626
627 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
628 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 return 0;
630}
631
632
633
634/*
635** Boot an RTA. If we have successfully processed this boot, then
636** return 1. If we havent, then return 0.
637*/
Alan Cox3b8e3f12006-03-24 03:18:24 -0800638int RIOBootRup(p, Rup, HostP, PacketP)
639struct rio_info *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640uint Rup;
641struct Host *HostP;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800642struct PKT *PacketP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643{
Alan Cox3b8e3f12006-03-24 03:18:24 -0800644 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 struct PktCmd_M *PktReplyP;
646 struct CmdBlk *CmdBlkP;
647 uint sequence;
648
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800650 ** If we haven't been told what to boot, we can't boot it.
651 */
652 if (p->RIONumBootPkts == 0) {
653 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 return 0;
655 }
656
657 /* rio_dprint(RIO_DEBUG_BOOT, NULL,DBG_BOOT,"Incoming command packet\n"); */
658 /* ShowPacket( DBG_BOOT, PacketP ); */
659
660 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800661 ** Special case of boot completed - if we get one of these then we
662 ** don't need a command block. For all other cases we do, so handle
663 ** this first and then get a command block, then handle every other
664 ** case, relinquishing the command block if disaster strikes!
665 */
666 if ((RBYTE(PacketP->len) & PKT_CMD_BIT) && (RBYTE(PktCmdP->Command) == BOOT_COMPLETED))
667 return RIOBootComplete(p, HostP, Rup, PktCmdP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668
669 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800670 ** try to unhook a command block from the command free list.
671 */
672 if (!(CmdBlkP = RIOGetCmdBlk())) {
673 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 return 0;
675 }
676
677 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800678 ** Fill in the default info on the command block
679 */
680 CmdBlkP->Packet.dest_unit = Rup < (ushort) MAX_RUP ? Rup : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 CmdBlkP->Packet.dest_port = BOOT_RUP;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800682 CmdBlkP->Packet.src_unit = 0;
683 CmdBlkP->Packet.src_port = BOOT_RUP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684
685 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800686 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687
688 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800689 ** process COMMANDS on the boot rup!
690 */
691 if (RBYTE(PacketP->len) & PKT_CMD_BIT) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800693 ** We only expect one type of command - a BOOT_REQUEST!
694 */
695 if (RBYTE(PktCmdP->Command) != BOOT_REQUEST) {
696 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %d\n", PktCmdP->Command, Rup, HostP - p->RIOHosts);
697 ShowPacket(DBG_BOOT, PacketP);
698 RIOFreeCmdBlk(CmdBlkP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 return 1;
700 }
701
702 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800703 ** Build a Boot Sequence command block
704 **
705 ** 02.03.1999 ARG - ESIL 0820 fix
706 ** We no longer need to use "Boot Mode", we'll always allow
707 ** boot requests - the boot will not complete if the device
708 ** appears in the bindings table.
709 ** So, this conditional is not required ...
710 **
711 if (p->RIOBootMode == RC_BOOT_NONE)
712 **
713 ** If the system is in slave mode, and a boot request is
714 ** received, set command to BOOT_ABORT so that the boot
715 ** will not complete.
716 **
717 PktReplyP->Command = BOOT_ABORT;
718 else
719 **
720 ** We'll just (always) set the command field in packet reply
721 ** to allow an attempted boot sequence :
722 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 PktReplyP->Command = BOOT_SEQUENCE;
724
725 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800726 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
727 PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728
Alan Cox3b8e3f12006-03-24 03:18:24 -0800729 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730
Alan Cox3b8e3f12006-03-24 03:18:24 -0800731 bcopy("BOOT", (void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732
Alan Cox3b8e3f12006-03-24 03:18:24 -0800733 rio_dprintk(RIO_DEBUG_BOOT, "Boot RTA on Host %d Rup %d - %d (0x%x) packets to 0x%x\n", HostP - p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts, p->RIOConf.RtaLoadBase);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734
735 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800736 ** If this host is in slave mode, send the RTA an invalid boot
737 ** sequence command block to force it to kill the boot. We wait
738 ** for half a second before sending this packet to prevent the RTA
739 ** attempting to boot too often. The master host should then grab
740 ** the RTA and make it its own.
741 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 p->RIOBooting++;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800743 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 return 1;
745 }
746
747 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800748 ** It is a request for boot data.
749 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 sequence = RWORD(PktCmdP->Sequence);
751
Alan Cox3b8e3f12006-03-24 03:18:24 -0800752 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %d Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753
Alan Cox3b8e3f12006-03-24 03:18:24 -0800754 if (sequence >= p->RIONumBootPkts) {
755 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
756 ShowPacket(DBG_BOOT, PacketP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 }
758
759 PktReplyP->Sequence = sequence;
760
Alan Cox3b8e3f12006-03-24 03:18:24 -0800761 bcopy(p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], PktReplyP->BootData, RTA_BOOT_DATA_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762
763 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800764 ShowPacket(DBG_BOOT, &CmdBlkP->Packet);
765 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 return 1;
767}
768
769/*
770** This function is called when an RTA been booted.
771** If booted by a host, HostP->HostUniqueNum is the booting host.
772** If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA.
773** RtaUniq is the booted RTA.
774*/
Alan Cox3b8e3f12006-03-24 03:18:24 -0800775static int RIOBootComplete(struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776{
Alan Cox3b8e3f12006-03-24 03:18:24 -0800777 struct Map *MapP = NULL;
778 struct Map *MapP2 = NULL;
779 int Flag;
780 int found;
781 int host, rta;
782 int EmptySlot = -1;
783 int entry, entry2;
784 char *MyType, *MyName;
785 uint MyLink;
786 ushort RtaType;
787 uint RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788
789 /* Was RIOBooting-- . That's bad. If an RTA sends two of them, the
790 driver will never think that the RTA has booted... -- REW */
791 p->RIOBooting = 0;
792
Alan Cox3b8e3f12006-03-24 03:18:24 -0800793 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794
795 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800796 ** Determine type of unit (16/8 port RTA).
797 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 RtaType = GetUnitType(RtaUniq);
Alan Cox3b8e3f12006-03-24 03:18:24 -0800799 if (Rup >= (ushort) MAX_RUP) {
800 rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, RBYTE(PktCmdP->LinkNum) + 'A');
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 } else {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800802 rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, RBYTE(PktCmdP->LinkNum) + 'A');
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 }
804
Alan Cox3b8e3f12006-03-24 03:18:24 -0800805 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806
Alan Cox3b8e3f12006-03-24 03:18:24 -0800807 if ((RtaUniq == 0x00000000) || (RtaUniq == 0xffffffff)) {
808 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 return TRUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 }
811
Alan Cox3b8e3f12006-03-24 03:18:24 -0800812 /*
813 ** If this RTA has just booted an RTA which doesn't belong to this
814 ** system, or the system is in slave mode, do not attempt to create
815 ** a new table entry for it.
816 */
817 if (!RIOBootOk(p, HostP, RtaUniq)) {
818 MyLink = RBYTE(PktCmdP->LinkNum);
819 if (Rup < (ushort) MAX_RUP) {
820 /*
821 ** RtaUniq was clone booted (by this RTA). Instruct this RTA
822 ** to hold off further attempts to boot on this link for 30
823 ** seconds.
824 */
825 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
826 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
827 }
828 } else {
829 /*
830 ** RtaUniq was booted by this host. Set the booting link
831 ** to hold off for 30 seconds to give another unit a
832 ** chance to boot it.
833 */
834 WWORD(HostP->LinkStrP[MyLink].WaitNoBoot, 30);
835 }
836 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);
837 return TRUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 }
Alan Cox3b8e3f12006-03-24 03:18:24 -0800839
840 /*
841 ** Check for a SLOT_IN_USE entry for this RTA attached to the
842 ** current host card in the driver table.
843 **
844 ** If it exists, make a note that we have booted it. Other parts of
845 ** the driver are interested in this information at a later date,
846 ** in particular when the booting RTA asks for an ID for this unit,
847 ** we must have set the BOOTED flag, and the NEWBOOT flag is used
848 ** to force an open on any ports that where previously open on this
849 ** unit.
850 */
851 for (entry = 0; entry < MAX_RUP; entry++) {
852 uint sysport;
853
854 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
855 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
856#ifdef NEED_TO_FIX
857 RIO_SV_BROADCAST(HostP->svFlags[entry]);
858#endif
859 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
860 if (sysport < p->RIOFirstPortsBooted)
861 p->RIOFirstPortsBooted = sysport;
862 if (sysport > p->RIOLastPortsBooted)
863 p->RIOLastPortsBooted = sysport;
864 /*
865 ** For a 16 port RTA, check the second bank of 8 ports
866 */
867 if (RtaType == TYPE_RTA16) {
868 entry2 = HostP->Mapping[entry].ID2 - 1;
869 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
870#ifdef NEED_TO_FIX
871 RIO_SV_BROADCAST(HostP->svFlags[entry2]);
872#endif
873 sysport = HostP->Mapping[entry2].SysPort;
874 if (sysport < p->RIOFirstPortsBooted)
875 p->RIOFirstPortsBooted = sysport;
876 if (sysport > p->RIOLastPortsBooted)
877 p->RIOLastPortsBooted = sysport;
878 }
879 }
880 if (RtaType == TYPE_RTA16) {
881 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
882 } else {
883 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
884 }
885 return TRUE;
886 }
887 }
888
889 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
890
891 if (Rup >= (ushort) MAX_RUP) {
892 /*
893 ** It was a host that did the booting
894 */
895 MyType = "Host";
896 MyName = HostP->Name;
897 } else {
898 /*
899 ** It was an RTA that did the booting
900 */
901 MyType = "RTA";
902 MyName = HostP->Mapping[Rup].Name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 MyLink = RBYTE(PktCmdP->LinkNum);
905
906 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800907 ** There is no SLOT_IN_USE entry for this RTA attached to the current
908 ** host card in the driver table.
909 **
910 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the
911 ** current host card in the driver table.
912 **
913 ** If we find one, then we re-use that slot.
914 */
915 for (entry = 0; entry < MAX_RUP; entry++) {
916 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
917 if (RtaType == TYPE_RTA16) {
918 entry2 = HostP->Mapping[entry].ID2 - 1;
919 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
920 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
921 else
922 continue;
923 } else
924 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
925 if (!p->RIONoMessage)
926 cprintf("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
927 return TRUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 }
930
931 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800932 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
933 ** attached to the current host card in the driver table.
934 **
935 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another
936 ** host for this RTA in the driver table.
937 **
938 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA
939 ** entry from the other host and add it to this host (using some of
940 ** the functions from table.c which do this).
941 ** For a SLOT_TENTATIVE entry on another host, we must cope with the
942 ** following scenario:
943 **
944 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry
945 ** in table)
946 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE
947 ** entries)
948 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE)
949 ** + Unplug RTA and plug back into host A.
950 ** + Configure RTA on host A. We now have the same RTA configured
951 ** with different ports on two different hosts.
952 */
953 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 found = 0;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800955 Flag = 0; /* Convince the compiler this variable is initialized */
956 for (host = 0; !found && (host < p->RIONumHosts); host++) {
957 for (rta = 0; rta < MAX_RUP; rta++) {
958 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
959 Flag = p->RIOHosts[host].Mapping[rta].Flags;
960 MapP = &p->RIOHosts[host].Mapping[rta];
961 if (RtaType == TYPE_RTA16) {
962 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
963 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
964 } else
965 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
966 found = 1;
967 break;
968 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 }
971
972 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800973 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
974 ** attached to the current host card in the driver table.
975 **
976 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on
977 ** another host for this RTA in the driver table...
978 **
979 ** Check for a SLOT_IN_USE entry for this RTA in the config table.
980 */
981 if (!MapP) {
982 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
983 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
984 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985
Alan Cox3b8e3f12006-03-24 03:18:24 -0800986 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
987 MapP = &p->RIOSavedTable[rta];
988 Flag = p->RIOSavedTable[rta].Flags;
989 if (RtaType == TYPE_RTA16) {
990 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
991 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
992 break;
993 }
994 MapP2 = &p->RIOSavedTable[entry2];
995 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
996 } else
997 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
998 break;
999 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 }
1002
1003 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001004 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1005 ** attached to the current host card in the driver table.
1006 **
1007 ** We may have found a SLOT_IN_USE entry on another host for this
1008 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry
1009 ** on another host for this RTA in the driver table.
1010 **
1011 ** Check the driver table for room to fit this newly discovered RTA.
1012 ** RIOFindFreeID() first looks for free slots and if it does not
1013 ** find any free slots it will then attempt to oust any
1014 ** tentative entry in the table.
1015 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 EmptySlot = 1;
Alan Cox3b8e3f12006-03-24 03:18:24 -08001017 if (RtaType == TYPE_RTA16) {
1018 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
1019 RIODefaultName(p, HostP, entry);
1020 FillSlot(entry, entry2, RtaUniq, HostP);
1021 EmptySlot = 0;
1022 }
1023 } else {
1024 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
1025 RIODefaultName(p, HostP, entry);
1026 FillSlot(entry, 0, RtaUniq, HostP);
1027 EmptySlot = 0;
1028 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029 }
1030
1031 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001032 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1033 ** attached to the current host card in the driver table.
1034 **
1035 ** If we found a SLOT_IN_USE entry on another host for this
1036 ** RTA in the config or driver table, and there are enough free
1037 ** slots in the driver table, then we need to move it over and
1038 ** delete it from the other host.
1039 ** If we found a SLOT_TENTATIVE entry on another host for this
1040 ** RTA in the driver table, just delete the other host entry.
1041 */
1042 if (EmptySlot == 0) {
1043 if (MapP) {
1044 if (Flag & SLOT_IN_USE) {
1045 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
1046 HostP->Mapping[entry].SysPort = MapP->SysPort;
1047 CCOPY(MapP->Name, HostP->Mapping[entry].Name, MAX_NAME_LEN);
1048 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
Olaf Hering44456d32005-07-27 11:45:17 -07001049#ifdef NEED_TO_FIX
Alan Cox3b8e3f12006-03-24 03:18:24 -08001050 RIO_SV_BROADCAST(HostP->svFlags[entry]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051#endif
Alan Cox3b8e3f12006-03-24 03:18:24 -08001052 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
1053 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
1054 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
1055 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
1056 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
1057 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
1058 } else {
1059 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
1060 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
Olaf Hering44456d32005-07-27 11:45:17 -07001061#ifdef NEED_TO_FIX
Alan Cox3b8e3f12006-03-24 03:18:24 -08001062 RIO_SV_BROADCAST(HostP->svFlags[entry]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063#endif
Alan Cox3b8e3f12006-03-24 03:18:24 -08001064 }
1065 if (RtaType == TYPE_RTA16) {
1066 if (Flag & SLOT_IN_USE) {
1067 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
Olaf Hering44456d32005-07-27 11:45:17 -07001068#ifdef NEED_TO_FIX
Alan Cox3b8e3f12006-03-24 03:18:24 -08001069 RIO_SV_BROADCAST(HostP->svFlags[entry2]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070#endif
Alan Cox3b8e3f12006-03-24 03:18:24 -08001071 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1072 /*
1073 ** Map second block of ttys for 16 port RTA
1074 */
1075 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
1076 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1077 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1078 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1079 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1080 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
1081 } else
1082 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
Olaf Hering44456d32005-07-27 11:45:17 -07001083#ifdef NEED_TO_FIX
Alan Cox3b8e3f12006-03-24 03:18:24 -08001084 RIO_SV_BROADCAST(HostP->svFlags[entry2]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085#endif
Alan Cox3b8e3f12006-03-24 03:18:24 -08001086 bzero((caddr_t) MapP2, sizeof(struct Map));
1087 }
1088 bzero((caddr_t) MapP, sizeof(struct Map));
1089 if (!p->RIONoMessage)
1090 cprintf("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
1091 } else if (!p->RIONoMessage)
1092 cprintf("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
1093 RIOSetChange(p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 return TRUE;
Alan Cox3b8e3f12006-03-24 03:18:24 -08001095 }
1096
1097 /*
1098 ** There is no room in the driver table to make an entry for the
1099 ** booted RTA. Keep a note of its Uniq Num in the overflow table,
1100 ** so we can ignore it's ID requests.
1101 */
1102 if (!p->RIONoMessage)
1103 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');
1104 for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
1105 if (HostP->ExtraUnits[entry] == RtaUniq) {
1106 /*
1107 ** already got it!
1108 */
1109 return TRUE;
1110 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111 }
1112 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001113 ** If there is room, add the unit to the list of extras
1114 */
1115 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
1116 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 return TRUE;
1118}
1119
1120
1121/*
1122** If the RTA or its host appears in the RIOBindTab[] structure then
1123** we mustn't boot the RTA and should return FALSE.
1124** This operation is slightly different from the other drivers for RIO
1125** in that this is designed to work with the new utilities
1126** not config.rio and is FAR SIMPLER.
1127** We no longer support the RIOBootMode variable. It is all done from the
1128** "boot/noboot" field in the rio.cf file.
1129*/
Alan Cox3b8e3f12006-03-24 03:18:24 -08001130int RIOBootOk(p, HostP, RtaUniq)
1131struct rio_info *p;
1132struct Host *HostP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133ulong RtaUniq;
1134{
Alan Cox3b8e3f12006-03-24 03:18:24 -08001135 int Entry;
1136 uint HostUniq = HostP->UniqueNum;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137
1138 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001139 ** Search bindings table for RTA or its parent.
1140 ** If it exists, return 0, else 1.
1141 */
1142 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
1143 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 return 0;
1145 }
1146 return 1;
1147}
1148
1149/*
1150** Make an empty slot tentative. If this is a 16 port RTA, make both
1151** slots tentative, and the second one RTA_SECOND_SLOT as well.
1152*/
1153
Alan Cox3b8e3f12006-03-24 03:18:24 -08001154void FillSlot(entry, entry2, RtaUniq, HostP)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155int entry;
1156int entry2;
1157uint RtaUniq;
1158struct Host *HostP;
1159{
Alan Cox3b8e3f12006-03-24 03:18:24 -08001160 int link;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161
Alan Cox3b8e3f12006-03-24 03:18:24 -08001162 rio_dprintk(RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163
1164 HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
1165 HostP->Mapping[entry].SysPort = NO_PORT;
1166 HostP->Mapping[entry].RtaUniqueNum = RtaUniq;
1167 HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum;
1168 HostP->Mapping[entry].ID = entry + 1;
1169 HostP->Mapping[entry].ID2 = 0;
1170 if (entry2) {
Alan Cox3b8e3f12006-03-24 03:18:24 -08001171 HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 HostP->Mapping[entry2].SysPort = NO_PORT;
1173 HostP->Mapping[entry2].RtaUniqueNum = RtaUniq;
1174 HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum;
1175 HostP->Mapping[entry2].Name[0] = '\0';
1176 HostP->Mapping[entry2].ID = entry2 + 1;
1177 HostP->Mapping[entry2].ID2 = entry + 1;
1178 HostP->Mapping[entry].ID2 = entry2 + 1;
1179 }
1180 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001181 ** Must set these up, so that utilities show
1182 ** topology of 16 port RTAs correctly
1183 */
1184 for (link = 0; link < LINKS_PER_UNIT; link++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
1186 HostP->Mapping[entry].Topology[link].Link = NO_LINK;
1187 if (entry2) {
1188 HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
1189 HostP->Mapping[entry2].Topology[link].Link = NO_LINK;
1190 }
1191 }
1192}