/RLSY: RL01 SYSTEM HANDLER
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1977 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED TO THE PURCHASER
/UNDER A LICENSE FOR USE ON A SINGLE COMPUTER SYSTEM AND CAN BE COPIED
/(WITH INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR USE IN SUCH
/SYSTEM, EXCEPT AS MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/
/RL01 SYSTEM HANDLER

	VERSION="A&77

/NOTES:
/1. PRE-OMNIBUS COMPUTERS NOT SUPPORTED.

/EDIT HISTORY:
/21-OCT-77 DAVID SPECTOR: CREATION

/INSTRUCTIONS THAT GENERATE CONSTANTS

AC0001=CLA IAC
AC0002=CLA CLL CML RTL
AC0003=CLA CLL CML IAC RAL	/*
AC0004=CLA CLL IAC RTL		/*
AC0006=CLA CLL CML IAC RTL	/*
AC0100=CLA IAC BSW		/*
AC2000=CLA CLL CML RTR
AC3777=CLA CLL CMA RAR
AC4000=CLA CLL CML RAR
AC5777=CLA CLL CMA RTR
AC6000=CLA CLL CML IAC RTR	/*
AC7775=CLA CLL CMA RTL
AC7776=CLA CLL CMA RAL

/* USE ONLY ON VT-78 AND PDP-8E,F,M,A

/ID CODE AT START OF BAD BLOCK LIST (BBL)
	ID=123
/RL01 DEFINITIONS

RLIOT=6600
RLDC=RLIOT 0	/CLEAR DEVICE
RLSD=RLIOT 1	/SKIP IF DONE
RLMA=RLIOT 2	/LOAD MEM ADDR
RLCA=RLIOT 3	/LOAD REGISTER "A"
RLCB=RLIOT 4	/LOAD REG "B" AND EXECUTE
RLSA=RLIOT 5	/LOAD SECTOR ADDR
		/RLIOT 6 UNUSED
RLWC=RLIOT 7	/LOAD WORD COUNT
RRER=RLIOT 10	/READ ERROR REG
RRWC=RLIOT 11	/READ WORD COUNT
RRCA=RLIOT 12	/READ REG "A"
RRCB=RLIOT 13	/READ REG "B"
RRSA=RLIOT 14	/READ SECTOR ADDR
RRSI=RLIOT 15	/READ SILO BYTE
		/RLIOT 16 UNUSED
RLSE=RLIOT 17	/SKIP IF ERROR
/RLCB FUNCTION BITS:
	RLMT=0	/MAINTENANCE MODE
	RLRE=1	/RESET DRIVE ERRORS
	RLST=2	/READ STATUS REGS INTO SILO
	RLSK=3	/SEEK
	RLRH=4	/READ HEADER
	RLWR=5	/WRITE
	RLRD=6	/READ
	RLRN=7	/READ WITH NO HEADER CHECK
/BIT DEFINITIONS IN REGISTERS:
BYTE=1000	/BYTE TRANSFER MODE
/HEADER BLOCK FOR USE BY "BUILD"

	*0
	-2		/- NR. OF ENTRY POINTS

/FORMAT OF ENTRIES IN HEADER BLOCK:
/WORD	DESCRIPTION
/1	GROUP NAME (4 CHAR)
/3	DEVICE NAME (4 CHAR)
/5	DCB WORD FOR AN RL (TYPE 26) DIRECTORY DEVICE,
/	NO MULTIPLE PLATTERS
/6	2-PAGE/SYS/CORESIDENT INDICATOR, OFFSET
/7	0 (UNUSED WORD)
/10	NUMBER OF BLOCKS IN DEVICE

DEVICE RLSY;DEVICE SYS;4260;SYS&177+6000;0;7761
DEVICE RLSY;DEVICE RL0A;4260;SYS&177+5000;0;7761
/DEVICE RLSY;DEVICE RL0B;4260;RL0B&177+5000;0;7761
/RL01 SECONDARY BOOTSTRAP

/SYSTEM MAP:
/BLOCK	CYL.	SURF.	SECTOR	CONTENTS
/0	0	0	20	SECONDARY BOOTSTRAP
/0	0	0	22	FIELD 0 RESIDENT
/66	1	1	1	FIELD 1 RESIDENT
/66	1	1	3	FIELD 2 RESIDENT

/RESIDENT MONITOR CODE OCCUPIES LAST PAGE OF FIELD
/FIELD 0 PAGE IS MONITOR CODE AND SYSTEM HANDLER
/FIELD 1 PAGE IS MONITOR TABLES
/FIELD 2 PAGE IS SYSTEM HANDLER

	BOOTA-BOOTB	/-LENGTH FOR "BUILD"

	RELOC 0		/WILL RUN AT 00000

BOOTA,			/START OF BOOTSTRAP CODE

/DATA
C16,	16
C26,	26
C300,	300
C2001,	2001
C6001,	6001
C7600,	7600
C7605,	7605
SECT,	2200		/INITIAL BLOCK 0 VALUE
SURCYL,	0		/INITIAL BLOCK 0 VALUE

	ZBLOCK 31-2-.	/LOCATE "IOSUB" (SEE BELOW)

FUNC,			/TEMPORARY STORAGE FOR RL01
			/FUNCTION WORD
IOSUB,	BOOT		/SUBROUTINE TO DO I/O; MATCHES
			/SIMILAR SUBR IN PRIMARY BOOTSTRAP
			/INITIAL VALUE WILL START SEC-
			/ONDARY BOOTSTRAP WHEN IT HAS BEEN
			/COMPLETELY READ IN.
	RLCB		/EXECUTE RL01 FUNCTION
	RLSD		/WAIT UNTIL DONE. NOTE: THIS WORD
			/AND THE NEXT ONE MUST BE IN THE
			/SAME LOCATIONS AS THEIR COUNTER-
			/PARTS IN THE PRIMARY BOOTSTRAP.
	JMP .-1
	RLSE
	JMP I IOSUB	/NO ERRORS: RETURN
	JMP .		/ERROR OCCURRED: LOOP IN PLACE AS
			/A CLEAR INDICATION THAT BOOTSTRAP
			/OPERATION FAILED.

/START OF SECONDARY BOOTSTRAP OPERATIONS
BOOT,	AC0006		/AC=READ FUNCTION
	JMS READ	/READ FIELD 0 RESIDENT
	RLDC		/CLEAR CONTROLLER REGISTERS IN
			/PREPARATION FOR SEEK
	TAD C6001	/DIFFERENCE WORD FOR CYL 1 SURF 1
	RLCA		/LOAD "A"
	AC0003		/AC=SEEK FUNCTION
	JMS IOSUB	/SEEK
	AC0100		/AC=SECTOR 1
	DCA SECT
	TAD C2001	/AC=CYL 1 SURF 1
	DCA SURCYL
	TAD C16		/AC=READ FUNCTION
	JMS READ	/READ FIELD 1 RESIDENT
	TAD C300	/AC=SECTOR 3
	DCA SECT
	TAD C26		/AC=READ FUNCTION
	JMS READ	/READ FIELD 2 RESIDENT
	CDF 00		/JUST IN CASE
	JMP I C7605	/START KEYBOARD MONITOR

/SUBROUTINE TO READ ONE SECTOR INTO ONE PAGE
READ,	0
	DCA FUNC	/SAVE FUNCTION WORD
	TAD SECT
	RLSA		/LOAD SECTOR ADDRESS
	TAD C7600
	RLWC		/LOAD WORD COUNT
	TAD SURCYL
	RLCA		/LOAD REGISTER "A"
	TAD C7600
	RLMA		/LOAD MA (ALL READS ARE INTO
			/LAST PAGE OF FIELDS)
	TAD FUNC	/RETRIEVE FUNCTION WORD
	JMS IOSUB	/DO THE READ
	JMP I READ	/NO ERROR: RETURN

BOOTB,			/END OF BOOTSTRAP CODE

	RELOC
/RL01 SYSTEM HANDLER CODE

	*200
	RELOC 7600

	ZBLOCK 7	/REQUIRED BY BUILD

/ENTRY POINT FOR SYS
SYS,	VERSION
	CLA
SWITCH,	JMP START	/CHANGED TO "JMP SET"
			/BY ONCE-ONLY CODE AT "START"
	3		/THIS IS A FLAG TO OS/8 THAT
			/THIS IS A 2-PAGE HANDLER.

/----- BAD BLOCK LIST (BBL) STARTS HERE
/      AND CONTINUES FOR 21 OCTAL LOCATIONS

BBL,

/ONCE-ONLY DATA
JMPSET,	JMP SET
COUNT,	-10
ADDR,	BARG
ABRTN,	BRTN
ACDIF,	CIF CDF 00

/ONCE-ONLY PARAMETERS FOR 2ND PAGE TO READ IN
/THE BAD BLOCK LIST (BBL) FOR DEVICE RL0A
LIST,	ARTN		/BARG: RETURN TO SELF
	1400		/SECTOR: SECTOR 14
	0		/TRACK: 0
	BBL		/MA: MA
	200		/PAGES: 1 PAGE COUNT
	RLRD		/FNC: READ FUNCTION
	-21		/WC: LENGTH OF READ
	2000		/CURTRK: FORCE HEADER READ
/ONCE-ONLY CODE TO READ IN BAD BLOCK LIST (BBL)

START,	RDF		/ONCE-ONLY CODE. DESTROYED WHEN
			/BBL IS READ IN ON TOP OF IT.
			/FIRST, SAVE CALLING FIELD OVER
			/THE READ-IN OF THE BBL.
	TAD BACK	/(INITIALLY CONTAINS A CDF)
	DCA BACK
	TAD JMPSET	/NEXT, RESET "SWITCH" TO SKIP
			/AROUND ONCE-ONLY CODE FROM
			/NOW ON.
	DCA SWITCH
	CDF 20
LOOP,	TAD LIST	/RESET ONCE-ONLY DATA IN 2ND PAGE
	DCA I ADDR	/(THIS IS REQUIRED BECAUSE "BUILD"
	ISZ LOOP	/DOESN'T ALLOW ONCE-ONLY CODE IN
	ISZ ADDR	/2ND PAGE OF 2-PAGE SYSTEM HANDLERS)
	IFNZRO .-7642	<KLUDGE:>
	CDF 20		/******** MUST BE AT LOCATION 7642
			/******** FOR FRTS.SV!
	ISZ COUNT
	JMP LOOP
	TAD ACDIF	/ANOTHER ONCE-ONLY RESET
	DCA I ABRTN
	JMS GO		/READ IN BBL
BACK,	CDF		/RESTORE CALLING FIELD

/----- ONCE-ONLY CODE ENDS HERE

/FALL THROUGH TO SET UP AND DO THE TRANSFER
/SET UP AND DO THE TRANSFER
SET,	TAD BASE	/INITIALIZE BAD BLOCK
			/MAPPING
	DCA MAP
	TAD SYS		/ADDR OF ARG LIST
	JMS GO		/CALL 2ND PAGE SETUP SUBROUTINE
			/DATA FIELD IS 2 ON RETURN
MAP,	TAD		/MAP AROUND BAD BLOCKS, IF
			/ANY.  LOOK AT NEXT BAD BLOCK.
	SNA		/IF 0, TERMINATOR
	JMP MAPPED
	STL CIA		/IF NOT, 13-BIT NEGATE
	TAD I ABLOCK	/SUBTRACT FROM CURRENT BLOCK
	SZL CLA		/SKIP IF BLOCK IS GREATER THAN
			/OR EQUAL TO BAD BLOCK
	JMP MAPPED	/ELSE NO MAPPING TO DO
	ISZ MAP
NEXT,	ISZ I ABLOCK	/INCREMENT CURRENT BLOCK,
			/EITHER DURING TRANSFER OR
			/TO MAP AROUND BAD BLOCK
	JMP MAP		/CONTINUE MAPPING UNTIL DONE
	CIF 20		/IF BLOCK EVER OVERFLOWS TO 0,
	JMP ERROR	/TAKE ERROR RETURN.

MAPPED,	TAD I ABLOCK	/CALCULATE TRACK AND SECTOR
			/FROM BLOCK
	RTR
	RTR
	AND A377
	DCA I ATRACK
	TAD I ABLOCK
	AND A17
	CLL RTL
	TAD A7751
	SPA
	TAD A47
	BSW
	DCA I ASECT
	JMS GO		/TRANSFER 1ST PAGE OF BLOCK
	TAD A200	/INCREMENT MA AND SECTOR
	TAD I AMA
	DCA I AMA
	TAD A200
	TAD I ASECT
	DCA I ASECT
	JMS GO		/TRANSFER 2ND PAGE OF BLOCK
	TAD A200	/INCREMENT MA
	TAD I AMA
	DCA I AMA
	JMP NEXT	/CONTINUE WITH NEXT BLOCK,
			/IF ANY
/SUBROUTINE TO CALL 2ND PAGE SUBR TO DO TRANSFER
GO,	0
	CIF 20
	JMS MAIN
ARTN,			/ON BBL READ, RETURN HERE
			/IF IO ERROR.
			/(ERROR WILL BE DETECTED
			/DURING 2ND PAGE VALIDITY
			/CHECK.)
	CDF 20		/DATA FIELD=2ND PAGE
	JMP I GO
/DATA
ASECT,	SECTOR
ATRACK,	TRACK
ABLOCK,	BLOCK
BASE,	TAD BBL+1	/SKIP ID CODE WORD
AMA,	MA
A17,	17
A47,	47
A200,	200
A377,	377
A7751,	7751

	ZBLOCK 7744-.	/UNUSED
/SECOND PAGE

	RELOC
	*400
	RELOC 7600

/SUBROUTINE TO SETUP OR TRANSFER
MAIN,	0
	SNA		/AC TELLS WHICH
	JMP TRANS	/NON-ZERO: TRANSFER
SETUP,	DCA BARG	/SAVE ADDRESS OF ARGUMENTS
	AC2000		/SET FOR INITIAL HEADER READ
	DCA CURTRK	/(2000 IS AN ILLEGAL TRACK)
	TAD B7600	/SET FOR FULL PAGE TRANSFERS
	DCA WC
	TAD I BARG	/GET HANDLER FUNCTION WORD
	AND B4070	/CONVERT TO RL01 FUNCTION
	SPA
	TAD B3777
	TAD BRLRD
	DCA FNC
	TAD I BARG
	RAL		/CONVERT TO PAGE COUNT
	AND B7600
	DCA PAGES
	ISZ BARG
	TAD I BARG	/GET MA
	DCA MA
	ISZ BARG
	TAD I BARG	/GET BLOCK
	DCA BLOCK
	ISZ BARG
	RDF		/SAVE CALLING FIELD
	TAD BCDIF	/FOR RETURN FROM HANDLER
	DCA BRTN
	CDF 00		/CHECK BBL FOR VALIDITY -
	TAD I BBBL	/A VALID BBL HAS AN ID
	TAD CHECK	/CODE IN ITS FIRST LOCATION
	SZA CLA
	JMP ERROR	/INVALID BBL: TAKE ERROR
			/RETURN FROM HANDLER
GOBACK,			/RETURN TO 1ST PAGE
BCDIF,	CIF CDF 00
	JMP I MAIN
/TRANSFER (READ OR WRITE)
TRANS,	AC7775		/SET FOR 3 TRIES
	DCA ERRCNT
	TAD TRACK	/CALCULATE CYLINDER AND
			/SURFACE FROM TRACK
	CLL RAR
	DCA CYL
	RTR
	DCA SURF
	JMS TRKCMP	/COMPARE TRACK WITH LAST
			/ONE TRANSFERRED; IF THE
			/SAME, DO TRANSFER.
RETRY,	RLDC		/IF DIFFERENT, OR IF RE-
			/TRYING, SEEK TO TRACK;
			/CLEAR CONTROLLER REGISTERS
			/FOR SEEK
SEEK,	IAC		/AC=1 FOR RESETTING DRIVE
			/REGISTERS (ERRORS), AC=3
			/FOR DOING SEEK
	JMS IO		/DO A RESET OR A SEEK
	TAD HEADER	/AC=READ HEADER FUNCTION
	JMS IO		/READ NEXT HEADER
	RRSI		/GET HEADER BYTE #1
	BSW		/CALCULATE TRACK
	AND B3
	DCA CURTRK
	RRSI		/GET HEADER BYTE #2
	AND B377
	CLL RTL
	TAD CURTRK
	DCA CURTRK
	JMS TRKCMP	/COMPARE CURRENT AND REQUESTED
			/TRACK; IF SAME, DO TRANSFER
	SPA		/IF DIFFERENT, SEEK: CALCULATE
	CLL CIA		/DIFFERENCE WORD
	RAR
	TAD SURF
	RLCA		/LOAD REGISTER "A"
	AC0002		/PREPARE FOR SEEK
	JMP SEEK	/LOOP BACK TO ENSURE THAT TRACK
			/REACHED IS REALLY THE DESIRED
			/TRACK, IN CASE OF RL01 SEEK
			/UNRELIABILITY.
/SUBROUTINE TO COMPARE CURRENT TRACK WITH REQUESTED
/TRACK AND DO TRANSFER IF THE SAME
TRKCMP,	0
	TAD CURTRK
	CIA
	TAD TRACK
	STL		/SET DIRECTION BIT IN
			/DIFFERENCE WORD IF DIFF-
			/ERENCE IS POSITIVE.
	SZA		/SAME?
	JMP I TRKCMP	/NO
	TAD SECTOR	/YES; LOAD DRIVE REGISTERS
	RLSA
	TAD WC
	RLWC
	TAD SURF
	TAD CYL
	RLCA
	TAD MA
	RLMA
	TAD FNC
	JMS IO		/READ OR WRITE
	TAD B7600	/COUNT PAGES TRANSFERRED
	TAD PAGES
	SNA
	JMP DONE	/NO MORE TO GO
	DCA PAGES
	JMP GOBACK	/MORE TO GO; RETURN TO
			/1ST PAGE

/SUBROUTINE TO DO RL01 I/O
IO,	0
	RLCB		/EXECUTE FUNCTION (DRIVE 0)
	RLSD		/WAIT UNTIL DONE
	JMP .-1
	RLSE		/ANY ERRORS?
	JMP I IO	/NO; RETURN
	ISZ ERRCNT	/YES; MORE RETRIES LEFT?
	JMP RETRY	/YES, RETRY IT.
ERROR,	AC4000		/NO, TAKE HANDLER ERROR
	SKP		/RETURN.
DONE,	ISZ BARG	/NORMAL HANDLER RETURN
BRTN,	CIF CDF 00	/RESTORE CALLING FIELD;
	JMP I BARG	/INITIALLY, RETURN TO 1ST PAGE
			/AFTER BBL READ-IN.
/DATA
B3,	3
B377,	377
B3777,	3777
B4070,	4070
B7600,	7600
HEADER,	BYTE RLRH
BRLRD,	RLRD
CHECK,	-ID
BBBL,	BBL
ERRCNT,	0
BLOCK,	0
SURF,	0
CYL,	0

/VARIABLES INITIALIZED TO PERFORM INITIAL BBL READ-IN
BARG,	ARTN		/INITIALLY, RETURN TO 1ST PAGE
			/AFTER BBL READ-IN.
SECTOR,	1400		/BBL: SECTOR 14 (TRACK 0)
TRACK,	0
MA,	BBL		/INITIAL BBL READ
PAGES,	200		/INITIAL BBL READ
FNC,	RLRD		/INITIAL BBL READ
WC,	-21		/INITIAL BBL READ
CURTRK,	2000		/INITIAL HEADER READ AND
			/SEEK IF REQUIRED.

	ZBLOCK 7774-.	/UNUSED

	ZBLOCK 4	/RESERVED FOR USE BY BATCH
			/IN 12K SYSTEMS.

	RELOC
$
