Google
 

Trailing-Edge - PDP-10 Archives - BB-K911B-SM - sources/cdksdv.mac
There are 20 other files named cdksdv.mac in the archive. Click here to see a list.
; 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 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

;CARDREADER SERVICE FOR KS10
	RESCD
	SEARCH PROKS,PROKL,SERCOD


CDVTKS==.
	IFIW!KSRD		;READ A CARD
	IFIW!KSCLZ		;CLOSE
	IFIW!KSRST		;RESTART
	IFIW!KSINI		;INIT
	IFIW!CDKSST		;STATUS
	IFIW!KSSWP		;PUT BUFFER IN CORRECT FORMAT FOR KL

;KS10 RESIDENT STORAGE

ASCBSZ:	POINT 18,0		;ASCII POINTER FOR UNSWAPPED BUFFER


RS (CDIACS,20)			;INTERRUPT ACS
CDSTSZ=40			;SIZE OF CARDREADER STACK
RS (CDRSTK,CDSTSZ)		;CARD READER STACK

RS (CDRINB,4)

;CDRTBL ENTRY OF EXTERNAL PAGE ADDRESSES

CDRTBL::CD11BA			;BASE ADDRESS OF CD11
KSINI:	MOVEI T1,KSTYP		;SET TYPE
	STOR T1,CDRTYP,(Q2)
	SKIPN PROFLG		;IF PROFLG NOT SET DO NOTHING MORE
	RET
	SETZ U,0		;DO ONLY UNIT 0 (ONLY ONE SUPPORTED)
	MOVE T1,CDRTBL(U)	;GET BASE ADDRESS OF THIS UNIT
	CALL UBGOOD		;CHECK FOR DEVICE
	RET			;NO DEVICE
	SETONE CDEXST,(Q2)	;INFORM WORLD WE EXIST
	MOVEM Q2,CDUNIT		;SAVE UNIT NUMBER
	MOVE T1,[XPCW CDRINB]	;POINT TO INTERRUPT ROUTINE
	HLR T2,CDRTBL(U)	;GET UBA NUMBER
	MOVE T2,SMTEPT(T2)	;GET VECTOR TABLE
	MOVEM T1,CDRIVT(T2)	;STORE VECTOR
	MOVEI T1,CDRINT		;SET UP INTERRUPT VECTOR IN INTERRUPT BLOCK
	MOVEM T1,CDRINB+3
	SETZM CDRINB+2		;INSURE NEW FLAGS 0
	HLR T1,CDRTBL(U)	;GET UBA NUMBER
	MOVEI T2,1		;ONE WINDOW NEEDE
	CALL ALUBWA		;GET UNIBUS WINDOW
	BUG(NCDWA)
	MOVEM T1,CDUBAD(U)	;SAVE UBA ADDRESS
	MOVEM T2,CD11A(U)	;SAVE CONVERSION ADDRESS
KSRST:	MOVEI T2,CDPWR		;RESET THE DEVICE
	WRIO T2,@CDRTBL(U)
	MOVEI T2,CDIEN		;SET INTERRUPT ENABLE
	WRIO T2,@CDRTBL(U)
	RET			;RETURN
;INTERRUPT SERVICE ROUTINE FOR CARDREADER

CDRINT:	MOVEM 17,CDIACS+17	;SAVE A REGISTER
	MOVEI 17,CDIACS		;SAVE REST OF REGISTERS
	BLT 17,CDIACS+16
	MOVE P,[IOWD CDSTSZ,CDRSTK] ;INIT STACK
	MOVE T4,CDUNIT		;GET UNIT ADDRESS
	SETZ U,0		;SET UP FOR UNIT 0 (ONLY SUPPORTED UNIT FOR NOW)
	JE CDOPN,(T4),[	CALL CDINOK	;EXIT IF NOTHING OPEN
			JRST CDRIXT]
	RDIO T1,@CDRTBL(U)	;READ THE STATUS REGISTER
	TRNE T1,CDERR1!CDOFL!CDTOL ;ANY ERRORS?
	JRST [	CALL CDINOK	;ERROR GO DO STATUS REPORT
		JRST CDRIXT]	;AND EXIT
	LOAD T1,CDCNT,(T4)	;GET THE COUNT
	ADDI T1,^D160		;UPDATE COUNT
	STOR T1,CDCNT,(T4)
	AOS CARDCT(T4)		;INDICATE ANOTHER CARD HERE
	AOS CDRCT1(T4)		;ONE MORE BUFFER FILLED
	SETZRO CDBLK,(T4)	;NOT WAITING FOR A CARD ANYMORE
	CALL SETBF1		;FIND INT BUFFER
	LOAD C,CDBFI,(T4)	;GET INTERRUPT LEVEL BUFFER BIT
	XORI C,1		;TOGGLE IT
	STOR C,CDBFI,(T4)
	JN CDAII,(T4),[	LDB T1,[POINT ^D16,0(T1),15]
			TRC A,7417 ;SEE IF THIS IS AN EOF
			TRCE T1,17 ;IS IT?
			TRCN T1,7400 ;OR THIS FLAVOR?
			JRST CDRIXT	     ;IS AN EOF
			JRST .+1]    ;NOT AN EOF
	MOVEI T1,CDHCK		;HOPPER EMPTY?
	SKIPLE CDRCT1(T4)	;ANOTHER PI BUFFER AVAILABLE?
	JRST CDRIXT		;NOPE
	TION T1,@CDRTBL(U)	;CHECK FOR HOPPER EMPTY
	CALL RDCARD		;READ NEXT CARD
CDRIXT:	MOVSI 17,CDIACS		;RESTORE AC'S
	BLT 17,16
	MOVE 17,CDIACS+17
	XJEN CDRINB
; ROUTINE TO READ A CARD

KSRD:	MOVE T4,CDUNIT		;GET UNIT
	MOVE T3,CDRTBL(T4)	;GET EXTERNAL PAGE ADDRESS
	LOAD T1,CDWRD,(U)	;ADDRESS OF BUFFER
	MAP T1,0(T1)		;GET PHYSICAL ADDRESS
	AND T1,[7,,-1]		;MASK OFF JUNK BITS
	LSH T1,-^D9		;MAKE PAGE ADDRESS
	TXO T1,UNBD18+UNBVBT	;SET VALID BITS
	WRIO T1,@CDUBAD(U)	;STORE IN WINDOW
	LOAD T1,CDWRD,(U)	;GET BUFFER
	LSH T1,2		;MAKE PDP11 ADDRESS
	ANDI T1,1777		;MASK JUNK
	ADD T1,CD11A(U)		;OFFSET
	WRIO T1,CDBA(T3)	;SET UP TRANSFER ADDRESS
	MOVNI T1,^D80		;COL COUNT
	WRIO T1,CDCC(T3)	;WRITE COUNT
	MOVEI T1,CDIEN+CDRED	;START
	WRIO T1,CDST(T3)
	RETSKP
;ROUTINE TO RETURN STATUS OF CARDREADER

CDKSST:	MOVE T4,CDUNIT		;GET UNIT
	JE CDEXST,(U),R		;CHECK FOR EXISTANCE
	MOVEI T1,CDIEN		;CHECK FOR INTERRUPT ENABLE
	TIOE T1,@CDRTBL(T4)	;
	JRST CDINOK		;YUP ALL OK
	BUG(CDBDIN,<<T4,D>>)
	BSIOB T1,@CDRTBL(T4)
CDINOK:	CALLRET CDRSTT		;GET STATUS
;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 (DV.XXX)
; WORD	1	STATUS WORD 1 (DD.XXX)
; WORD	2	(HIGH 8 BITS) # BYTES OF DEVICE DEPENDENT INFO
;		(LOW BYTE) # BYTES OF DEVICE REGISTERS 
;
;  	DEVICE REGISTERS
; WORD 	3	STATUS AND CONTROL REGISTER
; WORD	4	COLUMN COUNT REGISTER
; WORD	5	CURRENT ADDRESS REGISTER
; WORD	6	DATA BUFFER REGISTER

; THE FOLLOWING BITS ARE USED IN THE STATUS WORDS:

;	DV.OFL	OFF-LINE
;	DV.OIR	HARD ERROR (DD.RCK,DD.PCK,DD.SCK)
;	DV.EOF	E-O-F BUTTON PUSHED
;	DV.LOG	ERROR LOGGING REQUIRED
;	DV.HNG	DEVICE HUNG

;	DD.RCK	READ CHECK
;	DD.PCK	PICK CHECK
;	DD.SCK	STACK CHECK
;	DD.HEM	HOPPER EMPTY
;	DD.SFL	STACKER FULL

CDERSZ==7			;SIZE OF BUFFER
CDSIZ==20			;SIZE OF 8-BIT BYTES IN STATUS

CDRSTT:	HRRZ T1,T4		;GET UNIT NUMBER
	JE CDEXST,(T1),CDNEXD
	IMULI T1,CDERSZ		;GET CORRECT BLOCK
	SETONE CDSHA,(U)	;SAY STATUS ARRIVED
	ADD T1,[POINT 8,CDERBF]	;POINT TO BUFFER
	MOVE P6,T1		;SAVE POINTER TO BUFFER
	MOVE P5,T1
	SETZ Q3,0		;SECONDARY STATUS
	SETZB Q2,T2
	MOVE T3,CDRTBL(T4)	;GET EXTERNAL PAGE ADDRESS
	RDIO P3,CDDB(T3)	;READ SECONDARY STATUS
	TRNE P3,CDBRCK		;READ CHECK
	TXO Q2,.DDRCK
	TRNE P3,CDBPCK		;PICK CHECK?
	TXO Q2,.DDPCK
	TRNE P3,CDBSCK		;STACK CHECK?
	TXO Q2,.DDSCK
	RDIO T1,CDST(T3)	;GET STATUS WORD
	TRNE T1,CDOFL		;CHECK FOR OFFLINE
	TXO T2,.DVFOL		;YES
	SKIPN Q2		;HARD ERRORS?
	TRNE T1,CDRDK+CDDLT+CDNXM
	TXO T2,.DVFHE!.DVFOL	;SET HARD ERROR
	TRNE T1,CREOF		;CHECK FOR EOF
	TXO T2,.DVFEF	;YES SET EOF
	IDPB Q3,P5		;SET  FIRST STATUS
	IDPB T2,P5
	IDPB Q3,P5		;NEXT TW0 WORDS 0
	IDPB Q2,P5
	MOVEI T1,0		;NUMBER OF REGISTERS TO SAVE
	IDPB T1,P5
	MOVEI T1,10	
	IDPB T1,P5
	IDPB Q2,P5		;STORE NULL
	IDPB Q2,P5
	HRLI P5,(<POINT 16,0>)	;SET UP FOR 16 BIT WORDS
	IDPB T1,P5		;STORE STATUS
	RDIO T1,CDBA(T3)	;GET BADRESS
	IDPB T1,P5
	RDIO T1,CDCC(T3)	;GET BYTE COUNT
	IDPB T1,P5
	RDIO T1,CDDB(T3)	;GET PACKING REGISTER
	IDPB T1,P5
	TXNN T2,.DVFHE		;CHECK FOR HARD ERROR
	JRST CDNEXD		;NONE LEFT
	MOVEI T1,CDSIZ+FE%LEN	;GET LENGTH OF BUFFER NEEDED
	MOVEI T2,CDSIZ+FE%SIZ
	CALL ALCSEB		;ALLOCATE BUFFER
	JRST CDNEXD		;NO BUFFER QUIT
	SETZM FE%DTE+SEBDAT(T1)	;SET NO DET
	MOVEI T2,.FECDR		;GET DEVICE CODE
	HRLI T2,0(U)		;SET THE UNIT NUMBER
	MOVEM T2,FE%DEV+SEBDAT(T1)
	MOVNI T4,CDSIZ		;GET THE SIZE
	HRLM T4,FE%PTR+SEBDAT(T1) ;SAVE COUNT OF WORDS
	MOVEI T3,CDSIZ		;GET THE SIZE AGAIN
	MOVE T4,P6		;POINTER TO BUFFER
	MOVE T2,[POINT 8,FE%INF+SEBDAT(T1)] ;PONTER TO DEVICE DATA
	MOVEM T3,FE%BYT+SEBDAT(T1)
SYECD:	ILDB P5,T4		;GET BUFFER CHARACTERS
	IDPB P5,T2		;STORE CHARACTERS
	SOJG T3,SYECD
	MOVE T2,[-2,,[
			SEBPTR 0,SBTEVC,SEC%FE
			SEBPTR 0,SBTFNA,CDRSER]]
	MOVE Q2,T1		;SAVE POINTER TO ERROR BUFFER
	CALL SEBCPY
	JFCL			;NOP IF ERROR
	MOVE T1,Q2		;RESTORE BUFFER POINTER
	CALL QUESEB		;QUEUE ERROR
	CALL KSCLZ		;RESET
CDNEXD:	MOVE T2,CDUNIT		;
	MOVE T4,P6		;POINTER TO BUFFER
	CALLRET CDRTLS		;SAY STATUS RECEIVED

; CLOSE ROUTINE (FLUSH)

KSCLZ:	MOVE T4,CDUNIT
	MOVEI T1,CDPWR		;DO POWER CLEAR
	WRIO T1,@CDRTBL(T4)
	MOVEI T1,CDIEN		;INTERRUPT EANBLE
	WRIO T1,@CDRTBL(T4)
	RET			;QUIT

;ROUTINE CALLED TO DETERMINE OWNING PROCESS

CDRSER:	SETZ T2,		;GET UNIT
	JE CDOPN,(T2),[		;IS IT OPENED?
		MOVNI T3,-1	;NO. SAY UNASSIGNED
		JRST CDFKS]
	LOAD T2,CDFRK,(T2)	;GET FORK ID
	HLRZ T3,FKJOB(T2)	;FIND FORK
	HRLI T3,0(T2)		;UNIT
	MOVE T2,JOBDIR(T3)	;DIRECTORY
	HRLI T2,USRLH		;SET UP USER NUMBER
	MOVEM T2,FE%DIR+SEBDAT(T1) ;STORE DIRECTORY NUUMBER
	MOVE T2,JOBPNM(T3)	;GET NAME
	MOVEM T2,FE%NAM+SEBDAT(T1)
CDFKS:	MOVEM T3,FE%FJB+SEBDAT(T1)
	MOVEI T2,FE%INF		;START OF ERROR WORDS
	HRRM T2,FE%PTR+SEBDAT(T1)
	SETZM FE%ID+SEBDAT(T1)
	RET			;RETURN

KSSWP:	SAVET			;SAVE TEMPS
	MOVEI T4,^D40		;80 CHARS
	HRRZ T3,FILBYT(JFN)	;GET BUFFER POINTER
KSSWLP:	MOVE T1,0(T3)		;GET A WORD
	LSHC T1,-^D16		;SECOND CHARACTER
	LSH T1,-2		;JUNK BITS
	LSHC T1,-^D16		;FIRST CHARACTER
	MOVEM T2,0(T3)		;STORE CHARACTERS
	AOS T3
	SOJG T4,KSSWLP		;LOOP
	RET
	TNXEND
	END