

; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 1

; Digital Equipment Corporation

;

;	0001	MODULE INIALL (

;	0002			LANGUAGE (BLISS32),

;	0003			IDENT = 'X0004'

;	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:  INIT Utility Structure Level 1

;	0029	!

;	0030	! ABSTRACT:

;	0031	!

;	0032	!	This module contains the routines that allocate the pieces of the

;	0033	!	file structure on the disk.

;	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:  12-Nov-1977  20:02

;	0044	!

;	0045	! REVISION HISTORY:

;	0046	!

;	0047	!   Andrew C. Goldstein, 16-Feb-1978  16:21

;	0048	!   X0002 - Add /DIRECTORIES switch

;	0049	!

;	0050	!   Andrew C. Goldstein, 7-Jun-78  16:57

;	0051	!   X0003 - Add structure level 1

;	0052	!

;	0053	!   Andrew C. Goldstein, 14-Jun-78  18:06

;	0054	!   X0004 - Add block zero bad message

;	0055	!



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 1-1

; Digital Equipment Corporation

;

;	0056	!**

;	0057	

;	0058	

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

;	0060	REQUIRE 'SRC$:INIDEF.B32';

;	0322	REQUIRE 'LIBD$:[VMSLIB.OBJ]INITMSG.B32';

;	0382	

;	0383	

;	0384	FORWARD ROUTINE

;	0385		INIT_ALLOCATE	: NOVALUE,	! main allocation routine

;	0386		ALLOCATE	: NOVALUE,	! general allocation scan

;	0387		ALLOCATE_HOME	: NOVALUE,	! allocate on home block sequence

;	0388		CHECK_ALLOC;			! verify a candidate allocation

;	0389	

;	0390	

;	0391	

;	0392	!+

;	0393	!

;	0394	! Module own storage

;	0395	!

;	0396	!-

;	0397	

;	0398	OWN

;	0399		HOMEBLOCK_DELTA;		! home block search increment on this volume



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 2

; Digital Equipment Corporation

;

;	0400	GLOBAL ROUTINE INIT_ALLOCATE : NOVALUE =

;	0401	

;	0402	!++

;	0403	!

;	0404	! FUNCTIONAL DESCRIPTION:

;	0405	!

;	0406	!	This is the main allocation routine. It determines the size and

;	0407	!	location of each portion of the file structure. Each allocation is

;	0408	!	done by choosing a candidate location for the section and checking

;	0409	!	for conflicts. If a conflict exists, a new candidate location is

;	0410	!	chosen according an algorithm specific to the section being allocated.

;	0411	!

;	0412	!

;	0413	! CALLING SEQUENCE:

;	0414	!	INIT_ALLOCATE ()

;	0415	!

;	0416	! INPUT PARAMETERS:

;	0417	!	NONE

;	0418	!

;	0419	! IMPLICIT INPUTS:

;	0420	!	parser database

;	0421	!	allocation table in INIDSK

;	0422	!

;	0423	! OUTPUT PARAMETERS:

;	0424	!	NONE

;	0425	!

;	0426	! IMPLICIT OUTPUTS:

;	0427	!	NONE

;	0428	!

;	0429	! ROUTINE VALUE:

;	0430	!	NONE

;	0431	!

;	0432	! SIDE EFFECTS:

;	0433	!	allocation table modified

;	0434	!

;	0435	!--

;	0436	

;	0437	BEGIN

;	0438	

;	0439	LOCAL

;	0440		CLUST;				! local copy of volume cluster factor

;	0441	

;	0442	EXTERNAL

;	0443		INIT_OPTIONS	: BITVECTOR,	! command options

;	0444		CLUSTER,			! volume cluster factor

;	0445		INDEX,				! requested LBN of initial index file

;	0446		HEADERS,			! initial number of file headers

;	0447		MAXIMUM,			! maximum number of files

;	0448		DIRECTORIES,			! number of MFD entries to allocate

;	0449		VOLUME_SIZE,			! size of volume rounded to next cluster

;	0450		BOOTBLOCK_CNT,			! block count of boot block cluster

;	0451		BOOTBLOCK_LBN,			! LBN of boot block cluster

;	0452		HOMEBLOCK1_CNT,			! block count of home block 1 cluster

;	0453		HOMEBLOCK1_LBN,			! LBN of home block 1 cluster

;	0454		HOMEBLOCK2_CNT,			! block count of home block 2 cluster



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 2-1

; Digital Equipment Corporation

;

;	0455		HOMEBLOCK2_LBN,			! LBN of home block 2 cluster

;	0456		IDXFILE_CNT,			! block count of initial index file

;	0457		IDXFILE_LBN,			! LBN of initial index file

;	0458		IDXHDR2_CNT,			! block count of 2nd index header cluster

;	0459		IDXHDR2_LBN,			! LBN of 2nd index header cluster

;	0460		BITMAP_CNT,			! block count of storage bitmap

;	0461		BITMAP_LBN,			! LBN of storage bitmap

;	0462		MFD_CNT,			! block count of MFD

;	0463		MFD_LBN;			! LBN of MFD

;	0464	

;	0465	EXTERNAL LITERAL

;	0466		BOOTBLOCK_IDX	: UNSIGNED (6),	! table index of boot block cluster

;	0467		HOMEBLOCK1_IDX	: UNSIGNED (6),	! table index of home block 1 cluster

;	0468		HOMEBLOCK2_IDX	: UNSIGNED (6),	! table index of home block 2 cluster

;	0469		IDXFILE_IDX	: UNSIGNED (6),	! table index of initial index file

;	0470		IDXHDR2_IDX	: UNSIGNED (6),	! table index of 2nd index header cluster

;	0471		BITMAP_IDX	: UNSIGNED (6),	! table index of storage bitmap

;	0472		MFD_IDX		: UNSIGNED (6);	! table index of MFD

;	0473	

;	0474	

;	0475	! Allocate the boot block to the first available cluster (usually 0).

;	0476	!

;	0477	

;	0478	CLUST = .CLUSTER;

;	0479	BOOTBLOCK_CNT = .CLUST;

;	0480	ALLOCATE (BOOTBLOCK_IDX, 0);

;	0481	

;	0482	IF .BOOTBLOCK_LBN NEQ 0

;	0483	THEN ERR_MESSAGE (INIT$_BLKZERO);

;	0484	

;	0485	! Next allocate the primary and secondary home blocks. If the boot block is

;	0486	! on LBN 0 and the cluster factor is greater than 1, then the primary home

;	0487	! block cluster is a dummy since the real home block is LBN 1.

;	0488	!

;	0489	

;	0490	HOMEBLOCK1_CNT = .CLUST;

;	0491	

;	0492	IF .INIT_OPTIONS[OPT_STRUCTURE1]

;	0493	THEN

;	0494	    ALLOCATE_HOME (HOMEBLOCK1_IDX)

;	0495	ELSE

;	0496	    BEGIN

;	0497	    IF .BOOTBLOCK_LBN EQL 0 AND .CLUST GTR 1

;	0498	    THEN

;	0499		ALLOCATE (HOMEBLOCK1_IDX, 0)

;	0500	    ELSE

;	0501		ALLOCATE_HOME (HOMEBLOCK1_IDX);

;	0502	

;	0503	    HOMEBLOCK2_CNT = .CLUST;

;	0504	    ALLOCATE_HOME (HOMEBLOCK2_IDX);

;	0505	    END;

;	0506	

;	0507	! Now allocate the MFD, storage map, initial index file, and alternate

;	0508	! index file header, in that order. This results in optimal locality of

;	0509	! the most frequently referenced portions of the file structure. Note that



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 2-2

; Digital Equipment Corporation

;

;	0510	! if the index file is being placed at the end of the volume they are

;	0511	! allocated in reverse to achieve the same effect.

;	0512	!

;	0513	

;	0514	MFD_LBN = .INDEX;

;	0515	BITMAP_LBN = .INDEX;

;	0516	IDXFILE_LBN = .INDEX;

;	0517	

;	0518	IF NOT .INIT_OPTIONS[OPT_INDEX_END]

;	0519	THEN

;	0520	    BEGIN

;	0521	    MFD_CNT = .DIRECTORIES/16 + 1;

;	0522	    ALLOCATE (MFD_IDX, 0);

;	0523	    BITMAP_CNT = ((.VOLUME_SIZE/.CLUST + 4095) / 4096) + 1;

;	0524	    ALLOCATE (BITMAP_IDX, 0);

;	0525	    IDXFILE_CNT = .HEADERS + (.MAXIMUM+4095)/4096;

;	0526	    ALLOCATE (IDXFILE_IDX, 0);

;	0527	    IF NOT .INIT_OPTIONS[OPT_STRUCTURE1]

;	0528	    THEN

;	0529		BEGIN

;	0530		IDXHDR2_CNT = .CLUST;

;	0531		IDXHDR2_LBN = .IDXFILE_LBN + .HOMEBLOCK_DELTA;

;	0532		ALLOCATE (IDXHDR2_IDX, 0);

;	0533		END;

;	0534	    END

;	0535	ELSE

;	0536	    BEGIN

;	0537	    IDXFILE_CNT = .HEADERS + (.MAXIMUM+4095)/4096;

;	0538	    ALLOCATE (IDXFILE_IDX, 1);

;	0539	    BITMAP_CNT = ((.VOLUME_SIZE/.CLUST + 4095) / 4096) + 1;

;	0540	    ALLOCATE (BITMAP_IDX, 1);

;	0541	    MFD_CNT = .DIRECTORIES/16 + 1;

;	0542	    ALLOCATE (MFD_IDX, 1);

;	0543	    IF NOT .INIT_OPTIONS[OPT_STRUCTURE1]

;	0544	    THEN

;	0545		BEGIN

;	0546		IDXHDR2_CNT = .CLUST;

;	0547		IDXHDR2_LBN = .IDXFILE_LBN + .HOMEBLOCK_DELTA;

;	0548		ALLOCATE (IDXHDR2_IDX, 0);

;	0549		END;

;	0550	    END;

;	0551	

;	0552	END;					! end of routine INIT_ALLOCATE





							    .TITLE  INIALL

							    .IDENT  \X0004\



							    .PSECT  $OWN$,NOEXE,2



					      00000 HOMEBLOCK_DELTA:

							    .BLKB   4



							    .GLOBL  INIT_OPTIONS, CLUSTER, INDEX, HEADERS, MAXIMUM

							    .GLOBL  DIRECTORIES, VOLUME_SIZE, BOOTBLOCK_CNT, BOOTBLOCK_LBN



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 2-3

; Digital Equipment Corporation

;

							    .GLOBL  HOMEBLOCK1_CNT, HOMEBLOCK1_LBN, HOMEBLOCK2_CNT

							    .GLOBL  HOMEBLOCK2_LBN, IDXFILE_CNT, IDXFILE_LBN, IDXHDR2_CNT

							    .GLOBL  IDXHDR2_LBN, BITMAP_CNT, BITMAP_LBN, MFD_CNT, MFD_LBN

							    .GLOBL  BOOTBLOCK_IDX, HOMEBLOCK1_IDX, HOMEBLOCK2_IDX

							    .GLOBL  IDXFILE_IDX, IDXHDR2_IDX, BITMAP_IDX, MFD_IDX



							    .PSECT  $CODE$,NOWRT,2



					 0F84 00000 	    .ENTRY  INIT_ALLOCATE, Save R2,R7,R8,R9,R10,R11		      ; 0400

		         57	       00  D0 00002 	    MOVL    #IDXFILE_IDX, R7					      ;

		         58	       00  D0 00005 	    MOVL    #BITMAP_IDX, R8					      ;

		         59	       00  D0 00008 	    MOVL    #MFD_IDX, R9					      ;

		         5A	       00  D0 0000B 	    MOVL    #HOMEBLOCK1_IDX, R10				      ;

		         5B	0000V  CF  9E 0000E 	    MOVAB   ALLOCATE, R11					      ;

		         52	0000G  CF  D0 00013 	    MOVL    CLUSTER, CLUST					      ; 0478

		  0000G  CF	       52  D0 00018 	    MOVL    CLUST, BOOTBLOCK_CNT				      ; 0479

				       7E  D4 0001D 	    CLRL    -(SP)						      ; 0480

		         7E	       00  9A 0001F 	    MOVZBL  #BOOTBLOCK_IDX, -(SP)				      ;

		         6B	       02  FB 00022 	    CALLS   #2, ALLOCATE					      ;

				0000G  CF  D5 00025 	    TSTL    BOOTBLOCK_LBN					      ; 0482

				       0D  13 00029 	    BEQL    1$							      ;

			    00759000   8F  DD 0002B 	    PUSHL   #7704576						      ; 0483

	      00000000G  00	       01  FB 00031 	    CALLS   #1, LIB$SIGNAL					      ;

		  0000G  CF	       52  D0 00038 1$:     MOVL    CLUST, HOMEBLOCK1_CNT				      ; 0490

	   05	  0000G  CF	       07  E1 0003D 	    BBC     #7, INIT_OPTIONS+3, 2$				      ; 0492

		         7E	       5A  9A 00043 	    MOVZBL  R10, -(SP)						      ; 0494

				       25  11 00046 	    BRB     5$							      ;

				0000G  CF  D5 00048 2$:     TSTL    BOOTBLOCK_LBN					      ; 0497

				       0F  12 0004C 	    BNEQ    3$							      ;

		         01	       52  D1 0004E 	    CMPL    CLUST, #1						      ;

				       0A  15 00051 	    BLEQ    3$							      ;

				       7E  D4 00053 	    CLRL    -(SP)						      ; 0499

		         7E	       5A  9A 00055 	    MOVZBL  R10, -(SP)						      ;

		         6B	       02  FB 00058 	    CALLS   #2, ALLOCATE					      ;

				       08  11 0005B 	    BRB     4$							      ; 0497

		         7E	       5A  9A 0005D 3$:     MOVZBL  R10, -(SP)						      ; 0501

		  0000V  CF	       01  FB 00060 	    CALLS   #1, ALLOCATE_HOME					      ;

		  0000G  CF	       52  D0 00065 4$:     MOVL    CLUST, HOMEBLOCK2_CNT				      ; 0503

		         7E	       00  9A 0006A 	    MOVZBL  #HOMEBLOCK2_IDX, -(SP)				      ; 0504

		  0000V  CF	       01  FB 0006D 5$:     CALLS   #1, ALLOCATE_HOME					      ;

		         50	0000G  CF  D0 00072 	    MOVL    INDEX, R0						      ; 0514

		  0000G  CF	       50  D0 00077 	    MOVL    R0, MFD_LBN						      ;

		  0000G  CF	       50  D0 0007C 	    MOVL    R0, BITMAP_LBN					      ; 0515

		  0000G  CF	       50  D0 00081 	    MOVL    R0, IDXFILE_LBN					      ; 0516

	   5D	  0000G  CF	       06  E0 00086 	    BBS     #6, INIT_OPTIONS+2, 6$				      ; 0518

	   50	  0000G  CF	       10  C7 0008C 	    DIVL3   #16, DIRECTORIES, R0				      ; 0521

    0000G  CF	         50	       01  C1 00092 	    ADDL3   #1, R0, MFD_CNT					      ;

				       7E  D4 00098 	    CLRL    -(SP)						      ; 0522

		         7E	       59  9A 0009A 	    MOVZBL  R9, -(SP)						      ;

		         6B	       02  FB 0009D 	    CALLS   #2, ALLOCATE					      ;

	   50	  0000G  CF	       52  C7 000A0 	    DIVL3   CLUST, VOLUME_SIZE, R0				      ; 0523

		         50	0FFF   C0  9E 000A6 	    MOVAB   4095(R0), R0					      ;

		         50 00001000   8F  C6 000AB 	    DIVL2   #4096, R0						      ;

    0000G  CF	         50	       01  C1 000B2 	    ADDL3   #1, R0, BITMAP_CNT					      ;

				       7E  D4 000B8 	    CLRL    -(SP)						      ; 0524



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 2-4

; Digital Equipment Corporation

;

		         7E	       58  9A 000BA 	    MOVZBL  R8, -(SP)						      ;

		         6B	       02  FB 000BD 	    CALLS   #2, ALLOCATE					      ;

	   50	  0000G  CF 00000FFF   8F  C1 000C0 	    ADDL3   #4095, MAXIMUM, R0					      ; 0525

		         50 00001000   8F  C6 000CA 	    DIVL2   #4096, R0						      ;

    0000G  CF	         50	0000G  CF  C1 000D1 	    ADDL3   HEADERS, R0, IDXFILE_CNT				      ;

				       7E  D4 000D9 	    CLRL    -(SP)						      ; 0526

		         7E	       57  9A 000DB 	    MOVZBL  R7, -(SP)						      ;

		         6B	       02  FB 000DE 	    CALLS   #2, ALLOCATE					      ;

	   74	  0000G  CF	       07  E0 000E1 	    BBS     #7, INIT_OPTIONS+3, 8$				      ; 0527

				       5B  11 000E7 	    BRB     7$							      ; 0530

	   50	  0000G  CF 00000FFF   8F  C1 000E9 6$:     ADDL3   #4095, MAXIMUM, R0					      ; 0537

		         50 00001000   8F  C6 000F3 	    DIVL2   #4096, R0						      ;

    0000G  CF	         50	0000G  CF  C1 000FA 	    ADDL3   HEADERS, R0, IDXFILE_CNT				      ;

				       01  DD 00102 	    PUSHL   #1							      ; 0538

		         7E	       57  9A 00104 	    MOVZBL  R7, -(SP)						      ;

		         6B	       02  FB 00107 	    CALLS   #2, ALLOCATE					      ;

	   50	  0000G  CF	       52  C7 0010A 	    DIVL3   CLUST, VOLUME_SIZE, R0				      ; 0539

		         50	0FFF   C0  9E 00110 	    MOVAB   4095(R0), R0					      ;

		         50 00001000   8F  C6 00115 	    DIVL2   #4096, R0						      ;

    0000G  CF	         50	       01  C1 0011C 	    ADDL3   #1, R0, BITMAP_CNT					      ;

				       01  DD 00122 	    PUSHL   #1							      ; 0540

		         7E	       58  9A 00124 	    MOVZBL  R8, -(SP)						      ;

		         6B	       02  FB 00127 	    CALLS   #2, ALLOCATE					      ;

	   50	  0000G  CF	       10  C7 0012A 	    DIVL3   #16, DIRECTORIES, R0				      ; 0541

    0000G  CF	         50	       01  C1 00130 	    ADDL3   #1, R0, MFD_CNT					      ;

				       01  DD 00136 	    PUSHL   #1							      ; 0542

		         7E	       59  9A 00138 	    MOVZBL  R9, -(SP)						      ;

		         6B	       02  FB 0013B 	    CALLS   #2, ALLOCATE					      ;

	   17	  0000G  CF	       07  E0 0013E 	    BBS     #7, INIT_OPTIONS+3, 8$				      ; 0543

		  0000G  CF	       52  D0 00144 7$:     MOVL    CLUST, IDXHDR2_CNT					      ; 0546

    0000G  CF	  0000G  CF	0000'  CF  C1 00149 	    ADDL3   HOMEBLOCK_DELTA, IDXFILE_LBN, IDXHDR2_LBN		      ; 0547

				       7E  D4 00153 	    CLRL    -(SP)						      ; 0548

		         7E	       00  9A 00155 	    MOVZBL  #IDXHDR2_IDX, -(SP)					      ;

		         6B	       02  FB 00158 	    CALLS   #2, ALLOCATE					      ;

					   04 0015B 8$:     RET     							      ; 0400



; Routine Size:  348 bytes







; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 3

; Digital Equipment Corporation

;

;	0553	ROUTINE ALLOCATE (INDEX, REVERSE) : NOVALUE =

;	0554	

;	0555	!++

;	0556	!

;	0557	! FUNCTIONAL DESCRIPTION:

;	0558	!

;	0559	!	This routine allocates the given table entry in the first available

;	0560	!	position after the given start, searching in the given direction.

;	0561	!

;	0562	!

;	0563	! CALLING SEQUENCE:

;	0564	!	ALLOCATE (ARG1, ARG2)

;	0565	!

;	0566	! INPUT PARAMETERS:

;	0567	!	ARG1: allocation table index of entry to allocate

;	0568	!	ARG2: direction: 0 = forward

;	0569	!			 1 = reverse

;	0570	!

;	0571	! IMPLICIT INPUTS:

;	0572	!	allocation table

;	0573	!

;	0574	! OUTPUT PARAMETERS:

;	0575	!	NONE

;	0576	!

;	0577	! IMPLICIT OUTPUTS:

;	0578	!	entry in allocation table

;	0579	!

;	0580	! ROUTINE VALUE:

;	0581	!	NONE

;	0582	!

;	0583	! SIDE EFFECTS:

;	0584	!	NONE

;	0585	!

;	0586	!--

;	0587	

;	0588	BEGIN

;	0589	

;	0590	LOCAL

;	0591		CONFLICT;			! index of conflicting table entry

;	0592	

;	0593	EXTERNAL

;	0594		CLUSTER,			! volume cluster factor

;	0595		VOLUME_SIZE,			! size of volume rounded to next cluster

;	0596		ALLOC_TABLE_CNT	: VECTOR,	! allocation count table

;	0597		ALLOC_TABLE_LBN	: VECTOR;	! allocation LBN table

;	0598	

;	0599	

;	0600	! Round the starting LBN and count down and up, respectively, to cluster boundaries.

;	0601	! Iterate, checking the proposed location of the entry against the rest of

;	0602	! the allocation table. When we encounter a conflict, adjust the location

;	0603	! past the conflicting entry and try again.

;	0604	!

;	0605	

;	0606	ALLOC_TABLE_LBN[.INDEX] = .ALLOC_TABLE_LBN[.INDEX] / .CLUSTER * .CLUSTER;

;	0607	ALLOC_TABLE_CNT[.INDEX] = (.ALLOC_TABLE_CNT[.INDEX] + .CLUSTER - 1) / .CLUSTER * .CLUSTER;



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 3-1

; Digital Equipment Corporation

;

;	0608	WHILE 1 DO

;	0609	    BEGIN

;	0610	    CONFLICT = CHECK_ALLOC (.INDEX);

;	0611	    IF .CONFLICT EQL -1 THEN RETURN;

;	0612	

;	0613	    IF NOT .REVERSE

;	0614	    THEN				! search in forward direction

;	0615		ALLOC_TABLE_LBN[.INDEX] = .ALLOC_TABLE_LBN[.CONFLICT]

;	0616					+ .ALLOC_TABLE_CNT[.CONFLICT]

;	0617	

;	0618	    ELSE				! search in reverse direction

;	0619		ALLOC_TABLE_LBN[.INDEX] = .ALLOC_TABLE_LBN[.CONFLICT]

;	0620					- .ALLOC_TABLE_CNT[.INDEX];

;	0621	

;	0622	! The limit test works in the reverse direction since we will wrap through

;	0623	! zero.

;	0624	!

;	0625	

;	0626	    IF .ALLOC_TABLE_LBN[.INDEX] GEQU .VOLUME_SIZE

;	0627	    THEN ERR_EXIT (INIT$_ALLOCFAIL);

;	0628	    END;

;	0629	

;	0630	END;					! end of routine ALLOCATE







							    .GLOBL  ALLOC_TABLE_CNT, ALLOC_TABLE_LBN



					 087C 0015C ALLOCATE:

							    .WORD   Save R2,R3,R4,R5,R6,R11				      ; 0553

		         5B	0000G  CF  9E 0015E 	    MOVAB   ALLOC_TABLE_LBN, R11				      ;

		         53	  04   AC  D0 00163 	    MOVL    INDEX, R3						      ; 0606

		         54	     6B43  DE 00167 	    MOVAL   ALLOC_TABLE_LBN[R3], R4				      ;

		         50	0000G  CF  D0 0016B 	    MOVL    CLUSTER, R0						      ;

	   51	         64	       50  C7 00170 	    DIVL3   R0, (R4), R1					      ;

	   64	         51	       50  C5 00174 	    MULL3   R0, R1, (R4)					      ;

		         55	0000GCF43  DE 00178 	    MOVAL   ALLOC_TABLE_CNT[R3], R5				      ; 0607

	   51	         65	       50  C1 0017E 	    ADDL3   R0, (R5), R1					      ;

				       51  D7 00182 	    DECL    R1							      ;

		         51	       50  C6 00184 	    DIVL2   R0, R1						      ;

	   65	         51	       50  C5 00187 	    MULL3   R0, R1, (R5)					      ;

		         56	  08   AC  D2 0018B 	    MCOML   REVERSE, R6						      ; 0613

				       53  DD 0018F 1$:     PUSHL   R3							      ; 0610

		  0000V  CF	       01  FB 00191 	    CALLS   #1, CHECK_ALLOC					      ;

		         52	       50  D0 00196 	    MOVL    R0, CONFLICT					      ;

	      FFFFFFFF   8F	       52  D1 00199 	    CMPL    CONFLICT, #-1					      ; 0611

				       28  13 001A0 	    BEQL    4$							      ;

		         0A	       56  E9 001A2 	    BLBC    R6, 2$						      ; 0613

	   64	       6B42	0000GCF42  C1 001A5 	    ADDL3   ALLOC_TABLE_CNT[CONFLICT], ALLOC_TABLE_LBN[CONFLICT], -   ; 0616

								    (R4)						      ;

				       05  11 001AD 	    BRB     3$							      ; 0613

	   64	       6B42	       65  C3 001AF 2$:     SUBL3   (R5), ALLOC_TABLE_LBN[CONFLICT], (R4)		      ; 0620

		  0000G  CF	       64  D1 001B4 3$:     CMPL    (R4), VOLUME_SIZE					      ; 0626

				       D4  1F 001B9 	    BLSSU   1$							      ;

			    0075807C   8F  DD 001BB 	    PUSHL   #7700604						      ; 0627



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 3-2

; Digital Equipment Corporation

;

	      00000000G  00	       01  FB 001C1 	    CALLS   #1, LIB$STOP					      ;

				       C5  11 001C8 	    BRB     1$							      ; 0608

					   04 001CA 4$:     RET     							      ; 0553



; Routine Size:  111 bytes







; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 4

; Digital Equipment Corporation

;

;	0631	ROUTINE ALLOCATE_HOME (INDEX) : NOVALUE =

;	0632	

;	0633	!++

;	0634	!

;	0635	! FUNCTIONAL DESCRIPTION:

;	0636	!

;	0637	!	This routine allocates the indicated allocation table entry to

;	0638	!	the first available block on the home block search sequence.

;	0639	!

;	0640	!

;	0641	! CALLING SEQUENCE:

;	0642	!	ALLOC_HOME (ARG1)

;	0643	!

;	0644	! INPUT PARAMETERS:

;	0645	!	ARG1: table index of home block cluster

;	0646	!

;	0647	! IMPLICIT INPUTS:

;	0648	!	allocation table in INIDSK

;	0649	!

;	0650	! OUTPUT PARAMETERS:

;	0651	!	NONE

;	0652	!

;	0653	! IMPLICIT OUTPUTS:

;	0654	!	entry in table

;	0655	!

;	0656	! ROUTINE VALUE:

;	0657	!	NONE

;	0658	!

;	0659	! SIDE EFFECTS:

;	0660	!	NONE

;	0661	!

;	0662	!--

;	0663	

;	0664	BEGIN

;	0665	

;	0666	LOCAL

;	0667		DELTA,				! home block search delta

;	0668		LBN;				! home block candidate LBN

;	0669	

;	0670	EXTERNAL

;	0671		INIT_OPTIONS	: BITVECTOR,		! command options

;	0672		DEVICE_TABLE	: BBLOCKVECTOR [,DVT_LENGTH],

;	0673						! device data table

;	0674		DEV_INDEX,			! table index of this device

;	0675		CLUSTER,			! volume cluster factor

;	0676		VOLUME_SIZE,			! size of volume rounded to next cluster

;	0677		REAL_HOMEBLOCK,			! LBN of "official" home block

;	0678		ALLOC_TABLE_LBN	: VECTOR;	! allocation LBN table

;	0679	

;	0680	

;	0681	! Compute the home block search delta. For structure level 1, this is simply

;	0682	! 256, except that the first slot is on LBN 1 rather than 0. For level 2,

;	0683	! compute the home block search delta from the volume geometry in the

;	0684	! device table. This is done according to the following rules, where volume

;	0685	! geometry is expressed in the order sectors, tracks, cylinders:



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 4-1

; Digital Equipment Corporation

;

;	0686	!

;	0687	!	n x 1 x 1:	1

;	0688	!	1 x n x 1:	1

;	0689	!	1 x 1 x n:	1

;	0690	!

;	0691	!	n x m x 1:	n+1

;	0692	!	n x 1 x m:	n+1

;	0693	!	1 x n x m:	n+1

;	0694	!

;	0695	!	s x t x c:	(t+1)*s+1

;	0696	!

;	0697	

;	0698	IF .INIT_OPTIONS[OPT_STRUCTURE1]

;	0699	THEN

;	0700	    DELTA = 256

;	0701	ELSE

;	0702	    BEGIN

;	0703	    DELTA = 1;

;	0704	    IF NOT .DEVICE_TABLE[.DEV_INDEX, DVT_NOGEOM]

;	0705	    THEN

;	0706		BEGIN

;	0707		IF  .DEVICE_TABLE[.DEV_INDEX, DVT_CYLINDERS] GTR 1

;	0708		AND .DEVICE_TABLE[.DEV_INDEX, DVT_TRACKS] GTR 1

;	0709		THEN DELTA = .DELTA + .DEVICE_TABLE[.DEV_INDEX, DVT_TRACKS];

;	0710	

;	0711		IF  .DEVICE_TABLE[.DEV_INDEX, DVT_SECTORS] GTR 1

;	0712		AND (.DEVICE_TABLE[.DEV_INDEX, DVT_CYLINDERS] GTR 1

;	0713		    OR .DEVICE_TABLE[.DEV_INDEX, DVT_TRACKS] GTR 1)

;	0714		THEN DELTA = .DELTA * .DEVICE_TABLE[.DEV_INDEX, DVT_SECTORS] + 1;

;	0715		END;

;	0716	    END;

;	0717	

;	0718	HOMEBLOCK_DELTA = .DELTA;

;	0719	

;	0720	! Now find the first available cluster on the search sequence by starting

;	0721	! with LBN 1 and incrementing by the delta for each try.

;	0722	!

;	0723	

;	0724	LBN = 1;

;	0725	

;	0726	WHILE 1 DO

;	0727	    BEGIN

;	0728	    ALLOC_TABLE_LBN[.INDEX] = .LBN / .CLUSTER * .CLUSTER;

;	0729	    IF CHECK_ALLOC (.INDEX) EQL -1 THEN EXITLOOP;

;	0730	    IF .INIT_OPTIONS[OPT_STRUCTURE1]

;	0731	    THEN LBN = .LBN AND NOT 1;

;	0732	    LBN = .LBN + .DELTA;

;	0733	    IF .LBN GEQU .VOLUME_SIZE

;	0734	    THEN ERR_EXIT (INIT$_ALLOCFAIL);

;	0735	    END;

;	0736	

;	0737	REAL_HOMEBLOCK = .LBN;			! save LBN of actual block

;	0738	

;	0739	END;					! end of routine ALLOCATE_HOME





; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 4-2

; Digital Equipment Corporation

;





							    .GLOBL  DEVICE_TABLE, DEV_INDEX, REAL_HOMEBLOCK



					 081C 001CB ALLOCATE_HOME:

							    .WORD   Save R2,R3,R4,R11					      ; 0631

		         5B	0000G  CF  9E 001CD 	    MOVAB   DEVICE_TABLE+1, R11					      ;

	   07	  0000G  CF	       07  E1 001D2 	    BBC     #7, INIT_OPTIONS+3, 1$				      ; 0698

		         54	0100   8F  3C 001D8 	    MOVZWL  #256, DELTA						      ; 0700

				       47  11 001DD 	    BRB     4$							      ; 0698

		         54	       01  D0 001DF 1$:     MOVL    #1, DELTA						      ; 0703

	   50	  0000G  CF	       04  78 001E2 	    ASHL    #4, DEV_INDEX, R0					      ; 0704

	   38	    03 AB40	       00  E0 001E8 	    BBS     #0, DEVICE_TABLE+4[R0], 4$				      ;

				  01 AB40  9F 001EE 	    PUSHAB  DEVICE_TABLE+2[R0]					      ; 0707

		         01	       9E  B1 001F2 	    CMPW    @(SP)+, #1						      ;

				       0D  1B 001F5 	    BLEQU   2$							      ;

		         01	     6B40  91 001F7 	    CMPB    DEVICE_TABLE+1[R0], #1				      ; 0708

				       07  1B 001FB 	    BLEQU   2$							      ;

		         51	     6B40  9A 001FD 	    MOVZBL  DEVICE_TABLE+1[R0], R1				      ; 0709

		         54	       51  C0 00201 	    ADDL2   R1, DELTA						      ;

		         01	  FF AB40  91 00204 2$:     CMPB    DEVICE_TABLE[R0], #1				      ; 0711

				       1B  1B 00209 	    BLEQU   4$							      ;

				  01 AB40  9F 0020B 	    PUSHAB  DEVICE_TABLE+2[R0]					      ; 0712

		         01	       9E  B1 0020F 	    CMPW    @(SP)+, #1						      ;

				       06  1A 00212 	    BGTRU   3$							      ;

		         01	     6B40  91 00214 	    CMPB    DEVICE_TABLE+1[R0], #1				      ; 0713

				       0C  1B 00218 	    BLEQU   4$							      ;

		         50	  FF AB40  9A 0021A 3$:     MOVZBL  DEVICE_TABLE[R0], R0				      ; 0714

		         50	       54  C4 0021F 	    MULL2   DELTA, R0						      ;

	   54	         50	       01  C1 00222 	    ADDL3   #1, R0, DELTA					      ;

		  0000'  CF	       54  D0 00226 4$:     MOVL    DELTA, HOMEBLOCK_DELTA				      ; 0718

		         53	       01  D0 0022B 	    MOVL    #1, LBN						      ; 0724

		         52	  04   AC  D0 0022E 	    MOVL    INDEX, R2						      ; 0728

	   50	         53	0000G  CF  C7 00232 5$:     DIVL3   CLUSTER, LBN, R0					      ;

    0000GCF42	         50	0000G  CF  C5 00238 	    MULL3   CLUSTER, R0, ALLOC_TABLE_LBN[R2]			      ;

				       52  DD 00241 	    PUSHL   R2							      ; 0729

		  0000V  CF	       01  FB 00243 	    CALLS   #1, CHECK_ALLOC					      ;

	      FFFFFFFF   8F	       50  D1 00248 	    CMPL    R0, #-1						      ;

				       22  13 0024F 	    BEQL    7$							      ;

	   03	  0000G  CF	       07  E1 00251 	    BBC     #7, INIT_OPTIONS+3, 6$				      ; 0730

		         53	       01  CA 00257 	    BICL2   #1, LBN						      ; 0731

		         53	       54  C0 0025A 6$:     ADDL2   DELTA, LBN						      ; 0732

		  0000G  CF	       53  D1 0025D 	    CMPL    LBN, VOLUME_SIZE					      ; 0733

				       CE  1F 00262 	    BLSSU   5$							      ;

			    0075807C   8F  DD 00264 	    PUSHL   #7700604						      ; 0734

	      00000000G  00	       01  FB 0026A 	    CALLS   #1, LIB$STOP					      ;

				       BF  11 00271 	    BRB     5$							      ; 0726

		  0000G  CF	       53  D0 00273 7$:     MOVL    LBN, REAL_HOMEBLOCK					      ; 0737

					   04 00278 	    RET     							      ; 0631



; Routine Size:  174 bytes







; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 5

; Digital Equipment Corporation

;

;	0740	ROUTINE CHECK_ALLOC (INDEX) =

;	0741	

;	0742	!++

;	0743	!

;	0744	! FUNCTIONAL DESCRIPTION:

;	0745	!

;	0746	!	This routine checks the indicated allocation table entry for

;	0747	!	conflicts against all other table entries.

;	0748	!

;	0749	!

;	0750	! CALLING SEQUENCE:

;	0751	!	CHECK_ALLOC (ARG1)

;	0752	!

;	0753	! INPUT PARAMETERS:

;	0754	!	ARG1: index of table entry to check

;	0755	!

;	0756	! IMPLICIT INPUTS:

;	0757	!	allocation table in INIDSK

;	0758	!

;	0759	! OUTPUT PARAMETERS:

;	0760	!	NONE

;	0761	!

;	0762	! IMPLICIT OUTPUTS:

;	0763	!	NONE

;	0764	!

;	0765	! ROUTINE VALUE:

;	0766	!	index of conflicting table entry

;	0767	!	or -1 if no conflict

;	0768	!

;	0769	! SIDE EFFECTS:

;	0770	!	NONE

;	0771	!

;	0772	!--

;	0773	

;	0774	BEGIN

;	0775	

;	0776	EXTERNAL

;	0777		ALLOC_TABLE_CNT	: VECTOR,	! allocation count table

;	0778		ALLOC_TABLE_LBN	: VECTOR;	! allocation LBN table

;	0779	

;	0780	EXTERNAL LITERAL

;	0781		ALLOC_MAX	: UNSIGNED (16); ! total size of allocation table

;	0782	

;	0783	

;	0784	! Simply scan the entire table, doing a range compare on each entry (noting

;	0785	! not to compare the candidate against itself). Active table entries are

;	0786	! identified by a non-zero count.

;	0787	!

;	0788	

;	0789	INCR J FROM 0 TO ALLOC_MAX DO

;	0790	    BEGIN

;	0791	    IF .ALLOC_TABLE_CNT[.J] NEQ 0

;	0792	    AND .J NEQ .INDEX

;	0793	    AND .ALLOC_TABLE_LBN[.J] + .ALLOC_TABLE_CNT[.J] GTRU .ALLOC_TABLE_LBN[.INDEX]

;	0794	    AND .ALLOC_TABLE_LBN[.J] LSSU .ALLOC_TABLE_CNT[.INDEX] + .ALLOC_TABLE_LBN[.INDEX]



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 5-1

; Digital Equipment Corporation

;

;	0795	    THEN EXITLOOP .J;

;	0796	    END

;	0797	

;	0798	END;					! end of routine CHECK_ALLOC







							    .GLOBL  ALLOC_MAX



					 0804 00279 CHECK_ALLOC:

							    .WORD   Save R2,R11						      ; 0740

		         5B	0000G  CF  9E 0027B 	    MOVAB   ALLOC_TABLE_LBN, R11				      ;

		         50	       01  CE 00280 	    MNEGL   #1, J						      ; 0789

				       2F  11 00283 	    BRB     2$							      ;

		         51	0000GCF40  D0 00285 1$:     MOVL    ALLOC_TABLE_CNT[J], R1				      ; 0791

				       27  13 0028B 	    BEQL    2$							      ;

		    04   AC	       50  D1 0028D 	    CMPL    J, INDEX						      ; 0792

				       21  13 00291 	    BEQL    2$							      ;

	   52	       6B40	       51  C1 00293 	    ADDL3   R1, ALLOC_TABLE_LBN[J], R2				      ; 0793

		         51	  04   AC  D0 00298 	    MOVL    INDEX, R1						      ;

		       6B41	       52  D1 0029C 	    CMPL    R2, ALLOC_TABLE_LBN[R1]				      ;

				       12  1B 002A0 	    BLEQU   2$							      ;

		         51	  04   AC  D0 002A2 	    MOVL    INDEX, R1						      ; 0794

	   51	  0000GCF41	     6B41  C1 002A6 	    ADDL3   ALLOC_TABLE_LBN[R1], ALLOC_TABLE_CNT[R1], R1	      ;

		         51	     6B40  D1 002AE 	    CMPL    ALLOC_TABLE_LBN[J], R1				      ;

				       0B  1F 002B2 	    BLSSU   3$							      ;

	   C9	         50 00000000G  8F  F3 002B4 2$:     AOBLEQ  #ALLOC_MAX, J, 1$					      ; 0789

		         50	       01  CE 002BC 	    MNEGL   #1, R0						      ;

					   04 002BF 3$:     RET     							      ; 0740



; Routine Size:  71 bytes





;	0799	

;	0800	END

;	0801	ELUDOM









							    .GLOBL  LIB$SIGNAL, LIB$STOP



;				       PSECT SUMMARY

;

;	Name		 Bytes			       Attributes

;

;  $OWN$          	     4    WRT,  RD ,NOEXE,NOSHR,  LCL,  REL,  CON,NOPIC,ALIGN(2)

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









;				LIBRARY STATISTICS

;

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



; Bliss-32 7.352	Saturday 22-AUG-1978 00:17:49	DBB3:[INIT.SRC]INIALL.B32;11					Page 5-2

; Digital Equipment Corporation

;

;	File				     Total    Loaded   Percent      Read

;

;  DBA4:[SYSLIB]LIB.L32;1		      5582         3         0       222











; Size:		704 code + 4 data bytes

; Run Time:	00:19.5

; Elapsed Time:	00:43.9

; Memory Used:	302 pages

; Compilation Complete

