perm filename RSXRUT.MAC[EAL,HE] blob
sn#676503 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT ā VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 .TITLE RSXRUT - Root portion of the RSX message-passing routines.
C00006 00003 Misc routine for time-based interruptions
C00008 ENDMK
Cā;
.TITLE RSXRUT - Root portion of the RSX message-passing routines.
;Some stuff for message AST's
.MCALL ASTX$S,SRDA$S,SDAT$,RCVD$,DIR$,DRERR$
.MCALL MRKT$S,ASTX$S,SETF$S,DECL$S,RQST$S
DRERR$
MBUF: .BLKW 15. ;Message buffer.
MFLAG: .WORD 0 ;Address of message flag
SND: SDAT$ ARM,MBUF+4 ;Send data to ARM task.
RCV: RCVD$ ARM,MBUF ;Get data from ARM task. 2 words are for header
ARM: .RAD50 /ARM / ;Name of ARM task (for startArm)
RCVAST: INCB @MFLAG ;AST to detect incoming messages - bump counter
ASTX$S ; so interpreter knows to check for messages
;procedure initMsg(var buf: integer; var flag: boolean);
PROC INITMSG
PARAM BUF,ADDRESS
PARAM FLAG,ADDRESS
BEGIN
MOV #MBUF+4,@BUF(SP) ;Pass pointer to message buffer
MOV FLAG(SP),MFLAG ;Remember address of "message-rec'd" flag
SRDA$S #RCVAST ;So we get an AST when sent a message
ENDPR
;procedure sndmsg (var res,err: integer);
PROC SNDMSG
PARAM RES,ADDRESS
PARAM ERR,ADDRESS
BEGIN
MOV #1,@RES(SP) ;Assume successful transmission
CLR @ERR(SP)
DIR$ #SND ;Send data to arm code
BCC 20$ ;Success? Skip if yes
CLR @RES(SP) ;No - clear success flag
INC @ERR(SP) ;Assume ARM not installed
CMP $DSW,#IE.UPN ;Insufficient memory?
BNE 20$
INC @ERR(SP) ;Indicate RSX out of memory
; *** Code to wait til some memory gets freed up? ***
20$:
ENDPR
;procedure rcvmsg (var res,err: integer);
PROC RCVMSG
PARAM RES,ADDRESS
PARAM ERR,ADDRESS
BEGIN
CLR @ERR(SP) ;Clear error indicator
CLR @RES(SP) ;Assume no message was received
DIR$ #RCV ;Receive data from ARM task
CMP #IE.ITS,$DSW ;DSW = `IE.ITS' if no data waiting for me
BEQ 50$ ;No msg: exit with result false.
CMP #IS.SUC,$DSW ;DSW = `IS.SUC' if we got a message
BNE 20$ ;otherwise assume error and store error flag
INC @RES(SP) ;Set to 1 to mean we got a message.
BR 50$
20$: MOV $DSW,@ERR(SP) ;Some error - set error flag.
50$:
ENDPR
;function doRqst: boolean;
FUNC DORQST,ERR,INTEGER
BEGIN
CLR ERR(SP)
RQST$S #ARM ;This requests ARM to be run
BCC 20$ ;Branch & exit if no error
CMP $DSW,#IE.ACT
BEQ 20$ ;Not an error if it's already active
MOV $DSW,ERR(SP) ;Store error code
20$: ENDPR
;procedure signalArm;
PROC SIGNALARM
BEGIN
SETF$S #39. ;Set common flag for ARM background job
DECL$S ;Declare a significant event so it gets scheduled
ENDPR
; Misc routine for time-based interruptions
;AST for mark time requests
WAKEUP: TST (SP)+ ;Get rid of event flag number
INC @STADDR ;Bump counter so interpreter knows to reschedule
ASTX$S
;Procedure markTime(when: integer; var curTime,stime: integer); external;
PROC MARKTIME
PARAM WHEN,INTEGER
PARAM CURTIME,ADDRESS
PARAM STIME,ADDRESS
SAVE R0
BEGIN
ADD WHEN(SP),@CURTIME(SP) ;Remember when it's scheduled for
MOV WHEN(SP),R0 ;R0 gets time to wait (in ticks)
MOV STIME(SP),STADDR ;Store address of STIME given to us
MRKT$S ,R0,#1,#WAKEUP ;Issue the Mark Time request
ENDPR
STADDR: .WORD 0 ;Address of STIME (global variable)
.END