Example of Using the CVAFDIR Macro with an Indexed VTOC
This example uses the CVAFDIR macro to read one or more DSCBs from a VTOC. The UCB is supplied to the program in register 4 (labeled RUCB). The TTR of each DSCB read is to be returned to the caller as well as the return code received back from CVAFDIR. This program must be APF authorized.
The address of a parameter list is supplied to the program in register 5 (labeled RLIST). The parameter list contains one or more 4-word entries. The format of each 4-word entry is mapped by the LISTMAP DSECT. The first word contains the address of the data set name of the DSCB to be read. The second word contains the address of the 96-byte buffer into which the DSCB is to be read. The third word contains the address of the 3-byte TTR of the DSCB read. The fourth word contains the return code received back from CVAFDIR for the DSCB read.
The CVPL is generated by a list form of the CVAFDIR macro at label CVPL. The BUFLIST, IXRCDS, IOAREA, and BRANCH keywords are coded on the list form of the macro. IXRCDS=KEEP and IOAREA=KEEP are coded to avoid overhead if two or more DSCBs are to be read. BRANCH=(YES,PGM) is coded in the list form of the CVAFDIR macro to cause the CVPL to have the CV1PGM bit set to one; this indicates to CVAF that the caller is authorized by APF and not in supervisor state. The execute forms of the CVAFDIR macro then specify BRANCH=YES, and not BRANCH=(YES,PGM), because the CV1PGM bit is set in the list form of the macro.
The CVAFDIR macro with ACCESS=RLSE is coded before the program exits to release the CVAF I/O area and the index records buffer list. BUFLIST=0 is coded because no user-supplied buffer list is to be released; BUFLIST was coded on the list form of the CVAFDIR macro and, therefore, is in the CVBUFL field of the CVPL. This field must be set to zero for the release function.
DIRXMP2 CSECT
STM 14,12,12(13)
BALR 12,0
USING *,12
ST 13,SAVEAREA+4
LA RWORK,SAVEAREA
ST RWORK,8(,13)
LR 13,RWORK
*
************************************************************
*
* REGISTERS
*
************************************************************
*
RWORK EQU 3 WORK REGISTER
RUCB EQU 4 UCB ADDRESS SUPPLIED BY CALLER
RLIST EQU 5 ADDRESS OF PARAMETER LIST (SUPPLIED)
RDSN EQU 6 ADDRESS OF DATA SET NAME
RTTR EQU 7 ADDRESS OF TTR
REG15 EQU 15 RETURN CODE REGISTER 15
*
************************************************************
*
* UCB ADDRESS SUPPLIED IN RUCB.
* READ DSCB OF DATA SET NAME SUPPLIED.
* RETURN TTR OF DSCB.
* RETURN RETURN CODE FOR CVAFDIR REQUEST FOR DSCB.
* ADDRESS OF PARAMETER LIST IN RLIST.
* WORD 1 OF PARAMETER LIST = ADDRESS OF DATA SET NAME
* WORD 2 OF PARAMETER LIST = ADDRESS OF DSCB TO BE RETURNED
* WORD 3 OF PARAMETER LIST = ADDRESS OF TTR TO BE RETURNED
* WORD 4 OF PARAMETER LIST = RETURN CODE RETURNED FROM CVAFDIR FOR DSCB
* WORDS 1-4 CAN BE DUPLICATED FOR MULTIPLE REQUESTS
* THE HIGH ORDER BIT OF WORD 3 SET TO X'80' FOR THE LAST ENTRY ONLY.
*
************************************************************
*
USING LISTMAP,RLIST ADDRESSABILITY TO PARMLIST
TOPLOOP EQU * LOOP FOR EACH DSCB
XC BUFLIST(BFLHLN+BFLELN),BUFLIST ZERO BUFFER LIST
OI BFLHFL,BFLHDSCB DSCBS TO BE READ WITH BUFFER LIST
MVI BFLHNOE,1 ONE BUFFER LIST ENTRY
L RWORK,LISTDSCB ADDRESS OF DSCB BUFFER
ST RWORK,BFLEBUF PLACE IN BUFFER LIST
OI BFLEFL,BFLETTR TTR OF DSCB RETURNED BY CVAF
MVI BFLELTH,DSCBLTH DATA PORTION OF DSCB READ - DSN *
SUPPLIED IN CVPL
L RDSN,LISTDSN ADDRESS OF DATA SET NAME
CVAFDIR DSN=(RDSN),UCB=(RUCB),MF=(E,CVPL),BRANCH=YES
LA RTTR,LISTARG ADDRESS OF TTR TO BE RETURNED
USING TTRMAP,RTTR MAP OF TTR
LTR REG15,REG15 ANY ERROR
BZ NOERROR BRANCH IF NOT
XC TTR,TTR ZERO TTR INDICATING NO DSCB
ST REG15,LISTRC STORE RC FROM CVAFDIR INTO LISTRC
B RELOOP GET NEXT ENTRY
NOERROR EQU * DSCB READ
MVC TTR(3),BFLEATTR RETURN TTR OF DSCB
ST REG15,LISTRC STORE RC FROM CVAFDIR INTO LISTRC
RELOOP EQU * GET NEXT ENTRY
TM LASTLIST,LASTBIT IS IT LAST ENTRY IN LIST?
LA RLIST,NEXTLIST GET NEXT ENTRY
BZ TOPLOOP PROCESS NEXT LIST
CVAFDIR ACCESS=RLSE, RELEASE CVAF OBTAINED AREAS *
IOAREA=NOKEEP, RELEASE IOAREA *
IXRCDS=NOKEEP, RELEASE VIER BUFFER LIST *
BUFLIST=0, NO USER BUFFER LIST SUPPLIED TO RLSE *
BRANCH=YES, BRANCH ENTER CVAF *
MF=(E,CVPL)
L 13,SAVEAREA+4
RETURN (14,12)
BUFLIST ICVAFBFL DSECT=NO BUFFER LIST
SAVEAREA DS 18F REGISTER SAVE AREA
LISTMAP DSECT
LISTDSN DS F ADDRESS OF DATA SET NAME
LISTDSCB DS F ADDRESS OF BUFFER FOR DSCB TO BE
* RETURNED
LISTARG DS 0F ADDRESS OF FLAG AND TTR
* RETURNED
LASTLIST DS X FIRST BYTE
LASTBIT EQU X'80' LAST ENTRY IN LIST
LISTTTR DS XL3 REMAINDER OF TTR ADDRESS
LISTRC DS F RETURN CODE FROM CVAFDIR FOR THIS DSN
NEXTLIST EQU * NEXT LIST
DSCB DSECT
IECSDSL1 (1)
DSCBLTH EQU *-DSCB-L'DS1DSNAM LENGTH OF DATA PORTION OF DSCB
TTRMAP DSECT
TTRFLG DS XL1 FLAG VALUE
TTR DS XL3 TTR VALUE
DIRXMP2 CSECT
CVPL CVAFDIR ACCESS=READ,BUFLIST=BUFLIST,MF=L, *
IOAREA=KEEP, KEEP IOAREA TO AVOID OVERHEAD *
IXRCDS=KEEP, KEEP VIERS FOR 2ND / SUBSEQUENT CALLS*
BRANCH=(YES,PGM) CALLED IN PROGRAM STATE BUT APF *
AUTHORIZED SO UCB IS SUPPLIED
ORG CVPL OVERLAY CVPL WITH EXPANSION OF MAP
CVPLMAP ICVAFPL DSECT=NO
END