LMFL#!C(:HOST "SYS" :BACKUP-DATE 2760031834. :SYSTEM-TYPE :LOGICAL :VERSION 6. :TYPE "LISP" :NAME "SHUTDOWN" :DIRECTORY ("REL3-SOURCE" "NVRAM") :SOURCE-PATTERN "( :DIRECTORY (\"REL3-SOURCE\") :NAME :WILD :TYPE :WILD :VERSION :NEWEST)" :VERSION-LIMIT 0. :CHARACTERS T :NOT-BACKED-UP T :CREATION-DATE 2758741368. :AUTHOR "REL3" :LENGTH-IN-BYTES 8256. :LENGTH-IN-BLOCKS 9. :BYTE-SIZE 8.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ;;; -*- Mode: Common-Lisp; Package: SYSTEM-INTERNALS; Base: 8 -*-;;;                           RESTRICTED RIGHTS LEGEND;;;Use, duplication, or disclosure by the Government is subject to;;;restrictions as set forth in subdivision (b)(3)(ii) of the Rights in;;;Technical Data and Computer Software clause at 52.227-7013.;;;                     TEXAS INSTRUMENTS INCORPORATED.;;;                              P.O. BOX 2909;;;                           AUSTIN, TEXAS 78769;;;                                 MS 2151;;; Copyright (C) 1985,1987 Texas Instruments Incorporated. All rights reserved.;;; This file contains machine shutdown routines Shutdown (meant to be;;; called by user) and System-Shutdown (can be called by system code).;;; They quiet the system before crashing the machine (or System-Shutdown;;; can return with :RETURN t, so might be suitable for disk-save & friends).;;; Package dependencies: should be loaded into whatever package rest of NVRAM;;; system is in.  The package for the TYPE keyword is also affected.;;; Edit History:;;; -------------;;; 3/85      sdk  Original (SHUTDOWN);;; 5/85      ab     Minor cleanup, documentation.;;;                  Made sure all files closed.  Fixed bug in TYPE reporting.;;;                  Added keywords :ASK to Shutdown and :RETURN and :STREAM;;;                to System-Shutdown.  ;;; 7/85      ab     Removed *swan-song* support.  Also now screen reverse-video's;;;                instead of greying.;;; 9/85      ab     Broke out NVRAM & Crash record functions into ACCESSORS file.;;;                  Prefix external names.;;; 11/4/85   ab     NVRAM patch 2-7.  Change default stream arg for system-shutdown;;;                to Standard-Output.;;; 03-15-87  ab     Wrapped Notify-All-Servers in an IGNORE-ERRORS so don't get;;;                thrown into debugger because of chaos :LOS, etc.  Updated TV:;;;                symbols to W: symbols where appropriate.  Deleted DEFUN for;;;                %HALT and added MAKE-OBSOLETE for it.  The actual AUX-OP for;;;                it is now defined in DEFOP.;;; Notes:  -- Functions should be put on a Shutdown-initialization-list.  This;;;         will require changes to Add-Initialization.;;;         -- Would be nice if we could wait for active servers to quit.  Maybe;;;         a keyword?;;; This is version meant to be called by user.(Defun Shutdown (&Key (Type :User) (Ask T))  "Use this function to shut down the system in an orderly fashion.  It does generalcleanup work, such as calling LOGOUT, before halting the processor.  The ASK keyword controls whether you will be asked if you REALLY want to shut downthe system.  ASK defaults to T.  Note that the shutdown will proceed after 60 secondsif the question is not answered.  You can use CTL-META-Abort to break out of this function before the last status messageappears.  However, the state of the system will be unknown.  The network and filesystem will probably be gone.  The TYPE keyword controls the shutdown message that will be sent to any active serversand written to the who-line documentation window.  The message used is picked upfrom the SI:SHUTDOWN-REASON-STRING property of the symbol used as TYPE.  You may takeadvantage of this feature to send your own customized message to the who line whencalling Shutdown.  The default package for the TYPE symbol is SI. "  (Let ((Go-Ahead (If Ask   (With-Timeout ((* #o74 #o74) T);T after 60 seconds      (Y-Or-N-P       "~&Do you really want to shut down the system?~                                   ~%(Automatic yes after 60 seconds.)"))   T)))    (When Go-Ahead      (If (Eq Type :User);If :USER type, send generic message based on userid.(If (And (Boundp 'User-Id) (Stringp User-Id) (Not (String-Equal User-Id "")))  (System-Shutdown :Type Type :Reason-String (Format () "Shutdown by user: ~A" User-Id))  (System-Shutdown :Type Type :Reason-String "Shutdown by local user"))(System-Shutdown :Type Type))))) ;; NVRAM patch 2-7, -ab;; Change default stream arg to standard-output.;;; This is the version that can be called from system functions.  (Defun System-Shutdown (&Key (Type :System) Reason-String (Stream *Standard-Output*) (Return ()))  "This function is meant to be called only from system-level code to shut down the systemin an orderly fashion.  It does general cleanup work, such as calling LOGOUT, before haltingthe processor.  DO NOT use this function if you just want the machine to drop dead becauseyou have encountered an unrecoverable error.  In that case, use si:%crash instead, and besure to provide a crash code.  If the keyword RETURN is non-nil, this function WILL return (that is, it will shutdown all activity but not call si%crash).  If you use this option PLEASE look at thecode to make sure it does all the quieting you want done.  Do not expect the networkor the file system to be around when the function returns.  If the RETURN keyword is NIL(the default) the function will end by calling si:%crash with a code of 0, indicatinga normal shutdown.  If the optional STREAM keyword is non-nil (it defaults to *STANDARD-OUTPUT*) some statusmessages will be displayed to stream STREAM as the system shuts down.  The TYPE keyword controls the shutdown message that will be sent to any active serversand written to the who-line documentation window.  The message used is picked upfrom the SI:SHUTDOWN-REASON-STRING property of the symbol used as TYPE.  You may takeadvantage of this feature to send your own customized message to the who line whencalling Shutdown.  The default package for the TYPE symbol is SI.  Optionally, you mayprovide a REASON-STRING that will be used as the message text."  (If (Null Reason-String)    (Let ((Prop-Reason (Get Type 'Shutdown-Reason-String)))      (Setq Reason-String    (If (Not (Null Prop-Reason))      Prop-Reason      (Format () "Shutdown for ~A" Type)))))  ;; Do miscellaneous cleanup.  (If Stream    (Format Stream "~%Notifying network servers"))  (Setq Chaos::Chaos-Servers-Enabled ());Allow no new servers.  (Notify-All-Servers Reason-String);Notify any friends we have left we're going down.  (If Stream    (Format Stream "~%Processing logout"))  (Logout);Undo user inits and get username off screen.  (If Stream    (Format Stream "~%Shutting down file system"))  (Fs::Lmfs-Close-All-Files);Close any open streams our local file system  ; is serving.  Not done by file sys dismount,  ; but may be redundant considering what comes next.  (Close-All-Files);Close any open file streams we've left open.  (Chaos:Reset);Blow off any network connections  ; that are left.  Stand alone after this.  (Fs::Dismount-File-System);Help keep file system nice.  ;; Tell user going down now.  (If Stream    (Format Stream "~%Shutting down system..."))  (%Open-Mouse-Cursor);Hide the mouse  (Without-Interrupts;Don't allow who-line updates etc.   (Catch 'W::Page-Overflow;Dont let documentation window overflow     (Progn; stop shutdown      ;; Make mouse doc window empty.      (Send W::Who-Line-Documentation-Window :Clear-Screen)      (Send W::Who-Line-Documentation-Window :Line-Out Reason-String)      ;; Display message about restarting.      (Send W::Who-Line-Documentation-Window :Line-Out "To restart:  Hold both control keys and both meta keys and press RUBOUT, M, or ABORT")))   ;; Next two forms update the runstate   (Setq tv::Who-Line-Run-State "Shutdown")   (W:Who-Line-Update T)   ;; If no return requested, really go down by calling %crash.   ;; First arg of 0 is normal shutdown code; object = nil.   ;; PAWS-UP-P is t so screen will invert.   (If (Not Return)     (%Crash #o0 () T)))) (DEFUN Notify-All-Servers (String) ;; Notifies all active servers that machine is going down. ;; Sends STRING to all active servers. (LET (hosts)   (LOOP FOR server IN (SEND W:Who-Line-File-State-Sheet :Servers);Active servers         DO (LET ((host (tv::server-desc-host-name server)))   (UNLESS (MEMBER host hosts :test #'EQ)     ;; Don't send more than one message     (PUSH host hosts))))   (LOOP FOR shost IN hosts DO (IGNORE-ERRORS (chaos:notify shost string))))  )rmat-Processor Crash-Rec-Format-Processor-Type)    ;; Return number of records    Number-Of-Records))(DEFUN initialize-first-crash-record ()  ;; For future expansion.  nil);;;;;; User-callable NVRAM functions.;;;;; NVRAM patch 2-7, -ab;; Change default stream arg to standard-output.(Defun Nvram-Status (&Optional (Stream *Standard-Output*))  "Writes the current status of NVRAM, including the default boot values, to STREAM."  (If (Not (Nvram-Functioning-P))    (Format Stream    "~%WARNING:  NVRAM does not appear to be functioning.  Have your SIB checked.")    (If (Not (Nvram-Initialized-P))      (Format Stream "~%NVRAM has not been initialized.  Use SI:Setup-NVRAM.")      (Progn(Format Stream"~%   Default Boot Unit is ~d. ~                            ~&   Default Boot Slot is ~d. ~                            ~&   Keyboard Unit is ~d. ~                            ~&   Keyboard Slot is ~d. ~                         