// PupAlComProc.decl - declarations specific to the ComProc version
//		of the Pup Synchronous line transport protocol (aka SLA)
// Copyright Xerox Corporation 1979

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

//----------------------------------------------------------------------------
manifest		// ComProc interface definitions
//----------------------------------------------------------------------------
[
// high memory control locations
cpBase = 177300b	// 177300 + 4*line + 0-3 are line's locations
  cpControl0 = 0	// line control register offset
  cpControl1 = 1	// more control register bits
  cpSync = 2		// Sync byte register offset
  cpStatus = 3		// line status register offset

// 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.

// 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.

// microcode subroutines.
mcSilentBoot = 63000B	// SilentBoot(BootLocusVector).
mcSetLineTab = 63400B	// SetLineTab(cpLT)
mcChangeControlReg = 65400B // ChangeControlReg(lineTimes4, mask)
]

//----------------------------------------------------------------------------
structure CPLTE:  	// ComProc Line Table Entry
//----------------------------------------------------------------------------
[
exists word		// true if there is a LIM for this line
blank word		// EIA board status in EIA version
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 lenCPLTE = size CPLTE/16

//----------------------------------------------------------------------------
structure CPLT: [ cpLTE↑0,15 @CPLTE ]	// ComProc Line Table
//----------------------------------------------------------------------------
manifest lenCPLT = size CPLT/16

//----------------------------------------------------------------------------
structure CPLCB:  	// ComProc Line Command Block
//----------------------------------------------------------------------------
[
link word		// Next line command block in chain; zero if last.
intMask word		// Interrupt mask.
firmStatus word		// Microcode status.
hardStatus word		// 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 lenCPLCB = size CPLCB/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 = 15		// 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 CPPBI:	// ComProc 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:		// ComProc 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)
//----------------------------------------------------------------------------
[
@CPPBI
srcHost byte		// who it's from
numEntries byte		// number of RTEs in this packet
rt↑1,maxHost:@RTE
]
manifest lenRTPacket = (size RTPBI - offset CPPBI.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:		// ComProc 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
iCPLCB word		// -> input ComProc LCB
oPBI word		// -> output PBI. 0 if none
oCPLCB word		// -> output ComProc LCB
stats word = @LineStats	// line statistics
highOQ @Q		// high-priority output queue
lowOQ @Q		// low-priority output queue
]
manifest lenLCB = size LCB/16

//----------------------------------------------------------------------------
structure CPNDB:  	// 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 lenCPNDB = size CPNDB/16