	.TITLE	BHDRIVER - Black Hole driver.
	.IDENT	/V01/

;
;
;			  Free software BY
;		Project Software & Development, Inc.
;
; This software is furnished for free and may be used and  copied as
; desired. This software or  any  other copies  thereof may be provided
; or otherwise made available to any other person.  No title to and
; ownership of  the  software  is  hereby transferred or allowed. 
;
; The information in this software is subject to change  without  notice
; and  should  not  be  construed  as  a commitment by PROJECT SOFTWARE
; AND DEVELOPMENT, INC.
;
; PROJECT SOFTWARE assumes no responsibility for the use or  reliability  
; of this software on any equipment whatsoever.
;
;	Project Software & Development, Inc.
;	14 Story St.
;	Cambridge, Ma. 02138
;	617-661-1444
;
;
;++
;
; FACILITY:
;
;	VAX/VMS Black Hole driver.
;
; ABSTRACT:
;
;	This driver is used to service the pusedo device Black_hole.
;	This device is similar to the Null device except that it can be used
;	to fool the JOB_CONTROLer.  This is needed for the PRINT SYMBIOANTS
;	which spool the print and punch streams for VAX HASP.
;
; AUTHOR:
;
;	M. Erik Husby, march 1981.
;
;--

	.SBTTL	External and local symbol definitions
	.LIBRARY	/SYS$LIBRARY:LIB/
;
; External symbols
;

	$DCDEF				; Device classes and types
	$DDBDEF				; Device data block
	$DEVDEF				; Device characteristics
	$IODEF				; I/O function codes
	$IRPDEF				; I/O request packet
	$SSDEF				; System status codes
	$UCBDEF				; Unit control block
	$VECDEF				; Interrupt vector block

;
; Local symbols
;
bh_k_def_bufsiz=256			; Default buffer size.

;
; Argument list (AP) offsets for device-dependent QIO parameters
;

P1	= 0				; First QIO parameter
P2	= 4				; Second QIO parameter
P3	= 8				; Third QIO parameter
P4	= 12				; Fourth QIO parameter
P5	= 16				; Fifth QIO parameter
P6	= 20				; Sixth QIO parameter


	.SBTTL	Standard tables

;
; Driver prologue table
;
	DPTAB	-				; DPT-creation macro
		END=BH_END,-			; End of driver label
		ADAPTER=NULL,-			; software device.
		UCBSIZE=<UCB$K_LENGTH>,-	; Length of UCB
		NAME=BHDRIVER			; Driver name
	DPT_STORE INIT				; Start of load
	DPT_STORE UCB,UCB$B_FIPL,B,8		; Fork IPL
	DPT_STORE UCB,UCB$B_DIPL,B,8		; Interrupt IPL
	DPT_STORE UCB,UCB$W_STS,W,-		; Indicate that we are on-line
		<<UCB$M_ONLINE!UCB$M_TEMPLATE>>	; and a template UCB.
	DPT_STORE UCB,UCB$L_DEVCHAR,L,<-	; Device characteristics
		DEV$M_CCL!-			;   e.g., carrage control
		DEV$M_REC!-			; record oriented.
		DEV$M_IDV!-			;   input device
		DEV$M_ODV>			;   output device
	DPT_STORE UCB,UCB$B_DEVCLASS,B,DC$_LP
	DPT_STORE UCB,UCB$W_DEVBUFSIZ,W,BH_K_DEF_BUFSIZ
	DPT_STORE REINIT			; Start of reload
	DPT_STORE DDB,DDB$L_DDT,D,BH$DDT	; Address of driver dispatch
						; table.
						; initialization table
	DPT_STORE END				; End of initialization
						; tables

;
; Driver dispatch table
;
	DDTAB	-				; DDT-creation macro
		DEVNAM=BH,-			; Name of device
		FUNCTB=BH_FUNCTABLE		; FDT address

;
; Function dispatch table
;

BH_FUNCTABLE:					; FDT for driver
	FUNCTAB	,-				; Valid I/O functions
		<READVBLK,-			; Read virtual
		READLBLK,-			; Read logical
		READPBLK,-			; Read physical
		WRITEVBLK,-			; Write virtual
		WRITELBLK,-			; Write logical
		WRITEPBLK,-			; Write physical
		SETCHAR-			; Set device charactistics
		>				; 
	FUNCTAB	,<>				; No buffered functions
	FUNCTAB	READ,-				; FDT read routine for
		<READVBLK,-			; read virtual,
		READLBLK,-			; read logical,
		READPBLK>			; and read physical.
	FUNCTAB	WRITE,-				; FDT write routine for
		<WRITEVBLK,-			; write virtual,
		WRITELBLK,-			; write logical,
		WRITEPBLK>			; and write physical.
	FUNCTAB BH_SETCHAR,-			; Used to reset characteristics
		<SETCHAR>			; ...

	.SBTTL	BH_READ_WRITE, Black hole Read and write.
;++
;
; Functional description:  Like the null device, all black_hole i/o
;	requests are completed in the function table routine.  All reads
;	get end of file, and all writes get success.
;
; Inputs:
;
;	R0-R2	- scratch registers
;	R3	- address of the IRP (I/O request packet)
;	R4	- address of the PCB (process control block)
;	R5	- address of the UCB (unit control block)
;	R6	- address of the CCB (channel control block)
;	R7	- bit number of the I/O function code
;	R8	- address of the FDT table entry for this routine
;	R9-R11	- scratch registers
;	AP	- address of the 1st function dependent QIO parameter
;
; Outputs:
;
;	The routine must preserve all registers except R0-R2, and
;	R9-R11.
;
;--
READ:
	movzwl	#ss$_endoffile,r0		; all reads get end of file
	brb	all_done
WRITE:
	movzwl	#ss$_normal,r0			; all writes get success
all_done:
	jmp	g^exe$finishioc			; and finish the i/o

	.SBTTL	BH_SETCHAR - Set characteristics
;++
;
; Functional description:  This routine is only used to reset the
;	characteristics of a black hole device.
;
; Inputs:
;
;	R0-R2	- scratch registers
;	R3	- address of the IRP (I/O request packet)
;	R4	- address of the PCB (process control block)
;	R5	- address of the UCB (unit control block)
;	R6	- address of the CCB (channel control block)
;	R7	- bit number of the I/O function code
;	R8	- address of the FDT table entry for this routine
;	R9-R11	- scratch registers
;	AP	- address of the 1st function dependent QIO parameter
;
; Outputs:
;
;	The routine must preserve all registers except R0-R2, and
;	R9-R11.
;
;--
bh_setchar:
	movw	#ucb$m_online,ucb$w_sts(r5)	; Indicate that we are on-line
	tstw	ucb$w_unit(r5)			; Are we unit 0?
	bneq	10$				; If so then indicate
	bisw2	#UCB$M_TEMPLATE,ucb$w_sts(r5)	; a template UCB.

10$:	movl	#DEV$M_CCL!-			;   e.g., carrage control
		DEV$M_REC!-			; record oriented.
		DEV$M_IDV!-			;   input device
		DEV$M_ODV,-			;   output device
		UCB$L_DEVCHAR(r5)
	movb	#DC$_LP,UCB$B_DEVCLASS(r5)	; Set class as LP
	
	movzwl	#SS$_NORMAL,r0			; Always success.
	jmp	g^exe$finishioc			; and finish the i/o

	.SBTTL	BH_END, End of driver

;++
; Label that marks the end of the driver
;--

BH_END:					; Last location in driver
	.END
