LMFL#!C(:HOST "SYS" :BACKUP-DATE 2760031819. :SYSTEM-TYPE :LOGICAL :VERSION 5. :TYPE "LISP" :NAME "ACCESSORS" :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 2758740882. :AUTHOR "REL3" :LENGTH-IN-BYTES 12436. :LENGTH-IN-BLOCKS 13. :BYTE-SIZE 8.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ;;; -*- Mode:Common-Lisp; Package:SI; 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 low-level NVRAM and Crash-Record Accessor functions;;; and macros.  The templates describing the format of NVRAM and the Crash;;; area of NVRAM can be found in SYS:COLD-BAND;QDEV;;; Package dependencies: must be loaded into whatever package rest of NVRAM;;; system is in, but beyond that should work.  (All names defined outside;;; NVRAM system should carry explicit package prefix).;;; Edit History:;;; -------------;;; 3/85      sdk  Original (part of CRASH-RECORD);;; 5/85      ab   Minor cleanup, documentation.  Put NVRAM functions in SETUP-NVRAM;;; 9/85      ab     Broke out NVRAM & Crash record functions into ACCESSORS file.;;;                  Added Field accessor macros & related support.;;;                  Put all macros from CRASH-RECORD here.;;;                  Prefixed all non-NVRAM names with explicit pkg.;;;;;; NVRAM Variables.;;;;;; Initialized in Setup-NVRAM-Vars, run during warm inits.(Defvar Nvram-Slot #o0 "Slot address of board containing NVRAM") (Defvar Nvram-Slot-Offset #o0 "Offset into board memory of start of NVRAM") ;;;;;; NVRAM Reading, Writing routines.;;;(Defsubst Read-Nvram (Offset)  "Read byte of NVRAM at address OFFSET from start of NVRAM."  (%Nubus-Read-8b Nvram-Slot (+ Nvram-Slot-Offset Offset))) (Defsubst Write-Nvram (Offset Value)  "Write least significant byte of VALUE into NVRAM at address OFFSET from start of NVRAM."  (%Nubus-Write-8b Nvram-Slot (+ Nvram-Slot-Offset Offset) Value)) (Defsetf Read-Nvram Write-Nvram) (Defun Read-Nvram-16b (Offset)  "Read half-word of NVRAM (LSB first) at address OFFSET from start of NVRAM."  (Let ((Lo-8 (Read-Nvram Offset))(Hi-8 (Read-Nvram (+ Offset #o4))))    (Dpb Hi-8 (Byte #o10 #o10) Lo-8))) (Defun Write-Nvram-16b (Offset Value)  "Write least significant 16 bits of VALUE into NVRAM.  LSB is written first."  (Let ((Lo-8 (Ldb (Byte #o10 #o0) Value))(Hi-8 (Ldb (Byte #o10 #o10) Value)))    (Write-Nvram Offset Lo-8)    (Write-Nvram (+ Offset #o4) Hi-8))) (Defsetf Read-Nvram-16b Write-Nvram-16b) (Defun Write-Nvram-24b (Offset Value)  "Write least significant 24 bits of VALUE into NVRAM, LSB first."  (Let ((Lo-8 (Ldb (Byte #o10 #o0) Value))(Mid-8 (Ldb (Byte #o10 #o10) Value))(Hi-8 (Ldb (Byte #o10 #o20) Value)))    (Write-Nvram Offset Lo-8)    (Write-Nvram (+ Offset #o4) Mid-8)    (Write-Nvram (+ Offset #o10) Hi-8))) (Defun Read-Nvram-24b (Offset)  "Read 3 bytes of NVRAM starting at OFFSET, LSB first."  (Let ((Lo-8 (Read-Nvram Offset))(Mid-8 (Read-Nvram (+ Offset #o4)))(Hi-8 (Read-Nvram (+ Offset #o10))))    (Dpb Hi-8 (Byte #o10 #o20) (Dpb Mid-8 (Byte #o10 #o10) Lo-8)))) (Defsetf Read-Nvram-24b Write-Nvram-24b) (Defun Write-Nvram-32b (Offset Value)  "Write least significant 32 bits of VALUE into NVRAM, LSB first."  (Let ((Lo-16 (Ldb (Byte #o20 #o0) Value))(Hi-16 (Ldb (Byte #o20 #o20) Value)))    (Write-Nvram-16b Offset Lo-16)    (Write-Nvram-16b (+ Offset #o10) Hi-16))) (Defun Read-Nvram-32b (Offset)  "Read 4 bytes of NVRAM starting at OFFSET, LSB first."  (Let ((Lo-16 (Read-Nvram-16b Offset))(Hi-16 (Read-Nvram-16b (+ Offset #o10))))    (Dpb Hi-16 (Byte #o20 #o20) Lo-16)))  (Defsetf Read-Nvram-24b Write-Nvram-24b) ;;;;;; Crash Record Variables.;;;;;; Initialized in Setup-Crash-Rec-Vars, run during warm inits.(Defvar Current-Crash-Rec-Offset #o0   "Offset into NVRAM of current (for this boot) crash record.") ;;;;;; Crash Record reading, writing.;;;;;; Current crash record.  8-bit forms(Defun Write-Current-Crash-Rec (Offset Value)  "Write LSB of value to location OFFSET into current crash record."  (Write-Nvram (+ Offset Current-Crash-Rec-Offset) Value)) (Defun Read-Current-Crash-Rec (Offset)  "Read byte at location OFFSET in current crash record."  (Read-Nvram (+ Offset Current-Crash-Rec-Offset))) (Defsetf Read-Current-Crash-Rec Write-Current-Crash-Rec) ;;; Current crash record. 16-bit forms(Defun Read-Current-Crash-Rec-16b (Offset)  "Read half-word at OFFSET in current crash record, LSB first."  (Read-Nvram-16b (+ Offset Current-Crash-Rec-Offset))) (Defun Write-Current-Crash-Rec-16b (Offset Value)  "Write least significant 16 bits of VALUE, LSB first, to location OFFSET into current crash record."  (Write-Nvram-16b (+ Offset Current-Crash-Rec-Offset) Value)) (Defsetf Read-Current-Crash-Rec-16b Write-Current-Crash-Rec-16b) ;;; Current crash record. 32-bit forms(Defun Read-Current-Crash-Rec-32b (Offset)  "Read 32 bit word stored at OFFSET in current crash record, from LSB to MSB."  (Dpb (Read-Nvram-16b (+ Offset Current-Crash-Rec-Offset #o10)) (Byte #o20 #o20)       (Read-Nvram-16b (+ Offset Current-Crash-Rec-Offset)))) (Defun Write-Current-Crash-Rec-32b (Offset Value)  "Write 32 bits of VALUE into current crash record at location OFFSET, LSB first."  (Write-Nvram-16b (+ Offset Current-Crash-Rec-Offset) (Ldb (Byte #o20 #o0) Value))  (Write-Nvram-16b (+ Offset Current-Crash-Rec-Offset #o10) (Ldb (Byte #o20 #o20) Value)))   (Defsetf Read-Current-Crash-Rec-32b Write-Current-Crash-Rec-32b) ;;; Any crash record. 8-bit forms(Defun Write-Crash-Rec (Crash-Rec-Pointer Offset Value)  "Write LSB of value to location OFFSET into crash record."  (Write-Nvram (+ Offset Crash-Rec-Pointer) Value)) (Defun Read-Crash-Rec (Crash-Rec-Pointer Offset)  "Read byte at location OFFSET in crash record."  (Read-Nvram (+ Offset Crash-Rec-Pointer))) (Defsetf Read-Crash-Rec Write-Crash-Rec) ;;; Any crash record. 16-bit forms(Defun Read-Crash-Rec-16b (Crash-Rec-Pointer Offset)  "Read half-word at OFFSET in crash record, LSB first."  (Read-Nvram-16b (+ Offset Crash-Rec-Pointer))) (Defun Write-Crash-Rec-16b (Crash-Rec-Pointer Offset Value)  "Write least significant 16 bits of VALUE, LSB first, to location OFFSET into crash record."  (Write-Nvram-16b (+ Offset Crash-Rec-Pointer) Value)) (Defsetf Read-Crash-Rec-16b Write-Crash-Rec-16b) ;;; Any crash record. 32-bit forms(Defun Read-Crash-Rec-32b (Crash-Rec-Pointer Offset)  "Read 32 bit word stored at OFFSET into crash record, from LSB to MSB."  (Dpb (Read-Nvram-16b (+ Offset Crash-Rec-Pointer #o10)) (Byte #o20 #o20)       (Read-Nvram-16b (+ Offset Crash-Rec-Pointer)))) (Defun Write-Crash-Rec-32b (Crash-Rec-Pointer Offset Value)  "Write 32 bits of VALUE into crash record at location OFFSET.  LSB stored first."  (Write-Nvram-16b (+ Offset Crash-Rec-Pointer) (Ldb (Byte #o20 #o0) Value))  (Write-Nvram-16b (+ Offset Crash-Rec-Pointer #o10) (Ldb (Byte #o20 #o20) Value)))   (Defsetf Read-Crash-Rec-32b Write-Crash-Rec-32b) ;;;;;; Crash Record offset symbols property-list setup routines;;;;; Iterate over all symbols on CRASH-REC-OFFSETS and NVRAM-OFFSETS lists (defined in QDEV),;; adding NVRAM-Field-Size property to each.  This property is the length in bits;; of the particular crash record field.  It will be used by the read macros below;; in the generation of the correct accessor function for these fields.(Eval-When (Compile Load)   ;; Adds NVRAM-Field-Size property to all symbols on LIST.   (Defun Def-Nvram-Field-Size (List)     (If (Not (Consp List))       (Ferror () "Def-NVRAM-Field-Size argument LIST-NAME (~s) not a list" List))     (Do* ((L List (Rest L))   (Sym1 (First L) (First L))   (Sym2 (Second L) (Second L))   (Size    (* #o10(Truncate (- (Symbol-Value Sym2) (Symbol-Value Sym1)) #o4))    (* #o10(Truncate (- (Symbol-Value Sym2) (Symbol-Value Sym1)) #o4))))  ((= (Length L) #o2)   (Setf (Get Sym1 'Nvram-Field-Size) Size))       (Setf (Get Sym1 'Nvram-Field-Size) Size)))) (Eval-When (Compile Load) (Def-Nvram-Field-Size Crash-Rec-Offsets)   (Def-Nvram-Field-Size Nvram-Offsets)) ;;;;;; Crash Record field accessor macros;;;;; The macros below expand into the right accessor function for FIELD, a crash record;; offset.  They work off the property list for the symbol passed in their FIELD argument.;; The property list should contain an NVRAM-Field-Size property indicating the size of;; the field in bits. (Defmacro Read-Current-Crash-Field (Field)  (Check-Arg Field (Member Field Crash-Rec-Offsets :Test #'Eq)     "a member of the si:CRASH-REC-OFFSETS list")  (Check-Arg Field (Member (Get Field 'Nvram-Field-Size) '(#o10 #o20 #o40) :Test #'Eq)     "a symbol with an NVRAM-Field-Size property of 8., 16., or 32")  `(,(Case (Get Field 'Nvram-Field-Size)       (#o10 'Read-Current-Crash-Rec)       (#o20 'Read-Current-Crash-Rec-16b)       (#o40 'Read-Current-Crash-Rec-32b))    ,Field)) (Defmacro Write-Current-Crash-Field (Field Value)  (Check-Arg Field (Member Field Crash-Rec-Offsets :Test #'Eq)     "a member of the si:CRASH-REC-OFFSETS list")  (Check-Arg Field (Member (Get Field 'Nvram-Field-Size) '(#o10 #o20 #o40) :Test #'Eq)     "a symbol with an NVRAM-Field-Size property of 8., 16., or 32")  `(,(Case (Get Field 'Nvram-Field-Size)       (#o10 'Write-Current-Crash-Rec)       (#o20 'Write-Current-Crash-Rec-16b)       (#o40 'Write-Current-Crash-Rec-32b))    ,Field ,Value)) (Defmacro Read-Crash-Field (Crec Field)  (Check-Arg Field (Member Field Crash-Rec-Offsets :Test #'Eq)     "a member of the si:CRASH-REC-OFFSETS list")  (Check-Arg Field (Member (Get Field 'Nvram-Field-Size) '(#o10 #o20 #o40) :Test #'Eq)     "a symbol with an NVRAM-Field-Size property of 8., 16., or 32")  `(,(Case (Get Field 'Nvram-Field-Size)       (#o10 'Read-Crash-Rec)       (#o20 'Read-Crash-Rec-16b)       (#o40 'Read-Crash-Rec-32b))    ,Crec ,Field)) (Defmacro Write-Crash-Field (Crec Field Value)  (Check-Arg Field (Member Field Crash-Rec-Offsets :Test #'Eq)     "a member of the si:CRASH-REC-OFFSETS list")  (Check-Arg Field (Member (Get Field 'Nvram-Field-Size) '(#o10 #o20 #o40) :Test #'Eq)     "a symbol with an NVRAM-Field-Size property of 8., 16., or 32")  `(,(Case (Get Field 'Nvram-Field-Size)       (#o10 'Write-Crash-Rec)       (#o20 'Write-Crash-Rec-16b)       (#o40 'Write-Crash-Rec-32b))    ,Crec ,Field ,Value)) (Defmacro Read-Nvram-Field (Field)  (Check-Arg Field (Member Field Nvram-Offsets :Test #'Eq)     "a member of the si:NVRAM-OFFSETS list")  (Check-Arg Field (Member (Get Field 'Nvram-Field-Size) '(#o10 #o20 #o30 #o40) :Test #'Eq)     "a symbol with an NVRAM-Field-Size property of 8., 16., 24, or 32")  `(,(Case (Get Field 'Nvram-Field-Size)       (#o10 'Read-Nvram)       (#o20 'Read-Nvram-16b)       (#o30 'Read-Nvram-24b)       (#o40 'Read-Nvram-32b))    ,Field)) (Defmacro Write-Nvram-Field (Field Value)  (Check-Arg Field (Member Field Nvram-Offsets :Test #'Eq)     "a member of the si:NVRAM-OFFSETS list")  (Check-Arg Field (Member (Get Field 'Nvram-Field-Size) '(#o10 #o20 #o30 #o40) :Test #'Eq)     "a symbol with an NVRAM-Field-Size property of 8., 16., 24, or 32")  `(,(Case (Get Field 'Nvram-Field-Size)       (#o10 'Write-Nvram)       (#o20 'Write-Nvram-16b)       (#o30 'Write-Nvram-24b)       (#o40 'Write-Nvram-32b))    ,Field ,Value)) ;;;;;; Other macros;;;;; Crash Record keyword/value list support:(Defmacro Get-Item (Record Item) ;; Gets ITEM's value (ITEM is a crash field designator) from RECORD ;; (the internal Crash Record data structure).  `(Second (ASSOC ,Item ,Record :test #'EQ))) ;; CREC field test/set support:(Defmacro Test-Crash-Rec-Bits (Crec Offset Ppss) ;; Reads 8 bits from the NVRAM crash record at address CREC and returns ;; T if the field PPSS is not zero.  Used to test flag bits.  `(Ldb-Test ,Ppss (Read-Crash-Rec ,Crec ,Offset))) (Defmacro Store-Crash-Rec-Field (Crec Offset Ppss Value) ;; Deposits VALUE into field PPSS of the 8 bits of CREC at OFFSET. ;; Used to set flag bits.  `(Write-Crash-Rec ,Crec ,Offset (Dpb ,Value ,Ppss (Read-Crash-Rec ,Crec ,Offset)))) ion-failures)  (delete (list impl lcn) (get host :connection-failures)  :test #'(lambda (a b)    (and (eq (first a) (first b)) (eq (second a) (second b))))))    (return t)))finally (return t))            (select (the symbol next-step-type)(:network)(:medium (let ((medium-handler (find-medium next-step nil)))   (and medium-handler(setf connection (lexpr-send medium-handler :connect host logical-contact-name args)))))(:service (let ((gateway-host-list (find-hosts-for-gateway-service host next-step)))   (dolist (gateway-host gateway-host-list (ferror 'gni-connect-error "No gateway host responding."))          (condition-case (condition) (progn  (setf connection (apply 'invoke-service-on-host gateway-host next-step host  logical-contact-name args))  (if connection (return)))       (si:gni-se