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 <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 INTERRUPT_DISABLE,
78 INTERRUPT_DISABLE,
79 INTERRUPT_DISABLE,
80 INTERRUPT_DISABLE,
81 INTERRUPT_DISABLE,
82 INTERRUPT_DISABLE,
83 INTERRUPT_DISABLE,
84 INTERRUPT_DISABLE,
85 INTERRUPT_DISABLE,
86 IRQ_9 | INTERRUPT_ENABLE,
87 INTERRUPT_DISABLE,
88 IRQ_11 | INTERRUPT_ENABLE,
89 IRQ_12 | INTERRUPT_ENABLE,
90 INTERRUPT_DISABLE,
91 INTERRUPT_DISABLE,
92 IRQ_15 | INTERRUPT_ENABLE
93};
94
95
96
97
98
99
100
101
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
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
131
132
133
134 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
135
136
137
138
139
140
141 memset(p->RIOBootPackets, 0, offset);
142
143
144
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
156
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
167
168
169
170
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
183
184
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
198
199
200
201
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;
217 u8 *DownCode = NULL;
218 unsigned long flags;
219
220 HostP = NULL;
221
222
223
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
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
238
239 Cad = HostP->Caddr;
240
241
242
243
244
245
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
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
263
264
265 RIOHostReset(HostP->Type, HostP->CardP, HostP->Slot);
266
267
268
269
270
271
272 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
273
274
275
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
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
369 DestP = &Cad[0x7FF8];
370
371#define NFIX(N) (0x60 | (N))
372#define PFIX(N) (0x20 | (N))
373#define JUMP(N) (0x00 | (N))
374
375
376
377
378
379
380
381
382
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
399
400 HostP->Flags &= ~RUN_STATE;
401 HostP->Flags |= RC_STARTUP;
402
403
404
405
406
407 OldParmMap = readw(&HostP->__ParmMapR);
408
409 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
410
411
412
413
414
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
424
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
434
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
449
450
451
452
453
454
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
463
464
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
478
479
480
481 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
482 HostP->timeout_id = 0;
483 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) {
484 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
485 mdelay(100);
486 }
487 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
488
489 if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) {
490 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
491 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
492 HostP->Flags &= ~RUN_STATE;
493 HostP->Flags |= RC_STUFFED;
494 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot );
495 continue;
496 }
497
498 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
499
500
501
502
503 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
504
505
506
507
508 writew(p->RIOConf.Timer, &ParmMapP->timer);
509
510
511
512
513
514 HostP->ParmMapP = ParmMapP;
515 HostP->PhbP = (struct PHB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
516 HostP->RupP = (struct RUP __iomem *) RIO_PTR(Cad, readw(&ParmMapP->rups));
517 HostP->PhbNumP = (unsigned short __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
518 HostP->LinkStrP = (struct LPB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
519
520
521
522
523 for (RupN = 0; RupN < MAX_RUP; RupN++) {
524 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
525 HostP->UnixRups[RupN].Id = RupN + 1;
526 HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
527 spin_lock_init(&HostP->UnixRups[RupN].RupLock);
528 }
529
530 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
531 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
532 HostP->UnixRups[RupN + MAX_RUP].Id = 0;
533 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
534 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
535 }
536
537
538
539
540 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
541 if (p->RIOPortp[PortN]->HostP == HostP) {
542 struct Port *PortP = p->RIOPortp[PortN];
543 struct PHB __iomem *PhbP;
544
545
546 if (!PortP->Mapped)
547 continue;
548
549 PhbP = &HostP->PhbP[PortP->HostPort];
550 rio_spin_lock_irqsave(&PortP->portSem, flags);
551
552 PortP->PhbP = PhbP;
553
554 PortP->TxAdd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_add));
555 PortP->TxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_start));
556 PortP->TxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_end));
557 PortP->RxRemove = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
558 PortP->RxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_start));
559 PortP->RxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_end));
560
561 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
562
563
564
565 if (!(PortN % PORTS_PER_RTA))
566 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
567 }
568 }
569
570 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
571
572
573
574 HostP->Flags &= ~RUN_STATE;
575 HostP->Flags |= RC_RUNNING;
576 }
577
578
579
580
581
582 p->RIOPolling = 1;
583
584 p->RIOSystemUp++;
585
586 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
587 func_exit();
588 return 0;
589}
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem *PacketP)
605{
606 struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data;
607 struct PktCmd_M *PktReplyP;
608 struct CmdBlk *CmdBlkP;
609 unsigned int sequence;
610
611
612
613
614 if (p->RIONumBootPkts == 0) {
615 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
616 return 0;
617 }
618
619
620
621
622
623
624
625 if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED))
626 return RIOBootComplete(p, HostP, Rup, PktCmdP);
627
628
629
630
631 if (!(CmdBlkP = RIOGetCmdBlk())) {
632 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
633 return 0;
634 }
635
636
637
638
639 CmdBlkP->Packet.dest_unit = Rup < (unsigned short) MAX_RUP ? Rup : 0;
640 CmdBlkP->Packet.dest_port = BOOT_RUP;
641 CmdBlkP->Packet.src_unit = 0;
642 CmdBlkP->Packet.src_port = BOOT_RUP;
643
644 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
645 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
646
647
648
649
650 if (readb(&PacketP->len) & PKT_CMD_BIT) {
651
652
653
654 if (readb(&PktCmdP->Command) != BOOT_REQUEST) {
655 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts);
656 RIOFreeCmdBlk(CmdBlkP);
657 return 1;
658 }
659
660
661
662
663
664
665
666
667
668
669
670 PktReplyP->Command = BOOT_SEQUENCE;
671
672 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
673 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
674 PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
675
676 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
677
678 memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4);
679
680 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);
681
682
683
684
685
686
687
688
689 p->RIOBooting++;
690 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
691 return 1;
692 }
693
694
695
696
697 sequence = readw(&PktCmdP->Sequence);
698
699 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
700
701 if (sequence >= p->RIONumBootPkts) {
702 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
703 }
704
705 PktReplyP->Sequence = sequence;
706 memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE);
707 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
708 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
709 return 1;
710}
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP)
726{
727 struct Map *MapP = NULL;
728 struct Map *MapP2 = NULL;
729 int Flag;
730 int found;
731 int host, rta;
732 int EmptySlot = -1;
733 int entry, entry2;
734 char *MyType, *MyName;
735 unsigned int MyLink;
736 unsigned short RtaType;
737 u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
738
739 p->RIOBooting = 0;
740
741 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
742
743
744
745
746
747 RtaType = GetUnitType(RtaUniq);
748 if (Rup >= (unsigned short) MAX_RUP)
749 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');
750 else
751 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');
752
753 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
754
755 if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) {
756 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
757 return 1;
758 }
759
760
761
762
763
764
765
766 if (!RIOBootOk(p, HostP, RtaUniq)) {
767 MyLink = readb(&PktCmdP->LinkNum);
768 if (Rup < (unsigned short) MAX_RUP) {
769
770
771
772
773
774 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
775 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
776 }
777 } else
778
779
780
781
782
783 writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot);
784 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);
785 return 1;
786 }
787
788
789
790
791
792
793
794
795
796
797
798
799 for (entry = 0; entry < MAX_RUP; entry++) {
800 unsigned int sysport;
801
802 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
803 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
804 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
805 if (sysport < p->RIOFirstPortsBooted)
806 p->RIOFirstPortsBooted = sysport;
807 if (sysport > p->RIOLastPortsBooted)
808 p->RIOLastPortsBooted = sysport;
809
810
811
812 if (RtaType == TYPE_RTA16) {
813 entry2 = HostP->Mapping[entry].ID2 - 1;
814 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
815 sysport = HostP->Mapping[entry2].SysPort;
816 if (sysport < p->RIOFirstPortsBooted)
817 p->RIOFirstPortsBooted = sysport;
818 if (sysport > p->RIOLastPortsBooted)
819 p->RIOLastPortsBooted = sysport;
820 }
821 }
822 if (RtaType == TYPE_RTA16)
823 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
824 else
825 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
826 return 1;
827 }
828 }
829
830 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
831
832 if (Rup >= (unsigned short) MAX_RUP) {
833
834
835
836 MyType = "Host";
837 MyName = HostP->Name;
838 } else {
839
840
841
842 MyType = "RTA";
843 MyName = HostP->Mapping[Rup].Name;
844 }
845 MyLink = readb(&PktCmdP->LinkNum);
846
847
848
849
850
851
852
853
854
855
856 for (entry = 0; entry < MAX_RUP; entry++) {
857 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
858 if (RtaType == TYPE_RTA16) {
859 entry2 = HostP->Mapping[entry].ID2 - 1;
860 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
861 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
862 else
863 continue;
864 } else
865 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
866 if (!p->RIONoMessage)
867 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
868 return 1;
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
894 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
895 found = 0;
896 Flag = 0;
897 for (host = 0; !found && (host < p->RIONumHosts); host++) {
898 for (rta = 0; rta < MAX_RUP; rta++) {
899 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
900 Flag = p->RIOHosts[host].Mapping[rta].Flags;
901 MapP = &p->RIOHosts[host].Mapping[rta];
902 if (RtaType == TYPE_RTA16) {
903 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
904 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
905 } else
906 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
907 found = 1;
908 break;
909 }
910 }
911 }
912
913
914
915
916
917
918
919
920
921
922 if (!MapP) {
923 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
924 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
925 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
926
927 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
928 MapP = &p->RIOSavedTable[rta];
929 Flag = p->RIOSavedTable[rta].Flags;
930 if (RtaType == TYPE_RTA16) {
931 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
932 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
933 break;
934 }
935 MapP2 = &p->RIOSavedTable[entry2];
936 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
937 } else
938 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
939 break;
940 }
941 }
942 }
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957 EmptySlot = 1;
958 if (RtaType == TYPE_RTA16) {
959 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
960 RIODefaultName(p, HostP, entry);
961 rio_fill_host_slot(entry, entry2, RtaUniq, HostP);
962 EmptySlot = 0;
963 }
964 } else {
965 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
966 RIODefaultName(p, HostP, entry);
967 rio_fill_host_slot(entry, 0, RtaUniq, HostP);
968 EmptySlot = 0;
969 }
970 }
971
972
973
974
975
976
977
978
979
980
981
982
983 if (EmptySlot == 0) {
984 if (MapP) {
985 if (Flag & SLOT_IN_USE) {
986 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
987 HostP->Mapping[entry].SysPort = MapP->SysPort;
988 memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN);
989 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
990 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
991 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
992 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
993 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
994 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
995 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
996 } else {
997 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
998 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
999 }
1000 if (RtaType == TYPE_RTA16) {
1001 if (Flag & SLOT_IN_USE) {
1002 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1003 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1004
1005
1006
1007 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
1008 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1009 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1010 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1011 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1012 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
1013 } else
1014 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1015 memset(MapP2, 0, sizeof(struct Map));
1016 }
1017 memset(MapP, 0, sizeof(struct Map));
1018 if (!p->RIONoMessage)
1019 printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
1020 } else if (!p->RIONoMessage)
1021 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
1022 RIOSetChange(p);
1023 return 1;
1024 }
1025
1026
1027
1028
1029
1030
1031 if (!p->RIONoMessage)
1032 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');
1033 for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
1034 if (HostP->ExtraUnits[entry] == RtaUniq) {
1035
1036
1037
1038 return 1;
1039 }
1040 }
1041
1042
1043
1044 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
1045 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
1046 return 1;
1047}
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq)
1060{
1061 int Entry;
1062 unsigned int HostUniq = HostP->UniqueNum;
1063
1064
1065
1066
1067
1068 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
1069 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
1070 return 0;
1071 }
1072 return 1;
1073}
1074
1075
1076
1077
1078
1079
1080void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host)
1081{
1082 int link;
1083
1084 rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq);
1085
1086 host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
1087 host->Mapping[entry].SysPort = NO_PORT;
1088 host->Mapping[entry].RtaUniqueNum = rta_uniq;
1089 host->Mapping[entry].HostUniqueNum = host->UniqueNum;
1090 host->Mapping[entry].ID = entry + 1;
1091 host->Mapping[entry].ID2 = 0;
1092 if (entry2) {
1093 host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
1094 host->Mapping[entry2].SysPort = NO_PORT;
1095 host->Mapping[entry2].RtaUniqueNum = rta_uniq;
1096 host->Mapping[entry2].HostUniqueNum = host->UniqueNum;
1097 host->Mapping[entry2].Name[0] = '\0';
1098 host->Mapping[entry2].ID = entry2 + 1;
1099 host->Mapping[entry2].ID2 = entry + 1;
1100 host->Mapping[entry].ID2 = entry2 + 1;
1101 }
1102
1103
1104
1105
1106 for (link = 0; link < LINKS_PER_UNIT; link++) {
1107 host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
1108 host->Mapping[entry].Topology[link].Link = NO_LINK;
1109 if (entry2) {
1110 host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
1111 host->Mapping[entry2].Topology[link].Link = NO_LINK;
1112 }
1113 }
1114}
1115