Google
 

Trailing-Edge - PDP-10 Archives - BB-H348C-RM_1982 - swskit-v21/debugging-tools/dnboot.mac
There are no other files named dnboot.mac in the archive.
	SEARCH CMDSYM
;
	TITLE$ DNBOOT,1,,2,,<DN20 BOOTSTRAP AND TEST PROGRAM>
;
	PSECT$ IMPURE
;
PDL:	BLOCK <PDLEN==20>
LSTPDL:	BLOCK <LPDLEN==10>	;LISTEN FORK PDL
TLKFRK:	BLOCK 1			;FORK HANDLE OF LISTEN FORK
TLKJFN:	BLOCK 1			;JFN OF TALK TERMINAL
TLKFLG:	BLOCK 1			;0: NOT TALKING; -1: TALKING
LSNFLG:	BLOCK 1			;0: LISTENING DISABLED; -1: LISTENING ENABLED
LOGJFN:	BLOCK 1			;JFN OF LOG FILE
LOGLCK:	BLOCK 1			;LOG FILE LOCK FLAG
ESCHAR:	BLOCK 1			;ESCAPE CHARACTER
DEFDTE:	BLOCK 1			;DEFAULT DTE20 NUMBER (-1 IF NONE)
BOTPRM:	BLOCK 1			;LAST BOOT PARAMETER (-1 IF NONE)
BOTPRG:	BLOCK 2			;BOOTSTRAP PROGRAM FOR -11
;
	PSECT$ PURE
;
CMDTAB:
	XWD CMDNUM,CMDNUM
	CMD$ BOOT
	CMD$ CLOSE
	CMD$ EXIT
	CMD$ HELP
	CMD$ INITIALIZE
	CMD$ LISTEN
	CMD$ LOG
	CMD$ NO
	CMD$ REVIVE
	CMD$ SAY
	CMD$ SET
	CMD$ SHOW
	CMD$ SILENCE
	CMD$ TAKE
	CMD$ TALK
	CMD$ TERMINATE
CMDNUM==.-CMDTAB-1
;
NOCTAB:
	XWD NOCNUM,NOCNUM
	CMD$ LISTEN
	CMD$ NO
NOCNUM==.-NOCTAB-1
	SUBTTL INITIALIZE AND GET TOP-LEVEL KEYWORD
;
;
DNBOOT:
	RESET			;RESET THE WORLD
	MOVE P,[IOWD PDLEN,PDL] ;SET PDL
	SETZM TLKFRK		;INDICATE NO TALKING
	SETZM TLKFLG		; . .
	MOVEI T1,"E"-100	;GET "^E"
	MOVEM T1,ESCHAR		;SAVE AS ESCAPE CHARACTER
	SETOM DEFDTE		;INDICATE NO DEFAULT DTE
	SETOM BOTPRM		; AND NO BOOT PARAMETER
	SETZM LOGJFN		;NOT LOGGING
;
; INIT COMND STUFF
;
	TEXT$ T1,<DNBOOT>	;SET OUR NAME
	CALL $CMINI		;INIT CMD
	TEXT$ T1,<LISTEN (TO TERMINAL) >
	CALL $CMRSC		;CHECK FOR RESCAN COMMAND
	 JFCL			;OK IF IT IS
;
; ENABLE ^C CAPABILITY
;
	MOVEI T1,.FHSLF
	RPCAP
	TXNN T2,SC%CTC		;WE HAVE ^C ABILITY?
	 ERR$ <^C Capability required>
	TXON T3,SC%CTC
	 EPCAP
	ERCAL$
CMDLP:
	MOVE T1,[XWD [FLDDB. (.CMKEY,,NOCTAB)],[FLDDB. (.CMKEY,,CMDTAB)]]
	CALL $CMTLC		;GET A TOP LEVEL COMMAND
	 JRST CMDEX		;EXIT COMMAND OCCURED-- CHECK LOG FILE
	JRST CMDLP		;LOOP
;
; HERE IF AN EXIT OCCURED-- CHECK LOG FILE AND EXIT
;
CMDEX:
	SKIPN LOGJFN		;LOG FILE OPEN?
	 JRST CMDEX1		;NO-- JUST HALTF
	TYPE$ <[LOG FILE IS STILL OPEN]
>
CMDEX1:
	HALTF			;EXIT FROM DNBOOT
	JRST CMDLP		;BACK FOR ANOTHER COMMAND
	SUBTTL "BOOT" COMMAND
;
;
$BOOT:
	NOISE$ <DTE20>
	CALL DTENUM		;GET DTE20 #
	NOISE$ <FROM>
	COMND$ <.CMKEY,,BOTKWD,,PARAMETER>
	 ERRA$ <INVALID KEYWORD>
	HRRZ T2,(T2)		;GET DISPATCH ADDRESS
	CALLR (T2)		;CALL SUB-KEY ROUTINE AND RETURN FROM $BOOT
;
BOTKWD:
	XWD BOTKWZ,BOTKWZ
	TB$ BOTDSK,<DISK>
	TB$ BOTFLP,<FLOPPY>
	TB$ BOTPAR,<PARAMETER>
	TB$ BOTSTA,<START-ADDRESS>
	TB$ BOTSWR,<SWITCH-REGISTER>
BOTKWZ=.-BOTKWD-1
;
BOTFLP:
	TDZA T2,T2		;BIT7 = 0 FOR FLOPPY
BOTDSK:
	MOVEI T2,1B<35-7>	;BIT7 = 1 FOR DISK
	CALLR BOTPA1		;DO PARAMETER BOOT
;
BOTPAR:
	NOISE$ <VALUE>
	MOVE T2,BOTPRM		;GET BOOT PARAMETER
	CALL OCTDEF		;GET OCTAL/DEFAULT
BOTPA1:
	MOVX T1,<BYTE (16) 012700> ;GET "MOV #,R0"
	DPB T2,[POINT 16,T1,31]	;STORE PARAMETER
	MOVE P2,T2		;REMEMBER IT
	MOVEM T1,BOTPRG+0	;STORE FIRST WORD OF PROGRAM
	MOVX T1,<BYTE (16) 000137,173034> ;GET "JMP 173034"
	MOVEM T1,BOTPRG+1	;STORE SECOND WORD OF PROGRAM
	CALL $CMCFM		;GET CONFIRMATION
	MOVEM P2,BOTPRM		;REMEMBER THE PARAMETER
	CALLR BOTBOT		;PERFORM BOOT
;
BOTSWR:
	MOVEI T2,173000		;START HERE FOR SWITCH REGISTER
	CALLR BOTST1		;START BOOT
;
BOTSTA:
	COMND$ <.CMNUM,,^D8>	;GET START ADDRESS
	 ERRA$ <INVALID OCTAL NUMBER>
BOTST1:
	MOVX T1,<BYTE (16) 000137> ;GET "JMP "
	DPB T2,[POINT 16,T1,31]	;STORE START ADDRESS
	MOVEM T1,BOTPRG+0	;STORE PROGRAM
	CALL $CMCFM		;GET CONFIRMATION
	CALLRX BOTBOT		;FINICH UP
;
; BOTBOT -- COMPLETE BOOT COMMAND BY GRONKING ROM
;
BOTBOT:
	MOVX T1,.BTROM		;SET TO GRONK ROM
	MOVX T2,P1		;POINT TO ARGUMENT BLOCK
	BOOT			;GRONK
	ERCAL$
	MOVX T1,.BTLDS		;GET SECONDARY PROGRAM
	MOVEI P3,BOTPRG		;POINT TO PROGRAM
	BOOT			;SEND PROGRAM
	ERCAL$
	RETURN			;BOOT COMPLETE, RETURN FROM $BOOT
	SUBTTL "CLOSE" COMMAND
;
;
$CLOSE:
	NOISE$ <LOG FILE>
	CALL $CMCFM		;GET CONFIRMATION
	SKIPN LOGJFN		;GET LOG JFN
	 ERR$ <NOT LOGGING TERMINAL OUTPUT>
	AOSE LOGLCK		;LOG LOCKED?
	 JRST [	MOVEI T1,100		;YES-- WAIT
		DISMS			;100 MS
		JRST .-1]		;UNTIL UNLOCKED
	MOVE T1,LOGJFN		;GET LOG JFN
	SETZM LOGJFN		;NO MORE LOG JFN
	CLOSF			;CLOSE AND RELEASE LOG FILE
	 ERRJ$
	RETURN			;RETURN FROM $CLOSE
	SUBTTL "INITIALIZE", "TERMINATE" COMMANDS
;
;
$INITIALIZE:
	MOVX P2,.BTIPR		;SET INIT FUNCTION
	CALLR INITRM		;DO INIT/TERM
;
$TERMINATE:
	MOVX P2,.BTTPR		;SET TERMINATE FUNCTION
INITRM:
	NOISE$ <PROTOCOL ON DTE20>
	CALL DTENUM		;GET DTE20 #
	CALL $CMCFM		;GET CONFIRMATION
;
	MOVE T1,P2		;GET INIT/TERM FUNCTION
	MOVEI T2,P1		;POINT TO DTE20 #
	MOVEI P2,1		;SET NSP PROTOCOL
	BOOT			;DO BOOT
	ERCAL$
	RETURN			;RETURN FROM $INITIALIZE/$TERMINATE
	SUBTTL "LISTEN" COMMAND
;
;
$LISTEN:
	NOISE$ <TO TERMINAL>
	SKIPE $NOFLG		;NO LISTEN?
	 JRST LISTN1		;YES-- JUST RESET STUFF
	MOVX T1,GJ%OLD		;TERMINAL MUST EXIST
	SETZ T2,		;NO DEFAULT DEVICE
	SETZB T3,T4		;NO DEFAULT FILE OR TYPE
	CALL $CMFIL		;GET TERMINAL JFN
	MOVE P1,T2		;SAVE THAT JFN
LISTN1:
	CALL $CMCFM		;GET CONFIRMATION
;
; CLOSE OLD TALK TERMINAL AND LISTEN FORK
;
	SKIPN T1,TLKFRK		;WAS THERE AN OLD LISTEN FORK?
	 JRST LISTN2		;NO-- GO ON
	SETZM TLKFRK		;NO LONGER A FORK
	KFORK			;KILL OLD LISTEN FORK
	MOVE T1,TLKJFN		;GET OLD TALK JFN
	CLOSF			; AND CLOSE IT TOO
	 ERRJ$
;
; OPEN NEW TALK TERMINAL
;
LISTN2:
	SKIPE $NOFLG		;NO LISTEN?
	 RETURN			;YES-- DON'T LISTEN, RETURN FROM $LISTEN
	MOVE T1,P1		;GET NEW TALK JFN
	MOVX T2,<^D8>B5!OF%RD!OF%WR ;OPEN IN BINARY MODE
	OPENF			; . .
	 ERRJ$
;
; CREATE AND START LISTENING FORK
;
	MOVEM P1,TLKJFN		; AND TALK JFN
	SETOM LSNFLG		;NOTE LISTEN ENABLE
	MOVX T1,CR%MAP!CR%CAP!CR%ST+LISTEN ;SET TO CREATE LISTEN FORK
	CFORK			; AND START IT AT "LSTNLP"
	 ERRJ$
	MOVEM T1,TLKFRK		;SAVE FORK HANDLE
	MOVE T1,P1		;ALSO
	CALLR $JFCLR		; INDICATE JFN IS OK AND RETURN FROM $LISTEN
;
; LISTEN LOOP EXECUTED BY LISTEN FORK
;
LISTEN:
	MOVE P,[IOWD LPDLEN,LSTPDL] ;SET STACK
	MOVEI P1,12		;MAKE LIKE FIRST IS <LF>
;
LSTNLP:
	MOVE T1,TLKJFN		;GET TALK JFN
	BIN			;GET A BYTE (BLOCK UNTIL ONE THERE)
	ANDI T2,177		;TRIM TO 7 BITS
	SETZM LOGLCK		;INDICATE LOG FILE LOCKED
	SKIPN T1,LOGJFN		;LOGGING?
	 JRST LSTNL1		;NO-- GO ON
	CAIE T2,177		;<DEL>?
	CAIN T2,0		; OR <NUL>?
	 JRST LSTNL1		;YES-- DON'T LOG THEM
	CAIN T2,15		;<CR>?
	CAIE P1,15		;YES-- LAST ONE <CR> TOO?
	 BOUT			;NO-- LET'S LOG THE CHARACTER
LSTNL1:
	SETOM LOGLCK		;ENABLE IT
	SKIPE TLKFLG		;TALKING TOO?
	 JRST LSTNL2		;YES-- ALWAYS LISTEN, CLEARLY
	SKIPN LSNFLG		;LISTENING?
	 JRST LSTNL3		;NO-- JUST LOG IT
	CAIE P1,12		;WAS LAST CHAR <LF>?
	 JRST LSTNL2		;NO-- GO ON
	PUSH P,T2		;SAVE THIIS CHARACTER
	TYPE$ <*** >		;YES-- ADD PREFIX
	POP P,T2		; . .
LSTNL2:
	HRRZ T1,$CMBLK+.CMIOJ	;POINT TO CONSOLE
	BOUT			;SEND IT TO CONSOLE
LSTNL3:
	MOVE P1,T2		;REMEMBER IT
	JRST LSTNLP		;BACK FOR MORE
	SUBTTL "LOG" COMMAND
;
;
$LOG:
	NOISE$ <TERMINAL OUTPUT ON FILE>
	MOVX T1,GJ%MSG		;OLD FILE IS OK, WE'LL APPEND
	SETZB T2,T3		;NO DEFAULT DEVICE OR FILENAME
	TEXT$ T4,<LOG>		;DEFAULT LOG TYPE
	CALL $CMFIL		;GET FILE SPEC
	MOVE P1,T2		;SAVE THE JFN
	CALL $CMCFM		;GET CONFIRMATION
	SKIPE LOGJFN		;ALREADY LOGGING?
	 ERR$ <ALREADY LOGGING TERMINAL OUTPUT>
	MOVE T1,P1		;GET JFN
	MOVX T2,<^D7>B5+OF%APP	;APPEND, 7 BIT BYTES
	OPENF			;OPEN LOG FILE
	 ERRJ$			;OOPS
	CALL $JFCLR		;MARK JFN NOW OK
	SETOM LOGLCK		;INDICATE LOG LOCK AVAILABLE
	MOVEM T1,LOGJFN		;REMEMBER JFN
	RETURN			;RETURN FROM $LOG
	SUBTTL "REVIVE", "SILENCE" COMMANDS
;
;
$SILENCE:
	TDZA P1,P1		;INDICATE SILENCE
$REVIVE:
	SETO P1,		;INDICATE NOISE
	NOISE$ <OUTPUT FROM LISTENING TERMINAL>
	CALL $CMCFM		;CONFIRM IT
	MOVEM P1,LSNFLG		;SAVE STATE OF LISTEN FLAG
	RETURN			;RETURN FROM $REVIVE
	SUBTTL "SAY" COMMAND
;
;
$SAY:
	NOISE$ <LINE TO LISTENING TERMINAL>
	SETZM $ATBUF		;START WITH NO TEXT
	COMND$ <.CMQST,,,,,[FLDDB. (.CMTXT)]>
	 ERR$ <INVALID TEXT STRING>
	LDB P1,[POINT 9,.CMFNP(T3),8] ;GET COMND FUNCTION
	CALL $CMCFM
	SKIPN T1,TLKJFN		;GET LISTENING JFN
	 ERR$ <NO LISTENING TERMINAL>
	HRROI T2,$ATBUF		;POINT TO ATOM BUFFER
	MOVX T3,0		; IN ASCIZ
	SOUT			;OUTPUT STRING TO LISTENER
	MOVX T2,15		;GET <CR>
	CAIE P1,.CMQST		;QUOTED STRING?
	 BOUT			;NO-- SEND TRAILING <CR>
	RETURN			;RETURN FROM $SAY
	SUBTTL "SET" COMMAND
;
;
$SET:
	COMND$ <.CMKEY,,SETKWD>
	 ERRA$ <INVALID KEYWORD>
	HRRZ T2,(T2)		;GET SET SUBFUNCTION ROUTINE
	CALLR (T2)		;CALL IT AND RETURN FROM $SET
;
SETKWD:
	XWD SETKWZ,SETKWZ
	TB$ SETDEF,<DEFAULT-DTE20>
	TB$ SETESC,<ESCAPE-CHARACTER>
SETKWZ=.-SETKWD-1
;
;
SETDEF:
	NOISE$ <NUMBER TO>
	CALL DTENUM		;GET DTE20 #
	CALL $CMCFM		;CONFIRM.
	MOVEM P1,DEFDTE		;SAVE THE NUMBER
	RETURN			;RETURN FROM SETDEF
;
;
SETESC:
	NOISE$ <TO>
	COMND$ <.CMQST,,,,,<[FLDDB. (.CMNUM,,^D8)]>>
	 ERRA$ <INVALID ESCAPE CHARACTER>
	LDB T1,[POINT 9,.CMFNP(T3),8] ;GET FUNCTION CODE PARSED
	CAIE T1,.CMQST		;QUOTED STRING?
	 JRST SETES2		;NO-- OCTAL NUMBER
	MOVE T4,[POINT 7,$ATBUF] ;YES-- GET POINTER TO IT
	ILDB T2,T4		;GET OUR CHARACTER
	ILDB T1,T4		;GET NEXT ONE
	SKIPE T1		;NULL?
	 ERRA$ <INVALID ESCAPE CHARACTER>
SETES2:
	CAILE T2,177		;GOOD NUMBER?
	 ERRA$ <INVALID ESCAPE CHARACTER>
	MOVE P1,T2		;COPY NUMBER
	CALL $CMCFM		;GET CONFIRM
	MOVEM P1,ESCHAR		;SAVE THE ESCAPE
	RETURN			;RETURN FROM SETESC
	SUBTTL "SHOW" COMMAND
;
;
$SHOW:
	NOISE$ <STATUS OF PROTOCOL ON DTE20>
	CALL DTENUM		;GET DTE20 #
	CALL $CMCFM		;GET CONFIRMATION
;
	MOVX T1,.BTSTS		;STATUS FUNCTION
	MOVEI T2,P1		;POINT TO DTE20 # AND STATUS CODE
	BOOT			;GET STATUS
	ERCAL$
	TYPE$ < STATUS OF PROTOCOL ON DTE20 >
	MOVE T2,P1		;GET DTE20 NUMBER
	MOVX T3,^D8		;OCTAL
	NOUT
	 ERRJ$
	TYPE$ < IS >
	MOVE T2,P2		;GET STATUS
	MOVX T3,^D10		;DECIMAL
	NOUT
	 ERRJ$
	TYPE$ <.
>
	RETURN			;RETURN FROM $SHOW
	SUBTTL "TALK" COMMAND
;
;
$TALK:
	NOISE$ <TO LISTENING TERMINAL>
	CALL $CMCFM		;GET CONFIRMATION
	SKIPN TLKFRK		;THERE A LISTENER?
	 ERR$ <NO LISTENING TERMINAL>
;
	TYPE$ <[TYPE ">
	MOVE T2,ESCHAR		;GET ESCAPE
	CAIL T2," "		;CONTROL?
	 JRST TALK4		;NO-- GO ON
	TYPE$ <^>		;YES-- NOTE THAT
	MOVE T2,ESCHAR		;GET ESCAPE BACK
	ADDI T2,100		;MAKE IT ALPHABETIC
TALK4:
	BOUT			;TYPE ESCAPE
	TYPE$ <" TO RETURN TO DNBOOT COMMAND LEVEL]
>
;
; SET UP OUR TERMINAL CHARACTERISTICS SO WE CAN TALK PROPERLY
;
	HLRZ T1,$CMBLK+.CMIOJ	;GET CONSOLE JFN
	RFMOD			;GET EXISTING JFN MODE WORD
	MOVE P1,T2		;SAVE IT
	TXZ T2,TT%ECO!TT%DAM!TT%UOC!TT%LIC!TT%PGM
	TXO T2,TT%WAK
	SFMOD			;SET SOME BITS
	STPAR			;SET THE REST
;
	SETZ P2,		;ASSUME TERMINAL IS NOT CONTROLLING
	HLRZ T1,$CMBLK+.CMIOJ	;GET CONSOLE JFN
	DVCHR			;GET DEVICE DESIGNATOR FOR CONSOLE
	MOVE T4,T1		; TO T4
	MOVX T1,.CTTRM		;GET CONTROLLING TERMINAL
	DVCHR			; DEVICE DESIGNATOR
	CAME T1,T4		;DOES CONSOLE (COMND) MATCH CONTROLLING TERMINAL?
	 JRST TALK6		;NO-- DON'T SET TERMINAL INTERRUPT WORD
;
	MOVX T1,.FHJOB		;GET OUR TIW
	RTIW			; . .
	MOVE P2,T2		;SAVE IT
	SETZ T2,		;NO INTERRUPT CHARACTERS
	STIW			; . .
;
TALK6:
	SETOM TLKFLG		;INDICATE TALKING TO LISTENER
;
; NOW LOOP AND SEND THOSE CHARACTERS
;
TALKLP:
	HLRZ T1,$CMBLK+.CMIOJ	;GET CONSOLE JFN
	BIN			;GET A CHARACTER, OR BLOCK UNTIL ONE
	ERJMP TALKDN		;ERROR OR EOF-- RESTORE STATE
	ANDI T2,177		;CHECK FOR
	CAMN T2,ESCHAR		; ESCAPE?
	 JRST TALKDN		;YES-- GO CLEAN UP
	MOVE T1,TLKJFN		;GET WHERE TO SEND CHARACTER
	BOUT			;NO-- SEND THAT CHARACTER
	JRST TALKLP		;WAIT FOR ANOTHER CHARACTER
;
; RESTORE CONSOLE TERMINAL MODE
;
TALKDN:
	SETZM TLKFLG		;INDICATE NO LONGER TALKING TO LISTENER
;
	MOVX T1,.FHJOB		;SET BACK
	SKIPE T2,P2		; OUR TIW
	 STIW			; . .
;
	HLRZ T1,$CMBLK+.CMIOJ	;AND CONSOLE JFN MODE WORD
	MOVE T2,P1		; . .
	SFMOD			;SET SOME
	STPAR			; AND THE REST
;
	TYPE$ <
>
	RETURN			;RETURN FROM $TALK
	SUBTTL COMND ROUTINES
;
; DTENUM -- GET DTE20 NUMBER IN OCTAL
;	RETURNS +1:  P1 -- DTE20 NUMBER
;
DTENUM:
	MOVE T2,DEFDTE		;GET DEFAULT DTE NUMBER
	CALL OCTDEF		;GET OCTAL OR DEFAULT
	CAIL T2,0		;TOO SMALL?
	CAILE T2,3		;TOO BIG?
	 ERRA$ <INVALID DTE20 NUMBER>
	MOVE P1,T2		;SAVE THE NUMBER IN P1
	RETURN			;RETURN FROM DTENUM
;
; OCTDEF -- GET OCTAL NUMBER OR DEFAULT
;	T2 -- DEFAULT NUMBER (-1 IF NONE)
; RETURNS +1:
;	T2 -- NUMBER
;
OCTDEF:
	JUMPL T2,OCTDF1		;SKIP ALL THIS IF NO DEFAULT
	HRROI T1,$TXBUF		;ELSE GET
	MOVX T3,^D8		; NUMBER
	NOUT			;  IN $TXBUF
	 ERRJ$
	MOVEI T2,[
		EXP FLD(.CMNUM,CM%FNC)+CM%DPP
		EXP ^D8
		EXP 0
		POINT 7,$TXBUF]	;OCTAL, DEFAULT TO WHAT'S IN $TXBUF
	JRST OCTDF2		;AND GO ON
;
OCTDF1:
	MOVEI T2,[FLDDB.(.CMNUM,,^D8)] ;SKIP THIS STUFF
OCTDF2:
	COMND$			;GET THE NUMBER
	 ERRA$ <INVALID OCTAL NUMBER>
	RETURN			;RETURN FROM OCTDEF, NUMBER IN T2
	SUBTTL END
;
;
	END$ DNBOOT