blob: e1542e8dfb439a5ad5e226a8b921ba4c3cf65bd0 [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <linux/module.h>
34#include <linux/slab.h>
Alan Coxb6c6b602006-03-24 03:18:26 -080035#include <linux/termios.h>
36#include <linux/serial.h>
37#include <asm/semaphore.h>
38#include <linux/generic_serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/errno.h>
40#include <linux/interrupt.h>
Alan Coxb6c6b602006-03-24 03:18:26 -080041#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <asm/io.h>
43#include <asm/system.h>
44#include <asm/string.h>
Alan Coxb6c6b602006-03-24 03:18:26 -080045#include <asm/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47
48#include "linux_compat.h"
49#include "rio_linux.h"
50#include "typdef.h"
51#include "pkt.h"
52#include "daemon.h"
53#include "rio.h"
54#include "riospace.h"
55#include "top.h"
56#include "cmdpkt.h"
57#include "map.h"
58#include "riotypes.h"
59#include "rup.h"
60#include "port.h"
61#include "riodrvr.h"
62#include "rioinfo.h"
63#include "func.h"
64#include "errors.h"
65#include "pci.h"
66
67#include "parmmap.h"
68#include "unixrup.h"
69#include "board.h"
70#include "host.h"
71#include "error.h"
72#include "phb.h"
73#include "link.h"
74#include "cmdblk.h"
75#include "route.h"
76
Alan Coxb6c6b602006-03-24 03:18:26 -080077static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Alan Coxb6c6b602006-03-24 03:18:26 -080079static const unsigned char RIOAtVec2Ctrl[] = {
Alan Cox3b8e3f12006-03-24 03:18:24 -080080 /* 0 */ INTERRUPT_DISABLE,
81 /* 1 */ INTERRUPT_DISABLE,
82 /* 2 */ INTERRUPT_DISABLE,
83 /* 3 */ INTERRUPT_DISABLE,
84 /* 4 */ INTERRUPT_DISABLE,
85 /* 5 */ INTERRUPT_DISABLE,
86 /* 6 */ INTERRUPT_DISABLE,
87 /* 7 */ INTERRUPT_DISABLE,
88 /* 8 */ INTERRUPT_DISABLE,
89 /* 9 */ IRQ_9 | INTERRUPT_ENABLE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 /* 10 */ INTERRUPT_DISABLE,
Alan Cox3b8e3f12006-03-24 03:18:24 -080091 /* 11 */ IRQ_11 | INTERRUPT_ENABLE,
92 /* 12 */ IRQ_12 | INTERRUPT_ENABLE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 /* 13 */ INTERRUPT_DISABLE,
94 /* 14 */ INTERRUPT_DISABLE,
Alan Cox3b8e3f12006-03-24 03:18:24 -080095 /* 15 */ IRQ_15 | INTERRUPT_ENABLE
Linus Torvalds1da177e2005-04-16 15:20:36 -070096};
97
Alan Coxb6c6b602006-03-24 03:18:26 -080098/**
99 * RIOBootCodeRTA - Load RTA boot code
100 * @p: RIO to load
101 * @rbp: Download descriptor
102 *
103 * Called when the user process initiates booting of the card firmware.
104 * Lads the firmware
105 */
106
107int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108{
109 int offset;
110
Alan Cox3b8e3f12006-03-24 03:18:24 -0800111 func_enter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Alan Coxb6c6b602006-03-24 03:18:26 -0800113 rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800116 ** Check that we have set asside enough memory for this
117 */
118 if (rbp->Count > SIXTY_FOUR_K) {
119 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 p->RIOError.Error = HOST_FILE_TOO_LARGE;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800121 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 return -ENOMEM;
123 }
124
Alan Cox3b8e3f12006-03-24 03:18:24 -0800125 if (p->RIOBooting) {
126 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 p->RIOError.Error = BOOT_IN_PROGRESS;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800128 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 return -EBUSY;
130 }
131
132 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800133 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary,
134 ** so calculate how far we have to move the data up the buffer
135 ** to achieve this.
136 */
137 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800140 ** Be clean, and clear the 'unused' portion of the boot buffer,
141 ** because it will (eventually) be part of the Rta run time environment
142 ** and so should be zeroed.
143 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800144 memset(p->RIOBootPackets, 0, offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146 /*
Alan Coxb6c6b602006-03-24 03:18:26 -0800147 ** Copy the data from user space into the array
Alan Cox3b8e3f12006-03-24 03:18:24 -0800148 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Alan Coxb6c6b602006-03-24 03:18:26 -0800150 if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800151 rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 p->RIOError.Error = COPYIN_FAILED;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800153 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 return -EFAULT;
155 }
156
157 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800158 ** Make sure that our copy of the size includes that offset we discussed
159 ** earlier.
160 */
161 p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE;
162 p->RIOBootCount = rbp->Count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 func_exit();
165 return 0;
166}
167
Alan Coxb6c6b602006-03-24 03:18:26 -0800168/**
169 * rio_start_card_running - host card start
170 * @HostP: The RIO to kick off
171 *
172 * Start a RIO processor unit running. Encapsulates the knowledge
173 * of the card type.
174 */
175
Alan Cox3b8e3f12006-03-24 03:18:24 -0800176void rio_start_card_running(struct Host *HostP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
Alan Cox3b8e3f12006-03-24 03:18:24 -0800178 switch (HostP->Type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 case RIO_AT:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800180 rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n");
Alan Coxb6c6b602006-03-24 03:18:26 -0800181 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 case RIO_PCI:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800184 /*
185 ** PCI is much the same as MCA. Everything is once again memory
186 ** mapped, so we are writing to memory registers instead of io
187 ** ports.
188 */
189 rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n");
Alan Coxb6c6b602006-03-24 03:18:26 -0800190 writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 break;
192 default:
Alan Cox3b8e3f12006-03-24 03:18:24 -0800193 rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 break;
195 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 return;
197}
198
199/*
200** Load in the host boot code - load it directly onto all halted hosts
201** of the correct type.
202**
203** Put your rubber pants on before messing with this code - even the magic
204** numbers have trouble understanding what they are doing here.
205*/
Alan Coxb6c6b602006-03-24 03:18:26 -0800206
207int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208{
Alan Coxb6c6b602006-03-24 03:18:26 -0800209 struct Host *HostP;
210 u8 *Cad;
211 PARM_MAP *ParmMapP;
212 int RupN;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 int PortN;
Alan Coxb6c6b602006-03-24 03:18:26 -0800214 unsigned int host;
215 u8 *StartP;
216 u8 *DestP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 int wait_count;
Alan Coxb6c6b602006-03-24 03:18:26 -0800218 u16 OldParmMap;
219 u16 offset; /* It is very important that this is a u16 */
220 u8 *DownCode = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 unsigned long flags;
222
Alan Cox3b8e3f12006-03-24 03:18:24 -0800223 HostP = NULL; /* Assure the compiler we've initialized it */
Alan Coxb6c6b602006-03-24 03:18:26 -0800224
225
226 /* Walk the hosts */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800227 for (host = 0; host < p->RIONumHosts; host++) {
228 rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 HostP = &p->RIOHosts[host];
Alan Cox3b8e3f12006-03-24 03:18:24 -0800230
231 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 -0700232
Alan Coxb6c6b602006-03-24 03:18:26 -0800233 /* Don't boot hosts already running */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800234 if ((HostP->Flags & RUN_STATE) != RC_WAITING) {
235 rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 continue;
237 }
238
239 /*
Alan Coxb6c6b602006-03-24 03:18:26 -0800240 ** Grab a pointer to the card (ioremapped)
Alan Cox3b8e3f12006-03-24 03:18:24 -0800241 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 Cad = HostP->Caddr;
243
244 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800245 ** We are going to (try) and load in rbp->Count bytes.
246 ** The last byte will reside at p->RIOConf.HostLoadBase-1;
247 ** Therefore, we need to start copying at address
248 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count)
249 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800250 StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Alan Coxb6c6b602006-03-24 03:18:26 -0800252 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad);
253 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP);
Alan Cox3b8e3f12006-03-24 03:18:24 -0800254 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
255 rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Alan Coxb6c6b602006-03-24 03:18:26 -0800257 /* Make sure it fits */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800258 if (p->RIOConf.HostLoadBase < rbp->Count) {
259 rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 p->RIOError.Error = HOST_FILE_TOO_LARGE;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800261 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 return -EFBIG;
263 }
264 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800265 ** Ensure that the host really is stopped.
266 ** Disable it's external bus & twang its reset line.
267 */
268 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
270 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800271 ** Copy the data directly from user space to the SRAM.
272 ** This ain't going to be none too clever if the download
273 ** code is bigger than this segment.
274 */
275 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Alan Coxb6c6b602006-03-24 03:18:26 -0800277 /* Buffer to local memory as we want to use I/O space and
278 some cards only do 8 or 16 bit I/O */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Alan Coxb6c6b602006-03-24 03:18:26 -0800280 DownCode = vmalloc(rbp->Count);
281 if (!DownCode) {
282 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
283 func_exit();
284 return -ENOMEM;
285 }
286 if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) {
287 kfree(DownCode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 p->RIOError.Error = COPYIN_FAILED;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800289 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 return -EFAULT;
291 }
Alan Coxb6c6b602006-03-24 03:18:26 -0800292 HostP->Copy(DownCode, StartP, rbp->Count);
293 vfree(DownCode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Alan Cox3b8e3f12006-03-24 03:18:24 -0800295 rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800298 ** S T O P !
299 **
300 ** Upto this point the code has been fairly rational, and possibly
301 ** even straight forward. What follows is a pile of crud that will
302 ** magically turn into six bytes of transputer assembler. Normally
303 ** you would expect an array or something, but, being me, I have
304 ** chosen [been told] to use a technique whereby the startup code
305 ** will be correct if we change the loadbase for the code. Which
306 ** brings us onto another issue - the loadbase is the *end* of the
307 ** code, not the start.
308 **
309 ** If I were you I wouldn't start from here.
310 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
312 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800313 ** We now need to insert a short boot section into
314 ** the memory at the end of Sram2. This is normally (de)composed
315 ** of the last eight bytes of the download code. The
316 ** download has been assembled/compiled to expect to be
317 ** loaded from 0x7FFF downwards. We have loaded it
318 ** at some other address. The startup code goes into the small
319 ** ram window at Sram2, in the last 8 bytes, which are really
320 ** at addresses 0x7FF8-0x7FFF.
321 **
322 ** If the loadbase is, say, 0x7C00, then we need to branch to
323 ** address 0x7BFE to run the host.bin startup code. We assemble
324 ** this jump manually.
325 **
326 ** The two byte sequence 60 08 is loaded into memory at address
327 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0,
328 ** which adds '0' to the .O register, complements .O, and then shifts
329 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will
330 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new
331 ** location. Now, the branch starts from the value of .PC (or .IP or
332 ** whatever the bloody register is called on this chip), and the .PC
333 ** will be pointing to the location AFTER the branch, in this case
334 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8.
335 **
336 ** A long branch is coded at 0x7FF8. This consists of loading a four
337 ** byte offset into .O using nfix (as above) and pfix operators. The
338 ** pfix operates in exactly the same way as the nfix operator, but
339 ** without the complement operation. The offset, of course, must be
340 ** relative to the address of the byte AFTER the branch instruction,
341 ** which will be (urm) 0x7FFC, so, our final destination of the branch
342 ** (loadbase-2), has to be reached from here. Imagine that the loadbase
343 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which
344 ** is the first byte of the initial two byte short local branch of the
345 ** download code).
346 **
347 ** To code a jump from 0x7FFC (which is where the branch will start
348 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)=
349 ** 0x7BFE.
350 ** This will be coded as four bytes:
351 ** 60 2C 20 02
352 ** being nfix .O+0
353 ** pfix .O+C
354 ** pfix .O+0
355 ** jump .O+2
356 **
357 ** The nfix operator is used, so that the startup code will be
358 ** compatible with the whole Tp family. (lies, damn lies, it'll never
359 ** work in a month of Sundays).
360 **
361 ** The nfix nyble is the 1s complement of the nyble value you
362 ** want to load - in this case we wanted 'F' so we nfix loaded '0'.
363 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
365
366 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800367 ** Dest points to the top 8 bytes of Sram2. The Tp jumps
368 ** to 0x7FFE at reset time, and starts executing. This is
369 ** a short branch to 0x7FF8, where a long branch is coded.
370 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
Alan Coxb6c6b602006-03-24 03:18:26 -0800372 DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
374#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */
375#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */
Alan Cox3b8e3f12006-03-24 03:18:24 -0800376#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800379 ** 0x7FFC is the address of the location following the last byte of
380 ** the four byte jump instruction.
381 ** READ THE ABOVE COMMENTS
382 **
383 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about.
384 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned,
385 ** cos I don't understand 2's complement).
386 */
387 offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
Alan Coxb6c6b602006-03-24 03:18:26 -0800389 writeb(NFIX(((ushort) (~offset) >> (ushort) 12) & 0xF), DestP);
390 writeb(PFIX((offset >> 8) & 0xF), DestP + 1);
391 writeb(PFIX((offset >> 4) & 0xF), DestP + 2);
392 writeb(JUMP(offset & 0xF), DestP + 3);
393
394 writeb(NFIX(0), DestP + 6);
395 writeb(JUMP(8), DestP + 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
Alan Cox3b8e3f12006-03-24 03:18:24 -0800397 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
398 rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
400 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800401 ** Flag what is going on
402 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 HostP->Flags &= ~RUN_STATE;
404 HostP->Flags |= RC_STARTUP;
405
406 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800407 ** Grab a copy of the current ParmMap pointer, so we
408 ** can tell when it has changed.
409 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800410 OldParmMap = readw(&HostP->__ParmMapR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
Alan Cox3b8e3f12006-03-24 03:18:24 -0800412 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
414 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800415 ** And start it running (I hope).
416 ** As there is nothing dodgy or obscure about the
417 ** above code, this is guaranteed to work every time.
418 */
419 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 -0700420
421 rio_start_card_running(HostP);
422
Alan Cox3b8e3f12006-03-24 03:18:24 -0800423 rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
425 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800426 ** Now, wait for upto five seconds for the Tp to setup the parmmap
427 ** pointer:
428 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800429 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) {
430 rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR));
431 mdelay(100);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
433 }
434
435 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800436 ** If the parmmap pointer is unchanged, then the host code
437 ** has crashed & burned in a really spectacular way
438 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800439 if (readw(&HostP->__ParmMapR) == OldParmMap) {
440 rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR));
Alan Cox3b8e3f12006-03-24 03:18:24 -0800441 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
442 HostP->Flags &= ~RUN_STATE;
443 HostP->Flags |= RC_STUFFED;
Alan Coxb6c6b602006-03-24 03:18:26 -0800444 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
445 continue;
446 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
Alan Coxb6c6b602006-03-24 03:18:26 -0800448 rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800451 ** Well, the board thought it was OK, and setup its parmmap
452 ** pointer. For the time being, we will pretend that this
453 ** board is running, and check out what the error flag says.
454 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800457 ** Grab a 32 bit pointer to the parmmap structure
458 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800459 ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR));
460 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
461 ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR));
462 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463
464 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800465 ** The links entry should be 0xFFFF; we set it up
466 ** with a mask to say how many PHBs to use, and
467 ** which links to use.
468 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800469 if (readw(&ParmMapP->links) != 0xFFFF) {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800470 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
Alan Coxb6c6b602006-03-24 03:18:26 -0800471 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links));
Alan Cox3b8e3f12006-03-24 03:18:24 -0800472 HostP->Flags &= ~RUN_STATE;
473 HostP->Flags |= RC_STUFFED;
Alan Coxb6c6b602006-03-24 03:18:26 -0800474 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
475 continue;
476 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
Alan Coxb6c6b602006-03-24 03:18:26 -0800478 writew(RIO_LINK_ENABLE, &ParmMapP->links);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800481 ** now wait for the card to set all the parmmap->XXX stuff
482 ** this is a wait of upto two seconds....
483 */
484 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 HostP->timeout_id = 0;
Alan Coxb6c6b602006-03-24 03:18:26 -0800486 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800487 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
Alan Coxb6c6b602006-03-24 03:18:26 -0800488 mdelay(100);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 }
Alan Cox3b8e3f12006-03-24 03:18:24 -0800490 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491
Alan Coxb6c6b602006-03-24 03:18:26 -0800492 if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800493 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
494 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
495 HostP->Flags &= ~RUN_STATE;
496 HostP->Flags |= RC_STUFFED;
Alan Coxb6c6b602006-03-24 03:18:26 -0800497 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
498 continue;
499 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
Alan Cox3b8e3f12006-03-24 03:18:24 -0800501 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502
503 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800504 ** It runs! It runs!
505 */
506 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507
508 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800509 ** set the time period between interrupts.
510 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800511 writew(p->RIOConf.Timer, &ParmMapP->timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512
513 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800514 ** Translate all the 16 bit pointers in the __ParmMapR into
Alan Coxb6c6b602006-03-24 03:18:26 -0800515 ** 32 bit pointers for the driver in ioremap space.
Alan Cox3b8e3f12006-03-24 03:18:24 -0800516 */
517 HostP->ParmMapP = ParmMapP;
Alan Coxb6c6b602006-03-24 03:18:26 -0800518 HostP->PhbP = (PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
519 HostP->RupP = (RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups));
520 HostP->PhbNumP = (ushort *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
521 HostP->LinkStrP = (LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522
523 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800524 ** point the UnixRups at the real Rups
525 */
526 for (RupN = 0; RupN < MAX_RUP; RupN++) {
527 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
528 HostP->UnixRups[RupN].Id = RupN + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
530 spin_lock_init(&HostP->UnixRups[RupN].RupLock);
531 }
532
Alan Cox3b8e3f12006-03-24 03:18:24 -0800533 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
534 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
535 HostP->UnixRups[RupN + MAX_RUP].Id = 0;
536 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
537 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 }
539
540 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800541 ** point the PortP->Phbs at the real Phbs
542 */
543 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
544 if (p->RIOPortp[PortN]->HostP == HostP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 struct Port *PortP = p->RIOPortp[PortN];
546 struct PHB *PhbP;
547 /* int oldspl; */
548
Alan Cox3b8e3f12006-03-24 03:18:24 -0800549 if (!PortP->Mapped)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 continue;
551
552 PhbP = &HostP->PhbP[PortP->HostPort];
553 rio_spin_lock_irqsave(&PortP->portSem, flags);
554
555 PortP->PhbP = PhbP;
556
Alan Coxb6c6b602006-03-24 03:18:26 -0800557 PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add));
558 PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start));
559 PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end));
560 PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
561 PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start));
562 PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563
564 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
565 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800566 ** point the UnixRup at the base SysPort
567 */
568 if (!(PortN % PORTS_PER_RTA))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
570 }
571 }
572
Alan Cox3b8e3f12006-03-24 03:18:24 -0800573 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800575 ** last thing - show the world that everything is in place
576 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 HostP->Flags &= ~RUN_STATE;
578 HostP->Flags |= RC_RUNNING;
579 }
580 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800581 ** MPX always uses a poller. This is actually patched into the system
582 ** configuration and called directly from each clock tick.
583 **
584 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 p->RIOPolling = 1;
586
587 p->RIOSystemUp++;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800588
589 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
590 func_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 return 0;
592}
593
594
595
Alan Coxb6c6b602006-03-24 03:18:26 -0800596/**
597 * RIOBootRup - Boot an RTA
598 * @p: rio we are working with
599 * @Rup: Rup number
600 * @HostP: host object
601 * @PacketP: packet to use
602 *
603 * If we have successfully processed this boot, then
604 * return 1. If we havent, then return 0.
605 */
606
607int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608{
Alan Cox3b8e3f12006-03-24 03:18:24 -0800609 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 struct PktCmd_M *PktReplyP;
611 struct CmdBlk *CmdBlkP;
Alan Coxb6c6b602006-03-24 03:18:26 -0800612 unsigned int sequence;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800615 ** If we haven't been told what to boot, we can't boot it.
616 */
617 if (p->RIONumBootPkts == 0) {
618 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 return 0;
620 }
621
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800623 ** Special case of boot completed - if we get one of these then we
624 ** don't need a command block. For all other cases we do, so handle
625 ** this first and then get a command block, then handle every other
626 ** case, relinquishing the command block if disaster strikes!
627 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800628 if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED))
Alan Cox3b8e3f12006-03-24 03:18:24 -0800629 return RIOBootComplete(p, HostP, Rup, PktCmdP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
631 /*
Alan Coxb6c6b602006-03-24 03:18:26 -0800632 ** Try to allocate a command block. This is in kernel space
Alan Cox3b8e3f12006-03-24 03:18:24 -0800633 */
634 if (!(CmdBlkP = RIOGetCmdBlk())) {
635 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 return 0;
637 }
638
639 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800640 ** Fill in the default info on the command block
641 */
642 CmdBlkP->Packet.dest_unit = Rup < (ushort) MAX_RUP ? Rup : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 CmdBlkP->Packet.dest_port = BOOT_RUP;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800644 CmdBlkP->Packet.src_unit = 0;
645 CmdBlkP->Packet.src_port = BOOT_RUP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646
647 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800648 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649
650 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800651 ** process COMMANDS on the boot rup!
652 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800653 if (readb(&PacketP->len) & PKT_CMD_BIT) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800655 ** We only expect one type of command - a BOOT_REQUEST!
656 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800657 if (readb(&PktCmdP->Command) != BOOT_REQUEST) {
658 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts);
Alan Cox3b8e3f12006-03-24 03:18:24 -0800659 RIOFreeCmdBlk(CmdBlkP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 return 1;
661 }
662
663 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800664 ** Build a Boot Sequence command block
665 **
Alan Cox3b8e3f12006-03-24 03:18:24 -0800666 ** We no longer need to use "Boot Mode", we'll always allow
667 ** boot requests - the boot will not complete if the device
668 ** appears in the bindings table.
Alan Cox3b8e3f12006-03-24 03:18:24 -0800669 **
670 ** We'll just (always) set the command field in packet reply
671 ** to allow an attempted boot sequence :
672 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 PktReplyP->Command = BOOT_SEQUENCE;
674
675 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800676 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
677 PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678
Alan Cox3b8e3f12006-03-24 03:18:24 -0800679 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680
Alan Coxb6c6b602006-03-24 03:18:26 -0800681 memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682
Alan Coxb6c6b602006-03-24 03:18:26 -0800683 rio_dprintk(RIO_DEBUG_BOOT, "Boot RTA on Host %Zd Rup %d - %d (0x%x) packets to 0x%x\n", HostP - p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts, p->RIOConf.RtaLoadBase);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684
685 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800686 ** If this host is in slave mode, send the RTA an invalid boot
687 ** sequence command block to force it to kill the boot. We wait
688 ** for half a second before sending this packet to prevent the RTA
689 ** attempting to boot too often. The master host should then grab
690 ** the RTA and make it its own.
691 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 p->RIOBooting++;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800693 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 return 1;
695 }
696
697 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800698 ** It is a request for boot data.
699 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800700 sequence = readw(&PktCmdP->Sequence);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701
Alan Coxb6c6b602006-03-24 03:18:26 -0800702 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703
Alan Cox3b8e3f12006-03-24 03:18:24 -0800704 if (sequence >= p->RIONumBootPkts) {
705 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 }
707
708 PktReplyP->Sequence = sequence;
Alan Coxb6c6b602006-03-24 03:18:26 -0800709 memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800711 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 return 1;
713}
714
Alan Coxb6c6b602006-03-24 03:18:26 -0800715/**
716 * RIOBootComplete - RTA boot is done
717 * @p: RIO we are working with
718 * @HostP: Host structure
719 * @Rup: RUP being used
720 * @PktCmdP: Packet command that was used
721 *
722 * This function is called when an RTA been booted.
723 * If booted by a host, HostP->HostUniqueNum is the booting host.
724 * If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA.
725 * RtaUniq is the booted RTA.
726 */
727
728static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729{
Alan Cox3b8e3f12006-03-24 03:18:24 -0800730 struct Map *MapP = NULL;
731 struct Map *MapP2 = NULL;
732 int Flag;
733 int found;
734 int host, rta;
735 int EmptySlot = -1;
736 int entry, entry2;
737 char *MyType, *MyName;
Alan Coxb6c6b602006-03-24 03:18:26 -0800738 unsigned int MyLink;
739 unsigned short RtaType;
740 u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 p->RIOBooting = 0;
743
Alan Cox3b8e3f12006-03-24 03:18:24 -0800744 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745
746 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800747 ** Determine type of unit (16/8 port RTA).
748 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800749
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 RtaType = GetUnitType(RtaUniq);
Alan Coxb6c6b602006-03-24 03:18:26 -0800751 if (Rup >= (ushort) MAX_RUP)
752 rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
753 else
754 rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755
Alan Cox3b8e3f12006-03-24 03:18:24 -0800756 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757
Alan Coxb6c6b602006-03-24 03:18:26 -0800758 if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800759 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 return TRUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 }
762
Alan Cox3b8e3f12006-03-24 03:18:24 -0800763 /*
764 ** If this RTA has just booted an RTA which doesn't belong to this
765 ** system, or the system is in slave mode, do not attempt to create
766 ** a new table entry for it.
767 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800768
Alan Cox3b8e3f12006-03-24 03:18:24 -0800769 if (!RIOBootOk(p, HostP, RtaUniq)) {
Alan Coxb6c6b602006-03-24 03:18:26 -0800770 MyLink = readb(&PktCmdP->LinkNum);
771 if (Rup < (unsigned short) MAX_RUP) {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800772 /*
773 ** RtaUniq was clone booted (by this RTA). Instruct this RTA
774 ** to hold off further attempts to boot on this link for 30
775 ** seconds.
776 */
777 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
778 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
779 }
Alan Coxb6c6b602006-03-24 03:18:26 -0800780 } else
Alan Cox3b8e3f12006-03-24 03:18:24 -0800781 /*
782 ** RtaUniq was booted by this host. Set the booting link
783 ** to hold off for 30 seconds to give another unit a
784 ** chance to boot it.
785 */
Alan Coxb6c6b602006-03-24 03:18:26 -0800786 writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot);
Alan Cox3b8e3f12006-03-24 03:18:24 -0800787 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);
788 return TRUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 }
Alan Cox3b8e3f12006-03-24 03:18:24 -0800790
791 /*
792 ** Check for a SLOT_IN_USE entry for this RTA attached to the
793 ** current host card in the driver table.
794 **
795 ** If it exists, make a note that we have booted it. Other parts of
796 ** the driver are interested in this information at a later date,
797 ** in particular when the booting RTA asks for an ID for this unit,
798 ** we must have set the BOOTED flag, and the NEWBOOT flag is used
799 ** to force an open on any ports that where previously open on this
800 ** unit.
801 */
802 for (entry = 0; entry < MAX_RUP; entry++) {
Alan Coxb6c6b602006-03-24 03:18:26 -0800803 unsigned int sysport;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800804
805 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
806 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800807 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
808 if (sysport < p->RIOFirstPortsBooted)
809 p->RIOFirstPortsBooted = sysport;
810 if (sysport > p->RIOLastPortsBooted)
811 p->RIOLastPortsBooted = sysport;
812 /*
813 ** For a 16 port RTA, check the second bank of 8 ports
814 */
815 if (RtaType == TYPE_RTA16) {
816 entry2 = HostP->Mapping[entry].ID2 - 1;
817 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800818 sysport = HostP->Mapping[entry2].SysPort;
819 if (sysport < p->RIOFirstPortsBooted)
820 p->RIOFirstPortsBooted = sysport;
821 if (sysport > p->RIOLastPortsBooted)
822 p->RIOLastPortsBooted = sysport;
823 }
824 }
Alan Coxb6c6b602006-03-24 03:18:26 -0800825 if (RtaType == TYPE_RTA16)
Alan Cox3b8e3f12006-03-24 03:18:24 -0800826 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
Alan Coxb6c6b602006-03-24 03:18:26 -0800827 else
Alan Cox3b8e3f12006-03-24 03:18:24 -0800828 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
Alan Cox3b8e3f12006-03-24 03:18:24 -0800829 return TRUE;
830 }
831 }
832
833 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
834
Alan Coxb6c6b602006-03-24 03:18:26 -0800835 if (Rup >= (unsigned short) MAX_RUP) {
Alan Cox3b8e3f12006-03-24 03:18:24 -0800836 /*
837 ** It was a host that did the booting
838 */
839 MyType = "Host";
840 MyName = HostP->Name;
841 } else {
842 /*
843 ** It was an RTA that did the booting
844 */
845 MyType = "RTA";
846 MyName = HostP->Mapping[Rup].Name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 }
Alan Coxb6c6b602006-03-24 03:18:26 -0800848 MyLink = readb(&PktCmdP->LinkNum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849
850 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800851 ** There is no SLOT_IN_USE entry for this RTA attached to the current
852 ** host card in the driver table.
853 **
854 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the
855 ** current host card in the driver table.
856 **
857 ** If we find one, then we re-use that slot.
858 */
859 for (entry = 0; entry < MAX_RUP; entry++) {
860 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
861 if (RtaType == TYPE_RTA16) {
862 entry2 = HostP->Mapping[entry].ID2 - 1;
863 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
864 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
865 else
866 continue;
867 } else
868 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
869 if (!p->RIONoMessage)
Alan Coxb6c6b602006-03-24 03:18:26 -0800870 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
Alan Cox3b8e3f12006-03-24 03:18:24 -0800871 return TRUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 }
874
875 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800876 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
877 ** attached to the current host card in the driver table.
878 **
879 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another
880 ** host for this RTA in the driver table.
881 **
882 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA
883 ** entry from the other host and add it to this host (using some of
884 ** the functions from table.c which do this).
885 ** For a SLOT_TENTATIVE entry on another host, we must cope with the
886 ** following scenario:
887 **
888 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry
889 ** in table)
890 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE
891 ** entries)
892 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE)
893 ** + Unplug RTA and plug back into host A.
894 ** + Configure RTA on host A. We now have the same RTA configured
895 ** with different ports on two different hosts.
896 */
897 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 found = 0;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800899 Flag = 0; /* Convince the compiler this variable is initialized */
900 for (host = 0; !found && (host < p->RIONumHosts); host++) {
901 for (rta = 0; rta < MAX_RUP; rta++) {
902 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
903 Flag = p->RIOHosts[host].Mapping[rta].Flags;
904 MapP = &p->RIOHosts[host].Mapping[rta];
905 if (RtaType == TYPE_RTA16) {
906 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
907 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
908 } else
909 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
910 found = 1;
911 break;
912 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 }
915
916 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800917 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
918 ** attached to the current host card in the driver table.
919 **
920 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on
921 ** another host for this RTA in the driver table...
922 **
923 ** Check for a SLOT_IN_USE entry for this RTA in the config table.
924 */
925 if (!MapP) {
926 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
927 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
928 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929
Alan Cox3b8e3f12006-03-24 03:18:24 -0800930 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
931 MapP = &p->RIOSavedTable[rta];
932 Flag = p->RIOSavedTable[rta].Flags;
933 if (RtaType == TYPE_RTA16) {
934 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
935 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
936 break;
937 }
938 MapP2 = &p->RIOSavedTable[entry2];
939 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
940 } else
941 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
942 break;
943 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 }
946
947 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800948 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
949 ** attached to the current host card in the driver table.
950 **
951 ** We may have found a SLOT_IN_USE entry on another host for this
952 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry
953 ** on another host for this RTA in the driver table.
954 **
955 ** Check the driver table for room to fit this newly discovered RTA.
956 ** RIOFindFreeID() first looks for free slots and if it does not
957 ** find any free slots it will then attempt to oust any
958 ** tentative entry in the table.
959 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 EmptySlot = 1;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800961 if (RtaType == TYPE_RTA16) {
962 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
963 RIODefaultName(p, HostP, entry);
964 FillSlot(entry, entry2, RtaUniq, HostP);
965 EmptySlot = 0;
966 }
967 } else {
968 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
969 RIODefaultName(p, HostP, entry);
970 FillSlot(entry, 0, RtaUniq, HostP);
971 EmptySlot = 0;
972 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 }
974
975 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -0800976 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
977 ** attached to the current host card in the driver table.
978 **
979 ** If we found a SLOT_IN_USE entry on another host for this
980 ** RTA in the config or driver table, and there are enough free
981 ** slots in the driver table, then we need to move it over and
982 ** delete it from the other host.
983 ** If we found a SLOT_TENTATIVE entry on another host for this
984 ** RTA in the driver table, just delete the other host entry.
985 */
986 if (EmptySlot == 0) {
987 if (MapP) {
988 if (Flag & SLOT_IN_USE) {
989 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
990 HostP->Mapping[entry].SysPort = MapP->SysPort;
Alan Coxb6c6b602006-03-24 03:18:26 -0800991 memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN);
Alan Cox3b8e3f12006-03-24 03:18:24 -0800992 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
Alan Cox3b8e3f12006-03-24 03:18:24 -0800993 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
994 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
995 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
996 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
997 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
998 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
999 } else {
1000 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
1001 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
Alan Cox3b8e3f12006-03-24 03:18:24 -08001002 }
1003 if (RtaType == TYPE_RTA16) {
1004 if (Flag & SLOT_IN_USE) {
1005 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
Alan Cox3b8e3f12006-03-24 03:18:24 -08001006 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1007 /*
1008 ** Map second block of ttys for 16 port RTA
1009 */
1010 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
1011 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1012 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1013 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1014 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1015 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
1016 } else
1017 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
Alan Coxb6c6b602006-03-24 03:18:26 -08001018 memset(MapP2, 0, sizeof(struct Map));
Alan Cox3b8e3f12006-03-24 03:18:24 -08001019 }
Alan Coxb6c6b602006-03-24 03:18:26 -08001020 memset(MapP, 0, sizeof(struct Map));
Alan Cox3b8e3f12006-03-24 03:18:24 -08001021 if (!p->RIONoMessage)
Alan Coxb6c6b602006-03-24 03:18:26 -08001022 printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
Alan Cox3b8e3f12006-03-24 03:18:24 -08001023 } else if (!p->RIONoMessage)
Alan Coxb6c6b602006-03-24 03:18:26 -08001024 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
Alan Cox3b8e3f12006-03-24 03:18:24 -08001025 RIOSetChange(p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 return TRUE;
Alan Cox3b8e3f12006-03-24 03:18:24 -08001027 }
1028
1029 /*
1030 ** There is no room in the driver table to make an entry for the
1031 ** booted RTA. Keep a note of its Uniq Num in the overflow table,
1032 ** so we can ignore it's ID requests.
1033 */
1034 if (!p->RIONoMessage)
Alan Coxb6c6b602006-03-24 03:18:26 -08001035 printk("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n", MyType, MyName, MyLink + 'A');
Alan Cox3b8e3f12006-03-24 03:18:24 -08001036 for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
1037 if (HostP->ExtraUnits[entry] == RtaUniq) {
1038 /*
1039 ** already got it!
1040 */
1041 return TRUE;
1042 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 }
1044 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001045 ** If there is room, add the unit to the list of extras
1046 */
1047 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
1048 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 return TRUE;
1050}
1051
1052
1053/*
1054** If the RTA or its host appears in the RIOBindTab[] structure then
1055** we mustn't boot the RTA and should return FALSE.
1056** This operation is slightly different from the other drivers for RIO
1057** in that this is designed to work with the new utilities
1058** not config.rio and is FAR SIMPLER.
1059** We no longer support the RIOBootMode variable. It is all done from the
1060** "boot/noboot" field in the rio.cf file.
1061*/
Alan Coxb6c6b602006-03-24 03:18:26 -08001062int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063{
Alan Cox3b8e3f12006-03-24 03:18:24 -08001064 int Entry;
Alan Coxb6c6b602006-03-24 03:18:26 -08001065 unsigned int HostUniq = HostP->UniqueNum;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066
1067 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001068 ** Search bindings table for RTA or its parent.
1069 ** If it exists, return 0, else 1.
1070 */
1071 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
1072 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 return 0;
1074 }
1075 return 1;
1076}
1077
1078/*
1079** Make an empty slot tentative. If this is a 16 port RTA, make both
1080** slots tentative, and the second one RTA_SECOND_SLOT as well.
1081*/
1082
Alan Coxb6c6b602006-03-24 03:18:26 -08001083void FillSlot(int entry, int entry2, unsigned int RtaUniq, struct Host *HostP)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084{
Alan Cox3b8e3f12006-03-24 03:18:24 -08001085 int link;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086
Alan Cox3b8e3f12006-03-24 03:18:24 -08001087 rio_dprintk(RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088
1089 HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
1090 HostP->Mapping[entry].SysPort = NO_PORT;
1091 HostP->Mapping[entry].RtaUniqueNum = RtaUniq;
1092 HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum;
1093 HostP->Mapping[entry].ID = entry + 1;
1094 HostP->Mapping[entry].ID2 = 0;
1095 if (entry2) {
Alan Cox3b8e3f12006-03-24 03:18:24 -08001096 HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 HostP->Mapping[entry2].SysPort = NO_PORT;
1098 HostP->Mapping[entry2].RtaUniqueNum = RtaUniq;
1099 HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum;
1100 HostP->Mapping[entry2].Name[0] = '\0';
1101 HostP->Mapping[entry2].ID = entry2 + 1;
1102 HostP->Mapping[entry2].ID2 = entry + 1;
1103 HostP->Mapping[entry].ID2 = entry2 + 1;
1104 }
1105 /*
Alan Cox3b8e3f12006-03-24 03:18:24 -08001106 ** Must set these up, so that utilities show
1107 ** topology of 16 port RTAs correctly
1108 */
1109 for (link = 0; link < LINKS_PER_UNIT; link++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
1111 HostP->Mapping[entry].Topology[link].Link = NO_LINK;
1112 if (entry2) {
1113 HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
1114 HostP->Mapping[entry2].Topology[link].Link = NO_LINK;
1115 }
1116 }
1117}