Google
 

Trailing-Edge - PDP-10 Archives - cuspmar86binsrc_2of2_bb-fp63a-sb - 10,7/galaxy/batcon/batpty.mac
There are 3 other files named batpty.mac in the archive. Click here to see a list.
TITLE	BATPTY	- GALAXY-10 Batch controller PTY logic
SUBTTL	C.D.O'Toole, D.P.Mastrovito /CDO/DPM 12-SEP-85


;
;
;	      COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION
;     1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1986.
;			ALL RIGHTS RESERVED.
;
;
;     THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY  BE  USED
;     AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE
;     AND WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.   THIS
;     SOFTWARE  OR ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR
;     OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON.  NO  TITLE  TO
;     AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
;
;     THE INFORMATION  IN  THIS  SOFTWARE  IS  SUBJECT  TO  CHANGE
;     WITHOUT  NOTICE  AND SHOULD NOT BE CONSTRUED AS A COMMITMENT
;     BY DIGITAL EQUIPMENT CORPORATION.
;
;     DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
;     OF  ITS  SOFTWARE  ON  EQUIPMENT  WHICH  IS  NOT SUPPLIED BY
;     DIGITAL.


	SEARCH	BATMAC			;BATCON SYMBOLS
	SEARCH	GLXMAC			;GALAXY SYMBOLS
	SEARCH	QSRMAC			;QUASAR SYMBOLS
	SEARCH	ORNMAC			;ORION SYMBOLS

	PROLOG	(BATPTY)		;SET UP

	%%.BAT==:%%.BAT			;FORCE VERSION INTO SYMBOL TABLE

TOPS10	<IF1,<PRINTX [Assembling GALAXY-10 BATPTY]>>
TOPS20	<IF1,<PRINTX [Assembling GALAXY-20 BATPTY]>>

	GLOB	<NUMBER>
SUBTTL	Table of contents


;               TABLE OF CONTENTS FOR BATPTY
;
;
;                        SECTION                                   PAGE
;    1. Table of contents.........................................   2
;    2. P$OPEN - Open a PTY.......................................   3
;    3. P$CLOS - Close a PTY......................................   5
;    4. P$OBUF - Output a PTY buffer..............................   6
;    5. P$IBUF - Input a buffer...................................   7
;    6. P$OCHR - Output a character to a PTY......................   8
;    7. P$ICHR - Input a character from a PTY.....................   9
;    8. P$NXTC - Input next character always......................  10
;    9. P$CTLC - Output a Control-C to a PTY......................  11
;   10. P$READ - Read a line of output............................  12
;   11. P$STOP - Stop a job on a PTY..............................  13
;   12. P$TERM - Set up terminal characteristics..................  14
;   13. End.......................................................  15
SUBTTL	P$OPEN - Open a PTY


TOPS10	<				;TOPS-10 only
P$OPEN::SETOM	.JPCHN(R)		;INDICATE NO OPEN CHANNEL YET
	MOVE	T1,[FO.ASC+.FOWRT]	;ASSIGN A CHANNEL FOR READ AND WRITE
	MOVX	T2,UU.PHS!UU.FSP!UU.BJP ;PHYSICAL/FULL SCNSER CONTROL/BATCH PTY
	MOVSI	T3,'PTY'		;GET GENERIC PTY
	HRLI	T4,.JPOUT(R)		;GET BUFFER RING HEADER FOR OUTPUT
	HRRI	T4,.JPINP(R)		;GET BUFFER RING HEADER FOR INPUT
	MOVE	S1,[4,,T1]		;SET UP UUO
	FILOP.	S1,			;OPEN THE PTY
	  JRST	OPEN.1			;CAN'T
	LOAD	S1,T1,FO.CHN		;GET CHANNEL NUMBER
	MOVEM	S1,.JPCHN(R)		;SAVE IT
	IONDX.	S1,			;GET THE UDX
	  JRST	OPEN.1			;CAN'T
	ANDX	S1,UX.UNT		;KEEP JUST THE UNIT NUMBER
	TXO	S1,.UXTRM		;INCLUDE TTY OFFSET
	ADD	S1,G$PTYF##		;ADD THIS PTY'S NUMBER TO THE FIRST PTY
	MOVEM	S1,.JPTTY(R)		;STORE TTY UDX FOR THIS PTY
	MOVSI	T1,400000		;BUFFER USE BIT
	HRRI	T1,.JPTYO+.BFHDR(R)	;GET ADDRESS OF NEXT OUTPUT BUFFER
	MOVEM	T1,.JPOUT+.BFADR(R)	;STORE IN OUTPUT BUFFER CONTROL BLOCK
	HRRI	T1,.JPTYI+.BFHDR(R)	;GET ADDRESS OF NEXT INPUT BUFFER
	MOVEM	T1,.JPINP+.BFADR(R)	;STORE IN INPUT BUFFER CONTROL BLOCK
	MOVSI	T1,(POINT 7)		;7 BIT BYTES
	MOVEM	T1,.JPINP+.BFPTR(R)	;STORE IN INPUT BUFFER CONTROL BLOCK
	HRRI	T1,.JPTYO+.BFCNT+1(R)	;GET ADDRESS OF FIRST OUTPUT DATA WORD
	MOVEM	T1,.JPOUT+.BFPTR(R)	;STORE IN OUTPUT BUFFER CONTROL BLOCK
	MOVSI	T1,PTYBLK-2		;NUMBER OF DATA WORDS IN A BUFFER
	HRRI	T1,.JPTYO+.BFHDR(R)	;GET ADDRESS OF NEXT OUTPUT BUFFER
	MOVEM	T1,.JPTYO+.BFHDR(R)	;RING LOOPS ON ITSELF
	HRRI	T1,.JPTYI+.BFHDR(R)	;GET ADDRESS OF NEXT INPUT BUFFER
	MOVEM	T1,.JPTYI+.BFHDR(R)	;RING LOOPS ON ITSELF
	$RETT				;RETURN SUCESSFUL

OPEN.1:	PUSHJ	P,P$CLOS		;CLOSE AND RELEASE CHANNEL
	$RETF				;RETURN UNSUCESSFUL
>					;END OF TOPS-10 CONDITIONAL
TOPS20	<				;TOPS-20 ONLY
P$OPEN::$SAVE	<P1,P2>			;SAVE P1 AND P2
	MOVE	P1,[ASCIZ |PTY|]	;GET GENERIC DEVICE NAME
	MOVN	T2,G$PTYN##		;GET MINUS # OF PTYS IN THE SYSTEM
	HRLZS	T2			;MAKE AN AOBJN POINTER
OPEN.1:	MOVSI	S1,.DVDES+.DVPTY	;GET PTY DESIGNATOR
	HRRI	S1,(T2)			;LOAD A PTY NUMBER TO TRY FOR
	DVCHR				;GET DEVICE CHARACTERISTICS
	TXNN	S2,DV%AV		;PTY AVAILABLE?
	  JRST	OPEN.3			;NO - TRY ANOTHER
	MOVE	S2,S1			;COPY DVCHR WORD
	HRROI	S1,P1			;POINT TO SCRATCH LOCATION
	DEVST				;MAKE AN ASCIZ STRING
	  JRST	OPEN.3			;CAN'T
	MOVEI	S2,":"			;COLON
	IDPB	S2,S1			;END DEVICE SPEC
	MOVX	S2,.CHNUL		;A <NUL>
	IDPB	S2,S1			;END ASCIZ STRING WITH IT
	MOVX	S1,GJ%SHT		;SHORT FORM OF JFN
	HRROI	S2,P1			;POINT TO DESIRED DEVICE
	GTJFN				;GET A JFN
	  JRST	OPEN.3			;CAN'T
	MOVEM	S1,.JPCHN(R)		;STORE JFN
	MOVX	S2,7B5+OF%RD+OF%WR	;7 BIT BYTES/READ/WRITE
	OPENF				;OPEN THE PTY
	  JRST	OPEN.2			;CAN'T
	ADD	T2,G$PTYF##		;MAKE TTY NUMBER
	TXO	T2,.TTDES		;ADD TERMINAL DESIGNATOR
	HRRZM	T2,.JPTTY(R)		;STORE IT
	MOVE	S1,.JPTTY(R)		;GET TTY DESIGNATOR
	TXO	S1,TL%CRO		;CLEAR LINKS
	MOVX	S2,<-1>			;FROM ALL TTYS
	TLINK				;DO IT
	  JFCL				;IGNORE ERRORS
	MOVE	S1,.JPTTY(R)		;GET TTY DESIGNATOR
	CFOBF				;CLEAR OUTPUT BUFFER
	MOVE	S1,.JPCHN(R)		;GET PTY JFN
	MOVX	S2,.MOAPI		;FUNCTION CODE
	HRLI	S2,PTYCHN		;GET THE INTERRUPT CHANNEL
	TXO	S2,MO%WFI!MO%OIR	;WAIT FOR INPUT AND OUTPUT READY
	MTOPR				;ATTACH PTY TO INTERRUPT SYSTEM
	MOVE	S1,.JPCHN(R)		;GET PTY JFN
	MOVX	S2,.MOBAT		;BATCH FUNCTION
	MOVX	T1,.MOJCB		;SET THE BATCH PTY BIT
	MTOPR				;MAKE PTY A BATCH PTY
	MOVEI	S1,PTYBLK*5		;NO - GET CHARACTER COUNT
	MOVEM	S1,.JPOUT+.BFCTR(R)	;RESTORE BUFFER COUNT
	MOVE	S1,[POINT 7,.JPTYO(R)]	;BYTE POINTER TO BUFFER
	MOVEM	S1,.JPOUT+.BFPTR(R)	;STORE IT
	$RETT				;RETURN SUCESSFUL

OPEN.2:	PUSHJ	P,P$CLOS		;CLOSE AND RELEASE THE PTY JFN

OPEN.3:	AOBJN	T2,OPEN.1		;TRY NEXT PTY
	$RETF				;RETURN UNSUCESSFUL
>					;END OF TOPS-20 CONDITIONAL
SUBTTL	P$CLOS - Close a PTY


TOPS10	<				;TOPS-10 ONLY
P$CLOS::MOVE	S1,[1,,.FOREL]		;LENGTH AND FUNCTION CODE
	PUSHJ	P,FILOP			;CLOSE AND RELEASE THE PTY
	  JFCL				;IGNORE ERRORS
	SETOM	.JPCHN(R)		;CHANNEL NO LONGER IN USE
	POPJ	P,			;RETURN
>					;END OF TOPS-10 CONDITIONAL

TOPS20	<				;TOPS-20 ONLY
P$CLOS::MOVE	S1,.JPCHN(R)		;GET JFN
	CLOSF				;CLOSE THE PTY
	  SKIPA				;CAN'T
	POPJ	P,			;RETURN
	MOVE	S1,.JPCHN(R)		;GET JFN
	RLJFN				;RELEASE THE JFN
	  JFCL				;IGNORE ERRORS
	POPJ	P,			;RETURN
>					;END OF TOPS-20 CONDITIONAL
SUBTTL	P$OBUF - Output a PTY buffer


; Output a PTY buffer
; Call:	PUSHJ	P,P$OBUF
;
TOPS10 <
P$OBUF::PUSH	P,S1			;SAVE S1
	MOVE	S1,[1,,.FOOUT]		;LENGTH AND FUNCTION CODE
	PUSHJ	P,FILOP			;DO OUTPUT
	  JFCL				;CAN'T FAIL
	POP	P,S1			;RESTORE S1
	POPJ	P,			;RETURN
>					;END OF TOPS-10 CONDITIONAL

TOPS20 <				;TOPS-20 ONLY
P$OBUF::PUSH	P,S1			;SAVE S1
	PUSH	P,S2			;SAVE S2
	MOVE	S1,.JPCHN(R)		;GET JFN
	HRROI	S2,.JPTYO(R)		;POINT TO BUFFER
	SKIPGE	T1,.JPOUT+.BFCTR(R)	;LESS THAN ZERO?
	SETZ	T1,			;YES - MAKE IT ZERO
	SUBI	T1,PTYBLK*5		;GET NEGATIVE CHARACTER COUNT

OBUF.1:	SOUT				;OUTPUT A BUFFER
	  ERJMP	OBUF.2			;OUTPUT FAILED?
	HRRZI	S1,.JPTYO(R)		;GET ADDRESS OF BUFFER
	HRLZI	S2,.JPTYO(R)		;GET SOURCE ADDRESS
	HRRI	S2,.JPTYO+1(R)		;MAKE A BLT POINTER
	SETZM	.JPTYO(R)		;CLEAR THE FIRST WORD
	BLT	S2,PTYBLK-1(S1)		;CLEAR THE BUFFER
	MOVEI	S1,PTYBLK*5		;NO - GET CHARACTER COUNT
	MOVEM	S1,.JPOUT+.BFCTR(R)	;RESTORE BUFFER COUNT
	MOVE	S1,[POINT 7,.JPTYO(R)]	;BYTE POINTER TO BUFFER
	MOVEM	S1,.JPOUT+.BFPTR(R)	;STORE IT
	POP	P,S2			;RESTORE S2
	POP	P,S1			;RESTORE S1
	POPJ	P,			;RETURN

OBUF.2:	MOVX	S1,.FHSLF		;GET OUR PROCESS HANDLE
	GETER				;GET LAST ERROR CODE
	HRRZS	S2			;KEEP ONLY THE ERROR CODE
	CAXE	S2,IOX33		;OUPUT FAILED BECAUSE PTY BUFFER FULL?
	  JRST	OBUF.3			;NO - SOMETHING WORSE
	PUSHJ	P,QTS			;YES - TRY AGAIN LATER
	MOVE	S1,.JPCHN(R)		;GET PTY JFN
	JRST	OBUF.1			;GO TRY THE OUTPUT AGAIN

OBUF.3:	$IDENT	(BATBJC,<? ^I/OUTTXT/>)
	$WTO	(<BATCON error>,<^R/.JQJBB(R)/^I/OUTTXT/>,.JQOBJ(R),<$WTNOD(.JQLOC(R))>)
	JRST	B$ABORT##		;CANCEL THE JOB

OUTTXT:	ITEXT	(<Job canceled because output to PTY failed; ^E/[-2]/>)
>					;END OF TOPS-20 CONDITIONAL
SUBTTL	P$IBUF - Input a buffer


TOPS10	<				;TOPS-10 ONLY
P$IBUF::MOVE	S1,[1,,.FOINP]		;LENGTH AND FUNCTION CODE
	PUSHJ	P,FILOP			;DO INPUT
	  JFCL				;CAN'T FAIL
	POPJ	P,			;RETURN
>					;END OF TOPS-10 CONDITIONAL

TOPS20	<

P$IBUF::MOVE	S1,.JPTTY(R)		;GET TTY DESIGNATOR FOR THIS PTY
	SOBE				;CHECK FOR CHARACTERS AVAILABLE
	JRST	IBUF.1			;GO GET SOME
	$RETF				;NONE - RETURN

IBUF.1:	MOVE	T1,S2			;GET CHARACTER COUNT
	CAXLE	T1,PTYBLK*5		;MAKE SURE WE DON'T OVER RUN THE BUFFER
	MOVX	T1,PTYBLK*5		;LOAD THE MAXIMUM
	MOVE	S1,.JPCHN(R)		;GET PTY JFN
	HRROI	S2,.JPTYI(R)		;POINT TO THE INPUT BUFFER
	MOVEM	T1,.JPINP+.BFCTR(R)	;STORE BYTE COUNT FOR LATER
	MOVNS	T1			;AND NEGATE IT FOR THE JSYS
	SIN				;READ A BUFFER
	  ERJMP	.+2			;IGNORE ERRORS
	JRST	IBUF.2			;NO ERRORS
	SETZM	.JPINP+.BFCTR(R)	;CLEAR CHARACTER COUNT ON ERRORS

IBUF.2:	MOVEI	S1,.JPTYI(R)		;POINT TO THE BUFFER
	MOVEM	S1,.JPINP+.BFADR(R)	;STORE POINTER
	HRLI	S1,(POINT 7)		;MAKE A BYTE POINTER
	MOVEM	S1,.JPINP+.BFPTR(R)	;STORE IT
	$RETT				;RETURN
>					;END OF TOPS-20 CONDITIONAL

SUBTTL	P$OCHR - Output a character to a PTY


; output a character to a PTY
; Call:	MOVE	S1,character
;	PUSHJ	P,P$OCHR
;
; Always returns TRUE with character in S1
;
P$OCHR::SOSGE	.JPOUT+.BFCTR(R)	;IS BUFFER FULL?
	  JRST	OCHR.1			;YES - EMPTY IT
	IDPB	S1,.JPOUT+.BFPTR(R)	;STORE CHARACTER
	$RETT				;RETURN

OCHR.1:	PUSHJ	P,P$OBUF		;SEND BUFFER TO THE JOB
	SETOM	.JPEOL(R)		;INDICATE EOL SO ERRORS CAN BE FOUND
	PUSH	P,S1			;SAVE SOME ACS
	PUSH	P,S2			;...
	PUSHJ	P,IOWAIT##		;WAIT FOR I/O COMPLETION
	SKIPE	.JLTIM(R)		;TIME STAMP NEEDED?
	TXNE	F,FL.SIL		;JOB SILENCED?
	SKIPA				;THEN NO TIME STAMP
	PUSHJ	P,L$LSTP##		;RECORD TIME OF DAY
	SETZM	.JPEOL(R)		;CLEAR EOL FLAG
	POP	P,S2			;RESTORE ACS
	POP	P,S1			;...
	JRST	P$OCHR			;LOOP BACK AND STORE CHARACTER
SUBTTL	P$ICHR - Input a character from a PTY


; Input a character
; Call:	PUSHJ	P,P$ICHR
;
; Returns FALSE if PTY buffer empty
; Returns TRUE with S1 containing a character
;
P$ICHR::SOSGE	.JPINP+.BFCTR(R)	;COUNT CHARACTERS
	  $RETF				;RETURN UNSUCESSFUL
	ILDB	S1,.JPINP+.BFPTR(R)	;GET A CHARACTER
	JUMPE	S1,P$ICHR		;IGNORE <NUL>
	$RETT				;RETURN SUCESSFUL
SUBTTL	P$NXTC - Input next character always


; This routine unlike P$ICHR, will input the next character from a PTY
; even if it requires another buffer to be read in.
;
P$NXTC::PUSHJ	P,P$ICHR		;READ A CHARACTER
	SKIPF				;DID WE GET ONE?
	$RETT				;RETURN SUCESSFUL
	MOVX	S1,.CHNUL		;LOAD A <NUL> INCASE NO OUTPUT
	PUSHJ	P,P$STAT		;UPDATE JOB STATUS
	TXNE	J,JL.UDI		;JOB WANT INPUT?
	$RETT				;YES - THEN GIVE UP
	PUSHJ	P,QTS##			;NO - WAIT FOR NEXT WAKEUP
	PUSHJ	P,P$IBUF		;READ A BUFFER
	JRST	P$NXTC			;LOOP BACK AND TRY AGAIN
SUBTTL	P$CTLC - Output a Control-C to a PTY


; Send a Control-C to a PTY (all ACs saved)
;
P$CTLC::PUSH	P,S1			;SAVE S1
	MOVX	S1,.CHCNC		;LOAD A CONTROL-C
	PUSHJ	P,P$OCHR		;STORE IN OUTPUT BUFFER
	POP	P,S1			;RESTORE SAVED AC
	TXZ	F,FL.ECH		;NEVER IGNORE ^C ECHO
	PJRST	P$OBUF			;FORCE BUFFER OUT AND RETURN
SUBTTL	P$READ - Read a line of output


P$READ::PUSHJ	P,B$RINI##		;INITIALIZE THE RESPONSE BUFFER
	PUSHJ	P,P$IBUF		;INPUT A BUFFER
	TXNN	R,RL.QTS!RL.DIA		;SKIP WTO STUFF IF IN THE MIDDLE OF TEXT
	PUSHJ	P,B$WINI##		;INITIALIZE WTO/WTOR OPERATIONS

READ.1:	PUSHJ	P,P$ICHR		;GET A CHARACTER
	JUMPT	READ.2			;DID WE GET ONE?
	PJRST	B$REOL##		;NO - END RESPONSE BUFFER AND RETURN

READ.2:	AOSE	.JPEOL(R)		;WAS A LINE TERMINATOR SENT?
	SKIPE	.JLTIM(R)		;IS THIS THE FIRST CHARACTER ON LINE?
	PUSHJ	P,B$ECHK##		;YES - CHECK ERROR/OPERATOR CHARACTER
	TXNE	R,RL.JIE		;IS JOB IN ERROR?
	TXZ	F,FL.SIL		;YES - CLEAR SILENCE MODE
	TXNE	R,RL.QTS!RL.DIA		;WAS QUOTES SEEN OR IN DIALOGUE MODE?
	PUSHJ	P,B$WPUT##		;YES - PUT IN BUFFER FOR WTO/WTOR
	TXNE	F,FL.SIL		;IS JOB SILENCED?
	JRST	READ.3			;YES - DON'T RECORD OUTPUT
	PUSHJ	P,L$PLOG##		;PUT CHARACTER IN LOG FILE
	PUSHJ	P,B$RPUT##		;PUT CHARACTER IN RESPONSE BUFFER

READ.3:	SETOM	.JLTIM(R)		;ASSUME TIME STAMP NEEDED
	CAXG	S1,.CHFFD		;CHECK FOR EOL CHARACTER
	CAXGE	S1,.CHLFD		; MUST BE <LF> <VT> OR <FF>
	  SETZM	.JLTIM(R)		;DON'T ISSUE A TIME STAMP

READ.4:	SKIPN	.JLTIM(R)		;END OF LINE YET?
	JRST	READ.1			;NO - TRY FOR MORE OUTPUT
	PUSHJ	P,B$REOL##		;END RESPONSE BUFFER
	TXZN	R,RL.QTS		;QUOTES SEEN?
	JRST	READ.1			;NO - ONWARD
	PUSHJ	P,B$WEOL##		;END WTO BUFFER
	PUSHJ	P,B$WTO##		;DO A WTO
	PUSHJ	P,B$WINI##		;RESET WTO BUFFER
	JRST	READ.1			;BACK FOR MORE INPUT
SUBTTL	P$STOP - Stop a job on a PTY


; Stop a job on a PTY (put it into monitor mode)
; Note: It is necessary to put in a clock request on the -20 since
;	the monitor lacks the facilities to maintain a stable batch
;	system.  With every release of the monitor, the process of
;	halting a job gets slower and slower...
;
P$STOP::PUSHJ	P,P$STAT		;GET JOB'S STATUS
	TXNE	J,JL.UML		;IN MONITOR MODE ALREADY?
	POPJ	P,			;YES - RETURN

TOPS10	<				;TOPS-10 ONLY
	MOVE	TF,[2,,S1]		;SET UP TRMOP. UUO
	MOVEI	S1,.TOCLR		;GET FUNCTION TO CLEAR MIC STATUS
	MOVE	S2,.JPTTY(R)		;GET UDX
	TRMOP.	TF,			;ZAP MIC
	  JFCL				;IGNORE ERRORS
>					;END OF TOPS-10 CONDITIONAL

	TXNN	J,JL.UDI		;JOB IN INPUT WAIT?
	PUSHJ	P,P$CTLC		;NO - SEND AN EXTRA CONTROL-C
	PUSHJ	P,P$CTLC		;SEND A CONTROL-C

TOPS20	<				;TOPS-20 ONLY
	MOVE	T1,[.CQHLT,,HLTIME]	;WAIT 'TIL HALTED OR TIMEOUT
	MOVEI	T2,0			;NO DISPATCH
	PUSHJ	P,B$CLKS##		;CREATE A CLOCK REQUEST
>					;END OF TOPS-20 CONDITIONAL

	PUSHJ	P,IOWAIT##		;WAIT FOR I/O COMPLETION
	TXNN	R,RL.FKJ		;FAST KJOB?
	TXNE	J,JL.UML		;JOB IN MONITOR MODE?
	POPJ	P,			;YES TO EITHER - RETURN
	MOVEI	S1,STPTYP		;GET ADDRESS OF TYPE ITEXT BLOCK
	MOVEI	S2,STPTXT		;GET ADDRESS OF MAIN ITEXT BLOCK
	MOVEI	T1,STPTAB		;GET ADDRESS OF RESPONSE TABLE
	PUSHJ	P,B$OPER##		;ASK THE OPERATOR FOR HELP
	TXNN	J,JL.ULI		;JOB STILL THERE?
	JRST	CLOSJB##		;NO - CANCEL JOB
	JRST	P$STOP			;YES - TRY AGAIN


STPTYP:	ITEXT (<Batch error>)

STPTXT:	ITEXT	(<Cannot put job ^D/.JBJNO(R)/ in monitor mode.
Type 'RESPOND ^I/NUMBER/ PROCEED' to try again or kill the job>)

STPTAB:	$STAB
	KEYTAB	(0,<PROCEED>)
	$ETAB
SUBTTL	P$TERM - Set up terminal characteristics


TOPS10	<				;TOPS-10 ONLY
P$TERM::MOVX	S1,<XWD	-TERMSZ,TERMTB>	;AOBJN POINTER TO TABLE
	MOVE	T2,.JPTTY(R)		;GET TTY UDX FOR THIS PTY

TERM.1:	HLRZ	T1,(S1)			;GET A FUNCTION CODE
	HRRZ	T3,(S1)			;GET ADDRESS OF VALUE
	MOVE	T3,(T3)			;GET VALUE TO SET
	MOVX	S2,<XWD	3,T1>		;SET UP CALLI
	TRMOP.	S2,			;SET A TERMINAL VALUE
	  JFCL				;THATS OK
	AOBJN	S1,TERM.1		;LOOP
	POPJ	P,			;RETURN


; Table of TRMOP. functions and values
;
TERMTB:	XWD	.TOLCT+.TOSET,[0]	;TERMINAL HAS LOWER CASE
	XWD	.TOFRM+.TOSET,[1]	;TERMINAL PERFORMS FORM FEEDS
	XWD	.TOPAG+.TOSET,[0]	;TURN OFF XOFF/XON PROCESSING
	XWD	.TOBLK+.TOSET,[0]	;ALLOW BLANK LINES
	XWD	.TODEM+.TOSET,[0]	;TURN OFF TTY DEFER
TERMSZ==.-TERMTB			;LENGTH OF TABLE

>					;END OF TOPS-10 CONDITIONAL


TOPS20	<				;TOPS-20 ONLY
P$TERM::MOVE	S1,.JPTTY(R)		;GET TTY DESIGNATOR
	RFMOD%				;READ TTY PARAMETERS
	  ERJMP	.POPJ			;RETURN ON ERROR
	TXO	S2,TT%MFF!TT%LCA!TT%UOC!TT%LIC ; SET SOME STUFF
	TXZ	S2,TT%PGM		;CLEAR TTY PAGE
	STPAR%				;TELL THE MONITOR
	  ERJMP	.+1			;CAN'T
	POPJ	P,			;RETURN
>					;END OF TOPS-20 CONDITIONAL
SUBTTL	P$STAT - Get job status


; Return job status in AC 'J'
;
P$STAT::PUSHJ	P,JOBSTS		;GET JOB STATUS BITS
	TXNN	J,JL.UJA		;Job number assigned?
	POPJ	P,			;NO - JUST RETURN
	SKIPL	.JBJNO(R)		;IS A JOB NUMBER ALREADY STORRED?
	POPJ	P,			;YES - JUST RETURN
	MOVEM	J,.JBJNO(R)		;STORE STATUS WORD
	ANDX	J,JL.UJN		;KEEP JUST THE JOB NUMBER
	EXCH	J,.JBJNO(R)		;SWAP DATA
	POPJ	P,			;RETURN


TOPS10 <				;TOPS-10 ONLY
JOBSTS:	MOVE	J,.JPCHN(R)		;GET THE PTY CHANNEL NUMBER
	JOBSTS	J,			;GET THE STATUS
	  SETZ	J,			;ASSUME JOB HAS GONE AWAY
	POPJ	P,			;RETURN
>					;END OF TOPS-10 CONDITIONAL

TOPS20 <				;TOPS-20 ONLY
JOBSTS:	$SAVE	<S1,S2,T1>		;SAVE ACS FROM DESTRUCTION
	SETZ	J,			;CLEAR JOB STATUS
	SETZM	JSTBLK			;CLEAR FIRST WORD OF JOB STATUS BLOCK
	MOVE	S1,[JSTBLK,,JSTBLK+1]	;SET UP BLT
	BLT	S1,JSTBLK+.JIMAX-1	;CLEAR THE ENTIRE BLOCK
	MOVE	S1,.JPTTY(R)		;GET THE TERMINAL DESIGNATOR
	MOVE	S2,[-.JIMAX,,JSTBLK]	;SET UP POINTER
	MOVEI	T1,.JIJNO		;START WITH THE JOB NUMBER
	GETJI				;GET JOB INFORMATION
	  JFCL				;ASSUME JOB HAS GONE AWAY
	SKIPE	JSTBLK+.JIUNO		;USER LOGGED IN?
	TXO	J,JL.ULI		;YES
	SKIPE	JSTBLK+.JIT20		;AT MONITOR LEVEL?
	TXO	J,JL.UML		;YES
	MOVE	S1,.JPTTY(R)		;GET THE TERMINAL DESIGNATOR
	SOBE				;OUTPUT AVAILABLE?
	TXO	J,JL.UOA		;YES
	MOVE	S1,.JPTTY(R)		;GET THE TERMINAL DESIGNATOR
	RFMOD				;READ CHARACTERISTICS
	TXNN	S2,TT%ECO		;ECHO TURNED ON?
	TXO	J,JL.UNE		;NO
	MOVE	S1,.JPCHN(R)		;GET PTY JFN
	MOVEI	S2,.MOPIH		;FUNCTION TO CHECK IF PTY WANTS INPUT
	MTOPR				;MAKE THE CHECK
	  ERJMP	.POPJ			;GIVE UP WHEN THE -20 GIVES UP
	SKIPE	S2			;S2 IS NON-ZERO IF IN INPUT WAIT
	TXO	J,JL.UDI		;MARK PTY READY FOR INPUT
	SKIPL	S1,JSTBLK+.JIJNO 	;HAVE A JOB NUMBER?
	TXO	J,JL.UJA		;YES
	STORE	S1,J,JL.UJN		;STORE JOB NUMBER
	POPJ	P,			;RETURN
>					;END OF TOPS-20 CONDITIONAL
SUBTTL	Miscellaneous


; Routine to do a FILOP. UUO
; Call:	MOVE	S1,[length,,function]
;	PUSHJ	P,FILOP

TOPS10	<
FILOP:	PUSH	P,S2			;SAVE S2
	HRLZ	S2,.JPCHN(R)		;GET CHANNEL NUMBER
	HRR	S2,S1			;AND FUNCTION CODE
	HRRI	S1,S2			;POINT TO FILOP BLOCK
	FILOP.	S1,			;DO SOMETHING
	  SKIPA				;PROPAGATE ERROR BACK
	AOS	-1(P)			;SKIP
	POP	P,S2			;RESTORE S2
	POPJ	P,			;RETURN
> ;END TOPS10 CONDITIONAL
SUBTTL	End


	END