Google
 

Trailing-Edge - PDP-10 Archives - k20v7d - utilities/copyfe.mac
There is 1 other file named copyfe.mac in the archive. Click here to see a list.
	SALL
	TITLE COPYFE
	SEARCH MONSYM,MACSYM
	.REQUIRE SYS:MACREL
;
;	THIS PROGRAM TRIES TO RESTORE A FRONT-END SYSTEM IN PLACE
;
;	IT NEEDS A FILE , WRITTEN BY 'FEREAD' , WHICH HOLDS:
;	PAGE 0 == COPIES OF ORIGINAL BLOCKS 0 TO 4
;		BLOCK 0 BEING USED AS THE BOOTS-BLOCK
;	PAGE 1 == LENGTH-WORD OF FDB OF ORIGINAL FE-FILE
;	PAGE 2 == COPY OF FIRST INDEX-BLOCK OF ORIGINAL FILE
;		USED TO CHECK BEGINNING LOCATION
;
;	THE FILE TO BE COPIED IS READ PAGE BY PAGE VIA DSKOP'S
;	USING ADRESSES OBTAINED FROM SUPER-INDEX-BLOCK ,WHICH
;	IN TURN POINT TO INDEX-BLOCKS , AND THEIR ENTRIES POINT
;	TO THE 'REAL' PAGES.
;
;	THE FILE IS READ WITHOUT ERROR-RECOVERY , TO BE ABLE TO
;	DETECT HARD- OR SOFT-ERRORS. IN CASE OF HARD ERRORS , THE
;	COPYING PROCESS IS ABOLISHED.
;
;	THE SO FILLED PAGES ARE DSKOPED INTO THE FE-FILE INTO
;	SUCCESSIVE PAGES UNDER THE ASSUMPTION THAT THIS FILE
;	IS CONTIGUOUS.
;
;	IN CASE OF NO HARD-ERRORS THE BOOT-BLOCK IS COPIED AS
;	THE LAST OPERATION.
;
;	FLOW AND GENERAL HINTS:
;
;	STARTING POINT IS 'START' WHICH ASKS FOR STRUCTURE-FILE
;	OF ORIGINAL FE-SYSTEM AND BUILDS PARAMETERS FOR DSKOP.
;	HERE WE ALSO LOOK FOR THE 'OTHER' FILE 'FRONT-END-BOOT.BIN'
;	WHICH IS EXPECTED IN THE LOGGED-IN AREA.
;
;	LABEL CHECK1: COMPARES LENGTH OF ORIGINAL AND 'EMPTY' FILE
;	LABEL DOPT:   ROLLS SUCCESSIVE INDEX-BLOCKS INTO IDXPAG
;	LABEL DOPAG:  ROLLS IN SUCCESSIVE DATA-PAGES INTO DATPAG
;	LABEL BOOT:   WRITES THE BOOT-BLOCK
;	SETUP:	      SUB FOR DSKOP
;	LABEL DSKOUT:	WRITES TIMES-PAGES OUT TO FE-FILE
;	TIMES	      CLUSTER-COUNT FOR MAPPING
;
A==1			;JSYS-AC'S
B==2
C==3
D==4			;3 WORDS OUT OF FDB
W==5
W1==6
W2==7			;STR-DESIGNATOR FOR DSKOP
PTT==10			;HOLDS AOBJN POINTER INTO SUPER-INDEX-BLOCK
PT==11			;HOLDS AOBJN POINTER INTO INDEX-BLOCK
JFN==12			;WHERE TO SAVE THE JFN
JFN0==13		;HERE TO SAVE JFN OF COPY-FILE
COUNT==14		;READ/WRITE AOBJN COUNTER
MAPCNT==15		;PMAP COUNTER
DSKCNT==16		;COUNTER FOR SUCCESSIVE DSKOP-WRITES
P==17			;PDL

PDL:	BLOCK 10
FDBNEW: BLOCK 3		;FOR COMPARISON
CORDAT:	BLOCK 1		;DSKOP-WRITE CORE-ADRESS
DSKADR:	BLOCK 1		 ;DSK-ADRESS TO WRITE INTO (CONTIGUOUS)
LSTDSK:	BLOCK 1		;LAST DISK ADRESS FOR DSKOP
ERRTYP:	BLOCK 1		;LAST ERROR INDICATION FROM DSKOP
HRDERR:	BLOCK 1		;HARD ERROR INDICATOR
BUFFER:	BLOCK 11	;STR-NAME FOR ORIGINAL FILE
BUFF1:	BLOCK 11	;STR-NAME FOR COPY-DISK
BOOTPG==10000		;3 PAGES OF 'FRONT-END-BOOT.BIN'
BOOTNR==BOOTPG/PAGLEN
ORGPTR==13000		;FOR COMPARISON
IDXPAG==14000		;PAGE OF SUPER-INDEX-BLOCK
PTPAGE==15000		;PAGE FOR INDEX-BLOCK
DATPAG==16000		;WHERE FILE DATA GOES
PAGNR==DATPAG/PAGLEN	;THE PAGE-NR
PAGLEN==1000
TIMES==^D5		;THE REPEAT COUNT FOR DSKOP'S

	RELOC 1000-140



FILOUT:	TXNN JFN,GJ%DEV!GJ%DIR!GJ%NAM!GJ%EXT!GJ%VER
	RET			;NO. DON'T DO NAME THEN
	MOVEI A,.PRIOU
	MOVEI B,0(JFN)
	SETZ C,			;OUTPUT THE NAME
	JFNS			;DO IT
	HRROI A,[ASCIZ /
/]
	PSOUT
	RET

;	SUBROUTINE TO DSKOP PAGES TO FE-FILE

DSKOUT:MOVEI A,DATPAG-PAGLEN	;RESET CORE ADRESS
	MOVEM A,CORDAT		;AND STORE
	MOVSI DSKCNT,-TIMES	; X-TIMES OVER
DSKLOP:MOVE A,DSKADR		;ADRESS TO WRITE INTO
	ADDI A,4		;(CONTIGUOUS)!!
	MOVEM A,DSKADR		;
	MOVEI B,.DOPSR		;STR-RELATIVE ADRESSING
	STOR B,DOP%AT,A		;STORE IT
	SETONE DOP%SN,A		;DEVICE DESIGNATOR IN D
	MOVX B,DOP%WR!1000B35	;WRITE ONE PAGE
	MOVE D,DESIG		;STRUCTURE
	MOVE C,CORDAT		;FROM WHERE
	ADDI C,PAGLEN		;OUT OF OUR CORE
	MOVEM C,CORDAT		;FOR NEXT GO-AROUND
	DSKOP			;DO IT
	AOBJN DSKCNT,DSKLOP	; X-TIMES OVER
	RET

;	SUBROUTINE FOR DSKOP OUT OF ORIGINAL FILE

;	A == DISK-ADRESS
;	C == TARGET (MEMORY) ADRESS
;	W2 == STRUCTURE NUMBER

SETUP:	MOVEM A,LSTDSK		;SAVE DISK ADDRESS
	MOVEI B,.DOPSR		;STR RELATIVE ADDRESSING
	STOR B,DOP%AT,A		;STORE IT
	SETONE DOP%SN,A		;SAY DEVICE DESIGNATOR IN D
	MOVEI B,PAGLEN
	TXO B,DOP%IR		;INHIBIT ERROR RECOVERY
	MOVE D,W2		;DEVICE DESIGNATOR
	SETZM ERRTYP		;ASSUME NO ERROR
	DSKOP			;DO IT
	JUMPN A,[ MOVE A,LSTDSK	;GET LAST DISK ADDRESS AGAIN
		SETONE DOP%SN,A
		MOVEI W,.DOPSR
		STOR W,DOP%AT,A	;SET UP NEW ARGS
		TXZ B,DOP%IR	;ALLOW ERROR RECOVERY THIS TIME
		DSKOP		;TRY IT AGAIN
		MOVEM A,ERRTYP	;REMEMBER THE ERROR
		RET]		;RETURN WITH CODE IN A
	RETSKP			;NO

PRTDSC:	HRROI A,[ASCIZ / DISK ADDRESS /]
	PSOUT
	MOVEI A,.PRIOU
	MOVE B,LSTDSK
	MOVEI C,10
	NOUT
	 JFCL
	HRROI A,[ASCIZ /
/]
	PSOUT
	RET



START:	RESET			;GET A CLEAN SLATE
	SETZB MAPCNT,COUNTM
	SETZM HRDERR
	MOVE P,[IOWD 10,PDL]
	HRROI A,[ASCIZ /
COPY  AND VERIFY (FROM) : /]
	PSOUT
	MOVX A,GJ%OLD!GJ%FNS!GJ%SHT!GJ%CFM!GJ%IFG
	MOVE B,[.PRIIN,,.PRIOU]
	GTJFN			;GET THE FILE
	JRST [	JSERR
		JRST START]	
	MOVE JFN,A		;SAVE SOURCE JFN
FILLOP:	CALL FILOUT		;PRINT NAME IF APPROPRIATE
START2:	HRROI A,[ASCIZ /
(TO) FILE : /]
	PSOUT
	MOVX A,GJ%OLD!GJ%FNS!GJ%SHT!GJ%CFM!GJ%IFG
	MOVE B,[.PRIIN,,.PRIOU]
	GTJFN
	  JRST [JSERR
		 JRST START2]
	MOVE JFN0,A		;SAVE DEST-JFN
	MOVE B,A		;MOVE JFN
	HRROI A,BUFF1		;WHERE STR-NAME GOES
	MOVX C,1B2		;DEVICE NAME ONLY
	JFNS
	HRROI A,BUFF1		;GET STR-NAME
	STDEV			;DEST-FILE
	 JRST [JSERR
		  JRST START]
	MOVEM B,DESIG#		;SAVE DESIGNATOR DEST-FILE
	MOVEI A,0(JFN0)
	MOVX B,^D36B5!OF%WR!OF%RD
	OPENF			;OPEN DEST FILE
	 JRST [JSERR
		 JRST START2]
	MOVEI A,0(JFN)		;GET THE JFN
	MOVE B,[3,,.FBCTL]	;READ 3 FDB WORDS
	MOVEI C,D		;INTO THE REGS
	GTFDB			;FROM SOURCE-FILE

;GET STRUCTURE NAME FOR DSKOP

	MOVE B,A		;MOVE THE JFN
	HRROI A,BUFFER		;WHERE TO PUT STRUCTURE NAME
	MOVX C,1B2		;DEVICE NAME ONLY
	JFNS			;DO IT
	HRROI A,BUFFER		;GET STR NAME
	STDEV			;GET DEVICE DESIGNATOR SOURCE FILE
	 JRST [	JSERR
		JRST START]	;
	MOVE W2,B		;SAVE DESIGNATOR SOURCE FILE
	MOVX A,GJ%OLD!GJ%SHT
	HRROI B,[ASCIZ /DSK:FRONT-END-BOOT.BIN
/]
	GTJFN
	 JRST [	JSERR
		JRST START]
	MOVEM A,INJFN#		;SAVE JFN COMPARE JFN
	MOVX B,^D36B5!OF%RD
	OPENF
	 JRST [	JSERR
		JRST START]
	HRLZ A,INJFN
	HRLZI B,.FHSLF
	HRRI	B,BOOTNR
	MOVX C,PM%CNT!PM%RD!3B35
	PMAP
	MOVEI A,0(JFN0)
	MOVE B,[1,,.FBBYV]
	MOVEI C,FDBNEW
	GTFDB
	MOVE A,FDBNEW		;GET LENGTH DEST-FILE
	TLZ A,777777
	HRRZ B,BOOTPG+PAGLEN
CHECK1:	CAMGE A,B		;COMPARE LENGTH OF BOTH FILES
		JRST[HRROI A,[ ASCIZ /
? FRONT-END-FILE-SYSTEM.BIN OF DIFFERENT LENGTH,
  CANNOT RESTORE
/]
			PSOUT
			JRST DONE1]
	MOVEI A,0(JFN0)
	MOVE B,[3,,.FBCTL]
	MOVEI C,FDBNEW
	GTFDB
	TXNN D,FB%LNG		;IS SOURCE A LONG FILE?
	JRST [	MOVEM W1,IDXPAG	;NO. SAVE ONLY XB ADDRESS
		MOVSI PTT,-1	;ONLY LOOK AT ONE ENTRY
		JRST DOPT0]	;AND GO PROCESS THE PTT
	MOVE A,W1		;GET DISK ADDRESS
	MOVEI C,IDXPAG		;WHERE ITS GOING
	CALL SETUP		;GO SET UP ARGS AND DO OPERATION
	 JRST [	HRROI A,[ASCIZ /
?HARD ERROR READING SUPER-INDEX-POINTER/]
		SKIPN ERRTYP	;WAS IT REALLY HARD?
		HRROI A,[ASCIZ /
%RECOVERABLE ERROR READING SUPER-INDEX-POINTER/]
		PSOUT
		SKIPE ERRTYP
		SETOM HRDERR	;MARK HARD ERROR
		CALL PRTDSC
		SKIPN ERRTYP	;HARD ERROR
		JRST .+1	;NO. GO ON
		JRST START]

	MOVSI PTT,-PAGLEN		;DO ALL PTT'S
DOPT0:	MOVEI COUNT,DATPAG-PAGLEN
	MOVEM COUNT,DATA#	;SETUP ORIGINAL DSKOP-POINTER
	MOVSI COUNT,-TIMES	;AND AOBJN POINTER
DOPT:	MOVSI PT,-PAGLEN		;DO ALL OF THIS PT
	SKIPN A,IDXPAG(PTT)	;GET PAGE TABLE ADDRESS
	JRST DOPT1		;NONE HERE.
	TLZ A,777000		;IGNORE CHECKSUM
	JUMPE A,DOPT1		;SKIP IT IF NOTHING HERE
	MOVEI C,PTPAGE		;WHERE TO PUT IT
	CALL SETUP		;GET IT
	 JRST [	HRROI A,[ASCIZ /
?HARD ERROR READING INDEX-BLOCK # /]
		SKIPN ERRTYP	;WAS IT REALLY HARD?
		HRROI A,[ASCIZ /
%RECOVERABLE ERROR READING INDEX-BLOCK # /]
		PSOUT
		SKIPE ERRTYP
		SETOM HRDERR	;MARK HARD ERROR
		MOVEI B,0(PTT)
		MOVEI A,.PRIOU
		MOVEI C,10
		NOUT
		 JFCL
		CALL PRTDSC
		SKIPN ERRTYP	;RECOVERABLE?
		JRST .+1	;YES. PROCEED
		JRST DOPT1]
DOPAG:	SKIPN A,PTPAGE(PT)	;DO NEXT DATA PAGE
	JRST DOP3		;NONE HERE
	TLZ A,777000		;IGNORE CHECKSUM
	JUMPE A,DOP3		;IF NOW ZERO, IGNORE IT
	MOVE C,DATA
	ADDI C,PAGLEN
	MOVEM C,DATA		;BUMP DSKOP POINTER
	MOVEM COUNT,COUNTM	;SAVE READ-POINTER
	CALL SETUP		;DO IT
	 JRST [	HRROI A,[ASCIZ /
?HARD ERROR READING PAGE # /]
		SKIPN ERRTYP	;REALLY HARD?
		HRROI A,[ASCIZ /
%RECOVERABLE ERROR READING PAGE # /]
		PSOUT
		SKIPE ERRTYP
		SETOM HRDERR	;MARK HARD ERROR
		MOVEI A,.PRIOU
		MOVEI B,0(PT)
		MOVEI C,10
		NOUT
		 JFCL
		HRROI A,[ASCIZ / OF INDEX-BLOCK # /]
		PSOUT
		MOVEI A,.PRIOU
		MOVEI B,0(PTT)
		NOUT
		 JFCL
		CALL PRTDSC
		PSOUT
		JRST DOP2]	;DO NEXT
DOP2:	AOBJN COUNT,DOP3	;GET PAGES VIA DSKOP
	MOVEM COUNT,COUNTM#	;SAVE COUNT FOR POSTERITY
	CALL DSKOUT		;WRITE BUNCH OF PAGES OUT
	MOVEI COUNT,DATPAG-PAGLEN
	MOVEM COUNT,DATA	;RESTORE ORIGINAL DSKOP-POINTER
	MOVSI COUNT,-TIMES
	SETZM COUNTM
DOP3:	TRNE PTT,-1		;FIRST SUPER-INDEX POINTER ?
	JRST DOP4		;NOPE
	TRNE PT,-1		;AND FIRST INDEX-POINTER ?
	JRST DOP4		;NOPE
	MOVE D,FDBNEW		;IS DEST-FILE LONG ??
	TXNN D,FB%LNG
	  JRST [HRROI A,[ASCIZ /
? DESTINATION FILE NOT A LONG FILE ????
/]
		PSOUT
		JRST DONE1]	;GIVE UP ,THIS IS FISHY !!
	PUSH P,W2		;SAVE W2
	MOVE W2,DESIG
	MOVEI C,ORGPTR		;WHERE WE WANT TO READ TO
	MOVE A,FDBNEW+2		;READ SUPER-INDEX BLOCK
	CALL SETUP
	 JFCL			;FOR THE TIME BEING
	MOVEI C,ORGPTR
	MOVE A,ORGPTR
	CALL SETUP		;AND FIRST INDEX-BLOCK
	 JFCL			;FOR THE TIME BEING
	POP P,W2
	MOVE A,ORGPTR		;GET FIRST PAGE-ADRESS FOR COMPARISON
CHECK2:	CAME A,BOOTPG+PAGLEN+PAGLEN
	JRST [HRROI A,[ ASCIZ /
? FRONT-END-FILE-SYSTEM.BIN DOES NOT START
  AT SAME ADRESS AS ORIGINAL , CANNOT RESTORE
/]
	PSOUT
	JRST DONE1]
	TLZ A,777000		;GET RID OF CHECKSUM
	SUBI A,4		;
	MOVEM A,DSKADR		;AND STORE FOR DSKOUT

; THESE ARE THE LOOPS OVER SUPER-INDEX AND INDEX-BLOCKS !!
;
DOP4:	AOBJN PT,DOPAG		;DO ALL OF THIS INDEX-POINTER
DOPT1:	AOBJN PTT,DOPT		;DO NEXT INDEX-BLOCK
	MOVEI A,DATPAG-PAGLEN	;BUILD CORE-ADRESS
	MOVEM A,CORDAT		;AND STORE
	MOVN DSKCNT,COUNTM	;BUILD REPITITION COUNT
	HRLZS DSKCNT
	CALL DSKLOP		;GET FINAL BUNCH OUT
DONE:	SKIPE HRDERR
	 JRST 	[HRROI A,[ASCIZ /
?COPYING PROCESS UNSUCCESSFUL , HARD ERROR!!
DELETE ORIGINAL AND GET IT BACK WITH DUMPER !!
? BOOTS NOT WRITTEN ,CORRECT PROBLEMS FIST !
/]
			PSOUT
			JRST DONE1]
	HRLZI A,10		;BLOCK 0 GETS BOOTS
	MOVEI B,.DOPSR		;STRUCTURE RELATIVE ADRESSING
	STOR B,DOP%AT,A		;STORE  IT
	SETONE DOP%SN,A		;SAY DEVICE  DESIGNATOR IN D
	MOVX B,DOP%WR!200B35	;ONE BLOCK ONLY,WRITE
	MOVE D, DESIG		;DEVICE DESIGNATOR
	MOVEI C,BOOTPG		;FROM BOOT-PAGE
BOOT:	DSKOP
	JFCL
	HRROI A,[ASCIZ /
BOOT WRITTEN
/]
	PSOUT
	HRROI A,[ASCIZ /

DONE!
/]
	PSOUT
DONE1:	SETO A,
	HRLI B,.FHSLF
	HRRI B,BOOTNR
	MOVX C,PM%CNT!3B35
	PMAP			;UNMAP OUR BOOT-FILE
	SETO A,
	CLOSF
	 JRST [JSERR
		 JRST START]
	HALTF
	JRST START		;START OVER IF CONTINUED
	END START