;;; -*- Mode: Midas -*-
.AUXIL

;;; Canonical symbol definition macro, FOO==BAR with error check.
IFNDEF DEFSYM,[	
DEFINE DEFSYM X/
IRPS Z,,[X]
IFNDEF Z,X
.ELSE [	$$TEM1==Z
	X
	IFN Z-$$TEM1,.ERR Z MULTIPLY .QUOTE`.QUOTE/DEFINED/`
      ]
.ISTOP
TERMIN TERMIN
$$TEMP==1
] ;IFNDEF DEFSYM
.ELSE, $$TEMP==0


;;; RH11/TM78 Interrupt vector:
DEFSYM	%ARVEC==224		;(224/4 = 45) Interrupts occur on level 6
				; (high priority) on UBA #1.
DEFSYM	%ARBAS==772400		;Unibus address of first register 

;;; RH11/TM78 Unibus register addresses:

DEFSYM	%ARCS1==%ARBAS		;CONTROL AND STATUS 1 (RH11 and MB Reg 00)
 DEFSYM	%A1SC==1_15.		; Special Condition
 DEFSYM	%A1TE==1_14.		; Transfer Error
 DEFSYM	%A1MCP==1_13.		; Massbus Control Bus Parity Error
 DEFSYM	%A1DA==1_11.		; Drive (TM78) Available
 DEFSYM	%A1A7==1_9.		; UB Address Extension Bit 17
 DEFSYM	%A1A6==1_8.		; UB Address Extension Bit 16
 DEFSYM	%A1RDY==1_7.		; Ready
 DEFSYM	%A1IE==1_6.		; Interrupt Enable
 DEFSYM	%A1CMD==77		; Bits 0-5 specify commands.
 DEFSYM	%A1GO==1_0.		; GO bit

;;; Commands, with GO bit or'd in.
;;; --NOTE-- 
;;; Commands are passed to the controller in two ways. Data transfer
;;; command get written into the CS1 register, as usual. Non-data-transfer
;;; commands are written to the %ARNDC register for the desired drive
;;; unit (see below). Non-data-transfer commands are marked with a '*'.

DEFSYM	%ACNOP==3		;(*) No Operation
DEFSYM	%ACUNL==5		;(*) Unload
DEFSYM	%ACREW==7		;(*) Rewind
DEFSYM	%ACSNS==11		;(*) Sense (Get status from TM)
DEFSYM	%ACDSE==13		;(*) Data Security Erase! (Erase rest of tape)
DEFSYM	%ACWPM==15		;(*) Write Phase Encoded (1600bpi) Tape Mark
DEFSYM	%ACWGM==17		;(*) Write GCR (6250bpi Tape Mark
DEFSYM	%ACSFR==21		;(*) Space Forward Record
DEFSYM	%ACSRR==23		;(*) Space Reverse Record
DEFSYM	%ACSFF==25		;(*) Space Forward File
DEFSYM	%ACSRF==27		;(*) Space Reverse File
DEFSYM	%ACSFE==31		;(*) Space Forward Either (record or file)
DEFSYM	%ACSRE==33		;(*) Space Reverse Either
DEFSYM	%ACE3P==35		;(*) Erase Three-inch gap, set PE
DEFSYM	%ACE3G==37		;(*) Erase Three-inch gap, set GCR
DEFSYM	%ACCFP==41		;(*) Close File PE (write two marks, back one)
DEFSYM	%ACCFG==43		;(*) Close File GCR
DEFSYM	%ACEOT==45		;(*) Space to Logical EOT
DEFSYM	%ACSFU==47		;(*) Space forward usefully (to file or EOT)
DEFSYM	%ACWCF==51		;Write Check Forward
DEFSYM	%ACWCR==57		;Write Check Reverse
DEFSYM	%ACWRP==61		;Write Forward PE
DEFSYM	%ACWRG==63		;Write Forward GCR
DEFSYM	%ACRDF==71		;Read Forward
DEFSYM	%ACRES==73		;Read Extended Sense Information
DEFSYM	%ACRDR==77		;Read Data Reverse


DEFSYM	%ARWC==%ARBAS+2		;UNIBUS DMA WORD COUNT. (RH11)
 ; Negative count of the number of PDP11 (18-bit) words to DMA

DEFSYM	%ARBA==%ARBAS+4		;UNIBUS ADDRESS. (RH11)
 ; Unibus address of start of DMA transfer

DEFSYM	%ARFC==%ARBAS+6		;TAPE FRAME BYTE COUNT (MB Reg 05)

DEFSYM	%ARCS2==%ARBAS+10	;CONTROL AND STATUS 2. (RH11)
 DEFSYM	%A2DL==1_15.		; Data Late
 DEFSYM	%A2UPE==1_13.		; Unibus Parity Error
 DEFSYM	%A2NF==1_12.		; Non-existant Formatter (TM78)
 DEFSYM	%A2NM==1_11.		; Unibus mem NXM during DMA
 DEFSYM	%A2PE==1_10.		; Program Error
 DEFSYM	%A2MT==1_9.		; Missed Transfer
 DEFSYM	%A2MDP==1_8.		; Massbus Data Bus Parity Error
 DEFSYM	%A2OR==1_7.		; Output Ready (for Silo buffer diag.)
 DEFSYM	%A2IR==1_6.		; Input  Ready (for Silo buffer diag.)
 DEFSYM	%A2CC==1_5.		; Controller Clear
 DEFSYM	%A2PT==1_4.		; Parity Test
 DEFSYM	%A2UAI==1_3.		; Unibus Address Increment Inhibit

DEFSYM	%ARDER==%ARBAS+12	;DATA TRANSFER ERROR REPORT (MB Reg 01)
 DEFSYM %ADEIC==77		; Interrupt Code
 DEFSYM %ADEDP==1_8.		; DPR ???
 DEFSYM %ADEFC==77_10.		; Failure Code

DEFSYM	%ARDCA==%ARBAS+14	;DATA COMMAND ARGUMENTS (MB Reg 02)
 DEFSYM	%ADACA==3		; Command Address (TU78 unit number)
 DEFSYM	%ADARC==77_2.		; Record Count
 DEFSYM	%ADASC==17_8.		; Skip Count
 DEFSYM %ADAFT==7_12.		; Format
 DEFSYM	%ADASR==1_15.		; Supress Repositioning on error

DEFSYM	%ARASN==%ARBAS+16	;ATTENTION SUMMARY. (MB Reg 04)
 ;Each bit 3-0 corresponds to a drive wanting attention
 ; You must explicitly -RESET- an attention bit by writing a
 ; one into it before the controller can interrupt you again.

DEFSYM	%ARDS==%ARBAS+20	;DRIVE STATUS (MB Reg 07)
 ;;; This register is valid only after a SENSE command
 ;;; (or possibly an unsolicited ONLINE interrupt)
 DEFSYM	%ASRDY==1_15.		; Tape Ready
 DEFSYM %ASPRE==1_14.		; Present (TM78 powered up)
 DEFSYM %ASONL==1_13.		; Online
 DEFSYM %ASREW==1_12.		; Tape Rewinding
 DEFSYM %ASPE==1_11.		; Tape is Phase Encoded
 DEFSYM %ASBOT==1_10.		; Tape at BOT
 DEFSYM %ASEOT==1_9.		; Tape at EOT
 DEFSYM %ASWPT==1_8.		; Tape is Write Protected
 DEFSYM %ASUA==1_7.		; Unit Available
 DEFSYM %ASUS==1_6.		; Unit is shared
 DEFSYM %ASMMD==1_5.		; Unit is in Maintainance mode
 DEFSYM %ASDSE==1_4.		; Data Security Erase in progress.

DEFSYM	%ARBUF==%ARBAS+22	;DATA BUFFER REGISTER (RH11)

DEFSYM	%ARMR1==%ARBAS+24	;MAINTENANCE REGISTER 1 (MB Reg 03)

DEFSYM	%ARTYP==%ARBAS+26	;DRIVE TYPE. (MB Reg 06)
 ;;; This register is valid only after a SENSE command
				;2.7  Not Sector addressed
				;2.6  Tape
				;2.5  Moving Head (always 0)
				;2.4  7 track (always 0)
				;2.3  Dual port (must do arbitration)
				;2.2  Slave present (always 1)
				;2.1  Writable Control Store (always 0)
				;1.9 - 1.1  Drive Type Number.
				;   TU78=101

DEFSYM	%ARSER==%ARBAS+30	;SERIAL NUMBER (MB Reg 010)
 ;;; This register is valid only after a SENSE command
 ;0-3	SN digit 0, in BCD
 ;4-7	SN digit 1
 ;8-11	SN digit 2
 ;12-15	SN digit 3

DEFSYM	%ARMR2==%ARBAS+32	;MAINTAINANCE REGISTER 2 (MB Reg 011)

DEFSYM	%ARMR3==%ARBAS+34	;MAINTAINANCE REGISTER 3 (MB Reg 012)

DEFSYM	%ARNDE==%ARBAS+36	;NON-DATA CMD ERROR REGISTER (MB Reg 013)
 DEFSYM	%ANEIC==77		; NDT Interrupt code
 DEFSYM	%ANEAA==3_8.		; Attention Address (drive that caused this)
 DEFSYM %ANEFC==77_10.		; NDT Failure Code

DEFSYM	%ARNDA==%ARBAS+40	;NON-DATA CMD ARG REGISTERS (MB Reg 014 - 017)
 ;;; There are four of these, one for each of the possible slave TU78
 ;;; units on the TM78. This is where you write commands that don't
 ;;; move data over the massbus.
 DEFSYM	%ANCMD==77		; Command to execute
 DEFSYM	%ANCNT==377_8.		; Count

DEFSYM	%ARIA==%ARBAS+50	;INTERNAL ADDRESS (MB Reg 020)

DEFSYM	%ARID==%ARBAS+52	;HARDWARE CONTROL (MB Reg 021)
 DEFSYM %AHRDY==1_15.		; Set when controller is ready. (read only)
 DEFSYM %AHCLR==1_14.		; Write 1 here to reset controller.
 ;;; And a bunch of other stuff


IFN $$TEMP,EXPUNG DEFSYM


