;PSVDEF.MAC;16    21-JAN-83 11:05:53    EDIT BY TAFT
; Add LOGDAY
;PSVDEF.MAC;15     5-SEP-82 11:10:48    EDIT BY TAFT
; Raise NNETS to 256
;PSVDEF.MAC;14    27-FEB-81 16:47:29    EDIT BY TAFT
; Add NTDSVF
; Add LIWINT
; Raise NNETS to 128
;PSVDEF.MAC;13    12-SEP-80 13:54:26    EDIT BY TAFT
; Turn off RECPWF
;PSVDEF.MAC;12    29-AUG-80 16:14:06    EDIT BY TAFT
; Add RSTINT
;PSVDEF.MAC;11    15-AUG-80 16:33:56    EDIT BY TAFT
; Add RECPWF
;PSVDEF.MAC;10    15-FEB-80 18:42:31    EDIT BY TAFT
; Raise NNETS to 100
;PSVDEF.MAC;9    28-NOV-79 11:14:29    EDIT BY TAFT
; Give mail server distinct entry point
;PSVDEF.MAC;8     4-NOV-79 12:44:35    EDIT BY TAFT
; Revise MAXHOP
;PSVDEF.MAC;7     2-SEP-79 15:58:31    EDIT BY TAFT
;PSVDEF.MAC;6    24-NOV-78 19:10:23    EDIT BY TAFT
; Increase LOGBFS to 2 pages
;PSVDEF.MAC;5    15-APR-77 09:49:19    EDIT BY TAFT
; Move flag bits to avoid conflict with PUPDEF.MAC
;PSVDEF.MAC;4    31-MAR-77 20:18:43    EDIT BY TAFT
; Add mail server to table
;PSVDEF.MAC;3    18-MAR-77 19:02:06    EDIT BY TAFT
; Raise start of global storage
;PSVDEF.MAC;2    18-MAR-77 17:47:28    EDIT BY TAFT
; Make symbols defined by the local GS, LS, etc. macros be internal
;PSVDEF.MAC;1    10-MAR-77 14:02:43    EDIT BY TAFT
; Split out from PUPDEF.MAC
; This is stuff specific to the server (PUPSRV)

; Copyright 1979 by Xerox Corporation

	UNIVERSAL PSVDEF -- DEFINITIONS SPECIFIC TO PUPSRV
	SUBTTL E. A. Taft / March 1977

	LOC 140		; Labels in Universal must be unrelocatable


; Special accumulator assignments

	PB=7		; Pointer to packet buffer
	CX=14		; Connection table index
	SV=15		; Service table index
	FX=16		; Fork index of executing fork


; Parameters

NFORKS==↑D10		; Max # of inferior forks
NCONNS==↑D100		; Max # of connections maintained
NNETS==↑D256		; Highest net number in routing tables
STKLEN==100		; Length of stack
LOGBFS==↑D1024		; Size of logging buffer

; All time parameters are in seconds
LOGLAT==↑D<5*60>	; Maximum logging latency
STTINT==↑D<12*60*60>	; Statistics logging interval
GCCINT==↑D<30*60>	; Garbage-collect connection table interval
POLINT==↑D30		; Poll interval (for top fork)
WDTINT==↑D<5*60>	; Watchdog timer interval for inferiors
GATINT==↑D30		; Gateway info broadcast interval
RTTINT==↑D90		; Routing table entry timeout interval
DCKINT==↑D<5*60>	; Net dir server check interval
DPRINT==↑D<60*60>	; Net directory probe interval
RSTINT==↑D<10*60>	; Restart check interval
LIWINT==↑D<5*60>	; Lost interrupt watcher interval


; Flag assignments (accumulator F)

LGTTYF==1B9		; Log error on TTY as well as file
CHKTMF==1B10		; Need to check timers immediately
GATEWF==1B11		; This host is a gateway
GATINF==1B12		; Gateway info server initialization done
NTDSVF==1B13		; Network directory server enabled


; Storage assignment parameters
; Must be in the order given and multiples of 1000

IGSLOC==030000		; Start of global storage
IGSPLC==040000		; Start of global page storage
ILSLOC==100000		; Start of local storage
ILSPLC==120000		; Start of local page storage

RECPWF==0		; Enable password-recording hack if nonzero

; Parameters and byte pointers defining the structure of a Packet Buffer (PB)

PBHEAD==0	; Start of Pup Header
 PUPLEN: POINT 16,PBHEAD(PB),15	; Pup Length
 PUPTCB: POINT 8,PBHEAD(PB),23	; Transport Control Byte
 PUPTYP: POINT 8,PBHEAD(PB),31	; Pup Type

; PBHEAD+1
 ; B0-31			; Pup ID

; PBHEAD+2
 PPUPDN: POINT 8,PBHEAD+2(PB),7	; Destination Network
 PPUPDH: POINT 8,PBHEAD+2(PB),15  ; Destination Host
 PPUPD0: POINT 16,PBHEAD+2(PB),31  ; High 16 bits of Destination Socket

; PBHEAD+3
 PPUPD1: POINT 16,PBHEAD+3(PB),15  ; Low 16 bits of Destination Socket
 PPUPSN: POINT 8,PBHEAD+3(PB),23  ; Source Network
 PPUPSH: POINT 8,PBHEAD+3(PB),31  ; Source Host

; PBHEAD+4
 PPUPSS: POINT 32,PBHEAD+4(PB),31  ; Source Socket

PBCONT==PBHEAD+5  ; Start of Pup Contents

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

MAXHOP==17	; Maximum legal hop count


; Pup Type assignments

PT.ECH==1	; Echo Me
PT.IEC==2	; I'm An Echo
PT.BEC==3	; I'm A Bad Echo
PT.ERR==4	; Error
PT.RFC==10	; Request for Connection
PT.ABT==11	; Abort
PT.END==12	; End
PT.ENR==13	; End Reply
PT.DAT==20	; Data
PT.ADA==21	; AData
PT.ACK==22	; Acknowledgment
PT.MRK==23	; Mark
PT.INT==24	; Interrupt
PT.INR==25	; Interrupt Reply
PT.AMA==26	; AMark

; Declaration of all implemented services
; Macro call is:
;	X(name, socket, subroutine)

DEFINE SERVERS <
	X(Telnet,1,TELSRV)	; Telnet server
	X(GateInf,2,GATSRV)	; Gateway info server
	X(FTP,3,FTPSRV)		; FTP server
	X(Misc,4,MSCSRV)	; Miscellaneous services
	X(Echo,5,ECHSRV)	; Echo server
	X(Mail,7,MAISRV)	; Mail server
>

DEFINE X(NAME,SOCKET,ROUTINE) <
	SV.'ROUTINE==NSERVS
	NSERVS==NSERVS+1
>
NSERVS==0
	SERVERS		; Count them
PURGE X


FEVSRV==NSERVS		; Index of first Event Report server
NEVSRV==5		; Max # event report servers suppoerted
NSERVS==NSERVS+NEVSRV	; Accumulate total number of servers

; These storage assignment macros are used only in the
; definition file.  The macros used in other modules are
; defined in PUPDEF.MAC

; Global storage assignment macros
; Assigns storage to be used globally or in top fork only.

; Declare global storage, word-at-a-time

DEFINE GS(LOC,SIZE<1>) <
	LOC=:GSLOC
	GSLOC==GSLOC+SIZE
>

; Declare global storage, page-at-a-time

DEFINE GSP(LOC,SIZE<1>) <
	LOC=:GSPLOC
	GSPLOC==GSPLOC+1000*
>



; Local storage assignment macros
; Assigns storage private to each fork (including the top fork).
; Storage assigned in PSVDEF is treated uniformly in all forks.
; Storage assigned elsewhere may be used only within that fork.

; Declare local storage, word-at-a-time

DEFINE LS(LOC,SIZE<1>) <
	LOC=:LSLOC
	LSLOC==LSLOC+SIZE
>

; Declare local storage, page-at-a-time

DEFINE LSP(LOC,SIZE<1>) <
	LOC=:LSPLOC
	LSPLOC==LSPLOC+1000*
>


; Declare start of storage regions

GSLOC==IGSLOC
GSPLOC==IGSPLC
LSLOC==ILSLOC
LSPLOC==ILSPLC

; Global storage assignments

; Fork tables
GS FRKHND,NFORKS	; Fork handle (0 => slot empty)
GS FRKJFN,NFORKS	; Input JFN ,, Output JFN
GS FRKSRV,NFORKS	; Connection table ,, Service table indices
GS FRKTIM,NFORKS	; Time at which to flush fork

; Connection tables
GS CONLNH,NCONNS	; Local net,,host
GS CONLSK,NCONNS	; Local socket number
GS CONFNH,NCONNS	; Foreign net,,host
			; 0 => slot empty
GS CONFSK,NCONNS	; Foreign socket
GS CONCID,NCONNS	; Connection ID
GS CONFRK,NCONNS	; Tenex connection index ,, fork table index
			; -1 in rh => no fork for connection

; Data base for log maintenance
GS LOGLCK		; Interlock for logging routines
GS LOGLKF		; Fork # of last locker of LOGLCK
GS LOGTIM		; Time of last real append to log file
GS LOGDAY		; Day of week log file last opened
GS LOGBPT		; Byte ptr into LOGBUF
GS LOGBUF,LOGBFS	; Buffer region for logging entries


; Local (per-process) storage assignments, used universally

LS FORKX		; Global fork index of my fork
LS SERVX		; Server table index for current service

LS CH1PC		; PSI return locations
LS CH2PC
LS CH3PC

LS STACK,STKLEN		; Local stack
LSP TEMP,1		; One page for general scratch use


; Initialize variable storage PC's to be used in other modules

GSVAR=:GSLOC		; Storage global to all forks
GSPVAR=:GSPLOC
TOPVAR=:LSLOC		; Storage local to top fork
TOPPVR=:LSPLOC
FTPVAR=:LSLOC		; Storage local to FTP server fork
FTPPVR=:LSPLOC


	PURGE GS,GSP,LS,LSP	; Will be redefined by USEVAR

	RELOC .-140	; Bypass unrelocatable data
	END