Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/mapit.fai
There are no other files named mapit.fai in the archive.
	SUBTTL  Copy Program from Section 0 to Section 1.

	SEARCH MONSYM
	ENTRY MAPIT

A=1
B=2
C=3
D=4
P=17
DDTORG=770000			;starting address for DDT

;This subroutine copies the program in section 0 into section 1.
;DDT, if present, is also moved to section 1, with its entry point fixed
;up.
;call: via PUSHJ, with local stack set up but empty
MAPIT:	MOVEI	A,0		;make a private section
	MOVE	B,[.FHSLF,,1]	;section 1
	MOVE	C,[PM%CNT!PM%RWX+1] ;one section with all access
	SMAP%
	 ERJMP	SMPFAI		;shouldn't fail if SMAP% exists
	MOVE	D,[.FHSLF,,0]	;initial fork page pointer
MAPIT1: MOVE	A,D		;fork,,page #
	RMAP			;read fork's map.
	CAMN	A,[-1]		;-1 means no access
	 JRST	MAPIT2		;no work for no page
	MOVE	C,B		;access bits from RMAP
	MOVE	B,D		;fork,,source page#
	IORI	B,1000		;fork,,destination page #
	PMAP			;copy map from sect 0 to 1
	 ERJMP	PMPFAI		;unexpected failure
MAPIT2: ADDI	D,1		;increment fork page pointer
	TRNN	D,1000		;done yet?
	 JRST	MAPIT1
				;Now, unmap UDDT from section 0
	SETO	A,		;unmap process page
	MOVE	B,[.FHSLF,,771]	;unmap UDDT from section 0
	MOVE	C,[PM%CNT!7]	;remove pages 771 through 777
	PMAP
	 ERJMP	.+1		;ignore errors

	MOVE	A,[.FHSLF,,770]	;is UDDT present?
	RMAP
	MOVE	B,[JRST DDTORG+2]
	CAME	A,[-1]		;no page at 770000
	 CAME	B,DDTORG	;or not JRST 770002
	  JRST	MAPIT5		;no DDT at all.

;Make Section 0 UDDT jump to section 1.
;We can't write this page 770, so we discard it.
	PUSH	P,DDTORG	;save 770000,1,2
	PUSH	P,DDTORG+1
	PUSH	P,DDTORG+2
	SETO	A,		;unmap page 770
	MOVE	B,[.FHSLF,,770]
	MOVEI	C,0
	PMAP
	 ERJMP	PMPFAI
	POP	P,DDTORG+2	;Put back three words, creating a new page
	POP	P,DDTORG+1
	POP	P,DDTORG
	MOVE	A,[NEWDDT,,DDTORG+3]
	BLT	A,DDTORG+5
MAPIT5: XJRSTF  [0		;Now, jump to section 1
		1,,.+1]

	jrst mapit7		;for now
	SETO	A,		;now, unmap rest of section 0
	MOVSI	B,.FHSLF
	MOVEI	C,0		;clear page 0
	PMAP
	 ERJMP	PMPFAI
	MOVE	B,[.FHSLF,,0]	;destination is page 0
	SETZ	C,		;no access
	MOVSI	A,.FHSLF	;source is current fork
	MOVSI	D,-740		;number of pages to set indirect
MAPIT6:	HRR	A,D
	PMAP%			;set this page to point to 0, no access
	 ERJMP	.+1
	AOBJN	D,MAPIT6

MAPIT7:	MOVSI	A,1		;Set section 1 in return address
	HLLM	A,(P)		;set left half to section 1
	RET			;return in section 1


PMPFAI:	HRROI	A,[ASCIZ/PMAP failed: /]
	JRST	ERROR
;to here if SMAP% does not exist
SMPFAI:	HRROI	A,[ASCIZ/SMAP failed: /]
ERROR:	ESOUT
	MOVEI	A,.PRIOU
	HRLOI	B,.FHSLF
	MOVEI	C,0
	ERSTR%
	 JFCL
	 JRST [	HRROI	A,[ASCIZ/ (and so did ERSTR)
/]
		PSOUT%
		JRST SMPFA0 ]
SMPFA0:	HALTF%
	JRST	SMPFA0		;can't continue

NEWDDT:	XJRSTF	DDTORG+4	;starting instruction for UDDT at 770003
	0			;new PC flags for XJRSTF
	1,,DDTORG		;new PC for XJRSTF

	END