ASMB
      HED BAPS2 - REMOTE DATA BASE ACCESS PROGRAM SEGMENT 2 
      NAM BAPS2,5 91750-1X184 REV.2013 800523 
* 
* 
******************************************************************* 
* (C) COPYRIGHT HEWLETT-PACKARD COMPANY 1979. ALL RIGHTS RESERVED.
* NO PART OF THIS PROGRAM MAY BE PHOTOCOPIED, REPRODUCED, OR
* TRANSLATED TO ANOTHER PROGRAM LANGUAGE WITHOUT THE PRIOR WRITTEN
* CONSENT OF HEWLETT-PACKARD COMPANY. 
******************************************************************* 
* 
* 
*     SOURCE:    91750-18184
*     RELOC:     91750-1X184
* 
* 
* 
******************************************************************* 
* 
* 
* 
      COM DABUF(2174),RQBUF(30) 
      COM RECRQ,RECDA,SEGNM 
* 
*  Segment two of the Remote Data Base Access Program.  This segment has
*  the following sequence of operations.
* 
*  1)  Determine the type of IMAGE call and branch to the appropriate call
*      handler. 
* 
*      A)  DBFND
* 
*          I )  Perform the DBFND call. 
* 
*          II)  Go to 2.
* 
*      B)  DBGET
* 
*          I )  Perform the DBGET call. 
* 
*          II)  Go to 2.
* 
*      C)  DBUPD
* 
*          I )  Perform the DBUPD call. 
* 
*          II)  Go to 2.
* 
*  2)  Send the RDBA reply and any associated data.  Ignore any errors. 
* 
*  3)  Return to class get in main. 
* 
      SKP 
**********************************************************************
***                                                                ***
*                  Standard DS/1000 equates                          *
***                                                                ***
*$
*$
* 
******************************************************************
*                                                                *
*     G L O B A L   B L O C K               REV XXXX 790531      *
*                                                                *
*     GLOBAL OFFSETS INTO DS/1000 MESSAGE BUFFERS, USED BY:      *
*                                                                *
*         REMAT, RFMST, DEXEC, DMESS, FLOAD, POPEN, #MAST        *
*         GET,   #SLAV, RQCNV, RPCNV, GRPM,  LSTEN, PTOPM        *
*         EXECM, EXECW, OPERM, RFAM1, RFAM2, DLIST, DLIS3        *
*                                                                *
******************************************************************
* 
***!!!!! THE FIRST 7 WORDS (#STR THRU #ENO) MUST BE FIXED !!!!!***
#STR  EQU 0         STREAM WORD.
#SEQ  EQU #STR+1    SEQUENCE NUMBER.
#SRC  EQU #SEQ+1    SOURCE NODE #.
#DST  EQU #SRC+1    DEST. NODE #. 
#EC1  EQU #DST+1    REPLY ECOD1.
#EC2  EQU #EC1+1    REPLY ECOD2.
#ENO  EQU #EC2+1    NUMBER OF NODE REPORTING ERROR. 
* 
#ECQ  EQU #ENO+1    ERROR CODE QUALIFIER (BITS 4 TO 7)
#LVL  EQU #ECQ      MESSAGE FORMAT LEVEL (BITS 0 TO 3)
#MAS  EQU #LVL+1    MA "SEND" SEQ. #
#MAR  EQU #MAS+1    MA "RECV" SEQ. #
#MAC  EQU #MAR+1    MA "CANCEL" FLAGS 
#HCT  EQU #MAC+1    HOP COUNT 
#SID  EQU #HCT+1    SESSION ID WORD 
* 
#EHD  EQU #SID      LAST ITEM OF HEADER 
#MHD  EQU #EHD+1    MINIMUM HEADER SIZE 
#REQ  EQU #MHD      START OF REQUEST SPECIFIC AREA
#REP  EQU #MHD      START OF REPLY SPECIFIC AREA
* 
#MXR  EQU #MHD+24   <<< MAXIMUM DS REQ/REPLY BUFFER SIZE >>>
#LSZ  EQU 2         <<< SIZE OF LOCAL APPENDAGE AREA >>>
* 
******************************************************************
* 
***                                                                ***
**********************************************************************
**********************************************************************
*                                                                    *
*  DS/1000 RDBA Communications consist of two descriptive buffers:   *
*          1) Request buffer                                         *
*          2) Reply buffer                                           *
*  These two static buffers are as described below.                  *
*                                                                    *
**********************************************************************
***                                                                ***
*                                                                    *
*  Request buffer - one buffer of from 12 to 21 words per RDBA call  *
*                                                                    *
***                                                                ***
RBSTR EQU #STR      DS/1000 stream word 
RBSEQ EQU #SEQ      DS/1000 sequence number 
RBSRC EQU #SRC      DS/1000 source node number
RBDST EQU #DST      DS/1000 destination node number 
RBIDX EQU #REQ      RDBA call Index 
RBMOD EQU #REQ+1    RDBA call mode
RBID  EQU #REQ+2    RDBA call item or set number
*                                  or for a DBOPN, the level code word
RBITM EQU #REQ+3    Search item number for DBFND
RBMRT EQU #REQ+5    For DBOPN, the max. returned RT size
RBLEN EQU #REQ+6    Word size of ibase parameter
RBBAS EQU #REQ+7    Ibase parameter 
* 
MAXRQ DEC 30        Maximum request buffer length 
***                                                                ***
***                                                                ***
*                                                                    *
*  Reply buffer - one buffer of either 17 or 18 words per RDBA call  *
*                                                                    *
***                                                                  *
* RBSTR EQU #STR    DS 1000 stream word 
* RBSEQ EQU #SEQ    DS/1000 sequence number 
* RBSRC EQU #SRC    DS/1000 source node number
* RBDST EQU #DST    DS/1000 destination node number 
RBEC1 EQU #EC1      DS/1000 1st error code word 
RBEC2 EQU #EC2      DS/1000 2nd error code word 
RBEC3 EQU #ENO      DS/1000 error node number upon an error 
RBSTA EQU #REP      RDBA call status array
RBNUM EQU #REP+10   RDBA data base number for DBOPN 
* 
RPLEN DEC 23        Standard reply buffer length
*                                  24 for DBOPN 
***                                                                ***
**********************************************************************
      ENT BAPS2 
      EXT BP.GT,DBFND,DBGET,DBUPD 
      EXT RDEXT 
* 
DAADR DEF DABUF 
A     EQU 0 
B     EQU 1 
* 
*  Put our name suffix into SEGNM in common.  That way, if another request
*  comes through for this segment, RDBAP (the main) will not reload us. 
* 
BAPS2 LDA SUFIX 
      STA SEGNM 
* 
*  Determine the type of IMAGE call being made by the index calculated
*  in the main and jump to the proper handling routine.  Remember that
*  this index is: 45 - (RDBA Index).
* 
      LDB RQBUF+RBIDX 
      ADB JMPTB 
      JMP B,I 
* 
JMPTB DEF *+1 
      JMP E159
      JMP E159        RDBA Index within [45,42] 
      JMP E159          should not happen.
      JMP E159
      JMP UPD       RDBA Index = 41, DBUPD
      JMP GET       RDBA Index = 42, DBGET
      JMP FND       RDBA Index = 40, DBFND
      JMP E159
      JMP E159        RDBA Index within [39,36] 
      JMP E159          should not happen.
      SKP 
* 
*  A remote DBFND.
*  The request buffer contains the following information: 
* 
FNMOD EQU RQBUF+RBMOD   Find mode 
FNSET EQU RQBUF+RBID    Data set number 
FNITM EQU RQBUF+RBITM   Data item number
FNBAS EQU RQBUF+RBBAS   Data base parameter 
* 
*  The status array is directly following the DS reply buffer.
* 
FNSTA EQU RQBUF+RBSTA 
* 
*  The key item value is in the data buffer.
* 
FNARG EQU DABUF 
* 
*  Perform the DBFND call.
* 
FND   JSB DBFND 
       DEF *+7
       DEF FNBAS
       DEF FNSET
       DEF FNMOD
       DEF FNSTA
       DEF FNITM
       DEF FNARG
* 
*  There is no data to return, so set reply data length to zero (in B 
*  register) and jump to the exit routine.
* 
      CLB 
      JMP EXIT
      SKP 
* 
*  A remote DBGET.
*  The request buffer contains the following information: 
* 
GTMOD EQU RQBUF+RBMOD   Get mode
GTSET EQU RQBUF+RBID    Data set number 
GTBAS EQU RQBUF+RBBAS   Data base parameter 
* 
*  The status array is directly following the DS reply buffer.
* 
GTSTA EQU RQBUF+RBSTA 
* 
*  The item list is the 2nd through ?th words of the data buffer. 
* 
GTLST EQU DABUF+1 
* 
*  The key item value for a mode 7 get or the record number for a mode
*  4 get is in the necessary number of words immediately following the
*  item list in the data buffer.  The first word of the data buffer con-
*  tains the length of the item list.  Therefore, the address of the IARG 
*  parameter is the address of the data buffer plus the length of the list
*  plus one.
* 
GET   LDA DAADR 
      ADA DABUF 
      INA 
      STA GTARG 
* 
*  Perform the DBGET call, the data read is returned in the data buffer.
* 
      JSB DBGET 
       DEF *+8
       DEF GTBAS
       DEF GTSET
       DEF GTMOD
       DEF GTSTA
       DEF GTLST
       DEF DABUF
       DEF GTARG,I
* 
*  If DBGET did not succeed (i.e. first word of GTSTA NE 0) then the re-
*  turned data length is zero.  Else, the returned data length is in the
*  2nd word of the status array.  Get this length in the B register and 
*  jump to the exit routine.
* 
      CLB 
      LDA GTSTA 
      SZA,RSS 
      LDB GTSTA+1 
      JMP EXIT
* 
*  Constants and variables. 
* 
GTARG NOP 
      SKP 
* 
*  A remote DBUPD.
*  The request buffer contains the following information: 
* 
UPMOD EQU RQBUF+RBMOD   Update mode 
UPSET EQU RQBUF+RBID    Data set number 
UPBAS EQU RQBUF+RBBAS   Data base parameter 
* 
*  The status array is directly following the DS reply buffer.
* 
UPSTA EQU RQBUF+RBSTA 
* 
*  The item list starts in the 2nd word of the data buffer. 
* 
UPLST EQU DABUF+1 
* 
*  The values for the items in the item list immediately follow the item
*  list in the data buffer.  The first word of the data buffer contains 
*  the length of the item list.  Therefore, the address of the value buf- 
*  fer is the address of the data buffer plus the length of the item list 
*  plus one.
* 
UPD   LDA DAADR 
      ADA DABUF 
      INA 
      STA UPBUF 
* 
*  Perform the DBUPD call.
* 
      JSB DBUPD 
       DEF *+7
       DEF UPBAS
       DEF UPSET
       DEF UPMOD
       DEF UPSTA
       DEF UPLST
       DEF UPBUF,I
* 
*  There is no return data, so set the length of returned data to zero, 
*  and jump to the exit routine.
* 
      CLB 
      JMP EXIT
* 
*  Constants and variables. 
* 
UPBUF NOP 
      SKP 
* 
*  The only DS error routine is when the RDBA Index for this segment is 
*  in error.
* 
E159  LDB M159
      CLA 
      STA RECDA     Set data length to zero.
      JMP EXIT2 
* 
*  This is the exit routine for segment 2 of RDBAP.  Its purpose is to
*  call the necessary subroutines in order to send the RDBA reply to the
*  originating node and to terminate the program, saving resources.  All
*  DS replies are sent through RDEXT. 
* 
EXIT  STB RECDA     Set returning data length 
      CLA 
      CLB             and zero the error code.
EXIT2 DST ERROR 
* 
      JSB RDEXT     Then let RDEXT send the reply.
       DEF *+6
       DEF RQBUF    It needs: reply buffer
       DEF RPLEN              reply length
       DEF DABUF              data buffer 
       DEF RECDA              data length 
       DEF ERROR              error code
      NOP             <error return - ignore> 
* 
      JMP BP.GT     Return to class get in main.
* 
*  Constants and variables. 
* 
M159  DEC -159
* 
SUFIX ASC 1,2 
* 
ERROR BSS 2 
      END BAPS2 
                                                                                                                                                                                                                                            