

; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 1

;

;	0001	MODULE EXTIDX (

;	0002			LANGUAGE (BLISS32),

;	0003			IDENT = 'B0010'

;	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 extends the volume's index file.

;	0033	!

;	0034	! ENVIRONMENT:

;	0035	!

;	0036	!	STARLET operating system, including privileged system services

;	0037	!	and internal exec routines.

;	0038	!

;	0039	!--

;	0040	!

;	0041	!

;	0042	! AUTHOR:  Andrew C. Goldstein,	 CREATION DATE:  14-Apr-1977  10:44

;	0043	!

;	0044	! REVISION HISTORY:

;	0045	!

;	0046	!   Andrew C. Goldstein, 31-May-1977  10:43

;	0047	!   X0002 - Limit extension to 1000 blocks

;	0048	!

;	0049	!   Andrew C. Goldstein, 14-Jul-1977  15:42

;	0050	!   X0003 - New checksum logic

;	0051	!

;	0052	!   Andrew C. Goldstein, 22-Jul-1977  11:35

;	0053	!   X0004 - Additional arg to TURN_WINDOW

;	0054	!

;	0055	!   Andrew C. Goldstein, 15-Aug-1977  17:46



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 1-1

;

;	0056	!   X0005 - Load PRIMARY_FCB during extend

;	0057	!

;	0058	!   Andrew C. Goldstein, 12-Dec-1977  13:46

;	0059	!   X0006 - file ID interface changes

;	0060	!

;	0061	!   Andrew C. Goldstein, 14-Dec-1977  17:46

;	0062	!   X0007 - Modify for structure level 2

;	0063	!

;	0064	!   Andrew C. Goldstein, 20-Dec-1977  16:44

;	0065	!   B0008 - Update index file attributes after extend

;	0066	!

;	0067	!   Andrew C. Goldstein, 24-Jan-1978  19:03

;	0068	!   B0009 - Write second index file header

;	0069	!

;	0070	!   Andrew C. Goldstein, 10-Jul-78  14:56

;	0071	!   B0010 - Zero extend size in user status

;	0072	!

;	0073	!**

;	0074	

;	0075	

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

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



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 2

;

;	0426	GLOBAL ROUTINE EXTEND_INDEX (FILE_NUMBER) : NOVALUE =

;	0427	

;	0428	!++

;	0429	!

;	0430	! FUNCTIONAL DESCRIPTION:

;	0431	!

;	0432	!	This routine extends the volume's index file.

;	0433	!

;	0434	! CALLING SEQUENCE:

;	0435	!	EXTEND_INDEX (ARG1)

;	0436	!

;	0437	! INPUT PARAMETERS:

;	0438	!	ARG1: next file number to be created

;	0439	!

;	0440	! IMPLICIT INPUTS:

;	0441	!	CURRENT_VCB: address of volume VCB

;	0442	!

;	0443	! OUTPUT PARAMETERS:

;	0444	!	NONE

;	0445	!

;	0446	! IMPLICIT OUTPUTS:

;	0447	!	NONE

;	0448	!

;	0449	! ROUTINE VALUE:

;	0450	!	NONE

;	0451	!

;	0452	! SIDE EFFECTS:

;	0453	!	index file extended, index file window and index file FCB modified

;	0454	!

;	0455	!--

;	0456	

;	0457	BEGIN

;	0458	

;	0459	LOCAL

;	0460		FIB		: REF BBLOCK,	! address of FIB for extend operation

;	0461		HEADER		: REF BBLOCK,	! address of index file header

;	0462		FCB		: REF BBLOCK,	! address of index file FCB

;	0463		WINDOW		: REF BBLOCK,	! address of index file window

;	0464		FREE_POINTERS,			! number of free retrieval pointers

;	0465						! in index file window

;	0466		FILES_TO_GO,			! number of files likely to be created

;	0467						! on this volume

;	0468		BLOCKS_NEEDED;			! amount to extend index file by

;	0469	

;	0470	EXTERNAL

;	0471		CLEANUP_FLAGS	: BITVECTOR,	! cleanup action flags

;	0472		USER_STATUS	: VECTOR,	! I/O status block of user

;	0473		CURRENT_VCB	: REF BBLOCK,	! VCB of volume in process

;	0474		PRIMARY_FCB	: REF BBLOCK,	! address of FCB in process

;	0475		CURRENT_WINDOW	: REF BBLOCK,	! address of window in process

;	0476		CURRENT_FIB	: REF BBLOCK,	! address of FIB of current operation

;	0477		SECOND_FIB	: BBLOCK,	! FIB for secondary operation

;	0478		CONTEXT_START,			! context area

;	0479		CONTEXT_SAVE;			! context save area

;	0480	



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 2-1

;

;	0481	EXTERNAL LITERAL

;	0482		CONTEXT_SIZE;			! length of context area

;	0483	

;	0484	EXTERNAL ROUTINE

;	0485		READ_HEADER,			! read file header

;	0486		TURN_WINDOW,			! update file window

;	0487		EXTEND,				! extend a file

;	0488		CHECKSUM,			! compute file header checksum

;	0489		WRITE_HEADER,			! write back file header

;	0490		RESET_LBN,			! reassign LBN of buffer

;	0491		WRITE_BLOCK,			! write a disk block

;	0492		INVALIDATE,			! invalidate buffer

;	0493		INIT_FCB2;			! update file control block

;	0494	

;	0495	

;	0496	! Extending the index file is a secondary operation, so we must save away the

;	0497	! primary context, and then set up the appropriate context for this operation.

;	0498	!

;	0499	

;	0500	CH$MOVE (CONTEXT_SIZE, CONTEXT_START, CONTEXT_SAVE);

;	0501	CH$FILL (0, CONTEXT_SIZE, CONTEXT_START);

;	0502	CURRENT_FIB = FIB = SECOND_FIB;

;	0503	CH$FILL (0, FIB$C_LENGTH, .FIB);

;	0504	FIB[FIB$W_FID_NUM] = 1;

;	0505	FIB[FIB$W_FID_SEQ] = 1;

;	0506	

;	0507	PRIMARY_FCB = FCB = .CURRENT_VCB[VCB$L_FCBFL];

;	0508	CURRENT_WINDOW = WINDOW = .FCB[FCB$L_WLFL];

;	0509	

;	0510	! Now read the index file header and turn the index file window to VBN 3.

;	0511	! Then compute the number of free retrieval pointers in the index file window,

;	0512	! discounting pointers (if any) that only map the boot and home block.

;	0513	!

;	0514	

;	0515	HEADER = READ_HEADER (0, .FCB);

;	0516	KERNEL_CALL (TURN_WINDOW, .WINDOW, .HEADER, 3, 1);

;	0517	

;	0518	FREE_POINTERS = (.WINDOW[WCB$W_SIZE]-WCB$C_LENGTH)/6 - .WINDOW[WCB$W_NMAP];

;	0519	IF .WINDOW[WCB$L_STVBN] + .WINDOW[WCB$W_P1_COUNT] LEQU 3

;	0520	THEN

;	0521	    BEGIN

;	0522	    FREE_POINTERS = .FREE_POINTERS + 1;

;	0523	    IF .WINDOW[WCB$L_STVBN] + .WINDOW[WCB$W_P1_COUNT] + .WINDOW[WCB$W_P2_COUNT] LEQU 3

;	0524	    THEN FREE_POINTERS = .FREE_POINTERS + 1;

;	0525	    END;

;	0526	IF .FREE_POINTERS LEQ 0 THEN FREE_POINTERS = 1;

;	0527	

;	0528	! Compute the number of files likely to still be created on the volume.  This

;	0529	! is the minimum of the number permitted minus the current number and a

;	0530	! fraction of the number of free blocks on the volume. The amount to extend

;	0531	! the index file by is this quantity divided by the number of available

;	0532	! retrieval pointers in the index file window.

;	0533	!

;	0534	

;	0535	FILES_TO_GO = MINU (.CURRENT_VCB[VCB$L_MAXFILES] - .FILE_NUMBER + 1,



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 2-2

;

;	0536			.CURRENT_VCB[VCB$L_FREE] / .CURRENT_VCB[VCB$W_CLUSTER] / 4);

;	0537	

;	0538	BLOCKS_NEEDED = MINU (.FILES_TO_GO / .FREE_POINTERS, 1000);

;	0539	

;	0540	! Build the extend control in the FIB and call the EXTEND routine.

;	0541	!

;	0542	

;	0543	FIB[FIB$L_EXSZ] = .BLOCKS_NEEDED;

;	0544	FIB[FIB$V_ALCON] = 1;

;	0545	FIB[FIB$V_ALCONB] = 1;

;	0546	FIB[FIB$V_ALDEF] = 1;

;	0547	FIB[FIB$V_NOHDREXT] = 1;

;	0548	

;	0549	EXTEND (.FIB, .HEADER);

;	0550	

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

;	0552	BBLOCK [HEADER[FH2$W_RECATTR], FAT$L_EFBLK] = ROT (.FCB[FCB$L_EFBLK]+1, 16);

;	0553	

;	0554	! Now write the header, update the FCB, and restore the primary context.

;	0555	!

;	0556	

;	0557	CHECKSUM (.HEADER);

;	0558	WRITE_HEADER ();

;	0559	RESET_LBN (.HEADER, .CURRENT_VCB[VCB$L_IXHDR2LBN]);

;	0560	WRITE_BLOCK (.HEADER);

;	0561	INVALIDATE (.HEADER);

;	0562	KERNEL_CALL (INIT_FCB2, .FCB, .HEADER);

;	0563	

;	0564	CH$MOVE (CONTEXT_SIZE, CONTEXT_SAVE, CONTEXT_START);

;	0565	CONTEXT_SAVE = 0;

;	0566	USER_STATUS[1] = 0;

;	0567	

;	0568	END;					! end of routine EXTEND_INDEX





							    .TITLE  EXTIDX

							    .IDENT  \B0010\



							    .EXTRN  CLEANUP_FLAGS, USER_STATUS, CURRENT_VCB, PRIMARY_FCB

							    .EXTRN  CURRENT_WINDOW, CURRENT_FIB, SECOND_FIB, CONTEXT_START

							    .EXTRN  CONTEXT_SAVE, CONTEXT_SIZE, READ_HEADER, TURN_WINDOW

							    .EXTRN  EXTEND, CHECKSUM, WRITE_HEADER, RESET_LBN, WRITE_BLOCK

							    .EXTRN  INVALIDATE, INIT_FCB2, SYS$CMKRNL



							    .PSECT  $CODE$,NOWRT,2



					 07FC 00000 	    .ENTRY  EXTEND_INDEX, Save R2,R3,R4,R5,R6,R7,R8,R9,R10	      ; 0426

		         5A 	0000G  CF  9E 00002 	    MOVAB   CONTEXT_SAVE, R10					      ;

		         59 	0000G  CF  9E 00007 	    MOVAB   CONTEXT_START, R9					      ;

		         58 00000000G  9F  9E 0000C 	    MOVAB   @#SYS$CMKRNL, R8					      ;

		         57 00000000G  8F  D0 00013 	    MOVL    #CONTEXT_SIZE, R7					      ;

	   6A 	         69 	       57  28 0001A 	    MOVC3   R7, CONTEXT_START, CONTEXT_SAVE			      ; 0500

	   00 	         6E 	       00  2C 0001E 	    MOVC5   #0, (SP), #0, R7, CONTEXT_START			      ; 0501

		         69 	       57     00022									      ;

		         56 	0000G  CF  9E 00024 	    MOVAB   SECOND_FIB, FIB					      ; 0502



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 2-3

;

		  0000G  CF	       56  D0 00029 	    MOVL    FIB, CURRENT_FIB					      ;

	   00 	         6E 	       00  2C 0002E 	    MOVC5   #0, (SP), #0, #44, (FIB)				      ; 0503

		         66 	       2C     00032									      ;

		    04   A6 00010001   8F  D0 00034 	    MOVL    #65537, 4(FIB)					      ; 0504

		         55 	0000G  DF  D0 0003C 	    MOVL    @CURRENT_VCB, FCB					      ; 0507

		  0000G  CF	       55  D0 00041 	    MOVL    FCB, PRIMARY_FCB					      ;

		         52 	  10   A5  D0 00046 	    MOVL    16(FCB), WINDOW					      ; 0508

		  0000G  CF	       52  D0 0004A 	    MOVL    WINDOW, CURRENT_WINDOW				      ;

				       55  DD 0004F 	    PUSHL   FCB							      ; 0515

				       7E  D4 00051 	    CLRL    -(SP)						      ;

		  0000G  CF	       02  FB 00053 	    CALLS   #2, READ_HEADER					      ;

		         53 	       50  D0 00058 	    MOVL    R0, HEADER						      ;

				       01  DD 0005B 	    PUSHL   #1							      ; 0516

				       03  DD 0005D 	    PUSHL   #3							      ;

				       0C  BB 0005F 	    PUSHR   #^M<R2,R3>						      ;

				       04  DD 00061 	    PUSHL   #4							      ;

				       5E  DD 00063 	    PUSHL   SP							      ;

				0000G  CF  9F 00065 	    PUSHAB  TURN_WINDOW						      ;

		         68 	       07  FB 00069 	    CALLS   #7, SYS$CMKRNL					      ;

		         50 	  08   A2  3C 0006C 	    MOVZWL  8(WINDOW), R0					      ; 0518

		         50 	       24  C2 00070 	    SUBL2   #36, R0						      ;

		         50 	       06  C6 00073 	    DIVL2   #6, R0						      ;

		         54 	  16   A2  3C 00076 	    MOVZWL  22(WINDOW), FREE_POINTERS				      ;

	   54 	         50 	       54  C3 0007A 	    SUBL3   FREE_POINTERS, R0, FREE_POINTERS			      ;

		         50 	  24   A2  3C 0007E 	    MOVZWL  36(WINDOW), R0					      ; 0519

		         50 	  20   A2  C0 00082 	    ADDL2   32(WINDOW), R0					      ;

		         03 	       50  D1 00086 	    CMPL    R0, #3						      ;

				       10  1A 00089 	    BGTRU   1$							      ;

				       54  D6 0008B 	    INCL    FREE_POINTERS					      ; 0522

		         51 	  2A   A2  3C 0008D 	    MOVZWL  42(WINDOW), R1					      ; 0523

		         50 	       51  C0 00091 	    ADDL2   R1, R0						      ;

		         03 	       50  D1 00094 	    CMPL    R0, #3						      ;

				       02  1A 00097 	    BGTRU   1$							      ;

				       54  D6 00099 	    INCL    FREE_POINTERS					      ; 0524

				       54  D5 0009B 1$:     TSTL    FREE_POINTERS					      ; 0526

				       03  14 0009D 	    BGTR    2$							      ;

		         54 	       01  D0 0009F 	    MOVL    #1, FREE_POINTERS					      ;

		         50 	0000G  CF  D0 000A2 2$:     MOVL    CURRENT_VCB, R0					      ; 0535

	   51 	    44   A0	  04   AC  C3 000A7 	    SUBL3   FILE_NUMBER, 68(R0), R1				      ;

				       51  D6 000AD 	    INCL    R1							      ;

		         52 	  3C   A0  3C 000AF 	    MOVZWL  60(R0), R2						      ; 0536

	   50 	    40   A0	       52  C7 000B3 	    DIVL3   R2, 64(R0), R0					      ;

		         50 	       04  C6 000B8 	    DIVL2   #4, R0						      ;

		         50 	       51  D1 000BB 	    CMPL    R1, R0						      ; 0535

				       03  1B 000BE 	    BLEQU   3$							      ;

		         51 	       50  D0 000C0 	    MOVL    R0, R1						      ;

		         50 	       51  D0 000C3 3$:     MOVL    R1, FILES_TO_GO					      ;

		         50 	       54  C6 000C6 	    DIVL2   FREE_POINTERS, R0					      ; 0538

	      000003E8   8F	       50  D1 000C9 	    CMPL    R0, #1000						      ;

				       05  1B 000D0 	    BLEQU   4$							      ;

		         50 	03E8   8F  3C 000D2 	    MOVZWL  #1000, R0						      ;

		    18   A6	       50  D0 000D7 4$:     MOVL    BLOCKS_NEEDED, 24(FIB)				      ; 0543

		    16   A6	020B   8F  A8 000DB 	    BISW2   #523, 22(FIB)					      ; 0547

				       53  DD 000E1 	    PUSHL   HEADER						      ; 0549

				       56  DD 000E3 	    PUSHL   FIB							      ;



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 2-4

;

		  0000G  CF	       02  FB 000E5 	    CALLS   #2, EXTEND						      ;

	   50 	    18   A6	  1C   A6  C1 000EA 	    ADDL3   28(FIB), 24(FIB), R0				      ; 0551

				       50  D7 000F0 	    DECL    R0							      ;

      18   A3	         50 	       10  9C 000F2 	    ROTL    #16, R0, 24(HEADER)					      ;

	   50 	    40   A5	       01  C1 000F7 	    ADDL3   #1, 64(FCB), R0					      ; 0552

      1C   A3	         50 	       10  9C 000FC 	    ROTL    #16, R0, 28(HEADER)					      ;

				       53  DD 00101 	    PUSHL   HEADER						      ; 0557

		  0000G  CF	       01  FB 00103 	    CALLS   #1, CHECKSUM					      ;

		  0000G  CF	       00  FB 00108 	    CALLS   #0, WRITE_HEADER					      ; 0558

		         50 	0000G  CF  D0 0010D 	    MOVL    CURRENT_VCB, R0					      ; 0559

				  2C   A0  DD 00112 	    PUSHL   44(R0)						      ;

				       53  DD 00115 	    PUSHL   HEADER						      ;

		  0000G  CF	       02  FB 00117 	    CALLS   #2, RESET_LBN					      ;

				       53  DD 0011C 	    PUSHL   HEADER						      ; 0560

		  0000G  CF	       01  FB 0011E 	    CALLS   #1, WRITE_BLOCK					      ;

				       53  DD 00123 	    PUSHL   HEADER						      ; 0561

		  0000G  CF	       01  FB 00125 	    CALLS   #1, INVALIDATE					      ;

				       53  DD 0012A 	    PUSHL   HEADER						      ; 0562

				       55  DD 0012C 	    PUSHL   FCB							      ;

				       02  DD 0012E 	    PUSHL   #2							      ;

				       5E  DD 00130 	    PUSHL   SP							      ;

				0000G  CF  9F 00132 	    PUSHAB  INIT_FCB2						      ;

		         68 	       05  FB 00136 	    CALLS   #5, SYS$CMKRNL					      ;

	   69 	         6A 	       57  28 00139 	    MOVC3   R7, CONTEXT_SAVE, CONTEXT_START			      ; 0564

				       6A  D4 0013D 	    CLRL    CONTEXT_SAVE					      ; 0565

				0000G  CF  D4 0013F 	    CLRL    USER_STATUS+4					      ; 0566

					   04 00143 	    RET     							      ; 0426



; Routine Size:  324 bytes





;	0569	

;	0570	END

;	0571	ELUDOM













;				       PSECT SUMMARY

;

;	Name		 Bytes			       Attributes

;

;  $CODE$         	   324  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        32         0       240



; Bliss-32 10.1-416	Monday 21-AUG-1978 23:15:36	DBB3:[F11B.SRC]EXTIDX.B32;7					Page 2-5

;











; Size:		324 code + 0 data bytes

; Run Time:	00:08.1

; Elapsed Time:	00:18.7

; Memory Used:	323 pages

; Compilation Complete

