	.TITLE	BTDRV
	.IDENT	/01/
 
;
; VERSION 01
;
; J. S. SVENTEK  09-JUL-80
;
; BACKGROUND "TERMINAL" DEVICE DRIVER.
;
; MACRO LIBRARY CALLS
;
; EQUATED SYMBOLS
;
; LOCAL DATA
;
; NO CONTROLLER IMPURE DATA TABLES (THERE IS NO DEVICE TO
;	CAUSE INTERRUPTS)
;
; DRIVER DISPATCH TABLE
;
$BTTBL::
	.WORD	BTINI		;INITIATION
	.WORD	$INTXT		;CANCEL ($INTXT IS A "RETURN")
	.WORD	$INTXT		;TIMEOUT
	.WORD	$INTXT		;POWERFAIL
;+
; BTDRV AND DRQIO IMPLEMENT a device bt:, which acts as a null device,
; and is always logged in under the uic [BT$GRP,BR$MEM]
;
; This driver permits tasks to be spawned in the background, with their
; TI: redirected to BT:, thus assuring that the tasks are by default
; directed to the "null" device.
;-
;
; DRQIO (BECAUSE THE UC.QUE BIT IS SET IN THE UCB) SETS THE REGISTERS
; TO THE FOLLOWING:
;
;	R1 = ADDRESS OF I/O PACKET
;	R4 = ADDRESS OF SCB
;	R5 = ADDRESS OF UCB
;
; ONLY TWO FIELDS OF AN I/O PACKET MATTER
;	I.FCN+1 = THE I/O FUNCTION CODE.  ONLY IO.WLB
;		  AND IO.RLB MAKE IT TO BTDRV
;	I.PRM+4 = IF I.FCN+1 IS IO.WLB, THIS IS THE 
;		  NUMBER OF BYTES THE CALLER WANTS TO WRITE
;
BTINI:	MOV	R1,R3		;POINT AT PACKET FOR $IOFIN
	MOV	#IS.SUC&377,R0	;A WRITE ALWAYS SUCCEEDS
	MOV	I.PRM+4(R1),R1	;SAY EVERYTHING WAS WRITTEN
	CMPB	#IO.WLB/400,I.FCN+1(R3) ;WANTS TO WRITE?
	BEQ	10$		;IF EQ YES
	MOV	#IE.EOF&377,R0	;IT IS A READ
	CLR	R1		;READ NO CHARACTERS
10$:	CALLR	$IOFIN		;FINISH OFF PACKET
 
	.END
