1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 <linux/generic_serial.h>
39#include <linux/errno.h>
40#include <linux/interrupt.h>
41#include <linux/delay.h>
42#include <asm/io.h>
43#include <asm/system.h>
44#include <asm/string.h>
45#include <asm/uaccess.h>
46
47
48#include "linux_compat.h"
49#include "rio_linux.h"
50#include "pkt.h"
51#include "daemon.h"
52#include "rio.h"
53#include "riospace.h"
54#include "cmdpkt.h"
55#include "map.h"
56#include "rup.h"
57#include "port.h"
58#include "riodrvr.h"
59#include "rioinfo.h"
60#include "func.h"
61#include "errors.h"
62#include "pci.h"
63
64#include "parmmap.h"
65#include "unixrup.h"
66#include "board.h"
67#include "host.h"
68#include "phb.h"
69#include "link.h"
70#include "cmdblk.h"
71#include "route.h"
72
73static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP);
74
75static const unsigned char RIOAtVec2Ctrl[] = {
76 INTERRUPT_DISABLE,
77 INTERRUPT_DISABLE,
78 INTERRUPT_DISABLE,
79 INTERRUPT_DISABLE,
80 INTERRUPT_DISABLE,
81 INTERRUPT_DISABLE,
82 INTERRUPT_DISABLE,
83 INTERRUPT_DISABLE,
84 INTERRUPT_DISABLE,
85 IRQ_9 | INTERRUPT_ENABLE,
86 INTERRUPT_DISABLE,
87 IRQ_11 | INTERRUPT_ENABLE,
88 IRQ_12 | INTERRUPT_ENABLE,
89 INTERRUPT_DISABLE,
90 INTERRUPT_DISABLE,
91 IRQ_15 | INTERRUPT_ENABLE
92};
93
94
95
96
97
98
99
100
101
102
103int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp)
104{
105 int offset;
106
107 func_enter();
108
109 rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP);
110
111
112
113
114 if (rbp->Count > SIXTY_FOUR_K) {
115 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
116 p->RIOError.Error = HOST_FILE_TOO_LARGE;
117 func_exit();
118 return -ENOMEM;
119 }
120
121 if (p->RIOBooting) {
122 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
123 p->RIOError.Error = BOOT_IN_PROGRESS;
124 func_exit();
125 return -EBUSY;
126 }
127
128
129
130
131
132
133 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
134
135
136
137
138
139
140 memset(p->RIOBootPackets, 0, offset);
141
142
143
144
145
146 if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) {
147 rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n");
148 p->RIOError.Error = COPYIN_FAILED;
149 func_exit();
150 return -EFAULT;
151 }
152
153
154
155
156
157 p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE;
158 p->RIOBootCount = rbp->Count;
159
160 func_exit();
161 return 0;
162}
163
164
165
166
167
168
169
170
171
172void rio_start_card_running(struct Host *HostP)
173{
174 switch (HostP->Type) {
175 case RIO_AT:
176 rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n");
177 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control);
178 break;
179 case RIO_PCI:
180
181
182
183
184
185 rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n");
186 writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control);
187 break;
188 default:
189 rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
190 break;
191 }
192 return;
193}
194
195
196
197
198
199
200
201
202
203int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
204{
205 struct Host *HostP;
206 u8 __iomem *Cad;
207 PARM_MAP __iomem *ParmMapP;
208 int RupN;
209 int PortN;
210 unsigned int host;
211 u8 __iomem *StartP;
212 u8 __iomem *DestP;
213 int wait_count;
214 u16 OldParmMap;
215 u16 offset;
216 u8 *DownCode = NULL;
217 unsigned long flags;
218
219 HostP = NULL;
220
221
222
223 for (host = 0; host < p->RIONumHosts; host++) {
224 rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host);
225 HostP = &p->RIOHosts[host];
226
227 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
228
229
230 if ((HostP->Flags & RUN_STATE) != RC_WAITING) {
231 rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host);
232 continue;
233 }
234
235
236
237
238 Cad = HostP->Caddr;
239
240
241
242
243
244
245
246 StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count];
247
248 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad);
249 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP);
250 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
251 rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
252
253
254 if (p->RIOConf.HostLoadBase < rbp->Count) {
255 rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n");
256 p->RIOError.Error = HOST_FILE_TOO_LARGE;
257 func_exit();
258 return -EFBIG;
259 }
260
261
262
263
264 RIOHostReset(HostP->Type, HostP->CardP, HostP->Slot);
265
266
267
268
269
270
271 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
272
273
274
275
276 DownCode = vmalloc(rbp->Count);
277 if (!DownCode) {
278 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
279 func_exit();
280 return -ENOMEM;
281 }
282 if (copy_from_user(DownCode, rbp->DataP, rbp->Count)) {
283 kfree(DownCode);
284 p->RIOError.Error = COPYIN_FAILED;
285 func_exit();
286 return -EFAULT;
287 }
288 HostP->Copy(DownCode, StartP, rbp->Count);
289 vfree(DownCode);
290
291 rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n");
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368 DestP = &Cad[0x7FF8];
369
370#define NFIX(N) (0x60 | (N))
371#define PFIX(N) (0x20 | (N))
372#define JUMP(N) (0x00 | (N))
373
374
375
376
377
378
379
380
381
382
383 offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC;
384
385 writeb(NFIX(((unsigned short) (~offset) >> (unsigned short) 12) & 0xF), DestP);
386 writeb(PFIX((offset >> 8) & 0xF), DestP + 1);
387 writeb(PFIX((offset >> 4) & 0xF), DestP + 2);
388 writeb(JUMP(offset & 0xF), DestP + 3);
389
390 writeb(NFIX(0), DestP + 6);
391 writeb(JUMP(8), DestP + 7);
392
393 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
394 rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset);
395
396
397
398
399 HostP->Flags &= ~RUN_STATE;
400 HostP->Flags |= RC_STARTUP;
401
402
403
404
405
406 OldParmMap = readw(&HostP->__ParmMapR);
407
408 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
409
410
411
412
413
414
415 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
416
417 rio_start_card_running(HostP);
418
419 rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n");
420
421
422
423
424
425 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) {
426 rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR));
427 mdelay(100);
428
429 }
430
431
432
433
434
435 if (readw(&HostP->__ParmMapR) == OldParmMap) {
436 rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR));
437 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
438 HostP->Flags &= ~RUN_STATE;
439 HostP->Flags |= RC_STUFFED;
440 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot );
441 continue;
442 }
443
444 rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR));
445
446
447
448
449
450
451
452
453
454
455 ParmMapP = (PARM_MAP __iomem *) RIO_PTR(Cad, readw(&HostP->__ParmMapR));
456 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
457 ParmMapP = (PARM_MAP __iomem *)(Cad + readw(&HostP->__ParmMapR));
458 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
459
460
461
462
463
464
465 if (readw(&ParmMapP->links) != 0xFFFF) {
466 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
467 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links));
468 HostP->Flags &= ~RUN_STATE;
469 HostP->Flags |= RC_STUFFED;
470 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot );
471 continue;
472 }
473
474 writew(RIO_LINK_ENABLE, &ParmMapP->links);
475
476
477
478
479
480 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
481 HostP->timeout_id = 0;
482 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) {
483 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
484 mdelay(100);
485 }
486 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
487
488 if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) {
489 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
490 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
491 HostP->Flags &= ~RUN_STATE;
492 HostP->Flags |= RC_STUFFED;
493 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot );
494 continue;
495 }
496
497 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
498
499
500
501
502 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
503
504
505
506
507 writew(p->RIOConf.Timer, &ParmMapP->timer);
508
509
510
511
512
513 HostP->ParmMapP = ParmMapP;
514 HostP->PhbP = (struct PHB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
515 HostP->RupP = (struct RUP __iomem *) RIO_PTR(Cad, readw(&ParmMapP->rups));
516 HostP->PhbNumP = (unsigned short __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
517 HostP->LinkStrP = (struct LPB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
518
519
520
521
522 for (RupN = 0; RupN < MAX_RUP; RupN++) {
523 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
524 HostP->UnixRups[RupN].Id = RupN + 1;
525 HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
526 spin_lock_init(&HostP->UnixRups[RupN].RupLock);
527 }
528
529 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
530 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
531 HostP->UnixRups[RupN + MAX_RUP].Id = 0;
532 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
533 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
534 }
535
536
537
538
539 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
540 if (p->RIOPortp[PortN]->HostP == HostP) {
541 struct Port *PortP = p->RIOPortp[PortN];
542 struct PHB __iomem *PhbP;
543
544
545 if (!PortP->Mapped)
546 continue;
547
548 PhbP = &HostP->PhbP[PortP->HostPort];
549 rio_spin_lock_irqsave(&PortP->portSem, flags);
550
551 PortP->PhbP = PhbP;
552
553 PortP->TxAdd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_add));
554 PortP->TxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_start));
555 PortP->TxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_end));
556 PortP->RxRemove = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
557 PortP->RxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_start));
558 PortP->RxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_end));
559
560 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
561
562
563
564 if (!(PortN % PORTS_PER_RTA))
565 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
566 }
567 }
568
569 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
570
571
572
573 HostP->Flags &= ~RUN_STATE;
574 HostP->Flags |= RC_RUNNING;
575 }
576
577
578
579
580
581 p->RIOPolling = 1;
582
583 p->RIOSystemUp++;
584
585 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
586 func_exit();
587 return 0;
588}
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem *PacketP)
604{
605 struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data;
606 struct PktCmd_M *PktReplyP;
607 struct CmdBlk *CmdBlkP;
608 unsigned int sequence;
609
610
611
612
613 if (p->RIONumBootPkts == 0) {
614 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
615 return 0;
616 }
617
618
619
620
621
622
623
624 if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED))
625 return RIOBootComplete(p, HostP, Rup, PktCmdP);
626
627
628
629
630 if (!(CmdBlkP = RIOGetCmdBlk())) {
631 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
632 return 0;
633 }
634
635
636
637
638 CmdBlkP->Packet.dest_unit = Rup < (unsigned short) MAX_RUP ? Rup : 0;
639 CmdBlkP->Packet.dest_port = BOOT_RUP;
640 CmdBlkP->Packet.src_unit = 0;
641 CmdBlkP->Packet.src_port = BOOT_RUP;
642
643 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
644 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
645
646
647
648
649 if (readb(&PacketP->len) & PKT_CMD_BIT) {
650
651
652
653 if (readb(&PktCmdP->Command) != BOOT_REQUEST) {
654 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts);
655 RIOFreeCmdBlk(CmdBlkP);
656 return 1;
657 }
658
659
660
661
662
663
664
665
666
667
668
669 PktReplyP->Command = BOOT_SEQUENCE;
670
671 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
672 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
673 PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
674
675 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
676
677 memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4);
678
679 rio_dprintk(RIO_DEBUG_BOOT, "Boot RTA on Host %Zd Rup %d - %d (0x%x) packets to 0x%x\n", HostP - p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts, p->RIOConf.RtaLoadBase);
680
681
682
683
684
685
686
687
688 p->RIOBooting++;
689 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
690 return 1;
691 }
692
693
694
695
696 sequence = readw(&PktCmdP->Sequence);
697
698 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
699
700 if (sequence >= p->RIONumBootPkts) {
701 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
702 }
703
704 PktReplyP->Sequence = sequence;
705 memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE);
706 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
707 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
708 return 1;
709}
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP)
725{
726 struct Map *MapP = NULL;
727 struct Map *MapP2 = NULL;
728 int Flag;
729 int found;
730 int host, rta;
731 int EmptySlot = -1;
732 int entry, entry2;
733 char *MyType, *MyName;
734 unsigned int MyLink;
735 unsigned short RtaType;
736 u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
737
738 p->RIOBooting = 0;
739
740 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
741
742
743
744
745
746 RtaType = GetUnitType(RtaUniq);
747 if (Rup >= (unsigned short) MAX_RUP)
748 rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
749 else
750 rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
751
752 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
753
754 if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) {
755 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
756 return 1;
757 }
758
759
760
761
762
763
764
765 if (!RIOBootOk(p, HostP, RtaUniq)) {
766 MyLink = readb(&PktCmdP->LinkNum);
767 if (Rup < (unsigned short) MAX_RUP) {
768
769
770
771
772
773 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
774 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
775 }
776 } else
777
778
779
780
781
782 writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot);
783 rio_dprintk(RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n", RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
784 return 1;
785 }
786
787
788
789
790
791
792
793
794
795
796
797
798 for (entry = 0; entry < MAX_RUP; entry++) {
799 unsigned int sysport;
800
801 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
802 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
803 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
804 if (sysport < p->RIOFirstPortsBooted)
805 p->RIOFirstPortsBooted = sysport;
806 if (sysport > p->RIOLastPortsBooted)
807 p->RIOLastPortsBooted = sysport;
808
809
810
811 if (RtaType == TYPE_RTA16) {
812 entry2 = HostP->Mapping[entry].ID2 - 1;
813 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
814 sysport = HostP->Mapping[entry2].SysPort;
815 if (sysport < p->RIOFirstPortsBooted)
816 p->RIOFirstPortsBooted = sysport;
817 if (sysport > p->RIOLastPortsBooted)
818 p->RIOLastPortsBooted = sysport;
819 }
820 }
821 if (RtaType == TYPE_RTA16)
822 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
823 else
824 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
825 return 1;
826 }
827 }
828
829 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
830
831 if (Rup >= (unsigned short) MAX_RUP) {
832
833
834
835 MyType = "Host";
836 MyName = HostP->Name;
837 } else {
838
839
840
841 MyType = "RTA";
842 MyName = HostP->Mapping[Rup].Name;
843 }
844 MyLink = readb(&PktCmdP->LinkNum);
845
846
847
848
849
850
851
852
853
854
855 for (entry = 0; entry < MAX_RUP; entry++) {
856 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
857 if (RtaType == TYPE_RTA16) {
858 entry2 = HostP->Mapping[entry].ID2 - 1;
859 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
860 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
861 else
862 continue;
863 } else
864 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
865 if (!p->RIONoMessage)
866 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
867 return 1;
868 }
869 }
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
894 found = 0;
895 Flag = 0;
896 for (host = 0; !found && (host < p->RIONumHosts); host++) {
897 for (rta = 0; rta < MAX_RUP; rta++) {
898 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
899 Flag = p->RIOHosts[host].Mapping[rta].Flags;
900 MapP = &p->RIOHosts[host].Mapping[rta];
901 if (RtaType == TYPE_RTA16) {
902 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
903 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
904 } else
905 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
906 found = 1;
907 break;
908 }
909 }
910 }
911
912
913
914
915
916
917
918
919
920
921 if (!MapP) {
922 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
923 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
924 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
925
926 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
927 MapP = &p->RIOSavedTable[rta];
928 Flag = p->RIOSavedTable[rta].Flags;
929 if (RtaType == TYPE_RTA16) {
930 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
931 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
932 break;
933 }
934 MapP2 = &p->RIOSavedTable[entry2];
935 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
936 } else
937 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
938 break;
939 }
940 }
941 }
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956 EmptySlot = 1;
957 if (RtaType == TYPE_RTA16) {
958 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
959 RIODefaultName(p, HostP, entry);
960 rio_fill_host_slot(entry, entry2, RtaUniq, HostP);
961 EmptySlot = 0;
962 }
963 } else {
964 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
965 RIODefaultName(p, HostP, entry);
966 rio_fill_host_slot(entry, 0, RtaUniq, HostP);
967 EmptySlot = 0;
968 }
969 }
970
971
972
973
974
975
976
977
978
979
980
981
982 if (EmptySlot == 0) {
983 if (MapP) {
984 if (Flag & SLOT_IN_USE) {
985 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
986 HostP->Mapping[entry].SysPort = MapP->SysPort;
987 memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN);
988 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
989 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
990 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
991 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
992 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
993 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
994 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
995 } else {
996 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
997 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
998 }
999 if (RtaType == TYPE_RTA16) {
1000 if (Flag & SLOT_IN_USE) {
1001 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1002 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1003
1004
1005
1006 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
1007 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1008 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1009 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1010 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1011 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
1012 } else
1013 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1014 memset(MapP2, 0, sizeof(struct Map));
1015 }
1016 memset(MapP, 0, sizeof(struct Map));
1017 if (!p->RIONoMessage)
1018 printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
1019 } else if (!p->RIONoMessage)
1020 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
1021 RIOSetChange(p);
1022 return 1;
1023 }
1024
1025
1026
1027
1028
1029
1030 if (!p->RIONoMessage)
1031 printk("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n", MyType, MyName, MyLink + 'A');
1032 for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
1033 if (HostP->ExtraUnits[entry] == RtaUniq) {
1034
1035
1036
1037 return 1;
1038 }
1039 }
1040
1041
1042
1043 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
1044 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
1045 return 1;
1046}
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq)
1059{
1060 int Entry;
1061 unsigned int HostUniq = HostP->UniqueNum;
1062
1063
1064
1065
1066
1067 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
1068 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
1069 return 0;
1070 }
1071 return 1;
1072}
1073
1074
1075
1076
1077
1078
1079void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host)
1080{
1081 int link;
1082
1083 rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq);
1084
1085 host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
1086 host->Mapping[entry].SysPort = NO_PORT;
1087 host->Mapping[entry].RtaUniqueNum = rta_uniq;
1088 host->Mapping[entry].HostUniqueNum = host->UniqueNum;
1089 host->Mapping[entry].ID = entry + 1;
1090 host->Mapping[entry].ID2 = 0;
1091 if (entry2) {
1092 host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
1093 host->Mapping[entry2].SysPort = NO_PORT;
1094 host->Mapping[entry2].RtaUniqueNum = rta_uniq;
1095 host->Mapping[entry2].HostUniqueNum = host->UniqueNum;
1096 host->Mapping[entry2].Name[0] = '\0';
1097 host->Mapping[entry2].ID = entry2 + 1;
1098 host->Mapping[entry2].ID2 = entry + 1;
1099 host->Mapping[entry].ID2 = entry2 + 1;
1100 }
1101
1102
1103
1104
1105 for (link = 0; link < LINKS_PER_UNIT; link++) {
1106 host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
1107 host->Mapping[entry].Topology[link].Link = NO_LINK;
1108 if (entry2) {
1109 host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
1110 host->Mapping[entry2].Topology[link].Link = NO_LINK;
1111 }
1112 }
1113}
1114