1/* 2** ----------------------------------------------------------------------------- 3** 4** Perle Specialix driver for Linux 5** Ported from existing RIO Driver for SCO sources. 6 * 7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22** 23** Module : 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#include <linux/module.h> 34#include <linux/slab.h> 35#include <linux/termios.h> 36#include <linux/serial.h> 37#include <linux/vmalloc.h> 38#include <asm/semaphore.h> 39#include <linux/generic_serial.h> 40#include <linux/errno.h> 41#include <linux/interrupt.h> 42#include <linux/delay.h> 43#include <asm/io.h> 44#include <asm/system.h> 45#include <asm/string.h> 46#include <asm/uaccess.h> 47 48 49#include "linux_compat.h" 50#include "rio_linux.h" 51#include "pkt.h" 52#include "daemon.h" 53#include "rio.h" 54#include "riospace.h" 55#include "cmdpkt.h" 56#include "map.h" 57#include "rup.h" 58#include "port.h" 59#include "riodrvr.h" 60#include "rioinfo.h" 61#include "func.h" 62#include "errors.h" 63#include "pci.h" 64 65#include "parmmap.h" 66#include "unixrup.h" 67#include "board.h" 68#include "host.h" 69#include "phb.h" 70#include "link.h" 71#include "cmdblk.h" 72#include "route.h" 73 74static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP); 75 76static const unsigned char RIOAtVec2Ctrl[] = { 77 /* 0 */ INTERRUPT_DISABLE, 78 /* 1 */ INTERRUPT_DISABLE, 79 /* 2 */ INTERRUPT_DISABLE, 80 /* 3 */ INTERRUPT_DISABLE, 81 /* 4 */ INTERRUPT_DISABLE, 82 /* 5 */ INTERRUPT_DISABLE, 83 /* 6 */ INTERRUPT_DISABLE, 84 /* 7 */ INTERRUPT_DISABLE, 85 /* 8 */ INTERRUPT_DISABLE, 86 /* 9 */ IRQ_9 | INTERRUPT_ENABLE, 87 /* 10 */ INTERRUPT_DISABLE, 88 /* 11 */ IRQ_11 | INTERRUPT_ENABLE, 89 /* 12 */ IRQ_12 | INTERRUPT_ENABLE, 90 /* 13 */ INTERRUPT_DISABLE, 91 /* 14 */ INTERRUPT_DISABLE, 92 /* 15 */ IRQ_15 | INTERRUPT_ENABLE 93}; 94 95/** 96 * RIOBootCodeRTA - Load RTA boot code 97 * @p: RIO to load 98 * @rbp: Download descriptor 99 * 100 * Called when the user process initiates booting of the card firmware. 101 * Lads the firmware 102 */ 103 104int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp) 105{ 106 int offset; 107 108 func_enter(); 109 110 rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP); 111 112 /* 113 ** Check that we have set asside enough memory for this 114 */ 115 if (rbp->Count > SIXTY_FOUR_K) { 116 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n"); 117 p->RIOError.Error = HOST_FILE_TOO_LARGE; 118 func_exit(); 119 return -ENOMEM; 120 } 121 122 if (p->RIOBooting) { 123 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n"); 124 p->RIOError.Error = BOOT_IN_PROGRESS; 125 func_exit(); 126 return -EBUSY; 127 } 128 129 /* 130 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary, 131 ** so calculate how far we have to move the data up the buffer 132 ** to achieve this. 133 */ 134 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE; 135 136 /* 137 ** Be clean, and clear the 'unused' portion of the boot buffer, 138 ** because it will (eventually) be part of the Rta run time environment 139 ** and so should be zeroed. 140 */ 141 memset(p->RIOBootPackets, 0, offset); 142 143 /* 144 ** Copy the data from user space into the array 145 */ 146 147 if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) { 148 rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n"); 149 p->RIOError.Error = COPYIN_FAILED; 150 func_exit(); 151 return -EFAULT; 152 } 153 154 /* 155 ** Make sure that our copy of the size includes that offset we discussed 156 ** earlier. 157 */ 158 p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE; 159 p->RIOBootCount = rbp->Count; 160 161 func_exit(); 162 return 0; 163} 164 165/** 166 * rio_start_card_running - host card start 167 * @HostP: The RIO to kick off 168 * 169 * Start a RIO processor unit running. Encapsulates the knowledge 170 * of the card type. 171 */ 172 173void rio_start_card_running(struct Host *HostP) 174{ 175 switch (HostP->Type) { 176 case RIO_AT: 177 rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n"); 178 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control); 179 break; 180 case RIO_PCI: 181 /* 182 ** PCI is much the same as MCA. Everything is once again memory 183 ** mapped, so we are writing to memory registers instead of io 184 ** ports. 185 */ 186 rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n"); 187 writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control); 188 break; 189 default: 190 rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type); 191 break; 192 } 193 return; 194} 195 196/* 197** Load in the host boot code - load it directly onto all halted hosts 198** of the correct type. 199** 200** Put your rubber pants on before messing with this code - even the magic 201** numbers have trouble understanding what they are doing here. 202*/ 203 204int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) 205{ 206 struct Host *HostP; 207 u8 __iomem *Cad; 208 PARM_MAP __iomem *ParmMapP; 209 int RupN; 210 int PortN; 211 unsigned int host; 212 u8 __iomem *StartP; 213 u8 __iomem *DestP; 214 int wait_count; 215 u16 OldParmMap; 216 u16 offset; /* It is very important that this is a u16 */ 217 u8 *DownCode = NULL; 218 unsigned long flags; 219 220 HostP = NULL; /* Assure the compiler we've initialized it */ 221 222 223 /* Walk the hosts */ 224 for (host = 0; host < p->RIONumHosts; host++) { 225 rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host); 226 HostP = &p->RIOHosts[host]; 227 228 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec); 229 230 /* Don't boot hosts already running */ 231 if ((HostP->Flags & RUN_STATE) != RC_WAITING) { 232 rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host); 233 continue; 234 } 235 236 /* 237 ** Grab a pointer to the card (ioremapped) 238 */ 239 Cad = HostP->Caddr; 240 241 /* 242 ** We are going to (try) and load in rbp->Count bytes. 243 ** The last byte will reside at p->RIOConf.HostLoadBase-1; 244 ** Therefore, we need to start copying at address 245 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count) 246 */ 247 StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count]; 248 249 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad); 250 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP); 251 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase); 252 rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count); 253 254 /* Make sure it fits */ 255 if (p->RIOConf.HostLoadBase < rbp->Count) { 256 rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n"); 257 p->RIOError.Error = HOST_FILE_TOO_LARGE; 258 func_exit(); 259 return -EFBIG; 260 } 261 /* 262 ** Ensure that the host really is stopped. 263 ** Disable it's external bus & twang its reset line. 264 */ 265 RIOHostReset(HostP->Type, HostP->CardP, HostP->Slot); 266 267 /* 268 ** Copy the data directly from user space to the SRAM. 269 ** This ain't going to be none too clever if the download 270 ** code is bigger than this segment. 271 */ 272 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n"); 273 274 /* Buffer to local memory as we want to use I/O space and 275 some cards only do 8 or 16 bit I/O */ 276 277 DownCode = vmalloc(rbp->Count); 278 if (!DownCode) { 279 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY; 280 func_exit(); 281 return -ENOMEM; 282 } 283 if (copy_from_user(DownCode, rbp->DataP, rbp->Count)) { 284 kfree(DownCode); 285 p->RIOError.Error = COPYIN_FAILED; 286 func_exit(); 287 return -EFAULT; 288 } 289 HostP->Copy(DownCode, StartP, rbp->Count); 290 vfree(DownCode); 291 292 rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n"); 293 294 /* 295 ** S T O P ! 296 ** 297 ** Upto this point the code has been fairly rational, and possibly 298 ** even straight forward. What follows is a pile of crud that will 299 ** magically turn into six bytes of transputer assembler. Normally 300 ** you would expect an array or something, but, being me, I have 301 ** chosen [been told] to use a technique whereby the startup code 302 ** will be correct if we change the loadbase for the code. Which 303 ** brings us onto another issue - the loadbase is the *end* of the 304 ** code, not the start. 305 ** 306 ** If I were you I wouldn't start from here. 307 */ 308 309 /* 310 ** We now need to insert a short boot section into 311 ** the memory at the end of Sram2. This is normally (de)composed 312 ** of the last eight bytes of the download code. The 313 ** download has been assembled/compiled to expect to be 314 ** loaded from 0x7FFF downwards. We have loaded it 315 ** at some other address. The startup code goes into the small 316 ** ram window at Sram2, in the last 8 bytes, which are really 317 ** at addresses 0x7FF8-0x7FFF. 318 ** 319 ** If the loadbase is, say, 0x7C00, then we need to branch to 320 ** address 0x7BFE to run the host.bin startup code. We assemble 321 ** this jump manually. 322 ** 323 ** The two byte sequence 60 08 is loaded into memory at address 324 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0, 325 ** which adds '0' to the .O register, complements .O, and then shifts 326 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will 327 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new 328 ** location. Now, the branch starts from the value of .PC (or .IP or 329 ** whatever the bloody register is called on this chip), and the .PC 330 ** will be pointing to the location AFTER the branch, in this case 331 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8. 332 ** 333 ** A long branch is coded at 0x7FF8. This consists of loading a four 334 ** byte offset into .O using nfix (as above) and pfix operators. The 335 ** pfix operates in exactly the same way as the nfix operator, but 336 ** without the complement operation. The offset, of course, must be 337 ** relative to the address of the byte AFTER the branch instruction, 338 ** which will be (urm) 0x7FFC, so, our final destination of the branch 339 ** (loadbase-2), has to be reached from here. Imagine that the loadbase 340 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which 341 ** is the first byte of the initial two byte short local branch of the 342 ** download code). 343 ** 344 ** To code a jump from 0x7FFC (which is where the branch will start 345 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)= 346 ** 0x7BFE. 347 ** This will be coded as four bytes: 348 ** 60 2C 20 02 349 ** being nfix .O+0 350 ** pfix .O+C 351 ** pfix .O+0 352 ** jump .O+2 353 ** 354 ** The nfix operator is used, so that the startup code will be 355 ** compatible with the whole Tp family. (lies, damn lies, it'll never 356 ** work in a month of Sundays). 357 ** 358 ** The nfix nyble is the 1s complement of the nyble value you 359 ** want to load - in this case we wanted 'F' so we nfix loaded '0'. 360 */ 361 362 363 /* 364 ** Dest points to the top 8 bytes of Sram2. The Tp jumps 365 ** to 0x7FFE at reset time, and starts executing. This is 366 ** a short branch to 0x7FF8, where a long branch is coded. 367 */ 368 369 DestP = &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ 370 371#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */ 372#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */ 373#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */ 374 375 /* 376 ** 0x7FFC is the address of the location following the last byte of 377 ** the four byte jump instruction. 378 ** READ THE ABOVE COMMENTS 379 ** 380 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about. 381 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned, 382 ** cos I don't understand 2's complement). 383 */ 384 offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC; 385 386 writeb(NFIX(((unsigned short) (~offset) >> (unsigned short) 12) & 0xF), DestP); 387 writeb(PFIX((offset >> 8) & 0xF), DestP + 1); 388 writeb(PFIX((offset >> 4) & 0xF), DestP + 2); 389 writeb(JUMP(offset & 0xF), DestP + 3); 390 391 writeb(NFIX(0), DestP + 6); 392 writeb(JUMP(8), DestP + 7); 393 394 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase); 395 rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset); 396 397 /* 398 ** Flag what is going on 399 */ 400 HostP->Flags &= ~RUN_STATE; 401 HostP->Flags |= RC_STARTUP; 402 403 /* 404 ** Grab a copy of the current ParmMap pointer, so we 405 ** can tell when it has changed. 406 */ 407 OldParmMap = readw(&HostP->__ParmMapR); 408 409 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap); 410 411 /* 412 ** And start it running (I hope). 413 ** As there is nothing dodgy or obscure about the 414 ** above code, this is guaranteed to work every time. 415 */ 416 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec); 417 418 rio_start_card_running(HostP); 419 420 rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n"); 421 422 /* 423 ** Now, wait for upto five seconds for the Tp to setup the parmmap 424 ** pointer: 425 */ 426 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) { 427 rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR)); 428 mdelay(100); 429 430 } 431 432 /* 433 ** If the parmmap pointer is unchanged, then the host code 434 ** has crashed & burned in a really spectacular way 435 */ 436 if (readw(&HostP->__ParmMapR) == OldParmMap) { 437 rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR)); 438 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n"); 439 HostP->Flags &= ~RUN_STATE; 440 HostP->Flags |= RC_STUFFED; 441 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot ); 442 continue; 443 } 444 445 rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR)); 446 447 /* 448 ** Well, the board thought it was OK, and setup its parmmap 449 ** pointer. For the time being, we will pretend that this 450 ** board is running, and check out what the error flag says. 451 */ 452 453 /* 454 ** Grab a 32 bit pointer to the parmmap structure 455 */ 456 ParmMapP = (PARM_MAP __iomem *) RIO_PTR(Cad, readw(&HostP->__ParmMapR)); 457 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); 458 ParmMapP = (PARM_MAP __iomem *)(Cad + readw(&HostP->__ParmMapR)); 459 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); 460 461 /* 462 ** The links entry should be 0xFFFF; we set it up 463 ** with a mask to say how many PHBs to use, and 464 ** which links to use. 465 */ 466 if (readw(&ParmMapP->links) != 0xFFFF) { 467 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 468 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links)); 469 HostP->Flags &= ~RUN_STATE; 470 HostP->Flags |= RC_STUFFED; 471 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot ); 472 continue; 473 } 474 475 writew(RIO_LINK_ENABLE, &ParmMapP->links); 476 477 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime); 478 HostP->timeout_id = 0; 479 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) { 480 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n"); 481 mdelay(100); 482 } 483 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n"); 484 485 if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) { 486 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 487 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n"); 488 HostP->Flags &= ~RUN_STATE; 489 HostP->Flags |= RC_STUFFED; 490 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot ); 491 continue; 492 } 493 494 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n"); 495 496 /* 497 ** It runs! It runs! 498 */ 499 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum); 500 501 /* 502 ** set the time period between interrupts. 503 */ 504 writew(p->RIOConf.Timer, &ParmMapP->timer); 505 506 /* 507 ** Translate all the 16 bit pointers in the __ParmMapR into 508 ** 32 bit pointers for the driver in ioremap space. 509 */ 510 HostP->ParmMapP = ParmMapP; 511 HostP->PhbP = (struct PHB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr)); 512 HostP->RupP = (struct RUP __iomem *) RIO_PTR(Cad, readw(&ParmMapP->rups)); 513 HostP->PhbNumP = (unsigned short __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr)); 514 HostP->LinkStrP = (struct LPB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr)); 515 516 /* 517 ** point the UnixRups at the real Rups 518 */ 519 for (RupN = 0; RupN < MAX_RUP; RupN++) { 520 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN]; 521 HostP->UnixRups[RupN].Id = RupN + 1; 522 HostP->UnixRups[RupN].BaseSysPort = NO_PORT; 523 spin_lock_init(&HostP->UnixRups[RupN].RupLock); 524 } 525 526 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) { 527 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup; 528 HostP->UnixRups[RupN + MAX_RUP].Id = 0; 529 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT; 530 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock); 531 } 532 533 /* 534 ** point the PortP->Phbs at the real Phbs 535 */ 536 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) { 537 if (p->RIOPortp[PortN]->HostP == HostP) { 538 struct Port *PortP = p->RIOPortp[PortN]; 539 struct PHB __iomem *PhbP; 540 /* int oldspl; */ 541 542 if (!PortP->Mapped) 543 continue; 544 545 PhbP = &HostP->PhbP[PortP->HostPort]; 546 rio_spin_lock_irqsave(&PortP->portSem, flags); 547 548 PortP->PhbP = PhbP; 549 550 PortP->TxAdd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_add)); 551 PortP->TxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_start)); 552 PortP->TxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_end)); 553 PortP->RxRemove = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_remove)); 554 PortP->RxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_start)); 555 PortP->RxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_end)); 556 557 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 558 /* 559 ** point the UnixRup at the base SysPort 560 */ 561 if (!(PortN % PORTS_PER_RTA)) 562 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN; 563 } 564 } 565 566 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n"); 567 /* 568 ** last thing - show the world that everything is in place 569 */ 570 HostP->Flags &= ~RUN_STATE; 571 HostP->Flags |= RC_RUNNING; 572 } 573 /* 574 ** MPX always uses a poller. This is actually patched into the system 575 ** configuration and called directly from each clock tick. 576 ** 577 */ 578 p->RIOPolling = 1; 579 580 p->RIOSystemUp++; 581 582 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec); 583 func_exit(); 584 return 0; 585} 586 587 588 589/** 590 * RIOBootRup - Boot an RTA 591 * @p: rio we are working with 592 * @Rup: Rup number 593 * @HostP: host object 594 * @PacketP: packet to use 595 * 596 * If we have successfully processed this boot, then 597 * return 1. If we havent, then return 0. 598 */ 599 600int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem *PacketP) 601{ 602 struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data; 603 struct PktCmd_M *PktReplyP; 604 struct CmdBlk *CmdBlkP; 605 unsigned int sequence; 606 607 /* 608 ** If we haven't been told what to boot, we can't boot it. 609 */ 610 if (p->RIONumBootPkts == 0) { 611 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n"); 612 return 0; 613 } 614 615 /* 616 ** Special case of boot completed - if we get one of these then we 617 ** don't need a command block. For all other cases we do, so handle 618 ** this first and then get a command block, then handle every other 619 ** case, relinquishing the command block if disaster strikes! 620 */ 621 if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED)) 622 return RIOBootComplete(p, HostP, Rup, PktCmdP); 623 624 /* 625 ** Try to allocate a command block. This is in kernel space 626 */ 627 if (!(CmdBlkP = RIOGetCmdBlk())) { 628 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n"); 629 return 0; 630 } 631 632 /* 633 ** Fill in the default info on the command block 634 */ 635 CmdBlkP->Packet.dest_unit = Rup < (unsigned short) MAX_RUP ? Rup : 0; 636 CmdBlkP->Packet.dest_port = BOOT_RUP; 637 CmdBlkP->Packet.src_unit = 0; 638 CmdBlkP->Packet.src_port = BOOT_RUP; 639 640 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL; 641 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data; 642 643 /* 644 ** process COMMANDS on the boot rup! 645 */ 646 if (readb(&PacketP->len) & PKT_CMD_BIT) { 647 /* 648 ** We only expect one type of command - a BOOT_REQUEST! 649 */ 650 if (readb(&PktCmdP->Command) != BOOT_REQUEST) { 651 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts); 652 RIOFreeCmdBlk(CmdBlkP); 653 return 1; 654 } 655 656 /* 657 ** Build a Boot Sequence command block 658 ** 659 ** We no longer need to use "Boot Mode", we'll always allow 660 ** boot requests - the boot will not complete if the device 661 ** appears in the bindings table. 662 ** 663 ** We'll just (always) set the command field in packet reply 664 ** to allow an attempted boot sequence : 665 */ 666 PktReplyP->Command = BOOT_SEQUENCE; 667 668 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts; 669 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase; 670 PktReplyP->BootSequence.CodeSize = p->RIOBootCount; 671 672 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT; 673 674 memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4); 675 676 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); 677 678 /* 679 ** If this host is in slave mode, send the RTA an invalid boot 680 ** sequence command block to force it to kill the boot. We wait 681 ** for half a second before sending this packet to prevent the RTA 682 ** attempting to boot too often. The master host should then grab 683 ** the RTA and make it its own. 684 */ 685 p->RIOBooting++; 686 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 687 return 1; 688 } 689 690 /* 691 ** It is a request for boot data. 692 */ 693 sequence = readw(&PktCmdP->Sequence); 694 695 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup); 696 697 if (sequence >= p->RIONumBootPkts) { 698 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts); 699 } 700 701 PktReplyP->Sequence = sequence; 702 memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE); 703 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN; 704 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 705 return 1; 706} 707 708/** 709 * RIOBootComplete - RTA boot is done 710 * @p: RIO we are working with 711 * @HostP: Host structure 712 * @Rup: RUP being used 713 * @PktCmdP: Packet command that was used 714 * 715 * This function is called when an RTA been booted. 716 * If booted by a host, HostP->HostUniqueNum is the booting host. 717 * If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA. 718 * RtaUniq is the booted RTA. 719 */ 720 721static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP) 722{ 723 struct Map *MapP = NULL; 724 struct Map *MapP2 = NULL; 725 int Flag; 726 int found; 727 int host, rta; 728 int EmptySlot = -1; 729 int entry, entry2; 730 char *MyType, *MyName; 731 unsigned int MyLink; 732 unsigned short RtaType; 733 u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24); 734 735 p->RIOBooting = 0; 736 737 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting); 738 739 /* 740 ** Determine type of unit (16/8 port RTA). 741 */ 742 743 RtaType = GetUnitType(RtaUniq); 744 if (Rup >= (unsigned short) MAX_RUP) 745 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'); 746 else 747 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'); 748 749 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq); 750 751 if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) { 752 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n"); 753 return 1; 754 } 755 756 /* 757 ** If this RTA has just booted an RTA which doesn't belong to this 758 ** system, or the system is in slave mode, do not attempt to create 759 ** a new table entry for it. 760 */ 761 762 if (!RIOBootOk(p, HostP, RtaUniq)) { 763 MyLink = readb(&PktCmdP->LinkNum); 764 if (Rup < (unsigned short) MAX_RUP) { 765 /* 766 ** RtaUniq was clone booted (by this RTA). Instruct this RTA 767 ** to hold off further attempts to boot on this link for 30 768 ** seconds. 769 */ 770 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) { 771 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink); 772 } 773 } else 774 /* 775 ** RtaUniq was booted by this host. Set the booting link 776 ** to hold off for 30 seconds to give another unit a 777 ** chance to boot it. 778 */ 779 writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot); 780 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); 781 return 1; 782 } 783 784 /* 785 ** Check for a SLOT_IN_USE entry for this RTA attached to the 786 ** current host card in the driver table. 787 ** 788 ** If it exists, make a note that we have booted it. Other parts of 789 ** the driver are interested in this information at a later date, 790 ** in particular when the booting RTA asks for an ID for this unit, 791 ** we must have set the BOOTED flag, and the NEWBOOT flag is used 792 ** to force an open on any ports that where previously open on this 793 ** unit. 794 */ 795 for (entry = 0; entry < MAX_RUP; entry++) { 796 unsigned int sysport; 797 798 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) { 799 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT; 800 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) { 801 if (sysport < p->RIOFirstPortsBooted) 802 p->RIOFirstPortsBooted = sysport; 803 if (sysport > p->RIOLastPortsBooted) 804 p->RIOLastPortsBooted = sysport; 805 /* 806 ** For a 16 port RTA, check the second bank of 8 ports 807 */ 808 if (RtaType == TYPE_RTA16) { 809 entry2 = HostP->Mapping[entry].ID2 - 1; 810 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT; 811 sysport = HostP->Mapping[entry2].SysPort; 812 if (sysport < p->RIOFirstPortsBooted) 813 p->RIOFirstPortsBooted = sysport; 814 if (sysport > p->RIOLastPortsBooted) 815 p->RIOLastPortsBooted = sysport; 816 } 817 } 818 if (RtaType == TYPE_RTA16) 819 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1); 820 else 821 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1); 822 return 1; 823 } 824 } 825 826 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n"); 827 828 if (Rup >= (unsigned short) MAX_RUP) { 829 /* 830 ** It was a host that did the booting 831 */ 832 MyType = "Host"; 833 MyName = HostP->Name; 834 } else { 835 /* 836 ** It was an RTA that did the booting 837 */ 838 MyType = "RTA"; 839 MyName = HostP->Mapping[Rup].Name; 840 } 841 MyLink = readb(&PktCmdP->LinkNum); 842 843 /* 844 ** There is no SLOT_IN_USE entry for this RTA attached to the current 845 ** host card in the driver table. 846 ** 847 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the 848 ** current host card in the driver table. 849 ** 850 ** If we find one, then we re-use that slot. 851 */ 852 for (entry = 0; entry < MAX_RUP; entry++) { 853 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) { 854 if (RtaType == TYPE_RTA16) { 855 entry2 = HostP->Mapping[entry].ID2 - 1; 856 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq)) 857 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2); 858 else 859 continue; 860 } else 861 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry); 862 if (!p->RIONoMessage) 863 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A'); 864 return 1; 865 } 866 } 867 868 /* 869 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 870 ** attached to the current host card in the driver table. 871 ** 872 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another 873 ** host for this RTA in the driver table. 874 ** 875 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA 876 ** entry from the other host and add it to this host (using some of 877 ** the functions from table.c which do this). 878 ** For a SLOT_TENTATIVE entry on another host, we must cope with the 879 ** following scenario: 880 ** 881 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry 882 ** in table) 883 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE 884 ** entries) 885 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE) 886 ** + Unplug RTA and plug back into host A. 887 ** + Configure RTA on host A. We now have the same RTA configured 888 ** with different ports on two different hosts. 889 */ 890 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq); 891 found = 0; 892 Flag = 0; /* Convince the compiler this variable is initialized */ 893 for (host = 0; !found && (host < p->RIONumHosts); host++) { 894 for (rta = 0; rta < MAX_RUP; rta++) { 895 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) { 896 Flag = p->RIOHosts[host].Mapping[rta].Flags; 897 MapP = &p->RIOHosts[host].Mapping[rta]; 898 if (RtaType == TYPE_RTA16) { 899 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1]; 900 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name); 901 } else 902 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name); 903 found = 1; 904 break; 905 } 906 } 907 } 908 909 /* 910 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 911 ** attached to the current host card in the driver table. 912 ** 913 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on 914 ** another host for this RTA in the driver table... 915 ** 916 ** Check for a SLOT_IN_USE entry for this RTA in the config table. 917 */ 918 if (!MapP) { 919 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq); 920 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) { 921 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum); 922 923 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) { 924 MapP = &p->RIOSavedTable[rta]; 925 Flag = p->RIOSavedTable[rta].Flags; 926 if (RtaType == TYPE_RTA16) { 927 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) { 928 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq) 929 break; 930 } 931 MapP2 = &p->RIOSavedTable[entry2]; 932 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2); 933 } else 934 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta); 935 break; 936 } 937 } 938 } 939 940 /* 941 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 942 ** attached to the current host card in the driver table. 943 ** 944 ** We may have found a SLOT_IN_USE entry on another host for this 945 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry 946 ** on another host for this RTA in the driver table. 947 ** 948 ** Check the driver table for room to fit this newly discovered RTA. 949 ** RIOFindFreeID() first looks for free slots and if it does not 950 ** find any free slots it will then attempt to oust any 951 ** tentative entry in the table. 952 */ 953 EmptySlot = 1; 954 if (RtaType == TYPE_RTA16) { 955 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) { 956 RIODefaultName(p, HostP, entry); 957 rio_fill_host_slot(entry, entry2, RtaUniq, HostP); 958 EmptySlot = 0; 959 } 960 } else { 961 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) { 962 RIODefaultName(p, HostP, entry); 963 rio_fill_host_slot(entry, 0, RtaUniq, HostP); 964 EmptySlot = 0; 965 } 966 } 967 968 /* 969 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 970 ** attached to the current host card in the driver table. 971 ** 972 ** If we found a SLOT_IN_USE entry on another host for this 973 ** RTA in the config or driver table, and there are enough free 974 ** slots in the driver table, then we need to move it over and 975 ** delete it from the other host. 976 ** If we found a SLOT_TENTATIVE entry on another host for this 977 ** RTA in the driver table, just delete the other host entry. 978 */ 979 if (EmptySlot == 0) { 980 if (MapP) { 981 if (Flag & SLOT_IN_USE) { 982 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n"); 983 HostP->Mapping[entry].SysPort = MapP->SysPort; 984 memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN); 985 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT; 986 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]); 987 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted) 988 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort; 989 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted) 990 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort; 991 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name); 992 } else { 993 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n"); 994 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT; 995 } 996 if (RtaType == TYPE_RTA16) { 997 if (Flag & SLOT_IN_USE) { 998 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; 999 HostP->Mapping[entry2].SysPort = MapP2->SysPort; 1000 /* 1001 ** Map second block of ttys for 16 port RTA 1002 */ 1003 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]); 1004 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted) 1005 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort; 1006 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted) 1007 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort; 1008 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name); 1009 } else 1010 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; 1011 memset(MapP2, 0, sizeof(struct Map)); 1012 } 1013 memset(MapP, 0, sizeof(struct Map)); 1014 if (!p->RIONoMessage) 1015 printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A'); 1016 } else if (!p->RIONoMessage) 1017 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A'); 1018 RIOSetChange(p); 1019 return 1; 1020 } 1021 1022 /* 1023 ** There is no room in the driver table to make an entry for the 1024 ** booted RTA. Keep a note of its Uniq Num in the overflow table, 1025 ** so we can ignore it's ID requests. 1026 */ 1027 if (!p->RIONoMessage) 1028 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'); 1029 for (entry = 0; entry < HostP->NumExtraBooted; entry++) { 1030 if (HostP->ExtraUnits[entry] == RtaUniq) { 1031 /* 1032 ** already got it! 1033 */ 1034 return 1; 1035 } 1036 } 1037 /* 1038 ** If there is room, add the unit to the list of extras 1039 */ 1040 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS) 1041 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq; 1042 return 1; 1043} 1044 1045 1046/* 1047** If the RTA or its host appears in the RIOBindTab[] structure then 1048** we mustn't boot the RTA and should return 0. 1049** This operation is slightly different from the other drivers for RIO 1050** in that this is designed to work with the new utilities 1051** not config.rio and is FAR SIMPLER. 1052** We no longer support the RIOBootMode variable. It is all done from the 1053** "boot/noboot" field in the rio.cf file. 1054*/ 1055int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq) 1056{ 1057 int Entry; 1058 unsigned int HostUniq = HostP->UniqueNum; 1059 1060 /* 1061 ** Search bindings table for RTA or its parent. 1062 ** If it exists, return 0, else 1. 1063 */ 1064 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) { 1065 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq)) 1066 return 0; 1067 } 1068 return 1; 1069} 1070 1071/* 1072** Make an empty slot tentative. If this is a 16 port RTA, make both 1073** slots tentative, and the second one RTA_SECOND_SLOT as well. 1074*/ 1075 1076void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host) 1077{ 1078 int link; 1079 1080 rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq); 1081 1082 host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE); 1083 host->Mapping[entry].SysPort = NO_PORT; 1084 host->Mapping[entry].RtaUniqueNum = rta_uniq; 1085 host->Mapping[entry].HostUniqueNum = host->UniqueNum; 1086 host->Mapping[entry].ID = entry + 1; 1087 host->Mapping[entry].ID2 = 0; 1088 if (entry2) { 1089 host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT); 1090 host->Mapping[entry2].SysPort = NO_PORT; 1091 host->Mapping[entry2].RtaUniqueNum = rta_uniq; 1092 host->Mapping[entry2].HostUniqueNum = host->UniqueNum; 1093 host->Mapping[entry2].Name[0] = '\0'; 1094 host->Mapping[entry2].ID = entry2 + 1; 1095 host->Mapping[entry2].ID2 = entry + 1; 1096 host->Mapping[entry].ID2 = entry2 + 1; 1097 } 1098 /* 1099 ** Must set these up, so that utilities show 1100 ** topology of 16 port RTAs correctly 1101 */ 1102 for (link = 0; link < LINKS_PER_UNIT; link++) { 1103 host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT; 1104 host->Mapping[entry].Topology[link].Link = NO_LINK; 1105 if (entry2) { 1106 host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT; 1107 host->Mapping[entry2].Topology[link].Link = NO_LINK; 1108 } 1109 } 1110} 1111