;;; -*- 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.

(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 <val> 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 <val> 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

