// PupBootServ.decl

// Last modified March 5, 1979  4:01 PM by Boggs

get "PupMiscServ.decl"

manifest
[
etBreathOfLife = 602b	// raw Ethernet packet type
breathInterval = 500	// 5 seconds
bootStatsVersion = 2
]

//----------------------------------------------------------------------------
structure Queue:	// Singly linked list, usually maintained FIFO
//----------------------------------------------------------------------------
[
head word		// -> first thing; 0 if queue is empty
tail word		// -> last thing; undefined if queue is empty
]

//----------------------------------------------------------------------------
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
//----------------------------------------------------------------------------
[
ctx word		// -> Boot Server ctx

stats @Stats

bfeQ: @Queue		// queue of BFEs
bcstTimer word		// counts 5 second intervals to next boot dir bcst
bcstInterval word	// interval between boot dir bcsts
doneQ: @Queue		// queue of BCTXs awaiting destruction

locks word =
   [
   blank bit 11
   globalLocks bit 2 =	// module wide locks
      [
      internalLock bit	// set by LockBootServ()
      externalLock bit	// set by ptLockBootRequest
      ]
   localLocks bit 3 =
      [
      rcvrLock bit	// rcvr ctx active
      fastLock bit	// fast send ctx active
      slowLock bit	// slow send ctx active
      ]
   ]
]
manifest
[
lenBS = size BS/16
rcvrLock = 4
fastLock = 2
slowLock = 1
]

//----------------------------------------------------------------------------
structure BFD:		// Boot File Descriptor
//----------------------------------------------------------------------------
[
bfn word		// boot file number
date word 2		// Alto format date on which file was created
name @String		// BCPL string
]
manifest lenBFD = offset BFD.name/16  // not including name string

//----------------------------------------------------------------------------
structure BFE:		// Boot File Entry (in BS.bfQ)
//----------------------------------------------------------------------------
[
link word		// -> next BFE or 0 if end
flags word =
   [
   blank bit 14
   exists bit		// we have a copy on the disk
   update bit		// get a new copy from BFE.port
   ]
fp word 5		// getting AltoFileSys.d breaks the compiler
port @Port		// if update then receive boot file from this port
bfd word = @BFD
]
manifest lenBFE = offset BFE.name/16

//----------------------------------------------------------------------------
structure BCTX:		// Boot Context
//----------------------------------------------------------------------------
[
blank word 3		// standard ctx header
bfe word		// -> BFE
lockMask word		// used to set and clear bits in BS.localLocks
port @Port		// port to|from which we are sending|rcving a file
]
manifest BCTXextra = size BCTX/16 -3