Google
 

Trailing-Edge - PDP-10 Archives - BB-M081Z-SM - monitor-sources/plt.mac
There are 42 other files named plt.mac in the archive. Click here to see a list.
; UPD ID= 8596, RIP:<7.MONITOR>PLT.MAC.2,  11-Feb-88 16:57:32 by GSCOTT
;TCO 7.1218 - Update copyright date.
; UPD ID= 2168, SNARK:<6.1.MONITOR>PLT.MAC.5,   5-Jun-85 10:49:46 by MCCOLLUM
;TCO 6.1.1406  - Update copyright notice.
; UPD ID= 4488, SNARK:<6.MONITOR>PLT.MAC.4,  12-Jul-84 16:39:57 by PURRETTA
; UPD ID= 1318, SNARK:<6.MONITOR>PLT.MAC.3,   9-Oct-82 20:37:21 by PAETZOLD
;TCO 6.1219 - Extend PLTDTB for RLJFD
;<6.MONITOR>PLT.MAC.2, 16-Oct-81 18:11:10, EDIT BY MURPHY
;TCO 6.1030 - Node names in filespecs; etc.
;Revise DTB format; get rid of double skips on NLUKD, etc.
;<4.MONITOR>PLT.MAC.2,  6-Mar-79 09:39:09, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<HELLIWELL.1065>PLT.MAC.4,  5-Sep-77 01:29:00, EDIT BY HELLIWELL
;<HELLIWELL.1065>PLT.MAC.3, 21-Aug-77 12:44:11, EDIT BY HELLIWELL
;<HELLIWELL.1065>PLT.MAC.2, 21-Aug-77 12:32:46, EDIT BY HELLIWELL
;REL 3 CHANGES

;	COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1976, 1988.
;	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 THAT IS NOT SUPPLIED BY DIGITAL.
	SEARCH PROLOG
	TTITLE (PLT,,< - PLOTTER SERVICE, R. HELLIWELL>)

;LOCAL STORAGE DECLARED IN STG.MAC

EXTN <PLTCHR,PLTTIM>
EXTN <PLTBF1,PLTBF2,PLTSTS,PLTLCK,PLTCNT,PLTITC,PLTFDC,PLTPTR>
EXTN <PLTPWR,PLTBFZ>

; SPECIAL Ac's

DEFAC (U,Q1)			;UNIT NUMBER
DEFAC (IOS,Q2)			;DEVICE STATUS BITS
DEFAC (STS,P1)			;SEE GTJFN FOR FUNCTIONS
DEFAC (JFN,P2)
DEFAC (DEV,P4)

;DEVICE CODES
PLT0==140
PLT1==144

MAXPLT==2			;MAX NUMBER PLOTTERS

; Parameters

PLTDON==10			; Done coni/o bit
PLTBSY==20			; Busy coni/o bit
PLTEOT==40			; POWER ON CONI BIT
PLTPU==40			; PEN UP COMMAND
PLTDD==4			; DRUM DOWN COMMAND (+X DIRECTION)

; Entries to this part

INTERN	PLTSV			; Interrupt service routine
INTERN	PLTCHK			; Entry to clock routine
INTERN	PLTRST			; Reset

; Externally defined things


; Flags in pltsts and ios

FLG(ALTP,L,IOS,400000)		; Buffer 2 for prog
FLG(ALTI,L,IOS,200000)		; Buffer 1 for int
FLG(OPN,L,IOS,040000)		; Plt is open
FLG(PCLZF,L,IOS,004000)		; PLT IS BEING CLOSED
FLG(STOP,L,IOS,002000)		; Plt is stopped due to no power off
;I/O INSTRUCTION MACRO AND TABLES

DEFINE IOT (INST,Y)<
	MOVEI D,Y
	XCT %'INST(U)>

DEFINE IOTBLD (INST,DEV)<
%'INST:	ZZ==0
	REPEAT MAX'DEV,<IOTINS (INST,DEV,\ZZ)
			ZZ==ZZ+1>>

DEFINE IOTINS (INST,DEV,N)<
	INST DEV'N,0(D)>

;BUILD THE IOT TABLES (INDEXED BY UNIT NUMBER)

IOTBLD (CONO,PLT)
IOTBLD (CONI,PLT)
IOTBLD (CONSO,PLT)
IOTBLD (CONSZ,PLT)
IOTBLD (DATAO,PLT)
; Plt dispatch table

	SWAPCD

PLTDTB::PLTDTL			;LENGTH
	DTBDSP PLTDIR		;SET DIRECTORY
	DTBBAD(DESX9)	; NAME LOOKUP
	DTBBAD(DESX9)	; Extension lookup
	DTBBAD(DESX9)	; Version lookup
	DTBBAD(DESX9)	; Protection insertion
	DTBBAD(DESX9)		; Account insertion
	DTBBAD(DESX9)		; Status insertion
	DTBDSP(PLTOPN)		; Plt open
	DTBBAD(DESX9)		; Input
	DTBDSP(PLTSQO)		; Output
	DTBDSP(PLTCLZ)		; Close
	DTBBAD(DESX9)		; Rename
	DTBBAD(DESX9)		; Delete
	DTBBAD(DUMPX6)		;DUMPI
	DTBBAD(DUMPX6)		;DUMPO
	DTBBAD(DESX9)		; Mount
	DTBBAD(DESX9)		; Dismount
	DTBBAD(DESX9)		; Init directory
	DTBBAD(MTOX1)		; MTOPR
	DTBDSP(PLTGST)		; Get status
	DTBBAD(DESX9)		; Set status
	DTBDSP(RSKP)		; RECORD OUT
	DTBDSP(RFTADN)		; READ TAD
	DTBDSP(SFTADN)		; SET TAD
	DTBDSP (BIOINP)		;SET JFN FOR INPUT
	DTBDSP (BIOOUT)		;SET JFN FOR OUTPUT
	DTBBAD (GJFX49)		;CHECK ATTRIBUTE
	DTBSKP			;RELEASE JFN
	PLTDTL==:.-PLTDTB	;GLOBAL LENGTH OF DISPATCH TABLE

PLTDIR:	TQO NNAMF		;NO NAME DEVICE
	MOVEI A,DESX9
	RET
; Initialize plotter
; Call:	CALL PLTINI
; Returns
;	+1	; Always (called at system initialization time

	RESCD

PLTINI::MOVSI U,-PLTN		;INITIALIZE ALL PLOTTERS
PLTINL:	SETZM PLTPWR(U)		;INITIALIZE POWER INDICATE FLAG
	IOT CONSZ,PLTEOT	;POWER ON?
	SETOM PLTPWR(U)		;YES - FLAG FEATURE EXISTS
	CALL PLTIN0		;INITIALIZE THE STORAGE FOR THIS UNIT
	AOBJN U,PLTINL		;LOOP BACK FOR ALL UNITS
	RET

;ROUTINE TO INITIALIZE THE STORAGE AREA FOR A PARTICULAR UNIT

PLTIN0:	IOT CONO,0		;CLEAR INTERRUPT ASSIGNMENT
	SETZM PLTSTS(U)		;HERE FROM CLOSE TO CLEAN UP
	SETOM PLTLCK(U)
	SETOM PLTCNT(U)
	SETZM PLTFDC(U)
	RET

; Plotter reset routine turns plotter back on if it should be

PLTRST:	MOVSI U,-PLTN		;SET UP TO RESET ALL UNITS
PLTRS0:	SKIPGE PLTCNT(U)	;WAS PLT ACTIVE?
	JRST PLTRS1		;NO, PLT WAS NOT ACTIVE
	IOT CONO,PLTDON+PLTCHN	;YES, TURN IT BACK ON
PLTRS1:	AOBJN U,PLTRS0		;LOOP BACK FOR ALL UNITS
	RET

; ROUTINE TO RETURN PLOTTER STATUS

PLTGST:	IOT CONI,A		;GET PHYSICAL DEVICE STATUS
	RET			;AND RETURN
; Open plt
; Call:	JFN	; Jfn
;	CALL PLTOPN
; Returns
;	+1	; Error, error number in 1
;	+2	; Ok

	SWAPCD

PLTOPN:	HLRZ U,DEV		;SET UP THE UNIT NUMBER
	LOCK PLTLCK(U),<CALL LCKTST>
	MOVE IOS,PLTSTS(U)
	TQNE <WRTF>		;MUST WANT WRITE,
	TQNE <READF>		; BUT NOT READ
	JRST [	UNLOCK PLTLCK(U) ;OTHERWISE LOSE
		MOVEI A,OPNX13	;PLT DOESN'T OPEN THAT WAY
		RETBAD()]
	IOT CONSZ,PLTEOT	; IS PLT POWERED UP
	 SETOM PLTPWR(U)	;YES - POWER INDICATE FEATURE PRESENT
	TQOE <OPN>		; Test and set opn flag
	 JRST [	UNLOCK PLTLCK(U) ; Already opn
		MOVEI A,OPNX9	; Give busy error return
		RET]
	TXZ IOS,ALTP!ALTI!STOP
PLTOP1:	MOVEI B,6		; Get 6 bit bytes
	DPB B,[POINT 6,PLTPTR(U),11]
				; Store in byte pointer
	MOVEM IOS,PLTSTS(U)	; Store status word
	SETOM PLTCNT(U)		; No full buffers
	SETZM PLTITC(U)		; No items left in current buffer
	UNLOCK PLTLCK(U)
	HRROI A,PLTPU		; Pen up command
	MOVEM A,PLTFDC(U)
	IOT CONO,PLTDON+PLTCHN	; Set done flag to cause interrupt
	SETZM FILBYN(JFN)
	SETZM FILLEN(JFN)
	TQO <WNDF>
	RETSKP
; Close plt
; Call:	JFN	; Jfn
;	CALL PLTCLZ
; Returns
;	+1	; Always

PLTCLZ:	HLRZ U,DEV		;GET THE UNIT NUMBER OF THIS PLT
	TXNE A,CZ%ABT		;IS THIS AN ABORT?
	 JRST PLTCLA		;YES, DONT BLOCK EVER
	TQNN <WNDF>		; IS A BUFFER SET UP?
	SKIPN FILBYN(JFN)	; AND ARE THERE ANY CHARACTERS THERE
	  JRST PLTCL1		; NO, DONT EMPTY ANY BUFFERS
	CALL DMPBUF		; Dump partial buffer
PLTCL1:	HRLI A,PLTCNT(U)	; SET UP FOR DISMIS
	HRRI A,DISLT
	SKIPL PLTCNT(U)
	CALLRET PLTSBF		; Dismiss til last buffer being dumped
	HRLI A,PLTITC(U)	; SET UP FOR POSSIBLE DISMIS
	HRRI A,DISLET
	SKIPLE PLTITC(U)
	CALLRET PLTSBF		; Dismiss till last buffer out
	HRROI B,PLTPU
	CALL DOSTEP
	HRLI A,PLTFDC(U)	; GET MDISMS ARG
	HRRI A,DISET
	SKIPE PLTFDC(U)		;IS PLOTTER STILL GOING?
	  CALLRET PLTSBF	;YES, WAIT UNTIL PLOTTER IS DONE
PLTCL2:	CALL PLTIN0		;CLEAN UP
	RETSKP

	RESCD

DOSTEP:	PIOFF
	TQON <PCLZF>		; IF PLT DOING PENUP, DONT DO IT AGAIN
	MOVEM B,PLTFDC(U)
	IOT CONSZ,PLTBSY
	JRST DOSTP1
	IOT CONO,PLTDON+PLTCHN
DOSTP1:	PION
	RET

PLTCLA:	IOT CONO,PLTDON		;TRY TO RAISE THE PEN
	IOT DATAO,[PLTPU]
	JRST PLTCL2

	SWAPCD
; Plt sequential output
; Call:	A	; Byte
;	JFN	; Jfn
;	CALL PLTSQO
; Returns
;	+1	; Always

PLTSQO:	HLRZ U,DEV		;SET UP UNIT INDEX
	MOVE IOS,PLTSTS(U)	; Get status word
	PUSH P,A		; Preserve byte
	TQNE <WNDF>		; Buffers set up yet?
	  JRST [CALL SETBUF	; No, do it
		JRST [POP P,(P)	;TIME TO BLOCK
		      CALLRET PLTSBF]
		JRST .+1]	;BUFFER IS NOW SET UP
	SOSGE FILCNT(JFN)	; Buffer full?
	  JRST [CALL DMPBUF	; Yes, dump it
		POP P,A		; RESTORE BYTE
		JRST PLTSQO]	; TRY AGAIN
	AOS FILBYN(JFN)		; Count bytes in buffer
	POP P,A
	IDPB A,FILBYT(JFN)	; Deposit in buffer
	RET

DMPBUF:	MOVX IOS,ALTP
	XORB IOS,PLTSTS(U)	; Complement buffer
	MOVEI B,PLTBFZ		; CALCULATE OFFSET INTO BUFFER AREA
	IMULI B,(U)		; FOR THIS UNIT
	MOVEI A,PLTBF1(B)
	TQNN <ALTP>
	MOVEI A,PLTBF2(B)
	PUSH P,A
	MOVEI A,^D36
	LDB B,PBYTSZ		; User's byte size
	IDIV A,B		; User bytes per word
	MOVEI B,6		; 6 bytes per word
	IMUL B,FILBYN(JFN)
	IDIV B,A		; Number of output bytes in buffer
	SKIPE C
	AOS B			; Round up
	POP P,A			; Get buffer location
	HRRZM B,(A)		; Store count in buffer word 0
	AOSE PLTCNT(U)		; Count one more full buffer
	JRST DMPBF1		; NOT FIRST, DONT START PLOTTER
	IOT CONO,PLTDON+PLTCHN	; If this is first one, start plotter
DMPBF1:	TQO <WNDF>		;MARK THAT BUFFER IS NOT SET UP
	RET

SETBUF:	HRLI A,PLTCNT(U)	; SET UP FOR POSSIBLE DISMIS
	HRRI A,DISLET
	SKIPLE PLTCNT(U)	; Are all buffers non-empty?
	  CALLRET PLTSBF	; Yes, wait for one to empty
	MOVEI B,PLTBFZ		; CALCULATE OFFSET INTO BUFFER AREA
	IMULI B,0(U)		; FOR THIS UNIT
	MOVEI A,PLTBF1+1(B)	; Use buffer 1
	TQNE <ALTP>		; Unles alternate flag
	MOVEI A,PLTBF2+1(B)	; Then use 2
	HRRM A,FILBYT(JFN)	; Point program byte pointer to buffer
	MOVEI A,^D36
	STOR A,FLBPO,(JFN)	; Position to left of first word
	MOVEI A,^D36
	LDB B,PBYTSZ		; User's byte size
	IDIV A,B		; Bytes per word
	IMULI A,PLTBFZ-1	; Bytes per buffer
	MOVEM A,FILCNT(JFN)	; Init filcnt
	SETZM FILBYN(JFN)	; No bytes written yet
	TQZ <WNDF>		; MARK THAT A BUFFER IS READY
	RETSKP

PLTSBF:	TQO <BLKF>		;MARK THAT A BLOCK IS TO BE DONE
	RET			;RETURN TO BOUT
; Plt interrupt routine

	RESCD

PLTSV:	PUSH P,U		;SAVE THE UNIT NUMBER AC
	MOVSI U,-PLTN		;SET UP TO SEARCH FOR THE INTERRUPT
PLTSVL:	IOT CONI,A		;GET PLT BITS
	TRNN A,PLTDON		;PLT INTERRUPT?
	JRST [	AOBJN U,PLTSVL	; NO, LOOP BACK FOR OTHER PLOTTERS
		POP P,U		; NONE FOUND, RESTORE U
		RET]		;NOT OUR INTERRUPT
	TRNN A,PLTEOT		;DID POWER GO OFF?
	 JRST [	SKIPN PLTPWR(U)	;REMOTE POWER FEATURE PRESENT?
		JRST PLTSV0	;NO, DONT GO TO SLEEP
		MOVX A,STOP	;YES - INDICATE TO CLOCK RTN
		IORM A,PLTSTS(U) ; ...
		IOT CONO,0	;AND WAIT FOR POWER TO COME BACK
		SETZM PLTTIM	;CLEAR TIME WORD TO WAKE UP CLOCK RTN
		JRST PLTXIT]	;AND EXIT
	SETOM PLTPWR(U)		;REMOTE POWER FEATURE EXISTS FOR SURE.
PLTSV0:	SKIPE PLTFDC(U)		;ZERO?
	JRST PLTSVS		;NO - CHECK SPECIAL ACTION
PLTSV1:	SKIPG PLTITC(U)		; Items left in buffer?
	JRST PLTSV2		; No.
	ILDB A,PLTPTR(U)	; Yes, get one
	IOT DATAO,A
	SOSG PLTITC(U)		;ONE FEWER ITEMS
	JRST [	SOS PLTCNT(U)	;NO MORE LEFT - MEANS ONE FEWER BUFFER
		JRST PLTXIT]
PLTXIT:	POP P,U			;RESTORE SAVED AC
	JRST PLTCHR		;RETURN AND DISMISS INTERRUPT

PLTSVS:	SKIPGE PLTFDC(U)	; Negative?
	 JRST [	IOT DATAO,PLTFDC(U); Yes, has a special plot command
		SETZM PLTFDC(U)
		JRST PLTXIT]
	IOT DATAO,[PLTDD]	; Yes, plot +x
	SOS PLTFDC(U)
	JRST PLTXIT

PLTSV2:	SKIPGE PLTCNT(U)
	JRST [	IOT CONO,0	; Turn off plotter
		JRST PLTXIT]
	MOVEI B,PLTBFZ		; CALCULATE OFFSET INTO BUFFER AREA
	IMULI B,0(U)		; FOR THIS UNIT
	MOVEI A,PLTBF1(B)
	EXCH IOS,PLTSTS(U)	;GET PLOTTER STATUS
	TQCE <ALTI>
	MOVEI A,PLTBF2(B)
	EXCH IOS,PLTSTS(U)	;RESTORE STATUS
	HRRZ B,(A)		; Get item count of buffer
	AOS A
	MOVEM B,PLTITC(U)
	HRRM A,PLTPTR(U)	; Point pointer to the first word
	MOVEI A,44
	DPB A,[POINT 6,PLTPTR(U),5]; Point to left of first byte
	JRST PLTSV1		; And continue with the new buffer
; This routine is called periodically when plotter power has gone off
; To restart when power is returned

PLTCHK:	MOVEI A,^D60000
	MOVEM A,PLTTIM		; 1 minute if not active
	MOVSI U,-PLTN		; SET UP TO LOOK AT ALL UNITS
PLTCK1:	MOVE A,PLTSTS(U)
	TXNE A,OPN
	TXNN A,STOP
	JRST PLTCK2		; Plotter not in use or not stopped
	MOVEI A,^D5000
	MOVEM A,PLTTIM
	IOT CONSO,PLTEOT
	JRST PLTCK2		; Power is still off
	MOVX A,STOP		; Power back on
	ANDCAM A,PLTSTS(U)	; Clear stop bit
	IOT CONO,PLTDON+PLTCHN	; Turn plotter back on
PLTCK2:	AOBJN U,PLTCK1		; LOOP BACK FOR ALL UNITS
	RET

	TNXEND
	END