         PCC      0
*M*      HOTAVR  THE AUTO-AVR MODULE
         DEF      HOTAVR:
*P*      NAME:    HOTAVR
*P*      PURPOSE: TO PERFORM AUTOMATIC VOLUME RECOGNITION ON ANY
*P*               TAPE OR DISK DRIVES THAT ARE BROUGHT TO "READY"
*P*               STATUS AND ARE EITHER EMPTY OR SOLICITED.
         SPACE    3
         SYSTEM   SIG9P
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
R8       EQU      8
R9       EQU      9
R10      EQU      10
R11      EQU      11
R12      EQU      12
R13      EQU      13
R14      EQU      14
R15      EQU      15
         SPACE    3
         REF      TSTACK
         REF      DCT3         FOR 'PARTITIONED' FLAG
         REF      DCT5              FOR 'DEVICE BUSY' BIT
         REF      DCT24             CHECK FOR MPC TAPE
         REF      S:GUIS            TO SEE IF THE SYSTEM'S AWAKE YET
         REF      T:GJOBSTRT        TO START KEYIN GHOST
         REF      UB:US             TO SEE IF KEYIN'S RUNNING
         REF      SNULL                DITTO
         REF      AVRTBL            TO CHECK SERIAL #
         REF      BATAPE            DCT INDEX OFFSET
         REF      AVRTBLSIZ         # OF TAPES IN SYSTEMT
         REF      AVRTBLNE          SIZE OF AVR TABLES
         REF      SOLICIT           DRIVE BEING SOLICITED
         REF      DCT1P             TO GET UNIT ADDRESS OF DRIVE
         REF      AVRDCT            DCT # OF DRIVE TO AVR (FOR KEYIN)
         REF      TAPEFLGS          TAPE-AVR FLAGS IN TABLES:
         REF      OCDCT             DCT INDEX OF THE CONSOLE
         REF      Y04               X'04000000' - TAPE AT LOAD POINT
         TITLE    'HOTAVR -- AUTOMATIC AVR INITIATION'
*D*      NAME:    HOTAVR
*D*      DESCRIPTION:  HOTAVR INITIATES AUTOMATIC VOLUME RECOGNITION
*D*               (AVR) PROCESSING ON ANY TAPE DRIVE THAT MEETS
*D*               THE FOLLOWING QUALIFICATIONS:
*D*
*D*               (1) THE DRIVE IS EMPTY (AVRTBL<WORD 1> = 0) OR
*D*                   THE DRIVE IS BEING SOLICITED (SOLICIT = 1);
*D*               (2) THE DRIVE IS POSITIONED AT LOAD POINT (TAPES);
*D*               (3) THE UNIT IS WRITE-PROTECTED (TAPES);
*D*               (4) AN SIO IS POSSIBLE ON THE DRIVE;
*D*               (5) THE DRIVE IS IN 'AUTOMATIC' STATUS;
*D*               (6) AVR WASN'T ATTEMPTED ON THE DRIVE "RECENTLY"
*D*                   (I.E., SINCE THE LAST TIME CONDITIONS 1 - 5
*D*                   BECAME TRUE);
*D*               (7) THE DRIVE ISN'T AN MPC TAPE OR DISK UNIT;
*D*               (8) THE DRIVE ISN'T DOWN (PARTITIONED VIA DCT5, OR
*D*                   :REMOVED VIA DCT24);
*D*               (9) THE DRIVE DOESN'T HAVE ITS "I/O DEFERRED" BIT
*D*                   (X'04' IN DCT5) SET.
*D*
*D*                  IF ALL OF THE ABOVE ARE TRUE, HOTAVR STORES THE DCT
*D*               INDEX OF THE DRIVE INTO LOCATION "AVRDCT", AND CALLS
*D*               T:GJOBSTRT TO WAKE UP KEYIN (WHICH PERFORMS THE
*D*               ACTUAL AVR PROCESSING).
*D*
*D*                 HOTAVR WILL BE CALLED EVERY 1.2 SECONDS BY
*D*               CLOCK4 IF IT WAS INCLUDED IN THE SYSTEM BY THE
*D*               PRESENCE OF THE '(HOTAVR)' OPTION ON THE :MON
*D*               CARD DURING SYSTEM GENERATION (PASS2).  HOTAVR
*D*               PROCESSING WILL BE SKIPPED IF THE KEYIN GHOST
*D*               JOB IS RUNNING AND/OR THE OPERATOR'S CONSOLE
*D*               IS BUSY.
*D*
*D*                 IT IS *STRONGLY* SUGGESTED THAT SITES CHOOSING
*D*               THE HOTAVR FACILITY PATCH BIT 29 (X'4') OF
*D*               S:OPTION TO A 1.  THIS SELECTS A MUCH FASTER
*D*               VERSION OF THE AVR SEQUENCE (A SERIES OF TAPE
*D*               POSITIONING OPERATIONS IS SKIPPED) WHICH WILL
*D*               MAKE HOTAVR PERFORM MUCH MORE EFFICIENTLY.  THIS
*D*               VERSION IS NOT COMPLETELY BACKWARD-COMPATABLE WITH
*D*               THE STANDARD VERSION - IT CANNOT SUCCESSFULLY AVR
*D*               ANY TAPES WITH DATA OF ANY SORT WRITTEN BEFORE THE
*D*               :LBL RECORD (I.E., PO BOOT TAPES AND CERTAIN OLDER
*D*               LABELLED TAPES);  IT WILL, HOWEVER, PREVENT THE
*D*               TAPE DRIVES FROM RUNNING AWAY IF AN UNLABELLED TAPE
*D*               WITH A LARGE FIRST FILE IS AVR'ED, AND WILL HAVE
*D*               NO ADVERSE EFFECTS ON LABELLED TAPE HANDLING VIA
*D*               THE !MOUNT KEYIN.
*D*
*D*      PROGRAMMER:  D. PLATT.  MODULE DESIGN TAKEN FROM A PATCH
*D*               IMPLEMENTING A SIMILAR FUNCTION, WRITTEN BY K. PAUL
*D*               AND D. PLATT AT RIT; ADAPTED FOR CP-V UMOV BY PUTTING
*D*               IT ON A PIECE OF WOOD AND BANGING A FEW NAILS THROUGH
*D*               IT.
         PAGE
HOTAVR:  EQU      %                 PATCHING DE
         PSW,R11  TSTACK            SAVE RETURN ADDRESS
         LW,R1    S:GUIS            HOW MANY GHOSTS?
         CI,R1    3                 AT LEAST RBBAT/ALLOCAT/FIX?
         BL       HOTEND            IF NOT DON'T DO ANYTHING
         LI,R1    1                 KEYIN'S USER #
         PSW,R1   TSTACK            SET TO "DON'T GOOSE KEYIN"
         LB,R1    UB:US,R1          KEYIN'S STATE
         CI,R1    SNULL             IS KEYIN DOING SOMETHING?
         BNE      HOTCHEK           IF SO DON'T STOMP ON IT
         LI,R1    OCDCT             DCT INDEX OF CONSOLE
         LB,R1    DCT5,R1           GET DCT5 FOR THE CONSOLE
         CI,R1    X'80'             DEVICE BUSY?
         BANZ     HOTCHEK           IF SO DON'T GOOSE
         MTW,0    AVRDCT            SOMETHING THERE NOW?
         BNEZ     HOTCHEK           IF SO, DON'T STOMP.
         MTW,-1   *TSTACK           CLEAR THE "DON'T GOOSE GHOST" FLAG
HOTCHEK  LI,R1    AVRTBLNE          GET # OF UNITS TO CHECK
HOTLOOP  AI,R1    -1                GET NEXT TAPE DRIVE INDEX
         BLZ      HOTEXIT           IF NO MORE, GO EXIT
         LW,R3    R1
         SLS,R3   1                 SHIFT FOR A DBLWD DISPLACEMENT
         MTW,0    AVRTBL+1,R3       IS THIS A PUBLIC UNIT?
         BLZ      HOTSET            IF SO BLIP IT OUT
         MTW,0    AVRTBL,R3         IS THERE A SERIAL # THERE?
         BEZ      TRYIT             IF NOT, THIS ONE'S A POSSIBILITY
         MTB,0    SOLICIT,R1        IF THERE IS - IS IT SOLICITED?
         BEZ      HOTSET            IF NOT, IT'S IN USE - BLIP OUT.
TRYIT    SLS,R3   -1
         AI,R3    BATAPE            GET DCT TABLE INDEX
         LB,R5    DCT24,R3          GET DCT24 FOR MPC TEST
         CI,R5    X'46'             IS THIS AN MPC DEVICE, OR REMOVED?
         BANZ     HOTSET            IF SO KEEP HANDS TO SELF.
         LB,R5    DCT3,R3           GET DCT3 ENTRY FOR DRIVE
         CI,R5    X'20'             IS DRIVE DOWN?
         BANZ     HOTSET            IF SO, LEAVE IT ALONE.
         LB,R5    DCT5,R3           GET DCT5 ENTRY FOR UNIT
         CI,R5    X'04'             I/O DEFERRED ON THIS ONE?
         BANZ     HOTSET            IF SO, KEEP HANDS OFF.
         LH,R2    DCT1P,R3          GET HARDWARE ADDRESS
         LCI      0                 CLEAR CC3 FOR SIG 5/6/7
         TIO,R5   0,R2              CHECK OUT THE UNIT
         BCR,8    CC1RESET          IF CC1=0, MAYBE CAN TEST.
         BCR,4    HOTLOOP           CC1=1, CC2=0: SKIP THIS UNIT
         B        HOTCLEAR          CC1=1, CC2=1: UNIT NOT THERE, CLEAR.
CC1RESET BCS,2    HOTLOOP           CC1=0, CC3=1: STATUS NFG, SKIP UNIT
*                                   CC1=0, CC3=0: STATUS OK
         LC       R5                CHECK THE TIO STATUS A LITTLE..
         BCS,6    HOTCLEAR          IF NOT READY, UN-BLIP IT
         BCR,1    HOTCLEAR          IF MANUAL, UN-BLIP IT
         MTW,0    *TSTACK           ARE WE INHIBITING THE GHOST?
         BNEZ     HOTLOOP             IF SO GO EXAMINE NEXT DRIVE
         CI,R1    AVRTBLSIZ         IS THIS A DISK DRIVE?
         BG       AVRTEST           IF SO SKIP LOADPOINT/WRT PRT CHECKS
         LCI      0                 CLEAR CC3
         TDV,R5   0,R2              LOOK AT THE DEVICE NOW...
         BCR,8    CC1REST           IF CC1=0, MAYBE STATUS IS GOOD
         BCR,4    HOTLOOP           CC1=1, CC2=0: SKIP THIS UNIT
         B        HOTCLEAR          CC1=1, CC2=1: UNIT NOT THERE, CLEAR.
CC1REST  BCS,2    HOTLOOP           CC1=0, CC3=1: STATUS NFG, SKIP UNIT
*                                   CC1=0, CC3=0: STATUS OK, EXAMINE
         LC       R5                IS IT WRITE PROTECTED?
         BCS,4    HOTSET            IF NOT, BLIP IT OUT
         CW,R5    Y04               IS IT AT LOAD POINT?
         BAZ      HOTSET            IF NOT, BLIP IT OUT.
AVRTEST  LD,R6    DSET              MAKE THE SAMPLING MASK
         SLD,R6   0,R1              .. BY SHIFTING THINGS A LITTLE
         AND,R6   TAPEFLGS          CHECK THE TWO WORDS OF
         AND,R7   TAPEFLGS+1        .. THE TAPE FLAG DOUBLEWORD
         OR,R6    R7                IF THE BIT IN QUESTION IS ON,
         BNEZ     HOTLOOP           .. WE ALREADY LOOKED AT THIS UNIT.
         STW,R3   AVRDCT            SAVE ITS INDEX FOR KEYIN;
AVRGOOSE PSW,R1   TSTACK             SAVE THE LOOP INDEX;
         LD,R0    KEYIN               GET TEXTC 'KEYIN';
         BAL,R10  T:GJOBSTRT           TRY TO START THE GHOST;
         STCF     R0                    SAVE THE START-GHOST CC'S;
         PLW,R1   TSTACK               RESTORE THE LOOP INDEX;
         MTW,1    *TSTACK                 SET GOOSE-INHIBIT FLAG
         LCF      R0                  RESTORE THE START-GHOST CC'S;
         BCR,8    HOTSET             AND BLIP OUT THE DRIVE IF WE SUCCEEDED
         LI,R1    0                 WE FAILED - WIPE OUT
         STW,R1   AVRDCT              AVRDCT TO AVOID PROBLEMS,
HOTSET   LD,R6    DSET              GET THE SET-A-BIT MASK
         SLD,R6   0,R1              .. AND SHIFT THE BIT INTO POSITION
         OR,R6    TAPEFLGS          "OR" IN THE FIRST WORD OF THE FLAGS,
         OR,R7    TAPEFLGS+1        .. AND THEN THE SECOND WORD
         STD,R6   TAPEFLGS          RESTORE THE TAPE FLAGS
         B        HOTLOOP           AND GO BACK FOR MORE
HOTCLEAR LD,R6    DCLEAR            GET CLEARING MASK
         SCD,R6   0,R1              MOVE THE HOLE INTO POSITION
         AND,R6   TAPEFLGS          MASK THE FIRST WORD
         AND,R7   TAPEFLGS+1        MASK THE SECOND WORD
         STD,R6   TAPEFLGS          RESTORE TAPE FLAGS
         B        HOTLOOP           AND GO TRY ANOTHER DRIVE
         SPACE    3
HOTEXIT  PLW,R11  TSTACK            REMOVE GHOST-INHIBIT FLAG
HOTEND   PLW,R11  TSTACK            REMOVE RETURN ADDRESS
         B        *R11              GO HOME TO CLOCK4
         PAGE
         BOUND    8
DSET     DATA,8   1                 DOUBLEWORD SELECTOR BIT
DCLEAR   DATA,8   -2                DOUBLEWORD CLEARING BIT
KEYIN    TEXTC    'KEYIN'
         END

