-- ControlPack.pack

-- Yokota  March 23, 1981  10:37 AM  GetGreenwichMeanTime is moved from SwappableSystem to ResidentCool.
-- McJones  February 4, 1981  6:44 PM  Eliminate control-z's
-- Gobbel  January 31, 1981  11:18 AM  Add ResidentCool pack (reserved memory handle); add SystemImpl.InitializeLocalTimeParameters to Initialization; delete frames

Control: SEGMENT =
  BEGIN

  ResidentSystem: CODE PACK =
    {SystemImpl  [InitializeUIDCleanup]}; -- A cleanup procedure

  ResidentCool: CODE PACK = -- reserved memory handle only
    -- GetGreenwichMeanTime is moved here since Star uses it often
    {PilotControl [ReservedMemoryHandle]; SystemImpl [GetGreenwichMeanTime]};

  SwappableSystem: CODE PACK =
    {SystemImpl EXCEPT Initialization, ResidentCool, ResidentSystem};

  Initialization: CODE PACK =
    BEGIN
    PilotControl EXCEPT ResidentCool;
    SystemImpl [InitializeLocalTimeParameters];
    SystemImpl [MAIN];
    END;

END;
-- FileMgrPack.pack

-- Yokota  March 23, 1981  11:38 AM  GetLabelString is moved from FileHelperProcess to Volume, and GetSavedLocalTimeParameters is moved from FileAttributes to PhysicalVolume.
-- McJones  January 31, 1981  11:19 AM  {Get, Set}LocalTimeParameters; diddle Scavenger; delete frames
-- Gobbel  January 13, 1981  3:36 PM  (previous edit)
-- Levin	August 26, 1982 3:42 pm	ReplicateImmutable now separate from Move.

FileMgr: SEGMENT =
BEGIN

FileHelperProcess: CODE PACK =
  BEGIN
  FileImpl [FileHelperProcess, GetFileDescriptorSignals, GetFileDescriptor];
  VolAllocMapImpl [Close];
  VolFileMapImpl [Close, ContextSet, Find, Get, GetPageGroup, Lower,
    ReadNext];
    -- We include GetAttributes, GetLabelString, GetLogicalRootPage and
    -- GetStatus here as they fit and are (or are presumed to be) called
    -- frequently in the development environment
  VolumeImpl [Activate, Deactivate, GetAttributes, GetLogicalRootPage, GetNext,
    GetStatus, LogicalVolumeFind, LVGetEntryPointer, LVGetStatus, VolumeAccess];
   END;

VMMHelperProcs: CODE PACK =
  {FileImpl [GetFileAttributes]};

VFMChangingSize: CODE PACK =
  BEGIN
  VolAllocMapImpl [AccessVAM, AllocPageGroup, FreePageGroup];
  VolFileMapImpl [CreateVPage, Delete, DeletePageGroup, FreeVPage, Insert,
      InsertPageGroup, Merge, PutNext, Split, Xtra];
  END;

FileCreate: CODE PACK =
  {FileImpl [Create, CreateWithID, CreateWithIDExternal, CreateWithIDInternal,
      TmpsEnter, TmpsGet, TmpsGrow]};

FileDelete: CODE PACK =
  {FileImpl [Delete, DeleteCommon, DeleteFileOnVolumeInternal,
    DeleteImmutable, TmpsRemove]};

FileSetSize: CODE PACK =
  {FileImpl [SetSize, SetSizeInternal]};

FileAttributes: CODE PACK =
  BEGIN
  FileImpl [ChangeAttributes, ChangeAttributesInternal, GetAttributes,
    GetSize, MakeImmutable, MakePermanent];
  -- The following should be in a small cold PhysicalVolume pack (it is used once/boot), but it fits here:
  END;

FileMapLogging: CODE PACK =
  {FileImpl [GetBootLocation, GetFilePoint, GetVIDAndGroup]};

OtherFileStuff: CODE PACK =
  {FileImpl [IsOnVolume, MakeBootable,
    MakeBootableOrUnbootable, MakeUnbootable, SetDebuggerFiles]};

TransactionRelatedRunning: CODE PACK =
  {FileImpl [LogContents, TxSetSize]};

TransactionRelatedAborting: CODE PACK =
  {FileImpl [MakeMutable, MakeTemporary, TxCreate, TxMakePerm]};

Scavenger: CODE PACK =
  BEGIN
  ScavengeImpl EXCEPT [Initialize, MAIN];
  VolFileMapImpl [InitMap];
  VolumeImpl [BeginScavenging, EndScavenging];
  END;

Volume: CODE PACK =
  BEGIN
  FileImpl [CloseVolumeAndFlushFiles, DeleteTempsInternal,
    DeleteTmpsInternalNew, DeleteTmpsInternalOld, OpenVolumeAndDeleteTemps];
  VolFileMapImpl [GetNextFile];
  VolumeImpl [Close, CloseLogicalVolume, GetLabelString, GetRootFile, IsOnServer, Open,
    OpenLogicalVolume, OpenLogicalVolumeInternal, OpenVolume, PutRootFile,
    SetRootFile, SignalVolumeAccess];
  END;

PhysicalVolume: CODE PACK =
  BEGIN
  MarkerPageImpl [Enter, EnterMarkerID, Find, FindInternal, Flush];
  PhysicalVolumeImpl [AssertNotAPilotVolume, AssertPilotVolume,
    AwaitStateChange, CheckPhysicalRootLabel, DriveSize,
    FinishWithNonPilotVolume, GetAttributes, GetDrive, GetHandle, GetHints,
    GetNext, GetNextDrive, GetNextLogicalVolume, GetPVDrive,
    GetSavedLocalTimeParameters, InterpretHandle,
    IsReady, Offline, PhysicalRootPageAccess, PhysicalRootPageAccessInternal,
    PhysicalRootPageCheck, PhysicalRootPageMap, PhysicalRootPageUnmap,
    PhysicalVolumeOffLineInternal, PhysicalVolumeOnLineInternal,
    RegisterPvInfo, RegisterSubvolumeMarker, SetSavedLocalTimeParameters, ValidateDrive];
  VolumeImpl [CheckLogicalVolume, EnterLV, FindLogicalVolume, GetLVStatus,
    LogicalVolumeCheck, LogicalVolumeDebuggerCheck, LogicalVolumeLike,
    LogicalVolumeOffLine, LVDecrementPieceCount, PinnedFileEnter,
    PinnedFileFlush, ReadAndCheckLogicalRootLabel, RegisterLogicalSubvolume,
    RegisterVFiles, SubvolumeOffline, SubvolumeOnline, UnregisterVFiles,
    VFileEnter];
  END;

Othello: CODE PACK =
  BEGIN
  MarkerPageImpl [CreateMarkerPage, GetNextPhysicalVolume, MarkerPageMap,
    MarkerPageUnmap, UpdateLogicalMarkerPages, UpdatePhysicalMarkerPages];
  PhysicalVolumeImpl [AccessPhysicalVolumeRootPage, CreateLogicalVolume,
    CreatePhysicalVolume, EraseLogicalVolume, GetContainingPhysicalVolume,
    GetNextBadPage, GetNextSubVolume, GetPhysicalVolumeAttributes,
    GetPhysicalVolumeBootFiles, GetSubVolumeAttributes, MarkPageBad,
    SetPhysicalVolumeBootFiles];
  VolumeImpl [DriveSize, GetContainingPhysicalVolume,
    GetLogicalVolumeBootFiles, GetType, LogicalVolumeCreate,
    LogicalVolumeErase, SetLogicalVolumeBootFiles];
  END;

FileMgrInitialization: CODE PACK =
  BEGIN
  -- Pin is only called by PilotControl. Move and ReplicateImmutable are
  -- here only since they are unimplemented.
  FileImpl [InitializeFileMgr, MAIN, Move, Pin, ReplicateImmutable];
  MarkerPageImpl [MAIN];
  PhysicalVolumeImpl [InitDisks, MAIN];
  ScavengeImpl [Initialize, MAIN];
  VolAllocMapImpl [MAIN];
  VolFileMapImpl [MAIN];
  VolumeImpl [OpenInitialVolumes, MAIN];
  END;
END;
-- FilerPack.pack
-- Last edit by:
-- Yokota  March 23, 1981  9:55 AM  FCacheCleanUp, RemoveCacheEntry, SetFile, SetCacheEntry, SetPageGroup, Await, Report, Log and HandleError are moved from Resident to ResidentCool.

-- Gobbel  January 31, 1981  11:30 AM  Moved frame packs into PilotKernelFrames.pack.

-- Knutsen  January 21, 1981  3:45 PM  Added InitalizeSubVolume.

-- Gobbel  January 19, 1981  4:17 PM  Create ResidentCool code pack.

Filer: SEGMENT =
BEGIN

-- Resident code - by definition!

Resident: CODE PACK =
  BEGIN
  FileCacheImpl EXCEPT Initialization, ResidentCool;
  FilerTransferImpl EXCEPT Initialization, LabelHacking, ResidentCool;
  FileTaskImpl EXCEPT Initialization, ResidentCool;
  SubVolumeImpl EXCEPT Initialization, ResidentCool;
  END;

ResidentCool: CODE PACK = -- goes in display memory on Dandelion
  BEGIN
  FileCacheImpl [FlushFile, FlushFilesOnVolume, FCacheCleanUp, RemoveCacheEntry, SetFile,
    SetCacheEntry, SetPageGroup];
  FilerExceptionImpl EXCEPT Initialization;
  FilerTransferImpl [Log];
  FileTaskImpl [ErrorHalt, HandleError, LabelWait];
  SubVolumeImpl [GetPageAddress, ErrorHalt, GetNext, OnLine, OffLine];
  END;

-- Swappable code (resident descriptor)

LabelHacking: CODE PACK =
  {FilerTransferImpl [ReadLabel, Perform, ReadRootLabel, WriteLabels,
    VerifyLabels, ReadLabelAndData, WriteLabelAndData]};

-- Initialization code:

Initialization: CODE PACK = -- initially resident
  BEGIN
  FileCacheImpl [Initialize, MAIN];
  FilerControl;
  FilerExceptionImpl [MAIN];
  FilerTransferImpl [MAIN];
  FileTaskImpl [MAIN];
  SubVolumeImpl [MAIN, InitializeSubVolume];
  END;
END;
-- SwapperPack.pack

-- Last edited by:
-- Yokota  March 23, 1981  10:22 AM  Delete in CachedSpaceImpl is moved from Resident to ResidentCool. ResidentMemoryImpl and SwapperExceptionImpl in Resident are moved into ResidentCool. Some other procedures in Resident are moved into ResidentCool.

-- Knutsen  February 18, 1981  12:35 PM  Deleted MStoreImpl.Initialize.

-- McJones  February 3, 1981  4:37 PM  Add MStoreImpl.CheckRealPageMax

-- Gobbel  January 31, 1981  11:33 AM  Moved frame packs into PilotKernelFrames.pack.

-- Gobbel  January 19, 1981  6:34 PM  Create ResidentCool code pack

Swapper: SEGMENT =
BEGIN

Resident: CODE PACK =
  BEGIN
  CachedRegionImplA EXCEPT Initialization, ResidentCool;
  CachedRegionImplB EXCEPT Initialization;
  CachedSpaceImpl EXCEPT Initialization, ResidentCool;
  MStoreImpl EXCEPT Initialization, ResidentCool;
  PageFaultImpl EXCEPT Initialization;
  SwapBufferImpl EXCEPT Initialization, ResidentCool;
  SwapTaskImpl EXCEPT Initialization;
  END;

SwappableSwapperHot: CODE PACK =
  {SimpleSpaceImpl [ApplyToSpace, ForceOut, Map, Unmap]};

SwappableSwapperWarm: CODE PACK =
  {SimpleSpaceImpl [CopyIn, CopyOut, Kill]};

ResidentCool: CODE PACK =
  BEGIN
  CachedRegionImplA [AgingProcess, AwaitNotCheckedOut, FindUnreferenced, Insert,
    InitializeAllocateMStoreRuthlessly, InitializeDeallocateClean, InitializeInsertIfRoom];
  CachedSpaceImpl [Delete, Get, Insert, Update];
  MStoreImpl [AwaitBelowThreshold, CheckRealPageMax, DonateDedicatedRealMemory,
    Promise,
    -- CAUTION: RecoverMStore must be run BEFORE
    -- DeviceCleanup.Perform[disconnect] has run
    RecoverMStore];
  ResidentMemoryImpl EXCEPT Initialization;
  SwapBufferImpl [Error];
  SwapperControl EXCEPT Initialization;
  SwapperExceptionImpl EXCEPT Initialization;
  END;

Initialization: CODE PACK =
  BEGIN
  CachedRegionImplA [InitializeInternal, InitializeRegionCacheA,
    InitializeRegionCacheB, MAIN];
  CachedRegionImplB [Initialize, MAIN];
  CachedSpaceImpl [MAIN];
  MStoreImpl [InitializeMStore, MAIN, SetThreshold];
  PageFaultImpl [MAIN];
  ResidentMemoryImpl [InitializeResidentMemoryA, InitializeResidentMemoryB,
    MAIN];
  SimpleSpaceImpl [AllocateVM, Create, DescribeSpace, DescribeSpaceInternal,
    DisableInitialization, HandleFromPage, InitializeSimpleSpace, MAIN,
    SuperFromPage];
  SwapBufferImpl [InitializeSwapBuffer, MAIN];
  SwapperControl [InitializeSwapper, MAIN];
  SwapperExceptionImpl [MAIN];
  SwapTaskImpl [MAIN];
  END;

END; --SwapperPack.pack--


-- TransactionsPack.pack
-- Last edit by:

-- Gobbel  January 31, 1981  11:33 AM  Moved frame packs into PilotKernelFrames.pack.
-- Levin  June 1, 1982 2:51 pm  Add new TransactionExtras procedures to TransactionsInitialization


Transactions: SEGMENT =
BEGIN

RunningTransaction: CODE PACK =
   BEGIN
   TransactionLogImpl [AssureLogRoom, LogInternal];
   TransactionStateImpl [AddToTransaction, Log, MakeNode, MaybeCrash, NullProc,
                               UpdateStateFile, WithdrawFromTransaction];
   END;

AbortBeginCommitCommon: CODE PACK =
   BEGIN
   TransactionImpl [ReleaseLog, ReleaseLogInternal];
   TransactionStateImpl [FreeNode, NoMoreOperations, ReleaseTransaction];
   END;

BeginTransaction: CODE PACK =
   BEGIN
   TransactionStateImpl [Begin];
   END;

Abort: CODE PACK =
   BEGIN
   TransactionImpl [Abort, RestoreFilesInTransaction];
   END;

Commit: CODE PACK =
   BEGIN
   TransactionImpl [Commit];
   TransactionStateImpl [RecordCommit];
   END;

TransactionsInitialization: CODE PACK =
   BEGIN
   TransactionImpl [CheckState, CompareStateEdition, DisableTransactions,
                        InitializeTransactionData, MAIN, RecoverState,
                        RecoverTransactions, DoCrashRecovery,
                        TransactionsInProgress, ValidateLogFile];
   TransactionLogImpl [InitializeLogsA, InitializeLogsB, MAIN];
   TransactionStateImpl [InitializeStateA, InitializeStateB, MAIN, SetCrashProcedure];
   END;
END;
-- VMMgrPack.pack

-- Last edited by:

-- September 15, 1982 6:18 pm   Levin   Removed AddressFaultProcess.

--  4-Feb-82 10:41:54   Levin   Added GetMappingSpaceDesc to SpaceStatusOps.

-- 23-Nov-81 17:37:21   Levin   Added ResetGrain to SpaceMapLogging.

-- Yokota  March 23, 1981  11:13 AM  ValidSpaceOrSwapUnit in HierarchyImpl and LongPointer, LongPointerFromPage in SpaceImplA are moved from SpaceMisc to SpaceOpsCommon.

-- Yokota  March 6, 1981  1:31 PM  Move Code from SpaceCodeHacking PACK to SpaceStatusOps PACK.

-- Yokota  March 4, 1981  5:22 PM  Add Activate(Deactivate)Proc, Activate(Deactivate)SwapUnit to SpaceStatusOps PACK.

-- Knutsen  February 25, 1981  3:16 PM  Add AddressFaultProcess to SpaceMisc pack.

-- Knutsen  February 18, 1981  12:39 PM  EnterSpace moved into new code pack VMMgrResident.

-- Gobbel  January 31, 1981  11:33 AM  Moved frame packs into PilotKernelFrames.pack.

-- January 28, 1981   Knutsen   Renamed: WriteFaultProcess ← WriteProtectFaultProcess, CreateAny ← CreateInternal, DeleteAny ← DeleteInternal, VMHelperProcess ← VMMHelperProcess.  Moved: VMHelperProcess to SpaceImplB, EnterSpace to SpaceImplA.

-- January 23, 1981   Knutsen   Deleted *WriteProtectTrap, JoinTransaction, SpaceForCode, MaxIntervalForCode, ReleaseDefaultWindow.  Added WriteProtectFaultProcess, MakeCodeResident, MakeCodeSwappable, Code.  Moved CreateForCode to SpaceCreate pack.

-- January 13, 1981  3:43 PM   Gobbel   Created SpaceMapLogging pack.

-- December 4, 1980  12:59 PM   Luniewski   Moved JoinTransaction, ReleaseDefaultWindow to SpaceOpsCommon.

VMMgr: SEGMENT =
BEGIN

VMMHelperProcess: CODE PACK =
   BEGIN
   HierarchyImpl [Touch, LoadDesc];
   ProjectionImpl [Touch, Get];
   SpaceImplB [VMHelperProcess];
   STLeafImpl [Close, Open];
   STreeImpl [Get, KeyFromPDesc, SearchLeaf, SearchRoot, Update, UpdateRoot];
   END;

SpaceOpsCommon: CODE PACK =
   BEGIN
   -- we include the operations needed to get space handles from long pointers here as
   -- most clients will keep pointers to spaces instead of space handles, thus
   -- necessitating a translation before calling into the Space operations.  GetAttribute
   -- is included here: 1) it fits, and 2) in the development environment, it is frequently
   -- called from HeapImpl.SpaceFromLongPointer which is called from HeapImpl.PruneMDS
   -- which is frequently called.  The presence of GetAttributes here => FindFirstWIthin
   -- must also be here.
   HierarchyImpl [GetDescriptor, FindFirstWithin, GetInterval, Update,
      ValidSpaceOrSwapUnit];
   ProjectionImpl [ForceOut, TranslateLevel];
   SpaceImplA [ApplyToInterval, ForAllRegions, GetAttributes, GetHandle,
      LongPointer, LongPointerFromPage, PageFromLongPointer];
   SpaceImplB [GetSpaceDesc, ProcessWindow];
   END;

SpaceStatusOps: CODE PACK =
   { SpaceImplA [Activate, ActivateProc, ActivateSwapUnit, ApplyToSpace, Code,
         Deactivate, DeactivateProc, DeactivateSwapUnit, ForceOut, Kill];
     SpaceImplB [MakeReadOnly, MakeWritable, GetMappingSpaceDesc] };

SpaceMap: CODE PACK =
   { SpaceImplB [Map];
     STLeafImpl [AllocateWindow] };

SpaceUnmap: CODE PACK =
   { SpaceImplB [Unmap, UnmapInternal];
     STLeafImpl [DeallocateWindow] }; -- Also used by Space.Remap

SpaceCreate: CODE PACK =
   BEGIN
   HierarchyImpl [Insert];
   ProjectionImpl [Split];
   SpaceImplA [
       Create, CreateAligned, CreateForCode, CreateUniformSwapUnits, CreateAny];
   STLeafImpl [Create];
   STreeImpl [AllocateRoot, ExpandRoot, Insert];
   END;

SpaceDelete: CODE PACK =
   BEGIN
   HierarchyImpl [Delete];
   ProjectionImpl [DeleteSwapUnits, Merge];
   SpaceImplA [Delete, DeleteSwapUnits, DeleteAny];
   STLeafImpl [Delete];
   STreeImpl [Delete];
   END;

SpaceCopying: CODE PACK =
   { SpaceImplB [CopyIn, CopyOut, GetCopyInfo] };

SpaceTransactions: CODE PACK =
   { SpaceImplB [ReleaseFromTransaction, WriteFaultProcess] };

SpaceRemap: CODE PACK = { SpaceImplB [Remap] };

SpaceCodeHacking: CODE PACK =
   { SpaceImplA [MakeCodeResident, MakeCodeSwappable,
        MakeGlobalFrameResident, MakeGlobalFrameSwappable,
        MakeProcedureResident, MakeProcedureSwappable, MakeResident,
        MakeSwappable] };

SpaceMapLogging: CODE PACK = { MapLogImpl [ResetGrain, WriteLog1] };

SpaceMisc: CODE PACK =
   { SpaceImplA
        [GetWindow, Pointer, VMPageNumber] };

VMMgrInitialization: CODE PACK =
   BEGIN
   HierarchyImpl [MAIN];
   MapLogImpl [Initialize, MAIN];
   ProjectionImpl [MAIN];
   SpaceImplA [InitializeInternal, InitializeSpace, MAIN];
   SpaceImplB [InitializeSpaceImplB, MAIN];
   STLeafImpl [AllocateMapLogFile, InitVMMgrStore, InitSTLeaf, MAIN];
   STreeImpl [Initialize, MAIN];
   VMMControl [CreateSpace, FillHierarchyAndProjection, InitializeVMMgr,
                    IsDiagnosticPilot, MAIN];
   END;

VMMgrResident: CODE PACK = { SpaceImplA [EnterSpace] };
  -- Contrary to usual practice, this resident code pack is placed *last*.  This is because it is not required and not desired to pin the entry vector of SpaceImplA.  The only stuff that *must* be resident is the code starting from when EnterSpace releases the monitor lock and ending when it resets its priority to the caller's level.  (See notes in SpaceImplA.EnterSpace.)

END; --VMMgrPack.pack--


-- MesaRuntimePack.pack
-- Last edit by:
-- Yokota  March 23, 1981  10:00 AM  FrameImpl in Resident pack is moved into ResidentCool. All the procedures in Instructions are moved from Resident to ResidentCool. Several procedures are interchanged between ProcessesHot and ProcessesCold. Processes in Resident is moved to ResidentCool. GetCaller is moved from FrameImplHot to ResidentCool.

-- Gobbel  March 1, 1981  2:04 PM  Moved Process.SetTimeout, MsecToTicks, and EnableAborts into ResidentCool (for SoundGenerator on DLion).

-- Gobbel  February 23, 1981  11:53 AM  Moved Process.Pause into ResidentCool (for SoundGenerator on DLion).

-- Gobbel  January 31, 1981  11:33 AM  Moved frame packs into PilotKernelFrames.pack.

-- Gobbel January 26, 1981  5:02 PM  Put PilotNub.InitializeDeviceCleanup in Resident code pack.

-- January 20, 1981  10:55 AM   Knutsen   Deleted duplicate frame of Signals - it's now Cold.  Rearraged Processes code pack, deleted CheckProcess.  FrameImpl's frame and fault handler must be resident.  Procedures moved from Traps to FrameImpl.  Misc procedures appearing and disappearing.  Traps now swappable.  InLoadFromBootLocation no longer resident, InitializeInLoadFromBootLoc is.  GetPriority, SetPriority now resident.

-- Gobbel January 19, 1981  4:19 PM  Created ResidentCool code pack

MesaRuntime: SEGMENT =
BEGIN

Resident: CODE PACK =
  BEGIN
  BootSwapCross EXCEPT Initialization;
  PilotNub [InitializeDeviceCleanup];
  -- InitializeInLoadFromBootLoc is vanilla resident so that it won't be mapped
  --  with non-PrincOps memory.
  SnapshotImpl [InitializeInLoadFromBootLoc];
  END;

ResidentCool: CODE PACK = -- goes into display memory on Dandelion
  BEGIN
  -- GetCaller is moved from FrameHotImpl since Star often uses it
  FrameImpl [Codebase, FrameFaultProcess, FrameSize, GetCaller];
  Instructions EXCEPT Initialization;
  PilotNub EXCEPT Initialization, Resident;
  -- BootButton is resident so it is always available.
  -- Process stuff is here because it gets used by SoundGenerator.Beep
  -- GetPriority, SetPriority are used by the Swapper
  Processes [EnableAborts, MsecToTicks, Pause, SetTimeout, GetPriority, SetPriority];
  SnapshotImpl [BootButton];
  END;
  
FrameImplHot: CODE PACK =
  -- The following have been chosen basically at random only under
  -- the constraint that this pack take up only one page.
  -- GetCaller is here explicitly as it makes the working set
  -- for owner checking (in HeapImpl) smaller.
  {FrameImpl [InGFT, IsBound, ValidateFrame, ValidateGlobalFrame]};
  
FrameImplCold: CODE PACK =
  {FrameImpl [AllocGlobalFrame, Copy, DeletedFrame, EntGlobalFrame, EnterGlobalFrame,
    GetBcdTime, GetBuildTime, GetNextGlobalFrame, GetNxGlobalFrame, GlobalFrame, MakeFsi,
    RemoveGlobalFrame, RemvGlobalFrame, SelfDestruct, zUnNew]};
  
ProcessesHot: CODE PACK =
  {Processes [DisableAborts, DisableTimeout, GetCurrent, InitializeCondition,
    InitializeMonitor, SecondsToTicks, TicksToMsec, ValidateProcess, Yield]};
  
ProcessesCold: CODE PACK =
  {Processes [Abort, AllocateNakedCondition, DeallocateNakedCondition,
   Detach, End, Fork, Join, ProcessTrap]};
  
InLoadOutLoad: CODE PACK =
  {SnapshotImpl [BootFromFile, BootFromVolume, BootFromPhysicalVolume,
   GetBootFileSize, GetDevice, InLoad, InLoadFromBootLocation, OutLoad]};
  
Signals: CODE PACK =
  {Signals EXCEPT Initialization};
  
SnapshotMisc: CODE PACK =
  {SnapshotImpl [InstallPhysicalVolumeBootFile,
   InstallVolumeBootFile, MakeBootable, MakeUnbootable]};
  
Traps: CODE PACK =
  {Traps [BoundsFaultTrap, CodeTrap, ControlFaultTrap, DivideCheckTrap, HardwareErrorTrap,
   PointerFaultTrap, Restart, StackErrorTrap, Start, StartCM, StartWithState,
   UnboundProcedureTrap, WakeupErrorTrap, ZeroDivisorTrap] };
  
Initialization: CODE PACK =
  BEGIN
  BootSwapCross [MAIN];
  FrameImpl [InitializeFrameImpl, MAIN];
  Instructions [InitializeInstructions, MAIN];
  PilotNub [InitializeInterrupt, InitializePilotNub, Install, MAIN];
  Processes [InitializeProcesses, MAIN];
  Signals [InitializeSignals, MAIN];
  SnapshotImpl [InitializeSnapshot, MAIN];
  Traps [Initialize, MAIN];
  END;
END;
-- MiscPack.pack
-- Last edit by:
-- Yokota  March 23, 1981  10:11 AM  All the procedures in Resident are moved into ResidentCool. FreeSpace, SpaceFromLongPointer and CheckOwner in HeapImpl are moved into Nodes.

-- Gobbel  January 31, 1981  11:33 AM  Moved frame packs into PilotKernelFrames.pack.

-- Jose  January 27, 1981  2:10 PM  Deleted LargeNode, NodeSize, RelativePointerToPointer from ResidentHeapImplt
-- Gobbel  January 19, 1981  4:27 PM  Created ResidentCool code pack

Misc: SEGMENT =
BEGIN

ByteBlt: CODE PACK =
  {StreamImpl [ByteBlt]};

ResidentCool: CODE PACK = -- goes in display memory on Dandelion
  BEGIN
  ResidentHeapImpl [FreeNode, MakeNode, SplitNode, WordsToPages];
  UtilitiesImpl EXCEPT Initialization;
  ZoneImpl [AddSegment, MakeNode, FreeNode, Split, SplitNode, ValidateZone];
  END;

Streams: CODE PACK =
   {StreamImpl EXCEPT Initialization, ByteBlt};

-- The following code packs are non-resident and depend upon the resident
-- heap only creating, deleting, splitting nodes and adding segments.

Nodes: CODE PACK =
  BEGIN
  HeapImpl [CheckOwner, Expand, ExpandHeap, ExpandMDS, FreeLargeOrRegularNode,
    FreeMDSNode, FreeNode, FreeSpace, MakeLargeNode, MakeMDSNode, MakeNode,
    MakeSpace, Narrow, PagesForNewSegment, SpaceFromLongPointer];
  END;

HeapPruning: CODE PACK =
   BEGIN
   HeapImpl [EnumerateSpaces, Prune, PruneHeap, PruneMDS];
   ZoneImpl [GetAttributes, GetSegmentAttributes, RemoveSegment];
   END;

Attributes: CODE PACK =
   BEGIN
   HeapImpl [GetAttributes, GetAttributesHeap, GetAttributesMDS];
   ZoneImpl [NodeSize];
   END;

CreateDelete: CODE PACK =
   BEGIN
   HeapImpl [Create, CreateHeap, CreateMDS, Delete, DeleteHeap, DeleteMDS,
   MakeResident, MakeResidentHeap, MakeResidentMDS, MakeSwappable,
   MakeSwappableHeap, MakeSwappableMDS];
   ZoneImpl [Create];
   END;

Recreating: CODE PACK =
   {ZoneImpl [GetRootNode, Recreate, SetRootNode]};

Checking: CODE PACK =
   BEGIN
   HeapImpl [SetChecking, SetCheckingHeap, SetCheckingMDS];
   ZoneImpl [CheckNode, CheckZone, SetChecking];
   END;

Initialization: CODE PACK =
   BEGIN
   HeapImpl [InitializeHeap, MAIN];
   ResidentHeapImpl [InitializeResidentHeap, MAIN];
   StreamImpl [InitializeStream, MAIN];
   UtilitiesImpl [InitializeUtilities, MAIN];
   ZoneImpl [InitializeZone, MAIN];
   END;
END;
-- UserTerminalDriverPack.pack
-- Last edit by:
-- Yokota  March 23, 1981  10:29 AM  GetBitBltTable, SetCursorPattern, SetMousePosition
--    are moved from Resident to ResidentCool (new CODE PACK).
-- Gobbel  January 31, 1981  11:33 AM  Moved frame packs into PilotKernelFrames.pack.
-- Levin   22-Mar-82 13:04:50  Add ColorDisplayImpl.
-- Levin   June 10, 1982 9:32 am  Add ColorCursorImpl.

UserTerminalDriver: SEGMENT =
BEGIN

Resident: CODE PACK =
  BEGIN
  UserTerminalImpl [WaitForScanLine, WaitForVerticalRetrace];
  END;

ResidentCool: CODE PACK = {
  UserTerminalImpl [GetBitBltTable, SetCursorPattern, SetMousePosition];
  ColorCursorImpl [SetCursorPattern, Setup]};

UserTerminalDriverSwappable: CODE PACK = {
  UserTerminalImpl EXCEPT Initialization, Resident, ResidentCool;
  ColorDisplayImpl EXCEPT Initialization, Resident, ResidentCool;
  ColorCursorImpl EXCEPT Initialization, Resident, ResidentCool};

Initialization: CODE PACK =
  BEGIN
  -- Explicit qualification is needed below  to avoid ambiguous references
  -- when all of Pilot is packaged via a merged segment.
  UserTerminalDriver.StartChainPlug [MAIN, Start];
  UserTerminalImpl [MAIN, Start];
  ColorDisplayImpl [MAIN, Start, StartHead];
  ColorCursorImpl [MAIN, Start, Init];
  END;

END;
-- DiskDriversPack.pack
-- Last edit by:
-- Yokota  March 20, 1981  10:20 AM  MakeLP & MakeRP are moved from Resident to ResidentCool.
-- Gobbel  January 31, 1981  11:33 AM  Moved frame packs into PilotKernelFrames.pack.
-- Gobbel  January 19, 1981  3:41 PM  Discard AltoFileInterlock, move SA4000Impl.Start to initialization
-- Levin  28-Apr-82 11:54:30  Flush AltoFileInterlock; move its contents to ResidentCool.

DiskDrivers: SEGMENT =
BEGIN

Resident: CODE PACK =
  BEGIN
  -- The only resident driver code is that for the system volume (to prevent
  -- monitor deadlocks caused by a page fault while in that monitor lock) and
  -- the code is callable from the page fault path (i.e., the Filer) - the
  -- driver procs getPageAddress, requestIO.  WARNING: this packaging ASSUMES
  -- that the SA4000 is the system volume!
  DiskChannelImpl EXCEPT Initialization, ResidentCool;
  DiskDriverSharedImpl EXCEPT Initialization;
  SA4000Impl EXCEPT Initialization, ResidentCool;
  END;

ResidentCool: CODE PACK = -- goes in display memory on Dandelion
  BEGIN
  DiskChannelImpl [ErrorHalt, AwaitStateChange, GetDriveAttributes,
    GetDriveTag, GetNextDrive, GetPageNumber, SetDriveState, SetDriveTag,
    Create, Delete, GetAttributes, GetPageAddress, CreateCompletionObject,
    RegisterDrive, MakeLP, MakeRP, Idle, Restart, Suspend];
  SA4000Impl [ErrorHalt, GetPageNumber, ChangeState];
  SA800Impl [GetNextRequest, GetPageAddress, RequestIO];
  END;

SwappableDiskDrivers: CODE PACK =
  BEGIN
  FloppyChannelImpl EXCEPT Initialization;
  SA800Impl EXCEPT Initialization, ResidentCool;
  END;

Initialization: CODE PACK =
  BEGIN
  DiskChannelImpl [MAIN];
  DiskDriverSharedImpl [MAIN];
  FloppyChannelImpl [MAIN, RegisterDrives];
  SA4000Impl [InitGlobals, MAIN, RegisterDrives, Start];
  SA800Impl [MAIN, RegisterDriverProcs];
  DiskDrivers.StartChainPlug;
  END;

END;
-- PilotKernelPack.pack

-- This file specifies the code pack merging for all of PilotKernel.

-- Yokota March 23, 1981  6:07 PM  DiskDrivers.AltoFileInterlock is put into DISCARD CODE PACK (DiscardAltoFileInterlock). VMMgr.SpaceCreate and SpaceDelete are put into a separate code pack (SpaceCreateDelete). MesaRuntime.ProcessesHot is moved to ResidentCool. UserTerminalDriver.ResidentCool is added to ResidentCool. Packs in ResidentCool are rearranged.
-- Knutsen  February 18, 1981  12:50 PM  Added new code pack HighStoreResident.  Renamed code segments.
-- Gobbel  January 31, 1981  11:04 AM  Created from old TestPilotPack.pack
-- Knutsen  January 22, 1981  7:01 AM  New pack MesaRuntime.Traps.  Renamed code packs Frame* to FrameImpl*.  FrameImpl GFrame now resident.  Moved ResidentCool to be second.  Sorted swappable non-Store code packs by config name (only) [careful here!].  Improved documentation.
-- Gobbel  January 19, 1981  4:28 PM  Created ResidentCool code pack.  Deleted VMMgrCommon code pack.  Added MapLogging code pack.
-- Levin  28-Apr-82 11:58:25  Flush DiskDrivers.AltoFileInterlock

-- THE ORDER OF THE CODE PACKS BELOW IS CRUCIAL.
-- DO NOT REARRANGE THE ORDER OF ANYTHING UNLESS YOU
-- ARE SURE OF THE CONSEQUENCES.  In general, new packs will probably be
-- be placed later in the sequence, rather than earlier.

-- This file is used to merge all of the other CODE packaging specifications
-- so as minimize breakage.  This file is used as the next to the last .pack
-- file in the collection of files concatenated into the final packaging
-- specification.  (PilotKernelFrames.pack must be last.)

ResidentAndLowStore: SEGMENT
  MERGES Control, DiskDrivers, Filer, MesaRuntime, Misc,
             Swapper, UserTerminalDriver =
-- All resident code must go in this segment.  Swappable code from the rest
-- of Pilot (excluding FileMgr, Transactions, and VMMgr) goes here too.
BEGIN

Resident: CODE PACK =  -- must be first!
  -- This pack merges all of the resident code of the modules in this segment which goes in PrincOps real memory:
  BEGIN
  Control.ResidentSystem;
  DiskDrivers.Resident;
  Filer.Resident;
  MesaRuntime.Resident;
  -- Misc.Resident; Misc.Resident is moved to ResidentCool
  Swapper.Resident;
  UserTerminalDriver.Resident;
  END;

ResidentCool: CODE PACK =  -- must be second!
   -- This pack merges all of the resident code of the modules in this segment which goes in non-PrincOps real memory:
  BEGIN
  -- The order has been chosen to ensure that the COLDEST procedures end up in
  -- regular memory in case the display bank overflows.  This permits "easy"
  -- detection of performance problems related to executing out of the display bank.
  Swapper.ResidentCool;
  Misc.ResidentCool;
  MesaRuntime.ResidentCool;
  Filer.ResidentCool;
  MesaRuntime.ProcessesHot;  -- Since Star often uses these procedures
  UserTerminalDriver.ResidentCool;
  Control.ResidentCool;
  DiskDrivers.ResidentCool;
  END;


-- Swappable code packs for everything but FileMgr, Transactions, and VMMgr:

-- FOR A GIVEN CONFIG, THE ORDER IN WHICH THE PACKS ARE
--    MENTIONED IS IMPORTANT!
-- Place new packs together with the other packs of the same
--    config.  (If there are cross-config code packs, this rule will be violated.)
Control.SwappableSystem;
DiskDrivers.SwappableDiskDrivers;
Filer.LabelHacking;
MesaRuntime.FrameImplHot;
MesaRuntime.FrameImplCold;
-- MesaRuntime.ProcessesHot; ProcessesHot is put into ResidentCool
MesaRuntime.ProcessesCold;
MesaRuntime.InLoadOutLoad;
MesaRuntime.Signals;
MesaRuntime.SnapshotMisc;
MesaRuntime.Traps;
Misc.Nodes;
Misc.ByteBlt;
Misc.HeapPruning;
Misc.Attributes;
Misc.CreateDelete;
Misc.Recreating;
Misc.Checking;
Misc.Streams;
Swapper.SwappableSwapperHot;
Swapper.SwappableSwapperWarm;
UserTerminalDriver.UserTerminalDriverSwappable;

ResidentInitialization: CODE PACK =
  BEGIN
  Control.Initialization;
  DiskDrivers.Initialization;
  Filer.Initialization;
  MesaRuntime.Initialization;
  Misc.Initialization;
  Swapper.Initialization;
  UserTerminalDriver.Initialization
  END;

END; --of segment ResidentAndLowStore--

HighStore: SEGMENT
        MERGES FileMgr, Transactions, VMMgr =
-- This segment merges all of the code in the FileMgr, Transactions, and VMMgr configs.
BEGIN
  
FileMgr.FileHelperProcess;  -- should be first!

VMMHelperProcess: CODE PACK =  -- should be second!
  { VMMgr.VMMHelperProcess;
    FileMgr.VMMHelperProcs };

FileMgr.FileAttributes;
FileMgr.FileSetSize;
FileMgr.VFMChangingSize;
FileMgr.FileCreate;
FileMgr.FileDelete;
FileMgr.OtherFileStuff;
FileMgr.Volume;
FileMgr.PhysicalVolume;
FileMgr.Othello;
FileMgr.Scavenger;
VMMgr.SpaceOpsCommon;
VMMgr.SpaceMap;
VMMgr.SpaceUnmap;
VMMgr.SpaceCopying;
VMMgr.SpaceRemap;
VMMgr.SpaceStatusOps;
VMMgr.SpaceCodeHacking;
VMMgr.SpaceMisc;

SpaceCreateDelete: CODE PACK =  -- Star uses space Create & Delete in a short time.
  { VMMgr.SpaceCreate; VMMgr.SpaceDelete; };

TransactionsRunning: CODE PACK =
  { FileMgr.TransactionRelatedRunning;
    Transactions.RunningTransaction;
    VMMgr.SpaceTransactions };

TransactionsCommon: CODE PACK =
-- Merged from AbortBeginCommitCommon, BegTransaction, Commit,
-- VMMgr.SpaceTransactions.  This assumes that commiting a transacion is the
-- normal mode of operation and that aborting is "rare".
  { Transactions.AbortBeginCommitCommon;
    Transactions.BeginTransaction;
    Transactions.Commit };

TransactionsAborting: CODE PACK =
  { FileMgr.TransactionRelatedAborting;
    Transactions.Abort };

MapLogging: CODE PACK =
  { FileMgr.FileMapLogging;
    VMMgr.SpaceMapLogging };

FileMgr.FileMgrInitialization;
Transactions.TransactionsInitialization;
VMMgr.VMMgrInitialization;

HighStoreResident: CODE PACK =
  -- Contrary to usual practice, this resident code pack is placed *last* so as not to pin the entry vectors of their procedures.  (See notes in e.g. VMMgrPack.pack.)
  { --FileMgr.FileMgrResident;
    VMMgr.VMMgrResident };

END; --of segment HighStore--


-- PilotKernelFrames.pack

-- Frame packs for all of PilotKernel

-- January 31, 1981  10:58 AM   Gobbel   Created from old TestPilotPack.pack and frame packs for individual configs.
-- January 22, 1981  7:01 AM   Knutsen   Sorted the swappable frames in the Store config into alphabetical order.
-- 23-Mar-82 16:23:12		Levin		Add ColorDisplayImpl
--June 10, 1982 9:40 am	Levin		Add ColorCursorImpl

ResidentFrames: FRAME PACK =
   BEGIN
   -- Control
   SystemImpl;  -- contains cleanup procedure
   PilotControl;  -- must be resident due to its exported variables
   -- DiskDrivers
   DiskChannelImpl;
   DiskDriverSharedImpl;
   FloppyChannelImpl;
   SA4000Impl;
   SA800Impl; -- Must be resident until Pilot knows how to dynamically make it
                 -- resident
   -- Filer
   FileCacheImpl;
   FilerExceptionImpl;
   FilerTransferImpl;
   FileTaskImpl;
   SubVolumeImpl;
   -- MesaRuntime
   BootSwapCross;
   Instructions;
   FrameImpl;  -- resident since contains frame fault handler.
   PilotNub;
   Processes;  -- used by the Swapper.
   SnapshotImpl;
   -- Misc
   ResidentHeapImpl;
   UtilitiesImpl;
   ZoneImpl;
   -- Swapper
   CachedRegionImplA;
   CachedRegionImplB;
   CachedSpaceImpl;
   MStoreImpl;
   PageFaultImpl;
   ResidentMemoryImpl;
   SwapBufferImpl;
   SwapperControl;
   SwapperExceptionImpl;
   SwapTaskImpl;
   -- UserTerminalDriver
   UserTerminalImpl;
   ColorDisplayImpl;
   ColorCursorImpl;

   -- In addition, due to the need to swap writable frame packs to a temporary
   -- file and not to the boot file, it is necessary that anything that PilotControl calls
   -- before mapping initially out spaces have their frames be resident (even though,
   -- in a strictly logical sense, they need not be resident).  At the moment, this means
   -- everything in the Store config. 
   -- In ALPHABETICAL ORDER, the swappable frames in the Store config are:
   FileImpl;
   HConfig.STreeImpl;
   HierarchyImpl;
   MarkerPageImpl;
   MapLogImpl;
   PConfig.STreeImpl;
   PhysicalVolumeImpl;
   ProjectionImpl;
   ScavengeImpl;
   Signals;
   SimpleSpaceImpl;
   SpaceImplA;
   SpaceImplB;
   STLeafImpl;
   StreamImpl;
   Transactions;
   Traps;
   VolAllocMapImpl;
   VolFileMapImpl;
   VolumeImpl;

   -- The following are included here as they fit and are hot
   HeapImpl;

   -- The following are initialization only frames.  They are included here since
   -- they do not increase the size of this swap unit, thus saving one page of MDS
   DiskDrivers.StartChainPlug;
   FilerControl;
   UserTerminalDriver.StartChainPlug;
   VMMControl;

   END --of frame pack ResidentFrames--;