;<PUP>PSQDEF.MAC.11, 13-Oct-82 13:50:35, Edit by SCHOEN
; Upped nconn to ↑d12 (Wow!)
;<PUP>PSQDEF.MAC.9, 27-Apr-82 21:57:53, Edit by SCHOEN
; Define SQRTRN (Sequin retransmitting)
;<PUP>PSQDEF.MAC.6, 10-Apr-82 20:59:49, Edit by SCHOEN
; PSQVAR, PSQPVR -> TOPVAR, TOPPVR for compatibility with PUPUUO.MAC
;<PUP>PSQDEF.MAC.5,  3-Apr-82 00:12:19, Edit by SCHOEN
; Fix definition of ERCAL for non-Sumex Tenexes so LEAFSV can be
; compiled on Tenex for Tops-20
;<PUP>PSQDEF.MAC.3,  2-Apr-82 10:38:51, Edit by SCHOEN
; Don't search SYSDEF, STENEX, MONSYM
;<SCHOEN>PSQDEF.MAC.5,  4-Dec-81 22:50:35, Edit by SCHOEN
; Define format of Queue Information Block

	universal Psqdef
	subttl	Definitions for Tenex Sequin implementation
	search pupdef

;	Eric Schoen
;	SUMEX Computer Project
;	Stanford University Medical Center
;	Stanford, CA
;	August, 1981

;	Work on Leaf and Sequin implementations in Tenex
;	and Tops-20 was funded by NIH Biotechnology Resouces 
;	Program	under grant RR-00785

;	Sequin protocol definitions
;	Control field def'ns

; AC declarations

f=0		; flags

a=1		; temporary accumulators
b=2
c=3
d=4

sq=5		; sequin data block pointer
cx=6		; connection table index
pb=7		; packet buffer pointer

p1=10		; permanent accumulators (saved by callers)
p2=11
p3=12
p4=13
p5=14

fx=16
p=17		; stack pointer

callf==1b1	; BNTSRV PUSHJ'd to
defntf==1b2	; Recall BNTSRV on exit
inbntf==1b3	; Called SIGBNT from BNTSRV
lgttyf==1b4	; LOG errors to LOGTTY also

tempf1==1b18	; temp flags
tempf2==1b19

SeqDat==0	; Packet contains data
SeqAck==1	; Packet is a Sequin acknowledge
SeqNop==2	; Packet is a nop to prevent timeout
SeqRes==3	; Packet requests retransmissions of unacknowledged packets
SeqChk==4	; Obsolete, replaced by SeqNop
SeqOpn==5	; Packet opens a Sequin connection
SeqBrk==6	; Packet indicates user abort
SeqCls==7	; Packet indicates start of orderly exit [obsolete]
SeqCld==10	; Packet acknowledges a SeqCls packet
SeqDes==11	; Causes a connection to close (be destroyed)
SeqDal==12	; Packet causes recvr to wait for SeqQui, or timeout
SeqQui==13	; Packet causes receiver to go away 
SeqBro==14	; Sent before a party dies unexpectedly


; Well known sockets and packet types
LeafSk=43			; Leaf listens on well-known socket 43
SeqTyp=260			; Leaf/Sequin Pup type

;Sequin state codes
CLOS==0				; No open Sequin connection
OPEN==1				; There is an open sequin connection
DLLY==2				; In process of closing a connection
BROK==3				; Broken state
DSTR==4				; Destroyed state
TIMD==5				; Timed-out state

; Sequin data block format (indexed by sq)
recvsq==0			; receive sequence number
sendsq==1			; send sequence number
seqsta==2			; sequin connection state
seqall==3			; sequin allocations: mine,,his
sqtxcu==4			; dequeue,,enqueue pointers for trans packets
sqrxcu==5			; dequeue,,enqueue points for recvd packets
seqlnh==6			; local net,,host
seqlsk==7			; local socket
seqfnh==10			; foreign net,,host
seqfsk==11			; foreign socket
sqjfnx==12			; port jfn,,connection table index
sqtime==13			; Time at which input timeout occurs
seqout==14			; packets outstanding: mine,,his
leaffk==15			; fork for leaf server
sqblen==leaffk+1

; format of a queue header block
quptrs==0			; prev,,next buffer
qusize==1			; number of buffers allocated
qucnt==2			; number of buffers used
qulock==3			; lock word for queue
qulckr==4			; FX for locker of queue
lqutab==qulckr+1		; length of queue block

; bits on the pbstat word of a packet buffer
pNoAck=1b0			; packet has not been acknowledged

; error codes for sequin interactions
errBro==1000			; sequin broken
errAlc==1001			; no allocation at receiver
errDes==1002			; sequin has been destroyed
errTim==1003			; timeout on Sequin input

; random defined quantities
MNPLEN==↑D22	; Minimum Pup Length (bytes), incl header and checksum
MXPLEN==↑D554	; Maximum Pup Length
MNPBLN==<MNPLEN+3>/4  ; Minimum size of PB, in words
MXPBLN==<MXPLEN+3>/4  ; Maximum size of PB, in words

mxAhed=↑d6	; maximum get-ahead in sequences
nconn==↑d12	; number of connections
npupbf==mxAhed	; number of buffers in connections

connt==↑d12*↑d3600	; connection timeout default is 12 hours
filet==↑d10*↑d60	; file timeout default is ten minutes
sqtmin==↑d20000		; wait twenty seconds for receiver to respond

ilsloc==300000		; begin local variable storage
elsloc==310000		; end local variable storage
ishloc==320000		; begin thawed storage
eshloc==330000		; end thawed storage

lstvar==:270000		; lstat storage
lstpvr==:274000

topvar==:ilsloc		; local storage
toppvr==:elsloc		; local page storage

pshvar==:ishloc		; fork thawed storage
pshpvr==:eshloc		; fork thawed page storage

pupbuf==400000		; allocate pup buffers from here
stksiz==100		; pdl size
psisiz==30		; interrupt pdl size
sigchn==1b0		; channel on which to interrupt leaf server 
			; for new packet arrival

define 	noint,<pushj p,.noint>
define	okint,<pushj p,.okint>

ifn ft10x,<
ifndef ercal,<
; this is for non-Sumex Tenexes
opdef	ercal	[pushj 17,]
>
ifndef erjmp,<
opdef	erjmp	[jump 16,]
>
>
; flags in left half of f.
sqrtrn==1b4			; Sequin retransmitting

	end