TITLE GLXIPC -- IPCF INTERFACE FOR GALAXY PROGRAMS
SUBTTL Cliff Romash & Irwin L. Goverman/CER/PJT/DC/MLB/RCB 25-Aug-84
;
;
; COPYRIGHT (c) 1975,1976,1977,1978,1979,1980,1981,1982,
; 1983,1984,1985,1986,1987
; DIGITAL EQUIPMENT CORPORATION
; ALL RIGHTS RESERVED.
;
; 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.
SEARCH GLXMAC ;SEARCH SUBSYSTEMS SYMBOLS
PROLOG(GLXIPC,IPC) ;PRODUCE PROLOG CODE
;THE PURPOSE OF THIS MODULE IS TO PROVIDE AN OPERATING SYSTEM INDEPENDENT
; IPCF INTERFACE TO GALAXY PROGRAMS (OR ANY OTHER PROGRAM WHICH
; WANTS TO USE IT).
;ALL SUBROUTINES IN THIS MODULE USE ACS S1 AND S2 (1 AND 2) AND GUARANTEE
; THAT ALL OTHER ACS WILL BE PRESERVED.
IPCEDT==77 ;VERSION NUMBER

SUBTTL Revision History
COMMENT \
Edit GCO Reason
---- ------- -------------------------------------------------------
0001 Initial version of GLXIPC
0002 Make sending to PID 0 illegal
0003 Convert to new OTS format
0004 Add better send failure recovery code
Also, receive packets .GT. short packet size if they come
0005 G012 Change the definition of the 'capabilties' word in the MDB
to contain a canonical set of capabilities rather than the
operating-system specific capabilities. It also contains
the senders job number.
0006 G016 On the -10, don't try to determine the length of the System
PID table before doing the GETTABs. Just do SZ.PID GETTABs.
0007 Change the debugging system so that 'alternates' are used
only if DEBUGW is set.
0010 G025 Change the DEBUGW so that a non-zero value enables
the DEBUGGING System while a negative value will
declare a private component to SYSTEM[INFO].
Also fix C%RECV so that MD%PWH is only turned on with
JACCT on the -10.
0011 G026 FIX RSEFLG ACTION TO RETURN ON ERRORS AND LOOP THE
PROPER NUMBER OF TIMES IF NOT SET
0012 G027 MAKE C%RECV USE THE ASSOCIATED VARIABLE NAD DO PAGE
CHECK FIRST
0013 G052 Fix C%RECV to Destroy non-existent page if failed on
page mode due to wrong mode
0014 Remove DEBUGW test to set quotas and job wide pid
Also -- convert some$STOP messages to $FATAL and
some $TEXT to $WARN
0015 Made extensive changes to Debugging code and initializtion
code. Added error code ERICA$ to use in range checks.
Modified RSPIDS to do alternate search based on DEBUGW
and a special name table.
Modified C%SEND to clear the internal pid table entry
if a send to a system pid fails.
0016 Fixed TOPS20 code in KILPID and SNDSYS to work properly
0017 Fixed SNDSYS to save SNDFLG
0020 Cosmetic cleanup. Changed ERICA$ to ERARG$ for
errors which are caused by bad calling args.
Corrected spelling.
Added "PULSAR" name for SP.TLP
0021 Use SPIDS macro to make up SPDNAM
0022 Change C%INIT to setup debugging names based on SPIDS,
Not on contents of the IB
The degugging flag DEBUGW (135) now has 2, not 3 meanings
0== off, -1 == on. If it is ON, and the IB says to become
a system PID, then C%INIT uses the name in the SPIDS table
to declare [p,pn]NAME to system info
0023 Install PIB and multiple PID support
0024 Print Becomming PID message only if Debugging. Make getting
of maximum packet size a Library entry Point (C%MAXP)
0025 Make getting maximum packet size a part of C%INIT
even if no PIB is specified in IB
0026 Preserve RCVMDB+MDB.MS durring SNDSYS so C%REL will
always work after sending to a system component in
in DEBUG mode
0027 Make C%PIDJ entry to return Pid's job number
0030 Make C%KPID work for -10. Kill named PIDs via INFO only,
and unnamed PIDs via IPCC, then INFO if that fails.
0031 Fix setting of Maximum number of Pids to first
Read the number then increment and write it out
0032 Change SAVE to $SAVE
0033 Fix Maximum PID setting Bug
0034 Make MAXPAK a global variable
0035 Return ARG if sending a 0 length message
0036 Return ARG if attempting to SNDMSG with a 0 PID
0037 TOPS10 - Set job # as PID when conversing with
INFO or IPCC to get a PID.
0040 Write system PID table after setting MYPID
0041 Fix a bug in wait logic if debugging and the component
does not yet exist.
0042 -10, Set Job number as PID
while asking INFO for PIDs of debugging
system components
0043 CHANGE THE SEND QUOTA SETTINGS TO READ THE CURRENT
SETTING AND THEN ADD TO IT
0044 Add support for sending to any arbitrary process
by name.
Never send pages to the system gopher, send them
as large (510 wd max) packets.
0045 Just a recompile to pick up new value for SZ.PAK
0046 Return the located node if requested in PIB block for
TOPS10.
0047 Zero out out own $DATA space and comment out instructions
that used to zero out particular locations.
0050 If no IPCF privs and SYSINF not running then $FATAL error
0051 Set OPR priv in C%RECV if message received from a special
pid while debugging.
0052 Add support for using job numbers as PIDs.
0053 Fix a problem with SNDSYS flushing the IPCF queue looking
for the response from [SYSTEM]IPCC.
0054 Only type out "% GLXIPC alternate..." when debugging.
0055 Prevent IFN, BPN, and ILM stopcodes. Routine STAC IDPBs 1
byte too far.
0056 Fix bug in SNDSYS which caused MDA's pid to not be defined.
0057 FIX IPRM.1 TO DO THE CORRECT THING FOR BOTH TOPS10
AND TOPS20.
0060 3/7/81 Change reference to .JBOPS to the general symbol DEBUGW
0061 9/14/81 Fix FNDNAM bug and make sure we always return the PID in S1
0062 12/15/81 Handle error return from M%IPRM.
0063 1372 Prevent unprived user from becoming godly by clearing junk in
AC before setting up priv bits in MDB.PV
0064 G1394 Insure all messages get received by setting MSGFLG early.
0065 8-Feb-84 /DPM
Increased monitor free core usage could be attributed to
the fact that GLXIPC always sends 510 word packets to the
GOPHER. Make it send exact length packets instead.
0066 10055 26-Mar-84 /DPM
Add support for flag word in the SAB and return useful
priv bits.
0067 10079 14-Aug-84 /RCB
Include new IPCFM. code for efficient use under 7.03.
0070 10084 28-Aug-84 /RCB
Include fallback code for 7.02, and finish the IPCFM. code
for talking to [SYSTEM]INFO.
0071 10095 11-Sep-84 /RCB
Fix the fallback code.
0072 10261 23-Jul-85 /RCB
Fix more fallback code (GETTAB of .GTPID).
0073 10267 30-Jul-85 /RCB
More of above (%IPCPM).
0074 10307 22-Oct-85 /RCB
Fix some FTFLBK problems.
0076 10462 14-Nov-86 /BAH
Change $STOP to STOPCD.
0077 10557 21-Aug-87 /LWS
Remove FTFLBK conditionals.
\ ;END OF REVISION HISTORY

SUBTTL SYSPID - Helper for C%CPID to set up to acquire a system PID
;Call with no obvious args
;
;Return set up for CPID.7
SYSPID: SKIPN DEBUGW ;Are we debugging?
JRST SYSP.1 ;No, never bother INFO in production
PUSHJ P,CHKNAM ;Set up the name pointer
$RETIT ;All set, caller has special debug name
;Otherwise, set up library convention
LOAD S2,PB.INT(P2),IP.SPI ;Get back special index
SKIPN S1,SPDNAM(S2) ;Get debugging name from table
$FATAL (No debugging name for special index ^O/S2/) ;None there
MOVEI S2,NAMTXT ;Aim at ITEXT to convert debug name
$RETT ;Go setup the name, get the PID
SYSP.1: SETZ S2, ;ASSUME NO NAME DESIRED
$RETT ;RETURN TO SET UP FOR NULL PID

SUBTTL C%REL - Release the last message received
; C%REL is used to release the last message received via C%RECV or C%BRCV.
;If this message is a packet, then this is a null operation, and if its
;a page, the page is released.
;CALL IS: No arguments
;
;TRUE RETURN: Always
C%REL: SKIPN S2,RCVMDB+MDB.MS ;GET SIZE AND ADDRESS OF MESSAGE
STOPCD (RAR,HALT,,<Releasing already released IPCF message>) ;ALREADY RELEASED
SETZM RCVMDB+MDB.MS ;MARK MESSAGE AS RELEASED
LOAD S1,S2,MD.CNT ;GET SIZE OF MESSAGE
CAXE S1,PAGSIZ ;IS THIS MESSAGE A PAGE?
$RETT ;NO, SO RETURN NOW
LOAD S1,S2,MD.ADR ;GET ADDRESS OF MESSAGE
ADR2PG S1 ;GET THE PAGE NUMBER
PJRST M%RELP ;RETURN AFTER RELEASING THE PAGE
SUBTTL C%RPRM Routine to read IPCF Parameters
;C%RPRM IS USED TO EXAMINE THE MOST COMMONLY NEEDED
;IPCF PARAMETERS. THESE INCLUDE THE TOTAL NUMBER OF PIDS AND THE
;IPCF RECEPTION / SEND QUOTAS.
;CALL IS: S1/ -1 TO READ PARAMETERS OF PID QUOTA, SND,RCV QUOTAS
; OR ELSE AN SP.??? SYMBOL TO RETURN THAT ENTRY FROM
; THE PID TABLE
;
;TRUE RETURN: IF THE INFORMATION IS AVAILABLE
; S1/<MAX PIDS>B17+<SND QUOTA>B26+<RCV QUOTA>B35 ;IF S1=-1
; S1/ PID TABLE ENTRY ; IF S1=0 OR +
C%RPRM: JUMPGE S1,RSPID ;IF NON-ZERO, WANT SYSTEM PID
SETZ S1, ;SET TO READ IPCF PARAMETERS
PJRST IPRM ;GO READ PARAMS AND RETURN

SUBTTL KILPID Routine to delete a pid
;KILL PID IS CALLED DURING INITIALIZATION TO RETURN ANY PID ACQUIRED
;THAT WE NO LONGER NEED.
;Tops10 Alternate entry at KILPDN, to kill a PID via INFO, since
; the PID to be killed is known to be named
;CALL S1/ Pid to be killed
;TRUE RETURN: Pid has been killed
;FALSE RETURN: Pid wasn't killed
KILPID: MOVEM S1,MTLBLK+.IPCI1 ;SAVE PID TO BE KILLED
MOVE S1,[2,,.IPCSZ] ;CODE,,DELETE PID FUNCTION
PUSHJ P,SNDIPC ;ASK IPCC TO DO IT
$RETIT ;RETURN IF ALL SET
MOVE S1,MTLBLK+.IPCI1 ;Get back PID which should have gone
KILPDN: MOVEM S1,MTLBLK+.IPCI2 ;Save PID in message to INFO
SETZM STACL ;'NAME' FIT JUST FINE, THANK YOU
MOVE S1,[KILPID,,.IPCID] ;IPCC won't listen, probably no privs
PJRST SNDINF ;TRY INFO, PROPAGATE RETURN

SUBTTL SPID - Set a system PID
;SPID sets a system wide pid in the internal pid table and in the
;monitor pid table if not debugging.
;CALL IS: S1/ Index into the system pid table
; S2/ Pid to store in system Pid Table
;
;TRUE RETURN: Pid stored in internal and system pid table
; (if Debugging -- pid is stored in internal table only)
SPID: CAIL S1,1 ;MUST BE 1 THRU SZ.PID
CAXL S1,SZ.PID ;INDEX IN RANGE?
STOPCD (PIR,HALT,,<PID Index out of range>)
CAMN S2,PIDTAB(S1) ;IS REQUESTED INDEX ALREADY SET?
$RETT ;YES, NO NEED TO SET IT AGAIN
MOVEM S2,PIDTAB(S1) ;STORE MYPID IN INTERNAL TABLE
SKIPE DEBUGW ;DEBUGGING?
$RETT ;YES -- DON'T TELL THE MONITOR
MOVEM S1,MTLBLK+.IPCS1 ;STORE FIRST WORD, THE INDEX
MOVEM S2,MTLBLK+.IPCS2 ;STORE PID TO SET
MOVE S1,[XWD 3,.IPCWP] ;FUNCTION IS SET SYSTEM PID
PUSHJ P,SNDIPC ;ASK IPCC TO DO IT
$RETIT ;RETURN ALL OK IF WE ARE IN GOOD SHAPE
$FATAL <Can't write System PID table>

SUBTTL RSPIDS Routine to read System Pid tables
;RSPIDS is called from initialization to set up our internal System
;pid table. It requests all system pids from the monitor or from
;INFO if the pid has a name. If a Pid exists, it's entry in PIDTAB
;will be non-zero.
;RSPIDS is usually called only during intialization. It gets a PID for us,
;reads all the PIDS, then destroys the PID
;For hacking around, the ALTNAM table can be twiddled, and
;a debugger can do PUSHJ P,RSPIDS to set up some different PIDs
;CALL No Arguments
;TRUE RETURN PIDTAB Contains all valid system pids
RSPIDS: $SAVE <P1> ;PRESERVE P1
MOVE S1,[XWD PIDTAB,PIDTAB+1] ;Make BLT pointer
SETZM PIDTAB ;To clear all the PIDs
BLT S1,PIDTAB+MX.PID ;Clear it
PJOB S1, ;-10, just use job # as PID
PUSH P,MYPID ;Save whatever is there now
MOVEM S1,MYPID ;Save as ours, for now
MOVSI P1,-SZ.PID ;DO ALL ENTRIES
RSPD.1: HRRZ S1,P1 ;LOAD THE INDEX
PUSHJ P,RSPID ;GET THE PID
JUMPF [CAIE S1,ERARG$ ;INVALID INDEX?
TDZA S1,S1 ;NO -- MUST BE NO SUCH PID
SETO S1, ;YES -- MARK INVALID ENTRY
JRST .+1] ;RETURN IN LINE
MOVEM S1,PIDTAB(P1) ;STORE THE ENTRY
RSPD.2: AOBJN P1,RSPD.1 ;LOOP THRU ALL ENTRIES
POP P,MYPID ;Put back the old one
$RETT ;AND RETURN

SUBTTL RSPID Routine to return a system pid
;RSPID is called to return system PID when sending by special index.
;If the Pid is not found in our internal table, we request the Pid
;from the monitor (or from INFO if we are debugging and the System
;index has a name.)
;The PID is obtained from the system table unless
; 1) - the DEBUGW is set
; and ALTNAM(index) contains an address of a string
;or
; 2) - the DEBUGW is set
; and ALTNAM(index) = 0 (no fooling around), and SPDNAM has a SIXBIT
; library convention debug name.
;Under normal debug, ALTNAM is 0.
;To fool around, put a -1 in an entry to talk to system component, or
; put the address of a string which is the name of the PID you want to talk to.
;CALL IS: S1/ Index into System PID table
;
;TRUE RETURN: S1/ PID for that index
;FALSE RETURN: ERARG$ Invalid index
; ERNSP$ No Such Pid
; ERPWA$ PID went away
RSPID: MOVE S2,S1 ;GET THE INDEX
SKIPN DEBUGW ;Are we debugging?
JRST RSPI.1 ;No, never use names
RSPI.0: CAIL S2,0 ;INDEX VALID?
CAIL S2,SZ.PID
$RETE(ARG) ;NO -- FAIL
SKIPE S1,PIDTAB(S2) ;DO WE KNOW THIS PID?
$RETT ;YES, RETURN IT
SKIPGE S1,ALTNAM(S2) ;Force use of system for this component?
JRST RSPI.1 ;Yes, go thru system table
JUMPN S1,RSPI.3 ;If an addr was in there, use that name
SKIPE S1,SPDNAM(S2) ;0 in ALTNAM, is there a library entry?
JRST RSPI.3 ;Yes, use library convention
;Here to get PID from system table
RSPI.1: MOVEI S1,.GTSID ;NO -- ASK THE MONITOR
HRL S1,S2 ;LOAD THE INDEX
GETTAB S1, ;GET THE ENTRY
JRST RSPI.8 ;INVALID INDEX
JUMPE S1,RSPI.2 ;IS IT THERE?
SKIPL S2 ;RANGE CHECK
CAILE S2,MX.PID ;AGAINST OUR TABLE
$RETT ;DON'T STORE OUTSIDE OF TABLE
MOVEM S1,PIDTAB(S2) ;YES, REMEMBER THAT IT EXISTED ONCE
$RETT ;RETURN GOODNESS
;Here to see if it went away after we had known it once
RSPI.2: SKIPN PIDTAB(S2) ;DID WE EVER KNOW IT?
$RETE(NSP) ;NO -- RETURN NO SUCH PID
$RETE(PWA) ;YES -- RETURN PID WENT AWAY
;Here to check invalid index
RSPI.8:
$RETE(ARG) ;YES, GIVE INVALID ARGUMENT ERROR
;RSPIDS is continued on the next page

SUBTTL SETNAM - Routine to declare our name to INFO
;SETNAM is used to setup the name in the packet about to go to INFO or IPCC
;This allows programs to communicate
; by other means than the system PID table. This is useful for debugging
; purposes when multiple components are going to be used.
;SETNAM should always be called just before calling GETPID
;CALL: S2/ Addr of ITEXT of name to write
; or 0, to set up no name
;
;TRUE RETURN: Always, name has been established
; 2 nd word of PACKET has 0 or name,
; STACP has incremented pointer
SETNAM: SETZM MTLBLK+.IPCI2 ;CLEAR NAME FROM MESSAGE
SETZM MTLBLK+MTLSIZ-1 ;MAKE SURE IS ALWAYS ASCIZ
PUSH P,S2 ;SAVE NAME POINTER A MOMENT
MOVE S2,[POINT 7,MTLBLK+.IPCI2] ;GET POINTER TO MESSAGE AREA
MOVEM S2,STACP ;STORE THAT POINTER
MOVEI S2,SZ.INF ;GET MAXIMUM NAME LENGTH
MOVEM S2,STACL ;STORE IN LIMIT WORD
POP P,S2 ;RESTORE NAME POINTER
JUMPE S2,.RETT ;IF NO NAME DESIRED, WE'RE DONE
$TEXT(STAC,<^I/(S2)/^0>) ;CREATE THE NAME
$RETT ;RETURN SUCCESS
;FNDNAM is used to ask INFO for the pid of a specified name
; It is called by GETPID to look for our name and by RSPIDX
; to check for Private Quasar and Private Orion
;CALL: S2/ addr of ITEXT to build name
;TRUE RETURN: S1/ Pid of Specified Name
FNDNAM: PUSHJ P,SETNAM ;Set up name in message
MOVE S1,[XWD FNDNAM,.IPCIW] ;FUNCTION IS FIND PID FOR NAME
PUSHJ P,SNDINF ;ASK INFO
JUMPF [$RETE(NSP)] ;RETURN NO SUCH PID
MOVE S1,MTLBLK+.IPCI1 ;GET THE PID
SKIPE DEBUGW ;DEBUGGING ?
$WARN <Alternate ^T20/MTLBLK+.IPCI2/ (PID = ^O/S1/)> ;SHOW THE NAME
$RETT ;RETURN SUCCESS