Google
 

Trailing-Edge - PDP-10 Archives - BB-FB49A-RM - sources/snailh.mac
There are no other files named snailh.mac in the archive.
	Title	SNAILH	- TOPS-20 SNAIL host initializer
	Subttl	Gerard K. Newman/Dennis Brannon

;+
;
; ----- SNAILH: TOPS-20 SNAIL host initializer
;
;
; Copyright (c) 1984, 1985
; by DIGITAL Equipment Corporation, Maynard, Mass.
;
; This software is furnished under a license and may be used and  copied
; only  in  accordance  with  the  terms  of  such  license and with the
; inclusion of the above copyright notice.  This software or  any  other
; copies  thereof may not be provided or otherwise made available to any
; other person.  No title to and ownership of  the  software  is  hereby
; transferred.
;
; The information in this software is subject to change  without  notice
; and  should  not  be  construed  as  a commitment by DIGITAL Equipment
; Corporation.
;
; DIGITAL assumes no responsibility for the use or  reliability  of  its
; software on equipment which is not supplied by DIGITAL.
;
;
; This  program will declare  itself the SNAIL  host to perform the host
; specific  parts of  the SNA  Gateway intialization. The program uses a
; NICE-like protocol to be as consistent as possible across all systems.
;
; When the SNA Gateway  is first  boostraped,  a program called SNAIL is
; run.  SNAIL connects to the network management layer and asks it for a
; list of all the known nodes. It then connects to this program and asks
; for the  time.  Finally, it connects to FAL and looks up a file in the
; PLUTO directory which contains other initialization parameters such as
; access names and circuit definitinos.
;
; Unlike VMS or RSX, TOPS-20 will not activate a "dormant" DECnet object
; thus requiring that this program be running all the time...
;
;
; MODIFIED BY
;	Dennis Brannon, 3-Oct-84 : VERSION 1.00
;
; 1.01	D. Brannon, 3-Oct-84
;	Misc. cleanup, renamed prog from SNAIL to SNAILH to be consistent
;       with gateway error message.  Removed data returned on the connect
;       confirm message.
;
; 1.02	D. Brannon, 9-Oct-84
;	Added version numbers, and reentry vectors.
;	
; 1.03  D. Brannon, 18-Oct-84
;	Added COPYRIGHT notice that will be displayed when SNAILH.EXE is
;	typed.
;
; 1.04	D. Brannon, 22-Jan-85
;	Modified error message processing to display the last TOPS-20
;	error message encountered.  Add an error message and check for
;	a SNAILH server already running.
;-

	Page
	Subttl	Definitions

	Sall			;Pretty listings

	Search	MONSYM,MACSYM,JOBDAT ;The usual stuff

	Twoseg			;Shareable

SUBTTL	Job version and entry vector

				;Version Information
	VMAJOR==1		;Major Version
	VMINOR==0		;Minor Version
	VEDIT==004		;Edit Number
	VWHO==0 		;Who Last Edited (0=Dec Development)

	VSNA==	BYTE	(3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT ;VERSION


	LOC	137		;Set The Version
.JBVER:	EXP	VSNA
	RELOC	0

 				; Entry Vector Definition
ENTVEC:	JRST    SNAILH		;main entry point
	JRST    SNAILH		;Reenter Entry Point
	EXP     VSNA		;Version of SNAILH Program

	Opdef	PJRST	[JRST]	;Standard
	Opdef	RETURN	[POPJ	P,] ;Also standard

; ACs

T1==		1		;The
T2==		2		; usual
T3==		3		;  flock of
T4==		4		;   temporaries
T5==		5		;An oddball temporary
P1==		6		;A few preserved
P2==		7		; ACs - mainly
P3==		10		;  RDACNS
P4==		11		;    ...
JFN==		12		;Network JFN
FJFN==		13		;File JFN
P==		17		;Call stack

; "NICE-like" symbols

NC.SUC==	1		;NICE success
NC.MOR==	2		;NICE more to come
NC.DON==	-128.		;NICE done
NC.ILF==	-1		;NICE illegal function
NC.IVM==	-2		;NICE invalid message format
NC.FOP==	-13.		;NICE file open error
NC.IOE==	-18.		;NICE I/O error

FMT.AI==	^B01000000	;NICE format AI data
FMT.C1==	^B11000001	;NICE format CM-1 data
FMT.C2==	^B11000010	;NICE format CM-2 data
FMT.D2==	^B00000010	;NICE format DU-2 data

Define	DPB8Z(VALUE),<		;;Deposit 8 bit quanitity zero-filled to 16 bits
	Xlist			;;Boring boring boring
	MOVE	T1,VALUE	;;Grab our value
	IDPB	T1,T2		;;Assumes 8 bit byte-pointer in T2
	IDPB	T3,T2		;;Also assumes null in T3
	List			;;Potentially interesting again
>

	Page
	Subttl	Local data

COPYRT: ASCIZ/

  COPYRIGHT (C) 1984 BY
 Digital Equipment Corporation
     All Rights Reserved

/
MSGBUF:	Block	^D512		;DECnet message buffer

CHNTAB:	1,,HELLO		;Connect interrupts
	1,,DATAVL		;Data available interrupts
	Repeat	^D34,<0>	;Zero fill the rest of the table

LEVTAB:	PC			;Level 1 PC address
	0			;No level 2
	0			;No level 3

PC:	Block	1		;Place to stash PC on level 1 interrupts

YEAR:	Block	1		;Year
MONTH:	Block	1		;Month
DAY:	Block	1		;Day
HOURS:	Block	1		;Hour
MINS:	Block	1		;Minute
SECS:	Block	1		;Second

STACK:	Block	^D20		;Call stack

	Page
	Subttl	Entry point

	Reloc	.JBHGH		;To the high segment

; Start here...
START:
SNAILH:	RESET%			;Clean up our act
	MOVE	P,[Iowd ^D20,STACK] ;Get a stack
	MOVX	T1,.FHSLF	;Find out what
	RPCAP%			; our capabilities are
	MOVE	T3,T2		;Enable all of
	EPCAP%			; our capabilities
	MOVX	T1,GJ%SHT	;Short form GTJFN%
	HRROI	T2,[Asciz /SRV:.SNAILH/] ;We are the snail host
	GTJFN%			;Grab a JFN for the network
	 ERJMP	ERR1		;No good
	MOVE	JFN,T1		;Stash JFN

; Set up the interrupt system

	MOVX	T1,.FHSLF	;Us
	MOVE	T2,[LEVTAB,,CHNTAB] ;Standard interrupt tables
	SIR%			;Specify interrupt tables
	MOVX	T2,3B1		;Enable channels 0 and 1
	AIC%			;Activate channels 0 and 1
	EIR%			;Enable interrupts

; Open the network

	MOVE	T1,JFN		;Copy the network JFN
	MOVX	T2,<FLD(^D8,OF%BSZ)+OF%WR+OF%RD> ;Byte size = 8, R/W access
	OPENF%			;Create a path to the network
	 ERJMP	[CAIN T1,DCNX4	;Catch case of "Invalid task name"
		 JRST ERR9	;Another SNAIL server is already running
		 JRST ERR2]	;Sigh...

; Enable network interrupts

	MOVE	T1,JFN		;Get the network JFN again
	MOVX	T2,.MOACN	;Function code to enable network interrupts
	MOVX	T3,<FLD(0,MO%CDN)+FLD(1,MO%DAV)+FLD(.MONCI,MO%INA)> ;Notify on
	MTOPR%			; connect pending or data available
	 ERJMP	ERR3		;Oh well...

; Zzzzz

	WAIT%			;Hang around forever

	Page
	Subttl	HELLO	- Connect interrupt processing

;+
;
; ----- HELLO:  Connect interrupt processing
;
;
; This routine will be  executed when there is a connect pending
; from a  remote process.  This is, hopefully, a  copy of  SNAIL
; running  on a DX-24 (an SNA  Gateway).  The gateway sends some
; optional data with it's connect request, which amounts to some
; 3 bytes of  version information.  As far  as I can tell, SNAIL
; doesn't care if we send anything back or not.
;
; Inputs:
;
;	Optional data from the SNA gateway, 3 8-bit bytes,
;	containing 3,0,0 or better.
;
; Outputs:
;
;	Connection accepted if this matches, rejected otherwise.
;
;
;-

; Read the optional data

HELLO:	MOVE	T1,JFN		;Get the network JFN
	MOVX	T2,.MORDA	;Function code to read optional data
	MOVE	T3,[Point 8,MSGBUF] ;Load a byte pointer
	MTOPR%			;Read the optional data
	 ERJMP	ERR4		;?
	JUMPE	T4,REJECT	;Any data ?
	MOVE	T4,[Point 8,MSGBUF] ;Create a byte pointer
	ILDB	T4,T4		;Get the first byte of the message
	CAIGE	T4,3		;At least version 3 ?
	 JRST	REJECT		;No, reject the connection

; Accept the logical link connection

	MOVX	T2,.MOCC	;Function code for connect confirm
	SETZM	T4		;No user data
	 JRST	HEL.1		;Join common code

; Reject the logical link connection

REJECT:	MOVX	T2,.MOCLZ	;Say abort the link
	HRLI	T2,.DCX35	;Say logical link services incompatable
	SETZM	T4		;No user data

; Common code to accept or reject the link

HEL.1:	MTOPR%			;Accept or reject the link
	 ERJMP	ERR5		;? DECnet dissappeared
	DEBRK%			;Dismiss the interrupt

	Page
	Subttl	DATAVL	- Data available interrupt

;+
;
; ----- DATAVL:  Data available interrupt
;
;
; This routine is entered  whenever the software interrupt
; system  signals that  there  is data  avaiable  from the
; network.  We read all of the messages waiting for us and
; dispatch to the appropriate routine to process requests.
;
;
; Inputs:
;
;	None.
;
; Outputs:
;
;	Messages dequeued from the logical link and
;	specified function performed.
;
;
;-

DATAVL:	MOVE	T1,JFN		;Grab the network JFN
	SIBE%			;Anything there ?
	 JRST	[PUSHJ	P,DOWORK ;Yes, go process work
		 JRST	DATAVL]	;And look for more
	MOVX	T2,.MORLS	;Get the link status
	MTOPR%			; to see if it's still connected
	 ERJMP	ERR8		;?
	TXNN	T3,MO%CON	;Link still with us ?
	 PUSHJ	P,DISCON	;No, disconnect it
	DEBRK%			;Dismiss the interrupt

	Page
	Subttl	DISCON	- Disconnect the logical link

;+
;
; ----- DISCON:  Disconnect the logical link
;
;
; This routine will disconnect the logical link and
; restart the program. There is no return from this
; routine.
;
; Inputs:
;
;	JFN	- Network JFN
;
; Outputs:
;
;	Link disconnected and program restarted.
;
;-

DISCON:	MOVE	T1,JFN		;Grab the network JFN
	CLOSF%			;Close the link
	 ERJMP	[MOVE	T1,JFN	;Well, try it
		 TXO	T1,CZ%ABT ;this way
		 CLOSF%		;	...
		  CAI		;Sigh
		 JRST	.+1]	;Back in line
	JRST	START		;Restart

	Page
	Subttl	DOWORK	- Perform the requested function

;+
;
; ------ DOWORK:  Perform the requested function
;
;
; This routine will retrieve the data form the SNA Gateway
; and  perform the  specified  function.  At  present, the
; following functions are defined:
;
;	Get system time
;
; An illegal  function code  will be  returned to SNAIL if
; none of these functions are seen.
;
; Inputs:
;
;	Call from DATAVL at interrupt level
;	T1	- Network JFN
;
; Outputs:
;
;	Messages dequeued and processed.
;
; Temporaries clobbered.
;
;-

DOWORK:	MOVE	T2,[Point 8,MSGBUF] ;Point to our message buffer
	MOVNI	T3,^D512	;Set the size of the buffer
	SINR%			;Get the data
	 ERJMP	ERR6		;Sigh

; Legal function ?

	CAIN	T3,5		;Proper length ?
	 JRST	DOW.1		;No, return error
	SETZM	T1		;Get a null
	DPB	T1,T2		;Crump on the last byte in the message
	MOVE	T1,MSGBUF	;Grab the first 4.5 bytes in the message
	CAMN	T1,[Byte(8) ^D22,^D127,^D20,1] ;Read time function ?
	 JRST	RDTIME		;Yes, go do that

; Here on unrecognized function

DOW.1:	MOVE	T2,[Point 8,[Byte(8) NC.ILF,-1,-1,0]] ;Say illegal function
	MOVNI	T3,4		;String length is 4
;;	PJRST	SNDRSP		;Fall into SNDRSP

	Page
	Subttl	SNDRSP	- Send a response message

;+
;
; ----- SNDRSP:  Send a response message
;
;
; This routine will send a response message over the network.
;
; Inputs:
;
;	T2	- Byte pointer of message to send
;	T3	- Length of message to send (negative)
;
; Outputs:
;
;	Message sent
;
;-

SNDRSP:	MOVE	T1,JFN		;Get the network JFN
	SOUTR%			;Send the record
	 ERJMP	ERR7		;?
	POPJ	P,		;Return to caller

	Page
	Subttl	RDTIME	- Return the host system's time

;+
;
; ----- RDTIME:	 Return the host system's time
;
;
; This routine will return the host system's time as a string
; of 14 8-bit bytes.
;
; Inputs:
;
;	Host system time
;
; Outputs:
;
;	As described above.
;
;-

RDTIME:				;Ref. label

; Convert TOPS-20 date & time to RSX-11 date & time...

	SETOM	T2		;Current date
	SETZM	T4		;No bits
	ODCNV%			;Get date & time
	HLRZM	T2,YEAR		;Stash year
	HRRZM	T2,MONTH	;Stash month
	HLRZM	T3,DAY		;Stash day
	AOS	DAY		;Make the first of the month start at 1
	MOVE	T1,YEAR		;Get year
	SUBI	T1,^D1900	;Unbias it
	MOVEM	T1,YEAR		;Stash year again
	AOS	MONTH		;Make january = 1
	HRRZS	T4		;Get time in seconds since midnight
	IDIVI	T4,^D3600	;Get hours
	MOVEM	T4,HOURS	;Stash hours
	MOVE	T4,T5		;Get remainder
	IDIVI	T4,^D60		;Get minutes and seconds
	MOVEM	T4,MINS		;Stash minutes
	MOVEM	T5,SECS		;Stash seconds

; Load time into 8-bit bytes (build message header first)

	MOVE	T2,[Point 8,MSGBUF] ;Get a byte pointer
	PUSH	P,T2		;Save a copy of it for later
	SETZ	T3,		;Get a null as it will be handy
	MOVEI	T1,NC.SUC	;Get the first 8-bit byte
	IDPB	T1,T2		;Stash the first part of the message
	IDPB	T3,T2		;The next
	IDPB	T3,T2		;  3 bytes
	IDPB	T3,T2		;   are zero
	DPB8Z	YEAR		;Stash the year
	DPB8Z	MONTH		;    ...   month
	DPB8Z	DAY		;    ...   day
	DPB8Z	HOURS		;    ...   hours
	DPB8Z	MINS		;    ...   minutes
	DPB8Z	SECS		;    ...   seconds
	DPB8Z	T3		;Use zero for ticks

; Pack it off to the SNA Gateway and go home

	MOVNI	T3,^D18		;Total length of the response
	POP	P,T2		;Retrieve stashed byte pointer
	PJRST	SNDRSP		;Send the respone & return

	Page
	Subttl	Error routines

ERR1:	HRROI	T1,[Asciz /Can't get a network JFN/]
	JRST	ERRCOM		;Join common code

ERR2:	HRROI	T1,[Asciz /Can't open the network/]
	JRST	ERRCOM		;Join common code

ERR3:	HRROI	T1,[Asciz /Can't enable network interrupts/]
	JRST	ERRCOM		;Join common code

ERR4:	HRROI	T1,[Asciz /Can't read optional data for connect/]
	JRST	ERRCOM		;Join common code

ERR5:	HRROI	T1,[Asciz "Can't accept/reject an incoming connect"]
	JRST	ERRCOM		;Join common code

ERR6:	HRROI	T1,[Asciz /Can't receive data/]
	JRST	ERRCOM		;Join common code

ERR7:	HRROI	T1,[Asciz /Can't send data/]
	JRST	ERRCOM		;Join common code

ERR8:	HRROI	T1,[Asciz /Can't get the link status/]
	JRST	ERRCOM		;Join common code

ERR9:	HRROI	T1,[Asciz /Another SNAILH server is already running/]
	JRST	ERRCOM		;Join common code

ERRCOM:	PUSH	P,T1		;Save message pointer
	TMSG	<
? Error:  >			;Type prefix
	POP	P,T1		;Retrieve message pointer
	PSOUT%			;Output text
	TMSG	<.
>				;End up the message
				;Display the error message
	TMSG	<
Last error in this process:
> 				;End up the message
	MOVE	T2,[.FHSLF,,-1]	;Us,,most recent error
	MOVX	T1,.PRIOU	;Destination = TTY
	SETZ	T3,		;No limit on length
	ERSTR%			;Display our most recent error
	 CAI			;NOP
	  CAI			; errors
	HALTF%			;Exit
	 JRST	START		;Restart

	End	<3,,ENTVEC>