// IfsBootServ.decl
// Copyright Xerox Corporation 1979, 1980, 1981, 1982, 1983

// Last modified January 22, 1983  10:46 AM by Taft

// requires get of Ifs.decl, Pup0.decl, Pup1.decl, and IfsRs.decl
get "IfsMisc.decl"

manifest
[
etBreathOfLife = 602b	// raw Ethernet packet type
breathInterval = 500	// 5 seconds
bftCheckInterval = 12*30  // check BFT every 30 minutes
bftRebuildInterval = 2*8  // rebuild BFT every 8 hours
bootStatsVersion = 2
uCodeWordsPerPup = 258	// data words/Pup for microcode boot (multiple of 3)
uCodeOffsetBFN = 3000b	// offset from microcode BFNs to normal BFNs
bootTreePages = 25	// number of pages in BFT B-tree file
]

//----------------------------------------------------------------------------
structure Stats:
//----------------------------------------------------------------------------
[
version word		// = bootStatsVersion
dirsSent word 2		// # of directory requests serviced
fastSends word 2	// # of files sent to fast nets
slowSends word 2	// # of files sent to slow nets
filesRcvd word 2	// # of files received from other boot servers
]

//----------------------------------------------------------------------------
structure BS:		// 'global frame' for the Boot Server
//----------------------------------------------------------------------------
[
stats @Stats

bftCheckTimer word	// counts breathIntervals to next boot dir check
bftRebuildTimer word	// counts bftCheckIntervals to next BFT rebuild

tree word		// -> BFT B-tree
treeLock @Lock		// lock for B-tree

flags word =
   [
   globalLocks bit 2 =
      [
      externalLock bit	// set by ptLockBootRequest
      internalLock bit	// set until BFT B-tree first built
      ]
   noNewBootFiles bit	// set to disable obtaining new boot files
   fastBooter bit	// a fast BootCtx exists
   slowBooter bit	// a slow BootCtx exists
   ]

updateCtx word	// -> Ctx for CheckBFT (boot file update process), if any
]

manifest
[
lenBS = size BS/16
bsFastBooter = 100000B rshift (offset BS.fastBooter rem 16)
bsSlowBooter = 100000B rshift (offset BS.slowBooter rem 16)
]

//----------------------------------------------------------------------------
structure BootCtx:	// Boot Context
//----------------------------------------------------------------------------
[
@RSCtx			// standard ctx header
name word =		// -> full name of boot file (SendBootFile)
   bfe word		// -> boot file entry being updated (CheckBFT)
port @Port		// port to which we are sending file (SendBootFile)
booterFlags word	// bsFastBooter or bsSlowBooter flag (SendBootFile)
bytesToSkip word	// initial bytes to skip when sending boot file
]
manifest lenBootCtx = size BootCtx/16

//----------------------------------------------------------------------------
structure BFD:		// Boot File Descriptor -- defined by protocol
//----------------------------------------------------------------------------
[
bfn word		// boot file number
date word 2		// Alto format date on which file was created
name @String		// BCPL string
]

//----------------------------------------------------------------------------
structure BFE:		// Boot File Entry -- in BFT
//----------------------------------------------------------------------------
[
length word
flags word =
   [
   blank bit 14
   exists bit		// we have a copy on the disk
   update bit		// get a new copy from BFE.port
   ]
port @Port		// if update then receive boot file from this port
bfd word = @BFD
]