Trailing-Edge
-
PDP-10 Archives
-
k20v7c
-
mfg/src/uptime.mac
There are no other files named uptime.mac in the archive.
TITLE UPTIME
SEARCH MONSYM
P=17
JS1=1
JS2=2
JS3=3
JS4=4
PNT=7
T1=10
T2=11
T3=12
CNT=13
FLG=14
RST=15
UPMINS: Z
UPHRS: Z
CUPTIM: Z
PRVTIM: Z
ACCTIM: Z
RSTDON: Z
RSTTIM: BLOCK ^D15
TIMSTR: BLOCK ^D20
SETSTK: IOWD 5,STACK
STACK: BLOCK 5
;FIRST PART IS A ONE TIME ROUTINE
START: MOVE P,SETSTK
MOVEI RST,1 ;TO SIGNIFY PRGM JUST STARTED
;STORE TIME OF RESTART IN RSTTIM
MOVE JS1,[POINT 7,RSTTIM]
MOVEI T1,"-"
IDPB T1,JS1 ;-
SETOM JS2 ;
HRLZI JS3,(OT%DAY)
ODTIM ;SAVE RESTART TIME IN RSTTIM
HRROI JS2,[ASCIZ/ = Restart Time
/]
MOVEI JS3,^D20 ;LIMIT OF 20 CHRS
MOVEI JS4,0 ;TERM ON NULL
SOUT
;CHECK TO SEE IF UPTIME.TXT EXISTS
STLOOK: HRROI JS2,[ASCIZ/PS:<SYSTEM>UPTIME.INF/]
HRLZI JS1,(GJ%OLD+GJ%SHT)
GTJFN
JUMPA [TIME
CAML JS1,[^D600000]
JUMPA LOOKUP
JUMPA DELAY] ;IF UPTIME.TXT DOSN'T EXIST DON'T DO ANYTHING
HRRZM JS1,T3 ;SAVE JFN OF UPTIME.INF
;NOW CHECK UPTIME TO MAKE SURE SYSTEM WAS RELOADED (NOT JUST THE PROGRAM)
TIME
CAML JS1,[^D600000] ;BEEN UP FOR MORE THAN 10 MINUTES?
JRST APPEND ;YES COULD PRESENT A PROBLEM
;HERE ON SYSTEM STARTUP WHEN UPTIME.INF EXITS TO DO IMMEDIATE LOGGING OF
;RELOAD TIME.
QCKRST: HRRZ JS1,T3 ;RESTORE JFN OF UPTIME.INF
MOVE JS2,[7 B5+OF%APP]
OPENF ;OPEN UPTIME.TXT FOR APPEND
ERJMP ERROR
PUSHJ P,OUTRST ;ADD RESTART LINE
HRLI JS1,0
CLOSF
ERJMP ERROR
MOVEM RST,RSTDON ;TO REM WE ALREADY DID THIS
JRST DELAY
;HERE FOR A LATE START
;SINCE THE SYSTEM HAS BEEN UP FOR A WHILE AND THE PROGRAM PROBABLY WAS
; RUNNING WE DON'T KNOW IF THE UPTIME ON THIS RUN HAS ALREADY BEEN
; ADDED TO THE ACCUM TIME OF PREVIOUS RUNS. SO TAKING NO CHANCES
;APPEND UPTIME.TXT TO UPTIME.OLD-TXT AND DELETE UPTIME.TXT
APPEND: HRRZ JS1,T3 ;RESTOR JFN SAVED IN T3
MOVE JS2,[7 B5+OF%RD]
OPENF ;OPEN UPTIME.TXT FOR READ
ERJMP ERROR
HRROI JS2,[ASCIZ/PS:<SYSTEM>UPTIME.OLD-INF/]
HRLZI JS1,(GJ%SHT)
GTJFN
ERJMP ERROR
MOVEM JS1,T2 ;T2/ JFN OF UPTIME.OLD-TXT
MOVE JS2,[7 B5+OF%APP]
OPENF ;OPEN FILE
ERJMP ERROR
APPLOP: MOVE JS1,T3 ;RESTORE JFN OF UPTIME.TXT
BIN
ERJMP [GTSTS ;ERROR GET STATUS
TLNE JS2,(GS%EOF) ;AT END OF FILE?
JRST ENDAPP
JUMPA ERROR] ;NO POSSIBLY DATA ERROR
HRRZ JS1,T2 ;REST JFN OF UPTIME.OLD-TXT
BOUT
JRST APPLOP
ENDAPP: MOVE JS1,T2
HRLI JS1,0
CLOSF ;CLOSE UPTIME.OLD-TXT
ERJMP ERROR
MOVE JS1,T3
HRLI JS1,400000 ;
CLOSF ;CLOSE UPTIME.TXT BUT DON'T RELEASE JFN
MOVE JS1,T2 ;JS1/ JFN OF UPTIME.TXT
DELF ;DELETE UPTIME.TXT
ERJMP ERROR
JRST WAIT ;
DELAY: MOVE JS1,[^D60000]
DISMS ;SLEEP FOR 1 MINUTE BEFORE LOGGING UPTIME
JRST LOOKUP
;HERE EACH MINUTE ...START OF LOOP
LOOKUP: MOVEI FLG,0
HRROI JS2,[ASCIZ/PS:<SYSTEM>UPTIME.INF/]
HRLZI JS1,(GJ%OLD+GJ%SHT) ;MUST BE OLD FILE/ SHORT FORM
GTJFN ;IF FILE EXITS JS1/JFN
ERJMP [CAIE RST,1
HALTF ;IF NOT FIRST PASS AND FILE GONE QUIT
MOVEI FLG,1 ;FLG/1 TO FLAG NO EXISITNG FILE
JRST CURTIM]
RLJFN ;NOW RELEASE IT
ERJMP ERROR
CAIE RST,1
JRST CURTIM ;GET FILE LINE ONLY ON FIRST PASS
;HERE ON FIRST PASS TO READ UPTIME.TXT AND RECOVER THE PREVIOUS
; ACCUMULATED UPTIME
GETACC: HRLZI JS1,(GJ%SHT) ;SHORT FORM
HRROI JS2,[ASCIZ/PS:<SYSTEM>UPTIME.INF/]
GTJFN
ERJMP ERROR
OPEN: MOVE JS2,[7 B5+OF%RD+OF%WR]
OPENF ;OPEN FILE
ERJMP ERROR
SETZM CNT
HRLI JS1,0 ;CLEAR FLAG BITS IN JFN WORD
LSTLIN: BIN
ERJMP [GTSTS ;ERROR GET STATUS
TLNE JS2,(GS%EOF) ;AT END OF FILE?
JRST NOTAG ;YES AND NO ESC FOUND
JUMPA ERROR] ;NO POSSIBLY DATA ERROR
CAIE JS2,33 ;LOOK FOR THE ESC
AOJA CNT,LSTLIN ;INCREMENT COUNT AND CONT
MOVE PNT,[POINT 7,TIMSTR]
RESACC: BIN
ERJMP [GTSTS ;ERROR GET STATUS
TLNE JS2,(GS%EOF) ;AT END OF FILE?
JRST NOTAG ;YES AND PREVIOUS ACCUM TIME NOT RECOVERED
JUMPA ERROR] ;NO POSSIBLY DATA ERROR
ADDI CNT,1
IDPB JS2,PNT
CAIE JS2,012 ;READ UNTIL LF
JRST RESACC
HRLI JS1,0
CLOSF
ERJMP ERROR
SCHACC: MOVE JS1,[POINT 7,TIMSTR]
ILDB T1,JS1
CAIE T1,"=" ;ACCUM UPTIME SHOULD BE RIGHT AFTER FIRST =
JRST .-2
RESHRS: MOVEI JS3,^D10
NIN ;INPUT ACCUM HRS
ERJMP ERROR
IMULI JS2,^D3600 ;CONVERT HOURS TO SECONDS
MOVEM JS2,PRVTIM ;
RESMIN: NIN ;INPUT ACCUM MINS
ERJMP ERROR
IMULI JS2,^D60 ;CONVERT TO SECONDS
ADD JS2,PRVTIM ;PRVTIM/PREVIOUS ACCUM UPTIME IN MILISECS
IMULI JS2,^D1000 ;CONVERT TO MILLISECS AND
MOVEM JS2,PRVTIM ;SAVE IN PRVTIM
;HERE TO GET CURRENT TIME
CURTIM: MOVE JS1,[POINT 7,TIMSTR]
MOVEI T1,33
IDPB T1,JS1 ;ESC MARKS THE CURRENT LINE
SETOM JS2
HRLZI JS3,(OT%DAY)
ODTIM
MOVEM JS1,PNT ;SAVE UPDATED POINTER
;HERE TO GET CURRENT UPTIME
UPTIME: TIME ;GET CURR UPTIME IN MILLISECS
MOVEM JS1,CUPTIM ;AND STORE IN CUPTIM
;COMPUTE THE TOTAL ACCUMULATIVE UPTIME BY ADDING THE CURRENT UPTIME
; TO THE ACCUM UPTIME FOUND IN UPTIME.TXT
CMPACC: MOVE T1,CUPTIM ;GET CURR UPTIME IN MILLSECS
ADD T1,PRVTIM ;ADD CURR UPTIM TO PREVIOUS ACCUM UPTIME
MOVEM T1,ACCTIM ;SAVE TOTAL ACCUM TIME IN ACCTIM
MOVE JS1,ACCTIM
PUSHJ P,CNVTIM ;CONVERT INTO HOURS, MINUTES
ACCLAB: MOVE JS1,PNT
HRROI JS2,[ASCIZ/ * Accum Uptime = /]
MOVEI JS3,^D18
SETZM JS4
SOUT ;OUTPUT ACCUM UPTIME LABEL
MOVEM JS1,PNT
ACCOUT: MOVE JS1,PNT ;RESTORE UPDATED PNT FOR TIMSTR
MOVE JS2,UPHRS
MOVE JS3,[100004,,^D10]
NOUT ;OUTPUT ACCUM HOURS
ERJMP ERROR
MOVEI JS2,":" ;OUTPUT : AS DELIMITER
IDPB JS2,JS1
MOVE JS2,UPMINS ;OUTPUT ACCUM MINS
MOVE JS3,[140002,,^D10]
NOUT
ERJMP ERROR
CUTLAB: HRROI JS2,[ASCIZ/ * Curr Uptime = /]
MOVEI JS3,^D17
SETZM JS4
SOUT ;OUTPUT CURR UPTIME LABEL
MOVEM JS1,PNT ;SAVE TIMSTR POINTER
CUTOUT: MOVE JS1,CUPTIM ;JS1/ CURRENT UPTIME IN MILLISECS
PUSHJ P,CNVTIM ;CONVERT INTO HOURS, MINUTES
MOVE JS1,PNT ;RETORE TIMSTR POINTER
MOVE JS2,UPHRS
MOVE JS3,[100004,,^D10]
NOUT ;OUTPUT CURR HOURS
ERJMP ERROR
MOVEI JS2,":" ;OUTPUT : AS DELIMITER
IDPB JS2,JS1
MOVE JS2,UPMINS
MOVE JS3,[140002,,^D10]
NOUT ;OUTPUT CURR MINS
ERJMP ERROR
EOL: MOVEI T1,015 ;OUTPUT CR
IDPB T1,JS1
MOVEI T1,012 ;OUTPUT LF
IDPB T1,JS1
MOVEI T1,0
IDPB T1,JS1 ;OUTPUT NULL AT END JUST IN CASE
;HERE TO UPDATE UPTIME.TXT
STRACC: HRLZI JS1,(GJ%SHT) ;SHORT FORM
HRROI JS2,[ASCIZ/PS:<SYSTEM>UPTIME.INF/]
GTJFN
ERJMP ERROR
OPENO: MOVE JS2,[7 B5+OF%RD+OF%WR]
OPENF ;OPEN FILE
ERJMP ERROR
SETZM CNT
;FIRST COUNT THE NUMBER OF BYTES BEFORE THE LAST TIME LINE
SEOF: BIN
ERJMP [GTSTS ;ERROR GET STATUS
TLNE JS2,(GS%EOF) ;AT END OF FILE?
JRST [CAIN FLG,1 ;IF ESC NOT FOUND AND THIS IS NOT A NEW
JRST OUTLIN ;FILE AND WE DID NOT GET RID OF THE ESC
HALTF] ;THEN SOMETHINGS WRONG
JUMPA ERROR] ;NO POSSIBLY DATA ERROR
CAIE JS2,33 ;LOOK FOR THE ESC
AOJA CNT,SEOF ;INCREMENT COUNT OF BYTES UP TO ALTMODE
MOVE T3,CNT
HRLI JS1,400000 ;
CLOSF ;CLOSE BUT DON'T REL JFN
ERJMP ERROR
MOVE JS2,[7 B5+OF%RD+OF%WR]
HRLI JS1,0
OPENF ;REOPEN
ERJMP ERROR
HRLI JS1,0
;AFTER REOPENING FILE COUNT DOWN TO WHERE THE LINE SHOULD BE
REPLOP: SOJL CNT,DTEST
BIN
ERJMP [HALTF]
JRST REPLOP
;IF THIS IS A RESTART DON'T WRITE OVER THE LINE JUST REMOVE THE ESC
;AND START A NEW LINE
DTEST: CAIE RST,1 ;IF NOT FIRST PASS
JRST OUTLIN ;THEN WRITE OVER THIS LINE WITH UPDATED INFO
MOVEI JS2,"." ;OTHERWISE
BOUT ;REPLACE ESC WITH A SPACE
MOVEI FLG,1 ;SO WE WON'T EXPECT TO FIND ESC
MOVE CNT,T3 ;RESTORE CNT
AOJA CNT,SEOF ;UPD COUNT AND LOOP UNTIL EOF
MOVE CNT,T3
;OUTPUT THE RESTART TIME IF RST = 1
OUTLIN: CAIE RST,1 ;IF RESTART = 1
JRST OUTTIM
CAMN RST,RSTDON ;UNLESS ALREADY DONE
JRST OUTTIM
PUSHJ P,OUTRST ;ADD RESTART TIME LINE
JRST OUTTIM
;OUTPUT THE UPDATED LINE
OUTTIM: MOVE JS2,[POINT 7,TIMSTR]
HRLI JS1,0
MOVEI JS3,^D76
MOVEI JS4,012
SOUT
HRLI JS1,0
CLOSF
ERJMP ERROR
MOVEI RST,0 ;TO SIGNIFY NOT FIRST PASS
MOVEI FLG,0 ;SHOULD FIND ESC
WAIT: MOVEI JS1,^D60000 ;SLEEP FOR 1 MINUTE
DISMS
JRST LOOKUP
;HERE WHEN PROGRAM CAN'T FIND TAG
NOTAG: CAIE RST,1 ;UNLESS THIS IS ON A RESTART
HALTF ;CONSIDER IT FATAL
RESET ;ELSE INITIALIZE UPTIME.TXT
JRST APPEND ;AND CONTINUE
OUTRST: MOVE JS2,[POINT 7,RSTTIM]
HRLI JS1,0
MOVEI JS3,^D40
MOVEI JS4,0
SOUT
POPJ P,
CNVTIM: IDIVI JS1,^D1000 ;CNVRT TO SECS
IDIVI JS1,^D3600 ;JS1/HOURS
MOVEM JS1,UPHRS
IDIVI JS2,^D60 ;JS2/MINUTES
MOVEM JS2,UPMINS
POPJ P,
ERROR: HRRI JS2,777777 ;MOST RECENT ERROR
HRLI JS2,400000 ;FOR CURRENT PROCESS
MOVEI JS1,.PRIOU ;OUTPUT TO TERM
MOVEI JS3,0 ;NO LIMIT ON MESSAGE
ERSTR ;CONVERT ERRNUM AND PRINT MESSAGE
JRST .+1
JRST .+1
HALTF
END START