ROUTINE  SSLDR
! This is the subsystem loader for the shareable basegla subsystem.
! This version has the capability to run the subsystem with an unshareable
! basegla if it detects that Director's system call list has altered since
! the subsystem was linked.
! When this code is entered all the information available is the LNB and
! two params, Director's system call version no at LNB+5 and ADIRINF at LNB+6.
! (We also know, inter alia, that Director has created and connected a 'basegla'
! file at the first free segment after the end of the basefile.)
! SF is undefined so the first task is to set it to LNB+13. (LNB+7 - LNB+12
! is reserved for the local variables MARK - SSDAT).
! The address of the basefile GLAP is calculated and the SS system call
! version no compared with Director's. If they are the same then the GLAP
! address is loaded into LNB+4 and SSINIT called, else the glap is copied
! to the start of the basegla and LNB+4 set to this address before calling
! SSINIT.
! This routine must be compiled with PARM OPT set. After compilation
! the first word after the header must be overwritten with a jump
! to the first instruction of the loader. This jump has the format
! X1B8000NN where NN is the number of half words to be jumped. (NN=2A in this vsn)
SYSTEMROUTINESPEC  SSINIT(INTEGER  MARK,ADIRINF)
EXTRINSICINTEGER  SSDATELINKED
INTEGER  MARK,ADIRINF,BASEOBJAD,OFMAD,BGLA,SSDAT
! Reset SF to LNB+13
*STSF_TOS 
*LSS_TOS 
*STLN_TOS 
*ISB_TOS ;           ! No of bytes between SF and LNB
*USH_-2;             ! Convert to words
*IRSB_13
*ST_TOS 
*ASF_TOS 
! SF reset now get address of basegla
*JLK_1;              ! Store current PC on TOS
*LSS_TOS 
*USH_-18
*USH_18;             ! This is the connect address of the basefile
*IAD_32;             ! Address of basefile object
*ST_BASEOBJAD
*LXN_BASEOBJAD
*IAD_(XNB +7);       ! Add offset of object file map to ACC (contains BASEOBJAD)
*ST_TOS 
*LXN_TOS ;           ! XNB now contains addr of OFM
*STXN_OFMAD
*LSS_(XNB +4);       ! Offset of start of the gla
*IAD_BASEOBJAD;      ! ACC now contains address of start of the gla
*ST_(LNB +4);       ! Gla pointer points to GLAP.
! Copy supplied parameters to MARK and DIRINF
*LSD_(LNB +5)
*ST_(LNB +7)
! Before we can call SSINIT we must find out if the basegla is shareable.
! I.e. is this Director's SCT still the same as the one with which this SS
! was built. If it is SSINIT can be called without further ado otherwise
! must copy the GLAP to #BGLA and reset LNB+4 to the unshared basegla.
! The test is whether MARK=SSDATELINKED.
! Since LNB+4 is currently set with the GLAP address we can drag SSDATELINKED
! out of the GLAP.
SSDAT=SSDATELINKED
IF  MARK#SSDAT THEN  START 
   ! Get address of #BGLA - first segment beyond basefile.
   *LSS_BASEOBJAD
   *ISB_32;          ! Basefile conad
   *ST_TOS 
   *LXN_TOS 
   *UAD_(XNB +0);    ! Basefile length
   *UAD_X'0003FFFF'; ! Round up to next segment
   *USH_-18
   *USH_18
   *ST_BGLA;         ! Conad of #BGLA
   ! Now calculate the length of the GLA+UST and copy it to #BGLA
   *LXN_OFMAD
   *LB_(XNB +5);     ! Length of GLA
   *ADB_(XNB +14);    ! Length of UST
   ! Construct descriptor to GLAP
   *LDTB_X'18000000'
   *LDB_B 
   *LDA_(LNB +4)
   *CYD_0
   *LDA_BGLA
   *MV_L =DR 
   *LXN_BGLA
   *STXN_(LNB +4)
FINISH 
! Call SSINIT
SSINIT(MARK,ADIRINF)
*EXIT_-64;           ! Never gets here
END ; ! OF SSLDR
ENDOFFILE