;;; -*- MODE: 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, Texas Instruments Incorporated. All rights reserved. ;;; ;;; Declare and initialize NVRAM variables. ;;; (DefVar NVRAM-Slot 0 "Slot address of board containing NVRAM") (DefVar NVRAM-Slot-Offset 0 "Offset into board memory of start of NVRAM") ;;; These vars must be set up before any crash record reporting works (see NVRAM;crash-record) (Defun Setup-NVRAM-Vars () "Set up addresses that we need to access NVRAM." (select-processor ((:cadr :lambda)) (:explorer (setq NVRAM-Slot TV:tv-quad-slot NVRAM-Slot-Offset SIB-NVRAM-Offset)))) ;;; ;;; NVRAM Reading, Writing routines. ;;; (Defsubst Read-NVRAM (offset) "Read byte of NVRAM at address OFFSET from start of NVRAM." (%NuBus-Read-8 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-8 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 4)))) (Dpb hi-8 1010 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 0010 value)) (hi-8 (Ldb 1010 value))) (Write-NVRAM offset lo-8) (Write-NVRAM (+ offset 4) 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 0010 value)) (mid-8 (Ldb 1010 value)) (hi-8 (Ldb 2010 value))) (Write-NVRAM offset lo-8) (Write-NVRAM (+ offset 4) mid-8) (Write-NVRAM (+ offset 8.) 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 4))) (hi-8 (Read-NVRAM (+ offset 8.)))) (Dpb hi-8 2010 (Dpb mid-8 1010 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 0020 value)) (hi-16 (Ldb 2020 value))) (Write-NVRAM-16B offset lo-16) (Write-NVRAM-16B (+ offset 8.) 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 8.)))) (Dpb hi-16 2020 lo-16))) (DefSetf Read-NVRAM-24B Write-NVRAM-24B) ;;; ;;; SETUP-NVRAM and help functions. Must be run before crash records can be recorded. ;;; (Defun NVRAM-Functioning-p (&optional (offset 0)) "Simple check to see if we can read back a value written into NVRAM at OFFSET." (let ((save1 (%NuBus-Read-8-safe NVRAM-Slot (+ NVRAM-Slot-Offset offset))) (save2 (%NuBus-Read-8-safe NVRAM-Slot (+ NVRAM-Slot-Offset offset 4)))) (when (numberp save1) ;if we could read anything successfully (%NuBus-Write-8 NVRAM-Slot (+ NVRAM-Slot-Offset offset) #x+DE) (%NuBus-Write-8 NVRAM-Slot (+ NVRAM-Slot-Offset offset 4) #x37) (let ((result (if (and (eql (%NuBus-Read-8-safe NVRAM-Slot (+ NVRAM-Slot-Offset offset)) #x+DE) (eql (%NuBus-Read-8-safe NVRAM-Slot (+ NVRAM-Slot-Offset offset 4)) #x37)) t nil))) (%NuBus-Write-8 NVRAM-Slot (+ NVRAM-Slot-Offset offset) save1) (%NuBus-Write-8 NVRAM-Slot (+ NVRAM-Slot-Offset offset 4) save2) result) ))) (Defun initialize-reserved-areas () "Writes initial values out to all reserved locations recorded in NVRAM-Reserved list." (dolist (res-list NVRAM-Reserved nil) (Do ((offset (first res-list) (+ offset 4)) (last (second res-list)) (value (third res-list))) ((= offset last)) (Write-NVRAM offset value)))) (Defun Initialize-Crash-Record (crash-rec-pointer) "Zeros out a crash record" (Do ((addr crash-rec-pointer (+ addr 4)) (lim (+ crash-rec-pointer CRASH-REC-LEN))) ((>= addr lim) 0) (Write-NVRAM addr 0))) (Defun Initialize-Crash-Rec-Buffer (base limit) "Given BASE of crash record buffer area and LIMIT (both offsets from start of NVRAM) initialize the buffer area pointers and zero out all crash records." (Let* ((buffer-size (- limit base)) (number-of-records (floor buffer-size CRASH-REC-LEN)) (end-of-buff (+ base (* number-of-records CRASH-REC-LEN))) (last (- end-of-buff CRASH-REC-LEN))) (cond ((< number-of-records 1) (Ferror "buffer too small -- not even room for one crash record")) ((< number-of-records 4) (cerror :no-action nil nil "Buffer is small -- only room for ~D crash records." number-of-records))) (Write-NVRAM-16B NVRAM-Crash-Buff-Rec-Len CRASH-REC-LEN) (Write-NVRAM-16B NVRAM-Crash-Buff-Base base) (Write-NVRAM-16B NVRAM-Crash-Buff-Last last) (Write-NVRAM-16B NVRAM-Crash-Buff-Pointer base) (Write-NVRAM NVRAM-Crash-Buff-Format-Rev CRASH-REC-FORMAT-VERSION) (Write-NVRAM-16B NVRAM-Crash-Buff-Format-Processor CRASH-REC-FORMAT-PROCESSOR-TYPE) (Do ((crec base (+ crec CRASH-REC-LEN))) ((> crec last) nil) (Initialize-Crash-Record crec)) number-of-records ;return num of recs )) (Defun Setup-Nvram (&optional (unit 0.) ) "This utility initializes NVRAM in order to support STBM access to monitor, keyboard, and load source. One argument may be entered, the logical disk unit. The disk unit is formatted for the NUPI as a binary value: 00fffuuu where 0=0, fff=formatter number, and uuu=unit number. For example: formatter#0 + unit#1 = #o01, so the command would be (setup-nvram #o01) formatter#2 + unit#0 = #o20, so the command would be (setup-nvram #o20)" (If (NVRAM-functioning-p) (let ((slot (ldb 0004 NVRAM-Slot))) (Write-NVRAM-24B NVRAM-Monitor-Unit 0) (Write-NVRAM NVRAM-Monitor-Slot slot) (Write-NVRAM-24B NVRAM-Keyboard-Unit 0) (Write-NVRAM NVRAM-Keyboard-Slot slot) (Write-NVRAM-24B NVRAM-Boot-Unit unit) (Write-NVRAM NVRAM-Boot-Slot 2) ; ***get this somewhere -ab (Write-NVRAM NVRAM-Generation NVRAM-Format-Generation-Number) (Write-NVRAM NVRAM-Revision NVRAM-Format-Revision-Level) (Write-NVRAM-16B NVRAM-CRC #xFFFF) (Write-NVRAM-16B NVRAM-Config-Checksum #xFFFF) (Write-NVRAM NVRAM-Shutdown-Valid-Character 0) (Write-NVRAM NVRAM-Shutdown-Cause #xFF) (Write-NVRAM NVRAM-Boot-Month 0) (Write-NVRAM NVRAM-Boot-Day 0) (Write-NVRAM NVRAM-Boot-Hour 0) (Write-NVRAM NVRAM-Boot-Minute 0) (Write-NVRAM-32B NVRAM-Seconds-Since-Boot 0) (Write-NVRAM-16B NVRAM-Start-Unallocated-Area #x1000) ; ??? -ab (Write-NVRAM-16B NVRAM-Number-Typed-Blocks 6) (initialize-reserved-areas) (Initialize-Crash-Rec-Buffer #x400 #x1000) "NVRAM initialized successfully") "NVRAM initialization failed: unable to verify functioning of NVRAM.")) ;;; ;;; CHANGE-NVRAM. ;;; (Defun Change-NVRAM (&key (monitor-unit 0) (monitor-slot 5) (keyboard-unit 0) (keyboard-slot 5) (load-unit 0) (load-slot 2) (ns NVRAM-Slot) (no NVRAM-Slot-Offset)) "This utility changes specific NVRAM parameters to support STBM access to monitor, keyboard, and load source. One or more keyword argument pairs are entered to change the desired parameters as follows: (change-nvram {:monitor-unit n } ;default = 0 {:monitor-slot n } ;default = 5 {:keyboard-unit n } ;default = 0 {:keyboard-slot n } ;default = 5 {:load-unit n } ;default = 0 {:load-slot n } ;default = 2 {:ns n } ;nvram slot: default = 5 {:no #xnnnnnn} ) ;nvram offset:def.=#xfa0000 where: { xxx } = an optional entry (otherwise the default is entered into NVRAM) n = number For example: to change only load unit: (Change-NVRAM :load-unit 1)" (let ((NVRAM-Slot (Dpb #x+F 0404 ns)) ;Bind these for doing these writes, and for (NVRAM-Slot-Offset no)) ;NVRAM-functioning-p. May be used to set NVRAM (If (NVRAM-functioning-p) ;on a 2nd SIB board. (Progn (Write-NVRAM-24B NVRAM-Monitor-Unit monitor-unit) (Write-NVRAM NVRAM-Monitor-Slot monitor-slot) (Write-NVRAM-24B NVRAM-Keyboard-Unit keyboard-unit) (Write-NVRAM NVRAM-Keyboard-Slot keyboard-slot) (Write-NVRAM-24B NVRAM-Boot-Unit load-unit) (Write-NVRAM NVRAM-Boot-Slot load-slot) ; ***get this somewhere -ab (format t "~&NVRAM changes completed successfully.") (describe-NVRAM-setup)) "NVRAM changes failed: unable to verify functioning of NVRAM") (values))) (Defun Describe-NVRAM-Setup () "Displays the current boot default values stored in NVRAM." (format t "~& Monitor Slot is ~10r.~ ~& Monitor Unit is ~10r.~ ~& Keyboard Slot is ~10r.~ ~& Keyboard Unit is ~10r.~ ~& Load Unit is ~10r.~ ~& Load Slot is ~10r.~&" (Read-NVRAM-24B NVRAM-Monitor-Unit) (Read-NVRAM NVRAM-Monitor-Slot) (Read-NVRAM-24B NVRAM-Keyboard-Unit) (Read-NVRAM NVRAM-Keyboard-Slot) (Read-NVRAM-24B NVRAM-Boot-Unit) (Read-NVRAM NVRAM-Boot-Slot)) (values)) ;;; ;;; Edit NVRAM routine. Same idea as Setup-NVRAM, but uses CVV menu. This will be in system, ;;; but not in documentation. This needs much more work: error checking, and taking out ;;; absolute offsets. -ab ;;; (defvar *monitor-unit*) (defvar *monitor-slot*) (defvar *keyboard-unit*) (defvar *keyboard-slot*) (defvar *load-unit*) (defvar *load-slot*) (defun edit-nvram (&key ((:nvram-slot ns) 5) ((:nvram-offset no) #xfa0000)) "This utility allows editing specific NVRAM parameters to support STBM access to monitor, keyboard, and load source. All values are displayed and entered in hexadecimal. Optionally, the keyword :NVRAM-SLOT can be used if the NVRAM is not located on the default board in slot 5. Also, in case the NVRAM is located at a different offset within the slot space of the board than for the SIB then the keyword :NVRAM-OFFSET can be used." (let ((base 16.) (ibase 16.)) (setq *monitor-unit* (logand #xff (si:%nubus-read (plus #xf0 ns) (plus no #x00)))) ;monitor unit lsb byte (setq *monitor-slot* (logand #xff (si:%nubus-read (plus #xf0 ns) (plus no #x0c)))) ;monitor slot (setq *keyboard-unit* (logand #xff (si:%nubus-read (plus #xf0 ns) (plus no #x10)))) ;keyboard unit lsb byte (setq *keyboard-slot* (logand #xff (si:%nubus-read (plus #xf0 ns) (plus no #x1c)))) ;keyboard slot (setq *load-unit* (logand #xff (si:%nubus-read (plus #xf0 ns) (plus no #x20)))) ;load unit lsb byte (setq *load-slot* (logand #xff (si:%nubus-read (plus #xf0 ns) (plus no #x2c)))) ;load slot (tv:choose-variable-values '((*monitor-unit* "Monitor unit number") (*monitor-slot* "Monitor slot number") (*keyboard-unit* "Keyboard unit number") (*keyboard-slot* "Keyboard slot number") (*load-unit* "Load unit number") (*load-slot* "Load slot number")) ':label "Edit NVRAM values" ':width 25.) (si:%nubus-write (plus #xf0 ns) (plus no #x00) *monitor-unit*) ;monitor unit lsb byte (si:%nubus-write (plus #xf0 ns) (plus no #x0c) *monitor-slot*) ;monitor slot (si:%nubus-write (plus #xf0 ns) (plus no #x10) *keyboard-unit*) ;keyboard unit lsb byte (si:%nubus-write (plus #xf0 ns) (plus no #x1c) *keyboard-slot*) ;keyboard slot (si:%nubus-write (plus #xf0 ns) (plus no #x20) *load-unit*) ;load unit lsb byte (si:%nubus-write (plus #xf0 ns) (plus no #x2c) *load-slot*) )) ;load slot