(FILECREATED "14-Dec-84 12:48:20" {ERIS}<LISPCORE>32MB>DLFIXINIT.;1 21573  

      changes to:  (VARS DLFIXINITCOMS)
		   (FNS DLCOPYVMPAGE)

      previous date: "10-Dec-84 21:14:05" {ERIS}<LISPCORE>24BIT>DLFIXINIT.;6)


(* Copyright (c) 1983, 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT DLFIXINITCOMS)

(RPAQQ DLFIXINITCOMS [(FNS DLFIXINIT DLSORTSYSOUTPAGES DLNEXTFP DLLOCKEDPAGEP DLSETLOCKBIT 
			   DLCOPYPAGEMAP DLCOPYVMPAGE DLADDPAGEMAPENTRIES ASSIGNFILEPAGE 
			   ASSIGNFILEPAGERANGE DLDUMPSYSOUT DLDUMPFPTOVP DLDUMPPAGEMAPS 
			   DLDUMPVMEMPAGES DLSETBOOTPTR DLDUMPARRAY DLMARKASDUMPED DLDUMPVMEMPAGE 
			   INSTALLDOMINO INSTALLDOMINO.DIRECT INSTALLNEWDOMINO)
	(FNS DLPRINTFPTOVP PRINTPRIMARYMAP DLREADPAGEOFWORDS SETDIF)
	(CONSTANTS \NO.PAGE.ASSIGNED)
	(GLOBALVARS DLPRIMARYMAP DLSECONDARYMAP DLLOCKBITS DLLASTDOMINOPAGE DLIFPAGE DLNEXTPM 
		    DLPAGEMAPFP FPTOVP NEWFPFROMOLD VMEMFILE VMEMFILEX)
	(DECLARE: DONTEVAL@LOAD EVAL@COMPILE DONTCOPY (FILES (LOADCOMP)
							     READSYS LLFAULT)
		  (P (CHECKIMPORTS (QUOTE (MODARITH LLPARAMS))
				   T])
(DEFINEQ

(DLFIXINIT
  [LAMBDA (SYSOUTFILE DLBOOTFILE DBFILE #UCODEPAGES)         (* bvm: " 8-Dec-84 15:29")
    [COND
      ((NOT DLBOOTFILE)
	(SETQ DLBOOTFILE (PACKFILENAME (QUOTE EXTENSION)
				       (QUOTE DLINIT)
				       (QUOTE VERSION)
				       NIL
				       (QUOTE BODY)
				       SYSOUTFILE]
    (FILESLOAD (SYSLOAD)
	       READSYS RDSYS)
    (RESETLST (SETQ DBFILE (OPENFILE (OR DBFILE (QUOTE {PHYLUM}<LISPCORE>FUGUE>DLISPDOMINO.DB))
				     (QUOTE INPUT)))
	      (RESETSAVE NIL (LIST (QUOTE CLOSEF)
				   DBFILE))
	      (PROG ((DBPAGES (IPLUS (FOLDHI (GETFILEINFO DBFILE (QUOTE LENGTH))
					     BYTESPERPAGE)
				     2))
		     (#ADDEDFILEPAGES 0)
		     #OLDFILEPAGES #NEWFILEPAGES #FPTOVPPAGES DLFILEX)
		    (DECLARE (SPECVARS #NEWFILEPAGES #OLDFILEPAGES #ADDEDFILEPAGES #FPTOVPPAGES 
				       DLFILEX))             (* Plus 2 is to allow for interface page and copy of 
							     page 0)
		    (COND
		      ((NOT #UCODEPAGES)
			(SETQ #UCODEPAGES (IQUOTIENT (ITIMES DBPAGES 5)
						     4))
			(printout T "  Assuming " .P2 #UCODEPAGES " pages of uCode/Domino" T))
		      ((ILESSP #UCODEPAGES DBPAGES)
			(printout T "Not enough space for Domino; raising it to " .P2 (SETQ 
				    #UCODEPAGES DBPAGES)
				  " pages" T)))
		    (READSYS SYSOUTFILE)
		    (RESETSAVE NIL (QUOTE (READSYS)))        (* To close the sysout source on exit)
		    (SETQ #OLDFILEPAGES (FOLDHI (GETFILEINFO VMEMFILE (QUOTE LENGTH))
						BYTESPERPAGE))
		    (DLCOPYPAGEMAP)
		    (SETQ NEWFPFROMOLD (ARRAY #OLDFILEPAGES (QUOTE WORD)
					      \NO.PAGE.ASSIGNED 1))
		    (DLSORTSYSOUTPAGES)
		    (until (ERSETQ (DLDUMPSYSOUT)) do (printout T T 
							      "DLFIXINIT failed, trying again..."
								T))
		    (RETURN DLBOOTFILE])

(DLSORTSYSOUTPAGES
  [LAMBDA NIL                                                (* bvm: " 8-Dec-84 15:31")
    (DECLARE (USEDFREE FPSIZE NEWFPFROMOLD FPTOVPSIZE FPTOVP PGTAB #FPTOVPPAGES)
	     (SPECVARS LASTFP))
    (PROG (LASTFP)
          (ASSIGNFILEPAGE \FP.IFPAGE \VP.IFPAGE (SUB1 \FP.IFPAGE)
			  T)                                 (* SUB1 because old FP's are zero-based! See VMEM 
							     structures)
          (ASSIGNFILEPAGERANGE \VP.DISPLAY \NP.DISPLAY (DLFPFROMRP \RP.TEMPDISPLAY))
          (ASSIGNFILEPAGERANGE \VP.STACK PAGESPERSEGMENT (DLFPFROMRP \RP.STACK)
			       T)
          (ASSIGNFILEPAGERANGE \VP.TYPETABLE \NP.TYPETABLE (DLFPFROMRP \RP.TYPETABLE))
          (ASSIGNFILEPAGERANGE \VP.GCTABLE \NP.GCTABLE (DLFPFROMRP \RP.GCTABLE))
          (ASSIGNFILEPAGERANGE \VP.GCOVERFLOW \NP.GCOVERFLOW (DLFPFROMRP \RP.GCOVERFLOW))
          (ASSIGNFILEPAGERANGE \VP.FPTOVP #FPTOVPPAGES (DLFPFROMRP \RP.FPTOVP))
          (replace (IFPAGE FPTOVPStart) of DLIFPAGE with (DLFPFROMRP \RP.FPTOVP))
          (replace (IFPAGE LastDominoFilePage) of DLIFPAGE with (SETQ DLLASTDOMINOPAGE #UCODEPAGES))
          [SETQ LASTFP (SUB1 (SETQ DLPAGEMAPFP (DLFPFROMRP \RP.MISCLOCKED]

          (* Assign next the pagemap pages, since we have to know where they live (some are new) and it is very convenient for
	  them to be contiguous)


          (for J from 0 to (SUB1 \NumPMTpages) do (ASSIGNFILEPAGE (DLNEXTFP)
								  (IPLUS J \VP.PRIMARYMAP)
								  NIL T))
          (replace (IFPAGE filePnPMT0) of DLIFPAGE with DLPAGEMAPFP)
          (replace (IFPAGE filePnPMP0) of DLIFPAGE with (IPLUS DLPAGEMAPFP \NumPMTpages))
          (for J from 0 to (SUB1 (FOLDHI DLNEXTPM WORDSPERPAGE)) do (ASSIGNFILEPAGE (DLNEXTFP)
										    (IPLUS J 
										 \VP.SECONDARYMAP)
										    NIL T))

          (* * Similarly, assign locked page table, which is another structure we rewrite)


          (for J from 0 to (SUB1 \NumLPTPages) do (ASSIGNFILEPAGE (DLNEXTFP)
								  (IPLUS J \VP.LPT)
								  NIL T))

          (* * Finally, assign file pages for everyone we haven't taken care of yet. First the locked pages, which have to be 
	  at the front of the sysout, after the fixed assignments we have already made)


          [for IFLOCKED in (QUOTE (T NIL))
	     do (for VPSEG from 0 to \MAXVMSEGMENT bind PGTAB2 when (NEQ (SETQ PGTAB2
									   (FASTELT PGTAB VPSEG))
									 PGEMPTY)
		   do (for I from 0 to (SUB1 PAGESPERSEGMENT) bind (VPBASE ←(UNFOLD VPSEG 
										  PAGESPERSEGMENT))
								   OLDFP
			 when (AND [NOT (ZEROP (SETQ OLDFP (FASTELTN PGTAB2 I]
				   (EQ (DLLOCKEDPAGEP (IPLUS VPBASE I))
				       IFLOCKED)
				   (EQ (FASTELTN NEWFPFROMOLD OLDFP)
				       \NO.PAGE.ASSIGNED))
			 do (ASSIGNFILEPAGE (DLNEXTFP)
					    (IPLUS VPBASE I)
					    OLDFP IFLOCKED)))
		(COND
		  (IFLOCKED (replace (IFPAGE LastLockedFilePage) of DLIFPAGE with LASTFP)
			    (SETQ LASTFP DLLASTDOMINOPAGE]
          (replace (IFPAGE NDirtyPages) of DLIFPAGE with (replace (IFPAGE NActivePages) of DLIFPAGE
							    with #NEWFILEPAGES])

(DLNEXTFP
  [LAMBDA NIL                                                (* bvm: "29-MAR-83 11:46")
    (do (add LASTFP 1) repeatuntil (EQ (FASTELTN FPTOVP LASTFP)
				       \NO.VMEM.PAGE))
    LASTFP])

(DLLOCKEDPAGEP
  [LAMBDA (VP)                                               (* bvm: " 6-Dec-84 22:25")
    (NEQ 0 (LOGAND (.LOCKEDVPMASK. VP)
		   (FASTELTN DLLOCKBITS (FOLDLO VP BITSPERWORD])

(DLSETLOCKBIT
  [LAMBDA (VP)                                               (* bvm: " 6-Dec-84 22:26")
    (FASTSETAN DLLOCKBITS (FOLDLO VP BITSPERWORD)
	       (LOGOR (.LOCKEDVPMASK. VP)
		      (FASTELTN DLLOCKBITS (FOLDLO VP BITSPERWORD])

(DLCOPYPAGEMAP
  [LAMBDA NIL                                                (* bvm: "10-Dec-84 21:13")
    (PROG NIL
          [SETQ DLIFPAGE (DLCOPYVMPAGE \VP.IFPAGE (NCREATE (QUOTE VMEMPAGEP]
                                                             (* Install interface page by magic)
          (SETQ DLPRIMARYMAP (ARRAY (UNFOLD \NumPMTpages WORDSPERPAGE)
				    (QUOTE WORD)
				    0 0))                    (* Primary map table)
          [for J from 0 to (SUB1 \NumPMTpages) do (DLCOPYVMPAGE (IPLUS J \VP.PRIMARYMAP)
								(\ADDBASE (fetch (ARRAYP BASE)
									     of DLPRIMARYMAP)
									  (UNFOLD J WORDSPERPAGE]
          (SETQ DLNEXTPM (fetch (IFPAGE NxtPMAddr) of DLIFPAGE))
                                                             (* First free offset in secondary map)
          (DLADDPAGEMAPENTRIES \VP.FPTOVP \NP.FPTOVP)
          (COND
	    ((NOT (VMPAGEP \VP.DISPLAY))
	      (DLADDPAGEMAPENTRIES \VP.DISPLAY \NP.DISPLAY)
	      (add #ADDEDFILEPAGES \NP.DISPLAY)))
          (SETQ #NEWFILEPAGES (IPLUS (SUB1 #OLDFILEPAGES)
				     (SUB1 #UCODEPAGES)))
          (SETQ #FPTOVPPAGES (ADD1 (FOLDHI (IPLUS #NEWFILEPAGES #ADDEDFILEPAGES)
					   WORDSPERPAGE)))   (* Number of pages of FPTOVP needed -- cover everything
							     in sysout, plus one more possibly needed to cover 
							     FPTOVP itself)
          (add #ADDEDFILEPAGES #FPTOVPPAGES)
          (add #NEWFILEPAGES #ADDEDFILEPAGES)
          (SETQ FPTOVP (ARRAY #NEWFILEPAGES (QUOTE WORD)
			      \NO.VMEM.PAGE 1))
          (SETQ DLSECONDARYMAP (ARRAY (CEIL DLNEXTPM WORDSPERPAGE)
				      (QUOTE WORD)
				      0 0))                  (* Allocate enough space to accomodate existing 
							     secondary map plus anything we added.
							     Round up to a page boundary)
          (replace (IFPAGE NxtPMAddr) of DLIFPAGE with DLNEXTPM)
                                                             (* Store back new DLNEXTPM as updated by 
							     DLADDPAGEMAPENTRIES)
          (SETQ DLLOCKBITS (ARRAY (UNFOLD \NumLPTPages WORDSPERPAGE)
				  (QUOTE WORD)
				  0 0))                      (* Read the locked page table)
          (for J from 0 to (SUB1 \NumLPTPages) do (DLCOPYVMPAGE (IPLUS J \VP.LPT)
								(\ADDBASE (fetch (ARRAYP BASE)
									     of DLLOCKBITS)
									  (UNFOLD J WORDSPERPAGE])

(DLCOPYVMPAGE
  [LAMBDA (VP BASE)                                          (* bvm: "14-Dec-84 12:46")
                                                             (* Reads page VP from VMEMFILE into BASE, returning 
							     BASE)
    (SETVMPTR (UNFOLD VP WORDSPERPAGE))
    (\BINS VMEMFILEX BASE 0 BYTESPERPAGE)
    BASE])

(DLADDPAGEMAPENTRIES
  [LAMBDA (VP NPAGES)                                        (* bvm: "27-MAR-83 17:53")
    (to NPAGES
       do [COND
	    ((IEQ (FASTELTN DLPRIMARYMAP (fetch (VP PRIMARYKEY) of VP))
		  \EmptyPMTEntry)
	      (COND
		((EVENP DLNEXTPM WORDSPERPAGE)               (* must add a new page map page)
		  (add #ADDEDFILEPAGES 1)))
	      (FASTSETAN DLPRIMARYMAP (fetch (VP PRIMARYKEY) of VP)
			 DLNEXTPM)
	      (SETQ DLNEXTPM (IPLUS DLNEXTPM \PMblockSize]
	  (add VP 1])

(ASSIGNFILEPAGE
  [LAMBDA (FP VP OLDFP LOCKED)                               (* bvm: " 6-Dec-84 22:55")
                                                             (* Assign VP to live in FP (and hence a related real 
							     page); OLDFP is where VP lives in the old sysout)
    (COND
      ([NOT (ZEROP (OR OLDFP (SETQ OLDFP (LOGAND (FASTELTN (FASTELT PGTAB (LRSH VP 10Q))
							   (LOGAND VP 377Q))
						 77777Q]
	(FASTSETAN NEWFPFROMOLD OLDFP FP)))
    (FASTSETAN FPTOVP FP VP)
    (PROG [(SECONDARY (FASTELTN DLPRIMARYMAP (fetch (VP PRIMARYKEY) of VP]
                                                             (* Update pagemap to point to the new FP)
          (COND
	    ((IEQ SECONDARY \EmptyPMTEntry)
	      (HELP VP "has no primary map entry"))
	    (T (FASTSETAN DLSECONDARYMAP (IPLUS SECONDARY (fetch (VP SECONDARYKEY) of VP))
			  FP)))
          (COND
	    (LOCKED (DLSETLOCKBIT VP])

(ASSIGNFILEPAGERANGE
  [LAMBDA (VPSTART NPAGES FPSTART ONLYIFTHERE)               (* bvm: "25-MAR-83 12:44")
    (for I from 0 to (SUB1 NPAGES) unless [AND ONLYIFTHERE (NOT (VMPAGEP (IPLUS VPSTART I]
       do (ASSIGNFILEPAGE (IPLUS FPSTART I)
			  (IPLUS VPSTART I)
			  NIL T])

(DLDUMPSYSOUT
  [LAMBDA NIL                                                (* bvm: " 8-Dec-84 16:34")
    (PROG [(DLPAGEOFZEROS (NCREATE (QUOTE VMEMPAGEP]
          [RESETSAVE [SETQ DLFILEX (OPENSTREAM DLBOOTFILE (QUOTE OUTPUT)
					       (QUOTE NEW)
					       10Q
					       (CONS (LIST (QUOTE LENGTH)
							   (UNFOLD #NEWFILEPAGES BYTESPERPAGE))
						     (QUOTE ((SEQUENTIAL T)
							      (TYPE BINARY]
		     (QUOTE (PROGN (CLOSEF? OLDVALUE)
				   (AND RESETSTATE (DELFILE OLDVALUE]
          (SETQ DLBOOTFILE (FULLNAME DLFILEX))
          (PROGN (COPYBYTES DBFILE DLFILEX 0 BYTESPERPAGE)   (* First page of domino)
		 (\BOUTS DLFILEX DLIFPAGE 0 BYTESPERPAGE)    (* Interface Page)
		 (COPYBYTES DBFILE DLFILEX)                  (* Rest of Domino)
		 (RPTQ (IDIFFERENCE (UNFOLD (SUB1 DLLASTDOMINOPAGE)
					    BYTESPERPAGE)
				    (IPLUS (GETFILEPTR DBFILE)
					   BYTESPERPAGE))
		       (\BOUT DLFILEX 0))                    (* (SETFILEPTR DLFILEX (UNFOLD 
							     (SUB1 DLLASTDOMINOPAGE) BYTESPERPAGE)))
		 (SETFILEPTR DBFILE 0)
		 (COPYBYTES DBFILE DLFILEX 0 BYTESPERPAGE)   (* Replicate domino first page)
		 )
          (DLDUMPVMEMPAGES (ADD1 DLLASTDOMINOPAGE)
			   (SUB1 (DLFPFROMRP \RP.FPTOVP)))
          (DLDUMPFPTOVP)
          (DLDUMPVMEMPAGES (IPLUS (DLFPFROMRP \RP.FPTOVP)
				  #FPTOVPPAGES)
			   (SUB1 DLPAGEMAPFP))
          (DLDUMPPAGEMAPS)
          (DLDUMPVMEMPAGES (IPLUS DLPAGEMAPFP \NumPMTpages (FOLDHI DLNEXTPM WORDSPERPAGE)
				  \NumLPTPages)
			   #NEWFILEPAGES])

(DLDUMPFPTOVP
  [LAMBDA NIL                                                (* bvm: " 8-Dec-84 16:32")
    (printout T "[FPTOVP]")
    (\WOUT DLFILEX \NO.VMEM.PAGE)                            (* Filepages are one-based, but FPTOVP in the sysout is
							     zero-based for convenience. Hence, first entry 
							     (page zero) is dummy)
    (DLDUMPARRAY FPTOVP #NEWFILEPAGES)
    (RPTQ (IDIFFERENCE (UNFOLD #FPTOVPPAGES WORDSPERPAGE)
		       (ADD1 #NEWFILEPAGES))
	  (\WOUT DLFILEX \NO.VMEM.PAGE))                     (* Fill out rest of FPTOVP with no such page)
    NIL])

(DLDUMPPAGEMAPS
  [LAMBDA NIL                                                (* bvm: "10-Dec-84 21:13")
    (printout T "[PageMaps]")
    (DLDUMPARRAY DLPRIMARYMAP (UNFOLD \NumPMTpages WORDSPERPAGE))
                                                             (* Dump primary map)
    (DLDUMPARRAY DLSECONDARYMAP (CEIL DLNEXTPM WORDSPERPAGE))
                                                             (* Dump secondary map)
    (DLDUMPARRAY DLLOCKBITS (UNFOLD \NumLPTPages WORDSPERPAGE))
                                                             (* Dump locked page table)
    NIL])

(DLDUMPVMEMPAGES
  [LAMBDA (FIRSTFP LASTFP)                                   (* bvm: " 6-Dec-84 22:27")
    (for FP from FIRSTFP to LASTFP bind VP do (COND
						((AND (NEQ (SETQ VP (FASTELTN FPTOVP FP))
							   \NO.VMEM.PAGE)
						      (VMPAGEP VP))
						  (SETVMPTR (UNFOLD VP WORDSPERPAGE))
						  (COPYBYTES VMEMFILE DLFILEX BYTESPERPAGE)
						  (PRIN1 (QUOTE *)
							 T))
						(T (\BOUTS DLFILEX DLPAGEOFZEROS 0 BYTESPERPAGE)
						   (PRIN1 (QUOTE x)
							  T])

(DLSETBOOTPTR
  [LAMBDA (FP)                                               (* bvm: "27-MAR-83 17:39")
    (printout T "[" .P2 FP "]")
    (SETFILEPTR DLFILEX (UNFOLD (SUB1 FP)
				BYTESPERPAGE])

(DLDUMPARRAY
  [LAMBDA (ARR NWORDS)                                       (* bvm: "27-MAR-83 17:42")
    (\BOUTS DLFILEX (fetch (ARRAYP BASE) of ARR)
	    0
	    (UNFOLD NWORDS BYTESPERWORD])

(DLMARKASDUMPED
  [LAMBDA (FIRSTFP NPAGES)                                   (* bvm: "27-MAR-83 17:35")
    (for I from FIRSTFP to (IPLUS FIRSTFP NPAGES -1) do (FASTSETAN FPTOVP I \NO.VMEM.PAGE])

(DLDUMPVMEMPAGE
  [LAMBDA (NEWFP VP LOCKEDP)                                 (* bvm: "28-MAR-83 12:11")
    (COND
      ((VMPAGEP VP)
	(SETVMPTR (UNFOLD VP WORDSPERPAGE))
	[PROG ((DESTINATIONBYTE (UNFOLD (SUB1 NEWFP)
					BYTESPERPAGE)))
	      (COND
		((NOT (IEQP (\GETFILEPTR DLFILEX)
			    DESTINATIONBYTE))
		  (printout T "[" .P2 NEWFP "]")
		  (SETFILEPTR DLFILEX DESTINATIONBYTE]
	(COPYBYTES VMEMFILE DLFILEX BYTESPERPAGE)
	(PRIN1 (COND
		 (LOCKEDP (QUOTE $))
		 (T (QUOTE *)))
	       T))
      (T (PRIN1 (QUOTE x)
		T])

(INSTALLDOMINO
  [LAMBDA (DBFILE)                                           (* edited: "14-APR-83 12:00")
    (DLSETBOOTPTR 1)
    (COPYBYTES DBFILE DLFILEX 0 BYTESPERPAGE)
    (DLSETBOOTPTR (ADD1 \FP.IFPAGE))                         (* Skip over InterfacePage)
    (COPYBYTES DBFILE DLFILEX)                               (* Copy rest of Domino)
    (DLSETBOOTPTR DLLASTDOMINOPAGE)
    (SETFILEPTR DBFILE 0)

          (* Copy first DB page into scratch at end of Domino reserved space so that SYSOUT can get it 
	  (Dolphin and Dorado smash first page of vmem))


    (COPYBYTES DBFILE DLFILEX 0 BYTESPERPAGE])

(INSTALLDOMINO.DIRECT
  [LAMBDA (DBFILE)                                           (* bvm: "29-JUL-83 16:16")
    (PROG [(BUFFER (COND
		     ((IGREATERP \#SWAPBUFFERS 1)
		       (RESETSAVE \EMUSWAPBUFFERS (\ADDBASE \EMUSWAPBUFFERS WORDSPERPAGE))
		       (RESETSAVE \#SWAPBUFFERS (SUB1 \#SWAPBUFFERS))
		       \EMUSWAPBUFFERS)
		     (T (RESETSAVE \EMUDISKBUFFERS (\ADDBASE \EMUDISKBUFFERS WORDSPERPAGE))
			(RESETSAVE \#DISKBUFFERS (SUB1 \#DISKBUFFERS))
			\EMUDISKBUFFERS]
          (replace ENDOFSTREAMOP of DBFILE with (FUNCTION ZERO))
          (\BINS DBFILE BUFFER 0 BYTESPERPAGE)
          (COND
	    ((EQ \MACHINETYPE \DANDELION)
	      (\ACTONVMEMFILE 1 BUFFER 1 T)))
          (\BINS DBFILE BUFFER 0 BYTESPERPAGE)               (* Skip over InterfacePage)
          (for I from (ADD1 \FP.IFPAGE) until (\EOFP DBFILE)
	     do (\BINS DBFILE BUFFER 0 BYTESPERPAGE)
		(\ACTONVMEMFILE I BUFFER 1 T))               (* Copy rest of Domino)
      ])

(INSTALLNEWDOMINO
  [LAMBDA (SYSOUTFILE DBFILE)                                (* bvm: "29-JUL-83 16:08")
    (RESETLST (SETQ DBFILE (GETSTREAM (OPENFILE (OR DBFILE (INFILEP (QUOTE {DSK}DLISPDOMINO.DB))
						    (QUOTE 
						    {PHYLUM}<LISPCORE>DLION>BASICS>DLISPDOMINO.DB))
						(QUOTE INPUT))
				      (QUOTE INPUT)))
	      (RESETSAVE NIL (LIST (QUOTE CLOSEF)
				   DBFILE))
	      (PROG ((DBPAGES (IPLUS (FOLDHI (GETFILEINFO DBFILE (QUOTE LENGTH))
					     BYTESPERPAGE)
				     2))
		     #UCODEPAGES DLFILEX)
		    (DECLARE (SPECVARS DLFILEX))
		    [COND
		      [SYSOUTFILE [RESETSAVE NIL (LIST (QUOTE CLOSEF)
						       (SETQ SYSOUTFILE (OPENFILE SYSOUTFILE
										  (QUOTE INPUT]
				  (SETQ #UCODEPAGES (SETQ DLLASTDOMINOPAGE
				      (fetch (IFPAGE LastDominoFilePage) of (\MAPPAGE 1 (GETSTREAM
											SYSOUTFILE]
		      ((ASKUSER NIL NIL (LIST "Shall I install" (fetch FULLFILENAME of DBFILE)
					      "directly into the vmem file"))
			(SETQ #UCODEPAGES (SETQ DLLASTDOMINOPAGE (fetch (IFPAGE LastDominoFilePage)
								    of \InterfacePage]
		    (COND
		      ((ILESSP #UCODEPAGES DBPAGES)
			(RETURN "Not enough space for Domino")))
		    (COND
		      (SYSOUTFILE (OPENFILE (CLOSEF SYSOUTFILE)
					    (QUOTE BOTH))
				  (SETQ DLFILEX (GETSTREAM SYSOUTFILE))
				  (INSTALLDOMINO DBFILE))
		      (T (INSTALLDOMINO.DIRECT DBFILE)))
		    (RETURN SYSOUTFILE])
)
(DEFINEQ

(DLPRINTFPTOVP
  [LAMBDA (STREAM)                                           (* bvm: "28-MAR-83 12:42")
    (\PRINTFPTOVP (\ADDBASE (fetch (ARRAYP BASE) of FPTOVP)
			    -1)
		  (fetch (IFPAGE NActivePages) of DLIFPAGE)
		  STREAM])

(PRINTPRIMARYMAP
  [LAMBDA NIL                                                (* bvm: "28-MAR-83 23:25")
    (for I from 0 to 77Q
       do (printout T I ":  " 10Q)
	  [for J from 0 to 7 bind PMPE do (COND
					    ((EQ [SETQ PMPE (ELT DLPRIMARYMAP
								 (PLUS J (TIMES I 10Q]
						 177777Q)
					      (printout T " -----"))
					    (T (printout T .I6.8 PMPE]
	  (TERPRI T)
       unless (for J from 0 to 7 always (EQ (ELT DLPRIMARYMAP (PLUS J (TIMES I 10Q)))
					    177777Q])

(DLREADPAGEOFWORDS
  [LAMBDA (STREAM)                                           (* bvm: "29-MAR-83 00:03")
    (to WORDSPERPAGE collect (\WIN STREAM])

(SETDIF
  [LAMBDA (X Y)                                              (* bvm: "28-MAR-83 15:28")
    (for EL in X collect EL unless (FMEMB EL Y])
)
(DECLARE: EVAL@COMPILE 

(RPAQQ \NO.PAGE.ASSIGNED 0)

(CONSTANTS \NO.PAGE.ASSIGNED)
)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS DLPRIMARYMAP DLSECONDARYMAP DLLOCKBITS DLLASTDOMINOPAGE DLIFPAGE DLNEXTPM DLPAGEMAPFP 
	    FPTOVP NEWFPFROMOLD VMEMFILE VMEMFILEX)
)
(DECLARE: DONTEVAL@LOAD EVAL@COMPILE DONTCOPY 
(FILESLOAD (LOADCOMP)
	   READSYS LLFAULT)

(CHECKIMPORTS (QUOTE (MODARITH LLPARAMS))
	      T)
)
(PUTPROPS DLFIXINIT COPYRIGHT ("Xerox Corporation" 1983 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1096 19899 (DLFIXINIT 1106 . 3067) (DLSORTSYSOUTPAGES 3069 . 6558) (DLNEXTFP 6560 . 
6781) (DLLOCKEDPAGEP 6783 . 6995) (DLSETLOCKBIT 6997 . 7257) (DLCOPYPAGEMAP 7259 . 9869) (DLCOPYVMPAGE
 9871 . 10221) (DLADDPAGEMAPENTRIES 10223 . 10756) (ASSIGNFILEPAGE 10758 . 11781) (ASSIGNFILEPAGERANGE
 11783 . 12094) (DLDUMPSYSOUT 12096 . 13805) (DLDUMPFPTOVP 13807 . 14429) (DLDUMPPAGEMAPS 14431 . 
15056) (DLDUMPVMEMPAGES 15058 . 15618) (DLSETBOOTPTR 15620 . 15826) (DLDUMPARRAY 15828 . 16035) (
DLMARKASDUMPED 16037 . 16256) (DLDUMPVMEMPAGE 16258 . 16799) (INSTALLDOMINO 16801 . 17449) (
INSTALLDOMINO.DIRECT 17451 . 18450) (INSTALLNEWDOMINO 18452 . 19897)) (19900 21072 (DLPRINTFPTOVP 
19910 . 20170) (PRINTPRIMARYMAP 20172 . 20732) (DLREADPAGEOFWORDS 20734 . 20900) (SETDIF 20902 . 21070
)))))
STOP