ASMB,L,C,R
      HED RBLCK AND RBUNL SUBROUTINES OF RDBA-IMAGE/1000
      NAM RBLCK,7 92069-16223 REV.1912 790130 
* 
* 
******************************************************************* 
* (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:    92069-18223
*     RELOC:     92069-16223
* 
*     PRGMR:     CEJ
* 
* 
******************************************************************* 
* 
* 
* 
*  This is the remote DBLCK routine.  Its function is to transform the
*  DBLCK parameters into those needed for RDBA, then to send the request
*  to the remote machine through RBMST. 
* 
*  The calling sequence for RBLCK is: 
* 
*         JSB RBLCK 
*          DEF *+5          return point
*          DEF BASE         data base parameter from DBLCK call 
*          DEF SET          data set parameter from DBLCK call
*          DEF MODE         mode from DBLCK call
*          DEF STAT         status array from DBLCK call
* 
**********************************************************************
*                                                                    *
*  Run Table for local machine in Remote Data Base Access            *
*                                                                    *
*  The local copy of the Run Table used by the RDBA master subrou-   *
*  tines consists of the following sections:                         *
*                                                                    *
*    1) Data Base Control Block                                      *
*    2) Data Item Table                                              *
*    3) Data Set Table                                               *
*    4) Sort Table                                                   *
*                                                                    *
*  These sections are in the order stated.  Details of each section  *
*  follow.                                                           *
*                                                                    *
**********************************************************************
***                                                                ***
*                                                                    *
*  Data Base Control Block - one 17 word entry per data base         *
*                                                                    *
***                                                                ***
RDCBS DEC 17        DBCB size 
* 
RDNAM DEC 0         data base name - three words
      DEC 1 
      DEC 2 
RDRBN DEC 3         remote data base number 
      DEC 4 
RDDSN DEC 5         DS node number
      DEC 6 
RDITC DEC 7         data item count 
RDITP DEC 8         data item table pointer 
RDDSC DEC 9         data set count
RDDSP DEC 10        data set table pointer
RDSOP DEC 11        sort table pointer
      DEC 12
RDLMD DEC 13        lock flag/open mode 
RDLFG EQU RDLMD     1st byte: lock flag 
RDMOD EQU RDLMD     2nd byte: open mode 
      DEC 14
RDCBC DEC 15        # of DCBs desired = 0 
RDMDL DEC 16        maximum data length 
* 
ZERO  EQU RDNAM     base of zero for future equates 
***                                                                ***
*                                                                    *
*  Data Item Table - one 5 word entry per item in a 1000 data base   *
*                                                                    *
***                                                                ***
RI1LN EQU ZERO+5    length of a 1000 entry
* 
RI1NM EQU ZERO      item name - 3 words 
RI1NO EQU ZERO+3    item number 
RI1IL EQU ZERO+4    item length 
***                                                                ***
*                                                                    *
*  Data Set Table - one 6 word entry per set in a 1000 data base     *
*                                                                    *
***                                                                ***
RS1LN EQU ZERO+6    length of a 1000 entry
* 
RS1NM EQU ZERO      set name - 3 words
RS1NO EQU ZERO+3    set number
RS1EL EQU ZERO+4    entry length (in words) 
RS1KL EQU ZERO+5    key item length for a master
***                                                                ***
*                                                                    *
*  Sort Table - one 1 word entry per item and per set.  Each entry   *
*               is a pointer to the respective item or set table     *
*               entry relative to the start of the Run Table         *
*                                                                    *
***                                                                ***
A     EQU 0 
B     EQU 1 
* 
      ENT RBLCK,RBUNL 
      EXT .ENTR,AIRUN,RBMST 
* 
LBASE NOP 
LSET  NOP 
LMODE NOP 
LSTAT NOP 
* 
*  Get true parameter and return point addresses. 
* 
RBLCK NOP 
      JSB .ENTR 
       DEF LBASE
* 
*  Set error code word in status array to zero for ease in return.
* 
      CLA 
      STA LSTAT,I 
* 
*  Make sure that the open mode is 1 and that the data base is not
*  locked.  Else, if the open mode is 3, or the data base is already
*  locked, then just ignore the call and return successful.  Open mode
*  is in the low order byte of the 14th word of the DBCB, lock flag is
*  in the high order byte of the same word. 
* 
      LDB AIRUN 
      ADB RDMOD 
      LDA B,I 
      AND LOBYT 
* 
      CPA D1
      JMP RLCK1     Open mode = 1 
      CPA D3
      JMP RLCK4     Open mode = 3 
      JMP L134      Bad open mode for a lock. 
* 
RLCK1 LDA B,I 
      SSA,RSS 
      JMP RLCK2     Data base not locked to user. 
      JMP RLCK4     Data base already locked. 
* 
*  Check that the lock mode is either 1 or 2. 
* 
RLCK2 LDA LMODE,I 
      CMA,INA 
      INA,SZA,RSS 
      JMP RLCK3     Lock mode = 1 
      INA,SZA 
      JMP L115      Lock mode NE 1 or 2, error. 
* 
*  Ask RBMST to build the request, send it and await the reply. 
* 
RLCK3 JSB RBMST 
       DEF *+11 
       DEF D44      RBMST needs: RDBA Index 
       DEF LMODE,I               DBLCK mode 
       DEF LSET,I                dummy set parameter
       DEF D0                    dummy
       DEF LBASE,I               data base parameter
       DEF LSTAT,I               status array 
       DEF D0                    outgoing data buffer 
       DEF D0                    outgoing data length 
       DEF D0                    incoming data buffer 
       DEF D0                    incoming data length 
RLCK4 JMP RBLCK,I     <error return>
* 
*  If lock successful, set lock flag negative.  Lock flag is high order 
*  byte of 14th word of DBCB. 
* 
      LDA LSTAT,I   First word of status array is 
      SZA             zero if lock succeeded. 
      JMP RLCK4 
* 
      LDB AIRUN 
      ADB RDLFG 
      LDA B,I 
      IOR NWAIT 
      STA B,I 
      JMP RLCK4 
* 
*  Error return points. 
* 
L115  LDB D115      Invalid lock mode 
      RSS 
L134  LDB D134      Invalid open mode for Lock. 
      STB LSTAT,I 
      JMP RLCK4 
* 
*  Constants and variables. 
* 
D44   DEC 44
D134  DEC 134 
* 
NWAIT OCT 100000
* 
      SKP 
* 
*  This is the remote DBUNL routine.  Its function is to transform the
*  DBUNL parameters into those needed for RDBA and to send the request
*  to the remote machine through RBMST. 
* 
*  The calling sequence for RBUNL is: 
* 
*         JSB RBUNL 
*          DEF *+5         return point 
*          DEF BASE        data base parameter from DBUNL call
*          DEF SET         data set parameter from DBUNL call 
*          DEF MODE        mode from DBUNL call 
*          DEF STAT        status array from DBUNL call 
* 
UBASE NOP 
USET  NOP 
UMODE NOP 
USTAT NOP 
* 
*  Get true parameter and return point addresses. 
* 
RBUNL NOP 
      JSB .ENTR 
       DEF UBASE
* 
*  Set error code word in status array to zero for ease in return.
* 
      CLA 
      STA USTAT,I 
* 
*  Make sure that the data base was opened in mode 1 and that the data
*  base is locked.  Else, just ignore call and return successful.  Open 
*  mode is in low order byte of the 14th word of the DBCB, lock flag is 
*  in the high order byte of same word. 
* 
      LDB AIRUN 
      ADB RDMOD 
      LDA B,I 
      AND LOBYT 
* 
      CPA D1
      RSS           Open mode = 1.
      JMP RUNL3     No need to unlock, just return. 
* 
      LDA B,I 
      SSA,RSS       Lock flag is negative, if d.b. locked 
      JMP RUNL3     Not locked, just return.
* 
*  Make sure the DBUNL mode is 1. 
* 
      LDA UMODE,I 
      CPA D1
      RSS 
      JMP U115      Illegal DBUNL mode. 
* 
*  Ask RBMST to build the request, send it, and await the reply.
* 
      JSB RBMST 
       DEF *+11 
       DEF D45      RBMST needs: RDBA Index 
       DEF UMODE,I               DBUNL mode 
       DEF USET,I                dummy data set parameter 
       DEF D0                    dummy
       DEF UBASE,I               data base parameter
       DEF USTAT,I               status array 
       DEF D0                    outgoing data buffer 
       DEF D0                    outgoing data length 
       DEF D0                    incoming data buffer 
       DEF D0                    incoming data length 
RUNL3 JMP RBUNL,I     <error return>
* 
*  If unlock successful, clear the lock flag (in high order byte of 14th
*  word of DBCB). 
* 
      LDA USTAT,I   First word of status array
      SZA             is zero if unlock succeeded.
      JMP RUNL3 
* 
      LDB AIRUN 
      ADB RDLFG 
      LDA B,I 
      AND LOBYT 
      STA B,I 
      JMP RUNL3 
* 
*  Error return points. 
* 
U115  LDB D115      Illegal DBUNL mode. 
      STB USTAT,I 
      JMP RUNL3 
* 
*  Constants and variables. 
* 
D0    EQU ZERO
D1    EQU ZERO+1
D3    EQU ZERO+3
D7    EQU ZERO+7
D45   DEC 45
D115  DEC 115 
* 
LOBYT OCT 377 
* 
      END 
                                                                                              