z/OS TSO/E Guide to SRPI
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Sample Initialization/Termination Program

z/OS TSO/E Guide to SRPI
SA32-0980-00

The following initialization/termination program corresponds to the sample server in Sample Server IBMABASE. The initialization/termination program does the following:
  • Loads the server.
  • Issues the DEFSERV macro.
  • Cleans up at termination.
**********************************************************************
IBMINTRM CSECT
IBMINTRM AMODE 24
IBMINTRM RMODE 24
         STM   14,12,12(13)          Save the caller's registers.
         LR    12,15                 Establish addressability within
         USING IBMINTRM,12           this CSECT.
         LA    0,DYNSIZE             Obtain the dynamic storage size.
         GETMAIN RU,LV=(0)           Obtain the dynamic storage.
         LR    11,1                  Place the storage address in the
*                                    dynamic area register.
         USING DYNAREA,11            Establish addressability to the
*                                    dynamic area.
         ST    13,SAVEAREA+4         Save the callers savearea address.
         ST    11,8(,13)             Chain our savearea to the callers.
         LM    15,1,16(13)           Restore registers 15,0, and 1.
         LA    13,SAVEAREA           Point register 13 to our savearea.
         EJECT
**********************************************************************
* TITLE: IBMINTRM MAINLINE
*
* LOGIC: Perform server initialization/termination.
*
* OPERATION:
* 1. Determine if we are in initialization or termination.
* 2. If initialization:
*   - Call INIT_SERVER to load and define the servers to MVSSERV
*   - If the servers are defined to MVSSERV:
*     A. Exit the init/term program.
*   - Else:
*     A. Call CLEAN_UP to delete the servers.
*     B. Exit the init/term program.
* 3. Else, termination:
*   - Call CLEAN_UP to delete the servers.
* 4. Return to caller with return code.
**********************************************************************
         SPACE
         L     2,0(,1)               Load the init/term area address.
         USING INITTERM,2            Establish addressability to it.
         SPACE
         L     3,4(,1)               Load the CED address.
         USING CHSCED,3              Establish addressability to it.
         SPACE
**********************************************************************
* Determine if we are in INITIALIZATION or TERMINATION
**********************************************************************
         SPACE
         LA    4,INITIAL             Obtain the initialization equate.
         C     4,INTINIT             Are we in initialization?
         BNE   TERMINATE             No, then we must terminate.
         SPACE
**********************************************************************
* Perform INITIALIZATION processing
**********************************************************************
         SPACE
         BAL   14,INIT_SERVERS       Yes, Call INIT_SERVERS.
         LTR   15,15                 Are the servers defined to MVSSERV?
         BZ    EXIT                  Leave the init/term program.
         SPACE
**********************************************************************
* Perform TERMINATION processing
**********************************************************************
         SPACE
TERMINATE DS   0H
         BAL   14,CLEAN_UP           Call CLEAN_UP.
         EJECT
**********************************************************************
* Leave the INIT/TERM program
**********************************************************************
         SPACE
EXIT     DS    0H
         L     13,SAVEAREA+4         Restore the callers savearea
*                                    address.
         LR    2,15                  Save the return code.
         LR    1,11                  Obtain dynamic area address.
         LA    0,DYNSIZE             Obtain the dynamic storage size.
         FREEMAIN RU,LV=(0),A=(1)    Release the dynamic area.
         LR    15,2                  Restore the return code.
         L     14,12(,13)            Restore the caller's registers
         LM    0,12,20(13)           except for 15 (return code).
         BR    14                    Return to caller with return code.
         EJECT
**********************************************************************
* TITLE: INIT_SERVERS
*
* LOGIC: Define the servers to MVSSERV.
*
* OPERATION:
* 1. Issue the CHSTRACE macro to output a message to the TRACE data
*    set.
* 2. Issue the GETMAIN macro to obtain the SERVER parameter storage.
* 3. Clear the SERVER parameter storage and initialize the macro
*    list forms.
* 4. Load the servers.
* 5. Issue the DEFSERV macro for each server to attempt to define
*    the server to MVSSERV.
* 6. Save the return codes.
* 7. Return to the mainline.
**********************************************************************
         SPACE
INIT_SERVERS DS 0H
         STM   14,12,SUBSAVE         Save the caller's registers.
         SPACE 2
**********************************************************************
* Issue the CHSTRACE macro to output the initialization message.
**********************************************************************
         SPACE
         CHSTRACE DEST=TRACE,CED=CHSCED,BUFFER=INIT_MSG,               *
               BUFLEN=MSG_LEN,MF=(E,CHSLIST,COMPLETE)
         SPACE
**********************************************************************
* Obtain the Server Parameter Area.
**********************************************************************
         SPACE
         LA    0,SERVER_PARMS_SIZE   Obtain the length of the server
*                                    parameter area.
         GETMAIN RU,LV=(0)
         LR    4,1                   Obtain the address of the storage.
         USING SERVPARM,4            Establish addressability to the
*                                    server parameters.
         ST    0,INTWALEN            Save the server parameter area
*                                    length.
         ST    4,INTWAPTR            Save the server parameter area
*                                    address.
         SPACE
**********************************************************************
* Initialize the macro list forms.
**********************************************************************
         SPACE
         LA    5,L'SERVER_STORAGE
         SLR   6,6
         SLR   7,7
         MVCL  4,6
         L     4,INTWAPTR            Restore server parameter area
*                                    address.
         MVC   DCBIN(SDCBIN_LEN),SDCBIN
         MVC   DCBOUT(SDCBOUT_LEN),SDCBOUT
         MVC   DCBLOG(SDCBLOG_LEN),SDCBLOG
         MVC   OPEN_LIST(SOPEN_LEN),SOPEN_LIST
         MVC   CLOSE_LIST(SCLOSE_LEN),SCLOSE_LIST
         SPACE
**********************************************************************
* Issue the LOAD macro to load the servers into storage.
**********************************************************************
         SPACE
         LOAD  EP=IBMABASE
         ST    0,SERVER_ADDR         Save IBMABASE's address.
         SPACE
         LOAD  EP=IBMABAS1
         ST    0,SERVER1_ADDR        Save IBMABAS1's address.
         SPACE
         LOAD  EP=IBMABAS2
         ST    0,SERVER2_ADDR        Save IBMABAS2's address.
         SPACE
**********************************************************************
* Initialize the SERVER parameter list.
**********************************************************************
         SPACE
         LA    5,CHSDCPRB            Get the address of the CPRB.
         SPACE
         LA    6,SERVER_STORAGE      Get the Server dynamic storage
*                                    address.
         ST    6,PARM_LIST           Place it in the server parameter.
         LA    6,DCBIN               Get the INPUT DCB address.
         ST    6,PARM_LIST+4         Place it in the server parameter.
         LA    6,DCBOUT              Get the OUTPUT DCB address.
         ST    6,PARM_LIST+8         Place it in the server parameter.
         LA    6,DCBLOG              Get the LOG DCB address.
         ST    6,PARM_LIST+12        Place it in the server parameter.
         LA    6,OPEN_LIST           Get the OPEN macro list form.
         ST    6,PARM_LIST+16        Place it in the server parameter.
         LA    6,CLOSE_LIST          Get the CLOSE macro list form.
         ST    6,PARM_LIST+20        Place it in the server parameter.
         SPACE
         LA    6,PARM_LIST           Get the address of the server
*                                    parameter list.
         SPACE
**********************************************************************
* Issue the DEFSERV macro to define the servers to MVSSERV.
**********************************************************************
         SPACE
         DEFSERV CPRB=(5),CED=(3),SERVNAME=SERVER_NAME,                *
               SERVEPA=SERVER_ADDR,SERVPARM=(6),MF=(E,DEFLIST)
         LTR   15,15                 Check the return code.
         BNZ   DEFSERV_ERROR         If it is non-zero, then leave.
         L     15,CRBCRTNC           Obtain the return code.
         LTR   15,15                 Check the return code.
         BNZ   DEFSERV_ERROR         If it is non-zero, then leave.
         SPACE
         DEFSERV CPRB=(5),CED=(3),SERVNAME=SERVER1_NAME,               *
               SERVEPA=SERVER1_ADDR,SERVPARM=(6),MF=(E,DEFLIST)
         LTR   15,15                 Check the return code.
         BNZ   DEFSERV_ERROR         If it is non-zero, then leave.
         L     15,CRBCRTNC           Obtain the return code.
         LTR   15,15                 Check the return code.
         BNZ   DEFSERV_ERROR         If it is non-zero, then leave.
         SPACE
         DEFSERV CPRB=(5),CED=(3),SERVNAME=SERVER2_NAME,               *
               SERVEPA=SERVER2_ADDR,SERVPARM=(6),MF=(E,DEFLIST)
         LTR   15,15                 Check the return code.
         BNZ   DEFSERV_ERROR         If it is non-zero, then leave.
         L     15,CRBCRTNC           Obtain the return code.
         LTR   15,15                 Check the return code.
         BNZ   DEFSERV_ERROR         If it is non-zero, then leave.
         B     LEAVE                 Everything is O.K., so leave.
         SPACE
DEFSERV_ERROR DS 0H
         LA    15,4                  Set a bad return code.
         SPACE
LEAVE    DS    0H
         L     14,SUBSAVE            Restore the caller's registers
         LM    0,12,SUBSAVE+8        except for 15 (return code).
         BR    14                    Return to caller with return code.
         EJECT
**********************************************************************
* TITLE: CLEAN_UP
*
* LOGIC: Remove the servers.
*
* OPERATION:
* 1. Issue the CHSTRACE macro to output a message to the TRACE data
*    set.
* 2. Issue the FREEMAIN macro to release the SERVER parameter storage.
* 3. Delete the servers.
* 4. Return to the mainline.
**********************************************************************
         SPACE
CLEAN_UP DS 0H
         STM   14,12,SUBSAVE         Save the caller's registers.
         SPACE 2
**********************************************************************
* Issue the CHSTRACE macro to output the termination message.
**********************************************************************
         SPACE
         CHSTRACE DEST=TRACE,CED=CHSCED,BUFFER=TERM_MSG,               *
               BUFLEN=MSG_LEN,MF=(E,CHSLIST,COMPLETE)
         SPACE
**********************************************************************
* Release the Server Parameter Area.
**********************************************************************
         SPACE
         L     1,INTWAPTR            Obtain the address of the server
*                                    parameter area.
         L     0,INTWALEN            Obtain the length of the server
*                                    parameter area.
         FREEMAIN RU,LV=(0),A=(1)
         SPACE
**********************************************************************
* Issue the DELETE macro to delete the servers from storage.
**********************************************************************
         SPACE
         DELETE EP=IBMABASE
         SPACE
         DELETE EP=IBMABAS1
         SPACE
         DELETE EP=IBMABAS2
         SPACE
         LA    15,0
         L     14,SUBSAVE            Restore the caller's registers
         LM    0,12,SUBSAVE+8        except for 15 (return code).
         BR    14                    Return to caller with return code.
         EJECT
**********************************************************************
* Constants.
**********************************************************************
         SPACE
**********************************************************************
* SERVER names.
**********************************************************************
         SPACE
SERVER_NAME DC  CL8'IBMABASE'        Server name.
SERVER1_NAME DC CL8'IBMABAS1'        Server name.
SERVER2_NAME DC CL8'IBMABAS2'        Server name.
         SPACE
**********************************************************************
* TRACE data set messages.
**********************************************************************
         SPACE
INIT_MSG DC    CL80' Initialization/termination program IBMINTRM entered*
                for INITIALIZATION.'
TERM_MSG DC    CL80' Initialization/termination program IBMINTRM entered*
                for TERMINATION.'
MSG_LEN  DC    A(*-TERM_MSG)         Length of message
         SPACE
**********************************************************************
* OPEN macro (static list form).
**********************************************************************
         SPACE
SOPEN_LIST OPEN (,(INPUT),,(OUTPUT),,(EXTEND)),MF=L
SOPEN_LEN EQU  *-SOPEN_LIST
         SPACE
**********************************************************************
* CLOSE macro (static list form).
**********************************************************************
         SPACE
SCLOSE_LIST CLOSE (,,,,,),MF=L
SCLOSE_LEN EQU *-SCLOSE_LIST
         EJECT
**********************************************************************
* DCB macro (static input).
**********************************************************************
         SPACE
SDCBIN   DCB   DDNAME=CUSTRECS,DSORG=PS,MACRF=GM
SDCBIN_LEN EQU *-SDCBIN
         EJECT
**********************************************************************
* DCB macro (static output).
**********************************************************************
         SPACE
SDCBOUT  DCB   DDNAME=ACCTRECS,DSORG=PS,MACRF=PM
SDCBOUT_LEN EQU *-SDCBOUT
         EJECT
**********************************************************************
* DCB macro (static log).
**********************************************************************
         SPACE
SDCBLOG  DCB   DDNAME=LOGTRANS,DSORG=PS,MACRF=PM
SDCBLOG_LEN EQU *-SDCBLOG
         EJECT
**********************************************************************
* Dynamic Area.
**********************************************************************
         SPACE
DYNAREA  DSECT
         SPACE
SAVEAREA DS    18F                   IBMINTRM's save area.
SUBSAVE  DS    15F                   IBMINTRM subroutine's save area.
SERVER_ADDR DS F                     Used to hold the servers entry
*                                    point.
SERVER1_ADDR DS F                    Used to hold the servers entry
*                                    point.
SERVER2_ADDR DS F                    Used to hold the servers entry
*                                    point.
         SPACE
**********************************************************************
* Issue the DEFSERV macro list form to supply a parameter list.
**********************************************************************
         SPACE
DEFLIST  DEFSERV  MF=L
         SPACE
**********************************************************************
* Issue the CHSTRACE macro list form to supply a parameter list.
**********************************************************************
         SPACE
         CHSTRACE MF=(L,CHSLIST)
         EJECT
**********************************************************************
* CPRB
**********************************************************************
         SPACE
         CHSDCPRB DSECT=NO
         SPACE
DYNSIZE  EQU   *-DYNAREA             Size of the dynamic area.
         EJECT
**********************************************************************
* Server parameters.
**********************************************************************
         SPACE
SERVPARM DSECT
         SPACE
**********************************************************************
* Dynamic storage for server (saves GETMAIN and FREEMAIN in server)
*
* NOTE:  SERVER_STORAGE must be changed if the DYNAMIC area for
*        IBMABASE, IBMABAS1 and IBMABAS2 exceeds the current size.
**********************************************************************
         SPACE
SERVER_STORAGE DS CL500
         SPACE
**********************************************************************
* OPEN macro (dynamic list form).
**********************************************************************
         SPACE
OPEN_LIST OPEN (,(INPUT),,(OUTPUT),,(OUTPUT)),MF=L
         SPACE
**********************************************************************
* CLOSE macro (dynamic list form).
**********************************************************************
         SPACE
CLOSE_LIST CLOSE (,,,,,),MF=L
         EJECT
**********************************************************************
* DCB macro (dynamic input).
**********************************************************************
         SPACE
DCBIN    DCB   DDNAME=CUSTRECS,DSORG=PS,MACRF=GM
         EJECT
**********************************************************************
* DCB macro (dynamic output).
**********************************************************************
         SPACE
DCBOUT   DCB   DDNAME=ACCTRECS,DSORG=PS,MACRF=PM
         EJECT
**********************************************************************
* DCB macro (dynamic log).
**********************************************************************
         SPACE
DCBLOG   DCB   DDNAME=LOGTRANS,DSORG=PS,MACRF=PM
         EJECT
         SPACE
**********************************************************************
* Server parameter list, contains the addresses of:
*        The Server Dynamic Storage
*        The INPUT DCB
*        The OUTPUT DCB
*        The LOG DCB
*        The OPEN LIST FORM
*        The CLOSE LIST FORM
**********************************************************************
         SPACE
PARM_LIST DS 6A
         SPACE
SERVER_PARMS_SIZE EQU *-SERVPARM     Size of server parameter area.
         EJECT
**********************************************************************
* CED mapping.
**********************************************************************
         SPACE
         CHSCED   DSECT=YES
         EJECT
**********************************************************************
* INIT/TERM mapping.
**********************************************************************
         SPACE
         INITTERM DSECT=YES
         END   IBMINTRM

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014