.TITLE Get_system_boot_time into a DCL symbol .IDENT /V3.2/ ;++GTBOOTTIM.MAR ; ; Facility: ; Fermilib Accelerator Control System ; Pseudo-Lexical function for DCL. ; ; Abstract: ; Defines local DCL symbol giving the date and time of the last ; system startup. ; ; Environment: ; Used in DCL command procedures. ; Must be INSTALL'ed with CMKRNL privilege to allow use by non-privileged ; users. ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 19-Oct-82 ; ; V1.0 19-Oct-82 FJN Requested by Don Rohde for use in APL ; V2.0 20-Oct-82 FJN Convert frm GETSUPTIM to return time and date ; of last boot as absolute date and time ; V2.1 27-Oct-82 FJN Only return boot time to nearest second and ; delay for 1 Clock tick to synch with system ; V3.0 28-Oct-82 FJN Written in MACRO to lockout clock interrupts in ; Kernel mode routine for 2 instructions! ; V3.1 28-Oct-82 FJN First hibernate until just after the time at ; which EXE$TIMEOUT is called to increment the ; EXE$GL_ABSTIM value ; V3.2 02-Nov-82 FJN Get boot time twice (internally) and take the ; greater value to overcome residual imprecision ; in obtaining the answer. ; .DEFAULT DISPLACEMENT,WORD .PAGE .SUBTITLE Declarations ; ; Include Files: ; .LIBRARY "SYS$LIBRARY:LIB.MLB" ;Executive macro library ; ; Library Macros: ; .NOCROSS $SSDEF ;System condition names $TQEDEF ;Timer queue element offsets .CROSS ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; seconds = 10*1000*1000 ;Converts time in seconds to time in ; system units (100 nanoseconds) sym_len = 255 ;Maximum length of DCL symbol name time_len = 25 ;Maximum length of date and time text .SHOW BINARY .PAGE .SUBTITLE Impure data storage ; ; Impure Local Storage: ; .PSECT IMPURE_DATA,LONG,NOEXE,WRT,CON,LCL,NOSHR,RD SYMBOL_NAME: ;Descriptor for symbol name text .LONG sym_len .ADDRESS 10$ 10$: .BLKB sym_len ;Storage for symbol name text BOOTED: .QUAD 0 ;System boot time storage ;Temporary for delay-until time TIME_TEXT: ;Descriptor for boot time text .LONG time_len .ADDRESS 10$ 10$: .BLKB time_len ;Storage for boot time text .PAGE .SUBTITLE Pure data storage ; ; Pure Local Storage: ; .PSECT CODE,LONG,EXE,NOWRT,CON,LCL,SHR,RD GETSYMB: ;Argument list for getting command line .LONG 3 .ADDRESS SYMBOL_NAME ;Command line string descriptor .ADDRESS 10$ ;Prompt text string descriptor .ADDRESS SYMBOL_NAME ;Length of returned command line 10$: .ASCID "Prompt: " GETTIME: ;Argument lists to get boot time $CMKRNL BOOT_TIME,NOWTIME NOWTIME: ;List to get current/boot time $GETTIM BOOTED ASCTIME: ;Argument list to convert time to text $ASCTIM TIME_TEXT,TIME_TEXT,BOOTED DEFSYMB: ;Argument list to define DCL symbol .LONG 2 .ADDRESS SYMBOL_NAME .ADDRESS TIME_TEXT DELAYING: ;Argument list to schedule wakeup $SCHDWK daytim=BOOTED GETNEXT: ;List to get time of next EXE$TIMEOUT $CMKRNL GET_TIMEOUT_TIME,NOWTIME .PAGE .SUBTITLE Main program code and transfer ;+/GTBOOTTIM ; ; Function Description: ; Get DCL symbol name from command line. Get system boot time using ; Kernel mode procedure. Convert time to string and define the DCL ; symbol with the system boot time string as its value . ; ; Condition Codes: ; LIB$_AMBSYMDEF ambiguous symbol name ; LIB$_FATERRLIB fatal internal library error ; LIB$_INSCLIMEM insufficient CLI memory ; LIB$_INSVIRMEM insufficient virtual memory ; LIB$_INVSTRDEF invalid string descriptor ; LIB$_INVSYMNAM invalid symbol name ; LIB$_NOCLI no CLI present to perform function ; LIB$_UNECLIERR unexpected CLI error ; RMS$_xxx VAX-11 RMS error codes from getting command line ; ; Side Effects: ; Must be defined as a foreign command. ; Must be installed with CMKRNL privilege. ; ;- ; Linking Instuctions: ; $ LINK/NOTRACEBACK GTBOOTTIM,SYS$SYSTEM:SYS.STB/SELECTIVE ; ; Special Notes: ; The time is gotten twice and compared (using the later value) in order ; to remove a residual effect that sometimes results in an earlier time ; (by 1 second) for unknown reasons. ; ;+ GET_BOOT_TIME ; Return the date and time that the system was bootstrapped as a ; string in absolute-time format in a local DCL symbol: ; ; $ GET_BOOT_TIME symbol ; ; The GET_BOOT_TIME symbol must be defined as a foreign command by: ; ; $ GET_BOOT_TIME := $FERMI$EXE:GTBOOTTIM ; ;- .ENTRY GTBOOTTIM,^M ; ; Get symbol name from command line ; CALLG GETSYMB,G^LIB$GET_FOREIGN BLBC R0,B^ABORT ; ; Get boot time twice and compare results. ; CALLS #0,B^GET_ANSWER BLBC R0,B^ABORT MOVQ BOOTED,R2 ;Get the boot time returned CALLS #0,B^GET_ANSWER BLBC R0,B^ABORT CMPL R0,BOOTED ;Check only the low-order longword BLEQU 10$ ;If first is < or = just continue MOVQ R2,BOOTED ;Use first result: it is a later time! ; ; Convert system boot time to text format (absolute date and time) ; 10$: $ASCTIM_G ASCTIME BLBC R0,B^ABORT SUBW2 #3,TIME_TEXT ;Shorten text, eliminating 1/100's ; ; Define DCL symbol using system boot time text as its value ; CALLG DEFSYMB,G^LIB$SET_SYMBOL BLBC R0,B^ABORT RET ; ; Abort program by signalling the error ; ABORT: PUSHL R0 CALLS #1,G^LIB$STOP .PAGE .SUBTITLE Get time of last system boot ;+/GET_ANSWER ; ; Functional Description: ; Return time of last system boot. ; ; Calling Sequence: ; CALL GET_ANSWER ; ; Input Parameters: ; NONE ; ; Implicit Inputs: ; GETNEXT argument list for Kernel mode call to GET_TIMEOUT_TIME ; DELAYING argument list for $SCHDWK system service call ; GETTIME argument list for Kernel mode call to BOOT_TIME routine ; ; Output Parameters: ; R0 completion status code ; ; Implicit Outputs: ; BOOTED quadword in which boot time and date is returned. ; ; Condition Codes: ; See the various system services: $CMKRNL, $SCHDWK ; ; Side Effects: ; Will delay until after the next time the executive routine EXE$TIMEOUT ; has been called. ; ;- .ENTRY GET_ANSWER,^M<> ; ; Get absolute time of next call to EXE$TIMEOUT and add a microsecond to it ; $CMKRNL_G GETNEXT BLBC R0,99$ ADDL2 #10,BOOTED ;Increment to just past timeout time ; ; Delay until just after EXE$TIMEOUT has been called ; $SCHDWK_G DELAYING BLBC R0,99$ $HIBER_S ; ; Get system boot time in system time binary format ; $CMKRNL_G GETTIME BLBC R0,99$ 99$: RET .PAGE .SUBTITLE Calculate system boot time (kernel mode) ;+/BOOT_TIME ; ; Functional Description: ; Executes in Kernel mode to capture system uptime and current system ; time. Converts uptime to quadword format and system time units (as ; a delta-time) and adds the current system time quadword to give the ; system boot date and time. ; ; Calling Sequence: ; status = BOOT_TIME( booted ) ; ; Input Parameters: ; NONE ; ; Implicit Inputs: ; EXE$GL_ABSTIM absolute system uptime in seconds ; EXE$GQ_SYSTIME current system time and date (in system format) ; ; Output Parameters: ; R0 completion status code ; booted address of a quadword in which the system boot date and time ; (in system format) is returned. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; SS$_NORMAL success ; ; Side Effects: ; Raises IPL to HWCLK to capture system uptime and current system time ; together. ; ;- .ENTRY BOOT_TIME,^M ; ; Start of very-high IPL code ; LBEG: SETIPL B^LOCK ;;;Raise IPL to block clock interrupts MOVL G^EXE$GL_ABSTIM,R2 ;;;Capture system uptime MOVQ G^EXE$GQ_SYSTIME,R3 ;;;Capture current system time and date SETIPL #0 ;Restore normal IPL ; ; Truncate current system time to whole seconds ; EDIV #seconds,R3,R0,R1 ;Convert to seconds and fractions SUBL2 R1,R3 ;Truncate to whole seconds ; ; Now calculate absolute date and time of system boot ; EMUL #-seconds,R2,#0,R0 ;Uptime into system units and format ADDL2 R3,R0 ;Add in current system time (which was ADWC R4,R1 ; truncated to seconds) MOVQ R0,@4(AP) ;Return system boot time MOVZWL #SS$_NORMAL,R0 ; and success RET ; LOCK: .LONG IPL$_HWCLK ;IPL level for blocking interrupts ASSUME <.-LBEG> LE 512 ;Insure temporary page "locking" works .PAGE .SUBTITLE Get absolute time of next EXE$TIMEOUT call ;+/GET_TIMEOUT_TIME ; ; Functional Description: ; Executes in Kernel mode to capture the absolute time of the next ; EXE$TIMEOUT call from its timer queue entry. It is assumed that ; this permanent timer queue entry immediately follows the time queue ; listhead in SYSCOMMON. ; ; Calling Sequence: ; status = GET_TIMEOUT_TIME( nxttim ) ; ; Input Parameters: ; NONE ; ; Implicit Inputs: ; EXE$GQ_TQFL timer queue listhead in SYSCOMMON ; +8 offset to start of Time Queue Element (TQE) for ; EXE$TIMEOUT ; +TQE$Q_TIME absolute time of next EXE$TIMEOUT call in its TQE ; ; Output Parameters: ; R0 completion status code ; nxttim address of a quadword in which the absolute time (in system ; format) of the next EXE$TIMEOUT call is returned. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; SS$_NORMAL success ; ; Side Effects: ; NONE ; ;- .ENTRY GET_TIMEOUT_TIME,^M<> MOVQ G^EXE$GL_TQFL+8+TQE$Q_TIME,- ;Get time from EXE$TIMEOUT's TQE @4(AP) ; in permanent location in SYSCOMMON MOVZWL #SS$_NORMAL,R0 RET .END GTBOOTTIM