;;; -*- Mode:LISP; Package:UNIX; Base:8; Lowercase:T -*-

;;; Copyright (c) 1984, Lisp Machine, Inc.
;;;   See the file "Copyright" for
;;; licensing and release information.



(defun find-unix-op (&optional no-error)
  (dolist (op si:*other-processors*
	      (if no-error nil (ferror nil "can't find unix processor")))
    (cond ((= (si:%processor-conf-processor-type (si:op-proc-conf op)) 2)
	   (return op)))))

(defun unix-menu ()
  (setf (si:%processor-conf-boot-command (si:op-proc-conf (find-unix-op)))
	si:%proc-conf-boot-command-menu))

(defun reboot-unix ()
  (setf (si:%processor-conf-boot-command (si:op-proc-conf (find-unix-op)))
	si:%proc-conf-boot-command-boot))

(defun halt-unix ()
  (setf (si:%processor-conf-boot-command (si:op-proc-conf (find-unix-op)))
	si:%proc-conf-boot-command-halt))


(defun find-other-lambda-ops (&optional no-error)
  (let ((ops (loop for op in si:*other-processors*
		   as proc-conf = (si:op-proc-conf op)
		   when (and (= (si:%processor-conf-processor-type proc-conf) 1)
			     (not (= (logand #xf (si:%processor-conf-slot-number proc-conf))
			  (logand #xf si:rg-quad-slot))))
		   collect op)))
    (if (and (null ops)
	     (not no-error))
	(ferror nil "no other lambdas found"))
    ops))

(defun reboot-other-lambda ()
  (let ((ops (find-other-lambda-ops)))
    (cond ((= (length ops) 1)
	   (if (yes-or-no-p "Really reboot other lambda? ")
	       (setf (si:%processor-conf-boot-command (si:op-proc-conf (car ops)))
		     si:%proc-conf-boot-command-boot))))))

; 7/17/86 rpp
(defconst *version-7-signature* (format nil "SUPR~c~c~c~c" 0 0 0 1))

(defun version-7-unix-p ()
  (equal *version-7-signature*
	 (si:string-in-block 'unx0 0 0 8)))
