*M*      OCQ      PROCESS READS AND WRITES TO OPERATOR'S CONSOLE
         PCC      0
         SPACE    3
*P*   NAME:         OCQ
*P*
*P*   PURPOSE:      PROVIDE PRE-PROCESSING FOR ALL M:READ AND
*P*                 M:WRITE CALS TO THE OPERATOR'S CONSOLE.
*P*
*P*   DESCRIPTION:  M:WRITE:  THE SYSID OF THE USER IS PREFIXED ONTO
*P*                 THE MESSAGE TO BE WRITTEN, AND THE SYSID AND
*P*                 MESSAGE ARE WRITTEN.
*P*
*P*                 M:READ:  IF ONLINE, AN EOF TYC IS RETURNED.  FOR
*P*                 BATCH AND GHOST, THE SYSID AND THE CONTENTS
*P*                 OF JB:PROMPT (IF NON-ZERO) ARE WRITTEN.
         SPACE    2
MONPROC  SET      1
UTSPROC  SET      1
BITS     SET      1
UFLAGS   SET      1
         SYSTEM   UTS
         SPACE    3
OCQ:     EQU      %
         DEF      OCQ:              MODULE NAME FOR PATCHING
         SPACE    3
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    2
CR       EQU      X'15'             CARRIAGE RETURN
TAB      EQU      5                 TAB CHAR
         TITLE    '****  DEFS  ****'
         SPACE    2
         DEF      MSROCWRT          WRITE TO OPERATOR'S CONSOLE
         DEF      MSRTY             M:TYPE/M:MESSAGE TO OPERATOR'S CONSOLE
         DEF      MSROCRD           M:READ TO OPERATOR'S CONSOLE
         TITLE    '****  REFS  ****'
         SPACE    2
         REF      MSREXIT           EXIT FROM CAL
         REF      CKLIMIT           VALIDATE USER DATA ADDRESS
         REF      OCDCT             DCT INDEX OF OC
         REF      T:ABORTM          ABORT THE USER
         REF      RMB               RELEASE MPOOL BUFFER
         REF      IOGETBF           GET MPOOL BUFFER
         REF      NEWQNWM           QUEUE AN I/O
         REF      J:JIT             ADDRESS OF USER JIT
         REF      S:CUN             CURRENT USER #
         REF      S:GJOBTBL         GHOST JOB NAMES
         REF      SB:GJOBUN         GHOST JOB USER NUMBERS
         REF      MAXG              # OF HIGHEST GHOST SLOT
         REF      UH:FLG            USER'S FLAGS
         REF      PULLEXIT          PULL REG, BR INDIRECT
         REF      JB:PROMPT         PROMPT CHARACTER
         REF      J:ASSIGN          BYPASS I/O BUFFER CHECKS FLAG
         REF      DCT2              CHANNEL INDEX FOR DEVICE
         REF      CIT1              FIRST IOQ ENTRY FOR THIS CHANNEL
         REF      IOQ2              FORWARD IOQ LINK
         REF      E:SL              EVENT:  SLEEP
         REF      T:REG             REPORT EVENT, GIVE UP CONTROL
         REF      IOQ13             END-ACTION ADDR AND INFO
         REF      U:MISC            # TICS TO SLEEP
         REF      J:UNAME           USED TO GET ACCOUNT FOR OC WRITES
         REF      UB:ACP            SHARED PROCESSOR NUMBER
         REF      P:NAME            PROCESSOR NAME
         SPACE    4
         BOUND    8
LOWCASE  DATA     X'81',X'A9'
OCINFO   GEN,8,8,8,8   1,X'FE',10,0   FCN,PRIO,NRT,0
TLGN     TEXTC    'LOGON'
         TITLE    '****  MSROCWRT  ****'
         SPACE    2
*F*   NAME:         MSROCWRT
*F*
*F*   PURPOSE:      PERFORM M:WRITE TO OPERATOR'S CONSOLE
*F*
*F*   DESCRIPTION:  THE USER'S SYSID IS PREFIXED ONTO THE USER MESSAGE,
*F*                 AND THE RESULT IS WRITTEN TO THE OPERATOR'S CONSOLE.
*F*                 THE MESSAGE WILL NOT BE CONSTRUCTED AND QUEUED
*F*                 UNTIL THERE ARE FEWER THAN 4 WRITES BY THIS USER
*F*                 ALREADY QUEUED TO THE OC.
      SPACE         1
*D*   NAME:         MSROCWRT
*D*
*D*   REGISTERS:    ALL VOLATILE EXCEPT R6
*D*
*D*   CALL:         BRANCH AFTER PUSHALL.  EXIT IS TO MSREXIT.
*D*
*D*   INTERFACE:    MSRWRT10, MSREXIT
*D*
*D*   INPUT:        R6 = DCB ADDRESS
*D*                   DCB:BLK = # BYTES IN USER MESSAGE
*D*                   DCB:DSI = DCT INDEX OF DEVICE
*D*                   DCB:BUF = WORD ADDRESS OF USER MESSAGE
*D*                   DCB:UBTD = BYTE DISPLACEMENT OF USER MESSAGE
*D*
*D*   DESCRIPTION:  THE DCB VALUES ARE LOADED INTO THE APPROPRIATE
*D*                 REGISTERS, AND MSRWRT10 ENTERED TO BUILD THE SYSID.
         SPACE    1
MSROCWRT LW,R2    RWS,R6            # BYTES TO MOVE
         LI,R4    X'FF'
         AND,R4   DSI,R6            DCT INDEX
         LI,R1    X'1FFFF'
         AND,R1   BUF,R6            BUFFER WORD ADDRESS
         SLS,R1   2                 BYTE ADDRESS
         LI,R3    X'30'
         AND,R3   BTD,R6
         SLS,R3   -4                BYTE DISPLACEMENT
         AW,R1    R3                BA OF USER'S BUFFER
         LI,R11   MSREXIT           RETURN ADDRESS
         SPACE    2
*D*   NAME:         MSRWRT10
*D*
*D*   ENTRY:        MSRWRT11
*D*
*D*   REGISTERS:    ALL VOLATILE EXCEPT R6
*D*
*D*   CALL:         BAL,R11
*D*
*D*   INTERFACE:    BUILDID, OCWRT10
*D*
*D*   INPUT:        R1 = BA OF USER'S MESSAGE
*D*                 R2 = # BYTES IN USER MESSAGE
*D*                 R4 = DCT INDEX OF DEVICE TO WRITE TO
*D*
*D*   DESCRIPTION:  THE DCT, CIT AND IOQ TABLES ARE SEARCHED TO
*D*                 DETERMINE THE NUMBER OF WRITES THIS USER ALREADY
*D*                 HAS QUEUED TO THIS DEVICE.  IF THE NUMBER IS 4 OR
*D*                 MORE, THE USER IS PUT TO SLEEP UNTIL THE NUMBER
*D*                 IS LESS THAN 4.
*D*                 AN MPOOL BUFFER IS OBTAINED AND THE SYSID BUILT
*D*                 IN IT (BUILDID).  UP TO 115 BYTES OF THE USER
*D*                 MESSAGE ARE MOVED INTO THE MPOOL BUFFER.  IF
*D*                 ONLINE, THE USER MESSAGE IS SCANNED AND ANY
*D*                 LOWER CASE LETTERS ARE CHANGED TO UPPER CASE.
*D*                 THE BUFFER IS WRITTEN OUT.  IF THE USER MESSAGE IS
*D*                 GREATER THAN 115 BYTES,  THE ABOVE SEQUENCE IS
*D*                 REPEATED.  ANY PART OF THE MESSAGE GREATER THAN
*D*                 230 BYTES IS IGNORED.
         SPACE    1
MSRWRT10 PUSH     R11
MSRWRT11 PUSH     R4                SAVE DCTX
         AI,R2    0
         BLEZ     MSRX              NOTHING TO DO
         CI,R2    230
         BLE      %+2
         LI,R2    230               TRUNCATE MESSAGE TO 230 BYTES
MSRWRT20 LW,R4    *TSTACK           DCT INDEX
         PUSH     3,R0
MSRWRT21 LI,R12   -5
         LW,R5    S:CUN
         LB,R2    DCT2,R4           CHANNEL INDEX FOR THIS DEVICE
         DISABLE                    ****  DISABLE
         LB,R3    CIT1,R2           FIRST ACTIVE IOQ ENTRY
         BEZ      MSRWRT26          NOTHING ACTIVE
MSRWRT22 LD,R14   IOQ13,R3          END-ACTION ADDR AND INFO
         CI,R14   RMB               SEE IF IT IS WRITE FROM OCQ
         BNE      MSRWRT25          NO
         CB,R5    R15               YES - IS IT FOR THIS USER
         BNE      MSRWRT25          NO
         AI,R12   1                 YES - COUNT IT
MSRWRT25 LB,R3    IOQ2,R3           LOOK AT NEXT ACTIVE IOQ ENTRY
         BNEZ     MSRWRT22
MSRWRT26 ENABLE                     ****  ENABLE
         BIR,R12  MSRWRT28          OK IF < 4 ALREADY QUEUED
         SLS,R12  2
         AI,R12   2                 SLEEP FOR 4*(X-4)+2 TICS, WHERE
         STW,R12  U:MISC,R5           X IS # WRITES ALREADY ACTIVE
         PUSH     R6                SAVE DCB ADDRESS
         LI,R6    E:SL
         BAL,R11  T:REG             SLEEP
         PULL     R6
         B        MSRWRT21          GO TRY AGAIN
*
MSRWRT28 BAL,R11  BUILDID           GET MPOOL, PUT IN SYSID
*  R14 = WA OF MPOOL
*  R3 = # BYTES ALREADY INSERTED
         PULL     3,R0
         LW,R10   R1                BA OF BUFFER
         LW,R11   R14
         SLS,R11  2                 BA OF MPOOL
         AW,R11   R3                BA OF DESTINATION
         LW,R7    R2                # BYTES IN USER'S MESSAGE
         CI,R7    115
         BLE      %+2
         LI,R7    115               TRUNCATE TO 115
         STB,R7   R11
         MBS,R10  0                 MOVE IT
*
         LC       J:JIT
         BCR,8    MSRWRT45          NOT ONLINE
         LW,R10   R7                # BYTES IN USER MESSAGE
         LW,R4    R3                DISPL TO START OF MESSAGE
MSRWRT41 LB,R11   *R14,R4           GET NEXT CHAR
         CLM,R11  LOWCASE           IS IT LOWER CASE
         BCS,9    MSRWRT43          NO
         AI,R11   X'40'             YES - CONVERT TO UPPER
         STB,R11  *R14,R4
MSRWRT43 AI,R4    1
         BDR,R10  MSRWRT41
*
MSRWRT45 AW,R1    R7                INCR POINTER TO USER BUFFER
         AW,R3    R7                INCR INDEX INTO MPOOL
         LW,R12   *TSTACK           GET DCT INDEX
         PUSH     4,R0
         BAL,R7   OCWRT10           WRITE IT
         PULL     4,R0
         SW,R2    R3                SUBTRACT # BYTES PROCESSED
         BGZ      MSRWRT20          DO ANOTHER LINE
*
MSRX     PULL     R4
         PULL     R11
         CI,R11   X'8000'
         BGE      *R11              DON'T DESTRUCT IF FROM THIS OVERLAY
         DESTRUCT
         TITLE    '****  MSRTY  ****'
         SPACE    2
*F*   NAME:         MSRTY
*F*
*F*   PURPOSE:      PROCESS M:TYPE AND M:MESSAGE CALS TO OPERATOR'S CONSOLE
*F*
*F*   DESCRIPTION:  THE USER BUFFER ADDRESS IS VALIDATED, AND THE WRITE
*F*                 IS QUEUED VIA MSRWRT11.
      SPACE         1
*D*   NAME:         MSRTY
*D*
*D*   REGISTERS:    ALL VOLATILE
*D*
*D*   CALL:         BAL,R11
*D*
*D*   INTERFACE:    MSRWRT11, T:ABORTM
*D*
*D*   INPUT:        R12 = ADDRESS OF MESSAGE
*D*
*D*   DESCRIPTION:  USER'S BUFFER ADDRESS IS CHECKED FOR VALIDITY
*D*                 (UNLESS BYPASS BUFFER CHECKS FLAG IS SET).  ABORT
*D*                 4A-00 OCCURS IF ANY PART OF THE MESSAGE IS IN
*D*                 11 PROTECTED MEMORY.
*D*                 MSRWRT11 IS CALLED TO QUEUE THE MESSAGE
         SPACE    1
MSRTY    PUSH     R11
         LW,R13   Y4
         CW,R13   J:ASSIGN          CHECK AND RESET BYPASS
         STS,R12  J:ASSIGN            BUFFER CHECK FLAG
         BANZ     MSRTY2            SET - DON'T CHECK BUFFER
         LW,R7    R12
         LB,R15   *R7               TEXTC COUNT
         AI,R15   1                 INCLUDE TEXTC COUNT
         BAL,R0   CKLIMIT           VALIDATE BUFFER ADDRESS
         BCR,1    %+2               OK - 00 OR 10
         BCS,2    ABORT             ERROR - 11
MSRTY2   LB,R2    *R12              TEXTC COUNT
         LW,R1    R12
         SLS,R1   2                 BA OF MESSAGE
         AI,R1    1                 SKIP TEXTC COUNT
         LI,R4    OCDCT             DCT INDEX OF OPERATOR'S CONSOLE
         B        MSRWRT11
*
ABORT    LI,R14   X'4A'
         B        T:ABORTM
*E*   ERROR:        4A-00
*E*   DESCRIPTION:  BUFFER DOES NOT BELONG TO USER.
*E*                 ALL OR PART OF BUFFER SPECIFIED IN M:TYPE OR
*E*                 M:MESSAGE CAL HAS ACCESS CODE 11 (NO ACCESS).
         TITLE    '****  MSROCRD  ****'
         SPACE    2
*F*   NAME:         MSROCRD
*F*
*F*   PURPOSE:      BUILD AND WRITE SYSID HEADER MESSAGE FOR M:READ
*F*                 TO OPERATOR'S CONSOLE.  IT IS ASSUMED THAT
*F*                 A READ WILL BE QUEUED IMMEDIATELY FOLLOWING THE
*F*                 CALL TO THIS ROUTINE.
*F*
*F*   DESCRIPTION:  THE USER'S SYSID AND THE CONTENTS OF JB:PROMPT
*F*                 (IF NON-ZERO) ARE WRITTEN TO THE OC.
      SPACE         1
*D*   NAME:         MSROCRD
*D*
*D*   REGISTERS:    ALL VOLATILE EXCEPT R6
*D*
*D*   CALL:         BAL,R7
*D*                   RETURN SKIPPING IF NO ERROR.  RETURN NORMAL IF
*D*                   EOF IS TO BE RETURNED TO USER.
*D*
*D*   INTERFACE:    BUILDID, OCWRT
*D*
*D*   INPUT:        R6 = DCB ADDRESS
*D*
*D*   DESCRIPTION:  IF ONLINE USER, NORMAL RETURN IS MADE TO REPORT
*D*                 EOF (ONLINE USERS ARE NOT ALLOWED TO ISSUE
*D*                 M:READ TO OC).  BUILDID IS CALLED TO OBTAIN AN
*D*                 MPOOL BUFFER AND BUILD SYSID IN IT.  IF JB:PROMPT
*D*                 IS NON-ZERO, IT IS PLACED IN THE MPOOL AT END OF
*D*                 MESSAGE.  WAIT IS FORCED.  OCWRT IS CALLED TO
*D*                 QUEUE THE WRITE.
         SPACE    1
MSROCRD  LC       J:JIT
         BCS,8    0,R7              ONLINE - RETURN TO REPORT EOF
         AI,R7    1                 INCR RETURN
         BAL,R11  BUILDID
         LW,R11   Y001
         STS,R11  WAT,R6            FORCE WAIT
         LI,R2    BA(JB:PROMPT)
         LB,R11   0,R2              CURRENT PROMPT CHAR
         BEZ      OCWRT             NONE
         STB,R11  *R14,R3           PUT IN BUFFER
         AI,R3    1
         SPACE    2
*D*   NAME:         OCWRT
*D*
*D*   ENTRY:        OCWRT10
*D*
*D*   REGISTERS:    ALL VOLATILE EXCEPT R6
*D*
*D*   CALL:         BAL,R7
*D*
*D*   INTERFACE:    NEWQNWM
*D*
*D*   INPUT:        R3 = # BYTES TO WRITE
*D*                 R6 = DCB ADDRESS, DCB:DSI CONTAINS DCT INDEX
*D*                   (OCWRT ONLY)
*D*                 R7 = LINK
*D*                 R12 = DCT INDEX (OCWRT10 ONLY)
*D*                 R14 = WA OF MPOOL CONTAINING MESSAGE
*D*
*D*   DESCRIPTION:  NEWQNWM IS CALLED TO WRITE OUT THE MESSAGE.
*D*                 END ACTION ADDRESS AND INFORMATION ARE SPECIFIED
*D*                 SO THAT THE MPOOL BUFFER WILL BE RELEASED AT I/O
*D*                 COMPLETION.
         SPACE    1
OCWRT    LI,R12   X'FF'
         AND,R12  DSI,R6
OCWRT10  OR,R12   OCINFO            RETRIES,PRIO,FUNCTION CODE
         LW,R13   R14
         SLS,R13  2                 BA OF BUFFER
         LW,R1    R14               EAI IS BUFFER ADDRESS
         LI,R0    RMB               END ACTION ADDRESS
         LW,R14   R3                BYTE COUNT
         LW,R11   S:CUN
         STB,R11  R1                USER # IN EAI FOR MSRWRT10
         BAL,R11  NEWQNWM           QUEUE THE I/O
         NOP
         B        0,R7
         TITLE    '****  BUILDID  ****'
         SPACE    2
*D*   NAME:         BUILDID
*D*
*D*   REGISTERS:    R0-R3, R14 VOLATILE
*D*
*D*   CALL:         BAL,R11
*D*
*D*   INTERFACE:    IOGETBF, PULLEXIT
*D*
*D*   OUTPUT:       R3 = # BYTES PLACED IN MPOOL
*D*                 R14 = WA OF MPOOL BUFFER
*D*
*D*   DESCRIPTION:  IOGETBF IS CALLED TO GET AN MPOOL BUFFER.
*D*                 A CARRIAGE RETURN, THE USER'S SYSID AND A
*D*                 COLON ARE PLACED IN THE MPOOL.
*D*                 THE FOLLOWING CHARACTERS ARE ADDED:
*D*                   COMMAND PROCESSOR RUNNING - A BLANK.
*D*                   GHOST USER - ONE TAB.
*D*                   ONLINE OR BATCH USER - TWO TABS.
         SPACE    1
BUILDID  PUSH     R11
         BAL,R11  IOGETBF           GET AN MPOOL
*
         LI,R1    CR
         STB,R1   *R14              CARRIAGE RETURN
         LI,R3    1                 CURRENT BYTE DISPL
*
         LI,R2    4                 MAX # CHARS IN SYSID
         LW,R1    J:JIT
         SLS,R1   16                LEFT JUSTIFY SYSID
BLDID10  LI,R0    0
         SLD,R0   4                 GET NEXT CHAR
         AI,R0    0
         BNEZ     BLDID20           NOT A ZERO
         CI,R3    1
         BE       BLDID30           IGNORE LEADING ZEROS
BLDID20  AI,R0    'A'-10
         CI,R0    'A'
         BGE      %+2
         AI,R0    '0'-'A'+10
         STB,R0   *R14,R3
         AI,R3    1
BLDID30  BDR,R2   BLDID10
*
         LI,R1    ':'
         STB,R1   *R14,R3           COLON
         AI,R3    1
         LI,R2    -8
         LC       J:JIT             IS THIS A GHOST?
         BCR,4    GETACCT           IF NOT MOVE ACCOUNT #
         LI,R0    '('               BRACKET THE GHOST'S NAME
         STB,R0   *R14,R3           ...WITH PARENTHESES
         AI,R3    1
         LI,R1    MAXG              GET # OF GHOST SLOTS
         LI,R0    X'FFFF'           GET MASK, AND THEN
         AND,R0   J:JIT             GRAB THE USER NUMBER
GETGHOST CB,R0    SB:GJOBUN,R1      IS THIS THE RIGHT ONE?
         BE       GOTGHOST          IF SO USE IT
         BDR,R1   GETGHOST          IF NOT TRY THE NEXT GHOST
         AI,R3    -1                BACK UP OVER '('
         LI,R2    -8                THIS GHOST ISN'T IN THE TABLE??
         B        GETACCT           SO DO ONLINE-STYLE STUFF
GOTGHOST SLS,R1   3                 BYTE INDEX A DW TABLE
         LB,R2    S:GJOBTBL,R1      GET LENGTH OF NAME
         AI,R1    1                 POINT TO START OF NAME
MOVEGHOST LB,R0   S:GJOBTBL,R1      GET CHAR OF GJOB NAME
         STB,R0   *R14,R3           SAVE IT IN THE BUFFER
         AI,R1    1
         AI,R3    1
         BDR,R2   MOVEGHOST
         LI,R0    ')'               END OF GHOST NAME
         STB,R0   *R14,R3
         AI,R3    1
         CI,R3    9                 LONG NAME?
         BL       GOTACT1           IF NOT THEN TAB
         LI,R0    ' '               GET A BLANK
         LI,R1    3                 # OF BLANKS TO INSERT
         STB,R0   *R14,R3           SAVE THE BLANK
         AI,R3    1                 BUMP THE POINTER
         BDR,R1   %-2               GO BACK FOR NEXT BLANK
         B        FINID             GO FINISH UP
GETACCT  LB,R1    J:UNAME,R2        MOVE ACCOUNT TO MPOOL
         CI,R1    ' '               ONLY MOVE NON BLANKS
         BE       GOTACCT
         STB,R1   *R14,R3
         AI,R3    1
         BIR,R2   GETACCT
GOTACCT  EQU      %
         LI,R1    ' '               BLANK
*
         LW,R2    S:CUN
         LH,R2    UH:FLG,R2
         CI,R2    TIC
         BAZ      GOTACT1           NOT SHARED PROCESSOR
         LW,R2    S:CUN             GET CURRECT USER NUMBER
         LB,R2    UB:ACP,R2         GET SHARED PROCESSOR NO.
         LW,R0    TLGN              IS CURRENT PROCESSOR LOGON
         SLS,R2   1                 DOUBLE WORD TABLE
         CW,R0    P:NAME,R2
         BNE      GOTACT1           BIF NOT LOGON
         LW,R0    TLGN+1            CHECK SECOND HALF OF WORD
         CW,R0    P:NAME+1,R2
         BNE      GOTACT1           BIF NOT LOGON
         LI,R1    ' '               RESTORE BLANK
         B        ENDID             LOGON WILL DO OWN TABBING
GOTACT1  EQU      %                 SET UP TABBING
         LI,R1    TAB
         STB,R1   *R14,R3
         AI,R3    1
FINID    EQU      %
         LC       J:JIT
         BCS,4    PULLEXIT          GHOST - ONLY ONE TAB
         CI,3     11                * ** ARE WE AT FIRST TAB STOP?
         BG       PULLEXIT          * ** YES? SKIP EXTRA TAB INSERT
ENDID    STB,R1   *R14,R3
         AI,R3    1
         B        PULLEXIT
         END

