(FILECREATED "22-Nov-85 00:37:07" {ERIS}<LISPCORE>DOVE>VMEMSIZEPATCH.;9 6522   

      changes to:  (VARS VMEMSIZEPATCHCOMS)
		   (FNS \Dove.FixVMemSize)

      previous date: "18-Nov-85 17:08:04" {ERIS}<LISPCORE>DOVE>VMEMSIZEPATCH.;8)


(* 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#))
			    (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)
			    (DECLARE: DONTEVAL@LOAD DOCOPY [INITVARS (
\LispOthello.PhysicalVolumeRootPage (NCREATE (QUOTE VMEMPAGEP)))
								     (\LispOthello.FileDescriptor
								       (NCREATE (QUOTE FileDescriptor)
										))
								     (\LispOthello.Label
								       (NCREATE (QUOTE VMEMPAGEP]
				      (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]
)
)
(DECLARE: DOEVAL@COMPILE DONTCOPY

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

(\Dove.FixVMemSize
  [LAMBDA NIL                                                (* bvm: "22-Nov-85 00:33")
    (COND
      ((EQ (MACHINETYPE)
	     (QUOTE DOVE))
	(replace (IFPAGE DLLastVmemPage) of \InterfacePage with (SETQ \LASTVMEMFILEPAGE
									(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)                                            (* amd "18-Nov-85 17:07")
    (SELECTQ EVENT
	       ((AFTERSYSOUT AFTERLOGOUT AFTERSAVEVM AFTERMAKESYS)
		 (\PFEnsureInitialized)
		 (\Dove.FixVMemSize))
	       NIL])
)
(DECLARE: DONTEVAL@LOAD DOCOPY 

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

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

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

(\Dove.FixVMemSize)


(ADDTOVAR AROUNDEXITFNS VMemSizePatchEventFN)
)
(PUTPROPS VMEMSIZEPATCH COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1722 6120 (\Dove.FixVMemSize 1732 . 2100) (\Dove.GetBootFileDescriptor 2102 . 3088) (
\PV.DiskFileIDOfBootFile 3090 . 3376) (\PV.LVDescFromDiskAddress 3378 . 4011) (\PV.ReadPVRootPage 4013
 . 4600) (\PV.DiskPageNumber 4602 . 5114) (\PV.MapSubVolumes 5116 . 5635) (\Dove.GetVMemSize 5637 . 
5845) (VMemSizePatchEventFN 5847 . 6118)))))
STOP