{
 File name: Boot.dfn
 Description: Definitions for Initial microcode,
 Last Edited:
 	Fiala  5-Sep-86 11:07:58 Removed def for uE3FF now in Dandelion.dfn
	Fiala 25-Jul-86 14:27:28
	Fiala  9-Sep-86 15:15:33 Move display IOPage defn's to Dandelion.dfn
	Fiala 12-Jan-87 14:54:04 Added def for cedarGermAnyPilotDisk for Cedar 7.0.

	Copyright (C) 1986 by Xerox Corporation.  All rights reserved. 
}

{
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	Subroutines from CoreInitial.mc

	mapZap returns - Link 0; relative to miscRet
	RtnBLT returns - Link 0; relative to subrRet
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}

MacroDef[RtnMapZap, at[#1,10,miscRet]];	{CoreInitial}

MacroDef[RtnBLT, at[#1,10,subrRet]];	{CoreInitial, SAx000Initial, EtherInitial, TridentInitial}

Set[L0.BLTr0,		00];
Set[L0.BLTr1,		01];
Set[L0.BLTr2,		02];
Set[L0.BLTr3,		03];
Set[L0.BLTr4,		04];
Set[L0.BLTr5,		05];
Set[L0.BLTr6,		06];
Set[L0.BLTr7,		07];
Set[L0.BLTr8,		08];
Set[L0.BLTr9,		09];
Set[L0.vmSetup,		0A];
Set[L0.BLTrB,		0B];
Set[L0.garbageLoop,	0C];
Set[L0.mgLoop,		0D];
Set[L0.vswap,		0E];
Set[L0.germExch,	0F];


Set[ProtectStart, 0], Set[ProtectFence, 0FF];

RegDef[uESubBoot,	U,	0DE]; {Howard's subBoot}

RegDef[uTMErRst,	U,	0B9];	{MagTape}
RegDef[uStartActive,	U,	0E3];	{LSEP}
RegDef[uDisableLSEP,	U,	0E5];	{LSEP}

{
	Virtual Memory Parameterization
}

Set[X32kb,  04000];
Set[X64kb,  08000];
Set[X128kb, 10000];

 Set[VMMSize,  X32kb];   {Uncomment the appropriate Virt. Mem. size}
{Set[VMMSize,  X64kb];}  {Uncomment the appropriate Virt. Mem. size}
{Set[VMMSize, X128kb];}  {Uncomment the appropriate Virt. Mem. size}

Set[MapRealAddrLow, 0];
Set[MapRealAddrHigh, 1];

IfEqual[VMMSize, X32kb,Set[FirstRealPageToMap, 40],];	{this is the    }
IfEqual[VMMSize, X64kb,Set[FirstRealPageToMap, 80],];	{next page after}
IfEqual[VMMSize, X128kb,Set[FirstRealPageToMap, 00],];	{the memory map ends}

IfEqual[VMMSize, X32kb,Set[FirstRealPageToMapHigh, 1],];
IfEqual[VMMSize, X64kb,Set[FirstRealPageToMapHigh, 1],];
IfEqual[VMMSize, X128kb,Set[FirstRealPageToMapHigh, 2],];

Set[IOPageVirtual, 0FF];
Set[IOPageVirtualHigh, 0];

Set[VMM22Bit, 40];
Set[VMM23Bit, 80];
Set[VMM24Bit, 100];

IfEqual[VMMSize, X32kb,Set[mapPages, VMM22Bit],];	{number pages dedicated to map}
IfEqual[VMMSize, X64kb,Set[mapPages, VMM23Bit],];	{number pages dedicated to map}
IfEqual[VMMSize, X128kb,Set[mapPages, 00],];		{number pages dedicated to map}

{
	Notice that these values are left rotated into the high byte
	and a 1 is then subtracted from the resulting value;
	hence we have 3FFF, 7FFF, & FFFF.
}

Set[virtualIOPage, 0FF];	{virtual page number of IO page}
Set[vacant, 60];		{map flags for a vacant page}
Set[present, 10];		{map flags for a referenced and present page}

Set[IOPage.VMMSize, 6F];


Set[CTClrMEr, 9];		{ClearMemError bit (used in MagTapeInit in InitDLion)}
Set[CHeadMsk, 0F9];		{Mask used to detect Read operations.}
Set[CSA1MaxSectTst, 239'D];
Set[CSA4MaxSectTst, 227'D];	{256 - number of sectors in a track = 256-16-1 = 239 for the SA1000.  Used to cause PgCarryBr  <=> sector number+UMaxSectTst+1 >= 256.  The "+1" comes from the fact that a U register is being stored in the same instruction as the test is being done.}
Set[CSA4ErrMsk, 3F];		{256 - number of sectors in a track = 256-28-1 = 227 for the SA4000.  Used to cause PgCarryBr  <=> sector number+UMaxSectTst+1 >= 256.  The "+1" comes from the fact that a U register is being stored in the same instruction as the test is being done.}
Set[CAddrMkHi, 0A1];		{constants which define the address mark for the SA1000}
Set[CSA1ErrMsk, 7F];		{mask used to turn off irrelevant error flags in raw status for the SA4000 drive (does not include Header Tag)}
Set[CAddrMkLo, 041];

{Boot Time Error Codes}

Set[bootDeviceError, 1];
Set[bootNullGerm, 2];
Set[bootBrokenChain, 3];	{boot chain broken}
Set[bootIllegalCommand, 4];	{IOP sent illegal command}
Set[bootTrap, 5];	{trapped through control store 0}
Set[bootNoDiagnostics, 6];
Set[bootNoEmulator, 7];
Set[bootNoGerm, 8];

Set[IdleLoc, 1], Set[Maintenance1Loc, 2], Set[Maintenance2Loc, 3], Set[Maintenance3Loc, 4];
Set[ErrorHandlerLoc, 100];

{** this stuff is specific to PrincOps version! **
look in the device specific initial code
to see how this is used to construct the virtual address of the germ}

Set[germPageHigh, 0];
Set[germPageLow, 1];

Set[cedarGermPageHigh, 3E];
Set[cedarGermPageLow, 2];

Set[germRequest, 0F0]; {360'b offset from germ start}

Set[cedar.Request.Action, Add[germRequest, 0]];
Set[cedar.Request.deviceType, Add[germRequest, 1]];
Set[cedar.Request.devOrd, Add[germRequest, 2]];
Set[cedar.Request.BootFileNumber, Add[germRequest, 3]];
Set[cedar.Request.NetworkNumber, Add[germRequest, 4]];
Set[cedar.Request.HostNumber, Add[germRequest, 5]];

Set[cedarGermSAx000, 3];
Set[cedarGermEthernet, 5];
Set[cedarGermAnyPilotDisk, 100'b];

Set[inLoad, 0];
Set[bootPhysicalVolume, 2];
Set[diskDeviceOrdinal, 0];

Set[ethernetDeviceOrdinal, 0];

Set[Off, 0];
Set[EnableReceive, 1];
Set[EnableTransmit, 1];
Set[EnableTransmitLastWord, 3];
Set[EnableTransmitDefer, 5];

Set[InitialCountdown, 14];	{14 hex = 20 decimal, 20 x 51.2 us ~ 1 ms for delay before retransmission}

Set[Other, 0];
Set[UnderRun, 1];
Set[Collision, 2];
Set[CollisionUnderRun, 3]; 


{
*********************************************
	Def's removed from SAx000Initial.mc
*********************************************
}

{disk definitions}

Set[SA1000FindSectCmd,	20]; {null findSectorCmd for SA1000}
Set[SA1000HeaderLoopMsk,43]; {have SA1000 reject Label and Data fields when looking for Headers}

Set[stepBit,		80]; {KControl bits, low byte}
Set[inBit,		40];
Set[firmwareEnable,	20];
Set[SA4FindSect,	6];
Set[SA1FindSect,	0];

Set[driveSelectBit,	4]; {KControl bits, high byte}
Set[faultClearBit,	2];

Set[track00Bit,		2]; {KStatus bits, high byte}
Set[seekCompleteBit,	4];

Set[badBits,		3F]; {IOCB status error indicators}
Set[verifyBit,		1];

{IOCB page offsets}

Set[statusAddr,		3];	{status word}
{			4      not used, used to be pointer to next IOCB, always 0}
Set[seekAddr,		5];	{pointer to seek IOCB}
Set[transferAddr,	6];	{pointer to transfer IOCB}
Set[vrrAddr,		7];	{pointer to vrr parameter area}
Set[vvrAddr,		8];	{pointer to vrr parameter area}
Set[headerAddr,		9];	{header -- 2 words}
Set[labelAddr,		0B];	{label -- 0A words}
Set[labelPageLow,	10];	{low 16 bits of file page number}
Set[miscBitsAddr,	11];	{filePageHi[0..6], unused[0..5], immutable[0], temporary[0], zeroSize[0]}
Set[bootLink,		13];	{disk address of next run of pages in boot file}
Set[labelSize,		0A];

{parameter area offsets}

Set[sectors,		0];		{number of sectors to transfer}
Set[headerLoopMsk,	6];		{specifies non-fatal errors when looking for a header}
Set[dataPage,		0D];		{page number of data area in main storage}
Set[haltWord,		0F];		{requires head in high 5 bits}
Set[findWord,		10];		{requires head in high 5 bits}

{transfer IOCB offsets}

Set[parameters,	1];		{pointer to parameter area}

{seek IOCB offsets}

Set[cylinders,	0];		{-(number of cylinders to move heads)}
Set[stepHigh,	6];		{set step level high}
Set[stepLow,	8];		{set step level low}

{Miscellaneous disk constants}

Set[SA1000HeadCount,	Sub[4,1]];
Set[SA4000HeadCount,	Sub[4,1]];
Set[Q2040HeadCount,	Sub[8,1]];
Set[Q2080HeadCount,	Sub[7,1]];

{physical volume boot files}

{
	useful data formats extracted from Boot.mesa

	BootFileType: TYPE= {hardMicrocode, softMicrocode, germ, pilot, debugger, debugee};
	DiskFileID:   TYPE= RECORD[fID: File.ID, firstPage: File.PageNumber, da: DiskAddress];
	PVBootFiles:  POINTER TO ARRAY BootFileType[hardMicrocode..pilot] OF DiskFileID= 2;

	After reading from the disk, PVBootFiles moved to memory location 2
}

Set[bootingInfo,     			   8];	{origin of PVBootFiles in physical volume root page}
Set[DiskFileIDSize,  			   9];	{number of words in DiskFileID}
Set[bootingInfoSize,  Mul[DiskFileIDSize, 4]];	{size of PVBootFiles}

{
	things salted away in page 0
}

Set[availableDevices,	0];	{devices available for booting, set up by Phase 0}
Set[bootReadyFlag,	1];	{non-zero indicates boot file is ready}
Set[hardFileID,		2];	{hard microcode DiskFileID, copied from physical volume root page}
Set[emulatorFileID,	0B];	{emulator microcode DiskFileID, copied from physical volume root page}
Set[germFileID,		14];	{germ DiskFileID, copied from physical volume root page}
Set[bootFileID,		1D];	{working DiskFileID, copied from one of the above fileID's}
Set[bootPage,		22];
Set[bootDiskAddr,	24];
Set[labelTemplate,	26];	{template label used by boot loading routines}

{
*********************************************
	Def's for *Trident*.mc
*********************************************
}

{
*********************************************
	Def's from TridentInitial.mc
*********************************************
}

{word offsets} {into Working Page}

Set[WPinitCSB, 48];
Set[WPrdLblCtl, 42];
Set[WPverLblCtl, 46];
Set[WPvrrLabelParam, 40];
Set[WPvvrLabelParam, 44];

  {into IOCBs}
  
Set[IOCBcHeader, 0];	{clientHeader}
Set[IOCBcHeaderCyl, 0];	{clientHeader.cylinder}
Set[IOCBcHeaderHS, 1];	{clientHeader.head&sector}
Set[IOCBdataPtrLo, 4];
Set[IOCBtries, 6];
Set[IOCBpageCount, 7];
Set[IOCBcStatus, 8];	{Controller Status}
Set[IOCBdStatus, 9];	{Disk Status}
Set[IOCBdHeader, 0A];	
Set[IOCBdiskAdr, 0E];
Set[IOCBfilePageLo, 0F];
Set[IOCBseekDrive, 11];
Set[IOCBseekCyl, 12];
Set[IOCBseekHead, 13];
Set[IOCBhdrCtl, 16];
Set[IOCBlabelParam, 18];
Set[IOCBdataCtl, 1E];
Set[IOCBlabelParam, 18];
Set[IOCBlabelErrMask, 1B];
Set[IOCBclientLabel, 20];
Set[IOCBcLblFilePageLo, 25];
Set[IOCBcLblFilePageHi, 26];
Set[IOCBcLblBootLink, 28];
Set[IOCBcLblBootLink1, 29];
Set[IOCBdiskLabel, 30];
Set[IOCBdLblBootLink, 38];

{values}

Set[vDStatusEndCyl, 40];
Set[vDStatusAnyAtten, 80];
Set[vCStatusLastField, 6]; {Last Field Mask}
Set[vCStatusDataField, 6];
Set[vCStatusLblField, 4];
Set[vCStatusVerErrLRot8, 8];

Set[vCmdTagHd, 40];
Set[vCmdHd5, 5];
Set[vCmdTagCtl, 20];
Set[vCmdResetRecal, 0A];

Set[vLabelSize, 0A];

Set[vT300Heads, 19'd];
Set[vT80Heads, 5];
Set[vSecsPerTrack, 30'd];

{physical volume boot files}
{useful data formats extracted from Boot.mesa

	BootFileType: TYPE= {hardMicrocode, softMicrocode, germ, pilot, debugger, debugee};
	DiskFileID: TYPE= RECORD[fID: File.ID, firstPage: File.PageNumber, da: DiskAddress];
	PVBootFiles: POINTER TO ARRAY BootFileType[hardMicrocode..pilot] OF DiskFileID= 2;

After reading from the disk, PVBootFiles moved to memory location 2}

Set[bootingInfo, 8];	{origin of PVBootFiles in physical volume root page}
Set[DiskFileIDSize, 9];	{number of words in DiskFileID}
Set[bootingInfoSize, Mul[DiskFileIDSize, 4]];	{size of PVBootFiles}

{things salted away in page 0}

Set[availableDevices, 0];	{devices available for booting, set up by Phase 0}
Set[bootReadyFlag, 1];	{non-zero indicates boot file is ready}
Set[hardFileID, 2];	{hard microcode DiskFileID, copied from physical volume root page}
Set[emulatorFileID, 0B];	{emulator microcode DiskFileID, copied from physical volume root page}
Set[germFileID, 14];	{germ DiskFileID, copied from physical volume root page}
Set[bootFileID, 1D];	{working DiskFileID, copied from one of the above fileID's}
Set[bootPage, 22];
Set[bootDiskAddr, 24];
Set[labelTemplate, 26];	{template label used by boot loading routines}