BADLT -- LAST TRACK HANDLING	MACRO M1110  22-AUG-78 02:06  PAGE 2





      1					.TITLE	BADLT -- LAST TRACK HANDLING

      2					.IDENT	/04/

      3					;

      4					;

      5					; COPYRIGHT (C) 1976,1977

      6					;

      7					;

      8					; THIS  SOFTWARE  IS  FURNISHED  UNDER A LICENSE FOR USE ONLY ON A

      9					; SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH THE INCLUSION

     10					; OF  THE  ABOVE COPYRIGHT  NOTICE.  THIS SOFTWARE, OR  ANY  OTHER

     11					; COPIES THEREOF, MAY NOT BE PROVIDED OR OTHERWISE  MADE AVAILABLE

     12					; TO  ANY  OTHER PERSON  EXCEPT  FOR USE ON SUCH SYSTEM AND TO ONE

     13					; WHO AGREES TO THESE LICENSE TERMS.  TITLE  TO  AND  OWNERSHIP OF

     14					; THE SOFTWARE SHALL AT ALL TIMES REMAIN IN DIGITAL.

     15					;

     16					; THE  INFORMATION  IN THIS DOCUMENT IS SUBJECT  TO CHANGE WITHOUT

     17					; NOTICE AND SHOULD NOT BE CONSTRUED AS A  COMMITMENT  BY  DIGITAL

     18					; EQUIPMENT CORPORATION.

     19					;

     20					; DIGITAL ASSUMES NO  RESPONSIBILITY FOR THE USE OR RELIABILITY OF

     21					; ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

     22					;

     23					;

     24					; VERSION 04

     25					;

     26					; P. WANNHEDEN 14-AUG-76

     27					;

     28					;

     29					; MODIFIED BY:

     30					;

     31					;	P. J. BEZEREDI 01-NOV-76

     32					;

     33					;		PB010 -- CHANGE LAST TRACK BAD BLOCK FILE HANDLING

     34					;			TO SUPPORT ANY LAST TRACK DEVICE.  BREAK

     35					;			BAD INTO SEPERATE MODULES.

     36					;

     37					;	P. J. BEZEREDI 30-NOV-77

     38					;

     39					;		PB040 -- CHANGE LAST TRACK HANDLING TO INCLUDE NEW

     40					;			HEADER AND MDBSF FORMAT.

     41					;

     42						.MCALL	DIR$, WTSE$S

     43

     44

     45						.IF DF	R$$11M!R$$11S

     46					.MACRO	SOB	REG,LABEL

     47						DEC	REG

     48						BNE	LABEL

     49					.ENDM	SOB

     50						.ENDC

BADLT -- LAST TRACK HANDLING	MACRO M1110  22-AUG-78 02:06  PAGE 3





     52

     53					;+

     54					; **-$LTRCK-HANDLE LAST TRACK DISKS

     55					;

     56					; SPECIAL HANDLING OF BAD SECTOR FILES ON LAST TRACK OF

     57					; DEVICES WHICH SUPPORT MANUFACTURES BAD SECTOR FILES.

     58					;

     59					; THIS SUBROUTINE IS CALLED AFTER THE

     60					; DISK HAS BEEN EXERCISED AND ALL BAD SECTORS HAVE

     61					; BEEN FOUND AND ENTERED IN THE BUFFER "$BADBK".

     62					; $LTRCK WRITES THE BAD SECTOR INFORMATION IN THE

     63					; "SOFTWARE DETECTED BAD SECTOR FILE" ($SDBSF) IN THE

     64					; LAST TRACK ON THE DISK, WITH THE SAME FORMAT

     65					; AS THE "MANUFACTURER DETECTED BAD SECTOR FILE" ($MDBSF),

     66					; WHICH IS ALSO IN THE LAST TRACK.

     67					;

     68					; EACH BAD SECTOR FOUND IS CHECKED AGAINST THE CONTENTS

     69					; OF THE MDBSF, AND IF A MATCH IS FOUND, NO ENTRY

     70					; IS CREATED IN THE SDBSF.  THUS THE CONTENTS OF THE MDBSF

     71					; PLUS THE CONTENTS OF THE SDBSF WILL EQUAL THE TOTAL BAD

     72					; BLOCKS ON THE DISK.

     73					;

     74					; FOR DISKS WHICH HAVE MULTIPLE SECTORS FOR EACH BLOCK,

     75					; AN ENTRY FOR EACH SECTOR WILL BE MADE IN THE SDBSF.

     76					;

     77					; INPUT:

     78					;

     79					;	R4	POINTER IN $BADBK BUFFER JUST AFTER

     80					;		LAST ENTRY CREATED.

     81					;	$MXLBN	(DOUBLE WORD) NUMBER OF BLOCK FOLLOWING LAST

     82					;		BLOCK EXERCISED (I.E. START OF MDBSF).

     83					;

     84					; OUTPUT:

     85					;

     86					;	CARRY IS 0 FOR SUCCESS

     87					;

     88					;	CARRY IS 1 FOR ERROR AND

     89					;	R0=POINTER TO ERROR MESSAGE FOR ROUTINE $MESAG

     90					;

     91					;-

     92

     93	000000	010446 			$LTRCK::MOV	R4,-(SP)	; SAVE END OF BADBLK

     94	000002					CALL	$RMBBF		; READ MDBSF

     95	000006	103002 				BCC	10$		; IF CC OK

     96	000010	000167 	000442 			JMP	300$		; ERROR READING MDBSF

     97	000014	012704 	000000G		10$:	MOV	#$SBBUF,R4	; POINT AT SDBSF BUFFER

     98	000020	012703 	000000G			MOV	#$MBBUF,R3	; POINT AT MDBSF BUFFER

     99	000024	012324 				MOV	(R3)+,(R4)+	; COPY FIRST 4 WORDS FROM MDBSF TO SDBSF

    100	000026	012324 				MOV	(R3)+,(R4)+

    101	000030	012324 				MOV	(R3)+,(R4)+

    102	000032	012324 				MOV	(R3)+,(R4)+

    103	000034	012705 	000004G			MOV	#$BADBK+4,R5	; POINT AT FIRST ENTRY IN BADBLK

    104	000040	020516 			40$:	CMP	R5,(SP)		; END OF BADBLK?

    105	000042	001533 				BEQ	100$		; IF EQ YES

    106	000044	016500 	000000G			MOV	BB.NLO(R5),R0	; GET LOW ORDER

    107	000050	005002 				CLR	R2		;

    108	000052	156502 	000000G			BISB	BB.NHI(R5),R2	; GET HIGH ORDER

BADLT -- LAST TRACK HANDLING	MACRO M1110  22-AUG-78 02:06  PAGE 3-1





    109	000056	005003 				CLR	R3

    110	000060	156503 	000000G			BISB	BB.CNT(R5),R3	; GET SIZE

    111	000064	005203 				INC	R3		; ADJUST

    112	000066	062705 	000000G			ADD	#$PTRSZ,R5	; STEP POINTER IN BUFFER

    113	000072	010267 	000000G		45$:	MOV	R2,$BBLK	; SAVE BLOCK NUMBER

    114	000076	010067 	000002G			MOV	R0,$BBLK+2	;

    115	000102	012701 	000020 			MOV	#16.,R1		; SET DIVIDE LOOP COUNT

    116	000106	006300 			50$:	ASL	R0		; DOUBLE LEFT SHIFT

    117	000110	006102 				ROL	R2		;

    118	000112	020267 	000000G			CMP	R2,$LTBPC	; PARTIAL REMAINDER LARGER THAN DIVISOR?

    119	000116	103403 				BLO	55$		; IF LO NO

    120	000120	166702 	000000G			SUB	$LTBPC,R2	; REDUCE BY BLOCKS/CYLINDER

    121	000124	005200 				INC	R0		; ACCUMULATE QUOTENT

    122	000126	005301 			55$:	DEC	R1		; ANY MORE PARTIAL DIVIDES?

    123	000130	003366 				BGT	50$		; IF GT YES

    124	000132	010067 	000000G			MOV	R0,$BCYL	; SAVE CYLINDER NUMBER

    125

    126

    127						.IF DF	R$$11M!R$$11S

    128

    129	000136	010200 				MOV	R2,R0		; SET DIVIDEND TO TRACK/SECTOR REMAINDER

    130	000140	016701 	000000G			MOV	$LTBPT,R1	; SET DIVISOR TO BLOCKS/TRACK

    131	000144					CALL	$DIV		; CALCULATE TRACK AND SECTOR

    132

    133						.IFF

    134

    135						CLR	R0		; CLEAR REMAINDER

    136						MOV	R2,R1		; SET DIVIDEND

    137						DIV	$LTBPT,R0	; CALCULATE TRACK AND SECTOR

    138

    139						.ENDC

    140

    141

    142	000150	110067 	000000G			MOVB	R0,$BTRK	; SAVE TRACK NUMBER

    143	000154	016700 	000000G			MOV	$LTBLK,R0	; GET SECTORS/BLOCK

    144	000160	010067 	000000G			MOV	R0,$LTDSK	; AND SAVE IT

    145

    146

    147						.IF DF	R$$11M!R$$11S

    148

    149	000164					CALL	$MUL		; CONVERT REMAINDER TO SECTOR IN TRACK

    150

    151						.IFF

    152

    153						MUL	R0,R1		; CONVERT REMAINDER TO SECTOR IN TRACK

    154

    155						.ENDC

    156

    157

    158	000170	110167 	000000G			MOVB	R1,$BSEC	; SAVE SECTOR NUMBER

    159	000174	010546 			59$:	MOV	R5,-(SP)	; SAVE POINTER IN $BADBK

    160	000176	012705 	000010G			MOV	#$MBBUF+10,R5	; POINT AT FIRST ENTRY IN MDBSF

    161	000202	020527 	001000G		60$:	CMP	R5,#$MBBUF+1000	; END OF MDBSF?

    162	000206	103017 				BHIS	80$		; IF HIS YES

    163	000210	021527 	177777 			CMP	(R5),#-1

    164	000214	001414 				BEQ	80$		; IF EQ YES

    165	000216	042715 	010000 			BIC	#10000,(R5)	; CLEAR POSSIBLE FORMAT BIT

BADLT -- LAST TRACK HANDLING	MACRO M1110  22-AUG-78 02:06  PAGE 3-2





    166	000222	026725 	000000G			CMP	$BCYL,(R5)+	; IS THIS A MATCH?

    167	000226	001005 				BNE	70$		; IF NE NO

    168	000230	042715 	140000 			BIC	#140000,(R5)	; CLEAR SECTOR FLAGS

    169	000234	026715 	000000G			CMP	$BSEC,(R5)

    170	000240	001413 				BEQ	90$		; IF EQ YES

    171	000242	005725 			70$:	TST	(R5)+

    172	000244	000756 				BR	60$		; LOOP

    173					;

    174					; NO MATCH FOUND IN MDBSF. CREATE ENTRY IN SDBSF

    175					; IF THERE IS ROOM FOR IT.

    176					;

    177	000246	020427 	001000G		80$:	CMP	R4,#$SBBUF+1000	; SDBSF FULL?

    178	000252	103073 				BHIS	220$		; IF HIS YES

    179	000254	016724 	000000G			MOV	$BCYL,(R4)+	; MAKE NEW ENTRY

    180	000260	016714 	000000G			MOV	$BSEC,(R4)	;

    181	000264	052724 	040000 			BIS	#40000,(R4)+	; SET FLAGS TO SHOW DATA ERROR

    182	000270	012605 			90$:	MOV	(SP)+,R5	; RESTORE POINTER IN $BADBK

    183	000272	005367 	000000G			DEC	$LTDSK		; ANY MORE SECTORS/BLOCK?

    184	000276	001403 				BEQ	95$		; IF EQ NO

    185	000300	105267 	000000G			INCB	$BSEC		; UPDATE SECTOR NUMBER

    186	000304	000733 				BR	59$		; SEARCH MDBSF FOR SECTOR

    187	000306	016702 	000000G		95$:	MOV	$BBLK,R2	; RETREIVE HIGH ORDER BLOCK NUMBER

    188	000312	016700 	000002G			MOV	$BBLK+2,R0	; DITTO FOR LOW ORDER

    189	000316	062700 	000001 			ADD	#1,R0		; UPDATE BLOCK NUMBER

    190	000322	005502 				ADC	R2		;

    191	000324	005303 				DEC	R3		; MORE BLOCKS IN CLUSTER?

    192	000326	001261 				BNE	45$		; IF NE YES

    193	000330	000643 				BR	40$		; ELSE GO GET NEW ENTRY FROM BADBLK

    194					;

    195					; ALL BAD BLOCKS PROCESSED. FILL REST OF SDBSF BUFFER

    196					; (IF NOT FULL) WITH -1'S.

    197					;

    198	000332	020427 	001000G		100$:	CMP	R4,#$SBBUF+1000

    199	000336	103003 				BHIS	110$

    200	000340	012724 	177777 			MOV	#-1,(R4)+

    201	000344	000772 				BR	100$

    202					;

    203					; WRITE SDBSF IN ALL EVEN-NUMBERED BLOCKS OF THE

    204					; SDBSF AREA IN THE LAST TRACK.

    205					;

    206	000346	016767 	000000G	000000G	110$:	MOV	$MXLBN,$LBNH	; SET START OF MDBSF

    207	000354	016767 	000002G	000000G		MOV	$MXLBN+2,$LBNL	;

    208	000362	066767 	000000G	000000G		ADD	$LTMBS,$LBNL	;ADJUST TO START OF SDBSF

    209	000370	005567 	000000G			ADC	$LBNH		;

    210	000374	012705 	000000G			MOV	#$SBBUF,R5	; SET BUFFER ADDRESS

    211	000400	012703 	000000C			MOV	#IO.WLT!IQ.X!<IO.WLC&377>,R3 ; SET FUNCTION CODE

    212									; TO WRITE LAST TRACK WITH WRITE CHECK

    213	000404	016701 	000000G			MOV	$LTSBS,R1	; GET # OF BLOCKS IN SDBSF

    214	000410	006201 				ASR	R1		; DIVIDE BY 2

    215	000412				120$:	CALL	$DSKIO		; WRITE A BLOCK

    216	000416	103415 				BCS	230$		; IF CS ERROR

    217	000420	062767 	000002 	000000G		ADD	#2,$LBNL	; STEP 2 BLOCKS

    218	000426	005567 	000000G			ADC	$LBNH		;

    219	000432					SOB	R1,120$		; WRITE ALL SDBSF'S

    220	000436	005726 				TST	(SP)+		; PRUNE STACK AND CLEAR CARRY

    221	000440					RETURN

    222					;

BADLT -- LAST TRACK HANDLING	MACRO M1110  22-AUG-78 02:06  PAGE 3-3





    223	000442	005726 			220$:	TST	(SP)+		; PRUNE STACK

    224	000444	012700 	000000G			MOV	#$MSG7,R0	; SDBSF OVERFLOW

    225	000450	000402 				BR	300$

    226	000452	012700 	000000G		230$:	MOV	#$MSG14,R0	; FAILED TO WRITE SDBSF

    227					;

    228	000456	005126 			300$:	COM	(SP)+		; SKIP 1 WORD FROM STACK, SET CC-C

    229	000460					RETURN

    230

    231

    232					;+

    233					; **-$RMBBF-READ MANUFACTURES BAD BLOCK FILE

    234					;

    235					; READ MANUFACTURER DETECTED BAD SECTOR FILE.

    236					;

    237					; INPUT:

    238					;

    239					;	$MXLBN	(DOUBLE WORD) DISK ADDRESS OF START OF MDBSF

    240					;

    241					; OUTPUT:

    242					;

    243					;	CARRY IS 0 IF SUCCESS AND

    244					;	R0=0

    245					;

    246					;	CARRY IS 1 FOR FAILURE AND

    247					;	R0=ADDRESS OF ERROR MESSAGE

    248					;

    249					;-

    250

    251	000462	012767 	001000 	000000G	$RMBBF::MOV	#1000,$XFRSZ	; SET TRANSFER LENGTH = 1 SECTOR

    252	000470	016767 	000000G	000000G		MOV	$MXLBN,$LBNH	; SET DISK ADDRESS OF MDBSF

    253	000476	016767 	000002G	000000G		MOV	$MXLBN+2,$LBNL	;

    254	000504	012705 	000000G			MOV	#$MBBUF,R5	; SET BUFFER ADDRESS

    255	000510	012703 	000000C			MOV	#IO.RLB!IQ.X,R3	; SET FUNCTION = READ WITHOUT RECOVERY

    256	000514	016701 	000000G			MOV	$LTMBS,R1	; GET # OF BLOCKS IN MDBSF

    257	000520	006201 				ASR	R1		; DIVIDE BY 2

    258	000522				10$:	CALL	$DSKIO		; READ 1 BLOCK FROM MDBSF

    259	000526	103010 				BCC	20$		; IF CC OK

    260	000530	062767 	000002 	000000G		ADD	#2,$LBNL	; TRY NEXT USABLE BLOCK

    261	000536	005567 	000000G			ADC	$LBNH		;

    262	000542					SOB	R1,10$		; LOOP

    263	000546	000422 				BR	50$		; ALL BAD - EXIT

    264	000550	005000 			20$:	CLR	R0		; A GOOD MDBSF BLOCK HAS BEEN READ

    265	000552	005767 	000000G			TST	$MBBUF		; CHECK THAT SERIAL NUMBER IS NON-ZERO

    266	000556	001003 				BNE	30$		; IF NE OK

    267	000560	005767 	000002G			TST	$MBBUF+2

    268	000564	001410 				BEQ	40$		; IF EQ ZERO

    269	000566	016701 	000006G		30$:	MOV	$MBBUF+6,R1	; GET ALIGNMENT DISK FLAG

    270	000572	001413 				BEQ	70$		; IF EQ GOOD DISK

    271	000574	005201 				INC	R1		; NON-ZERO - IS IT ALL 1'S?

    272	000576	001003 				BNE	40$		; IF NE IT'S NOT AN ALIGNMENT DISK ...

    273									; ... BUT MDBSF IS CORRUPT

    274	000600	012700 	000000G			MOV	#$MSG19,R0	; IT IS AN ALIGNMENT DISK

    275	000604	000405 				BR	60$		; EXIT WITH ERROR

    276	000606	012700 	000000G		40$:	MOV	#$MSG18,R0	; MDBSF CORRUPT

    277	000612	000402 				BR	60$

    278	000614	012700 	000000G		50$:	MOV	#$MSG21,R0	; CAN'T READ MDBSF

    279	000620	000261 			60$:	SEC

BADLT -- LAST TRACK HANDLING	MACRO M1110  22-AUG-78 02:06  PAGE 3-4





    280	000622				70$:	RETURN

    281					;

    282		000001 				.END

BADLT -- LAST TRACK HANDLING	MACRO M1110  22-AUG-78 02:06  PAGE 3-5

SYMBOL TABLE



A$$CHK= 000000   	G$$TTK= 000000   	M$$NET= 000000   	R$$X11= 000001   	X$$DBT= 000000

A$$CPS= 000000   	IO.RLB= ****** GX	M$$OVR= 000000   	R$$11M= 000000   	$BADBK= ****** GX

A$$NSI= 000000   	IO.WLC= ****** GX	N$$CON= 000144   	S$$WPC= 000036   	$BBLK = ****** GX

A$$PRI= 000000   	IO.WLT= ****** GX	N$$LDV= 000001   	S$$WPR= 000005   	$BCYL = ****** GX

A$$TRP= 000000   	IQ.X  = ****** GX	N$$MOV= 000021   	S$$WRG= 000000   	$BSEC = ****** GX

BB.CNT= ****** GX	I$$RAR= 000000   	N$$MXM= 000400   	S$$YSZ= 030000   	$BTRK = ****** GX

BB.NHI= ****** GX	I$$RDN= 000000   	N$$TMO= 000012   	T$$ACR= 000000   	$DIV  = ****** GX

BB.NLO= ****** GX	K$$CNT= 177546   	P$$D70= 000000   	T$$BTW= 000000   	$DSKIO= ****** GX

C$$CDA= 000001   	K$$CSR= 177546   	P$$GMX= 000000   	T$$BUF= 000000   	$LBNH = ****** GX

C$$CKP= 000000   	K$$LDC= 000000   	P$$LAS= 000000   	T$$CCA= 000000   	$LBNL = ****** GX

C$$ORE= 002000   	K$$TPS= 000074   	P$$P11= 000001   	T$$CCO= 000000   	$LTBLK= ****** GX

C$$OVL= 000000   	LD$DB = 000000   	P$$P45= 000000   	T$$CTR= 000000   	$LTBPC= ****** GX

C$$RSH= 177564   	LD$DK = 000000   	P$$RFL= 000000   	T$$C11= 000001   	$LTBPT= ****** GX

D$$BUG= 177514   	LD$DS = 000000   	P$$RTY= 000000   	T$$GMC= 000000   	$LTDSK= ****** GX

D$$H11= 000002   	LD$DT = 000000   	P$$R11= 000001   	T$$GTS= 000000   	$LTMBS= ****** GX

D$$IAG= 000000   	LD$DX = 000000   	P$$SRF= 000000   	T$$J16= 000001   	$LTRCK  000000RG

D$$ISK= 000000   	LD$LP = 000000   	P$$TPT= 000000   	T$$KMG= 000000   	$LTSBS= ****** GX

D$$L11= 000001   	LD$MM = 000000   	Q$$OPT= 000014   	T$$LWC= 000000   	$MBBUF= ****** GX

D$$M11= 000001   	LD$PP = 000000   	R$$DER= 000000   	T$$MAN= 016703   	$MSG14= ****** GX

D$$SHF= 000000   	LD$PR = 000000   	R$$EXV= 000000   	T$$RNE= 000000   	$MSG18= ****** GX

D$$YNC= 000000   	LD$TT = 000000   	R$$JPO= 000000   	T$$RPR= 000000   	$MSG19= ****** GX

D$$YNM= 000000   	L$$ASG= 000000   	R$$JP1= 000001   	T$$RST= 000000   	$MSG21= ****** GX

E$$DVC= 000000   	L$$DRV= 000000   	R$$JS1= 000001   	T$$RUB= 000000   	$MSG7 = ****** GX

E$$NSI= 000000   	L$$P11= 000001   	R$$KWC= 000000   	T$$SYN= 000000   	$MUL  = ****** GX

E$$PER= 000000   	L$$11R= 000000   	R$$K11= 000001   	T$$TRW= 000000   	$MXLBN= ****** GX

E$$XPR= 000000   	M$$CRB= 000124   	R$$LKL= 000000   	T$$VBF= 000000   	$PTRSZ= ****** GX

F$$AST= 000000   	M$$CRX= 000000   	R$$NDC= 000006   	U$$MHI= 000040   	$RMBBF  000462RG

F$$LPP= 000000   	M$$EXT= 000000   	R$$NDH= 000144   	U$$MLO= 120000   	$SBBUF= ****** GX

F$$LVL= 000001   	M$$FCS= 000000   	R$$NDL= 000001   	U$$MRN= 170324   	$XFRSZ= ****** GX

G$$TPP= 000000   	M$$MGE= 000000   	R$$SND= 000000   	V$$CTR= 000400   	$$$R4 = 000000

G$$TSS= 000000   	M$$MUP= 000000   	R$$VAX= 000000



. ABS.	000000	   000

      	000624	   001

ERRORS DETECTED:  0



VIRTUAL MEMORY USED:  4005 WORDS  ( 16 PAGES)

DYNAMIC MEMORY:  4884 WORDS  ( 18 PAGES)

ELAPSED TIME:  00:00:09

OBJ$:BADLT,LIS$:BADLT/-SP=SRC$:RSXMC/PA:1,BADLT

