	.TITLE	DISMOUNT-A-DISK MCR FUNCTION
/
/ COPYRIGHT (C) 1975
/ DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/ THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/ THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/ SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/ VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/ EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/ THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/ SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/ WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/ MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/ DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/ OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY
/ DEC.
/
	.EJECT
/
/
/	EDIT 007	JUN 25 75	M. HEBENSTREIT
/
/
/ THIS PROGRAM IS USED TO LOGICALLY DISMOUNT A DISK.
/ IT CANNOT BE USED FOR THE SYSTEM DISK HOWVEVER.
/ THE COMMAND STRING IS: MCR>DSM DISK, WHERE DISK IS
/ RP, RF, OR RK FOLLOWED BY A UNIT NUMBER.
/ THIS MCR FUNCTION WILL CLEAR THE APPROPRIATE DISK-UFD
/ TABLE ENTRY AND ALL LUN-UFD TABLE ENTRIES ASSOCIATED
/ WITH THE DISK.
/
/ DEFINING TDV PRODUCES A VERSION FOR A TDV FUNCTION
/
/
/
PDVL=252
.ENB=705521
.INH=705522
IDX=ISZ
PENP=115
MCRRI=171
        .IFUND TDV
FAC=174
        .ENDC
LUTP1=142
LUTP2=143
LUFD1=304
X10=10
X11=11
X12=12
SYSDSK=301
DUFD1=306
DSAFLG=310
MSGLUN=2
RFACTB=210
RPACT0=364
RKACT0=414
/  
START	LAC	(START	/GET THE XR ADJUSTMENT
	AND	(70000
	DAC	MXRADJ
	TCA
	DAC	XRADJ
        .IFDEF TDV
        CAL     RDTDV
        CAL     WAIT
        LAC     EV
        DAC     XREREV
        SPA
        JMP     ERR09
        JMS     FAC
        SAD     (15
        JMP     ERR01
        SAD     (175
        JMP     ERR01
        SAD     (40
        SKP
        JMP     .-7
        .ENDC
	JMS	GETDEV	/GET DEVICE NAME AND UNIT NO.
	JMP	ERR01        /RETURN HERE IS A FORMAT ERROR IS FOUND
	SAD	(40	/NO ERRORS -- WHAT IS THE NEXT CHAR.?
	JMP	SPACE        /SPACE
	SAD	(15
	JMP	H1   /CARRIAGE RETURN
	SAD	(175
	JMP	H1   /ALTMODE
	JMP	ERR01 /ANY OTHER CHARACTERS ARE ERRORS
        .IFUND TDV
SPACE	JMS*	(FAC   /LOOK FOR THE TERMINATOR
        .ENDC
        .IFDEF TDV
SPACE   JMS     FAC
        .ENDC
	SAD	(40
	JMP	.-2
	SAD	(15
	JMP	H1
	SAD	(175
	JMP	H1
	JMP	ERR01        /OTHER CHARACTERS ARE ERRORS
H1	DAC	TERM       /SAVE THE TERMINATOR
	LAC	GN2	/SAVE THE UNIT NUMBER
	DAC	UNIT
	LAC	GN1	/SAVE THE NAME
	DAC	NAME1
	JMS	DEQUE        /TRY TO FIND DEVICE IN PDVL LIST
	JMP	ERR02        /IF DEVICE ISN'T IN LIST THAT'S AN ERROR
        LAC     NAME1	/GET NAME INOT AC
        SAD     (220600	/RF?
        JMP     RF0	/YES
        SAD     (222000	/NO -- RP?
        JMP     RP0	/YES
        SAD     (221300	/NO -- RK/
        SKP		/YES
        JMP     ERR03	/NO -- ERROR DEIVCE IS NOT A DISK
RK0     LAC     (24	/GET THE APPROPRIATE DEVICE CODE
        SKP
RP0     LAC     (3
        SKP
RF0     LAC     (2
        DAC     DEVICE	/SAVE THE DEVICE CODE
        LAC     UNIT
        SZA
        JMP     NOTSYS	/DEVICE CAN'T BE SYS. DEV. IF UNIT<>0
        LAC*    (SYSDSK
        SAD     DEVICE
        JMP     ERR04	/ERROR -- ILL TO DISMOUNT SYSTEM DISK
NOTSYS  LAC     DEVICE	/GET THE ADDR. OF THE UFD NAME FROM DISK-UFD TABLE
        SAD     (2
        JMP     RF1
        SAD     (3
        JMP     RP1
RK1     LAC*    (DUFD1
        AAC     10
        TAD     UNIT
        JMP     GETUFD
RP1     LAC*    (DUFD1
        TAD     UNIT
        JMP     GETUFD
RF1     LAC*    (DUFD1
        AAC     20
GETUFD  DAC     TEMP	/GET UFD STARTING BLOCK
        LAC*    TEMP
        SNA
        JMP      ERR05	/ERROR -- NOT MOUNTED
        LAC     NODEAD	/CALCULATE THE ADDRESS OF WORD 6 IN THE NODE
        AAC     6
        DAC     ADDWD6
        PXA		/SAVE THE XR
        DAC     XRSAV
        LAW     -20	/SET THE MARK TIME COUNTER TO -20
        DAC     MARKCT
INHIB   LAC     XRSAV	/TEST THAT NO I/O IS IN PROGRESS
        PAX
        .INH
        LAC     6,X	/I/O IN PROGRESS?
        SAD     ADDWD6
        JMP     OK1	/NO
MARKTM  .ENB		/YES -- MARK SOME TIME
        ISZ     MARKCT
        SKP
        JMP     ERR07	/ERROR -- DEVICE IN USE
        CAL     MARK
        CAL     WAIT
        LAC     EV
        SPA
        JMP     ERR08	/ERROR -- MARK TIME NEG. EV
        JMP     INHIB
OK1     LAC     11,X	/TEST FOR OPEN FILES
        AND     (200000
        SZA
        JMP     MARKTM	/OPEN FILES -- MARK SOME TIME
	LAC	10,X	/STOP I/O TO DSK
	DZM	10,X
	DAC	TEMP1	/BY CLEARING TRIGGER TEMPORARILY
	.ENB
	DZM*	TEMP	/CLEAR DSIK-UFD ENTRY
	LAC*	(LUTP1	/USE X11 AS A POINTER TO LUT TABLE
	AAC	-1
	DAC*	(X11
	LAC*	(LUFD1	/USE X10 AS A POINTER TO LUN-UFD TABLE
	AAC	-1
	DAC*	(X10
	LAC*	(LUTP1	/DETERMINE NUMBER OF LUNS
	TCA
	TAD*	(LUTP2
	IAC
	TCA		/NEGATE FOR USE AS A COUNTER
	DAC	TEMP	/USE TEMP AS A LUN COUNTER
UFD1	LAC*	X11	/IS THIS LUN ASSIGNED TO THE DISK?
	SAD	NODEAD
	JMP	UFD2	/YES
	LAC*	X10	/NO -- INCREMENT X10
	SKP
UFD2	DZM*	X10	/ZERO LUN-UFD TABLE ENTRY
	ISZ	TEMP	/DONE WITH ALL LUNS?
	JMP	UFD1	/NO
	.INH		/YES -- RESOTE PDVL NODE'S TRIGGER
	LAC	TEMP1
	.ENB
	DAC	10,X
	LAC	DEVICE	/SET UP TO DEAL THE FILE HANDLERS BLKS
	DAC	DEAL+4
	SAD	(2
	JMP	RF8
	SAD	(3
	JMP	RP8
	LAC	(RKACT0
	SKP
RF8	LAC	(RFACTB
	SKP
RP8	LAC	(RPACT0
	DAC	TEMP	/PREPARE TO FIND ADDR. OF DEAL CTA
	CLL
	LAC	UNIT
	MUL
	3
	LACQ
	TAD	TEMP
	DAC	DEAL+3	/SET CTA INTO DEAL CPB
	IAC
	DAC	TEMP	/SAVE ADDR OF PLATTER NO.
	LAC	UNIT
	ALS	17
	DAC	TEMP1
	LAC*	TEMP	/SET UNIT INTO CTA
	AND	(077777
	XOR	TEMP1
	DAC*	TEMP
	CAL	DEAL	/DEAL ALL THE FILES HANDLERS BLOCKS
	CAL	WAIT
	.INH
	LAC	TEMP	/ZERO THE CTA
	AAC	-1
	DAC	TEMP
	DZM*	TEMP
	IDX	TEMP
	DZM*	TEMP
	IDX	TEMP
	DZM*	TEMP
        LAC*    (DSAFLG	/GET THE PTR TO THE FLAG WHICH INDICATES
                       	/THAT A BIT MAP IS ALREADY IN CORE
        DAC     TEMP	/PREPARE TO INDICATE NO BIT MAPS ARE IN CORE
        LAW     -1
        DAC*    TEMP	/NO BIT MAPS IN CORE
        .ENB
        LAC     (MSG0	/PRINT MESSAGE -- OK TO DISMOUNT
        DAC     WRITE+4
        CAL     WRITE
        CAL     WAIT
        .IFUND TDV
EXIT	LAC TERM    /EXIT ACCORDING TO THE LINE TERMINATOR
	SAD	(15
        JMP     EXIT1
	DZM*	(MCRRI
        SKP
EXIT1   CAL     REQMCR
        CAL     (10
        .ENDC
        .IFDEF TDV
EXIT    LAC     XREREV
        SAD     (1
        SKP
EXIT1   CAL     REQMCR
        CAL     (10
        .ENDC
REQMCR	1
	0
        .IFUND TDV
	.SIXBT "..."
	.SIXBT "MCR"
        .ENDC
        .IFDEF TDV
        .SIXBT "TDV"
        .SIXBT "..."
        .ENDC
	0
/
/       S.R. TO LOOK UP A NODE IN PDVL
/       ONE ENTRY THE 1ST HALF OF THE NAME MUST BE IN NAME1 AND
/       THE UNIT NUMBER MUST BE IN UNIT.        ON RETURN, NODEAD HAS THE
/       ADDRESS OF THE INDICATED NODE (ASSUMING NO ERROR WERE DETECTED)
/       AND THE RETURN IS TO JMS+2. IF, HOWEVER, ERRORS WERE DETECTED
/       RETURN IS AT JMS+1.
/
DEQUE	0
	LAC	(PDVL	/SET XR TO ACCESS HEADER OF PDVL
	JMS	SETXR
	LAC	0,X	/GET ADDR. OF 1ST NODE
D1	JMS	SETXR      /COMPARE THE NAME AND UNIT NUMBER, JMP TO D2 IF NO MATCH
	LAC	2,X
	SAD	NAME1	/1ST HALF OF NAME MATCHES?
	SKP
	JMP	D2	/NO
        LAC     3,X		/YES -- 2ND HALF OF NAME?
	SZA
	JMP	D2	/NO
	LAC	5,X	/DOES THE UNIT NO. MATCH
	SAD	UNIT
	SKP
	JMP	D2	/NO
	PXA		/YES -- SAVE THE NODE ADDR
	TAD	MXRADJ
	DAC	NODEAD
	ISZ	DEQUE	/RETURN AT JMS+2 -- NODE FOUND
	JMP*	DEQUE
D2	LAC	0,X        /NO MATCH SO TEST FOR END OF DEQUE
	SAD	(PDVL
	JMP*	DEQUE
	JMP	D1	/NOT THE END OF THE DEQUE -- CHECK NEXT NODE
/
/       S.R. TO ADJUST THE XR
/
SETXR   0
	TAD	XRADJ
	PAX
	JMP*	SETXR
TERM	0
XRADJ	0
MXRADJ	0
UNIT	0
NODEAD	0
EV	0
GN1	0
GN2	0
GNNFLG	0
GNTEMP	0
NNODE	0
FP	0
NAME1	0
MARKCT  0
XRSAV   0
TEMP1   0
TEMP    0
DEVICE  0
ADDWD6  0
XREREV  0
/
/       S.R. TO GET A DEVICE NAME AND UNIT NUMBER
/       ON RETURN GN1 HAS 1ST HALF OF NAME AND GN2 HAS UNIT NUMBER
/       IF ANY ERRORS ARE DETECTED RETURN AT JMS+1
/       IF NO ERRORS ARE DETECTED RETURN AT JMS+2 WITH AC=NEXT CHAR.
/
GETDEV	0
	DZM	GN1	/INIT. NAME AND UNIT NO.
	DZM	GN2
	CLC		/INIT. FLAG -- SPACES NOW LEGAL
	DAC	GNNFLG
	JMS	GDSR /GET 1ST LETTER
	ALS	14
	DZM	GNNFLG	/CLEAR FLAG -- SPACES NOW ILLEGAL
	DAC	GN1	/SAVE CHAR.
	JMS	GDSR /GET 2ND CHAR
	ALS	6
	TAD	GN1
	DAC	GN1	/SAVE NAME OF DEVICE
	JMS	NEXT /GET NEXT CHAR
	JMS	NUMCK	/MAKE SURE IT'S A NO.
	DAC	GN2	/SAVE UNIT NO.
	JMS	NEXT /GET NEXT CHAR
	JMS	NUMCK	/MAKE SURE IT'S A NO.
	DAC	GNTEMP	/CONVERT 2 DIGIT DECI NO. INTO OCATL
	CLL
	LAC	GN2
	MUL
	12
	LACQ
	TAD	GNTEMP
	DAC	GN2	/SAVE UNIT NO.
        .IFUND TDV
	JMS*	(FAC	/GET NEXT CHAR INTO AS
        .ENDC
        .IFDEF TDV
        JMS     FAC
        .ENDC
	JMP	GDOK /PREPARE TO RETURN
/
/       S.R. TO GET NEXT NUMERICAL CHAR.
/
NEXT	0
        .IFUND TDV
	JMS*	(FAC
        .ENDC
        .IFDEF TDV
        JMS     FAC
        .ENDC
	SAD	(40	/SPACE?
	JMP	GDOK /YES
	SAD	(175 /NO -- ALTMODE?
	JMP	GDOK /YES
	SAD	(15	/NO -- CR?
	JMP	GDOK /YES
	DAC	GNTEMP	/NO -- SAVE CHAR
	JMP*	NEXT
/
/       S.R. TO CHECK TO SEE NUMBER IS REALLY A NUMBER
/       ON ENTRY AC HAS ASCII OF DIGIT
/       ON EXIT AC HAS OCTAL VALUE OF DIGIT
/       ERRORS FORCE A JMP TO GDERR
/
NUMCK	0
	TAD	(-60
	SPA
	JMP	GDERR	/ERROR IF ASCII<60
	LAC	GNTEMP
	TCA
	TAD	(71
	SPA
	JMP	GDERR	/ERROR IF ASCII>71
	LAC	GNTEMP
	AND	(17	/OK -- AC CONTAINS OCTAL NO.
	JMP*	NUMCK
/
/       S.R. TO CHECK THAT CHARACTER IS A LETTER
/       ON EXIT AC HAS SIXBT OF CHAR
/       ERRORS RESULT IN A JMP TO GDERR
/
GDSR	0
        .IFUND TDV
	JMS*	(FAC	/READ NEXT CHAR.
        .ENDC
        .IFDEF TDV
        JMS     FAC
        .ENDC
	DAC	GNTEMP
	SAD	(40	/SPACE?
	JMP	GDSPAC	/YES
	SAD	(15	/NO -- CR?
	JMP*	GETDEV	/YES -- RETURN AT JMS+1
	SAD	(175 /NO -- ALTMODE?
	JMP*	GETDEV	/YES -- RETURN
	LAC	(-101	/NO
	TAD	GNTEMP
	SPA
	JMP	GDERR	/ERROR IF ASCII<101
	LAC	GNTEMP
	TCA
	TAD	(132
	SPA
	JMP	GDERR	/ERROR IF ASCII>132
	LAC	GNTEMP
	AND	(77
	CLL
	JMP*	GDSR
GDSPAC	LAC	GNNFLG /IS THE SPACE LEGAL?
	SZA
	JMP	GDSR+1	/YES
GDERR	LAC	GNTEMP	/ERROR
	JMP*	GETDEV
GDOK	ISZ	GETDEV	/OK -- RETURN AT JMS+2
	JMP*	GETDEV
WRITE	2700
	EV
	MSGLUN
	2
	0
WAIT	20
	EV
DEAL	11600
	EV
	1
	XX
	XX
MARK    13
        EV
        15	/# OF TICKS=1/4 SEC.
        1	/TICKS
ERR01	LAC	(MSG1
	DAC	WRITE+4
	CAL	WRITE
	CAL	WAIT
	CLA
	JMP	EXIT1
ERR03	LAC	(MSG3
	JMP	ERR01+1
ERR02	LAC        (MSG2
	JMP	ERR01+1
ERR04	LAC	(MSG4
	JMP	ERR01+1
ERR05   LAC     (MSG5
        JMP     ERR01+1
ERR07   LAC     (MSG7
        JMP     ERR01+1
ERR08   LAC     (MSG8
        JMP     ERR01+1
        .IFDEF TDV
ERR09   LAC     (MSG9
        JMP     ERR01+1
        .ENDC
/
        .IFDEF TDV
RDTDV   37
        EV
        FACLB
        22
/  
/  
/ SUBROUTINE -- FAC -- STANDARD TDV S.R. TO FETCH CHARACTERS OFF A LINE
/  
/  
FAC     0
        LAC*    FACCBX
        SMA
        JMP     FAC2
        LAC     (FACCB-1
        DAC     FACCBX
        LAC*    FACLBX
        ISZ     FACLBX
        LMQ
        CLA!CLL
        JMS     FACUPS
        JMS     FACUPS
        JMS     FACUPS
        LAC*    FACLBX
        ISZ     FACLBX
	LRS	17
        XOR*    FACCBX
        DAC*    FACCBX
        CLA
        JMS     FACUPS
        JMS     FACUPS
        LAC     (FACCB
        DAC     FACCBX
        LAC*    FACCBX
FAC2    SAD     (15
        JMP*    FAC
        SAD     (175
        JMP*    FAC
        ISZ     FACCBX
        JMP*    FAC
/  
FACUPS  0
        LLS     7
        ISZ     FACCBX
        DAC*    FACCBX
        CLA
        JMP*    FACUPS
FACLBX  FACLB+2
FACCBX  FACCB+5
FACCB   .BLOCK 5
        -1
/  
FACLB   .BLOCK 22
        .ASCII <15>
/  
        .ENDC
/ 
MSG0	MSG1-MSG0/2*1000
	0
	.ASCII "DISK IS READY FOR DISMOUNTING"<15>
MSG1	MSG2-MSG1/2*1000
	0
	.ASCII "FORMAT ERROR"<15>
MSG2	MSG3-MSG2/2*1000
	0
	.ASCII "DISK HAS NO PDVL NODE"<15>
MSG3	MSG4-MSG3/2*1000
	0
        .ASCII "DEVICE IS NOT A DISK"<15>
MSG4	MSG5-MSG4/2*1000
	0
        .ASCII "ILLEGAL TO DISMOUNT THE SYSTEM DEVICE"<15>
MSG5    MSG7-MSG5/2*1000
        0
        .ASCII "DEVICE NOT MOUNTED"<15>
MSG7    MSG8-MSG7/2*1000
        0
        .ASCII "DEVICE IS IN USE"<15>
MSG8    MSG9-MSG8/2*1000
        0
	.ASCII "MARK TIME ERROR"<15>
        .IFUND TDV
MSG9	0
        .ENDC
        .IFDEF TDV
MSG9    MSG10-MSG9/2*1000
        0
        .ASCII "TDV READ ERROR"<15>
MSG10   0
        .ENDC
	.END
