Google
 

Trailing-Edge - PDP-10 Archives - saio_sources - 5sources/phypar.mac
There are 53 other files named phypar.mac in the archive. Click here to see a list.
;<5.ISI.MONITOR>PHYPAR.MAC.5070	24-Nov-82 13:40:48	Edit by SMITH
;#507 Change skip file function to use same code as SEEK ... ran out of bits
;#507  for new function.
;<5.ISI.MONITOR>PHYPAR.MAC.4160	20-Oct-82 21:11:22	Edit by SMITH
;#416	SA10 definitions
;#26	SA10 defs
;#25	SA10 defs
;#23 Change skip forward file routine to utilize hardware skip file function
;
; UPD ID= 147, SNARK:<5.MONITOR>PHYPAR.MAC.11,   3-Sep-81 16:35:17 by UHLER
;TCO 5.1487 ADD DEF'S FOR SUPPORT OF CHANNEL WRITE PARITY DETECTION IN PHYH2
; UPD ID= 1826, SNARK:<5.MONITOR>PHYPAR.MAC.10,  17-Apr-81 09:57:06 by WACHS
;TCO 5.1288 ADD DEF'S FOR MAGTAPE STATISTICS ON A PER-MODE BASIS
; UPD ID= 1574, SNARK:<5.MONITOR>PHYPAR.MAC.9,  23-Feb-81 16:12:02 by LYONS
; MAKE THE INTERUPT STACK FOR PHYSIO BIGGER.  WE CALL PHYSIO ON OUR STACK,
; AND COULD RUN OUT OF ROOM
; UPD ID= 1364, SNARK:<5.MONITOR>PHYPAR.MAC.8,  18-Dec-80 10:14:33 by WACHS
; TCO 5.1206 CHANGE DEVICE TYPES FOR TM78, RP07
; UPD ID= 734, SNARK:<5.MONITOR>PHYPAR.MAC.7,   7-Jul-80 00:47:06 by DBELL
;TCO 5.1096 - ADD UDSCCK DISPATCH OFFSET
; UPD ID= 626, SNARK:<5.MONITOR>PHYPAR.MAC.6,  11-Jun-80 17:02:29 by LYONS
;TCO 5.0162 - ADD DEFINITIONS FOR WRITE VERIFICATION
; UPD ID= 579, SNARK:<5.MONITOR>PHYPAR.MAC.5,  31-May-80 23:04:19 by DBELL
;TCO 5.1048 - ADD DEFINITIONS NEEDED FOR MULTIPLE-PAGE DSKOPS
; UPD ID= 503, SNARK:<5.MONITOR>PHYPAR.MAC.3,   1-May-80 15:19:11 by DBELL
;TCO 4.1.1153 - INCREASE NUIORB FROM 6 TO 15
; UPD ID= 365, SNARK:<4.1.MONITOR>PHYPAR.MAC.15,  26-Mar-80 11:07:27 by DBELL
;TCO 4.1.1119 - MAKE NECESSARY CHANGES FOR RP20 SUPPORT
;<4.MONITOR>PHYPAR.MAC.14, 25-Oct-79 18:56:45, EDIT BY DBELL
;TCO 4.2551 - ADD KS.HLT TO REMEMBER MICROCODE IS HALTED
;<4.MONITOR>PHYPAR.MAC.13, 19-Sep-79 15:45:04, EDIT BY DBELL
;TCO 4.2476 - ADD DISPATCHES UDSEXT AND CDSEXT
;<4.MONITOR>PHYPAR.MAC.12,  6-Mar-79 09:32:09, EDIT BY KONEN
;UPDATE COPYRIGHT FOR RELEASE 4
;<2BOSACK>PHYPAR.MAC.3, 14-Feb-79 10:54:52, EDIT BY BOSACK
;ADD TU77 HW DEVICE TYPE
;<4.MONITOR>PHYPAR.MAC.10, 26-Jul-78 00:20:36, Edit by MCLEAN
;DECOMMITT US.IDB AND MAKE IT BE US.PSI
;<4.MONITOR>PHYPAR.MAC.6, 18-Jul-78 01:03:21, Edit by MCLEAN
;ADD ONLINE/OFFLINE TRANSITION PSI (USED BY TAPE ONLY)
;<FORTMILLER>PHYPAR.MAC.3, 24-May-78 14:57:15, Edit by FORTMILLER
;ADD CHARACTERISTICS WORD TO UDB - UDBCHR
; AND DX20 SUPPORT
;<3A.MONITOR>PHYPAR.MAC.1, 19-Apr-78 02:28:35, Edit by MCLEAN
;ADD TY.T78 (TM78)
;<2BOSACK>PHYPAR.MAC.58, 24-Feb-78 01:09:25, EDIT BY BOSACK
;RENAME DATA AND DEVICE ERROR BITS IN IORB
;<1MCLEAN>PHYPAR.MAC.57, 27-Jan-78 16:48:20, Edit by MCLEAN
;ENLARGE INTERRUPT STACK FOR CALL TO ALLOCATE FREE SPACE


;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.

;	SAIO Changes Copyright 1982, All Rights Reserved
;	University of Southern California

	UNIVERSAL PHYPAR - UNIVERSAL FOR PHYSIO AND ASSOCIATED MODULES
	SUBTTL L.BOSACK/T.HESS 16-MAY-75
	SALL
	SEARCH MONSYM,MACSYM
	SUBTTL CHANNEL DATA BLOCK

CDBINT==-6			;JSR TO HERE IF VECTOR DEVICE
				;CDBINT+1 CONTAINS MOVEM P1,.+2+CDBSVQ
				;CDBINT+2 CONTAINS XPCW PHYINT
CDBSTS==0			;STATUS AND CONFIGURATION INFORMATION
CDBMBW==1			;MEMORY BANDWIDTH SCHEDULING INFORMATION
CDBODT==2			;OVERDUE TIMER WHEN DATA XFR ACTIVE
CDBICP==3			;EXEC VIRTUAL ADDR OF INAD/ICCW
CDBIUN==4			;INITIAL AOBJN PTR TO UDB TABLE
CDBCUN==5			;CURRENT AOBJN PTR TO UDB TABLE
CDBDSP==6			;UNIT UTILITIES DISPATCH,,MAIN ENTRY DISPATCH
CDBFCT==7			;FAIRNESS COUNT FOR LATENCY
CDBPAR==10			;CHANNEL MEMORY PARITY ERRORS
CDBNXM==11			;CHANNEL NXMS
CDBXFR==12			;CURRENTLY TRANSFERRING UDB
CDBCCL==13			;3 WORD BLOCK, CHANNEL COMMAND LIST
CDBUDB==16			;UDB TABLE - 8 WORDS
CDBSVQ==26			;P1 SAVED HERE ON VECTOR INTERRUPT ENTRY
CDBJEN==27			;INTERRUPT DISMISS (3 WORDS)
				;CDBJEN CONTAINS BLT 17,17
				;CDBJEN+1 CONTAINS DATAO RH,CDBRST
				;CDBJEN+2 CONTAINS JEN @CDBINT
CDBRST==32			;LOC USED BY CDBJEN
CDBCNI==33			;CHANNEL CONI AT START OF INTERRUPT
CDBONR==34			;FORK WHO HAS CHANNEL IN MAINT MODE
CDBADR==35			;NUMBER OF THIS CHANNEL (CHNTAB INDEX)
CDBCS0==36			;CHAN STATUS 0 AT ERROR
CDBCS1==37			;CHAN STATUS 1
CDBCS2==40			;CHAN STATUS 2
CDBCC1==41			;FIRST CCW
CDBCC2==42			;SECOND CCW
CDBOVR==43			;NUMBER OF OVERRUNS
CDBICR==44			;INITIAL STCR WHEN DEVICE STARTED
CDBCL2==45			;3 WD BLOCK, ALTERNATE CCW LIST
CDBIRB==50			;IORB WE MOST WANT TO START TRANSFER FOR
CDBLUN==51			;LAST UDB WHICH DID TRANSFER OR POSITIONING
CDBCAD==52			;2 WD BLOCK, ADDRESS OF CCW FOR FIRST AND
				; SECOND COMMANDS
CDBDDP==54			;START OF DEVICE DEPENDENT CDB


;BITS AND BYTES

;CDBSTS

CS.OFL==1B0			;OFFLINE
CS.AC1==1B1			;PRIMARY COMMAND ACTIVE
CS.AC2==1B2			;SECONDARY COMMAND ACTIVE
CS.ACT==CS.AC1!CS.AC2		;ANY ACTIVE
CS.MAI==1B3			;CHANNEL IS IN MAINT MODE
CS.MRQ==1B4			;MAINT MODE REQUESTED FOR SOME UNIT
CS.ERC==1B5			;ERROR RECOVERY IN PROGRESS
CS.STK==1B6			;CHANNEL SUPPORTS COMMAND STACKING
CS.ACL==1B7			;ALTERNATE CCW LIST IS CURRENT
CS.CWP==1B8			;CHANNEL WRITE PARITY ERROR DETECTED ON THIS
				; CHANNEL
CS.MUX==1B14			;#25 channel is multiplexor channel
CSSTYP==SIZ.UT			;SIZE OF TYPE FIELD
CSPTYP==^D35			;POSITION OF TYPE FIELD
CSSPIA==3			;SIZE OF PIA FIELD
CSPPIA==XSPTYP-XSSTYP		;POSITION OF PIA FIELD
;CHANNEL SERVICE ROUTINE MAIN ENTRY DISPATCH

CDSINI==0			;INITIALIZE AND BUILD DATA STRUCTURE
CDSSTK==1			;STACK SECOND CHANNEL COMMAND, SKIP IF OK
CDSSIO==2			;START IO, SKIP IF STARTED OK.
CDSPOS==3			;DO POSITIONING TO IDLE UNIT, SKIP IF OK.
CDSLTM==4			;RETURN LATENCY AND BEST REQUEST
CDSINT==5			;INTERRUPT ENTRY
CDSCCW==6			;GENERATE SINGLE CCW ENTRY
CDSHNG==7			;HUNG RESET
CDSRST==10			;RESET CHANNEL AND ALL DEVICES, ON RESTART
CDSCHK==11			;PERIODIC CHECK ENTRY, CHECK PIA, ETC.
CDSEXT==12			;CHECK LEGALITY OF A UNIT, SKIP IF EXISTANT
CDSCCA==13			;EXTRACT ADDRESS FROM CCW WORD

;CALLING SEQUENCES
;THE P&Q ACS ARE ASSUMED PRESERVED UNLESS STATED OTHERWISE.
;THE T ACS ARE ASSUMED DESTROYED UNLESS STATED OTHERWISE.
;INPUT ARGUMENTS ARE THOSE ACS WHICH MUST BE SETUP FOR THE CALL.
;OUTPT ARGUMENTS ARE THOSE ACS WHICH WILL BE SET TO A SPECIFIED VALUE
;BY THE CALL.

;ENTRY INPUT OUTPUT	;COMMENTS

;INI P4 P4	;TAKES FIRST FREE CHAN # IN P4, UPDATES P4
;			;CAN CLOBBER ALL OTHER ACS
;PRQ P4,P1,3 P4,P1,3	;SKIPS IF THE IORB IN P4 REQUIRES POSITIONING
;			;BEFORE TRANSFER CAN BE DONE
;SIO P4,P1,3 P4,P1,3	;STARTS IO ON THE IORB IN P4. SKIPS IF START OK
;POS P4,P1,3		;STARTS POSITIONING TO THE CYL OF THIS IORB.
;			;SKIPS IF SEEK STARTED OK.
;LTM T1,P1,3		;RETURNS THE BEST IORB TO XFR ON THIS UNIT.
;		T1,2,3	;T1/ TIME TO GO IN USEC,T2/ PREDECESSOR IORB, T3/ IORB
;INT P1 P4,P3	;CALLED ON AN INTERRUPT FOR THE CDB IN P1.
;			;RETURNS:P4/ 0=EXIT INTERRUPT,-1=DO SCHED CYCLE
;			;	POSITIVE=IORB COMPLETED
;CCW T1,2, T1	;BUILDS A SINGLE CCW FOR THE CHAN IN P1
;	P1		;T1/ DATA MODE,,BYTE COUNT (1B0 IF BACKWARDS XFR)
;			;T2/ PHYSICAL MEM ADDR. RETURNS CCW IN T1
	SUBTTL KONTROLLER DATA BLOCK (TM02/3, DX20A/B ONLY)

KDBSTS==0			;FLAGS, UNIT TYPE
KDBIUN==1			;INITIAL AOBJN WORD TO UDB TABLE
KDBCUN==2			;CURRENT AOBJN WORD TO UDB TABLE
KDBDSP==3			;DISPATCH FOR SERVICE RTN
KDBACT==4			;CURRENTLY ACTIVE UDB OR 0
KDBDDP==5			;START OF DEVICE DEPENDENT PART
KDBUDB==KDBDDP			;THE BLOCK FOR UDB ADDRESSES STARTS
				; AT THE DEVICE DEPENDENT PORTION
				; SINCE THERE CAN BE ONLY 8 UNITS
				; ON A TM02/TM03 AND THERE CAN
				; BE UP TO 16 UNITS ON A DX20/TX02

;BITS AND BYTES

;KDBSTS

KS.ACT==1B1			;ACTIVE
KS.HLT==1B2			;MICROCODE IS HALTED
KS.DSK==1B3			;THIS CONTROLLER IS FOR DISKS
	SUBTTL UNIT DATA BLOCK

UDBSTS==0			;STATUS AND CONFIGURATION INFORMATION
UDBMBW==1			;MEMORY BANDWIDTH SCHEDULING INFORMATION
UDBODT==2			;OVERDUE TIMER FOR SEEKS AND THE LIKE
UDBERR==3			;ERROR RECOVERY STATE WORD
UDBERP==4			;ERROR REPORTING WORK AREA IF NONZERO
UDBDSP==5			;UNIT ROUTINE MAIN ENTRY DISPATCH
UDBCDB==6			;SECONDARY,,PRIMARY CDB
UDBADR==7			;SECONDARY,,PRIMARY ADDRESS OF UNIT ON CHANNEL
UDBAKA==10			;CURRENT CDB,,CURRENT CHAN ADDR
UDBVID==11			;VOLUME ID
UDBSTR==12			;POINTER TO STR DATA BLOCK
UDBKDB==13			;POINTER TO KDB, IF ANY
UDBDSN==14			;DRIVE SERIAL NUMBER
UDBSEK==15			;SEEKS
UDBRED==16			;READS - SECTORS IF DISK, FRAMES IF TAPE
UDBWRT==17			;WRITES - SECTORS IF DISK, FRAMES IF TAPE
UDBRCT==20			;ACTUAL READ COUNT
UDBWCT==21			;ACTUAL WRITE COUNT
UDBSRE==22			;SOFT READ ERRORS
UDBSWE==23			;SOFT WRITE ERRORS
UDBHRE==24			;HARD READ ERRORS
UDBHWE==25			;HARD WRITE ERRORS
UDBPS1==26			;CURRENT CYL IF DISK,FILE IF TAPE
UDBPS2==27			;CURRENT SECTOR WITHIN CYL IF DISK, RECORD IN FILE IF TAPE
UDBPWQ==30			;POSITION WAIT QUEUE - TAIL,,HEAD
UDBTWQ==UDBPWQ+1		;TRANSFER WAIT QUEUE - TAIL,,HEAD
UDBONR==32			;FORK WHO OWNS THIS UNIT (MAINT MODE)
UDBERC==33			;CURRENT RETRY COUNT
UDBSPE==34			;SOFT POSITIONING ERROR
UDBHPE==35			;HARD POS ERR
UDBPNM==36			;PROGRAM NAME TO LOG ON ERROR
UDBUDR==37			;USER DIRECTORY NUMBER TO LOG ON ERROR
UDBSIZ==40			;UNIT SIZE (NUMBER OF CYLINDERS)
UDBFCT==41			;SEEK FAIRNESS COUNT
UDBCHB==42			;IORB USED BY HOME BLOCK CHECK
UDBFCR==43			;FAIRNESS COUNT FOR READ SEEK PREF
UDBSLV==44			;SLAVE NUMBER IF TAPE
UDBCHR==45			;CHARACTERISTICS WORD
UDBDDD==46			;DEVICE DEPENDENT PART IF A DISK
UDBRNR==46			;FRAMES READ IN NRZI (MAGTAPE)
UDBRPE==47			;FRAMES READ IN PE
UDBRGC==50			;FRAMES READ IN GCR
UDBWNR==51			;FRAMES WRITTEN IN NRZI
UDBWPE==52			;FRAMES WRITTEN IN PE
UDBWGC==53			;FRAMES WRITTEN IN GCR
UDBDDM==54			;DEVICE DEPENDENT PART IF A MAGTAPE


;BITS AND BYTES

;UDBSTS

US.OFS==1B0			;OFFLINE OR UNSAFE
US.CHB==1B1			;CHECK HOME BLOCKS BEFORE ANY NORMAL IO
US.POS==1B2			;POSITIONING IN PROGRESS
US.ACT==1B3			;ACTIVE
US.BAT==1B4			;ON IF BAD BAT BLOCKS ON THIS UNIT
US.BLK==1B5			;LOCK BIT FOR THIS UNITS BAT BLOCKS
US.PGM==1B6			;DUAL PORT SWITCH IN (A OR B) (RP04,5,6)
US.MAI==1B7			;UNIT IS IN MAINT MODE
US.MRQ==1B8			;MAINT MODE IS REQUESTED ON THIS UNIT
US.BOT==1B9			;UNIT IS AT BOT
US.REW==1B10			;UNIT IS REWINDING (FOR MAGTAPES)
US.WLK==1B11			;UNIT IS WRITE LOCKED
US.MAL==1B12			;MAINT MODE ALLOWED ON THIS UNIT
US.OIR==1B13			;OPERATOR INTERVENTION REQUIRED.
				;SET AT INTERRUPT LEVEL, CHECKED AT SCHED.
US.OMS==1B14			;ONCE A MINUTE MESSAGE TO OPR. USED IN
				;CONJUNCTION WITH US.OIR
US.PRQ==1B15			;POSITIONING REQUIRED ON THIS UNIT
US.TAP==1B16			;TAPE TYPE DEVICE
US.PSI==1B17			;PSI ONLINE/OFFLINE/REWIND DONE TRANSITION OCCURRED
US.DSK==1B18			;DISK TYPE DEVICE
USSTYP==SIZ.UT			;UNIT TYPE FIELD SIZE
USPTYP==^D35			;UNIT TYPE FIELD POSITION
DEFSTR (USTYP,UDBSTS,USPTYP,USSTYP) ;UNIT TYPE IN UDBSTS

MSKSTR (USOFL,UDBSTS,US.OFS)	;UNIT OFFLINE

;UDBCHR

UC.7TK==1B0			;7 TRACK TAPE DRIVE

;DENSITYS DRIVE IS CAPABLE OF
UC.200==1B1			;200 BPI
UC.556==1B2			;556 BPI
UC.800==1B3			;800 BPI
UC.160==1B4			;1600 BPI
UC.625==1B5			;6250 BPI

;DATA MODES DRIVE IS CAPABLE OF
UC.CD==1B6			;CORE DUMP MODE
UC.6B==1B7			;SIXBIT MODE
UC.AA==1B8			;ANSI ASCII MODE
UC.IC==1B9			;INDUSTRY COMPATIBLE MODE
UC.HD==1B10			;HI-DENSITY MODE
;UNIT ROUTINE MAIN ENTRY POINTS

UDSINI==0			;INITIALIZE
UDSSIO==1			;START IO,SKIPS IF OK.
UDSINT==2			;INTERRUPT ROUTINE
UDSERR==3			;ERROR RECOVERY,SKIP IF DONE.
UDSHNG==4			;HUNG RESET
UDSCNV==5			;CONVERT LINEAR ADDR TO CYL,SURF,SEC
UDSLTM==6			;RETURN LATENCY/BEST REQUEST
UDSPOS==7			;START POSITION,SKIP IF OK.
UDSATN==10			;ATTENTION INTERUPT
UDSPRQ==11			;SKIP IF POSITIONING REQUIRED
UDSSTK==12			;STACK SECOND COMMAND, SKIP IF OK
UDSEXT==13			;CHECK LEGALITY OF A UNIT, SKIP IF EXISTANT
UDSCCK==14			;CHECK FOR HALTED MICROCODE IN CONTROLLERS

;CALLING SEQUENCES

;ENTRY	INPUT	OUTPUT	;COMMENTS

;INI	P1,Q2	P2,3	;CALLED ONCE PER UNIT. Q2/ UNIT NUMBER
;			;Q3/ SUBUNIT # IF GT 1 SUBUNITS
;			;RETURNS UDB IN P3,MAY RETURN KDB IN P2.
;SIO	P4,P1,3		;STARTS IO ON AN IORB. SKIPS IF OK.
;INT	P1,P3		;CALLED ON INTERRUPT FOR XFR DONE.
;ERR	P4,P1,3		;INITIATE ERROR RETRY. SKIPS IF NO MORE RETRYS.
;HNG	P1,3		;CALLED FROM TIMER TO RESET HUNG DEVICE.
;CNV	T1,P1,3	T1,2,3	;CONVERTS FROM UNIT LINEAR ADDR TO CYL,SURF,SEC
;			;T1/ LINEAR ADDR, ON RETURN: T1/ SAME, T2/CYL,T3/SURF,,SEC
;LTM	P1,3	T1,2,3	;SEE CDSLTM
;POS	P4,P1,3		;START POSITIONING ON IORB. SKIPS IF OK
;ATN	P1,3,Q1	P4,2	;CALLED ON DRIVE ATTENTION INTERRUPT.
;			;RETURNS P4=0 IF NO ERRORS (SEEK ERRORS)
;			;SETS LH(Q1) TO -1 IF IORB POSITION DONE
;			;NOTE: TAPE SHOULD RETURN P4=0, Q1 UNCHANGED
	SUBTTL IO REQUEST BLOCK

IRBSTS==0			;STATUS,, NEXT IORB
IRBLNK==0			;WHEN REFERING TO LINK
IRBMOD==1			;PRIO,DENSITY,PAR,MORE
IRBCNT==2			;COUNT OF DATA TRANSFERRED
IRBXFL==3			;XFR LIST TAIL,,HEAD
IRBIVA==4			;SIO EXIT,,ROUTINE TO CALL ON TERMINATION
IRBADR==5			;PHYSICAL DEVICE ADDRESS (IF NEEDED)
IRBLEN==:6			;LENGTH OF IORB

;STRUCTURE DEFINITIONS FOR THE IORB

DEFSTR (IRLNK,IRBLNK,35,18)	;LINK TO NEXT IORB
DEFSTR (IRBHD,IRBXFL,35,18)	;POINTER TO HEAD OF TRANSFER LIST
DEFSTR (IRBTL,IRBXFL,17,18)	;POINTER TO TAIL OF TRANSFER LIST

;FUNCTIONS, POINTER IRYFCN
ISSFCN==4			;FUNCTION CODE SIZE
ISPFCN==^D17			;POSITION IN IRBSTS
DEFSTR (ISFCN,IRBSTS,ISPFCN,ISSFCN) ;FUNCTION CODE IN IORB

	IRFRED==1		;READ DATA
	IRFRDF==2		;READ DATA AND FORMAT (COUNT, KEY, HEADER)
	IRFWRT==3		;WRITE DATA
	IRFWTF==4		;WRITE FORMAT
	IRFSEK==5		;SEEK
	IRFFSB==6		;FORWARD SPACE BLOCK
	IRFBSB==7		;BACKSPACE BLOCK
	IRFWTM==10		;WRITE TAPE MARK
	IRFERG==11		;ERASE GAP
	IRFREW==12		;REWIND
	IRFRUN==13		;REWIND AND UNLOAD
	IRFRDR==14		;READ REVERSE
	IRFRCR==15		;RECOVERY READ
	IRFWVC==16		;WRITE WITH VALIDITY CHECK
	IRFRVC==17		;READ VALIDITY CHECK
	IRFFSF==IRFSEK		;#23 Forward space file : multiplex since OOB

;MODES

IMSMOD==3			;SIZE OF MODE WHAT
IMPMOD==^D17			;POSITION OF MODE FIELD
DEFSTR (IRBDM,IRBMOD,IMPMOD,IMSMOD) ;DATA MODE
IRBSDN==4			;SIZE OF DENSITY FIELD
DEFSTR (IRBDN,IRBMOD,35,IRBSDN)	;DENSITY FIELD
DEFSTR (IRBPAR,IRBMOD,31,1)	;PARITY BIT
DEFSTR (IRBPRI,IRBMOD,30,4)	;PRIORITY FIELD

	IRMWRD==1		;WORD MODE
	IRM6BT==2		;SIXBIT
	IRM7BT==3		;SEVEN BIT MODE
	IRM8BT==4		;EIGHT BIT MODE
	IRMHID==5		;HIGH DENSITY MODE
	IRMMAX==5		;MAXIMUM LEGAL MODE

;BITS AND BYTES

;LH IRBSTS

IS.SHT==1B0			;SHORT FORM (PAGEM) REQUEST
IS.DON==1B1			;DONE WITH THIS IORB
IS.ERR==1B2			;ERROR ON THIS OPERATION
IS.NRT==1B3			;NO MORE RETRIES
IS.WGU==1B4			;WRONG UNIT INTERRUPTED
IS.TPM==1B5			;HIT TAPE MARK
IS.EOT==1B6			;ON WRITE ONLY: HIT PHYSICAL EOT
IS.WLK==1B7			;WRITE LOCKED
IS.IER==1B8			;INHIBIT ERROR RECOVERY
IS.DTE==1B9			;DATA ERROR
IS.DVE==1B10			;DEVICE (HARDWARE) ERROR
IS.BOT==1B11			;HIT BEGINING OF TAPE
IS.RTL==1B12			;RECORD TOO LONG (BUFFER TOO SMALL?)
IS.IEL==1B13			;INHIBIT ERROR LOGGING

IS.ALE==IS.ERR!IS.NRT!IS.WGU!IS.DTE!IS.DVE!IS.RTL ;ALL ERROR BITS
MSKSTR (ISERR,IRBSTS,IS.ERR)	;ERROR ON THIS OPERATION
MSKSTR (ISTPM,IRBSTS,IS.TPM)	;TAPE MARK HIT
	SUBTTL PARAMETERS - USUALLY DETERMINE MAXIMUM # OF DEVICES

PZSSIZ==20			;PAGE ZERO STORAGE
CHNN==^D8			;MAXIMUM NUMBER OF CHANNELS
MAXRH==10			;MAXIMUM NUMBER OF UNITS ON RH20
NUIORB==^D15			;NUMBER OF IORBS FOR UDSKIO MUST BE GE 2
UIOLEN==IRBLEN+2		;LENGTH OF FREE STG BLOCK IN IORB POOL
CCWMAX==^D50			;GREATEST NUMBER OF CCW WORDS ALLOWABLE

LPHYPD==55			;PRIVATE PDL
LPHIPD==120			;INTERRUPT PDL
	SUBTTL MACRO DEFINITIONS

;PI SYSTEM CONTROL
PHYCHN==:5			;CHANNEL FOR PHYSIO DEVICES

DEFINE IOPIOF<
	CHNOFF PHYCHN
>

DEFINE IOPION<
	CHNON PHYCHN
>
	SUBTTL TYPE CODES

;BLOCK TYPES

SIZ.UT==5			;CHANNEL/UNIT TYPE CODE SIZE

XSSTYP==2		;SIZE OF BLOCK TYPE FIELD
XSPTYP==^D35-SIZ.UT	;POSITION OF BLOCK TYPE FIELD

.BTCDB==1		;CDB
.BTKDB==2		;KDB
.BTUDB==3		;UDB

;CHANNEL TYPES
.CTRH1==1			;RH10
.CTRH2==2			;RH20
.CTRH3==3			;RH11
.CTSSA==4			;#25 SA10

;UNIT TYPES

.UTRP4==1			;RP04
.UTRS4==2			;RS04
.UTT45==3			;TU45
.UTTM2==4			;TM02 (AS UNIT)
.UTRP5==5			;RP05
.UTRP6==6			;RP06
.UTRP7==7			;RP07
.UTRP8==10			;RP08
.UTRM3==11			;RM03
.UTTM3==12			;TM03
.UTT77==13			;TU77
.UTTM7==14			;TM78
.UTT78==15			;TU78
.UTDXA==16			;DX20A FOR TAPES
.UTT70==17			;TU70 (800/1600 200IPS 9TRK)
.UTT71==20			;TU71 (200,556,800 200IPS 7TRK)
.UTT72==21			;TU72 (1600/6250 125IPS 9TRK)
.UTT73==22			;TU7x (1600/6250 200IPS 9TRK) 
				;DO NOT REORDER .UTT70 - 3 WITHOUT
				; ALSO REORDERING TABLES IN PHYX2
.UTDXB==23			;DX20B FOR RP20 DISKS
.UTP20==24			;RP20

.UTCT1==30			;#416 ;#26 IBM compatable Tape drive
.UTCC1==31			;#416 ;#25 Calcomp 230 (=IBM 3330 mod I)
.UTCC2==32			;#416 ;#25 Calcomp 235 (=IBM 3330 mod II)


;MASS BUSS DEVICE TYPES

TY.RP4==020			;RP04
TY.RP5==021			;RP05
TY.RP6==022			;RP06
TY.RM3==24			;RM03
TY.R7F==42			;RP07 FIXED HEAD
TY.R7M==41			;MOVING RP07
 TY.RPL==TY.RP4			;LOWEST "RP04" TYPE
 TY.RPH==TY.R7F			;HIGHEST "RP04" TYPE
TY.RS4==002			;RS04 DRIVE TYPE
TY.T2L==010			;LOWEST TM02 TYPE
TY.T2H==017			;HIGHEST TM02 TYPE
TY.T3L==050			;LOWEST TM03 TYPE
TY.T3H==057			;HIGHEST TM03 TYPE
TY.T77==014			;TU77 NOTE: TM03 HAS 40 BIT ON
TY.DXA==060			;DX20A TYPE (FOR TUXX TAPES)
TY.DXB==061			;DX20B TYPE (FOR RP20 DISKS)
TY.T78==101			;TM78
	SUBTTL SA10 parameters	;#25 .
;#25 ;#26 Begin additions for disks, tapes on SA10

;Parameters for SA10 channel and IBM style devices used on SA10.

SSANSC==4			;number of subchannels on an SA10
SA10BF==1			;all are model "B" SA10s

SA0==274			;device number of 1st SA10
SA1==374			;device number of 2nd SA10
SA0BAS=:2000			;base address for 1st SA10
SA1BAS=:2020			;base address for 2nd SA10

SSACHN==5			;PI channel for SA10

MAXSAU==^D8			;maximum units supported on each SA10 subchan.

PGSIZ==:1000			;Better be same as in prolog
NWREC==PGSIZ			;size of physical record
NBREC==NWREC*9/2		;number of bytes per record
NRECS==5			;number of records per track, mod I or II

;PARAMETERS USED IN SA10 AND IBM-STYLE DEVICES

; 8 bit bytes in a word

BYTE0==MASKB(0,7)
BYTE1==MASKB(8,15)
BYTE2==MASKB(16,23)
BYTE3==MASKB(24,31)

; bits in an 8 bit byte

BB0==200
BB1==100
BB2==040
BB3==020
BB4==010
BB5==004
BB6==002
BB7==001
;CONO TO SSA

SA%INI==1B18		;Initialize whole SA10
SA%CME==1B19		;Clear memory error flags
SA%CLK==1B26		;Clock control in SA10 microprocessor
SA%FCN==MASKB(27,29)	;Function selection
 .SANOP==0		;NOP=0
 .SAHIO==2		;Halt I/O
 .SARSC==3		;Reset channel
 .SAGOF==4		;Go flag for channel
 .SASRQ==5		;Status request flag
 .SASTS==6		;Status done flag
 .SAPIE==7		;Interrupt enable for a channel
SA%SET==1B30		;Set/do one of above flags/functions.
SA%CLR==0B30		;Clear one of above flags.
SA%CHN==MASKB(31,32)	;(Sub)Channel select for above functions
 .SACH0==0		;Select channel 0
 .SACH1==1		;Select channel 1
 .SACH2==2		;Select channel 2
 .SACH3==3		;Select channel 3
SA%PIA==MASKB(33,35)	;PI assignment for the SA10 as a whole.

;CONI FROM SSA

SA%PIR==1B18		;A PI request is being made
SA%MPE==1B19		;Parity error flag
SA%NXM==1B20		;Non-existent memory flag
SA%IEN==MASKB(21,24)	;Interrupt enable bits
SA%GON==MASKB(25,28)	;Go flags
SA%SFN==MASKB(29,32)	;The status flags
 ;The following codes apply to SA%IEN, SA%FON,SA%SFN
 .SACB0==10		;Bit for channel 0
 .SACB1==04		;Bit for channel 1
 .SACB2==02		;Bit for channel 2
 .SACB3==01		;Bit for channel 3
;and the PIA comes back in bits 33-35 (SA%PIA)
; field sizes for 2 models of SA10

   IFE SA10BF,<
	WCSIZ==^D15		;size of word count field
	ADSIZ==^D20		;size of address field
   >
   IFN SA10BF,<
	WCSIZ==^D11		;size of word count field
	ADSIZ==^D24		;size of address field
   >

;Block Multiplexor Control Commands (entries in Device List)

   IFE SA10BF,<
BMX%CM==MASKB(0,3)		;command field
BMX%DV==MASKB(8,15)		;device field
   >
   IFN SA10BF,<
BMX%CM==MASKB(8,11)		;command field
BMX%DV==MASKB(0,7)		;device field
   >
BMX%AD==MASKB(36-ADSIZ,35)	;address field (points to CP)

; Commands in the command field

 .BMXS==^B1101			;Start this device
 .BMXW==^B1110			;Waiting on this device
 .BMXT==^B1111			;This device has terminated
 .BMXE==^B0000			;End of list

;Channel Program commands

TCH==1B1			;Transfer in Channel program
				; (valid in CP or at Base address)
BMX.LP==3B1			;Block multiplexor Device List Pointer
				; (only valid at Base address)
;Device Command Word

SC%CCF==BYTE0			;channel command flags
 .SCNMX==BB0			;No Memory Transfer
 .SCTMM==BB1			;Transfer mode modifier 
 .SCXCT==BB2			;execute this word
 .SCCHN==BB3			;chain to further words after this one
 .SCBYT==BB4			;transfer bytes, not words (byte = 8 bits)
				; (for tape, used with .SCTMM to specify mode)
 .SCINT==BB5			;cause an interrupt when this CMD executed
 .SCILE==BB6			;ignore length error
 .SCBOF==BB7			;byte offset. start 2 bytes over in word.
  .SCWDM==0*.SCBYT+0*.SCTMM	; Word mode
  .SCBTM==1*.SCBYT+0*.SCTMM	; Byte mode (SC name) [counts are byte counts]
  .SCICM==1*.SCBYT+0*.SCTMM	; "Industry Compatible" mode (DEC name) [byte count]
  .SCNLM==0*.SCBYT+1*.SCTMM	; Natural mode (SC name) 
  .SCHDM==0*.SCBYT+1*.SCTMM	; "High Density" mode (DEC name)
  .SCTCM==1*.SCBYT+1*.SCTMM	; "Tape Compatibility" mode (SC name)
  .SCCDM==1*.SCBYT+1*.SCTMM	; "Core Dump" mode (DEC name)

SC%CMD=BYTE1			;device command field
SC%DEV=BYTE2			;device address field

DEFINE DCW (BITS,CMD,DEV)<
	..CW==0
   IRP BITS,<..CW==..CW!.SC'BITS>
	EXP FLD(..CW,SC%CCF)+FLD(CMD,SC%CMD)+FLD(DEV,SC%DEV)>


;Device Chain Word (IOW) 

SC%LST==1B0			;last command in chain if on
SC%CNT==MASKB(1,WCSIZ)		;word count (negative)
SC%ADR==MASKB(36-ADSIZ,35) 	;core address
SC%PAG==<SC%ADR-<PGSIZ-1>>	;page number portion of address field


DEFINE IOW (CNT,ADR,CHN)<+<FLD(-CNT,SC%CNT)&SC%CNT>+FLD(ADR,SC%ADR)! IFB <CHN>,<SC%LST>>

; Halt command

DEFINE HLT.H <0B0>		;halt, hanging
DEFINE HLT.C <1B0>		;halt, continuing
DEFINE HLT <HLT.H>		;default to hang
;DEVICE CODES ON THE IBM BUS

.IDDSK==300			;Address of Disk drive 0
.IDMTA==340			;Address of Tape drive 0

;Channel status byte -- B0 - B7 of status word one in low core

S1%CHS==BYTE0			;channel status in status word 1
 S1%STY==MASKB(0,1)		;status type
  .S1INI==0			;Initial selection status 
  .S1END==1			;Ending status 
  .S1ASY==2			;Asynchronous status
  .S1DMY==3			;Dummy status (program requested)
 .S1SER==040			;Select err. no such device.
 .S1BIP==020			;Bus in parity error on IBM chan bus
 .S1CSE==004			;Control sequence error. Junk on BUS.
 .S1LNE==002			;Length error (data xfer word/byte count)
 .S1PIF==001			;Prog interrupt flag (req by chan prg)

;IBM-device status byte. Appears in B8-B15 of status wd 1

S1%DVS==BYTE1			;device status in status word 1
 .S1ATN==200			;Attention
 .S1SMD==100			;Status modifier
 .S1CUE==040			;Control unit end
 .S1BSY==020			;Busy (device or controller)
 .S1CHE==010			;Channel end (data xfr through)
 .S1DVE==004			;Device end
 .S1UCK==002			;Unit check
 .S1UEX==001			;Unit exception (unusual state, not error)
S1%DEV==BYTE2			;device code of unit interrupting
;IBM command codes - opcodes to tape or disk

.ICNOP==003			;No-operation
.ICWRT==001			;Write data (Tape)
.ICRDT==002			;Read data (Tape)
.ICRDD==006			;Read data area of DSK record
.ICWRD==005			;Write data area of DSK record
.ICSNS==004			;Request sense bytes from device
.ICREW==007			;Rewind (Tape)
.ICSEK==007			;Seek (Disk)
.ICRDR==014			;Read reverse (Tape)
.ICRUN==017			;Rewind-unload (Tape)
.ICERG==027			;Erase gap (Tape)
.ICWEF==037			;Write tape mark (end of file)
.ICBSB==047			;Backspace block
.ICBSF==057			;Backspace file
.ICSKB==067			;Skip block
.ICSKF==077			;Skip file
.ICSSC==043			;Set sector (Disk) wait for right angular pos.
.ICSIE==061			;Search id equal (Disk)
.ICRCL==027			;Recalibrate (restore) (Disk)
.ICRDC==022			;Read count (Disk)
.IC916==303			;Set mode to 9-track, Hi density (1600) (Tape)
.IC908==313			;Set mode to 9-track, Lo density (800) (Tape)
; Sense byte bits

;Sense byte 0
SN%CRJ==FLD(BB0,BYTE0)		;command reject
SN%IRQ==FLD(BB1,BYTE0)		;intervention required
SN%BOP==FLD(BB2,BYTE0)		;bus out parity check
SN%EQC==FLD(BB3,BYTE0)		;equipment check
SN%DC== FLD(BB4,BYTE0)		;data check
SN%OVR==FLD(BB5,BYTE0)		;overrun
SN%WCZ==FLD(BB6,BYTE0)		;word count zero (tape)
SN%DCC==FLD(BB7,BYTE0)		;data converter check (tape)

;sense byte 1 (disk)

SN%PRM==FLD(BB0,BYTE1)		;permanent error
SN%ITF==FLD(BB1,BYTE1)		;invalid track format
SN%EOC==FLD(BB2,BYTE1)		;end of cylinder
;	FLD(BB3,BYTE1)
SN%NRF==FLD(BB4,BYTE1)		;no record found
SN%FPR==FLD(BB5,BYTE1)		;file protect
SN%WIN==FLD(BB6,BYTE1)		;write inhibit
SN%OPI==FLD(BB7,BYTE1)		;operation incomplete

;sense byte 2 (disk)

SN%COR==FLD(BB1,BYTE2)		;correctable
SN%EDP==FLD(BB3,BYTE2)		;environmental data present

;
; macro to generate a channel program for disk
;
DEFINE CC1CP(LABEL,SHORT)<
...BEG:
...RCL:	DCW <NMX,XCT,CHN,ILE>,.ICRCL,.IDDSK ;recalibrate command
LABEL:				;normal channel program begins here
...SKC:	DCW <XCT,CHN,BYT>,.ICSEK,.IDDSK ;seek cylinder
	IOW 6,LABEL+DPOSEK	; address of cylinder
...SSC:	DCW <XCT,CHN,BYT>,.ICSSC,.IDDSK ;set sector
	IOW 1,LABEL+DPOSEK+2	; address of sector number
...SRC:	DCW <XCT,CHN,BYT,BOF>,.ICSIE,.IDDSK ;search ID equal
	IOW 5,LABEL+DPOSEK	; address of search address
...TCC:	TCH .-2			;keep searching
...OPC:	DCW <XCT>,.ICRDD,.IDDSK	;read data or write data

IFB <SHORT>,<
...ADR:	EXP 0,0,0,0		;room for up to 3 IOW's + HLT **
	EXP 0			;#2 extra halt for safety

...PSK:	DCW <XCT,BYT>,.ICSEK,.IDDSK ;#2 seek cylinder (no chaining)
	IOW 6,LABEL+DPOSEK	;#2  address of cylinder
	HLT.C			;#2 end of Seek-only program
	EXP 0			;#2 extra halt for safety

...SNP:
	DCW <XCT,CHN,BYT>,.ICSNS,.IDDSK ;sense command
	IOW ^D24,.-.		;where to store sense bytes
	HLT.H			;end of sense program (hang when done)

...SEK:	EXP 0,0,0		;seek argument for drive 
...LEN:				;end of CP
>				;end of IFB <SHORT>

IFB <SHORT>,<
DPORCL==:...RCL-LABEL		;displacement to Recalibrate command
DPOSKC==:...SKC-LABEL		;displacement to Seek command
DPOSSC==:...SSC-LABEL		;displacement to Set sector command
DPOSRC==:...SRC-LABEL		;displacement to Search command
DPOTCC==:...TCC-LABEL		;displacement to TCH back to Search
DPOOPC==:...OPC-LABEL		;displacement to Read/Write command
DPOADR==:...ADR-LABEL		;displacement to Read/Write IOW (address)
DPOPSK==:...PSK-LABEL		;#2 displacement to Position only Seek cmd
DPOSNP==:...SNP-LABEL		;displacement to Sense command
DPOSEK==:...SEK-LABEL		;displacement to Seek buffer
DPOCPL==:...SNP-...BEG		;length of standard channel program
DPOLEN==:...LEN-...BEG		;length of command program
>				;end of IFB <SHORT>

	PURGE ...BEG,...END,...RCL,...OPC,...ADR,...SNP,...SEK
	PURGE ...SKC,...SSC,...SRC,...TCC
>

;#25 ;#26  end additions for disks, Tapes on SA10
	END