Google
 

Trailing-Edge - PDP-10 Archives - BB-Y393J-SM - monitor-sources/cdksdv.mac
There are 20 other files named cdksdv.mac in the archive. Click here to see a list.
;<4-1-FIELD-IMAGE.MONITOR>CDKSDV.MAC.2, 25-Feb-82 20:12:53, EDIT BY DONAHUE
; UPD ID= 996, FARK:<4-WORKING-SOURCES.MONITOR>CDKSDV.MAC.2,  22-Feb-82 09:44:53 by ZIMA
;Edit 1984 - do the following:
; CLEAR CDBLK ON TRANSITION TO ONLINE
; CORRECT DATA PASSED TO SYSERR
; FIX IONXM BUGHLTS FROM CLOSE CODE
; SAVE SPACE BY MAKING CDERBF/CDERSZ RIGHT SIZE (IMPLIES CHANGE STG TOO)
; CORRECT STATUS BLOCK DOCUMENTATION, AND WRITE THE CORRECT DATA THERE
; FIX NOT PUTTING CDST INTO SYSERR ENTRY, SHORTEN SYSERR CODE SOME
; SHORTEN KSRD A BIT
; DO FULL CONVERSION TO T ACS,...
; ADD AND CALL ROUTINE TO CHECK HOPPER/STACKER STATE
; FIX BADLY HANDLED ONLINE TRANSITIONS
; CHECK FOR HOPPER/STACKER CONDITION IN KSRD
; CHECK FOR HOPPER/STACKER CONDITION IN CDRINT
; FIX EXTRA SYSERR ENTRY PROBLEM
; FIX EXTRA "PROBLEM ON DEVICE PCDR0:" MESSAGE PROBLEM
; PREVENT SYSERR ENTRIES FOR HOPPER EMPTY CONDITION
; CHANGE CDBDIN ARGUMENT SET FROM T4 TO U
; FINISH MORE UNIVERSAL USE OF U OVER RANDOM ACS
; CHANGE SOME HLR'S TO HLRZ'S SO THAT LH IS NOT GARBAGE
; MAKE CDRSER USE UNIT NUMBER ALREADY IN BLOCK INSTEAD OF FORCING ZERO
; CHANGE MORE RANDOM INSTRUCTIONS TO MOVX
; FINISH REMOVING CDUNIT CONSTRUCT (IMPLIES CHANGE STG TOO)
; FIX INDEXING IN CDRSER SO LH OF INDEX REGISTER ALWAYS ZERO
; FIX WRONG PAGE OFFSET MASKING IN KSRD
; CHANGE NCDWA TO BUGCHK AND RECOVER (IMPLIES CHANGE BUGS TOO)
; FIX WRONG VALUES IN SYSERR BLOCK IF NOT OPEN
; SHORTEN BUFFER FORMATTING ROUTINE
; DO THE AC RESTORE BLT MORE CLEVERLY
; REMOVE CDUNIT STUFF FROM KSCLZ
; COMBINE CLOSE AND RESTART ROUTINE CODE
; ADJUST JOB ZERO SYSERR ROUTINE, REMOVE ONE WORD OF CODE
; LET JOB ZERO CODE BE SWAPPABLE
; REMOVE Q2 STUFF FROM KSINI
; REMOVE CDUNIT STUFF FROM KSINI
; REMOVE CDUNIT STUFF FROM KSRD
; REMOVE CDUNIT STUFF FROM CDKSST, IMPACTS CDRSST
;End Edit 1984 changes.
; UPD ID= 214, SNARK:<4.1.MONITOR>CDKSDV.MAC.5,  22-Jan-80 08:42:50 by OSMAN
;tco 4.2597 -  prevent CDILVT bughlt at startup
;<OSMAN.MON>CDKSDV.MAC.1, 10-Sep-79 15:19:34, EDIT BY OSMAN
;TCO 4.2412 - Move definition of BUGHLTs, BUGCHKs, and BUGINFs to BUGS.MAC
;<4.MONITOR>CDKSDV.MAC.3,  4-Mar-79 14:40:02, Edit by KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<4.MONITOR>CDKSDV.MAC.2, 12-Dec-78 16:23:52, EDIT BY KIRSCHEN
;DO NOT TREAT HOPPER EMPTY AS HARD ERROR
;DO NOT PASS .DVFLG BACK TO USER IN CDRSTT
;<4.MONITOR>CDKSDV.MAC.1,  6-Dec-78 16:00:31, EDIT BY MILLER
;FIX TEST IN CDRINT FOR ERRORS

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976,1977,1978,1979,1980,1981,1982 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

;CARDREADER SERVICE FOR KS10
;SUPPORTS ONLY A SINGLE READER AS UNIT ZERO

;	SUBTTL	J. G. ZIMA, FEBRUARY 1982
	SEARCH PROKS,PROKL,SERCOD	;NOTE: PROKL IS USED TO FETCH .FECDR

	RESCD

CDVTKS==.			;DEFINE DEVICE DEPENDENT FUNCTION VECTOR TABLE
	IFIW!KSRD		;RDCD - READ A CARD
	IFIW!KSCLZ		;CDCLZ - CLOSE
	IFIW!KSRST		;CDRST - RESTART
	IFIW!KSINI		;CDINI - INITIALIZE
	IFIW!CDKSST		;GCDRST - RETURN STATUS
	IFIW!KSSWP		;BUFSWP - PUT BUFFER IN CORRECT FORMAT FOR KL

;KS10 RESIDENT STORAGE

ASCBSZ:	POINT 18,0		;BYTE POINTER FOR UNSWAPPED BUFFER
				; USED BY CDRAII TO CONVERT TO ASCII

RS (CDRINB,4)			;FOUR WORD INTERRUPT DISPATCH BLOCK
RS (CDIACS,20)			;INTERRUPT ACS STORED HERE
CDSTSZ=40			;SIZE OF CARDREADER STACK
RS (CDRSTK,CDSTSZ)		;CARD READER STACK


;CDRTBL - TABLE OF EXTERNAL PAGE ADDRESSES INDEXED BY UNIT NUMBER

CDRTBL::CD11BA			;BASE ADDRESS OF CD11
;KSINI - HERE TO INITIALIZE THE READER
;CALLED WITH Q2/ UNIT NUMBER (ACTUALLY ZERO, BUT WE IGNORE IT AND USE U)

KSINI:	SETZ U,0		;DO ONLY UNIT 0 (ONLY ONE SUPPORTED)
	MOVX T1,KSTYP		;SET TYPE OF READER TO KS
	STOR T1,CDRTYP,(U)	; IN THE CDR STATUS BLOCK
	SKIPN PROFLG		;IF PROFLG NOT SET DO NOTHING MORE
	 RET			;JUST RETURN QUIETLY

	MOVE T1,CDRTBL(U)	;GET BASE ADDRESS OF THIS UNIT
	CALL UBGOOD		;CHECK FOR DEVICE
	 RET			;NO DEVICE, RETURN QUIETLY

	SETONE CDEXST,(U)	;INFORM WORLD WE EXIST

	HLRZ T2,CDRTBL(U)	;GET UBA NUMBER FOR CDR
	MOVE T2,SMTEPT(T2)	;GET VECTOR TABLE ADDRESS FOR THAT UBA
	MOVE T1,[XPCW CDRINB]	;POINT TO INTERRUPT ROUTINE
	MOVEM T1,CDRIVT(T2)	;AND STORE INTERRUPT DISPATCH VECTOR

	XMOVEI T1,CDRINT	;SET UP INTERRUPT SERVICE ROUTINE ADDRESS
	MOVEM T1,CDRINB+3	; IN INTERRUPT BLOCK
	SETZM CDRINB+2		; AND INSURE NEW FLAGS ARE ZERO

	HLRZ T1,CDRTBL(U)	;GET UBA NUMBER FOR THIS CD11
	MOVEI T2,1		;ONE WINDOW NEEDED (FOR BUFFER)
	CALL ALUBWA		;ALLOCATE UNIBUS WINDOW
	 JRST [	BUG(NCDWA)	;BUGCHK TO SAY WE CAN'T USE THE CDR
		SETZRO CDEXST,(U) ;MAKE THE READER NONEXISTENT
		RET]		; AND RETURN
	MOVEM T1,CDUBAD(U)	;SAVE RETURNED UBA MAP REGISTER ADDRESS
	MOVEM T2,CD11A(U)	;SAVE ADDRESS ON UNIBUS OF WINDOW


;KSRST - HERE ON DEVICE DEPENDENT RESTART FUNCTIONS (FALL THROUGH FROM INIT)
;KSCLZ - CLOSE ROUTINE (FLUSH)
;ASSUMES U/ UNIT NUMBER OF READER TO RESTART
;DOES POWER CLEAR OPERATION AND SETS INTERRUPT ENABLE

KSCLZ:
KSRST:	JE CDEXST,(U),R		;DON'T IONXM IF NO READER PRESENT
	MOVX T2,CDPWR		;GET POWER RESET COMMAND AND
	WRIO T2,@CDRTBL(U)	; RESET THE READER
	MOVX T2,CDIEN		;SET INTERRUPT ENABLE
	WRIO T2,@CDRTBL(U)	; FOR THE READER
	RET			;RETURN
;CDRINT - DEVICE INTERRUPT SERVICE ROUTINE FOR THE KS CARDREADER

CDRINT:	MOVEM 17,CDIACS+17	;SAVE A REGISTER TO DO THE BLT
	MOVEI 17,CDIACS		;WHERE TO STORE THE ACS
	BLT 17,CDIACS+16	;SAVE AWAY THE ACS
	MOVE P,[IOWD CDSTSZ,CDRSTK] ;INITIALIZE THE INTERRUPT STACK
	SETZ U,0		;SET UP FOR UNIT 0 (ONLY SUPPORTED UNIT FOR NOW)
	JE CDOPN,(U),[
		CALL CDINOK	;EXIT VIA STATUS CHECK IF NOTHING OPEN
		CALL KSCLZ	;CLEAR OUT ANY GARBAGE BITS LEFT OVER
		SETZRO CDBLK,(U) ;MAKE SURE NO LONGER BLOCKED
		JRST CDRIXT]	; AND TERMINATE INTERRUPT
	RDIO T1,@CDRTBL(U)	;READ THE STATUS REGISTER
	TXNE T1,CDTOL		;COMING ONLINE?
	 JRST [	CALL CDINOK	;YES, DO STATUS REPORT
		CALL KSCLZ	;CLEAR OUT ANY GARBAGE BITS LEFT OVER
		JRST CDRIXT]	; AND TERMINATE INTERRUPT
	TXNE T1,CDERR1!CDOFL	;ANY ERRORS?
	 JRST [	CALL CDINOK	;SOME ERROR - GO DO STATUS REPORT
		CALL CDRHSC	;CHECK FOR HOPPER-EMPTY/STACKER-FULL
		 JRST .+1	;EMPTY/FULL - PROCESS THE CARD READ IN
		JRST CDRIXT]	;BUT JUST TERMINATE INTERRUPT FOR ERRORS
	LOAD T1,CDCNT,(U)	;GET THE BYTE TRANSFER COUNT
	ADDI T1,^D160		;UPDATE COUNT (TWO 8-BIT BYTES IN 12-BIT FRAME)
	STOR T1,CDCNT,(U)	;PUT IT BACK
	AOS CARDCT(U)		;INDICATE ANOTHER CARD HERE
	AOS CDRCT1(U)		;ONE MORE BUFFER FILLED
	SETZRO CDBLK,(U)	;NOT WAITING FOR A CARD ANYMORE
	CALL SETBF1		;FIND INTERRUPT BUFFER, ADDRESS TO T1
	SETCMP CDBFI,(U)	;TOGGLE INTERRUPT BUFFER BIT (***NOTE: IF
				; EVER MORE THAN 2 BUFFERS, THEN LOAD/AOS/STOR)
	JN CDAII,(U),[	LDB T1,[POINT 16,0(T1),15] ;IF ASCII MODE***RIGHT???
			TRC T1,7417	;SEE IF THIS IS AN EOF
			TRCE T1,17	;LOW FOUR BITS ON?
			TRCN T1,7400	;OR HIGH FOUR?
			 SKIPA		;YES, IS AN EOF
			JRST .+1	;NOT AN EOF
			SETZRO CDATN,(U) ;MAKE SURE ATTENTION NOT SET ON EOF
			JRST CDRIXT]	;AND TERMINATE WITHOUT NEW READ

	SKIPG CDRCT1(U)		;ANOTHER PI BUFFER AVAILABLE?
	CALL CDRHSC		;NEED TO WAIT CAUSE HOPPER-EMPTY/STACKER-FULL?
	 SKIPA			;EMPTY/FULL OR NO NEXT BUFFER TO USE, RETURN
	CALL RDCARD		;ELSE START READ OF NEXT CARD

CDRIXT:	HRLZI 17,CDIACS		;SET UP BLT POINTER TO
	BLT 17,17		; RESTORE THE ACS FROM CDIACS
	XJEN CDRINB		; AND TERMINATE THE INTERRUPT
;KSRD - ROUTINE TO START READING A CARD
;CALL WITH  U/  UNIT NUMBER
;RETURNS  +1:	IF CANNOT START READ
;	  +2:	AFTER STARTING READ OF CARD
;USES T1,T2.

KSRD:	CALL CDRHSC		;CHECK FOR HOPPER-EMPTY/STACKER-FULL
	 RETSKP			;EMPTY/FULL, RETURN AND TRY AGAIN LATER
	LOAD T1,CDWRD,(U)	;GET ADDRESS OF BUFFER
	MAP T2,0(T1)		;CONVERT TO PHYSICAL ADDRESS IN T2
	ANDX T2,<7,,777777>	;MASK OFF JUNK BITS
	LSH T2,-PGSFT		;MAKE PAGE ADDRESS
	TXO T2,UNBD18+UNBVBT	;SET 16 BIT (DISABLE 18) XFER AND VALID BITS
	WRIO T2,@CDUBAD(U)	;STORE IN UNIBUS MAP WINDOW
	ANDX T1,PGSIZ-1		;MASK VIRTUAL BUFFER ADDRESS TO PAGE OFFSET
	LSH T1,2		;MAKE INTO PDP11 BYTE ADDRESS
	ADD T1,CD11A(U)		;ADD IN BASE ADDRESS OF UNIBUS WINDOW
	MOVE T2,CDRTBL(U)	;GET EXTERNAL PAGE ADDRESS FOR DEVICE REGISTERS
	WRIO T1,CDBA(T2)	;SET TRANSFER ADDRESS
	MOVX T1,<-^D80>		;GET MINUS COLUMN COUNT
	WRIO T1,CDCC(T2)	;WRITE COUNT REGISTER
	MOVX T1,CDIEN+CDRED	;GET START READ + INTERRUPT ENABLE
	WRIO T1,CDST(T2)	;START READING
	RETSKP			; AND TAKE THE GOOD RETURN
;KSSWP - PUT BUFFER INTO THE FORM CDRSRV WANTS IT
;CONVERT BYTE FORMAT FROM 2-16-2-16 TO 16-16-4 FOR BINARY USE
;BY ROUTINE CDRAII WHICH USES ASCBSZ TO RETRIEVE BYTES.
;ASSUMES WORD ALIGNMENT OF BUFFER POINTED TO BY FILBYT(JFN)
;AND SIZE OF BUFFER EQUALS ONE CARD.  LEAVES TRASH IN LAST 4 BITS.
;PRESERVES ALL ACS.
;RETURNS  +1:	ALWAYS

KSSWP:	SAVET			;SAVE THE TEMP ACS
	MOVSI T3,-^D40		;DO 80 CHARS WORTH
	HRR T3,FILBYT(JFN)	;GET THE BUFFER POINTER
KSSWLP:	MOVE T1,0(T3)		;GET A WORD OF THE BUFFER
	LSHC T1,-^D16		;SECOND (LOW) CHARACTER TO T2
	LSH T1,-2		;DISCARD TWO JUNK BITS
	LSHC T1,-^D16		;SHIFT DOWN THE FIRST (HIGH) CHARACTER
	MOVEM T2,0(T3)		;PUT ADJUSTED WORD BACK
	AOBJN T3,KSSWLP		;LOOP OVER ALL THE BUFFER
	RET			;RETURN
;CDKSST - ROUTINE TO RETURN STATUS OF THE CARDREADER
;CALL WITH U/  UNIT NUMBER

CDKSST:	JE CDEXST,(U),R		;DON'T IONXM IF NO READER EXISTS
	MOVX T1,CDIEN		;INTERRUPTS ENABLED BIT
	TIOE T1,@CDRTBL(U)	;SEE IF WE HAVE LOST INTERRUPT ENABLE
	 JRST CDINOK		;ALL OK

	BUG(CDBDIN,<<U,D>>)	;INFORM WORLD WE LOST INTERRUPTS
	BSIOB T1,@CDRTBL(U)	;REENABLE LOST INTERRUPTS AND CONTINUE

CDINOK:	;CALLRET CDRSTT		;GET STATUS (FALL THROUGH)
;ROUTINE TO SET UP THE STATUS BLOCKS FOR THE CARD READER
;
; THE STATUS BLOCK IS IN THE FOLLOWING FORMAT:
;
;PDP11 WORD NUMBERS
;
; WORD	0	STATUS WORD 0 (.DVXXX BITS)
; WORD	1	STATUS WORD 1 (.DDXXX BITS)
; WORD	2	HIGH BYTE: # BYTES OF DEVICE DEPENDENT INFO (=0)
;		LOW BYTE: # BYTES OF DEVICE REGISTERS (=10)
;
;		DEVICE REGISTERS:
;
; WORD 	3	STATUS AND CONTROL REGISTER (CDST)
; WORD	4	CURRENT ADDRESS REGISTER (CDBA)
; WORD	5	COLUMN COUNT REGISTER (CDCC)
; WORD	6	DATA BUFFER REGISTER (CDDB)
;

CDERSZ==4			;SIZE OF BUFFER IN WORDS
CDSIZ==16			;SIZE OF DATA SECTION IN 8-BIT BYTES

CDRSTT:	JE CDEXST,(U),CDNEXD	;GO IF READER DOES NOT EXIST
	SETONE CDSHA,(U)	;SAY THAT STATUS HAS ARRIVED
	HRRZ P5,U		;COPY UNIT NUMBER TO P5
	IMULI P5,CDERSZ		;GET CORRECT BLOCK
	ADD P5,[POINT 8,CDERBF]	;BUILD POINTER TO STATUS BUFFER
	MOVE P6,P5		;SAVE POINTER TO BUFFER IN P6
	SETZ Q3,0		;CLEAR ACS TO BUILD STATUS
	SETZB Q2,T2
	MOVE T3,CDRTBL(U)	;GET UNIBUS REGISTER BASE ADDRESS TO T3

	RDIO T1,CDDB(T3)	;READ SECONDARY STATUS REGISTER
	TXNE T1,CDBRCK		;READ CHECK?
	 TXO Q2,.DDRCK		;YES
	TXNE T1,CDBPCK		;PICK CHECK?
	 TXO Q2,.DDPCK		;YES
	TXNE T1,CDBSCK		;STACK CHECK?
	 TXO Q2,.DDSCK		;YES

	RDIO T1,CDST(T3)	;READ PRIMARY STATUS REGISTER
	TXNE T1,CDOFL		;OFFLINE?
	 TXO T2,.DVFOL		;YES
	SKIPN Q2		;ANY HARD ERRORS NOTED YET?
	TXNE T1,CDDLT+CDNXM	; OR DATA LATE OR NXM?
	 TXO T2,.DVFHE+.DVFOL	;YES, SET HARD ERROR BITS
	TXNE T1,CREOF		;EOF BUTTON SEEN?
	 TXO T2,.DVFEF		;YES, SET EOF
	IDPB Q3,P5		;(0) SET FIRST STATUS (TO ZERO)
	IDPB T2,P5		;(1) SET .DVXXX FLAGS
	IDPB Q3,P5		;(2) ZERO
	IDPB Q2,P5		;(3) SECONDARY STATUS .DDXXX FLAGS
	IDPB Q3,P5		;(4) ZERO BYTES OF DEVICE DEPENDENT INFO
	MOVEI T1,10		;BUT 4 WORDS = 10 BYTES OF REGISTERS
	IDPB T1,P5		;(5) STORE COUNT OF DEVICE REGISTER BYTES
	HRLI P5,(<POINT 16,0,15>) ;SET UP FOR 16 BIT BYTES (IN MID-WORD)
	RDIO T1,CDST(T3)	;GET STATUS REGISTER
	IDPB T1,P5		;(6,7) STORE STATUS
	RDIO T1,CDBA(T3)	;GET BUS ADDRESS
	IDPB T1,P5		;(10,11) STORE IT
	RDIO T1,CDCC(T3)	;GET BYTE COUNT
	IDPB T1,P5		;(12,13) STORE IT
	RDIO T1,CDDB(T3)	;GET PACKING REGISTER
	IDPB T1,P5		;(14,15) STORE IT
	TXNN T2,.DVFHE		;ANY HARD ERRORS REQUIRING SYSERR ENTRY?
	 JRST CDNEXD		;NO, DON'T NEED TO DO SYSERR ENTRY

	MOVX T1,CDSIZ+FE%LEN	;GET LENGTH OF SYSERR BUFFER NEEDED
	MOVX T2,CDSIZ+FE%SIZ
	CALL ALCSEB		;ALLOCATE BUFFER
	 JRST CDNEXD		;NO BUFFER, SO DON'T BOTHER
	SETZM FE%DTE+SEBDAT(T1)	;SET NO DTE
	MOVX T2,.FECDR		;GET DEVICE CODE FOR CDR
	HRLI T2,0(U)		;SET THE UNIT NUMBER
	MOVEM T2,FE%DEV+SEBDAT(T1) ;STORE UNIT,,DEVICE TYPE
	MOVX T4,<-CDSIZ>	;GET MINUS THE SIZE
	HRLM T4,FE%PTR+SEBDAT(T1) ;SAVE COUNT OF WORDS
	MOVX T3,CDSIZ		;GET SIZE OF DATA SECTION IN 8-BIT BYTES
	MOVEM T3,FE%BYT+SEBDAT(T1) ;STORE IT IN BUFFER
	MOVE T4,P6		;GET POINTER TO STATUS BUFFER
	MOVE T2,[POINT 8,FE%INF+SEBDAT(T1)] ;POINTER TO DEVICE DATA
CDSYLP:	ILDB P5,T4		;GET STATUS BUFFER BYTES
	IDPB P5,T2		; AND STORE IN SYSERR BUFFER
	SOJG T3,CDSYLP		;LOOP OVER ALL BYTES
	MOVE T2,[-2,,[	SEBPTR 0,SBTEVC,SEC%FE   ;"FRONT END" ERROR EVENT CODE
			SEBPTR 0,SBTFNA,CDRSER]] ;ROUTINE FOR JOB ZERO TO CALL
	MOVE Q2,T1		;SAVE POINTER TO SYSERR BUFFER
	CALL SEBCPY		;HAVE THE POINTERS COPIED
	 JFCL			;NOP IF ERROR
	MOVE T1,Q2		;RESTORE BUFFER POINTER
	CALL QUESEB		;QUEUE THE ERROR BLOCK
	CALL KSCLZ		;RESET THE READER

CDNEXD:	MOVE T2,U		;PUT UNIT NUMBER TO T2 (REQUIRED FOR CDRTLS)
	MOVE T4,P6		;POINTER TO STATUS BUFFER
	CALLRET CDRTLS		;SAY STATUS RECEIVED
;CDRHSC - ROUTINE CALLED TO CHECK FOR THE HOPPER-EMPTY/STACKER-FULL CONDITION
;EXPECTS  U/ UNIT TO CHECK
;
;	CALL CDRHSC
;
;RETURNS  +1:	ON HOPPER-EMPTY OR STACKER-FULL CONDITION
;	  +2:	IF NEITHER
;
;***NOTE*** IN SPITE OF -11 MANUALS AND DOCUMENTATION, THE APPROPRIATE
;TESTS ARE:  FOR HOPPER EMPTY: CDHCK SET IN STATUS REGISTER
;	     FOR STACKER FULL: CDRDK SET IN STATUS REGISTER + NOT CDHCK
;				NOT CDBRCK + NOT CDBSCK + NOT CDBPCK
;				(IE JUST CDRDK AND NO OTHER ERROR BITS)
;REFER TO PAGE 4-27 OF THE CD-11 HARDWARE MANUAL FICHE FOR THIS GEM.
;(OR TO THE PRINTS)

CDRHSC:	RDIO T1,@CDRTBL(U)	;READ STATUS REGISTER
	TXNE T1,CDHCK		;HOPPER EMPTY?
	 RET			;YES, NONSKIP RETURN

	TXNN T1,CDRDK		;READER CHECK ERROR SET?
	 RETSKP			;NO, CAN'T BE STACKER FULL THEN

	MOVE T1,CDRTBL(U)	;GET CDR UNIBUS REGISTER BASE ADDRESS
	RDIO T1,CDDB(T1)	;READ THE SECONDARY STATUS REGISTER
	TXNN T1,CDBRCK!CDBSCK!CDBPCK ;ALL CHECK CONDITIONS CLEAR?
	 RET			;YES, RETURN NONSKIP FOR STACKER FULL
	RETSKP			;NO, CAN'T BE STACKER FULL
;CDRSER - ROUTINE CALLED BY JOB 0 SYSERR FORK TO DETERMINE OWNING PROCESS
;EXPECTS  T1/ OFFSET OF SYSERR BLOCK IN SEBDAT
;RETURNS  +1:	ALWAYS
;USES T2,T3.

	SWAPCD

CDRSER:	HLRZ T2,FE%DEV+SEBDAT(T1) ;FETCH THE UNIT NUMBER WE ARE DOING
	JE CDOPN,(T2),[		;IS IT OPENED?
		SETOM FE%FJB+SEBDAT(T1)	;NO. SAY UNASSIGNED FORK,,JOB
		JRST CDFKS]	; AND FORGE AHEAD
	LOAD T2,CDFRK,(T2)	;GET FORK NUMBER
	HLRZ T3,FKJOB(T2)	;GET JOB NUMBER TO RH
	HRL T2,T3		;JOB,,FORK
	MOVSM T2,FE%FJB+SEBDAT(T1) ;STORE FORK,,JOB
	MOVE T2,JOBDIR(T3)	;LOGGED-IN DIRECTORY
	HRLI T2,USRLH		;SET UP USER NUMBER
	MOVEM T2,FE%DIR+SEBDAT(T1) ;STORE DIRECTORY NUMBER
	MOVE T2,JOBPNM(T3)	;GET JOB PROGRAM NAME
	MOVEM T2,FE%NAM+SEBDAT(T1) ; AND STORE
CDFKS:	MOVX T2,FE%INF		;START OF ERROR WORDS
	HRRM T2,FE%PTR+SEBDAT(T1) ;SET FIRST ERROR WORD
	SETZM FE%ID+SEBDAT(T1)	;SET "FRONT-END" SOFTWARE VERSION NUMBER
	RET			;RETURN


	TNXEND
	END