         DEF      ECBPOST:
ECBPOST: EQU      %
         TITLE    'ECBPOST - RECORD EVENT COMPLETION'
         PCC      0
         REF      MASKS
         SYSTEM   UTS
         DEF      ECBPOST,ECBPOST1
         REF      T:RUE
         REF      ECBGBLK
         REF      M2,M9,M16,M17
         REF      U:MISC
         REF      E:WU,SW
         REF      UH:WL,UH:DL,UB:NECB,UB:US
         REF      JJAC,JCMAP
         REF      UX:JIT
         REF      UH:FLG
         REF      JOVVP
         REF      J:JIT
         REF      T:IACU
         REF      T:DOLISTR
         PAGE
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
RTRMASK  EQU      MASKS+1
         PAGE
*
*        TABLE SYMBOLS FOR ECB
*
ECBP     EQU      BT31TO0+32
ECBW     EQU      BT31TO0+31
NECBW    EQU      NB31TO0+31
ECBI     EQU      BT31TO0+30
NECBI    EQU      NB31TO0+30
ECBU     EQU      BT31TO0+29
WECB     EQU      0
ECBCC    EQU      1
*
*        TABLE SYMBOLS FOR WAIT LIST/DO LIST ECB BLOCK
*
ECBBLINK EQU      1
ECBBADDR EQU      1
ECBBP    EQU      ECBP
ECBBW    EQU      ECBW
ECBBI    EQU      ECBI
ECBBU    EQU      ECBU
WECBB    EQU      2
ECBBMULT EQU      10
ECBBC    EQU      BT31TO0+1
ECBBCC   EQU      3
ECBBLENG EQU      4
ECBBECB  EQU      1
         PAGE
***********************************************************************
*                                                                     *
*        ECBPOST                                                      *
*          -POST AN EVENT CONTROL BLOCK (ECB) AS COMPLETED            *
*                                                                     *
*        ENTRY POINTS                                                 *
*          ECBPOST,ECBPOST1                                           *
*                                                                     *
*        INPUT                                                        *
*          R11 - RETURN ADDRESS                                       *
*          R10 - VIRTUAL ADDESS OF ECB                                *
*          R9  - COMPLETION CODE VALUE                                *
*          R8  - USER NUMBER                                          *
*(ECBPOST1) R7 - NON-ZERO, WORD ADDRESS OF CALLER SUPPLIED  DOLIST BLOCK
*                ZERO, DO-LIST BLOCK TO BE ALLOCATED BY ECBPOST, IF
*                      NECESSARY
*                                                                     *
*        OUTPUT                                                       *
*          R10 - ZERO , REQUEST ACCOMPLISHED                          *
*                ONE  , ALLOCATION OF UH:DL ENTRY UNSUCCESSUL         *
*(ECBPOST1) R7 - BIT ZERO, SET IF CALLER-SUPPLIED BLOCK WAS USED
*                BITS 1 TO 31, UNCHANGED FROM INPUT
*          CC  - INDICATE WHETHER R10 IS ZERO OR NON-ZERO             *
*                                                                     *
*        REGISTER USAGE                                               *
*(ECBPOST1) R7 - BIT ZERO MAY BE ALTERED
*          R10 ALTERED, ALL OTHERS PRESERVED                          *
*                                                                     *
***********************************************************************
         SPACE    2
ECBPOST  EQU      %
         PUSH     7,R1              SAVE R1-R7
         LI,R7    0                 MUST ALLOCATE BLOCK
         PUSH     1,R7              SAVE INDICATION
         B        ECBP003
ECBPOST1 EQU      %
         PUSH     7,R1              SAVE R1-R7
         PUSH     1,R7              INDICATE R7 USEFUL (MAYBE)
ECBP003  EQU      %
         LW,R4    R8                TRANSFER USER NUMBER TO XR
         LH,R1    UH:WL,R4          WAIT LIST NULL
         BEZ      ECBP040           YES, POST ON DO-LIST (UH:DL)
ECBP010  EQU      %
         LD,R2    0,R1              COMPARE ADDRESS OF
         AND,R3   M17                 ECB TO BE POSTED AGAINST
         CW,R10   R3                  ADDRESS OF ECB IN WAIT-LIST ENTRY
         BE       ECBP015           MATCH, POST COMPLETE TO WL ENTRY
         AND,R2   M16               NO MATCH - END OF WL CHAIN
         BEZ      ECBP040           YES, POST ON DO-LIST (UH:DL)
         LW,R1    R2                STILL ANOTHER ENTRY ON CHAIN
         B        ECBP010           CONTINUE
ECBP015  EQU      %
         SLS,R1   1                   CONVERT TO WORD ADDRESS
         LI,R2    ECBBMULT          FETCH MULTIPLICITY COUNT FOR ECB
         LB,R3    *R1,R2
         LW,R2    ECBBP             POST COMPLETE
         OR,R2    WECBB,R1
         STW,R2   WECBB,R1
         STW,R9   ECBBCC,R1         RETURN COMPLETION CODE
         LW,R2    ECBBC             WATCH FOR CONCURRENT M:CHECKECB
         AND,R2   WECBB,R1
         BNEZ     ECBP120             IN PROCESS- IF SO, FINISHED HERE
         LI,R2    U:MISC            POSTEE IS WAITING
         AW,R2    R4                  DECREMENT WAIT COUNT
ECBP018  EQU      %
         MTB,-1   *R2               AND IF NOW ZERO
         BEZ      ECBP020           ASK SCHEDULER TO AWAKEN USER
         BDR,R3   ECBP018           REPEAT POST TILL COUNT ZERO
         B        ECBP120           POSTING DONE
ECBP020  EQU      %
         DISABLE
         LI,R5    SW                IS POSTEE
         CB,R5    UB:US,R4          WAITING
         BE       ECBP025           YES
         ENABLE                     NO, ALREADY AWAKENED
         B        ECBP120           FOR SOME OTHER REASON
ECBP025  EQU      %
         PUSH     13,R4               TO AWAKEN USER.
         LW,R5    R4                  OTHERWISE EXIT
         LI,R6    E:WU                BECAUSE POST
         BAL,R11  T:RUE               REQUIREMENT COUNT
         PULL     13,R4               NOT YET SATISFIED
         B        ECBP120
ECBP040  EQU      %
         DISABLE                    STEADY STATE DURING TRANSFER
         LH,R2    UH:FLG,R4         IF POSTEE IS CURRENTLY
         AND,R2   RTRMASK             IN MEMORY THEN ATTEMPT
         BNEZ     ECBP080             A DIRECT TRANSFER TO THE ECB
         ENABLE                     ALLOW INTERRUPTS, TRANSFER VIA UH:DL
ECBP044  EQU      %
         AI,R7    0                 DID CALLER SUPPLY BLOCK
         BEZ      ECBP046           NO
         LI,R1    0                 INITIALIZE
         LI,R2    ECBBLENG-1        THE
         STW,R1   *R7,R2            SUPPLIED BLOCK
         BDR,R2   %-1
         LI,R2    ECBBECB
         LI,R3    X'7F'             SET BLOCK AS ECB TYPE
         SLD,R2   16
         STS,R2   0,R7
         LW,R2    R7                YES, USE IT AND
         OR,R7    BT31TO0+32          TELL CALLER
         B      ECBP048
ECBP046  EQU      %
         BAL,R1   ECBGBLK           OBTAIN A DL BLOCK
         BNEZ     ECBP048           BLOCK ALLOCATED
         LI,R10   1                 NO DL ENTRY AVAILABLE
         B        ECBP210           GIVE UP
ECBP048  EQU      %
         LW,R1    R11               SAVE RETURN
         LW,R11   MASKS+24          INITIALIZE VIRTUAL ADDRESS OF ECB
         STS,R10  ECBBADDR,R2
         LW,R11   R1                RESTORE RETURN
         LW,R1    ECBBP             POST COMPLETE
         STS,R1   WECBB,R2
         STW,R9   ECBBCC,R2         TRANSFER COMPLETION CODE
         DISABLE                    NO INTERRUPTS DURING CHAINING
         LH,R1    UH:DL,R4          PLACE ECB DL BLOCK
         AND,R1   MASKS+12          ELIMINATE FLAGS
         LI,R3    ECBBLINK          CHAIN AT HEAD OF DO-LIST
         STH,R1   *R2,R3
         SLS,R2   -1                  (PRIORITY = ZERO,HIGHEST)
         LH,R1    UH:DL,R4
         LW,R3    MASKS+12
         STS,R2   R1                PRESERVE FLAGS
         STH,R1   UH:DL,R4          PUT BLOCK FIRST
         ENABLE
         B        ECBP120
ECBP080  EQU      %
         LOAD,R5  UX:JIT,R4         FETCH PHYSICAL PAGE OF JIT
         SLS,R5   9                 GENERATE WORD ADDRESS OF PAGE
         AI,R5    JJAC              POINT TO ACCESS CODES FOR POSTEE
         LI,R4    1                 ASSUME ECB DOES NOT CROSS PAGE
         AND,R10  MASKS+17          REMOVE EXTRANEOUS BITS
         LW,R3    R10               LOOK AT SECOND WORD OF ECB (WORD 1)
         AI,R3    1                 IF AT START OF PAGE THEN TWO
         AND,R3   M9                  PAGES MUST VE VERIFIED
         BNEZ     ECBP084             WITH RESPECT TO ACCESSIBILITY
         LI,R4    0                 POINT TO WORD ZERO OF ECB
ECBP084  EQU      %
         LW,R3    R10               FETCH VIRTUAL ADDRESS OF ECB
         AW,R3    R4                POINT TO WORD OF ECB TO BE CHECKED
         LI,R2    0
         SLS,R3   -9                CONVERT TO RELATIVE VIRTUAL PAGE
         CI,R3    JOVVP             IS ADDRESS IN RESIDENT MONITOR
         BL       ECBP120           YES, IGNORE POSTING
         SCD,R2   -4                DIVIDE BY 16 WITH REMAINDER IN R2
         SCS,R2   5                 RIGHT JUSTIFY AND DOUBLE REMAINDER
         LW,R1    J:JIT             IF MAPPED ENTRY THEN SWITCH TO REAL
         BEZ      ECBP086
         UNMAP
ECBP086  EQU      %
         LW,R3    *R5,R3            FETCH ACCESS WORD CONTAINING PAGE
         AI,R1    0                 REVERT TO ENTRY MODE
         BEZ      ECBP088
         MAP
ECBP088  EQU      %
         SLD,R2   2,R2              SHIFT TO ACCESS CODE FOR PAGE
         AND,R2   M2                REMOVE EXTRANEOUS RESIDUE
         BEZ      ECBP090           ACCESS ZERO, TRANSFER IMMEDIATE OK
         ENABLE                     NO IMMEDIATE TRANSFER, LET SYS HUM
         B        ECBP120           ACCESS NON-ZERO, IGNORE REQUEST
ECBP090  EQU      %
         AI,R4    0                 IF WORD POINTER OF ECB IS NON-ZERO
         BNEZ     ECBP094             THEN CHECKING COMPLETED
         LI,R4    1                 POINT TO LAST WORD OF ECB
         B        ECBP084           AND GO CHECK IT
ECBP094  EQU      %
         ENABLE                     ALLOW INTERRUPT
         DISABLE                      WINDOW
         LW,R4    R8                RESTORE USER NUMBER FOR HERE+ECBP044
         LH,R2    UH:FLG,R4         VERIFY POSTEE STILL
         AND,R2   RTRMASK             RESIDENT
         BEZ      ECBP044           NO, LOST POSTEE, PLACE DATA ON DL
         AI,R5    JCMAP-JJAC        POINT TO POST EE MAP IMAGE (PHYSICAL)
         LI,R4    0                 START AT WORD ZERO OF ECB
         LI,R6    1                 ASSUME ECB DOES NOT CROSS
         LW,R2    R10                 PAGE BOUNDARY - IF NOT SO
         AI,R2    1                   THEN INDICATE THAT BOTH WORDS
         AND,R2   M9                  OF ECB MUST BE TRANSLATED
         BNEZ     ECBP096
         LI,R6    0                 ECB IS SPLIT ACROSS TWO PAGES
ECBP096  EQU      %
         LW,R2    R10               FETCH VIRTUAL ADDRESS OF ECB
         AW,R2    R4                POINT TO ECB WORD TO TRANSFER
         SLD,R2   -9                PAGE NUMBER IN R2, DISPLACEMENT R3
         LW,R1    J:JIT             IF MAPPED ENTRY THEN SWITCH TO REAL
         BEZ      ECBP097
         UNMAP
ECBP097  EQU      %
         LOAD,R2  *R5,R2            TRANSLATE VIRTUAL TO PHYSICAL
         SLD,R2   9                 RETURN DISPLACEMENT VALUE
         CI,R4    0                 LAST WORD OF ECB
         BNE      ECBP105           YES, STORE ECBCC
         LW,R3    ECBP              POST COMPLETE
         STS,R3   WECB,R2
         LW,R3    NECBI             RESET INITIALIZED
         AND,R3   WECB,R2
         STW,R3   WECB,R2
         LW,R3    ECBU              TEST USER ECB
         AND,R3   WECB,R2
         BNEZ     ECBP098           YES
         LW,R3    R8                SYSTEM ECB
         MTB,-1   UB:NECB,R3        DECREMENT OUTSTANDING SYSTEM ECBS
ECBP098  EQU      %
         AI,R6    0                 IF NO PAGE BOUNDARY
         BNEZ     ECBP102             THEN TRANSLATION COMPLETED
         LI,R4    1                 PAGE BOUNDARY CROSSED - MUST
         B        ECBP096             TRANSLATE SECOND WORD ADDRESS
ECBP102  EQU      %
         AI,R2    1                 STEP TO WORD ONE OF ECB
ECBP105  EQU      %
         STW,R9   *R2               STORE ECBCC
         ENABLE                     TRANSFERENCE DONE
         AI,R1    0                 REVERT TO ENTRY MODE
         BEZ      ECBP120
         MAP
ECBP120  EQU      %
         LI,R10   0                 GOOD RETURN
ECBP210  EQU      %
         PULL     1,R1
         AI,R1    0                 WAS R7 ZERO AT ENTRY
         BEZ      ECBP215           NO
         PULL     1,R1              YES, LEVEL STACK
         B        ECBC217           AND USE CURRENT R7
ECBP215  EQU      %
         PULL     1,R7              RESTORE ORIGINAL R7
ECBC217  EQU      %
         PULL     6,R1              RESTORE REGS
         AI,R10   0                 SET CONDITION CODES
         B        *R11              RETURN
         PAGE
*
*  T:ECBSTORE IS THE DO-LIST PROCESSOR FOR ECBS.
*        ENTERED WITH:
*                 R4=  S:CUN (USER NUMBER).
*                 R5= DA(4-WORD BLOCK).
*                 R6/7= FIRST DOUBLEWORD OF BLOCK.
*                 R15= USER FLAGS (UH:FLG).
*
         DEF      T:ECBSTORE
T:ECBSTORE EQU    %
         LW,R6    R7                SAVE VWA OF ECB IN R6.
         AI,R7    1                 INCR TO SECOND WORD OF ECB.
         SCS,R7   -9                GET PAGE-ADDRESS.
         CW,R7    L(X'FF800000')    CROSSED A PAGE BOUNDARY...
         BANZ     T:ECBS10          ---> NO. ONLY CHECK ONCE.
         BAL,R11  T:IACU            CHECK ACCESS ON ECB.
         BCS,3    T:DOLISTR         ---> NOT WRITEABLE; DONT POST.
         AI,R7    -1                BACK UP A PAGE.
T:ECBS10 BAL,R11  T:IACU            CHECK ACCESS ON ECB.
         BCS,3    T:DOLISTR         ---> NOT WRITEABLE; DONT POST.
         LD,R8    2,R5              GET COMPLETION CODE
         STW,R9   ECBCC,R6          AND PUT INTO ECB.
         LW,R8    WECB,R6           GET FLAG WORD OF ECB.
         AND,R8   NECBW             RESET 'WAITING'
         AND,R8   NECBI              AND  'INITIALIZED'
         OR,R8    ECBP              AND SET 'POSTED'.
         STW,R8   WECB,R6
         AND,R8   ECBU              SEE IF 'USER' ECB.
         BNEZ     T:DOLISTR         ---> YES.
         MTB,-1   UB:NECB,R4        NO. DECREMENT SYSTEM ECB COUNT.
         B        T:DOLISTR
         END

