(FILECREATED "10-Dec-84 12:22:55" {ERIS}<LISPCORE>SOURCES>SYSOUTPATCH.;1 15257Q changes to: (VARS SYSOUTPATCHCOMS)) (* Copyright (c) 1984 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT SYSOUTPATCHCOMS) (RPAQQ SYSOUTPATCHCOMS ((FNS \COPYSYS1))) (DEFINEQ (\COPYSYS1 [LAMBDA (STREAM LASTPAGE) (* bvm: "10-Dec-84 12:13") (COND [(AND (type? M44DEVICE (fetch DEVICE of STREAM)) (EQ (fetch DEVICENAME of (fetch DEVICE of STREAM)) (QUOTE DSK))) (* Haven't quite worked out the buffer strategy yet) (\M44FLUSHDISKDESCRIPTOR (fetch DEVICE of STREAM)) (replace DDVALID of (fetch DEVICE of STREAM) with NIL) (PROG1 (\COPYSYS0SUBR (fetch (ARRAYP BASE) of (fetch FID of STREAM))) (replace LastPage of STREAM with (replace EPAGE of STREAM with (fetch (IFPAGE NActivePages) of \InterfacePage))) (replace LastOffset of STREAM with (replace EOFFSET of STREAM with 0] (T (PROG ((PAGEMAPPED (fetch PAGEMAPPED of (fetch DEVICE of STREAM))) (NBUFS (SUB1 \#EMUBUFFERS)) (BUFBASE \EMUBUFFERS) (FIRSTPAGE 2) (CURSORBAR \EM.CURSORBITMAP) (CURSORMASK (LLSH 1 (SUB1 BITSPERWORD))) (DOMINOPAGE (fetch LastDominoFilePage of \InterfacePage)) CURSORINC CURSORNEXT LASTPAGESEEN NPAGES BUFFERS DAS) (* * Strategy is to copy from the vmem file to STREAM - The vmem file is read with \DL.ACTONVMEMFILE on DLion, \ACTONDISKPAGES on Dolphin and Dorado where we know more. As buffers we use the set of pre-allocated swap buffers, reducing the number available for swapping to a bare minimum of one. If STREAM is pagemapped, we take advantage of knowledge of pagemapped streams to write these buffers directly to the destination stream, which saves the copying that would occur if we just generically used \BOUTS for all streams. In the case of Mod44 DSK, this also lets us use more buffers at a time, because DSK can write directly from the buffers we use for reading the vmem, rather than copying into its own buffers) (RESETSAVE \#SWAPBUFFERS 1) (* Reduce us to one swap buffer, so we can use the rest for copying the vmem) (RESETSAVE \EMUSWAPBUFFERS (\ADDBASE BUFBASE (UNFOLD NBUFS WORDSPERPAGE))) (RESETSAVE \#DISKBUFFERS (COND ((type? M44DEVICE (fetch DEVICE of STREAM)) (* DSK code needs 1 extra buffer beyond the ones we give to \WRITEPAGES) (SETQ NBUFS (SUB1 NBUFS)) (SETQ BUFBASE (\ADDBASE BUFBASE WORDSPERPAGE)) 1) (T 0))) (SETQ DAS (ARRAY (IPLUS NBUFS 2) (QUOTE WORD) NIL 0)) (SETQ BUFFERS (to NBUFS as (BUF ← BUFBASE) by (\ADDBASE BUF WORDSPERPAGE) collect BUF)) [SETQ CURSORINC (SETQ CURSORNEXT (FOLDLO LASTPAGE (ITIMES 20Q 20Q] (* How often to do something to the cursor) (COND ((ZEROP DOMINOPAGE) (* First page to write is the ISF map page, which should be blank in a sysout) (\ZEROPAGE (fetch (POINTER PAGE#) of BUFBASE)) (SETA DAS 1 (fetch ISFDA2 of \ISFMAP))) ((EQ \MACHINETYPE \DANDELION) (\DL.ACTONVMEMFILE DOMINOPAGE BUFBASE 1)) (T (SETA DAS 1 (\LOOKUPFMAP DOMINOPAGE)) (* Copy the first domino page, stashed at the end of the Domino area, into page 1 for a good Dandelion boot image) (\ACTONDISKPAGES \MAINDISK BUFBASE (fetch (ARRAYP BASE) of DAS) (SUB1 DOMINOPAGE) \ISFMAP DOMINOPAGE DOMINOPAGE \DC.READD) (SETA DAS 1 (fetch ISFDA2 of \ISFMAP)) (* Prepare DAS to start reading at page 2) )) (COND (PAGEMAPPED (replace EPAGE of STREAM with LASTPAGE) (* Set up end of file correctly. LASTPAGE is last alto page (full), which is last Lisp page plus 1) (replace EOFFSET of STREAM with 0) (\WRITEPAGES STREAM 0 (CAR BUFFERS))) (T (\BOUTS STREAM (CAR BUFFERS) 0 BYTESPERPAGE))) (while (ILEQ FIRSTPAGE LASTPAGE) do [COND ((IGEQ FIRSTPAGE CURSORNEXT) (* Gradually complement the cursor) (\PUTBASE CURSORBAR 0 (LOGXOR (\GETBASE CURSORBAR 0) CURSORMASK)) (add CURSORNEXT CURSORINC) (COND ((ZEROP (SETQ CURSORMASK (LRSH CURSORMASK 1))) (SETQ CURSORBAR (\ADDBASE CURSORBAR 1)) (SETQ CURSORMASK (LLSH 1 (SUB1 BITSPERWORD] [COND ((EQ \MACHINETYPE \DANDELION) [\DL.ACTONVMEMFILE FIRSTPAGE BUFBASE (SETQ NPAGES (IMIN NBUFS (ADD1 (IDIFFERENCE LASTPAGE FIRSTPAGE] (SETQ LASTPAGESEEN (IPLUS FIRSTPAGE NPAGES -1))) (T (for I from 2 to (ADD1 NBUFS) do (SETA DAS I \FILLINDA)) (SETQ LASTPAGESEEN (\ACTONDISKPAGES \MAINDISK BUFFERS (fetch (ARRAYP BASE) of DAS) (SUB1 FIRSTPAGE) \ISFMAP FIRSTPAGE (IMIN (IPLUS FIRSTPAGE NBUFS -1) LASTPAGE) \DC.READD)) (SETQ NPAGES (ADD1 (IDIFFERENCE LASTPAGESEEN FIRSTPAGE))) (SETA DAS 1 (ELT DAS (ADD1 NPAGES] (* Read NBUFS pages from vmem) [COND ((NOT PAGEMAPPED) (* Have to just ship the bits) (\BOUTS STREAM BUFBASE 0 (UNFOLD NPAGES BYTESPERPAGE))) (T (\WRITEPAGES STREAM (SUB1 FIRSTPAGE) (COND ((ILESSP LASTPAGESEEN LASTPAGE) BUFFERS) (T (* Don't write too many pages on the last pass if NPAGES is less than length of BUFFERS) (to NPAGES as BUF in BUFFERS collect BUF] (* Write them to output) (SETQ FIRSTPAGE (ADD1 LASTPAGESEEN))) (RETURN NIL]) ) (PUTPROPS SYSOUTPATCH COPYRIGHT ("Xerox Corporation" 3700Q)) (DECLARE: DONTCOPY (FILEMAP (NIL (430Q 15134Q (\COPYSYS1 442Q . 15132Q))))) STOP