// AltoFileSys.D -- Definitions for things kept on a disk.
// Copyright Xerox Corporation 1979
// Last modified December 1, 1979  2:43 PM by Boggs

manifest maxStringIndex = 255
structure STRING: [ length byte; char↑1,maxStringIndex byte ]
manifest lSTRING = size STRING/16

structure TIME: [ h word 1; l word 1 ]
manifest lTIME = size TIME/16


//  F I L E    D E S C R I P T O R S

//---------------------------------------------------------------------------
structure SN:		// File Serial Number
//---------------------------------------------------------------------------
[
word1 word  = 
   [
   directory bit 1	// this file is a directory
   random bit 1
   nolog bit		// no longer used
   part1 bit 13
   ]
word2 word  =  part2 word
]
manifest lSN = size SN/16


// file pointer -- describes a particular file by label & leader page position
//---------------------------------------------------------------------------
structure FP:		// File Pointer
//---------------------------------------------------------------------------
[
serialNumber @SN
version word
blank word		// expansion to 2-word virtual Da's
leaderVirtualDa word
]
manifest lFP = size FP/16


// file address -- describes a particular spot in some file, but
//		does not contain enough info to read it (SN, vn missing)
//---------------------------------------------------------------------------
structure FA:		// File Address
//---------------------------------------------------------------------------
[
da word			// Virtual DA for the page
pageNumber word		// Page number in file (0, 1, ....)
charPos word		// Byte position on the page
]
manifest lFA = size FA/16


// complete file address -- complete information needed to address
//		any byte in the file structure
//---------------------------------------------------------------------------
structure CFA:		// Complete File Address
//---------------------------------------------------------------------------
[
fp @FP
fa @FA
]
manifest lCFA = size CFA/16

//     D I S K    D E S C R I P T O R

//---------------------------------------------------------------------------
structure KDH:		// Disk Descriptor Header
//---------------------------------------------------------------------------
[
kd word =		// First word (for lv...)
nDisks word		// Number of disks
nTracks word		// Number of tracks
nHeads word		// Number of heads
nSectors word		// Number of sectors
lastSn @SN		// Last serial number used on disk
blank word		// formerly bitTableChanged (OS17 and before)
diskBTsize word		// Number of valid words in the disk bit table
defaultVersionsKept word	// Default # file versions retained
				// (0 implies no multiple version feature)
freePages word
blank word 6
]
manifest lKDHeader = size KDH/16

//      L E A D E R   P A G E

// leader page -- note that the definition is independent of page size
//		(assumes at least 256 words can be stored)

manifest maxLengthFn = 39		//For all OS routines
manifest maxLengthFnInWords = (maxLengthFn+2)/2 //enough for final "."

//---------------------------------------------------------------------------
structure LD:		// Leader Page
//---------------------------------------------------------------------------
[
created @TIME
written @TIME
read @TIME
name word maxLengthFnInWords
leaderProps word 210	// Properties stored in leader page
spare word 256-3*lTIME-maxLengthFnInWords-210-2-lFP-lFA
propertyBegin byte	// Index in LD of leaderProps
propertyLength byte	// number of words = 210
consecutive bit		// Hint that file is allocated consecutively
blank1 bit 7
changeSerial bit 8	// Bumped each time name => FP map changes
dirFp word lFP		// Hint for directory
hintLastPageFa @FA	// EOF hint
]


//---------------------------------------------------------------------------
structure FPROP:	// File properties (partly in leader)
//---------------------------------------------------------------------------
[			// 0 terminates list
type bit 8
length bit 8
]

manifest
[
// FPROP types 0-177b are reserved for the system.
fpropTypeDShape = 1	// contains a DSHAPE (in leader page of SysDir)
fpropTypePartitionName = 2  // contains a STRING which is the name of this
			// partition (in leader page of SysDir)
// FRPOP types 200b-277b are for users.
fpropTypeBravo = 200b	// used by Bravo X
]

//---------------------------------------------------------------------------
structure DSHAPE:	// Shape of the disk (a property in leader of SysDir)
//---------------------------------------------------------------------------
[
nDisks word		// Number of disks
nTracks word		// Number of tracks
nHeads word		// Number of heads
nSectors word		// Number of sectors
]
manifest lDSHAPE = size DSHAPE/16

//      D I R E C T O R I E S

//---------------------------------------------------------------------------
structure DV:		// Directory entry value
//---------------------------------------------------------------------------
[
type bit 6
length bit 10
fp @FP
name @STRING
]
manifest lDV = offset DV.name/16  //** note: length of header only

manifest		// DV types
[
dvTypeFree = 0
dvTypeFile = 1
]