.TITLE LEnable Aleda Unit Enable .PSECT Aleda,Gbl,Con .Dsabl GBL ;;********************************************************************** ;; Fortran callable subroutine to enable the specified Alvin unit # ;; for transfer of characters to the user specified circular buffer. ;; ;; Supports calls of the form: ;; Ierror = LEnabl ( Unit #, Buffer, Buffer Size, Return Code, ;; c Control Word, CSR, Vector, Assoc. Unit) ;;********************************************************************** ;; Last Modified: 8-May-84 DVJensen - Unit passed to AlvEna in DevDesc. ;; 18-Jul-85 DVJ - If the user does not provide a buffer, the Default ;; buffer desc remains as setup in the device table. ;; 17-Sep-85 DVJ - Working on Version 5.1c: TSX CL support, incorporating ;; dynamic adjustment to RT or TSX environments. ;; 4-Oct-85 DVJ - Return new AlvEnable errors, Setup new DEFAULT BUFFER ;; after the enable so the previous default is retained. ;; 30-Oct-85 DVJ - Using the new AlvEnable convention that the unit number ;; is passed in register 3. It is now Jsr PC, AlvEna . ;;********************************************************************** ;; .Mcall $Alv51 .Globl AlvEnable, AlvUpdate, GetDDA, GetParm ;External Globals $Alv51 ;; Control Word Bits - If set they indicate: ;;********************************************************************** LEnable:: MOV R5,-(SP) ;SAVE REGISTERS USED MOV R4,-(SP) MOV R3,-(SP) MOV R2,-(SP) MOV R1,-(SP) Clr Return ;Initialize Variables ;Fortran Calling Convention: Clr R0 ;Set for counting the parameters Mov (R5)+,R1 ;Get number of parameters passed. Bic #177400,R1 ;Clear possible high order junk Jsr PC,GetParm ;Get Parm # 1: Logical Unit number. Bcs EnaError ;Required Parm - Abort if not provided. Mov (R4),R3 ;Get the actual unit number Mov R3,Unit ;Save it Clr Buffer ;Default buffer descriptor to zero. Jsr PC,GetParm ;Get Parm # 2: Circular Buffer. Bcs Getp3 ;Optional Parm - Continue if not provided. Mov R4,Buffer ;Save pointer to the buffer region. Getp3: Clr Bufsize ;Default buffer size to zero. Jsr PC,GetParm ;Get Parm # 3: Circular Buffer Size. Bcs Getp4 ;Optional Parm - continue if not provided. Mov (R4),BufSize; Save the SIZE. Getp4: Jsr PC,GetParm ;Get Parm # 4: Return Code Location. Bcs Getp5 ;Continue if not available (defaulted above) Mov R4,Return ;Save the address to return the code to. Getp5: Clr Control ;Default Control Word to zero (optional). Jsr PC,GetParm ;Get Parm # 5: Control Word. Bcs Getp6 ;Continue if not available Mov (R4),Control ;Save the Control Word value. Getp6: Clr CSR ;Default CSR to zero (actual default CSR ; comes from the Device Desc Template) Jsr PC,GetParm ;Get Parm # 6: Control and Status Register Adr Bcs GetP7 ;Continue if not provided. Mov (R4),R2 Cmp R2,#160000 ;Check to see if CSR is in the I/O page. Blo CsrError ;If not, return an error. Mov R2,CSR ;Save the CSR address. Getp7: Clr NewVector ;Default Vector to zero (actual default vector ; comes from the Device Desc Template) Jsr PC,GetParm ;Get Parm # 7: Vector Address. Bcs Getp8 ;Continue if not available. Mov (R4),R2 Cmp R2,#1000 ;Is the Vector below address 1000 octal? Bhis VecError ;No, error. Cmp R2,#60 ;Is the Vector above octal address 60? Blo VecError ;No, error. Mov R2,NewVector ;Save the Vector Address. Getp8: Br EnaGO ;;**************************** CsrError: Mov #23.,R0 ;Put error code for invalid csr in R0. Br EnaError VecError: Mov #24.,R0 ;Put error code for out of range vector in R0. Br EnaError ;;**************************** EnaError: ;Error occurred - Code is in R0 Neg R0 ;Force return value negative to indicate error Sec ;For RT error convention. Jmp EnaRtn ; and Return. ;;**************************** ;; EnaGO: Jsr R5,GetDDA ;Get the Device Descriptor Address .Word -1 ;Requested unit is already in Register 3. Tst R0 ;Check if this was a valid unit number Bne EnaBD ;Proceed if non-zero. Ena1Err: Mov #20.,R0 ;Return Error Code #20. - No Descriptor. Br EnaError ;Return error. EnaBD: Mov R0,R2 ;Save the Device Desc Address. Bit #Disabled,(R2) ;Is this device currently disabled? Bne Ena100 ;Yes, branch - OK to enable it. Mov #22.,R0 ;No, return error #22. Br EnaError Ena100: Mov CSR,R1 ;Get user specified CSR. Beq Ena110 ;If zero, use CSR currently in DD. Mov R1,DevAdr(R2) ;Put it in the Dev Desc. Ena110: Mov NewVector,R1 ;Get user specified Vector. Beq Ena120 ;If zero, use Vector currently in DD. Mov R1,Vector(R2) ;Put it in the Device Descriptor. Ena120: Mov Buffer,R4 ;Get the default buffer address Beq Ena140 ;Branch if it is zero - there is none. Bit #1,R4 ; Is this an odd address? Beq Ena125 ; No, branch Inc R4 ; Yes, advance to next word boundary. Mov R4,Buffer ; Save what is being used. Tst Bufsiz ; Adjust the size of the buffer if not zero. Beq Ena139 ; If zero, then the buffer desc is setup. Dec BufSize ; Reduce the size of the buffer by one. ; Mov #31.,R0 ;Error code #31. - buffer not word alligned. ; Br EnaError Ena125: Mov BufSiz,R1 Beq Ena139 ; If zero, presume the buffer desc is set. Cmp R1,#20. ; Check to see if is big enough (20 bytes). Bhis Ena127 ; Branch if ok. Mov #30.,R0 ;Set error code Br EnaError ;Return error code #30. Ena127: Mov R4,R0 ;Start of the buffer descriptor. Add R0,R1 ;End address of the buffer ( +1 ) Dec R1 ; actual end address of the buffer. Add #12.,R0 ;Actual Start of character storage. Mov R0,(R4)+ ;Input pointer Mov R0,(R4)+ ;Output pointer Mov R0,(R4)+ ;Start address of buffer Mov R1,(R4)+ ;End Address of buffer Clr (R4) ;Buffer Status (not currently used) Ena139: Ena140: Mov Lunit(R2),R3 ; Get unit number of the device to be enabled. Jsr Pc,AlvEna ; Have Alvin enable the device. Bcs EnaRtn ; If carry set, return the code from Alvena. Mov Buffer,R4 ; Is there a new default buffer? Beq Useold Mov R4,BDefault(R2) ; Yes, it can be moved in now. Useold: Clr R0 ;Return code = Zero and Carry is clear. ;;**************************** EnaRtn: Mov Return,R1 ;Did the user specify to return the error code? Beq EnaExit ;No, exit. Mov R0,(R1) ;Return code to user location. EnaExit: MOV (SP)+,R1 MOV (SP)+,R2 MOV (SP)+,R3 MOV (SP)+,R4 MOV (SP)+,R5 RTS PC ;AND RETURN ;;**************************** Unit: .Word 0 ;Unit number to enable. Buffer: .Word 0 ;Address of User's Circular Buffer. BufSize: .Word 0 ;Size of the Circular Buffer. Return: .Word 0 ;Address of User's Location for Return Code. Control: .Word 0 ;User specified control word. CSR: .Word 0 ;User specified device CSR address. NewVect: .Word 0 ;User specified device vector. ;+ ;;************************************************************************** .Psect Aleda,Con,Gbl ;; ;; GetParm - Subroutine to Get the Next Parameter from the Fortran call list. ;; Assumes R1 contains the count of parms passed by the calling routine, and ;; R5 points to the next paramter in the list. ;; R0 is incremented for each call to GetParm. ;; R1 is decremented for each call to GetParm. ;; On return, CARRY is SET if the Parm is not available, CLEAR if available. ;; R5 is auto-incremented to the next parameter, and ;; R4 contains the address of the parameter (if it exists). ;- GetParm:: Inc R0 ;Count the Number of Parms processed. Dec R1 ;Count down number of parms passed. Blt GetPError ;If no Parm defined defined, then ERROR. Mov (R5)+,R4 ;Get the pointer to the parm. Cmp #-1,R4 ;Was this parm specified in the call list? Beq GetPError ;No, then return an indicator (may default). Clc ;Yes, Address of Parm now is Reg 4. Rts PC ;Return success. GetpError: Sec ;Error indicator is carry set. Rts PC ;Return - No parm. ;;**************************************************************************** .END