

; Bliss-32 10.1-416	Monday 21-AUG-1978 23:11:51	DBB3:[F11B.SRC]DELBAD.B32;10					Page 1

;

;	0001	MODULE DELBAD (

;	0002			LANGUAGE (BLISS32),

;	0003			IDENT = 'B0002'

;	0004			) =

;	0005	BEGIN

;	0006	

;	0007	!

;	0008	! Copyright (c) 1977

;	0009	! Digital Equipment Corporation, Maynard, Massachusetts 01754

;	0010	!

;	0011	! This software is furnished  under a license for use only on a single

;	0012	! computer  system and  may be  copied only with  the inclusion of the

;	0013	! above copyright notice.  This software, or any other copies thereof,

;	0014	! may not be provided or  otherwise made available to any other person

;	0015	! except for use on such system and to one who agrees to these license

;	0016	! terms.  Title to and  ownership of the  software  shall at all times

;	0017	! remain in DEC.

;	0018	!

;	0019	! The information in this software is subject to change without notice

;	0020	! and should  not be construed  as a commitment  by Digital  Equipment

;	0021	! Corporation.

;	0022	!

;	0023	! DEC assumes  no  responsibility  for  the use or  reliability of its

;	0024	! software on equipment which is not supplied by DEC.

;	0025	

;	0026	!++

;	0027	!

;	0028	! FACILITY:  F11ACP Structure Level 2

;	0029	!

;	0030	! ABSTRACT:

;	0031	!

;	0032	!	This routine removes the indicated blocks from the given file header

;	0033	!	and appends them to the bad block file.

;	0034	!

;	0035	! ENVIRONMENT:

;	0036	!

;	0037	!	STARLET operating system, including privileged system services

;	0038	!	and internal exec routines.

;	0039	!

;	0040	!--

;	0041	!

;	0042	!

;	0043	! AUTHOR:  Andrew C. Goldstein,	 CREATION DATE:  29-May-1978  22:43

;	0044	!

;	0045	! REVISION HISTORY:

;	0046	!

;	0047	!   Andrew C. Goldstein, 31-May-78  19:37

;	0048	!   B0002 - Position to last extension header

;	0049	!

;	0050	!**

;	0051	

;	0052	

;	0053	LIBRARY 'SYS$LIBRARY:LIB.L32';

;	0054	REQUIRE 'SRC$:FCPDEF.B32';



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:11:51	DBB3:[F11B.SRC]DELBAD.B32;10					Page 2

;

;	0403	GLOBAL ROUTINE DEALLOCATE_BAD (FIB, FILE_HEADER, DEALLOCATE, POINTER, LAST_COUNT) : NOVALUE =

;	0404	

;	0405	!++

;	0406	!

;	0407	! FUNCTIONAL DESCRIPTION:

;	0408	!

;	0409	!	This routine removes the indicated blocks from the given file header

;	0410	!	and appends them to the bad block file.

;	0411	!

;	0412	!

;	0413	! CALLING SEQUENCE:

;	0414	!	DEALLOCATE_BAD (ARG1, ARG2, ARG3, ARG4, ARG5)

;	0415	!

;	0416	! INPUT PARAMETERS:

;	0417	!	ARG1: address of user FIB

;	0418	!	ARG2: address of file header

;	0419	!	ARG3: = 1 to actually process the blocks

;	0420	!		0 to just clean up the file header

;	0421	!	ARG4: address of map pointer at which to start

;	0422	!	ARG5: new value for last pointer block count

;	0423	!

;	0424	! IMPLICIT INPUTS:

;	0425	!	NONE

;	0426	!

;	0427	! OUTPUT PARAMETERS:

;	0428	!	NONE

;	0429	!

;	0430	! IMPLICIT OUTPUTS:

;	0431	!	NONE

;	0432	!

;	0433	! ROUTINE VALUE:

;	0434	!	NONE

;	0435	!

;	0436	! SIDE EFFECTS:

;	0437	!	file header updated, bad block log file updated, bad block file extended

;	0438	!

;	0439	!--

;	0440	

;	0441	BEGIN

;	0442	

;	0443	MAP

;	0444		FIB		: REF BBLOCK,	! user FIB argument

;	0445		FILE_HEADER	: REF BBLOCK;	! address of file header

;	0446	

;	0447	LINKAGE

;	0448		L_MAP_POINTER	= JSB :

;	0449				GLOBAL (COUNT = 6, LBN = 7, MAP_POINTER = 8),

;	0450	

;	0451		L_MAKE_POINTER	= CALL :

;	0452				GLOBAL (BUILD_POINTER = 9);

;	0453	

;	0454	GLOBAL REGISTER

;	0455		COUNT		= 6,		! count of blocks returned

;	0456		LBN		= 7,		! LBN of map entry

;	0457		MAP_POINTER	= 8 : REF BBLOCK, ! pointer to scan map



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:11:51	DBB3:[F11B.SRC]DELBAD.B32;10					Page 2-1

;

;	0458		BUILD_POINTER	= 9 : REF BBLOCK; ! pointer to build new map entry

;	0459	

;	0460	LOCAL

;	0461		MAP_END,			! address of end of map pointers

;	0462		HEADER		: REF BBLOCK,	! local address of file header

;	0463		EXT_HEADER	: REF BBLOCK;	! address of extension header

;	0464	

;	0465	EXTERNAL

;	0466		CURRENT_VCB	: REF BBLOCK,	! address of VCB of volume

;	0467		CURRENT_WINDOW	: REF BBLOCK,	! window of file if open

;	0468		PRIMARY_FCB	: REF BBLOCK;	! FCB of file if open

;	0469	

;	0470	EXTERNAL ROUTINE

;	0471		GET_MAP_POINTER : L_MAP_POINTER, ! get value of next map entry

;	0472		MAKE_POINTER	: L_MAKE_POINTER, ! build new map entry

;	0473		NEXT_HEADER,			! read next extension header

;	0474		MARK_DIRTY,			! mark buffer for rewrite

;	0475		UPDATE_FILESIZE,		! update file size in FCB

;	0476		ZERO_WINDOWS,			! invalidate windows of file

;	0477		CHECKSUM,			! compute file header checksum

;	0478		READ_HEADER,			! read file header

;	0479		EXTEND_HEADER,			! create extention header

;	0480		SCAN_BADLOG;			! scan pending bad block log file

;	0481	

;	0482	

;	0483	! Construct pointers into the file header and get the current contents of the

;	0484	! last map pointer.

;	0485	!

;	0486	

;	0487	HEADER = .FILE_HEADER;

;	0488	BUILD_POINTER = MAP_POINTER = .POINTER;

;	0489	MAP_END = .HEADER + (.HEADER[FH2$B_MPOFFSET] + .HEADER[FH2$B_MAP_INUSE]) * 2;

;	0490	

;	0491	GET_MAP_POINTER ();

;	0492	

;	0493	! Check that (1) the pointer given is the last pointer in the header,

;	0494	! (2) the header is the last one for the file, and (3) that the quantity

;	0495	! being deallocated is exactly one cluster, this being the only condition

;	0496	! we can correstly handle.

;	0497	!

;	0498	

;	0499	IF .MAP_POINTER NEQ .MAP_END

;	0500	OR .COUNT - .LAST_COUNT NEQ .CURRENT_VCB[VCB$W_CLUSTER]

;	0501	OR .HEADER[FH2$W_EX_FIDNUM] NEQ 0

;	0502	OR .HEADER[FH2$W_EX_FIDSEQ] NEQ 0

;	0503	THEN ERR_EXIT (SS$_BADPARAM);

;	0504	

;	0505	! Now build a new last map pointer in the header, fix HIBLK, and do sundry

;	0506	! housekeeping.

;	0507	!

;	0508	

;	0509	MARK_DIRTY (.HEADER);

;	0510	IF .LAST_COUNT NEQ 0

;	0511	THEN MAKE_POINTER (.LAST_COUNT, .LBN, .HEADER);

;	0512	HEADER[FH2$B_MAP_INUSE] = (.BUILD_POINTER - .HEADER) / 2 - .HEADER[FH2$B_MPOFFSET];



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:11:51	DBB3:[F11B.SRC]DELBAD.B32;10					Page 2-2

;

;	0513	CH$FILL (0, .MAP_END - .BUILD_POINTER, .BUILD_POINTER);

;	0514	

;	0515	IF .PRIMARY_FCB NEQ 0

;	0516	THEN KERNEL_CALL (ZERO_WINDOWS, .PRIMARY_FCB);

;	0517	

;	0518	KERNEL_CALL (UPDATE_FILESIZE, .FIB[FIB$L_EXVBN] - 1);

;	0519	BBLOCK [HEADER[FH2$W_RECATTR], FAT$L_HIBLK] = ROT (.FIB[FIB$L_EXVBN] - 1, 16);

;	0520	CHECKSUM (.HEADER);

;	0521	

;	0522	IF NOT .DEALLOCATE THEN RETURN;		! done if just header cleanup

;	0523	

;	0524	! Now append the blocks to the bad block file.

;	0525	!

;	0526	

;	0527	PRIMARY_FCB = 0;			! no longer dealing with current file

;	0528	CURRENT_WINDOW = 0;

;	0529	

;	0530	LBN = .LBN + .LAST_COUNT;		! compute LBN of bad cluster

;	0531	COUNT = .COUNT - .LAST_COUNT;

;	0532	

;	0533	HEADER = READ_HEADER (UPLIT WORD (BADBLK_FID, BADBLK_FID, 0), 0);

;	0534	WHILE 1 DO

;	0535	    BEGIN

;	0536	    EXT_HEADER = NEXT_HEADER (.HEADER, 0);

;	0537	    IF .EXT_HEADER EQL 0 THEN EXITLOOP;

;	0538	    HEADER = .EXT_HEADER;

;	0539	    END;

;	0540	MARK_DIRTY (.HEADER);

;	0541	BUILD_POINTER = .HEADER + (.HEADER[FH2$B_MPOFFSET] + .HEADER[FH2$B_MAP_INUSE]) * 2;

;	0542	

;	0543	IF NOT MAKE_POINTER (.COUNT, .LBN, .HEADER)

;	0544	THEN

;	0545	    BEGIN

;	0546	    HEADER = EXTEND_HEADER (.HEADER, 0);

;	0547	    BUILD_POINTER = .HEADER + .HEADER[FH2$B_MPOFFSET] * 2;

;	0548	    MAKE_POINTER (.COUNT, .LBN, .HEADER);

;	0549	    END;

;	0550	

;	0551	BBLOCK [HEADER[FH2$W_RECATTR], FAT$L_HIBLK] =

;	0552		ROT (ROT (.BBLOCK [HEADER[FH2$W_RECATTR], FAT$L_HIBLK], 16) + .COUNT, 16);

;	0553	CHECKSUM (.HEADER);

;	0554	

;	0555	! Finally, remove the bad block cluster from the volume pending bad block log

;	0556	! file, if it was there.

;	0557	!

;	0558	

;	0559	SCAN_BADLOG (0, 0, .LBN, REMOVE_BADBLOCK, .COUNT);

;	0560	

;	0561	END;					! end of routine DEALLOCATE_BAD





							    .TITLE  DELBAD

							    .IDENT  \B0002\



							    .PSECT  $CODE$,NOWRT,2



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:11:51	DBB3:[F11B.SRC]DELBAD.B32;10					Page 2-3

;



			    0000  0003  0003  00000 P.AAA:  .WORD   3, 3, 0						      ;

					      00006	    .BLKB   2



							    .EXTRN  CURRENT_VCB, CURRENT_WINDOW, PRIMARY_FCB, GET_MAP_POINTER

							    .EXTRN  MAKE_POINTER, NEXT_HEADER, MARK_DIRTY, UPDATE_FILESIZE

							    .EXTRN  ZERO_WINDOWS, CHECKSUM, READ_HEADER, EXTEND_HEADER

							    .EXTRN  SCAN_BADLOG, SYS$CMKRNL



					 0FFC 00008 	    .ENTRY  DEALLOCATE_BAD, Save R2,R3,R4,R5,R6,R7,R8,R9,R10,R11      ; 0403

		         5B 00000000G  9F  9E 0000A 	    MOVAB   @#SYS$CMKRNL, R11					      ;

		         5A 	  08   AC  D0 00011 	    MOVL    FILE_HEADER, HEADER					      ; 0487

		         58 	  10   AC  D0 00015 	    MOVL    POINTER, MAP_POINTER				      ; 0488

		         59 	       58  D0 00019 	    MOVL    MAP_POINTER, BUILD_POINTER				      ;

		         50 	  01   AA  9A 0001C 	    MOVZBL  1(HEADER), R0					      ; 0489

		         51 	  3A   AA  9A 00020 	    MOVZBL  58(HEADER), R1					      ;

		         50 	       51  C0 00024 	    ADDL2   R1, R0						      ;

		         52 	     6A40  3E 00027 	    MOVAW   (HEADER)[R0], MAP_END				      ;

				     0000G 30 0002B 	    BSBW    GET_MAP_POINTER					      ; 0491

		         52 	       58  D1 0002E 	    CMPL    MAP_POINTER, MAP_END				      ; 0499

				       1C  12 00031 	    BNEQ    1$							      ;

	   51 	         56 	  14   AC  C3 00033 	    SUBL3   LAST_COUNT, COUNT, R1				      ; 0500

		         50 	0000G  CF  D0 00038 	    MOVL    CURRENT_VCB, R0					      ;

      3C   A0	         10 	       00  ED 0003D 	    CMPZV   #0, #16, 60(R0), R1					      ;

				       51     00042									      ;

				       0A  12 00043 	    BNEQ    1$							      ;

				  0E   AA  B5 00045 	    TSTW    14(HEADER)						      ; 0501

				       05  12 00048 	    BNEQ    1$							      ;

				  10   AA  B5 0004A 	    TSTW    16(HEADER)						      ; 0502

				       03  13 0004D 	    BEQL    2$							      ;

				       14  BF 0004F 1$:     CHMU    #20							      ; 0503

					   04 00051 	    RET     							      ;

				       5A  DD 00052 2$:     PUSHL   HEADER						      ; 0509

		  0000G  CF	       01  FB 00054 	    CALLS   #1, MARK_DIRTY					      ;

		         58 	  14   AC  D0 00059 	    MOVL    LAST_COUNT, R8					      ; 0510

				       0B  13 0005D 	    BEQL    3$							      ;

				0480   8F  BB 0005F 	    PUSHR   #^M<R7,R10>						      ; 0511

				       58  DD 00063 	    PUSHL   R8							      ;

		  0000G  CF	       03  FB 00065 	    CALLS   #3, MAKE_POINTER					      ;

	   50 	         59 	       5A  C3 0006A 3$:     SUBL3   HEADER, BUILD_POINTER, R0				      ; 0512

		         50 	       02  C6 0006E 	    DIVL2   #2, R0						      ;

      3A   AA	         50 	  01   AA  83 00071 	    SUBB3   1(HEADER), R0, 58(HEADER)				      ;

	   50 	         52 	       59  C3 00077 	    SUBL3   BUILD_POINTER, MAP_END, R0				      ; 0513

	   00 	         6E 	       00  2C 0007B 	    MOVC5   #0, (SP), #0, R0, (BUILD_POINTER)			      ;

		         69 	       50     0007F									      ;

		         50 	0000G  CF  D0 00081 	    MOVL    PRIMARY_FCB, R0					      ; 0515

				       0D  13 00086 	    BEQL    4$							      ;

				       50  DD 00088 	    PUSHL   R0							      ; 0516

				       01  DD 0008A 	    PUSHL   #1							      ;

				       5E  DD 0008C 	    PUSHL   SP							      ;

				0000G  CF  9F 0008E 	    PUSHAB  ZERO_WINDOWS					      ;

		         6B 	       04  FB 00092 	    CALLS   #4, SYS$CMKRNL					      ;

		         50 	  04   AC  D0 00095 4$:     MOVL    FIB, R0						      ; 0518

	   52 	    1C   A0	       01  C3 00099 	    SUBL3   #1, 28(R0), R2					      ;

				       52  DD 0009E 	    PUSHL   R2							      ;



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:11:51	DBB3:[F11B.SRC]DELBAD.B32;10					Page 2-4

;

				       01  DD 000A0 	    PUSHL   #1							      ;

				       5E  DD 000A2 	    PUSHL   SP							      ;

				0000G  CF  9F 000A4 	    PUSHAB  UPDATE_FILESIZE					      ;

		         6B 	       04  FB 000A8 	    CALLS   #4, SYS$CMKRNL					      ;

      18   AA	         52 	       10  9C 000AB 	    ROTL    #16, R2, 24(HEADER)					      ; 0519

				       5A  DD 000B0 	    PUSHL   HEADER						      ; 0520

		  0000G  CF	       01  FB 000B2 	    CALLS   #1, CHECKSUM					      ;

		         01 	  0C   AC  E8 000B7 	    BLBS    DEALLOCATE, 5$					      ; 0522

					   04 000BB 	    RET     							      ;

				0000G  CF  D4 000BC 5$:     CLRL    PRIMARY_FCB						      ; 0527

				0000G  CF  D4 000C0 	    CLRL    CURRENT_WINDOW					      ; 0528

		         57 	       58  C0 000C4 	    ADDL2   R8, LBN						      ; 0530

		         56 	       58  C2 000C7 	    SUBL2   R8, COUNT						      ; 0531

				       7E  D4 000CA 	    CLRL    -(SP)						      ; 0533

				FF30   CF  9F 000CC 	    PUSHAB  P.AAA						      ;

		  0000G  CF	       02  FB 000D0 	    CALLS   #2, READ_HEADER					      ;

		         5A 	       50  D0 000D5 	    MOVL    R0, HEADER						      ;

				       7E  D4 000D8 6$:     CLRL    -(SP)						      ; 0536

				       5A  DD 000DA 	    PUSHL   HEADER						      ;

		  0000G  CF	       02  FB 000DC 	    CALLS   #2, NEXT_HEADER					      ;

		         52 	       50  D0 000E1 	    MOVL    R0, EXT_HEADER					      ;

				       05  13 000E4 	    BEQL    7$							      ; 0537

		         5A 	       52  D0 000E6 	    MOVL    EXT_HEADER, HEADER					      ; 0538

				       ED  11 000E9 	    BRB     6$							      ; 0534

				       5A  DD 000EB 7$:     PUSHL   HEADER						      ; 0540

		  0000G  CF	       01  FB 000ED 	    CALLS   #1, MARK_DIRTY					      ;

		         50 	  01   AA  9A 000F2 	    MOVZBL  1(HEADER), R0					      ; 0541

		         51 	  3A   AA  9A 000F6 	    MOVZBL  58(HEADER), R1					      ;

		         50 	       51  C0 000FA 	    ADDL2   R1, R0						      ;

		         59 	     6A40  3E 000FD 	    MOVAW   (HEADER)[R0], BUILD_POINTER				      ;

				       5A  DD 00101 	    PUSHL   HEADER						      ; 0543

		         7E 	       56  7D 00103 	    MOVQ    COUNT, -(SP)					      ;

		  0000G  CF	       03  FB 00106 	    CALLS   #3, MAKE_POINTER					      ;

		         1E 	       50  E8 0010B 	    BLBS    R0, 8$						      ;

				       7E  D4 0010E 	    CLRL    -(SP)						      ; 0546

				       5A  DD 00110 	    PUSHL   HEADER						      ;

		  0000G  CF	       02  FB 00112 	    CALLS   #2, EXTEND_HEADER					      ;

		         5A 	       50  D0 00117 	    MOVL    R0, HEADER						      ;

		         50 	  01   AA  9A 0011A 	    MOVZBL  1(HEADER), R0					      ; 0547

		         59 	     6A40  3E 0011E 	    MOVAW   (HEADER)[R0], BUILD_POINTER				      ;

				       5A  DD 00122 	    PUSHL   HEADER						      ; 0548

		         7E 	       56  7D 00124 	    MOVQ    COUNT, -(SP)					      ;

		  0000G  CF	       03  FB 00127 	    CALLS   #3, MAKE_POINTER					      ;

	   50 	    18   AA	       10  9C 0012C 8$:     ROTL    #16, 24(HEADER), R0					      ; 0552

		         50 	       56  C0 00131 	    ADDL2   COUNT, R0						      ;

      18   AA	         50 	       10  9C 00134 	    ROTL    #16, R0, 24(HEADER)					      ;

				       5A  DD 00139 	    PUSHL   HEADER						      ; 0553

		  0000G  CF	       01  FB 0013B 	    CALLS   #1, CHECKSUM					      ;

				       56  DD 00140 	    PUSHL   COUNT						      ; 0559

				       7E  D4 00142 	    CLRL    -(SP)						      ;

				       57  DD 00144 	    PUSHL   LBN							      ;

				       7E  7C 00146 	    CLRQ    -(SP)						      ;

		  0000G  CF	       05  FB 00148 	    CALLS   #5, SCAN_BADLOG					      ;

					   04 0014D 9$:     RET     							      ; 0403





; Bliss-32 10.1-416	Monday 21-AUG-1978 23:11:51	DBB3:[F11B.SRC]DELBAD.B32;10					Page 2-5

;

; Routine Size:  326 bytes





;	0562	

;	0563	END

;	0564	ELUDOM













;				       PSECT SUMMARY

;

;	Name		 Bytes			       Attributes

;

;  $CODE$         	   334  NOWRT,  RD ,  EXE,NOSHR,  LCL,  REL,  CON,NOPIC,ALIGN(2)









;				LIBRARY STATISTICS

;

;					     -------- Symbols --------    Blocks

;	File				     Total    Loaded   Percent      Read

;

;  DBA4:[SYSLIB]LIB.L32;1		      5582        16         0       232











; Size:		326 code + 8 data bytes

; Run Time:	00:08.2

; Elapsed Time:	00:19.0

; Memory Used:	329 pages

; Compilation Complete

