(FILECREATED " 8-Nov-85 11:47:34" {ERIS}<LISPCORE>DOVE>VMEMSIZEPATCH.;7 6356   

      changes to:  (VARS VMEMSIZEPATCHCOMS)
		   (FNS VMemSizePatchEventFN)

      previous date: " 5-Nov-85 19:40:37" {ERIS}<LISPCORE>DOVE>VMEMSIZEPATCH.;6)


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT VMEMSIZEPATCHCOMS)

(RPAQQ VMEMSIZEPATCHCOMS ((DECLARE: DONTCOPY (FILES (LOADCOMP)
						      <LISPCORE>SOURCES>LOCALFILE 
						      <LISPCORE>DOVE>LISPOTHELLO)
				      (MACROS \PV.SubVolumeDescFromVol#))
			    (INITVARS (\LispOthello.PhysicalVolumeRootPage (NCREATE (QUOTE VMEMPAGEP))
									   )
				      (\LispOthello.FileDescriptor (NCREATE (QUOTE FileDescriptor)))
				      (\LispOthello.Label (NCREATE (QUOTE VMEMPAGEP))))
			    (GLOBALVARS \LispOthello.PhysicalVolumeRootPage 
					\LispOthello.FileDescriptor \LispOthello.Label)
			    (FNS \Dove.FixVMemSize \Dove.GetBootFileDescriptor 
				 \PV.DiskFileIDOfBootFile \PV.LVDescFromDiskAddress 
				 \PV.ReadPVRootPage \PV.DiskPageNumber \PV.MapSubVolumes 
				 \Dove.GetVMemSize VMemSizePatchEventFN)
			    (P (\Dove.FixVMemSize))
			    (ADDVARS (AROUNDEXITFNS VMemSizePatchEventFN))))
(DECLARE: DONTCOPY 
(FILESLOAD (LOADCOMP)
	   <LISPCORE>SOURCES>LOCALFILE <LISPCORE>DOVE>LISPOTHELLO)

(DECLARE: EVAL@COMPILE 
(DEFMACRO \PV.SubVolumeDescFromVol# (vol#)
	  (BQUOTE (\ADDBASE (fetch (PhysicalVolumeDescriptor subVolumes)
				   of \LispOthello.PhysicalVolumeRootPage)
			    (TIMES , vol# (MESASIZE SubVolumeDesc)))))
)
)

(RPAQ? \LispOthello.PhysicalVolumeRootPage (NCREATE (QUOTE VMEMPAGEP)))

(RPAQ? \LispOthello.FileDescriptor (NCREATE (QUOTE FileDescriptor)))

(RPAQ? \LispOthello.Label (NCREATE (QUOTE VMEMPAGEP)))
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS \LispOthello.PhysicalVolumeRootPage \LispOthello.FileDescriptor \LispOthello.Label)
)
(DEFINEQ

(\Dove.FixVMemSize
  (LAMBDA NIL                                                (* edited: " 5-Nov-85 19:40")
    (COND
      ((EQ (MACHINETYPE)
	     (QUOTE DOVE))
	(replace (IFPAGE DLLastVmemPage) of \InterfacePage with (IDIFFERENCE (
										\Dove.GetVMemSize)
										     2))))))

(\Dove.GetBootFileDescriptor
  (LAMBDA (BootFileType)                                     (* edited: " 5-Nov-85 18:13")

          (* * Find the logical volume of the boot file of type BootFileType. Return the leader page for that file)


    (LET* ((DiskFileID (\PV.DiskFileIDOfBootFile BootFileType))
	   (FileID (\GETBASE DiskFileID 0))
	   (PilotDiskAddress (fetch (DiskFileID da) of DiskFileID))
	   (LVDesc (COND
		     ((NEQ PilotDiskAddress 0)
		       (\PV.LVDescFromDiskAddress PilotDiskAddress))))
	   (vol# (COND
		   (LVDesc (GETHASH LVDesc \DFSLogicalVolumeHash)))))
          (COND
	    (vol# (replace (FileDescriptor fileID) of \LispOthello.FileDescriptor with FileID)
		  (replace (FileDescriptor volNum) of \LispOthello.FileDescriptor with vol#)
		  (replace (FileDescriptor type) of \LispOthello.FileDescriptor with 
									     tDiagnosticMicrocode)
		  \LispOthello.FileDescriptor)))))

(\PV.DiskFileIDOfBootFile
  (LAMBDA (N)                                                (* ejs: "10-Sep-85 01:16")
    (\ADDBASE (fetch (PhysicalVolumeDescriptor bootingInfo) of 
							      \LispOthello.PhysicalVolumeRootPage)
		(ITIMES N (MESASIZE DiskFileID)))))

(\PV.LVDescFromDiskAddress
  (LAMBDA (PilotDiskAddress)                                 (* ejs: " 9-Sep-85 23:38")
    (LET ((DiskPageNumber (\PV.DiskPageNumber PilotDiskAddress)))
         (\PV.MapSubVolumes (FUNCTION (LAMBDA (SVDesc LVDesc)
				  (LET* ((FirstPage (fetch (SubVolumeDesc pvPage) of SVDesc))
					 (LastPage (IPLUS FirstPage (fetch (SubVolumeDesc nPages)
									 of SVDesc))))
				        (COND
					  ((AND (IGEQ DiskPageNumber FirstPage)
						  (ILEQ DiskPageNumber LastPage))
					    (RETFROM (QUOTE \PV.LVDescFromDiskAddress)
						       LVDesc))))))))))

(\PV.ReadPVRootPage
  (LAMBDA NIL                                                (* ejs: "10-Sep-85 23:49")
    (\PFTransferPage 0 \LispOthello.PhysicalVolumeRootPage (QUOTE VRR)
		       \LispOthello.Label)
    (COND
      ((NEQ (fetch (PhysicalVolumeDescriptor seal) of \LispOthello.PhysicalVolumeRootPage)
	      \PV.RootSeal)
	(ERROR "Physical volume root page seal is invalid!" (fetch (PhysicalVolumeDescriptor
									 seal)
								 of 
							      \LispOthello.PhysicalVolumeRootPage)))
      (T \LispOthello.PhysicalVolumeRootPage))))

(\PV.DiskPageNumber
  (LAMBDA (PilotDiskAddress)                                 (* ejs: " 9-Sep-85 23:03")

          (* * Returns the disk page number for the Pilot disk address)


    (IPLUS (ITIMES (fetch (PilotDiskAddress Cylinder) of PilotDiskAddress)
		       \DLDISKSHAPE.SECTORSPERCYLINDER)
	     (ITIMES (fetch (PilotDiskAddress Head) of PilotDiskAddress)
		       \DLDISKSHAPE.SECTORSPERHEAD)
	     (fetch (PilotDiskAddress Sector) of PilotDiskAddress))))

(\PV.MapSubVolumes
  (LAMBDA (FUNCTION)                                       (* ejs: "10-Sep-85 17:32")
    (bind SVDesc for SVIndex from 0 to (SUB1 (fetch (PhysicalVolumeDescriptor 
										   subVolumeCount)
							  of \LispOthello.PhysicalVolumeRootPage))
       eachtime (SETQ SVDesc (\PV.SubVolumeDescFromVol# SVIndex))
       do (APPLY* FUNCTION SVDesc (ELT \DFSLogicalVolumes SVIndex)
		      SVIndex))))

(\Dove.GetVMemSize
  (LAMBDA NIL                                                (* edited: " 5-Nov-85 19:03")
    (\PV.ReadPVRootPage)
    (\PFFindFileSize (\Dove.GetBootFileDescriptor 2))))

(VMemSizePatchEventFN
  (LAMBDA (EVENT)                                            (* ejs: " 8-Nov-85 11:46")
    (SELECTQ EVENT
	       ((AFTERSYSOUT AFTERLOGOUT AFTERSAVEVM AFTERMAKESYS)
		 (\Dove.FixVMemSize))
	       NIL)))
)
(\Dove.FixVMemSize)

(ADDTOVAR AROUNDEXITFNS VMemSizePatchEventFN)
(PUTPROPS VMEMSIZEPATCH COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1873 6201 (\Dove.FixVMemSize 1883 . 2219) (\Dove.GetBootFileDescriptor 2221 . 3217) (
\PV.DiskFileIDOfBootFile 3219 . 3508) (\PV.LVDescFromDiskAddress 3510 . 4154) (\PV.ReadPVRootPage 4156
 . 4745) (\PV.DiskPageNumber 4747 . 5261) (\PV.MapSubVolumes 5263 . 5742) (\Dove.GetVMemSize 5744 . 
5954) (VMemSizePatchEventFN 5956 . 6199)))))
STOP