Google
 

Trailing-Edge - PDP-10 Archives - AP-4178E-RM - swskit-sources/phyh11.mac
There are 47 other files named phyh11.mac in the archive. Click here to see a list.
;<3A.MONITOR>PHYH11.MAC.53,  7-Jul-78 01:47:02, Edit by MCLEAN
;MAKE TM03'S WORK
;<3A-NEW>PHYH11.MAC.52, 26-May-78 16:19:59, Edit by FORTMILLER
;PUT CODE IN FOR DX20 EVEN THOUGH IT MAY NEVER BE USED
;<3.SM10-RELEASE-3>PHYH11.MAC.95,  8-May-78 11:13:12, Edit by MCLEAN
;REMOVE PHYDLT BUGINF MUTTER MUTTER
;<3A.MONITOR>PHYH11.MAC.50, 27-Apr-78 23:15:29, Edit by MCLEAN
;<3A.MONITOR>PHYH11.MAC.49, 27-Apr-78 21:44:09, Edit by MCLEAN
;<3A.MONITOR>PHYH11.MAC.48, 27-Apr-78 21:16:30, Edit by MCLEAN
;MORE READBACKWARDS
;<3A.MONITOR>PHYH11.MAC.47, 27-Apr-78 00:16:26, Edit by MCLEAN
;MAKE READ BACKWARDS WORK
;<3.SM10-RELEASE-3>PHYH11.MAC.94, 24-Apr-78 14:51:52, Edit by MCLEAN
;STORE LH OF WINDOW (INTERESTING PART ON ERROR)
;<3.SM10-RELEASE-3>PHYH11.MAC.92,  2-Apr-78 15:46:30, Edit by MCLEAN
;FIX ERROR RECOVERY TO USE CDBCNI (UNUSED IN PHYH11) TO BE AN
;INDICATOR AS TO WHETHER DOING DATA OP OR NOT ON XFER COMPLETION
;<3.SM10-RELEASE-3>PHYH11.MAC.91, 31-Mar-78 15:04:03, Edit by MCLEAN
;PUT ERROR REGISTER 2 DEFINITION IN CORRECT PLACE
;<3A.MONITOR>PHYH11.MAC.43, 29-Mar-78 21:18:49, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.88, 28-Mar-78 00:23:04, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.87, 28-Mar-78 00:21:13, Edit by MCLEAN
;FIX CKERR TO RETURN CHANNEL ERROR CORRECTLY
;<3.SM10-RELEASE-3>PHYH11.MAC.86,  7-Mar-78 15:40:47, Edit by MCLEAN
;SOME CODE CLEANUPS
;<3A.MONITOR>PHYH11.MAC.38,  3-Mar-78 16:13:00, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.85,  3-Mar-78 13:35:36, Edit by MCLEAN
;FIX UBGOOD CALL
;<3.SM10-RELEASE-3>PHYH11.MAC.32, 22-Feb-78 16:32:23, Edit by MCLEAN
;MAKE IT WORK IF RH IS NOT THERE
;<3.SM10-RELEASE-3>PHYH11.MAC.32, 22-Feb-78 16:32:23, Edit by MCLEAN
;MAKE IT WORK IF RH IS NOT THERE
;<4.MONITOR>PHYH11.MAC.34,  1-Feb-78 14:50:07, Edit by MCLEAN
;FIX PHYALC FOR NEW CALLING SEQ
;<4.MONITOR>PHYH11.MAC.33, 30-Jan-78 21:31:04, Edit by MCLEAN
;ADD CHANGES FOR UNIT GOING ON LINE
;<1MCLEAN>PHYH11.MAC.3, 25-Jan-78 15:19:16, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.31, 26-Jan-78 17:06:31, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.30, 26-Jan-78 16:17:04, Edit by MCLEAN
;MORE FIX OF CLRRAE
;<3.SM10-RELEASE-3>PHYH11.MAC.29, 23-Jan-78 14:59:49, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.27, 23-Jan-78 13:52:39, Edit by MCLEAN
;FIX REGISTER ACCESS ERROR RECOVERY
;<3.SM10-RELEASE-3>PHYH11.MAC.27, 23-Jan-78 13:52:39, Edit by MCLEAN
;FIX REGISTER ACCESS ERROR RECOVERY
;<3.SM10-RELEASE-3>PHYH11.MAC.26, 20-Jan-78 01:20:50, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.25, 15-Jan-78 20:10:10, Edit by MCLEAN
;MAX RQDUBW = MAXPPB
;<3.SM10-RELEASE-3>PHYH11.MAC.24, 15-Jan-78 18:21:33, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.23, 13-Jan-78 16:39:03, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.22, 13-Jan-78 16:15:26, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.21, 13-Jan-78 16:06:02, Edit by MCLEAN
;FIX CKERR FOR FCE ON TM02
;<3.SM10-RELEASE-3>PHYH11.MAC.20, 14-Dec-77 01:14:16, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.19, 13-Dec-77 00:32:25, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.18, 12-Dec-77 23:39:54, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.17, 12-Dec-77 23:39:21, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.16, 12-Dec-77 23:37:22, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.15, 12-Dec-77 22:11:13, Edit by MCLEAN
;FIX CHANNEL LOGOUT
;<3.SM10-RELEASE-3>PHYH11.MAC.14, 11-Dec-77 00:28:02, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.13, 11-Dec-77 00:26:21, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.12, 11-Dec-77 00:24:25, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.11, 11-Dec-77 00:02:43, Edit by MCLEAN
;ON ERRORS PUT UBA STATUS IN ERROR LOG
;<3.SM10-RELEASE-3>PHYH11.MAC.10, 22-Nov-77 23:41:39, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.9, 21-Nov-77 23:40:11, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.8, 21-Nov-77 13:57:55, Edit by MCLEAN
;MAKE MULTIPLE UBA'S WORK
;<3.SM10-RELEASE-3>PHYH11.MAC.7, 16-Nov-77 00:24:44, Edit by MCLEAN
;FIX RH2CHK:
;<3.SM10-RELEASE-3>PHYH11.MAC.6, 30-Oct-77 23:34:35, Edit by MCLEAN
;FIX TRE AND MCPE CAUSED BY CONTROL RESET WITH ILLEGAL UNIT SELECTED
;<3.SM10-RELEASE-3>PHYH11.MAC.5, 29-Oct-77 20:18:14, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.4, 29-Oct-77 19:50:05, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.4, 29-Oct-77 19:49:59, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.3, 28-Oct-77 16:45:27, Edit by MCLEAN
;FIX RH2INI FOR NON-EX UNIT 0
;<3.SM10-RELEASE-3>PHYH11.MAC.2, 27-Oct-77 00:36:44, Edit by MCLEAN
;<3.SM10-RELEASE-3>PHYH11.MAC.1, 24-Oct-77 11:06:01, EDIT BY MURPHY
;SEARCH PROKS
;<3-MONITOR>PHYH11.MAC.78, 12-Oct-77 19:20:25, Edit by MCLEAN
;ATNIRB DID NOT SET INTERRUPT ENABLE ON EXIT
;<3-MONITOR>PHYH11.MAC.77, 12-Oct-77 14:06:15, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3
;<3-MONITOR>PHYH11.MAC.76,  5-Oct-77 14:36:17, Edit by MCLEAN
;FIX BUGCHECK AND BUGINF MESSAGES
;<3-MONITOR>PHYH11.MAC.75,  5-Oct-77 14:33:10, Edit by MCLEAN
;MOVE CONTROLLER CLEAR LATER IN CODE AT RH2NXT INITALIZATION
;<3-MONITOR>PHYH11.MAC.74,  2-Oct-77 16:27:55, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.73, 30-Sep-77 13:57:06, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.72, 29-Sep-77 16:10:19, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.71, 29-Sep-77 15:15:06, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.70, 28-Sep-77 01:03:11, Edit by MCLEAN
;ADD CODE IN COMMENTS (TEMP) FOR GREATER THAN 32K ADDRESSES ON UNIBUS
;<3-MONITOR>PHYH11.MAC.69, 28-Sep-77 00:37:31, Edit by MCLEAN
;FIX BUGCHECK MESSAGE
;<3-MONITOR>PHYH11.MAC.68, 28-Sep-77 00:36:27, Edit by MCLEAN
;CHANGES FOR SECOND RH11 AND POSSIBLE ADDITIONAL UNIBUS ADAPTER
;<2BOSACK>PHYH11.MAC.67, 10-Sep-77 20:36:13, EDIT BY BOSACK
;<2BOSACK>PHYH11.MAC.66, 10-Sep-77 20:32:34, EDIT BY BOSACK
;<2BOSACK>PHYH11.MAC.65,  6-Sep-77 11:05:03, EDIT BY BOSACK
;<2BOSACK>PHYH11.MAC.64,  6-Sep-77 01:35:49, EDIT BY BOSACK
;<2BOSACK>PHYH11.MAC.63,  4-Sep-77 00:08:17, EDIT BY BOSACK
;<3-MONITOR>PHYH11.MAC.62, 21-Aug-77 00:20:49, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.61, 21-Aug-77 00:19:13, Edit by MCLEAN
;REMOVE RH1SC FROM RH1ERR
;<SM10-MONITOR>PHYH11.MAC.1, 17-Aug-77 11:53:33, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.59, 12-Aug-77 11:33:03, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.58,  5-Aug-77 01:39:17, Edit by MCLEAN
;<SM10-MONITOR>PHYH11.MAC.57,  3-Aug-77 19:39:39, Edit by MCLEAN
;<SM10-MONITOR>PHYH11.MAC.56,  1-Aug-77 13:50:27, Edit by MCLEAN
;FIX PUSH LOOP IN RDREGE
;<3-MONITOR>PHYH11.MAC.55, 28-Jul-77 00:54:03, Edit by MCLEAN
;REMOVED MONCLR
;<3-MONITOR>PHYH11.MAC.54, 23-Jul-77 22:45:46, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.53, 23-Jul-77 21:38:29, Edit by MCLEAN
;ADD READ MORE THAN ONE PAGE (FORWARD)
;<3-MONITOR>PHYH11.MAC.52, 29-Jun-77 14:49:06, Edit by MCLEAN
;ADDED CALL MONCLR IN XFR:
;<3-MONITOR>PHYH11.MAC.51, 16-Jun-77 14:16:57, Edit by MCLEAN
;ADD CORRECT CONTROLLER TYPE
;<3-MONITOR>PHYH11.MAC.50, 12-Jun-77 00:44:31, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.49, 10-Jun-77 15:40:16, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.48, 10-Jun-77 15:37:23, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.47,  9-Jun-77 23:56:03, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.46,  9-Jun-77 01:15:16, Edit by MCLEAN
;GENERAL FIXES
;<3-MONITOR>PHYH11.MAC.45,  5-Jun-77 02:18:00, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.44,  2-Jun-77 21:34:28, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.43, 29-May-77 02:28:40, Edit by MCLEAN
;INTERRUPT ENABLE FIXES
;<3-MONITOR>PHYH11.MAC.42, 29-May-77 00:48:49, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.41, 23-May-77 21:47:14, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.40, 23-May-77 19:03:33, Edit by MCLEAN
;FIX RDREGX
;<3-MONITOR>PHYH11.MAC.39, 12-May-77 20:45:04, EDIT BY BOSACK
;<3-MONITOR>PHYH11.MAC.38, 12-May-77 17:03:31, EDIT BY BOSACK
;<3-MONITOR>PHYH11.MAC.37, 12-May-77 01:55:21, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.36, 12-May-77 01:52:22, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.35,  4-May-77 01:08:09, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.34,  2-May-77 18:48:49, EDIT BY HURLEY
;<3-MONITOR>PHYH11.MAC.33,  1-May-77 14:01:35, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.32, 25-Apr-77 01:16:31, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.31, 23-Apr-77 15:30:14, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.30, 23-Apr-77 12:44:42, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.29, 22-Apr-77 21:15:35, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.28, 22-Apr-77 18:52:53, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.27, 22-Apr-77 16:50:33, Edit by MCLEAN
;GENERAL FIXES
;<3-MONITOR>PHYH11.MAC.26, 21-Apr-77 21:32:06, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.25, 18-Apr-77 02:37:31, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.24, 18-Apr-77 02:31:28, Edit by MCLEAN
;GENERAL FIXES MOSTLY IN INIT CODE
;<3-MONITOR>PHYH11.MAC.23, 16-Apr-77 16:37:26, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.22, 16-Apr-77 16:10:08, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.21, 15-Apr-77 01:37:57, Edit by MCLEAN
;MORE FIXES
;<3-MONITOR>PHYH11.MAC.20, 15-Apr-77 01:09:03, Edit by MCLEAN
;MANY FIXES TO RH2INI
;<3-MONITOR>PHYH11.MAC.19, 13-Apr-77 01:23:17, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.18,  7-Apr-77 22:37:19, EDIT BY BOSACK
;<3-MONITOR>PHYH11.MAC.17,  7-Apr-77 22:33:47, EDIT BY BOSACK
;<3-MONITOR>PHYH11.MAC.16, 28-Mar-77 22:12:44, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.16, 28-Mar-77 22:12:09, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.15, 28-Mar-77 00:19:54, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.14, 26-Mar-77 20:34:32, Edit by MCLEAN
;CHANGES TO USE RESIDENT FREEPOOL  - MAP CCW LIST ADDRESS IN CHSTRT
;<3-MONITOR>PHYH11.MAC.13,  9-Mar-77 02:05:53, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.12,  9-Mar-77 02:04:05, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.11,  9-Mar-77 01:46:57, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.10,  8-Feb-77 02:26:38, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.9,  7-Feb-77 13:30:05, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.8,  6-Feb-77 21:21:33, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.7,  6-Feb-77 21:20:12, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.6,  6-Feb-77 01:25:17, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.5,  6-Feb-77 01:23:33, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.4,  6-Feb-77 01:22:03, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.3,  6-Feb-77 01:19:03, Edit by MCLEAN
;<3-MONITOR>PHYH11.MAC.2,  6-Feb-77 01:17:33, Edit by MCLEAN
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1977 BY DIGITAL EQUIPMENT CORPORATION

	SEARCH PROLOG		;PARAMETER FILE
	TTITLE (PHYH11,,< - CHANNEL DEPENDENT CODE FOR RH11 CONTROLLER>)
	SUBTTL R. MCLEAN (FROM PHYH2 T. HESS,T. WACHS,L. BOSACK)
	SEARCH PROKS
	SEARCH PHYPAR		;PHYSIO PARAMETERS

	SUBTTL PARAMETERS

; DEVICE EPENDENT STUFF


;DEVICE INDEPENDENT REGISTERS

DO.AS==4B5			;ATTENTION SUMMARY REGISTER
DO.DA==5B5			;DESIRED ADDRESS REGISTER
DO.DT==6B5			;DRIVE TYPE REGISTER

DO.LR==1B6			;LOAD REGISTER ENABLE
DO.DRE==1B9			;DISABLE RAE STOP

;DEVICE DEPENDENT DEFINITIONS IN THE CDB

RC1CS1==CDBDDP+0		;CONTROL STATUS 1
RC1DS==CDBDDP+1			;DRIVE STATUS REGISTER
RC1ER1==CDBDDP+2		;ERROR REGISTER 1
RC1MR==CDBDDP+3			;MAINT REGISTER
RC1AS==CDBDDP+4			;ATTENTION SUMMARY REGISTER
RC1DA==CDBDDP+5			;DESIRED ADDRESS REGISTER
RC1DT==CDBDDP+6			;DRIVE TYPE REGISTER
RC1LA==CDBDDP+7			;LOOK AHEAD REGISTER
RC1SN==CDBDDP+10		;SERIAL NUMBER REGISTER
RC1OF==CDBDDP+11		;OFFSET REGISTER
RC1DC==CDBDDP+12		;DESIRED CYL REGISTER
RC1CA==CDBDDP+13		;CURRENT CYL REGISTER
RC1ER2==CDBDDP+14		;ERROR REGISTER 2
RC1ER3==CDBDDP+15		;ERROR REGISTER 3
RC1EC1==CDBDDP+16		;ECC REGISTER 1
RC1EC2==CDBDDP+17		;ECC REGISTER 2
RC1WC==CDBDDP+20		;WORD COUNT REGISTER
RC1BA==CDBDDP+21		;CURRENT ADDRESS REGISTER
RC1CS2==CDBDDP+22		;CONTROL AND STATUS REGISTER 2
RC1CNT==23			;COUNT OF ABOVE REGISTERS
UBADSW==CDBDDP+23		;UNIBUS STATUS REGISTER ADDRESS
UBBASA==CDBDDP+24		;UNIBUS BUS ADDRESS BASE ADDRESS

L.RH2==CDBDDP+RC1CNT-CDBINT+2	;LENGTH OF RH11 CDB

CHXFR==1B0			;INDICATE XFER WORD
CHJMP==1B1			;INDICATE CHANNEL JUMP
CHLST==1B1			;INDICATE LAST XFER
CHREV==1B2			;INDICATE REVERSE

CCYADR:	POINT 22,T1,35		;BYTE POINTER TO CCW ADDRESS FIELD
CCYCNT:	POINT 11,T1,13		;BYTE POINTER TO CCW COUNT FIELD

;BITS IN CHANNEL LOGOUT AREA

CS1MPE==1B1			;MEMORY PARITY ERROR
CS1NSE==1B2			;NEGATION OF SBUS ERR
CS1NC0==1B3			;NEGATION OF WORDCOUNT = 0
CS1NXM==1B4			;NONEXISTANT MEMORY
CS1LTE==1B9			;LAST TRANSFER ERROR
CS1RHE==1B10			;RH11 ERROR
CS1LWC==1B11			;LONG WORD COUNT (RH11 FINISHED BEFORE CHANNEL)
CS1SWC==1B12			;SHORT WORD COUNT (CHANNEL FINISHED BEFORE RH11)
CS1OVR==1B13			;OVERRUN (MBOX BUFFER)

;SOFTWARE FLAGS IN FUNCTION (USED BY CHSTRT)
ERETRY==200
RQDUBW==MAXPPB			;NUMBER OF UNIBUS WINDOWS TO ALLOCATE
;RH11 CHANNEL STATUS BITS


;STATUS BITS IN CONTROL AND STATUS 1
RH1SC==1B20		;SPECIAL CONDITION
RH1TRE==1B21		;TRANSFER ERROR
RH1CPE==1B22		;MASS I/O CONTROL PARITY ERROR
RH1PSL==1B25		;PORT SELECT
RH1UAD==3B27		;UNIBUS ADDRESS EXTENSION BITS
RH1RDY==1B28		;READY
RH1IE==1B29		;INTERRUPT ENABLE
RH1ERR==RH1TRE!RH1CPE 	;BITS THAT CAUSE ERRORS

;STATUS BITS IN CONTROL AND STATUS 2

RH1DLT==1B20		;DATA LATE
RH1WCE==1B21		;WRITE CHECK ERROR
RH1PE==1B22		;PARITY ERROR
RH1NED==1B23		;NON EXISTENT DISK
RH1NEM==1B24		;NON EX MEMORY
RH1PGE==1B25		;PROGRAM ERROR
RH1MXF==1B26		;MISSED TRANSFER
RH1MDP==1B27		;MASS BUS PARITY ERROR
RH1CLR==1B30		;CONTROLLER CLEAR (ALSO CLEARS DRIVES)
RH1UNI==7B35		;UNIT SELECT BITS

; ERROR REGISTER 1 DEFINITIONS

ER.CPE==1B32			;CONTROL BUS PARITY ERROR
ER.FCE=1B26			;FRAME COUNT ERROR

RHOFF:	BYTE (6)0,12,14,24,16,6
	BYTE (6)26,20,30,32,34,36
	BYTE (6)40,42,44,46,2,4
	BYTE (6)10


; CHANNEL ADDRESS TABLE

RH1CTB:	RH11CA			;ADDRESS OF CHANNEL 0
	RH21CA			;ADDRESS OF CHANNEL 1
RH1CTZ==.-RH1CTB		;SIZE OF RH11 CHANNEL TABLE

RH1IVT:	RH11IV/4		;UNIBUS ADAPTER #,,INTERRUPT VECTOR ADDRESS CHANNEL 0
	RH21IV/4		;UNIBUS ADAPTER #,,INTERRUPT VECTOR ADDRESS CHANNEL 1
;CHANNEL DISPATCH TABLE FOR RH11

RH2DSP::JRST RH2INI		;0 - INITIATION
	RET			;1 - STACK CHAN COMMAND - RETURN FAILURE ON RH11
	JRST RH2SIO		;2 - START I/O
	JRST RH2POS		;3 - POSITION REQUEST
	JRST RH2LTM		;4 - RETURN BEST XFER
	JRST RH2INT		;5 - INTERRUPT PROCESSING
	JRST RH2CCW		;6 - MAKE CHANNEL XFER WORD
	JRST RH2HNG		;7 - TRANSFER HUNG
	JRST RH2RST		;10 - RESET CHANNEL
	JRST RH2CHK		;11 - PERIODIC CHECK

;DUMMIES

RH2LTM:	RET
	SUBTTL INITIALIZATION

RH2INI:	MOVE Q1,RH1CTB		;GET CHANNEL ADDRESS
	PUSH P,[0]		;SAVE ON PDL
RH2NCH:	MOVE T1,Q1		;GET ADDRESS OF DEVICE
	CALL UBGOOD		;CHECK TO SEE IF IT EXISTS
	JRST RH2NOU		;NOT HERE FORGET IT
	MOVEI T1,L.RH2		;GET LENGTH OF CDB
	CALL PHYALC		;ALLOCATE SOME STORAGE
	JRST PA1		;FAILURE QUIT INITALIZATION
	MOVEI P1,-CDBINT(T1)	;CDB BASE ADDRESS TO P1
	MOVEM P1,CHNTAB(P4)	;SAVE CDB IN CHANNEL TABLE
	HRRZM P4,CDBADR(P1)	;STORE CHNTAB INDEX
	AOS P4			;ADVANCE TO NEXT
	MOVE T2,0(P)		;FIND CHANNEL NUMBER
	HLRZ T1,RH1CTB(T2)	;GET UNIBUS ADAPTER NUMBER
	MOVEI T2,RQDUBW		;NEED WINDOWS
	CALL ALUBWA		;ALLOCATE WINDOW
	BUG(HLT,NOUBWA,<RH2NCH: NO UNIBUS WINDOW FOR RH11>)
	MOVEM T1,UBADSW(P1)	;SAVE ADDRESSES
	MOVEM T2,UBBASA(P1)	;SAVE UNIBUS BASE ADDRESS
	MOVEI T1,.CTRH3		;SET TYPE
	DPB T1,CSYTYP		;..
	MOVEI T4,RC1CS1(P1)	;START THE SAVE OF ADDRESSES
	MOVNI T1,RC1CNT		;GET SIZE OF TABLE
	MOVE T2,[POINT 6,RHOFF] ;GET ADDRESS TABLE
RH11DL:	ILDB T3,T2		;FIND THE OFFSET
	ADD T3,Q1		;CREATE AN ADDRESS
	MOVEM T3,0(T4)		;STORE IN CDB
	AOS T4			;POINT TO NEXT
	AOJL T1,RH11DL		;DO ALL REGISTERS
	MOVEI T3,CDBINT(P1)	;ADDRESS FOR XPCW ON INTERRUPT
	HRLI T3,(<XPCW>)	;BUILD INSTRUCTION
	MOVE T1,0(P)		;GET CHANNEL NUMBER
	HLRZ T2,RH1CTB(T1)
	HRRZ T1,RH1IVT(T1)	;GET VECTOR
	ADD T1,SMTEPT(T2)	;AND TABLE ADDRESS
	MOVEM T3,0(T1)		;STORE XPCW IN INTERRUPT VECTOR LOCATION
	MOVEI T3,CDBINT+4(P1)	;SET JUMP ADDRESS
	MOVEM T3,CDBINT+3(P1)	;SET IN XFER VECTOR
	SETZM CDBINT+2(P1)	;SET FLAGS TO 0
	MOVEI T1,KIEPT		;ADDRESS OF CHANNEL ICP AREA
	HRRM T1,CDBICP(P1)	;STASH IN CDB
; ...
	MOVE T1,[MOVEM P1,CDBSVQ]
	ADDI T1,0(P1)		;INSTRUCTION TO STORE P1 IN CDB
	MOVEM T1,CDBINT+4(P1)	;BUILD INTERRUPT CODE
	MOVE T1,[JSP P1,PHYINT]
	MOVEM T1,CDBINT+5(P1)	;DISPATCH TO PHYSIO
	MOVE T1,[BLT 17,17]	;INSTRUCTION TO RESTORE ACCUMULATORS
	MOVEM T1,CDBJEN(P1)	;PUT IN CDB
	MOVEI T1,CDBRST(P1)	;BUILD DATAO CDBRST, TO RESET THE
	MOVEI T1,CDBINT(P1)	;ADDRESS OF INTERRUPT PC
	HRLI T1,(<XJEN 0>)	;BUILD XJEN INSTRUCTION
	MOVEM T1,CDBJEN+1(P1)	;STORE
	MOVEI T1,RH2DSP		;INSERT DISPATCH VECTOR
	MOVEM T1,CDBDSP(P1)	;SET UP DISPATCH
				;NOW FIND UNITS & TYPES
	MOVE Q3,[-MAXRH,,CDBUDB] ;AOBJN POINTER TO UDB TABLE
	ADDI Q3,0(P1)		;RELOCATE POINTER
	MOVEM Q3,CDBCUN(P1)	;STORE IN CDB
	MOVEM Q3,CDBIUN(P1)	;...
	SETOM CDBXFR(P1)	;INDICATE CHANNEL FREE
	MOVEI Q2,0		;FIRST UNIT #
RH2UNL:	MOVEI T2,RH1CLR		;RESET CONTROLLER ERRORS
	WRIO T2,@RC1CS2(P1)
	MOVEI P3,0		;IN CASE NOT WANTED
	WRIO Q2,@RC1CS2(P1)	;SET UNIT NUMBER
	MOVEI T1,1		;ISSUE A NOP TO GET NED
	WRIO T1,@RC1CS1(P1)
	RDIO T1,@RC1CS2(P1)	;CHECK FOR ERROR
	TRNE T1,RH1NED		;NON EX DEVICE?
	JRST RH2NXU		;YES, NEXT UNIT
	CALL RH2UNS		;SELECT A UNIT
RH2NXU:	MOVEM P3,0(Q3)		;STORE IN CDB IF ANY (0 IF NONE)
	AOS Q2			;NEXT UNIT #
	AOBJN Q3,RH2UNL		;KEEP GOING
	MOVE T1,CDBIUN(P1)	;CHECK IF ANY DEVICES FOUND.
	SETOM CDBXFR(P1)	;SET NO TRANSFER IN PROGRESS
	SETZ T2,0		;UNIT 0
RH2CKU:	SKIPE (T1)		;UNIT PRESENT?
	JRST RH2NXT		;YES, GO ON TO NEXT CHANNEL
	AOS T2			;NEXT UNIT NUMBER IN CLEAR REQUEST
	AOBJN T1,RH2CKU		;NO, LOOP FOR MORE
	MOVSI T1,(CS.OFL)	;NONE PRESENT, MARK OFFLINE.
	IORM T1,CDBSTS(P1)	; ...
	JRST RH2NOU		;NO UNIT FOUND
;THE FOLLOWING SEQUENCE IS REQUIRED BECAUSE THE RH11 REQUIRES
;THAT A CLEAR INSTRUCTION BE FOLLOWED IMMEDIATELY BY A SELECTION
;OF AN EXISTANT UNIT NUMBER OTHERWISE ANY ATTEMPT TO ACCESS
;A REGISTER THAT IS NOT IN THE RH (CS1) WILL CAUSE
;MASSBUS PARITY ERRORS.

RH2NXT:	MOVEI T1,RH1CLR		;CLEAR RH11
	WRIO T1,@RC1CS2(P1)	;ISSUE CLEAR
	WRIO T2,@RC1CS2(P1)	;CLEAR CONTROLLER
	MOVEI T1,RH1IE+RH1TRE	;RESET AND ENABLE INTERRUPTS
	WRIO T1,@RC1CS1(P1)
RH2NOU:	AOS Q1,0(P)		;LOOK AT NEXT AND RESTORE DEVICE CODE
	CAIL Q1,RH1CTZ		;BEYOND LAST?
	JRST PA1		;PRUNE AND EXIT
	MOVE Q1,RH1CTB(Q1)	;GET NEXT CHANNEL ADDRESS
	JRST RH2NCH		;TRY NEXT


; ROUTINE TO DETERMINE THE SPECIFIC UNIT TYPES AND
; REQUEST KDB AND UDB POINTERS BE SET UP



RH2UNS:	RDIO T1,@RC1DT(P1)	;GET DRIVE TYPE
	LDB T1,[POINT 9,T1,35]	;GET DEVICE TYPE CODE
	CAIG T1,TY.RPH		;WITHING RP04,5,6 RANGE?
	CAIGE T1,TY.RPL		; ??
	SKIPA			;NO
	JRST RH2IRP		;YES - INITIALIZE IT
	CAIN T1,TY.RS4		;RS04 TYPE?
	JRST RH2IRS		;YES - INITIALIZE IT
	CAIN T1,TY.DX2		;DX20 TYPE?
	JRST RH2IDX		;YES, INITIALIZE IT
	CAIG T1,TY.T3H		;WITHIN TM03 RANGE?
	CAIGE T1,TY.T3L		;
	SKIPA			;NO
	JRST RH2ITM		;YES
	CAIG T1,TY.T2H		;GREATER THAN HIGHEST TM02 TYPE
	CAIGE T1,TY.T2L		;OR LOWER THAN LOWEST?
	RET			;YES - NOT TM02
	JRST RH2ITM		;IS TM02 - GO INITIALIZE
;ROUTINE TO INVOKE RP04/RS04 INITIATION

RH2IRS:	SKIPA T1,[.UTRS4]	;RS04 TYPE
RH2IRP:	MOVEI T1,.UTRP4		;RP04 TYPE
	CALL FNDUTP		;FIND TABLE ENTRY
	 CALL UDSINI(T1)	;CALL INITIALIZE IF FOUND
	RET			;ADVANCE TO NEXT UNIT

;HERE TO INITIALIZE A DX20

RH2IDX:	MOVX T1,.UTDX2		;SEARCH FOR
	JRST RH2ITD		; A DX20

;HERE TO INITIALIZE A TM02

RH2ITM:	MOVEI T1,.UTTM2		;SEARCH FOR TM02
RH2ITD:	MOVEI P2,0		;IN CASE NOT FOUND IN TABLES
	CALL FNDUTP		; ...
	 CALL UDSINI(T1)	;FOUND - CALL INITIALIZE, RETURN KDB IN P2
	MOVE P3,P2		;COPY KDB TO WHERE COMMON CODE WANTS IT
	RET			;LOOP FOR MORE

;ROUTINE TO SCAN CHANNEL/UNIT TABLES FOR TYPE GIVEN IN T1
;RETURNS TABLE ENTRY IN T1 (SKIP RETURN ON NOT FOUND)

FNDUTP:	MOVE T2,[PHYUNL,,PHYUNT] ;ENTRY FOR UNIT TABLE
FNDTPL:	HLRZ T3,0(T2)		;GET LH = TYPE CODE
	CAME T1,T3		;TYPES MATCH?
	AOBJN T2,FNDTPL		;NO - TRY NEXT
	JUMPGE T2,RSKP		;SKIP RETURN IF NO MATCH
	HRRZ T1,0(T2)		;MATCH - GET DISPATCH ADDRESS
	RET			;RETURN
	SUBTTL START I/O AND POSITIONING

;HERE TO START POSITIONING (P3 := UDB)

RH2POS:	HRRZ T1,UDBDSP(P3)	;ADDRESS OF DEVICE ROUTINE
	JRST UDSPOS(T1)		;START IT

;HERE TO START ACTUAL OPERATION (P3 := UDB , P4 := IORB)

RH2SIO:	HRRZ T1,UDBDSP(P3)	;DISPATCH TO DEVICE CODE
	CALL UDSSIO(T1)		;ATTEMPT TO START IO
	 JRST CLRCHL		;LOSE
	RETSKP			;WIN
	SUBTTL HUNG, RESET AND CHECK ENTRIES
;HERE ON A HUNG TRANSFER
;CALLED WITH PI OFF

RH2HNG:	CALL CLRRAE		;CLEAR POSSIBLE RAE
	MOVEI T1,RH1CLR		;CLEAR RH11
	WRIO T1,@RC1CS2(P1)
	WRIO T2,@RC1CS2(P1)
	CALLRET CLRCHL		;AND RESET CHANNEL

;HERE TO RESET THE CHANNEL AND ALL UNITS
;T1/ 0 TO RESET JUST THE CHANNEL
;T1/ 1 FOR FULL RESET

RH2RST:	JUMPE T1,CLRCHL		;SIMPLE RESET
	JRST RH2HNG


;HERE EVERY NOW AND THEN (ABOUT 1 SEC) TO CHECK PIA.

RH2CHK:	MOVSI T1,(CS.OFL)	;CHECK FOR OFF LINE
	TDNE T1,CDBSTS(P1)
	RET			;OFF LINE IGNORE THIS REQUEST
	MOVEI T1,RH1IE		;CHECK FOR INTERRUPT ENABLE
	TIOE T1,@RC1CS1(P1)	;ON?
	RET			;YES ALL OK
	BUG(CHK,PH1PIE,<PHYH11 - RH11 LOST INTERRUPT ENABLE>)
	BSIO T1,@RC1CS1(P1)	;SET INTERRUPT ENABLE (THIS WILL CAUSE IMMEDIATE INTERRUPT!)
	RET
	SUBTTL CHANNEL UTILITY ROUTINES

;ROUTINE TO READ A MASS-BUSS REGISTER
;CALL - C(T2) := REGISTER TO BE READ
;	C(P3) := UDB POINTER
;	C(P1) := CDB POINTER
;RETURNS VALUE IN T1 , PRESERVES T4

RDREG::	HRRZ T3,UDBAKA(P3)	;GET UNIT #
	SKIPL T2		;INTERNAL REGISTER?
	TLO T2,(DO.DRE)		;NO - TRY FIRST WITH DRAES ON
	TLOA T2,(T3)		;SET UNIT NUMBER
RDREG3::TLO T2,<(DO.DRE)>(Q2)	;UNIT # IN Q2
	LDB T1,[POINT 3,T2,17]	;GET THE UNIT NUMBER
	WRIO T1,@RC1CS2(P1)	;SET THE UNIT NUMBER
RDREGX:	MOVEI T3,^D10		;INITIALIZE RETRY COUNTER
RDREGL:	LDB T1,[POINT 6,T2,5]	;GET THE REGISTER NUMBER
	ADD T1,P1		;POINT TO REGISTER ADDRESS
	RDIO T1,@RC1CS1(T1)	;READ REGISTER
	PUSH P,T1		;SAVE RESULT
	RDIO T1,@RC1CS2(P1)	;CHECK FOR DRIVE
	TRNE T1,RH1NED		;NON EX DISK?
	JRST RDRAE		;YES - BAD NEWS
RDRAE1:
	RDIO T1,@RC1CS1(P1)	;READ STATUS REGISTER
	TRNE T1,RH1CPE		;CONTROL BUS PAR ERR?
	JRST RDREGE		;YES - ERROR
RDEXIT:	POP P,T1		;RSTORE RESULT
	ANDI T1,177777		; CLEAR OUT GARBAGE
	RET			;EXIT

;HERE WHEN CBPE OR MISSING TRA

RDREGE:	SOJG T3,RDREGA		;LOOP IF RETRY STILL POSITIVE
	TLZ T2,(DO.DRE)		;TRY ONE MORE TIME - IF RAE, BOMB WORLD
	JUMPL T3,RDEXIT		;IF NOW NEGATIVE, DEPART, TRAGIC ERROR
RDREGA:	POP P,T1		;RESTORE REGISTER
	JRST RDREGL		;TRY AGAIN

;HERE WHEN A REGISTER ACCESS ERROR IS DETECTED

RDRAE:	PUSH P,T2		;SAVE ANOTHER REGISTER
	TLNE T2,(DO.DRE)	;DRAES?
	JRST RDRAE2		;YES - JUST CLEAR RAE
	BUG(CHK,P1NED1,<PHYH11 - RH11 NON EX DISK READING REGISTER>,<T1,T2>)
	CALL CLRRAE		;RESET RAE
	POP P,T2		;RESTORE REGISTERS
	JRST RDEXIT		;ALL WE COULD DO...

RDRAE2:	CALL CLRRAE		;CLEAR ERROR
	POP P,T2
	JRST RDRAE1		;CONTINUE ATTEMPT
;ROUTINE TO WRITE A MASS-BUSS REGISTER
;CALL - C(T2) := REGISTER TO BE WRITTEN & DATA
;	C(P1) := CDB , C(P3) := UDB
;PRESERVES T1,T4

WTREG::	HRRZ T3,UDBAKA(P3)	;GET UNIT #
	TLOA T2,(T3)		;SET IN LHS AND LR ENABLE
WTREG3::TLO T2,(Q2)		;SET LR AND UNIT NUMBER FROM Q2
	PUSH P,T1		;SAVE A REGISTER
	HLRZ T1,T2
	ANDI T1,7		;MAKE UNIT NUMBER
	WRIO T1,@RC1CS2(P1)	;SET UNIT NUMBER
	SKIPA
WTREGX:				;WRITE A REGISTER WHEN THE DRIVE NUMBER DOESNT MATTER
	PUSH P,T1		;SAVE REGISTER
	LDB T1,[POINT 6,T2,5]	;GET THE COMMAND NUMBER
	SKIPN T1		;SET INTERRUPT ENABLE IF REGISTER 0
	IORI T2,RH1IE
	ADD T1,P1		;FIND ADDRESS OF REGISTER
	WRIO T2,@RC1CS1(T1)	;WRITE THE REGISTER
	RDIO T1,@RC1CS1(P1)	;READ THE STATUS BACK
	TRNE T1,RH1NED		;NON EX DISK?
	JRST WTRAE		;YES - BAD NEWS
	RDIO T1,@RC1ER1(P1)	;CHECK FOR CONTROL BUS PARITY ERRORS
	TRNE T1,ER.CPE		;YES?
	BUG(CHK,P11PAR,<PHYH11 -- CONTROL WRITE PARITY ERR>,<T1,T2>)
	POP P,T1		;NO - RESTORE REGISTER
	RET			;RETURN

;HERE WHEN NED ON WRITE

WTRAE:	PUSH P,T3		;SAVE REGISTER
	RDIO T3,@RC1CS1(P1)
	BUG(CHK,P2RAE2,<PHYH11 - REGISTER ACCESS ERR WRITING REG>,<T1,T2,T3>)
	MOVE T3,T2		;SAVE ATTEMPTED REGISTER
	CALL CLRRAE		;CLEAR RAE
	MOVE T2,T3		;RESTORE
	POP P,T3		;RESTORE
	POP P,T1
	RET

;HERE TO CLEAR RAE

CLRRAE:	SETZ T2,0		;STOP CURRENT TRANSFER
	MOVE T1,CDBIUN(P1)	;GET UNIT TABLE
NOTQUI:	MOVEI T4,RH1CLR		;CLEAR RH
	WRIO T4,@RC1CS2(P1)
	WRIO T2,@RC1CS2(P1)	;WRITE UNIT NUMBER
	AOBJN T1,CLRRA1		;TRY NEXT SLOT
	BUG(HLT,CLRACE,UNABLE TO CLEAR REGISTER ACCESS ERROR)
CLRRA1:	RDIO T4,@RC1CS1(P1)	;FORCE AN ERROR BY GOING TO DRIVE
	MOVEI T4,RH1NED		;CHECK TO SEE IF IT IS STILL THERE
	TIOE T4,@RC1CS2(P1)
	AOJA T2,NOTQUI		;NOT QUITE THIS ONE DISAPPEARED
	MOVEI T2,RH1TRE!RH1IE	;CLEAR CONTROLLER ONLY
	WRIO T2,@RC1CS1(P1)	;CLEAR
	RET
;ROUTINE TO CLEAR RH20 CONTROLLER

CLRCHL::
ZAPCHL::MOVEI T1,RH1TRE!RH1IE	;RESET INTERRUPTING BITS
	WRIO T1,@RC1CS1(P1)
	RET			;RETURN
;ROUTINE TO START CHANNEL I/O
;CALLED WITH PI OFF
;C(T2) := DATAO , C(Q1) := FUNCTION , C(P3) := UDB POINTER
;GIVES SKIP RETURN TO SHOW ALL OK

CHSTRT::SKIPE T2		;CHECK FOR VALID OPS
	SKIPN Q1		; ...
	BUG(HLT,RH1ICF,<PHYH11 - INVALID CHANNEL FUNCTION>)
	HRRZ T1,UDBAKA(P3)	;GET UNIT NUMBER
	WRIO T1,@RC1CS2(P1)	;SET UNIT NUMBER SELECT
	CAIGE Q1,50		;DATA TRANSFER OPERATION?
	JRST CHST1		;NO
	SETOM CDBCNI(P1)	;INDICATE NOW DOING DATA XFER OPERATION
	PUSH P,T2		;SAVE DATAO
	PUSH P,UBADSW(P1)	;SAVE ADDRESS OF UNIBUS WINDOW
	PUSH P,UBBASA(P1)	;SAVE PDP11 ADDRESS
	PUSH P,Q2		;SAVE ANOTHER REGISTER
	MOVSI T2,(CS.ACL)	;TOGGLE  CCW LIST
	XORM T2,CDBSTS(P1)
	MOVEI T1,CDBCCL(P1)	;YES - DO SETUP
	MOVEI T2,CDBCCL+1(P1)
	TRZN Q1,ERETRY		;ECC RETRY?
	CALL PHYXFL		;NO - GET HEAD OF TRANSFER LIST
	MOVE T4,T1		;SAVE VIRTUAL ADDRESS
	MAP T1,(T1)		;GET PHYSICAL ADDRESS
	TLZ T1,777760		;FLUSH ACCESS BITS ETC
	TLO T1,(CHJMP)		;BUILD CHANNEL JUMP
	HRRZ T3,CDBICP(P1)	;AND STORE IN
	MOVEM T1,(T3)		;CHANNEL ICPC
	SETZM 1(T3)		;CLEAR CS1
	MOVE T1,0(T4)		;SET UP THE ADDRESS DEPENDENT REGISTERS
	MOVEM T1,2(T3)		;SAVE INITIAL CCW
	MOVSI T3,(CHLST)	;SET LAST TRANSFER
	IORM T3,-1(T2)		;IN CCW LIST
	SETZ Q2,0		;SET BYTE COUNT TO 0
	TLNE T1,(CHREV)		;CHECK FOR REVERSE READ
	JRST [	MOVEI T2,<RQDUBW-1>*4000+2 ;FIND END OF ADDRESS SPACE
		ADDM T2,UBBASA(P1) ;UPDATE POINTER
		MOVEI T2,RQDUBW-1 ;ALSO WINDOW POINTER
		ADDM T2,UBADSW(P1)
		JRST .+1]
	LDB T2,CCYADR		;FIND THE CURRENT ADDRESS
	ANDI T2,777		;FIND A UNIBUS ADDRESS
	LSH T2,2		;MAKE INTO UNIBUS ADDRESS
	ADD T2,UBBASA(P1)	;GET THE UNIBUS OFFSET
	WRIO T2,@RC1BA(P1)	;SET THE BUS ADDRESS
	LSH T2,-^D8		;MOVE HIGH ORDER ADDRESS BITS TO CONTROL
	ANDI T2,1400		;CORRECT POS FOR CONTROL STATUS REG
	IORM T2,Q1		;STORE IN COMMAND REGISTER WORD
CHSLP:	MOVE T1,0(T4)		;GET CHANNEL COMMAND
	LDB T2,CCYCNT		;GET THE COUNT
	MOVNS T2		;SET TO NEGATIVE
	LSH T2,1		;MAKE PDP11 WORD COUNT
	ADD Q2,T2		;UPDATE WORD COUNT
	LDB T2,CCYADR		;GET REST OF ADDRESS
	SKIPN T2
	BUG(HLT,RH11CC,<PHYH11 - ILLEGAL CHANNEL COMMAND WORD>)
	LSH T2,-^D9		;GET PAGE NUMBER
	MOVSI T3,(US.TAP)	;MAGTAPE?
	TDNE T3,UDBSTS(P3)
	JRST [	TLNE T1,(CHREV)	;YES CHECK FOR READ/REVERSE
		TROA T2,UNBVBT!UNBRPW ;SET READ/PAUSE WRITE
		TRO T2,UNBVBT	;NOT BACKWARDS ONLY VALID BIT
		JRST .+2]
	TRO T2,UNBVBT!UNB36B	;SET 36BIT TRANSFER AND VALID
	WRIO T2,@UBADSW(P1)	;WRITE THE UNIBUS STATUS REGISTER
	TLNE T1,(CHREV)		;REVERSE?
	SOSA UBADSW(P1)		;YES DOWN COUNT
	AOS UBADSW(P1)		;POINT TO THE NEXT UNIBUS WINDOW
	TLNN T1,(CHLST)		;LAST?
	AOJA T4,CHSLP		;NO -- DO NEXT WINDOW
	WRIO Q2,@RC1WC(P1)	;YES -- WRITE WORD COUNTER
	POP P,Q2		;RESTORE
	POP P,UBBASA(P1)	;RESTORE PDP11 ADDRESS
	POP P,UBADSW(P1)
	POP P,T2		;RECOVER DATAO

CHST1:	CALL WTREG		;WRITE REGISTER
	MOVEM Q1,CDBICR(P1)	;SAVE INITIAL TCR FOR LOGGER
	MOVE T2,Q1		;GET CONTROL REGISTER
	CALL WTREG		;WRITE AND START WORLD
	RETSKP			;INDICATE SUCCESS
;ROUTINE TO GENERATE A CHANNEL XFER WORD FOR THE RH11
;CALL - C(T1) := MODE,,+COUNT(1B0 IF BACKWARDS) , C(T2) := PHYSICAL-ADDRESS
;RETURNS+1(ALWAYS):
;T1/ CCW FOR THIS TRANSFER
;NOTE: THE MAXIMUM TRANSFER WHICH WILL ALWAYS WORK IS 1 PAGE.
;	THE CALLER IS EXPECTED TO WORRY ABOUT PAGE CROSSING PROBLEMS

RH2CCW:	PUSH P,T1		;SAVE ARGUMENT
	HRRZ T3,T1		;GET WORD COUNT
	HLRZS T1		;GET MODE IN CORRECT PLACE
	TRZ T1,(1B0)		;CLEAR BACKWARDS BIT FROM MODE
	CAIN T1,IRMWRD		;CHECK FOR WORD MODE
	JRST RH2CW1		;YES SKIP JUNK
	SKIPLE T1		;CHECK MODE FOR LEGALITY
	CAILE T1,IRMMAX		; ...
	JRST [	BUG(CHK,PH1IHM,<PHYH11 - ILLEGAL HDW MODE - WORD MODE ASSUMED>)
		MOVEI T1,IRMWRD	;ASSUME WORD MODE
		JRST .+1]
	IDIV T3,MODTAB(T1)	;CONVERT TO WORDS
	SKIPE T4		;ROUND?
	AOS T3			;YES
RH2CW1:	POP P,T4		;GET ARGUMENT BACK
	MOVSI T1,(CHXFR)	;BUILD CCW
	DPB T3,CCYCNT		;STORE COUNT IN T1
	DPB T2,CCYADR		;STORE ADDRESS IN T1
	SKIPGE T4		;BACKWARDS?
	TLO T1,(CHREV)		;YES
	RET			;RETURN
;ROUTINE TO DETERMINE IF ANY CHANNEL DEPENDENT ERROR OCCURED
;RETURN +1 IF ERROR , +2 IF NONE

CKERR::	RDIO T1,@RC1CS1(P1)	;GET RH11 STATUS
	ANDI T1,RH1ERR		;SEE IF ERRORS IN CONI
	LDB T3,USYTYP		;CHECK FOR MT
	CAIE T3,.UTT45
	JRST CKERR2		;NO -- DON'T CHECK FOR FCE
	MOVEI T3,ER.FCE		;CHECK FOR FRAME COUNT ERROR
	TIOE T3,@RC1ER1(P1)	;CHECK REGISTER
	JRST CKERR3		;YES -- BUT IT IS OK
CKERR2:	SKIPGE CDBXFR(P1)	;DATA TRANSFER?
	JRST [	JUMPN T1,CKERR1	;NO - CONI ERRORS
		RETSKP]		;NO TO BOTH, RETURN GOOD
	SKIPE T1		;DATA TRANSFER, CHECK CONI ERRORS
	CALL CKERR1		;YES - FLAG AND DO CHANNEL CHECKS
CKERR3:	HRRZ T1,CDBICP(P1)	;NONE IN CONI, CHECK CHANNEL
	SKIPN T1,1(T1)		;GET STATUS WORD 1
	JRST CKERR1		;NOT STORED, CALL IT AN ERROR
	TLNE T1,(CS1MPE!CS1NXM!CS1RHE!CS1OVR) ;OR OTHER DEFINITE ERRORS?
	JRST [	TLNE T1,(CS1MPE) ;A PARITY ERROR?
		AOS CDBPAR(P1)	;YES - NOTE
		TLNE T1,(CS1NXM) ;NONEXISTANT MEMORY?
		AOS CDBNXM(P1)	;YES - NOTE
		TLNE T1,(CS1OVR) ;AN OVERRUN?
		AOS CDBOVR(P1)	;YES - NOTE
		CALL CKERR1	;INDICATE SOME ERROR HAPPENED
		JRST .+1]	;AND CONTINUE WITH LENGTH ANALYSIS
	MOVSI T2,(CS1LWC!CS1SWC) ;WORD COUNT ERROR BITS
	MOVSI T3,(US.TAP)	;MAGTAPE?
	TDNN T3,UDBSTS(P3)
	TLNN T1,(CS1LWC)	;CHECK FOR LONG WORD COUNT
	JRST CKERR4		;NO CHECK FOR ERROR RETURN
	MOVSI T1,(IS.RTL)	;FLAG LENGTH ERROR IN IORB
	IORM T1,IRBSTS(P4)	; ...
CKERR1:	MOVSI T1,(IS.DVE)	;DECLARE A DEVICE ERROR
	IORM T1,IRBSTS(P4)	; ...
	RET

CKERR4:	MOVSI T1,(IS.DVE)	;ERROR SET?
	TDNE T1,IRBSTS(P4)
	RET			;YES RETURN BAD
	RETSKP			;NOPE ALL GOOD
;ROUTINE TO GET CONI AND DATAI'S ON ERROR
;RETURNS T1=RC1CS1, T2=RC1CS2  T3=UBA MAP REGISTER,,UBA STATUS
ERRCNI::HRRZ T1,CDBICP(P1)	;GET CHANNEL LOGOUT AREA
	DMOVE T2,(T1)		; CS0,1
	DMOVEM T2,CDBCS0(P1)	;SAVE
	MOVE T2,2(T1)		;GET CS2
	MOVEM T2,CDBCS2(P1)	;SAVE
	MOVE T1,(T1)		;GET ICCW
	TLNE T1,(CHXFR)		;IF NOT JUMP,
	JRST ERCNI1		;DON'T TRY FOR CCWS
	LDB T1,CCYADR		;GET ADDRESS PART OF JUMP
	LSH T1,-PGSFT		;AS A PAGE
	PIOFF			;INTERLOCK WINDOW
	CALL MAPRCA		;MAP THIS PAGE
	HRRZ T2,CDBICP(P1)	;GET CHAN BLOCK AGAIN
	MOVE T3,(T2)		;GET JUMP CCW BACK
	ANDI T3,777		;GET ADDRESS WITHIN PAGE
	ADD T3,T1		;GET INDEX INTO WINDOW PAGE
	MOVE T4,(T3)		;GET FIRST POSSIBLE CCW
	MOVEM T4,CDBCC1(P1)	;SAVE IN CDB
	ADDI T3,1		;INCREMENT POINTER
	MOVEI T4,0		;DONT STORE GARBAGE IF OVERFLOW
	TRNE T3,777		;STILL WITHIN WINDOW BOUND?
	MOVE T4,(T3)		;YES - FETCH SECOND POSSIBLE CCW
	MOVEM T4,CDBCC1+1(P1)	;SAVE IN CDB
	CALL UNMRCA		;FREE WINDOW
	PION			;ALLOW INTERRUPTS AGAIN
ERCNI1:	RDIO T1,@RC1CS1(P1)	;READ STATUS 1
	RDIO T2,@RC1CS2(P1)	;READ STATUS 2
	HLLZ T4,UBADSW(P1)	;GET ADDRESS OF UBA
	RDIO T4,UNBSTW(T4)
	RDIO T3,@UBADSW(P1)	;GET STATUS
	HLRS T3			;SAVE INTERESTING BITS
	HRL T3,T4		;PUT TOGETHER
	RET
	SUBTTL INTERRUPT ROUTINE

;ENTER FROM PHYSIO W/ C(P1) := CDB CAUSING INTERRUPT.

RH2INT:	RDIO T2,@RC1CS2(P1)	;READ STATUS 2
	TRNN T2,RH1NED		;IS NED SET?
	JRST RH2IN1		;NO - GO ON
	BUG(INF,P1NED3,<PHYH11 - NON EX DISK ON DONE OR ATN INTERRUPT>,<T1,T2>)
	CALL CLRRAE		;CLEAR RAE
RH2IN1:	MOVSI T2,(DO.AS)	;SET TO READ ATTENTION SUMMARY REGISTER
	CALL RDREGX		; READ (ANY UNIT WILL DO)
	MOVEI Q1,0		;INITIAL UNIT #
	ANDI T1,377		;MASK OUT IMPOSSIBLE BITS
	TRNN T1,377		;ANY ATTENTION ON?
	JRST NOATTN		;NO - CHECK DATA TRANSFER
ATCHKN:	LSHC T1,-1		;SHIFT 1 BIT OVER
	JUMPGE T2,ATCHK2	;JUMP IF NOT THIS UNIT
	PUSH P,T1		;SAVE REMAINDER
	HRRZ T1,Q1		;GET UNIT #
	CALL SETUDB		;SET UP P3 := UDB ADDRESS, T2 := DISPATCH
	JUMPE P3,ATNXU		;SPURIOUS INTERRUPT IF NO UNIT THERE
	SETZ P4,		;P4=0 IF NO ERRORS
	CALL UDSATN(T2)		;INFORM LOWER LEVEL
				;SETS LH(Q1) TO -1 IF POS DONE INTERRUPT
	JUMPN P4,ATNIRB		;IF DONE OR AN ERROR, GO RETURN
ATCHK1:	POP P,T1		;RESTORE ATTENTION REGISTER
ATCHK2:	SKIPE T1		;DONE IF ZERO
	AOJA Q1,ATCHKN		;INCR UNIT # AND TRY NEXT

NOATTN:	MOVE T1,CDBCNI(P1)	;PICK UP THE STATUS
	SKIPL T4,CDBXFR(P1)	;TRANSFER IN PROGRESS?
	JRST XFR		;YES - ANALYZE
NOATT1:	HLLE P4,Q1		;NO TRANSFER, SET P4=-1 OR 0
NOATT2:	MOVEI T1,RH1IE		;CHECK FOR INTERRUPT ENABLE
	TION T1,@RC1CS1(P1)	;IF INTERRUPT ENABLE SET LEAVE IT ALONE
	WRIOB T1,@RC1CS1(P1)	;OTHERWISE SET IT
	RETSKP			;AND LET PHYSIO DO ITS THING

XFR:	WRIOB T4,@RC1CS2(P1)	;SET UNIT NUMBER
	MOVEI T1,RH1RDY		;CHECK FOR READY
	TIOE T1,@RC1CS1(P1)
	SKIPN CDBCNI(P1)	;CHECK FOR DATA OPERATION
	JRST [	SETZ P4,	;YES, MUST BE FROM ERRPSI (PHYRP4)
		JRST NOATT2]	; SO JUST DISMISS THE INTERRUPT
	SETZM CDBCNI(P1)	;SET NO DATA OPERATION IN PROGRESS
	HRRZ T1,CDBICP(P1)	;FIND THE INITIAL CCW
	MOVE T1,2(T1)
	RDIO T2,@RC1WC(P1)	;FIND THE WORD COUNT
	MOVNS T2		;MAKE IT +
	ANDI T2,177777		;MASK OFF GOOD BITS
	LSH T2,-1		;MAKE  WORDS (PDP10)
	LDB T3,CCYCNT		;GET OLD COUNT
	DPB T2,CCYCNT		;SET IN NEW CCW
	SUB T3,T2		;FIND COUNT LEFT
	ADD T1,T3		;MAKE ADDRESS
	HRRZ T2,CDBICP(P1)	;FIND THE ADDRESS AGAIN
	MOVEM T1,2(T2)		;STORE IN LOGOUT AREA
	LDB T1,CCYCNT		;FIND THE COUNT AGAIN
	SKIPN T1		;SET WORD COUNT 0 IF TRUE