From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP 16-AUG-1988 17:06
To:	ARISIA::EVERHART
Subj:	ZDEC for VMS 5.0


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue, 16 AUG 88 09:53:34 PDT
Received: from WPAFB-AAMRL.ARPA by KL.SRI.COM with TCP; Tue, 16 Aug 88 09:27:38 PDT
Received: from FALCON by WPAFB-AAMRL.ARPA; Tue, 16 Aug 88 12:24 EDT
Date: Tue, 16 Aug 88 12:25 EDT
From: Ted Nieland - SRL <@WPAFB-AAMRL.ARPA:TNIELAND@FALCON>
Subject: ZDEC for VMS 5.0
To: info-vax@kl.sri.COM
X-VMS-To: IN%"info-vax@kl.sri.com"

Here is ZDEC that runs under VMS version 5.0

--------------------------------------------------------------------------------
|                M. Edward (Ted) Nieland - Systems Analyst                     |
|------------------------------------------------------------------------------|
| US Snail:                            | Arpa Internet:                        |
| Systems Research Laboratories, Inc.  | TNIELAND@WPAFB-AAMRL.ARPA             |
| 2800 Indian Ripple Road   WP 196     | TNIELAND%FALCON@WPAFB-AAMRL.ARPA      |
| Dayton, OH  45440                    |                                       |
|------------------------------------------------------------------------------|
| A T & T:  (513) 255-8846/8760/5156                                           |
--------------------------------------------------------------------------------
...................... Cut between dotted lines and save. .....................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.00 26-May-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user TNIELAND
$! on 14-OCT-1864 22:00:33.11.
$!
$! It contains the following 2 files:
$!        ZDEC.MAR
$!        ZDEC.COM
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.00 26-May-1988 requires VMS V4.4 or higher."
$ EXIT 44 
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY
b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) )
; s_file_spec := GET_INFO( COMMAND_LINE, "output_file" ); SET( OUTPUT_FILE
, b_part, s_file_spec ); b_errors := CREATE_BUFFER( "{Errors}" ); i_errors := 0
; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN 
& "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; POSITION
( BEGINNING_OF( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE 
) = END_OF( b_part ); s_x := ERASE_CHARACTER( 1 ); IF s_x = "+" THEN r_skip 
:= SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <> 0 THEN s_x := ""
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF
; IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF
; IF s_x = "V" THEN s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL
( 1 ); ENDIF; IF s_x = "X" THEN s_x := ""; IF i_append_line <
> 0 THEN APPEND_LINE; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line 
:= 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> "" THEN i_errors := i_errors + 1
; s_text := CURRENT_LINE; POSITION( b_errors ); COPY_TEXT
( "The following line could not be unpacked properly:" ); SPLIT_LINE; COPY_TEXT
( s_x ); COPY_TEXT( s_text ); POSITION( b_part ); MOVE_VERTICAL( 1 ); ENDIF
; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH( "`", FORWARD
, EXACT ); EXITIF r_x = 0; POSITION( r_x ); ERASE_CHARACTER( 1 )
; IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) )
; COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors
, "SYS$COMMAND" ); ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "ZDEC.MAR"
$ CHECKSUM_IS = 1213081465
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X`009.TITLE`009ZDEC Zero Device Error Count
X`009.IDENT`009/1.0/
X;++
X;
X; Title:
X;`009ZDEC.MAR - Zero-out device error count.
X;
X; Version:
X;`0091-001
X;
X; Facility:
X;`009System Management Tools.
X;
X; Abstract:
X;`009This program zeros-out the device error count stored in the
X;`009UCB for a particular device. This is useful when you wish 
X;`009reset this value without booting the machine.
X;
X;`009Calling sequence:
X;
X;`009`009$ ZDEC := $mydev:[mydir]ZDEC
X;`009`009$ ZDEC [/OVERRIDE]  device
X;
X; Environment:
X;`009CMKRNL privilege required, I/O data base is locked, program
X;`009executed at elevated IPL.
X;
X; Author:
X;`009Mark Oakley`009DuPont Experimental Station`00912-Nov-1984
X;`009This program is based upon the VARY program written by
X;`009Gary Grebus of Battelle Columbus Labs.
X;
X; Modifications:
X;
X;  17-Nov-1984`009Mark Oakley`009Added /OVERRIDE to handle allocated devices.
X;
X;  25-Nov-1985`009Mark Oakley`009Modified to correctly secure physical terminal
X;`009`009`009`009name that is associated with a virutal terminal.
X;
X;  23-May-1986`009Mark Oakley`009Modified to zero-out CPU and memory errors.
X;
X;  14-Jul-1988`009Ted Nieland `009Modified to work under VMS 5.0.
X;
X;--
X`012
X`009.SBTTL`009Symbols, Macros, Data
X
X`009.LIBRARY`009/SYS$LIBRARY:LIB.MLB/
X
X`009$TPADEF`009`009; Symbols for LIB$TPARSE.
X`009$SSDEF`009`009; Symbols for return status.
X`009$UCBDEF`009`009; Symbols for device ucb.
X`009$STSDEF`009`009; Symbols for returned status.
X`009$DVIDEF`009`009; Symbols for $GETDVI service.
X`009$DCDEF`009`009; Symbols for device type.
X
X;
X; Macro to handle return codes.
X;
X`009.MACRO`009ON_ERR  THERE,?HERE
X`009BLBS`009R0,HERE
X`009BRW`009THERE
XHERE:`009.ENDM`009ON_ERR
X
X`009.PSECT`009ZDEC_DATA,RD,WRT,NOEXE,LONG,SHR,PIC
X
XCMD_BUF:`009`009`009; Buffer to hold command line.
X`009.BLKB`00980
XCMD_BUF_SIZ = . - CMD_BUF
X
XCMD_BUF_DESC:`009`009`009; Descriptor to command line.
X`009.LONG`009 CMD_BUF_SIZ
X`009.ADDRESS CMD_BUF
X
XPROMPT:
X`009.ASCID`009/Device: /
X
XPARSE_BLK:`009`009`009; Parse block for LIB$TPARSE.
X`009.LONG`009TPA$K_COUNT0
X`009.LONG`009TPA$M_ABBREV`009; Permit unambiguous abbreviations.
X`009.BLKB`009TPA$K_LENGTH0-8
X
XOVERRIDE:`009`009`009; Zero out allocated devices, if set.
X`009.LONG`0090
X
XLOG_DEV_DESC:`009`009`009; Descriptor for device on command line.
X`009.BLKQ`0091
X
XCPU_STG:`009`009`009; Used to compare against command line parm.
X`009.ASCII`009/CPU/
X
XMEM_STG:`009`009`009; Used to compare against command line parm.
X`009.ASCII`009/MEMORY/
X`012
XDEV_BUF:`009`009`009; Buffer to hold device name.               
X`009.BLKB`00940
XDEV_BUF_SIZ = . - DEV_BUF
X
XDEV_BUF_DESC:`009`009`009; Descriptor pointing to device name.
X`009.LONG`009 DEV_BUF_SIZ
X`009.ADDRESS DEV_BUF
X
XPID:`009`009`009`009; Owner of device (if any).
X`009.BLKL`0091
X
XDEV_ITEM_LIST:`009`009`009; Device list for $GETDVI.
X`009.WORD`009 DEV_BUF_SIZ`009; Make sure we a have a physical device name.
X`009.WORD`009 DVI$_DEVNAM
X`009.ADDRESS DEV_BUF
X`009.ADDRESS DEV_BUF_DESC
X`009.WORD`009 4`009`009; See if someone has this device allocated.
X`009.WORD`009 DVI$_PID
X`009.ADDRESS PID
X`009.LONG`009 0
X`009.WORD`009 4
X`009.WORD`009 DVI$_DEVCLASS`009; Check for a terminal.
X`009.ADDRESS DEV_CLASS
X`009.LONG`009 0
X`009.LONG`009 0`009`009; End if item list.
X
XTT_ITEM_LIST:`009`009`009; Item list if we have a terminal.
X`009.WORD`009 DEV_BUF_SIZ`009; Make sure we a have a physical device name.
X`009.WORD`009 DVI$_TT_PHYDEVNAM
X`009.ADDRESS DEV_BUF
X`009.ADDRESS DEV_BUF_DESC
X`009.LONG`009 0
X
XDEV_CLASS:
X`009.LONG`0091
X
XK_ARG:`009`009`009`009; Argument list for kernel-mode routine.
X`009.LONG`009 1`009`009; Just one argument.
X`009.ADDRESS DEV_BUF_DESC`009; Pass descriptor for device name.
X`012
X`009.SBTTL`009State Table
X`009.PSECT`009ZDEC_STATES,RD,NOWRT,EXE,LONG,SHR,PIC
X
X`009$INIT_STATE`009STATE_TABLE,KEY_TABLE
X
X`009$STATE`009START
X`009$TRAN`009'/',QUAL
X`009$TRAN`009TPA$_SYMBOL,DEV,,,LOG_DEV_DESC
X`009$TRAN`009TPA$_EOS,TPA$_EXIT
X
X`009$STATE`009DEV
X`009$TRAN`009TPA$_EOS,TPA$_EXIT
X`009$TRAN`009'/',QUAL
X`009$TRAN`009':',COLON
X
X`009$STATE`009COLON
X`009$TRAN`009'/',QUAL
X`009$TRAN`009TPA$_EOS,TPA$_EXIT
X
X`009$STATE`009QUAL
X`009$TRAN`009'OVERRIDE',,,1,OVERRIDE
X`009$TRAN`009'NOOVERRIDE',,CLR_OV
X
X`009$STATE
X`009$TRAN`009TPA$_SYMBOL,DEV,,,LOG_DEV_DESC
X`009$TRAN`009TPA$_EOS,TPA$_EXIT
X
X`009$END_STATE
X
X
X`009.ENTRY`009CLR_OV,^M<>
X`009CLRL`009OVERRIDE
X`009MOVL`009#SS$_NORMAL,R0
X`009RET
X`012
X`009.SBTTL`009Main program
X`009.PSECT`009ZDEC_CODE,RD,NOWRT,EXE,LONG,SHR,PIC
X`009.ENTRY`009ZDEC,^M<R2,R3,R4,R5,R6,R7,R8,R9>
X
X;
X; Get the command line.
X;
X`009PUSHAL`009CMD_BUF_DESC`009`009; Return length.
X`009PUSHAL`009PROMPT`009`009`009; Prompt for device name.
X`009PUSHAL`009CMD_BUF_DESC`009`009; Place to hold line.
X`009CALLS`009#3,G^LIB$GET_FOREIGN
X`009ON_ERR`009EXIT
X
X`009PUSHAL`009CMD_BUF_DESC`009`009; Upper case the input.
X`009PUSHAL`009CMD_BUF_DESC
X`009CALLS`009#2,G^STR$UPCASE
X`009ON_ERR`009EXIT
X
X`009MOVL`009CMD_BUF_DESC,-`009`009; Set length of string to parse.
X`009`009PARSE_BLK+TPA$L_STRINGCNT
X`009MOVL`009CMD_BUF_DESC+4,-`009; Set address of string to parse.
X`009`009PARSE_BLK+TPA$L_STRINGPTR
X`009PUSHAL`009KEY_TABLE`009`009; Parse the command line for
X`009PUSHAL`009STATE_TABLE`009`009; qualifier and device.
X`009PUSHAL`009PARSE_BLK
X`009CALLS`009#3,G^LIB$TPARSE
X`009ON_ERR`009EXIT
X
X;
X; First, check if we are zeroing-out the cpu or memory.
X;
X`009MOVQ`009LOG_DEV_DESC,R6
X`009CMPC3`009R6,(R7),CPU_STG`009`009; Is it the cpu?
X`009BNEQ`00920$
X`009BRW`009DO_CPU
X
X20$:
X`009CMPC3`009R6,(R7),MEM_STG`009`009; Is it the memory?
X`009BNEQ`00940$
X`009BRW`009DO_MEM
X40$:
X`012
X;
X; Get the physical device name, and see if this device has an owner.
X;
X`009$GETDVI_S -
X`009`009DEVNAM=LOG_DEV_DESC,-`009; Command line has device name.
X`009`009ITMLST=DEV_ITEM_LIST
X`009ON_ERR`009EXIT
X
X`009CMPL`009#DC$_TERM,DEV_CLASS`009; Did we get a terminal?
X`009BNEQ`00950$
X`009$GETDVI_S -`009`009`009; Yes, make sure we get the
X`009`009DEVNAM=LOG_DEV_DESC,-`009; physical device name.
X`009`009ITMLST=TT_ITEM_LIST
X`009ON_ERR`009EXIT
X
X50$:
X`009TSTL`009PID
X`009BEQL`00960$
X`009TSTL`009OVERRIDE`009`009; Device is allocated, see if we
X`009BGTR`00960$`009`009`009; should proceed.
X`009MOVL`009#SS$_DEVALLOC,R0`009; Device is allocated, exit with
X`009BRW`009EXIT`009`009`009; error.
X60$:
X
XDO_DEV:
X`009$CMKRNL_S -`009`009`009; Enter k-mode to zero device error
X`009`009ROUTIN=ZERO_DEV,-`009`009; count.
X`009`009ARGLST=K_ARG
X`009ON_ERR`009EXIT
X`009BRW`009EXIT
X
XDO_CPU:
X`009$CMKRNL_S -`009`009`009; Enter k-mode to zero cpu error count.
X`009`009ROUTIN=ZERO_CPU
X`009ON_ERR`009EXIT
X`009BRW`009EXIT
X
XDO_MEM:
X       `009$CMKRNL_S -`009`009`009; Enter k-mode to zero memory error
X`009`009ROUTIN=ZERO_MEM`009`009; count.
X`009ON_ERR`009EXIT
X`009BRW`009EXIT
X
XEXIT:
X`009RET
X`012
X`009.SBTTL`009ZERO_DEV Routine
X;++
X;
X; Functional Description:
X;`009This routine zeros out the error count in the UCB for
X;`009a specified device.
X;
X; Calling Sequence:
X;`009$CMKRNL_S ROUTIN=ZERO_DEV,ARGLST=K_ARG
X;
X;`009`009where K_ARG is an argument list. This list contains
X;`009`009the number of arguments passes (always 1), followed
X;`009`009by the address of a descriptor pointing to the name
X;`009`009of a device.
X;
X; Formal Parameters:
X;`009Descriptor for name of a device.
X;
X; Implicit Inputs:
X;`009I/O database.
X;
X; Implicit Outputs:
X;`009Device error count is set to zero.
X;
X; Completion Status:
X;`009Returned in R0.
X;
X; Side Effects:
X;`009I/O database is locked (routine runs in kernel mode at elevated
X;`009IPL).
X;
X;--
X`012
X`009.ENTRY`009ZERO_DEV,^M<R2,R4>
X
X`009MOVL`009G^CTL$GL_PCB,R4`009;; Our PCB address is input to SCH
X`009`009`009`009`009;; routines.
X`009JSB`009G^SCH$IOLOCKW`009`009;; Lock the I/O database.
X
X`009MOVL`0094(AP),R1`009`009;;; Address of device name descriptor.
X`009JSB`009G^IOC$SEARCHDEV`009`009;;; Get UCB address for device into R1.
X`009ON_ERR`009ZERO_DEV_EXIT
X
X`009TSTL`009UCB$L_PID(R1)`009`009;;; Make sure device did not become
X`009BEQL`00980$`009`009`009;;; allocated.
X`009TSTL`009OVERRIDE`009`009;;; Device is allocated, see if we
X`009BGTR`00980$`009`009`009;;; should proceed.
X`009MOVL`009#SS$_DEVALLOC,R0
X`009BRW`009ZERO_DEV_EXIT
X
X80$:
X`009CLRW`009UCB$W_ERRCNT(R1)`009;;; Zero out the error count.
X`009MOVL`009#SS$_NORMAL,R0
X
XZERO_DEV_EXIT:
X`009PUSHL`009R0`009`009`009;;; Remember status.
X`009JSB`009G^SCH$IOUNLOCK`009`009;;; Unlock I/O database (drop IPL).
X`009POPL`009R0
X
X`009RET
X `012
X`009.SBTTL`009ZERO_CPU, ZERO_MEM Routines
X;++
X;
X;  Functional Description:
X;`009Routines to zero-out error-count location for cpu and memory.
X;
X;  Calling Sequence:
X;`009$CMKRNL_S ROUTIN=ZERO_CPU
X;`009$CMKRNL_S ROUTIN=ZERO_MEM
X;
X;  Input Parameters:
X;`009None.
X;`009
X;  Output Parameters:
X;`009None.
X;
X;  Implicit Inputs:
X;`009Global sysmbols, EXE$GL_MCHKERRS for cpu errors, and
X;`009EXE$GL_MEMERRS for memory errors.
X;
X;  Implicit Outputs:
X;`009None.
X;
X;  Procedures called:
X; `009None.
X;
X;  Completion Status:
X; `009Returned in R0, always successful.
X;
X;  Side Effects:
X;`009None.
X;
X;--
X
X`009.ENTRY`009ZERO_CPU,^M<>
X
X`009CLRL`009EXE$GL_MCHKERRS`009`009; Zero out cpu errors.
X`009MOVL`009#SS$_NORMAL,R0
X
X  `009RET
X
X
X`009.ENTRY`009ZERO_MEM,^M<>
X
X`009CLRL`009EXE$GL_MEMERRS`009`009; Zero out memory errors.
X`009MOVL`009#SS$_NORMAL,R0
X
X`009RET
X`009.END`009ZDEC
$ GOSUB UNPACK_FILE
$ FILE_IS = "ZDEC.COM"
$ CHECKSUM_IS = 1012351633
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ MACRO/LIST  ZDEC
X$ LINK/MAP/FULL ZDEC+SYS$SYSTEM:SYS.STB/SEL
X$ EXIT
$ GOSUB UNPACK_FILE
$ EXIT

