From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 30-AUG-1989 09:50
To:	MRGATE::"ARISIA::EVERHART"
Subj:	SNAP part 6 of 8

Message-Id:  <8908301317.AA09812@crdgw1.ge.com>
Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 30 AUG 89 05:48:20 PDT
Received: from drcvax.af.mil by KL.SRI.COM with TCP; Wed, 30 Aug 89 05:31:59 PDT
Date: 30 Aug 89 08:27:00 EST
From: "Daniel J. Graham" <graham@drcvax.af.mil>
Subject: SNAP part 6 of 8
To: "info-vax" <info-vax@kl.sri.com>

-+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+
X`0091`009//LASTLOG
X`009    UAF_LINE(5) = ' Lgicmd:  '//LGICMD
X`009    UAF_LINE(6) = '   Prio:      '//PRIBP//'   Pgflquo:  '
X`0091`009//PGFL//'   WSdef:  '//WSD
X`009    UAF_LINE(7) = '   Maxjobs:'//MAXJ//'   Prclm:        '
X`0091`009//PRCLIM//'   WSquo:  '//WSQ
X`009    UAF_LINE(8) = '   Enqlm:  '//ENQ//'   Fillm:     '//FILP//
X`0091`009'   WSext:  '//WSE
X`009    UAF_LINE(9) = '   Bytlm: '//BYTL
X
X`009    OPT_ROW = 12
X`009    OPT_COL = 72
X`009    STATUS = SMG$CREATE_VIRTUAL_DISPLAY(OPT_ROW,OPT_COL,VD3_ID,
X`0091`009SMG$M_BORDER)
X`009    STATUS = SMG$LABEL_BORDER (
X`0091`009VD3_ID,'UAF Data',SMG$K_TOP,,SMG$M_REVERSE)
X`009    DO I = 1,9
X`009`009STATUS = SMG$PUT_CHARS (VD3_ID,UAF_LINE(I),
X`0091`009%REF(I),%REF(1),,,)
X`009    ENDDO
X`009    STATUS = SMG$PUT_CHARS (VD1_ID,'    Press RETURN to continue...',
X`0091`009%REF(23),%REF(8),,,)
X`009    STATUS = SMG$PASTE_VIRTUAL_DISPLAY (
X`0091`009VD3_ID,PB_ID,%REF(5),%REF(5))
X`009    STATUS = SMG$SET_CURSOR_ABS(VD1_ID,%REF(23),%REF(32))
X`009    STATUS = SMG$READ_KEYSTROKE (KB_ID,DUMMY)
X`009    STATUS = SMG$DELETE_VIRTUAL_DISPLAY (VD3_ID)
X`009ENDIF
X
X`009STATUS = SMG$CHANGE_RENDITION(VD1_ID,%REF(24),CUR_COL,
X`0091   `009%REF(1),%REF(8),SMG$M_NORMAL)
X`009STATUS = SMG$ERASE_DISPLAY (VD2_ID)
X`009GOTO 5
X
X999`009STATUS = SYS$SETPRI(,,%VAL(4),)
X`009STATUS = SMG$DELETE_VIRTUAL_DISPLAY (VD1_ID)
X`009STATUS = SMG$DELETE_VIRTUAL_DISPLAY (VD2_ID)
X`009STATUS = SMG$DELETE_PASTEBOARD (PB_ID)
X`009END
$ CALL UNPACK SNAP.FOR;15 624548793
$ create/nolog 'f'
X$! This command porcedure runs the WATCH program from SNAP.  The foreign`032
X$! command SNAP must be defined for it to reinvoke SMAP.
X$!
X$ ON ERROR THEN CONTINUE
X$ WATCH := $SYS$DISK:`091`093WATCH.EXE
X$ WATCH 'P1
X$ DEFINE/USER_MODE SYS$INPUT 'F$LOGICAL("TT")
X$ SNAP
$ CALL UNPACK VIEW.COM;1 102632975
$ create/nolog 'f'
X;Last Modified:   6-SEP-1988 14:19:55.00, By: RLB`032
X
X`009`009.TITLE`009WATCH - Watch terminal output stream
X`009`009.LIBRARY`009/SYS$LIBRARY:LIB/
X`009`009.LINK`009`009'SYS$SYSTEM:SYS.STB'/SELECTIVE_SEARCH
X`009`009$CCBDEF`009`009`009`009; Channel control block offsets
X`009`009$IPLDEF`009`009`009`009; Define IPL levels
X`009`009$TTYDEF`009`009`009`009; Define term driver structures
X`009`009$TTYDEFS`009`009`009;  ditto
X`009`009$TTYMDMDEF`009`009`009; Define modem control signals
X`009`009$TTYVECDEF`009`009`009; Define port/class vectors
X`009`009$TT2DEF`009`009`009`009; Define terminal chars
X`009`009$SSDEF`009`009`009`009; Define system service returns
X`009`009$DVIDEF`009`009`009`009; GETDVI definitions
X`009`009$DYNDEF`009`009`009`009; Dynamic memory struct types
X`009`009$FKBDEF`009`009`009`009; Define fork block
X
X`009`009.PSECT`009$DATA`009RD, WRT, NOEXE, NOSHR, LONG
X
XWAIT:`009`009.BLKQ`009`0091`009`009; Flush timer quadword
XTERM_IOSB:`009.BLKQ`009`0091`009`009; Terminal output IOSB
XINPUT_IOSB:`009.BLKQ`009`0091`009`009; Terminal input IOSB
XMBX_IOSB:`009.BLKQ`009`0091`009`009; Mailbox IOSB
XUSER_IOSB:`009.BLKQ`009`0091`009`009; User IOSB
XUSER_UCB:`009.BLKL`009`0091`009`009; User's terminal UCB
X
XTERM_CHARS:`009.BLKL`009`0093`009`009; Terminal characteristics
XORIG_CHARS:`009.BLKL`009`0093`009`009; Original characteristics
X
XNAME_ARGS:`009.LONG`009`0093`009`009; Arg list for find UCB routine
XDESCR:`009`009.BLKL`009`0091`009`009; Device name descr address
XUCB:`009`009.BLKL`009`0091`009`009; Returned UCB address
XPUCB:`009`009.BLKL`009`0091`009`009; Returned phys UCB address
X
XSEND_ARGS:`009.LONG`009`0091`009`009; Arg list for send char routine
XSEND_CHAR:`009.BLKL`009`0091`009`009; Character to send
X
XTERM_EF:`009.BLKL`009`0091`009`009; Terminal output EF
XINPUT_EF:`009.BLKL`009`0091`009`009; Terminal input EF
XMBX_EF:`009`009.BLKL`009`0091`009`009; Mailbox event flag
XMBX_SIZE:`009.LONG`009`009512`009`009; Size of terminal mailbox
XMBX_QUO:`009.LONG`009`0092048`009`009; Quota for terminal mailbox
X
XT_NAME:`009`009.LONG`009`00964`009`009; Descriptor for terminal name
X`009`009.ADDRESS`009NAME_BUF
X
XDVI_LIST:`009.WORD`009`00964`009`009; GETDVI item list for
X`009`009.WORD`009`009DVI$_DEVNAM`009; Getting mailbox device name
X`009`009.ADDRESS`009MBX_NAME
X`009`009.ADDRESS`009MBX_DESC
X`009`009.LONG`009`0090
X`009`009.LONG`009`0090
X
XMBX_DESC:`009.BLKL`009`0091`009`009; Descriptor for data mailbox
X`009`009.ADDRESS`009MBX_NAME`009; Device name
XMBX_NAME:`009.BLKB`009`00964
X
XEXIT_BLOCK:`009.BLKL`009`0091`009`009; Link
X`009`009.ADDRESS`009EXIT_HANDLER`009; Handler
X`009`009.LONG`009`0091
X`009`009.ADDRESS`009EXIT_CODE`009; Exit reason
XEXIT_CODE:`009.BLKL`009`0091
X
XFLAGS:`009`009.LONG`009`0090`009`009; Status flags
XMBX_CHAN:`009.BLKW`009`0091`009`009; Terminal Mailbox Channel
XINPUT_CHAN:`009.BLKW`009`0091`009`009; user input channel
XUSER_MBX:`009.BLKW`009`0091`009`009; User input mailbox chan
X`009`009.ALIGN`009LONG
X
XNAME_BUF:`009.BLKB`009`00964`009`009; Terminal name input buffer
XMBX_BUF:`009.BLKB`009`0092048`009`009; Mailbox buffer
XINPUT_MBX_BUF:`009.BLKB`009`009512`009`009; Buffer for term mailbox
XINPUT_BUF:`009.BLKB`009`00980`009`009; Input buffer
XWHICH:`009`009.ASCID`009`009/What terminal:/
XUSER_TERM:`009.ASCID`009`009/SYS$COMMAND/`009; User's terminal for output
XTIMER:`009`009.ASCID`009`009/0 00:00:00.10/`009; Wait for one tenth second
XENABLED:`009.ASCID`009`009/Input mode enabled - `094\ to disable/
XDISABLED:`009.ASCID`009`009/Input mode disabled/
XNOT_SUPPORTED:`009.ASCID`009`009/You can't WATCH that terminal/<13><10>
XNOT_YOUR_OWN:`009.ASCID`009`009/You can't WATCH your own terminal/<13><10>
X`012
X`009`009.MACRO`009STATUS ?L1
X`009`009BLBS`009R0, L1
X`009`009$EXIT_S`009R0
XL1:
X`009`009.ENDM`009STATUS
X`012
X`009`009.SBTTL`009WATCH - Setup entry point
X
X`009`009.PSECT`009$CODE`009RD, NOWRT, SHR, EXE, LONG
X`009`009.ENTRY`009WATCH, `094M<>
X
X`009`009$BINTIM_S`009TIMBUF=TIMER,-`009`009; Convert delay to
X`009`009`009`009TIMADR=WAIT`009`009;  binary
X`009`009STATUS
X;+
X;`009Assign a channel to the user's terminal with an
X;`009associated mailbox.
X;-
X`009`009PUSHAL`009`009USER_MBX`009`009; Channel for user mailbox
X`009`009PUSHAL`009`009INPUT_CHAN`009`009; Channel for user term
X`009`009PUSHAL`009`009MBX_SIZE`009`009; And message size
X`009`009PUSHAL`009`009MBX_QUO`009`009`009; Quota
X`009`009PUSHAL`009`009USER_TERM`009`009; Device name
X`009`009CALLS`009`009#5,G`094LIB$ASN_WTH_MBX`009; Assign the channel
X`009`009STATUS
X;+
X;`009Get the UCB address of the user's terminal for later checks
X;-
X`009`009$CMKRNL_S ROUTIN=GET_USER_UCB
X`009`009STATUS
X;+
X;`009Get the user terminal characteristics
X;-
X`009`009$QIOW_S`009`009CHAN=INPUT_CHAN,-
X`009`009`009`009FUNC=#IO$_SENSEMODE,-
X`009`009`009`009P1=ORIG_CHARS, P2=#12
X`009`009STATUS
X`009`009MOVQ`009`009ORIG_CHARS, TERM_CHARS`009; Copy for mods
X`009`009MOVL`009`009ORIG_CHARS+8, TERM_CHARS+8
X;+
X;`009Allocate event flags
X;-
X`009`009PUSHAL`009`009MBX_EF`009`009`009; Get the mailbox EF
X`009`009CALLS`009`009#1,G`094LIB$GET_EF
X`009`009STATUS
X`009`009PUSHAL`009`009TERM_EF
X`009`009CALLS`009`009#1,G`094LIB$GET_EF
X`009`009STATUS
X`009`009PUSHAL`009`009INPUT_EF
X`009`009CALLS`009`009#1,G`094LIB$GET_EF
X`009`009STATUS
X;+
X;`009Create the data mailbox, and get it's UCB address
X;-
X`009`009$CREMBX_S`009CHAN=MBX_CHAN,-`009`009; Create the mailbox
X`009`009`009`009MAXMSG=#2048
X`009`009STATUS
X`009`009$GETDVI_S`009CHAN=MBX_CHAN,-`009`009; Get the mailbox name
X`009`009`009`009ITMLST=DVI_LIST,-
X`009`009`009`009EFN=#1
X`009`009STATUS
X`009`009$WAITFR_S`009EFN=#1
X`009`009STATUS
X`009`009MOVAL`009MBX_DESC, DESCR`009`009; Point to mailbox descriptor
X`009`009$CMKRNL_S`009ROUTIN=FIND_UCB,-
X`009`009`009`009ARGLST=NAME_ARGS
X`009`009STATUS
X`009`009MOVL`009UCB, MBX_UCB`009`009; Point to mailbox UCB
X;+
X;`009Get the name of the terminal to slave
X;+
XSTART:`009`009PUSHAL`009T_NAME`009`009`009; Return length
X`009`009PUSHAL`009WHICH`009`009`009; Prompt
X`009`009PUSHAL`009T_NAME`009`009`009; Return buffer
X`009`009CALLS`009#3, G`094LIB$GET_FOREIGN`009; Get the terminal name
X`009`009STATUS
X`009`009MOVAL`009NAME_BUF, R0`009`009; Check for trailing colon
X10$:`009`009CMPB`009(R0), #`094A/:/`009`009; Is it a colon?
X`009`009BEQL`00930$`009`009`009; Yup, all done
X`009`009CMPB`009(R0), #`094A/ /`009`009; A space?
X`009`009BNEQ`00920$`009`009`009; Nope.
X`009`009MOVB`009#`094A/:/,(R0)`009`009; Yes.. add colon.
X`009`009BRB`00930$`009`009`009; All done
X20$:`009`009INCL`009R0`009`009`009; Point to next
X`009`009BRB`00910$`009`009`009; Loop back
X;+
X;`009Uppercase the string and find the UCB
X;-
X30$:`009`009PUSHAL`009T_NAME
X`009`009PUSHAL`009T_NAME
X`009`009CALLS`009#2, G`094STR$UPCASE`009; Upcase it
X; Put getdvi here...
X`009`009MOVAL`009T_NAME, DESCR`009`009; Point kernel routine to arglist
X`009`009$CMKRNL_S`009ROUTIN=FIND_UCB,-; Find the device UCB
X`009`009`009`009ARGLST=NAME_ARGS
X`009`009STATUS
X`009`009MOVL`009UCB, TERM_UCB`009`009; Store UCB for it
X`009`009TSTL`009PUCB`009`009`009; Is it virtual?
X`009`009BEQL`00940$`009`009`009; Nope.
X`009`009MOVL`009PUCB, TERM_UCB`009`009; Yes, use physical
X
X40$:`009`009CALLS`009#0, G`094SET_EXIT`009`009; Declare the exit handler
X
X`009`009CMPL`009TERM_UCB, USER_UCB`009; Same UCB address as user's?
X`009`009BNEQ`00950$`009`009`009; Branch if not
X`009`009PUSHAL`009NOT_YOUR_OWN`009`009; Push message address
X`009`009CALLS`009#1, G`094LIB$PUT_OUTPUT`009; Display the message
X`009`009$EXIT_S`009`009`009`009; And exit
X;+
X;`009Set it to PASTHRU mode
X;-
X50$:`009`009BISL2`009`009#TT2$M_PASTHRU, TERM_CHARS+8
X`009`009$QIOW_S`009`009CHAN=INPUT_CHAN,-
X`009`009`009`009FUNC=#IO$_SETMODE,-
X`009`009`009`009P1=TERM_CHARS, P2=#12
X`009`009STATUS
X`012
X;+
X;`009Load the magic code into nonpaged pool
X;-
X`009`009$CMKRNL_S`009ROUTIN=LOAD_CODE; Load the code and set hook
X`009`009CMPL`009R0, #SS$_IVDEVNAM`009; Legal device to watch ?
X`009`009BNEQ`00960$`009`009`009; Branch it okay so far
X`009`009PUSHAL`009NOT_SUPPORTED`009`009; Push message dsc pointer
X`009`009CALLS`009#1, G`094LIB$PUT_OUTPUT`009; Display "non-supported" msg
X`009`009$EXIT_S`009`009`009`009; And just exit
X
X60$:`009`009STATUS
X`009`009BSBW`009SETUP_TERM_AST`009`009; Set up AST for terminal
X`009`009$SETIMR_S`009DAYTIM=WAIT,-`009; Set up the flush timer
X`009`009`009`009ASTADR=FLUSH
X`009`009STATUS
X`009`009CLRQ`009-(SP)`009`009`009; At top of screen..
X`009`009CALLS`009#2, G`094SCR$ERASE_PAGE`009; Erase it
X`009`009STATUS
X;+
X;`009Fall thru to begin reading the mailbox.
X;-
X`012
X`009`009.SBTTL`009MBX_READ - Read messages and echo
X;+
X;`009Read and echo the mailbox message
X;-
XMBX_READ:`009$QIOW_S`009`009EFN=MBX_EF,-`009`009; Read the mailbox
X`009`009`009`009CHAN=MBX_CHAN,-
X`009`009`009`009FUNC=#IO$_READVBLK,-
X`009`009`009`009IOSB=MBX_IOSB,-
X`009`009`009`009P1=MBX_BUF,P2=#2048
X`009`009STATUS`009`009`009`009`009; Check QIO Status
X`009`009MOVZWL`009MBX_IOSB, R0`009`009`009; Check I/O status
X`009`009STATUS
X`009`009MOVZWL`009MBX_IOSB+2, R1
X`009`009$QIOW_S`009`009EFN=TERM_EF,-`009`009; Write the text
X`009`009`009`009IOSB=TERM_IOSB,-
X`009`009`009`009CHAN=INPUT_CHAN,-
X`009`009`009`009FUNC=#IO$_WRITEVBLK,-
X`009`009`009`009P1=MBX_BUF, P2=R1
X`009`009STATUS
X`009`009MOVZWL`009TERM_IOSB, R0
X`009`009STATUS
X`009`009BRW`009MBX_READ`009`009`009; Read another
X`012
X;+
X; Get the user's UCB address
X;-
X`009`009.ENTRY GET_USER_UCB`094M<R2>
X`009`009MOVL`009INPUT_CHAN, R0`009`009; Get channel number
X`009`009JSB`009G`094IOC$VERIFYCHAN`009; Get UCB address
X`009`009BLBC`009R0, 10$`009`009`009; Branch on error
X`009`009MOVL`009CCB$L_UCB(R1), R2`009; Get the UCB address
X`009`009MOVL`009UCB$L_TL_PHYUCB(R2),USER_UCB ; Get the physical ucb
X10$:`009`009RET
X
X`012
X;+
X;`009Exit handler setup
X;-
X`009`009.ENTRY`009SET_EXIT,`094M<>
X`009`009$DCLEXH_S`009DESBLK=EXIT_BLOCK ; Declare exit handler
X`009`009RET`009`009
X`012
X`009`009.SBTTL`009EXIT_HANDLER, Exit reset handler
X`009`009.ENTRY`009EXIT_HANDLER,`094M<>
X`009`009$QIOW_S`009`009CHAN=INPUT_CHAN,-`009; Reset the term
X`009`009`009`009FUNC=#IO$_SETMODE,-
X`009`009`009`009P1=ORIG_CHARS,-
X`009`009`009`009P2=#12
X`009`009$QIOW_S`009`009EFN=TERM_EF,-`009`009; Write the text
X`009`009`009`009CHAN=INPUT_CHAN,-
X`009`009`009`009FUNC=#IO$_WRITEVBLK,-
X`009`009`009`009P1=EXIT_MESSAGE, P2=#EXIT_SIZE
X`009`009MOVL`009CODE_PTR, R0
X`009`009BEQL`00910$
X`009`009MOVAL`009RESET-KERNEL_CODE(R0), R0
X`009`009$CMKRNL_S`009ROUTIN=(R0)`009`009; Call fixup
X`009`009BLBC`009R0, 20$
X`009`009$CMKRNL_S`009ROUTIN=FREE_POOL`009; Free pool
X`009`009BLBC`009R0, 20$
X10$:`009`009MOVL`009#SS$_NORMAL, R0
X20$:`009`009RET
XEXIT_MESSAGE:`009.ASCII`009/Exiting.../
XEXIT_SIZE = .-EXIT_MESSAGE
X`012
X`009`009.SBTTL`009FLUSH - Flush the ring
X`009`009.ENTRY`009FLUSH, `094M<>
X`009`009$SETIMR_S`009DAYTIM=WAIT,-
X`009`009`009`009ASTADR=FLUSH
X`009`009STATUS
X`009`009MOVL`009CODE_PTR, R0
X`009`009MOVAL`009FLUSH_RING-KERNEL_CODE(R0), R0
X`009`009$CMKRNL_S`009ROUTIN=(R0)`009`009; Call the flusher
X`009`009STATUS
X`009`009RET
X`012
X`009`009.SBTTL`009FIND_UCB - Locate the device UCB
X;
X;`009This routine finds the address of the UCB for a specified
X;`009device.
X;
X;`009Arguments:
X;`009DESCR`009Address of device name descriptor
X;`009UCB`009Return pointer to `091virtual`093 UCB
X;`009PUCB`009Return pointer to `091physical`093 UCB, zero if none.
X;
X;`009This routine executes in Kernel mode at elevated IPL
X;
X`009`009.ENTRY`009FIND_UCB,`094M<R2,R3,R4,R5>
X`009`009CLRQ`0098(AP)`009`009`009; Clear UCB pointers
X`009`009MOVL`009G`094ctl$GL_PCB, R4`009; Get current PCB pointer
X`009`009JSB`009G`094SCH$IOLOCKR`009`009; Lock I/O database for read
X`009`009MOVL`0094(AP), R1`009`009; Point to device descr
X`009`009JSB`009G`094IOC$SEARCHDEV`009`009; Search for device
X`009`009BLBC`009R0, 10$`009`009`009; Exit on failure
X`009`009MOVL`009UCB$L_TL_PHYUCB(R1),12(AP) ; Return physical UCB
X`009`009MOVL`009R1, 8(AP)`009`009; Return UCB
X`009`009BBC`009#DEV$V_DET, UCB$L_DEVCHAR2(R1),-
X`009`009`00910$`009`009`009; Skip if not detached
X`009`009MOVL`009#SS$_DEVOFFLINE, R0`009; Say it's offline
X10$:`009`009PUSHL`009R0`009`009`009; Save status
X`009`009JSB`009G`094SCH$IOUNLOCK`009`009; Unlock the I/O database
X`009`009POPL`009R0
X`009`009RET`009`009`009`009; And return
X`012
X`009`009.SBTTL`009LOAD_CODE - Load hook code into pool
X
X`009`009.ENTRY`009LOAD_CODE,`094M<R2,R3,R4,R5>
X`009`009DSBINT`009#IPL$_ASTDEL`009`009; Stop ast delivery
+-+-+-+-+-+-+-+-  END  OF PART 6 +-+-+-+-+-+-+-+-


