-- BootFile.mesa (last edited by: McJones on: July 11, 1980 9:09 AM)
DIRECTORY
Environment
USING [PageCount, PageNumber, wordsPerPage],
PageMap
USING [Value];

BootFile:
DEFINITIONS =
BEGIN

currentVersion:
CARDINAL = 101; -- for boot files written using these definitions (see Header below)

-- A boot file is intended to capture the state of real memory and the relevant processor registers, most notably the map. It consists of a Header page followed by one or more data pages, followed by zero or more groups each consisting of a Trailer page followed by one or more data pages. Each Header or Trailer page assigns virtual and real addresses and flag bits to the accompanying data pages. The Header page contains some additional global state.

-- Assertion: if Entry[p, v] precedes Entry[p’, v’] in a boot file, then p is less than (and not equal to) p’.
-- If a boot file does NOT contain an entry for a given page, that page is understood to be vacant.

-- There are two variations of boot files, corresponding to whether the captured state is a snapshot of a running program or has been fabricated with "bit tweezers". In the former case (resumptive Continuation), some process is waiting on the BootSwap.pMon.condResponse condition variable. In the latter case (initial Continuation), a distinguished PSB is made ready to xfer to a given control link and the BootSwapGerm waits.

-- There is an additional distinction depending on whether the inLoadMode of a boot file is load or resume.

-- An inLoadMode=load signifies that the program captured in the boot file does not care into which real pages it is loaded. In this case InLoad expects all real memory to be mapped to an initial prefix of virtual memory; it leaves all excess real memory mapped immediately following the last virtual page it loads. (Thus those virtual pages between ones which are loaded are set vacant.)
-- An inLoadMode=restore signifies that the program captured in the boot file expects to be reloaded into the real pages specified in the boot file.
-- With either inLoadMode, the flags (W, D, R) of the loaded pages are set to the values specified in the boot file.

-- To be distributed via the current ethernet boot servers, one of these boot files would have to be "encapsulated" by preceding it with a dummy page containing an appropriate timestamp.

Header:
TYPE = MACHINE DEPENDENT RECORD [ -- first page of boot file
version --(0)--:
CARDINAL ← currentVersion,
creationDate --(1)--:
LONG UNSPECIFIED, -- System.GreenwichMeanTime
pStartListHeader --(3)--:
POINTER, -- when continuation kind=initial (and relative to that mds)
fill: [0..100000B) ← 0,
inLoadMode --(4:0..15)--: InLoadMode,
-- description of computation after InLoad
continuation --(5)--: Continuation,
-- processor CSB (how much applies only in resumptive case?)
-- currentPSB, readyList, currentSV,firstPSB,lastPSB,firstSV,wakeupsWaiting,active,timeoutCounter:
-- page map data
countData --(7)--: CARDINAL, -- number of nonvacant pages (not counting germ)
entries --(10B)--:
ARRAY [0..0) OF Entry];

Trailer:
TYPE = MACHINE DEPENDENT RECORD [
version --(0)--:
CARDINAL ← currentVersion,
entries --(1)--:
ARRAY [0..0) OF Entry];

InLoadMode:
TYPE = {load, restore};
Continuation: TYPE = MACHINE DEPENDENT RECORD [
fill: [0..177B] ← 0,
vp: SELECT kind --(0:0..7)--: ContinuationKind FROM
initial => [
mdsi --(0:8..15)--: MDSIndex,
destination --(1)--:
UNSPECIFIED -- control link --],
resumptive => [
mdsi --(0:8..15)--: MDSIndex
-- for WriteMDS hack --,
resumee --(1)--:
UNSPECIFIED -- handle of waiting process --],
ENDCASE];
ContinuationKind:
TYPE = {initial, resumptive};

Entry:
TYPE = MACHINE DEPENDENT RECORD [
page (0):
Environment.PageNumber,
value (1):
PageMap.Value];

MDSIndex:
TYPE = RECORD [[0..256)]; -- high order bits of long point to MDS (low 16 must be zero)
MemorySizeToFileSize: PROCEDURE [countReal: Environment.PageCount] RETURNS [Environment.PageCount] =
-- Calculate upper bound on boot file size as function of real memory size.
INLINE BEGIN RETURN[
countReal
-- total data pages
+1
-- header page
+(
MAX[countReal, maxEntriesPerHeader]-maxEntriesPerHeader+maxEntriesPerTrailer-1)
/maxEntriesPerTrailer
-- trailer pages
]
END;

maxEntriesPerHeader:
CARDINAL = (Environment.wordsPerPage-SIZE[Header])/SIZE[Entry];
maxEntriesPerTrailer:
CARDINAL = (Environment.wordsPerPage-SIZE[Trailer])/SIZE[Entry];

END.
LOG
Time: December 15, 1978 5:32 PMBy: McJonesAction: Create file
Time: January 26, 1980 11:29 PMBy: ForrestAction: Move MDSIndex here from Boot
Time: July 11, 1980 9:09 AMBy: McJonesAction: Delete self field of Header