// IFS.decl - Commonly-needed runtime structures
// This is presently a hodge-podge.  It is due for reorganization.
// Copyright Xerox Corporation 1979, 1980, 1981
// Last modified November 14, 1981  10:34 AM by Taft


//----------------------------------------------------------------------------
manifest		// file system declarations
//----------------------------------------------------------------------------
[
nDrives = 8		// maximum number of drives
nDisks = 2*nDrives	// maximum number of 'disk' objects
ifsSwapPages = 150	// pages to preallocate for IFS.Swap
ifsErrorPages = 10	// pages to preallocate for IFS.Errors
ifsSymsPages = 50	// pages to preallocate for IFS.Syms
systemInfoPages = 10	// pages to preallocate for <System>Info
logStdPageLength = 10	// log standard page length --
			//  unit of core page allocation

// Error codes returned by OpenIFS
ecDupLUnit = 18		// Duplicate logical unit
ecNoLUnit0 = 19		// No logical unit 0
ecNumUnits = 20		// can't find numUnits packs
ec2LUnit0s = 21		// two logical unit 0s with same id
ecNoIFSDir = 22		// can't open ifs.dir

// some other useful error codes
ecDiabloFile = 6	// OpenFile (Alto OS version) failed
ecTridentFile = 7	// OpenFile (Alto OS version) failed
]

//----------------------------------------------------------------------------
structure Lock:
//----------------------------------------------------------------------------
[
ctx word		// last context to set this lock
count word		// 0 means not locked
			// + read lock count, -1 write locked
]
manifest lenLock = size Lock/16

//----------------------------------------------------------------------------
structure ECB:		// Event Control Block
//----------------------------------------------------------------------------
[
link word
timer word		// 5.46 minutes (32767 x 10 ms) max
proc word		// called when timer has expired
]
manifest lenECB = size ECB/16

//----------------------------------------------------------------------------
structure DTE:		// Drive Table Entry
//----------------------------------------------------------------------------
[
ifs word		// -> IFS structure. 0 => not part of an IFS
disk↑0,1 word		// -> TFSDSK structure(s) for this drive
]

//----------------------------------------------------------------------------
structure DriveTab↑0, nDrives-1 @DTE	// Drive Table
//----------------------------------------------------------------------------
manifest lenDriveTab = size DriveTab/16

//----------------------------------------------------------------------------
structure IFS:		// Interim File System
//----------------------------------------------------------------------------
[
link word		// IFSs are linked together on fsQ

// configuration information
lpdt↑0,nDisks-1 word	// logical to physical disk table
logPageLength word	// size of pages in this file system
pageLength word
numUnits word		// # of units in this ifs
type word		// primary, backup etc
id word			// -> id string
name word		// -> name string
created word 2		// unique id for file system

// directory information
dirLock @Lock		// lock for IFS.Dir
dirLockConflict word	// true if lock conflict has occurred
dirVersion word		// directory version number, incremented
			// each time the directory is modified
dirBTree word		// -> B-Tree structure for IFS.Dir
oft word		// -> Open File Table
]
manifest lenIFS = size IFS/16

//----------------------------------------------------------------------------
structure CPar:		// Parameters passed to CreateIFS
//----------------------------------------------------------------------------
[
id word			// -> id string
name word		// -> name string
type word		// ifs type
numUnits word		// number of logical units
lpMap↑0,nDrives-1 word	// log-phys map. Entries are PUnit #s
blank word nDrives	// reserved for "fake" units (see CreateIFS)
dirSize word		// number of pages to preallocate for IFS.dir
]
manifest lenCPar = size CPar/16

// everyone needs this!  but it's also defined in Pup1.decl.
compileif newname String then
   [ structure String: [ length byte; char↑1,1 byte ] ]