;**********************************************************************
;*
;*                      BOOTUP.LIT
;*
;**********************************************************************

; WRITTEN AT: Victorex, Inc., 1529 Cypress Street, Suite 103, Walnut
; Creek, California 94596 (415) 943-1023.

; AUTHOR: John V. Kjellman

; PURPOSE: To provide a log of every system bootup, as an aid to
; monitoring system reliability.

; ENVIRONMENT: Any AM-100/L or AM-1000 running under AMOS/L

; DESCRIPTION/LIMITATIONS: Program adds a dated entry to DSK0:BOOTUP.-
; LOG[1,4] every time it is executed.  It must be run from a job
; logged-in to [1,*], and is normally run in [1,4].  In order for
; program to monitor system boots it must be installed in every
; AMOSL.INI file used on the system, usually somewhere after the
; final SYSTEM command.  In addition to the date and time, each log
; entry includes the high and low bytes of the system status word
; (FFFFF0) at the time of bootup.  This word MAY contain Status
; Display Codes that are useful in determining the reason the system
; was rebooted, and possibly the cause of a prior system crash.

; BOOTUP.LOG can be VUEed, PRINTed, or TYPEd.  Periodically it should
; be ERASEd to reduce disk space.  BOOTUP automatically creates a
; new file if one does not exist.

; REVISION HISTORY:
; 09/19/83,Rev0; New program;jvk

; HASH TOTAL: 411-741-411-755 (9/19/83)

; REGISTER & STACK USAGE


       SEARCH  SYS
       SEARCH  SYSSYM

; Process system date and time (Need LNKLIT to process LIT file)
       EXTERN  $ODTIM

DDBSIZ=D.DDB            ; Define DDB size

VMAJOR=1
VMINOR=0
VSUB=11.                ; Victorex code (K)
VEDIT=100.              ; Revision 0
VWHO=0

       PHDR    -1,0,PH$REU!PH$REE

; Allocate memory module for DDB
       PUSH    #D.DDB          ; Size of DDB
       PUSH                    ; Push 2nd long word for GETMEM
       GETMEM  @SP             ; Allocate impure mem module
       BNE     NOMEM
       POP     A5              ; Index mem module
       POP                     ; Restore SP
       CLEAR   @A5,D.DDB       ; Clear memory

       CALL    OPNLOG          ; Open output file log
       CLR     D3              ; Clr for use with next call
       CLR     D5              ; Clear D5 for use as flag
       ORW     #100000,D5      ; Set bit for date output
       MOV     A5,A2           ; Set up A2 indexing DDB
       CALL    $ODTIM          ; Output current date and time
       CLR     D1
       MOVB    WHYBOT+1,D1     ; High byte of Status Display Word
       OCVT    3,64            ; Output to file
       MOVB    WHYBOT,D1       ; Low byte
       OCVT    3,4             ; Output to file
       LEA     A4,CRLF$        ; C/R, L/F
       OUTL    @A4,OT$DDB      ; Output CR, LF
       CLOSE   @A5
       EXIT

NOMEM:  TYPECR  <?Insufficient memory>
       EXIT

; Open output file log
OPNLOG: LEA     A2,FILNAM       ; Index name of output file
       FSPEC   @A5             ; Put name into DDB
       INIT    @A5             ; Initialize a buffer module
       LOOKUP  @A5             ; Does the file exist?
       BNE     NEWLOG          ; Br to open new file
       OPENA   @A5             ; Else open to append to old file
       RTN
NEWLOG: OPENO   @A5             ; Open new file
       RTN

FILNAM: ASCII   $DSK0:BOOTUP.LOG[1,4]$
       BYTE    0
       EVEN

CRLF$:  BYTE    15,0            ; C/R (L/F is automatic)
       EVEN

       END