rioboot.c 37 KB

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