📄 rioboot.c
字号:
{ if ( sysport < p->RIOFirstPortsBooted ) p->RIOFirstPortsBooted = sysport; if ( sysport > p->RIOLastPortsBooted ) p->RIOLastPortsBooted = sysport; /* ** For a 16 port RTA, check the second bank of 8 ports */ if (RtaType == TYPE_RTA16) { entry2 = HostP->Mapping[entry].ID2 - 1; HostP->Mapping[entry2].Flags |= RTA_BOOTED|RTA_NEWBOOT;#ifdef NEED_TO_FIX RIO_SV_BROADCAST(HostP->svFlags[entry2]);#endif sysport = HostP->Mapping[entry2].SysPort; if ( sysport < p->RIOFirstPortsBooted ) p->RIOFirstPortsBooted = sysport; if ( sysport > p->RIOLastPortsBooted ) p->RIOLastPortsBooted = sysport; } } if (RtaType == TYPE_RTA16) { rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry+1, entry2+1); } else { rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given ID %d\n",entry+1); } return TRUE; } } rio_dprintk (RIO_DEBUG_BOOT, "RTA not configured for this host\n"); if ( Rup >= (ushort)MAX_RUP ) { /* ** It was a host that did the booting */ MyType = "Host"; MyName = HostP->Name; } else { /* ** It was an RTA that did the booting */ MyType = "RTA"; MyName = HostP->Mapping[Rup].Name; }#ifdef CHECK CheckString(MyType); CheckString(MyName);#endif MyLink = RBYTE(PktCmdP->LinkNum); /* ** There is no SLOT_IN_USE entry for this RTA attached to the current ** host card in the driver table. ** ** Check for a SLOT_TENTATIVE entry for this RTA attached to the ** current host card in the driver table. ** ** If we find one, then we re-use that slot. */ for ( entry=0; entry<MAX_RUP; entry++ ) { if ( (HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq) ) { if (RtaType == TYPE_RTA16) { entry2 = HostP->Mapping[entry].ID2 - 1; if ( (HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq) ) rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2); else continue; } else rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n",entry); if (! p->RIONoMessage) cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A'); return TRUE; } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another ** host for this RTA in the driver table. ** ** For a SLOT_IN_USE entry on another host, we need to delete the RTA ** entry from the other host and add it to this host (using some of ** the functions from table.c which do this). ** For a SLOT_TENTATIVE entry on another host, we must cope with the ** following scenario: ** ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry ** in table) ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE ** entries) ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE) ** + Unplug RTA and plug back into host A. ** + Configure RTA on host A. We now have the same RTA configured ** with different ports on two different hosts. */ rio_dprintk (RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq ); found = 0; Flag = 0; /* Convince the compiler this variable is initialized */ for ( host = 0; !found && (host < p->RIONumHosts); host++ ) { for ( rta=0; rta<MAX_RUP; rta++ ) { if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum==RtaUniq)) { Flag = p->RIOHosts[host].Mapping[rta].Flags; MapP = &p->RIOHosts[host].Mapping[rta]; if (RtaType == TYPE_RTA16) { MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1]; rio_dprintk (RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta+1, MapP->ID2, p->RIOHosts[host].Name); } else rio_dprintk (RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta+1, p->RIOHosts[host].Name); found = 1; break; } } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on ** another host for this RTA in the driver table... ** ** Check for a SLOT_IN_USE entry for this RTA in the config table. */ if ( !MapP ) { rio_dprintk (RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n",RtaUniq); for ( rta=0; rta < TOTAL_MAP_ENTRIES; rta++ ) { rio_dprintk (RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum); if ( (p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq) ) { MapP = &p->RIOSavedTable[rta]; Flag = p->RIOSavedTable[rta].Flags; if (RtaType == TYPE_RTA16) { for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) { if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq) break; } MapP2 = &p->RIOSavedTable[entry2]; rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2); } else rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta); break; } } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** We may have found a SLOT_IN_USE entry on another host for this ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry ** on another host for this RTA in the driver table. ** ** Check the driver table for room to fit this newly discovered RTA. ** RIOFindFreeID() first looks for free slots and if it does not ** find any free slots it will then attempt to oust any ** tentative entry in the table. */ EmptySlot = 1; if (RtaType == TYPE_RTA16) { if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) { RIODefaultName(p, HostP, entry); FillSlot(entry, entry2, RtaUniq, HostP); EmptySlot = 0; } } else { if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) { RIODefaultName(p, HostP, entry); FillSlot(entry, 0, RtaUniq, HostP); EmptySlot = 0; } } /* ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA ** attached to the current host card in the driver table. ** ** If we found a SLOT_IN_USE entry on another host for this ** RTA in the config or driver table, and there are enough free ** slots in the driver table, then we need to move it over and ** delete it from the other host. ** If we found a SLOT_TENTATIVE entry on another host for this ** RTA in the driver table, just delete the other host entry. */ if (EmptySlot == 0) { if ( MapP ) { if (Flag & SLOT_IN_USE) { rio_dprintk (RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n"); HostP->Mapping[entry].SysPort = MapP->SysPort; CCOPY( MapP->Name, HostP->Mapping[entry].Name, MAX_NAME_LEN ); HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;#ifdef NEED_TO_FIX RIO_SV_BROADCAST(HostP->svFlags[entry]);#endif RIOReMapPorts( p, HostP, &HostP->Mapping[entry] ); if ( HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted ) p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort; if ( HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted ) p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort; rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",(int)MapP->SysPort,MapP->Name); } else { rio_dprintk (RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n"); HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;#ifdef NEED_TO_FIX RIO_SV_BROADCAST(HostP->svFlags[entry]);#endif } if (RtaType == TYPE_RTA16) { if (Flag & SLOT_IN_USE) { HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;#ifdef NEED_TO_FIX RIO_SV_BROADCAST(HostP->svFlags[entry2]);#endif HostP->Mapping[entry2].SysPort = MapP2->SysPort; /* ** Map second block of ttys for 16 port RTA */ RIOReMapPorts( p, HostP, &HostP->Mapping[entry2] ); if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted) p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort; if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted) p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort; rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int)HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name); } else HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;#ifdef NEED_TO_FIX RIO_SV_BROADCAST(HostP->svFlags[entry2]);#endif bzero( (caddr_t)MapP2, sizeof(struct Map) ); } bzero( (caddr_t)MapP, sizeof(struct Map) ); if (! p->RIONoMessage) cprintf("An orphaned RTA has been adopted by %s '%s' (%c).\n",MyType,MyName,MyLink+'A'); } else if (! p->RIONoMessage) cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A'); RIOSetChange(p); return TRUE; } /* ** There is no room in the driver table to make an entry for the ** booted RTA. Keep a note of its Uniq Num in the overflow table, ** so we can ignore it's ID requests. */ if (! p->RIONoMessage) cprintf("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n",MyType,MyName,MyLink+'A'); for ( entry=0; entry<HostP->NumExtraBooted; entry++ ) { if ( HostP->ExtraUnits[entry] == RtaUniq ) { /* ** already got it! */ return TRUE; } } /* ** If there is room, add the unit to the list of extras */ if ( HostP->NumExtraBooted < MAX_EXTRA_UNITS ) HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq; return TRUE;}/*** If the RTA or its host appears in the RIOBindTab[] structure then** we mustn't boot the RTA and should return FALSE.** This operation is slightly different from the other drivers for RIO** in that this is designed to work with the new utilities** not config.rio and is FAR SIMPLER.** We no longer support the RIOBootMode variable. It is all done from the** "boot/noboot" field in the rio.cf file.*/intRIOBootOk(p, HostP, RtaUniq)struct rio_info * p;struct Host * HostP;ulong RtaUniq;{ int Entry; uint HostUniq = HostP->UniqueNum; /* ** Search bindings table for RTA or its parent. ** If it exists, return 0, else 1. */ for (Entry = 0; ( Entry < MAX_RTA_BINDINGS ) && ( p->RIOBindTab[Entry] != 0 ); Entry++) { if ( (p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq) ) return 0; } return 1;}/*** Make an empty slot tentative. If this is a 16 port RTA, make both** slots tentative, and the second one RTA_SECOND_SLOT as well.*/voidFillSlot(entry, entry2, RtaUniq, HostP)int entry;int entry2;uint RtaUniq;struct Host *HostP;{ int link; rio_dprintk (RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq); HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE); HostP->Mapping[entry].SysPort = NO_PORT; HostP->Mapping[entry].RtaUniqueNum = RtaUniq; HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum; HostP->Mapping[entry].ID = entry + 1; HostP->Mapping[entry].ID2 = 0; if (entry2) { HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT); HostP->Mapping[entry2].SysPort = NO_PORT; HostP->Mapping[entry2].RtaUniqueNum = RtaUniq; HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum; HostP->Mapping[entry2].Name[0] = '\0'; HostP->Mapping[entry2].ID = entry2 + 1; HostP->Mapping[entry2].ID2 = entry + 1; HostP->Mapping[entry].ID2 = entry2 + 1; } /* ** Must set these up, so that utilities show ** topology of 16 port RTAs correctly */ for ( link=0; link<LINKS_PER_UNIT; link++ ) { HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT; HostP->Mapping[entry].Topology[link].Link = NO_LINK; if (entry2) { HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT; HostP->Mapping[entry2].Topology[link].Link = NO_LINK; } }}#if 0/* Function: This function is to disable the disk interrupt Returns : Nothing*/voiddisable_interrupt(vector)int vector;{ int ps; int val; disable(ps); if (vector > 40) { val = 1 << (vector - 40); __outb(S8259+1, __inb(S8259+1) | val); } else { val = 1 << (vector - 32); __outb(M8259+1, __inb(M8259+1) | val); } restore(ps);}/* Function: This function is to enable the disk interrupt Returns : Nothing*/voidenable_interrupt(vector)int vector;{ int ps; int val; disable(ps); if (vector > 40) { val = 1 << (vector - 40); val = ~val; __outb(S8259+1, __inb(S8259+1) & val); } else { val = 1 << (vector - 32); val = ~val; __outb(M8259+1, __inb(M8259+1) & val); } restore(ps);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -