*M*      HANDLER FOR MPC DISC DRIVES
 TITLE '*** M P C   D I S C   D R I V E   H A N D L E R ***'
*
*
         SYSTEM   UTS
         PAGE
*
*        DEFS
*
MPCDIO:  EQU      %                 PATCHING SYMBOL FOR XDELTA
*
         DEF      MPCDIO:,MPCDIO,MPCDCU
*
*        REFS
*
         REF      M3,M4,M6,M16,M24
         REF      DCT19
         REF      Y2,Y8,Y08,YFF
         REF      NBYT2
         REF      DCT1P,DCT1A,DCT7,DCT12,DCT13,DCT17
         REF      IOQ3,IOQ4,IOQ5,IOQ8,IOQ9,IOQ11,IOQ12
         REF      IOSERCK,IOSST,IOSCU,RE:ENT,ERRLOG
         REF      COMLIST
         REF      RECIOERR
         REF      RESCHED
         REF      M:RDCK
         REF      MSG2
         PAGE
*
*        REGISTER DEFINITIONS
*
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
         PAGE
*
*        MISCELLANEOUS EQUATES
*
OPER     EQU      0
RTRY     EQU      1
NORM     EQU      2
NORME    EQU      3
ERRRET   EQU      4
SENSEBUF EQU      IDCWOFF-2         OFFSET IN CLIST FOR SENSE BUFFER
IDCWOFF  EQU      8                 DBL-WORD OFFSET FROM BASE OF CLIST
CC       EQU      X'2E'             CHAIN,HTE,IUE,SIL BITS
NCC      EQU      X'1E'             HTE,IUE,SIL NO CHAINING
DINT     EQU      X'0E'             DEVICE INTERRUPT FLAGS
         PAGE
*
*        IDCW DEVICE INSTRUCTIONS
*
REQST    EQU      0                 REQUEST STATUS
RDNS     EQU      4                 READ NON-STANDARD
BOOTCS   EQU      8                 BOOT C/S
BOOTITR  EQU      9                 BOOT ITR
WCR      EQU      14                WRITE CONTROL REGISTER
FORM     EQU      15                FORMAT
RDEDAC   EQU      17                READ EDAC
RDSTREG  EQU      18                READ STATUS REGISTER
RDASCII  EQU      X'13'             READ ASCII
RD       EQU      X'15'             READ
RDCR     EQU      X'16'             READ CONTROL REGISTER
RDHDR    EQU      X'17'             READ HEADER
EXDLI    EQU      X'18'             EXECUTE DLI
WRT      EQU      X'19'             WRITE
WASCII   EQU      X'1A'             WRITE ASCII
WRTCOMP  EQU      X'1B'             WRITE AND COMPARE
SK       EQU      X'1C'             SEEK
SPCSK    EQU      X'1E'             SPECIAL SEEK
PRESK    EQU      X'1F'             PRE-SEEK
RESTAT   EQU      X'20'             RESET STATUS
RESTORE  EQU      X'22'             RESTORE CARRAIGE
EXMDR    EQU      X'30'             EXECUTE MDR
STNDBY   EQU      X'3A'             SET STANDBY
RELEASE  EQU      X'3E'             RELEASE
RESERVE  EQU      X'3F'             RESERVE
         PAGE
:DOT     CNAME
         PROC
         DO1      NUM(LF)=1
LF(1)    EQU      %-DOT
         GEN,8,8,8,8    BA(AF(1))-BA(DOT),AF(2),AF(3),AF(4)
         PEND
*
*        DOT TABLE FOR MPC DISC
*
         BOUND    8
DOT      EQU      %                 SET FOR PROC ADDRESSING
*
SEEKREAD :DOT     A1,1,DESEN,RDON   00 = SEEK THEN READ
SEEKWRT  :DOT     A1,1,DESEN,WTON   01 = SEEK THEN WRITE
SENSE    :DOT     C1,1,SENSE,0      02 = EXTERNAL CALLERS SENSE
RDON     :DOT     D1,1,DESEN,COMPARE  03 = READ AFTER SEEK COMPLETE
WTON     :DOT     E1,1,DESEN,COMPARE  04 = WRIT AFTER SEEK COMPLETE
DESEN    :DOT     F1,1,DESEN,DEREST 05 = INTERNAL SENSE FOR ERROR LOG
DEREST   :DOT     G1,1,DEREST,0     06 = RESTORE CARRAIGE/THEN ORIG FUNC
COMPARE  :DOT     E1,1,DESEN,0      07 = COMPARE AFTER READ OR WRITE
         PAGE
:CLIST   CNAME
         PROC
         DO1      NUM(LF)=1
LF(1)    EQU      BA(%)
         LOCAL    I
I        DO       NUM(AF)
         DATA,1   DA(AF(1))-DA(DOT)
         FIN
         PEND
*
*        COMMAND LISTS FOR MPC
*
A1       :CLIST   PRESEEK           INITIAL OP TO PASS IDCW SEEK COM
         :CLIST   SKPASS            OP TO PASS SECTOR NUM TO MPC
C1       :CLIST   SENCDW            EXTERNAL SENSE OPERATION
D1       :CLIST   SEEK              PASS IDCW FOR SEEK COMMAND
         :CLIST   SKPASS2           PASS SECTOR NUMBER ITSELF
         :CLIST   CONTRL            PASS READ IDCW
         :CLIST   READ              SIGMA READ CDW
         :CLIST   STOP              AUTO-RCVRY STOP ORDER
         :CLIST   TIC               TIC BACK TO CONRD FOR AUTO-RCVRY
E1       :CLIST   SEEK              PASS IDCW FOR SEEK OP
         :CLIST   SKPASS2           PASS SECTOR NUMBER
         :CLIST   CONTRL            PASS WRITE IDCW
         :CLIST   WRITE             SIGMA WRITE CDW
         :CLIST   STOP              AUTO-RCVRY STOP ORDER
         :CLIST   TIC               TIC BACK TO CONWRT FOR AUTO-RCVRY
F1       :CLIST   INTSEN            INTERNAL SENSE OPERATION
G1       :CLIST   CENTS             RESTORE CARRAIGE
         PAGE
:CDW     CNAME
         PROC
         BOUND    8
LF       GEN,8,24,8,8,8,8     AF(1),AF(2),AF(3),X'80',AF(4),AF(5)
         PEND
*
*        CANNED COMMAND DOUBLE-WORDS FOR MPC DISC
*
PRESEEK  EQU      SEEK              SEND PRESEEK IDCW
SKPASS   :CDW     1,SKSETUP,DINT,4,5  PASS SEEK ADDRESS
CENTS    :CDW     3,CENSOR,NCC,4,5  PASS IDCW TO RESTORE CARRAGE
ALLSTOP  :CDW     X'B0',0,NCC,0,0
SEEK     :CDW     3,0,CC,0,5
SKPASS2  :CDW     1,0,CC,0,5
CONTRL   EQU      SEEK              SEND OPERATION IDCW
READ     :CDW     2,0,CC,2,0        ACTUAL TRANSFER
STOP     :CDW     X'B0',SETUP,NCC,4,0
TIC      DATA     X'08000000',0
WRITE    :CDW     1,0,CC,2,0        ACTUAL TRANSFER
SENCDW   :CDW     4,EXT:SEN,NCC,4,5
INTSEN   :CDW     4,INT:SEN,NCC,4,5 INTERNAL SENSE
         PAGE
*
*        IDCW PICTURE
*
*0       *6        *12      *18  *21 * 22 * 23 *24           *30-->63
*--------*---------*--------*----*---*----*----*-------------*---->
*        *         *        *    *   *    *    *             *    >
* DEVICE * DEVICE  * MBZ    * 7  * M * C  * M  * CHANNEL     * S  >
* INST   * ADDRESS * FIELD  *    * A * O  * A  * INST        * P  >
* FIELD  * FIELD   * AREA   *    * S * N  * R  * FIELD       * I  >
*        *         *        *    * K * T  * K  *             * L  >
*        *         *        *    *   *    *    *             *    >
*--------*---------*--------*----*---*----*----*-------------*---->
         PAGE
:IDCW    CNAME
         PROC
         BOUND    8
LF       SET      %
         GEN,6,6,6,3,1,1,1,6,10,24   CF(2),;  DEVICE COMMAND
                                         0,;  DEVICE ADDRESS
                                         0,;  MBZ
                                         7,;  MUST BE ALL ONES
                                         0,;  MASK FIELD
                                     AF(1),;  CONTINUE BIT
                                         0,;  MARK BIT
                                     AF(2),;  CHANNEL INSTRUCTION
                                         0,;  MBZ
                                         0    SPILL FOR SIGMA D/W
         PEND
*
*        IDCW STATIC DATA AREA
*
SEEKPRE  :IDCW,PRESK         0,X'11'       *CONTINUE
SEEKON   :IDCW,SK            1,X'11'
RDIT     :IDCW,RD            0,0
WRTIT    :IDCW,WRT           0,0
SENSIT   :IDCW,RESTORE    0,X'11'        RESTORE CARRAIGE
WRC      :IDCW,WRTCOMP    0,0       WRITE AND COMPAIRE IDCW
         PAGE
*************************************
* MISCELLANEOUS TABLES              *
*************************************
*
*        HANDLER POST-PROCESSING DECISION MAKER
*
*        I/O RECOVERY IS TABLE DRIVEN IN THAT I/O STATUS
*        IS EXAMINED TO CHECK FOR SOME TYPE OF ACTION TO
*        TO PERFORM.
*
:GNVCT   CNAME
         PROC
         DATA,1   AF-ERR
         PEND
*
:GENDAT  CNAME
         PROC
         LIST     0
         DO       AF(1)>0
         DO       AF(1)-P%-1
         DATA,1   ERRRET
         FIN
         ELSE
         FIN
         LIST     1
         DATA,1   AF(2)
P%       SET      AF(1)
         PEND
*
MAJ:STAT EQU      %
         :GNVCT   RDY                0 - READY
         :GNVCT   BSY                1 - BUSY
         :GNVCT   ATTN               2 - ATTENTION
         :GNVCT   DTALRT             3 - DATA ALERT
         :GNVCT   EOF                4 - END OF FILE
         :GNVCT   REJ                5 - INSTRUCTION REJECT
         :GNVCT   ERR                6 - ERROR
         :GNVCT   ERR                7 - ERROR
         :GNVCT   ERR                8 - ERROR
         :GNVCT   ERR                9 - ERROR
         :GNVCT   DATTN             10 - DEVICE ATTENTION
         :GNVCT   DDTALRT           11 - DEVICE DATA ALERT
         :GNVCT   ERR               12 - ERROR
         :GNVCT   CREJ              13 - COMMAND REJECT
         :GNVCT   ERR               14 - ERROR
         :GNVCT   ERR               15 - ERROR
         BOUND    4
*
*        TABLE OF SUB STATUS
*
ERR      EQU      %-1               ERROR
*
* - MAJOR STATUS OF READY -
*
RDY      EQU      %
         :GENDAT  0,NORM            NO SUBSTAT
         :GENDAT  1,NORME           RETRIES
         :GENDAT  2,NORME
         :GENDAT  3,NORME
         :GENDAT  4,NORM            DONT LOG BUFFERED RETRY
         :GENDAT  8,OPER            DEVICE IN T & D
         :GENDAT  9,OPER
         :GENDAT  X'A',OPER
         :GENDAT  X'B',OPER
         :GENDAT  X'10',NORME       DATA CORRECTED
         :GENDAT  X'3F',ERRRET      FILL OUT
*
* - MAJOR STATUS OF BUSY -
*
BSY      EQU      %
         :GENDAT  0,OPER            POSITIONING
         :GENDAT  X'20',OPER        ALTERNATE CHANNEL
         :GENDAT  X'3F',ERRRET      FILL OUT
*
* - MAJOR STATUS OF ATTENTION -
*
ATTN     EQU      %
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,OPER            WRITE INHIBIT
         :GENDAT  2,RTRY            SEEK INCOMPLETE
         :GENDAT  8,RTRY            DEVICE FAULT
         :GENDAT  X'10',OPER        DEVICE IN STANDBY
         :GENDAT  X'20',OPER        DEVICE OFF LINE
         :GENDAT  X'3F',ERRRET      FILL OUT
*
* - MAJOR STATUS OF DATA ALERT -
*
DTALRT   EQU      %
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,RTRY            TRANSFER  TIMEING
         :GENDAT  2,RTRY            PARITY
         :GENDAT  4,RTRY            INVALID SEEK ADDRESS
         :GENDAT  8,RTRY            HEADER VAR/CYCLIC CHK
         :GENDAT  X'10',RTRY        CYCLIC CHECKWORD ALERT
         :GENDAT  X'18',RTRY        HEADER VAR/CYCLIC CHK
         :GENDAT  X'20',RTRY        COMPARE ALERT
         :GENDAT  X'30',RTRY        CYCLIC CHK/CMP ALERT
         :GENDAT  X'38',RTRY        CYCLIC CHECK
         :GENDAT  X'3F',ERRRET      FILL OUT
*
*  - MAJOR STATUS OF END OF FILE -
*
EOF      EQU      %
         :GENDAT  0,NORME           GOOD TRACK
         :GENDAT  1,NORME           LAST CONSEC BLOCK
         :GENDAT  2,NORME           BLOCK COUNT LIMIT
         :GENDAT  3,NORME           LAST CONSEC/BLOCK COUNT
         :GENDAT  4,NORME           DEF TRACK - ALT ASSIGN
         :GENDAT  8,NORME           DEF TRACK - NO ALT
         :GENDAT  X'10',NORME       ALT TRACK DEF
         :GENDAT  X'3F',ERRRET      FILL OUT
*
* - MAJOR STATUS OF INSTRUCTION REJECT -
*
REJ      EQU      %
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,RTRY            INVALID OP CODE
         :GENDAT  2,RTRY            INVALID DEVICE CODE
         :GENDAT  4,RTRY            IDCW PARITY
         :GENDAT  8,RTRY            INVALID INSTRUCTION SEQUENCE
         :GENDAT  X'3F',ERRRET      FILL OUT
*
* - MJOR STATUS OF DEVICE ATTENTION -
*
DATTN    EQU      %
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,OPER            CONFIG ERROR
         :GENDAT  2,RTRY            MULTIPLE DEVICE
         :GENDAT  3,RTRY            DEVICE NO. ERROR
         :GENDAT  11,OPER           CA ERROR AND OPI DOWN
         :GENDAT  12,RTRY           ALERT N-1
         :GENDAT  13,RTRY           CA EN-1 ERROR
         :GENDAT  14,RTRY           CA ALERT (NO EN-1)
         :GENDAT  X'3F',ERRRET      FILL OUT
*
* - MAJOR STATUS OF DEVICE DATA ALERT -
*
DDTALRT  EQU      %
         :GENDAT  0,ERRRET          FILL OUT
         :GENDAT  1,RTRY            TRANSMISSION PARITY
         :GENDAT  2,RTRY            INCONSISTENT CMD
         :GENDAT  3,RTRY            SUM CHECK ERROR
         :GENDAT  4,RTRY            BYTE LOCKOUT
         :GENDAT  X'E',RTRY         EDAC PARITY
         :GENDAT  X'11',RTRY        SECTOR SIZE ERROR
         :GENDAT  X'12',RTRY        NONSTANDARD SECTOR SIZE
         :GENDAT  X'13',RTRY        SEARCH ALERT (1RST)
         :GENDAT  X'14',RTRY        CYCLIC CODE (1RST)
         :GENDAT  X'15',RTRY        SEARCH ALERT (NOT 1RST)
         :GENDAT  X'16',RTRY        SYNC BYTE ERROR
         :GENDAT  X'17',RTRY        ERROR IN ALT TRACK
         :GENDAT  X'19',RTRY        EDAC CORR - LAST SECTOR
         :GENDAT  X'1A',RTRY        EDAC CORR - NOT LAST SECTOR
         :GENDAT  X'1B',RTRY        EDAC CORR - B.C.L.
         :GENDAT  X'1C',RTRY        EDAC UNCORR
         :GENDAT  X'1D',RTRY        EDAC CORR - SHORT BLOCK
         :GENDAT  X'3F',ERRRET      FILL OUT
*
* - MAJOR STATUS OF MPC COMMAND REJECT -
*
CREJ     EQU      %
         :GENDAT  0,OPER            FILL OUT
         :GENDAT  1,OPER            ILLEGAL PROCEDURE
         :GENDAT  2,OPER            ILLEGAL L.C. NO.
         :GENDAT  3,OPER            ILLEGAL SUSPEND
         :GENDAT  4,OPER            CONTINUE BIT NOT SET
         :GENDAT  X'3F',ERRRET      FILL OUT
         PAGE
*
*        ACTION TABLES - ACTION TO TAKE UPON DETECTING PROPER
*        ERROR STATUS ENTRY
*
*        NOTE:    THERE ARE BASICLY 5 TYPES OF ERROR RECOVERY ACTION TO
*                 FOLLOW,IE;
*
*        1. ERROR LOG, REQUEST OPERATOR INTERVENTION AND WHEN HE
*           REPLIES ERROR WE QUIT OR REPLIES CONTINUE WE RETRY THE
*           OPERATION AGAIN.
*        2. PERFORM A SENSE TO STICK IN THE ERROR LOG AND RETRY THE
*           OPERATION AGAIN.
*        3. NORMAL COMPLETION OF THE I/O WITH A POSSIBLE INFO ONLY
*           ERROR LOG MSG PUT INTO THE LOG.
*        4. NORMAL COMPLETION OF THE I/O WITH A SENSE ENTRY STUCK
*           INTO THE ERROR LOG.
*        5. ERROR LOG ALL INFO AND ERROR RETURN TO THE USER DUE
*           AN UNCORRECTABLE ERROR FROM THE MPC. THIS TYPE ALOS
*           PUTS OUT AN ERROR MSG TO MAKE THE STATE OF THE MPC
*           VISIBLE TO THE EXTERNAL WORLD.
*
*        ACTION TABLES ARE INDEXED BY THE INDEX DERIVED FROM SEARCHING
*        THE SUB-STATUS TABLES.
*
ACTIONS  EQU      %
         B        OPER:HELP         00 = NEED OPERATOR'S HELP
         B        RETRY             01 = ERROR LOG / RETRY
         B        NORMAL            02 = NORMAL EXIT
         B        SEC:NORM          03 = ERROR LOG AND NORMAL EXIT
         B        ERROR             04 = ERROR EXIT
         PAGE
*
*        NORMAL ACTION VECTOR
*
NORMACT  EQU      %
         DATA,1   FOLLON-MPCDCU,;   00 - FOLLOW ON TO READ
                  FOLLON-MPCDCU,;   01 - FOLLOW ON TO WRITE
                  DONE-MPCDCU,;     02 - EXT SENSE COMPLETED
                  CHKRD-MPCDCU,;    03 - READ COMPLETE
                  CHKWRT-MPCDCU,;   04 - WRIT COMPLETED
                  SENSDONE-MPCDCU,; 05 - INTERNAL SENSE DONE
                  ORIG-MPCDCU,;     06 - RESTORE CARRAIGE DONE
                  DONE-MPCDCU       07 - COMPARE COMPLETE
         BOUND    4
         PAGE
*************************************
* FRONT END OF HANDLER              *
*************************************
*
*        FRONT END OF HANDLER CHECKS TO SEE IF ADDITIONAL HELP
*        IS REQUIRED FROM THIS MODULE OR JUST GO ON TO COMLIST
*        AND COME BACK AS REQUIRED.
*
MPCDIO   EQU      %                 PRE-PROCESSOR ENTRY POINT
         LI,R10   DOT               POINT TO DOT TABLE FOR COMLIST
         LB,R5    IOQ5,R3           GET CURRENT FUNCTION STEP
         BAL,R0   RE:ENT            IS THIS THE LAST ENTRY
         ENABLE
         EXU      FRONTACT,R5       DISPATCH ROUTINES
*
*        FRONT-END ACTIONS
*
FRONTACT EQU      %
         B        COMLIST           00 - SEEK FOR A READ
         B        COMLIST           01 - SEEK FOR A WRITE
         B        COMLIST           02 - EXTERNAL SENSE OP
         B        FRONTEND          03 - READ FOR COMPLETED SEEK
         B        FRONTEND          04 - WRIT FOR COMPLETED SEEK
         B        COMLIST           05 - INTERNAL SENSE FOR RCVRY
         B        COMLIST           06 - RESTORE CARRAIGE FOR RCVRY
         B        FRONTEND          07 - COMPARE AFTER WRITE COMPLETE
         PAGE
*************************************
* BACK END OF HANDLER               *
*************************************
*
*        POST-PROCESSING DECISION MAKER
*
MPCDCU   EQU      %
         BAL,R9   IOSERCK           CHECK FOR TIMEOUT / SIO REJECT
         B        RETRYA            ERR LOG ENTRY ALREADY MADE
         LW,R5    DCT12,R1          AIO STATUS BUCKET
         BLZ      NORMALA           DEVICE (PRESEEK) INT
*
         LB,R6    R5
         AND,R6   M6                ISOLATE SUB-STATUS
         LD,R8    DCT13,R1          TDV DW
         LB,R7    R9                TDV STATUS BYTE
         AND,R7   =X'6F'            STRIP STAY BITS
         AI,R7    -X'20'
         BEZ      FAST              TDV0-7,  001X0000 GOOD MAJOR STATUS
*
         CI,R7    X'E0'
         BANZ     MPCDCU1           TDV0-2,  NOT 001
         AND,R7   M4                ISOLATE NON ZERO MAJOR STATUS
         LB,R5    MAJ:STAT,R7       GET SUBSTATUS VECTOR
         BEZ      ERROR             ERROR
         AI,R5    ERR               POINT R5 TO SUBSTATUS TABLE
         LB,R4    *R5,R6            GET ACTION VECTOR
         EXU      ACTIONS,R4        AND EXECUTE
*
FAST     LB,R4    RDY,R6            GET SUB-STATUS FOR ZERO MAJOR STATUS
         EXU      ACTIONS,R4        GO TO SUB-STATUS VECTOR
*
MPCDCU1  AI,R7    X'20'
         BNEZ     RETRY             TDV0-2, NOT 000
*
         LB,R10   IOQ5,R3           CURRENT FUNCTION CODE
         CI,R10   DESEN             INTERNAL SENSE
         BE       NORMAL            YES-NORMAL
         CI,R10   SENSE             EXTERNAL SENSE
         BE       NORMAL            YES-NORMAL
*                                   DONT KNOW WHAT IT IS
*
*                                   FALL INTO OPER:HELP
         PAGE
*************************************
* POST PROCESSING ACTIONS           *
*************************************
*
* NEED OPERATOR HELP
*
OPER:HELP EQU     %
         BAL,R5   RECOORD           FILE A PRIMARY ERROR LOG MSG
         LI,R13   MSG2
         LI,R12   X'2800'           KEYIN REQUIRED
         B        IOSCU
*
*        NORMAL RETRY SEQUENCE
*
RETRY    EQU      %
         BAL,R5   RECOORD
RETRYA   EQU      %
         LI,R12   X'A408'           RETRY SEQUENCE
RETRYB   LI,R13   MSG2              ERROR MSG
         B        IOSCU
*
*        NORMAL COMPLETION
*
NORMAL   EQU      %
         LC       DCT19,R1          AIO CONDITION CODES
         BCS,4    RETRY             UN-END HAS BEEN INDICATED
NORMALA  EQU      %                 ENTER FROM DEVICE INTERRUPTS
         LB,R5    IOQ5,R3           GET CURRENT STEP #
         LB,R4    NORMACT,R5        GET ACTION ROUTINE #
         B        MPCDCU,R4         DISPATCH THAT ROUTINE
*
*        ERROR LOG THEN CONTINUE TO NEXT FUNCTION
*
SEC:NORM EQU      %
         BAL,R5   RECOORD           FILE PRIMMARY RECORD
         B        NORMAL            AND NORMAL EXIT
*
*        ERROR STOP SEQUENCE
*
ERROR    EQU      %
         BAL,R5   RECOORD           FILE ERROR LOG ENTRY
         LI,R12   0
         STB,R12  IOQ11,R3          NO MORE RETRIES
         LI,R12   X'A408'           RETRY CODE
         LI,R13   MPCERR            ERROR MSG TO TYPE
         B        IOSCU             QUIT
MPCERR   TEXTC    ' MPC DISC ERROR STOP'
*
*        FOLLOW ON TO NEXT STEP IN DOT TABLE
*
FOLLON   EQU      %
         LI,R12   X'6008'           FOLLOW ON SEQUENCE
         B        IOSCU
*
*        CHECK TO SEE IF READ CHECK IS NEEDED.
*
CHKRD    EQU      %
         MTW,0    M:RDCK            READ CHECK SET
         BEZ      DONE              NO
         LH,R4    IOQ9,R3           YES-GET SIZE OF WRITE
         CI,R4    X'3FF'            PARTIAL SECTOR INVOLVED
         BAZ      FOLLON            NO-CHECK READ
*
*        EVERYTHING HAS COMPLETED - SO EXIT
*
DONE     EQU      %
         LI,R12   1
         B        IOSCU
*
*        TEST FOR CHECK-WRITE NECESSITY
*
CHKWRT   EQU      %
         RD,0     0
         BCR,8    DONE              SENSE SWITCH ONE NOT SET TODAY
         B        FOLLON            ELSE FOLLOW ON TO COMPARE THE WRITE
*
*        SENSE HAS COMPLETED
*
SENSDONE EQU      %
         LH,R6    DCT7,R1           CLIST DA
         AI,R6    SENSEBUF-1
         SLS,R6   1
         LW,R8    DCT12,R1          DEVICE ADDRESS FROM AIO
         AND,R8   M16               SCRUB JUNK
         OR,R8    =X'16040000'      CODE AND COUNT FOR MSG
         LI,R9    0                 CLEAR TIME FIELD
         LCI      2
         STM,R8   0,R6              STORE MSG PREAMBLE AWAY
         BAL,R5   ERRLOG            INSERT THIS MSG INTO LOG
         B        FOLLON            FOLLOW ON TO RESTORE CARRIAGE
*
*        RETURN TO ORIGINAL STEP AND EXECUTE SAME AS A RETRY OP
*
ORIG     EQU      %
*
*        GET HERE WHEN RESTORE CARRAIGE HAS COMPLETED
*
         LB,R4    IOQ4,R3           GET ORIG #
         STH,R4   DCT17,R1          STORE AND
         B        FOLLON            USE AS FOLLOW ON CODE
         PAGE
*************************************
* ROUTINES ENTERED FROM COMLIST     *
*************************************
*
*        SEEK INIT SETUP
*
SKSETUP  EQU      %                 COME HERE FROM COMLIST
         LH,R7    DCT7,R1           GET DA OF CLIST AREA
         LW,R6    R7                COPY TO R6
         AI,R6    IDCWOFF           R6 IS IDCW AREA DA POINTER
         LD,R10   SEEKPRE           GET PRE-SEEK IDCW PAIR
         BAL,R4   DEVNUM            INSERT DEVICE # INTO IDCW
         LD,R12   0,R7              GET THE CDW PAIR
         BAL,R0   RE:ENT
         STD,R10  0,R6              STORE IDCW INTO CLIST TOP
         SLS,R6   3                 BA OF IDCW LOCATION
         OR,R12   R6                INSERT IT
         STD,R12  0,R7              STORE CDW BACK INTO CLIST BOTTOM
         SLS,R6   -3
         AI,R6    -1                BACK UP A PAIR
         AI,R7    1                 ADVANCE A PAIR
         LD,R10   SKPASS            THIS TYPE OF CDW FOR PRE-SEEKS
         BAL,R4   SEEKUPA           BUILD/INSERT SEEK ADDRESS
         BAL,R0   RE:ENT
         STD,R10  0,R7              REPLACE INTO CDW AREA
         LW,R5    Y8                SET FLAG TO KEEP CONTROLER FREE
         B        SIOST1            AND GO START THE I/O UP
*
*        COME HERE TO SETUP THE RESTORE CARRAIGE FUNCTION
*
CENSOR   EQU      %
         LD,R10   SENSIT            RESTORE CARRAIGE IDCW
         LH,R7    DCT7,R1           CLIST DA
         LW,R6    R7                COPY TO R6
         AI,R6    IDCWOFF           ADD IN IDCW OFFSET
         LD,R8    CENTS             GET SIGMA CONTROL PAIR
         AND,R8   YFF
         SLS,R6   3                 BA OF WHERE IDCW LIVES
         OR,R8    R6                INSERTED
         AND,R9   NBYT2             SCRUB HANDLER FUNCTION BYTE
         BAL,R0   RE:ENT            IS THIS THE LAST ENTRY
         STD,R8   0,R7              STORE SIGMA CDW
         BAL,R4   DEVNUM            INSERT DEVICE NUMBER
         SLS,R6   -3                BACK TO DA FORMAT
         STD,R10  0,R6              STORE IDCW AWAY
         B        SIOST
*
*        END OF CDW CONSTRUCTION - NOTE THAT THIS ROUTINE IS USED
*        ONLY FOR SINGLE GRANULE TRANSFERS FOR CODE SPEED.
*
SETUP    EQU      %
         LH,R7    DCT7,R1           DA OF CLIST AREA
         LW,R6    R7                COPY TO R6
         AI,R6    IDCWOFF           R6 = END OF CLIST AREA
*
*        FIRST CDW IS A CONTROL ORDER POINTING TO THE SEEK IDCW
*
         LD,R10   SEEKON            GET THE REGULAR SEEK IDCW
         BAL,R4   DEVNUM            INSERT DEVICE NUMBER INTO IDCW
         BAL,R0   RE:ENT            CHK AND DISABLE
         STD,R10  0,R6              STORE SEEK IDCW
         SLS,R6   3                 IDCW BA
         LD,R12   0,R7              GET CDW FOR SEEK
         OR,R12   R6                INSERT BA
         STD,R12  0,R7              REPLACE IT
         ENABLE                     TURN EM ON AGAIN
         SLS,R6   -3
*
*        NEXT PAIR IS SEEK ADDRESS IN IDCW AREA AND SIGMA CDW TO LOC IT
*
         AI,R6    -1                BACK UP TO SEEK SLOT
         AI,R7    1                 POINT TO SIGMA CDW LOC
         BAL,R4   SEEKUP            BUILD/INSERT SEEK ADDRESS
*
*        NEXT PAIR IS THE ORDER FOR THE TRANSFER
*
         BAL,R4   GETPAIRS          LOAD UP REGISTERS W/CDW'S & IDCW'S
         AI,R6    -1                BACK UP AGAIN
         AI,R7    1                 ADVANCE TO NEXT SIGMA CDW
         BAL,R0   RE:ENT            CHK AND DISABLE
         STD,R10  0,R6              STORE IDCW AWAY
         SLS,R6   3                 BA OF IDCW
         OR,R8    R6                INSERTED INTO SIGMA CDW
         STD,R8   0,R7              STORE SIGMA CDW AWAY
         ENABLE
         LW,R15   R7                AND HOLD IT IN R15
*
*        NEXT SIGMA CDW IS THE READ OPERATION PAIR ITSELF
*
         AI,R7    2                 NOTHING TO DO WITH THIS PAIR
*
*        NEXT SIGMA CDW IS THE STOP PAIR
*
STOPTIC  EQU      %
         LD,R8    ALLSTOP           GET COMPLETE STOP CDW (SIGMA)
         BAL,R0   RE:ENT            CHK & DISABLE
         STD,R8   0,R7              REPLACE
*
*        NEXT PAIR IS THE TIC ORDER
*
         AI,R7    1                 STEP TO THAT LOC
         LD,R8    TIC               PICK IT UP
         OR,R8    R15               R15 IS HOLDING THE DA OF THE ORDER
         STD,R8   0,R7              WE MUST TIC TO FOR RECOVERY STEPS
SIOST    EQU      %
         LW,R5    Y2                HOLD CHANNEL TO XFER BYTES
SIOST1   EQU      %
         LB,R4    IOQ3,R3           CHANNEL FLAGS
         ENABLE
         AND,R4   M3                ISOLATE CHANNEL BITS
         LI,R10   DOT               DOT TABLE ADDRESS
         BAL,R0   RE:ENT            WAS I CLOBBERED
         LH,R0    DCT7,R1           CLIST DW ADRRESS
         EXU      DEVFETCH,R4       GET DEVICE ADDRESS IN R6
         TIO,0    0,R6              CHANNEL CAN BE BUSY DOING A PRESEEK
         BCR,12   SIOST2            CHANNEL FREE GO
         BCR,8    RESCHED           CHANNEL BUSY - RESCHED
         BCR,4    RESCHED           CHANNEL BUSY - RESCHED
SIOST2   OR,R4    R5                SET CHANNEL HOLD/NO HOLD FLAG
         B        IOSST             JOIN UP
*
*        EXTERNAL SENSE HAS PASSED A BYTE ADDRESS TO USE
*
EXT:SEN  EQU      %
         LW,R7    IOQ8,R3           GET BA OF BUFFER
         AND,R7   M24               SCRUB ANY JUNK
         LD,R8    SENCDW            SENSE CDW
         AND,R8   YFF
         OR,R8    R7                INSERT BA
         AND,R9   NBYT2             DROP HANDLER FUNCTION BYTE
         LH,R7    DCT7,R1
         BAL,R0   RE:ENT            WAS I RE-ENTERED
         STD,R8   0,R7
         B        SIOST             JOIN UP
*
*        INTERNAL SENSE LIST ROUTINE
*
INT:SEN  EQU      %
         LH,R6    DCT7,R1           CLIST DA
         LW,R7    R6                COPY TO R7
         AI,R6    SENSEBUF          OFFSET TO SENSE BUFFER
         SLS,R6   3                 BA OF SENSE BUFFER
         LD,R8    INTSEN            GET SIGMA CDW PAIR
         AND,R8   YFF               SCRUB JUNK
         OR,R8    R6                INSERT BA OF SENSE BUFFER
         AND,R9   NBYT2             DROP HANDLER FUNCTION BYTE
         BAL,R0   RE:ENT            IS THIS THE LAST ENTRY
         STD,R8   0,R7              STORE SENSE CDW AWAY
         B        SIOST             JOIN UP
         PAGE
*************************************
* SUBROUTINES USED BY PROGRAM       *
*************************************
*
*        COME HERE TO CONSTRUCT THE LEVEL 66 STYLE SEEK ADDRESS
*        FOR SINGLE GRANULE TRANSFERS ONLY
*
*        INPUTS:
*
*        R6:      CONTAINS DA OF IDCW AREA
*        R7:      CONTAINS DA OF SIGMA CDW AREA
*        R3:      IOQ INDEX
*
SEEKUPA  EQU      %
         LI,R8    0                 ENTRY FOR PREE-SEEK HAS NO COUNT
         B        SEEKUP1
SEEKUP   EQU      %
         LD,R10   SKPASS2           GET CONTROL ORDER TO PASS SEEK #
*
         LH,R8    IOQ9,R3           TOTAL BYTE COUNT
         BNEZ     %+2               LESS THAN MAX
         LI,R8    X'10000'          SET AT MAX
         AI,R8    X'3FF'            ROUND UP
         SLS,R8   -10               TO SECTORS
*
         SLS,R8   4                 POSITION SECTOR COUNT LIMIT FIELD
SEEKUP1  AND,R10  YFF               SCREEN ANY GARBAGE
         LW,R9    IOQ12,R3          GET SEEK ADDRESS
         SLS,R9   12                POSITION RELATIVE SECTOR NUMBER
         SLD,R8   16                POSITION SECTOR NUMBER/SEEK ADDRESS
         BAL,R0   RE:ENT            CHK AND DISABLE
         STD,R8   0,R6              STORE SEEK ADDRESS IN TOP OF CLIST
         SLS,R6   3                 CREATE SEEK ADDRS BYTE ADDRESS
         OR,R10   R6                INSET THAT BA INTO SIGMA CDW
         AND,R11  NBYT2             SCRUB HANDLER BYTE
         STD,R10  0,R7              AND STORE THE CDW AWAY
         ENABLE                     OKAY
         SLS,R6   -3                BACK TO DA AGAIN
         B        0,R4              AND RETURN
*
*
DEVFETCH EQU      %
         LH,R6    DCT1P,R1          00 FLAGS
         LH,R6    DCT1P,R1          01
         LH,R6    DCT1A,R1          02
         DATA     0                 03-UNDEFINED
         B        %+1               04-EITHER
         LH,R6    DCT1P,R1          ADDRESS OF PRIMARY
         TIO,0    0,R6              IS PRIMARY FREE
         BCR,12   FETCH1            YES-SEE IF SECONDARY FREE
         LH,R6    DCT1A,R1          SECONDARY ADDRESS
         TIO,0    0,R6              PRIMARY BUSY-CHECK SECONDARY
         BCR,12   %+3               SECONDARY FREE-USE IT
         BCR,8    RESCHED           SECONDARY ALSO BUSY-RESCHED
         BCR,4    RESCHED           SECONDARY ALSO BUSY-RESCHED
         LI,R4    X'50'             SECONDARY CHANNEL MASK
         STB,R4   R2                  INTO CHANNEL FLAGS
         LI,R4    2                 SECONDARY FREE-SPECIFIE IT
         B        FETCH2
*
FETCH1   LH,R6    DCT1A,R1          ADDRESS OF SECONDARY
         TIO,0    0,R6              SECONDARY ALSO FREE
         BCR,12   SIOST2            YES-USE EITHER IOQ WILL DETERMINE
         LI,R4    X'A0'             PRIMARY CHANNEL MASK
         STB,R4   R2                  INTO CHANNEL FLAGS
         LI,R4    1                 NO-USE PRIMARY
FETCH2   LB,R6    IOQ3,R3           IOQ3 ENTRY
         AND,R6   =X'F8'            STRIP CHANNEL BITS
         OR,R6    R4                PUT IN NEW CHANNEL BITS
         STB,R6   IOQ3,R3           MAKE SURE CORE TABLE IS SAME AS REGISTER
         B        SIOST2
*
*        LOAD REGISTERS WITH CORRECT CDW'S AND IDCW'S FOR THIS
*        OPERATION
*
*        RETURNS VIA DEVNUM TO INSERT DEVICE # INTO IDCW
*
GETPAIRS EQU      %
         LB,R0    IOQ5,R3           CURRENT FUNCTION CODE
         LD,R8    CONTRL            PASS OPERATION IDCW
         LD,R10   RDIT              (HONEYWELL IDCW)
         CI,R0    RDON              TEST ASSUMPTION
         BE       GETPAIRS1         TRUE-> JUMP
         LD,R10   WRTIT             AND HONEYWELL IDCW
GETPAIRS1 EQU     %
         CI,R0    COMPARE           IS THIS A COMPARE PASS
         BNE      DEVNUM            NOPE
         LD,R10   WRC               YUP-> GET COMPARE IDCW THEN
*
*        INSERT DEVICE NUMBER INTO IDCW PASSED IN R10 & R11
*
*        INPUTS:
*
*        R4 =     LINK REGISTER
*        R10=     IDCW FIRST WORD
*
DEVNUM   EQU      %
         LH,R12   DCT1P,R1          GET LOW DIGIT OF DEVICE ADD.
         LI,R13   X'F'              MASK
         SLD,R12  20                POSITION DEVICE NUMBER
         STS,R12  R10               INSERT INTO IDCW
         B        0,R4              AND EXIT TO CALLER
*
*        RECORD ERROR LOG ENTRY
*
RECOORD  EQU      %
         LI,R6    X'150D'           ERROR MSG CODE AND COUNT
         B        RECIOERR          MERGE
         PAGE
*************************************
* SPECIAL FRONTEND PROCESSING FOR   *
* DATA CHAINING                     *
*************************************
*
*        THE CLIST AREA FOR THE MPC DISC DRIVES IS CURRENTLY EIGHTEEN
*        WORDS IN LENGTH. THIS AREA IS UTILIZED BOTH FOR THE
*        SIGMA COMMAND-DOUBLE-WORDS (CDW'S) AND THE IDCW'S FOR
*        THE MPC ITSELF.
*
*        THE SIGMA CDW'S ARE SITTING AT THE BOTTOM OF THE CLIST AREA
*        AND OCCUPY SPACE FROM THE BOTTOM TO THE TOP AND THE IDCW'S
*        ARE SITTING AT THE TOP AND OCCUPY SPACE FROM THE TOP BACKWARDS
*        TO THE BOTTOM.
*
FRONTEND EQU      %                 FRONT-END FOR DATA TRANSFERS
         MTW,0    IOQ8,R3           DATA CHAINED ENTRY
         BGEZ     COMLIST           NO-COMLIST WILL HANDLE
*
*        DATA CHAINED LISTS OR EXTERNAL LISTS NEED MASSAGING
*
         LB,R7    IOQ5,R3           GET CURRENT STEP
         CI,R7    COMPARE           IS IT A COMPARE
         BNE      FROUNT1           NOPE
         LH,R5    DCT7,R1           DA CLIST ADDRESS
         AI,R5    IDCWOFF-2         NO - POINT TO IDCW
         SLS,R5   3                 MAKE BYTE ADD
         LB,R7    WRC               SET COMPARE FUNC CODE
         BAL,R0   RE:ENT            DISABLE
         STB,R7   0,R5              PUT IT IN
*
*        CHANGE ALL POSIBLE ORDER CODES TO WRITE
*
         LI,R11   5                 FIVE POSIBLE CDWS
         LW,R5    IOQ8,R3           DA(MPOOL)
         AND,R5   M24               SCRUB
         SLS,R5   3                 BA(MPOOL)
         AI,R5    16                FIRST CDW
         LI,R7    1                 WRITE ORDER
         STB,R7   0,R5                INTO CDW
         AI,R5    24                NEXT CDW
         BDR,R11  %-2               LOOP ON NUMBER OF CDWS
         B        SIOST             GO
FROUNT1  LW,R5    IOQ8,R3           DA MPOOL ADDRESS
         AND,R5   M24               DROP THOSE FLAGS IN BITS0 - 3
         LW,R7    IOQ8,R3           DA MPOOL
         SLS,R7   3                 MAKE BYTE ADDRESS
         LI,R15   2                 ASSUME READ ORDER
         MTB,0    IOQ4,R3           TEST ASSUMPTION
         BEZ      %+2               TRUE
         LI,R15   1                 SET WRITE ORDER IF NOT
         BAL,R0   RE:ENT            LAST ENTRY
         MTB,0    0,R7              HAS MPOOL BEEN CHANGED FOR MPC
         BNEZ     FROUNT3           YES-USE MPOOL AS IS
         ENABLE
         LH,R12   IOQ9,R3           GET COMMAND PAIR COUNTER
         CI,R12   5                 NUMBER OF POSSIBLE CDWS
         BLE      FROUNT2           HAVE ROOM FOR THIS NO.
         BAL,R0   RE:ENT            HAVE I BEEN CLOBBERED
         SCREECH  X'19',1           MPOOL TOO SMALL
FROUNT2  LI,R10   X'AE80'           FLAGS/WRITE KEY FOR 560
         LI,R4    1                 HALF-WORD INDEX TO BYTE COUNT
         LW,R7    R5                DA OF THE MPOOL
         AI,R7    14                DA OF LAST CDW POSITION
         LW,R6    R5                DA OF MPOOL
         AW,R6    R12               ADD NUMBER OF CDWS
         AI,R6    -1                ADDRESS OF LAST CDW
         BAL,R0   RE:ENT            CHECK/DISABLE
         LI,R0    0                 INIT BYTE COUNTER REGISTER
ORDERLOP LD,R8    0,R6              CDW GREATED BY CHAINCHK
         STB,R15  R8                INSERT ORDER CODE
         STH,R10  R9                INSERT FLAGS
         AH,R0    R9,R4             CONTINUE CALCULATING B. C.
         STD,R8   0,R7              SPEAD OUT THE CDWS
         AI,R7    -1
         AI,R6    -1                MOVE THE POSITION ADDRESSES
         LD,R8    TIC               TIC ORDER CODE
         OR,R8    R5                MPC RE-TRY POINT
         STD,R8   0,R7              RE-TRY TIC INTO CLIST
         AI,R7    -1                MOVE POSITION ADDRESS
         LW,R8    Y08               TIC ORDER CODE
         OR,R8    R7
         AI,R8    2                 ADDRESS OF NEXT CDW
         STD,R8   0,R7              NEXT CDW TIC
         AI,R7    -1                MOVE POSITION ADDRESS
         BDR,R12  ORDERLOP          FINISH UP THE CDW LIST
*
         STH,R0   IOQ9,R3           SAVE TOTAL BYTE COUNT
         AI,R7    3                 ADDRESS OF FIRST CDW
         LW,R8    Y08               TIC ORDER CODE
         OR,R8    R7
         STD,R8   2,R5              TIC TO      THE FIRST CDW
         LD,R8    28,R5             LAST CDW
         LI,R10   X'2E80'           AT END OF DATA CHAIN LIST
         STH,R10  R9                DROP THE DC BIT FROM LAST CDW
         STD,R8   28,R5             REPLACE LAST CDW
         LW,R7    IOQ8,R3           DA MPOOL
         SLS,R7   3                 MAKE BYTE COUNT
         MTB,7    0,R7              SET CLIST CHANGED FOR MPC
         ENABLE                     DONE SO TURN EM ON AGAIN
         B        FROUNT4
*
*        FILL IN CORRECT ORDER CODE IF HERE ON RETRY
*
FROUNT3  LI,R11   5                 FIVE POSIBLE CDWS
         LW,R7    R5                DA(MPOOL)
         SLS,R7   3                 BA(MPOOL)
         AI,R7    16                FIRST CDW
         STB,R15  0,R7              CORRECT ORDER CODE
         AI,R7    24                NEXT CDW
         BDR,R11  %-2               LOOP ON NUMBER OF POSIBLE CDWS
         ENABLE
*
*        SIGMA CDW LIST FOR DATA CHAINING NOW READY TO GO
*
FROUNT4  LH,R7    DCT7,R1           DA(CLIST)
         LW,R6    R7                COPY CLIST DA TO R6
         AI,R6    IDCWOFF           R6 POINTS TO IDCW AREA
*
*        FIRST SIGMA PAIR MUST BE SEEK
*
         LD,R8    SEEK              NORMAL SEEK CDW
         LD,R10   SEEKON            GET IDCW PAIR FOR SEEK
         BAL,R4   DEVNUM            INSERT DEVICE NUMBER INTO IDCW
         BAL,R0   RE:ENT            WAS I CLOBBERED
         STD,R10  0,R6              SHOVE INTO IDCW AREA
         SLS,R6   3                 BA OF IDCW AREA
         OR,R8    R6                INSERT BA OF IDCW AREA
         STD,R8   0,R7              INSERT SIGMA CDW
         ENABLE
         SLS,R6   -3                BACK TO DA
*
*        NEXT IS CDW TO PASS THE SEEK ADDRESS
*
         AI,R7    1                 NEXT SIGMA PAIR
         AI,R6    -1                NEXT IDCW PAIR
         BAL,R4   SEEKUP            BUILD SECTOR #/ SECTOR COUNT
*
*        NEXT PAIR IS TIC OVER TO THE MPOOL AREA
*
         LD,R8    TIC               GET A SKELETON TIC CDW
         OR,R8    R5                INSERT THE DA OF THE DATA CHAIN LIST
         AI,R7    1                 NEXT CDW LOC IN CLIST
         AI,R6    -1                NEXT IDCW LIST
         BAL,R0   RE:ENT
         STD,R8   0,R7              STORE THE TIC TO THE DATACHAIN LIST
         ENABLE
*
*        NEXT PAIR IS THE CONTROL CDW FOR THE TRANSFER OPERATION
*
         BAL,R4   GETPAIRS          LOAD REGISTERS UP W/CDW'S AND IDCW'S
         LW,R12   R6                CURRENT IDCW DOUBLEWORD ADDRS
         SLS,R12  3                 INTO BA FORMAT
         OR,R8    R12               INSERT INTO SIGMA CDW
         BAL,R0   RE:ENT            WAS I CLOBBERED
         STD,R8   0,R5              STORE IN BOTTOM OF LIST
         STD,R10  0,R6              STORE THE OPERATION IDCW AWAY
         ENABLE
         LW,R15   R5                HOLD HEAD OF LIST DA IN R15
         LW,R7    R5                DA OF THE MPOOL
         AI,R7    15                DA OF POSITION FOR STOP ORDER
         B        STOPTIC           JOIN UP W/COMMON PATH
*
*
         END

