// PupAlEIA.decl - declarations specific to the Alto EIA Interface version
//		of the Pup Synchronous line transport protocol (aka SLA)
// Copyright Xerox Corporation 1979

// Last modified January 30, 1979  1:26 PM by Boggs


//----------------------------------------------------------------------------
manifest		// EIA interface definitions
//----------------------------------------------------------------------------
[
eiaControl = 177700B	// EIA interface controlled by storing into here
eiaData = 177703B	// EIA interface data register
eiaStatus = 177704B	// EIA interface status available from here

// EIA interface commands.
initIF = 100000B	// Initialize interface circuits.
initRT = 110000B	// initialize receiver/transmitter.
initRG = 120000B	// Initialize registers.
reset = 130000B		// Generate controller resets.
swi = 140000B		// Force the line to request an interrupt.
inta = 150000B		// Acknowledge interrupt to the selected line.

// EIA microcode states.
stateThrowAway = 0	// Throw away all inputs, ignore all outputs.
stateBiSyncInput = 1	// Input data according to BiSync protocol.
stateBiSyncOutput = 2	// Output data according to BiSync protocol.

// EIA microcode errors.
errorNone = 0		// No error.
errorFatal = 1		// Fatal hardware error.
errorSTX = 3		// Byte after first DLE was not an STX.
errorETX = 4		// Input buffer overflowed before ETX
errorDLE = 5		// DLE not followed by DLE, SYN, or ETX.
errorCRC = 6		// Bad CRC.

// EIA microcode subroutines.
mcSilentBoot = 63000B	// SilentBoot(BootLocusVector).
mcEnableEIA = 63400B	// EnableEIA(LineTable).
]

//----------------------------------------------------------------------------
structure EIALTE:  	// EIA Line Table Entry
//----------------------------------------------------------------------------
[
exists word		// nonzero if a board is plugged in.
status word		// EIA interface board status.
iLCB word		// -> lcb chain; zero if none.
iState word		// Input state of the line.
oLCB word		// -> lcb chain; zero if none.
oState word		// Output state of the line.
]
manifest lenEIALTE = size EIALTE/16

//----------------------------------------------------------------------------
structure EIALT: [ eiaLTE↑0,7 @EIALTE ]	// EIA Line Table
//----------------------------------------------------------------------------
manifest lenEIALT = size EIALT/16

//----------------------------------------------------------------------------
structure EIALCB:  	// EIA Line Command Block
//----------------------------------------------------------------------------
[
link word		// Next line command block in chain; zero if last.
intMask word		// Interrupt mask.
firmStatus word		// Microcode status.
hardStatus word		// EIA interface board status.
byteCount word		// Byte count and half-word selction; msb =0 => left.
bytePointer word	// Word address of next byte.
partialCRC word		// Partial cyclical redundancy check.
]
manifest lenEIALCB = size EIALCB/16

//----------------------------------------------------------------------------
manifest		// Synchronous line transport protocol definitions
//----------------------------------------------------------------------------
[
typePup = 1000b		// I'm a Pup
typeRoute = 1001b	// Routing table packet

slaStatsVersion = 1

maxHost = 32		// maximum host number on this network
maxLine = 3		// maximum line number in this host
maxHops = 15		// highest legal hop count
			//  = longest possible path in network
			//  (used to detect inaccessible nodes)

routingProbeInterval = 500  // broadcast routing table every 5 sec
routingTimeout = 2000	// time out line if no table rcvd in 20 sec
maxHiPriBytes = 50+22	// maximum length of high-priority packet
frameOverheadBytes = 10	// SYN*3 DLE STX DLE ETX CRC*2 PAD
]

//----------------------------------------------------------------------------
structure EIAPBI:	// EIA encapsulation
//----------------------------------------------------------------------------
[
blank word offset PBI.pup/16-2
allLines bit		// send this on all lines please
broadcast bit		// send on all lines that are up
line bit 6		// line number on which pbi came in
dest byte		// destination host number
//bytes below here are transmitted
type word		// packet type
]

//----------------------------------------------------------------------------
structure RTE:		// EIA Routing Table Entry
//----------------------------------------------------------------------------
[
hopCnt byte		// hops from here to host
line byte		// via line number
]
manifest lenRTE = size RTE/16

//----------------------------------------------------------------------------
structure RTPBI:	// Routing Table PBI (level 0)
//----------------------------------------------------------------------------
[
@EIAPBI
srcHost byte		// who it's from
numEntries byte		// number of RTEs in this packet
rt↑1,maxHost:@RTE
]
manifest lenRTPacket = (size RTPBI - offset EIAPBI.type)/16

//----------------------------------------------------------------------------
structure LineStats:	// Line statistics
//----------------------------------------------------------------------------
[
// These count all successful transmissions and receptions,
//  both Pups and non-Pups.
transmitPackets word 2	// Packets transmitted
receivePackets word 2	// Packets received
transmitBytes word 2	// Bytes transmitted (excl framing & doubled DLEs)
receiveBytes word 2	// Bytes received (excluding framing & doubled DLEs)

// These count bad packets, not included in the above counts.
inputOverrun word	// Probably lost sync
badCRC word		// Received bad CRC
lineControlError word	// Bad line control sequence

state word		// state of line (only 2 bits really needed)
]
manifest lenLineStats = size LineStats/16

//----------------------------------------------------------------------------
structure SLAStats:	// Level 0 stats for SLA drivers
//----------------------------------------------------------------------------
[
statsType word		// = netTypeSLA
statsVersion word	// = slaStatsVersion
maxHost word
rt↑1,maxHost @RTE
maxLine word
lineStats↑0,maxLine @LineStats
]
manifest lenSLAStats = size SLAStats/8  // *** in BYTES ***

manifest
[
// SLA line states
slaLineDown = 0
slaLineUp = 1
slaLineLoopedBack = 2
slaLineMissing = 3
]

//----------------------------------------------------------------------------
structure Q [ head word; tail word ]
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
structure LCB:		// EIA Line control block
//----------------------------------------------------------------------------
[
line word		// line number
rTimer word		// set when a routing packet arrives
tTimer word		// for timing out transmitter
iPBI word		// -> input PBI. 0 if none
iEIALCB word		// -> input EIA LCB
oPBI word		// -> output PBI. 0 if none
oEIALCB word		// -> output EIA LCB
stats word = @LineStats	// line statistics
highOQ @Q		// high-priority output queue
lowOQ @Q		// low-priority output queue
]
manifest lenLCB = size LCB/16

//----------------------------------------------------------------------------
structure EIANDB:  	// Network Data Block
//----------------------------------------------------------------------------
[
@NDB			// standard portion
lcb↑0,maxLine: @LCB	// line control blocks
rt↑1,maxHost:@RTE	// internal routing table
rPF: @PF		// routing packet filter
rIQ: @Q			// routing table input queue
]
manifest lenEIANDB = size EIANDB/16