Google
 

Trailing-Edge - PDP-10 Archives - BB-W661B-BM_1984 - tools/svcrcv.mac
There is 1 other file named svcrcv.mac in the archive. Click here to see a list.
	SALL
	TITLE	SVCRCV	Communication Slave Program
	SEARCH	MONSYM,MACSYM,X25SYM

; Copyright (c) 1982, 1983 by
; DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts 01754
;
; 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.

; Accumulators

S1=1					;Scratch ACs
S2=2
S3=3
S4=4
T1=5					;Temporary ACs
T2=6
SP=17

; Push Down Stack

SIZE=^D256
STACK:	BLOCK	SIZE

; X.25 Access Argument Blocks

WSPSIZ=<^D128/4>+.PBSIZ
WSPACE:	BLOCK	WSPSIZ			;Working area for the X.25 library
ARGBLK:	BLOCK	^D10			;Argument block
BUFFER:	BLOCK	^D32			;Incoming data buffer
STATE:	BLOCK	1			;Port state

; Interrupt System Storage Definitions

CH.X25=0				;Interrupt channel number
SAVEPC:	BLOCK	1			;Location for saved PC
LEVTAB:	SAVEPC				;Interrupt level table
	REPEAT	2,<0>
CHNTAB:	1,,SRVCKT			;Interrupt handler entry
	REPEAT	^D35,<0>		;Unused channels have 0

START:	RESET				;Reset the world
	MOVE	SP,[IOWD SIZE,STACK]	;Set up push down stack
	MOVEI	S1,.FHSLF		;Current process
	MOVE	S2,[LEVTAB,,CHNTAB]	;Interrupt table
	SIR
	EIR				;Enable system
	MOVE	S2,[1B<CH.X25>]		;Activate channel
	AIC
	MOVEI	T1,XS%UND
	MOVEM	T1,STATE		;Set port state to UNDEFINED
	SETZM	ARGBLK			;Initialize the argument block
	MOVE	T1,[ARGBLK,,ARGBLK+1]
	BLT	T1,ARGBLK+^D9
	MOVE	T1,[CH.X25,,WSPACE]
	MOVEM	T1,ARGBLK		;Interrupt channel and work area
	MOVE	T1,[POINT 7,[ASCIZ/SRV:.EXAMPLE/]]
	MOVEM	T1,ARGBLK+2		;SRV: file descriptor
	MOVEI	S1,ARGBLK		;Pass access argument block
	CALL	X%WIC##			;Wait Incoming Call
	MOVE	T1,ARGBLK+1		;Get return code
	CAIE	T1,XC%SUC		;Is it successful ?
	HALTF				;No, terminate
	MOVEI	T1,XS%LSN		;Yes,
	MOVEM	T1,STATE		;Change port state to LISTENING
	WAIT				;Dismiss the process

SRVCKT:	SETZM	ARGBLK+1		;Initialize argument block entries
	MOVE	T1,[ARGBLK+1,,ARGBLK+2]
	BLT	T1,ARGBLK+^D9
	MOVEI	S1,ARGBLK		;Pass access argument block
	CALL	X%RPS##			;Check current port status
	MOVE	T1,ARGBLK+1		;Get return code
	CAIE	T1,XC%SUC		;Is it successful ?
	 JRST	X25TPA			;No, terminate
	MOVE	T1,STATE		;Get old port state
	HRRZ	T2,ARGBLK+2		;Get new port state
	CAIN	T1,XS%LSN		;From LISTENING state
	 JRST	[CAIN	T2,XS%LSN	;Remain in LISTENING state
		  JRST	SRVCKT		;Check the port state again
		 CAIN	T2,XS%CAD	;Changed to CALLED state
		  JRST	X25AIC		;Accept incoming call
		 JRST	X25TPA]		;Otherwise, terminate
	CAIN	T1,XS%RUN		;From RUNNING state
	 JRST	[CAIE	T2,XS%RUN	;Changed to any other states
		  JRST	X25TPA		;Terminate
		 MOVE	T1,ARGBLK+3	;Get the port status word
		 TXNE	T1,XM%DAT	;Check incoming data indicator
		  JRST	X25RDM		;Yes, there is a data packet to be read
		 DEBRK]			;No, done servicing interrupt
	JRST	X25TPA			;Don't want to handle other states

X25AIC:	SETZM	ARGBLK+1		;Initialize argument block entries
	MOVE	T1,[ARGBLK+1,,ARGBLK+2]
	BLT	T1,ARGBLK+^D9
	MOVEI	S1,ARGBLK		;Accept incoming call unconditionally
	CALL	X%AIC##
	MOVE	T1,ARGBLK+1		;Get return code
	CAIE	T1,XC%SUC		;Is it successful ?
	 JRST	X25TPA			;No, terminate
	MOVEI	T1,XS%RUN		;Yes,
	MOVEM	T1,STATE		;Change port state to RUNNING
	DEBRK				;Done servicing interrupt

X25RDM:	SETZM	ARGBLK+1		;Initialize argument block entries
	MOVE	T1,[ARGBLK+1,,ARGBLK+2]
	BLT	T1,ARGBLK+^D9
	MOVEI	T1,^D128
	MOVEM	T1,ARGBLK+2		;Maximum packet size
	HRROI	T2,BUFFER
	MOVEM	T2,ARGBLK+3		;Destination buffer
	MOVEI	S1,ARGBLK
	CALL	X%RDM##			;Read one packet
	MOVE	T1,ARGBLK+1		;Get return code
	CAIE	T1,XC%SUC		;Is it successful ?
	 JRST	[TXNE	T1,XC%NDA	;No, is it No Data Available error ?
		 DEBRK			;Yes, dismiss interrupt
		 JRST	X25TPA]		;No, it is fatal error
	MOVEI	S1,.PRIOU		;Destination pointer
	MOVE	S2,T2			;Pointer to data buffer
	HRRZ	T1,ARGBLK+2		;Get length of the buffer
	MOVN	S3,T1
	SETZ	S4
	SOUT				;Write the text to terminal
	JRST	X25RDM			;Read the next packet

X25TPA:	MOVEI	S1,ARGBLK		;Terminate port access
	CALL	X%TPA##
	HALTF				;Stop program
	END	START			;End Of Program
; Local Modes:
; Mode:MACRO
; Auto Save Mode:2
; Comment Column:40
; Comment Rounding:+1
; End: