% File: MemInit.mc Edit by Jim Frandeen March 5, 1980 11:16 AM Delete Includes for Integration Procedure Edit by Johnsson February 3, 1980 2:00 PM % TITLE[MemInit]; OnPage[InitialPage]; SETTASK[0]; RV[xmad0,22]; *base register RV[xmad1,23]; RV[xmbuf0,24]; *quadword buffer for XMap and PFetch4 RV[rbuf0,24]; RV[xmbuf1,25]; RV[rbuf1,25]; RV[xmbuf2,26]; RV[rbuf2,26]; RV[xmbuf3,27]; RV[rbuf3,27]; RV[wbuf0,30]; *quadword buffer for PStore4 RV[wbuf1,31]; RV[wbuf2,32]; RV[wbuf3,33]; RV[rlink0,34]; *subroutine return link RV[MapEntry,35]; *current map location RV[ZPage,35]; *page being cleared RV[RealPage,36]; *current real storage page RV[ZWord,36]; RV[PageCount,37]; *count of available real pages in system RV[CompFlag,40]; *Failure codes MC[NotEnoughMemory,275]; MC[BadMap,276]; IMAP: CompFlag _ (zero)-1,goto[imCompx]; imAloop: T _ (CompFlag) xor (T); xmbuf0 _ T, call[imWriteMap]; T _ MapEntry; T _ (CompFlag) xor (T), call[imReadMap]; MapEntry _ T _ (MapEntry) + 1; goto[imAloop,nocarry]; MapEntry _ 140000C; imRloop: T _ MapEntry; T _ (CompFlag) xor (T), call[imReadMap]; MapEntry _ T _ (MapEntry) + 1; lu _ CompFlag, goto[imRloop,nocarry]; goto[.+2,ALU=0], CompFlag _ (zero); imCompx: goto[imAloop], MapEntry _ T _ 140000C; RealPage _ (10000C); *max real page +1 MapEntry _ 140000C; *carries beyond max VM cause ALUCY PageCount _ 0C; rlink0 _ FFaultAdd; *location in fault handler stkp _ rlink0; *fill first quadword of each real page with its page number and some constants. *go through real memory backwards so that hole in 96k modules will not *screw up non-hole banks. wbuf1 _ 326C; *random constant wbuf2 _ 134000C; wbuf3 _ (zero) ; imFloop: RealPage _ T _ (RealPage)-1; xmbuf0 _ T, goto[.+2,ALU>=0]; T _ RealPage _ 170000C, goto[imTloop]; wbuf0 _ T; call[imWriteMap]; PStore4[xmad0,wbuf0,0], goto[imFloop]; *during this phase, we sweep upward through real storage and the map, and *use any real pages discovered. imTloop: xmbuf0 _ T; xmbuf0 _ (xmbuf0) and not (70000C), call[imWriteMap]; *set base reg to point to MapEntry, *set MapEntry to point to RealPage. Set all map flags off. nop; call[.+2], stack _ (Stack) or (100000c); *turn on fault handler imFault: goto[imPageBad], stack _ (Stack) and not (100000c); *get here on a fault - turn off fault handler PFetch4[xmad0,rbuf0,0]; *fetch. Will cause fault if page is bad T _ rbuf0; lu _ (ldf[RealPage,4,14]) xor (T); goto[.+2, ALU = 0], stack _ (Stack) and not (100000c); *turn off fault handler goto[imPageBad]; *page number didn't compare T _ (rbuf1) xor (326C); *a final check against constants rbuf2 _ (rbuf2) xor (134000C); T _ (rbuf2) or (T); T _ (rbuf3) or (T); dblgoto[imPageGood, imPageBad, ALU=0]; imPageGood: MapEntry _ (MapEntry) + 1; PageCount _ (PageCount) + 1; imPageBad: T _ RealPage _ (RealPage) + 1; goto[imTloop, nocarry]; *done with all of real memory? wbuf1 _ 0C; *clear wbuf1 in preparation for core zap. imMarkVacant: xmbuf0 _ 60000C; *page vacant Call[imWriteMap]; MapEntry _ (MapEntry) + 1; T _ PageCount, goto[imMarkVacant, nocarry]; *done with all map entries? imCoreZap: wbuf3 _ 0C; wbuf2 _ 0c; Zpage _ T; imZapLoop: ZPage _ (ZPage) -1; T _ lhmask[ZPage], goto[imDone, ALU<0]; xmad1 _ T; *set up a base register for the page T _ lsh[Zpage,10]; xmad0 _ T; ZWord _ 400C, call[imZPloop]; imZPloop: Zword _ T _ (Zword) - (4C); goto[imZapLoop, ALU<0]; PStore4[xmad0, wbuf0], return; imDone: lu _ (PageCount) -(400c); *don't try to run with less than 64K T _ NotEnoughMemory, goto[InitFail, ALU<0]; goto[MemInitDone]; *SUBROUTINE imWriteMap writes the data in xmbuf0 *into map location MapEntry imWriteMap: T _ (MapEntry) and not (140000C); xmad1 _ T; xmad1 _ (xmad1) and not (377C); T _ lsh[MapEntry,10]; xmad0 _ T; Xmap[xmad0,xmbuf0,0]; xmbuf0 _ xmbuf0, return; *interlock *SUBROUTINE imReadMap reads one entry from MapEntry *into rbuf0, then compares it with (MapEntry xor CompFlag) imReadMap: xmbuf0 _ T, usectask; T _ apc&apctask; rlink0 _ T, call[imWriteMap]; T _ lsh[xmbuf3, 10]; *flags, card, blk.0 bits rbuf0 _ T; T _ (xmbuf1) and (377C); rbuf0 _ (rbuf0) xor (T); T _ MapEntry; T _ (CompFlag) xor (T); lu _ (rbuf0) xnor (T); *note, Map data is complemented, so we xnor goto[imGoodEntry, ALU=0]; imBadMap: T _ BadMap, goto[InitFail]; *Some map entry was bad imGoodEntry: apc&apctask _ rlink0; return; :END[MemInit];(1795)