.MCALL .MODULE .MODULE JRDWRT,VERSION=13,COMMENT=,IDENT=NO,LIB=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ;++ ; ; Edit Who Date Description of modification ; ---- --- ---- --------------------------- ; 001 WLD 15-OCT-90 Standardize PSECT names. ; ; (013) 08-Nov-90 MBG Rewrite for extended mapping support ; ;-- .SBTTL Module Declarations .NLIST .ENABL LC .DSABL GBL .NLIST CND .LIST ; ++ ; FACILITY: ; ; RT-11 System Subroutine Library ; ; ENVIRONMENT: ; ; This routine can be used by any job running in a single-job ; or multi-job environment. Under the XM monitor, these routines ; require that the AT pseudohandler be loaded in memory to provide ; address translation. ; ; CALLABLE ENTRIES: ; ; JREAD, JREADW, JREADC, JWRITE, JWRITW, JWRITC ; ; INCLUDE FILES: ; ; SYSMAC.SML ; RT-11 system macro library .LIBRARY "SRC:SYSTEM.MLB" ; RT-11 system definition library .MCALL .BR ;Assemble-time check .MCALL .CSTAT .DSTAT .SPFUN ;Programmed requests .MCALL .CF1DF .CF3DF .CSTDF ;Definitions .MCALL .DEVDF .FIXDF .SFDDF .MCALL ..SPFU .CF1DF ; Define $CNFG1 bits .CF3DF ; Define $CNFG3 bits .CSTDF ; Define .CSTAT offsets .DEVDF ; Define device codes .FIXDF ; Define fixed offsets .SFDDF ; Define SPFUN codes for disks ..SPFU ; Define SPFUN EMT arg block ; ; EQUATED SYMBOLS: ; CH.ERR =: -3 ; 'Channel not open' ID.ERR =: -4 ; 'Invalid device' AT.ERR =: -6 ; 'AT is not loaded' DEV.ERR =: -5 ; 'Channel not open as a device' IA.ERR =: -19. ;Invalid argument ; ; EXTERNAL REFERENCES: ; .GLOBL $NXVAL ; Entry point to next value routine .GLOBL $NXADR ; Entry point to next address routine .GLOBL $SYSLB ; Include system library work area .GLOBL $ERRM0 ; Convert and return any error .GLOBL $NOARG ; missing arg code .GLOBL $GVAL ; Entry point to $GVAL routine to return ; RMON fixed offset value .GLOBL $ARGER ; missing argument error for new routines .GLOBL $BCMOD ;Routine to process BMODE and CMODE arguments .SBTTL JRDWRT - Fortran-callable Routine ;+ ; ; FUNCTIONAL DESCRIPTION: ; ; The JREAD function transfers into memory a specified number of words ; from an MSCP device associated with the indicated channel. The monitor ; returns control to the user program immediately after the JREAD functi- ; on is initiated. ; ; The JREADC function transfers into memory a specified number of words ; from an MSCP device associated with the indicated channel. The monitor ; returns control to the user program immediately after the JREADC functi- ; on is initiated. When the operation is complete, the monitor enters the ; specified assembly language routine (crtn) as an asynchronous completion ; routine. ; ; The JREADW function transfers into memory a specified number of words ; from an MSCP device associated with the indicated channel. The monitor ; returns control to the user program when the transfer is complete or when ; an error is detected. ; ; The JWRITE function transfers a specified number of words from memory ; to an MSCP device associated with the indicated channel. The monitor ; returns control to the user program immediately after the JWRITE functi- ; on is initiated. ; ; The JWRITC function transfers a specified number of words from memory ; to the an MSCP device associated with the indicated channel. The monitor ; returns control to the user program immediately after the JWRITC functi- ; on is initiated. When the operation is complete, the monitor enters the ; specified assembly language routine (crtn) as an asynchronous completion ; routine. ; ; The JWRITW function transfers a specified number of words from memory ; to an MSCP device associated with the indicated channel. The monitor ; returns control to the user program when the transfer is complete or ; when an error is detected. ; ; Note: JREADF and JWRITF are located in JRDWRF.MAC, but they transfer ; control to $JRWRT in this module. ; ; CALLING SEQUENCE: ; ; i = JREAD ( wcnt, buff, jblock, chan [, area] [, bmode] ) ; i = JREADC ( wcnt, buff, jblock, chan [, area], crtn [, bmode] ; [, cmode] ) ; i = JREADW ( wcnt, buff, jblock, chan [, area] [, bmode] ) ; ; i = JWRITE ( wcnt, buff, jblock, chan [, area] [, bmode] ) ; i = JWRITC ( wcnt, buff, jblock, chan [, area], crtn [, bmode] ; [, cmode] ) ; i = JWRITW ( wcnt, buff, jblock, chan [, area] [, bmode] ) ; ; INPUT PARAMETERS: ; ; R5 address of argument list ; 0(R5) argument count ; 2(R5) address of the integer number of words to be transferred ; 4(R5) address of the array to be used as the buffer ; 6(R5) address of a 4-word argument block that contains a 2-word ; (32-bit) starting block number, and two words of returned ; status information ; 10(R5) address of the integer specification for the RT-11 channel ; 12(R5) address of a 80-word work area that is used internally ; (No longer used as of V5.5 -- ignored) ; ; Arguments beyond the fifth one depend on call: ; ; JREAD/JREADW/JWRITE/JWRITW: ; 14(R5) address of string specifying the data buffer address space ; ; JREADC/JWRITC: ; 14(R5) address of assembly language completion routine to ; be entered when the request completes ; 16(R5) address of string specifying the data buffer address space ; 20(R5) address of string specifying the completion routine ; address space ; ; RETURNED FUNCTION VALUE: ; ; R0 Return Code (i) ; n Normal return (wait-mode I/O), n = number of words transferred ; 0 Normal return (non wait-mode I/O) ; -2 Hardware error occurred on channel ; -3 Channel is not open ; -4 Invalid device (not DU) ; -5 Channel was open not as a device ; -6 AT (address translation in XM) not available ; -19. Invalid mode specified (M-form request) ; $ARGER Missing argument ; ;- .PSECT SYS$I,I JREAD:: MOV #1,R1 ;Set asynch flag (wait mode) BR $JRD ; and join common JREADx code JREADC:: MOV #$NOARG,R1 ;Indicate completion routine required BR $JRD ; and join common JREADx code JREADW:: CLR R1 ;Reset asynch flag (non-wait mode) .BR $JRD ; and join common JREADx code $JRD: MOV #,R2 ;R2 = Read function code BR $JRWRT ; and join common code JWRITE:: MOV #1,R1 ;Set asynch flag (wait mode) BR $JWRT ; and join common JWRITx code JWRITC:: MOV #$NOARG,R1 ;Indicate completion routine required BR $JWRT ; and join common JWRITx code JWRITW:: CLR R1 ;Reset asynch flag (non .BR $JWRT ; and join common JWRITx code $JWRT: MOV #,R2 ;R2 = Write function code BR $JRWRT ; and join common code .SBTTL $JRWRT - Common code ; Common code for all J%%%%% routines. Enter with two words on stack-- ; the SPFUN code in high byte of first word, and the completion routine ; argument in the second word. .ENABL LSB $JRWRT:: MOV #$CNFG1,R0 ;R0 = RMON Fixed offset to fetch CALL $GVAL ;Get contents of config word 1 BIT #KT11$,R0 ;Running under XM? BEQ 10$ ;Nope... ; When running under XM, AT handler should be loaded MOV #$CNFG3,R0 ;R0 = RMON Fixed offset to fetch CALL $GVAL ;Get contents of config word 3 BIT #CF3.AT,R0 ;Is AT available? BNE 10$ ;Yes...(optional handler under V5.5, ; inherent support in V5.6 monitor) ; indicate error and exit ... MOV #AT.ERR,R0 ;Indicate error = "AT not available" BR 90$ 10$: MOV (R5)+,R4 ;R4 (low byte) contains argument count SUB #L.SPFU,SP ;Make room on stack for EMT area MOV R2,A.SPFU(SP) ;Place function/type in EMT area MOV SP,R2 ;R2 -> Function/type word in EMT area ADD #A.SPFU,R2 ; ... ; Arguments to call are in an order which permit loading of ; the EMT area in reverse order beginning with word count CALL $NXVAL ;Get word count BCS ERR1 ;Required argument... MOV R0,-(R2) ;Place in EMT area CALL $NXADR ;Get buffer address BCS ERR1 ;Required argument... MOV R0,-(R2) ;Place in EMT area CALL $NXADR ;Get address of JBLK BCS ERR1 ;Required argument... MOV R0,-(R2) ;Place in EMT area CALL $NXVAL ;Get channel BCS ERR1 ;Required argument... MOV R0,-(R2) ;Place in EMT area ; Do .CSTAT to determine how appropriate this request is. MOV R0,R2 ;save 'chan' also in R2 SUB #<6*2>,SP ;allocate .CSTAT info block MOV SP,R3 ;save pntr in R3 BIC -(SP),-(SP) ;allocate .CSTAT arg block .CSTAT SP,R2,R3 ;get channel status BCC 20$ ;successful .CSTAT, continue ; indicate error for .CSTAT failure and exit ;force .CSTAT failure to be -3, MOV #CH.ERR,R0 ; 'channel is not open' ; to align with SPFUN failure BR 70$ ; Check .CSTAT info to see whether channel is open to a FILE, rather ; than to a DEVICE (non-file-structured). 20$: TST CS.SBK(R3) ;is channel open as a device ? BEQ 30$ ;yes, then continue MOV #DEV.ERR,R0 ;indicate error 'channel open to file' BR 70$ ; Do DSTAT on handler, to make sure that it's the MSCP disk 30$: MOV SP,R4 ;Point to available space ADD #CS.NAM,R3 ;Point to handler name .DSTAT R4,R3 ;Use the CSTAT block again BCS 70$ ;* should never happen * CMPB @SP,#DEV.DU ;Is this DU? BEQ 40$ ;Yes... MOV #ID.ERR,R0 ;Nope, report error... BR 70$ 40$: CALL $NXADR ;Get area argument ; and ignore it... CMP R1,#2 ;Is completion routine needed? BLO 50$ ;Nope... CMP R1,#$NOARG ;Has it been specified? BNE 55$ ;Yes, must be an -F form call, ; can't use I&D space in -F call ; BMODE and CMODE are rejected ; in module JRDWRF CALL $NXADR ;Nope, get it... BCS ERR1 ;Required argument... MOV R0,R1 ;R1 -> Completion routine 50$: CALL $BCMOD ;Process BMODE and CMODE arguments BCS 70$ ;Invalid argument, ; error code value (-19.) in R0 BIS (SP)+,<10*2+A.SPFU> ;Merge mapping mask with function 55$: ; Move the user's block number to a local 4-word block/status block on ; the stack. Change the SPFUN's BLK address to point to it. MOV #JRWBLK,R3 ; point to static status block MOV <10*2+A.BLK>(SP),R4 ; get SPFUN's BLK address MOV R3,<10*2+A.BLK>(SP) ; replace it with our local copy MOV (R4)+,(R3)+ ; get user's 32-bit block number MOV (R4)+,(R3)+ ; put it in 1st two words ; Do the SPFUN read/write MOV SP,R4 ;R4 -> SPFUN EMT block ADD #<10*2>,R4 ; on stack .SPFUN R4,CRTN=R1 ;Issue the request BCC 60$ ;Successful... CALL $ERRM0 ;Get and convert any errors BR 70$ ; and return... 60$: CLR R0 ;Normal success TST A.SRTN(R4) ;Wait mode request? BNE 80$ ;Nope, return zero... MOV JRWBLK+4,R0 ;Yes, return number of words transferred BR 70$ ERR1: MOV #$ARGER,R0 ;Most argument errors exit here BR 80$ 70$: ADD #<<2+6>*2>,SP ;Dump CSTAT EMT area and info block 80$: ADD #,SP ;Dump the SPFUN EMT area 90$: RETURN ;to user program. .DSABL LSB .SBTTL Static data area .PSECT SYS$S,D JRWBLK: .BLKW 4 ; status block for SF.x32 .END